Add support for stretchable spaces to wxToolBar.

Stretchable spaces consume all extra toolbar space not allocated to the fixed
size items. They can in particular be used to right-align (some) toolbar tools.

Add and document the new API, change the sample to show it and implement it
for MSW, GTK and OS X/Cocoa.

Also refactor MSW background erasing/repainting code to avoid duplicated calls
to DrawThemeBackground(), call it from a new helper MSWEraseRect() function.

Note that we may want to add support for "invisible" separators, IOW
non-stretchable spaces. This could be easily done for MSW after the changes in
this commit and is supported natively by GTK+ and Cocoa so implementing this
would be trivial if there is any interest.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-12-10 03:04:19 +00:00
parent 0b83552acf
commit cc26010927
9 changed files with 374 additions and 185 deletions

View File

@@ -228,10 +228,27 @@ public:
platform so it can be a vertical line (MSW, some versions of GTK) or
just an empty space or something else.
@see AddTool(), SetToolSeparation()
@see AddTool(), SetToolSeparation(), AddStretchableSpace()
*/
virtual wxToolBarToolBase* AddSeparator();
/**
Adds a stretchable space to the toolbar.
Any space not taken up by the fixed items (all items except for
stretchable spaces) is distributed in equal measure between the
stretchable spaces in the toolbar. The most common use for this method
is to add a single stretchable space before the items which should be
right-aligned in the toolbar, but more exotic possibilities are
possible, e.g. a stretchable space may be added in the beginning and
the end of the toolbar to centre all toolbar items.
@see AddTool(), AddSeparator(), InsertStretchableSpace()
@since 2.9.1
*/
wxToolBarToolBase *AddStretchableSpace();
//@{
/**
Adds a tool to the toolbar.
@@ -525,6 +542,17 @@ public:
*/
virtual wxToolBarToolBase* InsertSeparator(size_t pos);
/**
Inserts a stretchable space at the given position.
See AddStretchableSpace() for details about stretchable spaces.
@see InsertTool(), InsertSeparator()
@since 2.9.1
*/
wxToolBarToolBase *InsertStretchableSpace(size_t pos);
//@{
/**
Inserts the tool with the specified attributes into the toolbar at the