diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/PlatGTK.cxx | 863 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 59 |
2 files changed, 21 insertions, 901 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 064d5161a..1e36989ad 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -31,9 +31,6 @@ to be used to get the glib libraries for linking, otherwise g_thread_init will fail */ #define USE_LOCK defined(G_THREADS_ENABLED) && !defined(G_THREADS_IMPL_NONE) -/* Use fast way of getting char data on win32 to work around problems - with gdk_string_extents. */ -#define FAST_WAY #include "Converter.h" @@ -43,10 +40,6 @@ #define IS_WIDGET_FOCUSSED(w) (GTK_WIDGET_HAS_FOCUS(w)) #endif -#define USE_CAIRO 1 - -#ifdef USE_CAIRO - static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) { #if GTK_CHECK_VERSION(2,22,0) return gdk_window_create_similar_surface(window, content, width, height); @@ -65,8 +58,6 @@ static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t #endif } -#endif - static GdkWindow *WindowFromWidget(GtkWidget *w) { #if GTK_CHECK_VERSION(3,0,0) return gtk_widget_get_window(w); @@ -75,10 +66,6 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) { #endif } -#ifdef USE_CAIRO -#define DISABLE_GDK_FONT 1 -#endif - #ifdef _MSC_VER // Ignore unreferenced local functions in GTK+ headers #pragma warning(disable: 4505) @@ -147,41 +134,19 @@ class FontHandle { encodingType et; public: int ascent; -#ifndef DISABLE_GDK_FONT - GdkFont *pfont; -#endif PangoFontDescription *pfd; int characterSet; -#ifdef DISABLE_GDK_FONT FontHandle() : et(singleByte), ascent(0), pfd(0), characterSet(-1) { ResetWidths(et); } -#else - FontHandle(GdkFont *pfont_=0) { - et = singleByte; - ascent = 0; - pfont = pfont_; - pfd = 0; - characterSet = -1; - ResetWidths(et); - } -#endif FontHandle(PangoFontDescription *pfd_, int characterSet_) { et = singleByte; ascent = 0; -#ifndef DISABLE_GDK_FONT - pfont = 0; -#endif pfd = pfd_; characterSet = characterSet_; ResetWidths(et); } ~FontHandle() { -#ifndef DISABLE_GDK_FONT - if (pfont) - gdk_font_unref(pfont); - pfont = 0; -#endif if (pfd) pango_font_description_free(pfd); pfd = 0; @@ -319,11 +284,6 @@ void Palette::Allocate(Window &w) { paletteNew[iPal].blue = entries[iPal].desired.GetBlue() * (65535 / 255); paletteNew[iPal].pixel = entries[iPal].desired.AsLong(); } -#ifndef USE_CAIRO - gdk_colormap_alloc_colors(gtk_widget_get_colormap(PWidget(w)), - paletteNew, allocatedLen, FALSE, TRUE, - successPalette); -#endif for (iPal = 0; iPal < used; iPal++) { entries[iPal].allocated.Set(paletteNew[iPal].pixel); } @@ -332,117 +292,6 @@ void Palette::Allocate(Window &w) { #endif } -#ifndef DISABLE_GDK_FONT - -static const char *CharacterSetName(int characterSet) { - switch (characterSet) { - case SC_CHARSET_ANSI: - return "iso8859-*"; - case SC_CHARSET_DEFAULT: - return "iso8859-*"; - case SC_CHARSET_BALTIC: - return "iso8859-13"; - case SC_CHARSET_CHINESEBIG5: - return "*-*"; - case SC_CHARSET_EASTEUROPE: - return "*-2"; - case SC_CHARSET_GB2312: - return "gb2312.1980-*"; - case SC_CHARSET_GREEK: - return "*-7"; - case SC_CHARSET_HANGUL: - return "ksc5601.1987-*"; - case SC_CHARSET_MAC: - return "*-*"; - case SC_CHARSET_OEM: - return "*-*"; - case SC_CHARSET_RUSSIAN: - return "*-r"; - case SC_CHARSET_CYRILLIC: - return "*-cp1251"; - case SC_CHARSET_SHIFTJIS: - return "jisx0208.1983-*"; - case SC_CHARSET_SYMBOL: - return "*-*"; - case SC_CHARSET_TURKISH: - return "*-9"; - case SC_CHARSET_JOHAB: - return "*-*"; - case SC_CHARSET_HEBREW: - return "*-8"; - case SC_CHARSET_ARABIC: - return "*-6"; - case SC_CHARSET_VIETNAMESE: - return "*-*"; - case SC_CHARSET_THAI: - return "iso8859-11"; - case SC_CHARSET_8859_15: - return "iso8859-15"; - default: - return "*-*"; - } -} - -static bool IsDBCSCharacterSet(int characterSet) { - switch (characterSet) { - case SC_CHARSET_GB2312: - case SC_CHARSET_HANGUL: - case SC_CHARSET_SHIFTJIS: - case SC_CHARSET_CHINESEBIG5: - return true; - default: - return false; - } -} - -static void GenerateFontSpecStrings(const char *fontName, int characterSet, - char *foundary, int foundary_len, - char *faceName, int faceName_len, - char *charset, int charset_len) { - // supported font strings include: - // foundary-fontface-isoxxx-x - // fontface-isoxxx-x - // foundary-fontface - // fontface - if (strchr(fontName, '-')) { - char tmp[300]; - char *d1 = NULL, *d2 = NULL, *d3 = NULL; - strncpy(tmp, fontName, sizeof(tmp) - 1); - tmp[sizeof(tmp) - 1] = '\0'; - d1 = strchr(tmp, '-'); - // we know the first dash exists - d2 = strchr(d1 + 1, '-'); - if (d2) - d3 = strchr(d2 + 1, '-'); - if (d3 && d2) { - // foundary-fontface-isoxxx-x - *d2 = '\0'; - foundary[0] = '-'; - foundary[1] = '\0'; - strncpy(faceName, tmp, foundary_len - 1); - strncpy(charset, d2 + 1, charset_len - 1); - } else if (d2) { - // fontface-isoxxx-x - *d1 = '\0'; - strcpy(foundary, "-*-"); - strncpy(faceName, tmp, faceName_len - 1); - strncpy(charset, d1 + 1, charset_len - 1); - } else { - // foundary-fontface - foundary[0] = '-'; - foundary[1] = '\0'; - strncpy(faceName, tmp, faceName_len - 1); - strncpy(charset, CharacterSetName(characterSet), charset_len - 1); - } - } else { - strncpy(foundary, "-*-", foundary_len); - strncpy(faceName, fontName, faceName_len - 1); - strncpy(charset, CharacterSetName(characterSet), charset_len - 1); - } -} - -#endif - static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, float size, int weight, bool italic) { memset(&lf, 0, sizeof(lf)); lf.size = size; @@ -549,176 +398,18 @@ void FontCached::ReleaseId(FontID fid_) { FontMutexUnlock(); } -#ifndef DISABLE_GDK_FONT -static GdkFont *LoadFontOrSet(const char *fontspec, int characterSet) { - if (IsDBCSCharacterSet(characterSet)) { - return gdk_fontset_load(fontspec); - } else { - return gdk_font_load(fontspec); - } -} -#endif - FontID FontCached::CreateNewFont(const FontParameters &fp) { - if (fp.faceName[0] == '!') { - PangoFontDescription *pfd = pango_font_description_new(); - if (pfd) { - pango_font_description_set_family(pfd, fp.faceName+1); - pango_font_description_set_size(pfd, pango_units_from_double(fp.size)); - pango_font_description_set_weight(pfd, static_cast<PangoWeight>(fp.weight)); - pango_font_description_set_style(pfd, fp.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); - return new FontHandle(pfd, fp.characterSet); - } + PangoFontDescription *pfd = pango_font_description_new(); + if (pfd) { + pango_font_description_set_family(pfd, + (fp.faceName[0] == '!') ? fp.faceName+1 : fp.faceName); + pango_font_description_set_size(pfd, pango_units_from_double(fp.size)); + pango_font_description_set_weight(pfd, static_cast<PangoWeight>(fp.weight)); + pango_font_description_set_style(pfd, fp.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); + return new FontHandle(pfd, fp.characterSet); } -#ifndef DISABLE_GDK_FONT - char fontset[1024]; - char fontspec[300]; - char foundary[50]; - char faceName[100]; - char charset[50]; - fontset[0] = '\0'; - fontspec[0] = '\0'; - foundary[0] = '\0'; - faceName[0] = '\0'; - charset[0] = '\0'; - - GdkFont *newid = 0; - // If name of the font begins with a '-', assume, that it is - // a full fontspec. - if (fontName[0] == '-') { - if (strchr(fontName, ',') || IsDBCSCharacterSet(characterSet)) { - newid = gdk_fontset_load(fontName); - } else { - newid = gdk_font_load(fontName); - } - if (!newid) { - // Font not available so substitute a reasonable code font - // iso8859 appears to only allow western characters. - newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*", - characterSet); - } - return new FontHandle(newid); - } - - // it's not a full fontspec, build one. - - // This supports creating a FONT_SET - // in a method that allows us to also set size, slant and - // weight for the fontset. The expected input is multiple - // partial fontspecs seperated by comma - // eg. adobe-courier-iso10646-1,*-courier-iso10646-1,*-*-*-* - if (strchr(fontName, ',')) { - // build a fontspec and use gdk_fontset_load - int remaining = sizeof(fontset); - char fontNameCopy[1024]; - strncpy(fontNameCopy, fontName, sizeof(fontNameCopy) - 1); - char *fn = fontNameCopy; - char *fp = strchr(fn, ','); - for (;;) { - const char *spec = "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s"; - if (fontset[0] != '\0') { - // if this is not the first font in the list, - // append a comma seperator - spec = ",%s%s%s%s-*-*-*-%0d-*-*-*-*-%s"; - } - - if (fp) - *fp = '\0'; // nullify the comma - GenerateFontSpecStrings(fn, characterSet, - foundary, sizeof(foundary), - faceName, sizeof(faceName), - charset, sizeof(charset)); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - spec, - foundary, faceName, - (weight > 400) ? "-bold" : "-medium", - italic ? "-i" : "-r", - size * 10, - charset); - - // if this is the first font in the list, and - // we are doing italic, add an oblique font - // to the list - if (italic && fontset[0] == '\0') { - strncat(fontset, fontspec, remaining - 1); - remaining -= strlen(fontset); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - (weight > 400) ? "-bold" : "-medium", - size * 10, - charset); - } - - strncat(fontset, fontspec, remaining - 1); - remaining -= strlen(fontset); - - if (!fp) - break; - - fn = fp + 1; - fp = strchr(fn, ','); - } - - newid = gdk_fontset_load(fontset); - if (newid) - return new FontHandle(newid); - // if fontset load failed, fall through, we'll use - // the last font entry and continue to try and - // get something that matches - } - - // single fontspec support - - GenerateFontSpecStrings(fontName, characterSet, - foundary, sizeof(foundary), - faceName, sizeof(faceName), - charset, sizeof(charset)); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - (weight > 400) ? "-bold" : "-medium", - italic ? "-i" : "-r", - size * 10, - charset); - newid = LoadFontOrSet(fontspec, characterSet); - if (!newid) { - // some fonts have oblique, not italic - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - (weight > 400) ? "-bold" : "-medium", - italic ? "-o" : "-r", - size * 10, - charset); - newid = LoadFontOrSet(fontspec, characterSet); - } - if (!newid) { - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "-*-*-*-*-*-*-*-%0d-*-*-*-*-%s", - size * 10, - charset); - newid = gdk_font_load(fontspec); - } - if (!newid) { - // Font not available so substitute a reasonable code font - // iso8859 appears to only allow western characters. - newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*", - characterSet); - } - return new FontHandle(newid); -#else return new FontHandle(); -#endif } Font::Font() : fid(0) {} @@ -744,14 +435,8 @@ namespace Scintilla { // On GTK+ 2.x, SurfaceID is a GdkDrawable* and on GTK+ 3.x, it is a cairo_t* class SurfaceImpl : public Surface { encodingType et; -#ifdef USE_CAIRO cairo_t *context; cairo_surface_t *psurf; -#else - GdkDrawable *drawable; - GdkGC *gc; - GdkPixmap *ppixmap; -#endif int x; int y; bool inited; @@ -869,14 +554,8 @@ void SurfaceImpl::SetConverter(int characterSet_) { } SurfaceImpl::SurfaceImpl() : et(singleByte), -#ifdef USE_CAIRO context(0), psurf(0), -#else -drawable(0), -gc(0), -ppixmap(0), -#endif x(0), y(0), inited(false), createdGC(false) , pcontext(0), layout(0), characterSet(-1) { } @@ -887,28 +566,14 @@ SurfaceImpl::~SurfaceImpl() { void SurfaceImpl::Release() { et = singleByte; -#ifndef USE_CAIRO - drawable = 0; -#endif if (createdGC) { createdGC = false; -#ifdef USE_CAIRO cairo_destroy(context); -#else - g_object_unref(gc); -#endif } -#ifdef USE_CAIRO context = 0; if (psurf) cairo_surface_destroy(psurf); psurf = 0; -#else - gc = 0; - if (ppixmap) - g_object_unref(ppixmap); - ppixmap = 0; -#endif if (layout) g_object_unref(layout); layout = 0; @@ -930,7 +595,6 @@ bool SurfaceImpl::Initialised() { void SurfaceImpl::Init(WindowID wid) { Release(); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO #if GTK_CHECK_VERSION(3,0,0) GdkWindow *drawable_ = gtk_widget_get_window(PWidget(wid)); #else @@ -946,7 +610,6 @@ void SurfaceImpl::Init(WindowID wid) { context = cairo_create(psurf); } createdGC = true; -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); @@ -958,24 +621,14 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(sid); Release(); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO #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 -#else - drawable = reinterpret_cast<GdkDrawable *>(sid); - gc = gdk_gc_new(drawable); -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); layout = pango_layout_new(pcontext); -#ifdef USE_CAIRO cairo_set_line_width(context, 1); -#else - // Ask for lines that do not paint the last pixel so is like Win32 - gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); -#endif createdGC = true; inited = true; } @@ -985,27 +638,15 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID Release(); SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO context = cairo_reference(surfImpl->context); -#else - PLATFORM_ASSERT(surfImpl->drawable); - gc = gdk_gc_new(surfImpl->drawable); -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); -#ifdef USE_CAIRO if (height > 0 && width > 0) psurf = CreateSimilarSurface( WindowFromWidget(PWidget(wid)), CAIRO_CONTENT_COLOR_ALPHA, width, height); -#else - if (height > 0 && width > 0) - ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1); - drawable = ppixmap; -#endif -#ifdef USE_CAIRO cairo_destroy(context); context = cairo_create(psurf); cairo_rectangle(context, 0, 0, width, height); @@ -1013,19 +654,12 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID cairo_fill(context); // This produces sharp drawing more similar to GDK: //cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE); -#endif -#ifdef USE_CAIRO cairo_set_line_width(context, 1); -#else - // Ask for lines that do not paint the last pixel so is like Win32 - gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); -#endif createdGC = true; inited = true; } void SurfaceImpl::PenColour(ColourAllocated fore) { -#ifdef USE_CAIRO if (context) { ColourDesired cdFore(fore.AsLong()); cairo_set_source_rgb(context, @@ -1033,13 +667,6 @@ void SurfaceImpl::PenColour(ColourAllocated fore) { cdFore.GetGreen() / 255.0, cdFore.GetBlue() / 255.0); } -#else - if (gc) { - GdkColor co; - co.pixel = fore.AsLong(); - gdk_gc_set_foreground(gc, &co); - } -#endif } int SurfaceImpl::LogPixelsY() { @@ -1056,7 +683,6 @@ void SurfaceImpl::MoveTo(int x_, int y_) { y = y_; } -#ifdef USE_CAIRO static int Delta(int difference) { if (difference < 0) return -1; @@ -1065,10 +691,8 @@ static int Delta(int difference) { else return 0; } -#endif void SurfaceImpl::LineTo(int x_, int y_) { -#ifdef USE_CAIRO // cairo_line_to draws the end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST. // For simple cases, move back one pixel from end. if (context) { @@ -1097,20 +721,12 @@ void SurfaceImpl::LineTo(int x_, int y_) { } cairo_stroke(context); } -#else - if (drawable && gc) { - gdk_draw_line(drawable, gc, - x, y, - x_, y_); - } -#endif x = x_; y = y_; } void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) { -#ifdef USE_CAIRO PenColour(back); cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); for (int i = 1;i < npts;i++) { @@ -1120,73 +736,31 @@ void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - GdkPoint gpts[20]; - if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) { - for (int i = 0;i < npts;i++) { - gpts[i].x = pts[i].x; - gpts[i].y = pts[i].y; - } - PenColour(back); - gdk_draw_polygon(drawable, gc, 1, gpts, npts); - PenColour(fore); - gdk_draw_polygon(drawable, gc, 0, gpts, npts); - } -#endif } void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) { -#ifdef USE_CAIRO if (context) { -#else - if (gc && drawable) { -#endif -#ifdef USE_CAIRO cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1); PenColour(back); cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - PenColour(back); - gdk_draw_rectangle(drawable, gc, 1, - rc.left + 1, rc.top + 1, - rc.right - rc.left - 2, rc.bottom - rc.top - 2); - PenColour(fore); - // The subtraction of 1 off the width and height here shouldn't be needed but - // otherwise a different rectangle is drawn than would be done if the fill parameter == 1 - gdk_draw_rectangle(drawable, gc, 0, - rc.left, rc.top, - rc.right - rc.left - 1, rc.bottom - rc.top - 1); -#endif } } void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) { PenColour(back); -#ifdef USE_CAIRO if (context && (rc.left < maxCoordinate)) { // Protect against out of range cairo_rectangle(context, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); cairo_fill(context); } -#else - if (drawable && (rc.left < maxCoordinate)) { // Protect against out of range - gdk_draw_rectangle(drawable, gc, 1, - rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top); - } -#endif } void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern); -#ifdef USE_CAIRO bool canDraw = surfi.psurf; -#else - bool canDraw = surfi.drawable; -#endif if (canDraw) { // Tile pattern over rectangle // Currently assumes 8x8 pattern @@ -1196,18 +770,9 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat; for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) { int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat; -#ifdef USE_CAIRO cairo_set_source_surface(context, surfi.psurf, xTile, yTile); cairo_rectangle(context, xTile, yTile, widthx, heighty); cairo_fill(context); -#else - gdk_draw_drawable(drawable, - gc, - static_cast<SurfaceImpl &>(surfacePattern).drawable, - 0, 0, - xTile, yTile, - widthx, heighty); -#endif } } } else { @@ -1236,8 +801,6 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl } } -#ifdef USE_CAIRO - static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) { double degrees = M_PI / 180.0; @@ -1254,45 +817,8 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double cairo_close_path(context); } -#else - -// Plot a point into a guint32 buffer symetrically to all 4 qudrants -static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) { - pixels[y*stride+x] = val; - pixels[y*stride+width-1-x] = val; - pixels[(height-1-y)*stride+x] = val; - pixels[(height-1-y)*stride+width-1-x] = val; -} - -static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { - union { - guint8 pixVal[4]; - guint32 val; - } converter; - converter.pixVal[0] = r; - converter.pixVal[1] = g; - converter.pixVal[2] = b; - converter.pixVal[3] = a; - return converter.val; -} - -static unsigned int GetRValue(unsigned int co) { - return (co >> 16) & 0xff; -} - -static unsigned int GetGValue(unsigned int co) { - return (co >> 8) & 0xff; -} - -static unsigned int GetBValue(unsigned int co) { - return co & 0xff; -} - -#endif - void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int flags) { -#ifdef USE_CAIRO if (context && rc.Width() > 0) { ColourDesired cdFill(fill.AsLong()); cairo_set_source_rgba(context, @@ -1318,47 +844,6 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1); cairo_stroke(context); } -#else - if (gc && drawable && rc.Width() > 0) { - int width = rc.Width(); - int height = rc.Height(); - // Ensure not distorted too much by corners when small - cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2); - // Make a 32 bit deep pixbuf with alpha - GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - - guint32 valEmpty = u32FromRGBA(0,0,0,0); - guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()), - GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill); - guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()), - GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline); - guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha)); - int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4; - for (int yr=0; yr<height; yr++) { - for (int xr=0; xr<width; xr++) { - if ((xr==0) || (xr==width-1) || (yr == 0) || (yr == height-1)) { - pixels[yr*stride+xr] = valOutline; - } else { - pixels[yr*stride+xr] = valFill; - } - } - } - for (int c=0;c<cornerSize; c++) { - for (int xr=0;xr<c+1; xr++) { - AllFour(pixels, stride, width, height, xr, c-xr, valEmpty); - } - } - for (int xr=1;xr<cornerSize; xr++) { - AllFour(pixels, stride, width, height, xr, cornerSize-xr, valOutline); - } - - // Draw with alpha - gdk_draw_pixbuf(drawable, gc, pixalpha, - 0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0); - - g_object_unref(pixalpha); - } -#endif } void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { @@ -1369,7 +854,6 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi rc.top += (rc.Height() - height) / 2; rc.bottom = rc.top + height; -#ifdef USE_CAIRO int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); int ucs = stride * height; std::vector<unsigned char> image(ucs); @@ -1390,81 +874,28 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi cairo_fill(context); cairo_surface_destroy(psurf); -#else - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(pixelsImage, - GDK_COLORSPACE_RGB, - TRUE, - 8, - width, - height, - width * 4, - NULL, - NULL); - gdk_draw_pixbuf(drawable, gc, pixbuf, - 0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0); - g_object_unref(pixbuf); -#endif } void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { PenColour(back); -#ifdef USE_CAIRO cairo_arc(context, (rc.left + rc.right) / 2 + 0.5, (rc.top + rc.bottom) / 2 + 0.5, Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*M_PI); cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - gdk_draw_arc(drawable, gc, 1, - rc.left + 1, rc.top + 1, - rc.right - rc.left - 2, rc.bottom - rc.top - 2, - 0, 32767); - - // The subtraction of 1 here is similar to the case for RectangleDraw - PenColour(fore); - gdk_draw_arc(drawable, gc, 0, - rc.left, rc.top, - rc.right - rc.left - 1, rc.bottom - rc.top - 1, - 0, 32767); -#endif } void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource); -#ifdef USE_CAIRO bool canDraw = surfi.psurf; -#else - bool canDraw = surfi.drawable; -#endif if (canDraw) { -#ifdef USE_CAIRO cairo_set_source_surface(context, surfi.psurf, rc.left - from.x, rc.top - from.y); cairo_rectangle(context, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top); cairo_fill(context); -#else - gdk_draw_drawable(drawable, - gc, - static_cast<SurfaceImpl &>(surfaceSource).drawable, - from.x, from.y, - rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top); -#endif } } -#ifndef DISABLE_GDK_FONT -static size_t UTF8Len(char ch) { - unsigned char uch = static_cast<unsigned char>(ch); - if (uch < 0x80) - return 1; - else if (uch < (0x80 + 0x40 + 0x20)) - return 2; - else - return 3; -} -#endif - char *UTF8FromLatin1(const char *s, int &len) { char *utfForm = new char[len*2+1]; size_t lenU = 0; @@ -1517,49 +948,6 @@ static size_t MultiByteLenFromIconv(const Converter &conv, const char *s, size_t return 1; } -#ifndef DISABLE_GDK_FONT -static char *UTF8FromGdkWChar(GdkWChar *wctext, int wclen) { - char *utfForm = new char[wclen*3+1]; // Maximum of 3 UTF-8 bytes per character - size_t lenU = 0; - for (int i = 0; i < wclen && wctext[i]; i++) { - unsigned int uch = wctext[i]; - if (uch < 0x80) { - utfForm[lenU++] = static_cast<char>(uch); - } else if (uch < 0x800) { - utfForm[lenU++] = static_cast<char>(0xC0 | (uch >> 6)); - utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f)); - } else { - utfForm[lenU++] = static_cast<char>(0xE0 | (uch >> 12)); - utfForm[lenU++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f)); - utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f)); - } - } - utfForm[lenU] = '\0'; - return utfForm; -} -#endif - -static char *UTF8FromDBCS(const char *s, int &len) { -#ifndef DISABLE_GDK_FONT - GdkWChar *wctext = new GdkWChar[len + 1]; - GdkWChar *wcp = wctext; - int wclen = gdk_mbstowcs(wcp, s, len); - if (wclen < 1) { - // In the annoying case when non-locale chars in the line. - // e.g. latin1 chars in Japanese locale. - delete []wctext; - return 0; - } - - char *utfForm = UTF8FromGdkWChar(wctext, wclen); - delete []wctext; - len = strlen(utfForm); - return utfForm; -#else - return 0; -#endif -} - static size_t UTF8CharLength(const char *s) { const unsigned char *us = reinterpret_cast<const unsigned char *>(s); unsigned char ch = *us; @@ -1572,18 +960,10 @@ static size_t UTF8CharLength(const char *s) { } } -// On GTK+, wchar_t is 4 bytes - -const int maxLengthTextRun = 10000; - void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore) { PenColour(fore); -#ifdef USE_CAIRO if (context) { -#else - if (gc && drawable) { -#endif XYPOSITION xText = rc.left; if (PFont(font_)->pfd) { char *utfForm = 0; @@ -1594,84 +974,22 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, con SetConverter(PFont(font_)->characterSet); utfForm = UTF8FromIconv(conv, s, len); } - if (!utfForm) { // iconv failed so try DBCS if DBCS mode - if (et == dbcs) { - // Convert to utf8 - utfForm = UTF8FromDBCS(s, len); - } - } - if (!utfForm) { // iconv and DBCS failed so treat as Latin1 + if (!utfForm) { // iconv failed so treat as Latin1 utfForm = UTF8FromLatin1(s, len); } pango_layout_set_text(layout, utfForm, len); } pango_layout_set_font_description(layout, PFont(font_)->pfd); -#ifdef USE_CAIRO pango_cairo_update_layout(context, layout); -#endif #ifdef PANGO_VERSION PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0); #else PangoLayoutLine *pll = pango_layout_get_line(layout,0); #endif -#ifdef USE_CAIRO cairo_move_to(context, xText, ybase); pango_cairo_show_layout_line(context, pll); -#else - gdk_draw_layout_line(drawable, gc, xText, ybase, pll); -#endif delete []utfForm; - return; - } -#ifndef DISABLE_GDK_FONT - // Draw text as a series of segments to avoid limitations in X servers - const int segmentLength = 1000; - bool draw8bit = true; - if (et != singleByte) { - GdkWChar wctext[maxLengthTextRun]; - if (len >= maxLengthTextRun) - len = maxLengthTextRun-1; - int wclen; - if (et == UTF8) { - wclen = UTF16FromUTF8(s, len, - static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1); - } else { // dbcs, so convert using current locale - char sMeasure[maxLengthTextRun]; - memcpy(sMeasure, s, len); - sMeasure[len] = '\0'; - wclen = gdk_mbstowcs( - wctext, sMeasure, maxLengthTextRun - 1); - } - if (wclen > 0) { - draw8bit = false; - wctext[wclen] = L'\0'; - GdkWChar *wcp = wctext; - while ((wclen > 0) && (xText < maxCoordinate)) { - int lenDraw = Platform::Minimum(wclen, segmentLength); - gdk_draw_text_wc(drawable, PFont(font_)->pfont, gc, - xText, ybase, wcp, lenDraw); - wclen -= lenDraw; - if (wclen > 0) { // Avoid next calculation if possible as may be expensive - xText += gdk_text_width_wc(PFont(font_)->pfont, - wcp, lenDraw); - } - wcp += lenDraw; - } - } - } - if (draw8bit) { - while ((len > 0) && (xText < maxCoordinate)) { - int lenDraw = Platform::Minimum(len, segmentLength); - gdk_draw_text(drawable, PFont(font_)->pfont, gc, - xText, ybase, s, lenDraw); - len -= lenDraw; - if (len > 0) { // Avoid next calculation if possible as may be expensive - xText += gdk_text_width(PFont(font_)->pfont, s, lenDraw); - } - s += lenDraw; - } } -#endif } } @@ -1828,59 +1146,6 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION } return; } -#ifndef DISABLE_GDK_FONT - int totalWidth = 0; - GdkFont *gf = PFont(font_)->pfont; - bool measure8bit = true; - if (et != singleByte) { - GdkWChar wctext[maxLengthTextRun]; - if (len >= maxLengthTextRun) - len = maxLengthTextRun-1; - int wclen; - if (et == UTF8) { - wclen = UTF16FromUTF8(s, len, - static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1); - } else { // dbcsMode, so convert using current locale - char sDraw[maxLengthTextRun]; - memcpy(sDraw, s, len); - sDraw[len] = '\0'; - wclen = gdk_mbstowcs( - wctext, sDraw, maxLengthTextRun - 1); - } - if (wclen > 0) { - measure8bit = false; - wctext[wclen] = L'\0'; - // Map widths back to utf-8 or DBCS input string - int i = 0; - for (int iU = 0; iU < wclen; iU++) { - int width = gdk_char_width_wc(gf, wctext[iU]); - totalWidth += width; - int lenChar; - if (et == UTF8) { - lenChar = UTF8Len(s[i]); - } else { - lenChar = mblen(s+i, MB_CUR_MAX); - if (lenChar < 0) - lenChar = 1; - } - while (lenChar--) { - positions[i++] = totalWidth; - } - } - while (i < len) { // In case of problems with lengths - positions[i++] = totalWidth; - } - } - } - if (measure8bit) { - // Either Latin1 or conversion failed so treat as Latin1. - for (int i = 0; i < len; i++) { - int width = gdk_char_width(gf, s[i]); - totalWidth += width; - positions[i] = totalWidth; - } - } -#endif } else { // No font so return an ascending range of values for (int i = 0; i < len; i++) { @@ -1898,15 +1163,11 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (et == UTF8) { pango_layout_set_text(layout, s, len); } else { - if (et == dbcs) { - // Convert to utf8 - utfForm = UTF8FromDBCS(s, len); - } - if (!utfForm) { // DBCS failed so treat as iconv + if (!utfForm) { // use iconv SetConverter(PFont(font_)->characterSet); utfForm = UTF8FromIconv(conv, s, len); } - if (!utfForm) { // g_locale_to_utf8 failed so treat as Latin1 + if (!utfForm) { // iconv failed so treat as Latin1 utfForm = UTF8FromLatin1(s, len); } pango_layout_set_text(layout, utfForm, len); @@ -1920,19 +1181,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { delete []utfForm; return pango_units_to_double(pos.width); } -#ifndef DISABLE_GDK_FONT - if (et == UTF8) { - GdkWChar wctext[maxLengthTextRun]; - size_t wclen = UTF16FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)), - sizeof(wctext) / sizeof(GdkWChar) - 1); - wctext[wclen] = L'\0'; - return gdk_text_width_wc(PFont(font_)->pfont, wctext, wclen); - } else { - return gdk_text_width(PFont(font_)->pfont, s, len); - } -#else return 1; -#endif } else { return 1; } @@ -1943,37 +1192,17 @@ XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { if (PFont(font_)->pfd) { return WidthText(font_, &ch, 1); } -#ifndef DISABLE_GDK_FONT - return gdk_char_width(PFont(font_)->pfont, ch); -#else return 1; -#endif } else { return 1; } } -// Three possible strategies for determining ascent and descent of font: -// 1) Call gdk_string_extents with string containing all letters, numbers and punctuation. -// 2) Use the ascent and descent fields of GdkFont. -// 3) Call gdk_string_extents with string as 1 but also including accented capitals. -// Smallest values given by 1 and largest by 3 with 2 in between. -// Techniques 1 and 2 sometimes chop off extreme portions of ascenders and -// descenders but are mostly OK except for accented characters like Å which are -// rarely used in code. - -// This string contains a good range of characters to test for size. -//const char largeSizeString[] = "ÂÃÅÄ `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890" -// "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#ifndef FAST_WAY -const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890" - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#endif +// Ascent and descent determined by Pango font metrics. XYPOSITION SurfaceImpl::Ascent(Font &font_) { if (!(font_.GetID())) return 1; -#ifdef FAST_WAY FontMutexLock(); int ascent = PFont(font_)->ascent; if ((ascent == 0) && (PFont(font_)->pfd)) { @@ -1984,35 +1213,16 @@ XYPOSITION SurfaceImpl::Ascent(Font &font_) { pango_font_metrics_unref(metrics); ascent = PFont(font_)->ascent; } -#ifndef DISABLE_GDK_FONT - if ((ascent == 0) && (PFont(font_)->pfont)) { - ascent = PFont(font_)->pfont->ascent; - } -#endif if (ascent == 0) { ascent = 1; } FontMutexUnlock(); return ascent; -#else - - gint lbearing; - gint rbearing; - gint width; - gint ascent; - gint descent; - - gdk_string_extents(PFont(font_)->pfont, sizeString, - &lbearing, &rbearing, &width, &ascent, &descent); - return ascent; -#endif } XYPOSITION SurfaceImpl::Descent(Font &font_) { if (!(font_.GetID())) return 1; -#ifdef FAST_WAY - if (PFont(font_)->pfd) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); @@ -2020,23 +1230,7 @@ XYPOSITION SurfaceImpl::Descent(Font &font_) { pango_font_metrics_unref(metrics); return descent; } -#ifndef DISABLE_GDK_FONT - return PFont(font_)->pfont->descent; -#else return 0; -#endif -#else - - gint lbearing; - gint rbearing; - gint width; - gint ascent; - gint descent; - - gdk_string_extents(PFont(font_)->pfont, sizeString, - &lbearing, &rbearing, &width, &ascent, &descent); - return descent; -#endif } XYPOSITION SurfaceImpl::InternalLeading(Font &) { @@ -2061,14 +1255,8 @@ int SurfaceImpl::SetPalette(Palette *, bool) { } void SurfaceImpl::SetClip(PRectangle rc) { -#ifdef USE_CAIRO cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom); cairo_clip(context); -#else - GdkRectangle area = {rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top}; - gdk_gc_set_clip_rectangle(gc, &area); -#endif } void SurfaceImpl::FlushCachedState() {} @@ -2237,25 +1425,16 @@ PRectangle Window::GetMonitorRect(Point pt) { gdk_window_get_origin(WindowFromWidget(PWidget(wid)), &x_offset, &y_offset); -#if GTK_CHECK_VERSION(2,2,0) - // GTK+ 2.2+ - { - GdkScreen* screen; - gint monitor_num; - GdkRectangle rect; + GdkScreen* screen; + gint monitor_num; + GdkRectangle rect; - screen = gtk_widget_get_screen(PWidget(wid)); - monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); - gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); - rect.x -= x_offset; - rect.y -= y_offset; - return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); - } -#else - pt = pt; - return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(), - (-y_offset) + gdk_screen_height()); -#endif + screen = gtk_widget_get_screen(PWidget(wid)); + monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); + gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); + rect.x -= x_offset; + rect.y -= y_offset; + return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); } typedef std::map<int, RGBAImage*> ImageMap; diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index fd59e0f97..3b757a263 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -74,8 +74,6 @@ #define IS_WIDGET_VISIBLE(w) (GTK_WIDGET_VISIBLE(w)) #endif -#define USE_CAIRO 1 - static GdkWindow *WindowFromWidget(GtkWidget *w) { #if GTK_CHECK_VERSION(3,0,0) return gtk_widget_get_window(w); @@ -100,10 +98,6 @@ static GdkWindow *PWindow(const Window &w) { #pragma warning(disable: 4505) #endif -#if GTK_CHECK_VERSION(2,6,0) -#define USE_GTK_CLIPBOARD -#endif - #define OBJECT_CLASS GObjectClass #ifdef SCI_NAMESPACE @@ -122,11 +116,6 @@ class ScintillaGTK : public ScintillaBase { int scrollBarWidth; int scrollBarHeight; - // Because clipboard access is asynchronous, copyText is created by Copy -#ifndef USE_GTK_CLIPBOARD - SelectionText copyText; -#endif - SelectionText primary; GdkEventButton evbtn; @@ -218,11 +207,9 @@ private: void ReceivedSelection(GtkSelectionData *selection_data); void ReceivedDrop(GtkSelectionData *selection_data); static void GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *selected); -#ifdef USE_GTK_CLIPBOARD void StoreOnClipboard(SelectionText *clipText); static void ClipboardGetSelection(GtkClipboard* clip, GtkSelectionData *selection_data, guint info, void *data); static void ClipboardClearSelection(GtkClipboard* clip, void *data); -#endif void UnclaimSelection(GdkEventSelection *selection_event); void Resize(int width, int height); @@ -505,10 +492,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); -#ifndef USE_GTK_CLIPBOARD - gtk_selection_add_targets(widget, atomClipboard, - clipboardPasteTargets, nClipboardPasteTargets); -#endif } void ScintillaGTK::Realize(GtkWidget *widget) { @@ -519,9 +502,6 @@ void ScintillaGTK::Realize(GtkWidget *widget) { void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { try { gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); -#ifndef USE_GTK_CLIPBOARD - gtk_selection_clear_targets(widget, atomClipboard); -#endif if (IS_WIDGET_MAPPED(widget)) { gtk_widget_unmap(widget); @@ -1434,30 +1414,16 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) { } void ScintillaGTK::CopyToClipboard(const SelectionText &selectedText) { -#ifndef USE_GTK_CLIPBOARD - copyText.Copy(selectedText); - gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), - atomClipboard, - GDK_CURRENT_TIME); -#else SelectionText *clipText = new SelectionText(); clipText->Copy(selectedText); StoreOnClipboard(clipText); -#endif } void ScintillaGTK::Copy() { if (!sel.Empty()) { -#ifndef USE_GTK_CLIPBOARD - CopySelectionRange(©Text); - gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), - atomClipboard, - GDK_CURRENT_TIME); -#else SelectionText *clipText = new SelectionText(); CopySelectionRange(clipText); StoreOnClipboard(clipText); -#endif #if PLAT_GTK_WIN32 if (sel.IsRectangular()) { ::OpenClipboard(NULL); @@ -1717,7 +1683,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se #endif } -#ifdef USE_GTK_CLIPBOARD void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) { GtkClipboard *clipBoard = gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard); @@ -1738,7 +1703,6 @@ void ScintillaGTK::ClipboardClearSelection(GtkClipboard *, void *data) { SelectionText *obj = static_cast<SelectionText*>(data); delete obj; } -#endif void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) { try { @@ -2312,28 +2276,10 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str); pango_layout_set_attributes(layout, attrs); -#ifdef USE_CAIRO cairo_t *context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(WindowFromWidget(widget))); cairo_move_to(context, 0, 0); pango_cairo_show_layout(context, layout); cairo_destroy(context); -#else - GdkGC *gc = gdk_gc_new(widget->window); - GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000}, - {0, 0xffff, 0xffff, 0xffff} - }; - gdk_colormap_alloc_color(gdk_colormap_get_system(), color, FALSE, TRUE); - gdk_colormap_alloc_color(gdk_colormap_get_system(), color + 1, FALSE, TRUE); - - gdk_gc_set_foreground(gc, color + 1); - gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y, - ose->area.width, ose->area.height); - - gdk_gc_set_foreground(gc, color); - gdk_gc_set_background(gc, color + 1); - gdk_draw_layout(widget->window, gc, 0, 0, layout); - g_object_unref(gc); -#endif g_free(str); pango_attr_list_unref(attrs); g_object_unref(layout); @@ -2640,11 +2586,6 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget, } sciThis->GetSelection(selection_data, info, &sciThis->primary); } -#ifndef USE_GTK_CLIPBOARD - else { - sciThis->GetSelection(selection_data, info, &sciThis->copyText); - } -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } |