2005-02-27 23:41:19 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2010-01-10 02:58:28 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott and the Stella team
|
2005-02-27 23:41:19 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2005-03-10 22:59:40 +00:00
|
|
|
//
|
|
|
|
// Based on code from ScummVM - Scumm Interpreter
|
|
|
|
// Copyright (C) 2002-2004 The ScummVM project
|
2005-02-27 23:41:19 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef GUI_OBJECT_HXX
|
|
|
|
#define GUI_OBJECT_HXX
|
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
class Dialog;
|
2005-05-10 19:20:45 +00:00
|
|
|
class DialogContainer;
|
2005-02-27 23:41:19 +00:00
|
|
|
class Widget;
|
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
#include "Command.hxx"
|
2005-08-31 19:15:10 +00:00
|
|
|
#include "OSystem.hxx"
|
2005-08-10 12:23:42 +00:00
|
|
|
#include "Array.hxx"
|
|
|
|
|
Moved the Array class from namespace GUI to Common, since it's used in
many places other than the GUI code.
As a diversion from the joystick stuff, I'm experimenting with event
recording. Eventually, this will allow one to record a state + events,
and then load that INP file again. When loaded, Stella will replay the
events, and you'll be able to see exactly what happened before. Since
this is based on frames, the replaying can speed up and slow
down by changing the emulation framerate. And it can be exited at any
point, and normal emulation can continue. Or at least that's how I
want it to work.
A preliminary spec for the event stream is -X A B A B ... -X ...,
where X represents how many frames to wait, and 'A B' are event/value
pairs representing an event in Stella. I think this is very similar
to the scheme that Thomas J. recently added to z26, so converting to
a Stella eventstream should be easy.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@905 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2005-12-09 01:16:14 +00:00
|
|
|
typedef Common::Array<Widget*> WidgetArray;
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2007-09-03 18:37:24 +00:00
|
|
|
// The commands generated by various widgets
|
|
|
|
enum {
|
|
|
|
kOKCmd = 'OK ',
|
|
|
|
kCloseCmd = 'CLOS',
|
|
|
|
kNextCmd = 'NEXT',
|
|
|
|
kPrevCmd = 'PREV',
|
|
|
|
kEditCmd = 'EDIT',
|
|
|
|
kDefaultsCmd = 'DEFA',
|
|
|
|
kSetPositionCmd = 'SETP',
|
|
|
|
kTabChangedCmd = 'TBCH',
|
|
|
|
kCheckActionCmd = 'CBAC',
|
2008-12-29 20:42:15 +00:00
|
|
|
kRefreshAllCmd = 'REFA'
|
2007-09-03 18:37:24 +00:00
|
|
|
};
|
|
|
|
|
2005-02-27 23:41:19 +00:00
|
|
|
/**
|
|
|
|
This is the base class for all GUI objects/widgets.
|
|
|
|
|
|
|
|
@author Stephen Anthony
|
2009-05-13 13:55:40 +00:00
|
|
|
@version $Id$
|
2005-02-27 23:41:19 +00:00
|
|
|
*/
|
2005-03-10 22:59:40 +00:00
|
|
|
class GuiObject : public CommandReceiver
|
2005-02-27 23:41:19 +00:00
|
|
|
{
|
2005-03-10 22:59:40 +00:00
|
|
|
friend class Widget;
|
2005-05-13 01:03:27 +00:00
|
|
|
friend class DialogContainer;
|
2005-02-27 23:41:19 +00:00
|
|
|
|
|
|
|
public:
|
2008-06-13 13:14:52 +00:00
|
|
|
GuiObject(OSystem& osystem, DialogContainer& parent, Dialog& dialog,
|
|
|
|
int x, int y, int w, int h)
|
2005-08-10 12:23:42 +00:00
|
|
|
: myOSystem(osystem),
|
|
|
|
myParent(parent),
|
2008-06-13 13:14:52 +00:00
|
|
|
myDialog(dialog),
|
2005-08-10 12:23:42 +00:00
|
|
|
_x(x),
|
|
|
|
_y(y),
|
|
|
|
_w(w),
|
|
|
|
_h(h),
|
2006-01-15 20:46:20 +00:00
|
|
|
_dirty(false),
|
2005-08-10 12:23:42 +00:00
|
|
|
_firstWidget(0) {}
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
virtual ~GuiObject() {}
|
2005-05-21 16:12:13 +00:00
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
OSystem& instance() { return myOSystem; }
|
|
|
|
DialogContainer& parent() { return myParent; }
|
|
|
|
Dialog& dialog() { return myDialog; }
|
2005-03-11 23:36:30 +00:00
|
|
|
|
2005-05-13 18:28:06 +00:00
|
|
|
virtual int getAbsX() const { return _x; }
|
|
|
|
virtual int getAbsY() const { return _y; }
|
|
|
|
virtual int getChildX() const { return getAbsX(); }
|
|
|
|
virtual int getChildY() const { return getAbsY(); }
|
|
|
|
virtual int getWidth() const { return _w; }
|
|
|
|
virtual int getHeight() const { return _h; }
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2009-01-04 02:28:12 +00:00
|
|
|
virtual void setWidth(int w) { _w = w; }
|
|
|
|
virtual void setHeight(int h) { _h = h; }
|
2005-05-14 03:26:29 +00:00
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
virtual void setDirty() { _dirty = true; }
|
2005-08-01 22:33:16 +00:00
|
|
|
|
2005-02-27 23:41:19 +00:00
|
|
|
virtual bool isVisible() const = 0;
|
|
|
|
virtual void draw() = 0;
|
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
/** Add given widget to the focus list */
|
|
|
|
virtual void addFocusWidget(Widget* w) = 0;
|
|
|
|
|
|
|
|
/** Return focus list for this object */
|
|
|
|
WidgetArray& getFocusList() { return _focusList; }
|
|
|
|
|
|
|
|
/** Redraw the focus list */
|
|
|
|
virtual void redrawFocus() {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void releaseFocus() = 0;
|
2005-06-10 17:46:07 +00:00
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
private:
|
|
|
|
OSystem& myOSystem;
|
|
|
|
DialogContainer& myParent;
|
|
|
|
Dialog& myDialog;
|
2005-03-11 23:36:30 +00:00
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
protected:
|
2005-05-13 18:28:06 +00:00
|
|
|
int _x, _y;
|
|
|
|
int _w, _h;
|
2005-08-01 22:33:16 +00:00
|
|
|
bool _dirty;
|
|
|
|
|
2005-02-27 23:41:19 +00:00
|
|
|
Widget* _firstWidget;
|
2005-08-10 12:23:42 +00:00
|
|
|
WidgetArray _focusList;
|
2005-02-27 23:41:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|