/*------------------------------------------------------------------------------
 src/lib/djWidget/djSliderWidget.h

 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_SLIDER_WIDGET_H
#define DJ_SLIDER_WIDGET_H
#include <djWidget.h>

namespace dj {

// Slider widget base.
//
class SliderWidget : public Widget {
public:

  SliderWidget();
  virtual ~SliderWidget() = 0;
  
  // Increment.
  //
  virtual void inc() = 0;
  virtual void incBig() = 0;
  virtual void dec() = 0;
  virtual void decBig() = 0;

  // Layout.
  //
  virtual int handleWidth() { return 11; }
  const Vec2i sizeHint() const;
  
  // Widget.
  //
  virtual int handle(int);

protected:

  const Box2i contentsBox() const;
  virtual void drawSlider(double value);
  virtual void drawBackground(const Box2i &);
};

// Integer slider widget.
//
class IntSliderWidget : public SliderWidget {
public:

  IntSliderWidget();
  
  // Value.
  //
  virtual void set(int);
  int get() const { return _value; }
  
  // Range.
  //
  void range(int min, int max);
  int min() const { return _min; }
  int max() const { return _max; }
  
  // Increment.
  //
  void inc(int inc, int dec);
  void inc();
  void incBig();
  void dec();
  void decBig();
  int inc() const { return _inc; }
  int dec() const { return _dec; }
  
  // Signals.
  //
  Signal<int> & sig() { return _sig; }
  
  // Widget.
  //
  virtual void draw();
  virtual int handle(int);

private:

  int _value;
  int _min, _max;
  int _inc, _dec;
  
  Signal<int> _sig;
};

// Float slider widget.
//
class FloatSliderWidget : public SliderWidget {
public:

  FloatSliderWidget();
  
  // Value.
  //
  virtual void set(double);
  double get() const { return _value; }
  
  // Range.
  //
  void range(double min, double max);
  double min() const { return _min; }
  double max() const { return _max; }
  
  // Increment.
  //
  void inc(double inc, double dec);
  void inc();
  void incBig();
  void dec();
  void decBig();
  double inc() const { return _inc; }
  double dec() const { return _dec; }
  
  // Signals.
  //
  Signal<double> & sig() { return _sig; }
  
  // Widget.
  //
  virtual void draw();
  virtual int handle(int);

private:

  double _value;
  double _min, _max;
  double _inc, _dec;
  
  Signal<double> _sig;
};

}

#endif
