Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TNZ_SCROLLBAR_INCLUDED
Toshihiro Shimizu 890ddd
#define TNZ_SCROLLBAR_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "tw/action.h"
Toshihiro Shimizu 890ddd
//#include "traster.h"
Toshihiro Shimizu 890ddd
#include "tw/tw.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TWIN_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TScrollbarGenericAction {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TScrollbarGenericAction() {}
Shinya Kitaoka 120a6e
  virtual ~TScrollbarGenericAction() {}
Shinya Kitaoka 120a6e
  virtual void notify(int value) = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka 120a6e
class TScrollbarAction : public TScrollbarGenericAction {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef void (T::*CommandMethod)(int value);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  T *m_target;
Shinya Kitaoka 120a6e
  CommandMethod m_method;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TScrollbarAction<t>(T *target, CommandMethod method)</t>
Shinya Kitaoka 120a6e
      : m_target(target), m_method(method){};
Shinya Kitaoka 120a6e
  void notify(int value) { (m_target->*m_method)(value); };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TScrollbar : public TWidget {
Shinya Kitaoka 120a6e
  int m_oldPos;
Shinya Kitaoka 120a6e
  int m_gPos, m_gMinPos, m_gMaxPos, m_gSize;
Shinya Kitaoka 120a6e
  int m_value, m_minValue, m_maxValue, m_cursorSize;
Shinya Kitaoka 120a6e
  const int m_buttonAreaSize;
Shinya Kitaoka 120a6e
  TScrollbarGenericAction *m_action;
Shinya Kitaoka 120a6e
  bool m_firstButtonPressed, m_secondButtonPressed;
Shinya Kitaoka 120a6e
  bool m_horizontal;
Shinya Kitaoka 120a6e
  bool m_minOverflowEnabled;
Shinya Kitaoka 120a6e
  bool m_maxOverflowEnabled;
Shinya Kitaoka 120a6e
  int m_buttonIncrement;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  void updatePositions();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void drawHCursor(int x0, int x1);
Shinya Kitaoka 120a6e
  void drawVCursor(int y0, int y1);
Shinya Kitaoka 120a6e
  enum ButtonId { FIRST_BUTTON, SECOND_BUTTON };
Shinya Kitaoka 120a6e
  void drawButton(ButtonId id);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TScrollbar(TWidget *parent, string name = "scrollbar");
Shinya Kitaoka 120a6e
  ~TScrollbar();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void repaint();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void leftButtonDown(const TMouseEvent &);
Shinya Kitaoka 120a6e
  void leftButtonDrag(const TMouseEvent &);
Shinya Kitaoka 120a6e
  void leftButtonUp(const TMouseEvent &);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void configureNotify(const TDimension &d);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setValue(int value, int min, int max, int size);
Shinya Kitaoka 120a6e
  int getValue() const { return m_value; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // min <= value <= max
Shinya Kitaoka 120a6e
  // il cursore occupa almeno size/(max-min+size) dell'area disponibile
Shinya Kitaoka 120a6e
  // se size = 0 non c'e' cursore e lo slider e' disabilitato
Shinya Kitaoka 120a6e
  // se size>=max-min il cursore occupa tutto lo spazio e lo slider e'
Shinya Kitaoka 120a6e
  // disabilitato
Shinya Kitaoka 120a6e
  //
Shinya Kitaoka 120a6e
  // value == min quando il cursore e' in alto
Shinya Kitaoka 120a6e
  // value == max quando il cursore e' in basso
Shinya Kitaoka 120a6e
  //
Shinya Kitaoka 120a6e
  // quando vengono premuti i bottoni value viene incrementato/decrementato di
Shinya Kitaoka 120a6e
  // uno
Shinya Kitaoka 120a6e
  //
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // abilita/disabilita la possibilita' di agire sui bottoni anche
Shinya Kitaoka 120a6e
  // quando lo slider e' gia' sul massimo/minimo
Shinya Kitaoka 120a6e
  // default: false/false
Shinya Kitaoka 120a6e
  void enableButtonOverflow(bool min, bool max);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // default: 4
Shinya Kitaoka 120a6e
  void setButtonIncrement(int d);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setAction(TScrollbarGenericAction *action);
Shinya Kitaoka 120a6e
  void onTimer(int v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif