diff options
author | rubidium <rubidium@openttd.org> | 2008-05-08 12:59:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-08 12:59:47 +0000 |
commit | 9ed36409c5c39d26788dd8f99b0a6a1082cda375 (patch) | |
tree | 93e0cdfaa25c7e394324651ebd74bbe7cc253e3b /src/toolbar_gui.cpp | |
parent | 23fc96c3e8c252edbf2e7c22cefab633a0474410 (diff) | |
download | openttd-9ed36409c5c39d26788dd8f99b0a6a1082cda375.tar.xz |
(svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
Diffstat (limited to 'src/toolbar_gui.cpp')
-rw-r--r-- | src/toolbar_gui.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index f0ac39dd8..17061c005 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -77,6 +77,26 @@ static Point GetToolbarDropdownPos(uint16 parent_button, int width, int height) return pos; } +/** + * In a window with menu_d custom extension, retrieve the menu item number from a position + * @param w Window holding the menu items + * @param x X coordinate of the position + * @param y Y coordinate of the position + * @return Index number of the menu item, or \c -1 if no valid selection under position + */ +static int GetMenuItemIndex(const Window *w, int x, int y) +{ + if ((x -= w->left) >= 0 && x < w->width && (y -= w->top + 1) >= 0) { + y /= 10; + + if (y < WP(w, const menu_d).item_count && + !HasBit(WP(w, const menu_d).disabled_items, y)) { + return y; + } + } + return -1; +} + /* --- Pausing --- */ static void ToolbarPauseClick(Window *w) |