wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) : wxGCDCImpl( owner ) { m_window = window; m_ok = true ; m_window->GetSize( &m_width , &m_height); if ( !m_window->IsShownOnScreen() ) m_width = m_height = 0; CGContextRef cg = (CGContextRef) window->MacGetCGContextRef(); m_release = false; if ( cg == NULL ) { SetGraphicsContext( wxGraphicsContext::Create( window ) ) ; } else { CGContextSaveGState( cg ); m_release = true ; // make sure the context is having its origin at the wx-window coordinates of the // view (read at the top of window.cpp about the differences) if ( window->MacGetLeftBorderSize() != 0 || window->MacGetTopBorderSize() != 0 ) CGContextTranslateCTM( cg , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); } DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; SetBackground(wxBrush(window->GetBackgroundColour(),wxSOLID)); SetFont( window->GetFont() ) ; }
wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { wxASSERT_MSG( window->MacGetCGContextRef() != NULL, wxT("using wxPaintDC without being in a native paint event") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); SetDeviceOrigin( origin.x, origin.y ); DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; }
wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { wxCHECK_RET( window, wxT("invalid window in wxClientDCImpl") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); if ( !m_window->IsShownOnScreen() ) m_width = m_height = 0; SetDeviceOrigin( origin.x, origin.y ); DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; }
void wxDFBDCImpl::DoSetDeviceClippingRegion(const wxRegion& region) { // NB: this can be done because wxDFB only supports rectangular regions wxRect rect = region.AsRect(); // our parameter is in physical coordinates while DoSetClippingRegion() // takes logical ones rect.x = XDEV2LOG(rect.x); rect.y = YDEV2LOG(rect.y); rect.width = XDEV2LOG(rect.width); rect.height = YDEV2LOG(rect.height); DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) : wxGCDCImpl( owner ) { m_window = window; m_ok = true ; m_window->GetSize( &m_width , &m_height); if ( !m_window->IsShownOnScreen() ) m_width = m_height = 0; CGContextRef cg = (CGContextRef) window->MacGetCGContextRef(); m_release = false; if ( cg == NULL ) { SetGraphicsContext( wxGraphicsContext::Create( window ) ) ; m_contentScaleFactor = window->GetContentScaleFactor(); SetDeviceOrigin(-window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize()); } else { // determine content scale CGRect userrect = CGRectMake(0, 0, 10, 10); CGRect devicerect; devicerect = CGContextConvertRectToDeviceSpace(cg, userrect); m_contentScaleFactor = devicerect.size.height / userrect.size.height; CGContextSaveGState( cg ); m_release = true ; // make sure the context is having its origin at the wx-window coordinates of the // view (read at the top of window.cpp about the differences) if ( window->MacGetLeftBorderSize() != 0 || window->MacGetTopBorderSize() != 0 ) CGContextTranslateCTM( cg , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); wxGraphicsContext* context = wxGraphicsContext::CreateFromNative( cg ); context->EnableOffset(true); SetGraphicsContext( context ); } DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; SetBackground(wxBrush(window->GetBackgroundColour(),wxBRUSHSTYLE_SOLID)); SetFont( window->GetFont() ) ; }
void wxClientDCImpl::InitDC() { wxWindowDCImpl::InitDC(); // in wxUniv build we must manually do some DC adjustments usually // performed by Windows for us // // we also need to take the menu/toolbar manually into account under // Windows CE because they're just another control there, not anything // special as usually under Windows #if defined(__WXUNIVERSAL__) || defined(__WXWINCE__) wxPoint ptOrigin = m_window->GetClientAreaOrigin(); if ( ptOrigin.x || ptOrigin.y ) { // no need to shift DC origin if shift is null SetDeviceOrigin(ptOrigin.x, ptOrigin.y); } // clip the DC to avoid overwriting the non client area wxSize size = m_window->GetClientSize(); DoSetClippingRegion(0, 0, size.x, size.y); #endif // __WXUNIVERSAL__ || __WXWINCE__ }