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 | // Based on code from ScummVM - Scumm Interpreter |
18 | // Copyright (C) 2002-2004 The ScummVM project |
19 | //============================================================================ |
20 | |
21 | #ifndef RADIOBUTTON_WIDGET_HXX |
22 | #define RADIOBUTTON_WIDGET_HXX |
23 | |
24 | #include "bspf.hxx" |
25 | #include "Widget.hxx" |
26 | |
27 | class Dialog; |
28 | class RadioButtonGroup; |
29 | |
30 | class RadioButtonWidget : public CheckboxWidget |
31 | { |
32 | public: |
33 | RadioButtonWidget(GuiObject* boss, const GUI::Font& font, int x, int y, |
34 | const string& label, RadioButtonGroup* group, |
35 | int cmd = 0); |
36 | |
37 | void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; |
38 | void setState(bool state, bool send = true); |
39 | |
40 | protected: |
41 | void setFill(FillType type); |
42 | void drawWidget(bool hilite) override; |
43 | |
44 | private: |
45 | RadioButtonGroup* myGroup; |
46 | |
47 | private: |
48 | // Following constructors and assignment operators not supported |
49 | RadioButtonWidget() = delete; |
50 | RadioButtonWidget(const RadioButtonWidget&) = delete; |
51 | RadioButtonWidget(RadioButtonWidget&&) = delete; |
52 | RadioButtonWidget& operator=(const RadioButtonWidget&) = delete; |
53 | RadioButtonWidget& operator=(RadioButtonWidget&&) = delete; |
54 | }; |
55 | |
56 | class RadioButtonGroup |
57 | { |
58 | public: |
59 | RadioButtonGroup() : mySelected(0) { } |
60 | |
61 | // add widget to group |
62 | void addWidget(RadioButtonWidget* widget); |
63 | // tell the group which widget was selected |
64 | void select(RadioButtonWidget* widget); |
65 | void setSelected(uInt32 selected); |
66 | uInt32 getSelected() { return mySelected; } |
67 | |
68 | private: |
69 | WidgetArray myWidgets; |
70 | uInt32 mySelected; |
71 | |
72 | private: |
73 | // Following constructors and assignment operators not supported |
74 | RadioButtonGroup(const RadioButtonGroup&) = delete; |
75 | RadioButtonGroup(RadioButtonGroup&&) = delete; |
76 | RadioButtonGroup& operator=(const RadioButtonGroup&) = delete; |
77 | RadioButtonGroup& operator=(RadioButtonGroup&&) = delete; |
78 | }; |
79 | |
80 | #endif |
81 | |