Blender V2.61 - r43446

GHOST_WindowWin32.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_WIN32_H_
00034 #define _GHOST_WINDOW_WIN32_H_
00035 
00036 #ifndef WIN32
00037 #error WIN32 only!
00038 #endif // WIN32
00039 
00040 #include "GHOST_Window.h"
00041 #include "GHOST_TaskbarWin32.h"
00042 
00043 #define _WIN32_WINNT 0x501 // require Windows XP or newer
00044 #define WIN32_LEAN_AND_MEAN
00045 #include <windows.h>
00046 
00047 
00048 #include <wintab.h>
00049 #define PACKETDATA  (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
00050 #define PACKETMODE  PK_BUTTONS
00051 #include <pktdef.h>
00052 
00053 class GHOST_SystemWin32;
00054 class GHOST_DropTargetWin32;
00055 
00056 // typedefs for WinTab functions to allow dynamic loading
00057 typedef UINT (API * GHOST_WIN32_WTInfo) ( UINT, UINT, LPVOID );
00058 typedef HCTX (API * GHOST_WIN32_WTOpen) (HWND, LPLOGCONTEXTA, BOOL);
00059 typedef BOOL (API * GHOST_WIN32_WTClose) (HCTX);
00060 typedef BOOL (API * GHOST_WIN32_WTPacket) (HCTX, UINT, LPVOID);
00061 
00067 class GHOST_WindowWin32 : public GHOST_Window {
00068 public:
00083     GHOST_WindowWin32(
00084         GHOST_SystemWin32 * system,
00085         const STR_String& title,
00086         GHOST_TInt32 left,
00087         GHOST_TInt32 top,
00088         GHOST_TUns32 width,
00089         GHOST_TUns32 height,
00090         GHOST_TWindowState state,
00091         GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
00092         const bool stereoVisual = false,
00093         const GHOST_TUns16 numOfAASamples = 0,
00094         GHOST_TEmbedderWindowID parentWindowHwnd=0,
00095         GHOST_TSuccess msEnabled = GHOST_kFailure,
00096         int msPixelFormat = 0
00097     );
00098 
00103     virtual ~GHOST_WindowWin32();
00104 
00110     GHOST_Window *getNextWindow();
00111 
00116     virtual bool getValid() const;
00117 
00122     virtual HWND getHWND() const;
00123 
00128     virtual void setTitle(const STR_String& title);
00129 
00134     virtual void getTitle(STR_String& title) const;
00135 
00141     virtual void getWindowBounds(GHOST_Rect& bounds) const;
00142     
00148     virtual void getClientBounds(GHOST_Rect& bounds) const;
00149 
00154     virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
00155 
00160     virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
00161 
00167     virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
00168 
00173     virtual GHOST_TWindowState getState() const;
00174 
00182     virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00183 
00191     virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
00192 
00198     virtual GHOST_TSuccess setState(GHOST_TWindowState state);
00199 
00205     virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
00206 
00211     virtual GHOST_TSuccess swapBuffers();
00212 
00217     virtual GHOST_TSuccess activateDrawingContext();
00218 
00222     virtual GHOST_TSuccess invalidate();
00223 
00228     virtual GHOST_TSuccess setProgressBar(float progress);
00229     
00233     virtual GHOST_TSuccess endProgressBar();
00234     
00239     static LPCSTR getWindowClassName() { return s_windowClassName; }
00240 
00252     void registerMouseClickEvent(int press);
00253 
00258     void lostMouseCapture();
00259 
00265     void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
00266 
00267     const GHOST_TabletData* GetTabletData()
00268     { return m_tabletData; }
00269 
00270     void processWin32TabletInitEvent();
00271     void processWin32TabletEvent(WPARAM wParam, LPARAM lParam);
00272 
00273 protected:
00274     GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
00275 
00281     virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
00282 
00287     virtual GHOST_TSuccess removeDrawingContext();
00288 
00293     virtual GHOST_TSuccess setWindowCursorVisibility(bool visible);
00294     
00300     virtual GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
00301     
00306     virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
00307 
00312     virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
00313                                                       GHOST_TUns8 mask[16][2],
00314                                                       int hotX, int hotY);
00315 
00316     virtual GHOST_TSuccess setWindowCustomCursorShape(
00317         GHOST_TUns8 *bitmap, 
00318         GHOST_TUns8 *mask, 
00319         int sizex, 
00320         int sizey,
00321         int hotX, 
00322         int hotY,
00323         int fg_color, 
00324         int bg_color
00325     );
00326     
00328     GHOST_SystemWin32 * m_system;
00330     GHOST_DropTargetWin32 * m_dropTarget;
00332     HWND m_hWnd;
00334     HDC m_hDC;
00336     HGLRC m_hGlRc;
00338     static HGLRC s_firsthGLRc;
00340     static HDC s_firstHDC;
00342     bool m_hasMouseCaptured;
00345     bool m_hasGrabMouse;
00347     int m_nPressedButtons;
00349     HCURSOR m_customCursor;
00350 
00352     ITaskbarList3 * m_Bar;
00353 
00354     static LPCSTR s_windowClassName;
00355     static const int s_maxTitleLength;
00356 
00358     HMODULE m_wintab;
00359 
00361     GHOST_TabletData* m_tabletData;
00362 
00364     HCTX m_tablet;
00365     LONG m_maxPressure;
00366     LONG m_maxAzimuth, m_maxAltitude;
00367 
00369     GHOST_TUns16 m_multisample;
00370 
00372     GHOST_TSuccess m_multisampleEnabled;
00373 
00375     int m_msPixelFormat;
00376 
00378     const STR_String& m_title;
00379     GHOST_TInt32 m_left;
00380     GHOST_TInt32 m_top;
00381     GHOST_TUns32 m_width;
00382     GHOST_TUns32 m_height;
00383     GHOST_TWindowState m_normal_state;
00384     bool m_stereo;
00385 
00387     GHOST_Window *m_nextWindow;
00388 
00390     GHOST_TEmbedderWindowID m_parentWindowHwnd;
00391 };
00392 
00393 #endif // _GHOST_WINDOW_WIN32_H_