Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Chart User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

7.2 Component Placement

Every component has a placement rectangle stored in an SRGraphRect object. The definition of an SRGraphRect rectangle is similar to that of a CRect object with left, top, right, and bottom extents. The four positions are defined in a floating-point format so that a component can be accurately placed when using device independent coordinates. Thus, SRGraphRect can position a component according to one of four measurement modes. These are: Pixel, Metric (millimeters), Imperial (inches), and Percentage.

The functions SRGraphComponent::SetRect() and SetMeasurement() set the position rectangle coordinates and the measurement mode.

The parameter to SetMeasurement() can be one of:

SetMeasurement() calls SetSizeDefaults() to set default margins, tick sizes, and legend key sizes to values appropriate for the selected measurement mode.

SetRect() can specify rectangles that automatically expand to fill the available space in one or more directions. If you use a –1 value when setting a rectangle's right side, then that side locks to the right most position in the window in which the component is displayed. Setting –1 in all four parameters makes the component cover all of the available space.

The Objective Chart functions GetFinalRect() and CalcFinalRect() facilitate repositioning of resizeable components by users.

The two functions return the same information, but CalcFinalRect() can be used during chart setup while GetFinalRect() only works after the chart has been drawn.

For standard (nonresizeable) components both functions return the rectangle specified by SetRect().

The resizeable components — SRGraphTitleResizeable, SRGraphLegend, SRGTextPanel— store the final, resized rectangle, m_FinalRect, during the draw process and override CalcFinalRect() to estimate the final rectangle before it is drawn.

The code below demonstrates how CalcFinalRect() can be used in OnInitialUpdate() to position other components around a resizeable component.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.