Added CheckboxWidgets to CheckListWidget, but the signals aren't tied

to anything yet.  I may add the ability to CheckboxWidget to disable
drawing the surrounding border, as well as drawing a fill as well
as a bitmap.  When that's done, click a breakpoint in RomWidget will
show (for example) a red square only, which is more like how
other graphical debuggers show a breakpoint.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@733 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-08-22 19:27:59 +00:00
parent d5da3d3319
commit 69b96e928b
3 changed files with 51 additions and 31 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: CheckListWidget.cxx,v 1.2 2005-08-22 18:17:10 stephena Exp $ // $Id: CheckListWidget.cxx,v 1.3 2005-08-22 19:27:59 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
@ -21,14 +21,25 @@
#include "ScrollBarWidget.hxx" #include "ScrollBarWidget.hxx"
#include "CheckListWidget.hxx" #include "CheckListWidget.hxx"
#include "Widget.hxx"
#include "bspf.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h) int x, int y, int w, int h)
: ListWidget(boss, font, x, y, w, h) : ListWidget(boss, font, x, y, w, h)
{ {
int ypos = _y + 2;
// Create a CheckboxWidget for each row in the list
CheckboxWidget* t;
while((int)_checkList.size() < _rows)
{
t = new CheckboxWidget(boss, font, _x + 2, ypos, "", kCheckActionCmd);
t->setTarget(this);
ypos += _rowHeight;
_checkList.push_back(t);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -39,34 +50,44 @@ CheckListWidget::~CheckListWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::drawWidget(bool hilite) void CheckListWidget::drawWidget(bool hilite)
{ {
cerr << "CheckListWidget::drawWidget\n"; //cerr << "CheckListWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer(); FrameBuffer& fb = _boss->instance()->frameBuffer();
int i, pos, len = _list.size(); int i, pos, len = _list.size();
string buffer; string buffer;
int deltax; int deltax;
// Draw a thin frame around the list. // Draw a thin frame around the list and to separate columns
fb.hLine(_x, _y, _x + _w - 1, kColor); fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor); fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor); fb.vLine(_x, _y, _y + _h - 1, kColor);
fb.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor);
// Draw the list items // Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++)
{ {
const OverlayColor textColor = (_selectedItem == pos && _editMode) _checkList[i]->setDirty();
? kColor : kTextColor; _checkList[i]->draw();
// const OverlayColor textColor = (_selectedItem == pos && _editMode)
// ? kColor : kTextColor;
const int y = _y + 2 + _rowHeight * i; const int y = _y + 2 + _rowHeight * i;
GUI::Rect r(getEditRect());
// Draw the selected item inverted, on a highlighted background. // Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos) if (_selectedItem == pos)
{ {
if (_hasFocus && !_editMode) if (_hasFocus && !_editMode)
fb.fillRect(_x + 1, _y + 1 + _rowHeight * i, _w - 1, _rowHeight, kTextColorHi); fb.fillRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
_w - r.left, _rowHeight,
kTextColorHi);
else else
fb.frameRect(_x + 1, _y + 1 + _rowHeight * i, _w - 1, _rowHeight, kTextColorHi); fb.frameRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
_w - r.left, _rowHeight,
kTextColorHi);
} }
GUI::Rect r(getEditRect());
if (_selectedItem == pos && _editMode) if (_selectedItem == pos && _editMode)
{ {
buffer = _editString; buffer = _editString;
@ -93,20 +114,13 @@ cerr << "CheckListWidget::drawWidget\n";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect CheckListWidget::getEditRect() const GUI::Rect CheckListWidget::getEditRect() const
{ {
GUI::Rect r(2, 1, _w - 2 , _rowHeight); GUI::Rect r(2, 1, _w, _rowHeight);
const int offset = (_selectedItem - _currentPos) * _rowHeight; const int yoffset = (_selectedItem - _currentPos) * _rowHeight,
r.top += offset; xoffset = CheckboxWidget::boxSize() + 10;
r.bottom += offset; r.top += yoffset;
r.bottom += yoffset;
/* r.left += xoffset;
if (_numberingMode != kListNumberingOff) r.right -= xoffset - 15;
{
char temp[10];
// FIXME: Assumes that all digits have the same width.
sprintf(temp, "%2d. ", (_list.size() - 1 + _numberingMode));
r.left += _font->getStringWidth(temp);
}
*/
return r; return r;
} }

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: CheckListWidget.hxx,v 1.2 2005-08-22 18:17:10 stephena Exp $ // $Id: CheckListWidget.hxx,v 1.3 2005-08-22 19:27:59 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
@ -22,6 +22,8 @@
#ifndef CHECK_LIST_WIDGET_HXX #ifndef CHECK_LIST_WIDGET_HXX
#define CHECK_LIST_WIDGET_HXX #define CHECK_LIST_WIDGET_HXX
class CheckboxWidget;
#include "ListWidget.hxx" #include "ListWidget.hxx"
// Some special commands // Some special commands
@ -29,7 +31,10 @@ enum {
kListItemChecked = 'LIct' // checkbox toggled on current line kListItemChecked = 'LIct' // checkbox toggled on current line
}; };
/* CheckListWidget */ typedef GUI::Array<CheckboxWidget*> CheckboxArray;
/** CheckListWidget */
class CheckListWidget : public ListWidget class CheckListWidget : public ListWidget
{ {
public: public:
@ -41,8 +46,9 @@ class CheckListWidget : public ListWidget
void drawWidget(bool hilite); void drawWidget(bool hilite);
GUI::Rect getEditRect() const; GUI::Rect getEditRect() const;
protected: private:
BoolArray _checkList; BoolArray _stateList;
CheckboxArray _checkList;
}; };
#endif #endif

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: Widget.hxx,v 1.32 2005-08-22 18:17:10 stephena Exp $ // $Id: Widget.hxx,v 1.33 2005-08-22 19:27:59 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
@ -71,7 +71,7 @@ enum {
This is the base class for all widgets. This is the base class for all widgets.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Widget.hxx,v 1.32 2005-08-22 18:17:10 stephena Exp $ @version $Id: Widget.hxx,v 1.33 2005-08-22 19:27:59 stephena Exp $
*/ */
class Widget : public GuiObject class Widget : public GuiObject
{ {
@ -229,7 +229,7 @@ class CheckboxWidget : public ButtonWidget
void toggleState() { setState(!_state); } void toggleState() { setState(!_state); }
bool getState() const { return _state; } bool getState() const { return _state; }
static int boxWidth() { return 14; } static int boxSize() { return 14; } // box is square
protected: protected:
void drawWidget(bool hilite); void drawWidget(bool hilite);