replace 5 copies of size constraining code with one function
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -378,6 +378,8 @@ protected:
|
|||||||
// should be called from OnInternalIdle() if it's overridden
|
// should be called from OnInternalIdle() if it's overridden
|
||||||
void GTKUpdateCursor();
|
void GTKUpdateCursor();
|
||||||
|
|
||||||
|
void ConstrainSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
|
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
|
||||||
|
|
||||||
|
@@ -334,15 +334,7 @@ void wxFrame::GtkOnSize()
|
|||||||
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
||||||
importantly) m_mainWidget */
|
importantly) m_mainWidget */
|
||||||
|
|
||||||
int minWidth = GetMinWidth(),
|
ConstrainSize();
|
||||||
minHeight = GetMinHeight(),
|
|
||||||
maxWidth = GetMaxWidth(),
|
|
||||||
maxHeight = GetMaxHeight();
|
|
||||||
|
|
||||||
if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
|
|
||||||
if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
|
|
||||||
if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
|
|
||||||
if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
|
|
||||||
|
|
||||||
if (m_mainWidget)
|
if (m_mainWidget)
|
||||||
{
|
{
|
||||||
|
@@ -237,15 +237,7 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int minWidth = GetMinWidth(),
|
ConstrainSize();
|
||||||
minHeight = GetMinHeight(),
|
|
||||||
maxWidth = GetMaxWidth(),
|
|
||||||
maxHeight = GetMaxHeight();
|
|
||||||
|
|
||||||
if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
|
|
||||||
if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
|
|
||||||
if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
|
|
||||||
if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
|
|
||||||
|
|
||||||
if ((m_x != -1) || (m_y != -1))
|
if ((m_x != -1) || (m_y != -1))
|
||||||
{
|
{
|
||||||
|
@@ -857,23 +857,7 @@ void wxTopLevelWindowGTK::GTKDoSetSize(int width, int height)
|
|||||||
if ( height != -1 )
|
if ( height != -1 )
|
||||||
m_height = height;
|
m_height = height;
|
||||||
|
|
||||||
// GPE's window manager doesn't like size hints at all, esp. when the user
|
ConstrainSize();
|
||||||
// has to use the virtual keyboard, so don't constrain size there
|
|
||||||
#ifndef __WXGPE__
|
|
||||||
int minWidth = GetMinWidth(),
|
|
||||||
minHeight = GetMinHeight(),
|
|
||||||
maxWidth = GetMaxWidth(),
|
|
||||||
maxHeight = GetMaxHeight();
|
|
||||||
|
|
||||||
if ( minWidth != -1 && m_width < minWidth )
|
|
||||||
m_width = minWidth;
|
|
||||||
if ( minHeight != -1 && m_height < minHeight )
|
|
||||||
m_height = minHeight;
|
|
||||||
if ( maxWidth != -1 && m_width > maxWidth )
|
|
||||||
m_width = maxWidth;
|
|
||||||
if ( maxHeight != -1 && m_height > maxHeight )
|
|
||||||
m_height = maxHeight;
|
|
||||||
#endif // __WXGPE__
|
|
||||||
|
|
||||||
if ( m_width != old_width || m_height != old_height )
|
if ( m_width != old_width || m_height != old_height )
|
||||||
{
|
{
|
||||||
@@ -1046,25 +1030,7 @@ void wxTopLevelWindowGTK::GtkOnSize()
|
|||||||
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
||||||
importantly) m_mainWidget */
|
importantly) m_mainWidget */
|
||||||
|
|
||||||
int minWidth = GetMinWidth(),
|
ConstrainSize();
|
||||||
minHeight = GetMinHeight(),
|
|
||||||
maxWidth = GetMaxWidth(),
|
|
||||||
maxHeight = GetMaxHeight();
|
|
||||||
|
|
||||||
#ifdef __WXGPE__
|
|
||||||
// GPE's window manager doesn't like size hints
|
|
||||||
// at all, esp. when the user has to use the
|
|
||||||
// virtual keyboard.
|
|
||||||
minWidth = -1;
|
|
||||||
minHeight = -1;
|
|
||||||
maxWidth = -1;
|
|
||||||
maxHeight = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
|
|
||||||
if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
|
|
||||||
if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
|
|
||||||
if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
|
|
||||||
|
|
||||||
if (m_mainWidget)
|
if (m_mainWidget)
|
||||||
{
|
{
|
||||||
|
@@ -2625,6 +2625,23 @@ void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWindowGTK::ConstrainSize()
|
||||||
|
{
|
||||||
|
#ifdef __WXGPE__
|
||||||
|
// GPE's window manager doesn't like size hints at all, esp. when the user
|
||||||
|
// has to use the virtual keyboard, so don't constrain size there
|
||||||
|
if (!IsTopLevel())
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
const wxSize minSize = GetMinSize();
|
||||||
|
const wxSize maxSize = GetMaxSize();
|
||||||
|
if (minSize.x > 0 && m_width < minSize.x) m_width = minSize.x;
|
||||||
|
if (minSize.y > 0 && m_height < minSize.y) m_height = minSize.y;
|
||||||
|
if (maxSize.x > 0 && m_width > maxSize.x) m_width = maxSize.x;
|
||||||
|
if (maxSize.y > 0 && m_height > maxSize.y) m_height = maxSize.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
||||||
@@ -2657,15 +2674,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
|
|||||||
if (height != -1)
|
if (height != -1)
|
||||||
m_height = height;
|
m_height = height;
|
||||||
|
|
||||||
int minWidth = GetMinWidth(),
|
ConstrainSize();
|
||||||
minHeight = GetMinHeight(),
|
|
||||||
maxWidth = GetMaxWidth(),
|
|
||||||
maxHeight = GetMaxHeight();
|
|
||||||
|
|
||||||
if ((minWidth != -1) && (m_width < minWidth )) m_width = minWidth;
|
|
||||||
if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
|
|
||||||
if ((maxWidth != -1) && (m_width > maxWidth )) m_width = maxWidth;
|
|
||||||
if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
|
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR_NATIVE
|
#if wxUSE_TOOLBAR_NATIVE
|
||||||
if (wxDynamicCast(GetParent(), wxToolBar))
|
if (wxDynamicCast(GetParent(), wxToolBar))
|
||||||
|
Reference in New Issue
Block a user