22 #ifndef GRAPHICS_MACGUI_MACMENU_H 23 #define GRAPHICS_MACGUI_MACMENU_H 25 #include "common/str-array.h" 26 #include "graphics/macgui/macfontmanager.h" 27 #include "graphics/macgui/macwindow.h" 28 #include "graphics/font.h" 39 struct MacMenuSubMenu;
50 MacMenuSubMenu() : highlight(-1), visStart(0), visEnd(0), scroll(0) {}
54 void enableAllItems();
56 int ytoItem(
int y,
int itemHeight) {
return MIN<int>((y - bbox.top) / itemHeight, items.
size() - 1); }
74 MacMenuItem(
const Common::String &t,
int a = -1,
int s = 0,
char sh = 0,
int sp = -1,
bool e =
true,
bool c =
false,
int cs = 0) :
75 text(t), unicode(
false), action(a), style(s), shortcut(sh),
76 shortcutPos(sp), enabled(e), submenu(
nullptr), checked(c), checkSymbol(cs) {}
78 unicodeText(t), unicode(
true), action(a), style(s), shortcut(sh),
79 shortcutPos(sp), enabled(e), submenu(
nullptr), checked(c), checkSymbol(cs) {}
102 bool isDirty()
override {
return _contentIsDirty || _dimensionsDirty; }
109 void setCommandsCallback(
void (*callback)(
int,
Common::String &,
void *),
void *data) { _ccallback = callback; _cdata = data; }
110 void setCommandsCallback(
void (*callback)(
int,
Common::U32String &,
void *),
void *data) { _unicodeccallback = callback; _cdata = data; }
113 void calcDimensions();
124 int addMenuItem(
MacMenuSubMenu *submenu,
const Common::String &text,
int action = -1,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
125 int addMenuItem(
MacMenuSubMenu *submenu,
const Common::U32String &text,
int action = 0,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
126 void insertMenuItem(
MacMenuSubMenu *submenu,
const Common::String &text, uint pos,
int action = -1,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
127 void insertMenuItem(
MacMenuSubMenu *submenu,
const Common::U32String &text, uint pos,
int action = 0,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
131 void createSubMenuFromString(
int id,
const char *
string,
int commandId);
133 void clearSubMenu(
int id);
139 bool mouseClick(
int x,
int y);
140 bool draw(
bool forceRedraw =
false)
override {
return false; }
145 void enableCommand(
int menunum,
int action,
bool state);
146 void enableCommand(
const char *menuitem,
const char *menuaction,
bool state);
148 void enableAllMenus();
149 void disableAllMenus();
151 bool isVisible() {
return _isVisible; }
152 void setVisible(
bool visible,
bool silent =
false)
override { _isVisible = visible; _contentIsDirty =
true; }
154 void setFont(uint16 fontID, uint16 fontSize);
158 virtual void closeMenu();
163 void setCheckMark(
MacMenuItem *menuItem,
bool checkMark);
166 void setEnabled(
MacMenuItem *menuItem,
bool enabled);
172 void setAction(
MacMenuItem *menuItem,
int actionId);
175 int getLastSelectedMenuItem() {
return _lastActiveItem; };
176 int getLastSelectedSubmenuItem() {
return _lastActiveSubItem; };
177 void getMenuShortCut(uint16 key,
int &menuItem,
int &submenuItem);
181 int getScrollDirection() {
return _scrollDirection; }
183 int getDropdownItemHeight() {
return _menuDropdownItemHeight; }
185 void setOverlayDirty(
bool dirty) { _overlayDirty = dirty; _contentIsDirty |= dirty; }
193 bool _dimensionsDirty;
195 int _menuDropdownItemHeight;
207 int _menuLeftDropdownPadding;
208 int _menuRightDropdownPadding;
211 bool checkCallback(
bool unicode =
false);
212 const Font *getMenuFont(
int slant = kMacFontRegular);
213 Common::CodePage getMenuEncoding()
const;
221 bool mouseRelease(
int x,
int y);
222 bool mouseMove(
int x,
int y);
224 bool processMenuShortCut(uint16 ascii);
226 void drawSubMenuArrow(
ManagedSurface *dst,
int x,
int y,
int color);
227 bool contains(
int x,
int y);
229 void drawScrollArrow(
int arrowX,
int arrowY,
int direction);
241 int _lastActiveSubItem;
245 bool _scrollTimerActive;
246 int _scrollDirection;
Definition: managed_surface.h:51
Definition: macresman.h:126
Definition: winexe_pe.h:48
TextAlign
Definition: font.h:48
Definition: macwindowmanager.h:149
Definition: algorithm.h:29
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:316
Definition: macwindow.h:80