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

  1. /* ----------------------------------------------------------------------
  2. File: windows.c
  3.  
  4. Purpose:    This module implements a dispatch table mechanism which is
  5.             used to handle window events.
  6.             
  7. Tetris Light - a simple implementation of a Tetris game
  8. Copyright © 1993-1996 Hoylen Sue
  9.  
  10. Updated for CW9 by Paul Celestin
  11. Questions about this version should go to me at celestin@celestin.com
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; see the file COPYING.  If not, write to the
  25. Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26. ---------------------------------------------------------------------- */
  27.  
  28. #include "local.h"
  29. #include "windows.h"
  30.  
  31. /*--------------------------------------------------------------------*/
  32.  
  33. void window_mouseDown(WindowPtr wind, Point where)
  34. /* Sends a mouseDown event to the given window. */
  35. {
  36.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  37.     
  38.     if (table->mouseDown_handler != 0)
  39.         table->mouseDown_handler(where);
  40. }
  41.  
  42. /*--------------------------------------------------------------------*/
  43.  
  44. void window_key(WindowPtr wind, unsigned char code, unsigned char ascii)
  45. /* Sends a key press event to the given window. */
  46. {
  47.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  48.     
  49.     if (table->key_handler != 0)
  50.         table->key_handler(code, ascii);
  51. }
  52.  
  53. /*--------------------------------------------------------------------*/
  54.  
  55. void window_update(WindowPtr wind)
  56. /* Sends an update event to the given window. */
  57. {
  58.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  59.  
  60.     BeginUpdate(wind);
  61.     if (table->update_handler != 0)
  62.         table->update_handler();
  63.     EndUpdate(wind);
  64. }
  65.  
  66. /*--------------------------------------------------------------------*/
  67.  
  68. void window_activate(WindowPtr wind)
  69. /* Sends an activate event to the given window. */
  70. {
  71.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  72.     
  73.     if (table->activate_handler != 0)
  74.         table->activate_handler();
  75. }
  76.  
  77. /*--------------------------------------------------------------------*/
  78.  
  79. void window_deactivate(WindowPtr wind)
  80. /* Sends a deactivate event to the given window. */
  81. {
  82.     register Wind_table *table = (Wind_table *) GetWRefCon(wind);
  83.     
  84.     if (table->deactivate_handler != 0)
  85.         table->deactivate_handler();
  86. }
  87.  
  88. /*--------------------------------------------------------------------*/
  89.