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,
bool scale =
true);
317 void setGfx(
int w,
int h,
int r,
int g,
int b,
int statenum = kPicButtonStateEnabled);
319 void setButtonDisplay(
bool enable) {_showButton = enable; }
322 void drawWidget()
override;
325 Graphics::AlphaType _alphaType[kPicButtonStateMax + 1];
340 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
341 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
342 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
344 void setState(
bool state);
345 void toggleState() { setState(!_state); }
346 bool getState()
const {
return _state; }
348 void setOverride(
bool enable);
351 void drawWidget()
override;
364 void setValue(
int state);
365 int getValue()
const {
return _value; }
367 void setEnabled(
bool ena);
369 void setCmd(uint32 cmd) { _cmd = cmd; }
370 uint32 getCmd()
const {
return _cmd; }
386 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);
390 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
391 void handleMouseEntered(
int button)
override { readLabel(); setFlags(WIDGET_HILITED);
markAsDirty(); }
392 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
394 void setState(
bool state,
bool setGroup =
true);
395 void toggleState() { setState(!_state); }
396 bool getState()
const {
return _state; }
397 int getValue()
const {
return _value; }
400 void drawWidget()
override;
409 int _value, _oldValue;
410 int _valueMin, _valueMax;
418 void setCmd(uint32 cmd) { _cmd = cmd; }
419 uint32 getCmd()
const {
return _cmd; }
421 void setValue(
int value) { _value = value; }
422 int getValue()
const {
return _value; }
424 void setMinValue(
int value) { _valueMin = value; }
425 int getMinValue()
const {
return _valueMin; }
426 void setMaxValue(
int value) { _valueMax = value; }
427 int getMaxValue()
const {
return _valueMax; }
429 void handleMouseMoved(
int x,
int y,
int button)
override;
430 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
431 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
432 void handleMouseEntered(
int button)
override { setFlags(WIDGET_HILITED);
markAsDirty(); }
433 void handleMouseLeft(
int button)
override { clearFlags(WIDGET_HILITED);
markAsDirty(); }
434 void handleMouseWheel(
int x,
int y,
int direction)
override;
437 void drawWidget()
override;
439 int valueToPos(
int value);
440 int posToValue(
int pos);
441 int valueToBarWidth(
int value);
454 void setGfx(
int w,
int h,
int r,
int g,
int b);
455 void setGfxFromTheme(
const char *name);
458 void drawWidget()
override;
461 Graphics::AlphaType _alphaType;
471 bool useEllipsis =
true) :
474 align, tooltip, font, Common::UNK_LANG, useEllipsis),
476 _placeholder(placeholder) { }
482 bool useEllipsis =
true) :
485 align, tooltip, font, Common::UNK_LANG, useEllipsis),
487 _placeholder(placeholder) {}
493 bool useEllipsis =
true) :
496 tooltip, font, Common::UNK_LANG, useEllipsis),
498 _placeholder(placeholder) {}
502 StaticTextWidget::setLabel(_placeholder);
508 void setEmptyPlaceHolder(
const Common::U32String &placeholder) { _placeholder = placeholder; }
521 bool containsWidget(
Widget *)
const override;
522 Widget *findWidget(
int x,
int y)
override;
523 void removeWidget(
Widget *widget)
override;
527 void drawWidget()
override;
547 virtual void load() = 0;
554 virtual bool save() = 0;
565 void setParentDialog(
Dialog *parentDialog) { _parentDialog = parentDialog; }
566 void setDomain(
const Common::String &domain) { _domain = domain; }
570 void reflowLayout()
override;
571 void drawWidget()
override {}
572 bool containsWidget(
Widget *widget)
const override;
573 Widget *findWidget(
int x,
int y)
override;
574 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:195
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
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