home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / psort / example / event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.3 KB  |  87 lines

  1. /* *****************************************************************************
  2. *
  3. * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. *
  6. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  7. * the contents of this file may not be disclosed to third parties, copied or
  8. * duplicated in any form, in whole or in part, without the prior written
  9. * permission of Silicon Graphics, Inc.
  10. *
  11. * RESTRICTED RIGHTS LEGEND:
  12. * Use, duplication or disclosure by the Government is subject to restrictions
  13. * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  14. * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  15. * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  16. * rights reserved under the Copyright Laws of the United States.
  17. *
  18. ***************************************************************************** */
  19. /*
  20.  *    event.h
  21.  * External interface and defines to input-queue event handling
  22.  * routines.
  23.  * Written by Wade Olsen for Silicon Graphics, Inc.
  24.  */
  25.  
  26. /*
  27.  *    The event handler understands two kinds of things; events and
  28.  * updates.  Events are reactions to things occuring in the input
  29.  * queue.  Updates are functions that should be called whenever there
  30.  * is nothing waiting in the input queue, and may be active or
  31.  * inactive.  If there are no active updates and nothing in the input
  32.  * queue, then event() will block, using up no CPU time.
  33.  *
  34.  * add_event is used to look for events.  The first three arguments
  35.  * are used to identify which event to look for.  The first argument
  36.  * is the window (gid) the event must happen in; if this value is ANY
  37.  * then any window will do.  The second argument is the device to look
  38.  * for (e.g.  RIGHTMOUSE or REDRAW or KEYBD, etc).  Again, if it is
  39.  * ANY then any device will match.  The third argument is the value
  40.  * the device must generate (e.g.  DOWN or UP); ANY means all values
  41.  * match.  The last two arguments are what should be done when an
  42.  * event is generated.  The fourth argument is a function to be
  43.  * called, and the fifth is an argument that should be supplied to the
  44.  * function.  In addition, the value generated by the device will also
  45.  * be passed to the function when it is called.
  46.  *
  47.  * For example,
  48.  *    add_event(winget(), RIGHTMOUSE, DOWN, dopup, my_menus);
  49.  *    qdevice(RIGHTMOUSE);
  50.  * will make a pop-up menu appear when the right mousebutton goes
  51.  * down.  Note that you must do the qdevice() call yourself.
  52.  */
  53. void add_event(int, int, int, void (*fn)(void *, int), char *) ;
  54.  
  55. /*
  56.  * An update is like an event, only simpler.  The first argument is a
  57.  * pointer to an integer flag specifying whether or not this update
  58.  * function is active.  The second is a function to be called when it
  59.  * is active, and the last is an argument to be supplied to the
  60.  * function.
  61.  */
  62. void add_update(int *, void (*fn)(void *), char *) ;
  63.  
  64. /*
  65.  * Finally, when all updates and events have been added, repeatedly
  66.  * call event() to handle them -- something like
  67.  * 
  68.  *    while (quitflag == FALSE) event();
  69.  * 
  70.  * You should have previously added an event that sets quitflag to
  71.  * TRUE, of course.
  72.  */
  73. void event(void) ;
  74.  
  75. /*
  76.  *    These are some useful defines for the possible values buttons
  77.  * can generate.
  78.  */
  79. #define ANY    -1
  80. #define UP    0
  81. #define DOWN    1
  82.  
  83. /*
  84.  *    And a few external variables you might find useful
  85.  */
  86. extern int context, state, device;
  87.