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-2021 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 ~RomListWidget() override = default; 51 52 void setList(const CartDebug::Disassembly& disasm); 53 getSelected() const54 int getSelected() const { return _selectedItem; } getHighlighted() const55 int getHighlighted() const { return _highlightedItem; } 56 void setSelected(int item); 57 void setHighlighted(int item); 58 59 string getToolTip(const Common::Point& pos) const override; 60 bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; 61 62 protected: 63 void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; 64 void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; 65 void handleMouseWheel(int x, int y, int direction) override; 66 bool handleText(char text) override; 67 bool handleKeyDown(StellaKey key, StellaMod mod) override; 68 bool handleKeyUp(StellaKey key, StellaMod mod) override; 69 bool handleEvent(Event::Type e) override; 70 void handleCommand(CommandSender* sender, int cmd, int data, int id) override; 71 72 void drawWidget(bool hilite) override; 73 Common::Rect getLineRect() const; 74 Common::Rect getEditRect() const override; 75 76 int findItem(int x, int y) const; 77 void recalc(); 78 79 void startEditMode() override; 80 void endEditMode() override; 81 void abortEditMode() override; 82 void lostFocusWidget() override; 83 hasToolTip() const84 bool hasToolTip() const override { return true; } 85 scrollToSelected()86 void scrollToSelected() { scrollToCurrent(_selectedItem); } scrollToHighlighted()87 void scrollToHighlighted() { scrollToCurrent(_highlightedItem); } 88 89 private: 90 void scrollToCurrent(int item); 91 Common::Point getToolTipIndex(const Common::Point& pos) const; 92 93 private: 94 unique_ptr<RomListSettings> myMenu; 95 ScrollBarWidget* myScrollBar{nullptr}; 96 97 int _labelWidth{0}; 98 int _bytesWidth{0}; 99 int _rows{0}; 100 int _cols{0}; 101 int _currentPos{0}; // position of first line in visible window 102 int _selectedItem{-1}; 103 int _highlightedItem{-1}; 104 StellaKey _currentKeyDown{KBDK_UNKNOWN}; 105 Common::Base::Fmt _base{Common::Base::Fmt::_DEFAULT}; // base used during editing 106 107 const CartDebug::Disassembly* myDisasm{nullptr}; 108 vector<CheckboxWidget*> myCheckList; 109 110 private: 111 // Following constructors and assignment operators not supported 112 RomListWidget() = delete; 113 RomListWidget(const RomListWidget&) = delete; 114 RomListWidget(RomListWidget&&) = delete; 115 RomListWidget& operator=(const RomListWidget&) = delete; 116 RomListWidget& operator=(RomListWidget&&) = delete; 117 }; 118 119 #endif 120