code_uifinderwindow.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // UIFinderWindow application source code
  2. #include <Atomic/UI/UIEvents.h>
  3. #include <Atomic/UI/UIFinderWindow.h>
  4. #include "PeriodicApp.h"
  5. void PeriodicApp::setup_uifinderwindow( UIWidget *layout, UIView *uiview )
  6. {
  7. PODVector<UIWidget*> dest;
  8. layout->SearchWidgetClass( "TBButton", dest );
  9. for (unsigned ii = 0; ii < dest.Size(); ii++)
  10. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUifinderwindowEvent ));
  11. }
  12. void PeriodicApp::HandleFinderCompleteEvent(StringHash eventType, VariantMap& eventData)
  13. {
  14. using namespace UIFinderComplete;
  15. AppLog( "UIFinderWindow event : the window " + eventData[P_TITLE].GetString()
  16. + " file was " + eventData[P_SELECTED].GetString()
  17. + ", the button pressed was " + eventData[P_REASON].GetString());
  18. }
  19. void PeriodicApp::HandleUifinderwindowEvent(StringHash eventType, VariantMap& eventData)
  20. {
  21. using namespace WidgetEvent;
  22. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  23. if ( widget == NULL ) return;
  24. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  25. {
  26. if (widget->GetId() == "uifinderwindowcode" )
  27. {
  28. AppLog( "UIFinderWindow support : " + widget->GetId() + " was pressed " );
  29. ViewCode ( "Components/code_uifinderwindow.cpp", widget->GetParent() );
  30. }
  31. if (widget->GetId() == "uifinderwindowlayout" )
  32. {
  33. AppLog( "UIFinderWindow support : " + widget->GetId() + " was pressed ");
  34. ViewCode ( "Scenes/layout_uifinderwindow.ui.txt", widget->GetParent() );
  35. }
  36. if (widget->GetId() == "filefinder" )
  37. {
  38. AppLog( "UIFinderWindow action : " + widget->GetId() + " was pressed ");
  39. UIWidget *someview = (UIWidget *)widget->GetView();
  40. UIFinderWindow *windowf = new UIFinderWindow(context_, someview, widget->GetId());
  41. SubscribeToEvent( windowf, E_UIFINDERCOMPLETE, ATOMIC_HANDLER(PeriodicApp, HandleFinderCompleteEvent ));
  42. windowf->FindFile("Find a File", "", 0, 0, 0);
  43. }
  44. if (widget->GetId() == "folderfinder" )
  45. {
  46. AppLog( "UIFinderWindow action : " + widget->GetId() + " was pressed ");
  47. UIWidget *someview = (UIWidget *)widget->GetView();
  48. UIFinderWindow *windowd = new UIFinderWindow(context_, someview, widget->GetId() );
  49. SubscribeToEvent( windowd, E_UIFINDERCOMPLETE, ATOMIC_HANDLER(PeriodicApp, HandleFinderCompleteEvent ));
  50. windowd->FindPath("Find a Folder", "", 0, 0, 0);
  51. }
  52. }
  53. }