-void wxWindow::DoMoveWindow(int x, int y, int width, int height)
-{
- DoSetSize( x,y, width, height ) ;
-}
-
-void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
-
- int former_x = m_x ;
- int former_y = m_y ;
- int former_w = m_width ;
- int former_h = m_height ;
-
- int currentX, currentY;
- GetPosition(¤tX, ¤tY);
- int currentW,currentH;
- GetSize(¤tW, ¤tH);
-
- int actualWidth = width;
- int actualHeight = height;
- int actualX = x;
- int actualY = y;
- if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- actualX = currentX;
- if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- actualY = currentY;
- if (width == -1)
- actualWidth = currentW ;
- if (height == -1)
- actualHeight = currentH ;
-
- if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH)
- {
- MacRepositionScrollBars() ; // we might have a real position shift
- return ;
- }
-
- AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
-
-
- bool doMove = false ;
- bool doResize = false ;
-
- if ( actualX != former_x || actualY != former_y )
- {
- doMove = true ;
- }
- if ( actualWidth != former_w || actualHeight != former_h )
- {
- doResize = true ;
- }
-
- if ( doMove || doResize )
- {
- if ( m_macWindowData )
- {
- }
- else
- {
- // erase former position
- {
- wxMacDrawingClientHelper focus( this ) ;
- if ( focus.Ok() )
- {
- Rect clientrect = { 0 , 0 , m_height , m_width } ;
- InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
- }
- }
- }
- m_x = actualX ;
- m_y = actualY ;
- m_width = actualWidth ;
- m_height = actualHeight ;
- if ( m_macWindowData )
- {
- if ( doMove )
- ::MoveWindow(m_macWindowData->m_macWindow, m_x, m_y , false); // don't make frontmost
-
- if ( doResize )
- ::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height , true);
-
- // the OS takes care of invalidating and erasing
-
- if ( IsKindOf( CLASSINFO( wxFrame ) ) )
- {
- wxFrame* frame = (wxFrame*) this ;
- frame->PositionStatusBar();
- frame->PositionToolBar();
- }
- }
- else
- {
- // erase new position
- {
- wxMacDrawingClientHelper focus( this ) ;
- if ( focus.Ok() )
- {
- Rect clientrect = { 0 , 0 , m_height , m_width } ;
- InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
- }
- }
- if ( doMove )
- wxWindow::MacSuperChangedPosition() ; // like this only children will be notified
- }
- MacRepositionScrollBars() ;
- if ( doMove )
- {
- wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event) ;
- }
- if ( doResize )
- {
- MacRepositionScrollBars() ;
- wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- }
+void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
+{
+ int former_x = m_x ;
+ int former_y = m_y ;
+ int former_w = m_width ;
+ int former_h = m_height ;
+
+ int actualWidth = width;
+ int actualHeight = height;
+ int actualX = x;
+ int actualY = y;
+
+ if ((m_minWidth != -1) && (actualWidth < m_minWidth))
+ actualWidth = m_minWidth;
+ if ((m_minHeight != -1) && (actualHeight < m_minHeight))
+ actualHeight = m_minHeight;
+ if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
+ actualWidth = m_maxWidth;
+ if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
+ actualHeight = m_maxHeight;
+
+ bool doMove = false ;
+ bool doResize = false ;
+
+ if ( actualX != former_x || actualY != former_y )
+ {
+ doMove = true ;
+ }
+ if ( actualWidth != former_w || actualHeight != former_h )
+ {
+ doResize = true ;
+ }
+
+ if ( doMove || doResize )
+ {
+ // erase former position
+
+ bool partialRepaint = false ;
+
+ if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
+ {
+ wxPoint oldPos( m_x , m_y ) ;
+ wxPoint newPos( actualX , actualY ) ;
+ MacWindowToRootWindow( &oldPos.x , &oldPos.y ) ;
+ MacWindowToRootWindow( &newPos.x , &newPos.y ) ;
+ if ( oldPos == newPos )
+ {
+ partialRepaint = true ;
+ RgnHandle oldRgn,newRgn,diffRgn ;
+ oldRgn = NewRgn() ;
+ newRgn = NewRgn() ;
+ diffRgn = NewRgn() ;
+ SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ;
+ SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ;
+ DiffRgn( newRgn , oldRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+ DiffRgn( oldRgn , newRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+ DisposeRgn(oldRgn) ;
+ DisposeRgn(newRgn) ;
+ DisposeRgn(diffRgn) ;
+ }
+ }
+
+ if ( !partialRepaint )
+ Refresh() ;
+
+ m_x = actualX ;
+ m_y = actualY ;
+ m_width = actualWidth ;
+ m_height = actualHeight ;
+
+ // update any low-level frame-relative positions
+
+ MacUpdateDimensions() ;
+ // erase new position
+
+ if ( !partialRepaint )
+ Refresh() ;
+ if ( doMove )
+ wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
+
+ MacRepositionScrollBars() ;
+ if ( doMove )
+ {
+ wxPoint point(m_x, m_y);
+ wxMoveEvent event(point, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event) ;
+ }
+ if ( doResize )
+ {
+ MacRepositionScrollBars() ;
+ wxSize size(m_width, m_height);
+ wxSizeEvent event(size, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+ }
+ }
+
+}
+
+// set the size of the window: if the dimensions are positive, just use them,
+// but if any of them is equal to -1, it means that we must find the value for
+// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
+// which case -1 is a valid value for x and y)
+//
+// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
+// the width/height to best suit our contents, otherwise we reuse the current
+// width/height
+void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ // get the current size and position...
+ int currentX, currentY;
+ GetPosition(¤tX, ¤tY);
+
+ int currentW,currentH;
+ GetSize(¤tW, ¤tH);
+
+ // ... and don't do anything (avoiding flicker) if it's already ok
+ if ( x == currentX && y == currentY &&
+ width == currentW && height == currentH )
+ {
+ MacRepositionScrollBars() ; // we might have a real position shift
+ return;
+ }
+
+ if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ x = currentX;
+ if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ y = currentY;
+
+ AdjustForParentClientOrigin(x, y, sizeFlags);
+
+ wxSize size(-1, -1);
+ if ( width == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ {
+ size = DoGetBestSize();
+ width = size.x;
+ }
+ else
+ {
+ // just take the current one
+ width = currentW;
+ }
+ }
+
+ if ( height == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ {
+ if ( size.x == -1 )
+ {
+ size = DoGetBestSize();
+ }
+ //else: already called DoGetBestSize() above
+
+ height = size.y;
+ }
+ else
+ {
+ // just take the current one
+ height = currentH;
+ }
+ }
+
+ DoMoveWindow(x, y, width, height);
+