home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / GT_String.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  2.3 KB  |  77 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_String.cxx,v $
  9.  **   $Revision: 1.12 $
  10.  **   $Date: 1994/07/27 11:48:57 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. extern "C" {
  17. #ifdef __GNUG__
  18. #endif
  19.  
  20. #ifdef __SASC
  21. #endif
  22. }
  23. #include <APlusPlus/gadtools/GT_String.h>
  24. #include <APlusPlus/intuition/IntuiMessageC.h>
  25.  
  26.  
  27. static const char rcs_id[] = "$Id: GT_String.cxx,v 1.12 1994/07/27 11:48:57 Armin_Vogt Exp Armin_Vogt $";
  28.  
  29. //runtime type inquiry support
  30. intui_typeinfo(GT_String, derived(from(GT_Gadget)), rcs_id)
  31.  
  32.  
  33. GT_String::GT_String(GOB_OWNER,AttrList& attrs)
  34.    : GT_Gadget(gob_owner,STRING_KIND,attrs)
  35. {
  36.    
  37. }
  38.  
  39. void GT_String::callback(const IntuiMessageC* imsg)
  40.    /* String gadgets will send GADGETUP for each RETURN,HELP and TAB.
  41.    */
  42. {
  43.    if (imsg->getClass()==CLASS_GADGETUP)
  44.    {
  45.          setAttrs( AttrList(GTST_String,((struct StringInfo*)gadgetPtr()->SpecialInfo)->Buffer,
  46.                      GA_ID,gadgetPtr()->GadgetID, TAG_END) );
  47.    }
  48. }
  49.  
  50. ULONG GT_String::getAttribute(Tag tag,ULONG& dataStore)
  51. {
  52.    if (gadgetPtr())
  53.    {
  54.       switch (tag)
  55.       {
  56.          case GTST_String : return (dataStore=(ULONG)((struct StringInfo*)gadgetPtr()->SpecialInfo)->Buffer);
  57.          default : return GT_Gadget::getAttribute(tag,dataStore);
  58.       }
  59.    }
  60.    else return GT_Gadget::getAttribute(tag,dataStore);
  61. }
  62.  
  63. APTR GT_String::redrawSelf(GWindow *homeWindow,ULONG& returnType)
  64. {
  65.    if (gadgetPtr())
  66.    {
  67.       ULONG dummy;
  68.       intuiAttrs().updateAttrs( AttrList(GTST_String,getAttribute(GTST_String,dummy),TAG_END) );
  69.       // before the GT-string gadget is being deleted the edit buffer address needs to be copied
  70.       // to gadget that will be created in GT_Gadget::redrawSelf(). There, a new edit buffer is
  71.       // allocated and the old one's contents are copied to it.
  72.       // The old gadget will be deleted after this method has returned.
  73.       // AttrList::update() is used since no notification shall be triggered.
  74.    }
  75.    return GT_Gadget::redrawSelf(homeWindow,returnType);
  76. }
  77.