Menu.h 2.1 KB

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