diff options
-rw-r--r-- | backends/wince/CEgui/ItemSwitch.cpp | 53 | ||||
-rw-r--r-- | backends/wince/CEgui/ItemSwitch.h | 4 |
2 files changed, 44 insertions, 13 deletions
diff --git a/backends/wince/CEgui/ItemSwitch.cpp b/backends/wince/CEgui/ItemSwitch.cpp index 1d329c9991..7498463871 100644 --- a/backends/wince/CEgui/ItemSwitch.cpp +++ b/backends/wince/CEgui/ItemSwitch.cpp @@ -25,9 +25,7 @@ namespace CEGUI { - ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item) : - PanelItem(referenceTrue) { - _item = item; + void ItemSwitch::init(WORD referenceTrue, WORD referenceFalse) { _backgroundTrue = _background; _backgroundFalse = new SDL_ImageResource(); if (!_backgroundFalse->load(referenceFalse)) { @@ -36,10 +34,25 @@ namespace CEGUI { _background = NULL; _backgroundFalse = NULL; } + } + + ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item) : + PanelItem(referenceTrue) { + init(referenceTrue, referenceFalse); + _item = item; + _itemmax = -1; if (!*_item) _background = _backgroundFalse; } + ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, int *item, int max) : + PanelItem(referenceTrue) { + init(referenceTrue, referenceFalse); + _itemmultiple = item; + _itemmax = max; + if (!*item) + _background = _backgroundFalse; + } ItemSwitch::~ItemSwitch() { if (_backgroundFalse) @@ -49,18 +62,32 @@ namespace CEGUI { bool ItemSwitch::action(int x, int y, bool pushed) { if (checkInside(x, y) && _visible && pushed) { - *_item = !*_item; - if (*_item) - _background = _backgroundTrue; - else - _background = _backgroundFalse; + if (_itemmax <= 0) { + *_item = !*_item; + if (*_item) + _background = _backgroundTrue; + else + _background = _backgroundFalse; - if (_panel) - _panel->forceRedraw(); + if (_panel) + _panel->forceRedraw(); - return true; - } - else + return true; + } else { + *_itemmultiple = *_itemmultiple + 1; + if (*_itemmultiple > _itemmax) + *_itemmultiple = 0; + if (*_itemmultiple) + _background = _backgroundTrue; + else + _background = _backgroundFalse; + + if (_panel) + _panel->forceRedraw(); + + return true; + } + } else return false; } } diff --git a/backends/wince/CEgui/ItemSwitch.h b/backends/wince/CEgui/ItemSwitch.h index 33480544fe..60a96c4894 100644 --- a/backends/wince/CEgui/ItemSwitch.h +++ b/backends/wince/CEgui/ItemSwitch.h @@ -37,10 +37,14 @@ namespace CEGUI { class ItemSwitch : public PanelItem { public: ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item); + ItemSwitch(WORD referenceTrue, WORD referenceFalse, int *item, int max); virtual ~ItemSwitch(); virtual bool action(int x, int y, bool pushed); private: + void init(WORD referenceTrue, WORD referenceFalse); bool *_item; + static bool _itemdummy; + int *_itemmultiple, _itemmax; SDL_ImageResource *_backgroundTrue; SDL_ImageResource *_backgroundFalse; }; |