RadioButton.cpp 984 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "UnitTest.h"
  2. #include "Gwen/Controls/RadioButtonController.h"
  3. using namespace Gwen;
  4. class RadioButton2 : public GUnit
  5. {
  6. public:
  7. GWEN_CONTROL_INLINE( RadioButton2, GUnit )
  8. {
  9. Gwen::Controls::RadioButtonController* rc = new Gwen::Controls::RadioButtonController( this );
  10. rc->AddOption( "Option 1" );
  11. rc->AddOption( "Option 2" );
  12. rc->AddOption( "Option 3" );
  13. rc->AddOption( L"\u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631" );
  14. rc->SetBounds( 30, 30, 200, 200 );
  15. rc->onSelectionChange.Add( this, &RadioButton2::OnChange );
  16. }
  17. void OnChange( Controls::Base* pControl )
  18. {
  19. Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*) pControl;
  20. Gwen::Controls::LabeledRadioButton* pSelected = rc->GetSelected();
  21. UnitPrint( Utility::Format( L"RadioButton changed (using 'OnChange' event)\n Chosen Item: '%s'", pSelected->GetLabel()->GetText().c_str() ) );
  22. }
  23. };
  24. DEFINE_UNIT_TEST( RadioButton2, L"RadioButton" );