Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/graphics/GC.d @ 113:fb3aa8075988
D2 support for the linux port.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Wed, 06 Apr 2011 21:57:23 +0200 |
parents | 70388b0e6dad |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
112:9f4c18c268b2 | 113:fb3aa8075988 |
---|---|
190 this.device = data.device = device; | 190 this.device = data.device = device; |
191 init_(drawable, data, gdkGC); | 191 init_(drawable, data, gdkGC); |
192 init_(); | 192 init_(); |
193 } | 193 } |
194 | 194 |
195 static void addCairoString(cairo_t* cairo, String str, float x, float y, Font font) { | 195 static void addCairoString(org.eclipse.swt.internal.gtk.OS.cairo_t* cairo, String str, float x, float y, Font font) { |
196 char* buffer = toStringz( str ); | 196 char* buffer = toStringz( str ); |
197 if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) { | 197 if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) { |
198 auto layout = OS.pango_cairo_create_layout(cairo); | 198 auto layout = OS.pango_cairo_create_layout(cairo); |
199 if (layout is null) SWT.error(SWT.ERROR_NO_HANDLES); | 199 if (layout is null) SWT.error(SWT.ERROR_NO_HANDLES); |
200 OS.pango_layout_set_text(layout, buffer, -1); | 200 OS.pango_layout_set_text(layout, buffer, -1); |
532 int deltaX = destX - srcX, deltaY = destY - srcY; | 532 int deltaX = destX - srcX, deltaY = destY - srcY; |
533 if (deltaX is 0 && deltaY is 0) return; | 533 if (deltaX is 0 && deltaY is 0) return; |
534 auto drawable = data.drawable; | 534 auto drawable = data.drawable; |
535 if (data.image is null && paint) OS.gdk_gc_set_exposures(handle, true); | 535 if (data.image is null && paint) OS.gdk_gc_set_exposures(handle, true); |
536 OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height); | 536 OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height); |
537 if (data.image is null & paint) { | 537 if ((data.image is null) & paint) { |
538 OS.gdk_gc_set_exposures(handle, false); | 538 OS.gdk_gc_set_exposures(handle, false); |
539 bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); | 539 bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); |
540 GdkRectangle rect; | 540 GdkRectangle rect; |
541 if (disjoint) { | 541 if (disjoint) { |
542 rect.x = srcX; | 542 rect.x = srcX; |
1357 return; | 1357 return; |
1358 } | 1358 } |
1359 OS.gdk_draw_lines(data.drawable, handle, cast(GdkPoint*)pointArray.ptr, pointArray.length / 2); | 1359 OS.gdk_draw_lines(data.drawable, handle, cast(GdkPoint*)pointArray.ptr, pointArray.length / 2); |
1360 } | 1360 } |
1361 | 1361 |
1362 void drawPolyline(cairo_t* cairo, int[] pointArray, bool close) { | 1362 void drawPolyline(org.eclipse.swt.internal.gtk.OS.cairo_t* cairo, int[] pointArray, bool close) { |
1363 int count = pointArray.length / 2; | 1363 int count = pointArray.length / 2; |
1364 if (count is 0) return; | 1364 if (count is 0) return; |
1365 double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset; | 1365 double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset; |
1366 Cairo.cairo_move_to(cairo, pointArray[0] + xOffset, pointArray[1] + yOffset); | 1366 Cairo.cairo_move_to(cairo, pointArray[0] + xOffset, pointArray[1] + yOffset); |
1367 for (int i = 1, j=2; i < count; i++, j += 2) { | 1367 for (int i = 1, j=2; i < count; i++, j += 2) { |
1844 fillRectangle(x, y, width, height); | 1844 fillRectangle(x, y, width, height); |
1845 return; | 1845 return; |
1846 } | 1846 } |
1847 auto cairo = data.cairo; | 1847 auto cairo = data.cairo; |
1848 if (cairo !is null) { | 1848 if (cairo !is null) { |
1849 cairo_pattern_t* pattern; | 1849 org.eclipse.swt.internal.gtk.OS.cairo_pattern_t* pattern; |
1850 if (vertical) { | 1850 if (vertical) { |
1851 pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 0.0, 1.0); | 1851 pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 0.0, 1.0); |
1852 } else { | 1852 } else { |
1853 pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 1.0, 0.0); | 1853 pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 1.0, 0.0); |
1854 } | 1854 } |
3117 if (data.backgroundPattern is pattern) return; | 3117 if (data.backgroundPattern is pattern) return; |
3118 data.backgroundPattern = pattern; | 3118 data.backgroundPattern = pattern; |
3119 data.state &= ~BACKGROUND; | 3119 data.state &= ~BACKGROUND; |
3120 } | 3120 } |
3121 | 3121 |
3122 static void setCairoFont(cairo_t* cairo, Font font) { | 3122 static void setCairoFont(org.eclipse.swt.internal.gtk.OS.cairo_t* cairo, Font font) { |
3123 setCairoFont(cairo, font.handle); | 3123 setCairoFont(cairo, font.handle); |
3124 } | 3124 } |
3125 | 3125 |
3126 static void setCairoFont(cairo_t* cairo, PangoFontDescription* font) { | 3126 static void setCairoFont(org.eclipse.swt.internal.gtk.OS.cairo_t* cairo, PangoFontDescription* font) { |
3127 auto family = OS.pango_font_description_get_family(font); | 3127 auto family = OS.pango_font_description_get_family(font); |
3128 int len = /*OS.*/strlen(family); | 3128 int len = /*OS.*/strlen(family); |
3129 auto buffer = new char[len + 1]; | 3129 auto buffer = new char[len + 1]; |
3130 OS.memmove(buffer.ptr, family, len); | 3130 OS.memmove(buffer.ptr, family, len); |
3131 //TODO - convert font height from pango to cairo | 3131 //TODO - convert font height from pango to cairo |
3139 if (pangoWeight is OS.PANGO_WEIGHT_BOLD) weight = Cairo.CAIRO_FONT_WEIGHT_BOLD; | 3139 if (pangoWeight is OS.PANGO_WEIGHT_BOLD) weight = Cairo.CAIRO_FONT_WEIGHT_BOLD; |
3140 Cairo.cairo_select_font_face(cairo, buffer.ptr, slant, weight); | 3140 Cairo.cairo_select_font_face(cairo, buffer.ptr, slant, weight); |
3141 Cairo.cairo_set_font_size(cairo, height); | 3141 Cairo.cairo_set_font_size(cairo, height); |
3142 } | 3142 } |
3143 | 3143 |
3144 static void setCairoClip(cairo_t* cairo, GdkRegion* clipRgn) { | 3144 static void setCairoClip(org.eclipse.swt.internal.gtk.OS.cairo_t* cairo, GdkRegion* clipRgn) { |
3145 Cairo.cairo_reset_clip(cairo); | 3145 Cairo.cairo_reset_clip(cairo); |
3146 if (clipRgn is null) return; | 3146 if (clipRgn is null) return; |
3147 if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) { | 3147 if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) { |
3148 OS.gdk_cairo_region(cairo, clipRgn); | 3148 OS.gdk_cairo_region(cairo, clipRgn); |
3149 } else { | 3149 } else { |
3157 if (rects !is null) OS.g_free(rects); | 3157 if (rects !is null) OS.g_free(rects); |
3158 } | 3158 } |
3159 Cairo.cairo_clip(cairo); | 3159 Cairo.cairo_clip(cairo); |
3160 } | 3160 } |
3161 | 3161 |
3162 static void setCairoPatternColor( cairo_pattern_t* pattern, int offset, Color c, int alpha) { | 3162 static void setCairoPatternColor( org.eclipse.swt.internal.gtk.OS.cairo_pattern_t* pattern, int offset, Color c, int alpha) { |
3163 GdkColor* color = c.handle; | 3163 GdkColor* color = c.handle; |
3164 double aa = (alpha & 0xFF) / cast(double)0xFF; | 3164 double aa = (alpha & 0xFF) / cast(double)0xFF; |
3165 double red = ((color.red & 0xFFFF) / cast(double)0xFFFF); | 3165 double red = ((color.red & 0xFFFF) / cast(double)0xFFFF); |
3166 double green = ((color.green & 0xFFFF) / cast(double)0xFFFF); | 3166 double green = ((color.green & 0xFFFF) / cast(double)0xFFFF); |
3167 double blue = ((color.blue & 0xFFFF) / cast(double)0xFFFF); | 3167 double blue = ((color.blue & 0xFFFF) / cast(double)0xFFFF); |