ScummVM API documentation
mac_dialogs.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 MADS_NEBULAR_MAC_DIALOGS_H
23#define MADS_NEBULAR_MAC_DIALOGS_H
24
25#include "common/array.h"
26#include "common/rect.h"
27#include "common/str-array.h"
28
29namespace Graphics {
30class Font;
31class MacWindowManager;
32class ManagedSurface;
33}
34
35namespace MADS {
36namespace RexNebular {
37
38class MacResourceProvider;
39class MacNebularMenu;
40class RexNebularEngine;
41
42enum MacDialogEditCommand {
43 kMacDialogUndo,
44 kMacDialogCut,
45 kMacDialogCopy,
46 kMacDialogPaste,
47 kMacDialogClear
48};
49
51private:
52 enum ItemType {
53 kUserItem = 0,
54 kButton = 4,
55 kCheckbox = 5,
56 kRadioButton = 6,
57 kStaticText = 8,
58 kEditableText = 16
59 };
60
61 struct Item {
62 Common::Rect bounds;
63 Common::String text;
64 Common::String undoText;
66 byte type;
67 bool enabled;
68 bool checked;
69 bool listItem;
70 bool hasUndo;
71 int listSelection;
72 int listTop;
73 uint caret;
74 uint selectionStart;
75 uint selectionEnd;
76 uint maxLength;
77
78 Item();
79 };
80
81 RexNebularEngine &_engine;
82 MacResourceProvider &_resources;
84 Graphics::MacWindowManager &_windowManager;
85 MacNebularMenu *_menus;
86 const Graphics::Font *_font;
87 Common::Rect _bounds;
89 int _focusItem;
90 int _pressedItem;
91 int _defaultItem;
92 int _cancelItem;
93 bool _redraw;
94 bool _inlineEditable;
95
96 Item *getItem(int itemNumber);
97 const Item *getItem(int itemNumber) const;
98 Common::Rect getItemBounds(const Item &item) const;
99 bool loadDialogResource(uint16 resourceID, uint16 &itemResourceID);
100 bool loadDialogItems(uint16 resourceID);
101 void draw();
102 void drawItem(Item &item, int itemNumber);
103 void drawButton(const Item &item, const Common::Rect &bounds,
104 bool pressed);
105 void drawCheckbox(const Item &item, const Common::Rect &bounds);
106 void drawRadioButton(const Item &item, const Common::Rect &bounds);
107 void drawEditable(Item &item, const Common::Rect &bounds,
108 bool focused);
109 void drawList(const Item &item, const Common::Rect &bounds,
110 bool focused);
111 void setFocus(int itemNumber);
112 void focusNext(bool backwards);
113 void selectRadio(int itemNumber);
114 void selectList(Item &item, int selection);
115 void ensureListSelectionVisible(Item &item);
116 void moveCaret(Item &item, int position, bool extend);
117 void deleteSelection(Item &item);
118 void rememberUndo(Item &item);
119 void insertCharacter(Item &item, char character);
120 void handleKey(const Common::Event &event, int &result, bool &done);
121 void handleMouseDown(const Common::Point &point);
122 void handleMouseUp(const Common::Point &point, int &result, bool &done);
123 void restore(const Graphics::ManagedSurface &saved, bool cursorWasVisible);
124
125public:
128 Graphics::MacWindowManager &windowManager,
129 MacNebularMenu *menus = nullptr);
130
131 bool load(uint16 resourceID);
132 void configureInlineEditable(const Common::Rect &bounds,
133 const Common::String &text, uint maxLength);
134 void center();
135 void setItemEnabled(int itemNumber, bool enabled);
136 void setItemChecked(int itemNumber, bool checked);
137 bool isItemChecked(int itemNumber) const;
138 void setItemText(int itemNumber, const Common::String &text);
139 void setItemMaxLength(int itemNumber, uint maxLength);
140 Common::String getItemText(int itemNumber) const;
141 void setList(int itemNumber, const Common::StringArray &entries,
142 int selection);
143 int getListSelection(int itemNumber) const;
144 bool hasEditableFocus() const;
145 bool isEditCommandEnabled(MacDialogEditCommand commandId) const;
146 bool handleEditCommand(MacDialogEditCommand commandId);
147 int runModal(int defaultItem, int cancelItem);
148};
149
150} // namespace RexNebular
151} // namespace MADS
152
153#endif
Definition: str.h:59
Definition: font.h:83
Definition: macwindowmanager.h:149
Definition: managed_surface.h:51
Definition: mac_dialogs.h:50
Definition: mac_menus.h:48
Definition: mac_resources.h:43
Definition: nebular.h:44
Definition: formatinfo.h:28
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536