2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-07-05 16:56:53 +00:00
|
|
|
*/
|
|
|
|
|
2009-01-18 14:48:24 +00:00
|
|
|
#ifndef GUIMANAGER_H
|
|
|
|
#define GUIMANAGER_H
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2003-11-02 02:18:16 +00:00
|
|
|
#include "common/singleton.h"
|
2004-03-29 22:29:30 +00:00
|
|
|
#include "common/stack.h"
|
2002-09-26 11:44:02 +00:00
|
|
|
#include "common/str.h"
|
2009-01-02 20:03:45 +00:00
|
|
|
|
2008-09-02 17:51:08 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
2008-08-15 11:05:25 +00:00
|
|
|
|
2005-01-10 22:06:49 +00:00
|
|
|
class OSystem;
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
namespace Graphics {
|
|
|
|
class Font;
|
|
|
|
}
|
|
|
|
|
2013-05-16 21:18:09 +00:00
|
|
|
namespace Common {
|
|
|
|
struct Event;
|
|
|
|
}
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
class Dialog;
|
2008-08-05 09:54:36 +00:00
|
|
|
class ThemeEval;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2008-12-25 23:55:36 +00:00
|
|
|
#define g_gui (GUI::GuiManager::instance())
|
2003-11-02 02:18:16 +00:00
|
|
|
|
|
|
|
|
2004-03-13 13:03:25 +00:00
|
|
|
// Height of a single text line
|
2005-01-06 22:48:42 +00:00
|
|
|
#define kLineHeight (g_gui.getFontHeight() + 2)
|
2004-03-13 13:03:25 +00:00
|
|
|
|
2002-07-27 00:36:09 +00:00
|
|
|
|
2004-03-21 21:20:25 +00:00
|
|
|
|
2004-03-29 22:29:30 +00:00
|
|
|
// Simple dialog stack class
|
|
|
|
// Anybody nesting dialogs deeper than 4 is mad anyway
|
2004-05-05 01:19:42 +00:00
|
|
|
typedef Common::FixedStack<Dialog *> DialogStack;
|
2004-03-29 22:29:30 +00:00
|
|
|
|
2002-07-07 21:46:53 +00:00
|
|
|
|
2003-11-19 23:46:39 +00:00
|
|
|
/**
|
|
|
|
* GUI manager singleton.
|
2005-01-06 19:09:34 +00:00
|
|
|
*/
|
2008-12-25 23:55:36 +00:00
|
|
|
class GuiManager : public Common::Singleton<GuiManager> {
|
2003-11-02 02:18:16 +00:00
|
|
|
friend class Dialog;
|
2005-01-06 18:38:34 +00:00
|
|
|
friend class Common::Singleton<SingletonBaseType>;
|
2008-12-25 23:55:36 +00:00
|
|
|
GuiManager();
|
|
|
|
~GuiManager();
|
2002-07-05 16:56:53 +00:00
|
|
|
public:
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
// Main entry for the GUI: this will start an event loop that keeps running
|
|
|
|
// until no dialogs are active anymore.
|
|
|
|
void runLoop();
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2013-05-16 21:18:09 +00:00
|
|
|
void processEvent(const Common::Event &event, Dialog *const activeDialog);
|
|
|
|
|
2005-01-06 22:48:42 +00:00
|
|
|
bool isActive() const { return ! _dialogStack.empty(); }
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2010-06-15 10:44:51 +00:00
|
|
|
bool loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled, bool force = false);
|
2008-11-09 12:38:30 +00:00
|
|
|
ThemeEngine *theme() { return _theme; }
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-10-12 22:25:35 +00:00
|
|
|
ThemeEval *xmlEval() { return _theme->getEvaluator(); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2010-03-12 23:02:24 +00:00
|
|
|
int getWidth() const { return _width; }
|
|
|
|
int getHeight() const { return _height; }
|
|
|
|
|
2008-11-10 11:24:55 +00:00
|
|
|
const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
|
|
|
|
int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
|
|
|
|
int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
|
|
|
|
int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
|
2012-01-08 01:33:34 +00:00
|
|
|
int getKerningOffset(byte left, byte right, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold) const { return _theme->getKerningOffset(left, right, font); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2009-01-01 21:41:55 +00:00
|
|
|
/**
|
|
|
|
* Tell the GuiManager to check whether the screen resolution has changed.
|
|
|
|
* If that is the case, the GuiManager will reload/refresh the active theme.
|
|
|
|
*
|
|
|
|
* @return true if the a screen change indeed occurred, false otherwise
|
|
|
|
*/
|
|
|
|
bool checkScreenChange();
|
2010-06-15 10:52:35 +00:00
|
|
|
|
2009-01-01 21:41:55 +00:00
|
|
|
protected:
|
2008-07-17 21:58:43 +00:00
|
|
|
enum RedrawStatus {
|
|
|
|
kRedrawDisabled = 0,
|
2009-02-06 23:28:08 +00:00
|
|
|
kRedrawOpenDialog,
|
|
|
|
kRedrawCloseDialog,
|
|
|
|
kRedrawTopDialog,
|
2008-07-17 21:58:43 +00:00
|
|
|
kRedrawFull
|
|
|
|
};
|
|
|
|
|
2005-01-06 19:09:34 +00:00
|
|
|
OSystem *_system;
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2008-11-09 12:38:30 +00:00
|
|
|
ThemeEngine *_theme;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2008-07-17 21:58:43 +00:00
|
|
|
// bool _needRedraw;
|
|
|
|
RedrawStatus _redrawStatus;
|
2006-08-04 18:01:43 +00:00
|
|
|
int _lastScreenChangeID;
|
2010-03-12 23:02:24 +00:00
|
|
|
int _width, _height;
|
2002-07-07 21:46:53 +00:00
|
|
|
DialogStack _dialogStack;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
bool _stateIsSaved;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-10-08 20:37:39 +00:00
|
|
|
bool _useStdCursor;
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
// position and time of last mouse click (used to detect double clicks)
|
2002-07-06 12:57:51 +00:00
|
|
|
struct {
|
2010-06-15 12:33:20 +00:00
|
|
|
int16 x, y; // Position of mouse when the click occurred
|
2002-07-27 14:16:14 +00:00
|
|
|
uint32 time; // Time
|
|
|
|
int count; // How often was it already pressed?
|
2010-07-23 19:36:47 +00:00
|
|
|
} _lastClick, _lastMousePosition;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-09-19 23:06:54 +00:00
|
|
|
// mouse cursor state
|
2005-01-06 19:09:34 +00:00
|
|
|
int _cursorAnimateCounter;
|
|
|
|
int _cursorAnimateTimer;
|
2009-07-05 14:11:54 +00:00
|
|
|
byte _cursor[2048];
|
2006-10-08 18:22:28 +00:00
|
|
|
|
2009-05-10 22:05:04 +00:00
|
|
|
void initKeymap();
|
2011-10-22 03:54:33 +00:00
|
|
|
void pushKeymap();
|
|
|
|
void popKeymap();
|
2009-05-10 22:05:04 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
void saveState();
|
|
|
|
void restoreState();
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-07-07 21:46:53 +00:00
|
|
|
void openDialog(Dialog *dialog);
|
|
|
|
void closeTopDialog();
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2006-06-03 10:48:37 +00:00
|
|
|
void redraw();
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
void loop();
|
|
|
|
|
2006-10-08 18:22:28 +00:00
|
|
|
void setupCursor();
|
2002-09-19 23:06:54 +00:00
|
|
|
void animateCursor();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-12-27 22:51:14 +00:00
|
|
|
Dialog *getTopDialog() const;
|
2009-01-01 21:41:55 +00:00
|
|
|
|
|
|
|
void screenChange();
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
#endif
|