Add support for auto-orientable toolbars to AUI.

Allow wxAUI to change the toolbar orientation depending on where is it docked.
It is also now possible to specify wxAUI_TB_VERTICAL or HORIZONTAL to force
the toolbar to be always oriented in the given sense and to prevent it from
being docked at the sides incompatible with it.

Closes #11712.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-07-23 23:33:10 +00:00
parent 43fd7dbd79
commit e5dcae09e6
6 changed files with 357 additions and 35 deletions

View File

@@ -21,6 +21,7 @@
#include "wx/pen.h"
//class WXDLLIMPEXP_FWD_CORE wxSizerItem;
class wxAuiPaneInfo;
enum wxAuiToolBarStyle
{
@@ -29,9 +30,17 @@ enum wxAuiToolBarStyle
wxAUI_TB_NO_AUTORESIZE = 1 << 2,
wxAUI_TB_GRIPPER = 1 << 3,
wxAUI_TB_OVERFLOW = 1 << 4,
// using this style forces the toolbar to be vertical and
// be only dockable to the left or right sides of the window
// whereas by default it can be horizontal or vertical and
// be docked anywhere
wxAUI_TB_VERTICAL = 1 << 5,
wxAUI_TB_HORZ_LAYOUT = 1 << 6,
// analogous to wxAUI_TB_VERTICAL, but forces the toolbar
// to be horizontal
wxAUI_TB_HORIZONTAL = 1 << 7,
wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT),
wxAUI_ORIENTATION_MASK = (wxAUI_TB_VERTICAL | wxAUI_TB_HORIZONTAL),
wxAUI_TB_DEFAULT_STYLE = 0
};
@@ -564,6 +573,10 @@ public:
void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend,
const wxAuiToolBarItemArray& append);
// get size of hint rectangle for a particular dock location
wxSize GetHintSize(int dock_direction) const;
bool IsPaneValid(const wxAuiPaneInfo& pane) const;
protected:
virtual void OnCustomRender(wxDC& WXUNUSED(dc),
@@ -636,6 +649,14 @@ protected:
bool m_overflow_visible;
long m_style;
bool RealizeHelper(wxClientDC& dc, bool horizontal);
static bool IsPaneValid(long style, const wxAuiPaneInfo& pane);
bool IsPaneValid(long style) const;
void SetArtFlags() const;
wxOrientation m_orientation;
wxSize m_horzHintSize;
wxSize m_vertHintSize;
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiToolBar)
};

View File

@@ -222,6 +222,8 @@ public:
source.window = window;
source.frame = frame;
source.buttons = buttons;
wxCHECK_RET(source.IsValid(),
"window settings and pane settings are incompatible");
// now assign
*this = source;
}
@@ -253,7 +255,15 @@ public:
#ifdef SWIG
%typemap(out) wxAuiPaneInfo& { $result = $self; Py_INCREF($result); }
#endif
wxAuiPaneInfo& Window(wxWindow* w) { window = w; return *this; }
wxAuiPaneInfo& Window(wxWindow* w)
{
wxAuiPaneInfo test(*this);
test.window = w;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; }
wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; }
wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; }
@@ -308,10 +318,14 @@ public:
wxAuiPaneInfo& DefaultPane()
{
state |= optionTopDockable | optionBottomDockable |
wxAuiPaneInfo test(*this);
test.state |= optionTopDockable | optionBottomDockable |
optionLeftDockable | optionRightDockable |
optionFloatable | optionMovable | optionResizable |
optionCaption | optionPaneBorder | buttonClose;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
@@ -334,10 +348,14 @@ public:
wxAuiPaneInfo& SetFlag(int flag, bool option_state)
{
wxAuiPaneInfo test(*this);
if (option_state)
state |= flag;
test.state |= flag;
else
state &= ~flag;
test.state &= ~flag;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
@@ -416,6 +434,8 @@ public:
wxAuiPaneButtonArray buttons; // buttons on the pane
wxRect rect; // current rectangle (populated by wxAUI)
bool IsValid() const;
};