aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2004-03-13 12:33:31 +0000
committerMax Horn2004-03-13 12:33:31 +0000
commit7e3e79f41e6f56db1f83bbad629620f823c9e648 (patch)
treebadb61b63c9c31bb77b2a87a10a359e12cb80f5a /gui
parent0fc86ef674edd02b7eb4fcaf1f5c5e3ef82d3a85 (diff)
downloadscummvm-rg350-7e3e79f41e6f56db1f83bbad629620f823c9e648.tar.gz
scummvm-rg350-7e3e79f41e6f56db1f83bbad629620f823c9e648.tar.bz2
scummvm-rg350-7e3e79f41e6f56db1f83bbad629620f823c9e648.zip
useful helper method (will be used for improved options dialog)
svn-id: r13237
Diffstat (limited to 'gui')
-rw-r--r--gui/PopUpWidget.cpp10
-rw-r--r--gui/PopUpWidget.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index 9527db6491..71d861d35c 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -315,6 +315,16 @@ void PopUpWidget::setSelected(int item) {
}
}
+void PopUpWidget::setSelectedTag(uint32 tag) {
+ uint item;
+ for (item = 0; item < _entries.size(); ++item) {
+ if (_entries[item].tag == tag) {
+ setSelected(item);
+ return;
+ }
+ }
+}
+
void PopUpWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
int x = _x + _labelWidth;
diff --git a/gui/PopUpWidget.h b/gui/PopUpWidget.h
index ec6a6c363c..9a5e63ad09 100644
--- a/gui/PopUpWidget.h
+++ b/gui/PopUpWidget.h
@@ -62,7 +62,12 @@ public:
void appendEntry(const String &entry, uint32 tag = (uint32)-1);
void clearEntries();
+ /** Select the entry at the given index. */
void setSelected(int item);
+
+ /** Select the first entry matching the given tag. */
+ void setSelectedTag(uint32 tag);
+
int getSelected() const { return _selectedItem; }
uint32 getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (uint32)-1; }
const String& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : String::emptyString; }