Blender V2.61 - r43446

GHOST_WindowCocoa.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef _GHOST_WINDOW_COCOA_H_
00034 #define _GHOST_WINDOW_COCOA_H_
00035 
00036 #ifndef __APPLE__
00037 #error Apple OSX only!
00038 #endif // __APPLE__
00039 
00040 #include "GHOST_Window.h"
00041 #include "STR_String.h"
00042 
00043 @class CocoaWindow;
00044 @class CocoaOpenGLView;
00045 
00046 class GHOST_SystemCocoa;
00047 
00059 class GHOST_WindowCocoa : public GHOST_Window {
00060 public:
00076     GHOST_WindowCocoa(
00077         GHOST_SystemCocoa *systemCocoa,
00078         const STR_String& title,
00079         GHOST_TInt32 left,
00080         GHOST_TInt32 bottom,
00081         GHOST_TUns32 width,
00082         GHOST_TUns32 height,
00083         GHOST_TWindowState state,
00084         GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
00085         const bool stereoVisual = false,
00086         const GHOST_TUns16 numOfAASamples = 0
00087     );
00088 
00093     virtual ~GHOST_WindowCocoa();
00094 
00099     virtual bool getValid() const;
00100     
00105     virtual void* getOSWindow() const;
00106 
00111     virtual void setTitle(const STR_String& title);
00112 
00117     virtual void getTitle(STR_String& title) const;
00118 
00124     virtual void getWindowBounds(GHOST_Rect& bounds) const;
00125     
00131     virtual void getClientBounds(GHOST_Rect& bounds) const;
00132 
00137     virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
00138 
00143     virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
00144 
00150     virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
00151 
00156     virtual GHOST_TWindowState getState() const;
00157 
00163     virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges);
00164     
00172     virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00173 
00181     virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00182 
00191     void clientToScreenIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00192 
00201     void screenToClientIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00202 
00207     NSScreen* getScreen();
00208     
00214     virtual GHOST_TSuccess setState(GHOST_TWindowState state);
00215 
00221     virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
00222 
00227     virtual GHOST_TSuccess swapBuffers();
00228 
00234     GHOST_TSuccess updateDrawingContext();
00235 
00240     virtual GHOST_TSuccess activateDrawingContext();
00241 
00242     virtual void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
00243     
00244 
00245     const GHOST_TabletData* GetTabletData()
00246     { return &m_tablet; }
00247 
00248     GHOST_TabletData& GetCocoaTabletData()
00249     { return m_tablet; }
00250     
00255     virtual GHOST_TSuccess setProgressBar(float progress);
00256     
00260     virtual GHOST_TSuccess endProgressBar();
00261 protected:
00267     virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
00268 
00273     virtual GHOST_TSuccess removeDrawingContext();
00274     
00279     virtual GHOST_TSuccess invalidate();
00280 
00285     virtual GHOST_TSuccess setWindowCursorVisibility(bool visible);
00286     
00291     virtual GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
00292         
00297     virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
00298 
00303     virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
00304                     int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color);
00305                     
00306     virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
00307 
00309     CocoaWindow *m_window;
00310     
00312     CocoaOpenGLView *m_openGLView; 
00313 
00315     NSOpenGLContext *m_openGLContext;
00316     
00318     GHOST_SystemCocoa *m_systemCocoa;
00319             
00321     static NSOpenGLContext *s_firstOpenGLcontext;
00322     
00323     NSCursor*   m_customCursor;
00324 
00325     GHOST_TabletData m_tablet;
00326 };
00327 
00328 #endif // _GHOST_WINDOW_COCOA_H_
00329