[Scummvm-cvs-logs] CVS: scummvm/gui object.h,NONE,1.1 EditTextWidget.cpp,1.16,1.17 EditTextWidget.h,1.9,1.10 ListWidget.cpp,1.26,1.27 ListWidget.h,1.15,1.16 PopUpWidget.cpp,1.19,1.20 PopUpWidget.h,1.3,1.4 ScrollBarWidget.cpp,1.10,1.11 ScrollBarWidget.h,1.3,1.4 about.cpp,1.6,1.7 dialog.cpp,1.32,1.33 dialog.h,1.22,1.23 message.cpp,1.14,1.15 options.h,1.7,1.8 widget.cpp,1.19,1.20 widget.h,1.22,1.23
Max Horn
fingolfin at users.sourceforge.net
Sun Nov 2 06:51:20 CET 2003
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv16482
Modified Files:
EditTextWidget.cpp EditTextWidget.h ListWidget.cpp
ListWidget.h PopUpWidget.cpp PopUpWidget.h ScrollBarWidget.cpp
ScrollBarWidget.h about.cpp dialog.cpp dialog.h message.cpp
options.h widget.cpp widget.h
Added Files:
object.h
Log Message:
introduced common base class GuiObject for Dialog/Widget -> step towards making it possible to nest widgets (needed for TabWidget)
--- NEW FILE: object.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002-2003 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/gui/object.h,v 1.1 2003/11/02 14:50:44 fingolfin Exp $
*/
#ifndef GUI_OBJECT_H
#define GUI_OBJECT_H
class CommandReceiver;
class CommandSender;
class CommandReceiver {
friend class CommandSender;
protected:
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {}
};
class CommandSender {
// TODO - allow for multiple targets, i.e. store targets in a list
// and add methods addTarget/removeTarget.
protected:
CommandReceiver *_target;
public:
CommandSender(CommandReceiver *target) : _target(target) {}
void setTarget(CommandReceiver *target) { _target = target; }
CommandReceiver *getTarget() const { return _target; }
virtual void sendCommand(uint32 cmd, uint32 data) {
if (_target && cmd)
_target->handleCommand(this, cmd, data);
}
};
class Widget;
class GuiObject : public CommandReceiver {
friend class Widget;
protected:
int16 _x, _y;
uint16 _w, _h;
Widget *_firstWidget;
public:
GuiObject(int x, int y, int w, int h) : _x(x), _y(y), _w(w), _h(h), _firstWidget(0) { }
virtual bool isVisible() const = 0;
int16 getX() const { return _x; }
int16 getY() const { return _y; }
uint16 getW() const { return _w; }
uint16 getH() const { return _h; }
protected:
virtual void releaseFocus() = 0;
};
#endif
Index: EditTextWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- EditTextWidget.cpp 2 Nov 2003 02:18:13 -0000 1.16
+++ EditTextWidget.cpp 2 Nov 2003 14:50:43 -0000 1.17
@@ -23,7 +23,7 @@
#include "dialog.h"
#include "newgui.h"
-EditTextWidget::EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text)
+EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
: StaticTextWidget(boss, x, y-1, w, h+2, text, kTextAlignLeft), _backupString(text) {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
_type = kEditTextWidget;
@@ -83,7 +83,7 @@
switch (keycode) {
case '\n': // enter/return
case '\r':
- _boss->releaseFocus();
+ releaseFocus();
dirty = true;
break;
case 27: // escape
@@ -92,7 +92,7 @@
_labelOffset = (g_gui.getStringWidth(_label) - (_w-6));
if (_labelOffset < 0)
_labelOffset = 0;
- _boss->releaseFocus();
+ releaseFocus();
dirty = true;
break;
case 8: // backspace
Index: EditTextWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- EditTextWidget.h 2 Nov 2003 02:18:13 -0000 1.9
+++ EditTextWidget.h 2 Nov 2003 14:50:44 -0000 1.10
@@ -36,7 +36,7 @@
int _pos;
int _labelOffset;
public:
- EditTextWidget(Dialog *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);
virtual void handleTickle();
virtual void handleMouseDown(int x, int y, int button, int clickCount);
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- ListWidget.cpp 2 Nov 2003 02:18:13 -0000 1.26
+++ ListWidget.cpp 2 Nov 2003 14:50:44 -0000 1.27
@@ -25,7 +25,7 @@
#include "newgui.h"
-ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h)
+ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget(boss, x, y, w - kScrollBarWidth, h), CommandSender(boss) {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
_type = kListWidget;
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ListWidget.h 2 Oct 2003 17:43:01 -0000 1.15
+++ ListWidget.h 2 Nov 2003 14:50:44 -0000 1.16
@@ -41,7 +41,7 @@
};
/* ListWidget */
-class ListWidget : public Widget, public CommandReceiver, public CommandSender {
+class ListWidget : public Widget, public CommandSender {
typedef Common::StringList StringList;
typedef Common::String String;
protected:
@@ -58,7 +58,7 @@
bool _caretVisible;
uint32 _caretTime;
public:
- ListWidget(Dialog *boss, int x, int y, int w, int h);
+ ListWidget(GuiObject *boss, int x, int y, int w, int h);
virtual ~ListWidget();
void setList(const StringList& list);
Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- PopUpWidget.cpp 2 Nov 2003 02:18:13 -0000 1.19
+++ PopUpWidget.cpp 2 Nov 2003 14:50:44 -0000 1.20
@@ -271,7 +271,7 @@
// PopUpWidget
//
-PopUpWidget::PopUpWidget(Dialog *boss, int x, int y, int w, int h)
+PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget(boss, x, y - 1, w, h + 2), CommandSender(boss) {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = 'POPU';
Index: PopUpWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- PopUpWidget.h 2 Oct 2003 17:43:02 -0000 1.3
+++ PopUpWidget.h 2 Nov 2003 14:50:44 -0000 1.4
@@ -52,7 +52,7 @@
int _selectedItem;
public:
- PopUpWidget(Dialog *boss, int x, int y, int w, int h);
+ PopUpWidget(GuiObject *boss, int x, int y, int w, int h);
void handleMouseDown(int x, int y, int button, int clickCount);
/*
Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ScrollBarWidget.cpp 2 Nov 2003 02:18:13 -0000 1.10
+++ ScrollBarWidget.cpp 2 Nov 2003 14:50:44 -0000 1.11
@@ -60,7 +60,7 @@
0x00001000,
};
-ScrollBarWidget::ScrollBarWidget(Dialog *boss, int x, int y, int w, int h)
+ScrollBarWidget::ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget (boss, x, y, w, h), CommandSender(boss) {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG | WIDGET_WANT_TICKLE;
_type = kScrollBarWidget;
Index: ScrollBarWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ScrollBarWidget.h 6 Mar 2003 21:45:37 -0000 1.3
+++ ScrollBarWidget.h 2 Nov 2003 14:50:44 -0000 1.4
@@ -57,7 +57,7 @@
int _currentPos;
public:
- ScrollBarWidget(Dialog *boss, int x, int y, int w, int h);
+ ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h);
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseUp(int x, int y, int button, int clickCount);
Index: about.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- about.cpp 2 Nov 2003 02:18:13 -0000 1.6
+++ about.cpp 2 Nov 2003 14:50:44 -0000 1.7
@@ -19,10 +19,10 @@
*/
#include "stdafx.h"
-#include "about.h"
-#include "newgui.h"
#include "base/engine.h"
-#include "common/str.h"
+#include "gui/about.h"
+#include "gui/newgui.h"
+#include "gui/widget.h"
AboutDialog::AboutDialog()
: Dialog(10, 20, 300, 124) {
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- dialog.cpp 2 Nov 2003 02:18:14 -0000 1.32
+++ dialog.cpp 2 Nov 2003 14:50:44 -0000 1.33
@@ -27,10 +27,6 @@
/*
* TODO list
- * - If saving or loading fails (e.g. due to disk full/directory write protected),
- * display an error dialog?
- * - The user can edit the name of the autosave game. Of course this will not
- * do anything, but we should still prevent this.
* - add some sense of the window being "active" (i.e. in front) or not. If it
* was inactive and just became active, reset certain vars (like who is focused).
* Maybe we should just add lostFocus and receivedFocus methods to Dialog, just
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- dialog.h 2 Nov 2003 02:18:14 -0000 1.22
+++ dialog.h 2 Nov 2003 14:50:44 -0000 1.23
@@ -22,7 +22,9 @@
#define DIALOG_H
#include "common/scummsys.h"
-#include "widget.h" // For CommandReceiver
+#include "common/str.h"
+
+#include "gui/object.h"
class NewGui;
class ButtonWidget;
@@ -33,13 +35,9 @@
kCloseCmd = 'clos'
};
-class Dialog : public CommandReceiver {
- friend class Widget;
+class Dialog : public GuiObject {
friend class NewGui;
protected:
- int16 _x, _y;
- uint16 _w, _h;
- Widget *_firstWidget;
Widget *_mouseWidget;
Widget *_focusedWidget;
bool _visible;
@@ -49,7 +47,7 @@
public:
Dialog(int x, int y, int w, int h)
- : _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
+ : GuiObject(x, y, w, h),
_mouseWidget(0), _focusedWidget(0), _visible(false) {
}
virtual ~Dialog();
@@ -57,10 +55,8 @@
virtual int runModal();
bool isVisible() const { return _visible; }
- int16 getX() const { return _x; }
- int16 getY() const { return _y; }
- void releaseFocus();
+ void releaseFocus();
protected:
virtual void open();
Index: message.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- message.cpp 2 Nov 2003 02:18:14 -0000 1.14
+++ message.cpp 2 Nov 2003 14:50:44 -0000 1.15
@@ -19,15 +19,18 @@
*/
#include "stdafx.h"
-#include "gui/message.h"
-#include "gui/newgui.h"
#include "common/str.h"
#include "common/list.h"
+#include "gui/message.h"
+#include "gui/newgui.h"
+#include "gui/widget.h"
enum {
kOkCmd = 'OK ',
kCancelCmd = 'CNCL'
};
+
+// TODO: The default button should be visibly distinct from the alternate button
MessageDialog::MessageDialog(const String &message, const char *defaultButton, const char *altButton)
: Dialog(30, 20, 260, 124) {
Index: options.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- options.h 2 Nov 2003 02:18:14 -0000 1.7
+++ options.h 2 Nov 2003 14:50:44 -0000 1.8
@@ -28,6 +28,8 @@
class BrowserDialog;
class GameDetector;
class PopUpWidget;
+class SliderWidget;
+class StaticTextWidget;
class GlobalOptionsDialog : public Dialog {
typedef Common::String String;
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- widget.cpp 2 Nov 2003 02:18:14 -0000 1.19
+++ widget.cpp 2 Nov 2003 14:50:44 -0000 1.20
@@ -23,8 +23,9 @@
#include "dialog.h"
#include "newgui.h"
-Widget::Widget(Dialog *boss, int x, int y, int w, int h)
- : _type(0), _boss(boss), _x(x), _y(y), _w(w), _h(h),
+
+Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
+ : GuiObject(x, y, w, h), _type(0), _boss(boss),
_id(0), _flags(0), _hasFocus(false) {
// Insert into the widget list of the boss
_next = _boss->_firstWidget;
@@ -72,9 +73,10 @@
_y -= _boss->_y;
}
+
#pragma mark -
-StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text, int align)
+StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, int align)
: Widget(boss, x, y, w, h), _align(align) {
_type = kStaticTextWidget;
setLabel(text);
@@ -93,7 +95,7 @@
#pragma mark -
-ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
+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),
_cmd(cmd), _hotkey(hotkey) {
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
@@ -114,7 +116,7 @@
#pragma mark -
-PushButtonWidget::PushButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
+PushButtonWidget::PushButtonWidget(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) {
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget;
@@ -142,7 +144,7 @@
0x00000000,
};
-CheckboxWidget::CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
+CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
: PushButtonWidget(boss, x, y, w, h, label, cmd, hotkey) {
_flags = WIDGET_ENABLED;
_type = kCheckboxWidget;
@@ -173,7 +175,7 @@
#pragma mark -
-SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, uint32 cmd, uint8 hotkey)
+SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, "", cmd, hotkey),
_value(0), _oldValue(0),_valueMin(0), _valueMax(100), _isDragging(false) {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- widget.h 2 Nov 2003 02:18:14 -0000 1.22
+++ widget.h 2 Nov 2003 14:50:44 -0000 1.23
@@ -18,11 +18,12 @@
* $Header$
*/
-#ifndef WIDGET_H
-#define WIDGET_H
+#ifndef GUI_WIDGET_H
+#define GUI_WIDGET_H
#include "common/scummsys.h"
#include "common/str.h"
+#include "gui/object.h"
class Dialog;
@@ -59,47 +60,19 @@
};
-class CommandReceiver;
-class CommandSender;
-
-class CommandReceiver {
- friend class CommandSender;
-protected:
- virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) = 0;
-};
-
-class CommandSender {
- // TODO - allow for multiple targets, i.e. store targets in a list
- // and add methods addTarget/removeTarget.
-protected:
- CommandReceiver *_target;
-public:
- CommandSender(CommandReceiver *target) : _target(target) {}
-
- void setTarget(CommandReceiver *target) { _target = target; }
- CommandReceiver *getTarget() const { return _target; }
-
- virtual void sendCommand(uint32 cmd, uint32 data) {
- if (_target && cmd)
- _target->handleCommand(this, cmd, data);
- }
-};
-
/* Widget */
-class Widget {
+class Widget : public GuiObject {
friend class Dialog;
protected:
uint32 _type;
- Dialog *_boss;
+ GuiObject *_boss;
Widget *_next;
- int16 _x, _y;
- uint16 _w, _h;
uint16 _id;
uint16 _flags;
bool _hasFocus;
public:
- Widget(Dialog *boss, int x, int y, int w, int h);
+ Widget(GuiObject *boss, int x, int y, int w, int h);
virtual ~Widget() {}
virtual void handleMouseDown(int x, int y, int button, int clickCount) {}
@@ -131,6 +104,8 @@
virtual void lostFocusWidget() {}
virtual Widget *findWidget(int x, int y) { return this; }
+
+ void releaseFocus() { _boss->releaseFocus(); }
};
/* StaticTextWidget */
@@ -141,7 +116,7 @@
String _label;
int _align;
public:
- StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text, int align);
+ StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, int align);
void setValue(int value);
void setLabel(const String &label) { _label = label; }
const String &getLabel() const { return _label; }
@@ -159,7 +134,7 @@
uint32 _cmd;
uint8 _hotkey;
public:
- ButtonWidget(Dialog *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);
void setCmd(uint32 cmd) { _cmd = cmd; }
uint32 getCmd() const { return _cmd; }
@@ -177,7 +152,7 @@
protected:
bool _state;
public:
- PushButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
+ PushButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
void setState(bool state);
void toggleState() { setState(!_state); }
@@ -188,7 +163,7 @@
class CheckboxWidget : public PushButtonWidget {
protected:
public:
- CheckboxWidget(Dialog *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);
void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseEntered(int button) {}
@@ -205,7 +180,7 @@
int _valueMin, _valueMax;
bool _isDragging;
public:
- SliderWidget(Dialog *boss, int x, int y, int w, int h, uint32 cmd = 0, uint8 hotkey = 0);
+ SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd = 0, uint8 hotkey = 0);
void setValue(int value) { _value = value; }
int getValue() const { return _value; }
More information about the Scummvm-git-logs
mailing list