3 Copyright (C) 2010 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 General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
15 You should have received a copy of the GNU 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.
20 #ifndef MODALMENU_HEADER
21 #define MODALMENU_HEADER
23 #include "common_irrlicht.h"
25 //TODO: Change GUIElement private
26 class GUIModalMenu : public gui::IGUIElement
29 GUIModalMenu(gui::IGUIEnvironment* env,
30 gui::IGUIElement* parent, s32 id,
31 int *active_menu_count):
32 IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
33 core::rect<s32>(0,0,100,100))
35 m_active_menu_count = active_menu_count;
36 m_allow_focus_removal = false;
37 m_screensize_old = v2u32(0,0);
40 Environment->setFocus(this);
41 (*m_active_menu_count)++;
43 virtual ~GUIModalMenu()
45 (*m_active_menu_count)--;
48 bool canTakeFocus(gui::IGUIElement *e)
50 return (e && (e == this || isMyChild(e))) || m_allow_focus_removal;
55 m_allow_focus_removal = true;
56 // This removes Environment's grab on us
57 Environment->removeFocus(this);
61 virtual void regenerateGui(v2u32 screensize) = 0;
63 virtual void drawMenu() = 0;
70 video::IVideoDriver* driver = Environment->getVideoDriver();
71 v2u32 screensize = driver->getScreenSize();
72 if(screensize != m_screensize_old)
74 m_screensize_old = screensize;
75 regenerateGui(screensize);
81 virtual bool OnEvent(const SEvent& event) { return false; };
84 int *m_active_menu_count;
85 bool m_allow_focus_removal;
86 v2u32 m_screensize_old;