From ea07369a205b6a273e3c4b0e70ab16a93f6d9d9a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 7 Aug 2011 20:13:19 +1000 Subject: Implement fractional widths and range of weights for GTK+. --- gtk/PlatGTK.cxx | 132 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index b8ee6b385..9f24e1b1d 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -94,7 +94,7 @@ enum encodingType { singleByte, UTF8, dbcs}; struct LOGFONT { int size; - bool bold; + int weight; bool italic; int characterSet; char faceName[300]; @@ -445,10 +445,10 @@ static void GenerateFontSpecStrings(const char *fontName, int characterSet, #endif -static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, bool bold, bool italic) { +static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, float size, int weight, bool italic) { memset(&lf, 0, sizeof(lf)); lf.size = size; - lf.bold = bold; + lf.weight = weight; lf.italic = italic; lf.characterSet = characterSet; strncpy(lf.faceName, faceName, sizeof(lf.faceName) - 1); @@ -459,11 +459,11 @@ static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int * If one font is the same as another, its hash will be the same, but if the hash is the * same then they may still be different. */ -static int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic) { +static int HashFont(const char *faceName, int characterSet, int size, int weight, bool italic) { return size ^ (characterSet << 10) ^ - (bold ? 0x10000000 : 0) ^ + ((weight / 100) << 12) ^ (italic ? 0x20000000 : 0) ^ faceName[0]; } @@ -473,32 +473,32 @@ class FontCached : Font { int usage; LOGFONT lf; int hash; - FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + FontCached(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); ~FontCached() {} - bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + bool SameAs(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); virtual void Release(); static FontID CreateNewFont(const char *fontName, int characterSet, - int size, bool bold, bool italic); + float size, int weight, bool italic); static FontCached *first; public: - static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + static FontID FindOrCreate(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); static void ReleaseId(FontID fid_); }; FontCached *FontCached::first = 0; -FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) : +FontCached::FontCached(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) : next(0), usage(0), hash(0) { - ::SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_); - hash = HashFont(faceName_, characterSet_, size_, bold_, italic_); - fid = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); + ::SetLogFont(lf, faceName_, characterSet_, size_, weight_, italic_); + hash = HashFont(faceName_, characterSet_, size_, weight_, italic_); + fid = CreateNewFont(faceName_, characterSet_, size_, weight_, italic_); usage = 1; } -bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { +bool FontCached::SameAs(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) { return lf.size == size_ && - lf.bold == bold_ && + lf.weight == weight_ && lf.italic == italic_ && lf.characterSet == characterSet_ && 0 == strcmp(lf.faceName, faceName_); @@ -510,19 +510,19 @@ void FontCached::Release() { fid = 0; } -FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { +FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) { FontID ret = 0; FontMutexLock(); - int hashFind = HashFont(faceName_, characterSet_, size_, bold_, italic_); + int hashFind = HashFont(faceName_, characterSet_, size_, weight_, italic_); for (FontCached *cur = first; cur; cur = cur->next) { if ((cur->hash == hashFind) && - cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) { + cur->SameAs(faceName_, characterSet_, size_, weight_, italic_)) { cur->usage++; ret = cur->fid; } } if (ret == 0) { - FontCached *fc = new FontCached(faceName_, characterSet_, size_, bold_, italic_); + FontCached *fc = new FontCached(faceName_, characterSet_, size_, weight_, italic_); if (fc) { fc->next = first; first = fc; @@ -563,13 +563,13 @@ static GdkFont *LoadFontOrSet(const char *fontspec, int characterSet) { #endif FontID FontCached::CreateNewFont(const char *fontName, int characterSet, - int size, bool bold, bool italic) { + float size, int weight, bool italic) { if (fontName[0] == '!') { PangoFontDescription *pfd = pango_font_description_new(); if (pfd) { pango_font_description_set_family(pfd, fontName+1); - pango_font_description_set_size(pfd, size * PANGO_SCALE); - pango_font_description_set_weight(pfd, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); + pango_font_description_set_size(pfd, pango_units_from_double(size)); + pango_font_description_set_weight(pfd, static_cast(weight)); pango_font_description_set_style(pfd, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); return new FontHandle(pfd, characterSet); } @@ -638,7 +638,7 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, sizeof(fontspec) - 1, spec, foundary, faceName, - bold ? "-bold" : "-medium", + (weight > 400) ? "-bold" : "-medium", italic ? "-i" : "-r", size * 10, charset); @@ -654,7 +654,7 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, sizeof(fontspec) - 1, ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s", foundary, faceName, - bold ? "-bold" : "-medium", + (weight > 400) ? "-bold" : "-medium", size * 10, charset); } @@ -688,7 +688,7 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, sizeof(fontspec) - 1, "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", foundary, faceName, - bold ? "-bold" : "-medium", + (weight > 400) ? "-bold" : "-medium", italic ? "-i" : "-r", size * 10, charset); @@ -699,7 +699,7 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, sizeof(fontspec) - 1, "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", foundary, faceName, - bold ? "-bold" : "-medium", + (weight > 400) ? "-bold" : "-medium", italic ? "-o" : "-r", size * 10, charset); @@ -729,10 +729,10 @@ Font::Font() : fid(0) {} Font::~Font() {} -void Font::Create(const char *faceName, int characterSet, int size, - bool bold, bool italic, int) { +void Font::Create(const char *faceName, int characterSet, float size, + int weight, bool italic, int) { Release(); - fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); + fid = FontCached::FindOrCreate(faceName, characterSet, size, weight, italic); } void Font::Release() { @@ -792,19 +792,19 @@ public: void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back); void Copy(PRectangle rc, Point from, Surface &surfaceSource); - void DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore); - void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); - void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); - void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore); - void MeasureWidths(Font &font_, const char *s, int len, int *positions); - int WidthText(Font &font_, const char *s, int len); - int WidthChar(Font &font_, char ch); - int Ascent(Font &font_); - int Descent(Font &font_); - int InternalLeading(Font &font_); - int ExternalLeading(Font &font_); - int Height(Font &font_); - int AverageCharWidth(Font &font_); + void DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore); + void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore); + void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); + XYPOSITION WidthText(Font &font_, const char *s, int len); + XYPOSITION WidthChar(Font &font_, char ch); + XYPOSITION Ascent(Font &font_); + XYPOSITION Descent(Font &font_); + XYPOSITION InternalLeading(Font &font_); + XYPOSITION ExternalLeading(Font &font_); + XYPOSITION Height(Font &font_); + XYPOSITION AverageCharWidth(Font &font_); int SetPalette(Palette *pal, bool inBackGround); void SetClip(PRectangle rc); @@ -1581,7 +1581,7 @@ static size_t UTF8CharLength(const char *s) { const int maxLengthTextRun = 10000; -void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore) { PenColour(fore); #ifdef USE_CAIRO @@ -1589,7 +1589,7 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char #else if (gc && drawable) { #endif - int xText = rc.left; + XYPOSITION xText = rc.left; if (PFont(font_)->pfd) { char *utfForm = 0; bool useGFree = false; @@ -1685,20 +1685,20 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char } } -void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { FillRectangle(rc, back); DrawTextBase(rc, font_, ybase, s, len, fore); } // On GTK+, exactly same as DrawTextNoClip -void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { FillRectangle(rc, back); DrawTextBase(rc, font_, ybase, s, len, fore); } -void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore) { // Avoid drawing spaces in transparent mode for (int i=0;ipfd) { @@ -1904,7 +1904,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi } } -int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { +XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (font_.GetID()) { if (PFont(font_)->pfd) { char *utfForm = 0; @@ -1938,7 +1938,7 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { } else { delete []utfForm; } - return PANGO_PIXELS(pos.width); + return pango_units_to_double(pos.width); } #ifndef DISABLE_GDK_FONT if (et == UTF8) { @@ -1958,7 +1958,7 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { } } -int SurfaceImpl::WidthChar(Font &font_, char ch) { +XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { if (font_.GetID()) { if (PFont(font_)->pfd) { return WidthText(font_, &ch, 1); @@ -1990,7 +1990,7 @@ const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; #endif -int SurfaceImpl::Ascent(Font &font_) { +XYPOSITION SurfaceImpl::Ascent(Font &font_) { if (!(font_.GetID())) return 1; #ifdef FAST_WAY @@ -2000,7 +2000,7 @@ int SurfaceImpl::Ascent(Font &font_) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); PFont(font_)->ascent = - PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)); + pango_units_to_double(pango_font_metrics_get_ascent(metrics)); pango_font_metrics_unref(metrics); ascent = PFont(font_)->ascent; } @@ -2028,7 +2028,7 @@ int SurfaceImpl::Ascent(Font &font_) { #endif } -int SurfaceImpl::Descent(Font &font_) { +XYPOSITION SurfaceImpl::Descent(Font &font_) { if (!(font_.GetID())) return 1; #ifdef FAST_WAY @@ -2036,7 +2036,7 @@ int SurfaceImpl::Descent(Font &font_) { if (PFont(font_)->pfd) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); - int descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics)); + int descent = pango_units_to_double(pango_font_metrics_get_descent(metrics)); pango_font_metrics_unref(metrics); return descent; } @@ -2059,19 +2059,19 @@ int SurfaceImpl::Descent(Font &font_) { #endif } -int SurfaceImpl::InternalLeading(Font &) { +XYPOSITION SurfaceImpl::InternalLeading(Font &) { return 0; } -int SurfaceImpl::ExternalLeading(Font &) { +XYPOSITION SurfaceImpl::ExternalLeading(Font &) { return 0; } -int SurfaceImpl::Height(Font &font_) { +XYPOSITION SurfaceImpl::Height(Font &font_) { return Ascent(font_) + Descent(font_); } -int SurfaceImpl::AverageCharWidth(Font &font_) { +XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { return WidthChar(font_, 'n'); } @@ -2855,7 +2855,7 @@ void Menu::Show(Point pt, Window &) { pt.y = screenHeight - requisition.height; } gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc, - reinterpret_cast((pt.y << 16) | pt.x), 0, + reinterpret_cast((static_cast(pt.y) << 16) | static_cast(pt.x)), 0, gtk_get_current_event_time()); } @@ -2976,7 +2976,7 @@ bool Platform::IsDBCSLeadByte(int codePage, char ch) { // Shift_jis return ((uch >= 0x81) && (uch <= 0x9F)) || ((uch >= 0xE0) && (uch <= 0xFC)); - // Lead bytes F0 to FC may be a Microsoft addition. + // Lead bytes F0 to FC may be a Microsoft addition. case 936: // GBK return (uch >= 0x81) && (uch <= 0xFE); -- cgit v1.2.3 From b6c394825bf6dd8212bf1ff8820d6d2ffab2a7d3 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 11 Aug 2011 14:42:35 +1000 Subject: Implement new APIs defined for technology choice on Windows. --- gtk/PlatGTK.cxx | 77 +++++++++++++++++++++++++--------------------------- gtk/ScintillaGTK.cxx | 8 +++--- 2 files changed, 41 insertions(+), 44 deletions(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 9f24e1b1d..a8bd051a8 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -459,13 +459,13 @@ static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, floa * If one font is the same as another, its hash will be the same, but if the hash is the * same then they may still be different. */ -static int HashFont(const char *faceName, int characterSet, int size, int weight, bool italic) { +static int HashFont(const FontParameters &fp) { return - size ^ - (characterSet << 10) ^ - ((weight / 100) << 12) ^ - (italic ? 0x20000000 : 0) ^ - faceName[0]; + static_cast(fp.size+0.5) ^ + (fp.characterSet << 10) ^ + ((fp.weight / 100) << 12) ^ + (fp.italic ? 0x20000000 : 0) ^ + fp.faceName[0]; } class FontCached : Font { @@ -473,35 +473,34 @@ class FontCached : Font { int usage; LOGFONT lf; int hash; - FontCached(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); + FontCached(const FontParameters &fp); ~FontCached() {} - bool SameAs(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); + bool SameAs(const FontParameters &fp); virtual void Release(); - static FontID CreateNewFont(const char *fontName, int characterSet, - float size, int weight, bool italic); + static FontID CreateNewFont(const FontParameters &fp); static FontCached *first; public: - static FontID FindOrCreate(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_); + static FontID FindOrCreate(const FontParameters &fp); static void ReleaseId(FontID fid_); }; FontCached *FontCached::first = 0; -FontCached::FontCached(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) : +FontCached::FontCached(const FontParameters &fp) : next(0), usage(0), hash(0) { - ::SetLogFont(lf, faceName_, characterSet_, size_, weight_, italic_); - hash = HashFont(faceName_, characterSet_, size_, weight_, italic_); - fid = CreateNewFont(faceName_, characterSet_, size_, weight_, italic_); + ::SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic); + hash = HashFont(fp); + fid = CreateNewFont(fp); usage = 1; } -bool FontCached::SameAs(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) { +bool FontCached::SameAs(const FontParameters &fp) { return - lf.size == size_ && - lf.weight == weight_ && - lf.italic == italic_ && - lf.characterSet == characterSet_ && - 0 == strcmp(lf.faceName, faceName_); + lf.size == fp.size && + lf.weight == fp.weight && + lf.italic == fp.italic && + lf.characterSet == fp.characterSet && + 0 == strcmp(lf.faceName, fp.faceName); } void FontCached::Release() { @@ -510,19 +509,19 @@ void FontCached::Release() { fid = 0; } -FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, float size_, int weight_, bool italic_) { +FontID FontCached::FindOrCreate(const FontParameters &fp) { FontID ret = 0; FontMutexLock(); - int hashFind = HashFont(faceName_, characterSet_, size_, weight_, italic_); + int hashFind = HashFont(fp); for (FontCached *cur = first; cur; cur = cur->next) { if ((cur->hash == hashFind) && - cur->SameAs(faceName_, characterSet_, size_, weight_, italic_)) { + cur->SameAs(fp)) { cur->usage++; ret = cur->fid; } } if (ret == 0) { - FontCached *fc = new FontCached(faceName_, characterSet_, size_, weight_, italic_); + FontCached *fc = new FontCached(fp); if (fc) { fc->next = first; first = fc; @@ -562,16 +561,15 @@ static GdkFont *LoadFontOrSet(const char *fontspec, int characterSet) { } #endif -FontID FontCached::CreateNewFont(const char *fontName, int characterSet, - float size, int weight, bool italic) { - if (fontName[0] == '!') { +FontID FontCached::CreateNewFont(const FontParameters &fp) { + if (fp.faceName[0] == '!') { PangoFontDescription *pfd = pango_font_description_new(); if (pfd) { - pango_font_description_set_family(pfd, fontName+1); - pango_font_description_set_size(pfd, pango_units_from_double(size)); - pango_font_description_set_weight(pfd, static_cast(weight)); - pango_font_description_set_style(pfd, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); - return new FontHandle(pfd, characterSet); + 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(fp.weight)); + pango_font_description_set_style(pfd, fp.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); + return new FontHandle(pfd, fp.characterSet); } } @@ -729,10 +727,9 @@ Font::Font() : fid(0) {} Font::~Font() {} -void Font::Create(const char *faceName, int characterSet, float size, - int weight, bool italic, int) { +void Font::Create(const FontParameters &fp) { Release(); - fid = FontCached::FindOrCreate(faceName, characterSet, size, weight, italic); + fid = FontCached::FindOrCreate(fp); } void Font::Release() { @@ -2103,8 +2100,8 @@ void SurfaceImpl::SetDBCSMode(int codePage) { et = dbcs; } -Surface *Surface::Allocate() { - return new SurfaceImpl; +Surface *Surface::Allocate(int) { + return new SurfaceImpl(); } Window::~Window() {} @@ -2324,7 +2321,7 @@ public: } } virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); virtual int GetVisibleRows() const; @@ -2413,7 +2410,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { #endif } -void ListBoxX::Create(Window &, int, Point, int, bool) { +void ListBoxX::Create(Window &, int, Point, int, bool, int) { wid = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index b7cea5ed3..2b2a7c689 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -586,7 +586,7 @@ void ScintillaGTK::UnMapThis() { #else GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED); #endif - DropGraphics(); + DropGraphics(false); gdk_window_hide(PWindow(wMain)); gtk_widget_unmap(PWidget(wText)); gtk_widget_unmap(PWidget(scrollbarh)); @@ -1114,7 +1114,7 @@ void ScintillaGTK::SyncPaint(PRectangle rc) { PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); if (PWindow(wText)) { - Surface *sw = Surface::Allocate(); + Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (sw) { #if GTK_CHECK_VERSION(3,0,0) cairo_t *cr = gdk_cairo_create(PWindow(wText)); @@ -2475,7 +2475,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) { rcPaint.bottom = y2; PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow, rcPaint); @@ -2833,7 +2833,7 @@ gboolean ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, Scintil gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) { try { - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(cr, widget); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage); -- cgit v1.2.3 From a848e8165894cc4124635ea44b721f8eadf54354 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 9 Sep 2011 23:43:31 +1000 Subject: Update calls to Surface::Allocate for GTK+ 2. --- gtk/ScintillaGTK.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gtk') diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index efb0e0cd5..1422a183a 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -2534,7 +2534,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os rgnUpdate = gdk_region_copy(ose->region); PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(PWindow(wText), PWidget(wText)); Paint(surfaceWindow, rcPaint); @@ -2850,7 +2850,7 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) { gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) { try { - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(WindowFromWidget(widget), widget); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage); -- cgit v1.2.3 From 33e27dc25f933a92566d91a667ba4ee732ba6cfa Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 9 Sep 2011 23:44:33 +1000 Subject: Update deprecated calls to GTK+ 3 maintained functions. --- gtk/PlatGTK.cxx | 4 ++++ gtk/ScintillaGTK.cxx | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index ffb04d005..064d5161a 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -2219,7 +2219,11 @@ void Window::SetCursor(Cursor curs) { if (WindowFromWidget(PWidget(wid))) gdk_window_set_cursor(WindowFromWidget(PWidget(wid)), gdkCurs); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(gdkCurs); +#else gdk_cursor_unref(gdkCurs); +#endif } void Window::SetTitle(const char *s) { diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 1422a183a..fd59e0f97 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -405,6 +405,14 @@ ScintillaGTK::~ScintillaGTK() { g_idle_remove_by_data(this); } +static void UnRefCursor(GdkCursor *cursor) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor); +#else + gdk_cursor_unref(cursor); +#endif +} + void ScintillaGTK::RealizeThis(GtkWidget *widget) { //Platform::DebugPrintf("ScintillaGTK::realize this\n"); #if GTK_CHECK_VERSION(2,20,0) @@ -436,12 +444,14 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gtk_widget_set_window(widget, gdk_window_new(gtk_widget_get_parent_window(widget), &attrs, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_CURSOR)); gdk_window_set_user_data(gtk_widget_get_window(widget), widget); - // Deprecated: should chain up to parent class' "realize" implementation - gtk_widget_style_attach(widget); - gdk_window_set_background(gtk_widget_get_window(widget), - &(gtk_widget_get_style(widget)->bg[GTK_STATE_NORMAL])); + GtkStyleContext *styleContext = gtk_widget_get_style_context(widget); + if (styleContext) { + GdkRGBA colourBackWidget; + gtk_style_context_get_background_color(styleContext, GTK_STATE_FLAG_NORMAL, &colourBackWidget); + gdk_window_set_background_rgba(gtk_widget_get_window(widget), &colourBackWidget); + } gdk_window_show(gtk_widget_get_window(widget)); - gdk_cursor_unref(cursor); + UnRefCursor(cursor); #else widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrs, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR); @@ -449,7 +459,7 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { widget->style = gtk_style_attach(widget->style, widget->window); gdk_window_set_background(widget->window, &widget->style->bg[GTK_STATE_NORMAL]); gdk_window_show(widget->window); - gdk_cursor_unref(cursor); + UnRefCursor(cursor); #endif wPreedit = gtk_window_new(GTK_WINDOW_POPUP); wPreeditDraw = gtk_drawing_area_new(); @@ -483,15 +493,15 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { cursor = gdk_cursor_new(GDK_XTERM); gdk_window_set_cursor(PWindow(wText), cursor); - gdk_cursor_unref(cursor); + UnRefCursor(cursor); cursor = gdk_cursor_new(GDK_LEFT_PTR); gdk_window_set_cursor(PWindow(scrollbarv), cursor); - gdk_cursor_unref(cursor); + UnRefCursor(cursor); cursor = gdk_cursor_new(GDK_LEFT_PTR); gdk_window_set_cursor(PWindow(scrollbarh), cursor); - gdk_cursor_unref(cursor); + UnRefCursor(cursor); gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); -- cgit v1.2.3