home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / dialog2 / appwin.cxx next >
C/C++ Source or Header  |  1995-04-08  |  2KB  |  95 lines

  1.  
  2.  
  3.  
  4. #include "ui/orbtngrp.h"
  5. #include "ui/xrbtngrp.h"
  6. #include "ui/pushbtn.h"
  7. #include "ui/label.h"
  8. #include "ui/stred.h"
  9. #include "ui/dialog.h"
  10. #include "ui/applic.h"
  11.  
  12. #include "appwin.h"
  13. #include "ids.h"
  14.  
  15. UI_ViewDescriptor desc[] = {
  16.     {View_PushButton, ID_START, 0, 0,  60, 30, TRUE, "Start"},
  17.     {View_PushButton, ID_QUIT,  0, 60, 60, 30, TRUE, "Quit"},
  18.     {View_None, -1, 0, 0, 0, 0, 0, 0}
  19. };
  20.  
  21.  
  22. UI_DialogEventDescriptor desc2 [] = {
  23.     ID_OK,     Event_Select,
  24.     ID_CANCEL, Event_Select,
  25.     -1,  Event_None
  26. };
  27.  
  28.  
  29.  
  30.  
  31. AppWindow::AppWindow ()
  32. : UI_CompositeVObject (NULL, desc, FALSE, UI_Rectangle (50, 50, 500, 400))
  33. {
  34.     msg = new UI_Label (this, UI_Rectangle (10, 100, 340, 250));
  35.     msg->Font().PointSize(10);
  36.     _title = "YACL Dialog Demo";
  37. }
  38.  
  39.  
  40.  
  41.  
  42. extern FAR UI_ViewDescriptor  DLG_DIALOG_1_Item[];
  43. extern FAR UI_RectangleStruct DLG_DIALOG_1_Shape;
  44.  
  45.  
  46. #if defined(__MS_WINDOWS__)
  47. #define END_OF_LINE "\r\n"
  48. #else
  49. #define END_OF_LINE "\n"
  50. #endif
  51.  
  52.  
  53. bool AppWindow::HandleChildEvent(const UI_Event& e)
  54. {
  55.     UI_CompositeVObject::HandleChildEvent (e);
  56.     if( e.Origin()->ViewID() == ID_QUIT && e.Type()== Event_Select) {
  57.         _Application->End();
  58.         return FALSE;
  59.     }
  60.     if (e.Origin()->ViewID() != ID_START || e.Type() != Event_Select)
  61.         return FALSE;
  62.  
  63.  
  64.     UI_Dialog* d =  new UI_Dialog (this,  DLG_DIALOG_1_Item,
  65.                                    DLG_DIALOG_1_Shape, desc2);
  66.     d->Title() = "Inner dialog";
  67.     CL_String& stred_data = (CL_String &) ((*d) [ID_FILENAME])->Model();
  68.     stred_data = "File.txt";
  69.     CL_String& msg_value = (CL_String &) (msg->Model());
  70.     msg_value = "";
  71.  
  72.     UI_OrButtonGroup& grp = *(UI_OrButtonGroup*) (*d)[ID_PERMS];
  73.     grp[ID_READ]->Model() = CL_Integer (1);
  74.     
  75.     // Now execute the dialog modally
  76.     UI_ViewID quitID = d->ExecuteModal ().id; 
  77.  
  78.     // Retrieve its contents
  79.     CL_IntPtrMapIterator itr ((CL_IntPtrMap &) (d->Model()) );
  80.     itr.Reset();
  81.     while (itr.More()) {
  82.         CL_IntPtrAssoc  assoc = itr.Next();
  83.         UI_ViewID id = assoc.key;
  84.         msg_value += "Id " + CL_String (id)
  85.             + " value: " + assoc.value->AsString() + END_OF_LINE;
  86.     }
  87.     msg_value += "Quit button Id: " + CL_String (quitID)
  88.         + END_OF_LINE;
  89.  
  90.     // Get rid of the dialog
  91.     _Application->Destroy (d);
  92.     return TRUE;
  93. }
  94.  
  95.