[Scummvm-cvs-logs] CVS: scummvm/gui EditTextWidget.cpp,1.31,1.32 EditTextWidget.h,1.19,1.20 ListWidget.cpp,1.51,1.52 browser.cpp,1.30,1.31 chooser.cpp,1.14,1.15 dialog.cpp,1.57,1.58 dialog.h,1.38,1.39 editable.cpp,1.4,1.5 editable.h,1.3,1.4 launcher.cpp,1.123,1.124 message.cpp,1.26,1.27 newgui.cpp,1.113,1.114 newgui.h,1.58,1.59 options.cpp,1.88,1.89
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Fri May 20 08:05:35 CEST 2005
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18274/gui
Modified Files:
EditTextWidget.cpp EditTextWidget.h ListWidget.cpp browser.cpp
chooser.cpp dialog.cpp dialog.h editable.cpp editable.h
launcher.cpp message.cpp newgui.cpp newgui.h options.cpp
Log Message:
Added big editable text widget, and removed some cruft. I think this means
that all our widgets are able to scale themselves now, but I could be
mistaken.
Index: EditTextWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- EditTextWidget.cpp 29 Jan 2005 18:04:34 -0000 1.31
+++ EditTextWidget.cpp 20 May 2005 15:03:25 -0000 1.32
@@ -26,8 +26,8 @@
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, WidgetSize ws)
+ : EditableWidget(boss, x, y - 1, w, h + 2, ws) {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
_type = kEditTextWidget;
@@ -44,15 +44,13 @@
if (_caretVisible)
drawCaret(true);
- NewGui *gui = &g_gui;
-
x += _editScrollOffset;
int width = 0;
uint i;
for (i = 0; i < _editString.size(); ++i) {
- width += gui->getCharWidth(_editString[i]);
+ width += _font->getCharWidth(_editString[i]);
if (width >= x)
break;
}
@@ -70,7 +68,7 @@
// Draw the text
adjustOffset();
- g_gui.drawString(_editString, _x + 2, _y + 2, getEditRect().width(), g_gui._textcolor, kTextAlignLeft, -_editScrollOffset, false);
+ g_gui.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(), g_gui._textcolor, kTextAlignLeft, -_editScrollOffset, false);
}
Common::Rect EditTextWidget::getEditRect() const {
Index: EditTextWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- EditTextWidget.h 6 Apr 2005 15:21:23 -0000 1.19
+++ EditTextWidget.h 20 May 2005 15:03:25 -0000 1.20
@@ -34,7 +34,7 @@
String _backupString;
public:
- EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text);
+ EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, WidgetSize ws = kNormalWidgetSize);
void setEditString(const String &str);
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- ListWidget.cpp 16 May 2005 13:28:34 -0000 1.51
+++ ListWidget.cpp 20 May 2005 15:03:25 -0000 1.52
@@ -28,14 +28,11 @@
namespace GUI {
ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws)
- : EditableWidget(boss, x, y, w, h), CommandSender(boss) {
+ : EditableWidget(boss, x, y, w, h, ws), CommandSender(boss) {
- // TODO: When in kBigWidgetSize mode, use another font
if (ws == kBigWidgetSize) {
- _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
_w = w - kBigScrollBarWidth;
} else {
- _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
_w = w - kNormalScrollBarWidth;
}
_lineHeight = _font->getFontHeight() + 2;
Index: browser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/browser.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- browser.cpp 16 May 2005 09:24:28 -0000 1.30
+++ browser.cpp 20 May 2005 15:03:25 -0000 1.31
@@ -177,9 +177,9 @@
_fileList->setEditable(false);
// Buttons
- addButton(10, _h - buttonHeight - 8, "Go up", kGoUpCmd, 0, ws);
- addButton(_w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
- addButton(_w - (buttonWidth + 10), _h - buttonHeight - 8, "Choose", kChooseCmd, 0, ws);
+ addButton(this, 10, _h - buttonHeight - 8, "Go up", kGoUpCmd, 0, ws);
+ addButton(this, _w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
+ addButton(this, _w - (buttonWidth + 10), _h - buttonHeight - 8, "Choose", kChooseCmd, 0, ws);
}
void BrowserDialog::open() {
Index: chooser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/chooser.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- chooser.cpp 27 Mar 2005 11:27:07 -0000 1.14
+++ chooser.cpp 20 May 2005 15:03:25 -0000 1.15
@@ -39,8 +39,8 @@
_list->setNumberingMode(kListNumberingOff);
// Buttons
- addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
- _chooseButton = addButton(_w-(kButtonWidth + 10), _h - 24, buttonLabel, kChooseCmd, 0);
+ addButton(this, _w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
+ _chooseButton = addButton(this, _w-(kButtonWidth + 10), _h - 24, buttonLabel, kChooseCmd, 0);
_chooseButton->setEnabled(false);
}
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- dialog.cpp 19 May 2005 17:03:30 -0000 1.57
+++ dialog.cpp 20 May 2005 15:03:25 -0000 1.58
@@ -289,10 +289,6 @@
return Widget::findWidgetInChain(_firstWidget, x, y);
}
-ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
- return addButton(this, x, y, label, cmd, hotkey, ws);
-}
-
ButtonWidget *Dialog::addButton(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
int w = kButtonWidth;
int h = kButtonHeight;
@@ -303,10 +299,6 @@
return new ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws);
}
-CheckboxWidget *Dialog::addCheckbox(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
- return addCheckbox(this, x, y, label, cmd, hotkey, ws);
-}
-
CheckboxWidget *Dialog::addCheckbox(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
const Graphics::Font *font;
int w, h;
@@ -324,10 +316,6 @@
return new CheckboxWidget(boss, x, y, w, h, label, cmd, hotkey, ws);
}
-SliderWidget *Dialog::addSlider(int x, int y, uint32 cmd, WidgetSize ws) {
- return addSlider(this, x, y, cmd, ws);
-}
-
SliderWidget *Dialog::addSlider(GuiObject *boss, int x, int y, uint32 cmd, WidgetSize ws) {
int w, h;
@@ -342,10 +330,6 @@
return new SliderWidget(boss, x, y, w, h, cmd);
}
-PopUpWidget *Dialog::addPopUp(int x, int y, int w, const Common::String &label, uint labelWidth, WidgetSize ws) {
- return addPopUp(this, x, y, w, label, labelWidth, ws);
-}
-
PopUpWidget *Dialog::addPopUp(GuiObject *boss, int x, int y, int w, const Common::String &label, uint labelWidth, WidgetSize ws) {
const Graphics::Font *font;
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- dialog.h 19 May 2005 17:03:30 -0000 1.38
+++ dialog.h 20 May 2005 15:03:25 -0000 1.39
@@ -88,16 +88,9 @@
Widget *findWidget(int x, int y); // Find the widget at pos x,y if any
ButtonWidget *addButton(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize);
- ButtonWidget *addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize);
-
CheckboxWidget *addCheckbox(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize);
- CheckboxWidget *addCheckbox(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize);
-
SliderWidget *addSlider(GuiObject *boss, int x, int y, uint32 cmd, WidgetSize ws = kDefaultWidgetSize);
- SliderWidget *addSlider(int x, int y, uint32 cmd, WidgetSize ws = kDefaultWidgetSize);
-
PopUpWidget *addPopUp(GuiObject *boss, int x, int y, int w, const Common::String &label, uint labelWidth = 0, WidgetSize ws = kDefaultWidgetSize);
- PopUpWidget *addPopUp(int x, int y, int w, const Common::String &label, uint labelWidth = 0, WidgetSize ws = kDefaultWidgetSize);
void setResult(int result) { _result = result; }
int getResult() const { return _result; }
Index: editable.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/editable.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- editable.cpp 17 May 2005 06:19:11 -0000 1.4
+++ editable.cpp 20 May 2005 15:03:25 -0000 1.5
@@ -25,7 +25,7 @@
namespace GUI {
-EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h)
+EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws)
: Widget(boss, x, y, w, h) {
_caretVisible = false;
_caretTime = 0;
@@ -35,7 +35,17 @@
_editScrollOffset = 0;
- _font = &g_gui.getFont(); // Most widgets will probably set this to something else.
+ switch (ws) {
+ case kNormalWidgetSize:
+ _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ break;
+ case kBigWidgetSize:
+ _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ break;
+ default:
+ _font = &g_gui.getFont();
+ break;
+ }
}
EditableWidget::~EditableWidget() {
Index: editable.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/editable.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- editable.h 16 May 2005 13:43:31 -0000 1.3
+++ editable.h 20 May 2005 15:03:25 -0000 1.4
@@ -47,7 +47,7 @@
int _editScrollOffset;
public:
- EditableWidget(GuiObject *boss, int x, int y, int w, int h);
+ EditableWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kNormalWidgetSize);
virtual ~EditableWidget();
virtual void setEditString(const String &str);
Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- launcher.cpp 19 May 2005 17:03:31 -0000 1.123
+++ launcher.cpp 20 May 2005 15:03:25 -0000 1.124
@@ -79,8 +79,8 @@
*/
class DomainEditTextWidget : public EditTextWidget {
public:
- DomainEditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
- : EditTextWidget(boss, x, y, w, h, text) {
+ DomainEditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, WidgetSize ws = kNormalWidgetSize)
+ : EditTextWidget(boss, x, y, w, h, text, ws) {
}
protected:
@@ -188,15 +188,25 @@
tab->addTab("Game");
yoffset = vBorder;
+ const Graphics::Font *font;
+
+ if (ws == GUI::kBigWidgetSize) {
+ font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ } else {
+ font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ }
+
+ int lineHeight = font->getFontHeight() + 2;
+
// GUI: Label & edit widget for the game ID
- new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "ID: ", kTextAlignRight, ws);
- _domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain);
- yoffset += 16;
+ new StaticTextWidget(tab, x, yoffset + 2, labelWidth, lineHeight, "ID: ", kTextAlignRight, ws);
+ _domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, lineHeight, _domain, ws);
+ yoffset += _domainWidget->getHeight() + 3;
// GUI: Label & edit widget for the description
- new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "Name: ", kTextAlignRight, ws);
- _descriptionWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, description);
- yoffset += 16;
+ new StaticTextWidget(tab, x, yoffset + 2, labelWidth, lineHeight, "Name: ", kTextAlignRight, ws);
+ _descriptionWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, lineHeight, description, ws);
+ yoffset += _descriptionWidget->getHeight() + 3;
// Language popup
_langPopUp = addPopUp(tab, x, yoffset, w, "Language: ", labelWidth, ws);
@@ -224,12 +234,12 @@
// GUI: Button + Label for the game path
addButton(tab, x, yoffset, "Game Path:", kCmdGameBrowser, 0, ws);
- _gamePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, gamePath, kTextAlignLeft, ws);
+ _gamePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, gamePath, kTextAlignLeft, ws);
yoffset += buttonHeight + 4;
// GUI: Button + Label for the additional path
addButton(tab, x, yoffset, "Extra Path:", kCmdExtraBrowser, 0, ws);
- _extraPathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, extraPath, kTextAlignLeft, ws);
+ _extraPathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, extraPath, kTextAlignLeft, ws);
if (extraPath.isEmpty() || !ConfMan.hasKey("extrapath", _domain)) {
_extraPathWidget->setLabel("None");
}
@@ -237,7 +247,7 @@
// GUI: Button + Label for the save path
addButton(tab, x, yoffset, "Save Path:", kCmdSaveBrowser, 0, ws);
- _savePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, savePath, kTextAlignLeft, ws);
+ _savePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, savePath, kTextAlignLeft, ws);
if (savePath.isEmpty() || !ConfMan.hasKey("savepath", _domain)) {
_savePathWidget->setLabel("Default");
}
@@ -292,8 +302,8 @@
tab->setActiveTab(0);
// Add OK & Cancel buttons
- addButton(_w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
- addButton(_w - (buttonWidth + 10), _h - buttonHeight - 8, "OK", kOKCmd, 0, ws);
+ addButton(this, _w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
+ addButton(this, _w - (buttonWidth + 10), _h - buttonHeight - 8, "OK", kOKCmd, 0, ws);
}
void EditGameDialog::open() {
@@ -506,12 +516,13 @@
ws = GUI::kBigWidgetSize;
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
lineHeight = font->getFontHeight() + 2;
+ buttonHeight = kBigButtonHeight;
} else {
ws = GUI::kNormalWidgetSize;
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
lineHeight = font->getFontHeight() + 2;
+ buttonHeight = kButtonHeight;
}
- buttonHeight = lineHeight * 4 / 3;
// Show ScummVM version
new StaticTextWidget(this, hBorder, 8, _w - 2*hBorder, lineHeight, gScummVMFullVersion, kTextAlignCenter, ws);
Index: message.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- message.cpp 16 May 2005 10:26:20 -0000 1.26
+++ message.cpp 20 May 2005 15:03:25 -0000 1.27
@@ -100,10 +100,10 @@
}
if (defaultButton)
- addButton(okButtonPos, _h - buttonHeight - 8, defaultButton, kOkCmd, '\n', ws); // Confirm dialog
+ addButton(this, okButtonPos, _h - buttonHeight - 8, defaultButton, kOkCmd, '\n', ws); // Confirm dialog
if (altButton)
- addButton(cancelButtonPos, _h - buttonHeight - 8, altButton, kCancelCmd, '\27', ws); // Cancel dialog
+ addButton(this, cancelButtonPos, _h - buttonHeight - 8, altButton, kCancelCmd, '\27', ws); // Cancel dialog
}
void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- newgui.cpp 15 May 2005 17:59:27 -0000 1.113
+++ newgui.cpp 20 May 2005 15:03:25 -0000 1.114
@@ -466,8 +466,8 @@
getFont().drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
}
-void NewGui::drawString(const Graphics::Font *font, const String &s, int x, int y, int w, OverlayColor color, TextAlignment valign) {
- font->drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, valign);
+void NewGui::drawString(const Graphics::Font *font, const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) {
+ font->drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
}
//
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- newgui.h 12 May 2005 15:46:02 -0000 1.58
+++ newgui.h 20 May 2005 15:03:26 -0000 1.59
@@ -154,7 +154,7 @@
void drawChar(byte c, int x, int y, OverlayColor color, const Graphics::Font *font = 0);
void drawString(const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment align = Graphics::kTextAlignLeft, int deltax = 0, bool useEllipsis = true);
- void drawString(const Graphics::Font *font, const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment valign = Graphics::kTextAlignLeft);
+ void drawString(const Graphics::Font *font, const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment align = Graphics::kTextAlignLeft, int deltax = 0, bool useEllipsis = true);
int getStringWidth(const String &str) const;
int getCharWidth(byte c) const;
Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- options.cpp 19 May 2005 17:03:31 -0000 1.88
+++ options.cpp 20 May 2005 15:03:26 -0000 1.89
@@ -576,8 +576,8 @@
tab->setActiveTab(0);
// Add OK & Cancel buttons
- addButton(_w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
- addButton(_w - (buttonWidth + 10), _h - buttonHeight - 8, "OK", kOKCmd, 0, ws);
+ addButton(this, _w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws);
+ addButton(this, _w - (buttonWidth + 10), _h - buttonHeight - 8, "OK", kOKCmd, 0, ws);
// Create file browser dialogs
_dirBrowser = new BrowserDialog("Select directory for savegames", true);
More information about the Scummvm-git-logs
mailing list