ComboBox.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_CONTROLS_COMBOBOX_H
  8. #define GWEN_CONTROLS_COMBOBOX_H
  9. #include "Gwen/Controls/Base.h"
  10. #include "Gwen/Controls/Button.h"
  11. #include "Gwen/Gwen.h"
  12. #include "Gwen/Skin.h"
  13. #include "Gwen/Controls/TextBox.h"
  14. #include "Gwen/Controls/Menu.h"
  15. namespace Gwen
  16. {
  17. namespace Controls
  18. {
  19. class GWEN_EXPORT ComboBoxButton : public Button
  20. {
  21. GWEN_CONTROL_INLINE( ComboBoxButton, Button ){}
  22. virtual void Render( Skin::Base* skin )
  23. {
  24. skin->DrawComboBoxButton( this, m_bDepressed );
  25. }
  26. };
  27. class GWEN_EXPORT ComboBox : public Button
  28. {
  29. public:
  30. GWEN_CONTROL( ComboBox, Button );
  31. virtual void Render( Skin::Base* skin );
  32. virtual Gwen::Controls::Label* GetSelectedItem();
  33. virtual void OnPress();
  34. void OpenButtonPressed( Controls::Base* /*pControl*/ );
  35. virtual void OnItemSelected( Controls::Base* pControl );
  36. virtual void OpenList();
  37. virtual void CloseList();
  38. virtual Controls::Base* GetControlAt( int x, int y )
  39. {
  40. if ( x < 0 || y < 0 || x >= Width() || y >= Height() )
  41. return NULL;
  42. return this;
  43. }
  44. virtual bool IsMenuComponent()
  45. {
  46. return true;
  47. }
  48. virtual void ClearItems();
  49. virtual MenuItem* AddItem( const UnicodeString& strLabel, const String& strName = "", Gwen::Event::Handler* pHandler = NULL, Gwen::Event::Handler::Function fn = NULL );
  50. virtual bool OnKeyUp( bool bDown );
  51. virtual bool OnKeyDown( bool bDown );
  52. virtual void RenderFocus( Gwen::Skin::Base* skin );
  53. virtual void OnLostKeyboardFocus();
  54. virtual void OnKeyboardFocus();
  55. virtual bool IsMenuOpen();
  56. Gwen::Event::Caller onSelection;
  57. protected:
  58. Menu* m_Menu;
  59. MenuItem* m_SelectedItem;
  60. Controls::Base* m_Button;
  61. };
  62. }
  63. }
  64. #endif