From 495f877d39b71f9d9d3929da43f19c7aabe6722a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 16 Jul 2004 20:27:09 +0000 Subject: [PATCH] Added notes about the sizer changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 86 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 127b778e20..58cee172d9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -18,7 +18,91 @@ INCOMPATIBLE CHANGES SINCE 2.4.x exists but doesn't do anything any more, this behaviour is default now) ! wxWindow::m_font and m_backgroundColour/m_foregroundColour are no longer - always set, use GetFont(), GetBack/ForegroundColour() to access them + always set, use GetFont(), GetBack/ForegroundColour() to access + them, and they will be dynamically determined if necessary. + + +! The Sizers have had some fundamental internal changes in the 2.5.2 + and 2.5.3 releases intended to make them do more of the "Right + Thing" but also be as backwards compatible as possible. First a bit + about how things used to work: + + * The size that a window had when Add()ed to the sizer was assumed + to be its minimal size, and that size would always be used by + default when calculating layout size and positions, and the + sizer itself would keep track of that minimal size. + + * If the window item was Add()ed with the wxADJUST_MINSIZE flag + then when layout was calculated the item's GetBestSize would be + used to reset the minimal size that the sizer used. + + The main thrust of the new Sizer changes was to make behaviour like + wxADJUST_MINSIZE be the default, and also to push the tracking of + the minimal size to the window itself (since it knows its own needs) + instead of having the sizer take care of it. Consequently these + changes were made: + + * The wxFIXED_MINSIZE flag was added to allow for the old + behaviour. When this flag is used the size a window has when + Add()ed to the sizer will be treated as its minimal size and it + will not be readjusted on each layout. + + * The min size stored in wxWindow and settable with SetSizeHints or + SetMinSize will by default be used by the sizer (if it was set) + as the minimal size of the sizer item. If the minsize was not + set (or was only partially set) then the window's best size is + fetched and it is used instead of (or blended with) the minsize. + wxWindow:GetBestFittingSize was added to facilitate getting the + size to be used by the sizers. + + * The best size of a window is cached so it doesn't need to + recaculated on every layout. wxWindow::InvalidateBestSize was + added and should be called (usually just internally in control + methods) whenever something is done that would make the best + size change. + + * All wxControls were changed to set the minsize to what is passed + to the constructor or Create method, and also to set the real + size of the control to the blending of the minsize and bestsize. + wxWindow::SetBestFittingSize was added to help with this, + although most controls don't need to call it directly because it + is called indirectly via the SetInitialSize called in the base + classes. + + At this time, the only situation known not to work the same as + before is the following: + + win = new SomeWidget(parent); + win->SetSize(SomeNonDefaultSize); + sizer->Add(win); + + In this case the old code would have used the new size as the + minimum, but now the sizer will use the default size as the minimum + rather than the size set later. It is an easy fix though, just move + the specification of the size to the constructor (assuming that + SomeWidget will set its minsize there like the rest of the controls + do) or call SetMinSize instead of SetSize. + + In order to fit well with this new scheme of things, all wxControls + or custom controls should do the following things. (Depending on + how they are used you may also want to do the same thing for + non-control custom windows.) + + * Either override or inherit a meaningful DoGetBestSize method + that calculates whatever size is "best" for the control. Once + that size is calculated then there should normally be a call to + CacheBestSize to save it for later use, unless for some reason + you want the best size to be recalculated on every layout. + + * Any method that changes the attributes of the control such that + the best size will change should call InvalidateBestSize so it + will be recalculated the next time it is needed. + + * The control's constructor and/or Create method should ensure + that the minsize is set to the size passed in, and that the + control is sized to a blending of the min size and best size. + This can be done by calling SetBestFittingSize. + - no initialization/cleanup can be done in wxApp/~wxApp because they are -- 2.45.2