1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include "common/scummsys.h"
29 #include "common/singleton.h"
30 #include "common/stack.h"
31 #include "common/str.h"
33 #include "graphics/fontman.h"
35 #include "gui/widget.h"
36 #include "gui/ThemeEngine.h"
45 #define g_gui (GUI::GuiManager::instance())
48 // Height of a single text line
49 #define kLineHeight (g_gui.getFontHeight() + 2)
53 // Simple dialog stack class
54 // Anybody nesting dialogs deeper than 4 is mad anyway
55 typedef Common::FixedStack
<Dialog
*> DialogStack
;
59 * GUI manager singleton.
61 class GuiManager
: public Common::Singleton
<GuiManager
> {
63 friend class Common::Singleton
<SingletonBaseType
>;
68 // Main entry for the GUI: this will start an event loop that keeps running
69 // until no dialogs are active anymore.
72 bool isActive() const { return ! _dialogStack
.empty(); }
74 bool loadNewTheme(Common::String id
, ThemeEngine::GraphicsMode gfx
= ThemeEngine::kGfxDisabled
);
75 ThemeEngine
*theme() { return _theme
; }
77 ThemeEval
*xmlEval() { return _theme
->getEvaluator(); }
79 const Graphics::Font
&getFont(ThemeEngine::FontStyle style
= ThemeEngine::kFontStyleBold
) const { return *(_theme
->getFont(style
)); }
80 int getFontHeight(ThemeEngine::FontStyle style
= ThemeEngine::kFontStyleBold
) const { return _theme
->getFontHeight(style
); }
81 int getStringWidth(const Common::String
&str
, ThemeEngine::FontStyle style
= ThemeEngine::kFontStyleBold
) const { return _theme
->getStringWidth(str
, style
); }
82 int getCharWidth(byte c
, ThemeEngine::FontStyle style
= ThemeEngine::kFontStyleBold
) const { return _theme
->getCharWidth(c
, style
); }
85 * Tell the GuiManager to check whether the screen resolution has changed.
86 * If that is the case, the GuiManager will reload/refresh the active theme.
88 * @return true if the a screen change indeed occurred, false otherwise
90 bool checkScreenChange();
105 RedrawStatus _redrawStatus
;
106 int _lastScreenChangeID
;
107 DialogStack _dialogStack
;
113 // position and time of last mouse click (used to detect double clicks)
115 int16 x
, y
; // Position of mouse when the click occured
117 int count
; // How often was it already pressed?
120 // mouse cursor state
121 int _cursorAnimateCounter
;
122 int _cursorAnimateTimer
;
130 void openDialog(Dialog
*dialog
);
131 void closeTopDialog();
138 void animateCursor();
140 Dialog
*getTopDialog() const;
145 } // End of namespace GUI