Files
oboe/osx/dialogxml/button.h
Celtic Minstrel 269d6b0572 - Removed the SLEEP_TICKS and MOUSE_REGION macros (note: SLEEP_TICKS was at 2L, but I've changed it to 0; I think this should be fine, but I'm not sure)
- Stripped out the copying of external files (such as graphics, scenarios, bladbase) into a separate target which the other three are dependent on.
- Graphics.exd no longer included by reference; now the individual files are included directly.
- Added a recalcRect function to ledGroup, since it's a container.
- Added a special case to cLedGroup::setSelected to avoid a crash when no LED is initially selected.
- Added a few initializers to constructors.
- Changes to cDialog::parse<cPict> which were intended to prevent an access violation; unfortunately it doesn't work yet.
- Add cases to cDialog::parse<cPict> to handle PI_TER_MAP and PIC_STATUS.
- Fixed a stupid error in all specializations of cDialog::parse which resulted in an infinite loop.
- Fixed errors in some specializations of cDialog::parse in which an else statement belonged to a different if than it should have.
- Added code to cDialog::loadFromFile to turn the relative path in the argument into an absolute path.
- Fixed errors in cDialog::loadFromFile relating to incorrect use of the parser.
- Added exit statements to the catch clauses in cDialog::loadFromFile.
- Added definition of cDialog::init;
- Enclosed the WaitNextEvent call in cDialog::run in an if statement to ignore null events if they occur (I suspect they won't anyway though)
- Fixed errors in the Edit Terrain dialog definition which caused an exception to be thrown when parsing it: bold was changed to silom, key= was changed to def-key=
- Added status to the list of nullified GWorlPtrs in cPict::init.
- Changed the type of cPict::drawPict from map<ePicType,void(*)(short,GWorldPtr,Rect)> to void(*[])(short,GWorldPtr,Rect) - ie, it was changed from a map to an array because the map was causing an error for some reason.
- Fixed up the load_strings function, which didn't work at all due to a stupid logic error.

git-svn-id: http://openexile.googlecode.com/svn/trunk@96 4ebdad44-0ea0-11de-aab3-ff745001d230
2009-06-16 22:43:51 +00:00

128 lines
3.9 KiB
C++

/*
* button.h
* BoE
*
* Created by Celtic Minstrel on 11/05/09.
*
*/
#ifndef BUTTON_H
#define BUTTON_H
#include <string>
#include <map>
#include <vector>
enum eBtnType { // w x h
BTN_SM = 0, // 23x23 (PICT id 2000 / 2001)
BTN_REG, // 63x23 (PICT id 2002 / 2003)
BTN_LG, // 102x23 (PICT id 2004 / 2005)
BTN_HELP, // 16x13 (PICT id 2006 / 2007) white bubble w/ ? mark
BTN_LEFT, // 63x23 (PICT id 2008 / 2009) with left arrow
BTN_RIGHT, // 63x23 (PICT id 2010 / 2011) with right arrow
BTN_UP, // 63x23 (PICT id 2012 / 2013) with up arrow
BTN_DOWN, // 63x23 (PICT id 2014 / 2015) with down arrow
BTN_TINY, // 14x10 (PICT id 2021)
BTN_DONE, // 63x23 (PICT id 2022 / 2023) says "Done"
BTN_TALL, // 63x40 (PICT id 2024 / 2025)
BTN_TRAIT, // 63x40 (PICT id 2026 / 2027) says "Race Good/Bad Traits"
BTN_PUSH, // 30x30 (PICT id 2028 / 2029) red round button
BTN_LED, // 14x10 (PICT id 2018 / 2019 / 2020)
};
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, Point where);
//virtual void setPict(short pict, short type) = 0;
void setFormat(eFormat prop, short val) throw(xUnsupportedProp);
short getFormat(eFormat prop) throw(xUnsupportedProp);
explicit cButton(cDialog* parent);
bool isClickable();
void setType(eBtnType newType);
eBtnType getType();
virtual ~cButton();
protected:
//friend class cDialog;
void draw();
eBtnType type;
click_callback_t onClick;
cButton(cDialog* parent,eControlType t);
private:
friend class cDialog;
bool wrapLabel;
bool labelWithKey;
bool pressed;
std::string fromList;
static Rect btnRects[13][2];
static size_t btnGW[13];
protected:
static GWorldPtr buttons[7];
};
class cLed : public cButton {
public:
static void init();
void attachClickHandler(click_callback_t f) throw();
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);
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];
focus_callback_t onFocus;
};
class cLedGroup : public cControl {
std::vector<cLed> btns;
click_callback_t onClick;
focus_callback_t onFocus;
std::map<std::string,cLed*> choices;
std::string fromList;
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, Point where);
bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus);
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);
explicit cLedGroup(cDialog* parent);
bool isClickable();
virtual ~cLedGroup();
cLed& operator[](std::string id);
void setSelected(std::string id);
std::string getSelected();
std::string getPrevSelection(); // The id of the element that was last selected before the selection changed to the current selection.
void recalcRect();
typedef std::map<std::string,cLed*>::iterator ledIter;
protected:
void draw();
friend class cDialog;
};
#endif