ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

gui-manager.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUIMANAGER_H
00024 #define GUIMANAGER_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/singleton.h"
00028 #include "common/stack.h"
00029 #include "common/str.h"
00030 #include "common/list.h"
00031 
00032 #include "gui/ThemeEngine.h"
00033 
00034 class OSystem;
00035 
00036 namespace Graphics {
00037 class Font;
00038 }
00039 
00040 namespace Common {
00041     struct Event;
00042 }
00043 
00044 namespace GUI {
00045 
00046 class Dialog;
00047 class ThemeEval;
00048 class GuiObject;
00049 
00050 #define g_gui   (GUI::GuiManager::instance())
00051 
00052 
00053 // Height of a single text line
00054 #define kLineHeight (g_gui.getFontHeight() + 2)
00055 
00056 
00057 
00058 // Simple dialog stack class
00059 // Anybody nesting dialogs deeper than 4 is mad anyway
00060 typedef Common::FixedStack<Dialog *> DialogStack;
00061 
00062 
00066 class GuiManager : public Common::Singleton<GuiManager> {
00067     friend class Dialog;
00068     friend class Common::Singleton<SingletonBaseType>;
00069     GuiManager();
00070     ~GuiManager();
00071 public:
00072 
00073     // Main entry for the GUI: this will start an event loop that keeps running
00074     // until no dialogs are active anymore.
00075     void runLoop();
00076 
00077     void processEvent(const Common::Event &event, Dialog *const activeDialog);
00078     void scheduleTopDialogRedraw();
00079 
00080     bool isActive() const   { return ! _dialogStack.empty(); }
00081 
00082     bool loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled, bool force = false);
00083     ThemeEngine *theme() { return _theme; }
00084 
00085     ThemeEval *xmlEval() { return _theme->getEvaluator(); }
00086 
00087     int getWidth() const { return _width; }
00088     int getHeight() const { return _height; }
00089 
00090     const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
00091     int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
00092     int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
00093     int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
00094     int getKerningOffset(byte left, byte right, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold) const { return _theme->getKerningOffset(left, right, font); }
00095 
00102     bool checkScreenChange();
00103 
00109     void addToTrash(GuiObject*, Dialog* parent = 0);
00110 
00111     bool _launched;
00112 
00113 protected:
00114     enum RedrawStatus {
00115         kRedrawDisabled = 0,
00116         kRedrawOpenDialog,
00117         kRedrawCloseDialog,
00118         kRedrawTopDialog,
00119         kRedrawFull
00120     };
00121 
00122     OSystem         *_system;
00123 
00124     ThemeEngine     *_theme;
00125 
00126 //  bool        _needRedraw;
00127     RedrawStatus _redrawStatus;
00128     int         _lastScreenChangeID;
00129     int         _width, _height;
00130     DialogStack _dialogStack;
00131 
00132     bool        _stateIsSaved;
00133 
00134     bool        _useStdCursor;
00135 
00136     // position and time of last mouse click (used to detect double clicks)
00137     struct MousePos {
00138         MousePos() : x(-1), y(-1), count(0) { time = 0; }
00139         int16 x, y; // Position of mouse when the click occurred
00140         uint32 time;    // Time
00141         int count;  // How often was it already pressed?
00142     } _lastClick, _lastMousePosition, _globalMousePosition;
00143 
00144     // mouse cursor state
00145     int     _cursorAnimateCounter;
00146     int     _cursorAnimateTimer;
00147     byte    _cursor[2048];
00148 
00149     // delayed deletion of GuiObject
00150     struct GuiObjectTrashItem {
00151         GuiObject* object;
00152         Dialog* parent;
00153     };
00154     Common::List<GuiObjectTrashItem> _guiObjectTrash;
00155 
00156     void initKeymap();
00157     void pushKeymap();
00158     void popKeymap();
00159 
00160     void saveState();
00161     void restoreState();
00162 
00163     void openDialog(Dialog *dialog);
00164     void closeTopDialog();
00165 
00166     void redraw();
00167 
00168     void loop();
00169 
00170     void setupCursor();
00171     void animateCursor();
00172 
00173     Dialog *getTopDialog() const;
00174 
00175     void screenChange();
00176 
00177     void giveFocusToDialog(Dialog *dialog);
00178     void setLastMousePos(int16 x, int16 y);
00179 };
00180 
00181 } // End of namespace GUI
00182 
00183 #endif


Generated on Sat Apr 20 2019 05:02:50 for ResidualVM by doxygen 1.7.1
curved edge   curved edge