Back to index

libsfml  1.6+dfsg2
WindowImpl.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_WINDOWIMPL_HPP
00026 #define SFML_WINDOWIMPL_HPP
00027 
00029 // Headers
00031 #include <SFML/Config.hpp>
00032 #include <SFML/System/NonCopyable.hpp>
00033 #include <SFML/Window/Joystick.hpp>
00034 #include <SFML/Window/VideoMode.hpp>
00035 #include <SFML/Window/WindowHandle.hpp>
00036 #include <SFML/Window/WindowSettings.hpp>
00037 #include <set>
00038 #include <string>
00039 
00040 
00041 namespace sf
00042 {
00043 class Event;
00044 class WindowListener;
00045 
00046 namespace priv
00047 {
00051 class WindowImpl : NonCopyable
00052 {
00053 public :
00054 
00061     static WindowImpl* New();
00062 
00074     static WindowImpl* New(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, WindowSettings& Params);
00075 
00085     static WindowImpl* New(WindowHandle Handle, WindowSettings& Params);
00086 
00087 public :
00088 
00093     virtual ~WindowImpl();
00094 
00101     void AddListener(WindowListener* Listener);
00102 
00109     void RemoveListener(WindowListener* Listener);
00110 
00115     void Initialize();
00116 
00123     unsigned int GetWidth() const;
00124 
00131     unsigned int GetHeight() const;
00132 
00140     virtual void SetActive(bool Active = true) const = 0;
00141 
00149     void SetJoystickThreshold(float Threshold);
00150 
00155     void DoEvents();
00156 
00163     static bool IsContextActive();
00164 
00169     virtual void Display() = 0;
00170 
00177     virtual void UseVerticalSync(bool Enabled) = 0;
00178 
00185     virtual void ShowMouseCursor(bool Show) = 0;
00186 
00194     virtual void SetCursorPosition(unsigned int Left, unsigned int Top) = 0;
00195 
00203     virtual void SetPosition(int Left, int Top) = 0;
00204 
00212     virtual void SetSize(unsigned int Width, unsigned int Height) = 0;
00213 
00220     virtual void Show(bool State) = 0;
00221 
00228     virtual void EnableKeyRepeat(bool Enabled) = 0;
00229 
00238     virtual void SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels) = 0;
00239 
00240 protected :
00241 
00246     WindowImpl();
00247 
00254     void SendEvent(const Event& EventToSend);
00255 
00271     static int EvaluateConfig(const VideoMode& Mode, const WindowSettings& Settings, int ColorBits, int DepthBits, int StencilBits, int Antialiasing);
00272 
00274     // Member data
00276     unsigned int myWidth;  
00277     unsigned int myHeight; 
00278 
00279 private :
00280 
00285     void ProcessJoystickEvents();
00286 
00291     virtual void ProcessEvents() = 0;
00292 
00294     // Member data
00296     std::set<WindowListener*> myListeners;             
00297     Joystick                  myJoysticks[Joy::Count]; 
00298     JoystickState             myJoyStates[Joy::Count]; 
00299     float                     myJoyThreshold;          
00300 };
00301 
00302 } // namespace priv
00303 
00304 } // namespace sf
00305 
00306 
00307 #endif // SFML_WINDOWIMPL_HPP