Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoWinGDIWidget.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2017 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _SO_WIN_GDI_WIDGET_H_
24#define _SO_WIN_GDI_WIDGET_H_
25
26#include <Inventor/Win/SoWinBeginStrict.h>
27
28#include <Inventor/Win/SoWinComponent.h>
29
31//
32// Class: SoWinGDIWidget
33//
34//
36
37{
38 public:
39
40 virtual Window getNormalWindow();
41
42 Hdc getNormalDC() { return hdcNormal; }
43 Hdc copyWindowBits() ;
44
45 SoWidget getNormalWidget() { return singleBufferWidget; }
46
47 //
48 // shows/hides a border of thickness 3 around the glx widgets. This
49 // if OFF by default, but turned on by the render area.
50 //
51 void setBorder(SbBool onOrOff);
52 int getBorderSize() {return borderSize;} ;
53 SbBool isBorder() const { return borderSize != 0; }
54
55 private:
56
57 SoWinGDIWidget(
58 SoWidget parent = NULL,
59 const char *name = NULL,
60 SbBool buildInsideParent = TRUE,
61 SbBool buildNow = TRUE,
62 SbBool sync = TRUE);
63
64 virtual ~SoWinGDIWidget();
65
66 // subclasses MUST redefine redraw() to draw in the normal bit planes.
67 virtual void redraw() = 0;
68 virtual void processEvent(XAnyEvent *anyevent);
69
70 // subclasses can redefine these to do something useful.
71 // initGraphic() is called whenever a GLX window gets created
72 // sizeChanged() is called whenever the window changes size
73 // widgetChanged() is called whenever the widget is changed (i.e. at
74 // initialization or after switching from single->double buffer)
75 virtual void initGraphic();
76 virtual void sizeChanged(const SbVec2s &newSize);
77 virtual void widgetChanged(SoWidget newWidget);
78
79 // sets/gets the size of the glx widget(s) - Note this size could be
80 // different from the SoWinComponent::getSize() method which return
81 // the size of the component, not necessary the same as the glx widget
82 // window (because of extra stuff like the decoration in the viewers).
83 void setGlxSize(SbVec2s newSize);
84 const SbVec2s & getGlxSize() const { return glxSize; }
85 SbVec2s glxSize; // size of glx widgets which is always up to date
86
87 // subclasses can use this routine as the event handler for any
88 // devices they wish to get input from.
89 static void eventHandler(SoWidget, SoWinGDIWidget *, XAnyEvent *, Boolean *);
90
91 SbBool isRGBMode() { return (TRUE); }
92
93 Colormap colorMap; // set when color index is used
94
95 // make those methods protected so enable the SoWinRenderArea to use them
96 // directly when it needs to build the widget and get its resources.
97 SoWidget buildWidget(SoWidget parent);
98 SoWidget getGlxMgrWidget() { return singleBufferWidget; }
99
100 Pixmap XCreatePixmap(
101 UINT *dpy,
102 Window w,
103 int nWidth,
104 int nHeight,
105 int nDepth) ;
106
107 void XFillRectangle(
108 UINT *dpy,
109 Pixmap pix,
110 HDC gc,
111 int x,int y,
112 int width,int height);
113
114 void XDrawLine(
115 UINT *dpy,
116 Pixmap pix,
117 HDC gc,
118 int x1, int y1,
119 int x2, int y2);
120
121 void XCopyArea(
122 UINT* display ,
123 Hwnd src ,
124 Hwnd dest ,
125 HDC src_gc , /* extra hack for windows */
126 HDC dst_gc ,
127 int src_x ,
128 int src_y ,
129 unsigned int width ,
130 unsigned int height ,
131 int dest_x ,
132 int dest_y
133 );
134
135
136 private:
137 // local vars
138 SoWidget singleBufferWidget;
139
140 // Note for _WIN32:
141 // 1) All the "SoWidget" values above are actually type "HWND".
142 // 2) The "GLXContext" values above are actually type "HGLRC".
143
144 // For _WIN32 we need a GL context *and* a device context for each
145 // GL drawing window (we don't need one for the mgr because we don't
146 // plan to ever draw in it). These correspond to the "ctx..." vars.
147 // Note: This plan depends on use of the CS_OWNDC style.
148
149 Hdc hdcNormal;
150
151 // For _WIN32 we also need a logical color palette for each drawing
152 // area if we happen to running on an 8bit device...
153
154 HPALETTE palNormal ;
155 HPALETTE oldPalette; // Need this for cleanup before deletion
156
157 virtual void onExpose();
158
159 private:
160 // For _WIN32 we also need to remember who our parent is
161 SoWidget parent;
162
163 // For _WIN32 we have to simulate the behavior of X where getting a
164 // mouse button down event guarantees you will also get the
165 // corresponding button up event. Otherwise examiner viewer windows
166 // get out of sync if a mouse button is released outside the window.
167 UINT mouseCaptured;
168
169 // NOTYET?
170 // If parent of glxMgrWindow is MDI we need to call DefMDIChildProc
171 // in mgrWindowProce instead of DefWindowProc
172 // SbBool m_nParentIsMDI ;
173
174
175 int borderSize;
176
177 // specify if sizeChanged() should be called when an expose event
178 // is received (as opposed to when a resize event is received, where
179 // the window hasn't yet been maped to the new size).
180 // ??? a GlxDraw bug ?
181 SbBool windowResized;
182
183 // creates a GLX widget of the correct current type and get the current
184 // set of windows, color maps, etc...
185 void destroyNormalWindows();
186 void destroyGDIWidget(SoWidget &w);
187
188 // callbacks from glx widget
189 static void ginitCB(SoWidget, SoWinGDIWidget *, XtPointer);
190 static void exposeCB(SoWidget, SoWinGDIWidget *, XtPointer);
191 static void resizeCB(SoWidget, SoWinGDIWidget *, XtPointer);
192 static void mgrStructureNotifyCB(SoWidget, SoWinGDIWidget *, XAnyEvent *, Boolean *);
193
194 // Window proc for SoWinGDI drawing windows
195 static LRESULT CALLBACK gdiWindowProc( Hwnd hwnd, UINT message,
196 WPARAM wParam, LPARAM lParam );
197};
198
199#include <Inventor/Win/SoWinEndStrict.h>
200
201#endif // _SO_WIN_GDI_WIDGET_H_
202
2D vector class.
Definition SbVec.h:700
int SbBool
Boolean type.
Definition SbBase.h:87
char Boolean
Definition SoQtDef.h:124
void * XtPointer
Definition SoQtDef.h:122