aboutsummaryrefslogtreecommitdiff
path: root/gui/ListWidget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-07-18 20:26:35 +0000
committerMax Horn2002-07-18 20:26:35 +0000
commit6e6c3c3c962b403a89b80e38cd3702413bc6c4af (patch)
tree6e1b58ace59706672ecd34379f7728a273c2d4fb /gui/ListWidget.cpp
parentd66c9ea2b23ce4476783ddc7e1622fb6767b2cca (diff)
downloadscummvm-rg350-6e6c3c3c962b403a89b80e38cd3702413bc6c4af.tar.gz
scummvm-rg350-6e6c3c3c962b403a89b80e38cd3702413bc6c4af.tar.bz2
scummvm-rg350-6e6c3c3c962b403a89b80e38cd3702413bc6c4af.zip
put stuff in util.h into namespace ScummVM; fixed stupid bug in String class; took painelf's patch which implements save/load dialog in new GUI and fixed it slightly; various other minor changes
svn-id: r4591
Diffstat (limited to 'gui/ListWidget.cpp')
-rw-r--r--gui/ListWidget.cpp53
1 files changed, 20 insertions, 33 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 612c8e4d32..2f697acbaa 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -27,8 +27,13 @@
/*
* TODO:
- * - Allow escape to abort changes
- * - Add key repeat (for backspace, etc)
+ * - Abort changes when ESC is pressed or the selection changes
+ * - When the editing of a string is ended by return, we might consider sending
+ * a message. Return means that the edit was confirmed. Hence the SaveDialog
+ * could immediatly do the save in a trivial fashion.
+ * - Handle double clicks: either start editing of the selected item, or
+ * send a cmd to our target (i.e. as specified via setCmd or setDoubleCmd)
+ * This will allow a double click in the load dialog to immediatly load the game
*/
@@ -37,13 +42,13 @@
ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h)
- : Widget(boss, x, y, w - kScrollBarWidth, h)
+ : Widget(boss, x, y, w - kScrollBarWidth, h), CommandSender(boss)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
_type = kListWidget;
_numberingMode = kListNumberingOne;
_entriesPerPage = (_h - 4) / LINE_HEIGHT;
- _currentPos = 3;
+ _currentPos = 0;
_selectedItem = -1;
_scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h);
_scrollBar->setTarget(this);
@@ -53,38 +58,20 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h)
_editable = true;
_editMode = false;
+}
- // FIXME - fill in dummy data for now
- _list.push_back("A simple game?");
- _list.push_back("This space for rent!");
- _list.push_back("To be or not to be...");
- _list.push_back("It's not easy come up with dummy text :-)");
- _list.push_back("Foo bar baz");
- _list.push_back("Empty slots follow:");
- _list.push_back("");
- _list.push_back("");
- _list.push_back("Now again a filled slot");
- _list.push_back("We need some more text!");
- _list.push_back("Because only this way...");
- _list.push_back("...can you see the scrollbar...");
- _list.push_back("...and verify that it works!");
- _list.push_back("One");
- _list.push_back("Two");
- _list.push_back("Three");
- _list.push_back("Four");
- _list.push_back("The End");
-
+ListWidget::~ListWidget()
+{
+}
+void ListWidget::scrollBarRecalc()
+{
_scrollBar->_numEntries = _list.size();
_scrollBar->_entriesPerPage = _entriesPerPage;
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
}
-ListWidget::~ListWidget()
-{
-}
-
void ListWidget::handleMouseDown(int x, int y, int button)
{
int oldSelectedItem = _selectedItem;
@@ -220,19 +207,19 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
void ListWidget::drawWidget(bool hilite)
{
- NewGui *gui = _boss->getGui();
- int i, pos;
- String buffer;
+ NewGui *gui = _boss->getGui();
+ int i, pos, len = _list.size();
+ ScummVM::String buffer;
// Draw the list items
- // FIXME - this is just a temporary demo hack
- for (i = 0, pos = _currentPos; i < _entriesPerPage; i++, pos++) {
+ for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
if (_numberingMode == kListNumberingZero || _numberingMode == kListNumberingOne) {
char temp[10];
sprintf(temp, "%2d. ", (pos + _numberingMode));
buffer = temp;
} else
buffer = "";
+
buffer += _list[pos];
gui->drawString(buffer, _x+5, _y+2 + LINE_HEIGHT * i, _w - 10,