home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / stddlg / appwin.cxx next >
C/C++ Source or Header  |  1995-03-28  |  3KB  |  110 lines

  1.  
  2. #include "appwin.h"
  3. #include "ui/cntroler.h"
  4. #include "ui/dialog.h"
  5. #include "ui/pushbtn.h"
  6. #include "ui/stddlg.h"
  7.  
  8. #include <fstream.h>
  9.  
  10. #define ID_LABEL   10
  11. #define ID_BUTTON1 11
  12. #define ID_BUTTON2 12
  13. #define ID_BUTTON3 13
  14. #define ID_BUTTON4 14
  15. #define ID_BUTTON5 15
  16.  
  17.  
  18.  
  19. UI_ViewDescriptor desc[] = {
  20.     {View_PushButton, ID_BUTTON1,  50,  15, 200, 40, TRUE, ""},
  21.     {View_PushButton, ID_BUTTON2,  50,  75, 200, 40, TRUE, ""},
  22.     {View_PushButton, ID_BUTTON3,  50, 135, 200, 40, TRUE, ""},
  23.     {View_PushButton, ID_BUTTON4,  50, 195, 200, 40, TRUE, ""},
  24.     {View_PushButton, ID_BUTTON5,  50, 245, 200, 40, TRUE, ""},
  25.     {View_Label,      ID_LABEL,    50, 285, 200, 40, TRUE, ""},
  26.     {View_None, 0}
  27. };
  28.     
  29. AppWindow::AppWindow()
  30. : UI_CompositeVObject (NULL, desc, FALSE, UI_Rectangle (50, 50, 300, 350))
  31. {
  32.     (*this)[ID_BUTTON1]->Title() = "Information";
  33.     (*this)[ID_BUTTON2]->Title() = "Warning";
  34.     (*this)[ID_BUTTON3]->Title() = "Error";
  35.     (*this)[ID_BUTTON4]->Title() = "Confirm";
  36.     (*this)[ID_BUTTON5]->Title() = "Select file";
  37.     _title                       = "YACL Standard Dialogs Demo";
  38. }
  39.  
  40.  
  41. bool AppWindow::HandleChildEvent (const UI_Event& e)
  42. {
  43.     if (e.Type() != Event_Select)
  44.         return FALSE;
  45.     UI_ViewID btn_id = e.Origin()->ViewID();
  46.     if (btn_id == ID_BUTTON5) {
  47.         CL_String s = UI_FileSelectDialog (this);
  48.         UI_SimpleDialog (CL_String ("File name: ") + s);
  49.         return TRUE;
  50.     }
  51.     (*this)[ID_LABEL]->Title() = "";
  52.     char* msg;
  53.     UI_SimpleDialogStyle style;
  54.     UI_SimpleDialogIconStyle icon;
  55.     switch (btn_id) {
  56.     case ID_BUTTON1:
  57.         style = UIS_Ok;
  58.         icon  = UIS_Information;
  59.         msg   = "Hello from YACL.";
  60.         break;
  61.  
  62.     case ID_BUTTON2:
  63.         icon  = UIS_Warning;
  64.         style = UIS_YesNo;
  65.         msg   = "Format the hard drive?";
  66.         break;
  67.         
  68.     case ID_BUTTON3:
  69.         icon  = UIS_Error;
  70.         style = UIS_OkCancel;
  71.         msg   = "Remove the home directory?";
  72.         break;
  73.         
  74.     case ID_BUTTON4:
  75.         icon  = UIS_Question;
  76.         style = UIS_YesNoCancel;
  77.         msg   = "Rename the file?";
  78.         break;
  79.  
  80.     };
  81.  
  82.     UI_ViewID id = UI_SimpleDialog (msg, e.Origin()->Title(), this,
  83.                                     style, icon);
  84.     char* btnName = "";
  85.     switch (id) {
  86.     case UI_IDOK:
  87.         btnName = "'Ok'";
  88.         break;
  89.         
  90.     case UI_IDCANCEL:
  91.         btnName = "'Cancel'";
  92.         break;
  93.         
  94.     case UI_IDYES:
  95.         btnName = "'Yes'";
  96.         break;
  97.         
  98.     case UI_IDNO:
  99.         btnName = "'No'";
  100.         break;
  101.     };
  102.         
  103.     (*this)[ID_LABEL]->Title() = "Returned " + CL_String (btnName);
  104.     return TRUE;
  105. }
  106.  
  107.  
  108.  
  109.  
  110.