Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinGDIThumbWheel.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-2014 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_THUMB_WHEEL_
24#define _SO_WIN_GDI_THUMB_WHEEL_
25
26#include <Inventor/Win/SoWinBeginStrict.h>
27
28#include <Inventor/Win/SoWinGDIWidget.h>
29#include <Inventor/misc/SoCallbackList.h>
30
31
32class SoWinMouse;
33class SoDataCallbackList;
34
35class SgThumbWheelPart ;
36class XmPrimitivePart ;
37
38// callback function prototypes
39//mmh: typedef void SoWinGDIThumbWheelCB(void *userData, float val);
40typedef void SoWinGDIThumbWheelCB( void *userData, void *data );
41
42//mmh:
43// callback data struct
44{ int reason;
45 float value;
46} SoWinGDIThumbWheelCBData;
47
48//mmh:
49// callback reasons
50#define THUMBWHEEL_START 0
51#define THUMBWHEEL_DRAG 1
52#define THUMBWHEEL_FINISH 2
53#define THUMBWHEEL_VALUE_CHANGE 3
54
55
56#define XmCR_DRAG THUMBWHEEL_DRAG
57#define XmCR_VALUE_CHANGED THUMBWHEEL_VALUE_CHANGE
58
59
60class SoWinGDIThumbWheel ;
61typedef SoWinGDIThumbWheel *SgThumbWheelWidget ;
62
64//
65// Class: SoWinGDIThumbWheel
66//
67//
69
70{
71
72 public:
73
74 SoWinGDIThumbWheel(SbBool horizontal);
75 SoWinGDIThumbWheel(
76 SoWidget parent = NULL,
77 const char *name = NULL,
78 SbBool buildInsideParent = TRUE,
79 SbBool horizontal = TRUE);
80
81 // This constructor takes a boolean whether to build the widget now.
82 // call realizeWidget() for it to be built.
83 SoEXTENDER
84 SoWinGDIThumbWheel(
85 SoWidget parent,
86 const char *name,
87 SbBool buildInsideParent,
88 SbBool horizontal,
89 SbBool buildNow);
90
91 ~SoWinGDIThumbWheel();
92
93 void realizeWidget() ;
94
95 //
96 // Routines to specify the wheel value (a rotation given in radians) and get
97 // the current wheel value.
98 //
99 // NOTE: setValue() will call valueChanged callbacks if the value differs.
100 //
101 void setValue(float v);
102 float getValue() { return (float)thumbWheel.value; }
103
104 //
105 // Those routines are used to register callbacks for the different thumb wheel
106 // actions.
107 //
108 // NOTE: the start and finish callbacks are only to signal when the mouse
109 // goes down and up. No valid callback data is passed (NULL passed).
110 //
111 void addStartCallback(
112 SoWinGDIThumbWheelCB *f,
113 void *userData = NULL);
114 void addValueChangedCallback(
115 SoWinGDIThumbWheelCB *f,
116 void *userData = NULL);
117
118 void addDragCallback(
119 SoWinGDIThumbWheelCB *f,
120 void *userData = NULL);
121
122
123 void addFinishCallback(
124 SoWinGDIThumbWheelCB *f,
125 void *userData = NULL);
126
127 void removeStartCallback(
128 SoWinGDIThumbWheelCB *f,
129 void *userData = NULL);
130 void removeValueChangedCallback(
131 SoWinGDIThumbWheelCB *f,
132 void *userData = NULL);
133
134 void removeDragCallback(
135 SoWinGDIThumbWheelCB *f,
136 void *userData = NULL);
137
138 void removeFinishCallback(
139 SoWinGDIThumbWheelCB *f,
140 void *userData = NULL);
141
142 // true while the value is changing interactively
143 SbBool isInteractive() { return interactive; }
144
145 // new stuff
146 void setBounds(int nLower,int nUpper)
147 { thumbWheel.lower_bound = nLower ;
148 thumbWheel.upper_bound = nUpper ; } ;
149
150 void setHomePosition(int n)
151 { thumbWheel.home_position = n; } ;
152
153 void setAngleRange(int n)
154 { thumbWheel.angle_range = n; } ;
155
156 void setUnitsPerRotation(int n)
157 { thumbWheel.angle_factor = n; } ;
158
159 void setHighlightThickness(int n)
160 { primitive.highlight_thickness = n; } ;
161
162 void setShadowThickness(int n)
163 { primitive.shadow_thickness = n; } ;
164
165
166 void setValue(int n)
167 { thumbWheel.value = n; } ;
168
169 void setOrientation(unsigned char n)
170 { thumbWheel.orientation = n; } ;
171
172 void setAnimate(SbBool n)
173 { thumbWheel.animate = n; } ;
174
175 void setShowHomeButton(SbBool n)
176 { thumbWheel.show_home_button = n; } ;
177
178
179
180 private:
181
182
183 SoWidget buildWidget(SoWidget parent);
184
185 private:
186 // redefine these to do thumb wheel specific things
187 virtual void redraw();
188 virtual void processEvent(XAnyEvent *anyevent);
189 virtual void sizeChanged(const SbVec2s &newSize);
190
191 // local variables
192 SbBool horizontal;
193 SbBool realized;
194 SoWinMouse *mouse;
195
196 // callback variables
197 SoDataCallbackList *startCallbacks;
198 SoDataCallbackList *finishCallbacks;
199 SoDataCallbackList *changedCallbacks;
200 SoDataCallbackList *dragCallbacks;
201 SbBool interactive;
202
203 // this is called by both constructors
204 void constructorCommon(SbBool horizontal, SbBool buildNow);
205
206 // new stuff from motif thumbwheel
207
208 typedef struct _XmPrimitivePart
209 {
210 int highlight_thickness ;
211 int shadow_thickness ;
212 } XmPrimitivePart ;
213
214 typedef struct _XmCorePart
215 {
216 int width ;
217 int height ;
218 int depth ;
219 } XmCorePart ;
220
221 typedef int Dimension ;
222 typedef int Cardinal ;
223 typedef void XtString ;
224
225
226 typedef struct _SgThumbWheelPart {
227 /* resources */
228 int lower_bound;
229 int upper_bound;
230 int home_position;
231 int angle_range;
232 int angle_factor;
233 int value;
234 unsigned char orientation;
235 SbBool animate;
236 SbBool show_home_button;
237
238 /* private state */
239 SbBool infinite;
240 SbBool dragging;
241 int drag_begin_value;
242 int last_mouse_position;
243 SbBool pegged;
244 int pegged_mouse_position;
245 Dimension viewable_pixels;
246 int user_pixels;
247 Pixmap pix1;
248 Pixmap pix2;
249 Pixmap pix3;
250 Pixmap pix4;
251 Pixmap pix1_hilite;
252 Pixmap pix2_hilite;
253 Pixmap pix3_hilite;
254 Pixmap pix4_hilite;
255 Pixmap current_quiet_pixmap; /* this will be equal to one of the others */
256 Pixmap current_hilite_pixmap; /* this will be equal to one of the others */
257 SbBool wheel_hilite;
258
259 Pixmap button_quiet_pixmap;
260 Pixmap button_hilite_pixmap;
261 SbBool button_hilite;
262
263 HDC foreground_GC;
264 /*
265 shaderptr shader;
266 */
267
268 int wheel_x;
269 int wheel_y;
270 int button_x;
271 int button_y;
272
273 SbBool home_button_armed;
274 SbBool resizePixmaps ;
275
276 } SgThumbWheelPart ;
277
278
279 XmCorePart core ;
280 XmPrimitivePart primitive;
281 SgThumbWheelPart thumbWheel;
282
283 HDC hMemDC ;
284 HPEN hPen[7] ;
285 HBRUSH hBrush[7] ;
286 HPEN hOldPen ;
287 HBRUSH hOldBrush ;
288
289 void Initialize();
290 void GetForegroundGC() ;
291 int ConvertPixelsToUserUnits(int pixels);
292 int ConvertUserUnitsToPixels(int uu);
293 void CreateAndRenderPixmaps() ;
294 void Redisplay() ;
295
296 HDC SetupGC(int nGC) ;
297
298 void RenderPixmap(int which);
299 void RenderButtonPixmaps();
300
301 void Destroy() ;
302 void FreePixmaps();
303 void SetCurrentPixmap( SbBool value_increased) ;
304
305 void Resize() ;
306
307 SbBool MouseIsInWheel(int event_x,int event_y);
308 SbBool MouseIsInButton(int event_x,int event_y);
309
310 void Motion(XEvent *event, XtString *params, Cardinal *num_params);
311 void Btn1Down(XEvent *event, XtString *params, Cardinal *num_params);
312 void Btn2Down(XEvent *event, XtString *params, Cardinal *num_params);
313 void Btn3Down(XEvent *event, XtString *params, Cardinal *num_params);
314 void Btn1Motion(XEvent *event, XtString *params, Cardinal *num_params);
315 void Btn2Motion(XEvent *event, XtString *params, Cardinal *num_params);
316 void Btn3Motion(XEvent *event, XtString *params, Cardinal *num_params);
317 void Btn1Up(XEvent *event, XtString *params, Cardinal *num_params) ;
318 void Btn2Up(XEvent *event, XtString *params, Cardinal *num_params) ;
319 void Btn3Up(XEvent *event, XtString *params, Cardinal *num_params) ;
320 void Enter(XEvent *event, XtString *params, Cardinal *num_params);
321 void Leave(XEvent *event, XtString *params, Cardinal *num_params);
322
323 void PageUp(XEvent *event, XtString *params, Cardinal *num_params);
324 void PageDown(XEvent *event, XtString *params, Cardinal *num_params);
325 void Up(XEvent *event, XtString *params, Cardinal *num_params);
326 void Down(XEvent *event, XtString *params, Cardinal *num_params);
327 void Left(XEvent *event, XtString *params, Cardinal *num_params);
328 void Right(XEvent *event, XtString *params, Cardinal *num_params);
329 void Help(XEvent *event, XtString *params, Cardinal *num_params);
330 void BeginLine(XEvent *event, XtString *params, Cardinal *num_params);
331 void EndLine(XEvent *event, XtString *params, Cardinal *num_params);
332 void ArmHomeButton() ;
333 void DisarmHomeButton() ;
334 void RenderButtonShadows() ;
335 int ProcessMouseEvent( int event_x,int event_y) ;
336 void IssueCallback( int reason, int value, XEvent *event) ;
337
338 Boolean SetValues(SgThumbWheelWidget rw, SgThumbWheelWidget nw, ArgList args, Cardinal *num_args);
339 Boolean ValidateFields(SgThumbWheelWidget req_w,
340 SgThumbWheelWidget new_w) ;
341
342
343
344};
345
346#include <Inventor/Win/SoWinEndStrict.h>
347
348#endif /* _SO_WIN_THUMB_WHEEL_ */
349
350
2D vector class.
Definition SbVec.h:700
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Translates and r...
Definition SoWinMouse.h:56
int SbBool
Boolean type.
Definition SbBase.h:87
union _XEvent XEvent
Definition SoQtDef.h:126
char Boolean
Definition SoQtDef.h:124