home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Miscellaneous / CrunchShell Demo / myMenus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-16  |  3.8 KB  |  144 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  myMenus.c
  3.                     Menu Handlers for sample application
  4.                                 
  5.         Copyright 1988 Gregory H. Dow.  All Rights Reserved.
  6.         
  7. *******************************************************************************/
  8.  
  9. #include "Common.h"
  10. #include "GlobalVars.h"
  11. #include "CWindow.h"
  12. #include "CMenu.h"
  13. #include "CView.h"
  14. #include "CScrollView.h"
  15. #include "CStatTextV.h"
  16. #include "CItemPalV.h"
  17. #include "CCharPalette.h"
  18. #include "CTearMenu.h"
  19.  
  20. void    DoDemoFilter();
  21. void    DoDemoModeless();
  22.  
  23. ObjectH        conView;
  24.  
  25. /******************************************************************************
  26.  DoTestMenu
  27.  
  28.          The Test Menu (used for testing new features)
  29.  ******************************************************************************/
  30.  
  31. void    DoTestMenu(theItem)
  32. short        theItem;                    /* Index number of item selected    */
  33. {
  34.     ObjectH        windObject;
  35.     ObjectH        group;
  36.     ObjectH        theView;
  37.     Rect        theRect;
  38.     Handle        theHand;
  39.  
  40.     switch (theItem) {
  41.     
  42.         case 1:
  43.             SetRect(&theRect, 0, 0, 500, 300);
  44.             theView = NewObject(sizeof(ViewObj), ViewDispatcher);
  45.             SendMsg(theView, msgINITobj, &theRect);
  46.             
  47.             windObject = NewObject(sizeof(WindowObj), WindowDispatcher);
  48.             SendMsg(windObject, msgINITobj, NULL, 20000, wpSTANDARD);
  49.             SendMsg(windObject, msgADDVIEWwind, theView);
  50.             ShowWindowFW(windObject);
  51.             break;
  52.             
  53.         case 2:
  54.             SetRect(&theRect, 0, 0, 400, 200);
  55.             theView = NewObject(sizeof(ScrollViewObj), ScrollViewDispatcher);
  56.             SendMsg(theView, msgINITobj, &theRect, TRUE, TRUE);
  57.             
  58.             windObject = NewObject(sizeof(WindowObj), WindowDispatcher);
  59.             SendMsg(windObject, msgINITobj, NULL, 20000, wpSTANDARD);
  60.             SendMsg(windObject, msgADDVIEWwind, theView);
  61.             ShowWindowFW(windObject);
  62.             break;
  63.             
  64.         case 3:
  65.             SetRect(&theRect, 0, 0, 500, 300);
  66.             theView = NewObject(sizeof(ViewObj), ViewDispatcher);
  67.             SendMsg(theView, msgINITobj, &theRect);
  68.             
  69.             windObject = NewObject(sizeof(WindowObj), WindowDispatcher);
  70.             SendMsg(windObject, msgINITobj, NULL, 20010, wpFLOATING+wpPERMANENT);
  71.             SendMsg(windObject, msgADDVIEWwind, theView);
  72.             ShowWindowFW(windObject);
  73.             break;
  74.             
  75.         case 4:
  76.             SendMsg(gDebugger, msgLEVELdbug, 1 - gDebugLevel);
  77.             break;
  78.             
  79.         case 5:
  80.             theView = NewObject(sizeof(ItemPalVObj), ItemPalVDispatcher);
  81.             SendMsg(theView, msgINITobj, 500, CharPaletteDispatcher);
  82.             
  83.             windObject = NewObject(sizeof(WindowObj), WindowDispatcher);
  84.             SendMsg(windObject, msgINITobj, NULL, 20010,
  85.                         wpFLOATING+wpPERMANENT+wpMOUSEACT);
  86.             SendMsg(windObject, msgADDVIEWwind, theView);
  87.             ShowWindowFW(windObject);
  88.             break;
  89.             
  90.         case 6:
  91.             break;
  92.             
  93.         case 7:
  94.             break;
  95.             
  96.         case 8:
  97.             break;
  98.             
  99.         case 9:
  100.             break;
  101.     }
  102. }
  103.  
  104.  
  105. /******************************************************************************
  106.  DoPaletteMenu
  107.  
  108.          The Palette Menu
  109.  ******************************************************************************/
  110.  
  111. void    DoPaletteMenu(theItem, menuID)
  112. short        theItem;
  113. short        menuID;
  114. {
  115.     MenuHandle            theMenu;
  116.     ItemPaletteObjH        thePalette;
  117.     
  118.     theMenu = GetMHandle(menuID);
  119.     thePalette = (ItemPaletteObjH)
  120.                     GetResource(IPALRESTYPE, HiWord((**theMenu).enableFlags));
  121.     SendMsg(thePalette, msgSELECTipal, theItem);
  122. }
  123.  
  124.  
  125. /******************************************************************************
  126.  SetUpMyMenus
  127.  
  128.          Install menus for my application in the menu bar
  129.  ******************************************************************************/
  130.  
  131. void    SetUpMyMenus()
  132. {    
  133.     MakeStdAppleMenu();                    /* The Apple Menu                    */
  134.     MakeStdFileMenu();                    /* The File Menu                    */
  135.     MakeStdEditMenu();                    /* The Edit Menu                    */
  136.  
  137.                                         /* The Test Menu                    */
  138.     SendMsg(NewObject(sizeof(MenuObj), MenuDispatcher),
  139.                 msgINITobj, 131, 0, DoTestMenu);
  140.                                         /* Palette Menu                        */
  141.     SendMsg(NewResObject('Tear', 500, TearMenuDispatcher),
  142.                 msgINITobj, 500, 500, 500, CharPaletteDispatcher);
  143. }
  144.