diff options
author | Max Horn | 2002-07-12 16:24:11 +0000 |
---|---|---|
committer | Max Horn | 2002-07-12 16:24:11 +0000 |
commit | e34571dca90689bd7367697c842927994a38d62d (patch) | |
tree | 017bb4761fc65a9b517c2f08a45d17a20bd6a813 /gui/widget.h | |
parent | c99d9a57c0e6d3d24c3f6c51c50612a228f17158 (diff) | |
download | scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.gz scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.bz2 scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.zip |
Countless changes to the New GUI; some hightligths: new ScrollBarWidget class; ListWidget is usable (demo shows it off); added custom String/StringList classes
svn-id: r4521
Diffstat (limited to 'gui/widget.h')
-rw-r--r-- | gui/widget.h | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/gui/widget.h b/gui/widget.h index a061e31c85..f7cc5eb316 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -41,7 +41,35 @@ enum { kButtonWidget = 'BTTN', kCheckboxWidget = 'CHKB', kSliderWidget = 'SLDE', - kListWidget = 'LIST' + kListWidget = 'LIST', + kScrollBarWidget = 'SCRB' +}; + +class CommandReceiver; +class CommandSender; + +class CommandReceiver +{ +friend class CommandSender; +protected: + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) = 0; +}; + +class CommandSender +{ +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 */ @@ -59,7 +87,7 @@ public: Widget(Dialog *boss, int x, int y, int w, int h); virtual ~Widget() {} - virtual void handleClick(int button) {} + virtual void handleClick(int x, int y, int button) {} virtual void handleMouseEntered(int button) {} virtual void handleMouseLeft(int button) {} virtual void handleMouseMoved(int x, int y, int button) {} @@ -78,12 +106,12 @@ protected: /* StaticTextWidget */ class StaticTextWidget : public Widget { protected: - char *_text; + char *_label; public: StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text); ~StaticTextWidget(); - void setText(const char *text); - const char *getText() const { return _text; } + void setLabel(const char *label); + const char *getLabel() const { return _label; } protected: void drawWidget(bool hilite); @@ -91,17 +119,19 @@ protected: /* ButtonWidget */ -class ButtonWidget : public StaticTextWidget { -friend class Dialog; +class ButtonWidget : public StaticTextWidget, public CommandSender { + friend class Dialog; // Needed for the hotkey handling protected: - uint32 _cmd; - uint8 _hotkey; + uint32 _cmd; + uint8 _hotkey; public: ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd = 0, uint8 hotkey = 0); - void setCmd(uint32 cmd) { _cmd = cmd; } - uint32 getCmd() const { return _cmd; } + virtual ~ButtonWidget(); + + void setCmd(uint32 cmd) { _cmd = cmd; } + uint32 getCmd() const { return _cmd; } - void handleClick(int button); + void handleClick(int x, int y, int button); void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } }; @@ -115,7 +145,7 @@ public: void setState(bool state) { _state = state; } bool getState() const { return _state; } - void handleClick(int button); + void handleClick(int x, int y, int button); virtual void handleMouseEntered(int button) {} virtual void handleMouseLeft(int button) {} |