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
|
|
|
*
|
2006-02-11 10:08:56 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-07-05 16:56:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NEWGUI_H
|
|
|
|
#define NEWGUI_H
|
|
|
|
|
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"
|
2005-01-06 21:15:52 +00:00
|
|
|
#include "graphics/fontman.h"
|
2008-11-10 11:24:55 +00:00
|
|
|
|
2007-02-08 23:25:07 +00:00
|
|
|
#include "gui/widget.h"
|
2002-07-05 16:56:53 +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;
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
class Dialog;
|
2006-03-07 05:39:52 +00:00
|
|
|
class Eval;
|
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
|
|
|
|
2005-01-06 22:48:42 +00:00
|
|
|
bool isActive() const { return ! _dialogStack.empty(); }
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
bool loadNewTheme(Common::String file, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled);
|
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
|
|
|
|
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); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2006-05-27 05:46:04 +00:00
|
|
|
void clearDragWidget();
|
|
|
|
|
2006-11-08 10:06:42 +00:00
|
|
|
void screenChange();
|
|
|
|
|
2008-07-17 21:58:43 +00:00
|
|
|
enum RedrawStatus {
|
|
|
|
kRedrawDisabled = 0,
|
|
|
|
kRedrawOpenDialog,
|
|
|
|
kRedrawCloseDialog,
|
|
|
|
kRedrawTopDialog,
|
|
|
|
kRedrawFull
|
|
|
|
};
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
protected:
|
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;
|
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 {
|
2002-07-27 14:16:14 +00:00
|
|
|
int16 x, y; // Position of mouse when the click occured
|
|
|
|
uint32 time; // Time
|
|
|
|
int count; // How often was it already pressed?
|
|
|
|
} _lastClick;
|
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;
|
2002-09-19 23:06:54 +00:00
|
|
|
byte _cursor[2048];
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2006-10-08 18:22:28 +00:00
|
|
|
bool _themeChange;
|
|
|
|
|
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;
|
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
|