00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_WIN_GDI_THUMB_WHEEL_
00024 #define _SO_WIN_GDI_THUMB_WHEEL_
00025
00026 #include <Inventor/Win/SoWinBeginStrict.h>
00027
00028 #include <Inventor/Win/SoWinGDIWidget.h>
00029 #include <Inventor/misc/SoCallbackList.h>
00030
00031
00032 class SoWinMouse;
00033 class SoDataCallbackList;
00034
00035 class SgThumbWheelPart ;
00036 class XmPrimitivePart ;
00037
00038
00039
00040 typedef void SoWinGDIThumbWheelCB( void *userData, void *data );
00041
00042
00043
00044 { int reason;
00045 float value;
00046 } SoWinGDIThumbWheelCBData;
00047
00048
00049
00050 #define THUMBWHEEL_START 0
00051 #define THUMBWHEEL_DRAG 1
00052 #define THUMBWHEEL_FINISH 2
00053 #define THUMBWHEEL_VALUE_CHANGE 3
00054
00055
00056 #define XmCR_DRAG THUMBWHEEL_DRAG
00057 #define XmCR_VALUE_CHANGED THUMBWHEEL_VALUE_CHANGE
00058
00059
00060 class SoWinGDIThumbWheel ;
00061 typedef SoWinGDIThumbWheel *SgThumbWheelWidget ;
00062
00064
00065
00066
00067
00069
00070 {
00071
00072 public:
00073
00074 SoWinGDIThumbWheel(SbBool horizontal);
00075 SoWinGDIThumbWheel(
00076 SoWidget parent = NULL,
00077 const char *name = NULL,
00078 SbBool buildInsideParent = TRUE,
00079 SbBool horizontal = TRUE);
00080
00081
00082
00083 SoEXTENDER
00084 SoWinGDIThumbWheel(
00085 SoWidget parent,
00086 const char *name,
00087 SbBool buildInsideParent,
00088 SbBool horizontal,
00089 SbBool buildNow);
00090
00091 ~SoWinGDIThumbWheel();
00092
00093 void realizeWidget() ;
00094
00095
00096
00097
00098
00099
00100
00101 void setValue(float v);
00102 float getValue() { return (float)thumbWheel.value; }
00103
00104
00105
00106
00107
00108
00109
00110
00111 void addStartCallback(
00112 SoWinGDIThumbWheelCB *f,
00113 void *userData = NULL);
00114 void addValueChangedCallback(
00115 SoWinGDIThumbWheelCB *f,
00116 void *userData = NULL);
00117
00118 void addDragCallback(
00119 SoWinGDIThumbWheelCB *f,
00120 void *userData = NULL);
00121
00122
00123 void addFinishCallback(
00124 SoWinGDIThumbWheelCB *f,
00125 void *userData = NULL);
00126
00127 void removeStartCallback(
00128 SoWinGDIThumbWheelCB *f,
00129 void *userData = NULL);
00130 void removeValueChangedCallback(
00131 SoWinGDIThumbWheelCB *f,
00132 void *userData = NULL);
00133
00134 void removeDragCallback(
00135 SoWinGDIThumbWheelCB *f,
00136 void *userData = NULL);
00137
00138 void removeFinishCallback(
00139 SoWinGDIThumbWheelCB *f,
00140 void *userData = NULL);
00141
00142
00143 SbBool isInteractive() { return interactive; }
00144
00145
00146 void setBounds(int nLower,int nUpper)
00147 { thumbWheel.lower_bound = nLower ;
00148 thumbWheel.upper_bound = nUpper ; } ;
00149
00150 void setHomePosition(int n)
00151 { thumbWheel.home_position = n; } ;
00152
00153 void setAngleRange(int n)
00154 { thumbWheel.angle_range = n; } ;
00155
00156 void setUnitsPerRotation(int n)
00157 { thumbWheel.angle_factor = n; } ;
00158
00159 void setHighlightThickness(int n)
00160 { primitive.highlight_thickness = n; } ;
00161
00162 void setShadowThickness(int n)
00163 { primitive.shadow_thickness = n; } ;
00164
00165
00166 void setValue(int n)
00167 { thumbWheel.value = n; } ;
00168
00169 void setOrientation(unsigned char n)
00170 { thumbWheel.orientation = n; } ;
00171
00172 void setAnimate(SbBool n)
00173 { thumbWheel.animate = n; } ;
00174
00175 void setShowHomeButton(SbBool n)
00176 { thumbWheel.show_home_button = n; } ;
00177
00178
00179
00180 private:
00181
00182
00183 SoWidget buildWidget(SoWidget parent);
00184
00185 private:
00186
00187 virtual void redraw();
00188 virtual void processEvent(XAnyEvent *anyevent);
00189 virtual void sizeChanged(const SbVec2s &newSize);
00190
00191
00192 SbBool horizontal;
00193 SbBool realized;
00194 SoWinMouse *mouse;
00195
00196
00197 SoDataCallbackList *startCallbacks;
00198 SoDataCallbackList *finishCallbacks;
00199 SoDataCallbackList *changedCallbacks;
00200 SoDataCallbackList *dragCallbacks;
00201 SbBool interactive;
00202
00203
00204 void constructorCommon(SbBool horizontal, SbBool buildNow);
00205
00206
00207
00208 typedef struct _XmPrimitivePart
00209 {
00210 int highlight_thickness ;
00211 int shadow_thickness ;
00212 } XmPrimitivePart ;
00213
00214 typedef struct _XmCorePart
00215 {
00216 int width ;
00217 int height ;
00218 int depth ;
00219 } XmCorePart ;
00220
00221 typedef int Dimension ;
00222 typedef int Cardinal ;
00223 typedef void XtString ;
00224
00225
00226 typedef struct _SgThumbWheelPart {
00227
00228 int lower_bound;
00229 int upper_bound;
00230 int home_position;
00231 int angle_range;
00232 int angle_factor;
00233 int value;
00234 unsigned char orientation;
00235 SbBool animate;
00236 SbBool show_home_button;
00237
00238
00239 SbBool infinite;
00240 SbBool dragging;
00241 int drag_begin_value;
00242 int last_mouse_position;
00243 SbBool pegged;
00244 int pegged_mouse_position;
00245 Dimension viewable_pixels;
00246 int user_pixels;
00247 Pixmap pix1;
00248 Pixmap pix2;
00249 Pixmap pix3;
00250 Pixmap pix4;
00251 Pixmap pix1_hilite;
00252 Pixmap pix2_hilite;
00253 Pixmap pix3_hilite;
00254 Pixmap pix4_hilite;
00255 Pixmap current_quiet_pixmap;
00256 Pixmap current_hilite_pixmap;
00257 SbBool wheel_hilite;
00258
00259 Pixmap button_quiet_pixmap;
00260 Pixmap button_hilite_pixmap;
00261 SbBool button_hilite;
00262
00263 HDC foreground_GC;
00264
00265
00266
00267
00268 int wheel_x;
00269 int wheel_y;
00270 int button_x;
00271 int button_y;
00272
00273 SbBool home_button_armed;
00274 SbBool resizePixmaps ;
00275
00276 } SgThumbWheelPart ;
00277
00278
00279 XmCorePart core ;
00280 XmPrimitivePart primitive;
00281 SgThumbWheelPart thumbWheel;
00282
00283 HDC hMemDC ;
00284 HPEN hPen[7] ;
00285 HBRUSH hBrush[7] ;
00286 HPEN hOldPen ;
00287 HBRUSH hOldBrush ;
00288
00289 void Initialize();
00290 void GetForegroundGC() ;
00291 int ConvertPixelsToUserUnits(int pixels);
00292 int ConvertUserUnitsToPixels(int uu);
00293 void CreateAndRenderPixmaps() ;
00294 void Redisplay() ;
00295
00296 HDC SetupGC(int nGC) ;
00297
00298 void RenderPixmap(int which);
00299 void RenderButtonPixmaps();
00300
00301 void Destroy() ;
00302 void FreePixmaps();
00303 void SetCurrentPixmap( SbBool value_increased) ;
00304
00305 void Resize() ;
00306
00307 SbBool MouseIsInWheel(int event_x,int event_y);
00308 SbBool MouseIsInButton(int event_x,int event_y);
00309
00310 void Motion(XEvent *event, XtString *params, Cardinal *num_params);
00311 void Btn1Down(XEvent *event, XtString *params, Cardinal *num_params);
00312 void Btn2Down(XEvent *event, XtString *params, Cardinal *num_params);
00313 void Btn3Down(XEvent *event, XtString *params, Cardinal *num_params);
00314 void Btn1Motion(XEvent *event, XtString *params, Cardinal *num_params);
00315 void Btn2Motion(XEvent *event, XtString *params, Cardinal *num_params);
00316 void Btn3Motion(XEvent *event, XtString *params, Cardinal *num_params);
00317 void Btn1Up(XEvent *event, XtString *params, Cardinal *num_params) ;
00318 void Btn2Up(XEvent *event, XtString *params, Cardinal *num_params) ;
00319 void Btn3Up(XEvent *event, XtString *params, Cardinal *num_params) ;
00320 void Enter(XEvent *event, XtString *params, Cardinal *num_params);
00321 void Leave(XEvent *event, XtString *params, Cardinal *num_params);
00322
00323 void PageUp(XEvent *event, XtString *params, Cardinal *num_params);
00324 void PageDown(XEvent *event, XtString *params, Cardinal *num_params);
00325 void Up(XEvent *event, XtString *params, Cardinal *num_params);
00326 void Down(XEvent *event, XtString *params, Cardinal *num_params);
00327 void Left(XEvent *event, XtString *params, Cardinal *num_params);
00328 void Right(XEvent *event, XtString *params, Cardinal *num_params);
00329 void Help(XEvent *event, XtString *params, Cardinal *num_params);
00330 void BeginLine(XEvent *event, XtString *params, Cardinal *num_params);
00331 void EndLine(XEvent *event, XtString *params, Cardinal *num_params);
00332 void ArmHomeButton() ;
00333 void DisarmHomeButton() ;
00334 void RenderButtonShadows() ;
00335 int ProcessMouseEvent( int event_x,int event_y) ;
00336 void IssueCallback( int reason, int value, XEvent *event) ;
00337
00338 Boolean SetValues(SgThumbWheelWidget rw, SgThumbWheelWidget nw, ArgList args, Cardinal *num_args);
00339 Boolean ValidateFields(SgThumbWheelWidget req_w,
00340 SgThumbWheelWidget new_w) ;
00341
00342
00343
00344 };
00345
00346 #include <Inventor/Win/SoWinEndStrict.h>
00347
00348 #endif
00349
00350
00351