mirror of https://github.com/stella-emu/stella.git
More work on CheckListWidget. This widget now sends signals when it
need to be refilled or a line has been (un)checked. Also, checked lines are now shown correctly (scrolling the list scrolls the checkboxes as well). Added two different styles to CheckboxWidget. The first is as before, but the new one doesn't draw the surrounding box and fills with a solid color instead of using 'X'. Methods have been added to set/unset drawing of the surrounding box, and change to doing a fill vs using the 'X'. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@735 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
bd1f058b13
commit
9f15fa0d00
|
@ -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: RomWidget.cxx,v 1.2 2005-08-22 18:17:10 stephena Exp $
|
// $Id: RomWidget.cxx,v 1.3 2005-08-23 18:32:51 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
|
||||||
|
@ -35,6 +35,7 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
||||||
|
|
||||||
myRomList = new CheckListWidget(boss, font, x, y, w, h);
|
myRomList = new CheckListWidget(boss, font, x, y, w, h);
|
||||||
myRomList->setTarget(this);
|
myRomList->setTarget(this);
|
||||||
|
myRomList->setStyle(kSolidFill);
|
||||||
addFocusWidget(myRomList);
|
addFocusWidget(myRomList);
|
||||||
|
|
||||||
// Calculate real dimensions
|
// Calculate real dimensions
|
||||||
|
@ -50,11 +51,27 @@ RomWidget::~RomWidget()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
{
|
{
|
||||||
|
switch(cmd)
|
||||||
|
{
|
||||||
|
case kListScrolledCmd:
|
||||||
|
cerr << "data invalidated; refill list\n";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kListItemChecked:
|
||||||
|
cerr << "(un)set a breakpoint at address " << data << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void RomWidget::loadConfig()
|
void RomWidget::loadConfig()
|
||||||
{
|
{
|
||||||
|
/* FIXME
|
||||||
|
We need logic here to only fill the grid at startup and when
|
||||||
|
bankswitching. At other times, we receive 'kListScrolledCmd'
|
||||||
|
command, which means the current romlist view is invalid and
|
||||||
|
should be filled with new data.
|
||||||
|
*/
|
||||||
cerr << "RomWidget::loadConfig()\n";
|
cerr << "RomWidget::loadConfig()\n";
|
||||||
fillGrid();
|
fillGrid();
|
||||||
myRomList->setDirty(); myRomList->draw();
|
myRomList->setDirty(); myRomList->draw();
|
||||||
|
@ -64,13 +81,16 @@ cerr << "RomWidget::loadConfig()\n";
|
||||||
void RomWidget::fillGrid()
|
void RomWidget::fillGrid()
|
||||||
{
|
{
|
||||||
StringList l;
|
StringList l;
|
||||||
|
BoolArray b;
|
||||||
|
|
||||||
for(int i = 0; i < 100; ++i)
|
for(int i = 0; i < 50; ++i)
|
||||||
{
|
{
|
||||||
ostringstream tmp;
|
ostringstream tmp;
|
||||||
tmp << "Test line " << i;
|
tmp << "Test line " << i;
|
||||||
l.push_back(tmp.str());
|
l.push_back(tmp.str());
|
||||||
|
|
||||||
|
b.push_back(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
myRomList->setList(l);
|
myRomList->setList(l, b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: FrameBuffer.cxx,v 1.60 2005-08-11 21:57:30 stephena Exp $
|
// $Id: FrameBuffer.cxx,v 1.61 2005-08-23 18:32:51 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -226,7 +226,7 @@ void FrameBuffer::update()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::refresh(bool now)
|
void FrameBuffer::refresh(bool now)
|
||||||
{
|
{
|
||||||
cerr << "refreshTIA() " << myNumRedraws++ << endl;
|
// cerr << "refreshTIA() " << myNumRedraws++ << endl;
|
||||||
theRedrawTIAIndicator = true;
|
theRedrawTIAIndicator = true;
|
||||||
if(now)
|
if(now)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.3 2005-08-22 19:27:59 stephena Exp $
|
// $Id: CheckListWidget.cxx,v 1.4 2005-08-23 18:32:51 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
|
||||||
|
@ -30,12 +30,17 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
{
|
{
|
||||||
int ypos = _y + 2;
|
int ypos = _y + 2;
|
||||||
|
|
||||||
|
// rowheight is determined by largest item on a line
|
||||||
|
_rowHeight = MAX(_rowHeight, CheckboxWidget::boxSize());
|
||||||
|
|
||||||
// Create a CheckboxWidget for each row in the list
|
// Create a CheckboxWidget for each row in the list
|
||||||
CheckboxWidget* t;
|
CheckboxWidget* t;
|
||||||
while((int)_checkList.size() < _rows)
|
for(int i = 0; i < _rows; ++i)
|
||||||
{
|
{
|
||||||
t = new CheckboxWidget(boss, font, _x + 2, ypos, "", kCheckActionCmd);
|
t = new CheckboxWidget(boss, font, _x + 2, ypos, "", kCheckActionCmd);
|
||||||
t->setTarget(this);
|
t->setTarget(this);
|
||||||
|
t->setID(i);
|
||||||
|
t->holdFocus(false);
|
||||||
ypos += _rowHeight;
|
ypos += _rowHeight;
|
||||||
|
|
||||||
_checkList.push_back(t);
|
_checkList.push_back(t);
|
||||||
|
@ -47,6 +52,54 @@ CheckListWidget::~CheckListWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckListWidget::setStyle(CheckStyle style)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < _checkList.size(); ++i)
|
||||||
|
{
|
||||||
|
if(style == kXFill)
|
||||||
|
{
|
||||||
|
_checkList[i]->drawBox(true);
|
||||||
|
_checkList[i]->setFill(false);
|
||||||
|
}
|
||||||
|
else if(style == kSolidFill)
|
||||||
|
{
|
||||||
|
_checkList[i]->drawBox(false);
|
||||||
|
_checkList[i]->setFill(true, kTextColorEm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckListWidget::setList(const StringList& list, const BoolArray& state)
|
||||||
|
{
|
||||||
|
_list = list;
|
||||||
|
_stateList = state;
|
||||||
|
|
||||||
|
assert(_list.size() == _stateList.size());
|
||||||
|
|
||||||
|
// Enable all checkboxes
|
||||||
|
for(int i = 0; i < _rows; ++i)
|
||||||
|
_checkList[i]->setFlags(WIDGET_ENABLED);
|
||||||
|
|
||||||
|
// Then turn off any extras
|
||||||
|
if((int)_stateList.size() < _rows)
|
||||||
|
for(int i = _stateList.size(); i < _rows; ++i)
|
||||||
|
_checkList[i]->clearFlags(WIDGET_ENABLED);
|
||||||
|
|
||||||
|
ListWidget::recalc();
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckListWidget::setLine(int line, const string& str, const bool& state)
|
||||||
|
{
|
||||||
|
if(line >= (int)_list.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_list[line] = str;
|
||||||
|
_stateList[line] = state;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheckListWidget::drawWidget(bool hilite)
|
void CheckListWidget::drawWidget(bool hilite)
|
||||||
{
|
{
|
||||||
|
@ -66,11 +119,11 @@ void CheckListWidget::drawWidget(bool hilite)
|
||||||
// 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++)
|
||||||
{
|
{
|
||||||
|
// Draw checkboxes for correct lines (takes scrolling into account)
|
||||||
|
_checkList[i]->setState(_stateList[pos]);
|
||||||
_checkList[i]->setDirty();
|
_checkList[i]->setDirty();
|
||||||
_checkList[i]->draw();
|
_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());
|
GUI::Rect r(getEditRect());
|
||||||
|
@ -124,3 +177,25 @@ GUI::Rect CheckListWidget::getEditRect() const
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckListWidget::handleCommand(CommandSender* sender, int cmd,
|
||||||
|
int data, int id)
|
||||||
|
{
|
||||||
|
switch(cmd)
|
||||||
|
{
|
||||||
|
case kCheckActionCmd:
|
||||||
|
{
|
||||||
|
// Figure out which line has been checked
|
||||||
|
int line = _currentPos + id;
|
||||||
|
_stateList[line] = bool(data);
|
||||||
|
|
||||||
|
// Let the boss know about it
|
||||||
|
sendCommand(kListItemChecked, line, _id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
ListWidget::handleCommand(sender, cmd, data, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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.3 2005-08-22 19:27:59 stephena Exp $
|
// $Id: CheckListWidget.hxx,v 1.4 2005-08-23 18:32:51 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,6 +31,11 @@ enum {
|
||||||
kListItemChecked = 'LIct' // checkbox toggled on current line
|
kListItemChecked = 'LIct' // checkbox toggled on current line
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CheckStyle {
|
||||||
|
kXFill,
|
||||||
|
kSolidFill
|
||||||
|
};
|
||||||
|
|
||||||
typedef GUI::Array<CheckboxWidget*> CheckboxArray;
|
typedef GUI::Array<CheckboxWidget*> CheckboxArray;
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +47,12 @@ class CheckListWidget : public ListWidget
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
virtual ~CheckListWidget();
|
virtual ~CheckListWidget();
|
||||||
|
|
||||||
|
void setStyle(CheckStyle style);
|
||||||
|
void setList(const StringList& list, const BoolArray& state);
|
||||||
|
void setLine(int line, const string& str, const bool& state);
|
||||||
|
|
||||||
|
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawWidget(bool hilite);
|
void drawWidget(bool hilite);
|
||||||
GUI::Rect getEditRect() const;
|
GUI::Rect getEditRect() const;
|
||||||
|
|
|
@ -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: DebuggerDialog.cxx,v 1.35 2005-08-22 13:53:23 stephena Exp $
|
// $Id: DebuggerDialog.cxx,v 1.36 2005-08-23 18:32:51 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
|
||||||
|
@ -63,7 +63,6 @@ DebuggerDialog::~DebuggerDialog()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DebuggerDialog::loadConfig()
|
void DebuggerDialog::loadConfig()
|
||||||
{
|
{
|
||||||
cerr << " ==> DebuggerDialog::loadConfig()\n";
|
|
||||||
myTab->loadConfig();
|
myTab->loadConfig();
|
||||||
myTiaInfo->loadConfig();
|
myTiaInfo->loadConfig();
|
||||||
myTiaOutput->loadConfig();
|
myTiaOutput->loadConfig();
|
||||||
|
|
|
@ -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: ListWidget.cxx,v 1.27 2005-08-22 18:17:10 stephena Exp $
|
// $Id: ListWidget.cxx,v 1.28 2005-08-23 18:32:51 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
|
||||||
|
@ -82,24 +82,9 @@ void ListWidget::setSelected(int item)
|
||||||
|
|
||||||
_currentPos = _selectedItem - _rows / 2;
|
_currentPos = _selectedItem - _rows / 2;
|
||||||
scrollToCurrent();
|
scrollToCurrent();
|
||||||
setDirty(); draw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
void ListWidget::setList(const StringList& list)
|
|
||||||
{
|
|
||||||
int size = list.size();
|
|
||||||
_list = list;
|
|
||||||
if (_currentPos >= size)
|
|
||||||
_currentPos = size - 1;
|
|
||||||
if (_currentPos < 0)
|
|
||||||
_currentPos = 0;
|
|
||||||
_selectedItem = -1;
|
|
||||||
_editMode = false;
|
|
||||||
scrollBarRecalc();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ListWidget::scrollTo(int item)
|
void ListWidget::scrollTo(int item)
|
||||||
{
|
{
|
||||||
|
@ -116,6 +101,20 @@ void ListWidget::scrollTo(int item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ListWidget::recalc()
|
||||||
|
{
|
||||||
|
int size = _list.size();
|
||||||
|
|
||||||
|
if (_currentPos >= size)
|
||||||
|
_currentPos = size - 1;
|
||||||
|
if (_currentPos < 0)
|
||||||
|
_currentPos = 0;
|
||||||
|
_selectedItem = -1;
|
||||||
|
_editMode = false;
|
||||||
|
scrollBarRecalc();
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ListWidget::scrollBarRecalc()
|
void ListWidget::scrollBarRecalc()
|
||||||
{
|
{
|
||||||
|
@ -169,7 +168,6 @@ void ListWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||||
void ListWidget::handleMouseWheel(int x, int y, int direction)
|
void ListWidget::handleMouseWheel(int x, int y, int direction)
|
||||||
{
|
{
|
||||||
_scrollBar->handleMouseWheel(x, y, direction);
|
_scrollBar->handleMouseWheel(x, y, direction);
|
||||||
setDirty(); draw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -198,7 +196,6 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
bool dirty = false;
|
|
||||||
int oldSelectedItem = _selectedItem;
|
int oldSelectedItem = _selectedItem;
|
||||||
|
|
||||||
if (!_editMode && isalnum((char)ascii))
|
if (!_editMode && isalnum((char)ascii))
|
||||||
|
@ -230,7 +227,6 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
}
|
}
|
||||||
newSelectedItem++;
|
newSelectedItem++;
|
||||||
}
|
}
|
||||||
scrollToCurrent();
|
|
||||||
}
|
}
|
||||||
else if (_editMode)
|
else if (_editMode)
|
||||||
{
|
{
|
||||||
|
@ -248,10 +244,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
{
|
{
|
||||||
// override continuous enter keydown
|
// override continuous enter keydown
|
||||||
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r'))
|
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r'))
|
||||||
{
|
|
||||||
dirty = true;
|
|
||||||
startEditMode();
|
startEditMode();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
sendCommand(kListItemActivatedCmd, _selectedItem, _id);
|
sendCommand(kListItemActivatedCmd, _selectedItem, _id);
|
||||||
}
|
}
|
||||||
|
@ -290,17 +283,14 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
default:
|
default:
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToCurrent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_selectedItem != oldSelectedItem)
|
if (_selectedItem != oldSelectedItem)
|
||||||
{
|
{
|
||||||
sendCommand(kListSelectionChangedCmd, _selectedItem, _id);
|
|
||||||
// also draw scrollbar
|
|
||||||
_scrollBar->draw();
|
_scrollBar->draw();
|
||||||
|
scrollToCurrent();
|
||||||
|
|
||||||
setDirty(); draw();
|
sendCommand(kListSelectionChangedCmd, _selectedItem, _id);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentKeyDown = keycode;
|
_currentKeyDown = keycode;
|
||||||
|
@ -331,6 +321,9 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
{
|
{
|
||||||
_currentPos = data;
|
_currentPos = data;
|
||||||
setDirty(); draw();
|
setDirty(); draw();
|
||||||
|
|
||||||
|
// Let boss know the list has scrolled
|
||||||
|
sendCommand(kListScrolledCmd, _currentPos, _id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -339,16 +332,20 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ListWidget::scrollToCurrent()
|
void ListWidget::scrollToCurrent()
|
||||||
{
|
{
|
||||||
|
bool scrolled = false;
|
||||||
|
|
||||||
// Only do something if the current item is not in our view port
|
// Only do something if the current item is not in our view port
|
||||||
if (_selectedItem < _currentPos)
|
if (_selectedItem < _currentPos)
|
||||||
{
|
{
|
||||||
// it's above our view
|
// it's above our view
|
||||||
_currentPos = _selectedItem;
|
_currentPos = _selectedItem;
|
||||||
|
scrolled = true;
|
||||||
}
|
}
|
||||||
else if (_selectedItem >= _currentPos + _rows )
|
else if (_selectedItem >= _currentPos + _rows )
|
||||||
{
|
{
|
||||||
// it's below our view
|
// it's below our view
|
||||||
_currentPos = _selectedItem - _rows + 1;
|
_currentPos = _selectedItem - _rows + 1;
|
||||||
|
scrolled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_currentPos < 0 || _rows > (int)_list.size())
|
if (_currentPos < 0 || _rows > (int)_list.size())
|
||||||
|
@ -358,6 +355,11 @@ void ListWidget::scrollToCurrent()
|
||||||
|
|
||||||
_scrollBar->_currentPos = _currentPos;
|
_scrollBar->_currentPos = _currentPos;
|
||||||
_scrollBar->recalc();
|
_scrollBar->recalc();
|
||||||
|
|
||||||
|
setDirty(); draw();
|
||||||
|
|
||||||
|
if(scrolled)
|
||||||
|
sendCommand(kListScrolledCmd, _currentPos, _id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -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: ListWidget.hxx,v 1.10 2005-08-22 18:17:10 stephena Exp $
|
// $Id: ListWidget.hxx,v 1.11 2005-08-23 18:32:51 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
|
||||||
|
@ -36,7 +36,8 @@ enum {
|
||||||
kListItemDoubleClickedCmd = 'LIdb', // double click on item - 'data' will be item index
|
kListItemDoubleClickedCmd = 'LIdb', // double click on item - 'data' will be item index
|
||||||
kListItemActivatedCmd = 'LIac', // item activated by return/enter - 'data' will be item index
|
kListItemActivatedCmd = 'LIac', // item activated by return/enter - 'data' will be item index
|
||||||
kListItemDataChangedCmd = 'LIch', // item data changed - 'data' will be item index
|
kListItemDataChangedCmd = 'LIch', // item data changed - 'data' will be item index
|
||||||
kListSelectionChangedCmd = 'Lsch' // selection changed - 'data' will be item index
|
kListSelectionChangedCmd = 'Lsch', // selection changed - 'data' will be item index
|
||||||
|
kListScrolledCmd = 'Lscl' // list scrolled - 'data' will be current position
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ListWidget */
|
/** ListWidget */
|
||||||
|
@ -50,7 +51,6 @@ class ListWidget : public EditableWidget
|
||||||
int getSelected() const { return _selectedItem; }
|
int getSelected() const { return _selectedItem; }
|
||||||
void setSelected(int item);
|
void setSelected(int item);
|
||||||
|
|
||||||
void setList(const StringList& list);
|
|
||||||
const StringList& getList() const { return _list; }
|
const StringList& getList() const { return _list; }
|
||||||
const string& getSelectedString() const { return _list[_selectedItem]; }
|
const string& getSelectedString() const { return _list[_selectedItem]; }
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ class ListWidget : public EditableWidget
|
||||||
virtual GUI::Rect getEditRect() const = 0;
|
virtual GUI::Rect getEditRect() const = 0;
|
||||||
|
|
||||||
int findItem(int x, int y) const;
|
int findItem(int x, int y) const;
|
||||||
|
void recalc();
|
||||||
void scrollBarRecalc();
|
void scrollBarRecalc();
|
||||||
|
|
||||||
void abortEditMode();
|
void abortEditMode();
|
||||||
|
|
|
@ -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: StringListWidget.cxx,v 1.1 2005-08-22 23:09:13 stephena Exp $
|
// $Id: StringListWidget.cxx,v 1.2 2005-08-23 18:32:51 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
|
||||||
|
@ -36,6 +36,15 @@ StringListWidget::~StringListWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void StringListWidget::setList(const StringList& list)
|
||||||
|
{
|
||||||
|
_list = list;
|
||||||
|
|
||||||
|
ListWidget::recalc();
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void StringListWidget::drawWidget(bool hilite)
|
void StringListWidget::drawWidget(bool hilite)
|
||||||
{
|
{
|
||||||
FrameBuffer& fb = _boss->instance()->frameBuffer();
|
FrameBuffer& fb = _boss->instance()->frameBuffer();
|
||||||
|
|
|
@ -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: StringListWidget.hxx,v 1.1 2005-08-22 23:09:13 stephena Exp $
|
// $Id: StringListWidget.hxx,v 1.2 2005-08-23 18:32:51 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
|
||||||
|
@ -38,6 +38,7 @@ class StringListWidget : public ListWidget
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
virtual ~StringListWidget();
|
virtual ~StringListWidget();
|
||||||
|
|
||||||
|
void setList(const StringList& list);
|
||||||
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -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.cxx,v 1.31 2005-08-22 18:17:10 stephena Exp $
|
// $Id: Widget.cxx,v 1.32 2005-08-23 18:32:51 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
|
||||||
|
@ -381,7 +381,11 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
|
||||||
int cmd)
|
int cmd)
|
||||||
: ButtonWidget(boss, x, y, 16, 16, label, cmd, 0),
|
: ButtonWidget(boss, x, y, 16, 16, label, cmd, 0),
|
||||||
_state(false),
|
_state(false),
|
||||||
_editable(true)
|
_editable(true),
|
||||||
|
_holdFocus(true),
|
||||||
|
_fillRect(false),
|
||||||
|
_drawBox(true),
|
||||||
|
_fillColor(kColor)
|
||||||
{
|
{
|
||||||
_flags = WIDGET_ENABLED | WIDGET_RETAIN_FOCUS;
|
_flags = WIDGET_ENABLED | WIDGET_RETAIN_FOCUS;
|
||||||
_type = kCheckboxWidget;
|
_type = kCheckboxWidget;
|
||||||
|
@ -426,6 +430,28 @@ bool CheckboxWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool CheckboxWidget::wantsFocus()
|
||||||
|
{
|
||||||
|
if(!_holdFocus)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return _editable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckboxWidget::setEditable(bool editable)
|
||||||
|
{
|
||||||
|
_holdFocus = _editable = editable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckboxWidget::setFill(bool fill, OverlayColor color)
|
||||||
|
{
|
||||||
|
_fillRect = fill;
|
||||||
|
_fillColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheckboxWidget::setState(bool state)
|
void CheckboxWidget::setState(bool state)
|
||||||
{
|
{
|
||||||
|
@ -451,12 +477,18 @@ void CheckboxWidget::drawWidget(bool hilite)
|
||||||
text_yoff = (14 - _font->getFontHeight()) / 2;
|
text_yoff = (14 - _font->getFontHeight()) / 2;
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
|
if(_drawBox)
|
||||||
fb.box(_x, _y + box_yoff, 14, 14, kColor, kShadowColor);
|
fb.box(_x, _y + box_yoff, 14, 14, kColor, kShadowColor);
|
||||||
|
|
||||||
// If checked, draw cross inside the box
|
// If checked, draw cross inside the box
|
||||||
if(_state)
|
if(_state)
|
||||||
|
{
|
||||||
|
if(_fillRect)
|
||||||
|
fb.fillRect(_x + 2, _y + box_yoff + 2, 10, 10, _fillColor);
|
||||||
|
else
|
||||||
fb.drawBitmap(checked_img, _x + 3, _y + box_yoff + 3,
|
fb.drawBitmap(checked_img, _x + 3, _y + box_yoff + 3,
|
||||||
isEnabled() ? _color : kColor);
|
isEnabled() ? _color : kColor);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fb.fillRect(_x + 2, _y + box_yoff + 2, 10, 10, kBGColor);
|
fb.fillRect(_x + 2, _y + box_yoff + 2, 10, 10, kBGColor);
|
||||||
|
|
||||||
|
|
|
@ -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.33 2005-08-22 19:27:59 stephena Exp $
|
// $Id: Widget.hxx,v 1.34 2005-08-23 18:32:51 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.33 2005-08-22 19:27:59 stephena Exp $
|
@version $Id: Widget.hxx,v 1.34 2005-08-23 18:32:51 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Widget : public GuiObject
|
class Widget : public GuiObject
|
||||||
{
|
{
|
||||||
|
@ -221,9 +221,12 @@ class CheckboxWidget : public ButtonWidget
|
||||||
virtual void handleMouseLeft(int button) {}
|
virtual void handleMouseLeft(int button) {}
|
||||||
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
|
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
|
||||||
|
|
||||||
bool wantsFocus() { return _editable; };
|
bool wantsFocus();
|
||||||
|
void holdFocus(bool status) { _holdFocus = status; }
|
||||||
|
|
||||||
void setEditable(bool editable) { _editable = editable; }
|
void setEditable(bool editable);
|
||||||
|
void setFill(bool fill, OverlayColor color = kColor);
|
||||||
|
void drawBox(bool draw) { _drawBox = draw; }
|
||||||
|
|
||||||
void setState(bool state);
|
void setState(bool state);
|
||||||
void toggleState() { setState(!_state); }
|
void toggleState() { setState(!_state); }
|
||||||
|
@ -237,6 +240,11 @@ class CheckboxWidget : public ButtonWidget
|
||||||
protected:
|
protected:
|
||||||
bool _state;
|
bool _state;
|
||||||
bool _editable;
|
bool _editable;
|
||||||
|
bool _holdFocus;
|
||||||
|
bool _fillRect;
|
||||||
|
bool _drawBox;
|
||||||
|
|
||||||
|
OverlayColor _fillColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue