Added keyboard selection and navigation to checkbuttons (use space or

return key to toggle a selected checkbox).  Generally cleaned up
the CheckboxWidget class, so that it centers vertically based on
box/font size, and correctly determines its own size.

Added all P0/P1 info from 'tia' command to the TIA tab.  Some work
is still required on the NUSIZx registers, though.  I expect the
remainder of the TIA tab will be completed quickly, now that most
of the infrastructure is in place.  Still TODO is add methods to
TIADebug to enable/disable collisions.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@720 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-08-16 18:34:12 +00:00
parent e48cc40e14
commit e0bdb3512f
16 changed files with 420 additions and 82 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: Debugger.cxx,v 1.82 2005-08-15 18:52:15 stephena Exp $
// $Id: Debugger.cxx,v 1.83 2005-08-16 18:34:12 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -341,13 +341,17 @@ const string Debugger::valueToString(int value, BaseFormat outputBase)
sprintf(rendered, "%5d", value);
break;
case kBASE_16_4:
sprintf(rendered, Debugger::to_hex_4(value));
break;
case kBASE_16:
default:
if(value < 0x100)
sprintf(rendered, Debugger::to_hex_8(value));
else
sprintf(rendered, Debugger::to_hex_16(value));
break;
default:
if(value < 0x100)
sprintf(rendered, Debugger::to_hex_8(value));
else
sprintf(rendered, Debugger::to_hex_16(value));
break;
}
return string(rendered);

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: DebuggerParser.hxx,v 1.40 2005-07-30 22:08:25 urchlay Exp $
// $Id: DebuggerParser.hxx,v 1.41 2005-08-16 18:34:12 stephena Exp $
//============================================================================
#ifndef DEBUGGER_PARSER_HXX
@ -27,6 +27,7 @@ struct Command;
typedef enum {
kBASE_16,
kBASE_16_4,
kBASE_10,
kBASE_2,
kBASE_DEFAULT

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: TIADebug.cxx,v 1.17 2005-08-15 18:52:15 stephena Exp $
// $Id: TIADebug.cxx,v 1.18 2005-08-16 18:34:12 stephena Exp $
//============================================================================
#include "System.hxx"
@ -78,8 +78,13 @@ DebuggerState& TIADebug::getState()
myState.pf.push_back(pf1());
myState.pf.push_back(pf2());
myState.refP0 = refP0(); myState.delP0 = vdelP0();
myState.refP1 = refP1(); myState.delP1 = vdelP1();
// Reflect and delay registers
myState.refP0 = refP0(); myState.vdelP0 = vdelP0();
myState.refP1 = refP1(); myState.vdelP1 = vdelP1();
// NUSIZ registers
myState.nusiz.push_back(nusiz0());
myState.nusiz.push_back(nusiz1());
return myState;
}
@ -124,6 +129,15 @@ void TIADebug::saveOldState()
myOldState.pf.push_back(pf0());
myOldState.pf.push_back(pf1());
myOldState.pf.push_back(pf2());
// Reflect and delay registers
myOldState.refP0 = refP0(); myOldState.vdelP0 = vdelP0();
myOldState.refP1 = refP1(); myOldState.vdelP1 = vdelP1();
// NUSIZ registers
myOldState.nusiz.push_back(nusiz0());
myOldState.nusiz.push_back(nusiz1());
}
/* the set methods now use mySystem->poke(). This will save us the
@ -365,7 +379,7 @@ uInt8 TIADebug::nusiz0(int newVal)
if(newVal > -1)
mySystem->poke(NUSIZ0, newVal);
return myTIA->myGRP0;
return myTIA->myNUSIZ0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -374,7 +388,7 @@ uInt8 TIADebug::nusiz1(int newVal)
if(newVal > -1)
mySystem->poke(NUSIZ1, newVal);
return myTIA->myGRP1;
return myTIA->myNUSIZ1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -658,7 +672,7 @@ string TIADebug::state()
ret += " ";
ret += booleanWithLabel("reflect", state.refP0);
ret += " ";
ret += booleanWithLabel("delay", state.delP0);
ret += booleanWithLabel("delay", state.vdelP0);
ret += "\n";
ret += "P1: GR=";
@ -674,7 +688,7 @@ string TIADebug::state()
ret += " ";
ret += booleanWithLabel("reflect", state.refP1);
ret += " ";
ret += booleanWithLabel("delay", state.delP1);
ret += booleanWithLabel("delay", state.vdelP1);
ret += "\n";
ret += "M0: ";

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: TIADebug.hxx,v 1.15 2005-08-15 18:52:15 stephena Exp $
// $Id: TIADebug.hxx,v 1.16 2005-08-16 18:34:12 stephena Exp $
//============================================================================
#ifndef TIA_DEBUG_HXX
@ -95,9 +95,10 @@ class TiaState : public DebuggerState
IntArray pos;
IntArray hm;
IntArray pf;
IntArray nusiz;
bool refP0, delP0;
bool refP1, delP1;
bool refP0, vdelP0;
bool refP1, vdelP1;
};
class TIADebug : public DebuggerSystem

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: TiaInfoWidget.cxx,v 1.2 2005-08-10 12:23:42 stephena Exp $
// $Id: TiaInfoWidget.cxx,v 1.3 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -35,7 +35,7 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, int x, int y, int w, int h)
CommandSender(boss)
{
int xpos = x, ypos = y, lwidth = 45;
const GUI::Font& font = instance()->consoleFont();
const GUI::Font& font = instance()->font();
// Add frame info
xpos = x + 10; ypos = y + 10;
@ -53,11 +53,11 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, int x, int y, int w, int h)
myFrameCycles->setEditable(false);
xpos = x + 20; ypos += kLineHeight + 5;
myVSync = new CheckboxWidget(boss, xpos, ypos-3, 25, kLineHeight, "VSync", 0);
myVSync = new CheckboxWidget(boss, font, xpos, ypos-3, "VSync", 0);
myVSync->setEditable(false);
xpos = x + 20; ypos += kLineHeight + 5;
myVBlank = new CheckboxWidget(boss, xpos, ypos-3, 30, kLineHeight, "VBlank", 0);
myVBlank = new CheckboxWidget(boss, font, xpos, ypos-3, "VBlank", 0);
myVBlank->setEditable(false);
xpos = x + 10 + 100; ypos = y + 10;

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: TiaWidget.cxx,v 1.5 2005-08-15 18:52:15 stephena Exp $
// $Id: TiaWidget.cxx,v 1.6 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,10 +34,20 @@
// ID's for the various widgets
// We need ID's, since there are more than one of several types of widgets
enum {
kRamID = 'TWra',
kColorRegsID = 'TWcr',
kVSyncID = 'TWvs',
kVBlankID = 'TWvb'
kRamID,
kColorRegsID,
kGRP0ID,
kGRP1ID,
kPosP0ID,
kPosP1ID,
kHMP0ID,
kHMP1ID,
kRefP0ID,
kRefP1ID,
kDelP0ID,
kDelP1ID,
kNusizP0ID,
kNusizP1ID
};
// Color registers
@ -54,9 +64,10 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
CommandSender(boss)
{
const GUI::Font& font = instance()->consoleFont();
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
int xpos = 10, ypos = 25, lwidth = 4 * font.getMaxCharWidth();
int fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight();
int fontWidth = font.getMaxCharWidth();
StaticTextWidget* t;
// Create a 16x1 grid holding byte values with labels
@ -145,18 +156,7 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
myCOLUBKColor->setTarget(this);
// P0 register info
xpos = 10; ypos += 2*lineHeight;
t = new StaticTextWidget(boss, xpos, ypos+2,
7*fontWidth, fontHeight,
"P0/ GR:", kTextAlignLeft);
t->setFont(font);
xpos += 7*fontWidth + 5;
myGRP0 = new ToggleBitWidget(boss, font, xpos, ypos, 8, 1);
myGRP0->setTarget(this);
addFocusWidget(myGRP0);
// Set the strings to be used in the PSRegister
// Set the strings to be used in the grPx registers
// We only do this once because it's the state that changes, not the strings
const char* offstr[] = { "0", "0", "0", "0", "0", "0", "0", "0" };
const char* onstr[] = { "1", "1", "1", "1", "1", "1", "1", "1" };
@ -166,7 +166,157 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
off.push_back(offstr[i]);
on.push_back(onstr[i]);
}
////////////////////////////
// P0 register info
////////////////////////////
// grP0
xpos = 10; ypos += 2*lineHeight;
t = new StaticTextWidget(boss, xpos, ypos+2,
7*fontWidth, fontHeight,
"P0/ GR:", kTextAlignLeft);
t->setFont(font);
xpos += 7*fontWidth + 5;
myGRP0 = new ToggleBitWidget(boss, font, xpos, ypos, 8, 1);
myGRP0->setList(off, on);
myGRP0->setTarget(this);
myGRP0->setID(kGRP0ID);
addFocusWidget(myGRP0);
// posP0
xpos += myGRP0->getWidth() + 8;
t = new StaticTextWidget(boss, xpos, ypos+2,
4*fontWidth, fontHeight,
"Pos:", kTextAlignLeft);
t->setFont(font);
xpos += 4*fontWidth + 5;
myPosP0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 2, 8, kBASE_16);
myPosP0->setTarget(this);
myPosP0->setID(kPosP0ID);
addFocusWidget(myPosP0);
// hmP0
xpos += myPosP0->getWidth() + 8;
t = new StaticTextWidget(boss, xpos, ypos+2,
3*fontWidth, fontHeight,
"HM:", kTextAlignLeft);
t->setFont(font);
xpos += 3*fontWidth + 5;
myHMP0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_4);
myHMP0->setTarget(this);
myHMP0->setID(kHMP0ID);
addFocusWidget(myHMP0);
// P0 reflect and delay
xpos += myHMP0->getWidth() + 10;
myRefP0 = new CheckboxWidget(boss, font, xpos, ypos+1, "Reflect", kCheckActionCmd);
myRefP0->setFont(font);
myRefP0->setTarget(this);
myRefP0->setID(kRefP0ID);
addFocusWidget(myRefP0);
xpos += myRefP0->getWidth() + 10;
myDelP0 = new CheckboxWidget(boss, font, xpos, ypos+1, "Delay", kCheckActionCmd);
myDelP0->setFont(font);
myDelP0->setTarget(this);
myDelP0->setID(kDelP0ID);
addFocusWidget(myDelP0);
// NUSIZ0
xpos = 10 + lwidth; ypos += myGRP0->getHeight() + 2;
t = new StaticTextWidget(boss, xpos, ypos+2,
7*fontWidth, fontHeight,
"NUSIZ0:", kTextAlignLeft);
t->setFont(font);
xpos += 7*fontWidth + 5;
myNusiz0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 3, kBASE_16_4);
myNusiz0->setTarget(this);
myNusiz0->setID(kNusizP0ID);
addFocusWidget(myNusiz0);
xpos += myNusiz0->getWidth() + 5;
myNusiz0Text = new EditTextWidget(boss, xpos, ypos+1, 23*fontWidth, lineHeight, "");
myNusiz0Text->setFont(font);
myNusiz0Text->setEditable(false);
////////////////////////////
// P1 register info
////////////////////////////
// grP1
xpos = 10; ypos += 2*lineHeight;
t = new StaticTextWidget(boss, xpos, ypos+2,
7*fontWidth, fontHeight,
"P1/ GR:", kTextAlignLeft);
t->setFont(font);
xpos += 7*fontWidth + 5;
myGRP1 = new ToggleBitWidget(boss, font, xpos, ypos, 8, 1);
myGRP1->setList(off, on);
myGRP1->setTarget(this);
myGRP1->setID(kGRP1ID);
addFocusWidget(myGRP1);
// posP1
xpos += myGRP1->getWidth() + 8;
t = new StaticTextWidget(boss, xpos, ypos+2,
4*fontWidth, fontHeight,
"Pos:", kTextAlignLeft);
t->setFont(font);
xpos += 4*fontWidth + 5;
myPosP1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 2, 8, kBASE_16);
myPosP1->setTarget(this);
myPosP1->setID(kPosP1ID);
addFocusWidget(myPosP1);
// hmP1
xpos += myPosP1->getWidth() + 8;
t = new StaticTextWidget(boss, xpos, ypos+2,
3*fontWidth, fontHeight,
"HM:", kTextAlignLeft);
t->setFont(font);
xpos += 3*fontWidth + 5;
myHMP1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_4);
myHMP1->setTarget(this);
myHMP1->setID(kHMP1ID);
addFocusWidget(myHMP1);
// P1 reflect and delay
xpos += myHMP1->getWidth() + 10;
myRefP1 = new CheckboxWidget(boss, font, xpos, ypos+1, "Reflect", kCheckActionCmd);
myRefP1->setFont(font);
myRefP1->setTarget(this);
myRefP1->setID(kRefP1ID);
addFocusWidget(myRefP1);
xpos += myRefP1->getWidth() + 10;
myDelP1 = new CheckboxWidget(boss, font, xpos, ypos+1, "Delay", kCheckActionCmd);
myDelP1->setFont(font);
myDelP1->setTarget(this);
myDelP1->setID(kDelP1ID);
addFocusWidget(myDelP1);
// NUSIZ1
xpos = 10 + lwidth; ypos += myGRP1->getHeight() + 2;
t = new StaticTextWidget(boss, xpos, ypos+2,
7*fontWidth, fontHeight,
"NUSIZ1:", kTextAlignLeft);
t->setFont(font);
xpos += 7*fontWidth + 5;
myNusiz1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 3, kBASE_16_4);
myNusiz1->setTarget(this);
myNusiz1->setID(kNusizP1ID);
addFocusWidget(myNusiz1);
xpos += myNusiz1->getWidth() + 5;
myNusiz1Text = new EditTextWidget(boss, xpos, ypos+1, 23*fontWidth, lineHeight, "");
myNusiz1Text->setFont(font);
myNusiz1Text->setEditable(false);
}
@ -178,13 +328,14 @@ TiaWidget::~TiaWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
// We simply change the values in the ByteGridWidget
// We simply change the values in the DataGridWidget
// It will then send the 'kDGItemDataChangedCmd' signal to change the actual
// memory location
int addr, value;
string buf;
Debugger& dbg = instance()->debugger();
TIADebug& tia = dbg.tiaDebug();
switch(cmd)
{
@ -195,13 +346,51 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
changeColorRegs();
break;
case kPosP0ID:
tia.posP0(myPosP0->getSelectedValue());
break;
case kPosP1ID:
tia.posP1(myPosP1->getSelectedValue());
break;
case kHMP0ID:
tia.hmP0(myHMP0->getSelectedValue());
break;
case kHMP1ID:
tia.hmP1(myHMP1->getSelectedValue());
break;
case kNusizP0ID:
tia.nusiz0(myNusiz0->getSelectedValue());
myNusiz0Text->setEditString(tia.nusiz0String());
break;
case kNusizP1ID:
tia.nusiz1(myNusiz1->getSelectedValue());
myNusiz1Text->setEditString(tia.nusiz1String());
break;
default:
cerr << "TiaWidget DG changed\n";
break;
}
// FIXME - maybe issue a full reload, since changing one item can affect
// others in this tab??
// loadConfig();
break;
case kTBItemDataChangedCmd:
switch(id)
{
case kGRP0ID:
value = convertBoolToInt(myGRP0->getState());
tia.grP0(value);
break;
case kGRP1ID:
value = convertBoolToInt(myGRP1->getState());
tia.grP1(value);
break;
}
break;
case kDGSelectionChangedCmd:
@ -222,12 +411,20 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kCheckActionCmd:
switch(id)
{
case kVSyncID:
cerr << "vsync toggled\n";
case kRefP0ID:
tia.refP0(myRefP0->getState() ? 1 : 0);
break;
case kVBlankID:
cerr << "vblank toggled\n";
case kRefP1ID:
tia.refP1(myRefP1->getState() ? 1 : 0);
break;
case kDelP0ID:
tia.vdelP0(myDelP0->getState() ? 1 : 0);
break;
case kDelP1ID:
tia.vdelP1(myDelP1->getState() ? 1 : 0);
break;
}
break;
@ -246,7 +443,7 @@ void TiaWidget::fillGrid()
{
IntArray alist;
IntArray vlist;
BoolArray orig, changed;
BoolArray orig, changed, grNew, grOld;
Debugger& dbg = instance()->debugger();
TIADebug& tia = dbg.tiaDebug();
@ -278,8 +475,11 @@ void TiaWidget::fillGrid()
myCOLUPFColor->setColor(state.coluRegs[2]);
myCOLUBKColor->setColor(state.coluRegs[3]);
// GRP0 register
BoolArray grNew, grOld;
////////////////////////////
// P0 register info
////////////////////////////
// grP0
grNew.clear(); grOld.clear();
convertCharToBool(grNew, state.gr[P0]);
convertCharToBool(grOld, oldstate.gr[P0]);
@ -288,6 +488,49 @@ void TiaWidget::fillGrid()
changed.push_back(grNew[i] != grOld[i]);
myGRP0->setState(grNew, changed);
// posP0
myPosP0->setList(0, state.pos[P0], state.pos[P0] != oldstate.pos[P0]);
// hmP0 register
myHMP0->setList(0, state.hm[P0], state.hm[P0] != oldstate.hm[P0]);
// refP0 & vdelP0
myRefP0->setState(state.refP0);
myDelP0->setState(state.vdelP0);
// NUSIZ0
myNusiz0->setList(0, state.nusiz[0], state.nusiz[0] != oldstate.nusiz[0]);
myNusiz0Text->setEditString(tia.nusiz0String());
////////////////////////////
// P1 register info
////////////////////////////
// grP1
grNew.clear(); grOld.clear();
convertCharToBool(grNew, state.gr[P1]);
convertCharToBool(grOld, oldstate.gr[P1]);
changed.clear();
for(unsigned int i = 0; i < 8; ++i)
changed.push_back(grNew[i] != grOld[i]);
myGRP1->setState(grNew, changed);
// posP1
myPosP1->setList(0, state.pos[P1], state.pos[P1] != oldstate.pos[P1]);
// hmP1 register
myHMP1->setList(0, state.hm[P1], state.hm[P1] != oldstate.hm[P1]);
// refP1 & vdelP1
myRefP1->setState(state.refP1);
myDelP1->setState(state.vdelP1);
// NUSIZ1
myNusiz1->setList(0, state.nusiz[1], state.nusiz[1] != oldstate.nusiz[1]);
myNusiz1Text->setEditString(tia.nusiz1String());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -302,6 +545,20 @@ void TiaWidget::convertCharToBool(BoolArray& b, unsigned char value)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TiaWidget::convertBoolToInt(const BoolArray& b)
{
unsigned int value = 0, size = b.size();
for(unsigned int i = 0; i < size; ++i)
{
if(b[i])
value |= 1<<(size-i-1);
}
return value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::changeColorRegs()
{

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: TiaWidget.hxx,v 1.3 2005-08-15 18:52:15 stephena Exp $
// $Id: TiaWidget.hxx,v 1.4 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -47,6 +47,7 @@ class TiaWidget : public Widget, public CommandSender
void fillGrid();
void changeColorRegs();
void convertCharToBool(BoolArray& b, unsigned char value);
int convertBoolToInt(const BoolArray& b);
private:
DataGridWidget* myRamGrid;
@ -63,6 +64,22 @@ class TiaWidget : public Widget, public CommandSender
ToggleBitWidget* myGRP0;
ToggleBitWidget* myGRP1;
DataGridWidget* myPosP0;
DataGridWidget* myPosP1;
DataGridWidget* myHMP0;
DataGridWidget* myHMP1;
DataGridWidget* myNusiz0;
DataGridWidget* myNusiz1;
EditTextWidget* myNusiz0Text;
EditTextWidget* myNusiz1Text;
CheckboxWidget* myRefP0;
CheckboxWidget* myRefP1;
CheckboxWidget* myDelP0;
CheckboxWidget* myDelP1;
};
#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: AudioDialog.cxx,v 1.12 2005-08-10 12:23:42 stephena Exp $
// $Id: AudioDialog.cxx,v 1.13 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -45,6 +45,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
{
const GUI::Font& font = instance()->font();
int yoff = 10,
xoff = 30,
woff = _w - 80,
@ -71,7 +72,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
// Enable sound
new StaticTextWidget(this, xoff+8, yoff+3, 20, kLineHeight, "", kTextAlignLeft);
mySoundEnableCheckbox = new CheckboxWidget(this, xoff+28, yoff, woff - 14, kLineHeight,
mySoundEnableCheckbox = new CheckboxWidget(this, font, xoff+28, yoff,
"Enable sound", kSoundEnableChanged);
yoff += kAudioRowHeight + 12;

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.1 2005-08-05 02:28:22 urchlay Exp $
// $Id: CheatCodeDialog.cxx,v 1.2 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -38,11 +38,12 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
{
const GUI::Font& font = instance()->font();
myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Codes", kTextAlignCenter);
addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C');
addButton(w - (kButtonWidth + 10), h - 48, "Load", kLoadCmd, 'C');
myEnableCheat = new CheckboxWidget(this, 10, 20, kButtonWidth+10, kLineHeight,
"Enabled", kEnableCheat);
myEnableCheat = new CheckboxWidget(this, font, 10, 20, "Enabled", kEnableCheat);
myEnableCheat->setState(false);
myCheat = 0;
}

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.23 2005-08-15 18:52:15 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.24 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -126,7 +126,7 @@ void DataGridWidget::setList(const int a, const int v, const bool c)
alist.push_back(a);
vlist.push_back(v);
changed.push_back(changed);
changed.push_back(c);
setList(alist, vlist, changed);
}

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.9 2005-08-10 12:23:42 stephena Exp $
// $Id: LauncherOptionsDialog.cxx,v 1.10 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,6 +36,8 @@ LauncherOptionsDialog::LauncherOptionsDialog(
CommandSender(boss),
myBrowser(NULL)
{
const GUI::Font& font = instance()->font();
const int vBorder = 4;
int yoffset;
@ -71,7 +73,7 @@ LauncherOptionsDialog::LauncherOptionsDialog(
yoffset += 18;
// Snapshot single or multiple saves
mySnapSingleCheckbox = new CheckboxWidget(myTab, 30, yoffset, 80, kLineHeight,
mySnapSingleCheckbox = new CheckboxWidget(myTab, font, 30, yoffset,
"Multiple snapshots");
// Activate the first tab

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: ToggleBitWidget.hxx,v 1.4 2005-08-02 18:28:29 stephena Exp $
// $Id: ToggleBitWidget.hxx,v 1.5 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -46,6 +46,7 @@ class ToggleBitWidget : public Widget, public CommandSender
void setList(const StringList& off, const StringList& on);
void setState(const BoolArray& state, const BoolArray& changed);
const BoolArray& getState() { return _stateList; }
bool getSelectedState() const { return _stateList[_selectedItem]; }
virtual void handleMouseDown(int x, int y, int button, int clickCount);

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.20 2005-08-10 12:23:42 stephena Exp $
// $Id: VideoDialog.cxx,v 1.21 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -44,6 +44,8 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
{
const GUI::Font& font = instance()->font();
int yoff = 10,
xoff = 2,
woff = 110,
@ -120,11 +122,11 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myZoomLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 10;
myFullscreenCheckbox = new CheckboxWidget(this, xoff + 5, yoff, woff - 14, kLineHeight,
myFullscreenCheckbox = new CheckboxWidget(this, font, xoff + 5, yoff,
"Fullscreen mode");
yoff += kVideoRowHeight + 4;
myUseDeskResCheckbox = new CheckboxWidget(this, xoff + 5, yoff, woff - 14, kLineHeight,
myUseDeskResCheckbox = new CheckboxWidget(this, font, xoff + 5, yoff,
"Desktop Res in FS");
yoff += kVideoRowHeight + 20;

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.28 2005-08-11 19:12:39 stephena Exp $
// $Id: Widget.cxx,v 1.29 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -325,7 +325,8 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h,
_cmd(cmd),
_hotkey(hotkey)
{
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG |
WIDGET_RETAIN_FOCUS;
_type = kButtonWidget;
}
@ -376,14 +377,19 @@ static unsigned int checked_img[8] =
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h,
const string& label, int cmd, uInt8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
_state(false),
_editable(true)
CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, const string& label,
int cmd, uInt8 hotkey)
: ButtonWidget(boss, x, y, 16, 16, label, cmd, hotkey),
_state(false),
_editable(true)
{
_flags = WIDGET_ENABLED;
_flags = WIDGET_ENABLED | WIDGET_RETAIN_FOCUS;
_type = kCheckboxWidget;
setFont(font);
_w = font.getStringWidth(label) + 20;
_h = font.getFontHeight() < 14 ? 14 : font.getFontHeight();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -398,6 +404,26 @@ void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckboxWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
bool handled = false;
// (De)activate with space or return
switch(keycode)
{
case '\n': // enter/return
case '\r':
case ' ' : // space
// Simulate mouse event
handleMouseUp(0, 0, 1, 0);
handled = true;
break;
}
return handled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::setState(bool state)
{
@ -414,18 +440,27 @@ void CheckboxWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = _boss->instance()->frameBuffer();
// Depending on font size, either the font or box will need to be
// centered vertically
int box_yoff = 0, text_yoff = 0;
if(_h > 14) // center box
box_yoff = (_h - 14) / 2;
else // center text
text_yoff = (14 - _font->getFontHeight()) / 2;
// Draw the box
fb.box(_x, _y, 14, 14, kColor, kShadowColor);
fb.box(_x, _y + box_yoff, 14, 14, kColor, kShadowColor);
// If checked, draw cross inside the box
if(_state)
fb.drawBitmap(checked_img, _x + 3, _y + 3,
fb.drawBitmap(checked_img, _x + 3, _y + box_yoff + 3,
isEnabled() ? _color : kColor);
else
fb.fillRect(_x + 2, _y + 2, 10, 10, kBGColor);
fb.fillRect(_x + 2, _y + box_yoff + 2, 10, 10, kBGColor);
// Finally draw the label
fb.drawString(_font, _label, _x + 20, _y + 3, _w, isEnabled() ? _color : kColor);
fb.drawString(_font, _label, _x + 20, _y + text_yoff, _w,
isEnabled() ? _color : kColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.27 2005-08-10 12:23:42 stephena Exp $
// $Id: Widget.hxx,v 1.28 2005-08-16 18:34:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -71,7 +71,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.27 2005-08-10 12:23:42 stephena Exp $
@version $Id: Widget.hxx,v 1.28 2005-08-16 18:34:12 stephena Exp $
*/
class Widget : public GuiObject
{
@ -200,6 +200,8 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
void handleMouseEntered(int button);
void handleMouseLeft(int button);
bool wantsFocus() { return true; };
protected:
void drawWidget(bool hilite);
@ -213,12 +215,13 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
class CheckboxWidget : public ButtonWidget
{
public:
CheckboxWidget(GuiObject* boss, int x, int y, int w, int h,
CheckboxWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
const string& label, int cmd = 0, uInt8 hotkey = 0);
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);
void setEditable(bool editable) { _editable = editable; }

View File

@ -2,7 +2,6 @@ MODULE := src/gui
MODULE_OBJS := \
src/gui/AboutDialog.o \
src/gui/AddrValueWidget.o \
src/gui/AudioDialog.o \
src/gui/BrowserDialog.o \
src/gui/ColorWidget.o \