Sign in Join
FPDoc Onlineexperiment

TToolBar.WrapButtons function

Member of TToolBarprotectedIn unit ComCtrls

Calculates sizes and positions for buttons and controls, and handles wrapping to new rows or columns (when enabled).

Declaration

pascal
function WrapButtons(UseSize: Integer; out NewWidth: Integer; 
 out NewHeight: Integer; Simulate: Boolean): Boolean

Arguments

UseSize

Size requested for the tool buttons (height for vertical orientation, width for horizontal orientation).

NewWidth

Returns the new width calculated for the buttons.

NewHeight

Returns the new height calculated for the buttons.

Simulate

True when the tool button sizes are being recalculated but not actually drawn on the control.

Function result

Always returns True in WrapButtons.

Description

WrapButtons is a Boolean function used to resize and position tool buttons and child controls on the tool bar. When Simulate is True, the child control sizes and positions are calculated but not applied to the tool bar. The output parameters NewWidth and NewHeight can be used to return the new size for buttons on the control.

IsVertical determines the layout direction used for the child controls on the tool bar. If IsVertical returns True, controls are positioned from top to bottom with wrapped columns flowing towards the right edge of the control (when enabled in Wrapable). If IsVertical returns False, child controls are positioned horizontally in the direction indicated by UseRightToLeftAlignment with wrapped rows flowing towards the bottom of the control (when enabled).

Use Orientation to specify the preferred orientation for the child controls on the tool bar. tboAutomatic causes the dimensions for the toolbar or its Align setting to be used for the purpose.

WrapButtons examines child controls to determine their sizes and positions on the tool bar. If a child control is not aligned (Align = alNone), it is auto-sized and auto-positioned using Top and Left anchoring. If the child controls is aligned (Align <> alNone), it will be positioned and sized using the LCL layout routines but will not overlap a non-aligned child control.

A child control with its Visible property set to False is not positioned and/or resized in the method.

ButtonWidth and ButtonHeight contain the initial dimensions used for child controls which are not auto-sized. Child controls with AutoSize enabled use the values in their Width or Height properties (depending on Orientation). Tool buttons using divider or separator styles are not resized in the method; they use the Width or Height property (depending on Orientation).

Set Wrapable to True to allow a new row or column to be created when the cumulative width or height needed for child controls is larger than the width or height for the tool bar. Set the Wrap property in a specific tool button to True to force it and subsequent child controls onto a new row or column.

WrapButtons is called from the AlignControls method using the Width or Height needed for the Orientation on the tool bar. It is also called from the CalculatePreferredSize method.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.