code_uimessagewindow.cpp 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // UIMessageWindow application source code
  2. #include <Atomic/UI/UIMessageWindow.h>
  3. #include "PeriodicApp.h"
  4. void PeriodicApp::setup_uimessagewindow( 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, HandleUimessagewindowEvent ));
  10. }
  11. void PeriodicApp::HandleUimessagewindowEvent(StringHash eventType, VariantMap& eventData)
  12. {
  13. using namespace WidgetEvent;
  14. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  15. if ( widget == NULL ) return;
  16. UIWidget* mylayout = static_cast<UIWidget*>(widget->FindWidget("pageuimessagewindow"));
  17. String refid = eventData[P_REFID].GetString();
  18. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  19. {
  20. if (widget->GetId() == "uimessagewindowcode" )
  21. {
  22. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed " );
  23. ViewCode ( "Components/code_uimessagewindow.cpp", widget->GetParent() );
  24. }
  25. if (widget->GetId() == "uimessagewindowlayout" )
  26. {
  27. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed ");
  28. ViewCode ( "Scenes/layout_uimessagewindow.ui.txt", widget->GetParent() );
  29. }
  30. if (widget->GetId() == "msgnone" )
  31. {
  32. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed ");
  33. UIMessageWindow *mess1 = new UIMessageWindow(context_, mylayout, "mymess1");
  34. mess1->Show("MessageWindow - NONE", "this is a MessageWindow - None button", (UI_MESSAGEWINDOW_SETTINGS)0, 0, 0, 0);
  35. }
  36. if (widget->GetId() == "msgok" )
  37. {
  38. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed ");
  39. UIMessageWindow *mess2 = new UIMessageWindow(context_, mylayout, "mymess2");
  40. SubscribeToEvent(mess2, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUimessagewindowEvent ));
  41. mess2->Show("MessageWindow - OK", "this is a MessageWindow - OK button", UI_MESSAGEWINDOW_SETTINGS_OK, 0, 0, 0);
  42. }
  43. if (widget->GetId() == "msgkcancel" )
  44. {
  45. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed ");
  46. UIMessageWindow *mess3 = new UIMessageWindow(context_, mylayout, "mymess3");
  47. SubscribeToEvent(mess3, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUimessagewindowEvent ));
  48. mess3->Show("MessageWindow - OK CANCEL", "this is a MessageWindow - OK CANCEL buttons", UI_MESSAGEWINDOW_SETTINGS_OK_CANCEL, 0, 0, 0);
  49. }
  50. if (widget->GetId() == "msgyesno" )
  51. {
  52. AppLog( "UIMessageWindow support : " + widget->GetId() + " was pressed ");
  53. UIMessageWindow *mess4 = new UIMessageWindow(context_, mylayout, "mymess4");
  54. SubscribeToEvent(mess4, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUimessagewindowEvent ));
  55. mess4->Show( "MessageWindow - YES NO", "this is a MessageWindow - YES NO buttons", UI_MESSAGEWINDOW_SETTINGS_YES_NO, 0, 0, 0);
  56. }
  57. if (refid == "TBMessageWindow.ok" )
  58. {
  59. AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  60. }
  61. if (refid == "TBMessageWindow.cancel" )
  62. {
  63. AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  64. }
  65. if (refid == "TBMessageWindow.yes" )
  66. {
  67. AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  68. }
  69. if (refid == "TBMessageWindow.no" )
  70. {
  71. AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  72. }
  73. }
  74. else
  75. {
  76. AppLog( "UIMessageWindow event : " + widget->GetId() + " event type = " + EventReport(eventData[P_TYPE].GetInt()));
  77. }
  78. }