home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / GT_Gadget.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  3.7 KB  |  122 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:RCS/libsource/GT_Gadget.cxx,v $
  9.  **   $Revision: 1.12 $
  10.  **   $Date: 1994/07/27 11:48:37 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. extern "C" {
  17. #ifdef __GNUG__
  18. #include <inline/intuition.h>
  19. #include <inline/gadtools.h>
  20. #endif
  21.  
  22. #ifdef __SASC
  23. #include <proto/intuition.h>
  24. #include <proto/gadtools.h>
  25. #endif
  26. }
  27. #include <string.h>
  28. #include <intuition/intuition.h>
  29. #include <APlusPlus/intuition/GT_Gadget.h>
  30. #include <APlusPlus/intuition/GWindow.h>
  31. #include <APlusPlus/intuition/ScreenC.h>
  32.  
  33.  
  34. static const char rcs_id[] = "$Id: GT_Gadget.cxx,v 1.12 1994/07/27 11:48:37 Armin_Vogt Exp Armin_Vogt $";
  35.  
  36. //runtime type inquiry support
  37. intui_typeinfo(GT_Gadget, derived(from(GadgetCV)), rcs_id)
  38.  
  39.  
  40. /*************************************************************************************************
  41.       GT_Gadget methods
  42.  *************************************************************************************************/
  43.  
  44. GT_Gadget::GT_Gadget(GraphicObject *owner,ULONG createKind,AttrList& attrs)
  45.       : GadgetCV(owner,attrs)
  46. {
  47.    if (Ok())
  48.    {
  49.       kind = createKind;
  50.       getHomeWindow()->modifyIDCMP(intuiAttrs().getTagData(GT_IDCMP,LISTVIEWIDCMP));
  51.       // per default all IDCMP flags needed by any GadTools gadget are set
  52.       setIOType(IOTYPE_GTGADGET);
  53.    }
  54. }
  55.  
  56.  
  57. GT_Gadget::~GT_Gadget()
  58. {
  59.    /* The gadget itself is freed by the GWindow. */
  60. }
  61.  
  62.  
  63. APTR GT_Gadget::redrawSelf(GWindow *homeWindow,ULONG& returnType)
  64. {
  65.    struct NewGadget createNG;
  66.    GadgetCV::redrawSelf(homeWindow,returnType);
  67.  
  68.    storeGadget(NULL);    // the old gadgets will be deleted with FreeGadgets() afterwards.
  69.  
  70.    _dprintf("fill createNG struct..\n");
  71.    // set the NewGadget structure with valid values according to the taglist.
  72.    createNG.ng_LeftEdge    = (WORD)iLeft();
  73.    createNG.ng_TopEdge     = (WORD)iTop();
  74.    createNG.ng_Width       = (WORD)iWidth();
  75.    createNG.ng_Height      = (WORD)iHeight();
  76.    createNG.ng_GadgetText  = (UBYTE*)intuiAttrs().getTagData(GA_Text,NULL);
  77.    createNG.ng_TextAttr    = (struct TextAttr*)intuiAttrs().getTagData(GT_TextAttr,
  78.                               (ULONG)(const struct TextAttr*)homeWindow->getScreenFont());
  79.    createNG.ng_GadgetID    = (UWORD)intuiAttrs().getTagData(GA_ID,4711);
  80.    createNG.ng_Flags       = intuiAttrs().getTagData(GT_Flags,0);
  81.    createNG.ng_VisualInfo  = getHomeWindow()->screenC()->getVisualInfo();
  82.    createNG.ng_UserData    = (APTR)this;   // store reference to the GT_Gadget object in the gadget.
  83.  
  84.    if (storeGadget(CreateGadgetA(kind,getGT_Context(),&createNG,intuiAttrs())))
  85.    {
  86.       setIOType(IOTYPE_GTGADGET);
  87.       returnType = IOTYPE_GTGADGET;
  88.    }
  89.    else
  90.    {
  91.       returnType = NULL;
  92.       _ierror(GT_GADGET_CREATE_FAILED);
  93.       setIOType(IOTYPE_GTGADGET);
  94.       // immediately set object to valid state to have GWindow call redrawSelf next time the window changes
  95.    }
  96.    _dprintf("\tdone.\n");
  97.  
  98.    return gadgetPtr();
  99. }
  100.  
  101. ULONG GT_Gadget::setAttributes(AttrList& attrs)
  102. {
  103.    if (notificationLoop()) return 0L;
  104.  
  105.    if (gadgetPtr())  // gadget available ?
  106.    {
  107.       GT_SetGadgetAttrsA(gadgetPtr(),(Window*)getHomeWindow()->windowPtr(),NULL,attrs);
  108.    }
  109.    return GadgetCV::setAttributes(attrs);
  110. }
  111.  
  112. ULONG GT_Gadget::getAttribute(Tag tag,ULONG& dataStore)
  113. {
  114.    return GadgetCV::getAttribute(tag,dataStore);
  115. }
  116.  
  117. void GT_Gadget::callback(const IntuiMessageC *imsg)
  118. {
  119.    /* GadTools gadgets need specialized callback methods.
  120.       These are defined in the specialized GT_??? class methods. */
  121. }
  122.