2002-07-05 16:56:53 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2002-2006 The ScummVM project
|
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"
|
2006-01-27 15:43:23 +00:00
|
|
|
#include "gui/theme.h"
|
2007-02-08 23:25:07 +00:00
|
|
|
#include "gui/widget.h"
|
2002-07-05 16:56:53 +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;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-12-01 21:16:18 +00:00
|
|
|
#define g_gui (GUI::NewGui::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
|
|
|
using Graphics::TextAlignment;
|
|
|
|
using Graphics::kTextAlignCenter;
|
|
|
|
using Graphics::kTextAlignLeft;
|
|
|
|
using Graphics::kTextAlignRight;
|
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2003-11-02 02:18:16 +00:00
|
|
|
class NewGui : public Common::Singleton<NewGui> {
|
2003-10-02 17:43:02 +00:00
|
|
|
typedef Common::String String;
|
2003-11-02 02:18:16 +00:00
|
|
|
friend class Dialog;
|
2005-01-06 18:38:34 +00:00
|
|
|
friend class Common::Singleton<SingletonBaseType>;
|
2003-11-02 02:18:16 +00:00
|
|
|
NewGui();
|
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
|
|
|
|
2006-10-08 18:22:28 +00:00
|
|
|
bool loadNewTheme(const Common::String &file);
|
2006-01-27 15:43:23 +00:00
|
|
|
Theme *theme() { return _theme; }
|
2006-03-07 05:39:52 +00:00
|
|
|
Eval *evaluator() { return _theme->_evaluator; }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2006-06-05 12:22:51 +00:00
|
|
|
const Graphics::Font &getFont(Theme::FontStyle style = Theme::kFontStyleBold) const { return *(_theme->getFont(style)); }
|
|
|
|
int getFontHeight(Theme::FontStyle style = Theme::kFontStyleBold) const { return _theme->getFontHeight(style); }
|
|
|
|
int getStringWidth(const Common::String &str, Theme::FontStyle style = Theme::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
|
|
|
|
int getCharWidth(byte c, Theme::FontStyle style = Theme::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2006-03-24 14:15:45 +00:00
|
|
|
WidgetSize getWidgetSize();
|
2006-03-08 01:42:02 +00:00
|
|
|
|
2006-05-27 05:46:04 +00:00
|
|
|
void clearDragWidget();
|
|
|
|
|
2006-11-08 10:06:42 +00:00
|
|
|
void screenChange();
|
|
|
|
|
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
|
|
|
|
|
|
|
Theme *_theme;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
bool _needRedraw;
|
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-18 14:47:25 +00:00
|
|
|
// for continuous events (keyDown)
|
2002-11-22 14:02:54 +00:00
|
|
|
struct {
|
|
|
|
uint16 ascii;
|
|
|
|
byte flags;
|
|
|
|
int keycode;
|
|
|
|
} _currentKeyDown;
|
2002-09-30 12:56:59 +00:00
|
|
|
uint32 _keyRepeatTime;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
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();
|
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
|