WindowImpl.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef SFML_WINDOWIMPL_HPP
26 #define SFML_WINDOWIMPL_HPP
27 
29 // Headers
31 #include <SFML/Config.hpp>
32 #include <SFML/System/NonCopyable.hpp>
33 #include <SFML/Window/Joystick.hpp>
34 #include <SFML/Window/VideoMode.hpp>
35 #include <SFML/Window/WindowHandle.hpp>
36 #include <SFML/Window/WindowSettings.hpp>
37 #include <set>
38 #include <string>
39 
40 
41 namespace sf
42 {
43 class Event;
44 class WindowListener;
45 
46 namespace priv
47 {
51 class WindowImpl : NonCopyable
52 {
53 public :
54 
61  static WindowImpl* New();
62 
74  static WindowImpl* New(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, WindowSettings& Params);
75 
85  static WindowImpl* New(WindowHandle Handle, WindowSettings& Params);
86 
87 public :
88 
93  virtual ~WindowImpl();
94 
101  void AddListener(WindowListener* Listener);
102 
109  void RemoveListener(WindowListener* Listener);
110 
115  void Initialize();
116 
123  unsigned int GetWidth() const;
124 
131  unsigned int GetHeight() const;
132 
140  virtual void SetActive(bool Active = true) const = 0;
141 
149  void SetJoystickThreshold(float Threshold);
150 
155  void DoEvents();
156 
163  static bool IsContextActive();
164 
169  virtual void Display() = 0;
170 
177  virtual void UseVerticalSync(bool Enabled) = 0;
178 
185  virtual void ShowMouseCursor(bool Show) = 0;
186 
194  virtual void SetCursorPosition(unsigned int Left, unsigned int Top) = 0;
195 
203  virtual void SetPosition(int Left, int Top) = 0;
204 
212  virtual void SetSize(unsigned int Width, unsigned int Height) = 0;
213 
220  virtual void Show(bool State) = 0;
221 
228  virtual void EnableKeyRepeat(bool Enabled) = 0;
229 
238  virtual void SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels) = 0;
239 
240 protected :
241 
246  WindowImpl();
247 
254  void SendEvent(const Event& EventToSend);
255 
271  static int EvaluateConfig(const VideoMode& Mode, const WindowSettings& Settings, int ColorBits, int DepthBits, int StencilBits, int Antialiasing);
272 
274  // Member data
276  unsigned int myWidth;
277  unsigned int myHeight;
278 
279 private :
280 
285  void ProcessJoystickEvents();
286 
291  virtual void ProcessEvents() = 0;
292 
294  // Member data
296  std::set<WindowListener*> myListeners;
297  Joystick myJoysticks[Joy::Count];
298  JoystickState myJoyStates[Joy::Count];
299  float myJoyThreshold;
300 };
301 
302 } // namespace priv
303 
304 } // namespace sf
305 
306 
307 #endif // SFML_WINDOWIMPL_HPP
Total number of supported joysticks.
Definition: Event.hpp:188