|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TNZ_ACTION_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TNZ_ACTION_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
class TButton;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TGenericCommandAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGenericCommandAction() {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGenericCommandAction() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void sendCommand() = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual TGenericCommandAction *clone() const = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TCommandAction : public TGenericCommandAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*CommandMethod)();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
CommandMethod m_method;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCommandAction<t>(T *target, CommandMethod method)</t>
|
|
Shinya Kitaoka |
120a6e |
: m_target(target), m_method(method){};
|
|
Shinya Kitaoka |
120a6e |
void sendCommand() { (m_target->*m_method)(); };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TGenericCommandAction *clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TCommandAction<t>(m_target, m_method);</t>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class arg="" class="" t,=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TCommandAction1 : public TGenericCommandAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*CommandMethod)(Arg arg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
CommandMethod m_method;
|
|
Shinya Kitaoka |
120a6e |
Arg m_arg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCommandAction1<t, arg="">(T *target, CommandMethod method, Arg arg)</t,>
|
|
Shinya Kitaoka |
120a6e |
: m_target(target), m_method(method), m_arg(arg){};
|
|
Shinya Kitaoka |
120a6e |
void sendCommand() { (m_target->*m_method)(m_arg); };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TGenericCommandAction *clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TCommandAction1<t, arg="">(m_target, m_method, m_arg);</t,>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TCommandSource {
|
|
Shinya Kitaoka |
120a6e |
vector<tgenericcommandaction *=""> *m_actions;</tgenericcommandaction>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TCommandSource();
|
|
Shinya Kitaoka |
120a6e |
virtual ~TCommandSource();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addAction(TGenericCommandAction *action);
|
|
Shinya Kitaoka |
120a6e |
void sendCommand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// not implemented
|
|
Shinya Kitaoka |
120a6e |
TCommandSource(const TCommandSource &);
|
|
Shinya Kitaoka |
120a6e |
TCommandSource &operator=(const TCommandSource &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline void tconnect(TCommandSource &src, T *target, void (T::*method)()) {
|
|
Shinya Kitaoka |
120a6e |
src.addAction(new TCommandAction<t>(target, method));</t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class arg="" class="" t,=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline void tconnect(TCommandSource &src, T *target, void (T::*method)(Arg arg),
|
|
Shinya Kitaoka |
120a6e |
Arg arg) {
|
|
Shinya Kitaoka |
120a6e |
src.addAction(new TCommandAction1<t, arg="">(target, method, arg));</t,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TGuiCommand {
|
|
Shinya Kitaoka |
120a6e |
class Imp;
|
|
Shinya Kitaoka |
120a6e |
Imp *m_imp;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGuiCommand(string cmdName = "none");
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGuiCommand();
|
|
Shinya Kitaoka |
120a6e |
TGuiCommand(const TGuiCommand &);
|
|
Shinya Kitaoka |
120a6e |
TGuiCommand &operator=(const TGuiCommand &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// void setHelp(string longHelp, string shortHelp);
|
|
Shinya Kitaoka |
120a6e |
// void setHelp(string help) {setHelp(help, help);}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// void setTitle(string title);
|
|
Shinya Kitaoka |
120a6e |
// string getTitle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isToggle() const;
|
|
Shinya Kitaoka |
120a6e |
void setIsToggle(bool on);
|
|
Shinya Kitaoka |
120a6e |
void setStatus(bool on);
|
|
Shinya Kitaoka |
120a6e |
bool getStatus() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void enable();
|
|
Shinya Kitaoka |
120a6e |
void disable();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void add(TButton *button);
|
|
Shinya Kitaoka |
120a6e |
void setAction(TGenericCommandAction *action);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// debug!!
|
|
Shinya Kitaoka |
120a6e |
void sendCommand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static void execute(string cmdName);
|
|
Shinya Kitaoka |
120a6e |
static void getNames(std::vector<string> &cmdNames);</string>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TGuiCommandExecutor : public TGuiCommand {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGuiCommandExecutor(string cmdName) : TGuiCommand(cmdName) {
|
|
Shinya Kitaoka |
120a6e |
setAction(new TCommandAction<tguicommandexecutor>(</tguicommandexecutor>
|
|
Shinya Kitaoka |
120a6e |
this, &TGuiCommandExecutor::onCommand));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGuiCommandExecutor() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void onCommand() = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TGuiCommandGenericTarget {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
TGuiCommand m_command;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGuiCommandGenericTarget(string cmdName) : m_command(cmdName) {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGuiCommandGenericTarget() {}
|
|
Shinya Kitaoka |
120a6e |
virtual void activate() = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void deactivate() { m_command.setAction(0); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TGuiCommandTarget : public TGuiCommandGenericTarget {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*Method)();
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
Method m_method;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGuiCommandTarget(string cmdName, T *target, Method method)
|
|
Shinya Kitaoka |
120a6e |
: TGuiCommandGenericTarget(cmdName), m_target(target), m_method(method) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void activate() {
|
|
Shinya Kitaoka |
120a6e |
m_command.setAction(new TCommandAction<t>(m_target, m_method));</t>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|