diff --git a/.gitattributes b/.gitattributes index 7c1d8da4e2..cfd90b938c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -688,6 +688,7 @@ docs/xml/lcl/clipbrd.xml svneol=LF#text/xml eol=lf docs/xml/lcl/clistbox.xml svneol=LF#text/xml eol=lf docs/xml/lcl/colorbox.xml svneol=LF#text/xml eol=lf docs/xml/lcl/comctrls.xml svneol=LF#text/xml eol=lf +docs/xml/lcl/comctrls/ttoolbutton.pas svneol=native#text/plain docs/xml/lcl/commctrl.xml svneol=LF#text/xml eol=lf docs/xml/lcl/controls.xml svneol=LF#text/xml eol=lf docs/xml/lcl/customtimer.xml svneol=LF#text/xml eol=lf diff --git a/docs/xml/lcl/comctrls.xml b/docs/xml/lcl/comctrls.xml index 4b86050610..bcf57ee045 100644 --- a/docs/xml/lcl/comctrls.xml +++ b/docs/xml/lcl/comctrls.xml @@ -7088,29 +7088,29 @@ To add, change or delete a column use the Columns property. - - - + Determines the style of the tool buttons. + These are the possible values of Style: + - + The button appears and functions like a normal button. - + Clicking the button toggles the Down property. Once selected, the button remains selected until clicked again. - + The button displays a downwards-pointing arrow (suitable for accessing a drop-down menu). - + The button appears as an empty space on the toolbar (used to separate other controls). - + The button appears as a vertical line on the toolbar (used to separate other controls). @@ -7198,17 +7198,34 @@ To add, change or delete a column use the Columns property. - - - - + TToolbar manages tool buttons and other controls, arranging them in rows and automatically adjusting their sizes and positions. + +

TToolbar is a container for tool buttons (TToolButton). it provides an easy way to arrange and manage visual controls.

+

* All tool buttons on a toolbar maintain a uniform width and height.

+

* Other controls can sit on a toolbar. These controls (which are held in place by invisible tool buttons) maintain a uniform height.

+

* Controls can automatically wrap around and start a new row when they do not fit horizontally on the toolbar.

+

* The Flat property allows the background to show through the toolbar and gives pop-up borders to the tool buttons.

+

* Spaces and dividers (which are in fact specially configured tool buttons) can group controls on the toolbar both visually and functionally.

+

Typically, the tool buttons correspond to items in an application's menu and gives the user more direct access to the application's commands.

+
+ + + +
- - - - + TToolButton is a button control in a TToolBar object. + +

Use TToolButton to implement buttons on a toolbar. While other controls (including TButton and TSpeedButton) can be placed on toolbars, TToolButton utilizes special toolbar features to simplify the configuration of buttons and offers added display options such as pop-up borders and transparency.

+

To place tool buttons on a toolbar at design time, select the toolbar, right-click, and choose New Button.

+
+ + + + + +
@@ -7914,9 +7931,12 @@ To add, change or delete a column use the Columns property. - - - + Determines the style of the tool button. + See TToolButtonStyle for the possible Style values. + + + + @@ -8638,9 +8658,15 @@ To add, change or delete a column use the Columns property. - - - + Lists the tool buttons (TToolButton) in the toolbar. + +

Buttons maintains a list of TToolButton instances. All tool buttons that share a TToolBar parent have the same height and (except for separators and dividers) the same width. Other controls on a toolbar are held in place by invisible separators, which are automatically created and destroyed.

+

To add tool buttons to the toolbar at design time, select the toolbar, right-click, and choose New Button. To create a space (separator) between one button and the next, select New Separator. To create a divider between buttons, add a button and set its Style propery to tbsDivider. Other controls may be added to the toolbar directly from the Component palette.

+
+ + + +
diff --git a/docs/xml/lcl/comctrls/ttoolbutton.pas b/docs/xml/lcl/comctrls/ttoolbutton.pas new file mode 100644 index 0000000000..b3c20000b4 --- /dev/null +++ b/docs/xml/lcl/comctrls/ttoolbutton.pas @@ -0,0 +1,36 @@ +{ To use this example, create a new application and add the example code + to the unit. Remember to add the ComCtls unit in the uses clause. } + +procedure AddButtons(ToolBar: TToolBar; const ButtonCaptions: array of String); +var + i: integer; +begin + for i := 0 to High(ButtonCaptions) do + begin + with TToolButton.Create(ToolBar) do + begin + Parent := ToolBar; + Caption := ButtonCaptions[i]; + if (ButtonCaptions[i] = '|') then + Style := tbsSeparator + else + Style := tbsButton; + AutoSize := True; + end; + end; +end; + + +procedure TForm1.FormCreate(Sender: TObject); +var + ToolBar: TToolBar; +begin + ToolBar := TToolBar.Create(Self); + ToolBar.Parent := Self; + ShowMessage(IntToStr(ToolBar.ButtonCount)); + AddButtons(ToolBar, ['New', 'Save', '|', 'Cut', 'Copy', 'Paste']); + ToolBar.ShowCaptions := True; + ToolBar.Height := 40; + ToolBar.ButtonWidth := 75; + ShowMessage(IntToStr(ToolBar.ButtonCount)); +end;