1b2bd35e057aa480d001943030eed885b7932017
[blender.git] / intern / ghost / intern / GHOST_WindowSDL.h
1 /*
2  * $Id: GHOST_WindowSDL.h 38022 2011-07-01 15:15:22Z campbellbarton $
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_WindowSDL.h
25  *  \ingroup GHOST
26  * Declaration of GHOST_WindowSDL class.
27  */
28
29 #ifndef _GHOST_WINDOWSDL_H_
30 #define _GHOST_WINDOWSDL_H_
31
32 #include "GHOST_Window.h"
33 #include "GHOST_SystemSDL.h"
34 #include <map>
35
36 extern "C" {
37         #include "SDL.h"
38 }
39
40 #if !SDL_VERSION_ATLEAST(1, 3, 0)
41 #  error "SDL 1.3 or newer is needed to build with Ghost"
42 #endif
43
44 class STR_String;
45
46 class GHOST_WindowSDL : public GHOST_Window
47 {
48 private :
49         GHOST_SystemSDL  * m_system;
50         bool               m_invalid_window;
51
52         SDL_Window       * m_sdl_win;
53         SDL_GLContext      m_sdl_glcontext;
54         SDL_Cursor               * m_sdl_custom_cursor;
55
56 public:
57
58         const GHOST_TabletData* GetTabletData() { return NULL; }
59
60         GHOST_WindowSDL(GHOST_SystemSDL *system,
61                         const STR_String& title,
62                         GHOST_TInt32 left, GHOST_TInt32 top,
63                         GHOST_TUns32 width, GHOST_TUns32 height,
64                         GHOST_TWindowState state,
65                         const GHOST_TEmbedderWindowID parentWindow,
66                         GHOST_TDrawingContextType type,
67                         const bool stereoVisual,
68                         const GHOST_TUns16 numOfAASamples
69                         );
70
71         ~GHOST_WindowSDL();
72
73         /* SDL spesific */
74         SDL_Window *
75         getSDLWindow()
76         {
77                 return m_sdl_win;
78         }
79
80
81         GHOST_TSuccess invalidate(void);
82
83         /**
84          * called by the X11 system implementation when expose events
85          * for the window have been pushed onto the GHOST queue
86          */
87
88         void validate()
89         {
90                 m_invalid_window = false;
91         }
92
93         bool getValid() const
94         {
95                 return (m_sdl_win != NULL);
96         }
97
98         void getWindowBounds(GHOST_Rect& bounds) const;
99         void getClientBounds(GHOST_Rect& bounds) const;
100
101 protected:
102         GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
103         GHOST_TSuccess removeDrawingContext();
104
105         GHOST_TSuccess
106         setWindowCursorGrab(GHOST_TGrabCursorMode mode);
107
108         GHOST_TSuccess
109         setWindowCursorShape(GHOST_TStandardCursor shape);
110
111         GHOST_TSuccess
112         setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
113                                    GHOST_TUns8 mask[16][2],
114                                    int hotX, int hotY);
115
116         GHOST_TSuccess
117         setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
118                                    GHOST_TUns8 *mask,
119                                    int sizex, int sizey,
120                                    int hotX, int hotY,
121                                    int fg_color, int bg_color);
122
123         GHOST_TSuccess
124         setWindowCursorVisibility(bool visible);
125
126         void
127         setTitle(const STR_String& title);
128
129         void
130         getTitle(STR_String& title) const;
131
132         GHOST_TSuccess
133         setClientWidth(GHOST_TUns32 width);
134
135         GHOST_TSuccess
136         setClientHeight(GHOST_TUns32 height);
137
138         GHOST_TSuccess
139         setClientSize(GHOST_TUns32 width,
140                       GHOST_TUns32 height);
141
142         void
143         screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY,
144                        GHOST_TInt32& outX, GHOST_TInt32& outY) const;
145
146         void
147         clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY,
148                        GHOST_TInt32& outX, GHOST_TInt32& outY) const;
149
150         GHOST_TSuccess
151         swapBuffers();
152
153         GHOST_TSuccess
154         activateDrawingContext();
155
156         GHOST_TSuccess
157         setState(GHOST_TWindowState state);
158
159         GHOST_TWindowState
160         getState() const;
161
162         GHOST_TSuccess setOrder(GHOST_TWindowOrder order) { return GHOST_kSuccess; } // TODO
163
164 };
165
166
167 #endif // _GHOST_WINDOWSDL_H_