aboutsummaryrefslogtreecommitdiff
path: root/gui/Tooltip.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2010-11-18 18:17:00 +0000
committerJohannes Schickel2010-11-18 18:17:00 +0000
commit8cd20c70a9f179acf2980ee2c4557fae05295d30 (patch)
treea4fa191a2b241278fa0a987d2204a9926f501dc7 /gui/Tooltip.cpp
parenta9dcb11c54274053152ca7e657bc4d19afb26e92 (diff)
downloadscummvm-rg350-8cd20c70a9f179acf2980ee2c4557fae05295d30.tar.gz
scummvm-rg350-8cd20c70a9f179acf2980ee2c4557fae05295d30.tar.bz2
scummvm-rg350-8cd20c70a9f179acf2980ee2c4557fae05295d30.zip
GUI: Simplify Tooltip implementation.
Formerly there was much special handling for the Tooltip dialog in GuiManager::runLoop. This was replaced by overloading the event handling functions in Tooltip. Also the Tooltip was adapted to be run like every other normal dialog. svn-id: r54337
Diffstat (limited to 'gui/Tooltip.cpp')
-rw-r--r--gui/Tooltip.cpp35
1 files changed, 8 insertions, 27 deletions
diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp
index 457f53d011..7dec12d522 100644
--- a/gui/Tooltip.cpp
+++ b/gui/Tooltip.cpp
@@ -40,40 +40,21 @@ Tooltip::Tooltip() :
_backgroundType = GUI::ThemeEngine::kDialogBackgroundTooltip;
}
-void Tooltip::mustClose() {
- if (isVisible())
- Dialog::close();
-}
-
-bool Tooltip::tooltipModal(int x, int y) {
- Widget *wdg;
-
- if (!g_gui.getTopDialog())
- return false;
-
- wdg = g_gui.getTopDialog()->findWidget(x, y);
+void Tooltip::setup(Dialog *parent, Widget *widget, int x, int y) {
+ assert(widget->getTooltip());
- if (!wdg || !wdg->getTooltip())
- return false;
-
- if (_maxWidth == -1) {
- _maxWidth = g_gui.xmlEval()->getVar("Globals.Tooltip.MaxWidth", 100);
- _xdelta = g_gui.xmlEval()->getVar("Globals.Tooltip.XDelta", 0);
- _ydelta = g_gui.xmlEval()->getVar("Globals.Tooltip.YDelta", 0);
- }
+ _maxWidth = g_gui.xmlEval()->getVar("Globals.Tooltip.MaxWidth", 100);
+ _xdelta = g_gui.xmlEval()->getVar("Globals.Tooltip.XDelta", 0);
+ _ydelta = g_gui.xmlEval()->getVar("Globals.Tooltip.YDelta", 0);
const Graphics::Font *tooltipFont = g_gui.theme()->getFont(ThemeEngine::kFontStyleTooltip);
_wrappedLines.clear();
- _w = tooltipFont->wordWrapText(wdg->getTooltip(), _maxWidth - 4, _wrappedLines);
+ _w = tooltipFont->wordWrapText(widget->getTooltip(), _maxWidth - 4, _wrappedLines);
_h = (tooltipFont->getFontHeight() + 2) * _wrappedLines.size();
- _x = MIN<int16>(g_gui.getTopDialog()->_x + x + _xdelta, g_gui.getWidth() - _w - 3);
- _y = MIN<int16>(g_gui.getTopDialog()->_y + y + _ydelta, g_gui.getHeight() - _h - 3);
-
- open();
-
- return true;
+ _x = MIN<int16>(parent->_x + x + _xdelta, g_gui.getWidth() - _w - 3);
+ _y = MIN<int16>(parent->_y + y + _ydelta, g_gui.getHeight() - _h - 3);
}
void Tooltip::drawDialog() {