From b21f4960b13ad92398975de63e3a3f1de8536e52 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 31 Oct 2006 23:14:28 +0000 Subject: [PATCH] Return SetSizeHints() in wxWindow to its former life but still recommend to use SetMinSize() and SetMaxSize(). I've already purged wxWidgets of any use of this function internally, but others may use it still. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/window.tex | 9 +++++++-- include/wx/window.h | 15 ++++++++------- src/common/wincmn.cpp | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index 1a2965ae21..7b639b37a0 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -3299,8 +3299,13 @@ implements the following methods:\par \membersection{wxWindow::SetSizeHints}\label{wxwindowsetsizehints} -This method does nothing for a normal wxWindow and is only kept -for backwards compatibility. The actual implementation is in +Use of this function for windows which are not toplevel windows +(such as wxDialog or wxFrame) is discouraged. Please use +\helpref{SetMinSize}{wxwindowsetminsize} and \helpref{SetMaxSize}{wxwindowsetmaxsize} +instead. + +\wxheading{See also} + \helpref{wxTopLevelWindow::SetSizeHints}{wxtoplevelwindowsetsizehints}. diff --git a/include/wx/window.h b/include/wx/window.h index 3d39594bc4..ee574b4482 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -383,8 +383,11 @@ public: virtual void FitInside(); - // Methods for setting size hints. This is only used - // for toplevel windows. + // SetSizeHints is actually for setting the size hints + // for the wxTLW for a Window Manager - hence the name - + // and it is therefore overridden in wxTLW to do that. + // In wxWindow(Base), it has (unfortunately) been abused + // to mean the same as SetMinSize() and SetMaxSize(). virtual void SetSizeHints( int minW, int minH, int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, @@ -396,11 +399,9 @@ public: const wxSize& incSize=wxDefaultSize) { DoSetSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y, incSize.x, incSize.y); } - virtual void DoSetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), - int WXUNUSED(maxW), int WXUNUSED(maxH), - int WXUNUSED(incW), int WXUNUSED(incH) ) - { - } + virtual void DoSetSizeHints( int minW, int minH, + int maxW, int maxH, + int incW, int incH ); // Methods for setting virtual size hints // FIXME: What are virtual size hints? diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index e37d4f0897..66570d7882 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -660,6 +660,21 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant ) SetFont(font); } +void wxWindowBase::DoSetSizeHints( int minW, int minH, + int maxW, int maxH, + int incW, int incH ) +{ + wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) && + (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH), + _T("min width/height must be less than max width/height!") ); + + m_minWidth = minW; + m_maxWidth = maxW; + m_minHeight = minH; + m_maxHeight = maxH; +} + + void wxWindowBase::SetVirtualSizeHints( int minW, int minH, int maxW, int maxH ) { -- 2.45.2