From e8102b3ec36e44b60730dadabbf621577b82fdee Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 22 Jun 2005 18:30:44 +0000 Subject: [PATCH] Made EditableWidget take a flag that disables editing (ie, read-only). Added decimal, binary, and label fields to the RamWidget, which contain values for the currently selected cell. Added label, current instruction, cycle count, and status (breakpoint or trap set) fields to the CpuWidget. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@543 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/Debugger.cxx | 12 ++--- stella/src/debugger/Debugger.hxx | 14 +++--- stella/src/gui/AddrValueWidget.cxx | 5 +-- stella/src/gui/AddrValueWidget.hxx | 5 +-- stella/src/gui/CpuWidget.cxx | 72 +++++++++++++++++++++++++----- stella/src/gui/CpuWidget.hxx | 10 +++-- stella/src/gui/DataGridWidget.cxx | 8 ++-- stella/src/gui/DataGridWidget.hxx | 6 +-- stella/src/gui/EditTextWidget.cxx | 9 +++- stella/src/gui/EditTextWidget.hxx | 3 +- stella/src/gui/EditableWidget.cxx | 10 +++-- stella/src/gui/EditableWidget.hxx | 6 ++- stella/src/gui/ListWidget.cxx | 7 +-- stella/src/gui/ListWidget.hxx | 5 +-- stella/src/gui/RamWidget.cxx | 53 +++++++++++++++++++--- stella/src/gui/RamWidget.hxx | 6 ++- 16 files changed, 164 insertions(+), 67 deletions(-) diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 8f95a49e7..3cbe7c53c 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.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: Debugger.cxx,v 1.26 2005-06-21 23:01:24 stephena Exp $ +// $Id: Debugger.cxx,v 1.27 2005-06-22 18:30:42 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -142,11 +142,6 @@ const string Debugger::run(const string& command) return myParser->run(command); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Debugger::valueToString(int value) { - return valueToString(value, kBASE_DEFAULT); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const string Debugger::valueToString(int value, BaseFormat outputBase) { @@ -538,6 +533,11 @@ int Debugger::getP() { return myDebugger->ps(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Debugger::cycles() { + return mySystem->cycles(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Debugger::disassemble(int start, int lines) { char buf[255], bbuf[255]; diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index a5c6a541b..33d2c50d9 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.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: Debugger.hxx,v 1.23 2005-06-22 13:00:58 urchlay Exp $ +// $Id: Debugger.hxx,v 1.24 2005-06-22 18:30:42 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -51,7 +51,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.23 2005-06-22 13:00:58 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.24 2005-06-22 18:30:42 stephena Exp $ */ class Debugger : public DialogContainer { @@ -127,8 +127,7 @@ class Debugger : public DialogContainer int stringToValue(const string& stringval) { return myParser->decipher_arg(stringval); } - const string valueToString(int value, BaseFormat outputBase); - const string valueToString(int value); + const string valueToString(int value, BaseFormat outputBase = kBASE_DEFAULT); void toggleBreakPoint(int bp); @@ -185,6 +184,7 @@ class Debugger : public DialogContainer int getY(); int getP(); int getS(); + int cycles(); int peek(int addr); int dpeek(int addr); void toggleC(); @@ -202,9 +202,9 @@ class Debugger : public DialogContainer PromptWidget *prompt(); string showWatches(); - PackedBitArray *breakpoints() { return breakPoints; } - PackedBitArray *readtraps() { return readTraps; } - PackedBitArray *writetraps() { return writeTraps; } + PackedBitArray *breakpoints() { return breakPoints; } + PackedBitArray *readtraps() { return readTraps; } + PackedBitArray *writetraps() { return writeTraps; } protected: Console* myConsole; diff --git a/stella/src/gui/AddrValueWidget.cxx b/stella/src/gui/AddrValueWidget.cxx index 4c7bb7ff0..e0f0a17ad 100644 --- a/stella/src/gui/AddrValueWidget.cxx +++ b/stella/src/gui/AddrValueWidget.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: AddrValueWidget.cxx,v 1.5 2005-06-20 21:01:37 stephena Exp $ +// $Id: AddrValueWidget.cxx,v 1.6 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -56,9 +56,6 @@ AddrValueWidget::AddrValueWidget(GuiObject* boss, int x, int y, int w, int h, // The item is selected, thus _bgcolor is used to draw the caret and // _textcolorhi to erase it _caretInverse = true; - - // FIXME: This flag should come from widget definition - _editable = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/AddrValueWidget.hxx b/stella/src/gui/AddrValueWidget.hxx index 7b0645288..c6829b195 100644 --- a/stella/src/gui/AddrValueWidget.hxx +++ b/stella/src/gui/AddrValueWidget.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: AddrValueWidget.hxx,v 1.4 2005-06-20 21:01:37 stephena Exp $ +// $Id: AddrValueWidget.hxx,v 1.5 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -57,8 +57,6 @@ class AddrValueWidget : public EditableWidget, public CommandSender int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; } - bool isEditable() const { return _editable; } - void setEditable(bool editable) { _editable = editable; } void scrollTo(int item); virtual void handleMouseDown(int x, int y, int button, int clickCount); @@ -97,7 +95,6 @@ class AddrValueWidget : public EditableWidget, public CommandSender int _range; BaseFormat _base; - bool _editable; bool _editMode; int _currentPos; int _entriesPerPage; diff --git a/stella/src/gui/CpuWidget.cxx b/stella/src/gui/CpuWidget.cxx index 5c6ee5ff5..313f9a2ee 100644 --- a/stella/src/gui/CpuWidget.cxx +++ b/stella/src/gui/CpuWidget.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: CpuWidget.cxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ +// $Id: CpuWidget.cxx,v 1.3 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,6 +27,7 @@ #include "Debugger.hxx" #include "Widget.hxx" #include "DataGridWidget.hxx" +#include "EditTextWidget.hxx" #include "CpuWidget.hxx" @@ -47,7 +48,8 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h) int xpos = 10; int ypos = 10; int lwidth = 20; - const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; +// const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; + const GUI::Font& font = instance()->consoleFont(); // Create a 1x5 grid with labels for the CPU registers myCpuGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 1, 5, 8, 0xffff); @@ -61,14 +63,42 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h) lwidth, kLineHeight, labels[row] + string(":"), kTextAlignLeft); - t->setFont(instance()->consoleFont()); + t->setFont(font); } // Create a read-only textbox containing the current PC label - ypos = 10; - myPCLabel = new StaticTextWidget(boss, xpos + lwidth + myCpuGrid->colWidth() + 10, - ypos, 100, kLineHeight, "FIXME!", - kTextAlignLeft); + xpos += lwidth + myCpuGrid->colWidth() + 10; ypos = 10; + myPCLabel = new EditTextWidget(boss, xpos, ypos, 100, kLineHeight, ""); + myPCLabel->clearFlags(WIDGET_TAB_NAVIGATE); + myPCLabel->setFont(font); + myPCLabel->setEditable(false); + + // And some status fields + xpos = 10; ypos = 10 + 8*kLineHeight; + new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "Current Ins:", kTextAlignLeft); + xpos += 60; + myCurrentIns = new EditTextWidget(boss, xpos, ypos-2, 300, kLineHeight, ""); + myCurrentIns->clearFlags(WIDGET_TAB_NAVIGATE); + myCurrentIns->setFont(font); + myCurrentIns->setEditable(false); + + xpos = 10; ypos += kLineHeight + 5; + new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "Cycle Count:", kTextAlignLeft); + xpos += 60; + myCycleCount = new EditTextWidget(boss, xpos, ypos-2, 50, kLineHeight, ""); + myCycleCount->clearFlags(WIDGET_TAB_NAVIGATE); + myCycleCount->setFont(font); + myCycleCount->setEditable(false); + + xpos = 10; ypos += kLineHeight + 5; + new StaticTextWidget(boss, xpos, ypos, 55, kLineHeight, "BP/Trap:", kTextAlignLeft); + xpos += 60; + myStatus = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, ""); + myStatus->clearFlags(WIDGET_TAB_NAVIGATE); + myStatus->setFont(font); + myStatus->setEditable(false); + + /* // Add some buttons for common actions @@ -115,11 +145,8 @@ CpuWidget::~CpuWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data) { - // We simply change the values in the ByteGridWidget - // It will then send the 'kBGItemDataChangedCmd' signal to change the actual - // memory location int addr, value; - unsigned char byte; +// unsigned char byte; switch(cmd) { @@ -226,4 +253,27 @@ void CpuWidget::fillGrid() vlist.push_back(dbg.getY()); myCpuGrid->setList(alist, vlist); + + // Update the other status fields + int pc = dbg.getPC(); + const char* buf; + + buf = dbg.equates()->getLabel(pc); + if(buf) + myPCLabel->setEditString(buf); + else + myPCLabel->setEditString(""); + + myPCLabel->setEditString(""); + + myCurrentIns->setEditString(dbg.disassemble(pc, 1)); + + myCycleCount->setEditString(dbg.valueToString(dbg.cycles(), kBASE_10)); + + string status; + if(dbg.breakpoints()->isSet(pc)) + status = "BP set"; + + // FIXME - add trap info + myStatus->setEditString(status); } diff --git a/stella/src/gui/CpuWidget.hxx b/stella/src/gui/CpuWidget.hxx index 7473b909d..e9599068c 100644 --- a/stella/src/gui/CpuWidget.hxx +++ b/stella/src/gui/CpuWidget.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: CpuWidget.hxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ +// $Id: CpuWidget.hxx,v 1.3 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -24,7 +24,7 @@ class GuiObject; class ButtonWidget; -class StaticTextWidget; +class EditTextWidget; class DataGridWidget; #include "Array.hxx" @@ -51,7 +51,11 @@ class CpuWidget : public Widget, public CommandSender DataGridWidget* myCpuGrid; // FIXME - add a ToggleBitWidget for processor status (ps) register - StaticTextWidget* myPCLabel; + + EditTextWidget* myPCLabel; + EditTextWidget* myCurrentIns; + EditTextWidget* myCycleCount; + EditTextWidget* myStatus; }; #endif diff --git a/stella/src/gui/DataGridWidget.cxx b/stella/src/gui/DataGridWidget.cxx index 878c7194b..020cca710 100644 --- a/stella/src/gui/DataGridWidget.cxx +++ b/stella/src/gui/DataGridWidget.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: DataGridWidget.cxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.3 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -56,9 +56,6 @@ DataGridWidget::DataGridWidget(GuiObject* boss, int x, int y, int cols, int rows // The item is selected, thus _bgcolor is used to draw the caret and // _textcolorhi to erase it _caretInverse = true; - - // FIXME: This flag should come from widget definition - _editable = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -89,6 +86,9 @@ void DataGridWidget::setList(const AddrList& alist, const ValueList& vlist) } _editMode = false; + + // Send item selected signal for starting with cell 0 + sendCommand(kDGSelectionChangedCmd, _selectedItem); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/DataGridWidget.hxx b/stella/src/gui/DataGridWidget.hxx index 1cf8a740a..383930ab0 100644 --- a/stella/src/gui/DataGridWidget.hxx +++ b/stella/src/gui/DataGridWidget.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: DataGridWidget.hxx,v 1.1 2005-06-20 18:32:12 stephena Exp $ +// $Id: DataGridWidget.hxx,v 1.2 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -56,9 +56,6 @@ class DataGridWidget : public EditableWidget, public CommandSender int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; } - bool isEditable() const { return _editable; } - void setEditable(bool editable) { _editable = editable; } - virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual bool handleKeyDown(int ascii, int keycode, int modifiers); @@ -100,7 +97,6 @@ class DataGridWidget : public EditableWidget, public CommandSender StringList _addrStringList; StringList _valueStringList; - bool _editable; bool _editMode; int _selectedItem; int _currentKeyDown; diff --git a/stella/src/gui/EditTextWidget.cxx b/stella/src/gui/EditTextWidget.cxx index aa7617e87..969bfc042 100644 --- a/stella/src/gui/EditTextWidget.cxx +++ b/stella/src/gui/EditTextWidget.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: EditTextWidget.cxx,v 1.3 2005-06-16 00:55:59 stephena Exp $ +// $Id: EditTextWidget.cxx,v 1.4 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -33,6 +33,8 @@ EditTextWidget::EditTextWidget(GuiObject* boss, int x, int y, int w, int h, _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_TAB_NAVIGATE; _type = kEditTextWidget; + + setEditString(text); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -45,6 +47,9 @@ void EditTextWidget::setEditString(const string& str) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { + if(!_editable) + return; + x += _editScrollOffset; int width = 0; @@ -80,7 +85,7 @@ void EditTextWidget::drawWidget(bool hilite) fb.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(), kTextColor, kTextAlignLeft, -_editScrollOffset, false); - // Draw the caret + // Draw the caret drawCaret(); } diff --git a/stella/src/gui/EditTextWidget.hxx b/stella/src/gui/EditTextWidget.hxx index 83e4186fd..a0fb1e4a0 100644 --- a/stella/src/gui/EditTextWidget.hxx +++ b/stella/src/gui/EditTextWidget.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: EditTextWidget.hxx,v 1.2 2005-06-16 00:55:59 stephena Exp $ +// $Id: EditTextWidget.hxx,v 1.3 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -51,6 +51,7 @@ class EditTextWidget : public EditableWidget protected: string _backupString; + int _editable; }; #endif diff --git a/stella/src/gui/EditableWidget.cxx b/stella/src/gui/EditableWidget.cxx index 1cdb08cc2..a1a456c35 100644 --- a/stella/src/gui/EditableWidget.cxx +++ b/stella/src/gui/EditableWidget.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: EditableWidget.cxx,v 1.5 2005-06-17 14:42:49 stephena Exp $ +// $Id: EditableWidget.cxx,v 1.6 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -24,7 +24,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EditableWidget::EditableWidget(GuiObject* boss, int x, int y, int w, int h) - : Widget(boss, x, y, w, h) + : Widget(boss, x, y, w, h), + _editable(true) { _caretVisible = false; _caretTime = 0; @@ -70,6 +71,9 @@ bool EditableWidget::tryInsertChar(char c, int pos) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers) { + if(!_editable) + return true; + // Ignore all mod keys if(instance()->eventHandler().kbdControl(modifiers) || instance()->eventHandler().kbdAlt(modifiers)) @@ -159,7 +163,7 @@ int EditableWidget::getCaretOffset() const void EditableWidget::drawCaret() { // Only draw if item is visible - if (!isVisible() || !_boss->isVisible()) + if (!_editable || !isVisible() || !_boss->isVisible()) return; GUI::Rect editRect = getEditRect(); diff --git a/stella/src/gui/EditableWidget.hxx b/stella/src/gui/EditableWidget.hxx index b8bb24b0d..f32eb27b3 100644 --- a/stella/src/gui/EditableWidget.hxx +++ b/stella/src/gui/EditableWidget.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: EditableWidget.hxx,v 1.3 2005-06-16 00:55:59 stephena Exp $ +// $Id: EditableWidget.hxx,v 1.4 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -38,6 +38,9 @@ class EditableWidget : public Widget virtual void setEditString(const string& str); virtual const string& getEditString() const { return _editString; } + bool isEditable() const { return _editable; } + void setEditable(bool editable) { _editable = editable; } + virtual bool handleKeyDown(int ascii, int keycode, int modifiers); protected: @@ -54,6 +57,7 @@ class EditableWidget : public Widget virtual bool tryInsertChar(char c, int pos); protected: + bool _editable; string _editString; bool _caretVisible; diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx index aab790b0f..f4774ebb5 100644 --- a/stella/src/gui/ListWidget.cxx +++ b/stella/src/gui/ListWidget.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: ListWidget.cxx,v 1.20 2005-06-16 00:55:59 stephena Exp $ +// $Id: ListWidget.cxx,v 1.21 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -54,9 +54,6 @@ ListWidget::ListWidget(GuiObject* boss, int x, int y, int w, int h) // The item is selected, thus _bgcolor is used to draw the caret and // _textcolorhi to erase it _caretInverse = true; - - // FIXME: This flag should come from widget definition - _editable = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -450,7 +447,6 @@ void ListWidget::scrollToCurrent() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::startEditMode() { -cerr << "ListWidget::startEditMode()\n"; if (_editable && !_editMode && _selectedItem >= 0) { _editMode = true; @@ -474,7 +470,6 @@ void ListWidget::endEditMode() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::abortEditMode() { -cerr << "ListWidget::abortEditMode()\n"; // undo any changes made assert(_selectedItem >= 0); _editMode = false; diff --git a/stella/src/gui/ListWidget.hxx b/stella/src/gui/ListWidget.hxx index fabb7e773..1627ed4ed 100644 --- a/stella/src/gui/ListWidget.hxx +++ b/stella/src/gui/ListWidget.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: ListWidget.hxx,v 1.6 2005-06-16 00:55:59 stephena Exp $ +// $Id: ListWidget.hxx,v 1.7 2005-06-22 18:30:43 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -57,8 +57,6 @@ class ListWidget : public EditableWidget, public CommandSender int getSelected() const { return _selectedItem; } void setSelected(int item); const string& getSelectedString() const { return _list[_selectedItem]; } - bool isEditable() const { return _editable; } - void setEditable(bool editable) { _editable = editable; } void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; } void scrollTo(int item); @@ -89,7 +87,6 @@ class ListWidget : public EditableWidget, public CommandSender protected: StringList _list; - bool _editable; bool _editMode; NumberingMode _numberingMode; int _currentPos; diff --git a/stella/src/gui/RamWidget.cxx b/stella/src/gui/RamWidget.cxx index 2078581fe..742333164 100644 --- a/stella/src/gui/RamWidget.cxx +++ b/stella/src/gui/RamWidget.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: RamWidget.cxx,v 1.7 2005-06-20 18:32:12 stephena Exp $ +// $Id: RamWidget.cxx,v 1.8 2005-06-22 18:30:44 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,6 +27,7 @@ #include "GuiObject.hxx" #include "Debugger.hxx" #include "Widget.hxx" +#include "EditTextWidget.hxx" #include "DataGridWidget.hxx" #include "RamWidget.hxx" @@ -50,10 +51,12 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) int ypos = 20; int lwidth = 30; const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; + const GUI::Font& font = instance()->consoleFont(); // Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 0xff, kBASE_16); myRamGrid->setTarget(this); + myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE); myActiveWidget = myRamGrid; for(int row = 0; row < 8; ++row) @@ -62,7 +65,7 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) lwidth, kLineHeight, Debugger::to_hex_16(row*16 + kRamStart) + string(":"), kTextAlignLeft); - t->setFont(instance()->consoleFont()); + t->setFont(font); } for(int col = 0; col < 16; ++col) { @@ -72,9 +75,33 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) lwidth, kLineHeight, Debugger::to_hex_4(col), kTextAlignLeft); - t->setFont(instance()->consoleFont()); + t->setFont(font); } + xpos = 20; ypos = 11 * kLineHeight; + new StaticTextWidget(boss, xpos, ypos, 30, kLineHeight, "Label: ", kTextAlignLeft); + xpos += 30; + myLabel = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, ""); + myLabel->clearFlags(WIDGET_TAB_NAVIGATE); + myLabel->setFont(font); + myLabel->setEditable(false); + + xpos += 120; + new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Decimal: ", kTextAlignLeft); + xpos += 35; + myDecValue = new EditTextWidget(boss, xpos, ypos-2, 30, kLineHeight, ""); + myDecValue->clearFlags(WIDGET_TAB_NAVIGATE); + myDecValue->setFont(font); + myDecValue->setEditable(false); + + xpos += 48; + new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Binary: ", kTextAlignLeft); + xpos += 35; + myBinValue = new EditTextWidget(boss, xpos, ypos-2, 60, kLineHeight, ""); + myBinValue->clearFlags(WIDGET_TAB_NAVIGATE); + myBinValue->setFont(font); + myBinValue->setEditable(false); + // Add some buttons for common actions ButtonWidget* b; xpos = vWidth + 10; ypos = 20; @@ -123,13 +150,29 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data) // memory location int addr, value; unsigned char byte; + const char* buf; switch(cmd) { case kDGItemDataChangedCmd: - addr = myRamGrid->getSelectedAddr() - kRamStart; + addr = myRamGrid->getSelectedAddr(); value = myRamGrid->getSelectedValue(); - instance()->debugger().writeRAM(addr, value); + + instance()->debugger().writeRAM(addr - kRamStart, value); + myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); + myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); + break; + + case kDGSelectionChangedCmd: + addr = myRamGrid->getSelectedAddr(); + value = myRamGrid->getSelectedValue(); + + buf = instance()->debugger().equates()->getLabel(addr); + if(buf) myLabel->setEditString(buf); + else myLabel->setEditString(""); + + myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); + myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); break; case kRZeroCmd: diff --git a/stella/src/gui/RamWidget.hxx b/stella/src/gui/RamWidget.hxx index 3310f23d9..e62851f5d 100644 --- a/stella/src/gui/RamWidget.hxx +++ b/stella/src/gui/RamWidget.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: RamWidget.hxx,v 1.3 2005-06-20 18:32:12 stephena Exp $ +// $Id: RamWidget.hxx,v 1.4 2005-06-22 18:30:44 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ class GuiObject; class ButtonWidget; class StaticTextWidget; +class EditTextWidget; class DataGridWidget; #include "Array.hxx" @@ -50,6 +51,9 @@ class RamWidget : public Widget, public CommandSender Widget* myActiveWidget; DataGridWidget* myRamGrid; + EditTextWidget* myBinValue; + EditTextWidget* myDecValue; + EditTextWidget* myLabel; }; #endif