Browse Source

Virtualize ctkRangeWidget and ctkSliderWidget public API

Those widgets can be derived and it can be useful to add hooks to those
methods.
Julien Finet 11 years ago
parent
commit
e4eebdc52f
2 changed files with 98 additions and 99 deletions
  1. 50 51
      Libs/Widgets/ctkRangeWidget.h
  2. 48 48
      Libs/Widgets/ctkSliderWidget.h

+ 50 - 51
Libs/Widgets/ctkRangeWidget.h

@@ -75,8 +75,8 @@ public:
   /// When setting this property, the maximum is adjusted if necessary
   /// to ensure that the range remains valid.
   /// Also the slider's current value is adjusted to be within the new range.
-  double minimum()const;
-  void setMinimum(double minimum);
+  virtual double minimum()const;
+  virtual void setMinimum(double minimum);
 
   ///
   /// This property holds the sliders and spinbox minimum value.
@@ -84,77 +84,77 @@ public:
   /// When setting this property, the maximum is adjusted if necessary
   /// to ensure that the range remains valid.
   /// Also the slider's current value is adjusted to be within the new range.
-  double maximum()const;
-  void setMaximum(double maximum);
+  virtual double maximum()const;
+  virtual void setMaximum(double maximum);
   /// Description
   /// Utility function that set the min/max in once
-  void setRange(double min, double max);
-  void range(double minimumAndMaximum[2])const;
+  virtual void setRange(double min, double max);
+  virtual void range(double minimumAndMaximum[2])const;
 
   ///
   /// This property holds the slider and spinbox minimum value.
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
-  double minimumValue()const;
+  virtual double minimumValue()const;
 
   ///
   /// This property holds the slider and spinbox maximum value.
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
-  double maximumValue()const;
+  virtual double maximumValue()const;
 
   ///
   /// Utility function that returns both values at the same time
   /// Returns minimumValue and maximumValue
-  void values(double &minValue, double &maxValue)const;
+  virtual void values(double &minValue, double &maxValue)const;
 
   ///
   /// This property holds the single step.
   /// The smaller of two natural steps that the
   /// slider provides and typically corresponds to the
   /// user pressing an arrow key.
-  double singleStep()const;
-  void setSingleStep(double step);
+  virtual double singleStep()const;
+  virtual void setSingleStep(double step);
 
   ///
   /// This property holds the precision of the spin box, in decimals.
-  int decimals()const;
+  virtual int decimals()const;
 
   ///
   /// This property holds the spin box's prefix.
   /// The prefix is prepended to the start of the displayed value.
   /// Typical use is to display a unit of measurement or a currency symbol
-  QString prefix()const;
-  void setPrefix(const QString& prefix);
+  virtual QString prefix()const;
+  virtual void setPrefix(const QString& prefix);
 
   ///
   /// This property holds the spin box's suffix.
   /// The suffix is appended to the end of the displayed value.
   /// Typical use is to display a unit of measurement or a currency symbol
-  QString suffix()const;
-  void setSuffix(const QString& suffix);
+  virtual QString suffix()const;
+  virtual void setSuffix(const QString& suffix);
 
   ///
   /// This property holds the interval between tickmarks.
   /// This is a value interval, not a pixel interval.
   /// If it is 0, the slider will choose between lineStep() and pageStep().
   /// The default value is 0.
-  double tickInterval()const;
-  void setTickInterval(double ti);
+  virtual double tickInterval()const;
+  virtual void setTickInterval(double ti);
 
   ///
   /// This property holds the alignment of the spin boxes.
   /// Possible Values are Qt::AlignTop, Qt::AlignBottom, and Qt::AlignVCenter.
   /// By default, the alignment is Qt::AlignVCenter
-  void setSpinBoxAlignment(Qt::Alignment alignment);
-  Qt::Alignment spinBoxAlignment()const;
+  virtual void setSpinBoxAlignment(Qt::Alignment alignment);
+  virtual Qt::Alignment spinBoxAlignment()const;
 
   ///
   /// This property holds the alignment of the text inside the spin boxes.
   /// Possible Values are Qt::AlignLeft, Qt::AlignRight, and Qt::AlignHCenter.
   /// By default, the alignment is Qt::AlignLeft
-  void setSpinBoxTextAlignment(Qt::Alignment alignment);
-  Qt::Alignment spinBoxTextAlignment()const;
+  virtual void setSpinBoxTextAlignment(Qt::Alignment alignment);
+  virtual Qt::Alignment spinBoxTextAlignment()const;
 
   ///
   /// This property holds whether slider tracking is enabled.
@@ -162,51 +162,51 @@ public:
   /// signal while the slider or spinbox is being dragged. If tracking is
   /// disabled, the widget emits the valueChanged() signal only when the user
   /// releases the slider or spinbox.
-  void setTracking(bool enable);
-  bool hasTracking()const;
+  virtual void setTracking(bool enable);
+  virtual bool hasTracking()const;
 
   ///
   /// Set/Get the auto spinbox width
   /// When the autoSpinBoxWidth property is on, the width of the SpinBox is
   /// set to the same width of the largest QSpinBox of its
   // ctkRangeWidget siblings.
-  bool isAutoSpinBoxWidth()const;
-  void setAutoSpinBoxWidth(bool autoWidth);
+  virtual bool isAutoSpinBoxWidth()const;
+  virtual void setAutoSpinBoxWidth(bool autoWidth);
   
   ///
   /// When symmetricMoves is true, moving a handle will move the other handle
   /// symmetrically, otherwise the handles are independent. False by default
-  bool symmetricMoves()const;
-  void setSymmetricMoves(bool symmetry);
+  virtual bool symmetricMoves()const;
+  virtual void setSymmetricMoves(bool symmetry);
 
   /// Return the slider of the range widget.
   /// \sa minimumSpinBox(), maximumSpinBox()
-  ctkDoubleRangeSlider* slider()const;
+  virtual ctkDoubleRangeSlider* slider()const;
   /// Return the minimum spinbox.
   /// \sa maximumSpinBox(), slider()
-  ctkDoubleSpinBox* minimumSpinBox()const;
+  virtual ctkDoubleSpinBox* minimumSpinBox()const;
   /// Return the maximum spinbox.
   /// \sa minimumSpinBox(), slider()
-  ctkDoubleSpinBox* maximumSpinBox()const;
+  virtual ctkDoubleSpinBox* maximumSpinBox()const;
 
   /// Set/Get the value proxy of the slider and spinboxes.
   /// \sa setValueProxy(), valueProxy()
-  void setValueProxy(ctkValueProxy* proxy);
-  ctkValueProxy* valueProxy() const;
+  virtual void setValueProxy(ctkValueProxy* proxy);
+  virtual ctkValueProxy* valueProxy() const;
 
 public Q_SLOTS:
   ///
   /// Reset the slider and spinbox to zero (value and position)
-  void reset();
-  void setMinimumValue(double value);
-  void setMaximumValue(double value);
+  virtual void reset();
+  virtual void setMinimumValue(double value);
+  virtual void setMaximumValue(double value);
   ///
   /// Utility function that set the min and max values at once
-  void setValues(double minValue, double maxValue);
+  virtual void setValues(double minValue, double maxValue);
 
   /// Sets how many decimals the spinbox will use for displaying and
   /// interpreting doubles.
-  void setDecimals(int decimals);
+  virtual void setDecimals(int decimals);
 
 Q_SIGNALS:
   /// Use with care:
@@ -220,25 +220,25 @@ Q_SIGNALS:
   void rangeChanged(double min, double max);
 
 protected Q_SLOTS:
-  void startChanging();
-  void stopChanging();
-  void changeValues(double newMinValue, double newMaxValue);
-  void changeMinimumValue(double value);
-  void changeMaximumValue(double value);
+  virtual void startChanging();
+  virtual void stopChanging();
+  virtual void changeValues(double newMinValue, double newMaxValue);
+  virtual void changeMinimumValue(double value);
+  virtual void changeMaximumValue(double value);
   /// A spinbox value has been modified, update the slider.
-  void setSliderValues();
-  void setMinimumToMaximumSpinBox(double minimum);
-  void setMaximumToMinimumSpinBox(double maximum);
-  void onSliderRangeChanged(double min, double max);
+  virtual void setSliderValues();
+  virtual void setMinimumToMaximumSpinBox(double minimum);
+  virtual void setMaximumToMinimumSpinBox(double maximum);
+  virtual void onSliderRangeChanged(double min, double max);
 
-  void onValueProxyAboutToBeModified();
-  void onValueProxyModified();
+  virtual void onValueProxyAboutToBeModified();
+  virtual void onValueProxyModified();
 
 protected:
   virtual bool eventFilter(QObject *obj, QEvent *event);
 
   /// can be used to change the slider by a custom one
-  void setSlider(ctkDoubleRangeSlider* slider);
+  virtual void setSlider(ctkDoubleRangeSlider* slider);
 
 protected:
   QScopedPointer<ctkRangeWidgetPrivate> d_ptr;
@@ -246,7 +246,6 @@ protected:
 private:
   Q_DECLARE_PRIVATE(ctkRangeWidget);
   Q_DISABLE_COPY(ctkRangeWidget);
-
 };
 
 #endif

+ 48 - 48
Libs/Widgets/ctkSliderWidget.h

@@ -102,8 +102,8 @@ public:
   /// When setting this property, the maximum is adjusted if necessary 
   /// to ensure that the range remains valid. 
   /// Also the slider's current value is adjusted to be within the new range.
-  double minimum()const;
-  void setMinimum(double minimum);
+  virtual double minimum()const;
+  virtual void setMinimum(double minimum);
   
   /// 
   /// This property holds the sliders and spinbox minimum value.
@@ -111,11 +111,11 @@ public:
   /// When setting this property, the maximum is adjusted if necessary 
   /// to ensure that the range remains valid. 
   /// Also the slider's current value is adjusted to be within the new range.
-  double maximum()const;
-  void setMaximum(double maximum);
+  virtual double maximum()const;
+  virtual void setMaximum(double maximum);
   /// Description
   /// Utility function that set the min/max in once
-  void setRange(double min, double max);
+  virtual void setRange(double min, double max);
 
   /// 
   /// This property holds the current slider position.
@@ -127,63 +127,63 @@ public:
   /// This property holds the slider and spinbox current value.
   /// ctkSliderWidget forces the value to be within the
   /// legal range: minimum <= value <= maximum.
-  double value()const;
+  virtual double value()const;
 
   /// 
   /// This property holds the single step.
   /// The smaller of two natural steps that the 
   /// slider provides and typically corresponds to the 
   /// user pressing an arrow key.
-  double singleStep()const;
-  void setSingleStep(double step);
+  virtual double singleStep()const;
+  virtual void setSingleStep(double step);
 
   /// 
   /// This property holds the page step.
   /// The larger of two natural steps that an abstract slider provides and
   /// typically corresponds to the user pressing PageUp or PageDown.
-  double pageStep()const;
-  void setPageStep(double step);
+  virtual double pageStep()const;
+  virtual void setPageStep(double step);
 
   ///
   /// Return the decimals property value.
   /// \sa decimals, setDecimals(), decimalsChanged()
-  int decimals()const;
+  virtual int decimals()const;
 
   ///
   /// This property holds the spin box's prefix.
   /// The prefix is prepended to the start of the displayed value. 
   /// Typical use is to display a unit of measurement or a currency symbol
-  QString prefix()const;
-  void setPrefix(const QString& prefix);
+  virtual QString prefix()const;
+  virtual void setPrefix(const QString& prefix);
 
   ///
   /// This property holds the spin box's suffix.
   /// The suffix is appended to the end of the displayed value. 
   /// Typical use is to display a unit of measurement or a currency symbol
-  QString suffix()const;
-  void setSuffix(const QString& suffix);
+  virtual QString suffix()const;
+  virtual void setSuffix(const QString& suffix);
 
   /// 
   /// This property holds the interval between tickmarks.
   /// This is a value interval, not a pixel interval. 
   /// If it is 0, the slider will choose between lineStep() and pageStep().
   /// The default value is 0.
-  double tickInterval()const;
-  void setTickInterval(double tick);
+  virtual double tickInterval()const;
+  virtual void setTickInterval(double tick);
 
   /// 
   /// This property holds the tickmark position for the slider.
   /// The valid values are described by the QSlider::TickPosition enum.
   /// The default value is QSlider::NoTicks.
-  void setTickPosition(QSlider::TickPosition position);
-  QSlider::TickPosition tickPosition()const;
+  virtual void setTickPosition(QSlider::TickPosition position);
+  virtual QSlider::TickPosition tickPosition()const;
   
   /// 
   /// This property holds the alignment of the spin box.
   /// Possible Values are Qt::AlignLeft, Qt::AlignRight, and Qt::AlignHCenter.
   /// By default, the alignment is Qt::AlignLeft
-  void setSpinBoxAlignment(Qt::Alignment alignment);
-  Qt::Alignment spinBoxAlignment()const;
+  virtual void setSpinBoxAlignment(Qt::Alignment alignment);
+  virtual Qt::Alignment spinBoxAlignment()const;
 
   /// 
   /// This property holds whether slider tracking is enabled.
@@ -191,16 +191,16 @@ public:
   /// signal while the slider or spinbox is being dragged. If tracking is 
   /// disabled, the widget emits the valueChanged() signal only when the user 
   /// releases the slider or spinbox.
-  void setTracking(bool enable);
-  bool hasTracking()const;
+  virtual void setTracking(bool enable);
+  virtual bool hasTracking()const;
 
   /// 
   /// Set/Get the synchronize siblings mode. This helps when having multiple
   /// ctkSliderWidget stacked upon each other.
   /// Default flag is SynchronizeWidth | SynchronizeDecimals.
   /// \sa SynchronizeSiblingsModes
-  ctkSliderWidget::SynchronizeSiblings synchronizeSiblings() const;
-  void setSynchronizeSiblings(ctkSliderWidget::SynchronizeSiblings options);
+  virtual ctkSliderWidget::SynchronizeSiblings synchronizeSiblings() const;
+  virtual void setSynchronizeSiblings(ctkSliderWidget::SynchronizeSiblings options);
 
   /// This property holds whether or not a slider shows its values inverted.
   /// If this property is false (the default), the minimum and maximum will
@@ -211,8 +211,8 @@ public:
   /// or not the styles understand inverted appearance; most styles ignore this
   /// property for scroll bars.
   /// \sa invertedControls
-  void setInvertedAppearance(bool invertedAppearance);
-  bool invertedAppearance()const;
+  virtual void setInvertedAppearance(bool invertedAppearance);
+  virtual bool invertedAppearance()const;
 
   /// This property holds whether or not the slider and the spinbox invert
   /// their wheel and key events.
@@ -221,13 +221,13 @@ public:
   /// maximum. Otherwise, pressing page up will move value towards the minimum.
   /// The default value of the property is false.
   /// \sa invertedAppearance
-  void setInvertedControls(bool invertedControls);
-  bool invertedControls()const;
+  virtual void setInvertedControls(bool invertedControls);
+  virtual bool invertedControls()const;
 
   ///
   /// The Spinbox visibility can be controlled using setSpinBoxVisible() and
   /// isSpinBoxVisible().
-  bool isSpinBoxVisible()const;
+  virtual bool isSpinBoxVisible()const;
 
   ///
   /// The slider can be handled as a popup for the spinbox. The location where
@@ -236,45 +236,45 @@ public:
   /// Note: some sizing issues in the popup can happen if the ctkSliderWidget
   /// has already parent. You might want to consider setting this property
   /// before setting a parent to ctkSliderWidget.
-  bool hasPopupSlider()const;
-  void setPopupSlider(bool popup);
+  virtual bool hasPopupSlider()const;
+  virtual void setPopupSlider(bool popup);
 
   ///
   /// Return the popup if ctkSliderWidget hasPopupSlider() is true, 0 otherwise.
   /// It can be useful to control where the popup shows up relative to the
   /// spinbox the popup \sa ctkPopupWidget::baseWidget.
-  ctkPopupWidget* popup()const;
+  virtual ctkPopupWidget* popup()const;
 
   ///
   /// Returns the spinbox synchronized with the slider. Be careful
   /// with what you do with the spinbox as the slider might change
   /// properties automatically.
-  ctkDoubleSpinBox* spinBox();
+  virtual ctkDoubleSpinBox* spinBox();
 
   ///
   /// Returns the slider synchronized with the spinbox. Be careful
   /// with what you do with the slider as the spinbox might change
   /// properties automatically.
-  ctkDoubleSlider* slider();
+  virtual ctkDoubleSlider* slider();
 
   ///
   /// Set/Get a value proxy filter.
   /// This simply sets the same value proxy filter on the spinbox
   /// and the slider
   /// \sa setValueProxy(), valueProxy()
-  void setValueProxy(ctkValueProxy* proxy);
-  ctkValueProxy* valueProxy() const;
+  virtual void setValueProxy(ctkValueProxy* proxy);
+  virtual ctkValueProxy* valueProxy() const;
 
 public Q_SLOTS:
   /// 
   /// Reset the slider and spinbox to zero (value and position)
-  void reset();
-  void setValue(double value);
-  void setSpinBoxVisible(bool);
+  virtual void reset();
+  virtual void setValue(double value);
+  virtual void setSpinBoxVisible(bool);
 
   /// Sets how many decimals the spinbox uses for displaying and
   /// interpreting doubles.
-  void setDecimals(int decimals);
+  virtual void setDecimals(int decimals);
 
 Q_SIGNALS:
   /// When tracking is on (default), valueChanged is emitted when the
@@ -295,13 +295,13 @@ Q_SIGNALS:
   void decimalsChanged(int decimals);
 
 protected Q_SLOTS:
-  
-  void startChanging();
-  void stopChanging();
-  void setSpinBoxValue(double sliderValue);
-  void setSliderValue(double spinBoxValue);
-  void onValueProxyAboutToBeModified();
-  void onValueProxyModified();
+
+  virtual void startChanging();
+  virtual void stopChanging();
+  virtual void setSpinBoxValue(double sliderValue);
+  virtual void setSliderValue(double spinBoxValue);
+  virtual void onValueProxyAboutToBeModified();
+  virtual void onValueProxyModified();
 
 protected:
   virtual bool eventFilter(QObject *obj, QEvent *event);