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:
Paul Cornett 2007-04-26 05:22:09 +00:00
parent aa34396cb2
commit 82008f15b7
5 changed files with 24 additions and 63 deletions

View File

@ -378,6 +378,8 @@ protected:
// should be called from OnInternalIdle() if it's overridden
void GTKUpdateCursor();
void ConstrainSize();
private:
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };

View File

@ -334,15 +334,7 @@ void wxFrame::GtkOnSize()
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
importantly) m_mainWidget */
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;
ConstrainSize();
if (m_mainWidget)
{

View File

@ -237,15 +237,7 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag
}
*/
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;
ConstrainSize();
if ((m_x != -1) || (m_y != -1))
{

View File

@ -857,23 +857,7 @@ void wxTopLevelWindowGTK::GTKDoSetSize(int width, int height)
if ( height != -1 )
m_height = height;
// 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
#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__
ConstrainSize();
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
importantly) m_mainWidget */
int minWidth = GetMinWidth(),
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;
ConstrainSize();
if (m_mainWidget)
{

View File

@ -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 )
{
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)
m_height = height;
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;
ConstrainSize();
#if wxUSE_TOOLBAR_NATIVE
if (wxDynamicCast(GetParent(), wxToolBar))