diff options
Diffstat (limited to 'gui/widget.h')
-rw-r--r-- | gui/widget.h | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/gui/widget.h b/gui/widget.h index 0b075c19db..7b5fe9253f 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -27,6 +27,7 @@ #include "common/scummsys.h" #include "common/str.h" +#include "common/str-array.h" #include "common/keyboard.h" #include "graphics/surface.h" #include "gui/object.h" @@ -86,6 +87,7 @@ protected: uint16 _id; bool _hasFocus; ThemeEngine::WidgetStateInfo _state; + const char *_tooltip; private: uint16 _flags; @@ -95,8 +97,8 @@ public: static Widget *findWidgetInChain(Widget *start, const char *name); public: - Widget(GuiObject *boss, int x, int y, int w, int h); - Widget(GuiObject *boss, const Common::String &name); + Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0); + Widget(GuiObject *boss, const Common::String &name, const char *tooltip = 0); virtual ~Widget(); void init(); @@ -139,6 +141,8 @@ public: uint8 parseHotkey(const Common::String &label); Common::String cleanupHotkey(const Common::String &label); + const char *getTooltip() const { return _tooltip; } + protected: void updateState(int oldFlags, int newFlags); @@ -155,14 +159,39 @@ protected: void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { assert(_boss); _boss->handleCommand(sender, cmd, data); } }; +class GuiManager; + +class Tooltip : public GuiObject { +public: + Tooltip(GuiManager *guiManager); + + bool isVisible() const { return _visible; } + void draw(); + void reflowLayout(); + void releaseFocus() {} + void setVisible(bool state); + void setMouseXY(int x, int y); + +protected: + Common::String _text; + GuiManager *_guiManager; + bool _visible; + int _mouseX, _mouseY; + int _maxWidth; + int _xdelta, _ydelta; + + Common::StringArray _wrappedLines; + ThemeEngine::StoredState *_storedState; +}; + /* StaticTextWidget */ class StaticTextWidget : public Widget { protected: Common::String _label; Graphics::TextAlign _align; public: - StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align); - StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text); + StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip = 0); + StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip = 0); void setValue(int value); void setLabel(const Common::String &label); const Common::String &getLabel() const { return _label; } @@ -180,8 +209,8 @@ protected: uint32 _cmd; uint8 _hotkey; public: - ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); - ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); + ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0); + ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0); void setCmd(uint32 cmd) { _cmd = cmd; } uint32 getCmd() const { return _cmd; } @@ -199,8 +228,8 @@ class CheckboxWidget : public ButtonWidget { protected: bool _state; public: - CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); - CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); + CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0); + CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::String &label, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0); void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } @@ -245,8 +274,8 @@ protected: int _value; public: - RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey = 0); - RadiobuttonWidget(GuiObject *boss, const Common::String &name, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey = 0); + RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, RadiobuttonGroup *group, int value, const Common::String &label, const char *tooltip = 0, uint8 hotkey = 0); + RadiobuttonWidget(GuiObject *boss, const Common::String &name, RadiobuttonGroup *group, int value, const Common::String &label, const char *tooltip = 0, uint8 hotkey = 0); void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } @@ -272,8 +301,8 @@ protected: bool _isDragging; uint _labelWidth; public: - SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd = 0); - SliderWidget(GuiObject *boss, const Common::String &name, uint32 cmd = 0); + SliderWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0); + SliderWidget(GuiObject *boss, const Common::String &name, const char *tooltip = 0, uint32 cmd = 0); void setCmd(uint32 cmd) { _cmd = cmd; } uint32 getCmd() const { return _cmd; } @@ -304,8 +333,8 @@ protected: /* GraphicsWidget */ class GraphicsWidget : public Widget { public: - GraphicsWidget(GuiObject *boss, int x, int y, int w, int h); - GraphicsWidget(GuiObject *boss, const Common::String &name); + GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0); + GraphicsWidget(GuiObject *boss, const Common::String &name, const char *tooltip = 0); ~GraphicsWidget(); void setGfx(const Graphics::Surface *gfx); |