Blender  V2.59
GHOST_WindowSDL.h
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_WindowSDL.h 38349 2011-07-13 00:49:22Z gsrb3d $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * Contributor(s): Campbell Barton
00020  *
00021  * ***** END GPL LICENSE BLOCK *****
00022  */
00023 
00029 #ifndef _GHOST_WINDOWSDL_H_
00030 #define _GHOST_WINDOWSDL_H_
00031 
00032 #include "GHOST_Window.h"
00033 #include "GHOST_SystemSDL.h"
00034 #include <map>
00035 
00036 extern "C" {
00037         #include "SDL.h"
00038 }
00039 
00040 #if !SDL_VERSION_ATLEAST(1, 3, 0)
00041 #  error "SDL 1.3 or newer is needed to build with Ghost"
00042 #endif
00043 
00044 class STR_String;
00045 
00046 class GHOST_WindowSDL : public GHOST_Window
00047 {
00048 private :
00049         GHOST_SystemSDL  * m_system;
00050         bool               m_invalid_window;
00051 
00052         SDL_Window       * m_sdl_win;
00053         SDL_GLContext      m_sdl_glcontext;
00054         SDL_Cursor               * m_sdl_custom_cursor;
00055 
00056 public:
00057 
00058         const GHOST_TabletData* GetTabletData() { return NULL; }
00059 
00060         GHOST_WindowSDL(GHOST_SystemSDL *system,
00061                         const STR_String& title,
00062                         GHOST_TInt32 left, GHOST_TInt32 top,
00063                         GHOST_TUns32 width, GHOST_TUns32 height,
00064                         GHOST_TWindowState state,
00065                         const GHOST_TEmbedderWindowID parentWindow,
00066                         GHOST_TDrawingContextType type,
00067                         const bool stereoVisual,
00068                         const GHOST_TUns16 numOfAASamples
00069                         );
00070 
00071         ~GHOST_WindowSDL();
00072 
00073         /* SDL spesific */
00074         SDL_Window *
00075         getSDLWindow()
00076         {
00077                 return m_sdl_win;
00078         }
00079 
00080 
00081         GHOST_TSuccess invalidate(void);
00082 
00088         void validate()
00089         {
00090                 m_invalid_window = false;
00091         }
00092 
00093         bool getValid() const
00094         {
00095                 return (m_sdl_win != NULL);
00096         }
00097 
00098         void getWindowBounds(GHOST_Rect& bounds) const;
00099         void getClientBounds(GHOST_Rect& bounds) const;
00100 
00101 protected:
00102         GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
00103         GHOST_TSuccess removeDrawingContext();
00104 
00105         GHOST_TSuccess
00106         setWindowCursorGrab(GHOST_TGrabCursorMode mode);
00107 
00108         GHOST_TSuccess
00109         setWindowCursorShape(GHOST_TStandardCursor shape);
00110 
00111         GHOST_TSuccess
00112         setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
00113                                    GHOST_TUns8 mask[16][2],
00114                                    int hotX, int hotY);
00115 
00116         GHOST_TSuccess
00117         setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
00118                                    GHOST_TUns8 *mask,
00119                                    int sizex, int sizey,
00120                                    int hotX, int hotY,
00121                                    int fg_color, int bg_color);
00122 
00123         GHOST_TSuccess
00124         setWindowCursorVisibility(bool visible);
00125 
00126         void
00127         setTitle(const STR_String& title);
00128 
00129         void
00130         getTitle(STR_String& title) const;
00131 
00132         GHOST_TSuccess
00133         setClientWidth(GHOST_TUns32 width);
00134 
00135         GHOST_TSuccess
00136         setClientHeight(GHOST_TUns32 height);
00137 
00138         GHOST_TSuccess
00139         setClientSize(GHOST_TUns32 width,
00140                       GHOST_TUns32 height);
00141 
00142         void
00143         screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY,
00144                        GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00145 
00146         void
00147         clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY,
00148                        GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00149 
00150         GHOST_TSuccess
00151         swapBuffers();
00152 
00153         GHOST_TSuccess
00154         activateDrawingContext();
00155 
00156         GHOST_TSuccess
00157         setState(GHOST_TWindowState state);
00158 
00159         GHOST_TWindowState
00160         getState() const;
00161 
00162         GHOST_TSuccess setOrder(GHOST_TWindowOrder order) { return GHOST_kSuccess; } // TODO
00163 
00164 };
00165 
00166 
00167 #endif // _GHOST_WINDOWSDL_H_