1 | //============================================================================ |
2 | // |
3 | // SSSS tt lll lll |
4 | // SS SS tt ll ll |
5 | // SS tttttt eeee ll ll aaaa |
6 | // SSSS tt ee ee ll ll aa |
7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
8 | // SS SS tt ee ll ll aa aa |
9 | // SSSS ttt eeeee llll llll aaaaa |
10 | // |
11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
12 | // and the Stella Team |
13 | // |
14 | // See the file "License.txt" for information on usage and redistribution of |
15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
16 | //============================================================================ |
17 | |
18 | #include "Font.hxx" |
19 | #include "DataGridOpsWidget.hxx" |
20 | |
21 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
22 | DataGridOpsWidget::DataGridOpsWidget(GuiObject* boss, const GUI::Font& font, |
23 | int x, int y) |
24 | : Widget(boss, font, x, y, 16, 16), |
25 | CommandSender(boss), |
26 | _zeroButton(nullptr), |
27 | _invButton(nullptr), |
28 | _negButton(nullptr), |
29 | _incButton(nullptr), |
30 | _decButton(nullptr), |
31 | _shiftLeftButton(nullptr), |
32 | _shiftRightButton(nullptr) |
33 | { |
34 | const int bwidth = _font.getMaxCharWidth() * 4+2, |
35 | bheight = _font.getFontHeight() + 3, |
36 | space = 4; |
37 | int xpos, ypos; |
38 | |
39 | // Create operations buttons |
40 | xpos = x; ypos = y; |
41 | _zeroButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
42 | "0" , kDGZeroCmd); |
43 | |
44 | ypos += bheight + space; |
45 | _invButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
46 | "Inv" , kDGInvertCmd); |
47 | |
48 | ypos += bheight + space; |
49 | _incButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
50 | "++" , kDGIncCmd); |
51 | |
52 | ypos += bheight + space; |
53 | _shiftLeftButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
54 | "<<" , kDGShiftLCmd); |
55 | |
56 | // Move to next column, skip a row |
57 | xpos = x + bwidth + space; ypos = y + bheight + space; |
58 | _negButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
59 | "Neg" , kDGNegateCmd); |
60 | |
61 | ypos += bheight + space; |
62 | _decButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
63 | "--" , kDGDecCmd); |
64 | |
65 | ypos += bheight + space; |
66 | _shiftRightButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, |
67 | ">>" , kDGShiftRCmd); |
68 | |
69 | // Calculate real dimensions |
70 | _w = 2 * (bwidth+space); |
71 | _h = 4 * (bheight+space); |
72 | |
73 | // We don't enable the buttons until the DataGridWidget is attached |
74 | // Don't call setEnabled(false), since that does an immediate redraw |
75 | _zeroButton->clearFlags(Widget::FLAG_ENABLED); |
76 | _invButton->clearFlags(Widget::FLAG_ENABLED); |
77 | _negButton->clearFlags(Widget::FLAG_ENABLED); |
78 | _incButton->clearFlags(Widget::FLAG_ENABLED); |
79 | _decButton->clearFlags(Widget::FLAG_ENABLED); |
80 | _shiftLeftButton->clearFlags(Widget::FLAG_ENABLED); |
81 | _shiftRightButton->clearFlags(Widget::FLAG_ENABLED); |
82 | } |
83 | |
84 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
85 | void DataGridOpsWidget::setTarget(CommandReceiver* target) |
86 | { |
87 | _zeroButton->setTarget(target); |
88 | _invButton->setTarget(target); |
89 | _negButton->setTarget(target); |
90 | _incButton->setTarget(target); |
91 | _decButton->setTarget(target); |
92 | _shiftLeftButton->setTarget(target); |
93 | _shiftRightButton->setTarget(target); |
94 | } |
95 | |
96 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
97 | void DataGridOpsWidget::setEnabled(bool e) |
98 | { |
99 | _zeroButton->setEnabled(e); |
100 | _invButton->setEnabled(e); |
101 | _negButton->setEnabled(e); |
102 | _incButton->setEnabled(e); |
103 | _decButton->setEnabled(e); |
104 | _shiftLeftButton->setEnabled(e); |
105 | _shiftRightButton->setEnabled(e); |
106 | } |
107 | |