diff --git a/stella/src/debugger/CpuWidget.cxx b/stella/src/debugger/CpuWidget.cxx index d3a80e4fb..13d18c0bf 100644 --- a/stella/src/debugger/CpuWidget.cxx +++ b/stella/src/debugger/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.5 2005-08-10 14:44:00 stephena Exp $ +// $Id: CpuWidget.cxx,v 1.6 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -64,7 +64,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y) StaticTextWidget* t; // Create a 1x5 grid with labels for the CPU registers - xpos = x + 10, ypos = y, lwidth = 4 * fontWidth; + xpos = x; ypos = y; lwidth = 4 * fontWidth; myCpuGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 5, 8, 16); myCpuGrid->setTarget(this); addFocusWidget(myCpuGrid); @@ -80,12 +80,12 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y) // Create a read-only textbox containing the current PC label xpos += lwidth + myCpuGrid->getWidth() + 10; - myPCLabel = new EditTextWidget(boss, xpos, ypos, 100, lineHeight, ""); + myPCLabel = new EditTextWidget(boss, xpos, ypos, fontWidth*25, lineHeight, ""); myPCLabel->setFont(font); myPCLabel->setEditable(false); // Create a bitfield widget for changing the processor status - xpos = x + 10; ypos += 5*lineHeight + 5; + xpos = x; ypos += 5*lineHeight + 5; t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, fontHeight, "PS:", kTextAlignLeft); t->setFont(font); @@ -106,7 +106,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y) myPSRegister->setList(off, on); // Calculate real dimensions - _w = lwidth + myCpuGrid->getWidth() + myPSRegister->getWidth() + 20; + _w = lwidth + myCpuGrid->getWidth() + myPCLabel->getWidth() + 20; _h = ypos + myPSRegister->getHeight() - y; } diff --git a/stella/src/debugger/CpuWidget.hxx b/stella/src/debugger/CpuWidget.hxx index e00b2fc81..d5e8668c9 100644 --- a/stella/src/debugger/CpuWidget.hxx +++ b/stella/src/debugger/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-08-10 12:23:42 stephena Exp $ +// $Id: CpuWidget.hxx,v 1.3 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,12 +25,12 @@ class GuiObject; class ButtonWidget; class EditTextWidget; -class DataGridWidget; class ToggleBitWidget; #include "Array.hxx" #include "Widget.hxx" #include "Command.hxx" +#include "DataGridWidget.hxx" class CpuWidget : public Widget, public CommandSender @@ -40,7 +40,9 @@ class CpuWidget : public Widget, public CommandSender virtual ~CpuWidget(); void handleCommand(CommandSender* sender, int cmd, int data, int id); + void loadConfig(); + void setOpsWidget(DataGridOpsWidget* w) { myCpuGrid->setOpsWidget(w); } private: void fillGrid(); diff --git a/stella/src/debugger/RamWidget.cxx b/stella/src/debugger/RamWidget.cxx index d457270f5..b93e95524 100644 --- a/stella/src/debugger/RamWidget.cxx +++ b/stella/src/debugger/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.5 2005-08-10 14:44:00 stephena Exp $ +// $Id: RamWidget.cxx,v 1.6 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -47,7 +47,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y) 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 - xpos = x + 10; ypos = y + lineHeight; lwidth = 4 * fontWidth; + xpos = x; ypos = y + lineHeight; lwidth = 4 * fontWidth; myRamGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 16, 8, 2, 8, kBASE_16); myRamGrid->setTarget(this); @@ -77,11 +77,11 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y) "Label:", kTextAlignLeft); t->setFont(font); xpos += 6*fontWidth + 5; - myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*fontWidth, lineHeight, ""); + myLabel = new EditTextWidget(boss, xpos, ypos-2, 17*fontWidth, lineHeight, ""); myLabel->setFont(font); myLabel->setEditable(false); - xpos += 15*fontWidth + 20; + xpos += 17*fontWidth + 20; t = new StaticTextWidget(boss, xpos, ypos, 4*fontWidth, fontHeight, "Dec:", kTextAlignLeft); @@ -102,49 +102,13 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y) myBinValue->setEditable(false); /* - // Add some buttons for common actions - ButtonWidget* b; - xpos = vWidth + 10; ypos = 20; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "0", kDGZeroCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "Inv", kDGInvertCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "++", kDGIncCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "<<", kDGShiftLCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; // keep a pointer to this one, it gets disabled/enabled myUndoButton = b = new ButtonWidget(boss, xpos, ypos, buttonw*2+10, 16, "Undo", kUndoCmd, 0); b->setTarget(this); - ypos += 16 + space; // keep a pointer to this one, it gets disabled/enabled myRevertButton = b = new ButtonWidget(boss, xpos, ypos, buttonw*2+10, 16, "Revert", kRevertCmd, 0); b->setTarget(this); - - xpos = vWidth + 30 + 10; ypos = 20; -// b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "", kRCmd, 0); -// b->setTarget(this); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "Neg", kDGNegateCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "--", kDGDecCmd, 0); - b->setTarget(myRamGrid); - - ypos += 16 + space; - b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, ">>", kDGShiftRCmd, 0); - b->setTarget(myRamGrid); */ // Calculate real dimensions diff --git a/stella/src/debugger/RamWidget.hxx b/stella/src/debugger/RamWidget.hxx index bb61cadc1..e421e6e85 100644 --- a/stella/src/debugger/RamWidget.hxx +++ b/stella/src/debugger/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-08-10 14:44:00 stephena Exp $ +// $Id: RamWidget.hxx,v 1.4 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,7 +45,9 @@ class RamWidget : public Widget, public CommandSender virtual ~RamWidget(); void handleCommand(CommandSender* sender, int cmd, int data, int id); + void loadConfig(); + void setOpsWidget(DataGridOpsWidget* w) { myRamGrid->setOpsWidget(w); } private: void fillGrid(bool updateOld); diff --git a/stella/src/gui/DataGridOpsWidget.cxx b/stella/src/gui/DataGridOpsWidget.cxx new file mode 100644 index 000000000..3ffa5e339 --- /dev/null +++ b/stella/src/gui/DataGridOpsWidget.cxx @@ -0,0 +1,98 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DataGridOpsWidget.cxx,v 1.1 2005-08-10 18:44:37 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "DataGridOpsWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +DataGridOpsWidget::DataGridOpsWidget(GuiObject* boss, int x, int y) + : Widget(boss, x, y, 16, 16), + CommandSender(boss), + _zeroButton(NULL), + _invButton(NULL), + _negButton(NULL), + _incButton(NULL), + _decButton(NULL), + _shiftLeftButton(NULL), + _shiftRightButton(NULL) +{ + const int bwidth = _font->getMaxCharWidth() * 3, + bheight = 16, // FIXME - magic number + space = 6; + int xpos, ypos; + + // Create operations buttons + xpos = x; ypos = y; + _zeroButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "0", kDGZeroCmd, 0); + + ypos += bheight + space; + _invButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "Inv", kDGInvertCmd, 0); + + ypos += bheight + space; + _incButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "++", kDGIncCmd, 0); + + ypos += bheight + space; + _shiftLeftButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "<<", kDGShiftLCmd, 0); + + // Move to next column, skip a row + xpos = x + bwidth + space; ypos = y + bheight + space; + _negButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "Neg", kDGNegateCmd, 0); + + ypos += bheight + space; + _decButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + "--", kDGDecCmd, 0); + + ypos += bheight + space; + _shiftRightButton = new ButtonWidget(boss, xpos, ypos, bwidth, bheight, + ">>", kDGShiftRCmd, 0); + + // Calculate real dimensions + _w = xpos + bwidth; + _h = ypos + bheight; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridOpsWidget::setTarget(CommandReceiver* target) +{ + _zeroButton->setTarget(target); + _invButton->setTarget(target); + _negButton->setTarget(target); + _incButton->setTarget(target); + _decButton->setTarget(target); + _shiftLeftButton->setTarget(target); + _shiftRightButton->setTarget(target); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridOpsWidget::setEnabled(bool e) +{ + _zeroButton->setEnabled(e); + _invButton->setEnabled(e); + _negButton->setEnabled(e); + _incButton->setEnabled(e); + _decButton->setEnabled(e); + _shiftLeftButton->setEnabled(e); + _shiftRightButton->setEnabled(e); +} diff --git a/stella/src/gui/DataGridOpsWidget.hxx b/stella/src/gui/DataGridOpsWidget.hxx new file mode 100644 index 000000000..e53aae7d4 --- /dev/null +++ b/stella/src/gui/DataGridOpsWidget.hxx @@ -0,0 +1,59 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DataGridOpsWidget.hxx,v 1.1 2005-08-10 18:44:37 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef DATA_GRID_OPS_WIDGET_HXX +#define DATA_GRID_OPS_WIDGET_HXX + +#include "GuiObject.hxx" +#include "Widget.hxx" +#include "Command.hxx" + +// DataGridWidget operations +enum { + kDGZeroCmd = 'DGze', + kDGInvertCmd = 'DGiv', + kDGNegateCmd = 'DGng', + kDGIncCmd = 'DGic', + kDGDecCmd = 'DGdc', + kDGShiftLCmd = 'DGls', + kDGShiftRCmd = 'DGrs' +}; + +class DataGridOpsWidget : public Widget, public CommandSender +{ + public: + DataGridOpsWidget(GuiObject* boss, int x, int y); + virtual ~DataGridOpsWidget() {} + + void setTarget(CommandReceiver* target); + void setEnabled(bool e); + + private: + ButtonWidget* _zeroButton; + ButtonWidget* _invButton; + ButtonWidget* _negButton; + ButtonWidget* _incButton; + ButtonWidget* _decButton; + ButtonWidget* _shiftLeftButton; + ButtonWidget* _shiftRightButton; +}; + +#endif diff --git a/stella/src/gui/DataGridWidget.cxx b/stella/src/gui/DataGridWidget.cxx index 3732bedde..e2b976532 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.18 2005-08-10 12:23:42 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.19 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,7 +45,8 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, _colWidth(colchars * font.getMaxCharWidth() + 8), _bits(bits), _base(base), - _selectedItem(0) + _selectedItem(0), + _opsWidget(NULL) { setFont(font); @@ -122,6 +123,8 @@ void DataGridWidget::setSelectedValue(int value) _valueList[_selectedItem] = value; sendCommand(kDGItemDataChangedCmd, _selectedItem, _id); + + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -300,62 +303,41 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) case 'n': // negate if(_editable) - { negateCell(); - dirty = true; - } break; case 'i': // invert case '!': if(_editable) - { invertCell(); - dirty = true; - } break; case '-': // decrement if(_editable) - { decrementCell(); - dirty = true; - } break; case '+': // increment case '=': if(_editable) - { incrementCell(); - dirty = true; - } break; case '<': // shift left case ',': if(_editable) - { lshiftCell(); - dirty = true; - } break; case '>': // shift right case '.': if(_editable) - { rshiftCell(); - dirty = true; - } break; case 'z': // zero if(_editable) - { zeroCell(); - dirty = true; - } break; default: @@ -386,10 +368,25 @@ bool DataGridWidget::handleKeyUp(int ascii, int keycode, int modifiers) return true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridWidget::receivedFocusWidget() +{ + // Enable the operations widget and make it send its signals here + if(_opsWidget) + { + _opsWidget->setEnabled(true); + _opsWidget->setTarget(this); + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::lostFocusWidget() { _editMode = false; + + // Disable the operations widget + if(_opsWidget) + _opsWidget->setEnabled(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/DataGridWidget.hxx b/stella/src/gui/DataGridWidget.hxx index ac6964c03..b37b0c6ce 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.10 2005-08-02 18:28:28 stephena Exp $ +// $Id: DataGridWidget.hxx,v 1.11 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -30,21 +30,14 @@ #include "EditableWidget.hxx" #include "Array.hxx" #include "Rect.hxx" +#include "DataGridOpsWidget.hxx" // Some special commands enum { kDGItemDoubleClickedCmd = 'DGdb', kDGItemActivatedCmd = 'DGac', kDGItemDataChangedCmd = 'DGch', - kDGSelectionChangedCmd = 'DGsc', - - kDGZeroCmd = 'DGze', - kDGInvertCmd = 'DGiv', - kDGNegateCmd = 'DGng', - kDGIncCmd = 'DGic', - kDGDecCmd = 'DGdc', - kDGShiftLCmd = 'DGls', - kDGShiftRCmd = 'DGrs' + kDGSelectionChangedCmd = 'DGsc' }; /* DataGridWidget */ @@ -76,6 +69,8 @@ class DataGridWidget : public EditableWidget, public CommandSender int colWidth() { return _colWidth; } + void setOpsWidget(DataGridOpsWidget* w) { _opsWidget = w; } + protected: void drawWidget(bool hilite); @@ -85,6 +80,7 @@ class DataGridWidget : public EditableWidget, public CommandSender GUI::Rect getEditRect() const; + void receivedFocusWidget(); void lostFocusWidget(); bool tryInsertChar(char c, int pos); @@ -111,8 +107,10 @@ class DataGridWidget : public EditableWidget, public CommandSender int _currentKeyDown; string _backupString; + DataGridOpsWidget* _opsWidget; + private: - //* Common operations on the currently selected cell */ + /** Common operations on the currently selected cell */ void negateCell(); void invertCell(); void decrementCell(); diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index 4a98bbcba..73857e2bd 100644 --- a/stella/src/gui/DebuggerDialog.cxx +++ b/stella/src/gui/DebuggerDialog.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: DebuggerDialog.cxx,v 1.32 2005-08-10 14:44:01 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.33 2005-08-10 18:44:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,6 +29,7 @@ #include "RamWidget.hxx" #include "TiaWidget.hxx" #include "CheatWidget.hxx" +#include "DataGridOpsWidget.hxx" #include "Rect.hxx" #include "Debugger.hxx" @@ -186,10 +187,20 @@ void DebuggerDialog::addRomArea() myCpu = new CpuWidget(this, instance()->consoleFont(), xpos, ypos); addToFocusList(myCpu->getFocusList()); - ypos += myCpu->getHeight() + 10; + xpos = r.left + 10; ypos += myCpu->getHeight() + 10; myRam = new RamWidget(this, instance()->consoleFont(), xpos, ypos); addToFocusList(myRam->getFocusList()); + xpos = r.left + 10 + myCpu->getWidth() + 20; ypos = 20; + DataGridOpsWidget* ops = new DataGridOpsWidget(this, xpos, ypos); + ops->setEnabled(false); + + // Add the DataGridOpsWidget to any widgets which contain a + // DataGridWidget which we want controlled + myCpu->setOpsWidget(ops); + myRam->setOpsWidget(ops); + + // Add some buttons that are always shown, no matter which tab we're in // FIXME - these positions will definitely change xpos = r.right - 100; ypos = r.bottom - 150; diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 689aa38af..8f3c319b7 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \ src/gui/ColorWidget.o \ src/gui/CheatCodeDialog.o \ src/gui/DataGridWidget.o \ + src/gui/DataGridOpsWidget.o \ src/gui/DebuggerDialog.o \ src/gui/DialogContainer.o \ src/gui/Dialog.o \