diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index 37169ac48..81b997b2c 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -53,7 +53,7 @@ public : /// Construct the music with a buffer size /// /// \param bufferSize : Size of the internal buffer, expressed in number of samples - /// (ie. size taken by the music in memory) (44100 by default) + /// (ie. size taken by the music in memory) /// //////////////////////////////////////////////////////////// Music(std::size_t bufferSize = 44100); diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index f96943898..5b11871a5 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -65,11 +65,11 @@ public : //////////////////////////////////////////////////////////// /// Construct the sound from its parameters /// - /// \param buffer : Sound buffer to play (NULL by default) - /// \param loop : Loop flag (false by default) - /// \param pitch : Value of the pitch (1 by default) - /// \param volume : Volume (100 by default) - /// \param position : Position (0, 0, 0 by default) + /// \param buffer : Sound buffer to play + /// \param loop : Loop flag + /// \param pitch : Value of the pitch + /// \param volume : Volume + /// \param position : Position /// //////////////////////////////////////////////////////////// Sound(const SoundBuffer& buffer, bool loop = false, float pitch = 1.f, float volume = 100.f, const Vector3f& position = Vector3f(0, 0, 0)); diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index 1ab82a113..cd743d977 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -53,7 +53,7 @@ public : /// \param red : Red component (0 .. 255) /// \param green : Green component (0 .. 255) /// \param blue : Blue component (0 .. 255) - /// \param alpha : Alpha (opacity) component (0 .. 255) (255 by default) + /// \param alpha : Alpha (opacity) component (0 .. 255) /// //////////////////////////////////////////////////////////// Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255); diff --git a/include/SFML/Graphics/Drawable.hpp b/include/SFML/Graphics/Drawable.hpp index b8f7b8796..8bfe37809 100644 --- a/include/SFML/Graphics/Drawable.hpp +++ b/include/SFML/Graphics/Drawable.hpp @@ -63,10 +63,10 @@ public : //////////////////////////////////////////////////////////// /// Default constructor /// - /// \param position : Position of the object ((0, 0) by default) - /// \param scale : Scale factor ((1, 1) by default) - /// \param rotation : Orientation, in degrees (0 by default) - /// \param color : Color of the object (white by default) + /// \param position : Position of the object + /// \param scale : Scale factor + /// \param rotation : Orientation, in degrees + /// \param color : Color of the object /// //////////////////////////////////////////////////////////// Drawable(const Vector2f& position = Vector2f(0, 0), const Vector2f& scale = Vector2f(1, 1), float rotation = 0.f, const Color& color = Color(255, 255, 255)); diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index d36d2aa17..b9465e654 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -65,7 +65,7 @@ public : /// Load the font from a file /// /// \param filename : Font file to load - /// \param charSize : Size of characters in bitmap - the bigger, the higher quality (30 by default) + /// \param charSize : Size of characters in bitmap - the bigger, the higher quality /// \param charset : Characters set to generate (by default, contains the ISO-8859-1 printable characters) /// /// \return True if loading was successful @@ -78,7 +78,7 @@ public : /// /// \param data : Pointer to the data to load /// \param sizeInBytes : Size of the data, in bytes - /// \param charSize : Size of characters in bitmap - the bigger, the higher quality (30 by default) + /// \param charSize : Size of characters in bitmap - the bigger, the higher quality /// \param charset : Characters set to generate (by default, contains the ISO-8859-1 printable characters) /// /// \return True if loading was successful diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 86121d6c4..ae6500316 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -67,7 +67,7 @@ public : /// /// \param width : Image width /// \param height : Image height - /// \param color : Image color (black by default) + /// \param color : Image color /// //////////////////////////////////////////////////////////// Image(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0)); @@ -136,7 +136,7 @@ public : /// /// \param width : Image width /// \param height : Image height - /// \param color : Image color (black by default) + /// \param color : Image color /// /// \return True if creation was successful /// @@ -147,7 +147,7 @@ public : /// Create transparency mask from a specified colorkey /// /// \param transparentColor : Color to become transparent - /// \param alpha : Alpha value to assign to transparent pixels (0 by default) + /// \param alpha : Alpha value to assign to transparent pixels /// //////////////////////////////////////////////////////////// void CreateMaskFromColor(const Color& transparentColor, Uint8 alpha = 0); @@ -160,8 +160,8 @@ public : /// \param source : Source image to copy /// \param destX : X coordinate of the destination position /// \param destY : Y coordinate of the destination position - /// \param sourceRect : Sub-rectangle of the source image to copy (empty by default - entire image) - /// \param applyAlpha : Should the copy take in account the source transparency? (false by default) + /// \param sourceRect : Sub-rectangle of the source image to copy + /// \param applyAlpha : Should the copy take in account the source transparency? /// //////////////////////////////////////////////////////////// void Copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false); diff --git a/include/SFML/Graphics/RenderImage.hpp b/include/SFML/Graphics/RenderImage.hpp index 6ea0f2df6..1f5cf3f7e 100644 --- a/include/SFML/Graphics/RenderImage.hpp +++ b/include/SFML/Graphics/RenderImage.hpp @@ -76,7 +76,7 @@ public : /// Activate of deactivate the render-image as the current target /// for rendering /// - /// \param active : True to activate, false to deactivate (true by default) + /// \param active : True to activate, false to deactivate /// /// \return True if operation was successful, false otherwise /// diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index da1a65bb5..c90ca2c2f 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -57,8 +57,8 @@ public : /// /// \param mode : Video mode to use /// \param title : Title of the window - /// \param style : Window style (Resize | Close by default) - /// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values) + /// \param style : Window style + /// \param settings : Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// RenderWindow(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings()); diff --git a/include/SFML/Graphics/Shape.hpp b/include/SFML/Graphics/Shape.hpp index 589e168e3..6b5001b41 100644 --- a/include/SFML/Graphics/Shape.hpp +++ b/include/SFML/Graphics/Shape.hpp @@ -54,8 +54,8 @@ public : /// Add a point to the shape /// /// \param x, y : Position of the point - /// \param color : Color of the point (white by default) - /// \param outlineColor : Outline color of the point (black by default) + /// \param color : Color of the point + /// \param outlineColor : Outline color of the point /// //////////////////////////////////////////////////////////// void AddPoint(float x, float y, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0)); @@ -64,8 +64,8 @@ public : /// Add a point to the shape /// /// \param position : Position of the point - /// \param color : Color of the point (white by default) - /// \param outlineColor : Outline color of the point (black by default) + /// \param color : Color of the point + /// \param outlineColor : Outline color of the point /// //////////////////////////////////////////////////////////// void AddPoint(const Vector2f& position, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0)); @@ -186,8 +186,8 @@ public : /// \param p2x, p2y : Position second point /// \param thickness : Line thickness /// \param color : Color used to draw the line - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Line(float p1x, float p1y, float p2x, float p2y, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); @@ -199,8 +199,8 @@ public : /// \param p2 : Position second point /// \param thickness : Line thickness /// \param color : Color used to draw the line - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Line(const Vector2f& p1, const Vector2f& p2, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); @@ -211,8 +211,8 @@ public : /// \param p1x, p1y : Position of the first point /// \param p2x, p2y : Position second point /// \param color : Color used to fill the rectangle - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Rectangle(float p1x, float p1y, float p2x, float p2y, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); @@ -223,8 +223,8 @@ public : /// \param p1 : Position of the first point /// \param p2 : Position second point /// \param color : Color used to fill the rectangle - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Rectangle(const Vector2f& p1, const Vector2f& p2, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); @@ -235,8 +235,8 @@ public : /// \param x, y : Position of the center /// \param radius : Radius /// \param color : Color used to fill the circle - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Circle(float x, float y, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); @@ -247,8 +247,8 @@ public : /// \param center : Position of the center /// \param radius : Radius /// \param color : Color used to fill the circle - /// \param outline : Outline width (0 by default) - /// \param outlineColor : Color used to draw the outline (black by default) + /// \param outline : Outline width + /// \param outlineColor : Color used to draw the outline /// //////////////////////////////////////////////////////////// static Shape Circle(const Vector2f& center, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0)); diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp index ec7262eb4..8a6c38ebc 100644 --- a/include/SFML/Graphics/Sprite.hpp +++ b/include/SFML/Graphics/Sprite.hpp @@ -55,10 +55,10 @@ public : /// Construct the sprite from a source image /// /// \param image : Image of the sprite - /// \param position : Position of the sprite (0, 0 by default) - /// \param scale : Scale factor (1, 1 by default) - /// \param rotation : Orientation, in degrees (0 by default) - /// \param color : Color of the sprite (white by default) + /// \param position : Position of the sprite + /// \param scale : Scale factor + /// \param rotation : Orientation, in degrees + /// \param color : Color of the sprite /// //////////////////////////////////////////////////////////// Sprite(const Image& image, const Vector2f& position = Vector2f(0, 0), const Vector2f& scale = Vector2f(1, 1), float rotation = 0.f, const Color& color = Color(255, 255, 255, 255)); @@ -67,7 +67,7 @@ public : /// Change the image of the sprite /// /// \param image : New image - /// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image (false by default) + /// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image /// //////////////////////////////////////////////////////////// void SetImage(const Image& image, bool adjustToNewSize = false); diff --git a/include/SFML/Graphics/String.hpp b/include/SFML/Graphics/String.hpp index 10bc63e81..67625f2bc 100644 --- a/include/SFML/Graphics/String.hpp +++ b/include/SFML/Graphics/String.hpp @@ -66,8 +66,8 @@ public : /// Construct the string from any kind of text /// /// \param text : Text assigned to the string - /// \param font : Font used to draw the string (SFML built-in font by default) - /// \param size : Characters size (30 by default) + /// \param font : Font used to draw the string + /// \param size : Characters size /// //////////////////////////////////////////////////////////// explicit String(const Unicode::Text& text, const Font& font = Font::GetDefaultFont(), float size = 30.f); diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index 8331b2d43..d78fc9d6a 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -136,8 +136,8 @@ public : //////////////////////////////////////////////////////////// /// Default constructor /// - /// \param code : Response status code (InvalidResponse by default) - /// \param message : Response message (empty by default) + /// \param code : Response status code + /// \param message : Response message /// //////////////////////////////////////////////////////////// Response(Status code = InvalidResponse, const std::string& message = ""); @@ -387,7 +387,7 @@ public : /// /// \param distantFile : Path of the distant file to download /// \param destPath : Where to put to file on the local computer - /// \param mode : Transfer mode (binary by default) + /// \param mode : Transfer mode /// /// \return Server response to the request /// @@ -399,7 +399,7 @@ public : /// /// \param localFile : Path of the local file to upload /// \param destPath : Where to put to file on the server - /// \param mode : Transfer mode (binary by default) + /// \param mode : Transfer mode /// /// \return Server response to the request /// @@ -412,7 +412,7 @@ private : /// Send a command to the FTP server /// /// \param command : Command to send - /// \param parameter : Command parameter ("" by default) + /// \param parameter : Command parameter /// /// \return Server response to the request /// diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp index 0cc7afce2..3ccf42ddf 100644 --- a/include/SFML/Network/Http.hpp +++ b/include/SFML/Network/Http.hpp @@ -68,9 +68,9 @@ public : //////////////////////////////////////////////////////////// /// Default constructor /// - /// \param method : Method to use for the request (Get by default) - /// \param URI : Target URI ("/" by default -- index page) - /// \param body : Content of the request's body (empty by default) + /// \param method : Method to use for the request + /// \param URI : Target URI + /// \param body : Content of the request's body /// //////////////////////////////////////////////////////////// Request(Method method = Get, const std::string& URI = "/", const std::string& body = ""); diff --git a/include/SFML/Network/SocketTCP.hpp b/include/SFML/Network/SocketTCP.hpp index 745604612..4d5afa6b8 100644 --- a/include/SFML/Network/SocketTCP.hpp +++ b/include/SFML/Network/SocketTCP.hpp @@ -88,7 +88,7 @@ public : /// This function will block if the socket is blocking /// /// \param connected : Socket containing the connection with the connected client - /// \param address : Pointer to an address to fill with client infos (NULL by default) + /// \param address : Pointer to an address to fill with client infos /// /// \return Status code /// diff --git a/include/SFML/System/Thread.hpp b/include/SFML/System/Thread.hpp index 8b0a8a788..af2de6bab 100644 --- a/include/SFML/System/Thread.hpp +++ b/include/SFML/System/Thread.hpp @@ -53,7 +53,7 @@ public : /// \brief Construct the thread from a function pointer /// /// \param function Entry point of the thread - /// \param userData Data to pass to the thread function (NULL by default) + /// \param userData Data to pass to the thread function /// //////////////////////////////////////////////////////////// Thread(FuncType function, void* userData = NULL); diff --git a/include/SFML/System/ThreadLocal.hpp b/include/SFML/System/ThreadLocal.hpp index 1112b1b4d..f4d43f52d 100644 --- a/include/SFML/System/ThreadLocal.hpp +++ b/include/SFML/System/ThreadLocal.hpp @@ -51,7 +51,7 @@ public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// - /// \param value Optional value to initalize the variable (NULL by default) + /// \param value Optional value to initalize the variable /// //////////////////////////////////////////////////////////// ThreadLocal(void* value = NULL); diff --git a/include/SFML/System/ThreadLocalPtr.hpp b/include/SFML/System/ThreadLocalPtr.hpp index 060c22cf3..5be3eb1ed 100644 --- a/include/SFML/System/ThreadLocalPtr.hpp +++ b/include/SFML/System/ThreadLocalPtr.hpp @@ -45,7 +45,7 @@ public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// - /// \param value Optional value to initalize the variable (NULL by default) + /// \param value Optional value to initalize the variable /// //////////////////////////////////////////////////////////// ThreadLocalPtr(T* value = NULL); diff --git a/include/SFML/System/Unicode.hpp b/include/SFML/System/Unicode.hpp index 46a88c149..85973e361 100644 --- a/include/SFML/System/Unicode.hpp +++ b/include/SFML/System/Unicode.hpp @@ -115,7 +115,7 @@ public : /// \param end : Iterator pointing to the end of the input sequence /// \param output : Iterator pointing to the beginning of the output sequence /// \param replacement : Replacement character for characters not convertible to output encoding ('?' by default -- use 0 to use no replacement character) - /// \param locale : Locale to use for conversion (uses the current one by default) + /// \param locale : Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// @@ -130,7 +130,7 @@ public : /// \param begin : Iterator pointing to the beginning of the input sequence /// \param end : Iterator pointing to the end of the input sequence /// \param output : Iterator pointing to the beginning of the output sequence - /// \param locale : Locale to use for conversion (uses the current one by default) + /// \param locale : Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// diff --git a/include/SFML/Window/Context.hpp b/include/SFML/Window/Context.hpp index 57901ead5..c00527f4c 100644 --- a/include/SFML/Window/Context.hpp +++ b/include/SFML/Window/Context.hpp @@ -40,56 +40,33 @@ namespace priv } //////////////////////////////////////////////////////////// -/// Class holding a valid drawing context +/// \brief Class holding a valid drawing context /// -/// If you need to make OpenGL / graphics calls without -/// having an active window (like in a thread), you can use -/// an instance of this class to get a valid context. -/// -/// Having a valid context is necessary for *every* OpenGL call, -/// and for most of the classes from the Graphics package. -/// -/// Note that a context is only active in its current thread, -/// if you create a new thread it will have no valid context -/// by default. -/// -/// \code -/// void ThreadFunction(void*) -/// { -/// sf::Context context; -/// // from now on, you have a valid context -/// -/// // you can make OpenGL calls -/// glClear(GL_DEPTH_BUFFER_BIT); -/// -/// // as well as using objects from the graphics package -/// sf::Image Img; -/// Img.LoadFromFile("image.png"); -/// } -/// // the context is automatically deactivated and destroyed -/// // by the sf::Context destructor -/// \endcode //////////////////////////////////////////////////////////// class SFML_API Context : NonCopyable { public : //////////////////////////////////////////////////////////// - /// Default constructor -- creates and activates the context + /// \brief Default constructor + /// + /// The constructor creates and activates the context /// //////////////////////////////////////////////////////////// Context(); //////////////////////////////////////////////////////////// - /// Destructor -- deactivates and destroys the context + /// \brief Destructor + /// + /// The desctructor deactivates and destroys the context /// //////////////////////////////////////////////////////////// ~Context(); //////////////////////////////////////////////////////////// - /// Activate or deactivate explicitely the context + /// \brief Activate or deactivate explicitely the context /// - /// \param active : True to activate, false to deactivate + /// \param active True to activate, false to deactivate /// //////////////////////////////////////////////////////////// void SetActive(bool active); @@ -106,3 +83,43 @@ private : #endif // SFML_CONTEXT_HPP + +//////////////////////////////////////////////////////////// +/// \class sf::Context +/// +/// If you need to make OpenGL / graphics calls without +/// having an active window (like in a thread), you can use +/// an instance of this class to get a valid context. +/// +/// Having a valid context is necessary for *every* OpenGL call, +/// and for most of the classes from the Graphics package. +/// +/// Note that a context is only active in its current thread, +/// if you create a new thread it will have no valid context +/// by default. +/// +/// To use a sf::Context instance, just construct it and let it +/// live as long as you need a valid context. No explicit activation +/// is needed, all it has to do is to exist. Its destructor +/// will take care of deactivating and freeing all the attached +/// resources. +/// +/// Usage example: +/// \code +/// void ThreadFunction(void*) +/// { +/// sf::Context context; +/// // from now on, you have a valid context +/// +/// // you can make OpenGL calls +/// glClear(GL_DEPTH_BUFFER_BIT); +/// +/// // as well as using objects from the graphics package +/// sf::Image image; +/// image.LoadFromFile("image.png"); +/// } +/// // the context is automatically deactivated and destroyed +/// // by the sf::Context destructor +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/ContextSettings.hpp b/include/SFML/Window/ContextSettings.hpp index 9f26b9c34..941ba917f 100644 --- a/include/SFML/Window/ContextSettings.hpp +++ b/include/SFML/Window/ContextSettings.hpp @@ -29,17 +29,17 @@ namespace sf { //////////////////////////////////////////////////////////// -/// Structure defining the settings of the OpenGL -/// context attached to a window +/// \brief Structure defining the settings of the OpenGL +/// context attached to a window //////////////////////////////////////////////////////////// struct ContextSettings { //////////////////////////////////////////////////////////// - /// Default constructor + /// \brief Default constructor /// - /// \param depth : Depth buffer bits (24 by default) - /// \param stencil : Stencil buffer bits (8 by default) - /// \param antialiasing : Antialiasing level (0 by default) + /// \param depth Depth buffer bits + /// \param stencil Stencil buffer bits + /// \param antialiasing Antialiasing level /// //////////////////////////////////////////////////////////// explicit ContextSettings(unsigned int depth = 24, unsigned int stencil = 8, unsigned int antialiasing = 0) : diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp index c436d791f..8312c7cc1 100644 --- a/include/SFML/Window/Event.hpp +++ b/include/SFML/Window/Event.hpp @@ -33,80 +33,81 @@ namespace sf { -//////////////////////////////////////////////////////////// -/// Definition of key codes for keyboard events -//////////////////////////////////////////////////////////// namespace Key { + //////////////////////////////////////////////////////////// + /// \brief Definition of key codes for keyboard events + /// + //////////////////////////////////////////////////////////// enum Code { - A = 'a', - B = 'b', - C = 'c', - D = 'd', - E = 'e', - F = 'f', - G = 'g', - H = 'h', - I = 'i', - J = 'j', - K = 'k', - L = 'l', - M = 'm', - N = 'n', - O = 'o', - P = 'p', - Q = 'q', - R = 'r', - S = 's', - T = 't', - U = 'u', - V = 'v', - W = 'w', - X = 'x', - Y = 'y', - Z = 'z', - Num0 = '0', - Num1 = '1', - Num2 = '2', - Num3 = '3', - Num4 = '4', - Num5 = '5', - Num6 = '6', - Num7 = '7', - Num8 = '8', - Num9 = '9', - Escape = 256, - LControl, - LShift, - LAlt, - LSystem, ///< OS specific key (left side) : windows (Win and Linux), apple (MacOS), ... - RControl, - RShift, - RAlt, - RSystem, ///< OS specific key (right side) : windows (Win and Linux), apple (MacOS), ... - Menu, - LBracket, ///< [ - RBracket, ///< ] - SemiColon, ///< ; - Comma, ///< , - Period, ///< . - Quote, ///< ' - Slash, ///< / - BackSlash, - Tilde, ///< ~ - Equal, ///< = - Dash, ///< - - Space, - Return, - Back, - Tab, - PageUp, - PageDown, - End, - Home, - Insert, - Delete, + A = 'a', ///< The A key + B = 'b', ///< The B key + C = 'c', ///< The C key + D = 'd', ///< The D key + E = 'e', ///< The E key + F = 'f', ///< The F key + G = 'g', ///< The G key + H = 'h', ///< The H key + I = 'i', ///< The I key + J = 'j', ///< The J key + K = 'k', ///< The K key + L = 'l', ///< The L key + M = 'm', ///< The M key + N = 'n', ///< The N key + O = 'o', ///< The O key + P = 'p', ///< The P key + Q = 'q', ///< The Q key + R = 'r', ///< The R key + S = 's', ///< The S key + T = 't', ///< The T key + U = 'u', ///< The U key + V = 'v', ///< The V key + W = 'w', ///< The W key + X = 'x', ///< The X key + Y = 'y', ///< The Y key + Z = 'z', ///< The Z key + Num0 = '0', ///< The 0 key + Num1 = '1', ///< The 1 key + Num2 = '2', ///< The 2 key + Num3 = '3', ///< The 3 key + Num4 = '4', ///< The 4 key + Num5 = '5', ///< The 5 key + Num6 = '6', ///< The 6 key + Num7 = '7', ///< The 7 key + Num8 = '8', ///< The 8 key + Num9 = '9', ///< The 9 key + Escape = 256, ///< The Escape key + LControl, ///< The left Control key + LShift, ///< The left Shift key + LAlt, ///< The left Alt key + LSystem, ///< The left OS specific key : windows (Windows and Linux), apple (MacOS X), ... + RControl, ///< The right Control key + RShift, ///< The right Shift key + RAlt, ///< The right Alt key + RSystem, ///< The right OS specific key : windows (Windows and Linux), apple (MacOS X), ... + Menu, ///< The Menu key + LBracket, ///< The [ key + RBracket, ///< The ] key + SemiColon, ///< The ; key + Comma, ///< The , key + Period, ///< The . key + Quote, ///< The ' key + Slash, ///< The / key + BackSlash, ///< The \ key + Tilde, ///< The ~ key + Equal, ///< The = key + Dash, ///< The - key + Space, ///< The Space key + Return, ///< The Return key + Back, ///< The Backspace key + Tab, ///< The Tabulation key + PageUp, ///< The Page up key + PageDown, ///< The Page down key + End, ///< The End key + Home, ///< The Home key + Insert, ///< The Insert key + Delete, ///< The Delete key Add, ///< + Subtract, ///< - Multiply, ///< * @@ -115,180 +116,194 @@ namespace Key Right, ///< Right arrow Up, ///< Up arrow Down, ///< Down arrow - Numpad0, - Numpad1, - Numpad2, - Numpad3, - Numpad4, - Numpad5, - Numpad6, - Numpad7, - Numpad8, - Numpad9, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - Pause, + Numpad0, ///< The numpad 0 key + Numpad1, ///< The numpad 1 key + Numpad2, ///< The numpad 2 key + Numpad3, ///< The numpad 3 key + Numpad4, ///< The numpad 4 key + Numpad5, ///< The numpad 5 key + Numpad6, ///< The numpad 6 key + Numpad7, ///< The numpad 7 key + Numpad8, ///< The numpad 8 key + Numpad9, ///< The numpad 9 key + F1, ///< The F1 key + F2, ///< The F2 key + F3, ///< The F3 key + F4, ///< The F4 key + F5, ///< The F5 key + F6, ///< The F6 key + F7, ///< The F7 key + F8, ///< The F8 key + F9, ///< The F8 key + F10, ///< The F10 key + F11, ///< The F11 key + F12, ///< The F12 key + F13, ///< The F13 key + F14, ///< The F14 key + F15, ///< The F15 key + Pause, ///< The Pause key - Count // Keep last -- total number of keyboard keys + Count ///< Keep last -- the total number of keyboard keys }; } -//////////////////////////////////////////////////////////// -/// Definition of button codes for mouse events -//////////////////////////////////////////////////////////// namespace Mouse { + //////////////////////////////////////////////////////////// + /// \brief Definition of button codes for mouse events + /// + //////////////////////////////////////////////////////////// enum Button { - Left, - Right, - Middle, - XButton1, - XButton2, + Left, ///< The left mouse button + Right, ///< The right mouse button + Middle, ///< The middle (wheel) mouse button + XButton1, ///< The first extra mouse button + XButton2, ///< The second extra mouse button - Count // Keep last -- total number of mouse buttons + Count ///< Keep last -- the total number of mouse buttons }; } -//////////////////////////////////////////////////////////// -/// Definition of joystick axis for joystick events -//////////////////////////////////////////////////////////// namespace Joy { + //////////////////////////////////////////////////////////// + /// \brief Definition of joystick axis for joystick events + /// + //////////////////////////////////////////////////////////// enum Axis { - AxisX, - AxisY, - AxisZ, - AxisR, - AxisU, - AxisV, - AxisPOV, + AxisX, ///< The X axis + AxisY, ///< The Y axis + AxisZ, ///< The Z axis + AxisR, ///< The R axis + AxisU, ///< The U axis + AxisV, ///< The V axis + AxisPOV, ///< The Point-Of-View axis (hat) - Count // Keep last -- total number of joystick axis + Count ///< Keep last -- the total number of joystick axis }; } //////////////////////////////////////////////////////////// -/// Event defines a system event and its parameters +/// \brief Defines a system event and its parameters +/// //////////////////////////////////////////////////////////// class Event { public : //////////////////////////////////////////////////////////// - /// Keyboard event parameters + /// \brief Keyboard event parameters (KeyPressed, KeyReleased) + /// //////////////////////////////////////////////////////////// struct KeyEvent { - Key::Code Code; - bool Alt; - bool Control; - bool Shift; + Key::Code Code; ///< Code of the key that has been pressed + bool Alt; ///< Is the Alt key pressed? + bool Control; ///< Is the Control key pressed? + bool Shift; ///< Is the Shift key pressed? }; //////////////////////////////////////////////////////////// - /// Text event parameters + /// \brief Text event parameters (TextEntered) + /// //////////////////////////////////////////////////////////// struct TextEvent { - Uint32 Unicode; + Uint32 Unicode; ///< UTF-32 unicode value of the character }; //////////////////////////////////////////////////////////// - /// Mouse move event parameters + /// \brief Mouse move event parameters (MouseMoved) + /// //////////////////////////////////////////////////////////// struct MouseMoveEvent { - int X; - int Y; + int X; ///< X position of the mouse, relative to the left of the owner window + int Y; ///< Y position of the mouse, relative to the top of the owner window }; //////////////////////////////////////////////////////////// - /// Mouse buttons events parameters + /// \brief Mouse buttons events parameters + /// (MouseButtonPressed, MouseButtonReleased) + /// //////////////////////////////////////////////////////////// struct MouseButtonEvent { - Mouse::Button Button; - int X; - int Y; + Mouse::Button Button; ///< Code of the button that has been pressed + int X; ///< X position of the mouse, relative to the left of the owner window + int Y; ///< Y position of the mouse, relative to the top of the owner window }; //////////////////////////////////////////////////////////// - /// Mouse wheel events parameters + /// \brief Mouse wheel events parameters (MouseWheelMoved) + /// //////////////////////////////////////////////////////////// struct MouseWheelEvent { - int Delta; + int Delta; ///< Number of ticks the wheel has moved (positive is up, negative is down) }; //////////////////////////////////////////////////////////// - /// Joystick axis move event parameters + /// \brief Joystick axis move event parameters (JoyMoved) + /// //////////////////////////////////////////////////////////// struct JoyMoveEvent { - unsigned int JoystickId; - Joy::Axis Axis; - float Position; + unsigned int JoystickId; ///< Index of the joystick (0 or 1) + Joy::Axis Axis; ///< Axis on which the joystick moved + float Position; ///< New position on the axis (in range [-100, 100]) }; //////////////////////////////////////////////////////////// - /// Joystick buttons events parameters + /// \brief Joystick buttons events parameters + /// (JoyButtonPressed, JoyButtonReleased) + /// //////////////////////////////////////////////////////////// struct JoyButtonEvent { - unsigned int JoystickId; - unsigned int Button; + unsigned int JoystickId; ///< Index of the joystick (0 or 1) + unsigned int Button; ///< Index of the button that has been pressed }; //////////////////////////////////////////////////////////// - /// Size events parameters + /// \brief Size events parameters (Resized) + /// //////////////////////////////////////////////////////////// struct SizeEvent { - unsigned int Width; - unsigned int Height; + unsigned int Width; ///< New width, in pixels + unsigned int Height; ///< New height, in pixels }; //////////////////////////////////////////////////////////// - /// Enumeration of the different types of events + /// \brief Enumeration of the different types of events + /// //////////////////////////////////////////////////////////// enum EventType { - Closed, - Resized, - LostFocus, - GainedFocus, - TextEntered, - KeyPressed, - KeyReleased, - MouseWheelMoved, - MouseButtonPressed, - MouseButtonReleased, - MouseMoved, - MouseEntered, - MouseLeft, - JoyButtonPressed, - JoyButtonReleased, - JoyMoved, + Closed, ///< The window requested to be closed + Resized, ///< The window was resized + LostFocus, ///< The window lost the focus + GainedFocus, ///< The window gained the focus + TextEntered, ///< A character was entered + KeyPressed, ///< A key was pressed + KeyReleased, ///< A key was released + MouseWheelMoved, ///< The mouse wheel was scrolled + MouseButtonPressed, ///< A mouse button was pressed + MouseButtonReleased, ///< A mouse button was released + MouseMoved, ///< The mouse cursor moved + MouseEntered, ///< The mouse cursor entered the area of the window + MouseLeft, ///< The mouse cursor left the area of the window + JoyButtonPressed, ///< A joystick button was pressed + JoyButtonReleased, ///< A joystick button was released + JoyMoved, ///< The joystick moved along an axis - Count // Keep last -- total number of event types + Count ///< Keep last -- the total number of event types }; //////////////////////////////////////////////////////////// @@ -298,14 +313,14 @@ public : union { - KeyEvent Key; - TextEvent Text; - MouseMoveEvent MouseMove; - MouseButtonEvent MouseButton; - MouseWheelEvent MouseWheel; - JoyMoveEvent JoyMove; - JoyButtonEvent JoyButton; - SizeEvent Size; + KeyEvent Key; ///< Key event parameters + TextEvent Text; ///< Text event parameters + MouseMoveEvent MouseMove; ///< Mouse move event parameters + MouseButtonEvent MouseButton; ///< Mouse button event parameters + MouseWheelEvent MouseWheel; ///< Mouse wheel event parameters + JoyMoveEvent JoyMove; ///< Joystick move event parameters + JoyButtonEvent JoyButton; ///< Joystick button event parameters + SizeEvent Size; ///< Size event parameters }; }; @@ -313,3 +328,45 @@ public : #endif // SFML_EVENT_HPP + + +//////////////////////////////////////////////////////////// +/// \class sf::Event +/// +/// sf::Event holds all the informations about a system event +/// that just happened. Events are retrieved using the +/// sf::Window::GetEvent function. +/// +/// A sf::Event instance contains the type of the event +/// (mouse moved, key pressed, window closed, ...) as well +/// as the details about this particular event. Please note that +/// the event parameters are defined in a union, which means that +/// only the member matching the type of the event will be properly +/// filled; all other members will have undefined values and must not +/// be read if the type of the event doesn't match. For example, +/// if you received a KeyPressed event, then you must read the +/// event.Key member, all other members such as event.MouseMove +/// or event.Text will have undefined values. +/// +/// Usage example: +/// \code +/// sf::Event event; +/// while (window.GetEvent(event)) +/// { +/// // Request for closing the window +/// if (event.Type == sf::Event::Closed) +/// window.Close(); +/// +/// // The escape key was pressed +/// if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape)) +/// window.Close(); +/// +/// // The window was resized +/// if (event.Type == sf::Event::Resized) +/// DoSomethingWithTheNewSize(event.Size.Width, event.Size.Height); +/// +/// // etc ... +/// } +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/Input.hpp b/include/SFML/Window/Input.hpp index 247757492..1e8f5c6ce 100644 --- a/include/SFML/Window/Input.hpp +++ b/include/SFML/Window/Input.hpp @@ -37,24 +37,24 @@ namespace sf { //////////////////////////////////////////////////////////// -/// Input handles real-time input from keyboard and mouse. -/// Use it instead of events to handle continuous moves and more -/// game-friendly inputs +/// \brief Give access to the real-time states of keyboard, +/// mouse and joysticks +/// //////////////////////////////////////////////////////////// class SFML_API Input : public WindowListener, NonCopyable { public : //////////////////////////////////////////////////////////// - /// Default constructor + /// \brief Default constructor /// //////////////////////////////////////////////////////////// Input(); //////////////////////////////////////////////////////////// - /// Get the state of a key + /// \brief Get the current state of a key (pressed or released) /// - /// \param key : Key to check + /// \param key Code of the key to test /// /// \return True if key is down, false if key is up /// @@ -62,9 +62,9 @@ public : bool IsKeyDown(Key::Code key) const; //////////////////////////////////////////////////////////// - /// Get the state of a mouse button + /// \brief Get the current state of a mouse button (pressed or released) /// - /// \param button : Button to check + /// \param button Code of the mouse button to check /// /// \return True if button is down, false if button is up /// @@ -72,10 +72,10 @@ public : bool IsMouseButtonDown(Mouse::Button button) const; //////////////////////////////////////////////////////////// - /// Get the state of a joystick button + /// \brief Get the current state of a joystick button (pressed or released) /// - /// \param joystick : Identifier of the joystick to check (0 or 1) - /// \param button : Button to check + /// \param joystick Index of the joystick to test (0 or 1) + /// \param button Index of the button to test /// /// \return True if button is down, false if button is up /// @@ -83,28 +83,37 @@ public : bool IsJoystickButtonDown(unsigned int joystick, unsigned int button) const; //////////////////////////////////////////////////////////// - /// Get the mouse X position + /// \brief Get the current mouse X position /// - /// \return Current mouse left position, relative to owner window + /// The returned position is relative to the left border + /// of the owner window. + /// + /// \return Current mouse left position /// //////////////////////////////////////////////////////////// int GetMouseX() const; //////////////////////////////////////////////////////////// - /// Get the mouse Y position + /// \brief Get the current mouse Y position /// - /// \return Current mouse top position, relative to owner window + /// The returned position is relative to the top border + /// of the owner window. + /// + /// \return Current mouse top position /// //////////////////////////////////////////////////////////// int GetMouseY() const; //////////////////////////////////////////////////////////// - /// Get a joystick axis position + /// \brief Get the current position of a joystick axis /// - /// \param joystick : Identifier of the joystick to check (0 or 1) - /// \param axis : Axis to get + /// The returned position is in the range [-100, 100], except + /// the POV which is an angle and is thus defined in [0, 360]. /// - /// \return Current axis position, in the range [-100, 100] (except for POV, which is [0, 360]) + /// \param joystick Index of the joystick to test (0 or 1) + /// \param axis Axis to test + /// + /// \return Current axis position /// //////////////////////////////////////////////////////////// float GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const; @@ -112,7 +121,9 @@ public : private : //////////////////////////////////////////////////////////// - /// /see WindowListener::OnEvent + /// \brief Called each time an event is received from the attached window + /// + /// \param event Event received /// //////////////////////////////////////////////////////////// virtual void OnEvent(const Event& event); @@ -122,7 +133,7 @@ private : //////////////////////////////////////////////////////////// bool myKeys[Key::Count]; ///< Array containing the state of all keyboard keys bool myMouseButtons[Mouse::Count]; ///< Array containing the state of all mouse buttons - bool myJoystickButtons[2][16]; ///< Array containing the state of all joysticks buttons + bool myJoystickButtons[2][32]; ///< Array containing the state of all joysticks buttons int myMouseX; ///< Mouse position on X int myMouseY; ///< Mouse position on Y float myJoystickAxis[2][Joy::Count]; ///< Joysticks position on each axis @@ -132,3 +143,43 @@ private : #endif // SFML_INPUT_HPP + + +//////////////////////////////////////////////////////////// +/// \class sf::Input +/// +/// sf::Input provides a way to access the state of keys, +/// mouse buttons, mouse position, joystick buttons and +/// jostick axis. +/// +/// sf::Input provides the same informations as the event +/// system, but these informations can be accessed at any time, +/// which is more convenient in many situations. +/// +/// For example, to move an entity you can decide to catch the +/// sf::Event::KeyPressed event on arrow keys. But if you do so, +/// you will only receive one event when the key gets pressed +/// (or repeated events if you activated this feature), thus the +/// entity will not move smoothly. The best solution here is to +/// use sf::Input::IsKeyDown so that you can update your entity's +/// position at every iteration of your game loop, not only when you +/// catch a KeyPressed event. +/// +/// Note that instances of sf::Input cannot be created directly, +/// they must be retrieved from a window (sf::Window) with its +/// GetInput() function. +/// +/// Usage example: +/// \code +/// // Retrieve the input object attached to our window +/// const sf::Input& input = window.GetInput(); +/// +/// // Move an entity according to the current keys state +/// float offset = 5 * window.GetFrameTime(); // 5 pixels/sec +/// if (input.IsKeyDown(sf::Key::Left)) entity.Move(-offset, 0); +/// if (input.IsKeyDown(sf::Key::Right)) entity.Move( offset, 0); +/// if (input.IsKeyDown(sf::Key::Up)) entity.Move(0, -offset); +/// if (input.IsKeyDown(sf::Key::Down)) entity.Move(0, offset); +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/VideoMode.hpp b/include/SFML/Window/VideoMode.hpp index 415697113..e8b743550 100644 --- a/include/SFML/Window/VideoMode.hpp +++ b/include/SFML/Window/VideoMode.hpp @@ -35,32 +35,33 @@ namespace sf { //////////////////////////////////////////////////////////// -/// VideoMode defines a video mode (width, height, bpp, frequency) -/// and provides static functions for getting modes supported -/// by the display device +/// \brief VideoMode defines a video mode (width, height, bpp) +/// //////////////////////////////////////////////////////////// class SFML_API VideoMode { public : //////////////////////////////////////////////////////////// - /// Default constructor + /// \brief Default constructor + /// + /// This constructors initializes all members to 0. /// //////////////////////////////////////////////////////////// VideoMode(); //////////////////////////////////////////////////////////// - /// Construct the video mode with its attributes + /// \brief Construct the video mode with its attributes /// - /// \param width : Width in pixels - /// \param height : Height in pixels - /// \param bitsPerPixel : Pixel depths in bits per pixel (32 by default) + /// \param width Width in pixels + /// \param height Height in pixels + /// \param bitsPerPixel Pixel depths in bits per pixel /// //////////////////////////////////////////////////////////// VideoMode(unsigned int width, unsigned int height, unsigned int bitsPerPixel = 32); //////////////////////////////////////////////////////////// - /// Get the current desktop video mode + /// \brief Get the current desktop video mode /// /// \return Current desktop video mode /// @@ -68,11 +69,13 @@ public : static VideoMode GetDesktopMode(); //////////////////////////////////////////////////////////// - /// Get a valid video mode - /// Index must be in range [0, GetModesCount()[ - /// Modes are sorted from best to worst + /// \brief Get a valid video mode /// - /// \param index : Index of video mode to get + /// The parameter \index must be in the range [0, GetModesCount()[. + /// Modes are sorted from best to worst, so that + /// sf::VideoMode::GetMode(0) will always give the best. + /// + /// \param index Index of video mode to get /// /// \return Corresponding video mode (invalid mode if index is out of range) /// @@ -80,41 +83,29 @@ public : static VideoMode GetMode(std::size_t index); //////////////////////////////////////////////////////////// - /// Get valid video modes count + /// \brief Get the total number of valid video modes available /// - /// \return Number of valid video modes available + /// The validity of video modes is only relevant when using + /// fullscreen windows; otherwise any video mode can be used + /// with no restriction. + /// + /// \return Number of valid video modes available for fullscreen mode /// //////////////////////////////////////////////////////////// static std::size_t GetModesCount(); //////////////////////////////////////////////////////////// - /// Tell whether or not the video mode is supported + /// \brief Tell whether or not the video mode is valid /// - /// \return True if video mode is supported, false otherwise + /// The validity of video modes is only relevant when using + /// fullscreen windows; otherwise any video mode can be used + /// with no restriction. + /// + /// \return True if the video mode is valid for fullscreen mode /// //////////////////////////////////////////////////////////// bool IsValid() const; - //////////////////////////////////////////////////////////// - /// Comparison operator overload -- tell if two video modes are equal - /// - /// \param other : Video mode to compare - /// - /// \return True if modes are equal - /// - //////////////////////////////////////////////////////////// - bool operator ==(const VideoMode& other) const; - - //////////////////////////////////////////////////////////// - /// Comparison operator overload -- tell if two video modes are different - /// - /// \param other : Video mode to compare - /// - /// \return True if modes are different - /// - //////////////////////////////////////////////////////////// - bool operator !=(const VideoMode& other) const; - //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// @@ -123,7 +114,81 @@ public : unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels }; +//////////////////////////////////////////////////////////// +/// \brief Overload of binary == operator +/// +/// This operator compares strict equality between two modes, +/// i.e. it checks if all their members are equal. +/// +/// \param left Left operand +/// \param right Right operand +/// +/// \return True if modes are equal +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator ==(const VideoMode& left, const VideoMode& right); + +//////////////////////////////////////////////////////////// +/// \brief Overload of binary != operator +/// +/// This operator compares strict difference between two modes, +/// i.e. it checks if not all their members are equal. +/// +/// \param left Left operand +/// \param right Right operand +/// +/// \return True if modes are different +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator !=(const VideoMode& left, const VideoMode& right); + } // namespace sf #endif // SFML_VIDEOMODE_HPP + + +//////////////////////////////////////////////////////////// +/// \class sf::VideoMode +/// +/// A video mode is defined by a width and a height (in pixels) +/// and a depth (in bits per pixel). Video modes are used to +/// setup windows (sf::Window) at creation time. +/// +/// The main usage of video modes is for fullscreen mode: +/// indeed you must use one of the valid video modes +/// allowed by the OS (which are defined by what the monitor +/// and the graphics card support), otherwise your window +/// creation will just fail. +/// +/// sf::VideoMode provides two static functions for retrieving +/// the list of all the video modes supported by the system: +/// GetModesCount() to get the number of video modes in the +/// list, and GetMode() to retrieve a particular mode +/// from the list. +/// +/// A custom video mode can also be checked directly with +/// its IsValid() function. +/// +/// Additionnally, sf::VideoMode provides a static function +/// to get the mode currently used by the desktop: GetDesktopMode(). +/// This allows to build windows with the same size or pixel +/// depth as the current resolution. +/// +/// Usage example: +/// \code +/// // Display the list of all the video modes available for fullscreen +/// for (std::size_t i = 0; i < sf::VideoMode::GetModesCount(); ++i) +/// { +/// sf::VideoMode mode = sf::VideoMode::GetMode(i); +/// std::cout << "Mode #" << i << ": " +/// << mode.Width << "x" << mode.Height << " - " +/// << mode.BitsPerPixel << " bpp" << std::endl; +/// } +/// +/// // Create a window with the same pixel depth as the desktop +/// sf::VideoMode desktop = sf::VideoMode::GetDesktopMode(); +/// window.Create(sf::VideoMode(1024, 768, desktop.BitsPerPixel), "SFML window"); +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 6188cc3a5..1753da0e7 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -68,8 +68,8 @@ public : /// /// \param mode : Video mode to use /// \param title : Title of the window - /// \param style : Window style (Resize | Close by default) - /// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values) + /// \param style : Window style + /// \param settings : Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// Window(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings()); @@ -78,7 +78,7 @@ public : /// Construct the window from an existing control /// /// \param handle : Platform-specific handle of the control - /// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values) + /// \param settings : Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// Window(WindowHandle handle, const ContextSettings& settings = ContextSettings()); @@ -94,8 +94,8 @@ public : /// /// \param mode : Video mode to use /// \param title : Title of the window - /// \param style : Window style (Resize | Close by default) - /// \param Settings : Additional settings for the underlying OpenGL context (see default constructor for default values) + /// \param style : Window style + /// \param Settings : Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// void Create(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings()); @@ -104,7 +104,7 @@ public : /// Create (or recreate) the window from an existing control /// /// \param handle : Platform-specific handle of the control - /// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values) + /// \param settings : Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// void Create(WindowHandle handle, const ContextSettings& settings = ContextSettings()); @@ -236,7 +236,7 @@ public : /// Activate or deactivate the window as the current target /// for rendering /// - /// \param active : True to activate, false to deactivate (true by default) + /// \param active : True to activate, false to deactivate /// /// \return True if operation was successful, false otherwise /// diff --git a/include/SFML/Window/WindowListener.hpp b/include/SFML/Window/WindowListener.hpp index 4d3059943..396fb58d7 100644 --- a/include/SFML/Window/WindowListener.hpp +++ b/include/SFML/Window/WindowListener.hpp @@ -36,17 +36,17 @@ namespace sf class Event; //////////////////////////////////////////////////////////// -/// Base class for classes that want to receive events -/// from a window (for internal use only) +/// \brief Base class for classes that want to receive events +/// from a window (for internal use only) //////////////////////////////////////////////////////////// class SFML_API WindowListener { public : //////////////////////////////////////////////////////////// - /// Called each time an event is received from attached window + /// \brief Called each time an event is received from the attached window /// - /// \param event : Event received + /// \param event Event received /// //////////////////////////////////////////////////////////// virtual void OnEvent(const Event& event) = 0; @@ -54,7 +54,7 @@ public : protected : //////////////////////////////////////////////////////////// - /// Destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// virtual ~WindowListener() {} diff --git a/include/SFML/Window/WindowStyle.hpp b/include/SFML/Window/WindowStyle.hpp index 9fcc2e7a3..54392e926 100644 --- a/include/SFML/Window/WindowStyle.hpp +++ b/include/SFML/Window/WindowStyle.hpp @@ -28,9 +28,9 @@ namespace sf { - //////////////////////////////////////////////////////////// -/// Enumeration of window creation styles +/// \brief Enumeration of the window styles +/// //////////////////////////////////////////////////////////// namespace Style { @@ -44,7 +44,6 @@ namespace Style }; } - } // namespace sf diff --git a/samples/qt/QSFMLCanvas.hpp b/samples/qt/QSFMLCanvas.hpp index 2e7b03a5f..2f66ceab4 100644 --- a/samples/qt/QSFMLCanvas.hpp +++ b/samples/qt/QSFMLCanvas.hpp @@ -23,8 +23,8 @@ public : /// Construct the QSFMLCanvas /// /// \param size : Initial size of the widget - /// \param frameTime : Frame duration, in milliseconds (0 by default) - /// \param parent : Parent of the widget (NULL by default) + /// \param frameTime : Frame duration, in milliseconds + /// \param parent : Parent of the widget /// //////////////////////////////////////////////////////////// QSFMLCanvas(const QSize& size, unsigned int frameTime = 0, QWidget* parent = NULL); diff --git a/samples/wxwidgets/wxSFMLCanvas.hpp b/samples/wxwidgets/wxSFMLCanvas.hpp index e17219198..6ef8eb3ff 100644 --- a/samples/wxwidgets/wxSFMLCanvas.hpp +++ b/samples/wxwidgets/wxSFMLCanvas.hpp @@ -19,11 +19,11 @@ public : //////////////////////////////////////////////////////////// /// Construct the wxSFMLCanvas /// - /// \param parent : Parent of the control (NULL by default) - /// \param id : Identifier of the control (-1 by default) - /// \param position : Position of the control (wxDefaultPosition by default) - /// \param size : Size of the control (wxDefaultSize by default) - /// \param style : Style of the control (0 by default) + /// \param parent : Parent of the control + /// \param id : Identifier of the control + /// \param position : Position of the control + /// \param size : Size of the control + /// \param style : Style of the control /// //////////////////////////////////////////////////////////// wxSFMLCanvas(wxWindow* parent = NULL, wxWindowID id = -1, const wxPoint& position = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0); diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp index 0fec36daa..3054d0b54 100644 --- a/src/SFML/Window/Context.cpp +++ b/src/SFML/Window/Context.cpp @@ -32,8 +32,6 @@ namespace sf { //////////////////////////////////////////////////////////// -/// Default constructor -- creates and activates the context -//////////////////////////////////////////////////////////// Context::Context() { myContext = priv::ContextGL::New(); @@ -41,8 +39,6 @@ Context::Context() } -//////////////////////////////////////////////////////////// -/// Destructor -- deactivates and destroys the context //////////////////////////////////////////////////////////// Context::~Context() { @@ -51,8 +47,6 @@ Context::~Context() } -//////////////////////////////////////////////////////////// -/// Activate or deactivate explicitely the context //////////////////////////////////////////////////////////// void Context::SetActive(bool active) { diff --git a/src/SFML/Window/ContextGL.cpp b/src/SFML/Window/ContextGL.cpp index 05732b0ee..8d0be530a 100644 --- a/src/SFML/Window/ContextGL.cpp +++ b/src/SFML/Window/ContextGL.cpp @@ -73,16 +73,12 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Create a new context, not associated to a window -//////////////////////////////////////////////////////////// ContextGL* ContextGL::New() { return new ContextType(&referenceContext); } -//////////////////////////////////////////////////////////// -/// Create a new context attached to a window //////////////////////////////////////////////////////////// ContextGL* ContextGL::New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings) { @@ -96,8 +92,6 @@ ContextGL* ContextGL::New(const WindowImpl* owner, unsigned int bitsPerPixel, co } -//////////////////////////////////////////////////////////// -/// Destructor //////////////////////////////////////////////////////////// ContextGL::~ContextGL() { @@ -112,8 +106,6 @@ ContextGL::~ContextGL() } -//////////////////////////////////////////////////////////// -/// Get the settings of the context //////////////////////////////////////////////////////////// const ContextSettings& ContextGL::GetSettings() const { @@ -121,9 +113,6 @@ const ContextSettings& ContextGL::GetSettings() const } -//////////////////////////////////////////////////////////// -/// Activate or deactivate the context as the current target -/// for rendering //////////////////////////////////////////////////////////// bool ContextGL::SetActive(bool active) { @@ -151,8 +140,6 @@ bool ContextGL::SetActive(bool active) } -//////////////////////////////////////////////////////////// -/// Default constructor //////////////////////////////////////////////////////////// ContextGL::ContextGL() { @@ -160,10 +147,6 @@ ContextGL::ContextGL() } -//////////////////////////////////////////////////////////// -/// Evaluate a pixel format configuration. -/// This functions can be used by implementations that have -/// several valid formats and want to get the best one //////////////////////////////////////////////////////////// int ContextGL::EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing) { diff --git a/src/SFML/Window/ContextGL.hpp b/src/SFML/Window/ContextGL.hpp index 650e76503..00f073823 100644 --- a/src/SFML/Window/ContextGL.hpp +++ b/src/SFML/Window/ContextGL.hpp @@ -40,28 +40,35 @@ namespace priv class WindowImpl; //////////////////////////////////////////////////////////// -/// Abstract class representing an OpenGL context +/// \brief Abstract class representing an OpenGL context +/// //////////////////////////////////////////////////////////// class ContextGL : NonCopyable { public : //////////////////////////////////////////////////////////// - /// Create a new context, not associated to a window + /// \brief Create a new context, not associated to a window /// - /// \return Pointer to the created context + /// This function automatically chooses the specialized class + /// to use according to the OS. + /// + /// \return Pointer to the created context (don't forget to delete it) /// //////////////////////////////////////////////////////////// static ContextGL* New(); //////////////////////////////////////////////////////////// - /// Create a new context attached to a window + /// \brief Create a new context attached to a window /// - /// \param owner : Pointer to the owner window - /// \param bitsPerPixel : Pixel depth (in bits per pixel) - /// \param settings : Creation parameters + /// This function automatically chooses the specialized class + /// to use according to the OS. /// - /// \return Pointer to the created context + /// \param owner Pointer to the owner window + /// \param bitsPerPixel Pixel depth (in bits per pixel) + /// \param settings Creation parameters + /// + /// \return Pointer to the created context (don't forget to delete it) /// //////////////////////////////////////////////////////////// static ContextGL* New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings); @@ -69,13 +76,17 @@ public : public : //////////////////////////////////////////////////////////// - /// Virtual destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// virtual ~ContextGL(); //////////////////////////////////////////////////////////// - /// Get the settings of the context + /// \brief Get the settings of the context + /// + /// Note that these settings may be different than the ones + /// passed to the constructor; they are indeed adjusted if the + /// original settings are not directly supported by the system. /// /// \return Structure containing the settings /// @@ -83,10 +94,16 @@ public : const ContextSettings& GetSettings() const; //////////////////////////////////////////////////////////// - /// Activate or deactivate the context as the current target - /// for rendering + /// \brief Activate or deactivate the context as the current target + /// for rendering /// - /// \param active : True to activate, false to deactivate + /// A context is active only on the current thread, if you want to + /// make it active on another thread you have to deactivate it + /// on the previous thread first if it was active. + /// Only one context can be active on a thread at a time, thus + /// the context previously active (if any) automatically gets deactivated. + /// + /// \param active True to activate, false to deactivate /// /// \return True if operation was successful, false otherwise /// @@ -94,13 +111,18 @@ public : bool SetActive(bool active); //////////////////////////////////////////////////////////// - /// Display the contents of the context + /// \brief Display what has been rendered to the context so far /// //////////////////////////////////////////////////////////// virtual void Display() = 0; //////////////////////////////////////////////////////////// - /// Enable / disable vertical synchronization + /// \brief Enable or disable vertical synchronization + /// + /// Activating vertical synchronization will limit the number + /// of frames displayed to the refresh rate of the monitor. + /// This can avoid some visual artifacts, and limit the framerate + /// to a good value (but not constant across different computers). /// /// \param enabled : True to enable v-sync, false to deactivate /// @@ -110,15 +132,18 @@ public : protected : //////////////////////////////////////////////////////////// - /// Default constructor + /// \brief Default constructor + /// + /// This constructor is meant for derived classes only. /// //////////////////////////////////////////////////////////// ContextGL(); //////////////////////////////////////////////////////////// - /// Make this context the current one + /// \brief Activate or deactivate the context as the current target + /// for rendering /// - /// \param active : True to activate, false to deactivate + /// \param active True to activate, false to deactivate /// /// \return True on success, false if any error happened /// @@ -126,18 +151,21 @@ protected : virtual bool MakeCurrent(bool active) = 0; //////////////////////////////////////////////////////////// - /// Evaluate a pixel format configuration. + /// \brief Evaluate a pixel format configuration + /// /// This functions can be used by implementations that have - /// several valid formats and want to get the best one + /// several valid formats and want to get the best one. + /// A score is returned for the given configuration: the + /// lower the score is, the better the configuration is. /// - /// \param bitsPerPixel : Requested pixel depth (bits per pixel) - /// \param settings : Requested additionnal settings - /// \param colorBits : Color bits of the configuration to evaluate - /// \param depthBits : Depth bits of the configuration to evaluate - /// \param stencilBits : Stencil bits of the configuration to evaluate - /// \param antialiasing : Antialiasing level of the configuration to evaluate + /// \param bitsPerPixel Requested pixel depth (bits per pixel) + /// \param settings Requested additionnal settings + /// \param colorBits Color bits of the configuration to evaluate + /// \param depthBits Depth bits of the configuration to evaluate + /// \param stencilBits Stencil bits of the configuration to evaluate + /// \param antialiasing Antialiasing level of the configuration to evaluate /// - /// \return Score of the configuration : the lower the better + /// \return Score of the configuration /// //////////////////////////////////////////////////////////// static int EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing); diff --git a/src/SFML/Window/Input.cpp b/src/SFML/Window/Input.cpp index 4e5a6bb86..00507ac6f 100644 --- a/src/SFML/Window/Input.cpp +++ b/src/SFML/Window/Input.cpp @@ -31,8 +31,6 @@ namespace sf { //////////////////////////////////////////////////////////// -/// Default constructor -//////////////////////////////////////////////////////////// Input::Input() : myMouseX(0), myMouseY(0) @@ -43,7 +41,7 @@ myMouseY(0) for (int i = 0; i < Mouse::Count; ++i) myMouseButtons[i] = false; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 32; ++i) { myJoystickButtons[0][i] = false; myJoystickButtons[1][i] = false; @@ -57,8 +55,6 @@ myMouseY(0) } -//////////////////////////////////////////////////////////// -/// Get the state of a key //////////////////////////////////////////////////////////// bool Input::IsKeyDown(Key::Code key) const { @@ -66,8 +62,6 @@ bool Input::IsKeyDown(Key::Code key) const } -//////////////////////////////////////////////////////////// -/// Get the state of a mouse button //////////////////////////////////////////////////////////// bool Input::IsMouseButtonDown(Mouse::Button button) const { @@ -75,20 +69,16 @@ bool Input::IsMouseButtonDown(Mouse::Button button) const } -//////////////////////////////////////////////////////////// -/// Get the state of a joystick button //////////////////////////////////////////////////////////// bool Input::IsJoystickButtonDown(unsigned int joystick, unsigned int button) const { - if ((joystick < 2) && (button < 16)) + if ((joystick < 2) && (button < 32)) return myJoystickButtons[joystick][button]; else return false; } -//////////////////////////////////////////////////////////// -/// Get the mouse left position //////////////////////////////////////////////////////////// int Input::GetMouseX() const { @@ -96,8 +86,6 @@ int Input::GetMouseX() const } -//////////////////////////////////////////////////////////// -/// Get the mouse top position //////////////////////////////////////////////////////////// int Input::GetMouseY() const { @@ -105,8 +93,6 @@ int Input::GetMouseY() const } -//////////////////////////////////////////////////////////// -/// Get a joystick axis position //////////////////////////////////////////////////////////// float Input::GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const { @@ -114,8 +100,6 @@ float Input::GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const } -//////////////////////////////////////////////////////////// -/// /see WindowListener::OnEvent //////////////////////////////////////////////////////////// void Input::OnEvent(const Event& event) { @@ -153,7 +137,7 @@ void Input::OnEvent(const Event& event) for (int i = 0; i < Mouse::Count; ++i) myMouseButtons[i] = false; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 32; ++i) { myJoystickButtons[0][i] = false; myJoystickButtons[1][i] = false; diff --git a/src/SFML/Window/Joystick.hpp b/src/SFML/Window/Joystick.hpp index 4a17f4ef1..135bae6ef 100644 --- a/src/SFML/Window/Joystick.hpp +++ b/src/SFML/Window/Joystick.hpp @@ -37,7 +37,8 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Structure holding the joystick state's parameters +/// \brief Structure holding the joystick state's parameters +/// //////////////////////////////////////////////////////////// struct JoystickState { diff --git a/src/SFML/Window/Linux/ContextGLX.cpp b/src/SFML/Window/Linux/ContextGLX.cpp index 428a3329b..1817151a4 100644 --- a/src/SFML/Window/Linux/ContextGLX.cpp +++ b/src/SFML/Window/Linux/ContextGLX.cpp @@ -37,8 +37,6 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Create a new context, not associated to a window -//////////////////////////////////////////////////////////// ContextGLX::ContextGLX(ContextGLX* shared) : myWindow (0), myContext (NULL), @@ -63,13 +61,10 @@ myOwnsWindow(true) CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0)); // Activate the context - //if (shared) - SetActive(true); + SetActive(true); } -//////////////////////////////////////////////////////////// -/// Create a new context attached to a window //////////////////////////////////////////////////////////// ContextGLX::ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings) : myWindow (0), @@ -87,13 +82,10 @@ myOwnsWindow(false) CreateContext(shared, bitsPerPixel, settings); // Activate the context - //if (shared) - SetActive(true); + SetActive(true); } -//////////////////////////////////////////////////////////// -/// Destructor //////////////////////////////////////////////////////////// ContextGLX::~ContextGLX() { @@ -120,8 +112,6 @@ ContextGLX::~ContextGLX() } -//////////////////////////////////////////////////////////// -/// \see Context::MakeCurrent //////////////////////////////////////////////////////////// bool ContextGLX::MakeCurrent(bool active) { @@ -149,8 +139,6 @@ bool ContextGLX::MakeCurrent(bool active) } -//////////////////////////////////////////////////////////// -/// \see Context::Display //////////////////////////////////////////////////////////// void ContextGLX::Display() { @@ -159,8 +147,6 @@ void ContextGLX::Display() } -//////////////////////////////////////////////////////////// -/// \see Context::UseVerticalSync //////////////////////////////////////////////////////////// void ContextGLX::UseVerticalSync(bool enabled) { @@ -171,8 +157,6 @@ void ContextGLX::UseVerticalSync(bool enabled) } -//////////////////////////////////////////////////////////// -/// Check if a context is active on the current thread //////////////////////////////////////////////////////////// bool ContextGLX::IsContextActive() { @@ -180,8 +164,6 @@ bool ContextGLX::IsContextActive() } -//////////////////////////////////////////////////////////// -/// Create the context //////////////////////////////////////////////////////////// void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, const ContextSettings& settings) { diff --git a/src/SFML/Window/Linux/ContextGLX.hpp b/src/SFML/Window/Linux/ContextGLX.hpp index eb296673b..c1ea13d7d 100644 --- a/src/SFML/Window/Linux/ContextGLX.hpp +++ b/src/SFML/Window/Linux/ContextGLX.hpp @@ -38,57 +38,70 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Linux (GLX) implementation of OpenGL contexts +/// \brief Linux (GLX) implementation of OpenGL contexts +/// //////////////////////////////////////////////////////////// class ContextGLX : public ContextGL { public : //////////////////////////////////////////////////////////// - /// Create a new context, not associated to a window + /// \brief Create a new context, not associated to a window /// - /// \param shared : Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be NULL) /// //////////////////////////////////////////////////////////// ContextGLX(ContextGLX* shared); //////////////////////////////////////////////////////////// - /// Create a new context attached to a window + /// \brief Create a new context attached to a window /// - /// \param shared : Context to share the new one with (can be NULL) - /// \param owner : Pointer to the owner window - /// \param bitsPerPixel : Pixel depth (in bits per pixel) - /// \param settings : Creation parameters + /// \param shared Context to share the new one with (can be NULL) + /// \param owner Pointer to the owner window + /// \param bitsPerPixel Pixel depth (in bits per pixel) + /// \param settings Creation parameters /// //////////////////////////////////////////////////////////// ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings); //////////////////////////////////////////////////////////// - /// Destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// ~ContextGLX(); //////////////////////////////////////////////////////////// - /// \see Context::MakeCurrent + /// \brief Activate or deactivate the context as the current target + /// for rendering + /// + /// \param active True to activate, false to deactivate + /// + /// \return True on success, false if any error happened /// //////////////////////////////////////////////////////////// virtual bool MakeCurrent(bool active); //////////////////////////////////////////////////////////// - /// \see Context::Display + /// \brief Display what has been rendered to the context so far /// //////////////////////////////////////////////////////////// virtual void Display(); //////////////////////////////////////////////////////////// - /// \see Context::UseVerticalSync + /// \brief Enable or disable vertical synchronization + /// + /// Activating vertical synchronization will limit the number + /// of frames displayed to the refresh rate of the monitor. + /// This can avoid some visual artifacts, and limit the framerate + /// to a good value (but not constant across different computers). + /// + /// \param enabled : True to enable v-sync, false to deactivate /// //////////////////////////////////////////////////////////// virtual void UseVerticalSync(bool enabled); //////////////////////////////////////////////////////////// - /// Check if a context is active on the current thread + /// \brief Check if a context is active on the current thread /// /// \return True if there's an active context, false otherwise /// @@ -98,11 +111,11 @@ public : private : //////////////////////////////////////////////////////////// - /// Create the context + /// \brief Create the context /// - /// \param shared : Context to share the new one with (can be NULL) - /// \param bitsPerPixel : Pixel depth, in bits per pixel - /// \param settings : Creation parameters + /// \param shared Context to share the new one with (can be NULL) + /// \param bitsPerPixel Pixel depth, in bits per pixel + /// \param settings Creation parameters /// //////////////////////////////////////////////////////////// void CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, const ContextSettings& settings); diff --git a/src/SFML/Window/Linux/Joystick.cpp b/src/SFML/Window/Linux/Joystick.cpp index 1e6c339b3..77ae4bcf7 100644 --- a/src/SFML/Window/Linux/Joystick.cpp +++ b/src/SFML/Window/Linux/Joystick.cpp @@ -42,8 +42,6 @@ namespace priv { #if defined(SFML_SYSTEM_LINUX) -//////////////////////////////////////////////////////////// -/// Initialize the instance and bind it to a physical joystick //////////////////////////////////////////////////////////// void Joystick::Initialize(unsigned int index) { @@ -74,8 +72,6 @@ void Joystick::Initialize(unsigned int index) } -//////////////////////////////////////////////////////////// -/// Update the current joystick and return its new state //////////////////////////////////////////////////////////// JoystickState Joystick::UpdateState() { @@ -109,8 +105,6 @@ JoystickState Joystick::UpdateState() } -//////////////////////////////////////////////////////////// -/// Get the number of axes supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetAxesCount() const { @@ -118,8 +112,6 @@ unsigned int Joystick::GetAxesCount() const } -//////////////////////////////////////////////////////////// -/// Get the number of buttons supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetButtonsCount() const { @@ -130,16 +122,12 @@ unsigned int Joystick::GetButtonsCount() const #elif defined(SFML_SYSTEM_FREEBSD) -//////////////////////////////////////////////////////////// -/// Initialize the instance and bind it to a physical joystick //////////////////////////////////////////////////////////// void Joystick::Initialize(unsigned int index) { } -//////////////////////////////////////////////////////////// -/// Update the current joystick and return its new state //////////////////////////////////////////////////////////// JoystickState Joystick::UpdateState() { @@ -147,8 +135,6 @@ JoystickState Joystick::UpdateState() } -//////////////////////////////////////////////////////////// -/// Get the number of axes supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetAxesCount() const { @@ -156,8 +142,6 @@ unsigned int Joystick::GetAxesCount() const } -//////////////////////////////////////////////////////////// -/// Get the number of buttons supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetButtonsCount() const { diff --git a/src/SFML/Window/Linux/Joystick.hpp b/src/SFML/Window/Linux/Joystick.hpp index 33fb44a8d..b444ecdb3 100644 --- a/src/SFML/Window/Linux/Joystick.hpp +++ b/src/SFML/Window/Linux/Joystick.hpp @@ -35,22 +35,23 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Linux implementation of Joystick +/// \brief Linux implementation of Joystick +/// //////////////////////////////////////////////////////////// class Joystick { public : //////////////////////////////////////////////////////////// - /// Initialize the instance and bind it to a physical joystick + /// \brief Initialize the instance and bind it to a physical joystick /// - /// \param index : Index of the physical joystick to bind to + /// \param index Index of the physical joystick to bind to /// //////////////////////////////////////////////////////////// void Initialize(unsigned int index); //////////////////////////////////////////////////////////// - /// Update the current joystick and return its new state + /// \brief Update the current joystick and return its new state /// /// \return Current state of the joystick /// @@ -58,7 +59,7 @@ public : JoystickState UpdateState(); //////////////////////////////////////////////////////////// - /// Get the number of axes supported by the joystick + /// \brief Get the number of axes supported by the joystick /// /// \return Number of axis /// @@ -66,7 +67,7 @@ public : unsigned int GetAxesCount() const; //////////////////////////////////////////////////////////// - /// Get the number of buttons supported by the joystick + /// \brief Get the number of buttons supported by the joystick /// /// \return Number of buttons /// diff --git a/src/SFML/Window/Linux/VideoModeSupport.cpp b/src/SFML/Window/Linux/VideoModeSupport.cpp index 311139ba1..de8246019 100644 --- a/src/SFML/Window/Linux/VideoModeSupport.cpp +++ b/src/SFML/Window/Linux/VideoModeSupport.cpp @@ -1,103 +1,101 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// Get supported video modes -//////////////////////////////////////////////////////////// -void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) -{ - // First, clear array to fill - modes.clear(); - - // Open a connection with the X server +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) +{ + // First, clear array to fill + modes.clear(); + + // Open a connection with the X server Display* disp = XOpenDisplay(NULL); if (disp) { - // Retrieve the default screen number - int screen = DefaultScreen(disp); - - // Check if the XRandR extension is present - int version; - if (XQueryExtension(disp, "RANDR", &version, &version, &version)) - { - // Get the current configuration - XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen)); - if (config) - { - // Get the available screen sizes - int nbSizes; - XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); - if (sizes && (nbSizes > 0)) - { - // Get the list of supported depths - int nbDepths = 0; - int* depths = XListDepths(disp, screen, &nbDepths); - if (depths && (nbDepths > 0)) - { - // Combine depths and sizes to fill the array of supported modes - for (int i = 0; i < nbDepths; ++i) - { - for (int j = 0; j < nbSizes; ++j) - { - // Convert to VideoMode - VideoMode mode(sizes[j].width, sizes[j].height, depths[i]); - - // Add it only if it is not already in the array - if (std::find(modes.begin(), modes.end(), mode) == modes.end()) - modes.push_back(mode); - } - } - } - } - - // Free the configuration instance - XRRFreeScreenConfigInfo(config); - } - else - { - // Failed to get the screen configuration - std::cerr << "Failed to retrieve the screen configuration while trying to get the supported video modes" << std::endl; - } - } - else - { - // XRandr extension is not supported : we cannot get the video modes - std::cerr << "Failed to use the XRandR extension while trying to get the supported video modes" << std::endl; + // Retrieve the default screen number + int screen = DefaultScreen(disp); + + // Check if the XRandR extension is present + int version; + if (XQueryExtension(disp, "RANDR", &version, &version, &version)) + { + // Get the current configuration + XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen)); + if (config) + { + // Get the available screen sizes + int nbSizes; + XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); + if (sizes && (nbSizes > 0)) + { + // Get the list of supported depths + int nbDepths = 0; + int* depths = XListDepths(disp, screen, &nbDepths); + if (depths && (nbDepths > 0)) + { + // Combine depths and sizes to fill the array of supported modes + for (int i = 0; i < nbDepths; ++i) + { + for (int j = 0; j < nbSizes; ++j) + { + // Convert to VideoMode + VideoMode mode(sizes[j].width, sizes[j].height, depths[i]); + + // Add it only if it is not already in the array + if (std::find(modes.begin(), modes.end(), mode) == modes.end()) + modes.push_back(mode); + } + } + } + } + + // Free the configuration instance + XRRFreeScreenConfigInfo(config); + } + else + { + // Failed to get the screen configuration + std::cerr << "Failed to retrieve the screen configuration while trying to get the supported video modes" << std::endl; + } + } + else + { + // XRandr extension is not supported : we cannot get the video modes + std::cerr << "Failed to use the XRandR extension while trying to get the supported video modes" << std::endl; } // Close the connection with the X server @@ -105,71 +103,69 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) } else { - // We couldn't connect to the X server - std::cerr << "Failed to connect to the X server while trying to get the supported video modes" << std::endl; + // We couldn't connect to the X server + std::cerr << "Failed to connect to the X server while trying to get the supported video modes" << std::endl; } -} - - -//////////////////////////////////////////////////////////// -/// Get current desktop video mode -//////////////////////////////////////////////////////////// -VideoMode VideoModeSupport::GetDesktopVideoMode() -{ - VideoMode desktopMode; - - // Open a connection with the X server +} + + +//////////////////////////////////////////////////////////// +VideoMode VideoModeSupport::GetDesktopVideoMode() +{ + VideoMode desktopMode; + + // Open a connection with the X server Display* disp = XOpenDisplay(NULL); if (disp) { - // Retrieve the default screen number - int screen = DefaultScreen(disp); - - // Check if the XRandR extension is present - int version; - if (XQueryExtension(disp, "RANDR", &version, &version, &version)) - { - // Get the current configuration - XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen)); - if (config) - { - // Get the current video mode - Rotation currentRotation; - int currentMode = XRRConfigCurrentConfiguration(config, ¤tRotation); - - // Get the available screen sizes - int nbSizes; - XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); - if (sizes && (nbSizes > 0)) - desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(disp, screen)); - - // Free the configuration instance - XRRFreeScreenConfigInfo(config); - } - else - { - // Failed to get the screen configuration - std::cerr << "Failed to retrieve the screen configuration while trying to get the desktop video modes" << std::endl; - } - } - else - { - // XRandr extension is not supported : we cannot get the video modes - std::cerr << "Failed to use the XRandR extension while trying to get the desktop video modes" << std::endl; - } + // Retrieve the default screen number + int screen = DefaultScreen(disp); + + // Check if the XRandR extension is present + int version; + if (XQueryExtension(disp, "RANDR", &version, &version, &version)) + { + // Get the current configuration + XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen)); + if (config) + { + // Get the current video mode + Rotation currentRotation; + int currentMode = XRRConfigCurrentConfiguration(config, ¤tRotation); + + // Get the available screen sizes + int nbSizes; + XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); + if (sizes && (nbSizes > 0)) + desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(disp, screen)); + + // Free the configuration instance + XRRFreeScreenConfigInfo(config); + } + else + { + // Failed to get the screen configuration + std::cerr << "Failed to retrieve the screen configuration while trying to get the desktop video modes" << std::endl; + } + } + else + { + // XRandr extension is not supported : we cannot get the video modes + std::cerr << "Failed to use the XRandR extension while trying to get the desktop video modes" << std::endl; + } // Close the connection with the X server XCloseDisplay(disp); } else { - // We couldn't connect to the X server - std::cerr << "Failed to connect to the X server while trying to get the desktop video modes" << std::endl; + // We couldn't connect to the X server + std::cerr << "Failed to connect to the X server while trying to get the desktop video modes" << std::endl; } - return desktopMode; -} - -} // namespace priv - -} // namespace sf + return desktopMode; +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Linux/VideoModeSupport.hpp b/src/SFML/Window/Linux/VideoModeSupport.hpp index 758b71aec..c0207c0df 100644 --- a/src/SFML/Window/Linux/VideoModeSupport.hpp +++ b/src/SFML/Window/Linux/VideoModeSupport.hpp @@ -37,23 +37,23 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Linux implementation of VideoModeSupport -/// Give access to video mode related OS-specific functions +/// \brief Linux (X11) implementation of VideoModeSupport; +/// gives access to video mode related OS-specific functions //////////////////////////////////////////////////////////// class VideoModeSupport { public : //////////////////////////////////////////////////////////// - /// Get supported video modes + /// \brief Get the list of all the supported video modes /// - /// \param modes : Array to fill with available video modes + /// \param modes Array to fill with available video modes /// //////////////////////////////////////////////////////////// static void GetSupportedVideoModes(std::vector& modes); //////////////////////////////////////////////////////////// - /// Get current desktop video mode + /// \brief Get the current desktop video mode /// /// \return Current desktop video mode /// diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index a11b15d1a..f0eaeffa9 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -1,979 +1,938 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include // important to be included first (conflict with None) -#include -#include -#include -#include -#include -#include -#include -#include - - -//////////////////////////////////////////////////////////// -// Private data -//////////////////////////////////////////////////////////// -namespace -{ - sf::priv::WindowImplX11* fullscreenWindow = NULL; - unsigned long eventMask = FocusChangeMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | - EnterWindowMask | LeaveWindowMask; - - //////////////////////////////////////////////////////////// - /// Filter the events received by windows - /// (only allow those matching a specific window) - //////////////////////////////////////////////////////////// - Bool CheckEvent(::Display*, XEvent* event, XPointer userData) - { - // Just check if the event matches the window - return event->xany.window == reinterpret_cast< ::Window >(userData); - } -} - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// Create the window implementation from an existing control -//////////////////////////////////////////////////////////// -WindowImplX11::WindowImplX11(WindowHandle handle) : -myWindow (0), -myInputMethod (NULL), -myInputContext(NULL), -myIsExternal (true), -myAtomClose (0), -myOldVideoMode(-1), -myHiddenCursor(0), -myKeyRepeat (true) -{ - // Open a connection with the X server - myDisplay = XOpenDisplay(NULL); - myScreen = DefaultScreen(myDisplay); - - // Save the window handle - myWindow = handle; - - if (myWindow) - { - // Get the window size - XWindowAttributes windowAttributes; - if (XGetWindowAttributes(myDisplay, myWindow, &windowAttributes) == 0) - { - std::cerr << "Failed to get the window attributes" << std::endl; - return; - } - myWidth = windowAttributes.width; - myHeight = windowAttributes.height; - - // Make sure the window is listening to all the requiered events - XSelectInput(myDisplay, myWindow, eventMask & ~ButtonPressMask); - - // Do some common initializations - Initialize(); - } -} - - -//////////////////////////////////////////////////////////// -/// Create the window implementation -//////////////////////////////////////////////////////////// -WindowImplX11::WindowImplX11(VideoMode mode, const std::string& title, unsigned long style) : -myWindow (0), -myInputMethod (NULL), -myInputContext(NULL), -myIsExternal (false), -myAtomClose (0), -myOldVideoMode(-1), -myHiddenCursor(0), -myKeyRepeat (true) -{ - // Open a connection with the X server - myDisplay = XOpenDisplay(NULL); - myScreen = DefaultScreen(myDisplay); - - // Compute position and size - int left, top; - bool fullscreen = (style & Style::Fullscreen) != 0; - if (!fullscreen) - { - left = (DisplayWidth(myDisplay, myScreen) - mode.Width) / 2; - top = (DisplayHeight(myDisplay, myScreen) - mode.Height) / 2; - } - else - { - left = 0; - top = 0; - } - int width = myWidth = mode.Width; - int height = myHeight = mode.Height; - - // Switch to fullscreen if necessary - if (fullscreen) - SwitchToFullscreen(mode); - - // Define the window attributes - XSetWindowAttributes attributes; - attributes.event_mask = eventMask; - attributes.override_redirect = fullscreen; - - // Create the window - myWindow = XCreateWindow(myDisplay, - RootWindow(myDisplay, myScreen), - left, top, - width, height, - 0, - DefaultDepth(myDisplay, myScreen), - InputOutput, - DefaultVisual(myDisplay, myScreen), - CWEventMask | CWOverrideRedirect, &attributes); - if (!myWindow) - { - std::cerr << "Failed to create window" << std::endl; - return; - } - - // Set the window's name - XStoreName(myDisplay, myWindow, title.c_str()); - - // Set the window's style (tell the windows manager to change our window's decorations and functions according to the requested style) - if (!fullscreen) - { - Atom WMHintsAtom = XInternAtom(myDisplay, "_MOTIF_WM_HINTS", false); - if (WMHintsAtom) - { - static const unsigned long MWM_HINTS_FUNCTIONS = 1 << 0; - static const unsigned long MWM_HINTS_DECORATIONS = 1 << 1; - - //static const unsigned long MWM_DECOR_ALL = 1 << 0; - static const unsigned long MWM_DECOR_BORDER = 1 << 1; - static const unsigned long MWM_DECOR_RESIZEH = 1 << 2; - static const unsigned long MWM_DECOR_TITLE = 1 << 3; - static const unsigned long MWM_DECOR_MENU = 1 << 4; - static const unsigned long MWM_DECOR_MINIMIZE = 1 << 5; - static const unsigned long MWM_DECOR_MAXIMIZE = 1 << 6; - - //static const unsigned long MWM_FUNC_ALL = 1 << 0; - static const unsigned long MWM_FUNC_RESIZE = 1 << 1; - static const unsigned long MWM_FUNC_MOVE = 1 << 2; - static const unsigned long MWM_FUNC_MINIMIZE = 1 << 3; - static const unsigned long MWM_FUNC_MAXIMIZE = 1 << 4; - static const unsigned long MWM_FUNC_CLOSE = 1 << 5; - - struct WMHints - { - unsigned long Flags; - unsigned long Functions; - unsigned long Decorations; - long InputMode; - unsigned long State; - }; - - WMHints hints; - hints.Flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; - hints.Decorations = 0; - hints.Functions = 0; - - if (style & Style::Titlebar) - { - hints.Decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU; - hints.Functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE; - } - if (style & Style::Resize) - { - hints.Decorations |= MWM_DECOR_MAXIMIZE | MWM_DECOR_RESIZEH; - hints.Functions |= MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; - } - if (style & Style::Close) - { - hints.Decorations |= 0; - hints.Functions |= MWM_FUNC_CLOSE; - } - - const unsigned char* ptr = reinterpret_cast(&hints); - XChangeProperty(myDisplay, myWindow, WMHintsAtom, WMHintsAtom, 32, PropModeReplace, ptr, 5); - } - - // This is a hack to force some windows managers to disable resizing - if (!(style & Style::Resize)) - { - XSizeHints sizeHints; - sizeHints.flags = PMinSize | PMaxSize; - sizeHints.min_width = sizeHints.max_width = width; - sizeHints.min_height = sizeHints.max_height = height; - XSetWMNormalHints(myDisplay, myWindow, &sizeHints); - } - } - - // Do some common initializations - Initialize(); - - // In fullscreen mode, we must grab keyboard and mouse inputs - if (fullscreen) - { - XGrabPointer(myDisplay, myWindow, true, 0, GrabModeAsync, GrabModeAsync, myWindow, None, CurrentTime); - XGrabKeyboard(myDisplay, myWindow, true, GrabModeAsync, GrabModeAsync, CurrentTime); - } -} - - -//////////////////////////////////////////////////////////// -/// Destructor -//////////////////////////////////////////////////////////// -WindowImplX11::~WindowImplX11() -{ - // Cleanup graphical resources - CleanUp(); - - // Destroy the input context - if (myInputContext) - XDestroyIC(myInputContext); - - // Destroy the window - if (myWindow && !myIsExternal) - { - XDestroyWindow(myDisplay, myWindow); - XFlush(myDisplay); +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include // important to be included first (conflict with None) +#include +#include +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +// Private data +//////////////////////////////////////////////////////////// +namespace +{ + sf::priv::WindowImplX11* fullscreenWindow = NULL; + unsigned long eventMask = FocusChangeMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | + PointerMotionMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | + EnterWindowMask | LeaveWindowMask; + + /// Filter the events received by windows + /// (only allow those matching a specific window) + Bool CheckEvent(::Display*, XEvent* event, XPointer userData) + { + // Just check if the event matches the window + return event->xany.window == reinterpret_cast< ::Window >(userData); + } +} + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +WindowImplX11::WindowImplX11(WindowHandle handle) : +myWindow (0), +myInputMethod (NULL), +myInputContext(NULL), +myIsExternal (true), +myAtomClose (0), +myOldVideoMode(-1), +myHiddenCursor(0), +myKeyRepeat (true) +{ + // Open a connection with the X server + myDisplay = XOpenDisplay(NULL); + myScreen = DefaultScreen(myDisplay); + + // Save the window handle + myWindow = handle; + + if (myWindow) + { + // Get the window size + XWindowAttributes windowAttributes; + if (XGetWindowAttributes(myDisplay, myWindow, &windowAttributes) == 0) + { + std::cerr << "Failed to get the window attributes" << std::endl; + return; + } + myWidth = windowAttributes.width; + myHeight = windowAttributes.height; + + // Make sure the window is listening to all the requiered events + XSelectInput(myDisplay, myWindow, eventMask & ~ButtonPressMask); + + // Do some common initializations + Initialize(); + } +} + + +//////////////////////////////////////////////////////////// +WindowImplX11::WindowImplX11(VideoMode mode, const std::string& title, unsigned long style) : +myWindow (0), +myInputMethod (NULL), +myInputContext(NULL), +myIsExternal (false), +myAtomClose (0), +myOldVideoMode(-1), +myHiddenCursor(0), +myKeyRepeat (true) +{ + // Open a connection with the X server + myDisplay = XOpenDisplay(NULL); + myScreen = DefaultScreen(myDisplay); + + // Compute position and size + int left, top; + bool fullscreen = (style & Style::Fullscreen) != 0; + if (!fullscreen) + { + left = (DisplayWidth(myDisplay, myScreen) - mode.Width) / 2; + top = (DisplayHeight(myDisplay, myScreen) - mode.Height) / 2; + } + else + { + left = 0; + top = 0; + } + int width = myWidth = mode.Width; + int height = myHeight = mode.Height; + + // Switch to fullscreen if necessary + if (fullscreen) + SwitchToFullscreen(mode); + + // Define the window attributes + XSetWindowAttributes attributes; + attributes.event_mask = eventMask; + attributes.override_redirect = fullscreen; + + // Create the window + myWindow = XCreateWindow(myDisplay, + RootWindow(myDisplay, myScreen), + left, top, + width, height, + 0, + DefaultDepth(myDisplay, myScreen), + InputOutput, + DefaultVisual(myDisplay, myScreen), + CWEventMask | CWOverrideRedirect, &attributes); + if (!myWindow) + { + std::cerr << "Failed to create window" << std::endl; + return; + } + + // Set the window's name + XStoreName(myDisplay, myWindow, title.c_str()); + + // Set the window's style (tell the windows manager to change our window's decorations and functions according to the requested style) + if (!fullscreen) + { + Atom WMHintsAtom = XInternAtom(myDisplay, "_MOTIF_WM_HINTS", false); + if (WMHintsAtom) + { + static const unsigned long MWM_HINTS_FUNCTIONS = 1 << 0; + static const unsigned long MWM_HINTS_DECORATIONS = 1 << 1; + + //static const unsigned long MWM_DECOR_ALL = 1 << 0; + static const unsigned long MWM_DECOR_BORDER = 1 << 1; + static const unsigned long MWM_DECOR_RESIZEH = 1 << 2; + static const unsigned long MWM_DECOR_TITLE = 1 << 3; + static const unsigned long MWM_DECOR_MENU = 1 << 4; + static const unsigned long MWM_DECOR_MINIMIZE = 1 << 5; + static const unsigned long MWM_DECOR_MAXIMIZE = 1 << 6; + + //static const unsigned long MWM_FUNC_ALL = 1 << 0; + static const unsigned long MWM_FUNC_RESIZE = 1 << 1; + static const unsigned long MWM_FUNC_MOVE = 1 << 2; + static const unsigned long MWM_FUNC_MINIMIZE = 1 << 3; + static const unsigned long MWM_FUNC_MAXIMIZE = 1 << 4; + static const unsigned long MWM_FUNC_CLOSE = 1 << 5; + + struct WMHints + { + unsigned long Flags; + unsigned long Functions; + unsigned long Decorations; + long InputMode; + unsigned long State; + }; + + WMHints hints; + hints.Flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; + hints.Decorations = 0; + hints.Functions = 0; + + if (style & Style::Titlebar) + { + hints.Decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU; + hints.Functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE; + } + if (style & Style::Resize) + { + hints.Decorations |= MWM_DECOR_MAXIMIZE | MWM_DECOR_RESIZEH; + hints.Functions |= MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; + } + if (style & Style::Close) + { + hints.Decorations |= 0; + hints.Functions |= MWM_FUNC_CLOSE; + } + + const unsigned char* ptr = reinterpret_cast(&hints); + XChangeProperty(myDisplay, myWindow, WMHintsAtom, WMHintsAtom, 32, PropModeReplace, ptr, 5); + } + + // This is a hack to force some windows managers to disable resizing + if (!(style & Style::Resize)) + { + XSizeHints sizeHints; + sizeHints.flags = PMinSize | PMaxSize; + sizeHints.min_width = sizeHints.max_width = width; + sizeHints.min_height = sizeHints.max_height = height; + XSetWMNormalHints(myDisplay, myWindow, &sizeHints); + } + } + + // Do some common initializations + Initialize(); + + // In fullscreen mode, we must grab keyboard and mouse inputs + if (fullscreen) + { + XGrabPointer(myDisplay, myWindow, true, 0, GrabModeAsync, GrabModeAsync, myWindow, None, CurrentTime); + XGrabKeyboard(myDisplay, myWindow, true, GrabModeAsync, GrabModeAsync, CurrentTime); + } +} + + +//////////////////////////////////////////////////////////// +WindowImplX11::~WindowImplX11() +{ + // Cleanup graphical resources + CleanUp(); + + // Destroy the input context + if (myInputContext) + XDestroyIC(myInputContext); + + // Destroy the window + if (myWindow && !myIsExternal) + { + XDestroyWindow(myDisplay, myWindow); + XFlush(myDisplay); } // Close the input method - if (myInputMethod) + if (myInputMethod) XCloseIM(myInputMethod); // Close the connection with the X server - XCloseDisplay(myDisplay); -} + XCloseDisplay(myDisplay); +} - -//////////////////////////////////////////////////////////// -/// Get the display used by the window. -/// This functions is meant to be used internally by ContextGLX. -//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// ::Display* WindowImplX11::GetDisplay() const { return myDisplay; } - - -//////////////////////////////////////////////////////////// -/// /see WindowImpl::GetHandle -//////////////////////////////////////////////////////////// -WindowHandle WindowImplX11::GetHandle() const -{ - return myWindow; -} - - -//////////////////////////////////////////////////////////// -/// /see WindowImpl::ProcessEvents -//////////////////////////////////////////////////////////// -void WindowImplX11::ProcessEvents() -{ - // This function implements a workaround to properly discard - // repeated key events when necessary. The problem is that the - // system's key events policy doesn't match SFML's one: X server will generate - // both repeated KeyPress and KeyRelease events when maintaining a key down, while - // SFML only wants repeated KeyPress events. Thus, we have to: - // - Discard duplicated KeyRelease events when EnableKeyRepeat is true - // - Discard both duplicated KeyPress and KeyRelease events when EnableKeyRepeat is false - - - // Process any event in the queue matching our window - XEvent event; - while (XCheckIfEvent(myDisplay, &event, &CheckEvent, reinterpret_cast(myWindow))) - { - // Detect repeated key events - if ((event.type == KeyPress) || (event.type == KeyRelease)) - { - if (event.xkey.keycode < 256) - { - // To detect if it is a repeated key event, we check the current state of the key. - // - If the state is "down", KeyReleased events must obviously be discarded. - // - KeyPress events are a little bit harder to handle: they depend on the EnableKeyRepeat state, - // and we need to properly forward the first one. - char keys[32]; - XQueryKeymap(myDisplay, keys); - if (keys[event.xkey.keycode >> 3] & (1 << (event.xkey.keycode % 8))) - { - // KeyRelease event + key down = repeated event --> discard - if (event.type == KeyRelease) - { - myLastKeyReleaseEvent = event; - continue; - } - - // KeyPress event + key repeat disabled + matching KeyRelease event = repeated event --> discard - if ((event.type == KeyPress) && !myKeyRepeat && - (myLastKeyReleaseEvent.xkey.keycode == event.xkey.keycode) && - (myLastKeyReleaseEvent.xkey.time == event.xkey.time)) - { - continue; - } - } - } - } - - // Process the event - ProcessEvent(event); - } -} - - -//////////////////////////////////////////////////////////// -/// /see WindowImpl::ShowMouseCursor -//////////////////////////////////////////////////////////// -void WindowImplX11::ShowMouseCursor(bool show) -{ - XDefineCursor(myDisplay, myWindow, show ? None : myHiddenCursor); - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// /see sfWindowImpl::SetCursorPosition -//////////////////////////////////////////////////////////// -void WindowImplX11::SetCursorPosition(unsigned int left, unsigned int top) -{ - XWarpPointer(myDisplay, None, myWindow, 0, 0, 0, 0, left, top); - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// /see sfWindowImpl::SetPosition -//////////////////////////////////////////////////////////// -void WindowImplX11::SetPosition(int left, int top) -{ - XMoveWindow(myDisplay, myWindow, left, top); - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetSize -//////////////////////////////////////////////////////////// -void WindowImplX11::SetSize(unsigned int width, unsigned int height) -{ - XResizeWindow(myDisplay, myWindow, width, height); - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// /see sfWindowImpl::Show -//////////////////////////////////////////////////////////// -void WindowImplX11::Show(bool show) -{ - if (show) - XMapWindow(myDisplay, myWindow); - else - XUnmapWindow(myDisplay, myWindow); - - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// /see sfWindowImpl::EnableKeyRepeat -//////////////////////////////////////////////////////////// -void WindowImplX11::EnableKeyRepeat(bool enabled) -{ - myKeyRepeat = enabled; -} - - -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetIcon -//////////////////////////////////////////////////////////// -void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels) -{ - // X11 wants BGRA pixels : swap red and blue channels - // Note : this memory will never be freed, but it seems to cause a bug on exit if I do so - Uint8* iconPixels = new Uint8[width * height * 4]; - for (std::size_t i = 0; i < width * height; ++i) - { - iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; - iconPixels[i * 4 + 1] = pixels[i * 4 + 1]; - iconPixels[i * 4 + 2] = pixels[i * 4 + 0]; - iconPixels[i * 4 + 3] = pixels[i * 4 + 3]; - } - - // Create the icon pixmap - Visual* defVisual = DefaultVisual(myDisplay, myScreen); - unsigned int defDepth = DefaultDepth(myDisplay, myScreen); - XImage* iconImage = XCreateImage(myDisplay, defVisual, defDepth, ZPixmap, 0, (char*)iconPixels, width, height, 32, 0); - if (!iconImage) - { - std::cerr << "Failed to set the window's icon" << std::endl; - return; - } - Pixmap iconPixmap = XCreatePixmap(myDisplay, RootWindow(myDisplay, myScreen), width, height, defDepth); - XGCValues values; - GC iconGC = XCreateGC(myDisplay, iconPixmap, 0, &values); - XPutImage(myDisplay, iconPixmap, iconGC, iconImage, 0, 0, 0, 0, width, height); - XFreeGC(myDisplay, iconGC); - XDestroyImage(iconImage); - - // Create the mask pixmap (must have 1 bit depth) - std::size_t pitch = (width + 7) / 8; - static std::vector maskPixels(pitch * height, 0); - for (std::size_t j = 0; j < height; ++j) - { - for (std::size_t i = 0; i < pitch; ++i) - { - for (std::size_t k = 0; k < 8; ++k) - { - if (i * 8 + k < width) - { - Uint8 opacity = (pixels[(i * 8 + k + j * width) * 4 + 3] > 0) ? 1 : 0; - maskPixels[i + j * pitch] |= (opacity << k); - } - } - } - } - Pixmap maskPixmap = XCreatePixmapFromBitmapData(myDisplay, myWindow, (char*)&maskPixels[0], width, height, 1, 0, 1); - - // Send our new icon to the window through the WMHints - XWMHints* hints = XAllocWMHints(); - hints->flags = IconPixmapHint | IconMaskHint; - hints->icon_pixmap = iconPixmap; - hints->icon_mask = maskPixmap; - XSetWMHints(myDisplay, myWindow, hints); - XFree(hints); - - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// Switch to fullscreen mode -//////////////////////////////////////////////////////////// -void WindowImplX11::SwitchToFullscreen(const VideoMode& mode) -{ - // Check if the XRandR extension is present - int version; - if (XQueryExtension(myDisplay, "RANDR", &version, &version, &version)) - { - // Get the current configuration - XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen)); - if (config) - { - // Get the current rotation - Rotation currentRotation; - myOldVideoMode = XRRConfigCurrentConfiguration(config, ¤tRotation); - - // Get the available screen sizes - int nbSizes; - XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); - if (sizes && (nbSizes > 0)) - { - // Search a matching size - for (int i = 0; i < nbSizes; ++i) - { - if ((sizes[i].width == static_cast(mode.Width)) && (sizes[i].height == static_cast(mode.Height))) - { - // Switch to fullscreen mode - XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), i, currentRotation, CurrentTime); - - // Set "this" as the current fullscreen window - fullscreenWindow = this; - break; - } - } - } - - // Free the configuration instance - XRRFreeScreenConfigInfo(config); - } - else - { - // Failed to get the screen configuration - std::cerr << "Failed to get the current screen configuration for fullscreen mode, switching to window mode" << std::endl; - } - } - else - { - // XRandr extension is not supported : we cannot use fullscreen mode - std::cerr << "Fullscreen is not supported, switching to window mode" << std::endl; - } -} - - -//////////////////////////////////////////////////////////// -/// Do some common initializations after the window has been created -//////////////////////////////////////////////////////////// -void WindowImplX11::Initialize() -{ - // Make sure the "last key release" is initialized with invalid values - myLastKeyReleaseEvent.type = -1; - - // Get the atom defining the close event - myAtomClose = XInternAtom(myDisplay, "WM_DELETE_WINDOW", false); - XSetWMProtocols(myDisplay, myWindow, &myAtomClose, 1); - - // Create the input context - myInputMethod = XOpenIM(myDisplay, NULL, NULL, NULL); - if (myInputMethod) - { - myInputContext = XCreateIC(myInputMethod, - XNClientWindow, myWindow, - XNFocusWindow, myWindow, - XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - NULL); + + +//////////////////////////////////////////////////////////// +WindowHandle WindowImplX11::GetHandle() const +{ + return myWindow; +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::ProcessEvents() +{ + // This function implements a workaround to properly discard + // repeated key events when necessary. The problem is that the + // system's key events policy doesn't match SFML's one: X server will generate + // both repeated KeyPress and KeyRelease events when maintaining a key down, while + // SFML only wants repeated KeyPress events. Thus, we have to: + // - Discard duplicated KeyRelease events when EnableKeyRepeat is true + // - Discard both duplicated KeyPress and KeyRelease events when EnableKeyRepeat is false + + + // Process any event in the queue matching our window + XEvent event; + while (XCheckIfEvent(myDisplay, &event, &CheckEvent, reinterpret_cast(myWindow))) + { + // Detect repeated key events + if ((event.type == KeyPress) || (event.type == KeyRelease)) + { + if (event.xkey.keycode < 256) + { + // To detect if it is a repeated key event, we check the current state of the key. + // - If the state is "down", KeyReleased events must obviously be discarded. + // - KeyPress events are a little bit harder to handle: they depend on the EnableKeyRepeat state, + // and we need to properly forward the first one. + char keys[32]; + XQueryKeymap(myDisplay, keys); + if (keys[event.xkey.keycode >> 3] & (1 << (event.xkey.keycode % 8))) + { + // KeyRelease event + key down = repeated event --> discard + if (event.type == KeyRelease) + { + myLastKeyReleaseEvent = event; + continue; + } + + // KeyPress event + key repeat disabled + matching KeyRelease event = repeated event --> discard + if ((event.type == KeyPress) && !myKeyRepeat && + (myLastKeyReleaseEvent.xkey.keycode == event.xkey.keycode) && + (myLastKeyReleaseEvent.xkey.time == event.xkey.time)) + { + continue; + } + } + } + } + + // Process the event + ProcessEvent(event); + } +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::ShowMouseCursor(bool show) +{ + XDefineCursor(myDisplay, myWindow, show ? None : myHiddenCursor); + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::SetCursorPosition(unsigned int left, unsigned int top) +{ + XWarpPointer(myDisplay, None, myWindow, 0, 0, 0, 0, left, top); + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::SetPosition(int left, int top) +{ + XMoveWindow(myDisplay, myWindow, left, top); + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::SetSize(unsigned int width, unsigned int height) +{ + XResizeWindow(myDisplay, myWindow, width, height); + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::Show(bool show) +{ + if (show) + XMapWindow(myDisplay, myWindow); + else + XUnmapWindow(myDisplay, myWindow); + + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::EnableKeyRepeat(bool enabled) +{ + myKeyRepeat = enabled; +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels) +{ + // X11 wants BGRA pixels : swap red and blue channels + // Note : this memory will never be freed, but it seems to cause a bug on exit if I do so + Uint8* iconPixels = new Uint8[width * height * 4]; + for (std::size_t i = 0; i < width * height; ++i) + { + iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; + iconPixels[i * 4 + 1] = pixels[i * 4 + 1]; + iconPixels[i * 4 + 2] = pixels[i * 4 + 0]; + iconPixels[i * 4 + 3] = pixels[i * 4 + 3]; + } + + // Create the icon pixmap + Visual* defVisual = DefaultVisual(myDisplay, myScreen); + unsigned int defDepth = DefaultDepth(myDisplay, myScreen); + XImage* iconImage = XCreateImage(myDisplay, defVisual, defDepth, ZPixmap, 0, (char*)iconPixels, width, height, 32, 0); + if (!iconImage) + { + std::cerr << "Failed to set the window's icon" << std::endl; + return; + } + Pixmap iconPixmap = XCreatePixmap(myDisplay, RootWindow(myDisplay, myScreen), width, height, defDepth); + XGCValues values; + GC iconGC = XCreateGC(myDisplay, iconPixmap, 0, &values); + XPutImage(myDisplay, iconPixmap, iconGC, iconImage, 0, 0, 0, 0, width, height); + XFreeGC(myDisplay, iconGC); + XDestroyImage(iconImage); + + // Create the mask pixmap (must have 1 bit depth) + std::size_t pitch = (width + 7) / 8; + static std::vector maskPixels(pitch * height, 0); + for (std::size_t j = 0; j < height; ++j) + { + for (std::size_t i = 0; i < pitch; ++i) + { + for (std::size_t k = 0; k < 8; ++k) + { + if (i * 8 + k < width) + { + Uint8 opacity = (pixels[(i * 8 + k + j * width) * 4 + 3] > 0) ? 1 : 0; + maskPixels[i + j * pitch] |= (opacity << k); + } + } + } + } + Pixmap maskPixmap = XCreatePixmapFromBitmapData(myDisplay, myWindow, (char*)&maskPixels[0], width, height, 1, 0, 1); + + // Send our new icon to the window through the WMHints + XWMHints* hints = XAllocWMHints(); + hints->flags = IconPixmapHint | IconMaskHint; + hints->icon_pixmap = iconPixmap; + hints->icon_mask = maskPixmap; + XSetWMHints(myDisplay, myWindow, hints); + XFree(hints); + + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::SwitchToFullscreen(const VideoMode& mode) +{ + // Check if the XRandR extension is present + int version; + if (XQueryExtension(myDisplay, "RANDR", &version, &version, &version)) + { + // Get the current configuration + XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen)); + if (config) + { + // Get the current rotation + Rotation currentRotation; + myOldVideoMode = XRRConfigCurrentConfiguration(config, ¤tRotation); + + // Get the available screen sizes + int nbSizes; + XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); + if (sizes && (nbSizes > 0)) + { + // Search a matching size + for (int i = 0; i < nbSizes; ++i) + { + if ((sizes[i].width == static_cast(mode.Width)) && (sizes[i].height == static_cast(mode.Height))) + { + // Switch to fullscreen mode + XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), i, currentRotation, CurrentTime); + + // Set "this" as the current fullscreen window + fullscreenWindow = this; + break; + } + } + } + + // Free the configuration instance + XRRFreeScreenConfigInfo(config); + } + else + { + // Failed to get the screen configuration + std::cerr << "Failed to get the current screen configuration for fullscreen mode, switching to window mode" << std::endl; + } + } + else + { + // XRandr extension is not supported : we cannot use fullscreen mode + std::cerr << "Fullscreen is not supported, switching to window mode" << std::endl; + } +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::Initialize() +{ + // Make sure the "last key release" is initialized with invalid values + myLastKeyReleaseEvent.type = -1; + + // Get the atom defining the close event + myAtomClose = XInternAtom(myDisplay, "WM_DELETE_WINDOW", false); + XSetWMProtocols(myDisplay, myWindow, &myAtomClose, 1); + + // Create the input context + myInputMethod = XOpenIM(myDisplay, NULL, NULL, NULL); + if (myInputMethod) + { + myInputContext = XCreateIC(myInputMethod, + XNClientWindow, myWindow, + XNFocusWindow, myWindow, + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + NULL); } else { myInputContext = NULL; - } - if (!myInputContext) - std::cerr << "Failed to create input context for window -- TextEntered event won't be able to return unicode" << std::endl; - - // Show the window - XMapWindow(myDisplay, myWindow); - XFlush(myDisplay); - - // Create the hiden cursor - CreateHiddenCursor(); - - // Flush the commands queue - XFlush(myDisplay); -} - - -//////////////////////////////////////////////////////////// -/// Create a transparent mouse cursor -//////////////////////////////////////////////////////////// -void WindowImplX11::CreateHiddenCursor() -{ - // Create the cursor's pixmap (1x1 pixels) - Pixmap cursorPixmap = XCreatePixmap(myDisplay, myWindow, 1, 1, 1); - GC graphicsContext = XCreateGC(myDisplay, cursorPixmap, 0, NULL); - XDrawPoint(myDisplay, cursorPixmap, graphicsContext, 0, 0); - XFreeGC(myDisplay, graphicsContext); - - // Create the cursor, using the pixmap as both the shape and the mask of the cursor - XColor color; - color.flags = DoRed | DoGreen | DoBlue; - color.red = color.blue = color.green = 0; - myHiddenCursor = XCreatePixmapCursor(myDisplay, cursorPixmap, cursorPixmap, &color, &color, 0, 0); - - // We don't need the pixmap any longer, free it - XFreePixmap(myDisplay, cursorPixmap); -} - - -//////////////////////////////////////////////////////////// -/// Cleanup graphical resources attached to the window -//////////////////////////////////////////////////////////// -void WindowImplX11::CleanUp() -{ - // Restore the previous video mode (in case we were running in fullscreen) - if (fullscreenWindow == this) - { - // Get current screen info - XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen)); - if (config) - { - // Get the current rotation - Rotation currentRotation; - XRRConfigCurrentConfiguration(config, ¤tRotation); - - // Reset the video mode - XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), myOldVideoMode, currentRotation, CurrentTime); - - // Free the configuration instance - XRRFreeScreenConfigInfo(config); - } - - // Reset the fullscreen window - fullscreenWindow = NULL; - } - - // Unhide the mouse cursor (in case it was hidden) - ShowMouseCursor(true); -} - - -//////////////////////////////////////////////////////////// -/// Process an incoming event from the window -//////////////////////////////////////////////////////////// -void WindowImplX11::ProcessEvent(XEvent windowEvent) -{ - switch (windowEvent.type) - { - // Destroy event - case DestroyNotify : - { - // The window is about to be destroyed : we must cleanup resources - CleanUp(); - break; - } - - // Gain focus event - case FocusIn : - { - // Update the input context - if (myInputContext) - XSetICFocus(myInputContext); - - Event event; - event.Type = Event::GainedFocus; - SendEvent(event); - break; - } - - // Lost focus event - case FocusOut : - { - // Update the input context - if (myInputContext) - XUnsetICFocus(myInputContext); - - Event event; - event.Type = Event::LostFocus; - SendEvent(event); - break; - } - - // Resize event - case ConfigureNotify : - { - if ((windowEvent.xconfigure.width != static_cast(myWidth)) || (windowEvent.xconfigure.height != static_cast(myHeight))) - { - myWidth = windowEvent.xconfigure.width; - myHeight = windowEvent.xconfigure.height; - - Event event; - event.Type = Event::Resized; - event.Size.Width = myWidth; - event.Size.Height = myHeight; - SendEvent(event); - } - break; - } - - // Close event - case ClientMessage : - { - if ((windowEvent.xclient.format == 32) && (windowEvent.xclient.data.l[0]) == static_cast(myAtomClose)) - { - Event event; - event.Type = Event::Closed; - SendEvent(event); - } - break; - } - - // Key down event - case KeyPress : - { - // Get the keysym of the key that has been pressed - static XComposeStatus keyboard; - char buffer[32]; - KeySym symbol; - XLookupString(&windowEvent.xkey, buffer, sizeof(buffer), &symbol, &keyboard); - - // Fill the event parameters - Event event; - event.Type = Event::KeyPressed; - event.Key.Code = KeysymToSF(symbol); - event.Key.Alt = windowEvent.xkey.state & Mod1Mask; - event.Key.Control = windowEvent.xkey.state & ControlMask; - event.Key.Shift = windowEvent.xkey.state & ShiftMask; - SendEvent(event); - - // Generate a TextEntered event - if (!XFilterEvent(&windowEvent, None)) - { - #ifdef X_HAVE_UTF8_STRING - if (myInputContext) - { - Status status; - Uint8 keyBuffer[16]; - int length = Xutf8LookupString(myInputContext, &windowEvent.xkey, reinterpret_cast(keyBuffer), sizeof(keyBuffer), NULL, &status); - if (length > 0) - { - Uint32 unicode[2]; // just in case, but 1 character should be enough - const Uint32* end = Unicode::UTF8ToUTF32(keyBuffer, keyBuffer + length, unicode); - - if (end > unicode) - { - Event textEvent; - textEvent.Type = Event::TextEntered; - textEvent.Text.Unicode = unicode[0]; - SendEvent(textEvent); - } - } - } - else - #endif - { - static XComposeStatus status; - char keyBuffer[16]; - if (XLookupString(&windowEvent.xkey, keyBuffer, sizeof(keyBuffer), NULL, &status)) - { - Event textEvent; - textEvent.Type = Event::TextEntered; - textEvent.Text.Unicode = static_cast(keyBuffer[0]); - SendEvent(textEvent); - } - } - } - - break; - } - - // Key up event - case KeyRelease : - { - // Get the keysym of the key that has been pressed - char buffer[32]; - KeySym symbol; - XLookupString(&windowEvent.xkey, buffer, 32, &symbol, NULL); - - // Fill the event parameters - Event event; - event.Type = Event::KeyReleased; - event.Key.Code = KeysymToSF(symbol); - event.Key.Alt = windowEvent.xkey.state & Mod1Mask; - event.Key.Control = windowEvent.xkey.state & ControlMask; - event.Key.Shift = windowEvent.xkey.state & ShiftMask; - SendEvent(event); - - break; - } - - // Mouse button pressed - case ButtonPress : - { - unsigned int button = windowEvent.xbutton.button; - if ((button == Button1) || (button == Button2) || (button == Button3) || (button == 8) || (button == 9)) - { - Event event; - event.Type = Event::MouseButtonPressed; - event.MouseButton.X = windowEvent.xbutton.x; - event.MouseButton.Y = windowEvent.xbutton.y; - switch (button) - { - case Button1 : event.MouseButton.Button = Mouse::Left; break; - case Button2 : event.MouseButton.Button = Mouse::Middle; break; - case Button3 : event.MouseButton.Button = Mouse::Right; break; - case 8 : event.MouseButton.Button = Mouse::XButton1; break; - case 9 : event.MouseButton.Button = Mouse::XButton2; break; - } - SendEvent(event); - } - break; - } - - // Mouse button released - case ButtonRelease : - { - unsigned int button = windowEvent.xbutton.button; - if ((button == Button1) || (button == Button2) || (button == Button3) || (button == 8) || (button == 9)) - { - Event event; - event.Type = Event::MouseButtonReleased; - event.MouseButton.X = windowEvent.xbutton.x; - event.MouseButton.Y = windowEvent.xbutton.y; - switch (button) - { - case Button1 : event.MouseButton.Button = Mouse::Left; break; - case Button2 : event.MouseButton.Button = Mouse::Middle; break; - case Button3 : event.MouseButton.Button = Mouse::Right; break; - case 8 : event.MouseButton.Button = Mouse::XButton1; break; - case 9 : event.MouseButton.Button = Mouse::XButton2; break; - } - SendEvent(event); - } - else if ((button == Button4) || (button == Button5)) - { - Event event; - event.Type = Event::MouseWheelMoved; - event.MouseWheel.Delta = windowEvent.xbutton.button == Button4 ? 1 : -1; - SendEvent(event); - } - break; - } - - // Mouse moved - case MotionNotify : - { - Event event; - event.Type = Event::MouseMoved; - event.MouseMove.X = windowEvent.xmotion.x; - event.MouseMove.Y = windowEvent.xmotion.y; - SendEvent(event); - break; - } - - // Mouse entered - case EnterNotify : - { - Event event; - event.Type = Event::MouseEntered; - SendEvent(event); - break; - } - - // Mouse left - case LeaveNotify : - { - Event event; - event.Type = Event::MouseLeft; - SendEvent(event); - break; - } - } -} - - -//////////////////////////////////////////////////////////// -/// Convert a X11 keysym to SFML key code -//////////////////////////////////////////////////////////// -Key::Code WindowImplX11::KeysymToSF(KeySym symbol) -{ - // First convert to uppercase (to avoid dealing with two different keysyms for the same key) - KeySym lower, key; - XConvertCase(symbol, &lower, &key); - - switch (key) - { - case XK_Shift_L : return Key::LShift; - case XK_Shift_R : return Key::RShift; - case XK_Control_L : return Key::LControl; - case XK_Control_R : return Key::RControl; - case XK_Alt_L : return Key::LAlt; - case XK_Alt_R : return Key::RAlt; - case XK_Super_L : return Key::LSystem; - case XK_Super_R : return Key::RSystem; - case XK_Menu : return Key::Menu; - case XK_Escape : return Key::Escape; - case XK_semicolon : return Key::SemiColon; - case XK_slash : return Key::Slash; - case XK_equal : return Key::Equal; - case XK_minus : return Key::Dash; - case XK_bracketleft : return Key::LBracket; - case XK_bracketright : return Key::RBracket; - case XK_comma : return Key::Comma; - case XK_period : return Key::Period; - case XK_dead_acute : return Key::Quote; - case XK_backslash : return Key::BackSlash; - case XK_dead_grave : return Key::Tilde; - case XK_space : return Key::Space; - case XK_Return : return Key::Return; - case XK_KP_Enter : return Key::Return; - case XK_BackSpace : return Key::Back; - case XK_Tab : return Key::Tab; - case XK_Prior : return Key::PageUp; - case XK_Next : return Key::PageDown; - case XK_End : return Key::End; - case XK_Home : return Key::Home; - case XK_Insert : return Key::Insert; - case XK_Delete : return Key::Delete; - case XK_KP_Add : return Key::Add; - case XK_KP_Subtract : return Key::Subtract; - case XK_KP_Multiply : return Key::Multiply; - case XK_KP_Divide : return Key::Divide; - case XK_Pause : return Key::Pause; - case XK_F1 : return Key::F1; - case XK_F2 : return Key::F2; - case XK_F3 : return Key::F3; - case XK_F4 : return Key::F4; - case XK_F5 : return Key::F5; - case XK_F6 : return Key::F6; - case XK_F7 : return Key::F7; - case XK_F8 : return Key::F8; - case XK_F9 : return Key::F9; - case XK_F10 : return Key::F10; - case XK_F11 : return Key::F11; - case XK_F12 : return Key::F12; - case XK_F13 : return Key::F13; - case XK_F14 : return Key::F14; - case XK_F15 : return Key::F15; - case XK_Left : return Key::Left; - case XK_Right : return Key::Right; - case XK_Up : return Key::Up; - case XK_Down : return Key::Down; - case XK_KP_0 : return Key::Numpad0; - case XK_KP_1 : return Key::Numpad1; - case XK_KP_2 : return Key::Numpad2; - case XK_KP_3 : return Key::Numpad3; - case XK_KP_4 : return Key::Numpad4; - case XK_KP_5 : return Key::Numpad5; - case XK_KP_6 : return Key::Numpad6; - case XK_KP_7 : return Key::Numpad7; - case XK_KP_8 : return Key::Numpad8; - case XK_KP_9 : return Key::Numpad9; - case XK_A : return Key::A; - case XK_Z : return Key::Z; - case XK_E : return Key::E; - case XK_R : return Key::R; - case XK_T : return Key::T; - case XK_Y : return Key::Y; - case XK_U : return Key::U; - case XK_I : return Key::I; - case XK_O : return Key::O; - case XK_P : return Key::P; - case XK_Q : return Key::Q; - case XK_S : return Key::S; - case XK_D : return Key::D; - case XK_F : return Key::F; - case XK_G : return Key::G; - case XK_H : return Key::H; - case XK_J : return Key::J; - case XK_K : return Key::K; - case XK_L : return Key::L; - case XK_M : return Key::M; - case XK_W : return Key::W; - case XK_X : return Key::X; - case XK_C : return Key::C; - case XK_V : return Key::V; - case XK_B : return Key::B; - case XK_N : return Key::N; - case XK_0 : return Key::Num0; - case XK_1 : return Key::Num1; - case XK_2 : return Key::Num2; - case XK_3 : return Key::Num3; - case XK_4 : return Key::Num4; - case XK_5 : return Key::Num5; - case XK_6 : return Key::Num6; - case XK_7 : return Key::Num7; - case XK_8 : return Key::Num8; - case XK_9 : return Key::Num9; - } - - return Key::Code(0); -} - -} // namespace priv - -} // namespace sf + } + if (!myInputContext) + std::cerr << "Failed to create input context for window -- TextEntered event won't be able to return unicode" << std::endl; + + // Show the window + XMapWindow(myDisplay, myWindow); + XFlush(myDisplay); + + // Create the hiden cursor + CreateHiddenCursor(); + + // Flush the commands queue + XFlush(myDisplay); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::CreateHiddenCursor() +{ + // Create the cursor's pixmap (1x1 pixels) + Pixmap cursorPixmap = XCreatePixmap(myDisplay, myWindow, 1, 1, 1); + GC graphicsContext = XCreateGC(myDisplay, cursorPixmap, 0, NULL); + XDrawPoint(myDisplay, cursorPixmap, graphicsContext, 0, 0); + XFreeGC(myDisplay, graphicsContext); + + // Create the cursor, using the pixmap as both the shape and the mask of the cursor + XColor color; + color.flags = DoRed | DoGreen | DoBlue; + color.red = color.blue = color.green = 0; + myHiddenCursor = XCreatePixmapCursor(myDisplay, cursorPixmap, cursorPixmap, &color, &color, 0, 0); + + // We don't need the pixmap any longer, free it + XFreePixmap(myDisplay, cursorPixmap); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::CleanUp() +{ + // Restore the previous video mode (in case we were running in fullscreen) + if (fullscreenWindow == this) + { + // Get current screen info + XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen)); + if (config) + { + // Get the current rotation + Rotation currentRotation; + XRRConfigCurrentConfiguration(config, ¤tRotation); + + // Reset the video mode + XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), myOldVideoMode, currentRotation, CurrentTime); + + // Free the configuration instance + XRRFreeScreenConfigInfo(config); + } + + // Reset the fullscreen window + fullscreenWindow = NULL; + } + + // Unhide the mouse cursor (in case it was hidden) + ShowMouseCursor(true); +} + + +//////////////////////////////////////////////////////////// +void WindowImplX11::ProcessEvent(XEvent windowEvent) +{ + switch (windowEvent.type) + { + // Destroy event + case DestroyNotify : + { + // The window is about to be destroyed : we must cleanup resources + CleanUp(); + break; + } + + // Gain focus event + case FocusIn : + { + // Update the input context + if (myInputContext) + XSetICFocus(myInputContext); + + Event event; + event.Type = Event::GainedFocus; + SendEvent(event); + break; + } + + // Lost focus event + case FocusOut : + { + // Update the input context + if (myInputContext) + XUnsetICFocus(myInputContext); + + Event event; + event.Type = Event::LostFocus; + SendEvent(event); + break; + } + + // Resize event + case ConfigureNotify : + { + if ((windowEvent.xconfigure.width != static_cast(myWidth)) || (windowEvent.xconfigure.height != static_cast(myHeight))) + { + myWidth = windowEvent.xconfigure.width; + myHeight = windowEvent.xconfigure.height; + + Event event; + event.Type = Event::Resized; + event.Size.Width = myWidth; + event.Size.Height = myHeight; + SendEvent(event); + } + break; + } + + // Close event + case ClientMessage : + { + if ((windowEvent.xclient.format == 32) && (windowEvent.xclient.data.l[0]) == static_cast(myAtomClose)) + { + Event event; + event.Type = Event::Closed; + SendEvent(event); + } + break; + } + + // Key down event + case KeyPress : + { + // Get the keysym of the key that has been pressed + static XComposeStatus keyboard; + char buffer[32]; + KeySym symbol; + XLookupString(&windowEvent.xkey, buffer, sizeof(buffer), &symbol, &keyboard); + + // Fill the event parameters + Event event; + event.Type = Event::KeyPressed; + event.Key.Code = KeysymToSF(symbol); + event.Key.Alt = windowEvent.xkey.state & Mod1Mask; + event.Key.Control = windowEvent.xkey.state & ControlMask; + event.Key.Shift = windowEvent.xkey.state & ShiftMask; + SendEvent(event); + + // Generate a TextEntered event + if (!XFilterEvent(&windowEvent, None)) + { + #ifdef X_HAVE_UTF8_STRING + if (myInputContext) + { + Status status; + Uint8 keyBuffer[16]; + int length = Xutf8LookupString(myInputContext, &windowEvent.xkey, reinterpret_cast(keyBuffer), sizeof(keyBuffer), NULL, &status); + if (length > 0) + { + Uint32 unicode[2]; // just in case, but 1 character should be enough + const Uint32* end = Unicode::UTF8ToUTF32(keyBuffer, keyBuffer + length, unicode); + + if (end > unicode) + { + Event textEvent; + textEvent.Type = Event::TextEntered; + textEvent.Text.Unicode = unicode[0]; + SendEvent(textEvent); + } + } + } + else + #endif + { + static XComposeStatus status; + char keyBuffer[16]; + if (XLookupString(&windowEvent.xkey, keyBuffer, sizeof(keyBuffer), NULL, &status)) + { + Event textEvent; + textEvent.Type = Event::TextEntered; + textEvent.Text.Unicode = static_cast(keyBuffer[0]); + SendEvent(textEvent); + } + } + } + + break; + } + + // Key up event + case KeyRelease : + { + // Get the keysym of the key that has been pressed + char buffer[32]; + KeySym symbol; + XLookupString(&windowEvent.xkey, buffer, 32, &symbol, NULL); + + // Fill the event parameters + Event event; + event.Type = Event::KeyReleased; + event.Key.Code = KeysymToSF(symbol); + event.Key.Alt = windowEvent.xkey.state & Mod1Mask; + event.Key.Control = windowEvent.xkey.state & ControlMask; + event.Key.Shift = windowEvent.xkey.state & ShiftMask; + SendEvent(event); + + break; + } + + // Mouse button pressed + case ButtonPress : + { + unsigned int button = windowEvent.xbutton.button; + if ((button == Button1) || (button == Button2) || (button == Button3) || (button == 8) || (button == 9)) + { + Event event; + event.Type = Event::MouseButtonPressed; + event.MouseButton.X = windowEvent.xbutton.x; + event.MouseButton.Y = windowEvent.xbutton.y; + switch (button) + { + case Button1 : event.MouseButton.Button = Mouse::Left; break; + case Button2 : event.MouseButton.Button = Mouse::Middle; break; + case Button3 : event.MouseButton.Button = Mouse::Right; break; + case 8 : event.MouseButton.Button = Mouse::XButton1; break; + case 9 : event.MouseButton.Button = Mouse::XButton2; break; + } + SendEvent(event); + } + break; + } + + // Mouse button released + case ButtonRelease : + { + unsigned int button = windowEvent.xbutton.button; + if ((button == Button1) || (button == Button2) || (button == Button3) || (button == 8) || (button == 9)) + { + Event event; + event.Type = Event::MouseButtonReleased; + event.MouseButton.X = windowEvent.xbutton.x; + event.MouseButton.Y = windowEvent.xbutton.y; + switch (button) + { + case Button1 : event.MouseButton.Button = Mouse::Left; break; + case Button2 : event.MouseButton.Button = Mouse::Middle; break; + case Button3 : event.MouseButton.Button = Mouse::Right; break; + case 8 : event.MouseButton.Button = Mouse::XButton1; break; + case 9 : event.MouseButton.Button = Mouse::XButton2; break; + } + SendEvent(event); + } + else if ((button == Button4) || (button == Button5)) + { + Event event; + event.Type = Event::MouseWheelMoved; + event.MouseWheel.Delta = windowEvent.xbutton.button == Button4 ? 1 : -1; + SendEvent(event); + } + break; + } + + // Mouse moved + case MotionNotify : + { + Event event; + event.Type = Event::MouseMoved; + event.MouseMove.X = windowEvent.xmotion.x; + event.MouseMove.Y = windowEvent.xmotion.y; + SendEvent(event); + break; + } + + // Mouse entered + case EnterNotify : + { + Event event; + event.Type = Event::MouseEntered; + SendEvent(event); + break; + } + + // Mouse left + case LeaveNotify : + { + Event event; + event.Type = Event::MouseLeft; + SendEvent(event); + break; + } + } +} + + +//////////////////////////////////////////////////////////// +Key::Code WindowImplX11::KeysymToSF(KeySym symbol) +{ + // First convert to uppercase (to avoid dealing with two different keysyms for the same key) + KeySym lower, key; + XConvertCase(symbol, &lower, &key); + + switch (key) + { + case XK_Shift_L : return Key::LShift; + case XK_Shift_R : return Key::RShift; + case XK_Control_L : return Key::LControl; + case XK_Control_R : return Key::RControl; + case XK_Alt_L : return Key::LAlt; + case XK_Alt_R : return Key::RAlt; + case XK_Super_L : return Key::LSystem; + case XK_Super_R : return Key::RSystem; + case XK_Menu : return Key::Menu; + case XK_Escape : return Key::Escape; + case XK_semicolon : return Key::SemiColon; + case XK_slash : return Key::Slash; + case XK_equal : return Key::Equal; + case XK_minus : return Key::Dash; + case XK_bracketleft : return Key::LBracket; + case XK_bracketright : return Key::RBracket; + case XK_comma : return Key::Comma; + case XK_period : return Key::Period; + case XK_dead_acute : return Key::Quote; + case XK_backslash : return Key::BackSlash; + case XK_dead_grave : return Key::Tilde; + case XK_space : return Key::Space; + case XK_Return : return Key::Return; + case XK_KP_Enter : return Key::Return; + case XK_BackSpace : return Key::Back; + case XK_Tab : return Key::Tab; + case XK_Prior : return Key::PageUp; + case XK_Next : return Key::PageDown; + case XK_End : return Key::End; + case XK_Home : return Key::Home; + case XK_Insert : return Key::Insert; + case XK_Delete : return Key::Delete; + case XK_KP_Add : return Key::Add; + case XK_KP_Subtract : return Key::Subtract; + case XK_KP_Multiply : return Key::Multiply; + case XK_KP_Divide : return Key::Divide; + case XK_Pause : return Key::Pause; + case XK_F1 : return Key::F1; + case XK_F2 : return Key::F2; + case XK_F3 : return Key::F3; + case XK_F4 : return Key::F4; + case XK_F5 : return Key::F5; + case XK_F6 : return Key::F6; + case XK_F7 : return Key::F7; + case XK_F8 : return Key::F8; + case XK_F9 : return Key::F9; + case XK_F10 : return Key::F10; + case XK_F11 : return Key::F11; + case XK_F12 : return Key::F12; + case XK_F13 : return Key::F13; + case XK_F14 : return Key::F14; + case XK_F15 : return Key::F15; + case XK_Left : return Key::Left; + case XK_Right : return Key::Right; + case XK_Up : return Key::Up; + case XK_Down : return Key::Down; + case XK_KP_0 : return Key::Numpad0; + case XK_KP_1 : return Key::Numpad1; + case XK_KP_2 : return Key::Numpad2; + case XK_KP_3 : return Key::Numpad3; + case XK_KP_4 : return Key::Numpad4; + case XK_KP_5 : return Key::Numpad5; + case XK_KP_6 : return Key::Numpad6; + case XK_KP_7 : return Key::Numpad7; + case XK_KP_8 : return Key::Numpad8; + case XK_KP_9 : return Key::Numpad9; + case XK_A : return Key::A; + case XK_Z : return Key::Z; + case XK_E : return Key::E; + case XK_R : return Key::R; + case XK_T : return Key::T; + case XK_Y : return Key::Y; + case XK_U : return Key::U; + case XK_I : return Key::I; + case XK_O : return Key::O; + case XK_P : return Key::P; + case XK_Q : return Key::Q; + case XK_S : return Key::S; + case XK_D : return Key::D; + case XK_F : return Key::F; + case XK_G : return Key::G; + case XK_H : return Key::H; + case XK_J : return Key::J; + case XK_K : return Key::K; + case XK_L : return Key::L; + case XK_M : return Key::M; + case XK_W : return Key::W; + case XK_X : return Key::X; + case XK_C : return Key::C; + case XK_V : return Key::V; + case XK_B : return Key::B; + case XK_N : return Key::N; + case XK_0 : return Key::Num0; + case XK_1 : return Key::Num1; + case XK_2 : return Key::Num2; + case XK_3 : return Key::Num3; + case XK_4 : return Key::Num4; + case XK_5 : return Key::Num5; + case XK_6 : return Key::Num6; + case XK_7 : return Key::Num7; + case XK_8 : return Key::Num8; + case XK_9 : return Key::Num9; + } + + return Key::Code(0); +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Linux/WindowImplX11.hpp b/src/SFML/Window/Linux/WindowImplX11.hpp index 8065349eb..0c8a4ca90 100644 --- a/src/SFML/Window/Linux/WindowImplX11.hpp +++ b/src/SFML/Window/Linux/WindowImplX11.hpp @@ -1,203 +1,226 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_WINDOWIMPLX11_HPP -#define SFML_WINDOWIMPLX11_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// WindowImplX11 is the Linux (X11) implementation of WindowImpl -//////////////////////////////////////////////////////////// -class WindowImplX11 : public WindowImpl -{ -public : - - //////////////////////////////////////////////////////////// - /// Construct the window implementation from an existing control - /// - /// \param handle : Platform-specific handle of the control - /// - //////////////////////////////////////////////////////////// - WindowImplX11(WindowHandle handle); - - //////////////////////////////////////////////////////////// - /// Create the window implementation - /// - /// \param mode : Video mode to use - /// \param title : Title of the window - /// \param style : Window style (resizable, fixed, or fullscren) - /// - //////////////////////////////////////////////////////////// - WindowImplX11(VideoMode mode, const std::string& title, unsigned long style); - - //////////////////////////////////////////////////////////// - /// Destructor - /// - //////////////////////////////////////////////////////////// - ~WindowImplX11(); - - //////////////////////////////////////////////////////////// - /// Get the display used by the window. - /// This functions is meant to be used internally by ContextGLX. +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOWIMPLX11_HPP +#define SFML_WINDOWIMPLX11_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// \brief Linux (X11) implementation of WindowImpl +/// +//////////////////////////////////////////////////////////// +class WindowImplX11 : public WindowImpl +{ +public : + + //////////////////////////////////////////////////////////// + /// \brief Construct the window implementation from an existing control + /// + /// \param handle Platform-specific handle of the control + /// + //////////////////////////////////////////////////////////// + WindowImplX11(WindowHandle handle); + + //////////////////////////////////////////////////////////// + /// \brief Create the window implementation + /// + /// \param mode Video mode to use + /// \param title Title of the window + /// \param style Window style (resizable, fixed, or fullscren) + /// + //////////////////////////////////////////////////////////// + WindowImplX11(VideoMode mode, const std::string& title, unsigned long style); + + //////////////////////////////////////////////////////////// + /// \brief Destructor + /// + //////////////////////////////////////////////////////////// + ~WindowImplX11(); + + //////////////////////////////////////////////////////////// + /// \brief Get the display used by the window + /// + /// This functions is meant to be used internally by ContextGLX. /// /// \return Pointer to the X display of the window - /// - //////////////////////////////////////////////////////////// + /// + //////////////////////////////////////////////////////////// ::Display* GetDisplay() const; - -private : + +private : //////////////////////////////////////////////////////////// - /// /see WindowImpl::GetHandle + /// \brief Get the OS-specific handle of the window + /// + /// \return Handle of the window /// //////////////////////////////////////////////////////////// virtual WindowHandle GetHandle() const; //////////////////////////////////////////////////////////// - /// /see WindowImpl::ProcessEvents + /// \brief Process incoming events from operating system /// //////////////////////////////////////////////////////////// virtual void ProcessEvents(); //////////////////////////////////////////////////////////// - /// /see WindowImpl::ShowMouseCursor + /// \brief Show or hide the mouse cursor + /// + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void ShowMouseCursor(bool show); //////////////////////////////////////////////////////////// - /// /see sfWindowImpl::SetCursorPosition + /// \brief Change the position of the mouse cursor + /// + /// \param left Left coordinate of the cursor, relative to the window + /// \param top Top coordinate of the cursor, relative to the window /// //////////////////////////////////////////////////////////// virtual void SetCursorPosition(unsigned int left, unsigned int top); //////////////////////////////////////////////////////////// - /// /see sfWindowImpl::SetPosition + /// \brief Change the position of the window on screen + /// + /// \param left Left position + /// \param top Top position /// //////////////////////////////////////////////////////////// virtual void SetPosition(int left, int top); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetSize + /// \brief Change the size of the rendering region of the window + /// + /// \param width New width + /// \param height New height /// //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height); //////////////////////////////////////////////////////////// - /// /see sfWindowImpl::Show + /// \brief Show or hide the window + /// + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void Show(bool show); //////////////////////////////////////////////////////////// - /// /see sfWindowImpl::EnableKeyRepeat + /// \brief Enable or disable automatic key-repeat + /// + /// \param enabled True to enable, false to disable /// //////////////////////////////////////////////////////////// virtual void EnableKeyRepeat(bool enabled); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetIcon + /// \brief Change the window's icon + /// + /// \param width Icon's width, in pixels + /// \param height Icon's height, in pixels + /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels); - - //////////////////////////////////////////////////////////// - /// Switch to fullscreen mode - /// - /// \param Mode : video mode to switch to - /// - //////////////////////////////////////////////////////////// - void SwitchToFullscreen(const VideoMode& mode); - - //////////////////////////////////////////////////////////// - /// Do some common initializations after the window has been created - /// - //////////////////////////////////////////////////////////// - void Initialize(); - - //////////////////////////////////////////////////////////// - /// Create a transparent mouse cursor - /// - //////////////////////////////////////////////////////////// - void CreateHiddenCursor(); - - //////////////////////////////////////////////////////////// - /// Cleanup graphical resources attached to the window - /// - //////////////////////////////////////////////////////////// - void CleanUp(); - - //////////////////////////////////////////////////////////// - /// Process an incoming event from the window - /// - /// \param windowEvent : Event which has been received - /// - //////////////////////////////////////////////////////////// - void ProcessEvent(XEvent windowEvent); - - //////////////////////////////////////////////////////////// - /// Convert a X11 keysym to SFML key code - /// - /// \param symbol : keysym to convert - /// - /// \return Corrsponding SFML key code - /// - //////////////////////////////////////////////////////////// - static Key::Code KeysymToSF(KeySym symbol); - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - ::Window myWindow; ///< X11 structure defining our window - ::Display* myDisplay; ///< Pointer to the display + + //////////////////////////////////////////////////////////// + /// \brief Switch to fullscreen mode + /// + /// \param Mode video mode to switch to + /// + //////////////////////////////////////////////////////////// + void SwitchToFullscreen(const VideoMode& mode); + + //////////////////////////////////////////////////////////// + /// \brief Do some common initializations after the window has been created + /// + //////////////////////////////////////////////////////////// + void Initialize(); + + //////////////////////////////////////////////////////////// + /// \brief Create a transparent mouse cursor + /// + //////////////////////////////////////////////////////////// + void CreateHiddenCursor(); + + //////////////////////////////////////////////////////////// + /// \brief Cleanup graphical resources attached to the window + /// + //////////////////////////////////////////////////////////// + void CleanUp(); + + //////////////////////////////////////////////////////////// + /// \brief Process an incoming event from the window + /// + /// \param windowEvent Event which has been received + /// + //////////////////////////////////////////////////////////// + void ProcessEvent(XEvent windowEvent); + + //////////////////////////////////////////////////////////// + /// \brief Convert a X11 keysym to SFML key code + /// + /// \param symbol Key symbol to convert + /// + /// \return Corrsponding SFML key code + /// + //////////////////////////////////////////////////////////// + static Key::Code KeysymToSF(KeySym symbol); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + ::Window myWindow; ///< X11 structure defining our window + ::Display* myDisplay; ///< Pointer to the display int myScreen; ///< Screen identifier - XIM myInputMethod; ///< Input method linked to the X display - XIC myInputContext; ///< Input context used to get unicode input in our window - bool myIsExternal; ///< Tell whether the window has been created externally or by SFML - Atom myAtomClose; ///< Atom used to identify the close event - int myOldVideoMode; ///< Video mode in use before we switch to fullscreen - Cursor myHiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one - bool myKeyRepeat; ///< Is the KeyRepeat feature enabled ? - XEvent myLastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events) -}; - -} // namespace priv - -} // namespace sf - - -#endif // SFML_WINDOWIMPLX11_HPP + XIM myInputMethod; ///< Input method linked to the X display + XIC myInputContext; ///< Input context used to get unicode input in our window + bool myIsExternal; ///< Tell whether the window has been created externally or by SFML + Atom myAtomClose; ///< Atom used to identify the close event + int myOldVideoMode; ///< Video mode in use before we switch to fullscreen + Cursor myHiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one + bool myKeyRepeat; ///< Is the KeyRepeat feature enabled ? + XEvent myLastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events) +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_WINDOWIMPLX11_HPP diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp index c7a4bebd2..62fdf808f 100644 --- a/src/SFML/Window/VideoMode.cpp +++ b/src/SFML/Window/VideoMode.cpp @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////// -/// Internal data +/// Private data //////////////////////////////////////////////////////////// namespace { @@ -57,9 +57,7 @@ namespace } }; - //////////////////////////////////////////////////////////// - /// Get and sort valid video modes - //////////////////////////////////////////////////////////// + // Get and sort valid video modes static void InitializeModes() { // We request the array of valid modes @@ -74,8 +72,6 @@ namespace namespace sf { //////////////////////////////////////////////////////////// -/// Default constructor -//////////////////////////////////////////////////////////// VideoMode::VideoMode() : Width (0), Height (0), @@ -85,8 +81,6 @@ BitsPerPixel(0) } -//////////////////////////////////////////////////////////// -/// Construct the video mode with its attributes //////////////////////////////////////////////////////////// VideoMode::VideoMode(unsigned int width, unsigned int height, unsigned int bitsPerPixel) : Width (width), @@ -97,8 +91,6 @@ BitsPerPixel(bitsPerPixel) } -//////////////////////////////////////////////////////////// -/// Get the current desktop video mode //////////////////////////////////////////////////////////// VideoMode VideoMode::GetDesktopMode() { @@ -107,12 +99,10 @@ VideoMode VideoMode::GetDesktopMode() } -//////////////////////////////////////////////////////////// -/// Get a valid video mode -/// Index must be in range [0, GetModesCount()[ //////////////////////////////////////////////////////////// VideoMode VideoMode::GetMode(std::size_t index) { + // Build and cache the list of valid modes on first call if (supportedModes.empty()) InitializeModes(); @@ -123,11 +113,10 @@ VideoMode VideoMode::GetMode(std::size_t index) } -//////////////////////////////////////////////////////////// -/// Get valid video modes count //////////////////////////////////////////////////////////// std::size_t VideoMode::GetModesCount() { + // Build and cache the list of valid modes on first call if (supportedModes.empty()) InitializeModes(); @@ -135,11 +124,10 @@ std::size_t VideoMode::GetModesCount() } -//////////////////////////////////////////////////////////// -/// Tell whether or not the video mode is supported //////////////////////////////////////////////////////////// bool VideoMode::IsValid() const { + // Build and cache the list of valid modes on first call if (supportedModes.empty()) InitializeModes(); @@ -148,22 +136,18 @@ bool VideoMode::IsValid() const //////////////////////////////////////////////////////////// -/// Comparison operator overload -- tell if two video modes are equal -//////////////////////////////////////////////////////////// -bool VideoMode::operator ==(const VideoMode& other) const +bool operator ==(const VideoMode& left, const VideoMode& right) { - return (Width == other.Width) && - (Height == other.Height) && - (BitsPerPixel == other.BitsPerPixel); + return (left.Width == right.Width) && + (left.Height == right.Height) && + (left.BitsPerPixel == right.BitsPerPixel); } //////////////////////////////////////////////////////////// -/// Comparison operator overload -- tell if two video modes are different -//////////////////////////////////////////////////////////// -bool VideoMode::operator !=(const VideoMode& other) const +bool operator !=(const VideoMode& left, const VideoMode& right) { - return !(*this == other); + return !(left == right); } } // namespace sf diff --git a/src/SFML/Window/Win32/ContextWGL.cpp b/src/SFML/Window/Win32/ContextWGL.cpp index 8cdcc62c4..3a52454f0 100644 --- a/src/SFML/Window/Win32/ContextWGL.cpp +++ b/src/SFML/Window/Win32/ContextWGL.cpp @@ -37,8 +37,6 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Create a new context, not associated to a window -//////////////////////////////////////////////////////////// ContextWGL::ContextWGL(ContextWGL* shared) : myWindow (NULL), myDC (NULL), @@ -57,13 +55,10 @@ myOwnsWindow(true) CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0)); // Activate the context - //if (shared) - SetActive(true); + SetActive(true); } -//////////////////////////////////////////////////////////// -/// Create a new context attached to a window //////////////////////////////////////////////////////////// ContextWGL::ContextWGL(ContextWGL* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings) : myWindow (NULL), @@ -80,13 +75,10 @@ myOwnsWindow(false) CreateContext(shared, bitsPerPixel, settings); // Activate the context - //if (shared) - SetActive(true); + SetActive(true); } -//////////////////////////////////////////////////////////// -/// Destructor //////////////////////////////////////////////////////////// ContextWGL::~ContextWGL() { @@ -108,8 +100,6 @@ ContextWGL::~ContextWGL() } -//////////////////////////////////////////////////////////// -/// \see Context::MakeCurrent //////////////////////////////////////////////////////////// bool ContextWGL::MakeCurrent(bool active) { @@ -137,8 +127,6 @@ bool ContextWGL::MakeCurrent(bool active) } -//////////////////////////////////////////////////////////// -/// \see Context::Display //////////////////////////////////////////////////////////// void ContextWGL::Display() { @@ -147,8 +135,6 @@ void ContextWGL::Display() } -//////////////////////////////////////////////////////////// -/// \see Context::UseVerticalSync //////////////////////////////////////////////////////////// void ContextWGL::UseVerticalSync(bool enabled) { @@ -158,8 +144,6 @@ void ContextWGL::UseVerticalSync(bool enabled) } -//////////////////////////////////////////////////////////// -/// Check if a context is active on the current thread //////////////////////////////////////////////////////////// bool ContextWGL::IsContextActive() { @@ -167,8 +151,6 @@ bool ContextWGL::IsContextActive() } -//////////////////////////////////////////////////////////// -/// Create the context //////////////////////////////////////////////////////////// void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, const ContextSettings& settings) { diff --git a/src/SFML/Window/Win32/ContextWGL.hpp b/src/SFML/Window/Win32/ContextWGL.hpp index 837da6f47..2ab61ce05 100644 --- a/src/SFML/Window/Win32/ContextWGL.hpp +++ b/src/SFML/Window/Win32/ContextWGL.hpp @@ -37,57 +37,70 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Windows (WGL) implementation of OpenGL contexts +/// \brief Windows (WGL) implementation of OpenGL contexts +/// //////////////////////////////////////////////////////////// class ContextWGL : public ContextGL { public : //////////////////////////////////////////////////////////// - /// Create a new context, not associated to a window + /// \brief Create a new context, not associated to a window /// - /// \param shared : Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be NULL) /// //////////////////////////////////////////////////////////// ContextWGL(ContextWGL* shared); //////////////////////////////////////////////////////////// - /// Create a new context attached to a window + /// \brief Create a new context attached to a window /// - /// \param shared : Context to share the new one with (can be NULL) - /// \param owner : Pointer to the owner window - /// \param bitsPerPixel : Pixel depth (in bits per pixel) - /// \param settings : Creation parameters + /// \param shared Context to share the new one with (can be NULL) + /// \param owner Pointer to the owner window + /// \param bitsPerPixel Pixel depth (in bits per pixel) + /// \param settings Creation parameters /// //////////////////////////////////////////////////////////// ContextWGL(ContextWGL* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings); //////////////////////////////////////////////////////////// - /// Destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// ~ContextWGL(); //////////////////////////////////////////////////////////// - /// \see Context::MakeCurrent + /// \brief Activate or deactivate the context as the current target + /// for rendering + /// + /// \param active True to activate, false to deactivate + /// + /// \return True on success, false if any error happened /// //////////////////////////////////////////////////////////// virtual bool MakeCurrent(bool active); //////////////////////////////////////////////////////////// - /// \see Context::Display + /// \brief Display what has been rendered to the context so far /// //////////////////////////////////////////////////////////// virtual void Display(); //////////////////////////////////////////////////////////// - /// \see Context::UseVerticalSync + /// \brief Enable or disable vertical synchronization + /// + /// Activating vertical synchronization will limit the number + /// of frames displayed to the refresh rate of the monitor. + /// This can avoid some visual artifacts, and limit the framerate + /// to a good value (but not constant across different computers). + /// + /// \param enabled : True to enable v-sync, false to deactivate /// //////////////////////////////////////////////////////////// virtual void UseVerticalSync(bool enabled); //////////////////////////////////////////////////////////// - /// Check if a context is active on the current thread + /// \brief Check if a context is active on the current thread /// /// \return True if there's an active context, false otherwise /// @@ -97,11 +110,11 @@ public : private : //////////////////////////////////////////////////////////// - /// Create the context + /// \brief Create the context /// - /// \param shared : Context to share the new one with (can be NULL) - /// \param bitsPerPixel : Pixel depth, in bits per pixel - /// \param settings : Creation parameters + /// \param shared Context to share the new one with (can be NULL) + /// \param bitsPerPixel Pixel depth, in bits per pixel + /// \param settings Creation parameters /// //////////////////////////////////////////////////////////// void CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, const ContextSettings& settings); diff --git a/src/SFML/Window/Win32/Joystick.cpp b/src/SFML/Window/Win32/Joystick.cpp index 601f0980d..ed4b9bbef 100644 --- a/src/SFML/Window/Win32/Joystick.cpp +++ b/src/SFML/Window/Win32/Joystick.cpp @@ -37,8 +37,6 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Initialize the instance and bind it to a physical joystick -//////////////////////////////////////////////////////////// void Joystick::Initialize(unsigned int index) { // Reset state @@ -79,8 +77,6 @@ void Joystick::Initialize(unsigned int index) } -//////////////////////////////////////////////////////////// -/// Update the current joystick and return its new state //////////////////////////////////////////////////////////// JoystickState Joystick::UpdateState() { @@ -120,8 +116,6 @@ JoystickState Joystick::UpdateState() } -//////////////////////////////////////////////////////////// -/// Get the number of axes supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetAxesCount() const { @@ -129,8 +123,6 @@ unsigned int Joystick::GetAxesCount() const } -//////////////////////////////////////////////////////////// -/// Get the number of buttons supported by the joystick //////////////////////////////////////////////////////////// unsigned int Joystick::GetButtonsCount() const { diff --git a/src/SFML/Window/Win32/Joystick.hpp b/src/SFML/Window/Win32/Joystick.hpp index 34216b6ce..0b6599274 100644 --- a/src/SFML/Window/Win32/Joystick.hpp +++ b/src/SFML/Window/Win32/Joystick.hpp @@ -35,22 +35,23 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Win32 implementation of Joystick +/// \brief Windows implementation of Joystick +/// //////////////////////////////////////////////////////////// class Joystick { public : //////////////////////////////////////////////////////////// - /// Initialize the instance and bind it to a physical joystick + /// \brief Initialize the instance and bind it to a physical joystick /// - /// \param index : Index of the physical joystick to bind to + /// \param index Index of the physical joystick to bind to /// //////////////////////////////////////////////////////////// void Initialize(unsigned int index); //////////////////////////////////////////////////////////// - /// Update the current joystick and return its new state + /// \brief Update the current joystick and return its new state /// /// \return Current state of the joystick /// @@ -58,7 +59,7 @@ public : JoystickState UpdateState(); //////////////////////////////////////////////////////////// - /// Get the number of axes supported by the joystick + /// \brief Get the number of axes supported by the joystick /// /// \return Number of axis /// @@ -66,7 +67,7 @@ public : unsigned int GetAxesCount() const; //////////////////////////////////////////////////////////// - /// Get the number of buttons supported by the joystick + /// \brief Get the number of buttons supported by the joystick /// /// \return Number of buttons /// diff --git a/src/SFML/Window/Win32/VideoModeSupport.cpp b/src/SFML/Window/Win32/VideoModeSupport.cpp index 10b3eb273..c80eba603 100644 --- a/src/SFML/Window/Win32/VideoModeSupport.cpp +++ b/src/SFML/Window/Win32/VideoModeSupport.cpp @@ -35,19 +35,17 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Get supported video modes -//////////////////////////////////////////////////////////// void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) { // First, clear array to fill modes.clear(); - // Enumerate all available video modes for primary display adapter + // Enumerate all available video modes for the primary display adapter DEVMODE win32Mode; win32Mode.dmSize = sizeof(win32Mode); for (int count = 0; EnumDisplaySettings(NULL, count, &win32Mode); ++count) { - // Convert to sfVideoMode + // Convert to sf::VideoMode VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel); // Add it only if it is not already in the array @@ -57,8 +55,6 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) } -//////////////////////////////////////////////////////////// -/// Get current desktop video mode //////////////////////////////////////////////////////////// VideoMode VideoModeSupport::GetDesktopVideoMode() { diff --git a/src/SFML/Window/Win32/VideoModeSupport.hpp b/src/SFML/Window/Win32/VideoModeSupport.hpp index 14232aaeb..d3e5fb560 100644 --- a/src/SFML/Window/Win32/VideoModeSupport.hpp +++ b/src/SFML/Window/Win32/VideoModeSupport.hpp @@ -37,23 +37,24 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Win32 implementation of VideoModeSupport -/// Give access to video mode related OS-specific functions +/// \brief Windows implementation of VideoModeSupport; +/// gives access to video mode related OS-specific functions +/// //////////////////////////////////////////////////////////// class VideoModeSupport { public : //////////////////////////////////////////////////////////// - /// Get supported video modes + /// \brief Get the list of all the supported video modes /// - /// \param Modes : Array to fill with available video modes + /// \param modes Array to fill with available video modes /// //////////////////////////////////////////////////////////// static void GetSupportedVideoModes(std::vector& modes); //////////////////////////////////////////////////////////// - /// Get current desktop video mode + /// \brief Get the current desktop video mode /// /// \return Current desktop video mode /// diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 8d8731783..34a6f19a3 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -44,22 +44,22 @@ #endif +//////////////////////////////////////////////////////////// +// Private data +//////////////////////////////////////////////////////////// +namespace +{ + unsigned int WindowCount = 0; + const char* ClassNameA = "SFML_Window"; + const wchar_t* ClassNameW = L"SFML_Window"; + sf::priv::WindowImplWin32* FullscreenWindow = NULL; +} + namespace sf { namespace priv { //////////////////////////////////////////////////////////// -// Static member data -//////////////////////////////////////////////////////////// -unsigned int WindowImplWin32::ourWindowCount = 0; -const char* WindowImplWin32::ourClassNameA = "SFML_Window"; -const wchar_t* WindowImplWin32::ourClassNameW = L"SFML_Window"; -WindowImplWin32* WindowImplWin32::ourFullscreenWindow = NULL; - - -//////////////////////////////////////////////////////////// -/// Create the window implementation from an existing control -//////////////////////////////////////////////////////////// WindowImplWin32::WindowImplWin32(WindowHandle handle) : myHandle (NULL), myCallback (0), @@ -86,8 +86,6 @@ myIsCursorIn (false) } -//////////////////////////////////////////////////////////// -/// Create the window implementation //////////////////////////////////////////////////////////// WindowImplWin32::WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style) : myHandle (NULL), @@ -98,7 +96,7 @@ myKeyRepeatEnabled(true), myIsCursorIn (false) { // Register the window class at first call - if (ourWindowCount == 0) + if (WindowCount == 0) RegisterWindowClass(); // Compute position and size @@ -136,11 +134,11 @@ myIsCursorIn (false) wchar_t wTitle[256]; int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle)); wTitle[count] = L'\0'; - myHandle = CreateWindowW(ourClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); + myHandle = CreateWindowW(ClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); } else { - myHandle = CreateWindowA(ourClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); + myHandle = CreateWindowA(ClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); } // Switch to fullscreen if requested @@ -148,7 +146,7 @@ myIsCursorIn (false) SwitchToFullscreen(mode); // Increment window count - ourWindowCount++; + WindowCount++; // Get the actual size of the window, which can be smaller even after the call to AdjustWindowRect // This happens when the window is bigger than the desktop @@ -159,8 +157,6 @@ myIsCursorIn (false) } -//////////////////////////////////////////////////////////// -/// Destructor //////////////////////////////////////////////////////////// WindowImplWin32::~WindowImplWin32() { @@ -175,18 +171,18 @@ WindowImplWin32::~WindowImplWin32() DestroyWindow(myHandle); // Decrement the window count - ourWindowCount--; + WindowCount--; // Unregister window class if we were the last window - if (ourWindowCount == 0) + if (WindowCount == 0) { if (HasUnicodeSupport()) { - UnregisterClassW(ourClassNameW, GetModuleHandle(NULL)); + UnregisterClassW(ClassNameW, GetModuleHandle(NULL)); } else { - UnregisterClassA(ourClassNameA, GetModuleHandle(NULL)); + UnregisterClassA(ClassNameA, GetModuleHandle(NULL)); } } } @@ -198,8 +194,6 @@ WindowImplWin32::~WindowImplWin32() } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::GetHandle //////////////////////////////////////////////////////////// WindowHandle WindowImplWin32::GetHandle() const { @@ -207,8 +201,6 @@ WindowHandle WindowImplWin32::GetHandle() const } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::ProcessEvents //////////////////////////////////////////////////////////// void WindowImplWin32::ProcessEvents() { @@ -225,8 +217,6 @@ void WindowImplWin32::ProcessEvents() } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::ShowMouseCursor //////////////////////////////////////////////////////////// void WindowImplWin32::ShowMouseCursor(bool show) { @@ -239,8 +229,6 @@ void WindowImplWin32::ShowMouseCursor(bool show) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetCursorPosition //////////////////////////////////////////////////////////// void WindowImplWin32::SetCursorPosition(unsigned int left, unsigned int top) { @@ -250,8 +238,6 @@ void WindowImplWin32::SetCursorPosition(unsigned int left, unsigned int top) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetPosition //////////////////////////////////////////////////////////// void WindowImplWin32::SetPosition(int left, int top) { @@ -259,8 +245,6 @@ void WindowImplWin32::SetPosition(int left, int top) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetSize //////////////////////////////////////////////////////////// void WindowImplWin32::SetSize(unsigned int width, unsigned int height) { @@ -275,8 +259,6 @@ void WindowImplWin32::SetSize(unsigned int width, unsigned int height) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::Show //////////////////////////////////////////////////////////// void WindowImplWin32::Show(bool show) { @@ -284,8 +266,6 @@ void WindowImplWin32::Show(bool show) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::EnableKeyRepeat //////////////////////////////////////////////////////////// void WindowImplWin32::EnableKeyRepeat(bool enabled) { @@ -293,8 +273,6 @@ void WindowImplWin32::EnableKeyRepeat(bool enabled) } -//////////////////////////////////////////////////////////// -/// /see WindowImpl::SetIcon //////////////////////////////////////////////////////////// void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels) { @@ -328,8 +306,6 @@ void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uin } -//////////////////////////////////////////////////////////// -/// Register the window class //////////////////////////////////////////////////////////// void WindowImplWin32::RegisterWindowClass() { @@ -345,7 +321,7 @@ void WindowImplWin32::RegisterWindowClass() WindowClass.hCursor = 0; WindowClass.hbrBackground = 0; WindowClass.lpszMenuName = NULL; - WindowClass.lpszClassName = ourClassNameW; + WindowClass.lpszClassName = ClassNameW; RegisterClassW(&WindowClass); } else @@ -360,14 +336,12 @@ void WindowImplWin32::RegisterWindowClass() WindowClass.hCursor = 0; WindowClass.hbrBackground = 0; WindowClass.lpszMenuName = NULL; - WindowClass.lpszClassName = ourClassNameA; + WindowClass.lpszClassName = ClassNameA; RegisterClassA(&WindowClass); } } -//////////////////////////////////////////////////////////// -/// Switch to fullscreen mode //////////////////////////////////////////////////////////// void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode) { @@ -394,7 +368,7 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode) ShowWindow(myHandle, SW_SHOW); // Set "this" as the current fullscreen window - ourFullscreenWindow = this; + FullscreenWindow = this; // SetPixelFormat can fail (really ?) if window style doesn't contain these flags long style = GetWindowLong(myHandle, GWL_STYLE); @@ -402,16 +376,14 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode) } -//////////////////////////////////////////////////////////// -/// Free all the graphical resources attached to the window //////////////////////////////////////////////////////////// void WindowImplWin32::Cleanup() { // Restore the previous video mode (in case we were running in fullscreen) - if (ourFullscreenWindow == this) + if (FullscreenWindow == this) { ChangeDisplaySettings(NULL, 0); - ourFullscreenWindow = NULL; + FullscreenWindow = NULL; } // Unhide the mouse cursor (in case it was hidden) @@ -419,8 +391,6 @@ void WindowImplWin32::Cleanup() } -//////////////////////////////////////////////////////////// -/// Process a Win32 event //////////////////////////////////////////////////////////// void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam) { @@ -703,9 +673,6 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam) } -//////////////////////////////////////////////////////////// -/// Check the state of the shift keys on a key event, -/// and return the corresponding SF key code //////////////////////////////////////////////////////////// Key::Code WindowImplWin32::GetShiftState(bool keyDown) { @@ -734,8 +701,6 @@ Key::Code WindowImplWin32::GetShiftState(bool keyDown) } -//////////////////////////////////////////////////////////// -/// Convert a Win32 virtual key code to a SFML key code //////////////////////////////////////////////////////////// Key::Code WindowImplWin32::VirtualKeyCodeToSF(WPARAM key, LPARAM flags) { @@ -845,10 +810,6 @@ Key::Code WindowImplWin32::VirtualKeyCodeToSF(WPARAM key, LPARAM flags) } -//////////////////////////////////////////////////////////// -/// Check if the current version of the OS supports unicode -/// messages and functions ; Windows 95/98/Me may not support -/// it, whereas Windows NT/2000/XP/Vista will //////////////////////////////////////////////////////////// bool WindowImplWin32::HasUnicodeSupport() { @@ -867,8 +828,6 @@ bool WindowImplWin32::HasUnicodeSupport() } -//////////////////////////////////////////////////////////// -/// Function called whenever one of our windows receives a message //////////////////////////////////////////////////////////// LRESULT CALLBACK WindowImplWin32::GlobalOnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index cc305ac30..f5fcb9e35 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -39,32 +39,33 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// WindowImplWin32 is the Win32 implementation of WindowImpl +/// \brief Windows implementation of WindowImpl +/// //////////////////////////////////////////////////////////// class WindowImplWin32 : public WindowImpl { public : //////////////////////////////////////////////////////////// - /// Construct the window implementation from an existing control + /// \brief Construct the window implementation from an existing control /// - /// \param handle : Platform-specific handle of the control + /// \param handle Platform-specific handle of the control /// //////////////////////////////////////////////////////////// WindowImplWin32(WindowHandle handle); //////////////////////////////////////////////////////////// - /// Create the window implementation + /// \brief Create the window implementation /// - /// \param mode : Video mode to use - /// \param title : Title of the window - /// \param style : Window style + /// \param mode Video mode to use + /// \param title Title of the window + /// \param style Window style /// //////////////////////////////////////////////////////////// WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style); //////////////////////////////////////////////////////////// - /// Destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// ~WindowImplWin32(); @@ -72,55 +73,76 @@ public : private : //////////////////////////////////////////////////////////// - /// /see WindowImpl::GetHandle + /// \brief Get the OS-specific handle of the window + /// + /// \return Handle of the window /// //////////////////////////////////////////////////////////// virtual WindowHandle GetHandle() const; //////////////////////////////////////////////////////////// - /// /see WindowImpl::ProcessEvents + /// \brief Process incoming events from operating system /// //////////////////////////////////////////////////////////// virtual void ProcessEvents(); //////////////////////////////////////////////////////////// - /// /see WindowImpl::ShowMouseCursor + /// \brief Show or hide the mouse cursor + /// + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void ShowMouseCursor(bool show); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetCursorPosition + /// \brief Change the position of the mouse cursor + /// + /// \param left Left coordinate of the cursor, relative to the window + /// \param top Top coordinate of the cursor, relative to the window /// //////////////////////////////////////////////////////////// virtual void SetCursorPosition(unsigned int left, unsigned int top); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetPosition + /// \brief Change the position of the window on screen + /// + /// \param left Left position + /// \param top Top position /// //////////////////////////////////////////////////////////// virtual void SetPosition(int left, int top); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetSize + /// \brief Change the size of the rendering region of the window + /// + /// \param width New width + /// \param height New height /// //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height); //////////////////////////////////////////////////////////// - /// /see WindowImpl::Show + /// \brief Show or hide the window + /// + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void Show(bool show); //////////////////////////////////////////////////////////// - /// /see WindowImpl::EnableKeyRepeat + /// \brief Enable or disable automatic key-repeat + /// + /// \param enabled True to enable, false to disable /// //////////////////////////////////////////////////////////// virtual void EnableKeyRepeat(bool enabled); //////////////////////////////////////////////////////////// - /// /see WindowImpl::SetIcon + /// \brief Change the window's icon + /// + /// \param width Icon's width, in pixels + /// \param height Icon's height, in pixels + /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels); @@ -132,34 +154,34 @@ private : void RegisterWindowClass(); //////////////////////////////////////////////////////////// - /// Switch to fullscreen mode + /// \brief Switch to fullscreen mode /// - /// \param mode : video mode to switch to + /// \param mode Video mode to switch to /// //////////////////////////////////////////////////////////// void SwitchToFullscreen(const VideoMode& mode); //////////////////////////////////////////////////////////// - /// Free all the graphical resources attached to the window + /// \brief Free all the graphical resources attached to the window /// //////////////////////////////////////////////////////////// void Cleanup(); //////////////////////////////////////////////////////////// - /// Process a Win32 event + /// \brief Process a Win32 event /// - /// \param message : Message to process - /// \param wParam : First parameter of the event - /// \param lParam : Second parameter of the event + /// \param message Message to process + /// \param wParam First parameter of the event + /// \param lParam Second parameter of the event /// //////////////////////////////////////////////////////////// void ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam); //////////////////////////////////////////////////////////// - /// Check the state of the shift keys on a key event, - /// and return the corresponding SF key code + /// \brief Check the state of the shift keys on a key event, + /// and return the corresponding SFML key code /// - /// \param keyDown : True for a keydown event, false for a keyup event + /// \param keyDown True for a keydown event, false for a keyup event /// /// \return SFML key code corresponding to the shift key /// @@ -167,10 +189,10 @@ private : static Key::Code GetShiftState(bool keyDown); //////////////////////////////////////////////////////////// - /// Convert a Win32 virtual key code to a SFML key code + /// \brief Convert a Win32 virtual key code to a SFML key code /// - /// \param key : Virtual key code to convert - /// \param flags : Additional flags + /// \param key Virtual key code to convert + /// \param flags Additional flags /// /// \return SFML key code corresponding to the key /// @@ -178,9 +200,10 @@ private : static Key::Code VirtualKeyCodeToSF(WPARAM key, LPARAM flags); //////////////////////////////////////////////////////////// - /// Check if the current version of the OS supports unicode - /// messages and functions ; Windows 95/98/Me may not support - /// it, whereas Windows NT/2000/XP/Vista will + /// \brief Check if the current version of the OS supports + /// unicode messages and functions ; Windows 95/98/Me + /// may not support it, whereas Windows NT/2000/XP/Vista + /// will /// /// \return True if the OS supports unicode /// @@ -188,26 +211,18 @@ private : static bool HasUnicodeSupport(); //////////////////////////////////////////////////////////// - /// Function called whenever one of our windows receives a message + /// \brief Function called whenever one of our windows receives a message /// - /// \param handle : Win32 handle of the window - /// \param message : Message received - /// \param wParam : First parameter of the message - /// \param lParam : Second parameter of the message + /// \param handle Win32 handle of the window + /// \param message Message received + /// \param wParam First parameter of the message + /// \param lParam Second parameter of the message /// - /// \return Something... + /// \return True to discard the event after it has been processed /// //////////////////////////////////////////////////////////// static LRESULT CALLBACK GlobalOnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam); - //////////////////////////////////////////////////////////// - // Static member data - //////////////////////////////////////////////////////////// - static unsigned int ourWindowCount; ///< Number of windows that we own - static const char* ourClassNameA; ///< Win32 window class name (ANSI version) - static const wchar_t* ourClassNameW; ///< Win32 window class name (unicode version) - static WindowImplWin32* ourFullscreenWindow; ///< Window currently in fullscreen - //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 21d86826f..cc754199a 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -54,16 +54,12 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Create a new window depending on the current OS -//////////////////////////////////////////////////////////// WindowImpl* WindowImpl::New(VideoMode mode, const std::string& title, unsigned long style) { return new WindowImplType(mode, title, style); } -//////////////////////////////////////////////////////////// -/// Create a new window depending on the current OS //////////////////////////////////////////////////////////// WindowImpl* WindowImpl::New(WindowHandle handle) { @@ -71,8 +67,6 @@ WindowImpl* WindowImpl::New(WindowHandle handle) } -//////////////////////////////////////////////////////////// -/// Default constructor //////////////////////////////////////////////////////////// WindowImpl::WindowImpl() : myWidth (0), @@ -88,8 +82,6 @@ myJoyThreshold(0.1f) } -//////////////////////////////////////////////////////////// -/// Destructor //////////////////////////////////////////////////////////// WindowImpl::~WindowImpl() { @@ -97,8 +89,6 @@ WindowImpl::~WindowImpl() } -//////////////////////////////////////////////////////////// -/// Add a listener to the window //////////////////////////////////////////////////////////// void WindowImpl::AddListener(WindowListener* listener) { @@ -107,8 +97,6 @@ void WindowImpl::AddListener(WindowListener* listener) } -//////////////////////////////////////////////////////////// -/// Remove a listener from the window //////////////////////////////////////////////////////////// void WindowImpl::RemoveListener(WindowListener* listener) { @@ -116,8 +104,6 @@ void WindowImpl::RemoveListener(WindowListener* listener) } -//////////////////////////////////////////////////////////// -/// Get the client width of the window //////////////////////////////////////////////////////////// unsigned int WindowImpl::GetWidth() const { @@ -125,8 +111,6 @@ unsigned int WindowImpl::GetWidth() const } -//////////////////////////////////////////////////////////// -/// Get the client height of the window //////////////////////////////////////////////////////////// unsigned int WindowImpl::GetHeight() const { @@ -134,9 +118,6 @@ unsigned int WindowImpl::GetHeight() const } -//////////////////////////////////////////////////////////// -/// Change the joystick threshold, ie. the value below which -/// no move event will be generated //////////////////////////////////////////////////////////// void WindowImpl::SetJoystickThreshold(float threshold) { @@ -144,8 +125,6 @@ void WindowImpl::SetJoystickThreshold(float threshold) } -//////////////////////////////////////////////////////////// -/// Process incoming events from operating system //////////////////////////////////////////////////////////// void WindowImpl::DoEvents() { @@ -157,8 +136,6 @@ void WindowImpl::DoEvents() } -//////////////////////////////////////////////////////////// -/// Send an event to listeners //////////////////////////////////////////////////////////// void WindowImpl::SendEvent(const Event& event) { @@ -169,8 +146,6 @@ void WindowImpl::SendEvent(const Event& event) } -//////////////////////////////////////////////////////////// -/// Read the joysticks state and generate the appropriate events //////////////////////////////////////////////////////////// void WindowImpl::ProcessJoystickEvents() { diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index 1c63f73cb..27d50e3d0 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -45,30 +45,31 @@ class WindowListener; namespace priv { //////////////////////////////////////////////////////////// -/// Abstract base class for OS-specific window implementation +/// \brief Abstract base class for OS-specific window implementation +/// //////////////////////////////////////////////////////////// class WindowImpl : NonCopyable { public : //////////////////////////////////////////////////////////// - /// Create a new window depending on the current OS + /// \brief Create a new window depending on the current OS /// - /// \param mode : Video mode to use - /// \param title : Title of the window - /// \param style : Window style + /// \param mode Video mode to use + /// \param title Title of the window + /// \param style Window style /// - /// \return Pointer to the created window + /// \return Pointer to the created window (don't forget to delete it) /// //////////////////////////////////////////////////////////// static WindowImpl* New(VideoMode mode, const std::string& title, unsigned long style); //////////////////////////////////////////////////////////// - /// Create a new window depending on to the current OS + /// \brief Create a new window depending on to the current OS /// - /// \param handle : Platform-specific handle of the control + /// \param handle Platform-specific handle of the control /// - /// \return Pointer to the created window + /// \return Pointer to the created window (don't forget to delete it) /// //////////////////////////////////////////////////////////// static WindowImpl* New(WindowHandle handle); @@ -76,29 +77,29 @@ public : public : //////////////////////////////////////////////////////////// - /// Destructor + /// \brief Destructor /// //////////////////////////////////////////////////////////// virtual ~WindowImpl(); //////////////////////////////////////////////////////////// - /// Add a listener to the window + /// \brief Add a listener to the window /// - /// \param listener : Listener to add + /// \param listener Listener to add /// //////////////////////////////////////////////////////////// void AddListener(WindowListener* listener); //////////////////////////////////////////////////////////// - /// Remove a listener from the window + /// \brief Remove a listener from the window /// - /// \param listener : Listener to remove + /// \param listener Listener to remove /// //////////////////////////////////////////////////////////// void RemoveListener(WindowListener* listener); //////////////////////////////////////////////////////////// - /// Get the client width of the window + /// \brief Get the client width of the window /// /// \return Width of the window in pixels /// @@ -106,7 +107,7 @@ public : unsigned int GetWidth() const; //////////////////////////////////////////////////////////// - /// Get the client height of the window + /// \brief Get the client height of the window /// /// \return Height of the window in pixels /// @@ -114,8 +115,8 @@ public : unsigned int GetHeight() const; //////////////////////////////////////////////////////////// - /// Change the joystick threshold, ie. the value below which - /// no move event will be generated + /// \brief Change the joystick threshold, ie. the value below which + /// no move event will be generated /// /// \param threshold : New threshold, in range [0, 100] /// @@ -123,13 +124,13 @@ public : void SetJoystickThreshold(float threshold); //////////////////////////////////////////////////////////// - /// Process incoming events from operating system + /// \brief Process incoming events from operating system /// //////////////////////////////////////////////////////////// void DoEvents(); //////////////////////////////////////////////////////////// - /// Get the OS-specific handle of the window + /// \brief Get the OS-specific handle of the window /// /// \return Handle of the window /// @@ -137,62 +138,62 @@ public : virtual WindowHandle GetHandle() const = 0; //////////////////////////////////////////////////////////// - /// Show or hide the mouse cursor + /// \brief Show or hide the mouse cursor /// - /// \param show : True to show, false to hide + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void ShowMouseCursor(bool show) = 0; //////////////////////////////////////////////////////////// - /// Change the position of the mouse cursor + /// \brief Change the position of the mouse cursor /// - /// \param left : Left coordinate of the cursor, relative to the window - /// \param top : Top coordinate of the cursor, relative to the window + /// \param left Left coordinate of the cursor, relative to the window + /// \param top Top coordinate of the cursor, relative to the window /// //////////////////////////////////////////////////////////// virtual void SetCursorPosition(unsigned int left, unsigned int top) = 0; //////////////////////////////////////////////////////////// - /// Change the position of the window on screen + /// \brief Change the position of the window on screen /// - /// \param left : Left position - /// \param top : Top position + /// \param left Left position + /// \param top Top position /// //////////////////////////////////////////////////////////// virtual void SetPosition(int left, int top) = 0; //////////////////////////////////////////////////////////// - /// Change the size of the rendering region of the window + /// \brief Change the size of the rendering region of the window /// - /// \param width : New width - /// \param height : New height + /// \param width New width + /// \param height New height /// //////////////////////////////////////////////////////////// virtual void SetSize(unsigned int width, unsigned int height) = 0; //////////////////////////////////////////////////////////// - /// Show or hide the window + /// \brief Show or hide the window /// - /// \param show : True to show, false to hide + /// \param show True to show, false to hide /// //////////////////////////////////////////////////////////// virtual void Show(bool show) = 0; //////////////////////////////////////////////////////////// - /// Enable or disable automatic key-repeat + /// \brief Enable or disable automatic key-repeat /// - /// \param enabled : True to enable, false to disable + /// \param enabled True to enable, false to disable /// //////////////////////////////////////////////////////////// virtual void EnableKeyRepeat(bool enabled) = 0; //////////////////////////////////////////////////////////// - /// Change the window's icon + /// \brief Change the window's icon /// - /// \param width : Icon's width, in pixels - /// \param height : Icon's height, in pixels - /// \param pixels : Pointer to the pixels in memory, format must be RGBA 32 bits + /// \param width Icon's width, in pixels + /// \param height Icon's height, in pixels + /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels) = 0; @@ -200,15 +201,15 @@ public : protected : //////////////////////////////////////////////////////////// - /// Default constructor + /// \brief Default constructor /// //////////////////////////////////////////////////////////// WindowImpl(); //////////////////////////////////////////////////////////// - /// Send an event to listeners (for derived classes only) + /// \brief Send an event to listeners (for derived classes only) /// - /// \param event : Event to send + /// \param event Event to send /// //////////////////////////////////////////////////////////// void SendEvent(const Event& event); @@ -222,13 +223,13 @@ protected : private : //////////////////////////////////////////////////////////// - /// Read the joysticks state and generate the appropriate events + /// \brief Read the joysticks state and generate the appropriate events /// //////////////////////////////////////////////////////////// void ProcessJoystickEvents(); //////////////////////////////////////////////////////////// - /// Process incoming events from operating system + /// \brief Process incoming events from operating system /// //////////////////////////////////////////////////////////// virtual void ProcessEvents() = 0;