home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / BSDMenubarLib 1.0 / BSDMenubarLib Example / main.cp < prev   
Encoding:
Text File  |  1997-08-03  |  1.1 KB  |  70 lines  |  [TEXT/CWIE]

  1. #include "BSDMenubarLib.h"
  2.  
  3. Boolean mbar = true;
  4.  
  5. void FrameDialogItem (DialogPtr theDialog, short theItem);
  6. void ToggleMenuBar (void);
  7.  
  8. void FrameDialogItem (DialogPtr theDialog, short theItem) {
  9. GrafPtr        savePort;
  10. short        iType;
  11. Handle        iHandle;
  12. Rect        iRect;
  13. PenState    savePen;
  14.  
  15.     GetPort(&savePort);
  16.     SetPort(theDialog);
  17.     GetPenState(&savePen);
  18.     
  19.     GetDialogItem(theDialog, theItem, &iType, &iHandle, &iRect);
  20.     InsetRect(&iRect, -4, -4);
  21.     PenSize(3, 3);
  22.     FrameRoundRect(&iRect, 16, 16);
  23.     
  24.     SetPenState(&savePen);
  25.     SetPort(savePort);
  26. }
  27.  
  28. void ToggleMenuBar (void) {
  29.     if (mbar) HideMenuBar();
  30.     else ShowMenuBar();
  31.     mbar = !mbar;
  32. }
  33.  
  34. void main (void) {
  35.     InitGraf(&qd.thePort);
  36.     InitFonts();
  37.     InitWindows();
  38.     InitMenus();
  39.     InitDialogs(nil);
  40.     InitCursor();
  41.     TEInit();
  42.     MaxApplZone();
  43.     
  44.     DialogPtr dialog = GetNewDialog(128, nil, (WindowPtr)-1L);
  45.     ShowWindow(dialog);
  46.     
  47.     FrameDialogItem(dialog, 1);
  48.     
  49.     Boolean flag = false;
  50.     short item;
  51.     
  52.     while (!flag) {
  53.         ModalDialog(nil, &item);
  54.         
  55.         switch (item) {
  56.             case 1:
  57.                 flag = true;
  58.             break;
  59.             case 2:
  60.                 ToggleMenuBar();
  61.             break;
  62.         }
  63.     }
  64.     
  65.     CloseWindow(dialog);
  66.     
  67.     if (!mbar) ShowMenuBar();
  68. }
  69.  
  70.