WindowImplCocoa.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 Lucas Soltic (ceylow@gmail.com) and 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_WINDOWIMPLCOCOA_HPP
26 #define SFML_WINDOWIMPLCOCOA_HPP
27 
29 // Headers
31 #include <SFML/Window/Event.hpp>
32 #include <SFML/Window/WindowImpl.hpp>
33 #include <string>
34 
35 #ifdef __OBJC__
36 @class sfPrivWindow;
37 typedef sfPrivWindow* sfPrivWindowRef;
38 #else
39 typedef void* sfPrivWindowRef;
40 #endif
41 
42 namespace sf
43 {
44 namespace priv
45 {
46 
50 class WindowImplCocoa : public WindowImpl
51 {
52 public :
53 
59  WindowImplCocoa();
60 
69  WindowImplCocoa(WindowHandle Handle, WindowSettings& params);
70 
80  WindowImplCocoa(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, WindowSettings& params);
81 
86  ~WindowImplCocoa();
87 
94  static bool IsContextActive();
95 
99  void HandleNotifiedEvent(Event& eventRef);
100 
105  void HandleKeyDown(void *eventRef);
106  void HandleKeyUp(void *eventRef);
107  void HandleModifierKey(void *eventRef);
108  void HandleMouseDown(void *eventRef);
109  void HandleMouseUp(void *eventRef);
110  void HandleMouseMove(void *eventRef);
111  void HandleMouseWheel(void *eventRef);
112 
116  static bool IsTextEvent(void *event);
117 private :
118 
123  virtual void Display();
124 
129  virtual void ProcessEvents();
130 
135  virtual void SetActive(bool Active = true) const;
136 
141  virtual void UseVerticalSync(bool Enabled);
142 
147  virtual void ShowMouseCursor(bool Show);
148 
153  virtual void SetCursorPosition(unsigned int Left, unsigned int Top);
154 
159  virtual void SetPosition(int Left, int Top);
160 
165  virtual void SetSize(unsigned int Width, unsigned int Height);
166 
171  virtual void Show(bool State);
172 
177  virtual void EnableKeyRepeat(bool Enabled);
178 
183  virtual void SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels);
184 
185 
186 
190 
191 
193  // Member data
195  sfPrivWindowRef myWrapper;
196  bool myUseKeyRepeat;
197  bool myMouseIn;
198  float myWheelStatus;
199 };
200 
201 } // namespace priv
202 
203 } // namespace sf
204 
205 #endif // SFML_WINDOWIMPLCOCOA_HPP