Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/graphics/GC.d @ 54:70388b0e6dad
[swt lin] compiles
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 23:31:11 +0100 |
parents | 7a2dd761a8b2 |
children | fb3aa8075988 |
comparison
equal
deleted
inserted
replaced
53:7e78af7adab5 | 54:70388b0e6dad |
---|---|
408 case SWT.LINE_CUSTOM: dashes = data.lineDashes; break; | 408 case SWT.LINE_CUSTOM: dashes = data.lineDashes; break; |
409 default: | 409 default: |
410 } | 410 } |
411 if (dashes !is null) { | 411 if (dashes !is null) { |
412 if ((state & LINE_STYLE) !is 0) { | 412 if ((state & LINE_STYLE) !is 0) { |
413 String dash_list = new char[dashes.length]; | 413 auto dash_list = new char[dashes.length]; |
414 for (int i = 0; i < dash_list.length; i++) { | 414 for (int i = 0; i < dash_list.length; i++) { |
415 dash_list[i] = cast(char)(width is 0 || data.lineStyle is SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width); | 415 dash_list[i] = cast(char)(width is 0 || data.lineStyle is SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width); |
416 } | 416 } |
417 OS.gdk_gc_set_dashes(handle, 0, dash_list.ptr, dash_list.length); | 417 OS.gdk_gc_set_dashes(handle, 0, dash_list.ptr, dash_list.length); |
418 } | 418 } |
955 byte[] line = new byte[stride]; | 955 byte[] line = new byte[stride]; |
956 byte alpha = cast(byte)srcImage.alpha; | 956 byte alpha = cast(byte)srcImage.alpha; |
957 byte[] alphaData = srcImage.alphaData; | 957 byte[] alphaData = srcImage.alphaData; |
958 for (int y=0; y<srcHeight; y++) { | 958 for (int y=0; y<srcHeight; y++) { |
959 int alphaIndex = (y + srcY) * imgWidth + srcX; | 959 int alphaIndex = (y + srcY) * imgWidth + srcX; |
960 memmove(line.ptr, pixels + (y * stride), stride); | 960 OS.memmove(line.ptr, pixels + (y * stride), stride); |
961 for (int x=3; x<stride; x+=4) { | 961 for (int x=3; x<stride; x+=4) { |
962 line[x] = alphaData is null ? alpha : alphaData[alphaIndex++]; | 962 line[x] = alphaData is null ? alpha : alphaData[alphaIndex++]; |
963 } | 963 } |
964 memmove(pixels + (y * stride), line.ptr, stride); | 964 OS.memmove(pixels + (y * stride), line.ptr, stride); |
965 } | 965 } |
966 if (srcWidth !is destWidth || srcHeight !is destHeight) { | 966 if (srcWidth !is destWidth || srcHeight !is destHeight) { |
967 auto scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR); | 967 auto scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR); |
968 OS.g_object_unref(pixbuf); | 968 OS.g_object_unref(pixbuf); |
969 if (scaledPixbuf is null) return; | 969 if (scaledPixbuf is null) return; |
1004 int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf); | 1004 int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf); |
1005 auto maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf); | 1005 auto maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf); |
1006 byte[] maskLine = new byte[maskStride]; | 1006 byte[] maskLine = new byte[maskStride]; |
1007 for (int y=0; y<srcHeight; y++) { | 1007 for (int y=0; y<srcHeight; y++) { |
1008 auto offset = pixels + (y * stride); | 1008 auto offset = pixels + (y * stride); |
1009 memmove(line.ptr, offset, stride); | 1009 OS.memmove(line.ptr, offset, stride); |
1010 auto maskOffset = maskPixels + (y * maskStride); | 1010 auto maskOffset = maskPixels + (y * maskStride); |
1011 memmove(maskLine.ptr, maskOffset, maskStride); | 1011 OS.memmove(maskLine.ptr, maskOffset, maskStride); |
1012 for (int x=0; x<srcWidth; x++) { | 1012 for (int x=0; x<srcWidth; x++) { |
1013 if (maskLine[x * 3] is 0) { | 1013 if (maskLine[x * 3] is 0) { |
1014 line[x*4+3] = 0; | 1014 line[x*4+3] = 0; |
1015 } | 1015 } |
1016 } | 1016 } |
1017 memmove(offset, line.ptr, stride); | 1017 OS.memmove(offset, line.ptr, stride); |
1018 } | 1018 } |
1019 OS.g_object_unref(maskPixbuf); | 1019 OS.g_object_unref(maskPixbuf); |
1020 auto scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR); | 1020 auto scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR); |
1021 if (scaledPixbuf !is null) { | 1021 if (scaledPixbuf !is null) { |
1022 GdkPixmap * colorBuffer; | 1022 GdkPixmap * colorBuffer; |
1038 /* Merge clipping with mask if necessary */ | 1038 /* Merge clipping with mask if necessary */ |
1039 if (data.clipRgn !is null) { | 1039 if (data.clipRgn !is null) { |
1040 int newWidth = srcX + srcWidth; | 1040 int newWidth = srcX + srcWidth; |
1041 int newHeight = srcY + srcHeight; | 1041 int newHeight = srcY + srcHeight; |
1042 int bytesPerLine = (newWidth + 7) / 8; | 1042 int bytesPerLine = (newWidth + 7) / 8; |
1043 String maskData = new char[bytesPerLine * newHeight]; | 1043 auto maskData = new char[bytesPerLine * newHeight]; |
1044 auto mask = cast(GdkDrawable *) OS.gdk_bitmap_create_from_data(null, maskData.ptr, newWidth, newHeight); | 1044 auto mask = cast(GdkDrawable *) OS.gdk_bitmap_create_from_data(null, maskData.ptr, newWidth, newHeight); |
1045 if (mask !is null) { | 1045 if (mask !is null) { |
1046 auto gc = OS.gdk_gc_new(mask); | 1046 auto gc = OS.gdk_gc_new(mask); |
1047 OS.gdk_region_offset(data.clipRgn, -destX + srcX, -destY + srcY); | 1047 OS.gdk_region_offset(data.clipRgn, -destX + srcX, -destY + srcY); |
1048 OS.gdk_gc_set_clip_region(gc, data.clipRgn); | 1048 OS.gdk_gc_set_clip_region(gc, data.clipRgn); |
3124 } | 3124 } |
3125 | 3125 |
3126 static void setCairoFont(cairo_t* cairo, PangoFontDescription* font) { | 3126 static void setCairoFont(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 String buffer = new char[len + 1]; | 3129 auto buffer = new char[len + 1]; |
3130 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 |
3132 double height = OS.PANGO_PIXELS(OS.pango_font_description_get_size(font)) * 96 / 72; | 3132 double height = OS.PANGO_PIXELS(OS.pango_font_description_get_size(font)) * 96 / 72; |
3133 int pangoStyle = OS.pango_font_description_get_style(font); | 3133 int pangoStyle = OS.pango_font_description_get_style(font); |
3134 int pangoWeight = OS.pango_font_description_get_weight(font); | 3134 int pangoWeight = OS.pango_font_description_get_weight(font); |
3135 int slant = Cairo.CAIRO_FONT_SLANT_NORMAL; | 3135 int slant = Cairo.CAIRO_FONT_SLANT_NORMAL; |
3761 void setString(String str, int flags) { | 3761 void setString(String str, int flags) { |
3762 if (data.layout is null) createLayout(); | 3762 if (data.layout is null) createLayout(); |
3763 if (str is data.str && (flags & ~SWT.DRAW_TRANSPARENT) is (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) { | 3763 if (str is data.str && (flags & ~SWT.DRAW_TRANSPARENT) is (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) { |
3764 return; | 3764 return; |
3765 } | 3765 } |
3766 String buffer; | 3766 char[] buffer; |
3767 int mnemonic, len = str.length ; | 3767 int mnemonic, len = str.length ; |
3768 auto layout = data.layout; | 3768 auto layout = data.layout; |
3769 char[] text = str.dup; | 3769 char[] text = str.dup; |
3770 if ((flags & SWT.DRAW_MNEMONIC) !is 0 && (mnemonic = fixMnemonic(text)) !is -1) { | 3770 if ((flags & SWT.DRAW_MNEMONIC) !is 0 && (mnemonic = fixMnemonic(text)) !is -1) { |
3771 char[] text1 = new char[mnemonic - 1]; | 3771 char[] text1 = new char[mnemonic - 1]; |