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     class Keymap;
00043 }
00044 
00045 namespace GUI {
00046 
00047 class Dialog;
00048 class ThemeEval;
00049 class GuiObject;
00050 
00051 #define g_gui   (GUI::GuiManager::instance())
00052 
00053 
00054 // Height of a single text line
00055 #define kLineHeight (g_gui.getFontHeight() + 2)
00056 
00057 
00058 
00059 // Simple dialog stack class
00060 // Anybody nesting dialogs deeper than 4 is mad anyway
00061 typedef Common::FixedStack<Dialog *> DialogStack;
00062 
00063 
00067 class GuiManager : public Common::Singleton<GuiManager> {
00068     friend class Dialog;
00069     friend class Common::Singleton<SingletonBaseType>;
00070     GuiManager();
00071     ~GuiManager() override;
00072 public:
00073 
00074     // Main entry for the GUI: this will start an event loop that keeps running
00075     // until no dialogs are active anymore.
00076     void runLoop();
00077 
00078     void processEvent(const Common::Event &event, Dialog *const activeDialog);
00079     Common::Keymap *getKeymap() const;
00080     void scheduleTopDialogRedraw();
00081 
00082     bool isActive() const   { return ! _dialogStack.empty(); }
00083 
00084     bool loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled, bool force = false);
00085     ThemeEngine *theme() { return _theme; }
00086 
00087     ThemeEval *xmlEval() { return _theme->getEvaluator(); }
00088 
00089     int getWidth() const { return _width; }
00090     int getHeight() const { return _height; }
00091 
00092     bool useRTL() const { return _useRTL; }
00093     void setLanguageRTL();
00094 
00095     void setDialogPaddings(int l, int r);
00096     int getOverlayOffset() { return _topDialogRightPadding - _topDialogLeftPadding; }
00097 
00098     const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
00099     int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
00100     int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
00101     int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
00102     int getKerningOffset(byte left, byte right, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold) const { return _theme->getKerningOffset(left, right, font); }
00103 
00110     bool checkScreenChange();
00111 
00117     void addToTrash(GuiObject*, Dialog* parent = nullptr);
00118     void initTextToSpeech();
00119 
00120     bool _launched;
00121 
00122     void redrawFull();
00123 
00124 protected:
00125     enum RedrawStatus {
00126         kRedrawDisabled = 0,
00127         kRedrawOpenDialog,
00128         kRedrawCloseDialog,
00129         kRedrawTopDialog,
00130         kRedrawFull
00131     };
00132 
00133     OSystem         *_system;
00134 
00135     ThemeEngine     *_theme;
00136 
00137 //  bool        _needRedraw;
00138     RedrawStatus _redrawStatus;
00139     int         _lastScreenChangeID;
00140     int         _width, _height;
00141     DialogStack _dialogStack;
00142 
00143     bool        _stateIsSaved;
00144 
00145     bool        _useStdCursor;
00146 
00147     bool        _useRTL;
00148 
00149     int         _topDialogLeftPadding;
00150     int         _topDialogRightPadding;
00151 
00152     // position and time of last mouse click (used to detect double clicks)
00153     struct MousePos {
00154         MousePos() : x(-1), y(-1), count(0) { time = 0; }
00155         int16 x, y; // Position of mouse when the click occurred
00156         uint32 time;    // Time
00157         int count;  // How often was it already pressed?
00158     } _lastClick, _lastMousePosition, _globalMousePosition;
00159 
00160     // mouse cursor state
00161     int     _cursorAnimateCounter;
00162     int     _cursorAnimateTimer;
00163     byte    _cursor[2048];
00164 
00165     // delayed deletion of GuiObject
00166     struct GuiObjectTrashItem {
00167         GuiObject* object;
00168         Dialog* parent;
00169     };
00170     Common::List<GuiObjectTrashItem> _guiObjectTrash;
00171 
00172     void initKeymap();
00173     void enableKeymap(bool enabled);
00174 
00175     void saveState();
00176     void restoreState();
00177 
00178     void openDialog(Dialog *dialog);
00179     void closeTopDialog();
00180 
00181     void redraw();
00182 
00183     void setupCursor();
00184     void animateCursor();
00185 
00186     Dialog *getTopDialog() const;
00187 
00188     void screenChange();
00189 
00190     void giveFocusToDialog(Dialog *dialog);
00191     void setLastMousePos(int16 x, int16 y);
00192 };
00193 
00194 } // End of namespace GUI
00195 
00196 #endif


Generated on Sat Jul 11 2020 05:01:24 for ResidualVM by doxygen 1.7.1
curved edge   curved edge