mirror of https://github.com/stella-emu/stella.git
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:
parent
10bec1607c
commit
f27b41ca22
|
@ -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: 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
|
||||
// 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),
|
||||
CommandSender(boss)
|
||||
{
|
||||
int xpos = 10, ypos = 20, lwidth = 4 * kCFontWidth;
|
||||
StaticTextWidget* t;
|
||||
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
|
||||
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);
|
||||
myActiveWidget = myCpuGrid;
|
||||
|
||||
string labels[5] = { "PC:", "SP:", "A:", "X:", "Y:" };
|
||||
for(int row = 0; row < 5; ++row)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2,
|
||||
lwidth, kCFontHeight,
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
|
||||
lwidth, fontHeight,
|
||||
labels[row], kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
}
|
||||
|
||||
// Create a read-only textbox containing the current PC label
|
||||
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->setFont(font);
|
||||
myPCLabel->setEditable(false);
|
||||
|
||||
// Create a bitfield widget for changing the processor status
|
||||
xpos = 10; ypos += 5*kCLineHeight + 5;
|
||||
t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, kCFontHeight,
|
||||
xpos = 10; ypos += 5*lineHeight + 5;
|
||||
t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, fontHeight,
|
||||
"PS:", kTextAlignLeft);
|
||||
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);
|
||||
|
||||
// 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.
|
||||
|
||||
// And some status fields
|
||||
xpos = 10; ypos += 2*kCLineHeight;
|
||||
xpos = 10; ypos += 2*lineHeight;
|
||||
new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "Current Ins:", kTextAlignLeft);
|
||||
xpos += 60;
|
||||
myCurrentIns = new EditTextWidget(boss, xpos, ypos-2, 300, kLineHeight, "");
|
||||
|
@ -256,7 +257,11 @@ void CpuWidget::fillGrid()
|
|||
myCpuGrid->setList(alist, vlist, changed);
|
||||
|
||||
// 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
|
||||
int pc = state.PC;
|
||||
|
|
|
@ -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.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
|
||||
// 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),
|
||||
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();
|
||||
int xpos = 10, ypos = 25, lwidth = 4 * font.getMaxCharWidth();
|
||||
int fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight();
|
||||
int fontWidth = font.getMaxCharWidth();
|
||||
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
|
||||
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->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myActiveWidget = myRamGrid;
|
||||
|
||||
for(int row = 0; row < 8; ++row)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2,
|
||||
lwidth, kCFontHeight,
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
|
||||
lwidth, fontHeight,
|
||||
Debugger::to_hex_8(row*16 + kRamStart) + string(":"),
|
||||
kTextAlignLeft);
|
||||
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)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7,
|
||||
ypos - kCLineHeight,
|
||||
kCFontWidth, kCFontHeight,
|
||||
ypos - lineHeight,
|
||||
fontWidth, fontHeight,
|
||||
Debugger::to_hex_4(col),
|
||||
kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
}
|
||||
|
||||
xpos = 20; ypos += 9 * kCLineHeight;
|
||||
xpos = 20; ypos += 9 * lineHeight;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
6*kCFontWidth, kCFontHeight,
|
||||
6*fontWidth, fontHeight,
|
||||
"Label:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 6*kCFontWidth + 5;
|
||||
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 6*fontWidth + 5;
|
||||
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*fontWidth, lineHeight, "");
|
||||
myLabel->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myLabel->setFont(font);
|
||||
myLabel->setEditable(false);
|
||||
|
||||
xpos += 15*kCFontWidth + 20;
|
||||
xpos += 15*fontWidth + 20;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
4*kCFontWidth, kCFontHeight,
|
||||
4*fontWidth, fontHeight,
|
||||
"Dec:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 4*kCFontWidth + 5;
|
||||
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 4*fontWidth + 5;
|
||||
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*fontWidth, lineHeight, "");
|
||||
myDecValue->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myDecValue->setFont(font);
|
||||
myDecValue->setEditable(false);
|
||||
|
||||
xpos += 4*kCFontWidth + 20;
|
||||
xpos += 4*fontWidth + 20;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
4*kCFontWidth, kCFontHeight,
|
||||
4*fontWidth, fontHeight,
|
||||
"Bin:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 4*kCFontWidth + 5;
|
||||
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 4*fontWidth + 5;
|
||||
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*fontWidth, lineHeight, "");
|
||||
myBinValue->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myBinValue->setFont(font);
|
||||
myBinValue->setEditable(false);
|
||||
|
|
|
@ -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.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
|
||||
// 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),
|
||||
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();
|
||||
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
|
||||
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->setTarget(this);
|
||||
myRamGrid->setID(kRamID);
|
||||
myActiveWidget = myRamGrid;
|
||||
|
||||
t = new StaticTextWidget(boss, xpos, ypos + 2,
|
||||
lwidth, kCFontHeight,
|
||||
lwidth, fontHeight,
|
||||
Debugger::to_hex_8(0) + string(":"),
|
||||
kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
for(int col = 0; col < 16; ++col)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7,
|
||||
ypos - kCLineHeight,
|
||||
kCFontWidth, kCFontHeight,
|
||||
ypos - lineHeight,
|
||||
fontWidth, fontHeight,
|
||||
Debugger::to_hex_4(col),
|
||||
kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
}
|
||||
|
||||
xpos = 20; ypos += 2 * kCLineHeight;
|
||||
xpos = 20; ypos += 2 * lineHeight;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
6*kCFontWidth, kCFontHeight,
|
||||
6*fontWidth, fontHeight,
|
||||
"Label:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 6*kCFontWidth + 5;
|
||||
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 6*fontWidth + 5;
|
||||
myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*fontWidth, lineHeight, "");
|
||||
myLabel->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myLabel->setFont(font);
|
||||
myLabel->setEditable(false);
|
||||
|
||||
xpos += 15*kCFontWidth + 20;
|
||||
xpos += 15*fontWidth + 20;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
4*kCFontWidth, kCFontHeight,
|
||||
4*fontWidth, fontHeight,
|
||||
"Dec:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 4*kCFontWidth + 5;
|
||||
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 4*fontWidth + 5;
|
||||
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*fontWidth, lineHeight, "");
|
||||
myDecValue->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myDecValue->setFont(font);
|
||||
myDecValue->setEditable(false);
|
||||
|
||||
xpos += 4*kCFontWidth + 20;
|
||||
xpos += 4*fontWidth + 20;
|
||||
t = new StaticTextWidget(boss, xpos, ypos,
|
||||
4*kCFontWidth, kCFontHeight,
|
||||
4*fontWidth, fontHeight,
|
||||
"Bin:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
xpos += 4*kCFontWidth + 5;
|
||||
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kCLineHeight, "");
|
||||
xpos += 4*fontWidth + 5;
|
||||
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*fontWidth, lineHeight, "");
|
||||
myBinValue->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
myBinValue->setFont(font);
|
||||
myBinValue->setEditable(false);
|
||||
|
||||
// Color registers
|
||||
const char* regNames[] = { "COLUP0:", "COLUP1:", "COLUPF:", "COLUBK:" };
|
||||
xpos = 10; ypos += 2* kCLineHeight;
|
||||
xpos = 10; ypos += 2*lineHeight;
|
||||
for(int row = 0; row < 4; ++row)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*kCLineHeight + 2,
|
||||
7*kCFontWidth, kCFontHeight,
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
|
||||
7*fontWidth, fontHeight,
|
||||
regNames[row],
|
||||
kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
}
|
||||
xpos += 7*kCFontWidth + 5;
|
||||
myColorRegs = new DataGridWidget(boss, xpos, ypos, 1, 4, 2, 8, kBASE_16);
|
||||
xpos += 7*fontWidth + 5;
|
||||
myColorRegs = new DataGridWidget(boss, font, xpos, ypos,
|
||||
1, 4, 2, 8, kBASE_16);
|
||||
myColorRegs->setTarget(this);
|
||||
myColorRegs->setID(kColorRegsID);
|
||||
|
||||
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);
|
||||
|
||||
ypos += kCLineHeight;
|
||||
myCOLUP1Color = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4);
|
||||
ypos += lineHeight;
|
||||
myCOLUP1Color = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
|
||||
myCOLUP1Color->setTarget(this);
|
||||
|
||||
ypos += kCLineHeight;
|
||||
myCOLUPFColor = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4);
|
||||
ypos += lineHeight;
|
||||
myCOLUPFColor = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
|
||||
myCOLUPFColor->setTarget(this);
|
||||
|
||||
ypos += kCLineHeight;
|
||||
myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, kCLineHeight - 4);
|
||||
ypos += lineHeight;
|
||||
myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, lineHeight - 4);
|
||||
myCOLUBKColor->setTarget(this);
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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.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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -31,21 +31,23 @@
|
|||
#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)
|
||||
: 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),
|
||||
_rows(rows),
|
||||
_cols(cols),
|
||||
_currentRow(0),
|
||||
_currentCol(0),
|
||||
_colWidth(colchars * kCFontWidth + 8),
|
||||
_rowHeight(font.getLineHeight()),
|
||||
_colWidth(colchars * font.getMaxCharWidth() + 8),
|
||||
_bits(bits),
|
||||
_base(base),
|
||||
_selectedItem(0)
|
||||
{
|
||||
// This widget always uses a monospace font
|
||||
setFont(instance()->consoleFont());
|
||||
setFont(font);
|
||||
|
||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
|
||||
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 row = (y - 1) / kCLineHeight;
|
||||
int row = (y - 1) / _rowHeight;
|
||||
if(row >= _rows) row = _rows - 1;
|
||||
|
||||
int col = x / _colWidth;
|
||||
|
@ -448,8 +450,8 @@ cerr << "DataGridWidget::drawWidget\n";
|
|||
// Draw the internal grid and labels
|
||||
int linewidth = _cols * _colWidth;
|
||||
for (row = 0; row <= _rows; row++)
|
||||
fb.hLine(_x, _y + (row * kCLineHeight), _x + linewidth, kColor);
|
||||
int lineheight = _rows * kCLineHeight;
|
||||
fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
|
||||
int lineheight = _rows * _rowHeight;
|
||||
for (col = 0; col <= _cols; col++)
|
||||
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
|
||||
|
||||
|
@ -459,16 +461,16 @@ cerr << "DataGridWidget::drawWidget\n";
|
|||
for (col = 0; col < _cols; col++)
|
||||
{
|
||||
int x = _x + 4 + (col * _colWidth);
|
||||
int y = _y + 2 + (row * kCLineHeight);
|
||||
int y = _y + 2 + (row * _rowHeight);
|
||||
int pos = row*_cols + col;
|
||||
|
||||
// Draw the selected item inverted, on a highlighted background.
|
||||
if (_currentRow == row && _currentCol == col)
|
||||
{
|
||||
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
|
||||
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)
|
||||
|
@ -487,7 +489,7 @@ cerr << "DataGridWidget::drawWidget\n";
|
|||
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
@ -504,8 +506,8 @@ cerr << "DataGridWidget::drawWidget\n";
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
GUI::Rect DataGridWidget::getEditRect() const
|
||||
{
|
||||
GUI::Rect r(1, 0, _colWidth, kCLineHeight);
|
||||
const int rowoffset = _currentRow * kCLineHeight;
|
||||
GUI::Rect r(1, 0, _colWidth, _rowHeight);
|
||||
const int rowoffset = _currentRow * _rowHeight;
|
||||
const int coloffset = _currentCol * _colWidth + 4;
|
||||
r.top += rowoffset;
|
||||
r.bottom += rowoffset;
|
||||
|
|
|
@ -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.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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -51,7 +51,8 @@ enum {
|
|||
class DataGridWidget : public EditableWidget, public CommandSender
|
||||
{
|
||||
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);
|
||||
virtual ~DataGridWidget();
|
||||
|
||||
|
@ -93,6 +94,7 @@ class DataGridWidget : public EditableWidget, public CommandSender
|
|||
int _cols;
|
||||
int _currentRow;
|
||||
int _currentCol;
|
||||
int _rowHeight;
|
||||
int _colWidth;
|
||||
int _bits;
|
||||
|
||||
|
|
|
@ -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: 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -52,6 +52,7 @@ class Font
|
|||
const FontDesc& desc() { return myFontDesc; }
|
||||
|
||||
int getFontHeight() const { return myFontDesc.height; }
|
||||
int getLineHeight() const { return myFontDesc.height + 2; }
|
||||
int getMaxCharWidth() const { return myFontDesc.maxwidth; }
|
||||
|
||||
int getCharWidth(uInt8 chr) const;
|
||||
|
|
|
@ -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: 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -29,16 +29,12 @@
|
|||
Probably not very neat, but at least it works ...
|
||||
|
||||
@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 kLineHeight 12
|
||||
|
||||
#define kCFontWidth 9
|
||||
#define kCFontHeight 15
|
||||
#define kCLineHeight 17
|
||||
|
||||
#define kScrollBarWidth 9
|
||||
|
||||
// Colors indices to use for the various GUI elements
|
||||
|
|
|
@ -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.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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -27,19 +27,20 @@
|
|||
#include "ToggleBitWidget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ToggleBitWidget::ToggleBitWidget(GuiObject* boss, int x, int y,
|
||||
int cols, int rows, int colchars)
|
||||
: Widget(boss, x, y, cols*(colchars * kCFontWidth + 8) + 1, kCLineHeight*rows + 1),
|
||||
ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font,
|
||||
int x, int y, int cols, int rows, int colchars)
|
||||
: Widget(boss, x, y, cols*(colchars * font.getMaxCharWidth() + 8) + 1,
|
||||
font.getLineHeight()*rows + 1),
|
||||
CommandSender(boss),
|
||||
_rows(rows),
|
||||
_cols(cols),
|
||||
_currentRow(0),
|
||||
_currentCol(0),
|
||||
_colWidth(colchars * kCFontWidth + 8),
|
||||
_rowHeight(font.getLineHeight()),
|
||||
_colWidth(colchars * font.getMaxCharWidth() + 8),
|
||||
_selectedItem(0)
|
||||
{
|
||||
// This widget always uses a monospace font
|
||||
setFont(instance()->consoleFont());
|
||||
setFont(font);
|
||||
|
||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
|
||||
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 = 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 row = (y - 1) / kCLineHeight;
|
||||
int row = (y - 1) / _rowHeight;
|
||||
if(row >= _rows) row = _rows - 1;
|
||||
|
||||
int col = x / _colWidth;
|
||||
|
@ -254,8 +257,8 @@ cerr << "ToggleBitWidget::drawWidget\n";
|
|||
// Draw the internal grid and labels
|
||||
int linewidth = _cols * _colWidth;
|
||||
for (row = 0; row <= _rows; row++)
|
||||
fb.hLine(_x, _y + (row * kCLineHeight), _x + linewidth, kColor);
|
||||
int lineheight = _rows * kCLineHeight;
|
||||
fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
|
||||
int lineheight = _rows * _rowHeight;
|
||||
for (col = 0; col <= _cols; col++)
|
||||
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
|
||||
|
||||
|
@ -265,23 +268,31 @@ cerr << "ToggleBitWidget::drawWidget\n";
|
|||
for (col = 0; col < _cols; col++)
|
||||
{
|
||||
int x = _x + 4 + (col * _colWidth);
|
||||
int y = _y + 2 + (row * kCLineHeight);
|
||||
int y = _y + 2 + (row * _rowHeight);
|
||||
int pos = row*_cols + col;
|
||||
|
||||
// Draw the selected item inverted, on a highlighted background.
|
||||
if (_currentRow == row && _currentCol == col)
|
||||
{
|
||||
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
|
||||
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])
|
||||
buffer = _onList[pos];
|
||||
else
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -39,12 +39,12 @@ enum {
|
|||
class ToggleBitWidget : public Widget, public CommandSender
|
||||
{
|
||||
public:
|
||||
ToggleBitWidget(GuiObject* boss, int x, int y, int cols, int rows,
|
||||
int colchars = 1);
|
||||
ToggleBitWidget(GuiObject* boss, const GUI::Font& font,
|
||||
int x, int y, int cols, int rows, int colchars = 1);
|
||||
virtual ~ToggleBitWidget();
|
||||
|
||||
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]; }
|
||||
|
||||
|
@ -66,12 +66,14 @@ class ToggleBitWidget : public Widget, public CommandSender
|
|||
int _cols;
|
||||
int _currentRow;
|
||||
int _currentCol;
|
||||
int _rowHeight;
|
||||
int _colWidth;
|
||||
int _selectedItem;
|
||||
|
||||
StringList _offList;
|
||||
StringList _onList;
|
||||
BoolArray _stateList;
|
||||
BoolArray _changedList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue