concentrating content and structure region calculations
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -579,18 +579,21 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
||||
{
|
||||
UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes,typeUInt32) ;
|
||||
Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
|
||||
wxRect r( newRect.left , newRect.top , newRect.right - newRect.left , newRect.bottom - newRect.top ) ;
|
||||
|
||||
if ( (attributes & kWindowBoundsChangeSizeChanged) || (attributes & kWindowBoundsChangeOriginChanged) )
|
||||
{
|
||||
// all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
|
||||
int left , top , right , bottom ;
|
||||
toplevelWindow->MacGetContentAreaInset( left , top , right , bottom ) ;
|
||||
wxRect r( newRect.left - left , newRect.top - top ,
|
||||
newRect.right - newRect.left + left + right , newRect.bottom - newRect.top + top + bottom ) ;
|
||||
// this is a EVT_SIZING not a EVT_SIZE type !
|
||||
wxSizeEvent wxevent( r , toplevelWindow->GetId() ) ;
|
||||
wxevent.SetEventObject( toplevelWindow ) ;
|
||||
wxRect adjustR = r ;
|
||||
if ( toplevelWindow->GetEventHandler()->ProcessEvent(wxevent) )
|
||||
{
|
||||
adjustR = wxevent.GetRect() ;
|
||||
}
|
||||
|
||||
if ( toplevelWindow->GetMaxWidth() != -1 && adjustR.GetWidth() > toplevelWindow->GetMaxWidth() )
|
||||
adjustR.SetWidth( toplevelWindow->GetMaxWidth() ) ;
|
||||
if ( toplevelWindow->GetMaxHeight() != -1 && adjustR.GetHeight() > toplevelWindow->GetMaxHeight() )
|
||||
@@ -599,7 +602,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
||||
adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ;
|
||||
if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() )
|
||||
adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ;
|
||||
Rect adjustedRect = { adjustR.y , adjustR.x , adjustR.y + adjustR.height , adjustR.x + adjustR.width } ;
|
||||
Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height + bottom , adjustR.x + adjustR.width + right } ;
|
||||
if ( !EqualRect( &newRect , &adjustedRect ) )
|
||||
cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ;
|
||||
}
|
||||
@@ -717,6 +720,8 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
||||
// init our fields
|
||||
Init();
|
||||
|
||||
style = style & ~wxFRAME_SHAPED ;
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
SetName(name);
|
||||
@@ -1073,6 +1078,19 @@ bool wxTopLevelWindowMac::Show(bool show)
|
||||
|
||||
// we are still using coordinates of the content view, todo switch to structure bounds
|
||||
|
||||
void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
|
||||
{
|
||||
Rect content ;
|
||||
Rect structure ;
|
||||
GetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &structure ) ;
|
||||
GetWindowBounds( (WindowRef) m_macWindow, kWindowContentRgn , &content ) ;
|
||||
|
||||
left = content.left - structure.left ;
|
||||
top = content.top - structure.top ;
|
||||
right = structure.right - content.right ;
|
||||
bottom = structure.bottom - content.bottom ;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
Rect bounds = { y , x , y + height , x + width } ;
|
||||
|
@@ -1132,6 +1132,30 @@ void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const
|
||||
if ( y ) *y = y1 ;
|
||||
}
|
||||
|
||||
void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
|
||||
{
|
||||
RgnHandle rgn = NewRgn() ;
|
||||
Rect content ;
|
||||
if ( GetControlRegion( (ControlRef) m_macControl , kControlContentMetaPart , rgn ) == noErr )
|
||||
{
|
||||
GetRegionBounds( rgn , &content ) ;
|
||||
DisposeRgn( rgn ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetControlBounds( (ControlRef) m_macControl , &content ) ;
|
||||
}
|
||||
Rect structure ;
|
||||
GetControlBounds( (ControlRef) m_macControl , &structure ) ;
|
||||
#if !TARGET_API_MAC_OSX
|
||||
OffsetRect( &content , -structure.left , -structure.top ) ;
|
||||
#endif
|
||||
left = content.left - structure.left ;
|
||||
top = content.top - structure.top ;
|
||||
right = structure.right - content.right ;
|
||||
bottom = structure.bottom - content.bottom ;
|
||||
}
|
||||
|
||||
wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const
|
||||
{
|
||||
wxSize sizeTotal = size;
|
||||
|
Reference in New Issue
Block a user