home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / precognition / include / interactor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-24  |  6.0 KB  |  236 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.       Class             *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( 
  53.    #ifdef ANSI_HEADERS 
  54.                         Interactor *self 
  55.    #endif   
  56.                     );
  57.  
  58.  
  59.  
  60. struct pcgWindow *InteractorWindow( 
  61.    #ifdef ANSI_HEADERS
  62.                                     Interactor *self 
  63.    #endif
  64.                                   );
  65.    /*
  66.    ** Returns a pointer to the Precognition Window to which this
  67.    ** interactor belongs. (or NULL)
  68.    */
  69.  
  70.  
  71. void SetInteractorWindow( 
  72.    #ifdef ANSI_HEADERS
  73.                            Interactor *self, 
  74.                            struct pcgWindow *window 
  75.    #endif
  76.                         );
  77.  
  78.  
  79. struct Gadget *FirstGadget( 
  80.    #ifdef ANSI_HEADERS
  81.                               Interactor *self 
  82.    #endif
  83.                           );
  84.  
  85.    /*
  86.    ** Returns the address of the first gadget in the interactor.
  87.    ** If there are no gadgets, returns NULL.
  88.    **
  89.    ** This is useful for building composite Interactors out of
  90.    ** other Interactors.
  91.    */
  92.  
  93. USHORT nGadgets( 
  94. #ifdef ANSI_HEADERS
  95.                      Interactor *self 
  96. #endif
  97.                );
  98.    /*
  99.    ** Returns the # of gadgets in an interactor.
  100.    */
  101.  
  102.  
  103. ULONG IDCMPFlags( 
  104.    #ifdef ANSI_HEADERS
  105.                      Interactor *self 
  106.    #endif
  107.                   );
  108.    /*
  109.    ** Returns the IDCMP flags that 'self' needs to function.
  110.    */
  111.  
  112.  
  113. USHORT ClaimEvent( 
  114.    #ifdef ANSI_HEADERS
  115.                      Interactor    *self,
  116.                      IntuiMessage *event 
  117.    #endif
  118.                 );
  119.    /*
  120.    ** Returns TRUE iff 'self' would respond to 'event'.
  121.    ** (This is useful to determine if a Interactor will respond before
  122.    ** it actually does.)
  123.    */
  124.  
  125.  
  126. USHORT Respond( 
  127.    #ifdef ANSI_HEADERS
  128.                      Interactor    *self,
  129.                      IntuiMessage  *event 
  130.    #endif
  131.              );
  132.    /*
  133.    ** Respond() is THE routine for Interactors.  Calling Respond()
  134.    ** for an IntuiMessage tells the Interactor to do whatever it should
  135.    ** do for that message.
  136.    **
  137.    ** Returns a response code with the following bits:
  138.    **
  139.    **    RESPONDED      : Interactor paid attention to this event.
  140.    **                     If not set, Interactor ignored event.
  141.    **
  142.    **    CONSUMED_EVENT : Interactor guarantees that this event
  143.    **                     is _only_ for this Interactor.  This signals
  144.    **                     the event loop that it need not bother sending
  145.    **                     this event to any other interactor.
  146.    **
  147.    **    CHANGED_STATE  : The event caused the Interactor to change state.
  148.    **                     (e.g. Slider moved, text entered, button
  149.    **                     pressed.)
  150.    **                     Certain events (e.g. REFRESHWINDOW) cause
  151.    **                     the Interactor to respond without changing
  152.    **                     state.
  153.    **
  154.    **    DEACTIVATED    : The event caused the interactor to go from an active
  155.    **                     to an inactive state (string gadgets)
  156.    */
  157.  
  158. #define RESPONDED      1
  159. #define CONSUMED_EVENT 2
  160. #define CHANGED_STATE  4
  161. #define DEACTIVATED    8
  162.  
  163. void Refresh( 
  164.    #ifdef ANSI_HEADERS
  165.                      Interactor *self 
  166.    #endif
  167.                   );
  168.    /* Draws a interactor to a window.
  169.    **
  170.    ** I know what you're thinking: "Class 'GraphicObject' already has a
  171.    ** Render() methOD which does this, why do we need another?".  Because
  172.    ** Render() draws to a RastPort, and the Intuition function to refresh
  173.    ** Gadgets requires a pointer to a Window.  Therefore, we need a new
  174.    ** method.  (although the default action of 'Refresh()' is simply to
  175.    ** call 'Render() with the window's RastPort).
  176.    */
  177.  
  178.  
  179. BOOL EnableIactor( 
  180.    #ifdef ANSI_HEADERS
  181.                      Interactor *self,
  182.                      BOOL        enable 
  183.    #endif
  184.                  );
  185.    /*
  186.    ** This turns an Interactor On/Off.  i.e. 'EnableIactor( interactor, FALSE )'
  187.    ** will ghost an interactor.  'EnableIactor( interactor, TRUE )' un-ghosts.
  188.    */
  189.  
  190.  
  191. BOOL isEnabled( 
  192.    #ifdef ANSI_HEADERS
  193.                      Interactor *self  
  194.    #endif
  195.               );
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  /* These next two refer to Text-based Interactors only
  202.  ** (i.e. String gadgets) All other interactors return FALSE.
  203.  */
  204.  
  205. BOOL Activate( 
  206.    #ifdef ANSI_HEADERS
  207.                      Interactor *self,
  208.                      BOOL        activate 
  209.    #endif
  210.              );
  211.  
  212.    /* If 'activate' = TRUE, Interactor gains control of keyboard.
  213.    ** Returns FALSE if Interactor does not use the keyboard.
  214.    */
  215.  
  216. BOOL isActive( 
  217.    #ifdef ANSI_HEADERS
  218.                      Interactor *self 
  219.    #endif
  220.              );
  221.  
  222.  
  223.  
  224. BOOL ActivateNext( 
  225.    #ifdef ANSI_HEADERS
  226.                      Interactor *self 
  227.    #endif
  228.                   );
  229.    /*
  230.    ** Attempts to activate the next interactor in a chain.
  231.    */
  232.  
  233.  
  234. #endif
  235.  
  236.