ComboBox.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "UnitTest.h"
  2. #include "Gwen/Controls/ComboBox.h"
  3. using namespace Gwen;
  4. class ComboBox : public GUnit
  5. {
  6. public:
  7. GWEN_CONTROL_INLINE( ComboBox, GUnit )
  8. {
  9. {
  10. Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
  11. combo->SetKeyboardInputEnabled(true);
  12. combo->SetPos( 50, 50 );
  13. combo->SetWidth( 200 );
  14. combo->AddItem( L"Option One", "one" );
  15. combo->AddItem( L"Number Two", "two" );
  16. combo->AddItem( L"Door Three", "three" );
  17. combo->AddItem( L"Four Legs", "four" );
  18. combo->AddItem( L"Five Birds", "five" );
  19. combo->onSelection.Add( this, &ComboBox::OnComboSelect );
  20. }
  21. {
  22. // Empty..
  23. Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
  24. combo->SetPos( 50, 80 );
  25. combo->SetWidth( 200 );
  26. }
  27. {
  28. // Empty..
  29. Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
  30. combo->SetPos( 50, 110 );
  31. combo->SetWidth( 200 );
  32. for (int i=0; i<500; i++ )
  33. combo->AddItem( L"Lots Of Options" );
  34. }
  35. }
  36. void OnComboSelect( Gwen::Controls::Base* pControl )
  37. {
  38. Gwen::Controls::ComboBox* combo = (Gwen::Controls::ComboBox*)pControl;
  39. UnitPrint( Utility::Format( L"Combo Changed: %s", combo->GetSelectedItem()->GetText().c_str() ) );
  40. }
  41. };
  42. DEFINE_UNIT_TEST( ComboBox, L"ComboBox" );