home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 594b.lha / Precognition_rel1 / Interactor.h < prev    next >
C/C++ Source or Header  |  1991-12-12  |  5KB  |  178 lines

  1. /* ==========================================================================
  2. **
  3. **                               Interactor.h
  4. **
  5. ** Object<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.       Class             *isa;
  30.       char              *ObjectName;
  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( Interactor *self );
  53.  
  54.  
  55.  
  56. struct pcgWindow *InteractorWindow( Interactor *self );
  57.    /*
  58.    ** Returns a pointer to the Precognition Window to which this
  59.    ** interactor belongs. (or NULL)
  60.    */
  61.  
  62.  
  63. void SetInteractorWindow( Interactor *self, struct pcgWindow *window );
  64.  
  65.  
  66. Gadget *FirstGadget( Interactor *self );
  67.    /*
  68.    ** Returns the address of the first gadget in the interactor.
  69.    ** If there are no gadgets, returns NULL.
  70.    **
  71.    ** This is useful for building composite Interactors out of
  72.    ** other Interactors.
  73.    */
  74.  
  75. USHORT nGadgets( Interactor *self );
  76.    /*
  77.    ** Returns the # of gadgets in a interactor.
  78.    */
  79.  
  80.  
  81. ULONG IDCMPFlags( Interactor *self );
  82.    /*
  83.    ** Returns the IDCMP flags that 'self' needs to function.
  84.    */
  85.  
  86.  
  87. USHORT ClaimEvent( Interactor    *self,
  88.                    IntuiMessage *event );
  89.    /*
  90.    ** Returns TRUE iff 'self' would respod to 'event'.
  91.    ** (This is useful to determine if a Interactor will respond before
  92.    ** it actually does.)
  93.    */
  94.  
  95.  
  96. USHORT Respond( Interactor    *self,
  97.                 IntuiMessage  *event );
  98.    /*
  99.    ** Respond() is THE routine for Interactors.  Calling Respond()
  100.    ** for an IntuiMessage tells the Interactor to do whatever it should
  101.    ** do for that message.
  102.    **
  103.    ** Returns a response code with the following bits:
  104.    **
  105.    **    RESPONDED      : Interactor paid attention to this event.
  106.    **                     If not set, Interactor ignored event.
  107.    **
  108.    **    CONSUMED_EVENT : Interactor guarantees that this event
  109.    **                     is _only_ for this Interactor.  This signals
  110.    **                     the event loop that it need not bother sending
  111.    **                     this event to any other interactor.
  112.    **
  113.    **    CHANGED_STATE  : The event caused the Interactor to change state.
  114.    **                     (e.g. Slider moved, text entered, button
  115.    **                     pressed.)
  116.    **                     Certain events (e.g. REFRESHWINDOW) cause
  117.    **                     the Interactor to respond without changing
  118.    **                     state.
  119.    **
  120.    **    DEACTIVATED    : The event caused the interactor to go from an active
  121.    **                     to an inactive state (string gadgets)
  122.    */
  123.  
  124. #define RESPONDED      1
  125. #define CONSUMED_EVENT 2
  126. #define CHANGED_STATE  4
  127. #define DEACTIVATED    8
  128.  
  129. void Refresh( Interactor *self );
  130.    /* Draws a interactor to a window.
  131.    **
  132.    ** I know what you're thinking: "Class 'GraphicObject' already has a
  133.    ** Render() method which does this, why do we need another?".  Because
  134.    ** Render() draws to a RastPort, and the Intuition function to refresh
  135.    ** Gadgets requires a pointer to a Window.  Therefore, we need a new
  136.    ** method.  (Though the default action of 'Refresh()' is simply to
  137.    ** call 'Render() ).
  138.    */
  139.  
  140.  
  141. BOOL Enable( Interactor *self,
  142.              BOOL        enable );
  143.    /*
  144.    ** This turns an Interactor On/Off.  i.e. 'Enable( interactor, FALSE )'
  145.    ** will ghost an interactor.  'Enable( interactor, TRUE )' un-ghosts.
  146.    */
  147.  
  148.  
  149. BOOL isEnabled( Interactor *self  );
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  /* These next two refer to Text-based Interactors only
  156.  ** (i.e. String gadgets) All other interactors return FALSE.
  157.  */
  158.  
  159. BOOL Activate( Interactor *self,
  160.                BOOL       activate );
  161.  
  162.    /* If 'activate' = TRUE, Interactor gains control of keyboard.
  163.    ** Returns FALSE if Interactor does not use the keyboard.
  164.    */
  165.  
  166. BOOL isActive( Interactor *self );
  167.  
  168.  
  169.  
  170. BOOL ActivateNext( Interactor *self );
  171.    /*
  172.    ** Attempts to activate the next interactor in a chain.
  173.    */
  174.  
  175.  
  176. #endif
  177.  
  178.