00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_QT_SLIDER_
00025 #define _SO_QT_SLIDER_
00026
00027 #include <Inventor/Qt/OivQtCompat.h>
00028 #include <Inventor/misc/SoCallbackList.h>
00029 #include <Inventor/Qt/SoQtComponent.h>
00030 #include <Inventor/Qt/SoQtBasicSlider.h>
00031
00032 #include <QPointer>
00033
00034 class SoFloatCallbackList;
00035 class QLayout;
00036 class QHBoxLayout;
00037 class QLineEdit;
00038 class QLabel;
00039
00040
00041 typedef void SoQtSliderCB(void *userData, float val);
00042
00043
00045
00046
00047
00048
00049
00050
00051
00052 {
00053 Q_OBJECT
00054
00055 public:
00056
00057
00058 SoQtSlider( QWidget* parent = NULL,
00059 const char *name = NULL,
00060 SbBool buildInsideParent = TRUE);
00061 ~SoQtSlider();
00062
00063
00064 float getValue() const;
00065 void setLabel(const QString&);
00066 const QString& getLabel() const;
00067
00068
00069
00070
00071 void setNumericFieldVisible(SbBool b = TRUE);
00072 SbBool isNumericFieldVisible() const { return numberVisible; }
00073
00074
00075
00076
00077
00078 void addStartCallback (SoQtSliderCB *f, void *userData = NULL);
00079 void addValueChangedCallback (SoQtSliderCB *f, void *userData = NULL);
00080 void addFinishCallback (SoQtSliderCB *f, void *userData = NULL);
00081
00082 void removeStartCallback (SoQtSliderCB *f, void *userData = NULL);
00083 void removeValueChangedCallback (SoQtSliderCB *f, void *userData = NULL);
00084 void removeFinishCallback (SoQtSliderCB *f, void *userData = NULL);
00085
00086
00087 void interactivity( SbBool flag ) { sliderWidget->interactivity(flag); }
00088 SbBool isInteractive() { return sliderWidget->isInteractive(); }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 void setSliderSize(const SbVec2s &size);
00099 SbVec2s getSliderSize();
00100
00101
00102 private:
00103
00104
00105
00106 SoEXTENDER SoQtSlider (QWidget* parent,
00107 const char *name,
00108 SbBool buildInsideParent,
00109 SbBool buildNow);
00110
00111
00112 QWidget* buildWidget(QWidget* parent, SoQtBasicSlider::Type t = SoQtBasicSlider::PLAIN_SLIDER);
00113
00114
00115 SoQtBasicSlider* sliderWidget;
00116
00117 private:
00118
00119 QPointer<QWidget> mgrWidget;
00120 QPointer<QLineEdit> numberWidget;
00121 QPointer<QLabel> labelWidget;
00122 QHBoxLayout* layout;
00123 SbBool numberVisible;
00124 SbVec2s sliderSize;
00125 QString labelString;
00126
00127
00128 void constructorCommon(SbBool buildNow);
00129 void doLayout();
00130 void updateText ();
00131
00132
00133 void sliderChanged(float val);
00134 static void sliderChangedCB(void *p, float val) { ((SoQtSlider*)p)->sliderChanged (val); };
00135 void sliderStart();
00136 static void sliderStartCB(void *p, float val);
00137 void sliderStop();
00138 static void sliderStopCB(void *p, float val);
00139 static void textFieldCB(QWidget*, SoQtSlider *, XtPointer);
00140
00141 private Q_SLOTS:
00142
00143 void textChangedSlot();
00144
00145 public Q_SLOTS:
00146
00147 void setValue(float v);
00148
00149 Q_SIGNALS:
00150
00151 void start ();
00152 void valueChanged (float value);
00153 void finish ();
00154
00155 };
00156
00157 inline void
00158 SoQtSlider::sliderStartCB(void *p, float )
00159 {
00160 ((SoQtSlider*)p)->sliderStart ();
00161 }
00162
00163 inline void
00164 SoQtSlider::sliderStopCB(void *p, float )
00165 {
00166 ((SoQtSlider*)p)->sliderStop ();
00167 }
00168
00169 #endif
00170
00171
00172