Implement opcode 0x3d set animation skip point.
[scummvm-innocent.git] / gui / GuiManager.h
blobab5c653549ac4191e1a1be3efd41bddef2b00bca
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.
21 * $URL$
22 * $Id$
25 #ifndef GUIMANAGER_H
26 #define GUIMANAGER_H
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"
38 class OSystem;
40 namespace GUI {
42 class Dialog;
43 class ThemeEval;
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;
58 /**
59 * GUI manager singleton.
61 class GuiManager : public Common::Singleton<GuiManager> {
62 friend class Dialog;
63 friend class Common::Singleton<SingletonBaseType>;
64 GuiManager();
65 ~GuiManager();
66 public:
68 // Main entry for the GUI: this will start an event loop that keeps running
69 // until no dialogs are active anymore.
70 void runLoop();
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); }
84 /**
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();
91 protected:
92 enum RedrawStatus {
93 kRedrawDisabled = 0,
94 kRedrawOpenDialog,
95 kRedrawCloseDialog,
96 kRedrawTopDialog,
97 kRedrawFull
100 OSystem *_system;
102 ThemeEngine *_theme;
104 // bool _needRedraw;
105 RedrawStatus _redrawStatus;
106 int _lastScreenChangeID;
107 DialogStack _dialogStack;
109 bool _stateIsSaved;
111 bool _useStdCursor;
113 // position and time of last mouse click (used to detect double clicks)
114 struct {
115 int16 x, y; // Position of mouse when the click occured
116 uint32 time; // Time
117 int count; // How often was it already pressed?
118 } _lastClick;
120 // mouse cursor state
121 int _cursorAnimateCounter;
122 int _cursorAnimateTimer;
123 byte _cursor[2048];
125 void initKeymap();
127 void saveState();
128 void restoreState();
130 void openDialog(Dialog *dialog);
131 void closeTopDialog();
133 void redraw();
135 void loop();
137 void setupCursor();
138 void animateCursor();
140 Dialog *getTopDialog() const;
142 void screenChange();
145 } // End of namespace GUI
147 #endif