DataGridWidgets now show different background colour by default in

read-only mode.  This allows classes that were previously written
to auto-magically work, instead of having to manually edit them.
This commit is contained in:
Stephen Anthony 2017-04-01 20:39:00 -02:30
parent faba2540f9
commit 2d8ddd3296
5 changed files with 16 additions and 7 deletions

View File

@ -45,7 +45,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
2, 1, 2, 5, Common::Base::F_16);
myAudF->setTarget(this);
myAudF->setID(kAUDFID);
myAudF->setEditable(false, true);
myAudF->setEditable(false);
addFocusWidget(myAudF);
for(int col = 0; col < 2; ++col)
@ -65,7 +65,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
2, 1, 2, 4, Common::Base::F_16);
myAudC->setTarget(this);
myAudC->setID(kAUDCID);
myAudC->setEditable(false, true);
myAudC->setEditable(false);
addFocusWidget(myAudC);
// AudV registers
@ -77,7 +77,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
2, 1, 2, 4, Common::Base::F_16);
myAudV->setTarget(this);
myAudV->setID(kAUDVID);
myAudV->setEditable(false, true);
myAudV->setEditable(false);
addFocusWidget(myAudV);
}

View File

@ -178,6 +178,13 @@ void DataGridWidget::setList(int a, int v)
setList(alist, vlist, changed);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::setEditable(bool editable, bool hiliteBG)
{
// Override parent method; enable hilite when widget is not editable
EditableWidget::setEditable(editable, hiliteBG);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::setHiliteList(const BoolArray& hilitelist)
{

View File

@ -54,6 +54,8 @@ class DataGridWidget : public EditableWidget
void setList(int a, int v, bool changed);
void setList(int a, int v); // automatically calculate if changed
void setEditable(bool editable, bool hiliteBG = true) override;
void setHiliteList(const BoolArray& hilitelist);
void setNumRows(int rows);

View File

@ -121,7 +121,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
xpos += t->getWidth() + 5;
myTimRead = new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 32, Common::Base::F_16);
myTimRead->setTarget(this);
myTimRead->setEditable(false, true);
myTimRead->setEditable(false);
// Controller ports
const RiotDebug& riot = instance().debugger().riotDebug();
@ -143,7 +143,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
xpos += 6*fontWidth + 5;
myLeftINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::F_16);
myLeftINPT->setTarget(this);
myLeftINPT->setEditable(false, true);
myLeftINPT->setEditable(false);
// TIA INPTx registers (R), right port
const char* contRightReadNames[] = { "INPT2:", "INPT3:", "INPT5:" };
@ -156,7 +156,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
xpos += 6*fontWidth + 5;
myRightINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::F_16);
myRightINPT->setTarget(this);
myRightINPT->setEditable(false, true);
myRightINPT->setEditable(false);
// TIA INPTx VBLANK bits (D6-latch, D7-dump) (R)
xpos = col + 20; ypos += myLeftINPT->getHeight() + lineHeight;

View File

@ -52,7 +52,7 @@ class EditableWidget : public Widget, public CommandSender
const string& getText() const { return _editString; }
bool isEditable() const { return _editable; }
void setEditable(bool editable, bool hiliteBG = false);
virtual void setEditable(bool editable, bool hiliteBG = false);
bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override;