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