#include "wx/wxprec.h"
-#include "wx/dc.h"
-
#ifdef __BORLANDC__
#pragma hdrstop
#endif
+#if wxUSE_GRAPHICS_CONTEXT
+
+#include "wx/dc.h"
+
#ifndef WX_PRECOMP
#include "wx/image.h"
#include "wx/window.h"
#include "wx/module.h"
#endif
-#ifdef __WXGTK__
-#include <gtk/gtk.h>
-#endif
-
#include "wx/graphics.h"
#include "wx/rawbmp.h"
-#if wxUSE_GRAPHICS_CONTEXT
-
#include <vector>
using namespace std;
#include <cairo.h>
#ifdef __WXGTK__
-#include "wx/gtk/win_gtk.h"
#include <gtk/gtk.h>
#include "wx/fontutil.h"
#endif
// the rest is done using Pango layouts
#elif defined(__WXMAC__)
cairo_set_font_face(ctext, m_font);
+ cairo_set_font_size(ctext, m_size );
#else
cairo_select_font_face(ctext, m_fontName, m_slant, m_weights );
cairo_set_font_size(ctext, m_size );
: wxGraphicsContext(renderer)
{
#ifdef __WXGTK__
+#if wxUSE_NEW_DC
+ wxGTKImplDC *impldc = (wxGTKImplDC*) dc.GetImpl();
+ Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
+#else
Init( gdk_cairo_create( dc.m_window ) );
#endif
+#endif
#ifdef __WXMAC__
int width, height;
dc.GetSize( &width, &height );
#ifdef __WXGTK__
// something along these lines (copied from dcclient)
- GtkWidget *widget = window->m_wxwindow;
-
// Some controls don't have m_wxwindow - like wxStaticBox, but the user
// code should still be able to create wxClientDCs for them, so we will
// use the parent window here then.
- if ( !widget )
+ if (window->m_wxwindow == NULL)
{
window = window->GetParent();
- widget = window->m_wxwindow;
}
- wxASSERT_MSG( widget, wxT("wxCairoContext needs a widget") );
+ wxASSERT_MSG( window->m_wxwindow, wxT("wxCairoContext needs a widget") );
- wxPizza *pizza = WX_PIZZA( widget );
- GdkDrawable* drawable = pizza->m_backing_window;
- Init( gdk_cairo_create( drawable ) ) ;
+ Init(gdk_cairo_create(window->GTKGetDrawingWindow()));
#endif
}
while (ri)
{
path.AddRectangle(ri.GetX(), ri.GetY(), ri.GetW(), ri.GetH());
- ri++;
+ ++ri;
}
// Put it in the context
return;
#ifdef __WXGTK__
- const wxCharBuffer data = wxConvUTF8.cWC2MB( str );
+ const wxCharBuffer data = str.utf8_str();
if ( !data )
return;
size_t datalen = strlen(data);
PangoLayout *layout = pango_cairo_create_layout (m_context);
pango_layout_set_font_description( layout, ((wxCairoFontData*)m_font.GetRefData())->GetFont());
- const wxCharBuffer data = wxConvUTF8.cWC2MB( str );
+ const wxCharBuffer data = str.utf8_str();
if ( !data )
{
return;
{
cairo_font_extents_t fe;
cairo_font_extents(m_context, &fe);
+
+ // some backends have negative descents
+
+ if ( fe.descent < 0 )
+ fe.descent = -fe.descent;
+
+ if ( fe.height < (fe.ascent + fe.descent ) )
+ {
+ // some backends are broken re height ... (eg currently ATSUI)
+ fe.height = fe.ascent + fe.descent;
+ }
if (height)
*height = fe.height;
IMPLEMENT_DYNAMIC_CLASS(wxCairoRenderer,wxGraphicsRenderer)
static wxCairoRenderer gs_cairoGraphicsRenderer;
+// temporary hack to allow creating a cairo context on any platform
+extern wxGraphicsRenderer* gCairoRenderer;
+wxGraphicsRenderer* gCairoRenderer = &gs_cairoGraphicsRenderer;
#ifdef __WXGTK__
wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer()