[Scummvm-cvs-logs] CVS: scummvm/gui widget.h,1.40,1.41 widget.cpp,1.44,1.45 newgui.h,1.56,1.57 dialog.h,1.32,1.33 dialog.cpp,1.51,1.52
Max Horn
fingolfin at users.sourceforge.net
Wed May 11 12:32:42 CEST 2005
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2262
Modified Files:
widget.h widget.cpp newgui.h dialog.h dialog.cpp
Log Message:
Start work on support for 'big' widgets
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- widget.h 8 May 2005 22:38:29 -0000 1.40
+++ widget.h 11 May 2005 19:30:28 -0000 1.41
@@ -27,6 +27,10 @@
#include "graphics/surface.h"
#include "gui/object.h"
+namespace Graphics {
+ class Font;
+}
+
namespace GUI {
class Dialog;
@@ -61,9 +65,18 @@
kCaretBlinkTime = 300
};
+enum WidgetSize {
+ kDefaultWidgetSize,
+ kNormalWidgetSize,
+ kBigWidgetSize
+};
+
enum {
kButtonWidth = 72,
- kButtonHeight = 16
+ kButtonHeight = 16,
+
+ kBigButtonWidth = 108,
+ kBigButtonHeight = 24
};
@@ -87,6 +100,9 @@
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 @@
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 @@
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 @@
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 @@
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; }
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- widget.cpp 8 May 2005 23:39:37 -0000 1.44
+++ widget.cpp 11 May 2005 19:30:28 -0000 1.45
@@ -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 @@
#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::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::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 @@
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 @@
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 @@
// 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);
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- newgui.h 17 Apr 2005 11:20:59 -0000 1.56
+++ newgui.h 11 May 2005 19:30:29 -0000 1.57
@@ -127,6 +127,9 @@
// 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);
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- dialog.h 17 Apr 2005 11:20:58 -0000 1.32
+++ dialog.h 11 May 2005 19:30:30 -0000 1.33
@@ -25,6 +25,7 @@
#include "common/str.h"
#include "gui/object.h"
+#include "gui/widget.h"
namespace GUI {
@@ -86,7 +87,7 @@
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; }
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- dialog.cpp 17 Apr 2005 11:20:58 -0000 1.51
+++ dialog.cpp 11 May 2005 19:30:30 -0000 1.52
@@ -288,8 +288,14 @@
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);
}
More information about the Scummvm-git-logs
mailing list