Blender V2.61 - r43446
|
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_WINDOWX11_H_ 00034 #define _GHOST_WINDOWX11_H_ 00035 00036 #include "GHOST_Window.h" 00037 #include <X11/Xlib.h> 00038 #include <GL/glx.h> 00039 // For tablets 00040 #ifdef WITH_X11_XINPUT 00041 # include <X11/extensions/XInput.h> 00042 #endif 00043 00044 #include <map> 00045 00046 class STR_String; 00047 class GHOST_SystemX11; 00048 00056 class GHOST_WindowX11 : public GHOST_Window 00057 { 00058 public: 00074 GHOST_WindowX11( 00075 GHOST_SystemX11 *system, 00076 Display * display, 00077 const STR_String& title, 00078 GHOST_TInt32 left, 00079 GHOST_TInt32 top, 00080 GHOST_TUns32 width, 00081 GHOST_TUns32 height, 00082 GHOST_TWindowState state, 00083 const GHOST_TEmbedderWindowID parentWindow, 00084 GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone, 00085 const bool stereoVisual = false, 00086 const GHOST_TUns16 numOfAASamples = 0 00087 ); 00088 00089 bool 00090 getValid( 00091 ) const; 00092 00093 void 00094 setTitle(const STR_String& title); 00095 00096 void 00097 getTitle( 00098 STR_String& title 00099 ) const; 00100 00101 void 00102 getWindowBounds( 00103 GHOST_Rect& bounds 00104 ) const; 00105 00106 void 00107 getClientBounds( 00108 GHOST_Rect& bounds 00109 ) const; 00110 00111 GHOST_TSuccess 00112 setClientWidth( 00113 GHOST_TUns32 width 00114 ); 00115 00116 GHOST_TSuccess 00117 setClientHeight( 00118 GHOST_TUns32 height 00119 ); 00120 00121 GHOST_TSuccess 00122 setClientSize( 00123 GHOST_TUns32 width, 00124 GHOST_TUns32 height 00125 ); 00126 00127 void 00128 screenToClient( 00129 GHOST_TInt32 inX, 00130 GHOST_TInt32 inY, 00131 GHOST_TInt32& outX, 00132 GHOST_TInt32& outY 00133 ) const; 00134 00135 void 00136 clientToScreen( 00137 GHOST_TInt32 inX, 00138 GHOST_TInt32 inY, 00139 GHOST_TInt32& outX, 00140 GHOST_TInt32& outY 00141 ) const; 00142 00143 GHOST_TWindowState 00144 getState( 00145 ) const ; 00146 00147 GHOST_TSuccess 00148 setState( 00149 GHOST_TWindowState state 00150 ); 00151 00152 GHOST_TSuccess 00153 setOrder( 00154 GHOST_TWindowOrder order 00155 ); 00156 00157 GHOST_TSuccess 00158 swapBuffers( 00159 ); 00160 00161 GHOST_TSuccess 00162 activateDrawingContext( 00163 ); 00164 GHOST_TSuccess 00165 invalidate( 00166 ); 00167 00172 ~GHOST_WindowX11(); 00173 00184 void 00185 validate( 00186 ); 00187 00191 Window 00192 getXWindow( 00193 ); 00194 #ifdef WITH_X11_XINPUT 00195 class XTablet 00196 { 00197 public: 00198 GHOST_TabletData CommonData; 00199 00200 XDevice* StylusDevice; 00201 XDevice* EraserDevice; 00202 00203 XID StylusID, EraserID; 00204 00205 int MotionEvent; 00206 int ProxInEvent; 00207 int ProxOutEvent; 00208 00209 int PressureLevels; 00210 int XtiltLevels, YtiltLevels; 00211 }; 00212 00213 XTablet& GetXTablet() 00214 { return m_xtablet; } 00215 00216 const GHOST_TabletData* GetTabletData() 00217 { return &m_xtablet.CommonData; } 00218 #else // WITH_X11_XINPUT 00219 const GHOST_TabletData* GetTabletData() 00220 { return NULL; } 00221 #endif // WITH_X11_XINPUT 00222 00223 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING) 00224 XIC getX11_XIC() { return m_xic; } 00225 #endif 00226 00227 /* 00228 * Need this in case that we want start the window 00229 * in FullScree or Maximized state. 00230 * Check GHOST_WindowX11.cpp 00231 */ 00232 bool m_post_init; 00233 GHOST_TWindowState m_post_state; 00234 00235 protected: 00241 GHOST_TSuccess 00242 installDrawingContext( 00243 GHOST_TDrawingContextType type 00244 ); 00245 00250 GHOST_TSuccess 00251 removeDrawingContext( 00252 ); 00253 00258 GHOST_TSuccess 00259 setWindowCursorVisibility( 00260 bool visible 00261 ); 00262 00268 GHOST_TSuccess 00269 setWindowCursorGrab( 00270 GHOST_TGrabCursorMode mode 00271 ); 00272 00273 GHOST_TGrabCursorMode 00274 getWindowCursorGrab() const; 00275 00280 GHOST_TSuccess 00281 setWindowCursorShape( 00282 GHOST_TStandardCursor shape 00283 ); 00284 00289 GHOST_TSuccess 00290 setWindowCustomCursorShape( 00291 GHOST_TUns8 bitmap[16][2], 00292 GHOST_TUns8 mask[16][2], 00293 int hotX, 00294 int hotY 00295 ); 00296 00301 GHOST_TSuccess 00302 setWindowCustomCursorShape( 00303 GHOST_TUns8 *bitmap, 00304 GHOST_TUns8 *mask, 00305 int sizex, 00306 int sizey, 00307 int hotX, 00308 int hotY, 00309 int fg_color, 00310 int bg_color 00311 ); 00312 00313 private : 00314 00316 00317 GHOST_WindowX11( 00318 ); 00319 00320 GHOST_WindowX11( 00321 const GHOST_WindowX11 & 00322 ); 00323 00324 Cursor 00325 getStandardCursor( 00326 GHOST_TStandardCursor g_cursor 00327 ); 00328 00329 Cursor 00330 getEmptyCursor( 00331 ); 00332 00333 #ifdef WITH_X11_XINPUT 00334 void initXInputDevices(); 00335 #endif 00336 00337 GLXContext m_context; 00338 Window m_window; 00339 Display *m_display; 00340 XVisualInfo *m_visual; 00341 GHOST_TWindowState m_normal_state; 00342 00344 static GLXContext s_firstContext; 00345 00347 00348 GHOST_SystemX11 * m_system; 00349 00350 bool m_valid_setup; 00351 00353 bool m_invalid_window; 00354 00356 Cursor m_empty_cursor; 00357 00359 Cursor m_custom_cursor; 00360 00362 std::map<unsigned int, Cursor> m_standard_cursors; 00363 00364 #ifdef WITH_X11_XINPUT 00365 /* Tablet devices */ 00366 XTablet m_xtablet; 00367 #endif 00368 00369 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING) 00370 XIC m_xic; 00371 #endif 00372 00373 void icccmSetState(int state); 00374 int icccmGetState() const; 00375 00376 void netwmMaximized(bool set); 00377 bool netwmIsMaximized() const; 00378 00379 void netwmFullScreen(bool set); 00380 bool netwmIsFullScreen() const; 00381 00382 void motifFullScreen(bool set); 00383 bool motifIsFullScreen() const; 00384 }; 00385 00386 00387 #endif // _GHOST_WINDOWX11_H_