From 69b96e928b3ea9784c1c70dd0111f4945fef1d44 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 22 Aug 2005 19:27:59 +0000 Subject: [PATCH] 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 --- stella/src/gui/CheckListWidget.cxx | 62 ++++++++++++++++++------------ stella/src/gui/CheckListWidget.hxx | 14 +++++-- stella/src/gui/Widget.hxx | 6 +-- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/stella/src/gui/CheckListWidget.cxx b/stella/src/gui/CheckListWidget.cxx index b4ead2c67..060774e67 100644 --- a/stella/src/gui/CheckListWidget.cxx +++ b/stella/src/gui/CheckListWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CheckListWidget.cxx,v 1.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 // Copyright (C) 2002-2004 The ScummVM project @@ -21,14 +21,25 @@ #include "ScrollBarWidget.hxx" #include "CheckListWidget.hxx" - -#include "bspf.hxx" +#include "Widget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int 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) { -cerr << "CheckListWidget::drawWidget\n"; +//cerr << "CheckListWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); int i, pos, len = _list.size(); string buffer; 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 + _h - 1, _x + _w - 1, kShadowColor); fb.vLine(_x, _y, _y + _h - 1, kColor); + fb.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor); + // Draw the list items for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) { - const OverlayColor textColor = (_selectedItem == pos && _editMode) - ? kColor : kTextColor; + _checkList[i]->setDirty(); + _checkList[i]->draw(); + +// const OverlayColor textColor = (_selectedItem == pos && _editMode) +// ? kColor : kTextColor; const int y = _y + 2 + _rowHeight * i; + GUI::Rect r(getEditRect()); + // Draw the selected item inverted, on a highlighted background. if (_selectedItem == pos) { 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 - 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) { buffer = _editString; @@ -93,20 +114,13 @@ cerr << "CheckListWidget::drawWidget\n"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GUI::Rect CheckListWidget::getEditRect() const { - GUI::Rect r(2, 1, _w - 2 , _rowHeight); - const int offset = (_selectedItem - _currentPos) * _rowHeight; - r.top += offset; - r.bottom += offset; - -/* - if (_numberingMode != kListNumberingOff) - { - char temp[10]; - // FIXME: Assumes that all digits have the same width. - sprintf(temp, "%2d. ", (_list.size() - 1 + _numberingMode)); - r.left += _font->getStringWidth(temp); - } -*/ + GUI::Rect r(2, 1, _w, _rowHeight); + const int yoffset = (_selectedItem - _currentPos) * _rowHeight, + xoffset = CheckboxWidget::boxSize() + 10; + r.top += yoffset; + r.bottom += yoffset; + r.left += xoffset; + r.right -= xoffset - 15; return r; } diff --git a/stella/src/gui/CheckListWidget.hxx b/stella/src/gui/CheckListWidget.hxx index 28e164310..04a9ff625 100644 --- a/stella/src/gui/CheckListWidget.hxx +++ b/stella/src/gui/CheckListWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CheckListWidget.hxx,v 1.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 // Copyright (C) 2002-2004 The ScummVM project @@ -22,6 +22,8 @@ #ifndef CHECK_LIST_WIDGET_HXX #define CHECK_LIST_WIDGET_HXX +class CheckboxWidget; + #include "ListWidget.hxx" // Some special commands @@ -29,7 +31,10 @@ enum { kListItemChecked = 'LIct' // checkbox toggled on current line }; -/* CheckListWidget */ +typedef GUI::Array CheckboxArray; + + +/** CheckListWidget */ class CheckListWidget : public ListWidget { public: @@ -41,8 +46,9 @@ class CheckListWidget : public ListWidget void drawWidget(bool hilite); GUI::Rect getEditRect() const; - protected: - BoolArray _checkList; + private: + BoolArray _stateList; + CheckboxArray _checkList; }; #endif diff --git a/stella/src/gui/Widget.hxx b/stella/src/gui/Widget.hxx index 957488943..d60f5bc9e 100644 --- a/stella/src/gui/Widget.hxx +++ b/stella/src/gui/Widget.hxx @@ -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.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 // 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.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 { @@ -229,7 +229,7 @@ class CheckboxWidget : public ButtonWidget void toggleState() { setState(!_state); } bool getState() const { return _state; } - static int boxWidth() { return 14; } + static int boxSize() { return 14; } // box is square protected: void drawWidget(bool hilite);