code_uiradiobutton.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // UIRadioButton application source code
  2. #include <Atomic/UI/UIRadioButton.h>
  3. #include "PeriodicApp.h"
  4. void PeriodicApp::setup_uiradiobutton( UIWidget *layout)
  5. {
  6. PODVector<UIWidget*> dest;
  7. layout->SearchWidgetClass( "TBButton", dest );
  8. for (unsigned ii = 0; ii < dest.Size(); ii++)
  9. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiradiobuttonEvent ));
  10. UIWidget *demochk = layout->GetWidget ("demoradio");
  11. if ( demochk)
  12. SubscribeToEvent( demochk, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiradiobuttonEvent ));
  13. }
  14. void PeriodicApp::HandleUiradiobuttonEvent(StringHash eventType, VariantMap& eventData)
  15. {
  16. using namespace WidgetEvent;
  17. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  18. if ( widget == NULL ) return;
  19. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  20. {
  21. if (widget->GetId() == "uiradiobuttoncode" )
  22. {
  23. AppLog( "UIRadioButton support : " + widget->GetId() + " was pressed " );
  24. ViewCode ( "Components/code_uiradiobutton.cpp", widget->GetParent() );
  25. }
  26. if (widget->GetId() == "uiradiobuttonlayout" )
  27. {
  28. AppLog( "UIRadioButton support : " + widget->GetId() + " was pressed ");
  29. ViewCode ( "Scenes/layout_uiradiobutton.ui.txt", widget->GetParent() );
  30. }
  31. if (widget->GetId() == "demoradio" )
  32. {
  33. AppLog( "UIRadioButton event : " + widget->GetId() + " was pressed, state = " + String ( widget->GetValue() ) );
  34. }
  35. if (widget->GetId() == "radioset" )
  36. {
  37. UIWidget *demochk = widget->FindWidget ("demoradio");
  38. if (demochk)
  39. {
  40. demochk->SetValue (1);
  41. AppLog( "UIRadioButton action : " + widget->GetId() + " was pressed, set state to 1" );
  42. }
  43. }
  44. if (widget->GetId() == "radiounset" )
  45. {
  46. UIWidget *demochk = widget->FindWidget ("demoradio");
  47. if (demochk)
  48. {
  49. demochk->SetValue (0);
  50. AppLog( "UIRadioButton action : " + widget->GetId() + " was pressed, set state to 0" );
  51. }
  52. }
  53. }
  54. }