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