home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / lang / skel_azt.sha / select.c < prev    next >
C/C++ Source or Header  |  1986-07-08  |  2KB  |  67 lines

  1.  
  2. /*
  3.  *    select.c -- handle an activate or deactivate event for any window
  4.  */
  5.  
  6. #include <quickdraw.h>
  7. #include <control.h>
  8. #include <event.h>
  9. #include <menu.h>
  10. #include <textedit.h>
  11. #include <window.h>
  12.  
  13. #include "qdv.h"
  14. #include "def.h"
  15.  
  16. void
  17. select(ev)
  18. EventRecord    *ev;    /* return value from GetNextEvent */
  19. {
  20.     extern    QDVar             *QD;
  21.     extern    ControlHandle    hscroll[NWINDOWS];
  22.     extern    TEHandle        hTE;
  23.     int                        i;
  24.     extern    MenuHandle        mh[NMENUS + 1];
  25.     extern    GrafPtr            screenport;        /* the whole screen */
  26.     extern    int                swi;            /* scroll window index */
  27.     extern    ControlHandle    vscroll[NWINDOWS];
  28.     extern    WindowPtr        wp[NWINDOWS];
  29.     
  30.     for (i = 0;  i < NWINDOWS;  i++) {
  31.         if ((WindowPtr)ev->message == wp[i]) {
  32.             if (ev->modifiers & 1) {
  33.                 /* odd means an activate event */
  34.                 SetPort(wp[i]);
  35.                 /* must allow for changing to scroll bars, HiLited
  36.                  * or not, and (IMPORTANT) must be after SetPort to
  37.                  * have the correct QuickDraw Origin.
  38.                  * And -- include the grow icon, too!
  39.                  */
  40.                 (*vscroll[i])->contrlRect.bottom += 16;
  41.                 InvalRect(&(*vscroll[i])->contrlRect);
  42.                 (*vscroll[i])->contrlRect.bottom -= 16;
  43.                 InvalRect(&(*hscroll[i])->contrlRect);
  44.                 swi = i;
  45.                 if (i == 1 && hTE) {
  46.                     EnableItem(mh[3], 0);
  47.                     TEActivate(hTE);
  48.                 };
  49.             }
  50.             else {
  51.                 /* must allow for whitening out the scroll bars and
  52.                  * (IMPORTANT) must be before SetPort to have the
  53.                  * correct QuickDraw Origin.
  54.                  */
  55.                 (*vscroll[i])->contrlRect.bottom += 16;
  56.                 InvalRect(&(*vscroll[i])->contrlRect);
  57.                 (*vscroll[i])->contrlRect.bottom -= 16;
  58.                 InvalRect(&(*hscroll[i])->contrlRect);
  59.                 SetPort(screenport);
  60.                 if (i == 1 && hTE)
  61.                     TEDeactivate(hTE);
  62.             };
  63.             break;
  64.         };
  65.     };
  66. } /* end of select */
  67.