00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2017 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 #ifndef _SO_WIN_GDI_WIDGET_H_ 00024 #define _SO_WIN_GDI_WIDGET_H_ 00025 00026 #include <Inventor/Win/SoWinBeginStrict.h> 00027 00028 #include <Inventor/Win/SoWinComponent.h> 00029 00031 // 00032 // Class: SoWinGDIWidget 00033 // 00034 // 00036 00037 { 00038 public: 00039 00040 virtual Window getNormalWindow(); 00041 00042 Hdc getNormalDC() { return hdcNormal; } 00043 Hdc copyWindowBits() ; 00044 00045 SoWidget getNormalWidget() { return singleBufferWidget; } 00046 00047 // 00048 // shows/hides a border of thickness 3 around the glx widgets. This 00049 // if OFF by default, but turned on by the render area. 00050 // 00051 void setBorder(SbBool onOrOff); 00052 int getBorderSize() {return borderSize;} ; 00053 SbBool isBorder() const { return borderSize != 0; } 00054 00055 private: 00056 00057 SoWinGDIWidget( 00058 SoWidget parent = NULL, 00059 const char *name = NULL, 00060 SbBool buildInsideParent = TRUE, 00061 SbBool buildNow = TRUE, 00062 SbBool sync = TRUE); 00063 00064 virtual ~SoWinGDIWidget(); 00065 00066 // subclasses MUST redefine redraw() to draw in the normal bit planes. 00067 virtual void redraw() = 0; 00068 virtual void processEvent(XAnyEvent *anyevent); 00069 00070 // subclasses can redefine these to do something useful. 00071 // initGraphic() is called whenever a GLX window gets created 00072 // sizeChanged() is called whenever the window changes size 00073 // widgetChanged() is called whenever the widget is changed (i.e. at 00074 // initialization or after switching from single->double buffer) 00075 virtual void initGraphic(); 00076 virtual void sizeChanged(const SbVec2s &newSize); 00077 virtual void widgetChanged(SoWidget newWidget); 00078 00079 // sets/gets the size of the glx widget(s) - Note this size could be 00080 // different from the SoWinComponent::getSize() method which return 00081 // the size of the component, not necessary the same as the glx widget 00082 // window (because of extra stuff like the decoration in the viewers). 00083 void setGlxSize(SbVec2s newSize); 00084 const SbVec2s & getGlxSize() const { return glxSize; } 00085 SbVec2s glxSize; // size of glx widgets which is always up to date 00086 00087 // subclasses can use this routine as the event handler for any 00088 // devices they wish to get input from. 00089 static void eventHandler(SoWidget, SoWinGDIWidget *, XAnyEvent *, Boolean *); 00090 00091 SbBool isRGBMode() { return (TRUE); } 00092 00093 Colormap colorMap; // set when color index is used 00094 00095 // make those methods protected so enable the SoWinRenderArea to use them 00096 // directly when it needs to build the widget and get its resources. 00097 SoWidget buildWidget(SoWidget parent); 00098 SoWidget getGlxMgrWidget() { return singleBufferWidget; } 00099 00100 Pixmap XCreatePixmap( 00101 UINT *dpy, 00102 Window w, 00103 int nWidth, 00104 int nHeight, 00105 int nDepth) ; 00106 00107 void XFillRectangle( 00108 UINT *dpy, 00109 Pixmap pix, 00110 HDC gc, 00111 int x,int y, 00112 int width,int height); 00113 00114 void XDrawLine( 00115 UINT *dpy, 00116 Pixmap pix, 00117 HDC gc, 00118 int x1, int y1, 00119 int x2, int y2); 00120 00121 void XCopyArea( 00122 UINT* display , 00123 Hwnd src , 00124 Hwnd dest , 00125 HDC src_gc , /* extra hack for windows */ 00126 HDC dst_gc , 00127 int src_x , 00128 int src_y , 00129 unsigned int width , 00130 unsigned int height , 00131 int dest_x , 00132 int dest_y 00133 ); 00134 00135 00136 private: 00137 // local vars 00138 SoWidget singleBufferWidget; 00139 00140 // Note for _WIN32: 00141 // 1) All the "SoWidget" values above are actually type "HWND". 00142 // 2) The "GLXContext" values above are actually type "HGLRC". 00143 00144 // For _WIN32 we need a GL context *and* a device context for each 00145 // GL drawing window (we don't need one for the mgr because we don't 00146 // plan to ever draw in it). These correspond to the "ctx..." vars. 00147 // Note: This plan depends on use of the CS_OWNDC style. 00148 00149 Hdc hdcNormal; 00150 00151 // For _WIN32 we also need a logical color palette for each drawing 00152 // area if we happen to running on an 8bit device... 00153 00154 HPALETTE palNormal ; 00155 HPALETTE oldPalette; // Need this for cleanup before deletion 00156 00157 virtual void onExpose(); 00158 00159 private: 00160 // For _WIN32 we also need to remember who our parent is 00161 SoWidget parent; 00162 00163 // For _WIN32 we have to simulate the behavior of X where getting a 00164 // mouse button down event guarantees you will also get the 00165 // corresponding button up event. Otherwise examiner viewer windows 00166 // get out of sync if a mouse button is released outside the window. 00167 UINT mouseCaptured; 00168 00169 // NOTYET? 00170 // If parent of glxMgrWindow is MDI we need to call DefMDIChildProc 00171 // in mgrWindowProce instead of DefWindowProc 00172 // SbBool m_nParentIsMDI ; 00173 00174 00175 int borderSize; 00176 00177 // specify if sizeChanged() should be called when an expose event 00178 // is received (as opposed to when a resize event is received, where 00179 // the window hasn't yet been maped to the new size). 00180 // ??? a GlxDraw bug ? 00181 SbBool windowResized; 00182 00183 // creates a GLX widget of the correct current type and get the current 00184 // set of windows, color maps, etc... 00185 void destroyNormalWindows(); 00186 void destroyGDIWidget(SoWidget &w); 00187 00188 // callbacks from glx widget 00189 static void ginitCB(SoWidget, SoWinGDIWidget *, XtPointer); 00190 static void exposeCB(SoWidget, SoWinGDIWidget *, XtPointer); 00191 static void resizeCB(SoWidget, SoWinGDIWidget *, XtPointer); 00192 static void mgrStructureNotifyCB(SoWidget, SoWinGDIWidget *, XAnyEvent *, Boolean *); 00193 00194 // Window proc for SoWinGDI drawing windows 00195 static LRESULT CALLBACK gdiWindowProc( Hwnd hwnd, UINT message, 00196 WPARAM wParam, LPARAM lParam ); 00197 }; 00198 00199 #include <Inventor/Win/SoWinEndStrict.h> 00200 00201 #endif // _SO_WIN_GDI_WIDGET_H_ 00202 00203