backport the shrinking embedded controls fix

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45646 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-04-26 00:08:09 +00:00
parent 9503fa830b
commit 3814954344

View File

@@ -606,6 +606,7 @@ static pascal OSStatus ControlToolbarItemHandler( EventHandlerCallRef inCallRef,
item = (ControlToolbarItem*) malloc(sizeof(ControlToolbarItem)) ; item = (ControlToolbarItem*) malloc(sizeof(ControlToolbarItem)) ;
item->toolbarItem = toolbarItem ; item->toolbarItem = toolbarItem ;
item->lastValidSize = wxSize(-1,-1);
item->viewRef = NULL ; item->viewRef = NULL ;
SetEventParameter( inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof( void * ), &item ); SetEventParameter( inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof( void * ), &item );
@@ -680,16 +681,21 @@ static pascal OSStatus ControlToolbarItemHandler( EventHandlerCallRef inCallRef,
wxWindow* wxwindow = wxFindControlFromMacControl(object->viewRef ) ; wxWindow* wxwindow = wxFindControlFromMacControl(object->viewRef ) ;
if ( wxwindow ) if ( wxwindow )
{ {
wxSize sz = wxwindow->GetSize() ; // during toolbar layout the native window sometimes gets negative sizes,
sz.x -= wxwindow->MacGetLeftBorderSize() + wxwindow->MacGetRightBorderSize(); // sometimes it just gets shrunk behind our back, so in order to avoid
sz.y -= wxwindow->MacGetTopBorderSize() + wxwindow->MacGetBottomBorderSize(); // ever shrinking more, once a valid size is captured, we keep it
// during toolbar layout the native window sometimes gets negative sizes
// so we always keep the last valid size here, to make sure we survive the wxSize sz = object->lastValidSize;
// shuffle ... if ( sz.x <= 0 || sz.y <= 0 )
if ( sz.x > 0 && sz.y > 0 ) {
object->lastValidSize = sz ; sz = wxwindow->GetSize() ;
else sz.x -= wxwindow->MacGetLeftBorderSize() + wxwindow->MacGetRightBorderSize();
sz = object->lastValidSize ; sz.y -= wxwindow->MacGetTopBorderSize() + wxwindow->MacGetBottomBorderSize();
if ( sz.x > 0 && sz.y > 0 )
object->lastValidSize = sz ;
else
sz = wxSize(0,0) ;
}
HISize min, max; HISize min, max;
min.width = max.width = sz.x ; min.width = max.width = sz.x ;