From ae2ae15e12e501449a911c966669bf7ca7cfde50 Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Fri, 9 Apr 2010 07:35:08 +0000 Subject: [PATCH] FS#159 - Add sf::Window::SetTitle git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1502 4e206d99-4929-0410-ac5d-dfc041789085 --- include/SFML/Window/Window.hpp | 8 ++++++++ src/SFML/Window/Linux/WindowImplX11.cpp | 9 ++++++++- src/SFML/Window/Linux/WindowImplX11.hpp | 8 ++++++++ src/SFML/Window/Win32/WindowImplWin32.cpp | 7 +++++++ src/SFML/Window/Win32/WindowImplWin32.hpp | 8 ++++++++ src/SFML/Window/Window.cpp | 8 ++++++++ src/SFML/Window/WindowImpl.hpp | 8 ++++++++ 7 files changed, 55 insertions(+), 1 deletion(-) diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 06fc6ee78..49786b06e 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -310,6 +310,14 @@ public : //////////////////////////////////////////////////////////// void SetSize(unsigned int width, unsigned int height); + //////////////////////////////////////////////////////////// + /// \brief Change the title of the window + /// + /// \param title New title + /// + //////////////////////////////////////////////////////////// + void SetTitle(const std::string& title); + //////////////////////////////////////////////////////////// /// \brief Show or hide the window /// diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index d0a0ae228..78584bca3 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -156,7 +156,7 @@ myKeyRepeat (true) } // Set the window's name - XStoreName(myDisplay, myWindow, title.c_str()); + SetTitle(title); // Set the window's style (tell the windows manager to change our window's decorations and functions according to the requested style) if (!fullscreen) @@ -340,6 +340,13 @@ void WindowImplX11::SetSize(unsigned int width, unsigned int height) } +//////////////////////////////////////////////////////////// +void WindowImplX11::SetTitle(const std::string& title) +{ + XStoreName(myDisplay, myWindow, title.c_str()); +} + + //////////////////////////////////////////////////////////// void WindowImplX11::Show(bool show) { diff --git a/src/SFML/Window/Linux/WindowImplX11.hpp b/src/SFML/Window/Linux/WindowImplX11.hpp index c8174193b..64ee519ab 100644 --- a/src/SFML/Window/Linux/WindowImplX11.hpp +++ b/src/SFML/Window/Linux/WindowImplX11.hpp @@ -134,6 +134,14 @@ private : //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height); + //////////////////////////////////////////////////////////// + /// \brief Change the title of the window + /// + /// \param title New title + /// + //////////////////////////////////////////////////////////// + virtual void SetTitle(const std::string& title); + //////////////////////////////////////////////////////////// /// \brief Show or hide the window /// diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 492f8b461..40fc5a4b0 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -267,6 +267,13 @@ void WindowImplWin32::SetSize(unsigned int width, unsigned int height) } +//////////////////////////////////////////////////////////// +void WindowImplWin32::SetTitle(const std::string& title) +{ + SetWindowText(myHandle, title.c_str()); +} + + //////////////////////////////////////////////////////////// void WindowImplWin32::Show(bool show) { diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index caa128d16..65ed99ec5 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -123,6 +123,14 @@ private : //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height); + //////////////////////////////////////////////////////////// + /// \brief Change the title of the window + /// + /// \param title New title + /// + //////////////////////////////////////////////////////////// + virtual void SetTitle(const std::string& title); + //////////////////////////////////////////////////////////// /// \brief Show or hide the window /// diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 42d88594d..d8ea52740 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -280,6 +280,14 @@ void Window::SetSize(unsigned int width, unsigned int height) } +//////////////////////////////////////////////////////////// +void Window::SetTitle(const std::string& title) +{ + if (myWindow) + myWindow->SetTitle(title); +} + + //////////////////////////////////////////////////////////// void Window::Show(bool show) { diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index fd47f8387..0cf8cd356 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -167,6 +167,14 @@ public : //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height) = 0; + //////////////////////////////////////////////////////////// + /// \brief Change the title of the window + /// + /// \param title New title + /// + //////////////////////////////////////////////////////////// + virtual void SetTitle(const std::string& title) = 0; + //////////////////////////////////////////////////////////// /// \brief Show or hide the window ///