Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinSlider.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
24
25#ifndef _SO_WIN_SLIDER_
26#define _SO_WIN_SLIDER_
27
28#include <Inventor/Win/SoWinBeginStrict.h>
29#include <Inventor/misc/SoCallbackList.h>
30#include <Inventor/Win/SoWinGDIWidget.h>
31
32class SoFloatCallbackList;
33class SoWinMouse;
34
35// callback function prototypes
36typedef void SoWinSliderCB(void *userData, float val);
37
39//
40// Class: SoWinSlider
41//
42// This is the basic slider type, which lets you set the slider value and
43// register callbacks when the slider is being moved (either as soon as the
44// slider changes values, or when the slider has stopped moving (mouse up)).
45//
47
48{
49 public:
50
51 // constructor/destructor
52 SoWinSlider(SoWidget parent = NULL,
53 const char *name = NULL,
54 SbBool buildInsideParent = TRUE);
55 ~SoWinSlider();
56
57 //
58 // Those routines are used to specify the slider value (which is automatically
59 // reflected in the slider) and get the current value.
60 //
61 // NOTE: setValue() will call valueChanged callbacks if the value differs.
62 //
63 // NOTE: currently only values [0.0 , 1.0] are supported
64 //
65 void setValue(float v, SbBool updateText = TRUE);
66 float getValue() const { return value; }
67
68 //
69 // Specifies the label string which appears before the slider. A NULL
70 // string will remove the label altogether. (default behavior)
71 //
72 void setLabel(const char *newlabel);
73 const char *getLabel() const { return labelStr; }
74
75 //
76 // Display a numeric value in a text field to the right of the slider
77 // which can be edited to change the value of the slider.
78 // Default is TRUE (display the numeric value).
79 //
80 void setNumericFieldVisible(SbBool b);
81 SbBool isNumericFieldVisible() const { return numberVisible; }
82
83 //
84 // Those routines are used to register callbacks for the different slider
85 // actions.
86 //
87 // NOTE: the start and finish callbacks are only to signal when the mouse
88 // goes down and up. No valid callback data is passed (0.0 passed).
89 //
90 void addStartCallback(SoWinSliderCB *f, void *userData = NULL);
91 void addValueChangedCallback( SoWinSliderCB *f, void *userData = NULL);
92 void addFinishCallback(SoWinSliderCB *f, void *userData = NULL);
93
94 void removeStartCallback(SoWinSliderCB *f, void *userData = NULL);
95 void removeValueChangedCallback(SoWinSliderCB *f, void *userData = NULL);
96 void removeFinishCallback(SoWinSliderCB *f, void *userData = NULL);
97
98 // true while the value is changing interactively
99 void interactivity( SbBool flag ) { interactive = flag; }
100 SbBool isInteractive() { return interactive; }
101
102 // sets/gets the size of the actual slider, excluding the label and
103 // text field widget sizes which are fixed in size.
104 //
105 // This is the prefered behavior since it allows a user to align
106 // multiple sliders (same size) regardless of the text label size
107 // (which are usually different).
108 //
109 // NOTE: this is different from most widgets, which do resize their
110 // container widgets. This functionality can still be achieved using
111 // the setSize() and getSize() methods.
112 //
113 void setSliderSize(const SbVec2s &size);
114 SbVec2s getSliderSize();
115
116 void setNumberWidget(SoWidget hWnd) {numberWidget = hWnd;};
117 SoWidget getNumberWidget() {return numberWidget;} ;
118 static void textFieldCB(SoWinSlider *p,SoWidget hCtrl);
119
120 private:
121
122 // This constructor takes a boolean whether to build the widget now.
123 // Subclasses can pass FALSE, then call SoWinSlider::buildWidget()
124 // when they are ready for it to be built.
125 SoEXTENDER
126 SoWinSlider(SoWidget parent,
127 const char *name,
128 SbBool buildInsideParent,
129 SbBool buildNow);
130
131 // redefine these to do slider specific things
132 virtual void redraw();
133 virtual void processEvent(XAnyEvent *anyevent);
134 virtual void sizeChanged(const SbVec2s &newSize);
135
136 SoWidget buildWidget(SoWidget parent);
137
138 //
139 // this is the routine subclasses would redefine to change the look of
140 // the actual slider top region, which defaults to grey with a thin white marker.
141 //
142 virtual void drawSliderTopRegion();
143
144 // slider top region area (used by subclasses to do their own
145 // drawings in there).
146 short slx1, sly1, slx2, sly2;
147 short thumx1, thumy1, thumx2, thumy2;
148
149 private:
150
151 SoWidget mgrWidget, numberWidget, sliderWidget, labelWidget;
152 SbBool numberVisible; // whether numeric field is visible
153 char *labelStr; // label preceeding slider
154 SbVec2s sliderSize; // size of the 'widget' and 'shell'
155 SoWinMouse *mouse;
156
157 // slider local variables (slider value, thum position)
158 float value;
159 short position, posdiff;
160
161 // build routines
162 void doLabelLayout();
163 void doNumberLayout();
164
165 // callback variables
166 SoFloatCallbackList *startCallbacks;
167 SoFloatCallbackList *changedCallbacks;
168 SoFloatCallbackList *finishCallbacks;
169 SbBool interactive;
170
171 // this is called by both constructors
172 void constructorCommon(SbBool buildNow);
173
174};
175
176#include <Inventor/Win/SoWinEndStrict.h>
177
178#endif /* _SO_WIN_SLIDER_ */
179
180
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