1 /* 2 GWEN 3 Copyright (c) 2010 Facepunch Studios 4 See license in Gwen.h 5 */ 6 7 #pragma once 8 #ifndef GWEN_CONTROLS_MENU_H 9 #define GWEN_CONTROLS_MENU_H 10 11 #include "Gwen/BaseRender.h" 12 #include "Gwen/Controls/Base.h" 13 #include "Gwen/Controls/MenuItem.h" 14 #include "Gwen/Controls/ScrollControl.h" 15 16 namespace Gwen 17 { 18 namespace Controls 19 { 20 class MenuItem; 21 22 class GWEN_EXPORT Menu : public ScrollControl 23 { 24 public: 25 GWEN_CONTROL(Menu, ScrollControl); 26 27 virtual void Render(Skin::Base* skin); 28 virtual void RenderUnder(Skin::Base* skin); 29 30 virtual void Layout(Skin::Base* skin); 31 32 virtual MenuItem* AddItem(const Gwen::UnicodeString& strName, const UnicodeString& strIconName, Gwen::Event::Handler* pHandler = NULL, Gwen::Event::Handler::Function fn = NULL); 33 34 virtual MenuItem* AddItem(const Gwen::UnicodeString& strName, Gwen::Event::Handler* pHandler = NULL, Gwen::Event::Handler::Function fn = NULL) 35 { 36 return AddItem(strName, L"", pHandler, fn); 37 } 38 39 virtual MenuItem* AddItem(const Gwen::String& strName, const String& strIconName, Gwen::Event::Handler* pHandler = NULL, Gwen::Event::Handler::Function fn = NULL); 40 41 virtual MenuItem* AddItem(const Gwen::String& strName, Gwen::Event::Handler* pHandler = NULL, Gwen::Event::Handler::Function fn = NULL) 42 { 43 return AddItem(strName, "", pHandler, fn); 44 } 45 46 virtual void AddDivider(); 47 48 void OnHoverItem(Gwen::Controls::Base* pControl); 49 void CloseAll(); 50 bool IsMenuOpen(); 51 void ClearItems(); 52 53 virtual void Close(); 54 IsMenuComponent()55 virtual bool IsMenuComponent() { return true; } 56 virtual void CloseMenus(); 57 IconMarginDisabled()58 bool IconMarginDisabled() { return m_bDisableIconMargin; } SetDisableIconMargin(bool bDisable)59 void SetDisableIconMargin(bool bDisable) { m_bDisableIconMargin = bDisable; } 60 ShouldClip()61 virtual bool ShouldClip() { return false; } 62 63 protected: ShouldHoverOpenMenu()64 virtual bool ShouldHoverOpenMenu() { return true; } 65 virtual void OnAddItem(MenuItem* item); 66 67 bool m_bDisableIconMargin; 68 }; 69 70 class GWEN_EXPORT MenuDivider : public Base 71 { 72 public: GWEN_CONTROL_INLINE(MenuDivider,Base)73 GWEN_CONTROL_INLINE(MenuDivider, Base) 74 { 75 SetHeight(1); 76 } 77 78 void Render(Gwen::Skin::Base* skin); 79 }; 80 } // namespace Controls 81 82 } // namespace Gwen 83 #endif 84