Add to launcher not yet functional search widget.

Make EditableWidget CommandSender

svn-id: r41267
This commit is contained in:
Eugene Sandulenko 2009-06-06 17:53:25 +00:00
parent b0db1b5ed0
commit dcc90445f6
12 changed files with 59 additions and 22 deletions

View file

@ -30,16 +30,16 @@
namespace GUI {
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
: EditableWidget(boss, x, y - 1, w, h + 2) {
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, uint32 cmd)
: EditableWidget(boss, x, y - 1, w, h + 2, cmd) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
_type = kEditTextWidget;
setEditString(text);
}
EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text)
: EditableWidget(boss, name) {
EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text, uint32 cmd)
: EditableWidget(boss, name, cmd) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
_type = kEditTextWidget;

View file

@ -41,8 +41,8 @@ protected:
int _rightPadding;
public:
EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text);
EditTextWidget(GuiObject *boss, const String &name, const String &text);
EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, uint32 cmd = 0);
EditTextWidget(GuiObject *boss, const String &name, const String &text, uint32 cmd = 0);
void setEditString(const String &str);

View file

@ -34,7 +34,7 @@
namespace GUI {
ListWidget::ListWidget(GuiObject *boss, const String &name)
: EditableWidget(boss, name), CommandSender(boss) {
: EditableWidget(boss, name) {
_scrollBar = NULL;
_textWidth = NULL;
@ -63,7 +63,7 @@ ListWidget::ListWidget(GuiObject *boss, const String &name)
}
ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
: EditableWidget(boss, x, y, w, h), CommandSender(boss) {
: EditableWidget(boss, x, y, w, h) {
_scrollBar = NULL;
_textWidth = NULL;

View file

@ -47,7 +47,7 @@ enum {
};
/* ListWidget */
class ListWidget : public EditableWidget, public CommandSender {
class ListWidget : public EditableWidget {
public:
typedef Common::String String;
typedef Common::StringList StringList;

View file

@ -184,8 +184,9 @@ public:
//! Special image ids for images used in the GUI
enum kThemeImages {
kImageLogo = 0, //!< ScummVM Logo used in the launcher
kImageLogoSmall //!< ScummVM logo used in the GMM
kImageLogo = 0, //!< ScummVM logo used in the launcher
kImageLogoSmall, //!< ScummVM logo used in the GMM
kImageSearch //!< Search tool image used in the launcher
};
/**
@ -422,13 +423,17 @@ public:
}
const Graphics::Surface *getImageSurface(const kThemeImages n) const {
if (n == kImageLogo)
switch (n) {
case kImageLogo:
return _bitmaps.contains("logo.bmp") ? _bitmaps["logo.bmp"] : 0;
else if (n == kImageLogoSmall)
case kImageLogoSmall:
return _bitmaps.contains("logo_small.bmp") ? _bitmaps["logo_small.bmp"] : 0;
case kImageSearch:
return _bitmaps.contains("search.bmp") ? _bitmaps["search.bmp"] : 0;
default:
return 0;
}
}
/**
* Interface for the Theme Parser: Creates a new cursor by loading the given

View file

@ -28,13 +28,13 @@
namespace GUI {
EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget(boss, x, y, w, h) {
EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd)
: Widget(boss, x, y, w, h), CommandSender(boss), _cmd(cmd) {
init();
}
EditableWidget::EditableWidget(GuiObject *boss, const String &name)
: Widget(boss, name) {
EditableWidget::EditableWidget(GuiObject *boss, const String &name, uint32 cmd)
: Widget(boss, name), CommandSender(boss), _cmd(cmd) {
init();
}
@ -109,6 +109,8 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
_caretPos--;
_editString.deleteChar(_caretPos);
dirty = true;
sendCommand(_cmd, 0);
}
forcecaret = true;
break;
@ -116,6 +118,8 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
if (_caretPos < (int)_editString.size()) {
_editString.deleteChar(_caretPos);
dirty = true;
sendCommand(_cmd, 0);
}
forcecaret = true;
break;
@ -146,6 +150,8 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
_caretPos++;
dirty = true;
forcecaret = true;
sendCommand(_cmd, 0);
} else {
handled = false;
}

View file

@ -36,12 +36,14 @@ namespace GUI {
* Base class for widgets which need to edit text, like ListWidget and
* EditTextWidget.
*/
class EditableWidget : public Widget {
class EditableWidget : public Widget, public CommandSender {
public:
typedef Common::String String;
protected:
String _editString;
uint32 _cmd;
bool _caretVisible;
uint32 _caretTime;
int _caretPos;
@ -53,8 +55,8 @@ protected:
ThemeEngine::FontStyle _font;
public:
EditableWidget(GuiObject *boss, int x, int y, int w, int h);
EditableWidget(GuiObject *boss, const String &name);
EditableWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd = 0);
EditableWidget(GuiObject *boss, const String &name, uint32 cmd = 0);
virtual ~EditableWidget();
void init();

View file

@ -64,6 +64,7 @@ enum {
kRemoveGameCmd = 'REMG',
kLoadGameCmd = 'LOAD',
kQuitCmd = 'QUIT',
kSearchCmd = 'SRCH',
kCmdGlobalGraphicsOverride = 'OGFX',
@ -508,6 +509,10 @@ LauncherDialog::LauncherDialog()
_removeButton =
new ButtonWidget(this, "Launcher.RemoveGameButton", "Remove Game", kRemoveGameCmd, 'R');
// Search box
_searchPic = new GraphicsWidget(this, "Launcher.SearchPic");
_searchPic->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageSearch));
_searchWidget = new EditTextWidget(this, "Launcher.Search", _search, kSearchCmd);
// Add list with game titles
_list = new ListWidget(this, "Launcher.GameList");
@ -907,6 +912,8 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
setResult(-1);
close();
break;
case kSearchCmd:
break;
default:
Dialog::handleCommand(sender, cmd, data);
}

View file

@ -34,6 +34,7 @@ class BrowserDialog;
class ListWidget;
class GraphicsWidget;
class SaveLoadChooser;
class EditTextWidget;
Common::String addGameToConf(const GameDescriptor &result);
@ -50,6 +51,7 @@ public:
virtual void handleKeyUp(Common::KeyState state);
protected:
EditTextWidget *_searchWidget;
ListWidget *_list;
ButtonWidget *_addButton;
Widget *_startButton;
@ -58,11 +60,14 @@ protected:
Widget *_removeButton;
#ifndef DISABLE_FANCY_THEMES
GraphicsWidget *_logo;
GraphicsWidget *_searchPic;
#endif
StringList _domains;
BrowserDialog *_browser;
SaveLoadChooser *_loadDialog;
String _search;
virtual void reflowLayout();
void updateListing();

Binary file not shown.

View file

@ -99,6 +99,7 @@
<bitmap filename = 'checkbox.bmp'/>
<bitmap filename = 'checkbox_empty.bmp'/>
<bitmap filename = 'logo_small.bmp'/>
<bitmap filename = 'search.bmp'/>
</bitmaps>
<fonts>

View file

@ -104,6 +104,17 @@
width = '283'
height = '80'
/>
<layout type = 'horizontal' spacing = '5' padding = '10, 0, 0, 0'>
<widget name = 'SearchPic'
width = '16'
height = '17'
/>
<widget name = 'Search'
width = '150'
height = 'Globals.Line.Height'
/>
<space />
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0'>
<widget name = 'GameList'/>
<layout type = 'vertical' padding = '10, 0, 0, 0'>