Changed debugger font to 8x13 instead of 9x15. I'm not sure which

one we'll use yet.

More layout issue fixes.  When I changed the debugger fonts, everything
was redrawn correctly (just smaller).  This is exactly what should
happen, and is a good first step to making the GUI be font-size aware.

Added change tracking to the CPU PS register (ToggleBitWidget).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@708 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-08-02 18:28:29 +00:00
parent 10bec1607c
commit f27b41ca22
10 changed files with 2411 additions and 2769 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CpuWidget.cxx,v 1.2 2005-08-02 15:59:43 stephena Exp $ // $Id: CpuWidget.cxx,v 1.3 2005-08-02 18:28:27 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -57,37 +57,38 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h)
: Widget(boss, x, y, w, h), : Widget(boss, x, y, w, h),
CommandSender(boss) CommandSender(boss)
{ {
int xpos = 10, ypos = 20, lwidth = 4 * kCFontWidth;
StaticTextWidget* t;
const GUI::Font& font = instance()->consoleFont(); const GUI::Font& font = instance()->consoleFont();
int xpos = 10, ypos = 20, lwidth = 4 * font.getMaxCharWidth();
int fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight();
StaticTextWidget* t;
// Create a 1x5 grid with labels for the CPU registers // Create a 1x5 grid with labels for the CPU registers
myCpuGrid = new DataGridWidget(boss, xpos + lwidth, ypos, 1, 5, 8, 16); myCpuGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 5, 8, 16);
myCpuGrid->setTarget(this); myCpuGrid->setTarget(this);
myActiveWidget = myCpuGrid; myActiveWidget = myCpuGrid;
string labels[5] = { "PC:", "SP:", "A:", "X:", "Y:" }; string labels[5] = { "PC:", "SP:", "A:", "X:", "Y:" };
for(int row = 0; row < 5; ++row) for(int row = 0; row < 5; ++row)
{ {
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2, t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
lwidth, kCFontHeight, lwidth, fontHeight,
labels[row], kTextAlignLeft); labels[row], kTextAlignLeft);
t->setFont(font); t->setFont(font);
} }
// Create a read-only textbox containing the current PC label // Create a read-only textbox containing the current PC label
xpos += lwidth + myCpuGrid->colWidth() + 10; xpos += lwidth + myCpuGrid->colWidth() + 10;
myPCLabel = new EditTextWidget(boss, xpos, ypos, 100, kCLineHeight, ""); myPCLabel = new EditTextWidget(boss, xpos, ypos, 100, lineHeight, "");
myPCLabel->clearFlags(WIDGET_TAB_NAVIGATE); myPCLabel->clearFlags(WIDGET_TAB_NAVIGATE);
myPCLabel->setFont(font); myPCLabel->setFont(font);
myPCLabel->setEditable(false); myPCLabel->setEditable(false);
// Create a bitfield widget for changing the processor status // Create a bitfield widget for changing the processor status
xpos = 10; ypos += 5*kCLineHeight + 5; xpos = 10; ypos += 5*lineHeight + 5;
t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, kCFontHeight, t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, fontHeight,
"PS:", kTextAlignLeft); "PS:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
myPSRegister = new ToggleBitWidget(boss, xpos+lwidth, ypos-2, 8, 1); myPSRegister = new ToggleBitWidget(boss, font, xpos+lwidth, ypos-2, 8, 1);
myPSRegister->setTarget(this); myPSRegister->setTarget(this);
// FIXME -------------------------- // FIXME --------------------------
@ -95,7 +96,7 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h)
// so I won't bother fixing it here. // so I won't bother fixing it here.
// And some status fields // And some status fields
xpos = 10; ypos += 2*kCLineHeight; xpos = 10; ypos += 2*lineHeight;
new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "Current Ins:", kTextAlignLeft); new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "Current Ins:", kTextAlignLeft);
xpos += 60; xpos += 60;
myCurrentIns = new EditTextWidget(boss, xpos, ypos-2, 300, kLineHeight, ""); myCurrentIns = new EditTextWidget(boss, xpos, ypos-2, 300, kLineHeight, "");
@ -256,7 +257,11 @@ void CpuWidget::fillGrid()
myCpuGrid->setList(alist, vlist, changed); myCpuGrid->setList(alist, vlist, changed);
// Update the PS register booleans // Update the PS register booleans
myPSRegister->setState(state.PSbits); changed.clear();
for(unsigned int i = 0; i < state.PSbits.size(); ++i)
changed.push_back(state.PSbits[i] != oldstate.PSbits[i]);
myPSRegister->setState(state.PSbits, changed);
// Update the other status fields // Update the other status fields
int pc = state.PC; int pc = state.PC;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: RamWidget.cxx,v 1.2 2005-08-02 15:59:43 stephena Exp $ // $Id: RamWidget.cxx,v 1.3 2005-08-02 18:28:27 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -37,21 +37,26 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
: Widget(boss, x, y, w, h), : Widget(boss, x, y, w, h),
CommandSender(boss) CommandSender(boss)
{ {
int xpos = 10, ypos = 25, lwidth = 4 * kCFontWidth;
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
const GUI::Font& font = instance()->consoleFont(); const GUI::Font& font = instance()->consoleFont();
int xpos = 10, ypos = 25, lwidth = 4 * font.getMaxCharWidth();
int fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight();
int fontWidth = font.getMaxCharWidth();
StaticTextWidget* t; StaticTextWidget* t;
// FIXME - this contains magic numbers
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
// Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels // Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels
myRamGrid = new DataGridWidget(boss, xpos + lwidth, ypos, 16, 8, 2, 8, kBASE_16); myRamGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos,
16, 8, 2, 8, kBASE_16);
myRamGrid->setTarget(this); myRamGrid->setTarget(this);
myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE); myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE);
myActiveWidget = myRamGrid; myActiveWidget = myRamGrid;
for(int row = 0; row < 8; ++row) for(int row = 0; row < 8; ++row)
{ {
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2, t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
lwidth, kCFontHeight, lwidth, fontHeight,
Debugger::to_hex_8(row*16 + kRamStart) + string(":"), Debugger::to_hex_8(row*16 + kRamStart) + string(":"),
kTextAlignLeft); kTextAlignLeft);
t->setFont(font); t->setFont(font);
@ -59,42 +64,42 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
for(int col = 0; col < 16; ++col) for(int col = 0; col < 16; ++col)
{ {
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7, t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7,
ypos - kCLineHeight, ypos - lineHeight,
kCFontWidth, kCFontHeight, fontWidth, fontHeight,
Debugger::to_hex_4(col), Debugger::to_hex_4(col),
kTextAlignLeft); kTextAlignLeft);
t->setFont(font); t->setFont(font);
} }
xpos = 20; ypos += 9 * kCLineHeight; xpos = 20; ypos += 9 * lineHeight;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
6*kCFontWidth, kCFontHeight, 6*fontWidth, fontHeight,
"Label:", kTextAlignLeft); "Label:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 6*kCFontWidth + 5; xpos += 6*fontWidth + 5;
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kCLineHeight, ""); myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*fontWidth, lineHeight, "");
myLabel->clearFlags(WIDGET_TAB_NAVIGATE); myLabel->clearFlags(WIDGET_TAB_NAVIGATE);
myLabel->setFont(font); myLabel->setFont(font);
myLabel->setEditable(false); myLabel->setEditable(false);
xpos += 15*kCFontWidth + 20; xpos += 15*fontWidth + 20;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
4*kCFontWidth, kCFontHeight, 4*fontWidth, fontHeight,
"Dec:", kTextAlignLeft); "Dec:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 4*kCFontWidth + 5; xpos += 4*fontWidth + 5;
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kCLineHeight, ""); myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*fontWidth, lineHeight, "");
myDecValue->clearFlags(WIDGET_TAB_NAVIGATE); myDecValue->clearFlags(WIDGET_TAB_NAVIGATE);
myDecValue->setFont(font); myDecValue->setFont(font);
myDecValue->setEditable(false); myDecValue->setEditable(false);
xpos += 4*kCFontWidth + 20; xpos += 4*fontWidth + 20;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
4*kCFontWidth, kCFontHeight, 4*fontWidth, fontHeight,
"Bin:", kTextAlignLeft); "Bin:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 4*kCFontWidth + 5; xpos += 4*fontWidth + 5;
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kCLineHeight, ""); myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*fontWidth, lineHeight, "");
myBinValue->clearFlags(WIDGET_TAB_NAVIGATE); myBinValue->clearFlags(WIDGET_TAB_NAVIGATE);
myBinValue->setFont(font); myBinValue->setFont(font);
myBinValue->setEditable(false); myBinValue->setEditable(false);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TiaWidget.cxx,v 1.2 2005-08-02 15:59:43 stephena Exp $ // $Id: TiaWidget.cxx,v 1.3 2005-08-02 18:28:27 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -52,96 +52,99 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
: Widget(boss, x, y, w, h), : Widget(boss, x, y, w, h),
CommandSender(boss) CommandSender(boss)
{ {
int xpos = 10, ypos = 25, lwidth = 4 * kCFontWidth;
// const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
StaticTextWidget* t;
const GUI::Font& font = instance()->consoleFont(); const GUI::Font& font = instance()->consoleFont();
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 // Create a 16x1 grid holding byte values with labels
myRamGrid = new DataGridWidget(boss, xpos + lwidth, ypos, 16, 1, 2, 8, kBASE_16); myRamGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos,
16, 1, 2, 8, kBASE_16);
myRamGrid->setEditable(false); myRamGrid->setEditable(false);
myRamGrid->setTarget(this); myRamGrid->setTarget(this);
myRamGrid->setID(kRamID); myRamGrid->setID(kRamID);
myActiveWidget = myRamGrid; myActiveWidget = myRamGrid;
t = new StaticTextWidget(boss, xpos, ypos + 2, t = new StaticTextWidget(boss, xpos, ypos + 2,
lwidth, kCFontHeight, lwidth, fontHeight,
Debugger::to_hex_8(0) + string(":"), Debugger::to_hex_8(0) + string(":"),
kTextAlignLeft); kTextAlignLeft);
t->setFont(font); t->setFont(font);
for(int col = 0; col < 16; ++col) for(int col = 0; col < 16; ++col)
{ {
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7, t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7,
ypos - kCLineHeight, ypos - lineHeight,
kCFontWidth, kCFontHeight, fontWidth, fontHeight,
Debugger::to_hex_4(col), Debugger::to_hex_4(col),
kTextAlignLeft); kTextAlignLeft);
t->setFont(font); t->setFont(font);
} }
xpos = 20; ypos += 2 * kCLineHeight; xpos = 20; ypos += 2 * lineHeight;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
6*kCFontWidth, kCFontHeight, 6*fontWidth, fontHeight,
"Label:", kTextAlignLeft); "Label:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 6*kCFontWidth + 5; xpos += 6*fontWidth + 5;
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kCLineHeight, ""); myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*fontWidth, lineHeight, "");
myLabel->clearFlags(WIDGET_TAB_NAVIGATE); myLabel->clearFlags(WIDGET_TAB_NAVIGATE);
myLabel->setFont(font); myLabel->setFont(font);
myLabel->setEditable(false); myLabel->setEditable(false);
xpos += 15*kCFontWidth + 20; xpos += 15*fontWidth + 20;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
4*kCFontWidth, kCFontHeight, 4*fontWidth, fontHeight,
"Dec:", kTextAlignLeft); "Dec:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 4*kCFontWidth + 5; xpos += 4*fontWidth + 5;
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kCLineHeight, ""); myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*fontWidth, lineHeight, "");
myDecValue->clearFlags(WIDGET_TAB_NAVIGATE); myDecValue->clearFlags(WIDGET_TAB_NAVIGATE);
myDecValue->setFont(font); myDecValue->setFont(font);
myDecValue->setEditable(false); myDecValue->setEditable(false);
xpos += 4*kCFontWidth + 20; xpos += 4*fontWidth + 20;
t = new StaticTextWidget(boss, xpos, ypos, t = new StaticTextWidget(boss, xpos, ypos,
4*kCFontWidth, kCFontHeight, 4*fontWidth, fontHeight,
"Bin:", kTextAlignLeft); "Bin:", kTextAlignLeft);
t->setFont(font); t->setFont(font);
xpos += 4*kCFontWidth + 5; xpos += 4*fontWidth + 5;
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kCLineHeight, ""); myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*fontWidth, lineHeight, "");
myBinValue->clearFlags(WIDGET_TAB_NAVIGATE); myBinValue->clearFlags(WIDGET_TAB_NAVIGATE);
myBinValue->setFont(font); myBinValue->setFont(font);
myBinValue->setEditable(false); myBinValue->setEditable(false);
// Color registers // Color registers
const char* regNames[] = { "COLUP0:", "COLUP1:", "COLUPF:", "COLUBK:" }; const char* regNames[] = { "COLUP0:", "COLUP1:", "COLUPF:", "COLUBK:" };
xpos = 10; ypos += 2* kCLineHeight; xpos = 10; ypos += 2*lineHeight;
for(int row = 0; row < 4; ++row) for(int row = 0; row < 4; ++row)
{ {
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2, t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
7*kCFontWidth, kCFontHeight, 7*fontWidth, fontHeight,
regNames[row], regNames[row],
kTextAlignLeft); kTextAlignLeft);
t->setFont(font); t->setFont(font);
} }
xpos += 7*kCFontWidth + 5; xpos += 7*fontWidth + 5;
myColorRegs = new DataGridWidget(boss, xpos, ypos, 1, 4, 2, 8, kBASE_16); myColorRegs = new DataGridWidget(boss, font, xpos, ypos,
1, 4, 2, 8, kBASE_16);
myColorRegs->setTarget(this); myColorRegs->setTarget(this);
myColorRegs->setID(kColorRegsID); myColorRegs->setID(kColorRegsID);
xpos += myColorRegs->colWidth() + 5; xpos += myColorRegs->colWidth() + 5;
myCOLUP0Color = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4); myCOLUP0Color = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
myCOLUP0Color->setTarget(this); myCOLUP0Color->setTarget(this);
ypos += kCLineHeight; ypos += lineHeight;
myCOLUP1Color = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4); myCOLUP1Color = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
myCOLUP1Color->setTarget(this); myCOLUP1Color->setTarget(this);
ypos += kCLineHeight; ypos += lineHeight;
myCOLUPFColor = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4); myCOLUPFColor = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
myCOLUPFColor->setTarget(this); myCOLUPFColor->setTarget(this);
ypos += kCLineHeight; ypos += lineHeight;
myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4); myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
myCOLUBKColor->setTarget(this); myCOLUBKColor->setTarget(this);
/* /*

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DataGridWidget.cxx,v 1.16 2005-08-02 15:59:45 stephena Exp $ // $Id: DataGridWidget.cxx,v 1.17 2005-08-02 18:28:28 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -31,21 +31,23 @@
#include "RamWidget.hxx" #include "RamWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DataGridWidget::DataGridWidget(GuiObject* boss, int x, int y, int cols, int rows, DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows,
int colchars, int bits, BaseFormat base) int colchars, int bits, BaseFormat base)
: EditableWidget(boss, x, y, cols*(colchars * kCFontWidth + 8) + 1, kCLineHeight*rows + 1), : EditableWidget(boss, x, y, cols*(colchars * font.getMaxCharWidth() + 8) + 1,
font.getLineHeight()*rows + 1),
CommandSender(boss), CommandSender(boss),
_rows(rows), _rows(rows),
_cols(cols), _cols(cols),
_currentRow(0), _currentRow(0),
_currentCol(0), _currentCol(0),
_colWidth(colchars * kCFontWidth + 8), _rowHeight(font.getLineHeight()),
_colWidth(colchars * font.getMaxCharWidth() + 8),
_bits(bits), _bits(bits),
_base(base), _base(base),
_selectedItem(0) _selectedItem(0)
{ {
// This widget always uses a monospace font setFont(font);
setFont(instance()->consoleFont());
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_TAB_NAVIGATE; WIDGET_TAB_NAVIGATE;
@ -172,7 +174,7 @@ void DataGridWidget::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int DataGridWidget::findItem(int x, int y) int DataGridWidget::findItem(int x, int y)
{ {
int row = (y - 1) / kCLineHeight; int row = (y - 1) / _rowHeight;
if(row >= _rows) row = _rows - 1; if(row >= _rows) row = _rows - 1;
int col = x / _colWidth; int col = x / _colWidth;
@ -448,8 +450,8 @@ cerr << "DataGridWidget::drawWidget\n";
// Draw the internal grid and labels // Draw the internal grid and labels
int linewidth = _cols * _colWidth; int linewidth = _cols * _colWidth;
for (row = 0; row <= _rows; row++) for (row = 0; row <= _rows; row++)
fb.hLine(_x, _y + (row * kCLineHeight), _x + linewidth, kColor); fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
int lineheight = _rows * kCLineHeight; int lineheight = _rows * _rowHeight;
for (col = 0; col <= _cols; col++) for (col = 0; col <= _cols; col++)
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor); fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
@ -459,16 +461,16 @@ cerr << "DataGridWidget::drawWidget\n";
for (col = 0; col < _cols; col++) for (col = 0; col < _cols; col++)
{ {
int x = _x + 4 + (col * _colWidth); int x = _x + 4 + (col * _colWidth);
int y = _y + 2 + (row * kCLineHeight); int y = _y + 2 + (row * _rowHeight);
int pos = row*_cols + col; int pos = row*_cols + col;
// Draw the selected item inverted, on a highlighted background. // Draw the selected item inverted, on a highlighted background.
if (_currentRow == row && _currentCol == col) if (_currentRow == row && _currentCol == col)
{ {
if (_hasFocus && !_editMode) if (_hasFocus && !_editMode)
fb.fillRect(x - 4, y - 2, _colWidth+1, kCLineHeight+1, kTextColorHi); fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
else else
fb.frameRect(x - 4, y - 2, _colWidth+1, kCLineHeight+1, kTextColorHi); fb.frameRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
} }
if (_selectedItem == pos && _editMode) if (_selectedItem == pos && _editMode)
@ -487,7 +489,7 @@ cerr << "DataGridWidget::drawWidget\n";
if(_changedList[pos]) if(_changedList[pos])
{ {
fb.fillRect(x - 3, y - 1, _colWidth-1, kCLineHeight-1, kTextColorEm); fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm);
fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi); fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi);
} }
else else
@ -504,8 +506,8 @@ cerr << "DataGridWidget::drawWidget\n";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect DataGridWidget::getEditRect() const GUI::Rect DataGridWidget::getEditRect() const
{ {
GUI::Rect r(1, 0, _colWidth, kCLineHeight); GUI::Rect r(1, 0, _colWidth, _rowHeight);
const int rowoffset = _currentRow * kCLineHeight; const int rowoffset = _currentRow * _rowHeight;
const int coloffset = _currentCol * _colWidth + 4; const int coloffset = _currentCol * _colWidth + 4;
r.top += rowoffset; r.top += rowoffset;
r.bottom += rowoffset; r.bottom += rowoffset;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DataGridWidget.hxx,v 1.9 2005-07-07 15:19:04 stephena Exp $ // $Id: DataGridWidget.hxx,v 1.10 2005-08-02 18:28:28 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -51,7 +51,8 @@ enum {
class DataGridWidget : public EditableWidget, public CommandSender class DataGridWidget : public EditableWidget, public CommandSender
{ {
public: public:
DataGridWidget(GuiObject* boss, int x, int y, int cols, int rows, DataGridWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows,
int colchars, int bits, BaseFormat format = kBASE_DEFAULT); int colchars, int bits, BaseFormat format = kBASE_DEFAULT);
virtual ~DataGridWidget(); virtual ~DataGridWidget();
@ -93,6 +94,7 @@ class DataGridWidget : public EditableWidget, public CommandSender
int _cols; int _cols;
int _currentRow; int _currentRow;
int _currentCol; int _currentCol;
int _rowHeight;
int _colWidth; int _colWidth;
int _bits; int _bits;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Font.hxx,v 1.3 2005-08-01 22:33:15 stephena Exp $ // $Id: Font.hxx,v 1.4 2005-08-02 18:28:29 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -52,6 +52,7 @@ class Font
const FontDesc& desc() { return myFontDesc; } const FontDesc& desc() { return myFontDesc; }
int getFontHeight() const { return myFontDesc.height; } int getFontHeight() const { return myFontDesc.height; }
int getLineHeight() const { return myFontDesc.height + 2; }
int getMaxCharWidth() const { return myFontDesc.maxwidth; } int getMaxCharWidth() const { return myFontDesc.maxwidth; }
int getCharWidth(uInt8 chr) const; int getCharWidth(uInt8 chr) const;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: GuiUtils.hxx,v 1.15 2005-08-02 15:59:45 stephena Exp $ // $Id: GuiUtils.hxx,v 1.16 2005-08-02 18:28:29 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -29,16 +29,12 @@
Probably not very neat, but at least it works ... Probably not very neat, but at least it works ...
@author Stephen Anthony @author Stephen Anthony
@version $Id: GuiUtils.hxx,v 1.15 2005-08-02 15:59:45 stephena Exp $ @version $Id: GuiUtils.hxx,v 1.16 2005-08-02 18:28:29 stephena Exp $
*/ */
#define kFontHeight 10 #define kFontHeight 10
#define kLineHeight 12 #define kLineHeight 12
#define kCFontWidth 9
#define kCFontHeight 15
#define kCLineHeight 17
#define kScrollBarWidth 9 #define kScrollBarWidth 9
// Colors indices to use for the various GUI elements // Colors indices to use for the various GUI elements

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: ToggleBitWidget.cxx,v 1.5 2005-08-02 15:59:45 stephena Exp $ // $Id: ToggleBitWidget.cxx,v 1.6 2005-08-02 18:28:29 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -27,19 +27,20 @@
#include "ToggleBitWidget.hxx" #include "ToggleBitWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ToggleBitWidget::ToggleBitWidget(GuiObject* boss, int x, int y, ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font,
int cols, int rows, int colchars) int x, int y, int cols, int rows, int colchars)
: Widget(boss, x, y, cols*(colchars * kCFontWidth + 8) + 1, kCLineHeight*rows + 1), : Widget(boss, x, y, cols*(colchars * font.getMaxCharWidth() + 8) + 1,
font.getLineHeight()*rows + 1),
CommandSender(boss), CommandSender(boss),
_rows(rows), _rows(rows),
_cols(cols), _cols(cols),
_currentRow(0), _currentRow(0),
_currentCol(0), _currentCol(0),
_colWidth(colchars * kCFontWidth + 8), _rowHeight(font.getLineHeight()),
_colWidth(colchars * font.getMaxCharWidth() + 8),
_selectedItem(0) _selectedItem(0)
{ {
// This widget always uses a monospace font setFont(font);
setFont(instance()->consoleFont());
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_TAB_NAVIGATE; WIDGET_TAB_NAVIGATE;
@ -64,10 +65,12 @@ void ToggleBitWidget::setList(const StringList& off, const StringList& on)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleBitWidget::setState(const BoolArray& state) void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
{ {
_stateList.clear(); _stateList.clear();
_stateList = state; _stateList = state;
_changedList.clear();
_changedList = changed;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -112,7 +115,7 @@ void ToggleBitWidget::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ToggleBitWidget::findItem(int x, int y) int ToggleBitWidget::findItem(int x, int y)
{ {
int row = (y - 1) / kCLineHeight; int row = (y - 1) / _rowHeight;
if(row >= _rows) row = _rows - 1; if(row >= _rows) row = _rows - 1;
int col = x / _colWidth; int col = x / _colWidth;
@ -254,8 +257,8 @@ cerr << "ToggleBitWidget::drawWidget\n";
// Draw the internal grid and labels // Draw the internal grid and labels
int linewidth = _cols * _colWidth; int linewidth = _cols * _colWidth;
for (row = 0; row <= _rows; row++) for (row = 0; row <= _rows; row++)
fb.hLine(_x, _y + (row * kCLineHeight), _x + linewidth, kColor); fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
int lineheight = _rows * kCLineHeight; int lineheight = _rows * _rowHeight;
for (col = 0; col <= _cols; col++) for (col = 0; col <= _cols; col++)
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor); fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
@ -265,23 +268,31 @@ cerr << "ToggleBitWidget::drawWidget\n";
for (col = 0; col < _cols; col++) for (col = 0; col < _cols; col++)
{ {
int x = _x + 4 + (col * _colWidth); int x = _x + 4 + (col * _colWidth);
int y = _y + 2 + (row * kCLineHeight); int y = _y + 2 + (row * _rowHeight);
int pos = row*_cols + col; int pos = row*_cols + col;
// Draw the selected item inverted, on a highlighted background. // Draw the selected item inverted, on a highlighted background.
if (_currentRow == row && _currentCol == col) if (_currentRow == row && _currentCol == col)
{ {
if (_hasFocus) if (_hasFocus)
fb.fillRect(x - 4, y - 2, _colWidth+1, kCLineHeight+1, kTextColorHi); fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
else else
fb.frameRect(x - 4, y - 2, _colWidth+1, kCLineHeight+1, kTextColorHi); fb.frameRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
} }
if(_stateList[pos]) if(_stateList[pos])
buffer = _onList[pos]; buffer = _onList[pos];
else else
buffer = _offList[pos]; buffer = _offList[pos];
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
// Highlight changes
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm);
fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi);
}
else
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
} }
} }
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: ToggleBitWidget.hxx,v 1.3 2005-07-05 15:25:44 stephena Exp $ // $Id: ToggleBitWidget.hxx,v 1.4 2005-08-02 18:28:29 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -39,12 +39,12 @@ enum {
class ToggleBitWidget : public Widget, public CommandSender class ToggleBitWidget : public Widget, public CommandSender
{ {
public: public:
ToggleBitWidget(GuiObject* boss, int x, int y, int cols, int rows, ToggleBitWidget(GuiObject* boss, const GUI::Font& font,
int colchars = 1); int x, int y, int cols, int rows, int colchars = 1);
virtual ~ToggleBitWidget(); virtual ~ToggleBitWidget();
void setList(const StringList& off, const StringList& on); void setList(const StringList& off, const StringList& on);
void setState(const BoolArray& state); void setState(const BoolArray& state, const BoolArray& changed);
bool getSelectedState() const { return _stateList[_selectedItem]; } bool getSelectedState() const { return _stateList[_selectedItem]; }
@ -66,12 +66,14 @@ class ToggleBitWidget : public Widget, public CommandSender
int _cols; int _cols;
int _currentRow; int _currentRow;
int _currentCol; int _currentCol;
int _rowHeight;
int _colWidth; int _colWidth;
int _selectedItem; int _selectedItem;
StringList _offList; StringList _offList;
StringList _onList; StringList _onList;
BoolArray _stateList; BoolArray _stateList;
BoolArray _changedList;
}; };
#endif #endif