void wxGCDCImpl::Init(wxGraphicsContext* ctx) { m_ok = false; m_colour = true; m_mm_to_pix_x = mm2pt; m_mm_to_pix_y = mm2pt; m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; m_graphicContext = NULL; if (ctx) SetGraphicsContext(ctx); m_logicalFunctionSupported = true; }
// Create a DC representing the whole screen wxScreenDC::wxScreenDC() { #if wxMAC_USE_CORE_GRAPHICS CGRect cgbounds ; cgbounds = CGDisplayBounds(CGMainDisplayID()); Rect bounds; bounds.top = (short)cgbounds.origin.y; bounds.left = (short)cgbounds.origin.x; bounds.bottom = bounds.top + (short)cgbounds.size.height; bounds.right = bounds.left + (short)cgbounds.size.width; WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow ); ShowWindow((WindowRef)m_overlayWindow); SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) ); m_width = (wxCoord)cgbounds.size.width; m_height = (wxCoord)cgbounds.size.height; #else m_macPort = CreateNewPort() ; GrafPtr port ; GetPort( &port ) ; SetPort( (GrafPtr) m_macPort ) ; Point pt = { 0,0 } ; LocalToGlobal( &pt ) ; SetPort( port ) ; m_macLocalOrigin.x = -pt.h ; m_macLocalOrigin.y = -pt.v ; BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); m_minX = screenBits.bounds.left ; SInt16 height ; GetThemeMenuBarHeight( &height ) ; m_minY = screenBits.bounds.top + height ; m_maxX = screenBits.bounds.right ; m_maxY = screenBits.bounds.bottom ; MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; #endif m_ok = true ; }
wxMetafileDCImpl::wxMetafileDCImpl( wxDC *owner, const wxString& filename, int width, int height, const wxString& WXUNUSED(description) ) : wxGCDCImpl( owner ) { wxASSERT_MSG( width != 0 || height != 0, wxT("no arbitration of metafile size supported") ); wxASSERT_MSG( filename.empty(), wxT("no file based metafile support yet")); m_metaFile = new wxMetaFile( filename ); wxMetafileRefData* metafiledata = new wxMetafileRefData(width, height); m_metaFile->UnRef(); m_metaFile->SetRefData( metafiledata ); SetGraphicsContext( wxGraphicsContext::CreateFromNative(metafiledata->GetContext())); m_ok = (m_graphicContext != NULL) ; SetMapMode( wxMM_TEXT ); }
wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window) : base_type(owner, window) { GtkWidget* widget = window->m_wxwindow; if (widget == NULL) widget = window->m_widget; GdkWindow* gdkWindow = NULL; if (widget) { gdkWindow = gtk_widget_get_window(widget); m_ok = true; } if (gdkWindow) { cairo_t* cr = gdk_cairo_create(gdkWindow); SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr)); GtkAllocation a; gtk_widget_get_allocation(widget, &a); int x, y; if (gtk_widget_get_has_window(widget)) { m_width = gdk_window_get_width(gdkWindow); m_height = gdk_window_get_height(gdkWindow); x = m_width - a.width; y = m_height - a.height; } else { m_width = a.width; m_height = a.height; x = a.x; y = a.y; cairo_rectangle(cr, a.x, a.y, a.width, a.height); cairo_clip(cr); } if (x || y) SetDeviceLocalOrigin(x, y); } }
wxGCDC::wxGCDC(wxGraphicsContext* context) : wxDC( new wxGCDCImpl( this ) ) { SetGraphicsContext(context); }
wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc) : wxDCImpl(owner) { Init(); SetGraphicsContext(wxGraphicsContext::Create(dc)); }
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) : wxDCImpl( owner ) { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); }
wxGCDC::wxGCDC(const wxMemoryDC& dc) { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); }
wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr) : base_type(new wxGTKCairoDCImpl(this)) { cairo_reference(cr); SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr)); }