svn merge -r38300:38400 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / intern / ghost / intern / GHOST_SystemSDL.h
1 /*
2  * $Id: GHOST_SystemSDL.h 38349 2011-07-13 00:49:22Z gsrb3d $
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * Contributor(s): Campbell Barton
20  *
21  * ***** END GPL LICENSE BLOCK *****
22  */
23
24 /** \file ghost/intern/GHOST_SystemSDL.h
25  *  \ingroup GHOST
26  * Declaration of GHOST_SystemSDL class.
27  */
28
29 #ifndef _GHOST_SYSTEM_SDL_H_
30 #define _GHOST_SYSTEM_SDL_H_
31
32 #include "GHOST_System.h"
33 #include "../GHOST_Types.h"
34 #include "GHOST_DisplayManagerSDL.h"
35 #include "GHOST_TimerManager.h"
36 #include "GHOST_WindowSDL.h"
37 #include "GHOST_Event.h"
38
39 extern "C" {
40         #include "SDL.h"
41 }
42
43 #if !SDL_VERSION_ATLEAST(1, 3, 0)
44 #  error "SDL 1.3 or newer is needed to build with Ghost"
45 #endif
46
47
48 class GHOST_WindowSDL;
49
50
51 class GHOST_SystemSDL : public GHOST_System {
52 public:
53
54         void addDirtyWindow(GHOST_WindowSDL *bad_wind);
55
56         GHOST_SystemSDL();
57         ~GHOST_SystemSDL();
58
59         bool
60         processEvents(bool waitForEvent);
61
62         int
63         toggleConsole(int action) { return 0; }
64
65         GHOST_TSuccess
66         getModifierKeys(GHOST_ModifierKeys& keys) const;
67
68         GHOST_TSuccess
69         getButtons(GHOST_Buttons& buttons) const;
70
71         GHOST_TUns8 *
72         getClipboard(bool selection) const;
73
74         void
75         putClipboard(GHOST_TInt8 *buffer, bool selection) const;
76
77         GHOST_TUns64
78         getMilliSeconds();
79
80         GHOST_TUns8
81         getNumDisplays() const;
82
83         GHOST_TSuccess
84         getCursorPosition(GHOST_TInt32& x,
85                           GHOST_TInt32& y) const;
86
87         GHOST_TSuccess
88         setCursorPosition(GHOST_TInt32 x,
89                           GHOST_TInt32 y);
90
91         void
92         getMainDisplayDimensions(GHOST_TUns32& width,
93                                  GHOST_TUns32& height) const;
94
95 private:
96
97         GHOST_TSuccess
98         init();
99
100         GHOST_IWindow *
101         createWindow(const STR_String& title,
102                      GHOST_TInt32 left,
103                      GHOST_TInt32 top,
104                      GHOST_TUns32 width,
105                      GHOST_TUns32 height,
106                      GHOST_TWindowState state,
107                      GHOST_TDrawingContextType type,
108                      bool stereoVisual,
109                      const GHOST_TUns16 numOfAASamples,
110                      const GHOST_TEmbedderWindowID parentWindow
111                      );
112
113         /* SDL spesific */
114         GHOST_WindowSDL * findGhostWindow(SDL_Window *sdl_win);
115
116         bool
117         generateWindowExposeEvents();
118
119         void
120         processEvent(SDL_Event *sdl_event);
121
122         /// The vector of windows that need to be updated.
123         std::vector<GHOST_WindowSDL *> m_dirty_windows;
124 };
125
126 #endif