home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / precog2_1.lha / Precognition2_1 / include / Interactor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-02  |  5.6 KB  |  208 lines

  1. /* ==========================================================================
  2. **
  3. **                               Interactor.h
  4. **
  5. ** PObject<GraphicObject<Interactor
  6. **
  7. ** An Interactor is a virtual class, derrived from class GraphicObject.
  8. ** Interactors are things with which the user interacts.
  9. ** (generally gadgets (or sets of gadgets)).
  10. **
  11. ** Along with the functions prototyped here, you can also use the
  12. ** the funtions defined for a GraphicObject. (See GraphicObject.h)
  13. **
  14. ** ©1991 WILLISoft
  15. **
  16. ** ==========================================================================
  17. */
  18.  
  19. #ifndef INTERACTOR_H
  20. #define INTERACTOR_H
  21.  
  22. #include "GraphicObject.h"
  23. #include "Intuition_typedefs.h"
  24.  
  25.  
  26.  
  27. typedef struct Interactor
  28.    {
  29.       const PClass             *isa;
  30.       char              *PObjectName;
  31.       void              *Next;   /* Points to next Interactor in chain. */
  32.       struct pcgWindow  *IaWindow; /* window where this interactor lives. */
  33.       Point              Location;
  34.       Point              Size;
  35.    } Interactor;
  36.  
  37.    /*
  38.    ** NOTE: Do *NOT* set these fields directly!  Instead, use the
  39.    ** supplied methods 'SetInteractorWindow()', 'SetLocation()',
  40.    ** 'SetSize()' etc.  There is more to setting the window/location/size
  41.    ** of a interactor than simply assigning to these fields.
  42.    */
  43.  
  44.  
  45.  
  46. /*
  47. ** NOTE: Interactor & pcgWindow have circular dependencies.
  48. ** Each contain pointers to the other.
  49. */
  50.  
  51.  
  52. void Interactor_Init __PARMS((
  53.                         Interactor *self
  54.                 ));
  55.  
  56.  
  57.  
  58. struct pcgWindow *InteractorWindow __PARMS((
  59.                                     Interactor *self
  60.                               ));
  61.    /*
  62.    ** Returns a pointer to the Precognition Window to which this
  63.    ** interactor belongs. (or NULL)
  64.    */
  65.  
  66.  
  67. void SetInteractorWindow __PARMS((
  68.                            Interactor *self,
  69.                            struct pcgWindow *window
  70.                     ));
  71.  
  72.  
  73. struct Gadget *FirstGadget __PARMS((
  74.                               Interactor *self
  75.                       ));
  76.  
  77.    /*
  78.    ** Returns the address of the first gadget in the interactor.
  79.    ** If there are no gadgets, returns NULL.
  80.    **
  81.    ** This is useful for building composite Interactors out of
  82.    ** other Interactors.
  83.    */
  84.  
  85. USHORT nGadgets __PARMS((
  86.                      Interactor *self
  87.            ));
  88.    /*
  89.    ** Returns the # of gadgets in an interactor.
  90.    */
  91.  
  92.  
  93. ULONG IDCMPFlags __PARMS((
  94.                      Interactor *self
  95.               ));
  96.    /*
  97.    ** Returns the IDCMP flags that 'self' needs to function.
  98.    */
  99.  
  100.  
  101. USHORT ClaimEvent __PARMS((
  102.                      Interactor    *self,
  103.                      IntuiMessage *event
  104.             ));
  105.    /*
  106.    ** Returns TRUE if 'self' would respond to 'event'.
  107.    ** (This is useful to determine if an Interactor will respond before
  108.    ** it actually does.)
  109.    */
  110.  
  111.  
  112. USHORT Respond __PARMS((
  113.                      Interactor    *self,
  114.                      IntuiMessage  *event
  115.          ));
  116.    /*
  117.    ** Respond() is THE routine for Interactors.  Calling Respond()
  118.    ** for an IntuiMessage tells the Interactor to do whatever it should
  119.    ** do for that message.
  120.    **
  121.    ** Returns a response code with the following bits:
  122.    **
  123.    **    RESPONDED      : Interactor paid attention to this event.
  124.    **                     If not set, Interactor ignored event.
  125.    **
  126.    **    CONSUMED_EVENT : Interactor guarantees that this event
  127.    **                     is _only_ for this Interactor.  This signals
  128.    **                     the event loop that it need not bother sending
  129.    **                     this event to any other interactor.
  130.    **
  131.    **    CHANGED_STATE  : The event caused the Interactor to change state.
  132.    **                     (e.g. Slider moved, text entered, button
  133.    **                     pressed.)
  134.    **                     Certain events (e.g. REFRESHWINDOW) cause
  135.    **                     the Interactor to respond without changing
  136.    **                     state.
  137.    **
  138.    **    DEACTIVATED    : The event caused the interactor to go from an active
  139.    **                     to an inactive state (string gadgets)
  140.    */
  141.  
  142. #define RESPONDED      1
  143. #define CONSUMED_EVENT 2
  144. #define CHANGED_STATE  4
  145. #define DEACTIVATED    8
  146.  
  147. void Refresh __PARMS((
  148.                      Interactor *self
  149.               ));
  150.    /* Draws a interactor to a window.
  151.    **
  152.    ** I know what you're thinking: "Class 'GraphicObject' already has a
  153.    ** Render() methOD which does this, why do we need another?".  Because
  154.    ** Render() draws to a RastPort, and the Intuition function to refresh
  155.    ** Gadgets requires a pointer to a Window.  Therefore, we need a new
  156.    ** method.  (although the default action of 'Refresh()' is simply to
  157.    ** call 'Render() with the window's RastPort).
  158.    */
  159.  
  160.  
  161. BOOL EnableIactor __PARMS((
  162.                      Interactor *self,
  163.                      BOOL        enable
  164.              ));
  165.    /*
  166.    ** This turns an Interactor On/Off.  i.e. 'EnableIactor( interactor, FALSE )'
  167.    ** will ghost an interactor.  'EnableIactor( interactor, TRUE )' un-ghosts.
  168.    */
  169.  
  170.  
  171. BOOL isEnabled __PARMS((
  172.                      Interactor *self
  173.           ));
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  /* These next two refer to Text-based Interactors only
  180.  ** (i.e. String gadgets) All other interactors return FALSE.
  181.  */
  182.  
  183. BOOL Activate __PARMS((
  184.                      Interactor *self,
  185.                      BOOL        activate
  186.         ));
  187.  
  188.    /* If 'activate' = TRUE, Interactor gains control of keyboard.
  189.    ** Returns FALSE if Interactor does not use the keyboard.
  190.    */
  191.  
  192. BOOL isActive __PARMS((
  193.                      Interactor *self
  194.          ));
  195.  
  196.  
  197.  
  198. BOOL ActivateNext __PARMS((
  199.                      Interactor *self
  200.               ));
  201.    /*
  202.    ** Attempts to activate the next interactor in a chain.
  203.    */
  204.  
  205.  
  206. #endif
  207.  
  208.