home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-30 | 3.3 KB | 104 lines | [TEXT/CWIE] |
- //**************************************************************************************
- // Filename: LProportionalSizer.cp
- // Copyright © 1997 Dan Crevier. All rights reserved.
- // <mailto:Dan.Crevier@pobox.com>
- //
- // Description:
- // When this view is resized, it resizes all its subview proportionally, as if the
- // view is zoomed, or shrunk
- // To use it, make it as large as its enclosing view, with all of the frame bindings
- // turned on. Then put panes into the LProportionalSizer, and they will be resized
- // when the superview is resized
- // It was written for use with my LHiResPrintout class, but I'm sure there are other
- // uses
- //**************************************************************************************
- // Revision History:
- // Monday, June 30, 1997 - Original
- //**************************************************************************************
-
- #include "LProportionalSizer.h"
-
- //**************************************************************************************
- // Function: Default Constructor
- //
- // Description: Builds the LProportionalSizer class.
- //
- // Inputs: none
- //
- // Outputs: none
- //
- //**************************************************************************************
- LProportionalSizer::LProportionalSizer()
- {
- }
-
- //**************************************************************************************
- // Function: Stream Constructor
- //
- // Description: Builds the LProportionalSizer class from a PP Stream
- //
- // Inputs: inStream
- //
- // Outputs: none
- //
- //**************************************************************************************
- LProportionalSizer::LProportionalSizer(LStream *inStream)
- : LView(inStream)
- {
- }
-
- //**************************************************************************************
- // Function: Destructor
- //
- // Description: Destroys the LProportionalSizer class.
- //
- // Inputs: none
- //
- // Outputs: none
- //
- //**************************************************************************************
- LProportionalSizer::~LProportionalSizer()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • ResizeFrameBy
- // ---------------------------------------------------------------------------
- // Change the Frame size by the specified amounts
- //
- // inWidthDelta and inHeightDelta specify, in pixels, how much larger
- // to make the Frame. Positive deltas increase the size, negative deltas
- // reduce the size.
- // Resizes subpanes proportionately
-
- void
- LProportionalSizer::ResizeFrameBy(
- Int16 inWidthDelta,
- Int16 inHeightDelta,
- Boolean inRefresh)
- {
- SPoint32 subLocation;
- SDimension16 subSize;
- SDimension16 oldSize = mFrameSize;
-
- LPane::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
-
- CalcRevealedRect();
- OutOfFocus(this);
-
- TArrayIterator<LPane*> iterator(mSubPanes);
- LPane *theSub;
- while (iterator.Next(theSub)) {
- theSub->GetFrameLocation(subLocation);
- theSub->GetFrameSize(subSize);
- theSub->ResizeFrameBy(((float)inWidthDelta)*subSize.width/oldSize.width,
- ((float)inHeightDelta)*subSize.height/oldSize.height, inRefresh);
- theSub->MoveBy(((float)subLocation.h)*mFrameSize.width/oldSize.width - subLocation.h,
- ((float)subLocation.v)*mFrameSize.height/oldSize.height - subLocation.v, inRefresh);
- //theSub->AdaptToSuperFrameSize(inWidthDelta, inHeightDelta, inRefresh);
- }
-
- ReconcileFrameAndImage(inRefresh);
- }
-
-