ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

chooser.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/translation.h"
00024 #include "gui/chooser.h"
00025 #include "gui/widget.h"
00026 #include "gui/widgets/list.h"
00027 
00028 namespace GUI {
00029 
00030 enum {
00031     kChooseCmd = 'Chos'
00032 };
00033 
00034 ChooserDialog::ChooserDialog(const String &title, String dialogId)
00035     : Dialog(dialogId) {
00036 
00037     // Headline
00038     new StaticTextWidget(this, dialogId + ".Headline", title);
00039 
00040     // Add choice list
00041     _list = new ListWidget(this, dialogId + ".List");
00042     _list->setNumberingMode(kListNumberingOff);
00043     _list->setEditable(false);
00044 
00045     // Buttons
00046     new ButtonWidget(this, dialogId + ".Cancel", _("Cancel"), 0, kCloseCmd);
00047     _chooseButton = new ButtonWidget(this, dialogId + ".Choose", _("Choose"), 0, kChooseCmd);
00048     _chooseButton->setEnabled(false);
00049 }
00050 
00051 void ChooserDialog::setList(const StringArray& list) {
00052     _list->setList(list);
00053 }
00054 
00055 void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
00056     int item = _list->getSelected();
00057     switch (cmd) {
00058     case kChooseCmd:
00059     case kListItemActivatedCmd:
00060     case kListItemDoubleClickedCmd:
00061         _list->endEditMode();
00062         setResult(item);
00063         close();
00064         break;
00065     case kListSelectionChangedCmd:
00066         _chooseButton->setEnabled(item >= 0);
00067         _chooseButton->markAsDirty();
00068         break;
00069     case kCloseCmd:
00070         setResult(-1);
00071         // Fall through
00072     default:
00073         Dialog::handleCommand(sender, cmd, data);
00074     }
00075 }
00076 
00077 } // End of namespace GUI


Generated on Sat May 25 2019 05:00:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge