ScummVM API documentation
menuitem.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA4_VIEWS_MENUITEM_H
23 #define ULTIMA4_VIEWS_MENUITEM_H
24 
25 #include "common/str.h"
26 
27 namespace Ultima {
28 namespace Ultima4 {
29 
30 class MenuEvent;
31 
37 enum menuOutputType {
38  MENU_OUTPUT_INT,
39  MENU_OUTPUT_GAMMA,
40  MENU_OUTPUT_SHRINE,
41  MENU_OUTPUT_SPELL,
42  MENU_OUTPUT_VOLUME,
43  MENU_OUTPUT_REAGENT
44 };
45 
46 class MenuItem {
47 public:
51  MenuItem(const Common::String &text, short x, short y, int shortcutKey = -1);
52  virtual ~MenuItem() {}
53 
54  virtual void activate(MenuEvent &event) {}
55 
56  // Accessor Methods
57  int getId() const;
58  short getX() const;
59  short getY() const;
60  int getScOffset() const;
61 
62  virtual Common::String getText() const;
63  bool isHighlighted() const;
64  bool isSelected() const;
65  bool isVisible() const;
66  bool hasShortcutKey(int key) const;
67  bool getClosesMenu() const;
68 
69  void setId(int id);
70  void setX(int x);
71  void setY(int y);
72  void setText(const Common::String &text);
73  void setHighlighted(bool h = true);
74  void setSelected(bool s = true);
75  void setVisible(bool v = true);
76  void addShortcutKey(int shortcutKey);
77  void setClosesMenu(bool closesMenu);
78 
79 protected:
80  int _id;
81  short _x, _y;
82  Common::String _text;
83  bool _highlighted;
84  bool _selected;
85  bool _visible;
86  int _scOffset;
87  Common::Array<int> _shortcutKeys;
88  bool _closesMenu;
89 };
90 
95 class BoolMenuItem : public MenuItem {
96 public:
97  BoolMenuItem(const Common::String &text, short xp, short yp, int shortcutKey, bool *val);
98 
99  BoolMenuItem *setValueStrings(const Common::String &onString, const Common::String &offString);
100 
101  void activate(MenuEvent &event) override;
102  Common::String getText() const override;
103 
104 protected:
105  bool *_val;
106  Common::String _on, _off;
107 };
108 
113 class StringMenuItem : public MenuItem {
114 public:
115  StringMenuItem(const Common::String &text, short xp, short yp, int shortcutKey, Common::String *val, const Common::Array<Common::String> &validSettings);
116 
117  void activate(MenuEvent &event) override;
118  Common::String getText() const override;
119 
120 protected:
121  Common::String *_val;
122  Common::Array<Common::String> _validSettings;
123 };
124 
129 class IntMenuItem : public MenuItem {
130 public:
131  IntMenuItem(const Common::String &text, short xp, short yp, int shortcutKey, int *val, int min, int max, int increment, menuOutputType output = MENU_OUTPUT_INT);
132 
133  void activate(MenuEvent &event) override;
134  Common::String getText() const override;
135 
136 protected:
137  int *_val;
138  int _min, _max, _increment;
139  menuOutputType _output;
140 };
141 
142 } // End of namespace Ultima4
143 } // End of namespace Ultima
144 
145 #endif
Definition: str.h:59
Definition: menuitem.h:95
Definition: menu.h:36
Definition: detection.h:27
Definition: menuitem.h:46
Definition: menuitem.h:129
Definition: menuitem.h:113
MenuItem(const Common::String &text, short x, short y, int shortcutKey=-1)