Made wxLayoutAlgorithm more general (copes with nested sash windows)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -199,18 +199,41 @@ bool wxLayoutAlgorithm::LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* r)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Layout algorithm for normal frame. mainWindow gets what's left over.
|
||||
bool wxLayoutAlgorithm::LayoutFrame(wxFrame* frame, wxWindow* mainWindow)
|
||||
// Layout algorithm for any window. mainWindow gets what's left over.
|
||||
bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
|
||||
{
|
||||
int cw, ch;
|
||||
frame->GetClientSize(& cw, & ch);
|
||||
// Test if the parent is a sash window, and if so,
|
||||
// reduce the available space to allow space for any active edges.
|
||||
|
||||
wxRect rect(0, 0, cw, ch);
|
||||
int leftMargin = 0, rightMargin = 0, topMargin = 0, bottomMargin = 0;
|
||||
if (parent->IsKindOf(CLASSINFO(wxSashWindow)))
|
||||
{
|
||||
wxSashWindow* sashWindow = (wxSashWindow*) parent;
|
||||
|
||||
leftMargin = sashWindow->GetExtraBorderSize();
|
||||
rightMargin = sashWindow->GetExtraBorderSize();
|
||||
topMargin = sashWindow->GetExtraBorderSize();
|
||||
bottomMargin = sashWindow->GetExtraBorderSize();
|
||||
|
||||
if (sashWindow->GetSashVisible(wxSASH_LEFT))
|
||||
leftMargin += sashWindow->GetDefaultBorderSize();
|
||||
if (sashWindow->GetSashVisible(wxSASH_RIGHT))
|
||||
rightMargin += sashWindow->GetDefaultBorderSize();
|
||||
if (sashWindow->GetSashVisible(wxSASH_TOP))
|
||||
topMargin += sashWindow->GetDefaultBorderSize();
|
||||
if (sashWindow->GetSashVisible(wxSASH_BOTTOM))
|
||||
bottomMargin += sashWindow->GetDefaultBorderSize();
|
||||
}
|
||||
|
||||
int cw, ch;
|
||||
parent->GetClientSize(& cw, & ch);
|
||||
|
||||
wxRect rect(leftMargin, topMargin, cw - leftMargin - rightMargin, ch - topMargin - bottomMargin);
|
||||
|
||||
wxCalculateLayoutEvent event;
|
||||
event.SetRect(rect);
|
||||
|
||||
wxNode* node = frame->GetChildren().First();
|
||||
wxNode* node = parent->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = (wxWindow*) node->Data();
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "wx/string.h"
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/sashwin.h"
|
||||
#include "wx/laywin.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSashWindow, wxWindow)
|
||||
@@ -533,7 +534,7 @@ void wxSashWindow::SizeWindows()
|
||||
int cw, ch;
|
||||
GetClientSize(&cw, &ch);
|
||||
|
||||
if (GetChildren().Number() > 0)
|
||||
if (GetChildren().Number() == 1)
|
||||
{
|
||||
wxWindow* child = (wxWindow*) (GetChildren().First()->Data());
|
||||
|
||||
@@ -574,6 +575,16 @@ void wxSashWindow::SizeWindows()
|
||||
|
||||
child->SetSize(x, y, width, height);
|
||||
}
|
||||
else if (GetChildren().Number() > 1)
|
||||
{
|
||||
// Perhaps multiple children are themselves sash windows.
|
||||
// TODO: this doesn't really work because the subwindows sizes/positions
|
||||
// must be set to leave a gap for the parent's sash (hit-test and decorations).
|
||||
// Perhaps we can allow for this within LayoutWindow, testing whether the parent
|
||||
// is a sash window, and if so, allowing some space for the edges.
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutWindow(this);
|
||||
}
|
||||
|
||||
wxClientDC dc(this);
|
||||
DrawBorders(dc);
|
||||
|
Reference in New Issue
Block a user