25 #include "common/scummsys.h" 26 #include "common/array.h" 27 #include "common/str.h" 28 #include "common/keyboard.h" 29 #include "graphics/font.h" 30 #include "graphics/managed_surface.h" 31 #include "gui/object.h" 32 #include "gui/ThemeEngine.h" 33 #include "common/text-to-speech.h" 34 #include "common/system.h" 35 #include "common/config-manager.h" 36 #include "common/events.h" 40 class ScrollContainerWidget;
43 WIDGET_ENABLED = 1 << 0,
44 WIDGET_INVISIBLE = 1 << 1,
45 WIDGET_HILITED = 1 << 2,
46 WIDGET_BORDER = 1 << 3,
47 WIDGET_PRESSED = 1 << 4,
49 WIDGET_CLEARBG = 1 << 5,
50 WIDGET_WANT_TICKLE = 1 << 7,
51 WIDGET_TRACK_MOUSE = 1 << 8,
55 WIDGET_RETAIN_FOCUS = 1 << 9,
61 WIDGET_IGNORE_DRAG = 1 << 10,
62 WIDGET_DYN_TOOLTIP = 1 << 11,
66 kStaticTextWidget =
'TEXT',
67 kEditTextWidget =
'EDIT',
68 kButtonWidget =
'BTTN',
69 kCheckboxWidget =
'CHKB',
70 kRadiobuttonWidget =
'RDBT',
71 kSliderWidget =
'SLDE',
73 kScrollBarWidget =
'SCRB',
74 kPopUpWidget =
'POPU',
76 kGraphicsWidget =
'GFXW',
77 kContainerWidget =
'CTNR',
78 kScrollContainerWidget =
'SCTR',
79 kRichTextWidget =
'RTXT',
88 kPressedButtonTime = 200
92 kPicButtonStateEnabled = 0,
93 kPicButtonHighlight = 1,
94 kPicButtonStateDisabled = 2,
95 kPicButtonStatePressed = 3,
97 kPicButtonStateMax = 3
116 static Widget *findWidgetInChain(
Widget *start,
int x,
int y);
117 static Widget *findWidgetInChain(
Widget *start,
const char *name);
118 static Widget *findWidgetInChain(
Widget *w, uint32 type);
119 static bool containsWidgetInChain(
Widget *start,
Widget *search);
129 void setNext(
Widget *w) { _next = w; }
130 void setBoss(
GuiObject *newBoss) { _boss = newBoss; }
131 Widget *next() {
return _next; }
133 int16 getAbsX()
const override {
return _x + _boss->getChildX(); }
134 int16 getAbsY()
const override {
return _y + _boss->getChildY(); }
136 virtual void setPos(
int x,
int y) { _x = x; _y = y; }
137 virtual void setSize(
int w,
int h) { _w = w; _h = h; }
140 virtual void getMinSize(
int &minWidth,
int &minHeight) { minHeight = -1; minWidth = -1; }
142 virtual void handleMouseDown(
int x,
int y,
int button,
int clickCount) {}
143 virtual void handleMouseUp(
int x,
int y,
int button,
int clickCount) {}
144 virtual void handleMouseEntered(
int button) {}
145 virtual void handleMouseLeft(
int button) {}
146 virtual void handleMouseMoved(
int x,
int y,
int button) {}
147 void handleMouseWheel(
int x,
int y,
int direction)
override { assert(_boss); _boss->handleMouseWheel(x, y, direction); }
151 virtual void handleTickle() {}
159 void receivedFocus() { _hasFocus =
true; receivedFocusWidget(); }
160 void lostFocus() { _hasFocus =
false; lostFocusWidget(); }
161 virtual bool wantsFocus() {
return false; }
163 uint32 getType()
const {
return _type; }
165 void setFlags(
int flags);
166 void clearFlags(
int flags);
167 int getFlags()
const {
return _flags; }
169 void setEnabled(
bool e);
170 bool isEnabled()
const;
172 void setVisible(
bool e);
173 bool isVisible()
const override;
180 bool hasTooltip()
const {
return !_tooltip.empty(); }
185 virtual bool containsWidget(
Widget *)
const {
return false; }
190 void updateState(
int oldFlags,
int newFlags);
192 virtual void drawWidget() = 0;
194 virtual void receivedFocusWidget() {}
195 virtual void lostFocusWidget() {}
197 virtual Widget *findWidget(
int x,
int y) {
return this; }
199 void releaseFocus()
override { assert(_boss); _boss->releaseFocus(); }
202 void handleCommand(
CommandSender *sender, uint32 cmd, uint32 data)
override { assert(_boss); _boss->handleCommand(sender, cmd, data); }
215 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);
216 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);
218 void setValue(
int value);
220 void handleMouseEntered(
int button)
override { readLabel(); }
224 void readLabel() { read(_label); }
228 void reflowLayout()
override;
229 void drawWidget()
override;
239 uint8 _highresHotkey;
243 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());
247 void getMinSize(
int &minWidth,
int &minHeight)
override;
249 void setCmd(uint32 cmd) { _cmd = cmd; }
250 uint32 getCmd()
const {
return _cmd; }
257 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
258 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
259 void handleMouseEntered(
int button)
override { readLabel();
if (_duringPress) { setFlags(WIDGET_PRESSED); }
else { setFlags(WIDGET_HILITED); }
markAsDirty(); }
260 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED | WIDGET_PRESSED);
markAsDirty(); }
262 void setHighLighted(
bool enable);
263 void setPressedState();
264 void setUnpressedState();
266 void drawWidget()
override;
273 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());
277 void handleMouseMoved(
int x,
int y,
int button)
override;
278 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
279 void reflowLayout()
override;
280 void getMinSize(
int &minWidth,
int &minHeight)
override;
294 void drawWidget()
override;
297 bool isInDropDown(
int x,
int y)
const;
301 uint32 _dropdownWidth;
315 void setGfx(
const Graphics::Surface *gfx,
int statenum = kPicButtonStateEnabled,
bool scale =
true);
316 void setGfxFromTheme(
const char *name,
int statenum = kPicButtonStateEnabled);
317 void setGfx(
int w,
int h,
int r,
int g,
int b,
int statenum = kPicButtonStateEnabled);
318 void clearGfx(
int statenum = kPicButtonStateEnabled) { _gfx[statenum].reset(); }
320 void setButtonDisplay(
bool enable) {_showButton = enable; }
323 void drawWidget()
override;
326 Graphics::AlphaType _alphaType[kPicButtonStateMax + 1];
341 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
342 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
343 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
345 void setState(
bool state);
346 void toggleState() { setState(!_state); }
347 bool getState()
const {
return _state; }
349 void setOverride(
bool enable);
352 void drawWidget()
override;
365 void setValue(
int state);
366 int getValue()
const {
return _value; }
368 void setEnabled(
bool ena);
370 void setCmd(uint32 cmd) { _cmd = cmd; }
371 uint32 getCmd()
const {
return _cmd; }
387 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);
391 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
392 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
393 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
395 void setState(
bool state,
bool setGroup =
true);
396 void toggleState() { setState(!_state); }
397 bool getState()
const {
return _state; }
398 int getValue()
const {
return _value; }
401 void drawWidget()
override;
410 int _value, _oldValue;
411 int _valueMin, _valueMax;
419 void setCmd(uint32 cmd) { _cmd = cmd; }
420 uint32 getCmd()
const {
return _cmd; }
422 void setValue(
int value) { _value = value; }
423 int getValue()
const {
return _value; }
425 void setMinValue(
int value) { _valueMin = value; }
426 int getMinValue()
const {
return _valueMin; }
427 void setMaxValue(
int value) { _valueMax = value; }
428 int getMaxValue()
const {
return _valueMax; }
430 void handleMouseMoved(
int x,
int y,
int button)
override;
431 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
432 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
433 void handleMouseEntered(
int button)
override { setFlags(WIDGET_HILITED);
markAsDirty(); }
434 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
435 void handleMouseWheel(
int x,
int y,
int direction)
override;
438 void drawWidget()
override;
440 int valueToPos(
int value);
441 int posToValue(
int pos);
442 int valueToBarWidth(
int value);
455 void setGfx(
int w,
int h,
int r,
int g,
int b);
456 void setGfxFromTheme(
const char *name);
457 void clearGfx() { _gfx.reset(); }
460 void drawWidget()
override;
463 Graphics::AlphaType _alphaType;
473 bool useEllipsis =
true) :
476 align, tooltip, font, Common::UNK_LANG, useEllipsis),
478 _placeholder(placeholder) { }
484 bool useEllipsis =
true) :
487 align, tooltip, font, Common::UNK_LANG, useEllipsis),
489 _placeholder(placeholder) {}
495 bool useEllipsis =
true) :
498 tooltip, font, Common::UNK_LANG, useEllipsis),
500 _placeholder(placeholder) {}
504 StaticTextWidget::setLabel(_placeholder);
510 void setEmptyPlaceHolder(
const Common::U32String &placeholder) { _placeholder = placeholder; }
523 bool containsWidget(
Widget *)
const override;
524 Widget *findWidget(
int x,
int y)
override;
525 void removeWidget(
Widget *widget)
override;
529 void drawWidget()
override;
549 virtual void load() = 0;
556 virtual bool save() = 0;
567 void setParentDialog(
Dialog *parentDialog) { _parentDialog = parentDialog; }
568 void setDomain(
const Common::String &domain) { _domain = domain; }
572 void reflowLayout()
override;
573 void drawWidget()
override {}
574 bool containsWidget(
Widget *widget)
const override;
575 Widget *findWidget(
int x,
int y)
override;
576 void removeWidget(
Widget *widget)
override;
FontColor
Font color selector.
Definition: ThemeEngine.h:288
TextAlign
Definition: font.h:48
WidgetBackground
Widget background type.
Definition: ThemeEngine.h:226
Definition: ThemeEval.h:37
Definition: printman.h:30
static const char kNativeSeparator
Definition: path.h:195
bool empty() const
Definition: path.h:353
FontStyle
Font style selector.
Definition: ThemeEngine.h:274
String toString(char separator='/') const
A bold font. This is also the default font.
Definition: ThemeEngine.h:275
State
State of the widget to be drawn.
Definition: ThemeEngine.h:249
Definition: keyboard.h:294
Language
Definition: language.h:45