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