diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index ba8c731..ec3de13 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -120,4 +120,63 @@ void Window::SetSize(const Point& size) { SDL_SetWindowSize(window_, size.x, size.y); } +float Window::GetBrightness() const { + return SDL_GetWindowBrightness(window_); +} + +void Window::SetBrightness(float brightness) { + if (SDL_SetWindowBrightness(window_, brightness) != 0) + throw Exception("SDL_SetWindowBrightness failed"); +} + +Point Window::GetPosition() const { + int x, y; + SDL_GetWindowPosition(window_, &x, &y); + return Point(x, y); +} + +void Window::SetPosition(int x, int y) { + SDL_SetWindowPosition(window_, x, y); +} + +void Window::SetPosition(const Point& pos) { + SDL_SetWindowPosition(window_, pos.x, pos.y); +} + +Point Window::GetMinimumSize() const { + int w, h; + SDL_GetWindowMinimumSize(window_, &w, &h); + return Point(w, h); +} + +void Window::SetMinimumSize(int w, int h) { + SDL_SetWindowMinimumSize(window_, w, h); +} + +void Window::SetMinimumSize(const Point& size) { + SDL_SetWindowMinimumSize(window_, size.x, size.y); +} + +Point Window::GetMaximumSize() const { + int w, h; + SDL_GetWindowMaximumSize(window_, &w, &h); + return Point(w, h); +} + +void Window::SetMaximumSize(int w, int h) { + SDL_SetWindowMaximumSize(window_, w, h); +} + +void Window::SetMaximumSize(const Point& size) { + SDL_SetWindowMaximumSize(window_, size.x, size.y); +} + +bool Window::GetGrab() const { + return SDL_GetWindowGrab(window_) == SDL_TRUE; +} + +void Window::SetGrab(bool grabbed) { + SDL_SetWindowGrab(window_, grabbed ? SDL_TRUE : SDL_FALSE); +} + } diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index e98baa5..d0d7e6c 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -270,6 +270,141 @@ public: /// //////////////////////////////////////////////////////////// void SetSize(const Point& size); + + //////////////////////////////////////////////////////////// + /// \brief Get the brightness (gamma multiplier) for the display that owns a given window + /// + /// \returns Brightness for the display where 0.0 is completely dark and 1.0 is normal brightness + /// + /// \see http://wiki.libsdl.org/SDL_GetWindowBrightness + /// + //////////////////////////////////////////////////////////// + float GetBrightness() const; + + //////////////////////////////////////////////////////////// + /// \brief Set the brightness (gamma multiplier) for the display that owns a given window + /// + /// \param[in] brightness Brightness value to set where 0.0 is completely dark and 1.0 is normal brightness + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowBrightness + /// + //////////////////////////////////////////////////////////// + void SetBrightness(float brightness); + + //////////////////////////////////////////////////////////// + /// \brief Get the position of a window + /// + /// \returns Point representing window position + /// + /// \see http://wiki.libsdl.org/SDL_GetWindowPosition + /// + //////////////////////////////////////////////////////////// + Point GetPosition() const; + + //////////////////////////////////////////////////////////// + /// \brief Set the position of a window + /// + /// \param[in] x X coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED + /// \param[in] y Y coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowPosition + /// + //////////////////////////////////////////////////////////// + void SetPosition(int x, int y); + + //////////////////////////////////////////////////////////// + /// \brief Set the position of a window + /// + /// \param[in] pos Point representin position of the a window + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowPosition + /// + //////////////////////////////////////////////////////////// + void SetPosition(const Point& pos); + + //////////////////////////////////////////////////////////// + /// \brief Get the minimum size of a window's client area + /// + /// \returns Point representing minimum area of window's client area + /// + /// \see http://wiki.libsdl.org/SDL_GetWindowMinimumSize + /// + //////////////////////////////////////////////////////////// + Point GetMinimumSize() const; + + //////////////////////////////////////////////////////////// + /// \brief Set the minimum size of a window's client area + /// + /// \param[in] w Minimum width of the window in pixels + /// \param[in] h Minimum height of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowMinimumSize + /// + //////////////////////////////////////////////////////////// + void SetMinimumSize(int w, int h); + + //////////////////////////////////////////////////////////// + /// \brief Set the minimum size of a window's client area + /// + /// \param[in] size Minimum area of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowMinimumSize + /// + //////////////////////////////////////////////////////////// + void SetMinimumSize(const Point& size); + + //////////////////////////////////////////////////////////// + /// \brief Get the maximum size of a window's client area + /// + /// \returns Point representing maximum area of window's client area + /// + /// \see http://wiki.libsdl.org/SDL_GetWindowMaximumSize + /// + //////////////////////////////////////////////////////////// + Point GetMaximumSize() const; + + //////////////////////////////////////////////////////////// + /// \brief Set the maximum size of a window's client area + /// + /// \param[in] w Maximum width of the window in pixels + /// \param[in] h Maximum height of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowMaximumSize + /// + //////////////////////////////////////////////////////////// + void SetMaximumSize(int w, int h); + + //////////////////////////////////////////////////////////// + /// \brief Set the maximum size of a window's client area + /// + /// \param[in] size Maximum area of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowMaximumSize + /// + //////////////////////////////////////////////////////////// + void SetMaximumSize(const Point& size); + + //////////////////////////////////////////////////////////// + /// \brief Get a window's input grab mode + /// + /// \returns True if input is grabbed, flase otherwise + /// + /// \see http://wiki.libsdl.org/SDL_GetWindowGrab + /// + //////////////////////////////////////////////////////////// + bool GetGrab() const; + + //////////////////////////////////////////////////////////// + /// \brief Set a window's input grab mode + /// + /// \param[in] grabbed True to grab input, false to release input + /// + /// \see http://wiki.libsdl.org/SDL_SetWindowGrab + /// + //////////////////////////////////////////////////////////// + void SetGrab(bool grabbed); }; }