Merge branch 'tlw-layout'
Make wxTLW::Layout() do the right thing and resize the only child to fit the entire TLW client area. See https://github.com/wxWidgets/wxWidgets/pull/1496
This commit is contained in:
@@ -116,4 +116,9 @@ some simple explanations of things.
|
|||||||
the constraints algorithm is run. The @c Layout() method is what is called by
|
the constraints algorithm is run. The @c Layout() method is what is called by
|
||||||
the default @c EVT_SIZE handler for container windows.
|
the default @c EVT_SIZE handler for container windows.
|
||||||
|
|
||||||
|
@li wxTopLevelWindow::Layout(): this overridden version does the same thing as
|
||||||
|
the base wxWindow::Layout() except, for convenience, it will also resize
|
||||||
|
the only child of the top-level window to cover its entire client area if
|
||||||
|
there is no sizer associated with the window. Note that this only happens
|
||||||
|
if there is exactly one child.
|
||||||
*/
|
*/
|
||||||
|
@@ -276,9 +276,13 @@ public:
|
|||||||
virtual bool IsTopNavigationDomain(NavigationKind kind) const wxOVERRIDE;
|
virtual bool IsTopNavigationDomain(NavigationKind kind) const wxOVERRIDE;
|
||||||
virtual bool IsVisible() const { return IsShown(); }
|
virtual bool IsVisible() const { return IsShown(); }
|
||||||
|
|
||||||
|
// override to do TLW-specific layout: we resize our unique child to fill
|
||||||
|
// the entire client area
|
||||||
|
virtual bool Layout() wxOVERRIDE;
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCloseWindow(wxCloseEvent& event);
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); }
|
void OnSize(wxSizeEvent& WXUNUSED(event)) { Layout(); }
|
||||||
|
|
||||||
// Get rect to be used to center top-level children
|
// Get rect to be used to center top-level children
|
||||||
virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
|
virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
|
||||||
@@ -326,9 +330,8 @@ protected:
|
|||||||
// send the iconize event, return true if processed
|
// send the iconize event, return true if processed
|
||||||
bool SendIconizeEvent(bool iconized = true);
|
bool SendIconizeEvent(bool iconized = true);
|
||||||
|
|
||||||
// do TLW-specific layout: we resize our unique child to fill the entire
|
// this method is only kept for compatibility, call Layout() instead.
|
||||||
// client area
|
void DoLayout() { Layout(); }
|
||||||
void DoLayout();
|
|
||||||
|
|
||||||
static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
|
static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
|
||||||
static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
|
static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
|
||||||
|
@@ -283,8 +283,20 @@ public:
|
|||||||
bool IsUsingNativeDecorations() const;
|
bool IsUsingNativeDecorations() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
|
Lays out the children using the window sizer or resizes the only child
|
||||||
called automatically when the window is resized.
|
of the window to cover its entire area.
|
||||||
|
|
||||||
|
This class overrides the base class Layout() method to check if this
|
||||||
|
window contains exactly one child -- which is commonly the case, with
|
||||||
|
wxPanel being often created as the only child of wxTopLevelWindow --
|
||||||
|
and, if this is the case, resizes this child window to cover the entire
|
||||||
|
client area.
|
||||||
|
|
||||||
|
Note that if you associate a sizer with this window, the sizer takes
|
||||||
|
precedence and the only-child-resizing is only used as fallback.
|
||||||
|
|
||||||
|
@returns @false if nothing was done because the window doesn't have
|
||||||
|
neither a sizer nor a single child, @true otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool Layout();
|
virtual bool Layout();
|
||||||
|
|
||||||
|
@@ -3445,15 +3445,20 @@ public:
|
|||||||
void SetConstraints(wxLayoutConstraints* constraints);
|
void SetConstraints(wxLayoutConstraints* constraints);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Invokes the constraint-based layout algorithm or the sizer-based algorithm
|
Lays out the children of this window using the associated sizer.
|
||||||
for this window.
|
|
||||||
|
|
||||||
This function does not get called automatically when the window is resized
|
If a sizer hadn't been associated with this window (see SetSizer()),
|
||||||
because lots of windows deriving from wxWindow does not need this functionality.
|
this function doesn't do anything, unless this is a top level window
|
||||||
If you want to have Layout() called automatically, you should derive
|
(see wxTopLevelWindow::Layout()).
|
||||||
from wxPanel (see wxPanel::Layout).
|
|
||||||
|
Note that this method is called automatically when the window size
|
||||||
|
changes if it has the associated sizer (or if SetAutoLayout() with
|
||||||
|
@true argument had been explicitly called), ensuring that it is always
|
||||||
|
laid out correctly.
|
||||||
|
|
||||||
@see @ref overview_windowsizing
|
@see @ref overview_windowsizing
|
||||||
|
|
||||||
|
@returns Always returns @true, the return value is not useful.
|
||||||
*/
|
*/
|
||||||
virtual bool Layout();
|
virtual bool Layout();
|
||||||
|
|
||||||
|
@@ -465,7 +465,7 @@ void wxFrameBase::SetStatusBar(wxStatusBar *statBar)
|
|||||||
{
|
{
|
||||||
PositionStatusBar();
|
PositionStatusBar();
|
||||||
|
|
||||||
DoLayout();
|
Layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,19 +597,19 @@ void wxFrameBase::SetToolBar(wxToolBar *toolbar)
|
|||||||
m_frameToolBar = toolbar;
|
m_frameToolBar = toolbar;
|
||||||
PositionToolBar();
|
PositionToolBar();
|
||||||
}
|
}
|
||||||
//else: tricky: do not reset m_frameToolBar yet as otherwise DoLayout()
|
//else: tricky: do not reset m_frameToolBar yet as otherwise Layout()
|
||||||
// wouldn't recognize the (still existing) toolbar as one of our
|
// wouldn't recognize the (still existing) toolbar as one of our
|
||||||
// bars and wouldn't layout the single child of the frame correctly
|
// bars and wouldn't layout the single child of the frame correctly
|
||||||
|
|
||||||
|
|
||||||
// and this is even more tricky: we want DoLayout() to recognize the
|
// and this is even more tricky: we want Layout() to recognize the
|
||||||
// old toolbar for the purpose of not counting it among our non-bar
|
// old toolbar for the purpose of not counting it among our non-bar
|
||||||
// children but we don't want to reserve any more space for it so we
|
// children but we don't want to reserve any more space for it so we
|
||||||
// temporarily hide it
|
// temporarily hide it
|
||||||
if ( m_frameToolBar )
|
if ( m_frameToolBar )
|
||||||
m_frameToolBar->Hide();
|
m_frameToolBar->Hide();
|
||||||
|
|
||||||
DoLayout();
|
Layout();
|
||||||
|
|
||||||
if ( m_frameToolBar )
|
if ( m_frameToolBar )
|
||||||
m_frameToolBar->Show();
|
m_frameToolBar->Show();
|
||||||
|
@@ -411,20 +411,20 @@ bool wxTopLevelWindowBase::IsTopNavigationDomain(NavigationKind kind) const
|
|||||||
|
|
||||||
// default resizing behaviour - if only ONE subwindow, resize to fill the
|
// default resizing behaviour - if only ONE subwindow, resize to fill the
|
||||||
// whole client area
|
// whole client area
|
||||||
void wxTopLevelWindowBase::DoLayout()
|
bool wxTopLevelWindowBase::Layout()
|
||||||
{
|
{
|
||||||
// We are called during the window destruction several times, e.g. as
|
// We are called during the window destruction several times, e.g. as
|
||||||
// wxFrame tries to adjust to its tool/status bars disappearing. But
|
// wxFrame tries to adjust to its tool/status bars disappearing. But
|
||||||
// actually doing the layout is pretty useless in this case as the window
|
// actually doing the layout is pretty useless in this case as the window
|
||||||
// will disappear anyhow -- so just don't bother.
|
// will disappear anyhow -- so just don't bother.
|
||||||
if ( IsBeingDeleted() )
|
if ( IsBeingDeleted() )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
// if we're using constraints or sizers - do use them
|
// if we're using constraints or sizers - do use them
|
||||||
if ( GetAutoLayout() )
|
if ( GetAutoLayout() )
|
||||||
{
|
{
|
||||||
Layout();
|
return wxNonOwnedWindow::Layout();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -443,7 +443,7 @@ void wxTopLevelWindowBase::DoLayout()
|
|||||||
{
|
{
|
||||||
if ( child )
|
if ( child )
|
||||||
{
|
{
|
||||||
return; // it's our second subwindow - nothing to do
|
return false; // it's our second subwindow - nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
child = win;
|
child = win;
|
||||||
@@ -458,8 +458,12 @@ void wxTopLevelWindowBase::DoLayout()
|
|||||||
DoGetClientSize(&clientW, &clientH);
|
DoGetClientSize(&clientW, &clientH);
|
||||||
|
|
||||||
child->SetSize(0, 0, clientW, clientH);
|
child->SetSize(0, 0, clientW, clientH);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default implementation for the close window event.
|
// The default implementation for the close window event.
|
||||||
|
@@ -929,7 +929,7 @@ bool wxWizard::DoLayoutAdaptation()
|
|||||||
wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows);
|
wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows);
|
||||||
|
|
||||||
// Size event doesn't get sent soon enough on wxGTK
|
// Size event doesn't get sent soon enough on wxGTK
|
||||||
DoLayout();
|
Layout();
|
||||||
|
|
||||||
SetLayoutAdaptationDone(true);
|
SetLayoutAdaptationDone(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user