- }
- }
- EndUpdate( window ) ;
- }
-}
-
-void wxWindow::MacUpdate( EventRecord *ev )
-{
- WindowRef window = (WindowRef) ev->message ;
- wxWindow * win = wxFindWinFromMacWindow( window ) ;
-
- BeginUpdate( window ) ;
- if ( win )
- {
- // if windowshade gives incompatibility , take the follwing out
- #if ! TARGET_CARBON
- if ( !EmptyRgn( window->visRgn ) )
- #endif
- {
- MacRedraw( window->visRgn , ev->when ) ;
- /*
- {
- wxMacDrawingHelper help( this ) ;
- SetOrigin( 0 , 0 ) ;
- UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
- UMAUpdateControls( window , window->visRgn ) ;
- UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ;
- }
- */
- }
- }
- EndUpdate( window ) ;
-}
-
-WindowRef wxWindow::GetMacRootWindow() const
-{
- WindowRef window = NULL ;
- wxWindow *iter = (wxWindow*)this ;
-
- while( iter )
- {
- if ( iter->m_macWindowData )
- return iter->m_macWindowData->m_macWindow ;
-
- iter = iter->GetParent() ;
- }
- wxASSERT_MSG( 1 , "No valid mac root window" ) ;
- return NULL ;
-}
-
-void wxWindow::MacCreateScrollBars( long style )
-{
- wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ;
- bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ;
-
- if ( style & wxVSCROLL )
- {
- m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0),
- wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL);
-// m_vScrollBar->PushEventHandler( this ) ;
- }
- if ( style & wxHSCROLL )
- {
- m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ),
- wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL);
-// m_hScrollBar->PushEventHandler( this ) ;
- }
-
- // because the create does not take into account the client area origin
- MacRepositionScrollBars() ; // we might have a real position shift
-}
-
-void wxWindow::MacRepositionScrollBars()
-{
- bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ;
-
- if ( m_vScrollBar )
- {
- m_vScrollBar->SetSize( m_width-MAC_SCROLLBAR_SIZE, 0, MAC_SCROLLBAR_SIZE, m_height - adjust , wxSIZE_USE_EXISTING);
- }
- if ( m_hScrollBar )
- {
- m_hScrollBar->SetSize( 0 , m_height-MAC_SCROLLBAR_SIZE ,m_width - adjust, MAC_SCROLLBAR_SIZE, wxSIZE_USE_EXISTING);
- }
-}
-
-void wxWindow::MacKeyDown( EventRecord *ev )
-{
-}
-
-
-
-
-ControlHandle wxWindow::MacGetContainerForEmbedding()
-{
- if ( m_macWindowData )
- return m_macWindowData->m_macRootControl ;
- else
- return GetParent()->MacGetContainerForEmbedding() ;
-}
-
-void wxWindow::MacSuperChangedPosition()
-{
- // only window-absolute structures have to be moved i.e. controls
-
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- child->MacSuperChangedPosition() ;
- node = node->Next();
- }
-}
-
-bool wxWindow::MacSetupFocusPort( )
-{
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- GrafPtr port ;
-
- MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
- return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ;
-}
-
-bool wxWindow::MacSetupFocusClientPort( )
-{
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- GrafPtr port ;
-
- MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ;
- return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ;
-}
-
-bool wxWindow::MacSetupDrawingPort( )
-{
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- GrafPtr port ;
-
- MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
- return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ;
-}
-
-bool wxWindow::MacSetupDrawingClientPort( )
-{
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- GrafPtr port ;
-
- MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ;
- return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ;
-}
-
-
-bool wxWindow::MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win )
-{
- if ( window == NULL )
- return false ;
-
- GrafPtr currPort;
- GrafPtr port ;
-
- ::GetPort(&currPort);
- port = UMAGetWindowPort( window) ;
- if (currPort != port )
- ::SetPort(port);
-
- ::SetOrigin(-localOrigin.h, -localOrigin.v);
- return true;
-}
-
-bool wxWindow::MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win )
-{
- if ( window == NULL )
- return false ;
-
- GrafPtr currPort;
- GrafPtr port ;
- ::GetPort(&currPort);
- port = UMAGetWindowPort( window) ;
- if (currPort != port )
- ::SetPort(port);
-
- ::SetOrigin(-localOrigin.h, -localOrigin.v);
- ::ClipRect(&clipRect);
-
- ::PenNormal() ;
- ::RGBBackColor(& win->GetBackgroundColour().GetPixel() ) ;
- ::RGBForeColor(& win->GetForegroundColour().GetPixel() ) ;
- ::BackPat( &qd.white ) ;
- ::UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
- return true;
-}
-
-void wxWindow::MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin)
-{
- if ( m_macWindowData )
- {
- localOrigin->h = 0;
- localOrigin->v = 0;
- clipRect->left = 0;
- clipRect->top = 0;
- clipRect->right = m_width;
- clipRect->bottom = m_height;
- *window = m_macWindowData->m_macWindow ;
- *rootwin = this ;
- }
- else
- {
- wxASSERT( GetParent() != NULL ) ;
- GetParent()->MacGetPortParams( localOrigin , clipRect , window, rootwin) ;
- localOrigin->h += m_x;
- localOrigin->v += m_y;
- OffsetRect(clipRect, -m_x, -m_y);
-
- Rect myClip;
- myClip.left = 0;
- myClip.top = 0;
- myClip.right = m_width;
- myClip.bottom = m_height;
- SectRect(clipRect, &myClip, clipRect);
- }
-}
-
-void wxWindow::MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin )
-{
- int width , height ;
- GetClientSize( &width , &height ) ;
-
- if ( m_macWindowData )
- {
- localOrigin->h = 0;
- localOrigin->v = 0;
- clipRect->left = 0;
- clipRect->top = 0;
- clipRect->right = m_width ;//width;
- clipRect->bottom = m_height ;// height;
- *window = m_macWindowData->m_macWindow ;
- *rootwin = this ;
- }
- else
- {
- wxASSERT( GetParent() != NULL ) ;
-
- GetParent()->MacGetPortClientParams( localOrigin , clipRect , window, rootwin) ;
-
- localOrigin->h += m_x;
- localOrigin->v += m_y;
- OffsetRect(clipRect, -m_x, -m_y);
-
- Rect myClip;
- myClip.left = 0;
- myClip.top = 0;
- myClip.right = width;
- myClip.bottom = height;
- SectRect(clipRect, &myClip, clipRect);
- }
-}
-
-wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow )
-{
- m_ok = false ;
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- m_currentPort = NULL ;
- GetPort( &m_formerPort ) ;
- if ( theWindow )
- {
-
- theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
- m_currentPort = UMAGetWindowPort( window ) ;
- theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ;
- m_ok = true ;
- }
-}
-
-wxMacFocusHelper::~wxMacFocusHelper()
-{
- if ( m_ok )
- {
- SetOrigin( 0 , 0 ) ;
- }
- if ( m_formerPort != m_currentPort )
- SetPort( m_formerPort ) ;
-}
-
-wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow )
-{
- m_ok = false ;
- Point localOrigin ;
- Rect clipRect ;
- WindowRef window ;
- wxWindow *rootwin ;
- m_currentPort = NULL ;
-
- GetPort( &m_formerPort ) ;
- if ( theWindow )
- {
- theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
- m_currentPort = UMAGetWindowPort( window ) ;
- if ( m_formerPort != m_currentPort )
- SetPort( m_currentPort ) ;
- GetPenState( &m_savedPenState ) ;
- theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ;
- m_ok = true ;
- }
-}
-
+
+ event.m_timeStamp = ev->when;
+ event.SetEventObject(this);
+ if ( wxTheApp->s_captureWindow )
+ {
+ int x = event.m_x ;
+ int y = event.m_y ;
+ wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ;
+ event.m_x = x ;
+ event.m_y = y ;
+ wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ;
+ if ( ev->what == mouseUp )
+ {
+ wxTheApp->s_captureWindow = NULL ;
+ if ( wxBusyCursorCount == 0 )
+ {
+ m_cursor.MacInstall() ;
+ }
+ }
+ }
+ else
+ {
+ MacDispatchMouseEvent( event ) ;
+ }
+}
+
+void wxWindowMac::MacMouseDown( EventRecord *ev , short part)
+{
+ MacFireMouseEvent( ev ) ;
+}
+
+void wxWindowMac::MacMouseUp( EventRecord *ev , short part)
+{
+ switch (part)
+ {
+ case inContent:
+ {
+ MacFireMouseEvent( ev ) ;
+ }
+ break ;
+ }
+}
+
+void wxWindowMac::MacMouseMoved( EventRecord *ev , short part)
+{
+ switch (part)
+ {
+ case inContent:
+ {
+ MacFireMouseEvent( ev ) ;
+ }
+ break ;
+ }
+}
+void wxWindowMac::MacActivate( EventRecord *ev , bool inIsActivating )
+{
+ if ( !m_macWindowData->m_macHasReceivedFirstActivate )
+ m_macWindowData->m_macHasReceivedFirstActivate = true ;
+
+ wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
+ event.m_timeStamp = ev->when ;
+ event.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(event);
+
+ Refresh(false) ;
+ UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ;
+// MacUpdateImmediately() ;
+}
+
+void wxWindowMac::MacRedraw( RgnHandle updatergn , long time)
+{
+ // updatergn is always already clipped to our boundaries
+ WindowRef window = GetMacRootWindow() ;
+ // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
+ RgnHandle ownUpdateRgn = NewRgn() ;
+ CopyRgn( updatergn , ownUpdateRgn ) ;
+
+ {
+ wxMacDrawingHelper focus( this ) ; // was client
+ if ( focus.Ok() )
+ {
+ WindowRef window = GetMacRootWindow() ;
+ bool eraseBackground = false ;
+ if ( m_macWindowData )
+ eraseBackground = true ;
+ if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
+ {
+ ::SetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
+ }
+ else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
+ // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
+ // either a non gray background color or a non control window
+
+
+ wxWindowMac* parent = GetParent() ;
+ while( parent )
+ {
+ if ( parent->GetMacRootWindow() != window )
+ {
+ // we are in a different window on the mac system
+ parent = NULL ;
+ break ;
+ }
+
+ if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() )
+ {
+ if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ // if we have any other colours in the hierarchy
+ RGBBackColor( &parent->m_backgroundColour.GetPixel()) ;
+ break ;
+ }
+ // if we have the normal colours in the hierarchy but another control etc. -> use it's background
+ if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
+ {
+ Rect box ;
+ GetRegionBounds( updatergn , &box) ;
+ ::ApplyThemeBackground(kThemeBackgroundTabPane, &box , kThemeStateActive,8,true);
+ break ;
+ }
+ }
+ else
+ {
+ parent = NULL ;
+ break ;
+ }
+ parent = parent->GetParent() ;
+ }
+ if ( !parent )
+ {
+ // if there is nothing special -> use default
+ ::SetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ;
+ }
+ }
+ else
+ {
+ RGBBackColor( &m_backgroundColour.GetPixel()) ;
+ }
+ // subtract all non transparent children from updatergn
+
+ RgnHandle childarea = NewRgn() ;
+ for (wxNode *node = GetChildren().First(); node; node = node->Next())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->Data();
+ // eventually test for transparent windows
+ if ( child->GetMacRootWindow() == window && child->IsShown() )
+ {
+ if ( child->GetBackgroundColour() != m_backgroundColour && !child->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)child)->GetMacControl() )
+ {
+ SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ;
+ }
+ }
+ }
+ DisposeRgn( childarea ) ;
+
+ if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
+ eraseBackground = true ;
+ SetClip( ownUpdateRgn ) ;
+ if ( m_macEraseOnRedraw ) {
+ if ( eraseBackground )
+ {
+ EraseRgn( ownUpdateRgn ) ;
+ }
+ }
+ else {
+ m_macEraseOnRedraw = true ;
+ }
+ }
+
+ {
+ RgnHandle newupdate = NewRgn() ;
+ wxSize point = GetClientSize() ;
+ wxPoint origin = GetClientAreaOrigin() ;
+
+ SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ;
+ SectRgn( newupdate , ownUpdateRgn , newupdate ) ;
+ OffsetRgn( newupdate , -origin.x , -origin.y ) ;
+ m_updateRegion = newupdate ;
+ DisposeRgn( newupdate ) ;
+ }
+
+ MacPaintBorders() ;
+ wxPaintEvent event;
+ event.m_timeStamp = time ;
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+ }
+
+
+ RgnHandle childupdate = NewRgn() ;
+
+ for (wxNode *node = GetChildren().First(); node; node = node->Next())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->Data();
+ SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ SectRgn( childupdate , updatergn , childupdate ) ;
+ OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
+ if ( child->GetMacRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) )
+ {
+ // because dialogs may also be children
+ child->MacRedraw( childupdate , time ) ;
+ }
+ }
+ DisposeRgn( childupdate ) ;
+ // eventually a draw grow box here
+}
+
+void wxWindowMac::MacUpdateImmediately()
+{
+ WindowRef window = GetMacRootWindow() ;
+ if ( window )
+ {
+ wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
+ #if TARGET_CARBON
+ AGAPortHelper help( GetWindowPort(window) ) ;
+ #else
+ AGAPortHelper help( (window) ) ;
+ #endif
+ SetOrigin( 0 , 0 ) ;
+ BeginUpdate( window ) ;
+ if ( win )
+ {
+ RgnHandle region = NewRgn();
+
+ if ( region )
+ {
+ GetPortVisibleRegion( GetWindowPort( window ), region );
+
+ // if windowshade gives incompatibility , take the follwing out
+ if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate )
+ {
+ win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ;
+ }
+ DisposeRgn( region );
+ }
+ }
+ EndUpdate( window ) ;
+ }
+}
+
+void wxWindowMac::MacUpdate( EventRecord *ev )
+{
+ WindowRef window = (WindowRef) ev->message ;
+ wxWindowMac * win = wxFindWinFromMacWindow( window ) ;
+ #if TARGET_CARBON
+ AGAPortHelper help( GetWindowPort(window) ) ;
+ #else
+ AGAPortHelper help( (window) ) ;
+ #endif
+ SetOrigin( 0 , 0 ) ;
+ BeginUpdate( window ) ;
+ if ( win )
+ {
+ RgnHandle region = NewRgn();
+
+ if ( region )
+ {
+ GetPortVisibleRegion( GetWindowPort( window ), region );
+
+ // if windowshade gives incompatibility , take the follwing out
+ if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate )
+ {
+ MacRedraw( region , ev->when ) ;
+ }
+ DisposeRgn( region );
+ }
+ }
+ EndUpdate( window ) ;
+}
+
+WindowRef wxWindowMac::GetMacRootWindow() const
+{
+ wxWindowMac *iter = (wxWindowMac*)this ;
+
+ while( iter )
+ {
+ if ( iter->m_macWindowData )
+ return iter->m_macWindowData->m_macWindow ;
+
+ iter = iter->GetParent() ;
+ }
+ wxASSERT_MSG( 1 , "No valid mac root window" ) ;
+ return NULL ;
+}
+
+void wxWindowMac::MacCreateScrollBars( long style )
+{
+ wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ;
+
+ bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ;
+ int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ;
+ int width, height ;
+ GetClientSize( &width , &height ) ;
+
+ wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
+ wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
+ wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
+ wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
+
+ m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint,
+ vSize , wxVERTICAL);
+
+ if ( style & wxVSCROLL )
+ {
+
+ }
+ else
+ {
+ m_vScrollBar->Show(false) ;
+ }
+ m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint,
+ hSize , wxHORIZONTAL);
+ if ( style & wxHSCROLL )
+ {
+ }
+ else
+ {
+ m_hScrollBar->Show(false) ;
+ }
+
+ // because the create does not take into account the client area origin
+ MacRepositionScrollBars() ; // we might have a real position shift
+}
+
+void wxWindowMac::MacRepositionScrollBars()
+{
+ bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
+ int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ;
+
+ // get real client area
+
+ int width = m_width ;
+ int height = m_height ;
+
+ width -= MacGetLeftBorderSize() + MacGetRightBorderSize();
+ height -= MacGetTopBorderSize() + MacGetBottomBorderSize();
+
+ wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
+ wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
+ wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
+ wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
+
+ int x = 0 ;
+ int y = 0 ;
+ int w = m_width ;
+ int h = m_height ;
+
+ MacClientToRootWindow( &x , &y ) ;
+ MacClientToRootWindow( &w , &h ) ;
+
+ wxWindowMac *iter = (wxWindowMac*)this ;
+
+ int totW = 10000 , totH = 10000;
+ while( iter )
+ {
+ if ( iter->m_macWindowData )
+ {
+ totW = iter->m_width ;
+ totH = iter->m_height ;
+ break ;
+ }
+
+ iter = iter->GetParent() ;
+ }
+
+ if ( x == 0 )
+ {
+ hPoint.x = -1 ;
+ hSize.x += 1 ;
+ }
+ if ( y == 0 )
+ {
+ vPoint.y = -1 ;
+ vSize.y += 1 ;
+ }
+
+ if ( w-x >= totW )
+ {
+ hSize.x += 1 ;
+ vPoint.x += 1 ;
+ }
+
+ if ( h-y >= totH )
+ {
+ vSize.y += 1 ;
+ hPoint.y += 1 ;
+ }
+
+ if ( m_vScrollBar )
+ {
+ m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE);
+ }
+ if ( m_hScrollBar )
+ {
+ m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE);
+ }
+}
+
+void wxWindowMac::MacKeyDown( EventRecord *ev )
+{
+
+}
+
+
+bool wxWindowMac::AcceptsFocus() const
+{
+ return MacCanFocus() && wxWindowBase::AcceptsFocus();
+}
+
+ControlHandle wxWindowMac::MacGetContainerForEmbedding()
+{
+ if ( m_macWindowData )
+ return m_macWindowData->m_macRootControl ;
+ else
+ return GetParent()->MacGetContainerForEmbedding() ;
+}
+
+void wxWindowMac::MacSuperChangedPosition()
+{
+ // only window-absolute structures have to be moved i.e. controls
+
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindowMac *child = (wxWindowMac *)node->Data();
+ child->MacSuperChangedPosition() ;
+ node = node->Next();
+ }
+}
+
+void wxWindowMac::MacTopLevelWindowChangedPosition()
+{
+ // only screen-absolute structures have to be moved i.e. glcanvas
+
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindowMac *child = (wxWindowMac *)node->Data();
+ child->MacTopLevelWindowChangedPosition() ;
+ node = node->Next();
+ }
+}
+
+bool wxWindowMac::MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* win )
+{
+ if ( window == NULL )
+ return false ;
+
+ GrafPtr currPort;
+ GrafPtr port ;
+
+ ::GetPort(&currPort);
+ port = UMAGetWindowPort( window) ;
+ if (currPort != port )
+ ::SetPort(port);
+
+// wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
+ ::SetOrigin(-localOrigin.h, -localOrigin.v);
+ return true;
+}
+
+bool wxWindowMac::MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* win )
+{
+ if ( window == NULL )
+ return false ;
+
+ GrafPtr currPort;
+ GrafPtr port ;
+ ::GetPort(&currPort);
+ port = UMAGetWindowPort( window) ;
+ if (currPort != port )
+ ::SetPort(port);
+// wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
+ ::SetOrigin(-localOrigin.h, -localOrigin.v);
+ ::ClipRect(&clipRect);
+
+ ::PenNormal() ;
+ ::RGBBackColor(& win->GetBackgroundColour().GetPixel() ) ;
+ ::RGBForeColor(& win->GetForegroundColour().GetPixel() ) ;
+ Pattern whiteColor ;
+
+ ::BackPat( GetQDGlobalsWhite( &whiteColor) ) ;
+ ::SetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
+ return true;
+}
+
+void wxWindowMac::MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin)
+{
+ if ( m_macWindowData )
+ {
+ localOrigin->h = 0;
+ localOrigin->v = 0;
+ clipRect->left = 0;
+ clipRect->top = 0;
+ clipRect->right = m_width;
+ clipRect->bottom = m_height;
+ *window = m_macWindowData->m_macWindow ;
+ *rootwin = this ;
+ }
+ else
+ {
+ wxASSERT( GetParent() != NULL ) ;
+ GetParent()->MacGetPortParams( localOrigin , clipRect , window, rootwin) ;
+ localOrigin->h += m_x;
+ localOrigin->v += m_y;
+ OffsetRect(clipRect, -m_x, -m_y);
+
+ Rect myClip;
+ myClip.left = 0;
+ myClip.top = 0;
+ myClip.right = m_width;
+ myClip.bottom = m_height;
+ SectRect(clipRect, &myClip, clipRect);
+ }
+}
+
+void wxWindowMac::MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin )
+{
+// int width , height ;
+// GetClientSize( &width , &height ) ;
+
+ if ( m_macWindowData )
+ {
+ localOrigin->h = 0;
+ localOrigin->v = 0;
+ clipRect->left = 0;
+ clipRect->top = 0;
+ clipRect->right = m_width ;//width;
+ clipRect->bottom = m_height ;// height;
+ *window = m_macWindowData->m_macWindow ;
+ *rootwin = this ;
+ }
+ else
+ {
+ wxASSERT( GetParent() != NULL ) ;
+
+ GetParent()->MacDoGetPortClientParams( localOrigin , clipRect , window, rootwin) ;
+
+ localOrigin->h += m_x;
+ localOrigin->v += m_y;
+ OffsetRect(clipRect, -m_x, -m_y);
+
+ Rect myClip;
+ myClip.left = 0;
+ myClip.top = 0;
+ myClip.right = m_width ;//width;
+ myClip.bottom = m_height ;// height;
+ SectRect(clipRect, &myClip, clipRect);
+ }
+}
+
+void wxWindowMac::MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin )
+{
+ MacDoGetPortClientParams( localOrigin , clipRect , window , rootwin ) ;
+
+ int width , height ;
+ GetClientSize( &width , &height ) ;
+ wxPoint client ;
+ client = GetClientAreaOrigin( ) ;
+
+ localOrigin->h += client.x;
+ localOrigin->v += client.y;
+ OffsetRect(clipRect, -client.x, -client.y);
+
+ Rect myClip;
+ myClip.left = 0;
+ myClip.top = 0;
+ myClip.right = width;
+ myClip.bottom = height;
+ SectRect(clipRect, &myClip, clipRect);
+}
+
+long wxWindowMac::MacGetLeftBorderSize( ) const
+{
+ if( m_macWindowData )
+ return 0 ;
+
+ if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
+ {
+ return 3 ;
+ }
+ else if ( m_windowStyle &wxDOUBLE_BORDER)
+ {
+ return 3 ;
+ }
+ else if (m_windowStyle &wxSIMPLE_BORDER)
+ {
+ return 1 ;
+ }
+ return 0 ;
+}
+
+long wxWindowMac::MacGetRightBorderSize( ) const
+{
+ if( m_macWindowData )
+ return 0 ;
+
+ if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
+ {
+ return 3 ;
+ }
+ else if ( m_windowStyle &wxDOUBLE_BORDER)
+ {
+ return 3 ;
+ }
+ else if (m_windowStyle &wxSIMPLE_BORDER)
+ {
+ return 1 ;
+ }
+ return 0 ;
+}
+
+long wxWindowMac::MacGetTopBorderSize( ) const
+{
+ if( m_macWindowData )
+ return 0 ;
+
+ if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
+ {
+ return 3 ;
+ }
+ else if ( m_windowStyle &wxDOUBLE_BORDER)
+ {
+ return 3 ;
+ }
+ else if (m_windowStyle &wxSIMPLE_BORDER)
+ {
+ return 1 ;
+ }
+ return 0 ;
+}
+
+long wxWindowMac::MacGetBottomBorderSize( ) const
+{
+ if( m_macWindowData )
+ return 0 ;
+
+ if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
+ {
+ return 3 ;
+ }
+ else if ( m_windowStyle &wxDOUBLE_BORDER)
+ {
+ return 3 ;
+ }
+ else if (m_windowStyle &wxSIMPLE_BORDER)
+ {
+ return 1 ;
+ }
+ return 0 ;
+}
+
+long wxWindowMac::MacRemoveBordersFromStyle( long style )
+{
+ return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
+}
+
+
+wxMacDrawingHelper::wxMacDrawingHelper( wxWindowMac * theWindow )
+{
+ m_ok = false ;
+ Point localOrigin ;
+ Rect clipRect ;
+ WindowRef window ;
+ wxWindowMac *rootwin ;
+ m_currentPort = NULL ;
+
+ GetPort( &m_formerPort ) ;
+ if ( theWindow )
+ {
+ theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
+ m_currentPort = UMAGetWindowPort( window ) ;
+ if ( m_formerPort != m_currentPort )
+ SetPort( m_currentPort ) ;
+ GetPenState( &m_savedPenState ) ;
+ theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ;
+ m_ok = true ;
+ }
+}
+