|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TNZ_BUTTON_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TNZ_BUTTON_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tw.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/action.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.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 |
|
|
Toshihiro Shimizu |
890ddd |
class TButtonSet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TButton : public TWidget, public TCommandSource {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
bool m_pressed, m_active;
|
|
Shinya Kitaoka |
120a6e |
int m_border;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
vector<tbuttonset *=""> *m_buttonSets;</tbuttonset>
|
|
Shinya Kitaoka |
120a6e |
friend class TButtonSet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TButton(TWidget *parent, string name = "button");
|
|
Shinya Kitaoka |
120a6e |
~TButton();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void repaint();
|
|
Shinya Kitaoka |
120a6e |
void enter(const TPoint &p);
|
|
Shinya Kitaoka |
120a6e |
void leave(const TPoint &p);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDown(const TMouseEvent &);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonUp(const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void setTitle(string title) { m_name = title; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TIconButton : public TButton {
|
|
Shinya Kitaoka |
120a6e |
TRaster32P m_rasterUp, m_rasterDown;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TIconButton(TWidget *parent, TRaster32P raster, string name = "button");
|
|
Shinya Kitaoka |
120a6e |
TIconButton(TWidget *parent, TRaster32P rasterUp, TRaster32P rasterDown,
|
|
Shinya Kitaoka |
120a6e |
string name = "button");
|
|
Shinya Kitaoka |
120a6e |
void repaint();
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDown(const TMouseEvent &);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonUp(const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TIconToggle : public TButton {
|
|
Shinya Kitaoka |
120a6e |
TRaster32P m_up, m_down;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TIconToggle(TWidget *parent, TRaster32P up, TRaster32P down,
|
|
Shinya Kitaoka |
120a6e |
string name = "button");
|
|
Shinya Kitaoka |
120a6e |
void repaint();
|
|
Shinya Kitaoka |
120a6e |
void setStatus(bool v);
|
|
Shinya Kitaoka |
120a6e |
bool getStatus();
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDown(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonUp(const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TButtonSetAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TButtonSetAction(){};
|
|
Shinya Kitaoka |
120a6e |
virtual ~TButtonSetAction(){};
|
|
Shinya Kitaoka |
120a6e |
virtual void sendCommand(string value) = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TButtonSetActionT : public TButtonSetAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*CommandMethod)(string);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
CommandMethod m_method;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TButtonSetActionT<t>(T *target, CommandMethod method)</t>
|
|
Shinya Kitaoka |
120a6e |
: m_target(target), m_method(method){};
|
|
Shinya Kitaoka |
120a6e |
void sendCommand(string value) { (m_target->*m_method)(value); };
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TButtonSet {
|
|
Shinya Kitaoka |
120a6e |
std::map<tbutton *,="" string=""> *m_buttons;</tbutton>
|
|
Shinya Kitaoka |
120a6e |
string m_currentValue;
|
|
Shinya Kitaoka |
120a6e |
TButtonSetAction *m_action;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TButtonSet();
|
|
Shinya Kitaoka |
120a6e |
~TButtonSet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// not implemented
|
|
Shinya Kitaoka |
120a6e |
TButtonSet(const TButtonSet &);
|
|
Shinya Kitaoka |
120a6e |
TButtonSet &operator=(const TButtonSet &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
void addButton(TButton *button, string value);
|
|
Shinya Kitaoka |
120a6e |
void removeButton(TButton *button);
|
|
Shinya Kitaoka |
120a6e |
void setValue(string value);
|
|
Shinya Kitaoka |
120a6e |
void setValue(TButton *value);
|
|
Shinya Kitaoka |
120a6e |
// Note: setValue fires the buttons actions as well as the buttonset action
|
|
Shinya Kitaoka |
120a6e |
string getValue() { return m_currentValue; };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setAction(TButtonSetAction *action);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void enable(bool on);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|