BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
EVT_NC_PAINT(wxWindowMac::OnNcPaint)
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
- EVT_PAINT(wxWindowMac::OnPaint)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
END_EVENT_TABLE()
// TODO: REMOVE
MacRepositionScrollBars() ; // we might have a real position shift
+ if (sizeFlags & wxSIZE_FORCE_EVENT)
+ {
+ wxSizeEvent event( wxSize(width,height), GetId() );
+ event.SetEventObject( this );
+ HandleWindowEvent( event );
+ }
+
return;
}
int size = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
- CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
CGContextSaveGState( cgContext );
if ( m_backgroundColour.Ok() )
/*
This function must not change the updatergn !
*/
-bool wxWindowMac::MacDoRedraw( void* updatergnr , long time )
+bool wxWindowMac::MacDoRedraw( long time )
{
bool handled = false ;
-#if wxOSX_USE_CARBON
- Rect updatebounds ;
- RgnHandle updatergn = (RgnHandle) updatergnr ;
- GetRegionBounds( updatergn , &updatebounds ) ;
+
+ wxRegion formerUpdateRgn = m_updateRegion;
+ wxRegion clientUpdateRgn = formerUpdateRgn;
- // wxLogDebug(wxT("update for %s bounds %d, %d, %d, %d"), wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left, updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
+ wxSize sz = GetClientSize() ;
+ wxPoint origin = GetClientAreaOrigin() ;
+
+ clientUpdateRgn.Intersect(origin.x , origin.y , origin.x + sz.x , origin.y + sz.y);
+
+ // first send an erase event to the entire update area
+ {
+ // for the toplevel window this really is the entire area
+ // for all the others only their client area, otherwise they
+ // might be drawing with full alpha and eg put blue into
+ // the grow-box area of a scrolled window (scroll sample)
+ wxDC* dc = new wxWindowDC(this);
+ if ( IsTopLevel() )
+ dc->SetDeviceClippingRegion(formerUpdateRgn);
+ else
+ dc->SetDeviceClippingRegion(clientUpdateRgn);
- if ( !EmptyRgn(updatergn) )
- {
- 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 , updatergn , newupdate ) ;
+ wxEraseEvent eevent( GetId(), dc );
+ eevent.SetEventObject( this );
+ HandleWindowEvent( eevent );
+ delete dc ;
+ }
- // first send an erase event to the entire update area
- {
- // for the toplevel window this really is the entire area
- // for all the others only their client area, otherwise they
- // might be drawing with full alpha and eg put blue into
- // the grow-box area of a scrolled window (scroll sample)
- wxDC* dc = new wxWindowDC(this);
- if ( IsTopLevel() )
- dc->SetDeviceClippingRegion(wxRegion(HIShapeCreateWithQDRgn(updatergn)));
- else
- dc->SetDeviceClippingRegion(wxRegion(HIShapeCreateWithQDRgn(newupdate)));
+ MacPaintGrowBox();
- wxEraseEvent eevent( GetId(), dc );
- eevent.SetEventObject( this );
- HandleWindowEvent( eevent );
- delete dc ;
- }
+ // calculate a client-origin version of the update rgn and set m_updateRegion to that
+ clientUpdateRgn.Offset( -origin.x , -origin.y );
+ m_updateRegion = clientUpdateRgn ;
- MacPaintGrowBox();
+ if ( !m_updateRegion.Empty() )
+ {
+ // paint the window itself
- // calculate a client-origin version of the update rgn and set m_updateRegion to that
- OffsetRgn( newupdate , -origin.x , -origin.y ) ;
- m_updateRegion = wxRegion(HIShapeCreateWithQDRgn(newupdate)) ;
- DisposeRgn( newupdate ) ;
+ wxPaintEvent event(GetId());
+ event.SetTimestamp(time);
+ event.SetEventObject(this);
+ handled = HandleWindowEvent(event);
+ }
- if ( !m_updateRegion.Empty() )
- {
- // paint the window itself
+ m_updateRegion = formerUpdateRgn;
+ return handled;
+}
- wxPaintEvent event;
- event.SetTimestamp(time);
- event.SetEventObject(this);
- HandleWindowEvent(event);
- handled = true ;
- }
+void wxWindowMac::MacPaintChildrenBorders()
+{
+ // now we cannot rely on having its borders drawn by a window itself, as it does not
+ // get the updateRgn wide enough to always do so, so we do it from the parent
+ // this would also be the place to draw any custom backgrounds for native controls
+ // in Composited windowing
+ wxPoint clientOrigin = GetClientAreaOrigin() ;
+
+ wxWindowMac *child;
+ int x, y, w, h;
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ child = node->GetData();
+ if (child == NULL)
+ continue;
+ if (child == m_vScrollBar)
+ continue;
+ if (child == m_hScrollBar)
+ continue;
+ if (child->IsTopLevel())
+ continue;
+ if (!child->IsShown())
+ continue;
- // now we cannot rely on having its borders drawn by a window itself, as it does not
- // get the updateRgn wide enough to always do so, so we do it from the parent
- // this would also be the place to draw any custom backgrounds for native controls
- // in Composited windowing
- wxPoint clientOrigin = GetClientAreaOrigin() ;
+ // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
- wxWindowMac *child;
- int x, y, w, h;
- for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
+ child->GetPosition( &x, &y );
+ child->GetSize( &w, &h );
+
+ if ( m_updateRegion.Contains(clientOrigin.x+x-10, clientOrigin.y+y-10, w+20, h+20) )
{
- child = node->GetData();
- if (child == NULL)
- continue;
- if (child == m_vScrollBar)
- continue;
- if (child == m_hScrollBar)
- continue;
- if (child->IsTopLevel())
- continue;
- if (!child->IsShown())
- continue;
-
- // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
-
- child->GetPosition( &x, &y );
- child->GetSize( &w, &h );
- Rect childRect = { y , x , y + h , x + w } ;
- OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ;
- InsetRect( &childRect , -10 , -10) ;
-
- if ( RectInRgn( &childRect , updatergn ) )
+ // paint custom borders
+ wxNcPaintEvent eventNc( child->GetId() );
+ eventNc.SetEventObject( child );
+ if ( !child->HandleWindowEvent( eventNc ) )
{
- // paint custom borders
- wxNcPaintEvent eventNc( child->GetId() );
- eventNc.SetEventObject( child );
- if ( !child->HandleWindowEvent( eventNc ) )
- {
- child->MacPaintBorders(0, 0) ;
- }
+ child->MacPaintBorders(0, 0) ;
}
}
}
-#endif
- return handled ;
}
}
}
-void wxWindowMac::OnPaint( wxPaintEvent & WXUNUSED(event) )
-{
-#if wxOSX_USE_COCOA_OR_CARBON
- // for native controls: call their native paint method
- if ( !MacIsUserPane() || ( IsTopLevel() && GetBackgroundStyle() == wxBG_STYLE_SYSTEM ) )
- {
- if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL
- && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT )
- CallNextEventHandler(
- (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() ,
- (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
- }
-#endif
-}
-
void wxWindowMac::TriggerScrollEvent( wxEventType WXUNUSED(scrollEvent) )
{
}
return bounds ;
}
-bool wxWindowMac::HandleClicked( double timestampsec )
+bool wxWindowMac::OSXHandleClicked( double timestampsec )
{
return false;
}
wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event )
{
#if wxOSX_USE_COCOA_OR_CARBON
- if ( HandleClicked( GetEventTime((EventRef)event) ) )
+ if ( OSXHandleClicked( GetEventTime((EventRef)event) ) )
return noErr;
return eventNotHandledErr ;
return wxWindowBase::IsShownOnScreen();
}
-bool wxWindowMac::HandleKeyEvent( wxKeyEvent& event )
+bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
{
bool handled = HandleWindowEvent( event ) ;
if ( handled && event.GetSkipped() )