home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Tetris Light 1.0.3 / source / about.c next >
Encoding:
C/C++ Source or Header  |  1996-07-07  |  3.1 KB  |  103 lines  |  [TEXT/CWIE]

  1. /* ----------------------------------------------------------------------
  2. File: about.c
  3.  
  4. Purpose:    This module handles the displaying of the about box.
  5.             
  6. Tetris Light - a simple implementation of a Tetris game
  7. Copyright © 1993-1996 Hoylen Sue
  8.  
  9. Updated for CW9 by Paul Celestin
  10. Questions about this version should go to me at celestin@celestin.com
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; see the file COPYING.  If not, write to the
  24. Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25. ---------------------------------------------------------------------- */
  26.  
  27. #include "local.h"
  28. #include "about.h"
  29. #include "dialutil.h"
  30. #include "resources.h"
  31. #include "windows.h"
  32.  
  33. /*--------------------------------------------------------------------*/
  34.  
  35. static pascal Boolean about_filter_proc(DialogPtr dp, EventRecord *evt,
  36.                                         INTEGER *itemhit)
  37. /* Filter proc for the dialog.  Traps mouseDown events anywhere to
  38.    remove the dialog.  Pressing the return or enter key also removes
  39.    the dialog.  Processes activateEvt and updateEvt normally, so that
  40.    windows behind it get updated correctly. */
  41. {
  42.     INTEGER type;
  43.     Handle handle;
  44.     Rect box;
  45.     Point local;
  46.     
  47.     switch (evt->what) {
  48.     case mouseDown:
  49.         local = evt->where;
  50.         SetPort(dp);
  51.         GlobalToLocal(&local);
  52.         GetDItem(dp, OK, &type, &handle, &box);
  53.         if (!PtInRect(local, &box)) {
  54.             /* Was not pressed inside (near enough) the button */
  55.             *itemhit = OK;
  56.             return TRUE;
  57.         }
  58.         break;
  59.     case keyDown:
  60.         if ((evt->message & charCodeMask) == ENTER_CODE ||
  61.             (evt->message & charCodeMask) == RETURN_CODE) {            
  62.             simulate_key_hit(dp, OK);
  63.             *itemhit = OK;
  64.             return TRUE;
  65.         }
  66.         break;
  67.     case activateEvt:
  68.         if (dp != (WindowPtr) evt->message) {
  69.             if (evt->modifiers & activeFlag)
  70.                 window_activate((WindowPtr) evt->message);
  71.             else
  72.                 window_deactivate((WindowPtr) evt->message);
  73.         }
  74.         break;
  75.     case updateEvt:
  76.         if (dp != (WindowPtr) evt->message)
  77.             window_update((WindowPtr) evt->message);
  78.         break;
  79.     }
  80.  
  81.     return FALSE;
  82. }
  83.  
  84. /*--------------------------------------------------------------------*/
  85.  
  86. void about_box(void)
  87. /* Brings up the about box, and processes it until the user makes it
  88.    go away.  The dialog box is removed if the mouse is pressed or the
  89.    return or enter key is pressed. */
  90. {
  91.     ModalFilterUPP filter = NewModalFilterProc(about_filter_proc);
  92.     DialogPtr    dial;
  93.     INTEGER        item;
  94.     
  95.     dial = GetNewDialog(ABOUT_DIAL_ID, NIL, (WindowPtr) -1);
  96.     install_hilight_button(dial, OK, ABOUT_HIGHLIGHT_ITEM);
  97.     ModalDialog(filter, &item);
  98.     DisposDialog(dial);
  99. }
  100.  
  101. /*--------------------------------------------------------------------*/
  102.  
  103.