|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TNZ_CHECKBOX_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TNZ_CHECKBOX_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tw.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/action.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 TCheckBoxActionInterface;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TCheckBox : public TWidget {
|
|
Shinya Kitaoka |
120a6e |
class TCheckBoxData;
|
|
Shinya Kitaoka |
120a6e |
TCheckBoxData *m_data;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TCheckBox(TWidget *parent, string name = "button");
|
|
Shinya Kitaoka |
120a6e |
~TCheckBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void repaint();
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDown(const TMouseEvent &);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonUp(const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isSelected() const;
|
|
Shinya Kitaoka |
120a6e |
void addAction(TCheckBoxActionInterface *);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void select(bool on);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isGray() const;
|
|
Shinya Kitaoka |
120a6e |
void setIsGray(bool on);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// per default switchOff e' abilitato. se disabilitato il checkbox si puo'
|
|
Shinya Kitaoka |
120a6e |
// spegnare solo con select(false) (e non con il mouse). Questo serve
|
|
Shinya Kitaoka |
120a6e |
// per implementare un gruppo di radio button (in cui si puo' fare click
|
|
Shinya Kitaoka |
120a6e |
// solo su quelli spenti)
|
|
Shinya Kitaoka |
120a6e |
void enableSwitchOff(bool enabled);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TCheckBoxActionInterface {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TCheckBoxActionInterface() {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~TCheckBoxActionInterface() {}
|
|
Shinya Kitaoka |
120a6e |
virtual void triggerAction(TCheckBox *checkbox, bool selected) = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TCheckBoxAction : public TCheckBoxActionInterface {
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*Method)(TCheckBox *checkbox, bool selected);
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
Method m_method;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TCheckBoxAction(T *target, Method method)
|
|
Shinya Kitaoka |
120a6e |
: m_target(target), m_method(method) {}
|
|
Shinya Kitaoka |
120a6e |
void triggerAction(TCheckBox *checkbox, bool selected) {
|
|
Shinya Kitaoka |
120a6e |
(m_target->*m_method)(checkbox, selected);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline void tconnect(TCheckBox &src, T *target,
|
|
Shinya Kitaoka |
120a6e |
void (T::*method)(TCheckBox *checkbox, bool selected)) {
|
|
Shinya Kitaoka |
120a6e |
src.addAction(new TCheckBoxAction<t>(target, method));</t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|