2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2002-07-05 16:56:53 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-02 14:50:53 +00:00
|
|
|
#ifndef GUI_WIDGET_H
|
|
|
|
#define GUI_WIDGET_H
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/array.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
#include "common/str.h"
|
2007-06-30 12:26:59 +00:00
|
|
|
#include "common/keyboard.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/font.h"
|
2021-04-05 17:17:17 +00:00
|
|
|
#include "graphics/managed_surface.h"
|
2003-11-02 14:50:53 +00:00
|
|
|
#include "gui/object.h"
|
2008-11-08 01:30:32 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
2019-07-10 22:14:28 +00:00
|
|
|
#include "common/text-to-speech.h"
|
|
|
|
#include "common/system.h"
|
2019-07-12 10:52:18 +00:00
|
|
|
#include "common/config-manager.h"
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2020-03-22 14:19:56 +00:00
|
|
|
class ScrollContainerWidget;
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
enum {
|
2009-01-02 01:31:46 +00:00
|
|
|
WIDGET_ENABLED = 1 << 0,
|
|
|
|
WIDGET_INVISIBLE = 1 << 1,
|
|
|
|
WIDGET_HILITED = 1 << 2,
|
|
|
|
WIDGET_BORDER = 1 << 3,
|
2012-05-03 16:32:08 +00:00
|
|
|
WIDGET_PRESSED = 1 << 4,
|
2009-01-02 01:31:46 +00:00
|
|
|
//WIDGET_INV_BORDER = 1 << 4,
|
|
|
|
WIDGET_CLEARBG = 1 << 5,
|
|
|
|
WIDGET_WANT_TICKLE = 1 << 7,
|
|
|
|
WIDGET_TRACK_MOUSE = 1 << 8,
|
2009-05-24 15:17:42 +00:00
|
|
|
// Retain focus on mouse up. By default widgets lose focus on mouseup,
|
2009-01-02 01:31:46 +00:00
|
|
|
// but some widgets might want to retain it - widgets where you enter
|
|
|
|
// text, for instance
|
|
|
|
WIDGET_RETAIN_FOCUS = 1 << 9,
|
|
|
|
// Usually widgets would lock mouse input when the user pressed the
|
|
|
|
// left mouse button till the user releases it.
|
|
|
|
// The PopUpWidget for example does not want this behavior, since the
|
|
|
|
// mouse down will open up a new dialog which silently eats the mouse
|
|
|
|
// up event for its own purposes.
|
|
|
|
WIDGET_IGNORE_DRAG = 1 << 10
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2002-07-08 11:55:55 +00:00
|
|
|
enum {
|
|
|
|
kStaticTextWidget = 'TEXT',
|
2002-11-21 15:20:52 +00:00
|
|
|
kEditTextWidget = 'EDIT',
|
2002-07-08 11:55:55 +00:00
|
|
|
kButtonWidget = 'BTTN',
|
|
|
|
kCheckboxWidget = 'CHKB',
|
2010-06-15 10:48:39 +00:00
|
|
|
kRadiobuttonWidget = 'RDBT',
|
2002-07-10 22:49:41 +00:00
|
|
|
kSliderWidget = 'SLDE',
|
2002-07-12 16:24:11 +00:00
|
|
|
kListWidget = 'LIST',
|
2003-11-02 17:41:01 +00:00
|
|
|
kScrollBarWidget = 'SCRB',
|
2003-11-03 01:00:26 +00:00
|
|
|
kPopUpWidget = 'POPU',
|
2005-05-08 22:38:29 +00:00
|
|
|
kTabWidget = 'TABW',
|
2006-05-27 05:46:04 +00:00
|
|
|
kGraphicsWidget = 'GFXW',
|
2016-06-21 08:36:21 +00:00
|
|
|
kContainerWidget = 'CTNR',
|
|
|
|
kScrollContainerWidget = 'SCTR'
|
2002-07-12 16:24:11 +00:00
|
|
|
};
|
|
|
|
|
2002-11-21 15:20:52 +00:00
|
|
|
enum {
|
|
|
|
kCaretBlinkTime = 300
|
|
|
|
};
|
|
|
|
|
2012-05-03 16:32:08 +00:00
|
|
|
enum {
|
|
|
|
kPressedButtonTime = 200
|
|
|
|
};
|
|
|
|
|
2014-05-02 15:09:30 +00:00
|
|
|
enum {
|
|
|
|
kPicButtonStateEnabled = 0,
|
|
|
|
kPicButtonHighlight = 1,
|
|
|
|
kPicButtonStateDisabled = 2,
|
|
|
|
kPicButtonStatePressed = 3,
|
|
|
|
|
|
|
|
kPicButtonStateMax = 3
|
|
|
|
};
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
/* Widget */
|
2003-11-02 14:50:53 +00:00
|
|
|
class Widget : public GuiObject {
|
2003-11-02 02:18:16 +00:00
|
|
|
friend class Dialog;
|
2002-07-05 16:56:53 +00:00
|
|
|
protected:
|
2002-07-13 22:41:29 +00:00
|
|
|
uint32 _type;
|
2003-11-02 14:50:53 +00:00
|
|
|
GuiObject *_boss;
|
2002-07-05 16:56:53 +00:00
|
|
|
Widget *_next;
|
2002-07-16 10:52:48 +00:00
|
|
|
bool _hasFocus;
|
2008-11-10 11:24:55 +00:00
|
|
|
ThemeEngine::WidgetStateInfo _state;
|
2020-06-13 16:42:25 +00:00
|
|
|
Common::U32String _tooltip;
|
2007-11-04 03:38:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint16 _flags;
|
2018-01-06 13:40:02 +00:00
|
|
|
bool _needsRedraw;
|
2002-07-13 22:41:29 +00:00
|
|
|
|
2003-11-02 18:57:20 +00:00
|
|
|
public:
|
|
|
|
static Widget *findWidgetInChain(Widget *start, int x, int y);
|
2006-04-19 01:05:28 +00:00
|
|
|
static Widget *findWidgetInChain(Widget *start, const char *name);
|
2017-04-06 20:50:16 +00:00
|
|
|
static bool containsWidgetInChain(Widget *start, Widget *search);
|
2003-11-02 18:57:20 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
Widget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip = Common::U32String());
|
2020-11-15 18:15:58 +00:00
|
|
|
Widget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String());
|
|
|
|
Widget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String());
|
2020-01-05 16:48:04 +00:00
|
|
|
~Widget() override;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2006-03-07 05:39:52 +00:00
|
|
|
void init();
|
2006-04-19 01:05:28 +00:00
|
|
|
|
|
|
|
void setNext(Widget *w) { _next = w; }
|
2021-12-07 13:29:53 +00:00
|
|
|
void setBoss(GuiObject *newBoss) { _boss = newBoss; }
|
2006-04-19 01:05:28 +00:00
|
|
|
Widget *next() { return _next; }
|
2006-03-07 05:39:52 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
int16 getAbsX() const override { return _x + _boss->getChildX(); }
|
|
|
|
int16 getAbsY() const override { return _y + _boss->getChildY(); }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-05-18 16:44:44 +00:00
|
|
|
virtual void setPos(int x, int y) { _x = x; _y = y; }
|
|
|
|
virtual void setSize(int w, int h) { _w = w; _h = h; }
|
2003-11-02 17:41:01 +00:00
|
|
|
|
2019-12-28 09:43:58 +00:00
|
|
|
/** Returns the minimal size the widget needs to have for its contents to fit */
|
|
|
|
virtual void getMinSize(int &minWidth, int &minHeight) { minHeight = -1; minWidth = -1; }
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
virtual void handleMouseDown(int x, int y, int button, int clickCount) {}
|
|
|
|
virtual void handleMouseUp(int x, int y, int button, int clickCount) {}
|
2002-07-10 22:49:41 +00:00
|
|
|
virtual void handleMouseEntered(int button) {}
|
|
|
|
virtual void handleMouseLeft(int button) {}
|
2002-07-08 13:52:50 +00:00
|
|
|
virtual void handleMouseMoved(int x, int y, int button) {}
|
2022-04-06 16:57:56 +00:00
|
|
|
void handleMouseWheel(int x, int y, int direction) override { assert(_boss); _boss->handleMouseWheel(x, y, direction); }
|
2007-06-30 12:26:59 +00:00
|
|
|
virtual bool handleKeyDown(Common::KeyState state) { return false; } // Return true if the event was handled
|
|
|
|
virtual bool handleKeyUp(Common::KeyState state) { return false; } // Return true if the event was handled
|
2002-07-13 22:41:29 +00:00
|
|
|
virtual void handleTickle() {}
|
2003-11-02 22:31:20 +00:00
|
|
|
|
2018-01-06 13:40:02 +00:00
|
|
|
/** Mark the widget and its children as dirty so they are redrawn on the next screen update */
|
|
|
|
virtual void markAsDirty();
|
|
|
|
|
|
|
|
/** Redraw the widget if it was marked as dirty, and recursively proceed with its children */
|
|
|
|
virtual void draw();
|
|
|
|
|
2002-07-16 22:34:16 +00:00
|
|
|
void receivedFocus() { _hasFocus = true; receivedFocusWidget(); }
|
2002-07-16 10:52:48 +00:00
|
|
|
void lostFocus() { _hasFocus = false; lostFocusWidget(); }
|
2005-04-06 15:21:32 +00:00
|
|
|
virtual bool wantsFocus() { return false; }
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2021-06-18 11:27:36 +00:00
|
|
|
uint32 getType() const { return _type; }
|
|
|
|
|
2007-11-04 03:38:30 +00:00
|
|
|
void setFlags(int flags);
|
|
|
|
void clearFlags(int flags);
|
2002-07-05 16:56:53 +00:00
|
|
|
int getFlags() const { return _flags; }
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2008-12-27 14:36:28 +00:00
|
|
|
void setEnabled(bool e);
|
2007-10-28 12:02:09 +00:00
|
|
|
bool isEnabled() const;
|
2008-12-27 14:36:28 +00:00
|
|
|
|
|
|
|
void setVisible(bool e);
|
2020-01-05 16:48:04 +00:00
|
|
|
bool isVisible() const override;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2020-05-07 20:16:13 +00:00
|
|
|
bool useRTL() const;
|
|
|
|
|
2020-06-10 16:07:51 +00:00
|
|
|
uint8 parseHotkey(const Common::U32String &label);
|
|
|
|
Common::U32String cleanupHotkey(const Common::U32String &label);
|
2010-06-15 10:47:31 +00:00
|
|
|
|
2012-06-20 01:31:50 +00:00
|
|
|
bool hasTooltip() const { return !_tooltip.empty(); }
|
2020-06-13 16:42:25 +00:00
|
|
|
const Common::U32String &getTooltip() const { return _tooltip; }
|
|
|
|
void setTooltip(const Common::U32String &tooltip) { _tooltip = tooltip; }
|
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
|
|
|
void setTooltip(const Common::String &tooltip) { _tooltip = Common::U32String(tooltip); }
|
2010-06-15 10:52:35 +00:00
|
|
|
|
2017-04-06 20:50:16 +00:00
|
|
|
virtual bool containsWidget(Widget *) const { return false; }
|
|
|
|
|
2020-06-17 18:29:45 +00:00
|
|
|
void read(const Common::U32String &str);
|
2019-07-12 10:52:18 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
protected:
|
2007-11-04 03:38:30 +00:00
|
|
|
void updateState(int oldFlags, int newFlags);
|
|
|
|
|
|
|
|
virtual void drawWidget() = 0;
|
2002-07-16 10:52:48 +00:00
|
|
|
|
2002-07-16 22:34:16 +00:00
|
|
|
virtual void receivedFocusWidget() {}
|
2002-07-16 10:52:48 +00:00
|
|
|
virtual void lostFocusWidget() {}
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-02 02:18:16 +00:00
|
|
|
virtual Widget *findWidget(int x, int y) { return this; }
|
2003-11-02 14:50:53 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
void releaseFocus() override { assert(_boss); _boss->releaseFocus(); }
|
2003-11-03 00:17:12 +00:00
|
|
|
|
|
|
|
// By default, delegate unhandled commands to the boss
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override { assert(_boss); _boss->handleCommand(sender, cmd, data); }
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* StaticTextWidget */
|
|
|
|
class StaticTextWidget : public Widget {
|
|
|
|
protected:
|
2020-06-10 16:07:51 +00:00
|
|
|
Common::U32String _label;
|
2008-11-12 14:30:16 +00:00
|
|
|
Graphics::TextAlign _align;
|
2016-03-30 09:09:32 +00:00
|
|
|
ThemeEngine::FontStyle _font;
|
2022-04-01 12:51:55 +00:00
|
|
|
ThemeEngine::FontColor _fontColor;
|
2021-09-30 16:17:49 +00:00
|
|
|
bool _useEllipsis;
|
2020-10-24 23:38:05 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, Graphics::TextAlign align, const Common::U32String &tooltip = Common::U32String(), ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold, Common::Language lang = Common::UNK_LANG, bool useEllipsis = true);
|
2021-09-30 16:17:49 +00:00
|
|
|
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &text, Graphics::TextAlign align, const Common::U32String &tooltip = Common::U32String(), ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold, Common::Language lang = Common::UNK_LANG, bool useEllipsis = true);
|
|
|
|
StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String(), ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold, Common::Language lang = Common::UNK_LANG, bool useEllipsis = true);
|
2002-07-27 00:05:46 +00:00
|
|
|
void setValue(int value);
|
2020-06-10 16:07:51 +00:00
|
|
|
void setLabel(const Common::U32String &label);
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleMouseEntered(int button) override { readLabel(); }
|
2020-06-10 16:07:51 +00:00
|
|
|
const Common::U32String &getLabel() const { return _label; }
|
2008-11-12 14:30:16 +00:00
|
|
|
void setAlign(Graphics::TextAlign align);
|
|
|
|
Graphics::TextAlign getAlign() const { return _align; }
|
2020-06-17 18:29:45 +00:00
|
|
|
void readLabel() { read(_label); }
|
2022-04-01 12:51:55 +00:00
|
|
|
void setFontColor(ThemeEngine::FontColor color);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2020-10-24 23:38:05 +00:00
|
|
|
void setFont(ThemeEngine::FontStyle font, Common::Language lang);
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ButtonWidget */
|
2002-07-12 16:24:11 +00:00
|
|
|
class ButtonWidget : public StaticTextWidget, public CommandSender {
|
|
|
|
friend class Dialog; // Needed for the hotkey handling
|
2002-07-05 16:56:53 +00:00
|
|
|
protected:
|
2002-10-19 01:22:41 +00:00
|
|
|
uint32 _cmd;
|
|
|
|
uint8 _hotkey;
|
2022-05-23 21:36:56 +00:00
|
|
|
uint8 _highresHotkey;
|
|
|
|
uint8 _lowresHotkey;
|
2022-05-15 10:16:29 +00:00
|
|
|
Common::U32String _lowresLabel;
|
2002-07-05 16:56:53 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
ButtonWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
2022-05-15 10:16:29 +00:00
|
|
|
ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
|
|
|
ButtonWidget(GuiObject *boss, const Common::String &name, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
2002-07-12 16:24:11 +00:00
|
|
|
|
2019-12-28 09:43:58 +00:00
|
|
|
void getMinSize(int &minWidth, int &minHeight) override;
|
|
|
|
|
2003-07-22 16:26:12 +00:00
|
|
|
void setCmd(uint32 cmd) { _cmd = cmd; }
|
|
|
|
uint32 getCmd() const { return _cmd; }
|
2002-07-06 12:57:51 +00:00
|
|
|
|
2020-06-10 16:07:51 +00:00
|
|
|
void setLabel(const Common::U32String &label);
|
2020-07-03 21:43:05 +00:00
|
|
|
void setLabel(const Common::String &label);
|
2022-05-15 10:16:29 +00:00
|
|
|
void setLowresLabel(const Common::U32String &label);
|
|
|
|
const Common::U32String &getLabel();
|
2011-08-06 09:12:34 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseDown(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseEntered(int button) override { readLabel(); if (_duringPress) { setFlags(WIDGET_PRESSED); } else { setFlags(WIDGET_HILITED); } markAsDirty(); }
|
|
|
|
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED | WIDGET_PRESSED); markAsDirty(); }
|
2002-10-12 00:26:24 +00:00
|
|
|
|
2012-05-03 16:32:08 +00:00
|
|
|
void setHighLighted(bool enable);
|
|
|
|
void setPressedState();
|
2016-04-13 12:02:33 +00:00
|
|
|
void setUnpressedState();
|
2002-10-12 00:26:24 +00:00
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2016-03-23 19:24:43 +00:00
|
|
|
bool _duringPress;
|
2019-11-13 20:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* DropdownButtonWidget */
|
|
|
|
class DropdownButtonWidget : public ButtonWidget {
|
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
DropdownButtonWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
2022-05-15 10:16:29 +00:00
|
|
|
DropdownButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
|
|
|
DropdownButtonWidget(GuiObject *boss, const Common::String &name, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
|
2019-11-13 20:09:21 +00:00
|
|
|
|
|
|
|
void handleMouseMoved(int x, int y, int button) override;
|
|
|
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
|
|
|
void reflowLayout() override;
|
2019-12-28 09:43:58 +00:00
|
|
|
void getMinSize(int &minWidth, int &minHeight) override;
|
|
|
|
|
2019-11-13 20:09:21 +00:00
|
|
|
|
2020-06-10 16:07:51 +00:00
|
|
|
void appendEntry(const Common::U32String &label, uint32 cmd);
|
2019-11-13 20:09:21 +00:00
|
|
|
void clearEntries();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
struct Entry {
|
2020-06-10 16:07:51 +00:00
|
|
|
Common::U32String label;
|
2019-11-13 20:09:21 +00:00
|
|
|
uint32 cmd;
|
|
|
|
};
|
|
|
|
typedef Common::Array<Entry> EntryList;
|
|
|
|
|
|
|
|
// Widget API
|
|
|
|
void drawWidget() override;
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
bool isInDropDown(int x, int y) const;
|
|
|
|
|
|
|
|
EntryList _entries;
|
|
|
|
|
|
|
|
uint32 _dropdownWidth;
|
|
|
|
bool _inDropdown;
|
|
|
|
bool _inButton;
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2011-01-03 12:23:50 +00:00
|
|
|
/* PicButtonWidget */
|
2011-10-24 17:34:51 +00:00
|
|
|
class PicButtonWidget : public ButtonWidget {
|
2011-01-03 12:23:50 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
2020-11-15 18:15:58 +00:00
|
|
|
PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
|
|
|
PicButtonWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
2020-01-05 16:48:04 +00:00
|
|
|
~PicButtonWidget() override;
|
2011-01-03 12:23:50 +00:00
|
|
|
|
2021-04-08 13:08:57 +00:00
|
|
|
void setGfx(const Graphics::ManagedSurface *gfx, int statenum = kPicButtonStateEnabled, bool scale = true);
|
2021-03-26 00:41:53 +00:00
|
|
|
void setGfx(const Graphics::Surface *gfx, int statenum = kPicButtonStateEnabled, bool scale = true);
|
2021-04-05 23:51:53 +00:00
|
|
|
void setGfxFromTheme(const char *name, int statenum = kPicButtonStateEnabled, bool scale = true);
|
2014-05-02 15:09:30 +00:00
|
|
|
void setGfx(int w, int h, int r, int g, int b, int statenum = kPicButtonStateEnabled);
|
2011-01-03 12:23:50 +00:00
|
|
|
|
2014-04-27 22:05:04 +00:00
|
|
|
void setButtonDisplay(bool enable) {_showButton = enable; }
|
2011-01-03 12:23:50 +00:00
|
|
|
|
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2021-07-08 10:33:43 +00:00
|
|
|
|
2021-04-05 23:51:53 +00:00
|
|
|
Graphics::ManagedSurface _gfx[kPicButtonStateMax + 1];
|
2014-04-27 22:05:04 +00:00
|
|
|
bool _showButton;
|
2011-01-03 12:23:50 +00:00
|
|
|
};
|
|
|
|
|
2002-10-19 01:22:41 +00:00
|
|
|
/* CheckboxWidget */
|
2003-11-03 23:33:40 +00:00
|
|
|
class CheckboxWidget : public ButtonWidget {
|
2002-10-19 01:22:41 +00:00
|
|
|
protected:
|
2003-11-03 23:33:40 +00:00
|
|
|
bool _state;
|
2022-05-24 21:45:45 +00:00
|
|
|
bool _overrideText;
|
2021-09-30 14:13:26 +00:00
|
|
|
int _spacing;
|
2002-10-19 01:22:41 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
2020-11-15 18:15:58 +00:00
|
|
|
CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
|
|
|
CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
2002-07-07 23:37:47 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseEntered(int button) override { readLabel(); setFlags(WIDGET_HILITED); markAsDirty(); }
|
|
|
|
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
|
2002-07-07 23:37:47 +00:00
|
|
|
|
2003-11-03 23:33:40 +00:00
|
|
|
void setState(bool state);
|
|
|
|
void toggleState() { setState(!_state); }
|
|
|
|
bool getState() const { return _state; }
|
|
|
|
|
2022-05-24 21:45:45 +00:00
|
|
|
void setOverride(bool enable);
|
2022-05-12 19:43:31 +00:00
|
|
|
|
2002-07-07 23:37:47 +00:00
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2002-07-07 23:37:47 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 10:48:39 +00:00
|
|
|
class RadiobuttonWidget;
|
|
|
|
|
|
|
|
class RadiobuttonGroup : public CommandSender {
|
|
|
|
public:
|
|
|
|
RadiobuttonGroup(GuiObject *boss, uint32 cmd = 0);
|
2020-01-05 16:48:04 +00:00
|
|
|
~RadiobuttonGroup() override {}
|
2010-06-15 10:48:39 +00:00
|
|
|
|
|
|
|
void addButton(RadiobuttonWidget *button) { _buttons.push_back(button); }
|
|
|
|
Common::Array<RadiobuttonWidget *> getButtonList() const { return _buttons; }
|
|
|
|
|
|
|
|
void setValue(int state);
|
|
|
|
int getValue() const { return _value; }
|
|
|
|
|
|
|
|
void setEnabled(bool ena);
|
|
|
|
|
|
|
|
void setCmd(uint32 cmd) { _cmd = cmd; }
|
|
|
|
uint32 getCmd() const { return _cmd; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Common::Array<RadiobuttonWidget *> _buttons;
|
|
|
|
int _value;
|
|
|
|
uint32 _cmd;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* RadiobuttonWidget */
|
|
|
|
class RadiobuttonWidget : public ButtonWidget {
|
|
|
|
protected:
|
|
|
|
bool _state;
|
2021-09-30 14:13:26 +00:00
|
|
|
int _spacing;
|
2010-06-15 10:48:39 +00:00
|
|
|
int _value;
|
2010-07-21 18:17:51 +00:00
|
|
|
|
2010-06-15 10:48:39 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, RadiobuttonGroup *group, int value, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint8 hotkey = 0);
|
2020-11-15 18:15:58 +00:00
|
|
|
RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, RadiobuttonGroup *group, int value, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint8 hotkey = 0);
|
|
|
|
RadiobuttonWidget(GuiObject *boss, const Common::String &name, RadiobuttonGroup *group, int value, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint8 hotkey = 0);
|
2010-06-15 10:48:39 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseEntered(int button) override { readLabel(); setFlags(WIDGET_HILITED); markAsDirty(); }
|
|
|
|
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
|
2010-06-15 10:48:39 +00:00
|
|
|
|
|
|
|
void setState(bool state, bool setGroup = true);
|
|
|
|
void toggleState() { setState(!_state); }
|
|
|
|
bool getState() const { return _state; }
|
|
|
|
int getValue() const { return _value; }
|
|
|
|
|
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2010-06-15 10:48:39 +00:00
|
|
|
|
|
|
|
RadiobuttonGroup *_group;
|
|
|
|
};
|
|
|
|
|
2002-07-08 13:52:50 +00:00
|
|
|
/* SliderWidget */
|
2005-05-18 10:24:02 +00:00
|
|
|
class SliderWidget : public Widget, public CommandSender {
|
2002-07-08 13:52:50 +00:00
|
|
|
protected:
|
2005-05-18 10:24:02 +00:00
|
|
|
uint32 _cmd;
|
2002-07-26 23:29:43 +00:00
|
|
|
int _value, _oldValue;
|
2002-07-26 15:34:04 +00:00
|
|
|
int _valueMin, _valueMax;
|
2002-07-13 18:32:09 +00:00
|
|
|
bool _isDragging;
|
2003-11-03 01:00:26 +00:00
|
|
|
uint _labelWidth;
|
2002-07-08 13:52:50 +00:00
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
SliderWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
|
2020-11-15 18:15:58 +00:00
|
|
|
SliderWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
|
|
|
|
SliderWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
|
2005-05-18 10:24:02 +00:00
|
|
|
|
|
|
|
void setCmd(uint32 cmd) { _cmd = cmd; }
|
|
|
|
uint32 getCmd() const { return _cmd; }
|
|
|
|
|
2002-07-28 14:59:27 +00:00
|
|
|
void setValue(int value) { _value = value; }
|
|
|
|
int getValue() const { return _value; }
|
2002-07-08 22:11:47 +00:00
|
|
|
|
2002-07-26 15:34:04 +00:00
|
|
|
void setMinValue(int value) { _valueMin = value; }
|
2002-07-26 00:41:07 +00:00
|
|
|
int getMinValue() const { return _valueMin; }
|
2002-07-26 15:34:04 +00:00
|
|
|
void setMaxValue(int value) { _valueMax = value; }
|
2002-07-26 00:41:07 +00:00
|
|
|
int getMaxValue() const { return _valueMax; }
|
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
void handleMouseMoved(int x, int y, int button) override;
|
|
|
|
void handleMouseDown(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
|
|
|
void handleMouseEntered(int button) override { setFlags(WIDGET_HILITED); markAsDirty(); }
|
|
|
|
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
|
|
|
|
void handleMouseWheel(int x, int y, int direction) override;
|
2002-07-08 13:52:50 +00:00
|
|
|
|
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-07-26 23:29:43 +00:00
|
|
|
int valueToPos(int value);
|
|
|
|
int posToValue(int pos);
|
2008-12-24 01:11:58 +00:00
|
|
|
int valueToBarWidth(int value);
|
2002-07-08 13:52:50 +00:00
|
|
|
};
|
|
|
|
|
2005-05-08 22:38:29 +00:00
|
|
|
/* GraphicsWidget */
|
|
|
|
class GraphicsWidget : public Widget {
|
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip = Common::U32String());
|
2020-11-15 18:15:58 +00:00
|
|
|
GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String());
|
|
|
|
GraphicsWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String());
|
2020-01-05 16:48:04 +00:00
|
|
|
~GraphicsWidget() override;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2021-04-17 10:51:44 +00:00
|
|
|
void setGfx(const Graphics::ManagedSurface *gfx, bool scale = false);
|
|
|
|
void setGfx(const Graphics::Surface *gfx, bool scale = false);
|
2006-05-29 14:38:56 +00:00
|
|
|
void setGfx(int w, int h, int r, int g, int b);
|
2021-04-04 21:57:30 +00:00
|
|
|
void setGfxFromTheme(const char *name);
|
2006-03-14 02:19:38 +00:00
|
|
|
|
2005-05-08 22:38:29 +00:00
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2021-04-05 17:17:17 +00:00
|
|
|
Graphics::ManagedSurface _gfx;
|
2005-05-08 22:38:29 +00:00
|
|
|
};
|
|
|
|
|
2006-05-27 05:46:04 +00:00
|
|
|
/* ContainerWidget */
|
|
|
|
class ContainerWidget : public Widget {
|
|
|
|
public:
|
2023-03-23 21:04:50 +00:00
|
|
|
ContainerWidget(GuiObject *boss, int x, int y, int w, int h, bool scale = false);
|
2006-06-03 13:33:39 +00:00
|
|
|
ContainerWidget(GuiObject *boss, const Common::String &name);
|
2020-01-05 16:48:04 +00:00
|
|
|
~ContainerWidget() override;
|
2006-05-27 05:46:04 +00:00
|
|
|
|
2020-01-05 16:48:04 +00:00
|
|
|
bool containsWidget(Widget *) const override;
|
|
|
|
Widget *findWidget(int x, int y) override;
|
|
|
|
void removeWidget(Widget *widget) override;
|
2019-12-28 09:43:58 +00:00
|
|
|
|
|
|
|
void setBackgroundType(ThemeEngine::WidgetBackground backgroundType);
|
2006-05-27 05:46:04 +00:00
|
|
|
protected:
|
2020-01-05 16:48:04 +00:00
|
|
|
void drawWidget() override;
|
2019-12-28 09:43:58 +00:00
|
|
|
|
|
|
|
ThemeEngine::WidgetBackground _backgroundType;
|
2006-05-27 05:46:04 +00:00
|
|
|
};
|
|
|
|
|
2020-03-22 14:19:56 +00:00
|
|
|
/* OptionsContainerWidget */
|
|
|
|
class OptionsContainerWidget : public Widget {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @param widgetsBoss parent widget for the container widget
|
|
|
|
* @param name name of the container widget in the layout system
|
|
|
|
* @param dialogLayout name of the layout used by the contained widgets, empty string for manually layed out widgets
|
|
|
|
* @param scrollable whether the container is made scrollable through a ScrollContainerWidget
|
|
|
|
* @param domain the configuration manager domain this widget is meant to edit
|
|
|
|
*/
|
|
|
|
OptionsContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogLayout,
|
|
|
|
bool scrollable, const Common::String &domain);
|
|
|
|
~OptionsContainerWidget() override;
|
|
|
|
|
|
|
|
/** Implementing classes should (re)initialize their widgets with state from the configuration domain */
|
|
|
|
virtual void load() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementing classes should save their widget's state to the configuration domain
|
|
|
|
*
|
|
|
|
* @return true if changes were made to the configuration since the last call to load()
|
|
|
|
*/
|
|
|
|
virtual bool save() = 0;
|
|
|
|
|
2021-01-17 10:03:51 +00:00
|
|
|
/** Implementing classes should return if there are relevant keys set in the configuration domain
|
|
|
|
*
|
|
|
|
* @return true if there are relevant keys set in the configuration domain
|
|
|
|
*/
|
|
|
|
virtual bool hasKeys() { return true; }
|
|
|
|
|
|
|
|
/** Implementing classes should enable or disable all active widgets */
|
|
|
|
virtual void setEnabled(bool e) {}
|
|
|
|
|
2020-03-22 14:19:56 +00:00
|
|
|
void setParentDialog(Dialog *parentDialog) { _parentDialog = parentDialog; }
|
2020-04-11 06:02:30 +00:00
|
|
|
void setDomain(const Common::String &domain) { _domain = domain; }
|
2020-03-22 14:19:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
enum {
|
|
|
|
/** The command that gets sent when the scroll container needs to reflow its contents */
|
|
|
|
kReflowCmd = 'REFL'
|
|
|
|
};
|
|
|
|
|
|
|
|
// Widget API
|
|
|
|
void reflowLayout() override;
|
|
|
|
void drawWidget() override {}
|
|
|
|
bool containsWidget(Widget *widget) const override;
|
|
|
|
Widget *findWidget(int x, int y) override;
|
|
|
|
void removeWidget(Widget *widget) override;
|
|
|
|
|
|
|
|
/** The pareent object to use when creating child widgets */
|
|
|
|
GuiObject *widgetsBoss();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Child classes can override this method to define the layout used by the contained widgets in the layout system
|
|
|
|
*
|
|
|
|
* This is called only when the layout was not found in the theme definition files.
|
|
|
|
*/
|
|
|
|
virtual void defineLayout(ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {}
|
|
|
|
|
2020-04-11 06:02:30 +00:00
|
|
|
Common::String _domain;
|
2020-03-22 14:19:56 +00:00
|
|
|
const Common::String _dialogLayout;
|
|
|
|
|
|
|
|
Dialog *_parentDialog;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ScrollContainerWidget *_scrollContainer;
|
|
|
|
};
|
|
|
|
|
2023-03-23 21:04:50 +00:00
|
|
|
ButtonWidget *addClearButton(GuiObject *boss, const Common::String &name, uint32 cmd, int x=0, int y=0, int w=0, int h=0, bool scale = false);
|
2022-02-22 17:00:19 +00:00
|
|
|
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h, bool filtering = false);
|
2011-12-13 02:33:28 +00:00
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|
2002-07-08 13:52:50 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
#endif
|