It also fixes a bug in GetPanePositionsAndSizes where "size" was being incremented by the gripper size (if one was present) irrespective of whether the bar was docked vertically; grippers drawn on the left should not affect layout of controls where the bar is vertically docked (just as grippers drawn on the top should not affect layout of controls when the bar is horizontally docked).
This patch is against 0.9.1 and is available under the wxWidgets license. I hope I've transcribed it right (applies cleanly to a stock build).
Ben - I've updated this since the patch against 0.9.0 I sent you so that DrawGripper now reads from the PaneInfo object that's passed.
- Code: Select all
diff -u -r ../wxaui-0.9.1.orig/include/manager.h ./include/manager.h
--- ../wxaui-0.9.1.orig/include/manager.h 2006-01-10 17:11:39.000000000 +0000
+++ ./include/manager.h 2006-01-10 20:35:23.000000000 +0000
@@ -187,6 +187,7 @@
bool HasMaximizeButton() const { return HasFlag(buttonMaximize); }
bool HasMinimizeButton() const { return HasFlag(buttonMinimize); }
bool HasPinButton() const { return HasFlag(buttonPin); }
+ bool HasGripperTop() const { return HasFlag(optionGripperTop); }
wxPaneInfo& Window(wxWindow* w) { window = w; return *this; }
wxPaneInfo& Name(const wxString& n) { name = n; return *this; }
@@ -220,6 +221,7 @@
wxPaneInfo& CaptionVisible(bool visible = true) { return SetFlag(optionCaption, visible); }
wxPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); }
wxPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); }
+ wxPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); }
wxPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose,
visible); }
wxPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); }
wxPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); }
@@ -295,6 +297,7 @@
optionDestroyOnClose = 1 << 12,
optionToolbar = 1 << 13,
optionActive = 1 << 14,
+ optionGripperTop = 1 << 15,
buttonClose = 1 << 24,
buttonMaximize = 1 << 25,
diff -u -r ../wxaui-0.9.1.orig/src/manager.cpp ./src/manager.cpp
--- ../wxaui-0.9.1.orig/src/manager.cpp 2006-01-10 17:11:39.000000000 +0000
+++ ./src/manager.cpp 2006-01-10 20:45:53.000000000 +0000
@@ -359,22 +359,45 @@
dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height);
- int y = 5;
- while (1)
+ if (!pane.HasGripperTop())
{
- dc.SetPen(m_gripper_pen1);
- dc.DrawPoint(rect.x+3, rect.y+y);
- dc.SetPen(m_gripper_pen2);
- dc.DrawPoint(rect.x+3, rect.y+y+1);
- dc.DrawPoint(rect.x+4, rect.y+y);
- dc.SetPen(m_gripper_pen3);
- dc.DrawPoint(rect.x+5, rect.y+y+1);
- dc.DrawPoint(rect.x+5, rect.y+y+2);
- dc.DrawPoint(rect.x+4, rect.y+y+2);
-
- y += 4;
- if (y > rect.GetHeight()-5)
- break;
+ int y = 5;
+ while (1)
+ {
+ dc.SetPen(m_gripper_pen1);
+ dc.DrawPoint(rect.x+3, rect.y+y);
+ dc.SetPen(m_gripper_pen2);
+ dc.DrawPoint(rect.x+3, rect.y+y+1);
+ dc.DrawPoint(rect.x+4, rect.y+y);
+ dc.SetPen(m_gripper_pen3);
+ dc.DrawPoint(rect.x+5, rect.y+y+1);
+ dc.DrawPoint(rect.x+5, rect.y+y+2);
+ dc.DrawPoint(rect.x+4, rect.y+y+2);
+
+ y += 4;
+ if (y > rect.GetHeight()-5)
+ break;
+ }
+ }
+ else
+ {
+ int x = 5;
+ while (1)
+ {
+ dc.SetPen(m_gripper_pen1);
+ dc.DrawPoint(rect.x+x, rect.y+3);
+ dc.SetPen(m_gripper_pen2);
+ dc.DrawPoint(rect.x+x+1, rect.y+3);
+ dc.DrawPoint(rect.x+x, rect.y+4);
+ dc.SetPen(m_gripper_pen3);
+ dc.DrawPoint(rect.x+x+1, rect.y+5);
+ dc.DrawPoint(rect.x+x+2, rect.y+5);
+ dc.DrawPoint(rect.x+x+2, rect.y+4);
+
+ x += 4;
+ if (x > rect.GetWidth()-5)
+ break;
+ }
}
}
@@ -517,7 +540,12 @@
if (size == wxDefaultSize)
size = m_pane_window->GetSize();
if (pane.HasGripper())
- size.x += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
+ {
+ if (pane.HasGripperTop())
+ size.y += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
+ else
+ size.x += m_owner_mgr->m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);
+ }
SetClientSize(size);
}
@@ -1543,15 +1571,18 @@
if (pane.HasBorder())
size += (pane_border_size*2);
- if (pane.HasGripper())
- size += gripper_size;
if (dock.IsHorizontal())
{
+ if (pane.HasGripper() && !pane.HasGripperTop())
+ size += gripper_size;
size += pane.best_size.x;
}
else
{
+ if (pane.HasGripper() && pane.HasGripperTop())
+ size += gripper_size;
+
if (pane.HasCaption())
size += caption_size;
size += pane.best_size.y;
@@ -1625,7 +1656,10 @@
if (pane.HasGripper())
{
- sizer_item = horz_pane_sizer->Add(gripper_size, 1, 0, wxEXPAND);
+ if (pane.HasGripperTop())
+ sizer_item = vert_pane_sizer ->Add(1, gripper_size, 0, wxEXPAND);
+ else
+ sizer_item = horz_pane_sizer ->Add(gripper_size, 1, 0, wxEXPAND);
part.type = wxDockUIPart::typeGripper;
part.dock = &dock;
diff -u -r ../wxaui-0.9.1.orig/sample/wxauitest.cpp ./sample/wxauitest.cpp
--- ../wxaui-0.9.1.orig/sample/wxauitest.cpp 2006-01-10 17:11:39.000000000 +0000
+++ ./sample/wxauitest.cpp 2006-01-10 20:32:54.000000000 +0000
@@ -703,6 +703,18 @@
tb4->AddTool(101, wxT("Item 8"), tb4_bmp1);
tb4->Realize();
+ // create some toolbars
+ wxToolBar* tb5 = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize,
+ wxTB_FLAT | wxTB_NODIVIDER | wxTB_VERTICAL);+ tb5->SetToolBitmapSize(wxSize(48,48));
+ tb5->AddTool(101, wxT("Test"), wxArtProvider::GetBitmap(wxART_ERROR));
+ tb5->AddSeparator();
+ tb5->AddTool(102, wxT("Test"), wxArtProvider::GetBitmap(wxART_QUESTION));
+ tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_INFORMATION));
+ tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_WARNING));
+ tb5->AddTool(103, wxT("Test"), wxArtProvider::GetBitmap(wxART_MISSING_IMAGE));
+ tb5->Realize();
+
// add a bunch of panes
m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
@@ -794,6 +806,12 @@
ToolbarPane().Top().Row(2).
LeftDockable(false).RightDockable(false));
+ m_mgr.AddPane(tb5, wxPaneInfo().
+ Name(wxT("tb4")).Caption(wxT("Sample Vertical Toolbar")).
+ ToolbarPane().Left().
+ GripperTop().
+ TopDockable(false).BottomDockable(false));
+
m_mgr.AddPane(new wxButton(this, -1, _("Test Button")),
wxPaneInfo().Name(wxT("tb5")).
ToolbarPane().Top().Row(2).Position(1).