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 text(t), unicode(
false), action(a), style(s), shortcut(sh),
75 shortcutPos(sp), enabled(e), submenu(
nullptr), checked(c) {}
77 unicodeText(t), unicode(
true), action(a), style(s), shortcut(sh),
78 shortcutPos(sp), enabled(e), submenu(
nullptr), checked(c) {}
101 bool isDirty()
override {
return _contentIsDirty || _dimensionsDirty; }
108 void setCommandsCallback(
void (*callback)(
int,
Common::String &,
void *),
void *data) { _ccallback = callback; _cdata = data; }
109 void setCommandsCallback(
void (*callback)(
int,
Common::U32String &,
void *),
void *data) { _unicodeccallback = callback; _cdata = data; }
112 void calcDimensions();
123 int addMenuItem(
MacMenuSubMenu *submenu,
const Common::String &text,
int action = -1,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
124 int addMenuItem(
MacMenuSubMenu *submenu,
const Common::U32String &text,
int action = 0,
int style = 0,
char shortcut = 0,
bool enabled =
true,
bool checked =
false);
125 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);
126 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);
130 void createSubMenuFromString(
int id,
const char *
string,
int commandId);
131 void clearSubMenu(
int id);
137 bool mouseClick(
int x,
int y);
138 bool draw(
bool forceRedraw =
false)
override {
return false; }
143 void enableCommand(
int menunum,
int action,
bool state);
144 void enableCommand(
const char *menuitem,
const char *menuaction,
bool state);
146 void enableAllMenus();
147 void disableAllMenus();
149 bool isVisible() {
return _isVisible; }
150 void setVisible(
bool visible,
bool silent =
false)
override { _isVisible = visible; _contentIsDirty =
true; }
154 virtual void closeMenu();
159 void setCheckMark(
MacMenuItem *menuItem,
bool checkMark);
162 void setEnabled(
MacMenuItem *menuItem,
bool enabled);
168 void setAction(
MacMenuItem *menuItem,
int actionId);
171 int getLastSelectedMenuItem() {
return _lastActiveItem; };
172 int getLastSelectedSubmenuItem() {
return _lastActiveSubItem; };
176 int getScrollDirection() {
return _scrollDirection; }
178 int getDropdownItemHeight() {
return _menuDropdownItemHeight; }
187 bool _dimensionsDirty;
188 int _menuDropdownItemHeight;
200 int _menuLeftDropdownPadding;
201 int _menuRightDropdownPadding;
204 bool checkCallback(
bool unicode =
false);
205 const Font *getMenuFont(
int slant = kMacFontRegular);
213 bool mouseRelease(
int x,
int y);
214 bool mouseMove(
int x,
int y);
216 bool processMenuShortCut(uint16 ascii);
218 void drawSubMenuArrow(
ManagedSurface *dst,
int x,
int y,
int color);
219 bool contains(
int x,
int y);
221 void drawScrollArrow(
int arrowX,
int arrowY,
int direction);
231 int _lastActiveSubItem;
233 bool _scrollTimerActive;
234 int _scrollDirection;
Definition: managed_surface.h:51
Definition: macresman.h:125
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:315
Definition: macwindow.h:73