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',
87 kPressedButtonTime = 200
91 kPicButtonStateEnabled = 0,
92 kPicButtonHighlight = 1,
93 kPicButtonStateDisabled = 2,
94 kPicButtonStatePressed = 3,
96 kPicButtonStateMax = 3
115 static Widget *findWidgetInChain(
Widget *start,
int x,
int y);
116 static Widget *findWidgetInChain(
Widget *start,
const char *name);
117 static bool containsWidgetInChain(
Widget *start,
Widget *search);
127 void setNext(
Widget *w) { _next = w; }
128 void setBoss(
GuiObject *newBoss) { _boss = newBoss; }
129 Widget *next() {
return _next; }
131 int16 getAbsX()
const override {
return _x + _boss->getChildX(); }
132 int16 getAbsY()
const override {
return _y + _boss->getChildY(); }
134 virtual void setPos(
int x,
int y) { _x = x; _y = y; }
135 virtual void setSize(
int w,
int h) { _w = w; _h = h; }
138 virtual void getMinSize(
int &minWidth,
int &minHeight) { minHeight = -1; minWidth = -1; }
140 virtual void handleMouseDown(
int x,
int y,
int button,
int clickCount) {}
141 virtual void handleMouseUp(
int x,
int y,
int button,
int clickCount) {}
142 virtual void handleMouseEntered(
int button) {}
143 virtual void handleMouseLeft(
int button) {}
144 virtual void handleMouseMoved(
int x,
int y,
int button) {}
145 void handleMouseWheel(
int x,
int y,
int direction)
override { assert(_boss); _boss->handleMouseWheel(x, y, direction); }
149 virtual void handleTickle() {}
157 void receivedFocus() { _hasFocus =
true; receivedFocusWidget(); }
158 void lostFocus() { _hasFocus =
false; lostFocusWidget(); }
159 virtual bool wantsFocus() {
return false; }
161 uint32 getType()
const {
return _type; }
163 void setFlags(
int flags);
164 void clearFlags(
int flags);
165 int getFlags()
const {
return _flags; }
167 void setEnabled(
bool e);
168 bool isEnabled()
const;
170 void setVisible(
bool e);
171 bool isVisible()
const override;
178 bool hasTooltip()
const {
return !_tooltip.empty(); }
183 virtual bool containsWidget(
Widget *)
const {
return false; }
188 void updateState(
int oldFlags,
int newFlags);
190 virtual void drawWidget() = 0;
192 virtual void receivedFocusWidget() {}
193 virtual void lostFocusWidget() {}
195 virtual Widget *findWidget(
int x,
int y) {
return this; }
197 void releaseFocus()
override { assert(_boss); _boss->releaseFocus(); }
200 void handleCommand(
CommandSender *sender, uint32 cmd, uint32 data)
override { assert(_boss); _boss->handleCommand(sender, cmd, data); }
213 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);
214 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);
216 void setValue(
int value);
218 void handleMouseEntered(
int button)
override { readLabel(); }
222 void readLabel() { read(_label); }
226 void drawWidget()
override;
236 uint8 _highresHotkey;
240 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());
244 void getMinSize(
int &minWidth,
int &minHeight)
override;
246 void setCmd(uint32 cmd) { _cmd = cmd; }
247 uint32 getCmd()
const {
return _cmd; }
254 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
255 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
256 void handleMouseEntered(
int button)
override { readLabel();
if (_duringPress) { setFlags(WIDGET_PRESSED); }
else { setFlags(WIDGET_HILITED); }
markAsDirty(); }
257 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED | WIDGET_PRESSED);
markAsDirty(); }
259 void setHighLighted(
bool enable);
260 void setPressedState();
261 void setUnpressedState();
263 void drawWidget()
override;
270 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());
274 void handleMouseMoved(
int x,
int y,
int button)
override;
275 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
276 void reflowLayout()
override;
277 void getMinSize(
int &minWidth,
int &minHeight)
override;
291 void drawWidget()
override;
294 bool isInDropDown(
int x,
int y)
const;
298 uint32 _dropdownWidth;
312 void setGfx(
const Graphics::Surface *gfx,
int statenum = kPicButtonStateEnabled,
bool scale =
true);
313 void setGfxFromTheme(
const char *name,
int statenum = kPicButtonStateEnabled,
bool scale =
true);
314 void setGfx(
int w,
int h,
int r,
int g,
int b,
int statenum = kPicButtonStateEnabled);
316 void setButtonDisplay(
bool enable) {_showButton = enable; }
319 void drawWidget()
override;
336 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
337 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
338 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
340 void setState(
bool state);
341 void toggleState() { setState(!_state); }
342 bool getState()
const {
return _state; }
344 void setOverride(
bool enable);
347 void drawWidget()
override;
360 void setValue(
int state);
361 int getValue()
const {
return _value; }
363 void setEnabled(
bool ena);
365 void setCmd(uint32 cmd) { _cmd = cmd; }
366 uint32 getCmd()
const {
return _cmd; }
382 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);
386 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
387 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
388 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
390 void setState(
bool state,
bool setGroup =
true);
391 void toggleState() { setState(!_state); }
392 bool getState()
const {
return _state; }
393 int getValue()
const {
return _value; }
396 void drawWidget()
override;
405 int _value, _oldValue;
406 int _valueMin, _valueMax;
414 void setCmd(uint32 cmd) { _cmd = cmd; }
415 uint32 getCmd()
const {
return _cmd; }
417 void setValue(
int value) { _value = value; }
418 int getValue()
const {
return _value; }
420 void setMinValue(
int value) { _valueMin = value; }
421 int getMinValue()
const {
return _valueMin; }
422 void setMaxValue(
int value) { _valueMax = value; }
423 int getMaxValue()
const {
return _valueMax; }
425 void handleMouseMoved(
int x,
int y,
int button)
override;
426 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
427 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
428 void handleMouseEntered(
int button)
override { setFlags(WIDGET_HILITED);
markAsDirty(); }
429 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
430 void handleMouseWheel(
int x,
int y,
int direction)
override;
433 void drawWidget()
override;
435 int valueToPos(
int value);
436 int posToValue(
int pos);
437 int valueToBarWidth(
int value);
450 void setGfx(
int w,
int h,
int r,
int g,
int b);
451 void setGfxFromTheme(
const char *name);
454 void drawWidget()
override;
466 bool useEllipsis =
true) :
469 align, tooltip, font, Common::UNK_LANG, useEllipsis),
471 _placeholder(placeholder) { }
477 bool useEllipsis =
true) :
480 align, tooltip, font, Common::UNK_LANG, useEllipsis),
482 _placeholder(placeholder) {}
488 bool useEllipsis =
true) :
491 tooltip, font, Common::UNK_LANG, useEllipsis),
493 _placeholder(placeholder) {}
497 StaticTextWidget::setLabel(_placeholder);
503 void setEmptyPlaceHolder(
const Common::U32String &placeholder) { _placeholder = placeholder; }
516 bool containsWidget(
Widget *)
const override;
517 Widget *findWidget(
int x,
int y)
override;
518 void removeWidget(
Widget *widget)
override;
522 void drawWidget()
override;
542 virtual void load() = 0;
549 virtual bool save() = 0;
560 void setParentDialog(
Dialog *parentDialog) { _parentDialog = parentDialog; }
561 void setDomain(
const Common::String &domain) { _domain = domain; }
563 uint16 getWidth()
const override;
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;
Definition: managed_surface.h:51
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
static const char kNativeSeparator
Definition: path.h:198
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
bool empty() const
Definition: path.h:351
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