Huge GUI-related changes. The GUI in launcher/options/command modes

is now fully navigable via the keyboard be means of 'tab-like'
functionality.  This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).

Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key.  So widgets now respond to events, and events
can (eventually) be remapped to *any* device.

Currently, these UI events are as follows:
  UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
  UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect

At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc.  When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode.  So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.

Modified 'tab' key while in emulation mode to only enter the options
menu.  Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-05-04 17:45:25 +00:00
parent 6596cbe94b
commit e49e1f17e4
49 changed files with 854 additions and 875 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.cxx,v 1.9 2006-03-23 16:16:32 stephena Exp $
// $Id: CheatCodeDialog.cxx,v 1.10 2006-05-04 17:45:20 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -35,15 +35,6 @@
#include "bspf.hxx"
enum {
kAddCheatCmd = 'CHTa',
kEditCheatCmd = 'CHTe',
kAddOneShotCmd = 'CHTo',
kCheatAdded = 'CHad',
kCheatEdited = 'CHed',
kOneShotCheatAdded = 'CHoa',
kRemCheatCmd = 'CHTr'
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
@ -51,6 +42,8 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
: Dialog(osystem, parent, x, y, w, h)
{
int xpos, ypos;
WidgetArray wid;
ButtonWidget* b;
// List of cheats, with checkboxes to enable/disable
xpos = 10; ypos = 10;
@ -58,14 +51,17 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
_w - 25 - kButtonWidth, _h - 50);
myCheatList->setStyle(kXFill);
myCheatList->setEditable(false);
myCheatList->setFlags(WIDGET_NODRAW_FOCUS);
addFocusWidget(myCheatList);
wid.push_back(myCheatList);
xpos += myCheatList->getWidth() + 15; ypos = 15;
addButton(font, xpos, ypos, "Add", kAddCheatCmd, 0);
myEditButton = addButton(font, xpos, ypos+=20, "Edit", kEditCheatCmd, 0);
myRemoveButton = addButton(font, xpos, ypos+=20, "Remove", kRemCheatCmd, 0);
addButton(font, xpos, ypos+=30, "One shot", kAddOneShotCmd, 0);
b = addButton(font, xpos, ypos, "Add", kAddCheatCmd);
wid.push_back(b);
myEditButton = addButton(font, xpos, ypos+=20, "Edit", kEditCheatCmd);
wid.push_back(myEditButton);
myRemoveButton = addButton(font, xpos, ypos+=20, "Remove", kRemCheatCmd);
wid.push_back(myRemoveButton);
b = addButton(font, xpos, ypos+=30, "One shot", kAddOneShotCmd);
wid.push_back(b);
// Inputbox which will pop up when adding/editing a cheat
StringList labels;
@ -76,14 +72,20 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
// Add OK and Cancel buttons **** FIXME - coordinates
#ifndef MAC_OSX
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
myCancelButton = addButton(font, _w - (kButtonWidth + 10), _h - 24,
"Cancel", kCloseCmd, 0);
"Cancel", kCloseCmd);
wid.push_back(myCancelButton);
#else
myCancelButton = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24,
"Cancel", kCloseCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
"Cancel", kCloseCmd);
wid.push_back(myCancelButton);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -154,6 +156,7 @@ void CheatCodeDialog::editCheat()
myCheatInput->setEditString(name, 0);
myCheatInput->setEditString(code, 1);
myCheatInput->setTitle("");
myCheatInput->setFocus(1);
myCheatInput->setEmitSignal(kCheatEdited);
parent()->addDialog(myCheatInput);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.hxx,v 1.5 2006-02-22 17:38:03 stephena Exp $
// $Id: CheatCodeDialog.hxx,v 1.6 2006-05-04 17:45:21 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -63,6 +63,16 @@ class CheatCodeDialog : public Dialog
ButtonWidget* myEditButton;
ButtonWidget* myRemoveButton;
ButtonWidget* myCancelButton;
enum {
kAddCheatCmd = 'CHTa',
kEditCheatCmd = 'CHTe',
kAddOneShotCmd = 'CHTo',
kCheatAdded = 'CHad',
kCheatEdited = 'CHed',
kOneShotCheatAdded = 'CHoa',
kRemCheatCmd = 'CHTr'
};
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DataGridOpsWidget.cxx,v 1.3 2006-02-22 17:38:04 stephena Exp $
// $Id: DataGridOpsWidget.cxx,v 1.4 2006-05-04 17:45:23 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -42,32 +42,32 @@ DataGridOpsWidget::DataGridOpsWidget(GuiObject* boss, const GUI::Font& font,
// Create operations buttons
xpos = x; ypos = y;
_zeroButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"0", kDGZeroCmd, 0);
"0", kDGZeroCmd);
ypos += bheight + space;
_invButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Inv", kDGInvertCmd, 0);
"Inv", kDGInvertCmd);
ypos += bheight + space;
_incButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"++", kDGIncCmd, 0);
"++", kDGIncCmd);
ypos += bheight + space;
_shiftLeftButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"<<", kDGShiftLCmd, 0);
"<<", kDGShiftLCmd);
// Move to next column, skip a row
xpos = x + bwidth + space; ypos = y + bheight + space;
_negButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Neg", kDGNegateCmd, 0);
"Neg", kDGNegateCmd);
ypos += bheight + space;
_decButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"--", kDGDecCmd, 0);
"--", kDGDecCmd);
ypos += bheight + space;
_shiftRightButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
">>", kDGShiftRCmd, 0);
">>", kDGShiftRCmd);
// Calculate real dimensions
_w = xpos + bwidth;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DataGridWidget.cxx,v 1.7 2006-03-25 00:34:17 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.8 2006-05-04 17:45:23 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -45,7 +45,8 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
_selectedItem(0),
_opsWidget(NULL)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_RAWDATA;
_type = kDataGridWidget;
_editMode = false;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerDialog.cxx,v 1.13 2006-03-23 16:16:32 stephena Exp $
// $Id: DebuggerDialog.cxx,v 1.14 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -211,6 +211,7 @@ void DebuggerDialog::addStatusArea()
xpos, ypos, myTiaZoom->getWidth(),
font.getLineHeight(), "");
myMessageBox->setEditable(false);
myMessageBox->clearFlags(WIDGET_RETAIN_FOCUS);
myMessageBox->setColor(kTextColorEm);
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptWidget.cxx,v 1.8 2006-03-25 00:34:17 stephena Exp $
// $Id: PromptWidget.cxx,v 1.9 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -52,7 +52,7 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
_firstTime(true)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_TAB;
WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA;
_type = kPromptWidget;
_kConsoleCharWidth = font.getMaxCharWidth();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RamWidget.cxx,v 1.5 2006-03-29 13:53:00 stephena Exp $
// $Id: RamWidget.cxx,v 1.6 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -66,27 +66,27 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Create actions buttons to the left of the RAM grid
xpos += lwidth + myRamGrid->getWidth() + 4;
myUndoButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Undo", kUndoCmd, 0);
"Undo", kUndoCmd);
myUndoButton->setTarget(this);
ypos += bheight + 4;
myRevertButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Rev", kRevertCmd, 0);
"Rev", kRevertCmd);
myRevertButton->setTarget(this);
ypos += 2 * bheight + 2;
mySearchButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Srch", kSearchCmd, 0);
"Srch", kSearchCmd);
mySearchButton->setTarget(this);
ypos += bheight + 4;
myCompareButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Cmp", kCmpCmd, 0);
"Cmp", kCmpCmd);
myCompareButton->setTarget(this);
ypos += bheight + 4;
myRestartButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Rset", kRestartCmd, 0);
"Rset", kRestartCmd);
myRestartButton->setTarget(this);
// Labels for RAM grid

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RomListWidget.cxx,v 1.5 2006-02-22 17:38:04 stephena Exp $
// $Id: RomListWidget.cxx,v 1.6 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -71,6 +71,12 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
ListWidget::handleMouseDown(x, y, button, clickCount);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RomListWidget::handleEvent(Event::Type e)
{
return ListWidget::handleEvent(e); // override CheckListWidget::handleEvent()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::drawWidget(bool hilite)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RomListWidget.hxx,v 1.4 2005-09-07 18:34:52 stephena Exp $
// $Id: RomListWidget.hxx,v 1.5 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -43,6 +43,7 @@ class RomListWidget : public CheckListWidget
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleEvent(Event::Type e);
void drawWidget(bool hilite);
GUI::Rect getLineRect() const;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TiaZoomWidget.cxx,v 1.7 2006-03-25 00:34:17 stephena Exp $
// $Id: TiaZoomWidget.cxx,v 1.8 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,7 +34,8 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font,
CommandSender(boss),
myMenu(NULL)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_RAWDATA;
_w = 210;
_h = 120;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ToggleWidget.cxx,v 1.3 2006-02-22 17:38:04 stephena Exp $
// $Id: ToggleWidget.cxx,v 1.4 2006-05-04 17:45:24 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,7 +34,8 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font,
_currentCol(0),
_selectedItem(0)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_RAWDATA;
_type = kToggleWidget;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Event.hxx,v 1.19 2006-01-05 18:53:22 stephena Exp $
// $Id: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $
//============================================================================
#ifndef EVENT_HXX
@ -26,7 +26,7 @@ class EventStreamer;
/**
@author Bradford W. Mott
@version $Id: Event.hxx,v 1.19 2006-01-05 18:53:22 stephena Exp $
@version $Id: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $
*/
class Event
{
@ -34,7 +34,7 @@ class Event
/**
Enumeration of all possible events in Stella, including both
console and controller event types as well as events that aren't
technically part of the core
technically part of the emulation core
*/
enum Type
{
@ -80,6 +80,9 @@ class Event
MenuMode, CmdMenuMode, DebuggerMode, LauncherMode, Fry,
VolumeDecrease, VolumeIncrease,
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect,
LastType
};

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.cxx,v 1.160 2006-04-05 12:28:37 stephena Exp $
// $Id: EventHandler.cxx,v 1.161 2006-05-04 17:45:24 stephena Exp $
//============================================================================
#include <sstream>
@ -187,11 +187,6 @@ void EventHandler::reset(State state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::refreshDisplay(bool forceUpdate)
{
// These are reset each time the display changes size
DialogContainer::ourJoyMouse.x_max = myOSystem->frameBuffer().imageWidth();
DialogContainer::ourJoyMouse.y_max = myOSystem->frameBuffer().imageHeight();
DialogContainer::ourJoyMouse.amt = myOSystem->frameBuffer().zoomLevel() * 3;
switch(myState)
{
case S_EMULATE:
@ -863,9 +858,6 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
{
// Take window zooming into account
int x = event.motion.x, y = event.motion.y;
DialogContainer::ourJoyMouse.x = x;
DialogContainer::ourJoyMouse.y = y;
myOSystem->frameBuffer().translateCoords(&x, &y);
// Determine which mode we're in, then send the event to the appropriate place
@ -1223,8 +1215,8 @@ bool EventHandler::eventStateChange(Event::Type type)
{
if(myState == S_EMULATE)
enterMenuMode(S_MENU);
else if(myState == S_MENU)
leaveMenuMode();
// else if(myState == S_MENU) // FIXME - maybe 'tab' should only enter, not exit
// leaveMenuMode();
else
handled = false;
}
@ -1856,6 +1848,79 @@ inline bool EventHandler::eventIsAnalog(Event::Type event)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForKey(int key, EventMode mode)
{
// FIXME - eventually make this a one-line inliner in the header
Event::Type e = Event::NoType;
// FIXME - eventually this will return the mapped events for
// keys either for emulation mode or UI mode. For now, it always
// assumes UI mode, and generates the key statically.
if(key < 0 || key >= SDLK_LAST)
return e;
switch(key)
{
case '\n': // enter/return
case '\r':
e = Event::UISelect;
break;
case 256+17: // cursor up
e = Event::UIUp;
break;
case 256+18: // cursor down
e = Event::UIDown;
break;
case 256+20: // cursor left
e = Event::UILeft;
break;
case 256+19: // cursor right
e = Event::UIRight;
break;
case 256+24: // Page Up:
e = Event::UIPgUp;
break;
case 256+25: // Page Down
e = Event::UIPgDown;
break;
case 256+22: // Home
e = Event::UIHome;
break;
case 256+23: // End
e = Event::UIEnd;
break;
default:
break;
}
return e; // ... myKeyTable[key];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyButton(int stick, int button,
EventMode mode)
{
// FIXME - do a lookup
return Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyAxis(int stick, int axis, int value,
EventMode mode)
{
// FIXME - do a lookup
return Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyHat(int stick, int hat, int value,
EventMode mode)
{
// FIXME - do a lookup
return Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline bool EventHandler::isJitter(int paddle, int value)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.hxx,v 1.85 2006-04-05 12:28:37 stephena Exp $
// $Id: EventHandler.hxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -64,6 +64,11 @@ enum {
kActionListSize = 81
};
enum EventMode {
kEmulation,
kMenuOverlay
};
// Joystick related items
enum {
kNumJoysticks = 8,
@ -107,7 +112,7 @@ struct JoyMouse {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.85 2006-04-05 12:28:37 stephena Exp $
@version $Id: EventHandler.hxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
*/
class EventHandler
{
@ -328,6 +333,11 @@ class EventHandler
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
Event::Type eventForKey(int key, EventMode mode);
Event::Type eventForJoyButton(int stick, int button, EventMode mode);
Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode);
Event::Type eventForJoyHat(int stick, int hat, int value, EventMode mode);
private:
/**
Bind a key to an event/action and regenerate the mapping array(s)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.cxx,v 1.85 2006-03-25 00:34:17 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
//============================================================================
#include <sstream>
@ -608,7 +608,7 @@ void FrameBuffer::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
break;
case kDashLine:
unsigned int i, skip, lwidth = 1;
unsigned int i, skip, lwidth = 0;
for(i = x, skip = 1; i < x+w-1; i=i+lwidth+1, ++skip)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: AboutDialog.cxx,v 1.12 2006-04-05 16:06:59 stephena Exp $
// $Id: AboutDialog.cxx,v 1.13 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,12 +36,20 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent,
myPage(1),
myNumPages(6)
{
WidgetArray wid;
// Add Previous, Next and Close buttons
myPrevButton = addButton(font, 10, h - 24, "Previous", kPrevCmd, 'P');
myNextButton = addButton(font, (kButtonWidth + 15), h - 24,
"Next", kNextCmd, 'N');
addButton(font, w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C');
myPrevButton = addButton(font, 10, h - 24, "Previous", kPrevCmd);
myPrevButton->clearFlags(WIDGET_ENABLED);
wid.push_back(myPrevButton);
myNextButton = addButton(font, (kButtonWidth + 15), h - 24,
"Next", kNextCmd);
wid.push_back(myNextButton);
ButtonWidget* b = addButton(font, w - (kButtonWidth + 10), h - 24,
"Close", kCloseCmd);
wid.push_back(b);
myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(),
"", kTextAlignCenter);
@ -52,6 +60,8 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent,
myDesc[i] = new StaticTextWidget(this, font, 10, 18 + (10 * i), w - 20,
font.getFontHeight(), "", kTextAlignLeft);
}
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: AudioDialog.cxx,v 1.18 2006-02-22 17:38:04 stephena Exp $
// $Id: AudioDialog.cxx,v 1.19 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -44,6 +44,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
int xpos, ypos;
int lwidth = font.getStringWidth("Fragment Size: "),
pwidth = font.getStringWidth("4096");
WidgetArray wid;
// Volume
xpos = (w - lwidth - pwidth - 40) / 2; ypos = 10;
@ -51,6 +52,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
myVolumeSlider = new SliderWidget(this, font, xpos, ypos, 30, lineHeight,
"Volume: ", lwidth, kVolumeChanged);
myVolumeSlider->setMinValue(1); myVolumeSlider->setMaxValue(100);
wid.push_back(myVolumeSlider);
myVolumeLabel = new StaticTextWidget(this, font,
xpos + myVolumeSlider->getWidth() + 4,
ypos + 1,
@ -68,27 +70,38 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
myFragsizePopup->appendEntry("1024", 3);
myFragsizePopup->appendEntry("2048", 4);
myFragsizePopup->appendEntry("4096", 5);
wid.push_back(myFragsizePopup);
ypos += lineHeight + 4;
// Stereo sound
mySoundTypeCheckbox = new CheckboxWidget(this, font, xpos+28, ypos,
"Stereo mode", 0);
wid.push_back(mySoundTypeCheckbox);
ypos += lineHeight + 4;
// Enable sound
mySoundEnableCheckbox = new CheckboxWidget(this, font, xpos+28, ypos,
"Enable sound", kSoundEnableChanged);
wid.push_back(mySoundEnableCheckbox);
ypos += lineHeight + 12;
// Add Defaults, OK and Cancel buttons
addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd, 0);
ButtonWidget* b;
b = addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd);
wid.push_back(b);
#ifndef MAC_OSX
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
#else
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: BrowserDialog.cxx,v 1.18 2006-03-20 13:23:13 stephena Exp $
// $Id: BrowserDialog.cxx,v 1.19 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -49,6 +49,7 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
bwidth = font.getStringWidth("Cancel") + 20,
bheight = font.getLineHeight() + 4;
int xpos, ypos;
ButtonWidget* b;
xpos = 10; ypos = 4;
_title = new StaticTextWidget(this, font, xpos, ypos,
@ -67,28 +68,33 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
_w - 2 * xpos, _h - bheight - ypos - 15);
_fileList->setNumberingMode(kListNumberingOff);
_fileList->setEditable(false);
_fileList->setFlags(WIDGET_NODRAW_FOCUS);
addFocusWidget(_fileList);
// Buttons
xpos = 10; ypos = _h - bheight - 8;
_goUpButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Go up", kGoUpCmd, 0);
b = _goUpButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Go up", kGoUpCmd);
addFocusWidget(b);
#ifndef MAC_OSX
xpos = _w - 2 *(bwidth + 10);
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Choose",
kChooseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Choose",
kChooseCmd);
addFocusWidget(b);
xpos += bwidth + 10;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd);
addFocusWidget(b);
#else
xpos = _w - 2 *(bwidth + 10); ypos = _h - bheight - 8;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd);
addFocusWidget(b);
xpos += bwidth + 10;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Choose",
kChooseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Choose",
kChooseCmd);
addFocusWidget(b);
#endif
addFocusWidget(_fileList);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheckListWidget.cxx,v 1.10 2006-02-22 17:38:04 stephena Exp $
// $Id: CheckListWidget.cxx,v 1.11 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -41,7 +41,6 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
t = new CheckboxWidget(boss, font, _x + 2, ypos, "", kCheckActionCmd);
t->setTarget(this);
t->setID(i);
t->holdFocus(false);
ypos += _fontHeight;
_checkList.push_back(t);
@ -190,6 +189,23 @@ bool CheckListWidget::getState(int line)
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckListWidget::handleEvent(Event::Type e)
{
switch(e)
{
case Event::UISelect:
// Simulate a mouse button click
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, 1, 0);
return true;
break;
default:
return ListWidget::handleEvent(e);
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::handleCommand(CommandSender* sender, int cmd,
int data, int id)
@ -209,5 +225,6 @@ void CheckListWidget::handleCommand(CommandSender* sender, int cmd,
default:
ListWidget::handleCommand(sender, cmd, data, id);
break;
}
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheckListWidget.hxx,v 1.8 2005-12-09 01:16:13 stephena Exp $
// $Id: CheckListWidget.hxx,v 1.9 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -54,6 +54,7 @@ class CheckListWidget : public ListWidget
bool getState(int line);
bool getSelectedState() { return getState(_selectedItem); }
bool handleEvent(Event::Type e);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
protected:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CommandDialog.cxx,v 1.8 2006-02-22 17:38:04 stephena Exp $
// $Id: CommandDialog.cxx,v 1.9 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -49,89 +49,73 @@ CommandDialog::CommandDialog(OSystem* osystem, DialogContainer* parent)
ButtonWidget* b;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Select", kSelectCmd, 0);
b->setEditable(true);
"Select", kSelectCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Reset", kResetCmd, 0);
b->setEditable(true);
"Reset", kResetCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Color TV", kColorCmd, 0);
b->setEditable(true);
"Color TV", kColorCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"B/W TV", kBWCmd, 0);
b->setEditable(true);
"B/W TV", kBWCmd);
wid.push_back(b);
xoffset = 5; yoffset += buttonHeight + 5;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Left Diff A", kLeftDiffACmd, 0);
b->setEditable(true);
"Left Diff A", kLeftDiffACmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Left Diff B", kLeftDiffBCmd, 0);
b->setEditable(true);
"Left Diff B", kLeftDiffBCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Right Diff A", kRightDiffACmd, 0);
b->setEditable(true);
"Right Diff A", kRightDiffACmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Right Diff B", kRightDiffBCmd, 0);
b->setEditable(true);
"Right Diff B", kRightDiffBCmd);
wid.push_back(b);
xoffset = 5; yoffset += buttonHeight + 5;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Save State", kSaveStateCmd, 0);
b->setEditable(true);
"Save State", kSaveStateCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"State Slot", kStateSlotCmd, 0);
b->setEditable(true);
"State Slot", kStateSlotCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Load State", kLoadStateCmd, 0);
b->setEditable(true);
"Load State", kLoadStateCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Snapshot", kSnapshotCmd, 0);
b->setEditable(true);
"Snapshot", kSnapshotCmd);
wid.push_back(b);
xoffset = 5; yoffset += buttonHeight + 5;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"NTSC/PAL", kFormatCmd, 0);
b->setEditable(true);
"NTSC/PAL", kFormatCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Palette", kPaletteCmd, 0);
b->setEditable(true);
"Palette", kPaletteCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Reload ROM", kReloadRomCmd, 0);
b->setEditable(true);
"Reload ROM", kReloadRomCmd);
wid.push_back(b);
xoffset += lwidth;
b = new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight,
"Exit Game", kExitCmd, 0);
b->setEditable(true);
"Exit Game", kExitCmd);
wid.push_back(b);
addToFocusList(wid);
@ -142,100 +126,6 @@ CommandDialog::~CommandDialog()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{
bool handled = true;
int row = mySelectedItem / kNumRows,
col = mySelectedItem - (row * kNumCols);
// Only detect the cursor keys, otherwise pass to base class
switch(ascii)
{
case kCursorUp:
if (row > 0)
--row;
else if(col > 0)
{
row = kNumRows - 1;
--col;
}
break;
case kCursorDown:
if (row < kNumRows - 1)
++row;
else if(col < kNumCols - 1)
{
row = 0;
++col;
}
break;
case kCursorLeft:
if (col > 0)
--col;
else if(row > 0)
{
col = kNumCols - 1;
--row;
}
break;
case kCursorRight:
if (col < kNumCols - 1)
++col;
else if(row < kNumRows - 1)
{
col = 0;
++row;
}
break;
default:
handled = false;
break;
}
if(handled)
{
mySelectedItem = row * kNumCols + col;
Dialog::setFocus(getFocusList()[mySelectedItem]);
}
else
Dialog::handleKeyDown(ascii, keycode, modifiers);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::handleJoyAxis(int stick, int axis, int value)
{
if(!parent()->joymouse())
return;
// We make the (hopefully) valid assumption that all joysticks
// treat axis the same way. Eventually, we may need to remap
// these actions of this assumption is invalid.
// TODO - make this work better with analog axes ...
int key = -1;
if(axis % 2 == 0) // x-direction
{
if(value < 0)
key = kCursorLeft;
else if(value > 0)
key = kCursorRight;
}
else // y-direction
{
if(value < 0)
key = kCursorUp;
else if(value > 0)
key = kCursorDown;
}
if(key != -1)
handleKeyDown(key, 0, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CommandDialog.hxx,v 1.4 2006-01-04 01:24:17 stephena Exp $
// $Id: CommandDialog.hxx,v 1.5 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,12 +36,8 @@ class CommandDialog : public Dialog
~CommandDialog();
protected:
virtual void handleKeyDown(int ascii, int keycode, int modifiers);
virtual void handleJoyAxis(int stick, int axis, int value);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual bool wantsEvents() { return true; }
private:
int mySelectedItem;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Dialog.cxx,v 1.43 2006-03-02 13:10:53 stephena Exp $
// $Id: Dialog.cxx,v 1.44 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -98,6 +98,10 @@ void Dialog::releaseFocus()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::addFocusWidget(Widget* w)
{
// All focusable widgets should retain focus
if(w)
w->setFlags(WIDGET_RETAIN_FOCUS);
if(_ourFocusList.size() == 0)
{
Focus f;
@ -111,6 +115,10 @@ void Dialog::addFocusWidget(Widget* w)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::addToFocusList(WidgetArray& list, int id)
{
// All focusable widgets should retain focus
for(unsigned int i = 0; i < list.size(); ++i)
list[i]->setFlags(WIDGET_RETAIN_FOCUS);
id++; // Arrays start at 0, not -1.
// Make sure the array is large enough
@ -125,7 +133,7 @@ void Dialog::addToFocusList(WidgetArray& list, int id)
if(id == 0 && _ourFocusList.size() > 0)
_focusList = _ourFocusList[0].focusList;
if(list.size() > 0 && !(list[0]->getFlags() & WIDGET_NODRAW_FOCUS))
if(list.size() > 0)
_ourFocusList[id].focusedWidget = list[0];
}
@ -186,12 +194,6 @@ void Dialog::redrawFocus()
_focusedWidget = Widget::setFocusForChain(this, getFocusList(), _focusedWidget, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::wantsEvents()
{
return _focusedWidget && _focusedWidget->wantsEvents();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::draw()
{
@ -290,41 +292,79 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
// Shift-left/shift-right cursor selects next tab
// Tab sets next widget in current tab
// Shift-Tab sets previous widget in current tab
//
// Widgets are only cycled if currently focused key hasn't claimed
// the TAB key
// TODO - figure out workaround for this
if(_ourTab && instance()->eventHandler().kbdShift(modifiers))
{
// these key-combos are never passed to the child widget
if(ascii == 256 + 20) // left arrow
{
_ourTab->cycleTab(-1);
return;
}
else if(ascii == 256 + 19) // right arrow
{
_ourTab->cycleTab(+1);
return;
}
}
Event::Type e = Event::NoType;
if(keycode == 9) // tab key
// Detect selection of previous and next tab headers and objects
// For some strange reason, 'tab' needs to be interpreted as keycode,
// not ascii??
if(instance()->eventHandler().kbdShift(modifiers))
{
if(_focusedWidget && !(_focusedWidget->getFlags() & WIDGET_WANTS_TAB))
{
if(instance()->eventHandler().kbdShift(modifiers))
if(ascii == 256+20) // left arrow
e = Event::UITabPrev;
else if(ascii == 256+19) // right arrow
e = Event::UITabNext;
else if(keycode == 9) // tab
e = Event::UINavPrev;
}
else if(keycode == 9) // tab
e = Event::UINavNext;
// Check the keytable now, since we might get one of the above events,
// which must always be processed before any widget sees it.
bool handled = false;
if(e == Event::NoType)
e = instance()->eventHandler().eventForKey(ascii, kMenuOverlay);
switch(e)
{
case Event::UITabPrev:
if(_ourTab)
{
_ourTab->cycleTab(-1);
handled = true;
}
break;
case Event::UITabNext:
if(_ourTab)
{
_ourTab->cycleTab(+1);
handled = true;
}
break;
case Event::UINavPrev:
if(_focusedWidget && !_focusedWidget->wantsTab())
{
_focusedWidget = Widget::setFocusForChain(this, getFocusList(),
_focusedWidget, -1);
else
handled = true;
}
break;
case Event::UINavNext:
if(_focusedWidget && !_focusedWidget->wantsTab())
{
_focusedWidget = Widget::setFocusForChain(this, getFocusList(),
_focusedWidget, +1);
return; // this key-combo is never passed to the child widget
}
handled = true;
}
break;
default:
handled = false;
break;
}
if (_focusedWidget)
_focusedWidget->handleKeyDown(ascii, keycode, modifiers);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
if(!handled && _focusedWidget)
{
if(_focusedWidget->wantsRaw() || e == Event::NoType)
_focusedWidget->handleKeyDown(ascii, keycode, modifiers);
else
_focusedWidget->handleEvent(e);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -388,9 +428,18 @@ void Dialog::handleMouseMoved(int x, int y, int button)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleJoyDown(int stick, int button)
{
// Focused widget receives joystick events
if(_focusedWidget)
_focusedWidget->handleJoyDown(stick, button);
Event::Type e = Event::NoType; // FIXME - do a lookup
bool handled = false; // isNavigation(e);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
if(!handled && _focusedWidget)
{
if(_focusedWidget->wantsRaw() || e == Event::NoType)
_focusedWidget->handleJoyDown(stick, button);
else
_focusedWidget->handleEvent(e);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -404,16 +453,36 @@ void Dialog::handleJoyUp(int stick, int button)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleJoyAxis(int stick, int axis, int value)
{
// Focused widget receives joystick events
if(_focusedWidget)
_focusedWidget->handleJoyAxis(stick, axis, value);
Event::Type e = Event::NoType; // FIXME - do a lookup
bool handled = false; // isNavigation(e);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
if(!handled && _focusedWidget)
{
if(_focusedWidget->wantsRaw() || e == Event::NoType)
_focusedWidget->handleJoyAxis(stick, axis, value);
else
_focusedWidget->handleEvent(e);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::handleJoyHat(int stick, int hat, int value)
{
// Focused widget receives joystick events
return (_focusedWidget && _focusedWidget->handleJoyHat(stick, hat, value));
Event::Type e = Event::NoType; // FIXME - do a lookup
bool handled = false; // isNavigation(e);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
if(!handled && _focusedWidget)
{
if(_focusedWidget->wantsRaw() || e == Event::NoType)
return _focusedWidget->handleJoyHat(stick, hat, value);
else
return _focusedWidget->handleEvent(e);
}
return handled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -444,14 +513,14 @@ Widget* Dialog::findWidget(int x, int y)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget* Dialog::addButton(const GUI::Font& font, int x, int y,
const string& label, int cmd, char hotkey)
const string& label, int cmd)
{
#if 0
const int w = 6 * font.getMaxCharWidth(),
h = font.getFontHeight() + 6;
return new ButtonWidget(this, font, x, y, w, h, label, cmd, hotkey);
return new ButtonWidget(this, font, x, y, w, h, label, cmd);
#else
return new ButtonWidget(this, font, x, y, kButtonWidth, 16, label, cmd, hotkey);
return new ButtonWidget(this, font, x, y, kButtonWidth, 16, label, cmd);
#endif
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Dialog.hxx,v 1.28 2006-03-02 13:10:53 stephena Exp $
// $Id: Dialog.hxx,v 1.29 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,7 +36,7 @@ class TabWidget;
This is the base class for all dialog boxes.
@author Stephen Anthony
@version $Id: Dialog.hxx,v 1.28 2006-03-02 13:10:53 stephena Exp $
@version $Id: Dialog.hxx,v 1.29 2006-05-04 17:45:25 stephena Exp $
*/
class Dialog : public GuiObject
{
@ -86,13 +86,10 @@ class Dialog : public GuiObject
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual void handleScreenChanged() {}
/** The dialog wants all events */
virtual bool wantsEvents();
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
ButtonWidget* addButton(const GUI::Font& font, int x, int y,
const string& label = "", int cmd = 0, char hotkey = 0);
const string& label = "", int cmd = 0);
void setResult(int result) { _result = result; }
int getResult() const { return _result; }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DialogContainer.cxx,v 1.31 2006-03-02 13:10:53 stephena Exp $
// $Id: DialogContainer.cxx,v 1.32 2006-05-04 17:45:25 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -32,10 +32,6 @@ DialogContainer::DialogContainer(OSystem* osystem)
myTime(0),
myRefreshFlag(false)
{
memset(&ourJoyMouse, 0, sizeof(JoyMouse));
ourJoyMouse.delay_time = 25;
ourEnableJoyMouseFlag = myOSystem->settings().getBool("joymouse");
reset();
}
@ -73,6 +69,7 @@ void DialogContainer::updateTime(uInt32 time)
myClickRepeatTime = myTime + kClickRepeatSustainDelay;
}
/* FIXME - make this similar to the key-repeat code above
if(ourEnableJoyMouseFlag && myCurrentAxisDown.stick != -1 &&
myAxisRepeatTime < myTime)
{
@ -98,10 +95,7 @@ void DialogContainer::updateTime(uInt32 time)
myAxisRepeatTime = myTime + kAxisRepeatSustainDelay / interval;
}
}
// Update joy to mouse events
if(ourEnableJoyMouseFlag)
handleJoyMouse(time);
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -277,16 +271,10 @@ void DialogContainer::handleJoyEvent(int stick, int button, uInt8 state)
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
if(activeDialog->wantsEvents())
{
if(state == 1)
activeDialog->handleJoyDown(stick, button);
else
activeDialog->handleJoyUp(stick, button);
}
else if(ourEnableJoyMouseFlag)
myOSystem->eventHandler().createMouseButtonEvent(
ourJoyMouse.x, ourJoyMouse.y, state);
if(state == 1)
activeDialog->handleJoyDown(stick, button);
else
activeDialog->handleJoyUp(stick, button);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -305,57 +293,21 @@ void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value)
else
value = 0;
if(activeDialog->wantsEvents())
// Only stop firing events if it's the current stick
if(myCurrentAxisDown.stick == stick && value == 0)
{
// Only stop firing events if it's the current key
if(myCurrentAxisDown.stick == stick && value == 0)
{
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
myCurrentAxisDown.count = 0;
}
else
{
// Now account for repeated axis events (press and hold)
myCurrentAxisDown.stick = stick;
myCurrentAxisDown.axis = axis;
myCurrentAxisDown.value = value;
myAxisRepeatTime = myTime + kAxisRepeatInitialDelay;
}
activeDialog->handleJoyAxis(stick, axis, value);
}
else
{
if(axis % 2 == 0) // x-direction
{
if(value != 0)
{
ourJoyMouse.x_vel = (value > 0) ? 1 : -1;
ourJoyMouse.x_down_count = 1;
}
else
{
ourJoyMouse.x_vel = 0;
ourJoyMouse.x_down_count = 0;
}
}
else // y-direction
{
value = -value;
if(value != 0)
{
ourJoyMouse.y_vel = (-value > 0) ? 1 : -1;
ourJoyMouse.y_down_count = 1;
}
else
{
ourJoyMouse.y_vel = 0;
ourJoyMouse.y_down_count = 0;
}
}
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
myCurrentAxisDown.count = 0;
}
else
{
// Now account for repeated axis events (press and hold)
myCurrentAxisDown.stick = stick;
myCurrentAxisDown.axis = axis;
myCurrentAxisDown.value = value;
myAxisRepeatTime = myTime + kAxisRepeatInitialDelay;
}
activeDialog->handleJoyAxis(stick, axis, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -367,126 +319,8 @@ void DialogContainer::handleJoyHatEvent(int stick, int hat, int value)
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
if(!(activeDialog->wantsEvents() &&
activeDialog->handleJoyHat(stick, hat, value)))
{
bool handled = true;
switch(value)
{
case kJHatCentered:
handleJoyAxisEvent(stick, 0, 0);
handleJoyAxisEvent(stick, 1, 0); // axis 0 & 1, 0 ==> OFF
break;
case kJHatUp:
handleJoyAxisEvent(stick, 1, -32767); // axis 1, -value ==> UP
break;
case kJHatLeft:
handleJoyAxisEvent(stick, 0, -32767); // axis 0, -value ==> LEFT
break;
case kJHatDown:
handleJoyAxisEvent(stick, 1, 32767); // axis 1, +value ==> DOWN
break;
case kJHatRight:
handleJoyAxisEvent(stick, 0, 32767); // axis 0, +value ==> RIGHT
break;
default:
handled = false;
}
if(handled)
return;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::handleJoyMouse(uInt32 time)
{
bool mouseAccel = true;//false; // TODO - make this a commandline option
int oldX = ourJoyMouse.x, oldY = ourJoyMouse.y;
if(time >= ourJoyMouse.last_time + ourJoyMouse.delay_time)
{
ourJoyMouse.last_time = time;
if(ourJoyMouse.x_down_count == 1)
{
ourJoyMouse.x_down_time = time;
ourJoyMouse.x_down_count = 2;
}
if(ourJoyMouse.y_down_count == 1)
{
ourJoyMouse.y_down_time = time;
ourJoyMouse.y_down_count = 2;
}
if(ourJoyMouse.x_vel || ourJoyMouse.y_vel)
{
if(ourJoyMouse.x_down_count)
{
if(mouseAccel && time > ourJoyMouse.x_down_time + ourJoyMouse.delay_time * 12)
{
if(ourJoyMouse.x_vel > 0)
ourJoyMouse.x_vel++;
else
ourJoyMouse.x_vel--;
}
else if(time > ourJoyMouse.x_down_time + ourJoyMouse.delay_time * 8)
{
if(ourJoyMouse.x_vel > 0)
ourJoyMouse.x_vel = ourJoyMouse.amt;
else
ourJoyMouse.x_vel = -ourJoyMouse.amt;
}
}
if(ourJoyMouse.y_down_count)
{
if(mouseAccel && time > ourJoyMouse.y_down_time + ourJoyMouse.delay_time * 12)
{
if(ourJoyMouse.y_vel > 0)
ourJoyMouse.y_vel++;
else
ourJoyMouse.y_vel--;
}
else if(time > ourJoyMouse.y_down_time + ourJoyMouse.delay_time * 8)
{
if(ourJoyMouse.y_vel > 0)
ourJoyMouse.y_vel = ourJoyMouse.amt;
else
ourJoyMouse.y_vel = -ourJoyMouse.amt;
}
}
ourJoyMouse.x += ourJoyMouse.x_vel;
ourJoyMouse.y += ourJoyMouse.y_vel;
if(ourJoyMouse.x < 0)
{
ourJoyMouse.x = 0;
ourJoyMouse.x_vel = -1;
ourJoyMouse.x_down_count = 1;
}
else if(ourJoyMouse.x > ourJoyMouse.x_max)
{
ourJoyMouse.x = ourJoyMouse.x_max;
ourJoyMouse.x_vel = 1;
ourJoyMouse.x_down_count = 1;
}
if(ourJoyMouse.y < 0)
{
ourJoyMouse.y = 0;
ourJoyMouse.y_vel = -1;
ourJoyMouse.y_down_count = 1;
}
else if(ourJoyMouse.y > ourJoyMouse.y_max)
{
ourJoyMouse.y = ourJoyMouse.y_max;
ourJoyMouse.y_vel = 1;
ourJoyMouse.y_down_count = 1;
}
if(oldX != ourJoyMouse.x || oldY != ourJoyMouse.y)
myOSystem->eventHandler().createMouseMotionEvent(ourJoyMouse.x, ourJoyMouse.y);
}
}
// FIXME - add speedup processing, similar to axis events
activeDialog->handleJoyHat(stick, hat, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -500,19 +334,4 @@ void DialogContainer::reset()
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
myCurrentAxisDown.count = 0;
int oldX = ourJoyMouse.x, oldY = ourJoyMouse.y;
if(ourJoyMouse.x > ourJoyMouse.x_max)
ourJoyMouse.x = ourJoyMouse.x_max;
if(ourJoyMouse.y > ourJoyMouse.y_max)
ourJoyMouse.y = ourJoyMouse.y_max;
if(oldX != ourJoyMouse.x || oldY != ourJoyMouse.y)
myOSystem->eventHandler().createMouseMotionEvent(ourJoyMouse.x, ourJoyMouse.y);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DialogContainer::ourEnableJoyMouseFlag;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
JoyMouse DialogContainer::ourJoyMouse;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DialogContainer.hxx,v 1.16 2006-01-09 16:50:01 stephena Exp $
// $Id: DialogContainer.hxx,v 1.17 2006-05-04 17:45:25 stephena Exp $
//============================================================================
#ifndef DIALOG_CONTAINER_HXX
@ -37,7 +37,7 @@ typedef FixedStack<Dialog *> DialogStack;
a stack, and handles their events.
@author Stephen Anthony
@version $Id: DialogContainer.hxx,v 1.16 2006-01-09 16:50:01 stephena Exp $
@version $Id: DialogContainer.hxx,v 1.17 2006-05-04 17:45:25 stephena Exp $
*/
class DialogContainer
{
@ -150,13 +150,7 @@ class DialogContainer
*/
virtual void initialize() = 0;
/**
Whether joymouse emulation is enabled
*/
static bool joymouse() { return ourEnableJoyMouseFlag; }
private:
void handleJoyMouse(uInt32);
void reset();
protected:
@ -211,12 +205,6 @@ class DialogContainer
uInt32 time; // Time
int count; // How often was it already pressed?
} myLastClick;
// Whether to enable joymouse emulation
static bool ourEnableJoyMouseFlag;
// Emulation of mouse using joystick axis events
static JoyMouse ourJoyMouse;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EditTextWidget.cxx,v 1.14 2006-02-22 17:38:04 stephena Exp $
// $Id: EditTextWidget.cxx,v 1.15 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,6 +34,7 @@ EditTextWidget::EditTextWidget(GuiObject* boss, const GUI::Font& font,
_type = kEditTextWidget;
_editable = true;
startEditMode(); // We're always in edit mode
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -105,15 +106,18 @@ void EditTextWidget::lostFocusWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::startEditMode()
{
EditableWidget::startEditMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::endEditMode()
{
EditableWidget::endEditMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::abortEditMode()
{
setEditString(_backupString);
EditableWidget::abortEditMode();
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EditableWidget.cxx,v 1.17 2006-03-25 00:34:17 stephena Exp $
// $Id: EditableWidget.cxx,v 1.18 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -58,6 +58,15 @@ void EditableWidget::setEditString(const string& str)
// Make sure the new string is seen onscreen
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditableWidget::setEditable(bool editable)
{
_editable = editable;
if(_editable)
setFlags(WIDGET_WANTS_RAWDATA|WIDGET_RETAIN_FOCUS);
else
clearFlags(WIDGET_WANTS_RAWDATA|WIDGET_RETAIN_FOCUS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EditableWidget::tryInsertChar(char c, int pos)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EditableWidget.hxx,v 1.9 2006-02-22 17:38:04 stephena Exp $
// $Id: EditableWidget.hxx,v 1.10 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -45,8 +45,8 @@ class EditableWidget : public Widget, public CommandSender
virtual void setEditString(const string& str);
virtual const string& getEditString() const { return _editString; }
bool isEditable() const { return _editable; }
void setEditable(bool editable) { _editable = editable; }
bool isEditable() const { return _editable; }
void setEditable(bool editable);
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
@ -54,9 +54,9 @@ class EditableWidget : public Widget, public CommandSender
virtual bool wantsFocus() { return _editable; }
protected:
virtual void startEditMode() = 0;
virtual void endEditMode() = 0;
virtual void abortEditMode() = 0;
virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); }
virtual void endEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); }
virtual void abortEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); }
virtual GUI::Rect getEditRect() const = 0;
virtual int getCaretOffset() const;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventMappingWidget.cxx,v 1.14 2006-03-05 01:18:42 stephena Exp $
// $Id: EventMappingWidget.cxx,v 1.15 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -50,7 +50,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myActionsList->setTarget(this);
myActionsList->setNumberingMode(kListNumberingOff);
myActionsList->setEditable(false);
myActionsList->setFlags(WIDGET_NODRAW_FOCUS);
addFocusWidget(myActionsList);
// Add remap, erase, cancel and default buttons
@ -58,19 +57,23 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myMapButton = new ButtonWidget(boss, font, xpos, ypos, 50, 16,
"Map", kStartMapCmd);
myMapButton->setTarget(this);
addFocusWidget(myMapButton);
ypos += 20;
myEraseButton = new ButtonWidget(boss, font, xpos, ypos, 50, 16,
"Erase", kEraseCmd);
myEraseButton->setTarget(this);
addFocusWidget(myEraseButton);
ypos += 20;
myCancelMapButton = new ButtonWidget(boss, font, xpos, ypos, 50, 16,
"Cancel", kStopMapCmd);
myCancelMapButton->setTarget(this);
myCancelMapButton->clearFlags(WIDGET_ENABLED);
addFocusWidget(myCancelMapButton);
ypos += 30;
myDefaultsButton = new ButtonWidget(boss, font, xpos, ypos, 50, 16,
"Defaults", kDefaultsCmd);
myDefaultsButton->setTarget(this);
addFocusWidget(myDefaultsButton);
// Show message for currently selected event
xpos = 10; ypos = 5 + myActionsList->getHeight() + 3;
@ -136,9 +139,9 @@ void EventMappingWidget::startRemapping()
myKeyMapping->setColor(kTextColorEm);
myKeyMapping->setLabel(buf.str());
// Make sure that this widget receives all events,
// and they aren't handled anywhere else
myActionsList->setFlags(WIDGET_WANTS_EVENTS);
// Make sure that this widget receives all raw data, before any
// pre-processing occurs
myActionsList->setFlags(WIDGET_WANTS_RAWDATA);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -175,7 +178,7 @@ void EventMappingWidget::stopRemapping()
}
// Widget is now free to process events normally
myActionsList->clearFlags(WIDGET_WANTS_EVENTS);
myActionsList->clearFlags(WIDGET_WANTS_RAWDATA);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventMappingWidget.hxx,v 1.8 2006-03-02 13:10:53 stephena Exp $
// $Id: EventMappingWidget.hxx,v 1.9 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -45,10 +45,10 @@ class EventMappingWidget : public Widget, public CommandSender
int x, int y, int w, int h);
~EventMappingWidget();
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
virtual void handleJoyDown(int stick, int button);
virtual void handleJoyAxis(int stick, int axis, int value);
virtual bool handleJoyHat(int stick, int hat, int value);
bool handleKeyDown(int ascii, int keycode, int modifiers);
void handleJoyDown(int stick, int button);
void handleJoyAxis(int stick, int axis, int value);
bool handleJoyHat(int stick, int hat, int value);
bool remapMode() { return myRemapStatus; }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GameInfoDialog.cxx,v 1.24 2006-03-05 01:18:42 stephena Exp $
// $Id: GameInfoDialog.cxx,v 1.25 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -47,6 +47,7 @@ GameInfoDialog::GameInfoDialog(
// The tab widget
xpos = 2; ypos = vBorder;
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - 24 - 2*ypos);
addTabWidget(myTab);
// 1) Cartridge properties
wid.clear();
@ -268,13 +269,20 @@ GameInfoDialog::GameInfoDialog(
"(*) Requires a ROM reload", kTextAlignLeft);
// Add Defaults, OK and Cancel buttons
ButtonWidget* b;
wid.clear();
#ifndef MAC_OSX
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
#else
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GuiObject.hxx,v 1.19 2006-02-22 17:38:04 stephena Exp $
// $Id: GuiObject.hxx,v 1.20 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -31,22 +31,11 @@ class Widget;
typedef Common::Array<Widget*> WidgetArray;
enum {
kCursorUp = 256+17,
kCursorDown = 256+18,
kCursorRight = 256+19,
kCursorLeft = 256+20,
kCursorHome = 256+22,
kCursorEnd = 256+23,
kCursorPgUp = 256+24,
kCursorPgDn = 256+25
};
/**
This is the base class for all GUI objects/widgets.
@author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.19 2006-02-22 17:38:04 stephena Exp $
@version $Id: GuiObject.hxx,v 1.20 2006-05-04 17:45:25 stephena Exp $
*/
class GuiObject : public CommandReceiver
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: HelpDialog.cxx,v 1.15 2006-02-22 17:38:04 stephena Exp $
// $Id: HelpDialog.cxx,v 1.16 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,12 +34,20 @@ HelpDialog::HelpDialog(OSystem* osystem, DialogContainer* parent,
myPage(1),
myNumPages(4)
{
WidgetArray wid;
// Add Previous, Next and Close buttons
myPrevButton = addButton(font, 10, h - 24, "Previous", kPrevCmd, 'P');
myNextButton = addButton(font, (kButtonWidth + 15), h - 24,
"Next", kNextCmd, 'N');
addButton(font, w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C');
myPrevButton = addButton(font, 10, h - 24, "Previous", kPrevCmd);
myPrevButton->clearFlags(WIDGET_ENABLED);
wid.push_back(myPrevButton);
myNextButton = addButton(font, (kButtonWidth + 15), h - 24,
"Next", kNextCmd);
wid.push_back(myNextButton);
ButtonWidget* b = addButton(font, w - (kButtonWidth + 10), h - 24,
"Close", kCloseCmd);
wid.push_back(b);
myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(),
"", kTextAlignCenter);
@ -50,6 +58,8 @@ HelpDialog::HelpDialog(OSystem* osystem, DialogContainer* parent,
myDesc[i] = new StaticTextWidget(this, font, 90, 18 + (10 * i), 160,
font.getFontHeight(), "", kTextAlignLeft);
}
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: InputDialog.cxx,v 1.13 2006-04-05 12:28:39 stephena Exp $
// $Id: InputDialog.cxx,v 1.14 2006-05-04 17:45:25 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -42,6 +42,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
{
const int vBorder = 4;
int xpos, ypos, tabID;
WidgetArray wid;
// The tab widget
xpos = 2; ypos = vBorder;
@ -64,13 +65,19 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
myTab->setActiveTab(0);
// Add OK and Cancel buttons
ButtonWidget* b;
#ifndef MAC_OSX
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
#else
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: InputTextDialog.cxx,v 1.12 2006-03-23 16:16:33 stephena Exp $
// $Id: InputTextDialog.cxx,v 1.13 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -29,10 +29,6 @@
#include "bspf.hxx"
enum {
kAcceptCmd = 'ACPT'
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
const StringList& labels, int x, int y)
@ -46,6 +42,7 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
bwidth = font.getStringWidth(" Cancel "),
bheight = font.getLineHeight() + 2;
unsigned int xpos, ypos, i, lwidth = 0, maxIdx = 0;
WidgetArray wid;
// Calculate real dimensions
_w = fontWidth * 25;
@ -63,7 +60,6 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
lwidth = font.getStringWidth(labels[maxIdx]);
// Create editboxes for all labels
WidgetArray wid;
ypos = lineHeight;
for(i = 0; i < labels.size(); ++i)
{
@ -80,24 +76,30 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
myInput.push_back(w);
ypos += lineHeight + 5;
}
addToFocusList(wid);
xpos = 10;
myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - 2*xpos, fontHeight,
"", kTextAlignCenter);
myTitle->setColor(kTextColorEm);
ButtonWidget* b;
#ifndef MAC_OSX
new ButtonWidget(this, font, _w - 2 * (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "OK", kAcceptCmd, 0);
new ButtonWidget(this, font, _w - (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "Cancel", kCloseCmd, 0);
b = new ButtonWidget(this, font, _w - 2 * (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "OK", kAcceptCmd);
wid.push_back(b);
b = new ButtonWidget(this, font, _w - (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "Cancel", kCloseCmd);
wid.push_back(b);
#else
new ButtonWidget(this, font, _w - 2 * (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "Cancel", kCloseCmd, 0);
new ButtonWidget(this, font, _w - (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "OK", kAcceptCmd, 0);
b = new ButtonWidget(this, font, _w - 2 * (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "Cancel", kCloseCmd);
wid.push_back(b);
b = new ButtonWidget(this, font, _w - (bwidth + 10), _h - bheight - 10,
bwidth, bheight, "OK", kAcceptCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: InputTextDialog.hxx,v 1.6 2005-12-20 00:56:31 stephena Exp $
// $Id: InputTextDialog.hxx,v 1.7 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,6 +56,10 @@ class InputTextDialog : public Dialog, public CommandSender
bool myErrorFlag;
int myCmd;
enum {
kAcceptCmd = 'ACPT'
};
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherDialog.cxx,v 1.53 2006-04-12 13:32:06 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.54 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -83,8 +83,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
_w - 20, _h - 28 - bheight - 2*fontHeight);
myList->setNumberingMode(kListNumberingOff);
myList->setEditable(false);
myList->setFlags(WIDGET_STICKY_FOCUS);
//wid.push_back(myList);
wid.push_back(myList);
// Add note textwidget to show any notes for the currently selected ROM
xpos += 5; ypos += myList->getHeight() + 4;
@ -100,45 +99,37 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
xpos = 10; ypos += myNote->getHeight() + 4;
#ifndef MAC_OSX
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Select", kStartCmd, 0);
myStartButton->setEditable(true);
"Select", kStartCmd);
wid.push_back(myStartButton);
xpos += bwidth + 8;
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Go Up", kPrevDirCmd, 0);
myPrevDirButton->setEditable(true);
"Go Up", kPrevDirCmd);
wid.push_back(myPrevDirButton);
xpos += bwidth + 8;
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Options", kOptionsCmd, 0);
myOptionsButton->setEditable(true);
"Options", kOptionsCmd);
wid.push_back(myOptionsButton);
xpos += bwidth + 8;
myQuitButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Quit", kQuitCmd, 0);
myQuitButton->setEditable(true);
"Quit", kQuitCmd);
wid.push_back(myQuitButton);
xpos += bwidth + 8;
mySelectedItem = 0; // Highlight 'Select' button
#else
myQuitButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Quit", kQuitCmd, 0);
myQuitButton->setEditable(true);
"Quit", kQuitCmd);
wid.push_back(myQuitButton);
xpos += bwidth + 8;
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Options", kOptionsCmd, 0);
myOptionsButton->setEditable(true);
"Options", kOptionsCmd);
wid.push_back(myOptionsButton);
xpos += bwidth + 8;
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Go Up", kPrevDirCmd, 0);
myPrevDirButton->setEditable(true);
"Go Up", kPrevDirCmd);
wid.push_back(myPrevDirButton);
xpos += bwidth + 8;
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Select", kStartCmd, 0);
myStartButton->setEditable(true);
"Select", kStartCmd);
wid.push_back(myStartButton);
xpos += bwidth + 8;
mySelectedItem = 3; // Highlight 'Select' button
@ -418,67 +409,6 @@ string LauncherDialog::MD5FromFile(const string& path)
return md5;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Only detect the cursor keys, otherwise pass to base class
switch(ascii)
{
case kCursorLeft:
mySelectedItem--;
if(mySelectedItem < 0) mySelectedItem = 3;
Dialog::setFocus(getFocusList()[mySelectedItem]);
break;
case kCursorRight:
mySelectedItem++;
if(mySelectedItem > 3) mySelectedItem = 0;
Dialog::setFocus(getFocusList()[mySelectedItem]);
break;
case ' ': // Used to activate currently focused button
case '\n':
case '\r':
Dialog::handleKeyDown(ascii, keycode, modifiers);
break;
default:
if(!myList->handleKeyDown(ascii, keycode, modifiers))
Dialog::handleKeyDown(ascii, keycode, modifiers);
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleJoyAxis(int stick, int axis, int value)
{
if(!parent()->joymouse())
return;
// We make the (hopefully) valid assumption that all joysticks
// treat axis the same way. Eventually, we may need to remap
// these actions of this assumption is invalid.
// TODO - make this work better with analog axes ...
int key = -1;
if(axis % 2 == 0) // x-direction
{
if(value < 0)
key = kCursorLeft;
else if(value > 0)
key = kCursorRight;
}
else // y-direction
{
if(value < 0)
key = kCursorUp;
else if(value > 0)
key = kCursorDown;
}
if(key != -1)
handleKeyDown(key, 0, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherDialog.hxx,v 1.20 2006-03-19 23:11:31 stephena Exp $
// $Id: LauncherDialog.hxx,v 1.21 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -52,15 +52,11 @@ class LauncherDialog : public Dialog
~LauncherDialog();
protected:
virtual void handleKeyDown(int ascii, int keycode, int modifiers);
virtual void handleJoyAxis(int stick, int axis, int value);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void updateListing(bool fullReload = false);
void loadConfig();
virtual bool wantsEvents() { return true; }
protected:
ButtonWidget* myStartButton;
ButtonWidget* myPrevDirButton;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherOptionsDialog.cxx,v 1.16 2006-03-19 20:57:55 stephena Exp $
// $Id: LauncherOptionsDialog.cxx,v 1.17 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -39,6 +39,9 @@ LauncherOptionsDialog::LauncherOptionsDialog(
{
const int vBorder = 4;
int xpos, ypos, bwidth, bheight;
WidgetArray wid;
ButtonWidget* b;
int tabID;
bwidth = font.getStringWidth("Cancel") + 20;
bheight = font.getLineHeight() + 4;
@ -46,14 +49,17 @@ LauncherOptionsDialog::LauncherOptionsDialog(
// The tab widget
xpos = 2; ypos = vBorder;
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - 2*bheight - ypos);
addTabWidget(myTab);
// 1) The ROM locations tab
myTab->addTab("ROM Settings");
wid.clear();
tabID = myTab->addTab("ROM Settings");
// ROM path
xpos = 15; ypos += 5;
new ButtonWidget(myTab, font, xpos, ypos, bwidth, bheight, "Path",
kChooseRomDirCmd, 0);
b = new ButtonWidget(myTab, font, xpos, ypos, bwidth, bheight, "Path",
kChooseRomDirCmd);
wid.push_back(b);
xpos += bwidth + 20;
myRomPath = new StaticTextWidget(myTab, font, xpos, ypos + 3,
_w - xpos - 10, font.getLineHeight(),
@ -63,22 +69,29 @@ LauncherOptionsDialog::LauncherOptionsDialog(
xpos = 30; ypos += myRomPath->getHeight() + 8;
myBrowseCheckbox = new CheckboxWidget(myTab, font, xpos, ypos,
"Browse folders", kBrowseDirCmd);
wid.push_back(myBrowseCheckbox);
// Reload current ROM listing
xpos += myBrowseCheckbox->getWidth() + 20;
myReloadButton = new ButtonWidget(myTab, font, xpos, ypos-2,
font.getStringWidth("Reload ROM Listing") + 20,
bheight,
"Reload ROM Listing", kReloadRomDirCmd, 0);
"Reload ROM Listing", kReloadRomDirCmd);
// myReloadButton->setEditable(true);
wid.push_back(myReloadButton);
// Add focus widgets for ROM tab
addToFocusList(wid, tabID);
// 2) The snapshot settings tab
myTab->addTab(" Snapshot Settings ");
wid.clear();
tabID = myTab->addTab(" Snapshot Settings ");
// Snapshot path
xpos = 15; ypos = vBorder + 5;
new ButtonWidget(myTab, font, xpos, ypos, bwidth, bheight, "Path",
kChooseSnapDirCmd, 0);
b = new ButtonWidget(myTab, font, xpos, ypos, bwidth, bheight, "Path",
kChooseSnapDirCmd);
wid.push_back(b);
xpos += bwidth + 20;
mySnapPath = new StaticTextWidget(myTab, font, xpos, ypos + 3,
_w - xpos - 10, font.getLineHeight(),
@ -93,31 +106,39 @@ LauncherOptionsDialog::LauncherOptionsDialog(
font.getStringWidth("Save snapshot as: "), 0);
mySnapTypePopup->appendEntry("romname", 1);
mySnapTypePopup->appendEntry("md5sum", 2);
wid.push_back(mySnapTypePopup);
// Snapshot single or multiple saves
xpos = 30; ypos += mySnapTypePopup->getHeight() + 5;
mySnapSingleCheckbox = new CheckboxWidget(myTab, font, xpos, ypos,
"Multiple snapshots");
wid.push_back(mySnapSingleCheckbox);
// Add focus widgets for Snapshot tab
addToFocusList(wid, tabID);
// Activate the first tab
myTab->setActiveTab(0);
// Add OK & Cancel buttons
wid.clear();
#ifndef MAC_OSX
xpos = _w - 2 *(bwidth + 10); ypos = _h - bheight - 8;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "OK",
kOKCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "OK", kOKCmd);
wid.push_back(b);
xpos += bwidth + 10;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel", kCloseCmd);
wid.push_back(b);
#else
xpos = _w - 2 *(bwidth + 10); ypos = _h - bheight - 8;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel",
kCloseCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cancel", kCloseCmd);
wid.push_back(b);
xpos += bwidth + 10;
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "OK",
kOKCmd, 0);
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "OK", kOKCmd);
wid.push_back(b);
#endif
// Add focus widgets for OK/Cancel buttons
addToFocusList(wid);
// Create file browser dialog
int baseW = instance()->frameBuffer().baseWidth();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ListWidget.cxx,v 1.41 2006-03-19 22:06:20 stephena Exp $
// $Id: ListWidget.cxx,v 1.42 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -137,6 +137,9 @@ void ListWidget::recalc()
_scrollBar->_numEntries = _list.size();
_scrollBar->_entriesPerPage = _rows;
// Reset to normal data entry
abortEditMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -269,48 +272,6 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
}
break;
case '\n': // enter/return
case '\r':
if (_selectedItem >= 0)
{
// override continuous enter keydown
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r'))
startEditMode();
else
sendCommand(kListItemActivatedCmd, _selectedItem, _id);
}
break;
case kCursorUp:
if (_selectedItem > 0)
_selectedItem--;
break;
case kCursorDown:
if (_selectedItem < (int)_list.size() - 1)
_selectedItem++;
break;
case kCursorPgUp:
_selectedItem -= _rows - 1;
if (_selectedItem < 0)
_selectedItem = 0;
break;
case kCursorPgDn:
_selectedItem += _rows - 1;
if (_selectedItem >= (int)_list.size() )
_selectedItem = _list.size() - 1;
break;
case kCursorHome:
_selectedItem = 0;
break;
case kCursorEnd:
_selectedItem = _list.size() - 1;
break;
default:
handled = false;
}
@ -336,10 +297,79 @@ bool ListWidget::handleKeyUp(int ascii, int keycode, int modifiers)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ListWidget::handleEvent(Event::Type e)
{
if(_editMode)
return false;
bool handled = true;
int oldSelectedItem = _selectedItem;
switch(e)
{
case Event::UISelect:
if (_selectedItem >= 0)
{
if (_editable)
startEditMode();
else
sendCommand(kListItemActivatedCmd, _selectedItem, _id);
}
break;
case Event::UIUp:
if (_selectedItem > 0)
_selectedItem--;
break;
case Event::UIDown:
if (_selectedItem < (int)_list.size() - 1)
_selectedItem++;
break;
case Event::UIPgUp:
_selectedItem -= _rows - 1;
if (_selectedItem < 0)
_selectedItem = 0;
break;
case Event::UIPgDown:
_selectedItem += _rows - 1;
if (_selectedItem >= (int)_list.size() )
_selectedItem = _list.size() - 1;
break;
case Event::UIHome:
_selectedItem = 0;
break;
case Event::UIEnd:
_selectedItem = _list.size() - 1;
break;
default:
handled = false;
}
if (_selectedItem != oldSelectedItem)
{
_scrollBar->draw();
scrollToSelected();
sendCommand(kListSelectionChangedCmd, _selectedItem, _id);
}
return handled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::lostFocusWidget()
{
_editMode = false;
// Reset to normal data entry
abortEditMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -408,6 +438,9 @@ void ListWidget::startEditMode()
{
_editMode = true;
setEditString(_list[_selectedItem]);
// Widget gets raw data while editing
EditableWidget::startEditMode();
}
}
@ -417,16 +450,22 @@ void ListWidget::endEditMode()
if (!_editMode)
return;
// send a message that editing finished with a return/enter key press
// Send a message that editing finished with a return/enter key press
_editMode = false;
_list[_selectedItem] = _editString;
sendCommand(kListItemDataChangedCmd, _selectedItem, _id);
// Reset to normal data entry
EditableWidget::endEditMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::abortEditMode()
{
// undo any changes made
// Undo any changes made
assert(_selectedItem >= 0);
_editMode = false;
// Reset to normal data entry
EditableWidget::abortEditMode();
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ListWidget.hxx,v 1.17 2006-03-19 22:06:20 stephena Exp $
// $Id: ListWidget.hxx,v 1.18 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -67,10 +67,10 @@ class ListWidget : public EditableWidget
virtual void handleMouseWheel(int x, int y, int direction);
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
virtual bool handleKeyUp(int ascii, int keycode, int modifiers);
virtual bool handleEvent(Event::Type e);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual GUI::Rect getRect() const;
virtual bool wantsFocus() { return !isSticky(); }
void startEditMode();
void endEditMode();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OptionsDialog.cxx,v 1.38 2006-04-05 12:28:39 stephena Exp $
// $Id: OptionsDialog.cxx,v 1.39 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,8 +56,8 @@ enum {
kMainMenuHeight = 8 * kRowHeight + 10,
};
#define addBigButton(label, cmd, hotkey) \
new ButtonWidget(this, font, xoffset, yoffset, kBigButtonWidth, 18, label, cmd, hotkey); yoffset += kRowHeight
#define addBigButton(label, cmd) \
new ButtonWidget(this, font, xoffset, yoffset, kBigButtonWidth, 18, label, cmd); yoffset += kRowHeight
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
@ -77,26 +77,38 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
int yoffset = 7;
const int xoffset = (_w - kBigButtonWidth) / 2;
const GUI::Font& font = instance()->font(); // FIXME - change reference to optionsFont()
WidgetArray wid;
ButtonWidget* b = NULL;
b = addBigButton("Video Settings", kVidCmd, 0);
#ifdef SOUND_SUPPORT
addBigButton("Audio Settings", kAudCmd, 0);
#else
b = addBigButton("Audio Settings", kAudCmd, 0);
b = addBigButton("Video Settings", kVidCmd);
wid.push_back(b);
b = addBigButton("Audio Settings", kAudCmd);
#ifndef SOUND_SUPPORT
b->clearFlags(WIDGET_ENABLED);
#endif
addBigButton("Input Settings", kInptCmd, 0);
addBigButton("Game Properties", kInfoCmd, 0);
#ifdef CHEATCODE_SUPPORT
addBigButton("Cheat Code", kCheatCmd, 0);
#else
b = addBigButton("Cheat Code", kCheatCmd, 0);
wid.push_back(b);
b = addBigButton("Input Settings", kInptCmd);
wid.push_back(b);
b = addBigButton("Game Properties", kInfoCmd);
wid.push_back(b);
b = addBigButton("Cheat Code", kCheatCmd);
#ifndef CHEATCODE_SUPPORT
b->clearFlags(WIDGET_ENABLED);
#endif
addBigButton("Help", kHelpCmd, 0);
addBigButton("About", kAboutCmd, 0);
addBigButton("Exit Menu", kExitCmd, 0);
wid.push_back(b);
b = addBigButton("Help", kHelpCmd);
wid.push_back(b);
b = addBigButton("About", kAboutCmd);
wid.push_back(b);
b = addBigButton("Exit Menu", kExitCmd);
wid.push_back(b);
// Set some sane values for the dialog boxes
int fbWidth = osystem->frameBuffer().baseWidth();
@ -133,6 +145,8 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
w = 255; h = 150;
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
myAboutDialog = new AboutDialog(myOSystem, parent, font, x, y, w, h);
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PopUpWidget.cxx,v 1.24 2006-02-22 17:38:04 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.25 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -137,25 +137,43 @@ void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
switch (ascii)
{
case '\n': // enter/return
case '\r':
sendSelection();
break;
case 27: // escape
cancelSelection();
break;
case 256+17: // up arrow
default:
{
Event::Type e = instance()->eventHandler().eventForKey(ascii,
kMenuOverlay);
handleEvent(e);
break;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleEvent(Event::Type e)
{
switch(e)
{
case Event::UISelect:
sendSelection();
break;
case Event::UIUp:
case Event::UILeft:
moveUp();
break;
case 256+18: // down arrow
case Event::UIDown:
case Event::UIRight:
moveDown();
break;
case 256+22: // home
case Event::UIHome:
setSelection(0);
break;
case 256+23: // end
case Event::UIEnd:
setSelection(_popUpBoss->_entries.size()-1);
break;
default:
break;
}
}
@ -389,8 +407,7 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
_labelWidth(labelWidth),
_cmd(cmd)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_NODRAW_FOCUS;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kPopUpWidget;
_selectedItem = -1;
@ -424,6 +441,19 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpWidget::handleEvent(Event::Type e)
{
switch(e)
{
case Event::UISelect:
handleMouseDown(0, 0, 1, 0);
return true;
default:
return false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::appendEntry(const string& entry, int tag)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PopUpWidget.hxx,v 1.12 2006-02-22 17:38:04 stephena Exp $
// $Id: PopUpWidget.hxx,v 1.13 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -65,6 +65,9 @@ class PopUpWidget : public Widget, public CommandSender
~PopUpWidget();
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleEvent(Event::Type e);
bool wantsFocus() { return true; }
void appendEntry(const string& entry, int tag = (int)-1);
void clearEntries();
@ -75,9 +78,12 @@ class PopUpWidget : public Widget, public CommandSender
/** Select the first entry matching the given tag. */
void setSelectedTag(int tag);
int getSelected() const { return _selectedItem; }
int getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (int)-1; }
const string& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : EmptyString; }
int getSelected() const
{ return _selectedItem; }
int getSelectedTag() const
{ return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (int)-1; }
const string& getSelectedString() const
{ return (_selectedItem >= 0) ? _entries[_selectedItem].name : EmptyString; }
protected:
void drawWidget(bool hilite);
@ -104,9 +110,9 @@ class PopUpDialog : public Dialog
void drawDialog();
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel
void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc.
void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel
void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
protected:
void drawMenuEntry(int entry, bool hilite);
@ -122,6 +128,7 @@ class PopUpDialog : public Dialog
private:
void sendSelection();
void cancelSelection();
void handleEvent(Event::Type e);
protected:
PopUpWidget* _popUpBoss;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: StringListWidget.cxx,v 1.6 2006-03-25 00:34:17 stephena Exp $
// $Id: StringListWidget.cxx,v 1.7 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -68,7 +68,7 @@ void StringListWidget::drawWidget(bool hilite)
// Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos)
{
if ((_hasFocus && !_editMode) || isSticky())
if (_hasFocus && !_editMode)
fb.fillRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);
else
fb.frameRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: VideoDialog.cxx,v 1.29 2006-03-25 00:34:17 stephena Exp $
// $Id: VideoDialog.cxx,v 1.30 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,13 +36,14 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
: Dialog(osystem, parent, x, y, w, h)
{
const int lineHeight = font.getLineHeight(),
fontHeight = font.getFontHeight();
int xpos, ypos;
int lwidth = font.getStringWidth("Dirty Rects: "),
pwidth = font.getStringWidth("Software");
WidgetArray wid;
// Use dirty rectangle updates
xpos = 5; ypos = 10;
@ -50,6 +51,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
pwidth, lineHeight, "Dirty Rects: ", lwidth);
myDirtyPopup->appendEntry("Yes", 1);
myDirtyPopup->appendEntry("No", 2);
wid.push_back(myDirtyPopup);
ypos += lineHeight + 4;
// Video renderer
@ -63,6 +65,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
#ifdef DISPLAY_OPENGL
myRendererPopup->appendEntry("OpenGL", 3);
#endif
wid.push_back(myRendererPopup);
ypos += lineHeight + 4;
// Video filter
@ -70,12 +73,14 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
pwidth, lineHeight, "GL Filter: ", lwidth);
myFilterPopup->appendEntry("Linear", 1);
myFilterPopup->appendEntry("Nearest", 2);
wid.push_back(myFilterPopup);
ypos += lineHeight + 4;
// Aspect ratio
myAspectRatioSlider = new SliderWidget(this, font, xpos, ypos, pwidth, lineHeight,
"GL Aspect: ", lwidth, kAspectRatioChanged);
myAspectRatioSlider->setMinValue(1); myAspectRatioSlider->setMaxValue(100);
wid.push_back(myAspectRatioSlider);
myAspectRatioLabel = new StaticTextWidget(this, font,
xpos + myAspectRatioSlider->getWidth() + 4,
ypos + 1,
@ -89,6 +94,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myPalettePopup->appendEntry("Standard", 1);
myPalettePopup->appendEntry("Original", 2);
myPalettePopup->appendEntry("Z26", 3);
wid.push_back(myPalettePopup);
ypos += lineHeight + 4;
// Move over to the next column
@ -98,6 +104,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myFrameRateSlider = new SliderWidget(this, font, xpos, ypos, 30, lineHeight,
"Framerate: ", lwidth, kFrameRateChanged);
myFrameRateSlider->setMinValue(1); myFrameRateSlider->setMaxValue(300);
wid.push_back(myFrameRateSlider);
myFrameRateLabel = new StaticTextWidget(this, font,
xpos + myFrameRateSlider->getWidth() + 4,
ypos + 1,
@ -109,6 +116,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myZoomSlider = new SliderWidget(this, font, xpos, ypos, 30, lineHeight,
"Zoom: ", lwidth, kZoomChanged);
myZoomSlider->setMinValue(0); myZoomSlider->setMaxValue(50);
wid.push_back(myZoomSlider);
myZoomLabel = new StaticTextWidget(this, font,
xpos + myZoomSlider->getWidth() + 4,
ypos + 1,
@ -118,26 +126,36 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myFullscreenCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Fullscreen mode");
wid.push_back(myFullscreenCheckbox);
ypos += lineHeight + 4;
myUseDeskResCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Desktop Res in FS");
wid.push_back(myUseDeskResCheckbox);
ypos += lineHeight + 4;
myTiaDefaultsCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Use TIA defaults");
wid.push_back(myTiaDefaultsCheckbox);
ypos += lineHeight + 20;
// Add Defaults, OK and Cancel buttons
addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd, 0);
ButtonWidget* b;
b = addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd);
wid.push_back(b);
#ifndef MAC_OSX
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
#else
addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd);
wid.push_back(b);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
#endif
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.cxx,v 1.43 2006-03-25 00:34:17 stephena Exp $
// $Id: Widget.cxx,v 1.44 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -239,8 +239,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
if(tmp->_hasFocus)
{
tmp->lostFocus();
if(!(tmp->_flags & WIDGET_NODRAW_FOCUS))
fb.frameRect(x, y, w, h, kBGColor);
fb.frameRect(x, y, w, h, kBGColor);
tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h);
@ -279,8 +278,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
w = rect.width(), h = rect.height();
tmp->receivedFocus();
if(!(tmp->_flags & WIDGET_NODRAW_FOCUS))
fb.frameRect(x, y, w, h, kTextColorEm, kDashLine);
fb.frameRect(x, y, w, h, kTextColorEm, kDashLine);
tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h);
@ -338,12 +336,11 @@ void StaticTextWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h,
const string& label, int cmd, uInt8 hotkey)
const string& label, int cmd)
: StaticTextWidget(boss, font, x, y, w, h, label, kTextAlignCenter),
CommandSender(boss),
_cmd(cmd),
_editable(false),
_hotkey(hotkey)
_editable(false)
{
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget;
@ -364,14 +361,11 @@ void ButtonWidget::handleMouseLeft(int button)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ButtonWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool ButtonWidget::handleEvent(Event::Type e)
{
// (De)activate with space or return
switch(ascii)
switch(e)
{
case '\n': // enter/return
case '\r':
case ' ' : // space
case Event::UISelect:
// Simulate mouse event
handleMouseUp(0, 0, 1, 0);
return true;
@ -380,14 +374,6 @@ bool ButtonWidget::handleKeyDown(int ascii, int keycode, int modifiers)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleJoyDown(int stick, int button)
{
// Any button activates the button, but only while in joymouse mode
if(DialogContainer::joymouse())
handleMouseUp(0, 0, 1, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
{
@ -398,22 +384,6 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ButtonWidget::wantsFocus()
{
return _editable;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::setEditable(bool editable)
{
_editable = editable;
if(_editable)
setFlags(WIDGET_RETAIN_FOCUS);
else
clearFlags(WIDGET_RETAIN_FOCUS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::drawWidget(bool hilite)
{
@ -440,7 +410,7 @@ static unsigned int checked_img[8] =
CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, const string& label,
int cmd)
: ButtonWidget(boss, font, x, y, 16, 16, label, cmd, 0),
: ButtonWidget(boss, font, x, y, 16, 16, label, cmd),
_state(false),
_editable(true),
_holdFocus(true),
@ -450,7 +420,7 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
_boxY(0),
_textY(0)
{
_flags = WIDGET_ENABLED | WIDGET_RETAIN_FOCUS;
_flags = WIDGET_ENABLED;
_type = kCheckboxWidget;
if(label == "")
@ -480,36 +450,10 @@ void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckboxWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// (De)activate with space or return
switch(ascii)
{
case '\n': // enter/return
case '\r':
case ' ' : // space
// Simulate mouse event
handleMouseUp(0, 0, 1, 0);
return true;
default:
return false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckboxWidget::wantsFocus()
{
if(!_holdFocus)
return false;
else
return _editable;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::setEditable(bool editable)
{
_holdFocus = _editable = editable;
_editable = editable;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -553,10 +497,10 @@ void CheckboxWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SliderWidget::SliderWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h,
const string& label, int labelWidth, int cmd, uInt8 hotkey)
: ButtonWidget(boss, font, x, y, w, h, label, cmd, hotkey),
const string& label, int labelWidth, int cmd)
: ButtonWidget(boss, font, x, y, w, h, label, cmd),
_value(0),
_oldValue(0),
_stepValue(5),
_valueMin(0),
_valueMax(100),
_isDragging(false),
@ -574,8 +518,35 @@ SliderWidget::SliderWidget(GuiObject *boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::setValue(int value)
{
_value = value;
setDirty(); draw();
/*cerr << "SliderWidget::setValue: " << value
<< ", max = " << _valueMax
<< ", min = " << _valueMin
<< endl;*/
if(value < _valueMin)
value = _valueMin;
else if(value > _valueMax)
value = _valueMax;
if(value != _value)
{
_value = value;
setDirty(); draw();
sendCommand(_cmd, _value, _id);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::setMinValue(int value)
{
_valueMin = value;
_stepValue = (int) ((_valueMax - _valueMin) * 0.05); // Step at 5% intervals
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::setMaxValue(int value)
{
_valueMax = value;
_stepValue = (int) ((_valueMax - _valueMin) * 0.05); // Step at 5% intervals
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -584,21 +555,7 @@ void SliderWidget::handleMouseMoved(int x, int y, int button)
// TODO: when the mouse is dragged outside the widget, the slider should
// snap back to the old value.
if(isEnabled() && _isDragging && x >= (int)_labelWidth)
{
int newValue = posToValue(x - _labelWidth);
if(newValue < _valueMin)
newValue = _valueMin;
else if (newValue > _valueMax)
newValue = _valueMax;
if(newValue != _value)
{
_value = newValue;
setDirty(); draw();
sendCommand(_cmd, _value, _id);
}
}
setValue(posToValue(x - _labelWidth));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -620,6 +577,38 @@ void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount)
_isDragging = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SliderWidget::handleEvent(Event::Type e)
{
switch(e)
{
case Event::UILeft:
case Event::UIDown:
case Event::UIPgDown:
setValue(_value - _stepValue);
break;
case Event::UIRight:
case Event::UIUp:
case Event::UIPgUp:
setValue(_value + _stepValue);
break;
case Event::UIHome:
setValue(_valueMin);
break;
case Event::UIEnd:
setValue(_valueMax);
break;
default:
return false;
break;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::drawWidget(bool hilite)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.hxx,v 1.49 2006-03-25 00:34:17 stephena Exp $
// $Id: Widget.hxx,v 1.50 2006-05-04 17:45:25 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -26,6 +26,7 @@ class Dialog;
#include <assert.h>
#include "Event.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "GuiObject.hxx"
@ -36,18 +37,16 @@ class Dialog;
#include "bspf.hxx"
enum {
WIDGET_ENABLED = 1 << 0,
WIDGET_INVISIBLE = 1 << 1,
WIDGET_HILITED = 1 << 2,
WIDGET_BORDER = 1 << 3,
WIDGET_INV_BORDER = 1 << 4,
WIDGET_CLEARBG = 1 << 5,
WIDGET_TRACK_MOUSE = 1 << 6,
WIDGET_RETAIN_FOCUS = 1 << 7,
WIDGET_NODRAW_FOCUS = 1 << 8,
WIDGET_STICKY_FOCUS = 1 << 9,
WIDGET_WANTS_TAB = 1 << 10,
WIDGET_WANTS_EVENTS = 1 << 11
WIDGET_ENABLED = 1 << 0,
WIDGET_INVISIBLE = 1 << 1,
WIDGET_HILITED = 1 << 2,
WIDGET_BORDER = 1 << 3,
WIDGET_INV_BORDER = 1 << 4,
WIDGET_CLEARBG = 1 << 5,
WIDGET_TRACK_MOUSE = 1 << 6,
WIDGET_RETAIN_FOCUS = 1 << 7,
WIDGET_WANTS_TAB = 1 << 8,
WIDGET_WANTS_RAWDATA = 1 << 9
};
enum {
@ -75,7 +74,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.49 2006-03-25 00:34:17 stephena Exp $
@version $Id: Widget.hxx,v 1.50 2006-05-04 17:45:25 stephena Exp $
*/
class Widget : public GuiObject
{
@ -100,6 +99,7 @@ class Widget : public GuiObject
virtual void handleJoyUp(int stick, int button) {}
virtual void handleJoyAxis(int stick, int axis, int value) {}
virtual bool handleJoyHat(int stick, int hat, int value) { return false; }
virtual bool handleEvent(Event::Type event) { return false; }
void draw();
void receivedFocus();
@ -107,7 +107,6 @@ class Widget : public GuiObject
void addFocusWidget(Widget* w) { _focusList.push_back(w); }
virtual GUI::Rect getRect() const;
virtual bool wantsFocus() { return false; }
/** Set/clear WIDGET_ENABLED flag and immediately redraw */
void setEnabled(bool e);
@ -116,10 +115,11 @@ class Widget : public GuiObject
void clearFlags(int flags) { _flags &= ~flags; }
int getFlags() const { return _flags; }
bool isEnabled() const { return _flags & WIDGET_ENABLED; }
bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); }
bool isSticky() const { return _flags & WIDGET_STICKY_FOCUS; }
bool wantsEvents() const { return _flags & WIDGET_WANTS_EVENTS; }
bool isEnabled() const { return _flags & WIDGET_ENABLED; }
bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); }
bool wantsFocus() const { return _flags & WIDGET_RETAIN_FOCUS; }
bool wantsTab() const { return _flags & WIDGET_WANTS_TAB; }
bool wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; }
void setID(int id) { _id = id; }
int getID() { return _id; }
@ -185,7 +185,6 @@ class StaticTextWidget : public Widget
void setLabel(const string& label);
void setAlign(TextAlignment align) { _align = align; }
const string& getLabel() const { return _label; }
void setEditable(bool editable);
protected:
void drawWidget(bool hilite);
@ -203,19 +202,15 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
public:
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
const string& label, int cmd = 0, uInt8 hotkey = 0);
const string& label, int cmd = 0);
void setCmd(int cmd) { _cmd = cmd; }
int getCmd() const { return _cmd; }
void handleMouseUp(int x, int y, int button, int clickCount);
void handleMouseEntered(int button);
void handleMouseLeft(int button);
bool handleKeyDown(int ascii, int keycode, int modifiers);
void handleJoyDown(int stick, int button);
bool wantsFocus();
void setEditable(bool editable);
virtual void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseEntered(int button);
virtual void handleMouseLeft(int button);
virtual bool handleEvent(Event::Type event);
protected:
void drawWidget(bool hilite);
@ -223,7 +218,6 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
protected:
int _cmd;
bool _editable;
uInt8 _hotkey;
};
@ -237,10 +231,6 @@ class CheckboxWidget : public ButtonWidget
void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseEntered(int button) {}
virtual void handleMouseLeft(int button) {}
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
bool wantsFocus();
void holdFocus(bool status) { _holdFocus = status; }
void setEditable(bool editable);
void setFill(bool fill) { _fillRect = fill; }
@ -276,19 +266,20 @@ class SliderWidget : public ButtonWidget
public:
SliderWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h, const string& label = "",
int labelWidth = 0, int cmd = 0, uInt8 hotkey = 0);
int labelWidth = 0, int cmd = 0);
void setValue(int value);
int getValue() const { return _value; }
void setMinValue(int value) { _valueMin = value; }
void setMinValue(int value);
int getMinValue() const { return _valueMin; }
void setMaxValue(int value) { _valueMax = value; }
void setMaxValue(int value);
int getMaxValue() const { return _valueMax; }
void handleMouseMoved(int x, int y, int button);
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseMoved(int x, int y, int button);
virtual void handleMouseDown(int x, int y, int button, int clickCount);
virtual void handleMouseUp(int x, int y, int button, int clickCount);
virtual bool handleEvent(Event::Type event);
protected:
void drawWidget(bool hilite);
@ -297,7 +288,7 @@ class SliderWidget : public ButtonWidget
int posToValue(int pos);
protected:
int _value, _oldValue;
int _value, _stepValue;
int _valueMin, _valueMax;
bool _isDragging;
int _labelWidth;