home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / aplusplus-1.01-src.lha / GNU / src / amiga / APlusPlus-1.01 / libsource / BoopsiGadget.cxx < prev    next >
C/C++ Source or Header  |  1994-04-23  |  4KB  |  138 lines

  1. /******************************************************************************
  2.  **
  3.  **    C++ Class Library for the Amiga© system software.
  4.  **
  5.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **    All Rights Reserved.
  7.  **
  8.  **    $Source: apphome:APlusPlus/RCS/libsource/BoopsiGadget.cxx,v $
  9.  **    $Revision: 1.6 $
  10.  **    $Date: 1994/04/23 21:00:43 $
  11.  **    $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15. extern "C" {
  16. #ifdef __GNUG__
  17. #include <inline/intuition.h>
  18. #endif
  19.  
  20. #ifdef __SASC
  21. #include <proto/intuition.h>
  22. #endif
  23. }
  24. #include <APlusPlus/intuition/BoopsiGadget.h>
  25.  
  26.  
  27. volatile static char rcs_id[] = "$Id: BoopsiGadget.cxx,v 1.6 1994/04/23 21:00:43 Armin_Vogt Exp Armin_Vogt $";
  28.  
  29.  
  30. void BoopsiGadget::create(Class *privClass,UBYTE *pubClass)
  31. {
  32.    if (Ok()) 
  33.     {
  34.        privateClass = privClass;
  35.        publicClass  = pubClass;
  36.  
  37.        intuiAttrs().addAttrs(AttrList(GA_Left,0, GA_Top,0, GA_Width,0, GA_Height,0, TAG_END));
  38.    
  39.        getHomeWindow()->modifyIDCMP(CLASS_IDCMPUPDATE|CLASS_GADGETDOWN|CLASS_GADGETUP);
  40.    
  41.        setIOType(IOTYPE_BOOPSIGADGET);
  42.     }
  43.       _dout("Boopsigadget "<<(APTR)this<<" initialised. status = "<<(isKindOfIntuiObject()?"OK":"ERROR")<<"\n");
  44.    _dout("status = "<<status()<<endl);
  45. }
  46.  
  47.  
  48. APTR BoopsiGadget::redrawSelf(GWindow *homeWindow,ULONG& returnType)
  49. {
  50.    _dout("Boopsigadget::redrawSelf()\n");
  51.    
  52.    GadgetCV::redrawSelf(homeWindow,returnType);
  53.    
  54.    // destroy old Boopsigadget
  55.    if (gadgetPtr()!=NULL)
  56.    {
  57.       _dout("DisposeObject()\n");
  58.       DisposeObject(gadgetPtr());
  59.       _dout("\tdone\n");
  60.    }
  61.    
  62.    // copy GraphicObject rectangle to gadget taglist
  63.    intuiAttrs().updateAttrs(AttrList(GA_Left,iLeft(),GA_Top,iTop(),GA_Width,iWidth(),GA_Height,iHeight(),TAG_END));
  64.  
  65.    // create new Boopsigadget
  66.    if ( storeGadget((struct Gadget*)NewObjectA(privateClass,publicClass,intuiAttrs()) ) )
  67.    {
  68.       gadgetPtr()->NextGadget = NULL; // important for AddGList() in GWindow::On_NEWSIZE()
  69.       returnType = IOTYPE_BOOPSIGADGET;
  70.    }
  71.    else
  72.    {
  73.       returnType = NULL;
  74.       _ierror(BOOPSIGADGET_NEWOBJECT_FAILED);
  75.    }
  76.    
  77.    _dout("\tdone\n");
  78.    return gadgetPtr();
  79. }
  80.  
  81. void BoopsiGadget::callback(const IntuiMessageC *imsg)
  82.    /* Boopsigadgets receive IDCMPUPDATE messages in case they have ICA_TARGET set to ICTARGET_IDCMP.
  83.       Each IDCMPUPDATE message contains a taglist of changed attributes in the IAddress field.
  84.       This taglist is used to change the IntuiObject attribute tags, spreading changes through the
  85.       ITransponder in the process.
  86.    */
  87. {
  88.    if (imsg && imsg->getIAddress())
  89.    {
  90.         _dout("BoopsiGadget::callback\n");
  91.  
  92.       switch(imsg->getClass())
  93.       {
  94.          case CLASS_IDCMPUPDATE :
  95.             setAttrs( AttrList((struct TagItem*)imsg->getIAddress()) );
  96.             break;
  97.       }
  98.    }
  99.    else _dout("BoopsiGadget::callback() received imsg==null!!\n");
  100. }
  101.  
  102. ULONG BoopsiGadget::setAttributes(AttrList& attrs)
  103. {
  104.     if (notificationLoop()) return 0L;
  105.  
  106.    _dout("BoopsiGadget("<<(APTR)this<<")::setAttributes("<<attrs<<")\n");
  107.    
  108.    if (gadgetPtr())
  109.    {
  110.       SetGadgetAttrsA(gadgetPtr(),(Window*)getHomeWindow()->windowPtr(),NULL,attrs);
  111.    }
  112.     
  113.    return GadgetCV::setAttributes(attrs);
  114. }
  115.  
  116. ULONG BoopsiGadget::getAttribute(Tag attrID,ULONG& dataStore)
  117.    /* read a specific BOOPSI attribute. If the attribute is recognized by the BOOPSI object
  118.       0L is being returned and dataStore is undefined, otherwise the attribute's value is
  119.       stored in dataStore, a reference to a ULONG variable.
  120.    */
  121. {
  122.     if (gadgetPtr() && GetAttr(attrID,gadgetPtr(),&dataStore))
  123.         return dataStore;
  124.     else
  125.         return GadgetCV::getAttribute(attrID,dataStore);
  126. }
  127.  
  128. BoopsiGadget::~BoopsiGadget()
  129.    /* Dispose the Boopsi object.
  130.    */
  131. {
  132.    _dout("BoopsiGadget::~\n");
  133.    if (gadgetPtr()!=NULL)
  134.    {  _dout("DisposeObject()\n");
  135.       DisposeObject(gadgetPtr());
  136.    }
  137.    _dout("done\n");
  138. }