diff --git a/osx/dialogxml/button.cpp b/osx/dialogxml/button.cpp index c3dc0d3d..cad8d91d 100644 --- a/osx/dialogxml/button.cpp +++ b/osx/dialogxml/button.cpp @@ -8,7 +8,7 @@ #include #include -using namespace std; +#include #include "dialog.h" #include "graphtool.h" @@ -21,12 +21,14 @@ void cButton::attachClickHandler(click_callback_t f) throw(){ onClick = f; } -bool cButton::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){ +bool cButton::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){ if(onClick != NULL) return onClick(me,id,mods); return false; } -cButton::cButton(cDialog* parent) : cControl(parent) {} +cButton::cButton(cDialog* parent) : cControl(parent,CTRL_BTN) {} + +cButton::cButton(cDialog* parent,eControlType t) : cControl(parent,t) {} bool cButton::isClickable(){ return true; @@ -131,6 +133,11 @@ void cButton::init(){ OffsetRect(&btnRects[BTN_PUSH][1],30,0); } +void cButton::finalize(){ + for(int i = 0; i < 7; i++) + DisposeGWorld(buttons[i]); +} + Rect cLed::ledRects[3][2]; void cLed::init(){ @@ -142,19 +149,41 @@ void cLed::init(){ } } -cLed::cLed(cDialog* parent) : cButton(parent) {} +cLed::cLed(cDialog* parent) : cButton(parent,CTRL_LED) {} void cLed::attachClickHandler(click_callback_t f) throw(){ onClick = f; } -void cLed::attachFocusHandler(focus_callback_t __attribute__((unused))) throw(xHandlerNotSupported){ - throw xHandlerNotSupported(true); +void cLed::attachFocusHandler(focus_callback_t f) throw(){ + onFocus = f; } -bool cLed::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){ - if(onClick != NULL) return onClick(me,id,mods); - return false; +bool cLed::triggerFocusHandler(cDialog& me, std::string id, bool losing){ + if(onFocus != NULL) return onFocus(me,id,losing); + return true; +} + +bool cLed::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){ + bool result; + eLedState oldState = state; + if(onClick != NULL) result = onClick(me,id,mods); + else{ // simple state toggle + switch(state){ + case led_red: + case led_green: + state = led_off; + break; + case led_off: + state = led_red; + } + result = true; + } + if(!triggerFocusHandler(me,id, oldState != led_off)){ + result = false; + state = oldState; + } + return result; } void cLed::setFormat(eFormat prop __attribute__((unused)), short val __attribute__((unused))) throw(xUnsupportedProp){ @@ -195,7 +224,7 @@ void cLed::draw(){ SetPort(old_port); } -cLedGroup::cLedGroup(cDialog* parent) : cControl(parent) {} +cLedGroup::cLedGroup(cDialog* parent) : cControl(parent,CTRL_GROUP) {} cButton::~cButton() {} @@ -208,3 +237,131 @@ cLedGroup::~cLedGroup(){ iter++; } } + +/** A click handler is called whenever a click is received, even on the currently selected element. */ +void cLedGroup::attachClickHandler(click_callback_t f) throw() { + onClick = f; +} + +/** A focus handler is called when the currently selected element changes. */ +void cLedGroup::attachFocusHandler(focus_callback_t f) throw() { + onFocus = f; +} + +void cLed::setState(eLedState to){ + state = to; +} + +eLedState cLed::getState(){ + return state; +} + +bool cLedGroup::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){ + std::string which_clicked; + ledIter iter = choices.begin(); + while(iter != choices.end()){ + if(iter->second->visible && PtInRect(where,&iter->second->frame)){ + if(iter->second->handleClick()) + which_clicked = iter->first; + } + iter++; + } + + if(choices[which_clicked]->triggerClickHandler(me,curSelect,mods,where)){ + eLedState a, b; + a = choices[curSelect]->getState(); + b = choices[which_clicked]->getState(); + choices[curSelect]->setState(led_off); + choices[which_clicked]->setState(led_red); + if(!choices[curSelect]->triggerFocusHandler(me,curSelect,true)){ + choices[curSelect]->setState(a); + choices[which_clicked]->setState(b); + return false; + } + if(!choices[which_clicked]->triggerFocusHandler(me,curSelect,false)){ + choices[curSelect]->setState(a); + choices[which_clicked]->setState(b); + return false; + } + curSelect = which_clicked; + }else return false; + + return triggerFocusHandler(me,id,false); +} + +bool cLedGroup::triggerFocusHandler(cDialog& me, std::string id, bool losingFocus){ + if(onFocus != NULL) return onFocus(me,id,losingFocus); + return true; +} + +void cLedGroup::disable(std::string id) { + // TODO: Implement this +} + +void cLedGroup::enable(std::string id) { + // TODO: Implement this +} + +void cLedGroup::show(std::string id){ + choices[id]->show(); +} + +void cLedGroup::hide(std::string id){ + choices[id]->hide(); +} + +void cLedGroup::setFormat(eFormat prop __attribute__((unused)), short val __attribute__((unused))) throw(xUnsupportedProp) { + throw xUnsupportedProp(prop); +} + +short cLedGroup::getFormat(eFormat prop __attribute__((unused))) throw(xUnsupportedProp) { + throw xUnsupportedProp(prop); +} + +bool cLedGroup::isClickable(){ + return true; +} + +cLed& cLedGroup::operator[](std::string id){ + ledIter iter = choices.find(id); + if(iter == choices.end()) throw std::invalid_argument(id + " does not exist in the ledgroup."); + return *(iter->second); +} + +void cLedGroup::setSelection(std::string id){ + ledIter iter = choices.find(id); + if(iter == choices.end()) throw std::invalid_argument(id + " does not exist in the ledgroup."); + + eLedState a, b; + a = choices[curSelect]->getState(); + b = iter->second->getState(); + choices[curSelect]->setState(led_off); + iter->second->setState(led_red); + if(!choices[curSelect]->triggerFocusHandler(*parent,curSelect,true)){ + choices[curSelect]->setState(a); + iter->second->setState(b); + return; + } + if(!iter->second->triggerFocusHandler(*parent,curSelect,false)){ + choices[curSelect]->setState(a); + iter->second->setState(b); + return; + } + curSelect = iter->first; +} + +std::string cLedGroup::getSelection(){ + return curSelect; +} + +std::string cLedGroup::getPrevSelection(){ + return prevSelect; +} + +void cLedGroup::draw(){ + ledIter iter = choices.begin(); + while(iter != choices.end()){ + iter->second->draw(); + iter++; + } +} diff --git a/osx/dialogxml/button.h b/osx/dialogxml/button.h index b027c3b5..4c59b642 100644 --- a/osx/dialogxml/button.h +++ b/osx/dialogxml/button.h @@ -35,25 +35,27 @@ enum eLedState {led_green = 0, led_red, led_off}; class cButton : public cControl { public: static void init(); + static void finalize(); void attachClickHandler(click_callback_t f) throw(); void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported); - bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods); + bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); //virtual void setPict(short pict, short type) = 0; void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); - cButton(cDialog* parent); + explicit cButton(cDialog* parent); + cButton(cDialog* parent,eControlType t); bool isClickable(); virtual ~cButton(); protected: //friend class cDialog; void draw(); + eBtnType type; + click_callback_t onClick; private: friend class cDialog; - click_callback_t onClick; bool wrapLabel; bool labelWithKey; bool pressed; - eBtnType type; std::string fromList; static Rect btnRects[13][2]; static size_t btnGW[13]; @@ -65,22 +67,26 @@ class cLed : public cButton { public: static void init(); void attachClickHandler(click_callback_t f) throw(); - void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported); - bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods); + void attachFocusHandler(focus_callback_t f) throw(); + bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); + bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus); void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); - cLed(cDialog* parent); + explicit cLed(cDialog* parent); virtual ~cLed(); + void setState(eLedState to); + eLedState getState(); protected: void draw(); private: friend class cDialog; + friend class cLedGroup; eLedState state; eTextFont textFont; RGBColor color; short textSize; static Rect ledRects[3][2]; - click_callback_t onClick; + focus_callback_t onFocus; }; class cLedGroup : public cControl { @@ -89,25 +95,32 @@ class cLedGroup : public cControl { focus_callback_t onFocus; std::map choices; std::string fromList; - friend class cDialog; + std::string curSelect, prevSelect; public: void attachClickHandler(click_callback_t f) throw(); // activated whenever a click is received, even on the currently active LED void attachFocusHandler(focus_callback_t f) throw(); // activated only when the selection changes - bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods); + bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus); void setSelected(std::string id); std::string getSelected(); void disable(std::string id); void enable(std::string id); + using cControl::show; + using cControl::hide; void hide(std::string id); void show(std::string id); void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); - cLedGroup(cDialog* parent); + explicit cLedGroup(cDialog* parent); bool isClickable(); virtual ~cLedGroup(); + cLed& operator[](std::string id); + void setSelection(std::string id); + std::string getSelection(); + std::string getPrevSelection(); // The id of the element that was last selected before the selection changed to the current selection. typedef std::map::iterator ledIter; protected: void draw(); + friend class cDialog; }; #endif diff --git a/osx/dialogxml/control.cpp b/osx/dialogxml/control.cpp index bd4da2d6..0213c029 100644 --- a/osx/dialogxml/control.cpp +++ b/osx/dialogxml/control.cpp @@ -12,56 +12,15 @@ extern bool play_sounds; -void cControl::setLabel(std::string l){ +void cControl::setText(std::string l){ lbl = l; if(isVisible()) draw(); } -std::string cControl::getLabel(){ +std::string cControl::getText(){ return lbl; } -static unsigned char applyShift(unsigned char c){ - static const char afterShift[] = { - ' ', '!', '"', '#', '$', '%', '&', '"', '(', ')', '*', '+', '<', '_', '>', '?', - ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', ':', ':', '<', '+', '>', '?', - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '^', '_', - '~', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', - }; - return afterShift[c - ' ']; -} - -static unsigned char removeShift(unsigned char c){ - static const char afterUnShift[] = { - ' ', '1', '\'','3', '4', '5', '7', '\'','9', '0', '8', '=', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';', ';', ',', '=', '.', '/', - '2', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '6', '-', - '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '`', - }; - return afterUnShift[c - ' ']; -} - -void cControl::setLabelToKey(){ - if(key.spec); // TODO: Handle this case - else{ - unsigned char c = key.c; - if(key.mod - mod_shift != key.mod) c = applyShift(c); - else c = removeShift(c); - if(key.mod - mod_ctrl != key.mod) lbl = "^" + c; - else if(key.mod - mod_alt != key.mod) lbl = "*" + c; - else lbl = c; - } - if(isVisible()) draw(); -} - -void cControl::attachKey(cKey key){ - this->key = key; -} - const char* xHandlerNotSupported::focusMsg = "This control cannot handle focus events.\n"; const char* xHandlerNotSupported::clickMsg = "This control cannot handle click events.\n"; @@ -227,11 +186,55 @@ bool cControl::handleClick(){ return clicked; } -cControl::cControl(cDialog* p){ - parent = p; +static unsigned char applyShift(unsigned char c){ + static const char afterShift[] = { + ' ', '!', '"', '#', '$', '%', '&', '"', '(', ')', '*', '+', '<', '_', '>', '?', + ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', ':', ':', '<', '+', '>', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '^', '_', + '~', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', + }; + return afterShift[c - ' ']; } -bool cControl::triggerClickHandler(cDialog& me __attribute__((unused)), std::string id __attribute__((unused)), eKeyMod mods __attribute__((unused))){ +static unsigned char removeShift(unsigned char c){ + static const char afterUnShift[] = { + ' ', '1', '\'','3', '4', '5', '7', '\'','9', '0', '8', '=', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';', ';', ',', '=', '.', '/', + '2', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '6', '-', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '`', + }; + return afterUnShift[c - ' ']; +} + +void cControl::setTextToKey(){ + if(key.spec); // TODO: Handle this case + else{ + unsigned char c = key.c; + if(key.mod - mod_shift != key.mod) c = applyShift(c); + else c = removeShift(c); + if(key.mod - mod_ctrl != key.mod) lbl = "^" + c; + else if(key.mod - mod_alt != key.mod) lbl = "*" + c; + else lbl = c; + } + if(isVisible()) draw(); +} + +void cControl::attachKey(cKey key){ + this->key = key; +} + +void cControl::detachKey(){ + this->key.spec = false; + this->key.c = 0; +} + +cControl::cControl(cDialog* p, eControlType t) : parent(p), type(t) {} + +bool cControl::triggerClickHandler(cDialog& __attribute__((unused)), std::string __attribute__((unused)), eKeyMod __attribute__((unused)), Point __attribute__((unused))){ return true; } @@ -296,3 +299,7 @@ bool cControl::foundSilom(){ } cControl::~cControl() {} + +eControlType cControl::getType(){ + return type; +} diff --git a/osx/dialogxml/control.h b/osx/dialogxml/control.h index b38cf444..9748b30f 100644 --- a/osx/dialogxml/control.h +++ b/osx/dialogxml/control.h @@ -53,6 +53,17 @@ enum eFormat { TXT_WRAP, }; +enum eControlType { + CTRL_UNKNOWN, + CTRL_BTN, // An ordinary push button + CTRL_LED, // An LED (checkbox/radiobutton) + CTRL_PICT, // A picture + CTRL_FIELD, // An edit text field + CTRL_TEXT, // A static text object + CTRL_GROUP, // A LED radiobutton-like group + CTRL_STACK, // A group of controls that display pages (not implemented yet) +}; + enum eTextFont {DUNGEON, GENEVA, SILOM, MAIDENWORD}; class cDialog; @@ -81,35 +92,40 @@ class cControl { public: static void init(); void attachKey(cKey key); + void detachKey(); + void setTextToKey(); 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 triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); 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(); + eControlType getType(); + virtual void setText(std::string l); + virtual std::string getText(); 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); + cControl(cDialog* p,eControlType t); virtual ~cControl(); protected: cDialog* parent; std::string lbl; - cKey key; bool visible, depressed; // depressed is only applicable for clickable controls Rect frame; + cKey key; friend class cDialog; + friend class cLedGroup; + //friend class cStack; virtual void draw() = 0; static bool foundSilom(); static short font_nums[4]; void drawFrame(short amt, short med_or_lt); private: + eControlType type; static bool found_silom; }; diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index 05e6d031..c6137a04 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -12,6 +12,7 @@ #include "dialog.h" #include "graphtool.h" #include "soundtool.h" +#include using namespace std; using namespace ticpp; @@ -644,13 +645,17 @@ cDialog::cDialog(string path){ win = NewCWindow(NULL, &winRect, (unsigned char*) "", false, dBoxProc, IN_FRONT, false, 0); } -void cDialog::init(){ +cDialog::_init::_init(){ cControl::init(); cButton::init(); cLed::init(); cPict::init(); } +cDialog::_init::~_init(){ + cButton::finalize(); +} + cDialog::~cDialog(){ ctrlIter iter = controls.begin(); while(iter != controls.end()){ @@ -787,7 +792,7 @@ void cDialog::run(){ break; } ctrlIter ctrl = controls.find(itemHit); - if(ctrl != controls.end()) ctrl->second->triggerClickHandler(*this,itemHit,key.mod); + if(ctrl != controls.end()) ctrl->second->triggerClickHandler(*this,itemHit,key.mod,currentEvent.where); } EndAppModalStateForWindow(win); HideWindow(win); @@ -918,3 +923,25 @@ void cDialog::draw(){ SetPort(old_port); } + +cControl& cDialog::operator[](std::string id){ + ctrlIter iter = controls.find(id); + if(iter != controls.end()) return *(iter->second); + + iter = controls.begin(); + while(iter != controls.end()){ + if(iter->second->getType() == CTRL_GROUP){ + try{ + cLedGroup* tmp = (cLedGroup*) (iter->second); + return tmp->operator[](id); + }catch(std::invalid_argument) {} + }else if(iter->second->getType() == CTRL_STACK){ // TODO: Implement stacks +// try{ +// cStack* tmp = (cStack*) (iter->second); +// return tmp->operator[](id); +// }catch(std::invalid_argument) {} + } + iter++; + } + throw std::invalid_argument(id + " does not exist in the dialog."); +} diff --git a/osx/dialogxml/dialog.h b/osx/dialogxml/dialog.h index ad6ebd23..1c5be626 100644 --- a/osx/dialogxml/dialog.h +++ b/osx/dialogxml/dialog.h @@ -31,9 +31,13 @@ class cDialog { cKey parseKey(std::string what); WindowRef win; cTextField* currentFocus; + class _init { + _init(); + ~_init(); + }; + static _init init; public: static const short BG_LIGHT, BG_DARK; - static void init(); // must call this before constructing any dialogs cDialog(std::string path); // cd_create_dialog cDialog(std::string path,cDialog parent); // cd_create_dialog_parent_num ~cDialog(); // cd_kill_dialog @@ -44,6 +48,7 @@ public: void setBg(short n); void setDefTextClr(RGBColor clr); void toast(); + cControl& operator[](std::string id); private: void draw(); std::string process_keystroke(cKey keyHit); @@ -57,6 +62,7 @@ private: friend class cPict; friend class cTextField; friend class cTextMsg; + friend class _init; }; class xBadNode : std::exception { diff --git a/osx/dialogxml/field.cpp b/osx/dialogxml/field.cpp index 21e013bd..8fd97820 100644 --- a/osx/dialogxml/field.cpp +++ b/osx/dialogxml/field.cpp @@ -63,7 +63,7 @@ bool cTextField::isClickable(){ return false; } -cTextField::cTextField(cDialog* parent) : cControl(parent) { +cTextField::cTextField(cDialog* parent) : cControl(parent,CTRL_FIELD) { OSStatus err; err = CreateEditTextControl(parent->win,&frame,NULL,false,true/*useInlineInput*/,NULL,&theField); } diff --git a/osx/dialogxml/field.h b/osx/dialogxml/field.h index 0f33da33..4385c4fd 100644 --- a/osx/dialogxml/field.h +++ b/osx/dialogxml/field.h @@ -22,7 +22,7 @@ public: void setText(std::string what); short getTextAsNum(); void setTextToNum(short what); - cTextField(cDialog* parent); + explicit cTextField(cDialog* parent); bool isClickable(); virtual ~cTextField(); void show(); diff --git a/osx/dialogxml/message.cpp b/osx/dialogxml/message.cpp index fde47741..b379e7cd 100644 --- a/osx/dialogxml/message.cpp +++ b/osx/dialogxml/message.cpp @@ -18,7 +18,7 @@ void cTextMsg::attachFocusHandler(focus_callback_t f __attribute__((unused))) th throw xHandlerNotSupported(true); } -bool cTextMsg::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){ +bool cTextMsg::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){ if(onClick != NULL) return onClick(me,id,mods); return false; } @@ -90,15 +90,7 @@ short cTextMsg::getFormat(eFormat prop) throw(xUnsupportedProp){ return 0; } -std::string cTextMsg::getText(){ - return getLabel(); -} - -void cTextMsg::setText(std::string what){ - setLabel(what); -} - -cTextMsg::cTextMsg(cDialog* parent) : cControl(parent) {} +cTextMsg::cTextMsg(cDialog* parent) : cControl(parent,CTRL_TEXT) {} bool cTextMsg::isClickable(){ return clickable; diff --git a/osx/dialogxml/message.h b/osx/dialogxml/message.h index 6bce28d6..3d86eb5f 100644 --- a/osx/dialogxml/message.h +++ b/osx/dialogxml/message.h @@ -15,12 +15,10 @@ class cTextMsg : public cControl { public: void attachClickHandler(click_callback_t f) throw(); void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported); - bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods); + bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); - std::string getText(); - void setText(std::string what); - cTextMsg(cDialog* parent); + explicit cTextMsg(cDialog* parent); bool isClickable(); virtual ~cTextMsg(); protected: diff --git a/osx/dialogxml/pict.cpp b/osx/dialogxml/pict.cpp index b1d0e993..b5acf092 100644 --- a/osx/dialogxml/pict.cpp +++ b/osx/dialogxml/pict.cpp @@ -71,7 +71,7 @@ void cPict::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw throw xHandlerNotSupported(true); } -bool cPict::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){ +bool cPict::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){ if(onClick != NULL) return onClick(me,id,mods); else return false; } @@ -228,7 +228,7 @@ void cPict::setPict(short num, ePicType type){ if(isVisible()) draw(); } -cPict::cPict(cDialog* parent) : cControl(parent) {} +cPict::cPict(cDialog* parent) : cControl(parent,CTRL_PICT) {} bool cPict::isClickable(){ return clickable; diff --git a/osx/dialogxml/pict.h b/osx/dialogxml/pict.h index e72a0c2d..1b05a40f 100644 --- a/osx/dialogxml/pict.h +++ b/osx/dialogxml/pict.h @@ -89,13 +89,13 @@ public: static void init(); void attachClickHandler(click_callback_t f) throw(); void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported); - bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods); + bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); static void setSheet(eSheetType type, short n, GWorldPtr sheet); static bool isSheetSet(eSheetType type, size_t n); void setPict(short num, ePicType type); - cPict(cDialog* parent); + explicit cPict(cDialog* parent); bool isClickable(); static void advanceAnim(); virtual ~cPict();