2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef MAINSHELL_INCLUDED
|
|
|
|
#define MAINSHELL_INCLUDED
|
|
|
|
|
|
|
|
//#include "tcommon.h"
|
|
|
|
#include "menubar.h"
|
|
|
|
//#include "toolbar.h"
|
|
|
|
//#include "label.h"
|
|
|
|
//#include "panel.h"
|
|
|
|
// #include "tcli.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TWIN_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class TGenericCommandAction;
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace TCli {
|
2016-03-19 06:57:51 +13:00
|
|
|
class Usage;
|
|
|
|
}
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TMainshell : public TWidget {
|
2016-03-19 06:57:51 +13:00
|
|
|
protected:
|
2016-06-15 18:43:10 +12:00
|
|
|
static TMainshell *theShell;
|
|
|
|
virtual void create();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
|
|
|
#ifndef WIN32
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_ending;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static TMainshell *getMainshell() { return theShell; }
|
|
|
|
static TMainshell *instance() { return theShell; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TMainshell(string name);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void init() {}
|
|
|
|
virtual void atExit() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual bool beforeShow() { return true; }
|
|
|
|
virtual void close();
|
|
|
|
virtual void closeWithoutQuestion();
|
|
|
|
// void pushStatusMessage(string );
|
|
|
|
// virtual void pushStatusMessage(std::wstring ) {}
|
|
|
|
// virtual void popStatusMessage() {};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// static void errorMessage(const string &str);
|
|
|
|
// static bool questionMessage(const string &str);
|
|
|
|
// static int multipleChoicesMessage(const string &str, vector<string>
|
|
|
|
// &choices);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// brutto (ma veloce da implementare :-)
|
|
|
|
// restituisce 0=yes, 1=no, 2=cancel
|
|
|
|
// static int yesNoCancelMessage(const string &str);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual TDimension getPreferredSize() { return TDimension(800, 600); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual bool isResizable() const { return true; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual int getMainIconId() { return 0; } // ha senso solo su NT
|
|
|
|
virtual int getSplashScreenBitmapId() { return 0; } // ha senso solo su NT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// void setAccelerator(
|
|
|
|
// string acc,
|
|
|
|
// TGenericCommandAction *onKeyDown);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setAccelerator(string acc, string guiCommandName);
|
|
|
|
string getAccelerator(string guiCommandName);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void forwardMessage(string msg) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void contextHelp();
|
|
|
|
virtual void onContextHelp(string reference) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual string getAppId() const = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void defineUsage(TCli::Usage &usage);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TKeyListener {
|
|
|
|
string m_keyName;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TKeyListener(string keyName);
|
|
|
|
virtual ~TKeyListener();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void onKeyDown() = 0;
|
|
|
|
virtual void onKeyUp(bool mouseEventReceived) = 0;
|
|
|
|
virtual bool autoreatIsEnabled() { return false; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
string getKeyName() const { return m_keyName; }
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
template <class T>
|
2016-06-15 18:43:10 +12:00
|
|
|
class TCommandKey : public TKeyListener {
|
|
|
|
typedef void (T::*Method)();
|
|
|
|
T *m_target;
|
|
|
|
Method m_method;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TCommandKey(string keyName, T *target, Method method)
|
|
|
|
: TKeyListener(keyName), m_target(target), m_method(method) {}
|
|
|
|
|
|
|
|
void onKeyDown() { (m_target->*m_method)(); }
|
|
|
|
void onKeyUp(bool mouseEventReceived) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
DVAPI void enableShortcuts(bool on);
|
|
|
|
|
|
|
|
DVAPI void enableShortcuts(bool on);
|
|
|
|
|
|
|
|
DVAPI void enableShortcuts(bool on);
|
|
|
|
|
|
|
|
#endif
|