First version of the new dialog engine added to the repository. It compiles, and links with one error. Because of this, it is untested as yet.
git-svn-id: http://openexile.googlecode.com/svn/trunk@73 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
120
osx/dialogxml/control.h
Normal file
120
osx/dialogxml/control.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* control.h
|
||||
* BoE
|
||||
*
|
||||
* Created by Celtic Minstrel on 11/05/09.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONTROL_H
|
||||
#define CONTROL_H
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
//struct cPict {
|
||||
// short pict;
|
||||
// short type;
|
||||
//};
|
||||
enum eKeyMod {
|
||||
mod_none = 0,
|
||||
mod_alt = 1, mod_shift = 2, mod_ctrl = 4,
|
||||
mod_altshift = mod_alt + mod_shift,
|
||||
mod_altctrl = mod_alt + mod_ctrl,
|
||||
mod_shiftctrl = mod_shift + mod_ctrl,
|
||||
mod_all = mod_alt + mod_shift + mod_ctrl,
|
||||
};
|
||||
|
||||
enum eSpecKey {
|
||||
key_left, key_right, key_up, key_down,
|
||||
key_esc, key_enter, key_tab, key_help, // key_help should bind to the help key on Mac and the F1 key on Windows
|
||||
key_bsp, key_del, key_home, key_end, key_pgup, key_pgdn, // TODO: Implement these
|
||||
// On Mac, command-left should trigger key_home; command-right should trigger key_end;
|
||||
// command-up should trigger key_pgup; and command-down should trigger key_pgdn.
|
||||
// This is in addition to the home, end, pgup, pgdn keys triggering these.
|
||||
};
|
||||
|
||||
struct cKey {
|
||||
bool spec;
|
||||
union {
|
||||
unsigned char c;
|
||||
eSpecKey k;
|
||||
};
|
||||
eKeyMod mod;
|
||||
};
|
||||
|
||||
bool operator== (cKey& a, cKey& b);
|
||||
|
||||
enum eFormat {
|
||||
TXT_COLOR,
|
||||
TXT_FRAME,
|
||||
TXT_FONT,
|
||||
TXT_SIZE,
|
||||
TXT_WRAP,
|
||||
};
|
||||
|
||||
enum eTextFont {DUNGEON, GENEVA, SILOM, MAIDENWORD};
|
||||
|
||||
class cDialog;
|
||||
typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/);
|
||||
typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus.
|
||||
|
||||
class xHandlerNotSupported : std::exception {
|
||||
static const char* focusMsg;
|
||||
static const char* clickMsg;
|
||||
bool isFocus;
|
||||
public:
|
||||
xHandlerNotSupported(bool isFocus);
|
||||
const char* what();
|
||||
};
|
||||
|
||||
class xUnsupportedProp : std::exception {
|
||||
eFormat whichProp;
|
||||
char* msg;
|
||||
public:
|
||||
xUnsupportedProp(eFormat prop) throw();
|
||||
~xUnsupportedProp() throw();
|
||||
const char* what() throw();
|
||||
};
|
||||
|
||||
class cControl {
|
||||
public:
|
||||
static void init();
|
||||
void attachKey(cKey key);
|
||||
virtual void attachClickHandler(click_callback_t f) throw(xHandlerNotSupported) = 0;
|
||||
virtual void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported) = 0;
|
||||
virtual bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods);
|
||||
virtual bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus);
|
||||
//virtual void setPict(short pict, short type) = 0;
|
||||
virtual void show(); // cd_activate_item true
|
||||
virtual void hide(); // cd_activate_item false
|
||||
bool isVisible(); // cd_get_active
|
||||
void setLabel(std::string l);
|
||||
std::string getLabel();
|
||||
void setLabelToKey();
|
||||
virtual void setFormat(eFormat prop, short val) throw(xUnsupportedProp) = 0;
|
||||
virtual short getFormat(eFormat prop) throw(xUnsupportedProp) = 0;
|
||||
virtual bool isClickable() = 0;
|
||||
bool handleClick();
|
||||
cControl(cDialog* p);
|
||||
virtual ~cControl();
|
||||
protected:
|
||||
cDialog* parent;
|
||||
std::string lbl;
|
||||
cKey key;
|
||||
bool visible, depressed; // depressed is only applicable for clickable controls
|
||||
Rect frame;
|
||||
friend class cDialog;
|
||||
virtual void draw() = 0;
|
||||
static bool foundSilom();
|
||||
static short font_nums[4];
|
||||
void drawFrame(short amt, short med_or_lt);
|
||||
private:
|
||||
static bool found_silom;
|
||||
};
|
||||
|
||||
eKeyMod operator + (eKeyMod lhs, eKeyMod rhs);
|
||||
eKeyMod operator - (eKeyMod lhs, eKeyMod rhs);
|
||||
eKeyMod&operator += (eKeyMod&lhs, eKeyMod rhs);
|
||||
eKeyMod&operator -= (eKeyMod&lhs, eKeyMod rhs);
|
||||
#endif
|
Reference in New Issue
Block a user