From f9b1708cf57d57bc91f4e870a4646efd1f174c3d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 30 Jan 1999 21:37:17 +0000 Subject: [PATCH] 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 --- distrib/msw/gtk.rsp | 1 + docs/latex/wx/clipbrd.tex | 2 +- docs/latex/wx/layalgor.tex | 14 +++++++++++--- docs/latex/wx/tdnd.tex | 2 +- include/wx/generic/laywin.h | 11 +++++++++-- src/generic/laywin.cpp | 33 ++++++++++++++++++++++++++++----- src/generic/sashwin.cpp | 13 ++++++++++++- 7 files changed, 63 insertions(+), 13 deletions(-) diff --git a/distrib/msw/gtk.rsp b/distrib/msw/gtk.rsp index 6cd5f4543d..f7772e4377 100644 --- a/distrib/msw/gtk.rsp +++ b/distrib/msw/gtk.rsp @@ -7,6 +7,7 @@ config.guess config.sub wx-config.in mkinstalldirs +wxGTK.spec docs/gtk/*.html docs/gtk/*.txt diff --git a/docs/latex/wx/clipbrd.tex b/docs/latex/wx/clipbrd.tex index 25c8fe089f..9c6bb2eb95 100644 --- a/docs/latex/wx/clipbrd.tex +++ b/docs/latex/wx/clipbrd.tex @@ -102,7 +102,7 @@ should keep the clipboard open for only a very short time. Returns TRUE on success. This should be tested (as in the sample shown above). -\membersection{wxClipboard::SetData}\label{wxclipboardadddata} +\membersection{wxClipboard::SetData}\label{wxclipboardsetdata} \func{bool}{SetData}{\param{wxDataObject*}{ data}} diff --git a/docs/latex/wx/layalgor.tex b/docs/latex/wx/layalgor.tex index 81c39dfbfa..6b0ff45c75 100644 --- a/docs/latex/wx/layalgor.tex +++ b/docs/latex/wx/layalgor.tex @@ -114,6 +114,14 @@ Default constructor. Destructor. +\membersection{wxLayoutAlgorithm::LayoutFrame}\label{wxlayoutalgorithmlayoutframe} + +\constfunc{bool}{LayoutFrame}{\param{wxFrame* }{frame}, \param{wxWindow*}{ mainWindow = NULL}} + +Lays out the children of a normal frame. {\it mainWindow} is set to occupy the remaining space. + +This function simply calls \helpref{wxLayoutAlgorithm::LayoutWindow}{wxlayoutalgorithmlayoutwindow}. + \membersection{wxLayoutAlgorithm::LayoutMDIFrame}\label{wxlayoutalgorithmlayoutmdiframe} \constfunc{bool}{LayoutMDIFrame}{\param{wxMDIParentFrame* }{frame}, \param{wxRect*}{ rect = NULL}} @@ -123,11 +131,11 @@ given rectangle will be used as a starting point instead of the frame's client a The MDI client window is set to occupy the remaining space. -\membersection{wxLayoutAlgorithm::LayoutFrame}\label{wxlayoutalgorithmlayoutframe} +\membersection{wxLayoutAlgorithm::LayoutWindow}\label{wxlayoutalgorithmlayoutwindow} -\constfunc{bool}{LayoutFrame}{\param{wxFrame* }{frame}, \param{wxWindow*}{ mainWindow = NULL}} +\constfunc{bool}{LayoutWindow}{\param{wxWindow* }{parent}, \param{wxWindow*}{ mainWindow = NULL}} -Lays out the children of a normal frame. +Lays out the children of a normal frame or other window. {\it mainWindow} is set to occupy the remaining space. diff --git a/docs/latex/wx/tdnd.tex b/docs/latex/wx/tdnd.tex index 28c95e0be7..ecdb4cf770 100644 --- a/docs/latex/wx/tdnd.tex +++ b/docs/latex/wx/tdnd.tex @@ -8,7 +8,7 @@ Classes: \helpref{wxDataObject}{wxdataobject}, \helpref{wxFileDropTarget}{wxfiledroptarget} It has to be noted that the API for drag and drop in wxWindows is not -yet finnished which is mostly due to the fact that DnD support under +yet finished which is mostly due to the fact that DnD support under GTK 1.0 is very rudimentary and entirely different from the XDnD protocoll used by GTK 1.2. This also entails that not all of the documentation concerning DnD might be correct and some of the code might get broken diff --git a/include/wx/generic/laywin.h b/include/wx/generic/laywin.h index 49afa3d91b..47182c627c 100644 --- a/include/wx/generic/laywin.h +++ b/include/wx/generic/laywin.h @@ -173,8 +173,15 @@ public: // The MDI client window is sized to whatever's left over. bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = (wxRect*) NULL); - // mainWindow is sized to whatever's left over. - bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL); + // mainWindow is sized to whatever's left over. This function for backward + // compatibility; use LayoutWindow. + bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL) + { + return LayoutWindow(frame, mainWindow); + } + + // mainWindow is sized to whatever's left over. This function for backward + bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL); }; #endif diff --git a/src/generic/laywin.cpp b/src/generic/laywin.cpp index c7d54c931d..6b9ee02ebc 100644 --- a/src/generic/laywin.cpp +++ b/src/generic/laywin.cpp @@ -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) { + // Test if the parent is a sash window, and if so, + // reduce the available space to allow space for any active edges. + + 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; - frame->GetClientSize(& cw, & ch); + parent->GetClientSize(& cw, & ch); - wxRect rect(0, 0, 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(); diff --git a/src/generic/sashwin.cpp b/src/generic/sashwin.cpp index 35dc510806..b079f5c250 100644 --- a/src/generic/sashwin.cpp +++ b/src/generic/sashwin.cpp @@ -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); -- 2.45.2