home *** CD-ROM | disk | FTP | other *** search
/ EDUCORP 8 / Educorp2Compilation.sit / educorp2 / Demos / Aztec Source Level Debugger / demo / event.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-14  |  1.9 KB  |  106 lines

  1. #include "barchart.h"
  2.  
  3. struct EventRecord myEvent;
  4. struct GrafPort *whichWindow;
  5.  
  6. handleevents()
  7. {
  8.     int code;
  9.  
  10.     for (;;) {
  11.         SystemTask();
  12.         if (!GetNextEvent(everyEvent, &myEvent))
  13.             continue;
  14.         switch(myEvent.what) {
  15.         case mouseDown:
  16.             code = FindWindow(&myEvent.where, &whichWindow);
  17.             switch (code) {
  18.             case inMenuBar:
  19.                 docommand(MenuSelect(&myEvent.where));
  20.                 break;
  21.             case inSysWindow:
  22.                 SystemClick(&myEvent, whichWindow);
  23.                 break;
  24.             case inDrag:
  25.                 DragWindow(whichWindow, &myEvent.where, &dragRect);
  26.                 break;
  27.             case inGrow:
  28.                 dogrow(whichWindow);
  29.                 break;
  30.             case inContent:
  31.                 if (whichWindow != FrontWindow())
  32.                     SelectWindow(whichWindow);
  33.                 else {
  34.                 }
  35.                 break;
  36.             case inGoAway:
  37.                 DisposeWindow(myWindow);
  38.                 return;
  39.             }
  40.             break;
  41.  
  42.         case keyDown:
  43.         case autoKey:
  44.             break;
  45.         case activateEvt:
  46.             SetPort(myWindow);
  47.             break;
  48.  
  49.         case updateEvt:
  50.             SetPort(myWindow);
  51.             BeginUpdate(myWindow);
  52.             EraseRect(&myWindow->portRect);
  53.             redraw();
  54.             EndUpdate(myWindow);
  55.             break;
  56.         }
  57.     }
  58. }
  59.  
  60. docommand(mResult)
  61. long mResult;
  62. {
  63.     int theItem, theMenu;
  64.     char name[40];
  65.  
  66.     theMenu = mResult >> 16;
  67.     theItem = mResult;
  68.     if (theMenu == appleMenu) {
  69.             GetItem(myMenus[0], theItem, name);
  70.             OpenDeskAcc(name);
  71.     }
  72.     HiliteMenu(0);
  73. }
  74.  
  75. #define ScreenWidth    512
  76. #define ScreenHeight 342
  77. #define MenuBarHeight 20
  78. #define MinWidth 80
  79. #define MinHeight 80
  80. #define SBarWidth 16
  81.  
  82. dogrow(whichWindow)
  83. WindowPtr whichWindow;
  84. {
  85.     Rect sizeRect;
  86.     long newSize;
  87.     int newWidth, newHeight;
  88.  
  89.     if (whichWindow != FrontWindow())
  90.         SelectWindow(whichWindow);
  91.     else {
  92.         SetRect(&sizeRect, MinWidth, MinHeight, ScreenWidth,
  93.                             ScreenHeight - MenuBarHeight);
  94.         newSize = GrowWindow(whichWindow,&myEvent.where,&sizeRect);
  95.  
  96.         if (newSize) {
  97.             EraseRect(&whichWindow->portRect);
  98.             newWidth = newSize & 0xffff;
  99.             newHeight = (newSize>>16) & 0xffff;
  100.             SizeWindow(whichWindow, newWidth, newHeight, TRUE);
  101.             InvalRect(&whichWindow->portRect);
  102.             redraw();
  103.         }
  104.     }
  105. }
  106.