home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / gempp19.zoo / gem++19 / src / gemrawo.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-29  |  2.3 KB  |  96 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is Copyright 1992,1993 by Warwick W. Allison.
  4. //  This file is part of the gem++ library.
  5. //  You are free to copy and modify these sources, provided you acknowledge
  6. //  the origin by retaining this notice, and adhere to the conditions
  7. //  described in the file COPYING.LIB.
  8. //
  9. /////////////////////////////////////////////////////////////////////////////
  10.  
  11. #include "gemrawo.h"
  12. #include <string.h>
  13.  
  14. GEMrawobject::GEMrawobject(const GEMrawobject& copy)
  15. {
  16.     memcpy(this,©,sizeof(GEMrawobject));
  17.  
  18.     int copylevel=ExtType()&3;
  19.  
  20.     if (Editable()) copylevel^=2;
  21.  
  22.     unsigned long& spec=Indirect() ? *((unsigned long*)ob_spec) : ob_spec;
  23.  
  24.     if (copylevel) {
  25.         switch (Type()) {
  26.          case G_TEXT: case G_BOXTEXT: case G_FTEXT: case G_FBOXTEXT: {
  27.             TEDINFO* cp=(TEDINFO*)spec;
  28.             TEDINFO* te=new TEDINFO;
  29.             *te=*cp;
  30.  
  31.             if (copylevel&2) {
  32.                 te->te_ptext=strdup(cp->te_ptext);
  33.             }
  34.  
  35.             if (copylevel&1) {
  36.                 te->te_ptmplt=strdup(cp->te_ptmplt);
  37.                 te->te_pvalid=strdup(cp->te_pvalid);
  38.             }
  39.  
  40.             spec=(unsigned long)te;
  41.         } break; case G_IMAGE: {
  42.             BITBLK* cp=(BITBLK*)spec;
  43.             BITBLK* bi=new BITBLK;
  44.             *bi=*cp;
  45.             bi->bi_pdata=new char[cp->bi_wb*cp->bi_hl];
  46.             memcpy(bi->bi_pdata,cp->bi_pdata,cp->bi_wb*cp->bi_hl);
  47.             spec=(unsigned long)bi;
  48.         } break; case G_BUTTON: case G_STRING: case G_TITLE: {
  49.             spec=(unsigned long)strdup((char*)spec);
  50.         } break; case G_ICON: {
  51.             ICONBLK* cp=(ICONBLK*)spec;
  52.             ICONBLK* ib=new ICONBLK;
  53.             *ib=*cp;
  54.  
  55.             if (copylevel&1) {
  56.                 int dlen=cp->ib_wicon*cp->ib_hicon/16;
  57.                 ib->ib_pdata=new short[dlen];
  58.                 ib->ib_pmask=new short[dlen];
  59.                 memcpy(ib->ib_pdata,cp->ib_pdata,dlen*sizeof(short));
  60.                 memcpy(ib->ib_pmask,cp->ib_pmask,dlen*sizeof(short));
  61.             }
  62.  
  63.             if (copylevel&2) {
  64.                 ib->ib_ptext=strdup(cp->ib_ptext);
  65.             }
  66.  
  67.             spec=(unsigned long)ib;
  68.         } break; case G_USERDEF:    // Hmm...
  69.             ;
  70.         }
  71.     }
  72. }
  73.  
  74. GEMobject* GEMrawobject::Cook()
  75. {
  76.     return Indirect() ? (GEMobject*)ob_spec : 0;
  77. }
  78.  
  79. unsigned long GEMrawobject::ObjectSpecific() const
  80. {
  81.     return Indirect() ? (*((unsigned long*)ob_spec)) : ob_spec;
  82. }
  83.  
  84. void GEMrawobject::ObjectSpecific(unsigned long l)
  85. {
  86.     if (Indirect())
  87.         *((long*)ob_spec)=l;
  88.     else
  89.         ob_spec=l;
  90. }
  91.  
  92.  
  93. #define CLASS GEMrawobject
  94. #include "gemo_m.cc"
  95. #undef CLASS
  96.