home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / Life Simulator / HandleMouseDown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-04  |  2.0 KB  |  110 lines  |  [TEXT/MMCC]

  1. /* Cell Proj 1.0 */
  2.  
  3. #include "Cell_Proto.h"
  4. #include "Cell_Definitions.h"
  5. #include "Cell_Variables.h"
  6.  
  7. HandleMouseDown()
  8. {
  9.     WindowPtr        whichWindow;
  10.     short            thePart;
  11.     int                theControlPart;
  12.     long int        menuChoice, windSize;
  13.     ControlHandle    controlHitHandle;
  14.     int                hitControl, oldValue, currentValue;
  15.     
  16.     thePart = FindWindow( gTheEvent.where, &whichWindow );
  17.     switch ( thePart )
  18.     {
  19.         case inMenuBar:
  20.             menuChoice = MenuSelect( gTheEvent.where );
  21.             HandleMenuChoice( menuChoice );
  22.             break;
  23.         case inSysWindow:
  24.             SystemClick( &gTheEvent, whichWindow );
  25.             break;
  26.         case inDrag:
  27.             DragWindow( whichWindow, gTheEvent.where, &gDragRect );
  28.             SetPort( whichWindow );
  29.             break;
  30.         case inGoAway:
  31.             HideWindow( whichWindow );
  32.             break;
  33.         case inContent:
  34.             SelectWindow( whichWindow );
  35.             break;
  36.         case inGrow:
  37.             break;
  38.     }
  39. }
  40.  
  41. HandleMenuChoice( menuChoice )
  42. long int    menuChoice;
  43. {
  44.     int        theMenu;
  45.     int        theItem;
  46.     
  47.     if ( menuChoice != 0 )
  48.     {
  49.         theMenu = HiWord( menuChoice );
  50.         theItem = LoWord( menuChoice );
  51.         switch ( theMenu )
  52.         {
  53.             case APPLE_MENU_ID:
  54.                 HandleAppleChoice( theItem );
  55.                 break;
  56.             case FILE_MENU_ID:
  57.                 HandleFileChoice( theItem );
  58.                 break;
  59.         }
  60.         HiliteMenu( 0 );
  61.     }
  62. }
  63.  
  64. HandleAppleChoice( theItem )
  65. int        theItem;
  66. {
  67.     Str255        accName;
  68.     int            accNumber;
  69.     short int    itemNumber;
  70.  
  71.     switch ( theItem )
  72.     {
  73.         case ABOUT_ITEM:
  74.             NoteAlert( ABOUT_ALERT, NIL_POINTER );
  75.             break;
  76.         default:
  77.             GetItem( gAppleMenu, theItem, accName );
  78.             accNumber = OpenDeskAcc( accName );
  79.             break;
  80.     }
  81. }
  82.  
  83. HandleFileChoice( theItem )
  84. int        theItem;
  85. {
  86.     switch( theItem )
  87.     {
  88.         case SHOW_ALL_WINDOW_ITEM:
  89.             ShowWindow( gCellWindow );
  90.             ShowWindow( gCellInfoDialog );
  91.             DrawDialog( gCellInfoDialog );
  92.             SelectWindow( gCellInfoDialog );
  93.             break;
  94.         case QUIT_ITEM:
  95.             gDone = TRUE;
  96.             break;
  97.     }
  98. }
  99.  
  100. ResizeWindow( whichWindow, windSize )
  101. long            windSize;
  102. WindowPtr        whichWindow;
  103. {
  104.     GrafPtr            oldPort;
  105.  
  106.     GetPort( &oldPort );
  107.     SetPort( whichWindow );
  108.     SizeWindow( whichWindow, 170, HiWord( windSize ), NORMAL_UPDATES );
  109.     SetPort( oldPort );
  110. }