8
8
// SS SS tt ee ll ll aa aa
9
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
11
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
13
13
// See the file "license" for information on usage and redistribution of
14
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: Widget.hxx,v 1.49 2006/03/25 00:34:17 stephena Exp $
16
// $Id: Widget.hxx,v 1.61 2008/05/11 21:18:35 stephena Exp $
18
18
// Based on code from ScummVM - Scumm Interpreter
19
19
// Copyright (C) 2002-2004 The ScummVM project
27
27
#include <assert.h>
29
#include "OSystem.hxx"
30
34
#include "FrameBuffer.hxx"
31
35
#include "GuiObject.hxx"
32
#include "GuiUtils.hxx"
36
#include "OSystem.hxx"
34
37
#include "Rect.hxx"
39
WIDGET_ENABLED = 1 << 0,
40
WIDGET_INVISIBLE = 1 << 1,
41
WIDGET_HILITED = 1 << 2,
42
WIDGET_BORDER = 1 << 3,
43
WIDGET_INV_BORDER = 1 << 4,
44
WIDGET_CLEARBG = 1 << 5,
45
WIDGET_TRACK_MOUSE = 1 << 6,
46
WIDGET_RETAIN_FOCUS = 1 << 7,
47
WIDGET_NODRAW_FOCUS = 1 << 8,
48
WIDGET_STICKY_FOCUS = 1 << 9,
49
WIDGET_WANTS_TAB = 1 << 10,
50
WIDGET_WANTS_EVENTS = 1 << 11
40
WIDGET_ENABLED = 1 << 0,
41
WIDGET_INVISIBLE = 1 << 1,
42
WIDGET_HILITED = 1 << 2,
43
WIDGET_BORDER = 1 << 3,
44
WIDGET_CLEARBG = 1 << 4,
45
WIDGET_TRACK_MOUSE = 1 << 5,
46
WIDGET_RETAIN_FOCUS = 1 << 6,
47
WIDGET_WANTS_TAB = 1 << 7,
48
WIDGET_WANTS_RAWDATA = 1 << 8
54
kStaticTextWidget = 'TEXT',
55
kEditTextWidget = 'EDIT',
56
kButtonWidget = 'BTTN',
57
kCheckboxWidget = 'CHKB',
58
kSliderWidget = 'SLDE',
60
kScrollBarWidget = 'SCRB',
61
kPopUpWidget = 'POPU',
63
kPromptWidget = 'PROM',
64
kDataGridWidget = 'BGRI',
65
kToggleWidget = 'TOGL',
52
kStaticTextWidget = 'TEXT',
53
kEditTextWidget = 'EDIT',
54
kButtonWidget = 'BTTN',
55
kCheckboxWidget = 'CHKB',
56
kSliderWidget = 'SLDE',
58
kScrollBarWidget = 'SCRB',
59
kPopUpWidget = 'POPU',
61
kEventMappingWidget = 'EVMP',
62
kEditableWidget = 'EDLE',
63
kAudioWidget = 'AUDW',
64
kColorWidget = 'COLR',
66
kDataGridOpsWidget = 'BGRO',
67
kDataGridWidget = 'BGRI',
68
kPromptWidget = 'PROM',
71
kRomListWidget = 'ROML',
73
kTiaInfoWidget = 'TIAI',
74
kTiaOutputWidget = 'TIAO',
76
kTiaZoomWidget = 'TIAZ',
77
kToggleBitWidget = 'TGLB',
78
kTogglePixelWidget = 'TGLP',
79
kToggleWidget = 'TOGL'
75
88
This is the base class for all widgets.
77
90
@author Stephen Anthony
78
@version $Id: Widget.hxx,v 1.49 2006/03/25 00:34:17 stephena Exp $
91
@version $Id: Widget.hxx,v 1.61 2008/05/11 21:18:35 stephena Exp $
80
93
class Widget : public GuiObject
100
113
virtual void handleJoyUp(int stick, int button) {}
101
114
virtual void handleJoyAxis(int stick, int axis, int value) {}
102
115
virtual bool handleJoyHat(int stick, int hat, int value) { return false; }
116
virtual bool handleEvent(Event::Type event) { return false; }
105
119
void receivedFocus();
116
129
void clearFlags(int flags) { _flags &= ~flags; }
117
130
int getFlags() const { return _flags; }
119
bool isEnabled() const { return _flags & WIDGET_ENABLED; }
120
bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); }
121
bool isSticky() const { return _flags & WIDGET_STICKY_FOCUS; }
122
bool wantsEvents() const { return _flags & WIDGET_WANTS_EVENTS; }
132
bool isEnabled() const { return _flags & WIDGET_ENABLED; }
133
bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); }
134
bool wantsFocus() const { return _flags & WIDGET_RETAIN_FOCUS; }
135
bool wantsTab() const { return _flags & WIDGET_WANTS_TAB; }
136
bool wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; }
124
138
void setID(int id) { _id = id; }
125
139
int getID() { return _id; }
127
void setColor(int color) { _color = color; }
128
141
virtual const GUI::Font* font() { return _font; }
143
void setTextColor(int color) { _textcolor = color; }
144
void setTextColorHi(int color) { _textcolorhi = color; }
145
void setBGColor(int color) { _bgcolor = color; }
146
void setBGColorHi(int color) { _bgcolorhi = color; }
130
148
virtual void loadConfig() {}
185
206
void setLabel(const string& label);
186
207
void setAlign(TextAlignment align) { _align = align; }
187
208
const string& getLabel() const { return _label; }
188
void setEditable(bool editable);
191
211
void drawWidget(bool hilite);
204
224
ButtonWidget(GuiObject* boss, const GUI::Font& font,
205
225
int x, int y, int w, int h,
206
const string& label, int cmd = 0, uInt8 hotkey = 0);
226
const string& label, int cmd = 0);
208
228
void setCmd(int cmd) { _cmd = cmd; }
209
229
int getCmd() const { return _cmd; }
211
void handleMouseUp(int x, int y, int button, int clickCount);
212
void handleMouseEntered(int button);
213
void handleMouseLeft(int button);
214
bool handleKeyDown(int ascii, int keycode, int modifiers);
215
void handleJoyDown(int stick, int button);
218
void setEditable(bool editable);
231
virtual void handleMouseUp(int x, int y, int button, int clickCount);
232
virtual void handleMouseEntered(int button);
233
virtual void handleMouseLeft(int button);
234
virtual bool handleEvent(Event::Type event);
221
237
void drawWidget(bool hilite);
237
251
void handleMouseUp(int x, int y, int button, int clickCount);
238
252
virtual void handleMouseEntered(int button) {}
239
253
virtual void handleMouseLeft(int button) {}
240
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
243
void holdFocus(bool status) { _holdFocus = status; }
245
255
void setEditable(bool editable);
246
256
void setFill(bool fill) { _fillRect = fill; }
277
286
SliderWidget(GuiObject *boss, const GUI::Font& font,
278
287
int x, int y, int w, int h, const string& label = "",
279
int labelWidth = 0, int cmd = 0, uInt8 hotkey = 0);
288
int labelWidth = 0, int cmd = 0);
281
290
void setValue(int value);
282
291
int getValue() const { return _value; }
284
void setMinValue(int value) { _valueMin = value; }
285
int getMinValue() const { return _valueMin; }
286
void setMaxValue(int value) { _valueMax = value; }
287
int getMaxValue() const { return _valueMax; }
293
void setMinValue(int value);
294
int getMinValue() const { return _valueMin; }
295
void setMaxValue(int value);
296
int getMaxValue() const { return _valueMax; }
297
void setStepValue(int value);
298
int getStepValue() const { return _stepValue; }
289
void handleMouseMoved(int x, int y, int button);
290
void handleMouseDown(int x, int y, int button, int clickCount);
291
void handleMouseUp(int x, int y, int button, int clickCount);
300
virtual void handleMouseMoved(int x, int y, int button);
301
virtual void handleMouseDown(int x, int y, int button, int clickCount);
302
virtual void handleMouseUp(int x, int y, int button, int clickCount);
303
virtual bool handleEvent(Event::Type event);
294
306
void drawWidget(bool hilite);