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 ROM_LIST_WIDGET_HXX |
19 | #define ROM_LIST_WIDGET_HXX |
20 | |
21 | class ScrollBarWidget; |
22 | class CheckListWidget; |
23 | class RomListSettings; |
24 | |
25 | #include "Base.hxx" |
26 | #include "CartDebug.hxx" |
27 | #include "EditableWidget.hxx" |
28 | |
29 | /** RomListWidget */ |
30 | class RomListWidget : public EditableWidget |
31 | { |
32 | public: |
33 | enum { |
34 | kBPointChangedCmd = 'RLbp', // 'data' will be disassembly line number, |
35 | // 'id' will be the checkbox state |
36 | kRomChangedCmd = 'RLpr', // 'data' will be disassembly line number |
37 | // 'id' will be the Base::Format of the data |
38 | kSetPCCmd = 'STpc', // 'data' will be disassembly line number |
39 | kRuntoPCCmd = 'RTpc', // 'data' will be disassembly line number |
40 | kDisassembleCmd = 'REds', |
41 | kTentativeCodeCmd = 'TEcd', // 'data' will be boolean |
42 | kPCAddressesCmd = 'PCad', // 'data' will be boolean |
43 | kGfxAsBinaryCmd = 'GFXb', // 'data' will be boolean |
44 | kAddrRelocationCmd = 'ADre' // 'data' will be boolean |
45 | }; |
46 | |
47 | public: |
48 | RomListWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
49 | int x, int y, int w, int h); |
50 | virtual ~RomListWidget() = default; |
51 | |
52 | void setList(const CartDebug::Disassembly& disasm); |
53 | |
54 | int getSelected() const { return _selectedItem; } |
55 | int getHighlighted() const { return _highlightedItem; } |
56 | void setSelected(int item); |
57 | void setHighlighted(int item); |
58 | |
59 | protected: |
60 | void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; |
61 | void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; |
62 | void handleMouseWheel(int x, int y, int direction) override; |
63 | void handleMouseEntered() override; |
64 | void handleMouseLeft() override; |
65 | bool handleText(char text) override; |
66 | bool handleKeyDown(StellaKey key, StellaMod mod) override; |
67 | bool handleKeyUp(StellaKey key, StellaMod mod) override; |
68 | bool handleEvent(Event::Type e) override; |
69 | void handleCommand(CommandSender* sender, int cmd, int data, int id) override; |
70 | |
71 | void drawWidget(bool hilite) override; |
72 | Common::Rect getLineRect() const; |
73 | Common::Rect getEditRect() const override; |
74 | |
75 | int findItem(int x, int y) const; |
76 | void recalc(); |
77 | |
78 | void startEditMode() override; |
79 | void endEditMode() override; |
80 | void abortEditMode() override; |
81 | void lostFocusWidget() override; |
82 | void scrollToSelected() { scrollToCurrent(_selectedItem); } |
83 | void scrollToHighlighted() { scrollToCurrent(_highlightedItem); } |
84 | |
85 | private: |
86 | void scrollToCurrent(int item); |
87 | |
88 | private: |
89 | unique_ptr<RomListSettings> ; |
90 | ScrollBarWidget* myScrollBar; |
91 | |
92 | int _labelWidth; |
93 | int _bytesWidth; |
94 | int _rows; |
95 | int _cols; |
96 | int _currentPos; // position of first line in visible window |
97 | int _selectedItem; |
98 | int _highlightedItem; |
99 | bool _editMode; |
100 | StellaKey _currentKeyDown; |
101 | Common::Base::Format _base; // base used during editing |
102 | |
103 | const CartDebug::Disassembly* myDisasm; |
104 | vector<CheckboxWidget*> myCheckList; |
105 | |
106 | private: |
107 | // Following constructors and assignment operators not supported |
108 | RomListWidget() = delete; |
109 | RomListWidget(const RomListWidget&) = delete; |
110 | RomListWidget(RomListWidget&&) = delete; |
111 | RomListWidget& operator=(const RomListWidget&) = delete; |
112 | RomListWidget& operator=(RomListWidget&&) = delete; |
113 | }; |
114 | |
115 | #endif |
116 | |