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 | #ifndef RAM_WIDGET_HXX |
19 | #define RAM_WIDGET_HXX |
20 | |
21 | class GuiObject; |
22 | class ButtonWidget; |
23 | class DataGridWidget; |
24 | class DataGridOpsWidget; |
25 | class EditTextWidget; |
26 | class StaticTextWidget; |
27 | class InputTextDialog; |
28 | |
29 | #include "Widget.hxx" |
30 | #include "Command.hxx" |
31 | |
32 | class RamWidget : public Widget, public CommandSender |
33 | { |
34 | public: |
35 | RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
36 | int x, int y, int w, int h, |
37 | uInt32 ramsize, uInt32 numrows, uInt32 pagesize); |
38 | virtual ~RamWidget(); |
39 | |
40 | void loadConfig() override; |
41 | void setOpsWidget(DataGridOpsWidget* w); |
42 | void handleCommand(CommandSender* sender, int cmd, int data, int id) override; |
43 | |
44 | private: |
45 | // To be implemented by derived classes |
46 | virtual uInt8 getValue(int addr) const = 0; |
47 | virtual void setValue(int addr, uInt8 value) = 0; |
48 | virtual string getLabel(int addr) const = 0; |
49 | |
50 | virtual void fillList(uInt32 start, uInt32 size, |
51 | IntArray& alist, IntArray& vlist, BoolArray& changed) const = 0; |
52 | virtual uInt32 readPort(uInt32 start) const = 0; |
53 | virtual const ByteArray& currentRam(uInt32 start) const = 0; |
54 | |
55 | private: |
56 | void fillGrid(bool updateOld); |
57 | |
58 | void showInputBox(int cmd); |
59 | string doSearch(const string& str); |
60 | string doCompare(const string& str); |
61 | void doRestart(); |
62 | void showSearchResults(); |
63 | |
64 | protected: |
65 | // Font used for 'normal' text; _font is for 'label' text |
66 | const GUI::Font& _nfont; |
67 | |
68 | // These will be needed by most of the child classes; |
69 | // we may as well make them protected variables |
70 | int myFontWidth, myFontHeight, myLineHeight, myButtonHeight; |
71 | |
72 | private: |
73 | enum { |
74 | kUndoCmd = 'RWud', |
75 | kRevertCmd = 'RWrv', |
76 | kSearchCmd = 'RWse', |
77 | kCmpCmd = 'RWcp', |
78 | kRestartCmd = 'RWrs', |
79 | kSValEntered = 'RWsv', |
80 | kCValEntered = 'RWcv', |
81 | kRamHexID, |
82 | kRamDecID, |
83 | kRamBinID |
84 | }; |
85 | |
86 | uInt32 myUndoAddress, myUndoValue; |
87 | uInt32 myCurrentRamBank; |
88 | uInt32 myRamSize; |
89 | uInt32 myNumRows; |
90 | uInt32 myPageSize; |
91 | |
92 | unique_ptr<InputTextDialog> myInputBox; |
93 | |
94 | StaticTextWidget* myRamStart; |
95 | StaticTextWidget* myRamLabels[16]; |
96 | |
97 | DataGridWidget* myRamGrid; |
98 | DataGridWidget* myDecValue; |
99 | DataGridWidget* myBinValue; |
100 | EditTextWidget* myLabel; |
101 | |
102 | ButtonWidget* myRevertButton; |
103 | ButtonWidget* myUndoButton; |
104 | ButtonWidget* mySearchButton; |
105 | ButtonWidget* myCompareButton; |
106 | ButtonWidget* myRestartButton; |
107 | |
108 | ByteArray myOldValueList; |
109 | IntArray mySearchAddr; |
110 | IntArray mySearchValue; |
111 | BoolArray mySearchState; |
112 | |
113 | private: |
114 | // Following constructors and assignment operators not supported |
115 | RamWidget() = delete; |
116 | RamWidget(const RamWidget&) = delete; |
117 | RamWidget(RamWidget&&) = delete; |
118 | RamWidget& operator=(const RamWidget&) = delete; |
119 | RamWidget& operator=(RamWidget&&) = delete; |
120 | }; |
121 | |
122 | #endif |
123 | |