home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / RowColumnGroup.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  2.6 KB  |  90 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/RowColumnGroup.cxx,v $
  9.  **   $Revision: 1.8 $
  10.  **   $Date: 1994/08/03 15:17:31 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/graphics/RowColumnGroup.h>
  17. #include <APlusPlus/intuition/GadgetCV.h>
  18.  
  19.  
  20. static const char rcs_id[] = "$Id: RowColumnGroup.cxx,v 1.8 1994/08/03 15:17:31 Armin_Vogt Exp Armin_Vogt $";
  21.  
  22. //runtime type inquiry support
  23. intui_typeinfo(RowColumnGroup, derived(from(GadgetCV)), rcs_id)
  24.  
  25.  
  26. RowColumnGroup::RowColumnGroup(GOB_OWNER,AttrList& attrs) : GadgetCV(gob_owner,attrs)
  27. {
  28.    if (Ok())
  29.       setIOType(IOTYPE_GROUPGADGET);
  30. }
  31.  
  32. RowColumnGroup::~RowColumnGroup()
  33. {
  34. }
  35.  
  36. void RowColumnGroup::callback(const IntuiMessageC* imsg)
  37. {
  38.    // do nothing   
  39. }
  40.  
  41. void RowColumnGroup::adjustChilds()
  42.    /* Adjust graphical dimensions of the GraphicObject childs of 'this' GraphicObject
  43.       according to the GOB_ tags defined in GraphicObject.h, depending on the dimensions
  44.       of 'this'. The adjustment of each child will cause adjustments of all its GraphicObject
  45.       childs down the IntuiObject tree.
  46.       'adjustChilds' needs to be invoked on every window since each invokation only
  47.       regards non-window childs.
  48.    */
  49. {
  50.    GraphicObject *relative = NULL;
  51.    GraphicObject *pred = NULL;
  52.    WHVAL widthSum=0;
  53.    int numberOfChilds=0;
  54.  
  55.    // enclose the two FOREACHOF loops in their own scope to allow the 
  56.    // declaration of variable 'node' twice.
  57.    {
  58.       // first run: sum up the width of all childs
  59.       FOREACHOF(GraphicObject,this)
  60.       {
  61.          if (ptr_cast(GadgetCV,node))
  62.          {
  63.             widthSum += node->width();
  64.             numberOfChilds++;
  65.    
  66.             pred = node;
  67.             _dprintf("adjustChild to: (%ld/%ld,%ld/%ld,%ld/%ld,%ld/%ld)\n",node->left(),node->iLeft(),node->top(),node->iTop(),node->right(),node->iRight(),node->bottom(),node->iBottom());
  68.          }
  69.       }
  70.    }
  71.    WHVAL space = 0;
  72.    if (numberOfChilds > 1)
  73.       space = ((iWidth()-widthSum)>0 ?(iWidth()-widthSum):0 )/(numberOfChilds-1);
  74.  
  75.    // second run: position the childs
  76.    XYVAL leftX = iLeft();
  77.    XYVAL topY = iTop();
  78.    {
  79.       FOREACHOF(GraphicObject,this)
  80.       {
  81.          if (ptr_cast(GadgetCV,node)) 
  82.          {
  83.             node->setRectWH(leftX,topY,node->width(),node->height());
  84.             leftX += node->width()+space;
  85.             node->adjustChilds();
  86.          }
  87.       }
  88.    }
  89. }
  90.