From f17c363683690f25915ee8cb1fef9ad21f76734a Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 18 Jul 2010 09:34:31 +0000 Subject: Selected entries are now marked as '(selected)', toggled by double click svn-id: r50985 --- engines/testbed/config.cpp | 11 +++++++---- engines/testbed/config.h | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'engines/testbed') diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp index afd507a290..8f2b8f1f93 100644 --- a/engines/testbed/config.cpp +++ b/engines/testbed/config.cpp @@ -32,9 +32,7 @@ TestbedOptionsDialog::TestbedOptionsDialog(Common::Array &tsList, T _testbedConfMan = tsConfMan; new GUI::StaticTextWidget(this, "Browser.Headline", "Select Testsuites to Execute"); - new GUI::StaticTextWidget(this, "Browser.Path", "Selected entries shown in dark, click to select"); - _testListDisplay = new TestbedListWidget(this, "Browser.List"); - _testListDisplay->setNumberingMode(GUI::kListNumberingOff); + new GUI::StaticTextWidget(this, "Browser.Path", "Use Double click to select / deselect"); // Construct a String Array Common::Array::const_iterator iter; @@ -45,8 +43,13 @@ TestbedOptionsDialog::TestbedOptionsDialog(Common::Array &tsList, T _colors.push_back(GUI::ThemeEngine::kFontColorAlternate); } + _testListDisplay = new TestbedListWidget(this, "Browser.List", _testSuiteDescArray); + _testListDisplay->setNumberingMode(GUI::kListNumberingOff); _testListDisplay->setList(_testSuiteDescArray, &_colors); + // This list shouldn't be editable + _testListDisplay->setEditable(false); + new GUI::ButtonWidget(this, "Browser.Up", "Select All", kTestbedSelectAll, 0); new GUI::ButtonWidget(this, "Browser.Cancel", "Continue", GUI::kCloseCmd); // XXX: Add more commands for this @@ -58,7 +61,7 @@ TestbedOptionsDialog::~TestbedOptionsDialog() {} void TestbedOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { Testsuite *ts; switch (cmd) { - case kSelectionToggle: + case GUI::kListItemDoubleClickedCmd: ts = _testbedConfMan->getTestsuiteByName(_testSuiteArray[_testListDisplay->getSelected()]); if (ts) { ts->enable(!ts->isEnabled()); diff --git a/engines/testbed/config.h b/engines/testbed/config.h index 6fecf771ab..f357651259 100644 --- a/engines/testbed/config.h +++ b/engines/testbed/config.h @@ -30,16 +30,15 @@ #include "common/str-array.h" #include "common/tokenizer.h" +#include "gui/ListWidget.h" #include "gui/options.h" #include "gui/ThemeEngine.h" -#include "gui/ListWidget.h" #include "testbed/testsuite.h" namespace Testbed { enum { - kSelectionToggle = 'Tgle', kTestbedQuitCmd = 'Quit', kTestbedSelectAll = 'sAll' }; @@ -59,23 +58,26 @@ private: class TestbedListWidget : public GUI::ListWidget { public: - TestbedListWidget(GUI::Dialog *boss, const Common::String &name) : GUI::ListWidget(boss, name){} - void handleMouseUp(int x, int y, int button, int clickCount) { - // If the mouse is clicked once, toggle the selection as it happens in checkboxes. - sendCommand(kSelectionToggle, _selectedItem); - } + TestbedListWidget(GUI::Dialog *boss, const Common::String &name, Common::StringArray &tsDescArr) : GUI::ListWidget(boss, name), _testSuiteDescArray(tsDescArr) {} void changeColor() { // Using Font Color Mechanism to highlight selected entries. - // Might not be detectable in some cases + // Might not be detectable with some themes if (_listColors.size() >= 2) { if (GUI::ThemeEngine::kFontColorNormal == _listColors[_selectedItem]) { _listColors[_selectedItem] = GUI::ThemeEngine::kFontColorAlternate; } else if (GUI::ThemeEngine::kFontColorAlternate == _listColors[_selectedItem]) { _listColors[_selectedItem] = GUI::ThemeEngine::kFontColorNormal; } - draw(); } + + // Also append (selected) to each selected entry + if (_list[_selectedItem].contains("selected")) { + _list[_selectedItem] = _testSuiteDescArray[_selectedItem]; + } else { + _list[_selectedItem] += " (selected)"; + } + draw(); } void setColorAll(GUI::ThemeEngine::FontColor color) { @@ -91,6 +93,8 @@ public: draw(); } +private: + const Common::StringArray _testSuiteDescArray; }; class TestbedOptionsDialog : public GUI::Dialog { -- cgit v1.2.3