| 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 CHECK_LIST_WIDGET_HXX |
| 19 | #define CHECK_LIST_WIDGET_HXX |
| 20 | |
| 21 | class CheckboxWidget; |
| 22 | |
| 23 | #include "ListWidget.hxx" |
| 24 | |
| 25 | using CheckboxArray = vector<CheckboxWidget*>; |
| 26 | |
| 27 | |
| 28 | /** CheckListWidget */ |
| 29 | class CheckListWidget : public ListWidget |
| 30 | { |
| 31 | public: |
| 32 | enum { kListItemChecked = 'LIct' /* checkbox toggled on current line*/ }; |
| 33 | |
| 34 | public: |
| 35 | CheckListWidget(GuiObject* boss, const GUI::Font& font, |
| 36 | int x, int y, int w, int h); |
| 37 | virtual ~CheckListWidget() = default; |
| 38 | |
| 39 | void setList(const StringList& list, const BoolArray& state); |
| 40 | void setLine(int line, const string& str, const bool& state); |
| 41 | |
| 42 | bool getState(int line); |
| 43 | bool getSelectedState() { return getState(_selectedItem); } |
| 44 | |
| 45 | protected: |
| 46 | void handleMouseEntered() override; |
| 47 | void handleMouseLeft() override; |
| 48 | |
| 49 | private: |
| 50 | bool handleEvent(Event::Type e) override; |
| 51 | void handleCommand(CommandSender* sender, int cmd, int data, int id) override; |
| 52 | |
| 53 | void drawWidget(bool hilite) override; |
| 54 | Common::Rect getEditRect() const override; |
| 55 | |
| 56 | protected: |
| 57 | BoolArray _stateList; |
| 58 | CheckboxArray _checkList; |
| 59 | |
| 60 | private: |
| 61 | // Following constructors and assignment operators not supported |
| 62 | CheckListWidget() = delete; |
| 63 | CheckListWidget(const CheckListWidget&) = delete; |
| 64 | CheckListWidget(CheckListWidget&&) = delete; |
| 65 | CheckListWidget& operator=(const CheckListWidget&) = delete; |
| 66 | CheckListWidget& operator=(CheckListWidget&&) = delete; |
| 67 | }; |
| 68 | |
| 69 | #endif |
| 70 | |