diff options
author | nyamatongwe <unknown> | 2011-12-12 17:47:48 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-12-12 17:47:48 +1100 |
commit | a6d786df58e4f1fad37a4a7a44060801cf323f52 (patch) | |
tree | 1a95500615908ebc2dc2529789eb3a4bbf90775b | |
parent | 962ff3562a9ebb3ba11d8c1e340e7a56a8273e06 (diff) | |
download | scintilla-mirror-a6d786df58e4f1fad37a4a7a44060801cf323f52.tar.gz |
On GTK+ 2.x, change SurfaceID from GdkDrawable* to a cairo_t* so that it is
the same as on GTK+ 3.x.
This simplifies compatibility and allows implementing printing on GTK+ 2.x.
-rw-r--r-- | gtk/PlatGTK.cxx | 6 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 14 |
2 files changed, 7 insertions, 13 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index e56847483..f1445afc2 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -346,7 +346,7 @@ void Font::Release() { namespace Scintilla { #endif -// On GTK+ 2.x, SurfaceID is a GdkDrawable* and on GTK+ 3.x, it is a cairo_t* +// SurfaceID is a cairo_t* class SurfaceImpl : public Surface { encodingType et; cairo_t *context; @@ -534,11 +534,7 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(sid); Release(); PLATFORM_ASSERT(wid); -#if GTK_CHECK_VERSION(3,0,0) context = cairo_reference(reinterpret_cast<cairo_t *>(sid)); -#else - context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(sid)); -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); layout = pango_layout_new(pcontext); cairo_set_line_width(context, 1); diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index bd5ef08b4..b7d3fd22a 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1112,18 +1112,12 @@ void ScintillaGTK::SyncPaint(PRectangle rc) { if (PWindow(wText)) { Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (sw) { -#if GTK_CHECK_VERSION(3,0,0) cairo_t *cr = gdk_cairo_create(PWindow(wText)); sw->Init(cr, PWidget(wText)); -#else - sw->Init(PWindow(wText), PWidget(wText)); -#endif Paint(sw, rc); sw->Release(); delete sw; -#if GTK_CHECK_VERSION(3,0,0) cairo_destroy(cr); -#endif } } if (paintState == paintAbandoned) { @@ -2500,10 +2494,12 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os paintingAllText = rcPaint.Contains(rcClient); Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { - surfaceWindow->Init(PWindow(wText), PWidget(wText)); + cairo_t *cr = gdk_cairo_create(PWindow(wText)); + surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow, rcPaint); surfaceWindow->Release(); delete surfaceWindow; + cairo_destroy(cr); } if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace highlight positions @@ -2811,12 +2807,14 @@ gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, Cal try { Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { - surfaceWindow->Init(WindowFromWidget(widget), widget); + cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget)); + surfaceWindow->Init(cr, widget); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage); surfaceWindow->SetDBCSMode(ctip->codePage); ctip->PaintCT(surfaceWindow); surfaceWindow->Release(); delete surfaceWindow; + cairo_destroy(cr); } } catch (...) { // No pointer back to Scintilla to save status |