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 / GraphicObject.cxx < prev    next >
C/C++ Source or Header  |  1994-05-07  |  4KB  |  133 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/GraphicObject.cxx,v $
  9.  **    $Revision: 1.3 $
  10.  **    $Date: 1994/04/23 21:01:09 $
  11.  **    $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/graphics/GraphicObject.h>
  17.  
  18.  
  19. volatile static char rcs_id[] = "$Id: GraphicObject.cxx,v 1.3 1994/04/23 21:01:09 Armin_Vogt Exp Armin_Vogt $";
  20.  
  21.  
  22. GraphicObject::GraphicObject(GraphicObject *owner,AttrList& attrs)
  23.    : IntuiObject(owner,attrs)
  24. {    
  25.     if (Ok())
  26.     {
  27.       setIOType(GRAPHICOBJECT);
  28.         GBorder *gbObj = (GBorder*)intuiAttrs().getTagData(GOB_Border);
  29.         if (gbObj) gbObj->makeBorder(this);
  30.     }
  31. }
  32.  
  33. GraphicObject::~GraphicObject()
  34. {
  35.     
  36. }
  37.  
  38.  
  39. ULONG GraphicObject::setAttributes(AttrList& attrs) 
  40.    /* only propagates the update attrs to the base class.
  41.    */
  42. {
  43.     GBorder *gbObj = (GBorder*)attrs.getTagData(GOB_Border);
  44.     if (gbObj) gbObj->makeBorder(this);
  45.     
  46.    return IntuiObject::setAttributes(attrs); 
  47. }     
  48.         
  49. ULONG GraphicObject::getAttribute(Tag tag,ULONG& dataStore)
  50. {
  51.     return IntuiObject::getAttribute(tag,dataStore);
  52. }
  53.  
  54. APTR GraphicObject::redrawSelf(GWindow *homeWindow,ULONG& returnType) 
  55. {    
  56.     GBorder *gbObj = (GBorder*)intuiAttrs().getTagData(GOB_Border);
  57.     if (gbObj) gbObj->drawBorder(this,homeWindow);
  58.     
  59.     //    notifyFlush(AttrList());    // flush all attributes into the notification stream
  60.     returnType = 0L;
  61.     return NULL; 
  62. }
  63.  
  64. void GraphicObject::adjustChilds()
  65.    /* Adjust graphical dimensions of the GraphicObject childs of 'this' GraphicObject
  66.       according to the GOB_ tags defined in GraphicObject.h, depending on the dimensions
  67.       of 'this'. The adjustment of each child will cause adjustments of all its GraphicObject
  68.       childs down the IntuiObject tree.
  69.         'adjustChilds' needs to be invoked on every window since each invokation only
  70.         regards non-window childs.
  71.    */
  72. {    
  73.    GraphicObject *relative = NULL;
  74.    GraphicObject *pred = NULL;
  75.     
  76.    FOREACHOF(GraphicObject,this)
  77.    {
  78.         if (node->isKindOf(IOBASE_WINDOW)) continue;    // leave out child windows
  79.         
  80.       node->setRect(0,0,0,0);
  81.       
  82.         AttrIterator next(node->intuiAttrs());
  83.       while (next())
  84.       {
  85.          LONG data = (LONG)next.data();
  86.             ULONG tagID = next.tag() - GOB_Spec_Dummy;
  87.             
  88.          if (tagID < 16)
  89.          {                
  90.             relative = tagID&gob_relative ? (pred==NULL?this:pred) : this;
  91.                 
  92.             _dout("relative has ("<<relative->iLeft()<<"),("<<relative->iTop()
  93.                 <<"),("<<relative->iRight()<<"),("<<relative->iBottom()<<")\n");
  94.             WHVAL distance;
  95.   
  96.             if (tagID & gob_orient)
  97.             {
  98.                distance = ((tagID & gob_reledge)? 
  99.                             ((tagID & gob_relative)?relative->bottom():relative->iBottom()) 
  100.                             : 
  101.                             ((tagID & gob_relative)?relative->top():relative->iTop()) 
  102.                             ) + GOB_Absolute(iHeight(),data);
  103.                if (tagID & gob_edge)            
  104.                   node->maxY(distance);
  105.                else
  106.                   node->minY(distance);
  107.             }
  108.             else 
  109.             {     
  110.                distance = ((tagID & gob_reledge) ? 
  111.                         ((tagID & gob_relative)?relative->right():relative->iRight())
  112.                         : 
  113.                         ((tagID & gob_relative)?relative->left():relative->iLeft()) 
  114.                         ) + GOB_Absolute(iWidth(),data);
  115.                if (tagID & gob_edge)
  116.                   node->maxX(distance);
  117.                else 
  118.                   node->minX(distance);                                
  119.             }
  120.          }
  121.          else switch(next.tag())       // other GraphicObject tags
  122.          {
  123.                 
  124.             default: break;      
  125.          }         
  126.       }
  127.       pred = node;
  128.       _dout("adjustChild to: "<<node->left()<<"("<<node->iLeft()<<"),"<<node->top()<<"("<<node->iTop()<<"),"
  129.         <<node->right()<<"("<<node->iRight()<<"),"<<node->bottom()<<"("<<node->iBottom()<<")\n");
  130.       node->adjustChilds();
  131.    }
  132. }
  133.