class CHuiGridLayout : public CHuiLayout |
CHuiGridLayout is a layout that allows visuals to be positioned within a grid.
To use this class, a grid layout is created of a desired width and height. Then, when visuals are added to grid layout, they will populate the grid. By default, all slots in a grid layout are of a uniform size, but the weighting of individual rows and columns can be modified, and can be specified using metric units. Slots will resize automatically as the grid layout size changes.
The standard application grid is one example of a grid layout.
Private Member Functions | |
---|---|
void | CalculateCellInPixels(THuiGridDimension, TInt, TReal32, TInt &, TInt &) |
void | CalculateCellInPixelsReal(THuiGridDimension, TInt, TReal32, TReal32 &, TReal32 &, TInt &, TInt &) |
TReal32 | ProportionalInnerOuterPadding(THuiGridDimension, TReal32, TReal32) |
TBool | UseRightToLeftFillingOrder() |
void | WeightFromMetric(THuiGridDimension, THuiMetric &, TReal32 &, TInt &) |
Inherited Enumerations | |
---|---|
CHuiLayout:EHuiLayoutChildRect | |
CHuiLayout:TExpansionFlags |
Private Attributes | |
---|---|
TGridLayoutPrivateData * | iGridLayoutData |
TAny * | iSpare |
Inherited Attributes | |
---|---|
CHuiLayout::iHuiLayoutPrivateData | |
CHuiVisual::iDepthOffset | |
CHuiVisual::iOpacity | |
CHuiVisual::iOwner | |
CHuiVisual::iPreviousDrawn | |
CHuiVisual::iSessionId | |
CHuiVisual::iTrackVisual |
IMPORT_C | CHuiGridLayout | ( | MHuiVisualOwner & | aOwner | ) |
MHuiVisualOwner & aOwner |
IMPORT_C CHuiGridLayout * | AddNewL | ( | CHuiControl & | aOwnerControl, |
TInt | aColumns, | |||
TInt | aRows, | |||
CHuiLayout * | aParentLayout = 0 | |||
) | [static] |
Construct a new grid layout and give its ownership to a control.
Default expansion direction is vertical. See SetExpanding() to changed the direction.
the columns and rows will be initialized with unit weights equal to 1, so that blocks will all share even proportions of the available area to start with.
in order to use a mixture of metric weights, or to set different weights, set rows and columns to zero when calling this method, then use e.g. AppendWeightL to subsequently populate the weights.
CHuiControl & aOwnerControl | Owner control. |
TInt aColumns | Number of columns in the grid. |
TInt aRows | Number of rows in the grid. |
CHuiLayout * aParentLayout = 0 | Parent layout for the new grid layout. |
IMPORT_C void | AppendWeightL | ( | THuiGridDimension | aDim, |
const THuiMetric & | aWeight | |||
) |
Add a new line of blocks to this grid layout at the last position in the direction of the specified dimension. It will have the supplied weight. Weights can be any metric value, hence different units can be used for each block. In particular, EHuiUnitWeight can be used to represent weight values in aribtrary proportional units.
In the case of proportional weights, the effect of this will be to cause the other blocks to resize according to the new total weight.
If non-relative coordinates are specified (e.g., real pixels), the combined blocks might not fill the entire layout area. However, weights will always stretch to fill all available space after the fixed units have been determined. Therefore, depending on circumstances it may be better to use EHuiUnitWeight
For example [2 weights, 1 weight, 2 weights] in a layout of 100 pixels would result in [40 pixels, 20 pixels, 40 pixels].
For example [10 pixels, 1 weight, 15 pixels] in a layout of 100 pixels would result in [10 pixels, 75 pixels, 15 pixels].
THuiGridDimension aDim | the dimension to which the weight corresponds |
const THuiMetric & aWeight | the weight to be used for the block in the specified dimension, replacing any previously existing weight for that block |
IMPORT_C THuiXYMetric | BaseUnit | ( | ) | const [virtual] |
Returns the layout's base measurement unit. The positions and sizes of the children of this layout are interpreted as multiples of this base unit. For example, the actual X position of a child is determined by aBaseUnit.iX * childX.
The effect of the base unit is limited to the children of this layout -- the grandchildren use the base units of their parents, not this base unit.
that if the visual flag EHuiVisualFlagAutomaticLocaleMirroringEnabled is set, the value returned by this method will change based on the current platform locale mirroring in the X-axis. So for example if the current layout is mirrored, then the value returned by this method will have the X magnitude set to the negative of the value that was set using SetBaseUnit.
void | CalculateCellInPixels | ( | THuiGridDimension | aDim, |
TInt | aIndex, | |||
TReal32 | aAvailablePixels, | |||
TInt & | aPos, | |||
TInt & | aSize | |||
) | const [private] |
Calculates the size and position along the specified axis according to the current weights. The non-weights are resolved into pixels and the remainder after subtracting from InnerSize is shared between the other cells that are specified using weight metrics. Returns integer pixel values, taking into account the TAlfGridLayoutModeFlags for error rounding.
THuiGridDimension aDim | the dimension along which to calculate |
TInt aIndex | the block being calculated |
TReal32 aAvailablePixels | the space available within the grid layout, after the paddings and inner paddings have already been subtracted |
TInt & aPos | the resulting position in pixels of the block along the axis (replaces contents) |
TInt & aSize | the resulting size in pixels of the block along the axis (replaces contents) |
void | CalculateCellInPixelsReal | ( | THuiGridDimension | aDim, |
TInt | aIndex, | |||
TReal32 | aAvailablePixels, | |||
TReal32 & | aPos, | |||
TReal32 & | aSize, | |||
TInt & | aFloorPixelPos, | |||
TInt & | aCeilingPixelPos | |||
) | const [private] |
Calculates the size and position along the specified axis according to the current weights. The non-weights are resolved into pixels and the remainder after subtracting from InnerSize is shared between the other cells that are specified using weight metrics.
that this calculation assumes that the inner paddings have already been subtracted from the inner size, and that they will be added back in when calculating the actual position in base units.
when called repeatedly by UpdateChildrenLayout, all the cells will be calculated for each time UpdateChildLayout is called.
THuiGridDimension aDim | the dimension along which to calculate |
TInt aIndex | the block being calculated |
TReal32 aAvailablePixels | the space available within the grid layout, after the paddings and inner paddings have already been subtracted |
TReal32 & aPos | the resulting position in pixels of the block along the axis (replaces contents) |
TReal32 & aSize | the resulting size in pixels of the block along the axis (replaces contents) |
TInt & aFloorPixelPos | the total width assuming every item width is floored. |
TInt & aCeilingPixelPos | the total width assuming every item width is ceilinged. |
IMPORT_C TInt | ChildOrdinal | ( | TInt | aIndex | ) | [virtual] |
Determines the layout ordinal for a child visual. The child's placement depends on the ordinal number.
TInt aIndex | Index of the child visual. |
IMPORT_C TBool | ChildPos | ( | TInt | aOrdinal, |
TPoint & | aPos | |||
) | [virtual] |
New virtual method. Determines the position of a child visual according to the layout. The child position is determined using the base units of the layout. Derived layout classes should refer to InnerSize() and InnerTopLeft() to determine the area suitable for placing children into.
IMPORT_C TInt | ChildRect | ( | TInt | aOrdinal, |
THuiRealRect & | aRect | |||
) | [virtual] |
New virtual method. Determines the position and size of a child visual according to the layout. The child position is determined using the base units of the layout. Derived layout classes should refer to InnerSize() and InnerTopLeft() to determine the area suitable for placing children into.
TInt aOrdinal | Layout ordinal of the child visual. |
THuiRealRect & aRect | New position for the child. This is used to set the child size and position with no conversions. |
IMPORT_C TBool | ChildSize | ( | TInt | aOrdinal, |
TSize & | aSize | |||
) | [virtual] |
New virtual method. Determines the size of a child visual according to the layout. The child size is determined using the base units of the layout. Derived layout classes should refer to InnerSize() and InnerTopLeft() to determine the area suitable for placing children into.
IMPORT_C void | ClearLayoutModeFlags | ( | THuiGridDimension | aDim, |
TUint | aGridLayoutModeFlags | |||
) |
Clears flag(s) which alter the children's pixel error distribution within the grid layout.
THuiGridDimension aDim | the dimension to which the given flag(s) affect. |
TUint aGridLayoutModeFlags | Flags to be cleared |
IMPORT_C void | ConstructL | ( | ) | [virtual] |
From CHuiLayout, deriving class must implement base call
IMPORT_C TInt | Count | ( | ) | const [virtual] |
From CHuiVisual. Returns the number of child visuals in the layout.
IMPORT_C TInt | DimensionCount | ( | THuiGridDimension | aDim | ) | const |
Return the number of lines of blocks in this grid, along the specified dimension.
THuiGridDimension aDim | the dimension along which to count |
IMPORT_C void | Draw | ( | CHuiGc & | aGc | ) | const [virtual] |
From CHuiVisual. Draws (renders) this layout.
The default implementataion applies transformations (affects the positions of the layout), draws brushes and of course children.
Layout clipping is not affected by transformation.
CHuiGc & aGc |
IMPORT_C void | DrawSelf | ( | CHuiGc & | aGc, |
const TRect & | aDisplayRect | |||
) | const [virtual] |
From CHuiVisual. Overridden by subclasses to draw the content of the visual. By default DrawSelf does not draw anything.
IMPORT_C void | ExpandRectWithContent | ( | TRect & | aRect | ) | const [virtual] |
Expands the dirty region of the visual depending on the content of the visual. This includes any brushes attached to the visual. Used during dirty region reporting.
TRect & aRect | Dirty region. |
IMPORT_C void | FillWeightsL | ( | THuiGridDimension | aDim, |
TInt | aCount, | |||
const THuiMetric & | aWeight | |||
) |
Sets the number and weights of blocks in this grid layout in the direction of the specified dimension. Each block's weight will be set to equal the supplied value, the result of which is that all blocks will be equally spaced, whatever the units.
This API could be useful if then subsequent calls to ReplaceWeightL are made to change specific values, depending on how many of the values are different.
Calling this with aCount set to 0 will clear all of the existing weights in the direction of the specified dimension.
this is the same as using metrics with unit type EHuiUnitWeight.
THuiGridDimension aDim | the dimension along which to fill |
TInt aCount | The number of lines of blocks to fill |
const THuiMetric & aWeight | the weights to be used for all blocks |
IMPORT_C CHuiVisual * | FindTag | ( | const TDesC8 & | aTag | ) | [virtual] |
From CHuiVisual. Finds a visual whose tag descriptor contains a specific tag. Checks self first, then looks through the child visuals.
CHuiLayout::FindTag() extends upon the basic implementation in CHuiVisual::FindTag() by adding recursive visual hierarchy searching.
CHuiVisual::Tag() CHuiVisual::SetTagL() CHuiVisual::IsTagged() CHuiVisual::FindTag()
const TDesC8 & aTag | Tag to look for. If this tag is found as a part of a visual's colon-separated tag descriptor, it is treated as a match and the visual is returned. The tag to look for cannot contain separator characters (:). |
IMPORT_C void | GetClassName | ( | TDes & | aName | ) | const [virtual] |
Returns the name of the class.
TDes & aName | Name of the visual class. |
IMPORT_C void | GetInstanceName | ( | TDes & | aName | ) | const [virtual] |
TDes & aName |
IMPORT_C void | InsertWeightL | ( | THuiGridDimension | aDim, |
const THuiMetric & | aWeight, | |||
TInt | aPos | |||
) |
Add a new line of blocks to this grid layout at the specified position in the direciton of the specified dimension. It will have the supplied weight. In the case of proportional weights, the effect of this will be to cause the other blocks to resize according to the new total weight. It will also mean that many child visuals will now occupy different blocks within the grid according to how the blocks wrap.
will leave if the specified position is greater than the number of objects currently in the array, so check first by calling Count
THuiGridDimension aDim | the dimension to which the weight corresponds |
const THuiMetric & aWeight | the weight to be used for the block in the specified dimension, replacing any previously existing weight for that block |
TInt aPos | the index of the block |
IMPORT_C TUint | LayoutModeFlags | ( | THuiGridDimension | aDim | ) |
Return flag(s) which alter the children's pixel error distribution within the grid layout.
THuiGridDimension aDim | the dimension to return the flags for. |
IMPORT_C void | NotifySkinChangedL | ( | ) | [virtual] |
Notifies children of the change in the environment's skin.
IMPORT_C TPoint | OrdinalToBlock | ( | TInt | aOrdinal | ) | const |
Calculates the (x,y) position of a child in the grid. Returns the block position, where block (0, 0) is in the top left corner (top right corner when the layout is mirrored).
TInt aOrdinal | Ordinal of a child. |
IMPORT_C TBool | PrepareDrawL | ( | ) | [virtual] |
From CHuiVisual. Prepares all children of this layout for drawing. The preparation is done in drawing order.
Actually this default implementation is not leaving, since it traps the prepare errors inside and handles the errors by calling the visual owners "prepare draw failed" -callback.
TReal32 | ProportionalInnerOuterPadding | ( | THuiGridDimension | aDim, |
TReal32 | aInnerPadPos, | |||
TReal32 | aOuterPadPos | |||
) | const [private] |
Calculate inner/outer distribution of padding. Interpolates between the previously calculated positions for inner padding and outer padding of the child, according to the proportion between inner and outer padding size.
THuiGridDimension aDim | the dimension along which to calculate |
TReal32 aInnerPadPos | the calculated position if inner padding is applied |
TReal32 aOuterPadPos | the calculated position if outer padding is applied |
IMPORT_C void | RemoveAndDestroyAllD | ( | ) | [virtual] |
From CHuiVisual. Removes this layout from its owner and and destroys the layout. Also removes the entire hierarchy of child visuals and destroys all of them.
IMPORT_C void | RemoveWeightL | ( | THuiGridDimension | aDim, |
TInt | aPos | |||
) |
Remove a line of blocks from this grid layout at the specified position in the specified dimension. In the case of proportional weights, the effect of this will be to cause the other blocks to resize according to the new total weight. It will also mean that many child visuals will now occupy different blocks within the grid according to how the blocks wrap.
THuiGridDimension aDim | the dimension to which the weight corresponds |
TInt aPos | the index of the cell |
IMPORT_C void | ReplaceWeightL | ( | THuiGridDimension | aDim, |
const THuiMetric & | aWeight, | |||
TInt | aPos | |||
) |
Sets the weight of a specific line of blocks in this grid layout, in the direction of the supplied dimension. In the case of proportional weights, the effect of this will be to cause the other blocks to resize according to the new total weight.
THuiGridDimension aDim | the dimension to which the weight corresponds |
const THuiMetric & aWeight | the weight to be used for the block in the specified dimension, replacing any previously existing weight for that cell |
TInt aPos | the index of the cell |
IMPORT_C void | ReportChanged | ( | ) | [virtual] |
From CHuiVisual. Called to inform the display that a dirty region has to be defined.
Forward the notification request to all the child visuals. Scrolling causes changed reports from the layout itself.
IMPORT_C void | SetColumnsL | ( | TInt | aColumnCount | ) |
Sets the number of columns in this grid layout. All weights are set to 1 (ie. each column is of an equal width).
TInt aColumnCount | The number of columns. |
IMPORT_C void | SetColumnsL | ( | const RArray< TInt > & | aWeights | ) |
Sets the number and weights of columns in this grid layout. The caller specifies an array of relative weights to use for each column. Weights can be any integer, ie a column of weight 30 would be twice the width of a column of weight 15.
this is equivalent to using metrics with unit type EHuiUnitWeight.
IMPORT_C void | SetExpanding | ( | TInt | aFlags | ) |
Sets the expansion flags to the given bitfield, made up of bits from CHuiLayout::TExpansionFlags.
With EExpandVertically, the filling starts from top left corner (right if mirrored) and a row is filled full before moving to the next row. If there are more items than rows*colums, they are layouted accordingly below the grid content area.
With EExpandHorizontally, the filling starts from top left corner (right if mirrored) and a column is filled full before moving to the next column. If there are more items than rows*colums, they are layouted accordingly on the right side (left if mirrored) of the content area of the grid.
TInt aFlags | Determines the expansion direction. |
IMPORT_C void | SetLayoutModeFlags | ( | THuiGridDimension | aDim, |
TUint | aGridLayoutModeFlags | |||
) |
Sets flag(s) which alter the children's pixel error distribution within the grid layout.
This method allows the client to force all items in the grid layout to be the same pixel size. The floating point error that this introduces is distributed between the various paddings of the layout.
iGridLayout->SetLayoutModeFlags(EHuiGridRow, EHuiGridAdjustOuterPadding);
Note that some flags are mutually exclusive, and will clear some existing flags if set.
THuiGridDimension aDim | the dimension to which the given flag(s) affect. |
TUint aGridLayoutModeFlags | Flags to be set or cleared |
IMPORT_C void | SetPos | ( | const THuiRealPoint & | aPos, |
TInt | aTransitionTime = 0 | |||
) | [virtual] |
From CHuiVisual. Sets the position of the layout.
const THuiRealPoint & aPos | Target position, in the local coordinate system as defined by the parent layout (or the display, if there is no parent). |
TInt aTransitionTime = 0 | Transition time in milliseconds. |
IMPORT_C void | SetRowsL | ( | TInt | aRowCount | ) |
Sets the number of rows in this grid layout. All weights are set to 1 (ie. each column is of an equal height).
TInt aRowCount | The number of rows. |
IMPORT_C void | SetRowsL | ( | const RArray< TInt > & | aWeights | ) |
Sets the number and weights of rows in this grid layout. The caller specifies an array of relative weights to use for each row. Weights can be any integer, ie a row of weight 30 would be twice the height of a row of weight 15.
this is the same as using metrics with unit type EHuiUnitWeight.
IMPORT_C void | SetSessionId | ( | TInt | aSessionId | ) |
Sets the session id for object.
TInt aSessionId |
IMPORT_C void | SetSize | ( | const THuiRealSize & | aSize, |
TInt | aTransitionTime = 0 | |||
) | [virtual] |
From CHuiVisual. Change the size of the layout. Children's positions and sizes are updated accordingly. Each layout class is responsible for determining how to update children's layout.
const THuiRealSize & aSize | Size to set the layout to. |
TInt aTransitionTime = 0 |
IMPORT_C void | UpdateChildrenLayout | ( | TInt | aTransitionTime = 0 | ) | [virtual] |
From CHuiVisual. Update the layout of all children. Subclasses can call this to recalculate the layout of all children.
TInt aTransitionTime = 0 | Time for layout transition. |
TBool | UseRightToLeftFillingOrder | ( | ) | const [private] |
Checks if the grid filling order is from top right corner instead the top left (default)
IMPORT_C CHuiVisual & | Visual | ( | TInt | aIndex | ) | const [virtual] |
From CHuiVisual. Returns a child visual.
TInt aIndex | Index of the child visual. |
IMPORT_C void | VisualExtension | ( | const TUid & | aExtensionUid, |
TAny ** | aExtensionParams | |||
) | [virtual] |
! From HuiVisual
IMPORT_C THuiMetric | Weight | ( | THuiGridDimension | aDim, |
TInt | aPos | |||
) | const |
Returns the weight of a specific line of blocks in this grid layout, in the specified dimension.
THuiGridDimension aDim | the dimension to which the weight corresponds |
TInt aPos | the index of the cell |
void | WeightFromMetric | ( | THuiGridDimension | aDim, |
THuiMetric & | aMetric, | |||
TReal32 & | aWeight, | |||
TInt & | aPix | |||
) | const [private] |
Retrieve the weight and pixel size from a metric. Returns one or the other depending on what type the metric is. Zeroes unused params.
THuiGridDimension aDim | the dimension along which to calculate |
THuiMetric & aMetric | The metric to examine |
TReal32 & aWeight | Contains weight from metric. |
TInt & aPix | Contains pixel size from metric. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.