aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2005-05-11 19:30:30 +0000
committerMax Horn2005-05-11 19:30:30 +0000
commit79241d323fec0299e55bbfb420d0b4cdb4a70965 (patch)
tree59c947e9610c9ed16f2f0d2d8777f80cf5d880c5 /gui
parent25404478438b60cf1bb121a79c5e083c26dc8784 (diff)
downloadscummvm-rg350-79241d323fec0299e55bbfb420d0b4cdb4a70965.tar.gz
scummvm-rg350-79241d323fec0299e55bbfb420d0b4cdb4a70965.tar.bz2
scummvm-rg350-79241d323fec0299e55bbfb420d0b4cdb4a70965.zip
Start work on support for 'big' widgets
svn-id: r18060
Diffstat (limited to 'gui')
-rw-r--r--gui/dialog.cpp10
-rw-r--r--gui/dialog.h3
-rw-r--r--gui/newgui.h3
-rw-r--r--gui/widget.cpp37
-rw-r--r--gui/widget.h32
5 files changed, 63 insertions, 22 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 42433ea659..e67c82e023 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -288,8 +288,14 @@ Widget *Dialog::findWidget(int x, int y) {
return Widget::findWidgetInChain(_firstWidget, x, y);
}
-ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) {
- return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey);
+ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
+ int w = kButtonWidth;
+ int h = kButtonHeight;
+ if (ws == kBigWidgetSize) {
+ w = kBigButtonWidth;
+ h = kBigButtonHeight;
+ }
+ return new ButtonWidget(this, x, y, w, h, label, cmd, hotkey, ws);
}
diff --git a/gui/dialog.h b/gui/dialog.h
index f17eb30181..2e84191ee3 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -25,6 +25,7 @@
#include "common/str.h"
#include "gui/object.h"
+#include "gui/widget.h"
namespace GUI {
@@ -86,7 +87,7 @@ protected:
Widget *findWidget(int x, int y); // Find the widget at pos x,y if any
- ButtonWidget *addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey);
+ ButtonWidget *addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize);
void setResult(int result) { _result = result; }
int getResult() const { return _result; }
diff --git a/gui/newgui.h b/gui/newgui.h
index bdff549838..5724499ec6 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -127,6 +127,9 @@ public:
// Font
const Graphics::Font &getFont() const;
+
+ // Screen surface
+ Graphics::Surface &getScreen() { return _screen; }
// Drawing primitives
void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 582f7b902b..158fac64dd 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -20,6 +20,7 @@
#include "stdafx.h"
#include "common/util.h"
+#include "graphics/fontman.h"
#include "gui/widget.h"
#include "gui/dialog.h"
#include "gui/newgui.h"
@@ -106,11 +107,23 @@ Widget *Widget::findWidgetInChain(Widget *w, int x, int y) {
#pragma mark -
-StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align)
- : Widget(boss, x, y, w, h), _align(align) {
+StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align, WidgetSize ws)
+ : Widget(boss, x, y, w, h), _align(align), _ws(ws) {
_flags = WIDGET_ENABLED;
_type = kStaticTextWidget;
_label = text;
+
+ switch (_ws) {
+ case kNormalWidgetSize:
+ _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ break;
+ case kBigWidgetSize:
+ _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ break;
+ case kDefaultWidgetSize:
+ _font = &g_gui.getFont();
+ break;
+ }
}
void StaticTextWidget::setValue(int value) {
@@ -137,13 +150,13 @@ void StaticTextWidget::setAlign(TextAlignment align) {
void StaticTextWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
- gui->drawString(_label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
+ _font->drawString(&gui->getScreen(), _label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
}
#pragma mark -
-ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
- : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss),
+ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws)
+ : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter, ws), CommandSender(boss),
_cmd(cmd), _hotkey(hotkey) {
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget;
@@ -156,7 +169,7 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
void ButtonWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
- gui->drawString(_label, _x, _y + (_h - kLineHeight)/2 + 1, _w,
+ _font->drawString(&gui->getScreen(), _label, _x, _y + (_h - (_font->getFontHeight() + 2))/2 + 1, _w,
!isEnabled() ? gui->_color :
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
}
@@ -175,8 +188,8 @@ static uint32 checked_img[8] = {
0x00000000,
};
-CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
- : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) {
+CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws), _state(false) {
_flags = WIDGET_ENABLED;
_type = kCheckboxWidget;
}
@@ -208,13 +221,13 @@ void CheckboxWidget::drawWidget(bool hilite) {
gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
// Finally draw the label
- gui->drawString(_label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
+ _font->drawString(&g_gui.getScreen(), _label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
}
#pragma mark -
-SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, uint32 cmd, uint8 hotkey)
- : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
+SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, uint32 cmd, uint8 hotkey, WidgetSize ws)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws),
_value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false),
_labelWidth(labelWidth) {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
@@ -256,7 +269,7 @@ void SliderWidget::drawWidget(bool hilite) {
// Draw the label, if any
if (_labelWidth > 0)
- gui->drawString(_label, _x, _y + 2, _labelWidth, isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
+ _font->drawString(&g_gui.getScreen(), _label, _x, _y + 2, _labelWidth, isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
// Draw the box
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
diff --git a/gui/widget.h b/gui/widget.h
index 1b6623d620..830297f0f9 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -27,6 +27,10 @@
#include "graphics/surface.h"
#include "gui/object.h"
+namespace Graphics {
+ class Font;
+}
+
namespace GUI {
class Dialog;
@@ -61,9 +65,18 @@ enum {
kCaretBlinkTime = 300
};
+enum WidgetSize {
+ kDefaultWidgetSize,
+ kNormalWidgetSize,
+ kBigWidgetSize
+};
+
enum {
kButtonWidth = 72,
- kButtonHeight = 16
+ kButtonHeight = 16,
+
+ kBigButtonWidth = 108,
+ kBigButtonHeight = 24
};
@@ -87,6 +100,9 @@ public:
virtual int16 getAbsX() const { return _x + _boss->getChildX(); }
virtual int16 getAbsY() const { return _y + _boss->getChildY(); }
+
+// virtual void setPos(int x, int y);
+// virtual void setSize(int w, int h);
virtual void handleMouseDown(int x, int y, int button, int clickCount) {}
virtual void handleMouseUp(int x, int y, int button, int clickCount) {}
@@ -131,10 +147,12 @@ protected:
typedef Common::String String;
typedef Graphics::TextAlignment TextAlignment;
- String _label;
- TextAlignment _align;
+ String _label;
+ TextAlignment _align;
+ const WidgetSize _ws;
+ const Graphics::Font *_font;
public:
- StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align);
+ StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align, WidgetSize ws = kDefaultWidgetSize);
void setValue(int value);
void setLabel(const String &label);
const String &getLabel() const { return _label; }
@@ -152,7 +170,7 @@ protected:
uint32 _cmd;
uint8 _hotkey;
public:
- ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
+ ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize);
void setCmd(uint32 cmd) { _cmd = cmd; }
uint32 getCmd() const { return _cmd; }
@@ -170,7 +188,7 @@ class CheckboxWidget : public ButtonWidget {
protected:
bool _state;
public:
- CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
+ CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize);
void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseEntered(int button) {}
@@ -192,7 +210,7 @@ protected:
bool _isDragging;
uint _labelWidth;
public:
- SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label = String::emptyString, uint labelWidth = 0, uint32 cmd = 0, uint8 hotkey = 0);
+ SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label = String::emptyString, uint labelWidth = 0, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize);
void setValue(int value) { _value = value; }
int getValue() const { return _value; }