diff options
author | Johannes Schickel | 2006-04-19 01:05:28 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-04-19 01:05:28 +0000 |
commit | 30787714d30e9202890922ec10833e695bc8a3bf (patch) | |
tree | b2a699d793bbafd7a5fade0f366b3ec3636f4ffe | |
parent | ec7e734adb2133a653f500636b101fc09ab6e4ae (diff) | |
download | scummvm-rg350-30787714d30e9202890922ec10833e695bc8a3bf.tar.gz scummvm-rg350-30787714d30e9202890922ec10833e695bc8a3bf.tar.bz2 scummvm-rg350-30787714d30e9202890922ec10833e695bc8a3bf.zip |
Started to prepare the gui for runtime resolution switches.
(some little things could be missing yet though)
svn-id: r22017
-rw-r--r-- | gui/ListWidget.cpp | 39 | ||||
-rw-r--r-- | gui/ListWidget.h | 2 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 14 | ||||
-rw-r--r-- | gui/PopUpWidget.h | 4 | ||||
-rw-r--r-- | gui/TabWidget.cpp | 11 | ||||
-rw-r--r-- | gui/TabWidget.h | 2 | ||||
-rw-r--r-- | gui/ThemeClassic.cpp | 1 | ||||
-rw-r--r-- | gui/ThemeNew.cpp | 1 | ||||
-rw-r--r-- | gui/about.cpp | 37 | ||||
-rw-r--r-- | gui/about.h | 2 | ||||
-rw-r--r-- | gui/dialog.cpp | 25 | ||||
-rw-r--r-- | gui/dialog.h | 5 | ||||
-rw-r--r-- | gui/launcher.cpp | 21 | ||||
-rw-r--r-- | gui/newgui.cpp | 46 | ||||
-rw-r--r-- | gui/object.h | 2 | ||||
-rw-r--r-- | gui/options.cpp | 13 | ||||
-rw-r--r-- | gui/options.h | 2 | ||||
-rw-r--r-- | gui/themes/modern.ini | 34 | ||||
-rw-r--r-- | gui/widget.cpp | 22 | ||||
-rw-r--r-- | gui/widget.h | 9 |
20 files changed, 255 insertions, 37 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 240223f760..07a3cd25fd 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -31,7 +31,7 @@ namespace GUI { ListWidget::ListWidget(GuiObject *boss, String name) : EditableWidget(boss, name), CommandSender(boss) { - int w = g_gui.evaluator()->getVar(name + ".w"); + int w = g_gui.evaluator()->getVar(_name + ".w"); WidgetSize ws = g_gui.getWidgetSize(); @@ -47,6 +47,9 @@ ListWidget::ListWidget(GuiObject *boss, String name) } else { _w = w - kNormalScrollBarWidth; } + + _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h); + _scrollBar->setTarget(this); _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; setHints(THEME_HINT_SAVE_BACKGROUND); @@ -56,8 +59,6 @@ ListWidget::ListWidget(GuiObject *boss, String name) _entriesPerPage = (_h - _topPadding - _bottomPadding) / kLineHeight; _currentPos = 0; _selectedItem = -1; - _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h); - _scrollBar->setTarget(this); _currentKeyDown = 0; _quickSelectTime = 0; @@ -436,4 +437,36 @@ void ListWidget::abortEditMode() { g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); } +void ListWidget::handleScreenChanged() { + Widget::handleScreenChanged(); + + int w = g_gui.evaluator()->getVar(_name + ".w"); + + WidgetSize ws = g_gui.getWidgetSize(); + + _leftPadding = g_gui.evaluator()->getVar("ListWidget.leftPadding", 0); + _rightPadding = g_gui.evaluator()->getVar("ListWidget.rightPadding", 0); + _topPadding = g_gui.evaluator()->getVar("ListWidget.topPadding", 0); + _bottomPadding = g_gui.evaluator()->getVar("ListWidget.bottomPadding", 0); + _hlLeftPadding = g_gui.evaluator()->getVar("ListWidget.hlLeftPadding", 0); + _hlRightPadding = g_gui.evaluator()->getVar("ListWidget.hlRightPadding", 0); + + if (ws == kBigWidgetSize) { + _w = w - kBigScrollBarWidth; + } else { + _w = w - kNormalScrollBarWidth; + } + + _entriesPerPage = (_h - _topPadding - _bottomPadding) / kLineHeight; + + delete [] _textWidth; + _textWidth = new int[_entriesPerPage]; + + for (int i = 0; i < _entriesPerPage; i++) + _textWidth[i] = 0; + + _scrollBar->resize(_x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h); + scrollBarRecalc(); +} + } // End of namespace GUI diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 3457620ac3..5e47cf7bb7 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -90,6 +90,8 @@ public: virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleScreenChanged(); + virtual bool wantsFocus() { return true; } // Made startEditMode for SCUMM's SaveLoadChooser diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 859d7f0ba8..89e42f4993 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -344,10 +344,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { PopUpWidget::PopUpWidget(GuiObject *boss, String name, const String &label, uint labelWidth) : Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) { - _ws = g_gui.getWidgetSize(); - - _leftPadding = g_gui.evaluator()->getVar("PopUpWidget.leftPadding", 0); - _rightPadding = g_gui.evaluator()->getVar("PopUpWidget.rightPadding", 0); + handleScreenChanged(); _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; setHints(THEME_HINT_SAVE_BACKGROUND); @@ -371,6 +368,15 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) { } } +void PopUpWidget::handleScreenChanged() { + _ws = g_gui.getWidgetSize(); + + _leftPadding = g_gui.evaluator()->getVar("PopUpWidget.leftPadding", 0); + _rightPadding = g_gui.evaluator()->getVar("PopUpWidget.rightPadding", 0); + + Widget::handleScreenChanged(); +} + void PopUpWidget::appendEntry(const String &entry, uint32 tag) { Entry e; e.name = entry; diff --git a/gui/PopUpWidget.h b/gui/PopUpWidget.h index 786f3461f8..d4df3654e2 100644 --- a/gui/PopUpWidget.h +++ b/gui/PopUpWidget.h @@ -62,6 +62,8 @@ protected: public: PopUpWidget(GuiObject *boss, String name, const String &label, uint labelWidth = 0); + void changeLabelWidth(uint newWidth) { _labelWidth = newWidth; } + void handleMouseDown(int x, int y, int button, int clickCount); void appendEntry(const String &entry, uint32 tag = (uint32)-1); @@ -79,6 +81,8 @@ public: void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + + virtual void handleScreenChanged(); protected: void drawWidget(bool hilite); }; diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp index 3d236b2f20..31173604cf 100644 --- a/gui/TabWidget.cpp +++ b/gui/TabWidget.cpp @@ -137,6 +137,17 @@ bool TabWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { return Widget::handleKeyDown(ascii, keycode, modifiers); } +void TabWidget::handleScreenChanged() { + for (uint i = 0; i < _tabs.size(); ++i) { + Widget *w = _tabs[i].firstWidget; + while (w) { + w->handleScreenChanged(); + w = w->next(); + } + } + Widget::handleScreenChanged(); +} + void TabWidget::drawWidget(bool hilite) { Common::Array<Common::String> tabs; for (int i = 0; i < (int)_tabs.size(); ++i) { diff --git a/gui/TabWidget.h b/gui/TabWidget.h index 6b4c80904d..38b4543aed 100644 --- a/gui/TabWidget.h +++ b/gui/TabWidget.h @@ -69,6 +69,8 @@ public: virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual void handleScreenChanged(); + protected: virtual void drawWidget(bool hilite); diff --git a/gui/ThemeClassic.cpp b/gui/ThemeClassic.cpp index df2fc4751e..bda8836af5 100644 --- a/gui/ThemeClassic.cpp +++ b/gui/ThemeClassic.cpp @@ -55,6 +55,7 @@ bool ThemeClassic::init() { } else { _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); } + resetDrawArea(); } if (isThemeLoadingRequired()) diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp index 1d93e290ac..96d3e49745 100644 --- a/gui/ThemeNew.cpp +++ b/gui/ThemeNew.cpp @@ -322,6 +322,7 @@ bool ThemeNew::init() { _initOk = true; clearAll(); setupFonts(); + resetDrawArea(); } if (isThemeLoadingRequired()) { diff --git a/gui/about.cpp b/gui/about.cpp index 2e7113ced4..90f7eb3600 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -84,9 +84,9 @@ AboutDialog::AboutDialog() const int screenW = g_system->getOverlayWidth(); const int screenH = g_system->getOverlayHeight(); - xOff = g_gui.evaluator()->getVar("aboutXOff");; - yOff = g_gui.evaluator()->getVar("aboutYOff");; - int outerBorder = g_gui.evaluator()->getVar("aboutOuterBorder");; + xOff = g_gui.evaluator()->getVar("aboutXOff"); + yOff = g_gui.evaluator()->getVar("aboutYOff"); + int outerBorder = g_gui.evaluator()->getVar("aboutOuterBorder"); _w = screenW - 2 * outerBorder; _h = screenH - 2 * outerBorder; @@ -289,4 +289,35 @@ void AboutDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { close(); } +void AboutDialog::handleScreenChanged() { + Dialog::handleScreenChanged(); + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + xOff = g_gui.evaluator()->getVar("aboutXOff"); + yOff = g_gui.evaluator()->getVar("aboutYOff"); + int outerBorder = g_gui.evaluator()->getVar("aboutOuterBorder"); + + _w = screenW - 2 * outerBorder; + _h = screenH - 2 * outerBorder; + + _lineHeight = g_gui.getFontHeight() + 3; + + // Heuristic to compute 'optimal' dialog width + int maxW = _w - 2*xOff; + _w = 0; + for (int i = 0; i < ARRAYSIZE(credits); i++) { + int tmp = g_gui.getStringWidth(credits[i] + 5); + if ( _w < tmp && tmp <= maxW) { + _w = tmp; + } + } + _w += 2*xOff; + + _lineHeight = g_gui.getFontHeight() + 3; + + _x = (screenW - _w) / 2; + _y = (screenH - _h) / 2; +} + } // End of namespace GUI diff --git a/gui/about.h b/gui/about.h index b607d87591..40fa35d8ba 100644 --- a/gui/about.h +++ b/gui/about.h @@ -52,6 +52,8 @@ public: void handleMouseUp(int x, int y, int button, int clickCount); void handleKeyDown(uint16 ascii, int keycode, int modifiers); void handleKeyUp(uint16 ascii, int keycode, int modifiers); + + void handleScreenChanged(); }; } // End of namespace GUI diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 0f264c5d6a..0bccfb91ab 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -106,9 +106,12 @@ void Dialog::handleScreenChanged() { _drawingHints |= THEME_HINT_FIRST_DRAW; Widget *w = _firstWidget; while (w) { + w->handleScreenChanged(); w->setHints(THEME_HINT_FIRST_DRAW); w = w->_next; } + + GuiObject::handleScreenChanged(); } void Dialog::releaseFocus() { @@ -304,6 +307,28 @@ Widget *Dialog::findWidget(int x, int y) { return Widget::findWidgetInChain(_firstWidget, x, y); } +Widget *Dialog::findWidget(const char *name) { + return Widget::findWidgetInChain(_firstWidget, name); +} + +void Dialog::deleteWidget(Widget *del) { + Widget *w = _firstWidget; + + if (del == _firstWidget) { + _firstWidget = _firstWidget->_next; + return; + } + + w = _firstWidget; + while (w) { + if (w->_next == del) { + w->_next = w->_next->_next; + return; + } + w = w->_next; + } +} + ButtonWidget *Dialog::addButton(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) { int w = kButtonWidth; int h = kButtonHeight; diff --git a/gui/dialog.h b/gui/dialog.h index 794aaa2395..a2471ea59a 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -62,6 +62,8 @@ public: void releaseFocus(); + virtual void handleScreenChanged(); + protected: virtual void open(); virtual void close(); @@ -77,9 +79,10 @@ protected: virtual void handleKeyUp(uint16 ascii, int keycode, int modifiers); virtual void handleMouseMoved(int x, int y, int button); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); - virtual void handleScreenChanged(); Widget *findWidget(int x, int y); // Find the widget at pos x,y if any + Widget *findWidget(const char *name); + void deleteWidget(Widget *widget); ButtonWidget *addButton(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws = kDefaultWidgetSize); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 73f5471f03..928d36f725 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -767,6 +767,11 @@ void LauncherDialog::updateButtons() { void LauncherDialog::handleScreenChanged() { #ifndef DISABLE_FANCY_THEMES if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1) { + StaticTextWidget *ver = (StaticTextWidget*)findWidget("launcher_version"); + if (ver) { + ver->setLabel(gScummVMVersionDate); + } + if (!_logo) _logo = new GraphicsWidget(this, "launcher_logo"); ThemeNew *th = (ThemeNew *)g_gui.theme(); @@ -774,9 +779,23 @@ void LauncherDialog::handleScreenChanged() { _logo->setGfx(th->getImageSurface(th->kThemeLogo)); } else { - delete _logo; + StaticTextWidget *ver = (StaticTextWidget*)findWidget("launcher_version"); + if (ver) { + ver->setLabel(gScummVMFullVersion); + } + + if (_logo) { + deleteWidget(_logo); + _logo->setNext(0); + delete _logo; + _logo = 0; + } } #endif + + _w = g_system->getOverlayWidth(); + _h = g_system->getOverlayHeight(); + Dialog::handleScreenChanged(); } diff --git a/gui/newgui.cpp b/gui/newgui.cpp index fb3a0ff103..024dde3657 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -59,29 +59,33 @@ enum { // HACK. FIXME. This doesn't belong here. But otherwise it creates compulation problems GuiObject::GuiObject(Common::String name) : _firstWidget(0) { - if ((_x = g_gui.evaluator()->getVar(name + ".x")) == EVAL_UNDEF_VAR) - error("Undefined variable %s.x", name.c_str()); - if ((_y = g_gui.evaluator()->getVar(name + ".y")) == EVAL_UNDEF_VAR) - error("Undefined variable %s.y", name.c_str()); - _w = g_gui.evaluator()->getVar(name + ".w"); - _h = g_gui.evaluator()->getVar(name + ".h"); - - if(_x < 0) - error("Widget <%s> has x < 0", name.c_str()); - if(_x >= g_system->getOverlayWidth()) - error("Widget <%s> has x > %d", name.c_str(), g_system->getOverlayWidth()); - if(_x + _w > g_system->getOverlayWidth()) - error("Widget <%s> has x + w > %d (%d)", name.c_str(), g_system->getOverlayWidth(), _x + _w); - if(_y < 0) - error("Widget <%s> has y < 0", name.c_str()); - if(_y >= g_system->getOverlayWidth()) - error("Widget <%s> has y > %d", name.c_str(), g_system->getOverlayHeight()); - if(_y + _h > g_system->getOverlayWidth()) - error("Widget <%s> has y + h > %d (%d)", name.c_str(), g_system->getOverlayHeight(), _y + _h); - _name = name; + handleScreenChanged(); } +void GuiObject::handleScreenChanged() { + if (_name != "") { + if ((_x = g_gui.evaluator()->getVar(_name + ".x")) == EVAL_UNDEF_VAR) + error("Undefined variable %s.x", _name.c_str()); + if ((_y = g_gui.evaluator()->getVar(_name + ".y")) == EVAL_UNDEF_VAR) + error("Undefined variable %s.y", _name.c_str()); + _w = g_gui.evaluator()->getVar(_name + ".w"); + _h = g_gui.evaluator()->getVar(_name + ".h"); + + if(_x < 0) + error("Widget <%s> has x < 0", _name.c_str()); + if(_x >= g_system->getOverlayWidth()) + error("Widget <%s> has x > %d", _name.c_str(), g_system->getOverlayWidth()); + if(_x + _w > g_system->getOverlayWidth()) + error("Widget <%s> has x + w > %d (%d)", _name.c_str(), g_system->getOverlayWidth(), _x + _w); + if(_y < 0) + error("Widget <%s> has y < 0", _name.c_str()); + if(_y >= g_system->getOverlayWidth()) + error("Widget <%s> has y > %d", _name.c_str(), g_system->getOverlayHeight()); + if(_y + _h > g_system->getOverlayWidth()) + error("Widget <%s> has y + h > %d (%d)", _name.c_str(), g_system->getOverlayHeight(), _y + _h); + } +} // Constructor NewGui::NewGui() : _needRedraw(false), @@ -235,7 +239,7 @@ void NewGui::runLoop() { _needRedraw = true; // refresh all dialogs for (i = 0; i < _dialogStack.size(); ++i) { - activeDialog->handleScreenChanged(); + _dialogStack[i]->handleScreenChanged(); } break; } diff --git a/gui/object.h b/gui/object.h index 5067ab8354..cb553fa1a7 100644 --- a/gui/object.h +++ b/gui/object.h @@ -78,6 +78,8 @@ public: virtual void draw() = 0; + virtual void handleScreenChanged(); + protected: virtual void releaseFocus() = 0; diff --git a/gui/options.cpp b/gui/options.cpp index 7d1025d0d0..46128dad6f 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -446,6 +446,19 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) { _enableVolumeSettings = true; } +void OptionsDialog::handleScreenChanged() { + Dialog::handleScreenChanged(); + + int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW"); + + if (_midiPopUp) + _midiPopUp->changeLabelWidth(labelWidth); + if (_gfxPopUp) + _gfxPopUp->changeLabelWidth(labelWidth); + if (_renderModePopUp) + _renderModePopUp->changeLabelWidth(labelWidth); +} + #pragma mark - diff --git a/gui/options.h b/gui/options.h index b50920a9a8..343aae33af 100644 --- a/gui/options.h +++ b/gui/options.h @@ -49,6 +49,8 @@ public: void close(); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleScreenChanged(); + enum { kOKCmd = 'ok ' }; diff --git a/gui/themes/modern.ini b/gui/themes/modern.ini index 456eada976..84e08b9fd9 100644 --- a/gui/themes/modern.ini +++ b/gui/themes/modern.ini @@ -148,6 +148,7 @@ shading_dim_percent=30 fontfile_normal=helvr12-l1.bdf [640xY] +def_launcherX=23 def_widgetSize=kBigWidgetSize def_buttonWidth=120 def_buttonHeight=25 @@ -155,7 +156,7 @@ def_sliderWidth=kBigSliderWidth def_sliderHeight=kBigSliderHeight def_kLineHeight=16 def_kFontHeight=14 -def_globOptionsW=466 +def_globOptionsW=(w - buttonWidth - 17 * 2 - launcherX) def_gameOptionsH=(h - 2 * 40) def_gameOptionsLabelWidth=90 def_tabPopupsLabelW=110 @@ -197,13 +198,13 @@ browser_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) browser_choose=(prev.x2 + 10) prev.y prev.w prev.h ##### launcher -launcher_version=85 21 247 kLineHeight +launcher_version=(w / 2 - 283 / 2 - 90) 21 247 kLineHeight launcher_version.align=kTextAlignRight -launcher_logo=180 5 283 80 +launcher_logo=(w / 2 - 283 / 2) 5 283 80 launcher_logo.visible=true space1=20 space2=5 -launcher_list=23 94 466 (h - 23 - self.y) +launcher_list=launcherX 94 (w - buttonWidth - 17 * 2 - self.x) (h - 23 - self.y) launcher_start_button=(prev.x2 + 17) prev.y buttonWidth buttonHeight launcher_addGame_button=prev.x (prev.y2 + space1) prev.w prev.h launcher_editGame_button=prev.x (prev.y2 + space2) prev.w prev.h @@ -461,3 +462,28 @@ scummmain_quit=prev.x smY prev.w prev.h smH=(smY + buttonHeight + scummmainHOffset) smW=(buttonWidth + 2 * scummmainHOffset) scummmain=((w - smW) / 2) ((h - smH) / 2) smW smH + +## 960xY modes +[960xY] +def_launcherX=23 +def_widgetSize=kBigWidgetSize +def_buttonWidth=120 +def_buttonHeight=25 +def_sliderWidth=kBigSliderWidth +def_sliderHeight=kBigSliderHeight +def_kLineHeight=16 +def_kFontHeight=14 +def_globOptionsW=(w - buttonWidth - 17 * 2 - launcherX) +def_gameOptionsH=(h - 2 * 40) +def_gameOptionsLabelWidth=90 +def_tabPopupsLabelW=110 +def_aboutXOff=8 +def_aboutYOff=5 +def_aboutOuterBorder=80 +def_scummmainHOffset=12 +def_scummmainVSpace=15 +def_scummmainVAddOff=5 +def_scummhelpW=370 +def_scummhelpX=((w - scummhelpW) / 2) +def_midiControlsSpacing=4 +use=640xY diff --git a/gui/widget.cpp b/gui/widget.cpp index fe3bb5252f..a9aae5342a 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -49,6 +49,13 @@ void Widget::init() { _hints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; } +void Widget::resize(int x, int y, int w, int h) { + _x = x; + _y = y; + _w = w; + _h = h; +} + Widget::~Widget() { delete _next; } @@ -114,6 +121,16 @@ Widget *Widget::findWidgetInChain(Widget *w, int x, int y) { return w; } +Widget *Widget::findWidgetInChain(Widget *w, const char *name) { + while (w) { + if (w->_name == name) { + return w; + } + w = w->_next; + } + return 0; +} + bool Widget::isVisible() const { if (g_gui.evaluator()->getVar(_name + ".visible") == 0) return false; @@ -173,6 +190,11 @@ void StaticTextWidget::drawWidget(bool hilite) { g_gui.theme()->convertAligment(_align)); } +void StaticTextWidget::handleScreenChanged() { + Widget::handleScreenChanged(); + _ws = g_gui.getWidgetSize(); +} + #pragma mark - ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws) diff --git a/gui/widget.h b/gui/widget.h index 9869331909..08e811cd6a 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -98,6 +98,7 @@ protected: public: static Widget *findWidgetInChain(Widget *start, int x, int y); + static Widget *findWidgetInChain(Widget *start, const char *name); public: Widget(GuiObject *boss, int x, int y, int w, int h); @@ -105,6 +106,10 @@ public: virtual ~Widget(); void init(); + void resize(int x, int y, int w, int h); + + void setNext(Widget *w) { _next = w; } + Widget *next() { return _next; } virtual int16 getAbsX() const { return _x + _boss->getChildX(); } virtual int16 getAbsY() const { return _y + _boss->getChildY(); } @@ -122,6 +127,8 @@ public: virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers) { return false; } // Return true if the event was handled virtual void handleTickle() {} + virtual void handleScreenChanged() { GuiObject::handleScreenChanged(); } + void draw(); void receivedFocus() { _hasFocus = true; receivedFocusWidget(); } void lostFocus() { _hasFocus = false; lostFocusWidget(); } @@ -171,6 +178,8 @@ public: void setAlign(TextAlignment align); TextAlignment getAlign() const { return _align; } + virtual void handleScreenChanged(); + protected: void drawWidget(bool hilite); }; |