home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / TransSkel 3.18 / Demos / Pascal Demos / Button / Modal3.p < prev    next >
Encoding:
Text File  |  1994-04-30  |  3.5 KB  |  152 lines  |  [TEXT/PJMM]

  1. unit Modal3;
  2.  
  3. interface
  4.  
  5.     uses
  6.         TransSkel, ButtonGlobals;
  7.  
  8.  
  9.     procedure DoModal3;
  10.  
  11. implementation
  12.  
  13.     const
  14.  
  15.         iPushDismiss = 1;
  16.         iPushButton1 = 2;
  17.         iPushButton2 = 3;
  18.         iPushButton3 = 4;
  19.         iRadioStaticText = 5;
  20.         iRadioButton1 = 6;
  21.         iRadioButton2 = 7;
  22.         iRadioButton3 = 8;
  23.         iRadioNone = 9;
  24.         iCheckStaticText = 10;
  25.         iCheckButton1 = 11;
  26.         iCheckButton2 = 12;
  27.         iCheckButton3 = 13;
  28.         iOutline = 14;
  29.  
  30.  
  31.     var
  32.  
  33.         defaultButton: Integer;
  34.  
  35.  
  36. {--------------------------------------------------------------------}
  37. { Dialog 3 procedures }
  38. {--------------------------------------------------------------------}
  39.  
  40.     procedure OutlineButton (dlog: DialogPtr;
  41.                                     item: Integer);
  42.     begin
  43.         SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
  44.     end;
  45.  
  46.  
  47.     procedure InstallOutliner (dlog: DialogPtr;
  48.                                     item: Integer);
  49.         var
  50.             r: Rect;
  51.     begin
  52.         SkelGetDlogRect(dlog, item, r);
  53.         InsetRect(r, -4, -4);
  54.         SkelSetDlogRect(dlog, iOutline, r);
  55.         SkelSetDlogProc(dlog, iOutline, @OutlineButton);
  56.         SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
  57.     end;
  58.  
  59.  
  60.     procedure RemoveOutliner (dlog: DialogPtr);
  61.     begin
  62.         SkelSetDlogProc(dlog, iOutline, nil);
  63.         SkelEraseButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
  64.     end;
  65.  
  66.  
  67.     procedure SetDefaultButton (dlog: DialogPtr;
  68.                                     item: Integer);
  69.     begin
  70.         if (defaultButton <> 0) then
  71.             RemoveOutliner(dlog);
  72.         defaultButton := item;
  73.         if (defaultButton <> 0) then
  74.             InstallOutliner(dlog, defaultButton);
  75.     end;
  76.  
  77.  
  78.     procedure DoModal3;
  79.         var
  80.             filter: ModalFilterProcPtr;
  81.             dlog: DialogPtr;
  82.             savePort: GrafPtr;
  83.             item: Integer;
  84.             value: Integer;
  85.             hilite: Integer;
  86.             loop: Boolean;
  87.     begin
  88.         dlog := GetNewDialog(modal3Res, nil, WindowPtr(-1));
  89.         if (dlog = DialogPtr(nil)) then
  90.             begin
  91.                 SysBeep(1);
  92.                 exit(DoModal3);
  93.             end;
  94.  
  95.         SkelPositionWindow(dlog, skelPositionOnMainDevice, horizRatio, vertRatio);
  96.  
  97.         GetPort(savePort);
  98.         SetPort(dlog);
  99.  
  100.         SetDefaultButton(dlog, iPushButton1);
  101.         SkelSetDlogCtlValue(dlog, iCheckButton1, 1);
  102.         SkelSetDlogCtlValue(dlog, iCheckButton2, 1);
  103.         SkelSetDlogCtlValue(dlog, iCheckButton3, 1);
  104.         SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, iRadioButton1);
  105.  
  106.         ShowWindow(dlog);
  107.  
  108.         loop := true;
  109.         while (loop) do
  110.             begin
  111.                 filter := SkelDlogFilter(nil, false);
  112.                 SkelDlogDefaultItem(defaultButton); { turns off if zero }
  113.                 ModalDialog(filter, item);
  114.                 SkelRmveDlogFilter;
  115.                 case item of
  116.                     iPushDismiss: 
  117.                         loop := false;
  118.                     iPushButton1, iPushButton2, iPushButton3: 
  119.                         begin
  120.                             { ignore hits in these items }
  121.                         end;
  122.                     iRadioButton1, iRadioButton2, iRadioButton3: 
  123.                         begin
  124.                             SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, item);
  125.                             { remap item number from radio button range into pushbutton range }
  126.                             item := item + iPushButton1 - iRadioButton1;
  127.                             SetDefaultButton(dlog, item);
  128.                         end;
  129.                     iRadioNone: 
  130.                         begin
  131.                             SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, item);
  132.                             SetDefaultButton(dlog, 0);    { no default button }
  133.                         end;
  134.                     iCheckButton1, iCheckButton2, iCheckButton3: 
  135.                         begin
  136.                             value := SkelToggleDlogCtlValue(dlog, item);
  137.                             if (value <> 0) then
  138.                                 hilite := normalHilite
  139.                             else
  140.                                 hilite := dimHilite;
  141.                             { remap item number from checkbox range into pushbutton range }
  142.                             item := item + iPushButton1 - iCheckButton1;
  143.                             if (SkelSetDlogCtlHilite(dlog, item, hilite) and (item = defaultButton)) then
  144.                                 SkelDrawButtonOutline(SkelGetDlogCtl(dlog, item));
  145.                         end;
  146.                 end;
  147.             end;
  148.         DisposeDialog(dlog);
  149.         SetPort(savePort);
  150.     end;
  151.  
  152. end.