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