Merge branch 'x11-layout-fix'
See https://github.com/wxWidgets/wxWidgets/pull/1638
This commit is contained in:
@@ -101,9 +101,6 @@ protected:
|
||||
const wxString& label) wxOVERRIDE;
|
||||
|
||||
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
|
||||
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
|
||||
|
||||
// get the bounding rect for the given tool
|
||||
|
@@ -563,33 +563,6 @@ wxSize wxToolBar::DoGetBestClientSize() const
|
||||
return wxSize(m_maxWidth, m_maxHeight);
|
||||
}
|
||||
|
||||
void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int old_width, old_height;
|
||||
GetSize(&old_width, &old_height);
|
||||
|
||||
wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
|
||||
|
||||
// Correct width and height if needed.
|
||||
if ( width == wxDefaultCoord || height == wxDefaultCoord )
|
||||
{
|
||||
int tmp_width, tmp_height;
|
||||
GetSize(&tmp_width, &tmp_height);
|
||||
|
||||
if ( width == wxDefaultCoord )
|
||||
width = tmp_width;
|
||||
if ( height == wxDefaultCoord )
|
||||
height = tmp_height;
|
||||
}
|
||||
|
||||
// We must refresh the frame size when the toolbar changes size
|
||||
// otherwise the toolbar can be shown incorrectly
|
||||
if ( old_width != width || old_height != height )
|
||||
{
|
||||
SendSizeEventToParent();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxToolBar drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -98,6 +98,26 @@ wxEND_EVENT_TABLE()
|
||||
// helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Passing size with a 0 component to X11 functions results in a BadValue X
|
||||
// error, so ensure we never do it by using the smallest valid size instead.
|
||||
inline void EnsureValidXWindowSize(int& x, int& y)
|
||||
{
|
||||
if ( x <= 0 )
|
||||
x = 1;
|
||||
if ( y <= 0 )
|
||||
y = 1;
|
||||
}
|
||||
|
||||
inline void EnsureValidXWindowSize(wxSize& size)
|
||||
{
|
||||
EnsureValidXWindowSize(size.x, size.y);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constructors
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -155,13 +175,8 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
||||
xparent = (Window) parent->X11GetMainWindow();
|
||||
}
|
||||
|
||||
// Size (not including the border) must be nonzero (or a Value error results)!
|
||||
// Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
|
||||
wxSize size2(size);
|
||||
if (size2.x <= 0)
|
||||
size2.x = 20;
|
||||
if (size2.y <= 0)
|
||||
size2.y = 20;
|
||||
EnsureValidXWindowSize(size2);
|
||||
|
||||
wxPoint pos2(pos);
|
||||
if (pos2.x == wxDefaultCoord)
|
||||
@@ -258,10 +273,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
||||
}
|
||||
|
||||
// Make again sure the size is nonzero.
|
||||
if (size2.x <= 0)
|
||||
size2.x = 1;
|
||||
if (size2.y <= 0)
|
||||
size2.y = 1;
|
||||
EnsureValidXWindowSize(size2);
|
||||
|
||||
#if wxUSE_NANOX
|
||||
backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue());
|
||||
@@ -920,16 +932,13 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (width != wxDefaultCoord)
|
||||
{
|
||||
new_w = width;
|
||||
if (new_w <= 0)
|
||||
new_w = 20;
|
||||
}
|
||||
if (height != wxDefaultCoord)
|
||||
{
|
||||
new_h = height;
|
||||
if (new_h <= 0)
|
||||
new_h = 20;
|
||||
}
|
||||
|
||||
EnsureValidXWindowSize(new_w, new_h);
|
||||
DoMoveWindow( new_x, new_y, new_w, new_h );
|
||||
}
|
||||
|
||||
@@ -941,6 +950,7 @@ void wxWindowX11::DoSetClientSize(int width, int height)
|
||||
|
||||
wxCHECK_RET( xwindow, wxT("invalid window") );
|
||||
|
||||
EnsureValidXWindowSize(width, height);
|
||||
XResizeWindow( wxGlobalDisplay(), xwindow, width, height );
|
||||
|
||||
if (m_mainWindow != m_clientWindow)
|
||||
@@ -956,6 +966,7 @@ void wxWindowX11::DoSetClientSize(int width, int height)
|
||||
height -= border.y + border.height;
|
||||
}
|
||||
|
||||
EnsureValidXWindowSize(width, height);
|
||||
XResizeWindow( wxGlobalDisplay(), xwindow, width, height );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user