3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "irrlichttypes_extrabloated.h"
24 #include "util/string.h"
31 // A GUIModalMenu calls these when this class is passed as a parameter
32 virtual void createdMenu(gui::IGUIElement *menu) = 0;
33 virtual void deletingMenu(gui::IGUIElement *menu) = 0;
36 // Remember to drop() the menu after creating, so that it can
37 // remove itself when it wants to.
39 class GUIModalMenu : public gui::IGUIElement
42 GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id,
43 IMenuManager *menumgr, bool remap_dbl_click = true);
44 virtual ~GUIModalMenu();
46 void allowFocusRemoval(bool allow);
47 bool canTakeFocus(gui::IGUIElement *e);
51 virtual void regenerateGui(v2u32 screensize) = 0;
52 virtual void drawMenu() = 0;
53 virtual bool preprocessEvent(const SEvent &event);
54 virtual bool OnEvent(const SEvent &event) { return false; };
55 virtual bool pausesGame() { return false; } // Used for pause menu
57 virtual bool getAndroidUIInput() { return false; }
58 bool hasAndroidUIInput();
62 virtual std::wstring getLabelByID(s32 id) = 0;
63 virtual std::string getNameByID(s32 id) = 0;
66 * check if event is part of a double click
67 * @param event event to evaluate
68 * @return true/false if a doubleclick was detected
70 bool DoubleClickDetection(const SEvent &event);
73 v2s32 m_old_pointer; // Mouse position after previous mouse event
74 v2u32 m_screensize_old;
77 std::string m_jni_field_name;
79 #ifdef HAVE_TOUCHSCREENGUI
81 bool m_touchscreen_visible = true;
90 clickpos m_doubleclickdetect[2];
92 IMenuManager *m_menumgr;
93 /* If true, remap a double-click (or double-tap) action to ESC. This is so
94 * that, for example, Android users can double-tap to close a formspec.
96 * This value can (currently) only be set by the class constructor
97 * and the default value for the setting is true.
99 bool m_remap_dbl_click;
100 // This might be necessary to expose to the implementation if it
101 // wants to launch other menus
102 bool m_allow_focus_removal = false;
104 #ifdef HAVE_TOUCHSCREENGUI
105 irr_ptr<gui::IGUIElement> m_hovered;
107 bool simulateMouseEvent(gui::IGUIElement *target, ETOUCH_INPUT_EVENT touch_event);
108 void enter(gui::IGUIElement *element);