home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / precog2_1.lha / Precognition2_1 / src / src.lha / Precognition / toolbutton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-18  |  2.3 KB  |  91 lines

  1. #include "parms.h"
  2. #include "BuilderMethods.h"
  3. #include "ToolButton.h"
  4. #include "ValuatorClass.h"
  5. #include "BoolGadget.h" /* added for boolgadget prototypes -- EDB */
  6. #ifndef __GNUC__
  7. #include <clib/exec_protos.h>
  8. #include <clib/intuition_protos.h>
  9. #include <clib/graphics_protos.h>
  10. #endif
  11. #ifdef __GNUC__
  12. #include <proto/exec.h>
  13. #include <proto/intuition.h>
  14. #include <proto/graphics.h>
  15. #endif
  16. #ifdef __SASC
  17. #include <proto/exec.h>
  18. #include <proto/intuition.h>
  19. #include <proto/graphics.h>
  20. #endif
  21.  
  22. #include "amigamem.h"
  23.  
  24. USHORT ToolButton_Respond( ToolButton   *self,
  25.                            IntuiMessage *Event )
  26. {
  27.    USHORT response = 0;
  28.  
  29.    switch( Event->Class )
  30.    {
  31.       case REFRESHWINDOW:
  32.          Refresh( (struct Interactor *)self );
  33.          response = RESPONDED;
  34.          break;
  35.  
  36.       case GADGETDOWN:
  37.          if( Event->IAddress == (void *)&self->g )
  38.          {
  39.             response = RESPONDED | CONSUMED_EVENT | CHANGED_STATE;
  40.          }
  41.          break;
  42.  
  43.       case GADGETUP:
  44.          if( Event->IAddress == (void *)&self->g )
  45.          {
  46.             response = RESPONDED | CONSUMED_EVENT | CHANGED_STATE;
  47.          }
  48.          break;
  49.  
  50.    }
  51.    return response;
  52. }
  53.  
  54. BOOL ToolButton_elaborated = FALSE;
  55.  
  56. struct ValuatorClass ToolButton_Class;
  57.  
  58. struct ValuatorClass *ToolButtonClass( void )
  59. {
  60.    if( ! ToolButton_elaborated )
  61.       ToolButtonClass_Init( &ToolButton_Class );
  62.  
  63.    return &ToolButton_Class;
  64. }
  65.  
  66. void ToolButtonClass_Init( struct ValuatorClass *class )
  67. {
  68.    BoolGadgetClass_Init( class );
  69.    class->isa        = BoolGadgetClass();
  70.    class->ClassName  = "ToolButton";
  71.    class->Respond    = (USHORT(*)(Interactor *, IntuiMessage *))ToolButton_Respond;
  72. }
  73.  
  74. void ToolButton_Init( ToolButton    *self,
  75.                       WORD           leftedge,
  76.                       WORD           topedge,
  77.                       WORD           width,
  78.                       pcg_3DPens     pens,
  79.                       GraphicObject *archetype )
  80. {
  81.    BoolGadget_Init( self, leftedge, topedge, width, 14, pens, ClassName( (struct PObject *)archetype ) );
  82.    self->isa          = ToolButtonClass();
  83.    self->g.Activation =  TOGGLESELECT | GADGIMMEDIATE; /* | RELVERIFY | FOLLOWMOUSE; */
  84.    self->g.UserData   = archetype;
  85. }
  86.  
  87. GraphicObject *Archetype( ToolButton *self )
  88. {
  89.    return (GraphicObject *)self->g.UserData;
  90. }
  91.