home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Core / source / bound.cp < prev    next >
Encoding:
Text File  |  1995-03-19  |  2.6 KB  |  43 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    bound.cp
  3. //    Date:                    7/20/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a bound widget. a
  7. //                                bound widget is a user interface item that frames other
  8. //                                types of widgets.
  9. //
  10. //------------------------------------------------------------------------------
  11.  
  12. #include    "bound.h"
  13.  
  14. //------------------------------------------------------------------------------
  15. //    constructor
  16. //------------------------------------------------------------------------------
  17. bound::bound (Rect &c1, Rect &c2) : widget ()                                                                        //    constructor
  18. {                                                                                                                                                                //    begin
  19.     constrain = c1;                                                                                                                                //    copy the constrain values
  20.     constraint = c2;                                                                                                                            //    copy the parent relationship
  21. }                                                                                                                                                                //    end
  22.  
  23. //------------------------------------------------------------------------------
  24. //    resize the widget
  25. //------------------------------------------------------------------------------
  26. void        bound::Resize (EventRecord &event)                                                                            //    recompute sizing information from parent
  27. {                                                                                                                                                                //    begin
  28.     Rect    bnd = (*region)->rgnBBox;                                                                                                //    copy my current bounding rect
  29.     short    *pbnd = (short *) &(*(parent->region))->rgnBBox;                                                //    get a pointer to the parent bound
  30.     if (constrain.top >= 0)                                                                                                                //    if the top of the bound is constrained
  31.         bnd.top = pbnd[constrain.top] + constraint.top;                                                            //    update my bounds according to my constraints and parent rect
  32.     if (constrain.left >= 0)                                                                                                            //    if the left of the bound is constrained
  33.         bnd.left = pbnd[constrain.left] + constraint.left;                                                    //    update my bounds according to my constraints and parent rect
  34.     if (constrain.bottom >= 0)                                                                                                        //    if the bottom of the bound is constrained
  35.         bnd.bottom = pbnd[constrain.bottom] + constraint.bottom;                                        //    update my bounds according to my constraints and parent rect
  36.     if (constrain.right >= 0)                                                                                                            //    if the right of the bound is constrained
  37.         bnd.right = pbnd[constrain.right] + constraint.right;                                                //    update my bounds according to my constraints and parent rect
  38.     RectRgn (region, &bnd);                                                                                                                //    recompute my region
  39.     widget::Resize (event);                                                                                                                //    do what the other widgets do
  40. }                                                                                                                                                                //    end
  41.  
  42. //------------------------------------------------------------------------------
  43.