# HG changeset patch
# User Frank Benoit
# Date 1199744961 -3600
# Node ID bc06000c081677b8f9691189a2c72fa04d06ccc8
# Parent 3c2d10c00f61ae5b27f6647190f742ceecdd29ab
TextLayout and GC, graphics complete
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/events/PaintEvent.d
--- a/dwt/events/PaintEvent.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/events/PaintEvent.d Mon Jan 07 23:29:21 2008 +0100
@@ -12,9 +12,7 @@
import dwt.widgets.Event;
-
-//PROTING_LEFT
-//import dwt.graphics.GC;
+import dwt.graphics.GC;
import dwt.events.TypedEvent;
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/graphics/GC.d
--- a/dwt/graphics/GC.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/graphics/GC.d Mon Jan 07 23:29:21 2008 +0100
@@ -13,12 +13,9 @@
import dwt.graphics.Image;
-import dwt.internal.cairo.Cairo;
-import dwt.internal.gtk.OS;
-import dwt.internal.gtk.c.gdktypes;
-import dwt.internal.Converter;
-import dwt.internal.Compatibility;
import dwt.SWT;
+import dwt.SWTException;
+import dwt.SWTError;
import dwt.graphics.Color;
import dwt.graphics.Drawable;
import dwt.graphics.Resource;
@@ -28,17 +25,30 @@
import dwt.graphics.GCData;
import dwt.graphics.Image;
import dwt.graphics.ImageData;
-//import dwt.graphics.Path;
+import dwt.graphics.Path;
import dwt.graphics.Pattern;
import dwt.graphics.Point;
import dwt.graphics.RGB;
import dwt.graphics.Rectangle;
import dwt.graphics.Region;
import dwt.graphics.Resource;
-//import dwt.graphics.Transform;
+import dwt.graphics.Transform;
+import dwt.graphics.LineAttributes;
+import dwt.internal.gtk.OS;
+import dwt.internal.gtk.c.gdktypes;
+import dwt.internal.gtk.c.gtktypes;
import dwt.internal.gtk.c.cairotypes;
+import dwt.internal.cairo.Cairo;
+import dwt.internal.Converter;
+import dwt.internal.Compatibility;
+import tango.text.convert.Format;
+import tango.stdc.string;
+import tango.stdc.stringz;
+
+
+/+
class GC{
void drawImage(Image, int, int, int, int, int, int, int, int ){}
void dispose(){}
@@ -60,11 +70,18 @@
const static int DRAW = FOREGROUND | LINE_WIDTH | LINE_STYLE | LINE_CAP | LINE_JOIN | LINE_MITERLIMIT | DRAW_OFFSET;
const static int FILL = BACKGROUND;
+ public GdkGC* handle;
GCData data;
+ public Rectangle getClipping() { return null; }
+ public void getClipping(Region) { }
+ void setClipping(GdkRegion* clipRgn) {}
+ //void setClipping(Path clipRgn) {}
+ void setClipping(Region clipRgn) {}
+ void setClipping(Rectangle clipRgn) {}
}
-/+++
++/
/**
* Class GC
is where all of the drawing capabilities that are
@@ -190,46 +207,46 @@
* @since 2.1.2
*/
public this(Drawable drawable, int style) {
- if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (drawable is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
GCData data = new GCData();
data.style = checkStyle(style);
- int /*long*/ gdkGC = drawable.internal_new_GC(data);
+ auto gdkGC = drawable.internal_new_GC(data);
Device device = data.device;
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (device is null) device = Device.getDevice();
+ if (device is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = data.device = device;
init(drawable, data, gdkGC);
if (device.tracking) device.new_Object(this);
}
-static void addCairoString(cairo_t* cairo, String string, float x, float y, Font font) {
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
- int /*long*/ layout = OS.pango_cairo_create_layout(cairo);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.pango_layout_set_text(layout, buffer, -1);
+static void addCairoString(cairo_t* cairo, char[] str, float x, float y, Font font) {
+ char[] buffer = str.dup;
+ if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ auto layout = OS.pango_cairo_create_layout(cairo);
+ if (layout is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.pango_layout_set_text(layout, buffer.ptr, -1);
OS.pango_layout_set_font_description(layout, font.handle);
Cairo.cairo_move_to(cairo, x, y);
OS.pango_cairo_layout_path(cairo, layout);
OS.g_object_unref(layout);
} else {
GC.setCairoFont(cairo, font);
- cairo_font_extents_t extents = new cairo_font_extents_t();
+ cairo_font_extents_t* extents = new cairo_font_extents_t();
Cairo.cairo_font_extents(cairo, extents);
double baseline = y + extents.ascent;
Cairo.cairo_move_to(cairo, x, baseline);
- Cairo.cairo_text_path(cairo, buffer);
+ Cairo.cairo_text_path(cairo, buffer.ptr);
}
}
static int checkStyle (int style) {
- if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
+ if ((style & SWT.LEFT_TO_RIGHT) !is 0) style &= ~SWT.RIGHT_TO_LEFT;
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
}
public static GC gtk_new(Drawable drawable, GCData data) {
GC gc = new GC();
- int /*long*/ gdkGC = drawable.internal_new_GC(data);
+ auto gdkGC = drawable.internal_new_GC(data);
gc.device = data.device;
gc.init(drawable, data, gdkGC);
return gc;
@@ -237,15 +254,15 @@
void checkGC (int mask) {
int state = data.state;
- if ((state & mask) == mask) return;
+ if ((state & mask) is mask) return;
state = (state ^ mask) & mask;
data.state |= mask;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if ((state & (BACKGROUND | FOREGROUND)) != 0) {
- GdkColor color;
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if ((state & (BACKGROUND | FOREGROUND)) !is 0) {
+ GdkColor* color;
Pattern pattern;
- if ((state & FOREGROUND) != 0) {
+ if ((state & FOREGROUND) !is 0) {
color = data.foreground;
pattern = data.foregroundPattern;
data.state &= ~BACKGROUND;
@@ -254,40 +271,40 @@
pattern = data.backgroundPattern;
data.state &= ~FOREGROUND;
}
- if (pattern != null) {
+ if (pattern !is null) {
Cairo.cairo_set_source(cairo, pattern.handle);
} else {
- Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+ Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / cast(float)0xFFFF, (color.green & 0xFFFF) / cast(float)0xFFFF, (color.blue & 0xFFFF) / cast(float)0xFFFF, data.alpha / cast(float)0xFF);
}
}
- if ((state & FONT) != 0) {
- if (data.layout != 0) {
+ if ((state & FONT) !is 0) {
+ if (data.layout !is null) {
OS.pango_layout_set_font_description(data.layout, data.font);
}
- if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ if (OS.GTK_VERSION < OS.buildVERSION(2, 8, 0)) {
setCairoFont(cairo, data.font);
}
}
- if ((state & LINE_CAP) != 0) {
+ if ((state & LINE_CAP) !is 0) {
int cap_style = 0;
switch (data.lineCap) {
case SWT.CAP_ROUND: cap_style = Cairo.CAIRO_LINE_CAP_ROUND; break;
case SWT.CAP_FLAT: cap_style = Cairo.CAIRO_LINE_CAP_BUTT; break;
case SWT.CAP_SQUARE: cap_style = Cairo.CAIRO_LINE_CAP_SQUARE; break;
}
- Cairo.cairo_set_line_cap(cairo, cap_style);
+ Cairo.cairo_set_line_cap(cairo, cast(cairo_line_cap_t) cap_style);
}
- if ((state & LINE_JOIN) != 0) {
+ if ((state & LINE_JOIN) !is 0) {
int join_style = 0;
switch (data.lineJoin) {
case SWT.JOIN_MITER: join_style = Cairo.CAIRO_LINE_JOIN_MITER; break;
case SWT.JOIN_ROUND: join_style = Cairo.CAIRO_LINE_JOIN_ROUND; break;
case SWT.JOIN_BEVEL: join_style = Cairo.CAIRO_LINE_JOIN_BEVEL; break;
}
- Cairo.cairo_set_line_join(cairo, join_style);
+ Cairo.cairo_set_line_join(cairo, cast(cairo_line_join_t)join_style);
}
- if ((state & LINE_WIDTH) != 0) {
- Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth);
+ if ((state & LINE_WIDTH) !is 0) {
+ Cairo.cairo_set_line_width(cairo, data.lineWidth is 0 ? 1 : data.lineWidth);
switch (data.lineStyle) {
case SWT.LINE_DOT:
case SWT.LINE_DASH:
@@ -296,54 +313,54 @@
state |= LINE_STYLE;
}
}
- if ((state & LINE_STYLE) != 0) {
+ if ((state & LINE_STYLE) !is 0) {
float dashesOffset = 0;
float[] dashes = null;
float width = data.lineWidth;
switch (data.lineStyle) {
case SWT.LINE_SOLID: break;
- case SWT.LINE_DASH: dashes = width != 0 ? LINE_DASH : LINE_DASH_ZERO; break;
- case SWT.LINE_DOT: dashes = width != 0 ? LINE_DOT : LINE_DOT_ZERO; break;
- case SWT.LINE_DASHDOT: dashes = width != 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
- case SWT.LINE_DASHDOTDOT: dashes = width != 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
+ case SWT.LINE_DASH: dashes = width !is 0 ? LINE_DASH : LINE_DASH_ZERO; break;
+ case SWT.LINE_DOT: dashes = width !is 0 ? LINE_DOT : LINE_DOT_ZERO; break;
+ case SWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
+ case SWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
case SWT.LINE_CUSTOM: dashes = data.lineDashes; break;
}
- if (dashes != null) {
+ if (dashes !is null) {
dashesOffset = data.lineDashesOffset;
double[] cairoDashes = new double[dashes.length];
for (int i = 0; i < cairoDashes.length; i++) {
- cairoDashes[i] = width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width;
+ cairoDashes[i] = width is 0 || data.lineStyle is SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width;
}
- Cairo.cairo_set_dash(cairo, cairoDashes, cairoDashes.length, dashesOffset);
+ Cairo.cairo_set_dash(cairo, cairoDashes.ptr, cairoDashes.length, dashesOffset);
} else {
Cairo.cairo_set_dash(cairo, null, 0, 0);
}
}
- if ((state & LINE_MITERLIMIT) != 0) {
+ if ((state & LINE_MITERLIMIT) !is 0) {
Cairo.cairo_set_miter_limit(cairo, data.lineMiterLimit);
}
- if ((state & DRAW_OFFSET) != 0) {
+ if ((state & DRAW_OFFSET) !is 0) {
data.cairoXoffset = data.cairoYoffset = 0;
double[] matrix = new double[6];
- Cairo.cairo_get_matrix(cairo, matrix);
+ Cairo.cairo_get_matrix(cairo,cast(cairo_matrix_t*) matrix.ptr);
double scaling = matrix[0];
if (scaling < 0) scaling = -scaling;
double strokeWidth = data.lineWidth * scaling;
- if (strokeWidth == 0 || ((int)strokeWidth % 2) == 1) {
+ if (strokeWidth is 0 || (cast(int)strokeWidth % 2) is 1) {
data.cairoXoffset = 0.5 / scaling;
}
scaling = matrix[3];
if (scaling < 0) scaling = -scaling;
strokeWidth = data.lineWidth * scaling;
- if (strokeWidth == 0 || ((int)strokeWidth % 2) == 1) {
+ if (strokeWidth is 0 || (cast(int)strokeWidth % 2) is 1) {
data.cairoYoffset = 0.5 / scaling;
}
}
return;
}
- if ((state & (BACKGROUND | FOREGROUND)) != 0) {
- GdkColor foreground;
- if ((state & FOREGROUND) != 0) {
+ if ((state & (BACKGROUND | FOREGROUND)) !is 0) {
+ GdkColor* foreground;
+ if ((state & FOREGROUND) !is 0) {
foreground = data.foreground;
data.state &= ~BACKGROUND;
} else {
@@ -352,19 +369,19 @@
}
OS.gdk_gc_set_foreground(handle, foreground);
}
- if ((state & BACKGROUND_BG) != 0) {
- GdkColor background = data.background;
+ if ((state & BACKGROUND_BG) !is 0) {
+ GdkColor* background = data.background;
OS.gdk_gc_set_background(handle, background);
}
- if ((state & FONT) != 0) {
- if (data.layout != 0) {
+ if ((state & FONT) !is 0) {
+ if (data.layout !is null) {
OS.pango_layout_set_font_description(data.layout, data.font);
}
}
- if ((state & (LINE_CAP | LINE_JOIN | LINE_STYLE | LINE_WIDTH)) != 0) {
+ if ((state & (LINE_CAP | LINE_JOIN | LINE_STYLE | LINE_WIDTH)) !is 0) {
int cap_style = 0;
int join_style = 0;
- int width = (int)data.lineWidth;
+ int width = cast(int)data.lineWidth;
int line_style = 0;
float[] dashes = null;
switch (data.lineCap) {
@@ -379,17 +396,17 @@
}
switch (data.lineStyle) {
case SWT.LINE_SOLID: break;
- case SWT.LINE_DASH: dashes = width != 0 ? LINE_DASH : LINE_DASH_ZERO; break;
- case SWT.LINE_DOT: dashes = width != 0 ? LINE_DOT : LINE_DOT_ZERO; break;
- case SWT.LINE_DASHDOT: dashes = width != 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
- case SWT.LINE_DASHDOTDOT: dashes = width != 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
+ case SWT.LINE_DASH: dashes = width !is 0 ? LINE_DASH : LINE_DASH_ZERO; break;
+ case SWT.LINE_DOT: dashes = width !is 0 ? LINE_DOT : LINE_DOT_ZERO; break;
+ case SWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
+ case SWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
case SWT.LINE_CUSTOM: dashes = data.lineDashes; break;
}
- if (dashes != null) {
- if ((state & LINE_STYLE) != 0) {
+ if (dashes !is null) {
+ if ((state & LINE_STYLE) !is 0) {
byte[] dash_list = new byte[dashes.length];
for (int i = 0; i < dash_list.length; i++) {
- dash_list[i] = (byte)(width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width);
+ dash_list[i] = cast(byte)(width is 0 || data.lineStyle is SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width);
}
OS.gdk_gc_set_dashes(handle, 0, dash_list, dash_list.length);
}
@@ -397,45 +414,45 @@
} else {
line_style = OS.GDK_LINE_SOLID;
}
- OS.gdk_gc_set_line_attributes(handle, width, line_style, cap_style, join_style);
+ OS.gdk_gc_set_line_attributes(handle, width,cast(GdkLineStyle) line_style, cast(GdkCapStyle)cap_style,cast(GdkJoinStyle) join_style);
}
}
-int /*long*/ convertRgn(int /*long*/ rgn, double[] matrix) {
- int /*long*/ newRgn = OS.gdk_region_new();
- int[] nRects = new int[1];
- int /*long*/[] rects = new int /*long*/[1];
- OS.gdk_region_get_rectangles(rgn, rects, nRects);
- GdkRectangle rect = new GdkRectangle();
+GdkRegion* convertRgn(GdkRegion* rgn, double[] matrix) {
+ auto newRgn = OS.gdk_region_new();
+ int nRects;
+ GdkRectangle* rects;
+ OS.gdk_region_get_rectangles(rgn, &rects, &nRects);
+ GdkRectangle* rect = new GdkRectangle();
int[] pointArray = new int[8];
- double[] x = new double[1], y = new double[1];
- for (int i=0; i
*/
public void copyArea(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.type !is SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
Rectangle rect = image.getBounds();
- int /*long*/ gdkGC = OS.gdk_gc_new(image.pixmap);
- if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS);
+ auto gdkGC = OS.gdk_gc_new(image.pixmap);
+ if (gdkGC is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.gdk_gc_set_subwindow(gdkGC, cast(GdkSubwindowMode) OS.GDK_INCLUDE_INFERIORS);
OS.gdk_draw_drawable(image.pixmap, gdkGC, data.drawable, x, y, 0, 0, rect.width, rect.height);
OS.g_object_unref(gdkGC);
}
@@ -503,44 +520,44 @@
*
* @since 3.1
*/
-public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, bool paint) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width <= 0 || height <= 0) return;
int deltaX = destX - srcX, deltaY = destY - srcY;
- if (deltaX == 0 && deltaY == 0) return;
- int /*long*/ drawable = data.drawable;
- if (data.image == null && paint) OS.gdk_gc_set_exposures(handle, true);
+ if (deltaX is 0 && deltaY is 0) return;
+ auto drawable = data.drawable;
+ if (data.image is null && paint) OS.gdk_gc_set_exposures(handle, true);
OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height);
- if (data.image == null & paint) {
+ if (data.image is null & paint) {
OS.gdk_gc_set_exposures(handle, false);
- boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
- GdkRectangle rect = new GdkRectangle ();
+ bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
+ GdkRectangle* rect = new GdkRectangle ();
if (disjoint) {
rect.x = srcX;
rect.y = srcY;
rect.width = width;
rect.height = height;
- OS.gdk_window_invalidate_rect (drawable, rect, false);
+ OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
} else {
- if (deltaX != 0) {
+ if (deltaX !is 0) {
int newX = destX - deltaX;
if (deltaX < 0) newX = destX + width;
rect.x = newX;
rect.y = srcY;
rect.width = Math.abs(deltaX);
rect.height = height;
- OS.gdk_window_invalidate_rect (drawable, rect, false);
+ OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
}
- if (deltaY != 0) {
+ if (deltaY !is 0) {
int newY = destY - deltaY;
if (deltaY < 0) newY = destY + height;
rect.x = srcX;
rect.y = newY;
rect.width = width;
rect.height = Math.abs(deltaY);
- OS.gdk_window_invalidate_rect (drawable, rect, false);
+ OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
}
}
@@ -548,25 +565,26 @@
}
void createLayout() {
- int /*long*/ context = OS.gdk_pango_context_get();
- if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto context = OS.gdk_pango_context_get();
+ if (context is null) SWT.error(SWT.ERROR_NO_HANDLES);
data.context = context;
- int /*long*/ layout = OS.pango_layout_new(context);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto layout = OS.pango_layout_new(context);
+ if (layout is null) SWT.error(SWT.ERROR_NO_HANDLES);
data.layout = layout;
OS.pango_context_set_language(context, OS.gtk_get_default_language());
- OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
+ OS.pango_context_set_base_dir(context, cast(PangoDirection) OS.PANGO_DIRECTION_LTR);
OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+ if (OS.GTK_VERSION >= OS.buildVERSION(2, 4, 0)) {
OS.pango_layout_set_auto_dir(layout, false);
}
}
void disposeLayout() {
- data.string = null;
- if (data.context != 0) OS.g_object_unref(data.context);
- if (data.layout != 0) OS.g_object_unref(data.layout);
- data.layout = data.context = 0;
+ data.str = null;
+ if (data.context !is null) OS.g_object_unref(data.context);
+ if (data.layout !is null) OS.g_object_unref(data.layout);
+ data.layout = null;
+ data.context = null;
}
/**
@@ -579,22 +597,22 @@
*
*/
public void dispose() {
- if (handle == 0) return;
+ if (handle is null) return;
if (data.device.isDisposed()) return;
if (data.disposeCairo) {
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) Cairo.cairo_destroy(cairo);
- data.cairo = 0;
+ auto cairo = data.cairo;
+ if (cairo !is null) Cairo.cairo_destroy(cairo);
+ data.cairo = null;
}
/* Free resources */
- int /*long*/ clipRgn = data.clipRgn;
- if (clipRgn != 0) OS.gdk_region_destroy(clipRgn);
+ auto clipRgn = data.clipRgn;
+ if (clipRgn !is null) OS.gdk_region_destroy(clipRgn);
Image image = data.image;
- if (image != null) {
+ if (image !is null) {
image.memGC = null;
- if (image.transparentPixel != -1) image.createMask();
+ if (image.transparentPixel !is -1) image.createMask();
}
disposeLayout();
@@ -603,11 +621,12 @@
Device device = data.device;
drawable.internal_dispose_GC(handle, data);
- data.drawable = data.clipRgn = 0;
+ data.drawable = null;
+ data.clipRgn = null;
drawable = null;
- handle = 0;
+ handle = null;
data.image = null;
- data.string = null;
+ data.str = null;
if (device.tracking) device.dispose_Object(this);
data.device = null;
data = null;
@@ -643,7 +662,7 @@
*
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -653,24 +672,24 @@
y = y + height;
height = -height;
}
- if (width == 0 || height == 0 || arcAngle == 0) return;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ if (width is 0 || height is 0 || arcAngle is 0) return;
+ auto cairo = data.cairo;
+ if (cairo !is null) {
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
- if (width == height) {
+ if (width is height) {
if (arcAngle >= 0) {
- Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
} else {
- Cairo.cairo_arc(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
}
} else {
Cairo.cairo_save(cairo);
Cairo.cairo_translate(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f);
Cairo.cairo_scale(cairo, width / 2f, height / 2f);
if (arcAngle >= 0) {
- Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
} else {
- Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
}
Cairo.cairo_restore(cairo);
}
@@ -698,31 +717,32 @@
* @see #drawRectangle(int, int, int, int)
*/
public void drawFocus(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
/*
* Feature in GTK. The function gtk_widget_get_default_style()
* can't be used here because gtk_paint_focus() uses GCs, which
* are not valid in the default style. The fix is to use a style
* from a widget.
*/
- int /*long*/ style = OS.gtk_widget_get_style(data.device.shellHandle);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto style = OS.gtk_widget_get_style(data.device.shellHandle);
+ auto cairo = data.cairo;
+ if (cairo !is null) {
checkGC(FOREGROUND);
- int[] lineWidth = new int[1];
- OS.gtk_widget_style_get(data.device.shellHandle, OS.focus_line_width, lineWidth, 0);
+ int lineWidth;
+ OS.gtk_widget_style_get1(data.device.shellHandle, OS.focus_line_width.ptr, &lineWidth );
Cairo.cairo_save(cairo);
- Cairo.cairo_set_line_width(cairo, lineWidth[0]);
- double[] dashes = new double[]{1, 1};
- double dash_offset = -lineWidth[0] / 2f;
+ Cairo.cairo_set_line_width(cairo, lineWidth);
+ double[] dashes = [1, 1];
+ double dash_offset = -lineWidth / 2f;
while (dash_offset < 0) dash_offset += 2;
- Cairo.cairo_set_dash(cairo, dashes, dashes.length, dash_offset);
- Cairo.cairo_rectangle(cairo, x + lineWidth[0] / 2f, y + lineWidth[0] / 2f, width, height);
+ Cairo.cairo_set_dash(cairo, dashes.ptr, dashes.length, dash_offset);
+ Cairo.cairo_rectangle(cairo, x + lineWidth / 2f, y + lineWidth / 2f, width, height);
Cairo.cairo_stroke(cairo);
Cairo.cairo_restore(cairo);
return;
}
- OS.gtk_paint_focus(style, data.drawable, OS.GTK_STATE_NORMAL, null, data.device.shellHandle, new byte[1], x, y, width, height);
+ char dummy;
+ OS.gtk_paint_focus(style,cast(GdkWindow *) data.drawable,cast(GtkStateType) OS.GTK_STATE_NORMAL, null, data.device.shellHandle, &dummy, x, y, width, height);
}
/**
@@ -745,8 +765,8 @@
*
*/
public void drawImage(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
@@ -784,43 +804,43 @@
*
*/
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (srcWidth is 0 || srcHeight is 0 || destWidth is 0 || destHeight is 0) return;
if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
}
-void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
- int[] width = new int[1];
- int[] height = new int[1];
- OS.gdk_drawable_get_size(srcImage.pixmap, width, height);
- int imgWidth = width[0];
- int imgHeight = height[0];
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) {
+ int width;
+ int height;
+ OS.gdk_drawable_get_size(srcImage.pixmap, &width, &height);
+ int imgWidth = width;
+ int imgHeight = height;
if (simple) {
srcWidth = destWidth = imgWidth;
srcHeight = destHeight = imgHeight;
} else {
- simple = srcX == 0 && srcY == 0 &&
- srcWidth == destWidth && destWidth == imgWidth &&
- srcHeight == destHeight && destHeight == imgHeight;
+ simple = srcX is 0 && srcY is 0 &&
+ srcWidth is destWidth && destWidth is imgWidth &&
+ srcHeight is destHeight && destHeight is imgHeight;
if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if (data.alpha != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if (data.alpha !is 0) {
srcImage.createSurface();
Cairo.cairo_save(cairo);
Cairo.cairo_rectangle(cairo, destX , destY, destWidth, destHeight);
Cairo.cairo_clip(cairo);
Cairo.cairo_translate(cairo, destX - srcX, destY - srcY);
- if (srcWidth != destWidth || srcHeight != destHeight) {
- Cairo.cairo_scale(cairo, destWidth / (float)srcWidth, destHeight / (float)srcHeight);
+ if (srcWidth !is destWidth || srcHeight !is destHeight) {
+ Cairo.cairo_scale(cairo, destWidth / cast(float)srcWidth, destHeight / cast(float)srcHeight);
}
int filter = Cairo.CAIRO_FILTER_GOOD;
switch (data.interpolation) {
@@ -829,9 +849,9 @@
case SWT.LOW: filter = Cairo.CAIRO_FILTER_FAST; break;
case SWT.HIGH: filter = Cairo.CAIRO_FILTER_BEST; break;
}
- int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface(srcImage.surface);
- if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- if (srcWidth != destWidth || srcHeight != destHeight) {
+ auto pattern = Cairo.cairo_pattern_create_for_surface(srcImage.surface);
+ if (pattern is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (srcWidth !is destWidth || srcHeight !is destHeight) {
/*
* Bug in Cairo. When drawing the image streched with an interpolation
* alghorithm, the edges of the image are faded. This is not a bug, but
@@ -848,8 +868,8 @@
* the image that was created or the edges are still faded.
*/
if (Cairo.cairo_version () >= Cairo.CAIRO_VERSION_ENCODE(1, 4, 0)) {
- int /*long*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, imgWidth * 3, imgHeight * 3);
- int /*long*/ cr = Cairo.cairo_create(surface);
+ auto surface = Cairo.cairo_image_surface_create(cast(cairo_format_t)Cairo.CAIRO_FORMAT_ARGB32, imgWidth * 3, imgHeight * 3);
+ auto cr = Cairo.cairo_create(surface);
Cairo.cairo_set_source_surface(cr, srcImage.surface, imgWidth, imgHeight);
Cairo.cairo_paint(cr);
Cairo.cairo_scale(cr, -1, -1);
@@ -872,22 +892,22 @@
Cairo.cairo_set_source_surface(cr, srcImage.surface, imgWidth, -imgHeight * 3);
Cairo.cairo_paint(cr);
Cairo.cairo_destroy(cr);
- int /*long*/ newPattern = Cairo.cairo_pattern_create_for_surface(surface);
+ auto newPattern = Cairo.cairo_pattern_create_for_surface(surface);
Cairo.cairo_surface_destroy(surface);
- if (newPattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (newPattern is null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_pattern_destroy(pattern);
pattern = newPattern;
- Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_PAD);
+ Cairo.cairo_pattern_set_extend(pattern,cast(cairo_extend_t) Cairo.CAIRO_EXTEND_PAD);
double[] matrix = new double[6];
- Cairo.cairo_matrix_init_translate(matrix, imgWidth, imgHeight);
- Cairo.cairo_pattern_set_matrix(pattern, matrix);
+ Cairo.cairo_matrix_init_translate(cast(cairo_matrix_t*)matrix.ptr, imgWidth, imgHeight);
+ Cairo.cairo_pattern_set_matrix(pattern, cast(cairo_matrix_t*)matrix.ptr);
}
// Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REFLECT);
}
- Cairo.cairo_pattern_set_filter(pattern, filter);
+ Cairo.cairo_pattern_set_filter(pattern,cast(cairo_filter_t) filter);
Cairo.cairo_set_source(cairo, pattern);
- if (data.alpha != 0xFF) {
- Cairo.cairo_paint_with_alpha(cairo, data.alpha / (float)0xFF);
+ if (data.alpha !is 0xFF) {
+ Cairo.cairo_paint_with_alpha(cairo, data.alpha / cast(float)0xFF);
} else {
Cairo.cairo_paint(cairo);
}
@@ -896,32 +916,32 @@
}
return;
}
- if (srcImage.alpha != -1 || srcImage.alphaData != null) {
+ if (srcImage.alpha !is -1 || srcImage.alphaData !is null) {
drawImageAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
- } else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) {
+ } else if (srcImage.transparentPixel !is -1 || srcImage.mask !is null) {
drawImageMask(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
} else {
drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
}
}
-void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
- if (srcWidth == destWidth && srcHeight == destHeight) {
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) {
+ if (srcWidth is destWidth && srcHeight is destHeight) {
OS.gdk_draw_drawable(data.drawable, handle, srcImage.pixmap, srcX, srcY, destX, destY, destWidth, destHeight);
} else {
if (device.useXRender) {
- drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, 0, -1);
+ drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, null, -1);
return;
}
- int /*long*/ pixbuf = scale(srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destWidth, destHeight);
- if (pixbuf != 0) {
- OS.gdk_pixbuf_render_to_drawable(pixbuf, data.drawable, handle, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+ auto pixbuf = scale(srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destWidth, destHeight);
+ if (pixbuf !is null) {
+ OS.gdk_pixbuf_render_to_drawable(pixbuf, data.drawable, handle, 0, 0, destX, destY, destWidth, destHeight,cast(GdkRgbDither) OS.GDK_RGB_DITHER_NORMAL, 0, 0);
OS.g_object_unref(pixbuf);
}
}
}
-void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
- if (srcImage.alpha == 0) return;
- if (srcImage.alpha == 255) {
+void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) {
+ if (srcImage.alpha is 0) return;
+ if (srcImage.alpha is 255) {
drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
return;
}
@@ -929,84 +949,84 @@
drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, srcImage.mask, OS.PictStandardA8);
return;
}
- int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
- if (pixbuf == 0) return;
- int /*long*/ colormap = OS.gdk_colormap_get_system();
+ auto pixbuf = OS.gdk_pixbuf_new(cast(GdkColorspace)OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
+ if (pixbuf is null) return;
+ auto colormap = OS.gdk_colormap_get_system();
OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
- int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+ auto pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
byte[] line = new byte[stride];
- byte alpha = (byte)srcImage.alpha;
+ byte alpha = cast(byte)srcImage.alpha;
byte[] alphaData = srcImage.alphaData;
for (int y=0; y= OS.VERSION (2, 2, 0)) {
- OS.gdk_draw_pixbuf(data.drawable, handle, pixbuf, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+ if (OS.GTK_VERSION >= OS.buildVERSION (2, 2, 0)) {
+ OS.gdk_draw_pixbuf(data.drawable, handle, pixbuf, 0, 0, destX, destY, destWidth, destHeight, cast(GdkRgbDither)OS.GDK_RGB_DITHER_NORMAL, 0, 0);
} else {
- OS.gdk_pixbuf_render_to_drawable_alpha(pixbuf, data.drawable, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_PIXBUF_ALPHA_BILEVEL, 128, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+ OS.gdk_pixbuf_render_to_drawable_alpha(pixbuf, data.drawable, 0, 0, destX, destY, destWidth, destHeight,cast(GdkPixbufAlphaMode) OS.GDK_PIXBUF_ALPHA_BILEVEL, 128, cast(GdkRgbDither) OS.GDK_RGB_DITHER_NORMAL, 0, 0);
}
OS.g_object_unref(pixbuf);
}
-void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
- int /*long*/ drawable = data.drawable;
- int /*long*/ colorPixmap = srcImage.pixmap;
+void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) {
+ auto drawable = data.drawable;
+ auto colorPixmap = srcImage.pixmap;
/* Generate the mask if necessary. */
- if (srcImage.transparentPixel != -1) srcImage.createMask();
- int /*long*/ maskPixmap = srcImage.mask;
+ if (srcImage.transparentPixel !is -1) srcImage.createMask();
+ auto maskPixmap = srcImage.mask;
if (device.useXRender) {
drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, maskPixmap, OS.PictStandardA1);
} else {
- if (srcWidth != destWidth || srcHeight != destHeight) {
- int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
- if (pixbuf != 0) {
- int /*long*/ colormap = OS.gdk_colormap_get_system();
+ if (srcWidth !is destWidth || srcHeight !is destHeight) {
+ auto pixbuf = OS.gdk_pixbuf_new(cast(GdkColorspace)OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
+ if (pixbuf !is null) {
+ auto colormap = OS.gdk_colormap_get_system();
OS.gdk_pixbuf_get_from_drawable(pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
- int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
- if (maskPixbuf != 0) {
- OS.gdk_pixbuf_get_from_drawable(maskPixbuf, maskPixmap, 0, srcX, srcY, 0, 0, srcWidth, srcHeight);
+ auto maskPixbuf = OS.gdk_pixbuf_new(cast(GdkColorspace)OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
+ if (maskPixbuf !is null) {
+ OS.gdk_pixbuf_get_from_drawable(maskPixbuf, maskPixmap, null, srcX, srcY, 0, 0, srcWidth, srcHeight);
int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
- int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+ auto pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
byte[] line = new byte[stride];
int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
- int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+ auto maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
byte[] maskLine = new byte[maskStride];
for (int y=0; y
*/
public void drawLine(int x1, int y1, int x2, int y2) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
Cairo.cairo_move_to(cairo, x1 + xOffset, y1 + yOffset);
Cairo.cairo_line_to(cairo, x2 + xOffset, y2 + yOffset);
@@ -1187,7 +1208,7 @@
*
*/
public void drawOval(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1197,16 +1218,16 @@
y = y + height;
height = -height;
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
- if (width == height) {
- Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, 0, -2 * (float)Compatibility.PI);
+ if (width is height) {
+ Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, 0, -2 * cast(float)Compatibility.PI);
} else {
Cairo.cairo_save(cairo);
Cairo.cairo_translate(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f);
Cairo.cairo_scale(cairo, width / 2f, height / 2f);
- Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, -2 * (float)Compatibility.PI);
+ Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, -2 * cast(float)Compatibility.PI);
Cairo.cairo_restore(cairo);
}
Cairo.cairo_stroke(cairo);
@@ -1239,17 +1260,17 @@
* @since 3.1
*/
public void drawPath(Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (path is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (path.handle is null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
initCairo();
checkGC(DRAW);
- int /*long*/ cairo = data.cairo;
+ auto cairo = data.cairo;
Cairo.cairo_save(cairo);
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
Cairo.cairo_translate(cairo, xOffset, yOffset);
- int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
- if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto copy = Cairo.cairo_copy_path(path.handle);
+ if (copy is null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_append_path(cairo, copy);
Cairo.cairo_path_destroy(copy);
Cairo.cairo_stroke(cairo);
@@ -1274,10 +1295,10 @@
* @since 3.0
*/
public void drawPoint (int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
Cairo.cairo_rectangle(cairo, x, y, 1, 1);
Cairo.cairo_fill(cairo);
return;
@@ -1303,16 +1324,16 @@
*
*/
public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
checkGC(DRAW);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
drawPolyline(cairo, pointArray, true);
Cairo.cairo_stroke(cairo);
return;
}
- OS.gdk_draw_polygon(data.drawable, handle, 0, pointArray, pointArray.length / 2);
+ OS.gdk_draw_polygon(data.drawable, handle, 0, cast(GdkPoint*)pointArray.ptr, pointArray.length / 2);
}
/**
@@ -1333,21 +1354,21 @@
*
*/
public void drawPolyline(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
checkGC(DRAW);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
drawPolyline(cairo, pointArray, false);
Cairo.cairo_stroke(cairo);
return;
}
- OS.gdk_draw_lines(data.drawable, handle, pointArray, pointArray.length / 2);
+ OS.gdk_draw_lines(data.drawable, handle, cast(GdkPoint*)pointArray.ptr, pointArray.length / 2);
}
-void drawPolyline(int /*long*/ cairo, int[] pointArray, boolean close) {
+void drawPolyline(cairo_t* cairo, int[] pointArray, bool close) {
int count = pointArray.length / 2;
- if (count == 0) return;
+ if (count is 0) return;
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
Cairo.cairo_move_to(cairo, pointArray[0] + xOffset, pointArray[1] + yOffset);
for (int i = 1, j=2; i < count; i++, j += 2) {
@@ -1372,7 +1393,7 @@
*
*/
public void drawRectangle(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1382,8 +1403,8 @@
y = y + height;
height = -height;
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
Cairo.cairo_rectangle(cairo, x + xOffset, y + yOffset, width, height);
Cairo.cairo_stroke(cairo);
@@ -1409,7 +1430,7 @@
*
*/
public void drawRectangle(Rectangle rect) {
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
drawRectangle (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -1434,7 +1455,7 @@
*
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
int nx = x;
int ny = y;
@@ -1452,8 +1473,8 @@
}
if (naw < 0) naw = 0 - naw;
if (nah < 0) nah = 0 - nah;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
float naw2 = naw / 2f;
float nah2 = nah / 2f;
float fw = nw / naw2;
@@ -1474,7 +1495,7 @@
}
int naw2 = naw / 2;
int nah2 = nah / 2;
- int /*long*/ drawable = data.drawable;
+ auto drawable = data.drawable;
if (nw > naw) {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 0, nx, ny, naw, nah, 5760, 5760);
@@ -1504,100 +1525,100 @@
}
/**
- * Draws the given string, using the receiver's current font and
+ * Draws the given str, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
* will be performed. The background of the rectangular area where
- * the string is being drawn will be filled with the receiver's
+ * the str is being drawn will be filled with the receiver's
* background color.
*
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param str the str to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the str is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the str is to be drawn
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
+public void drawString (char[] str, int x, int y) {
+ drawString(str, x, y, false);
}
/**
- * Draws the given string, using the receiver's current font and
+ * Draws the given str, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
* will be performed. If isTransparent
is true
,
- * then the background of the rectangular area where the string is being
+ * then the background of the rectangular area where the str is being
* drawn will not be modified, otherwise it will be filled with the
* receiver's background color.
*
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param str the str to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the str is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the str is to be drawn
* @param isTransparent if true
the background will be transparent, otherwise it will be opaque
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public void drawString(String string, int x, int y, boolean isTransparent) {
- drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
+public void drawString(char[] str, int x, int y, bool isTransparent) {
+ drawText(str, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
}
/**
- * Draws the given string, using the receiver's current font and
+ * Draws the given str, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
* are performed. The background of the rectangular area where
* the text is being drawn will be filled with the receiver's
* background color.
*
- * @param string the string to be drawn
+ * @param str the str to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public void drawText(String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+public void drawText(char[] str, int x, int y) {
+ drawText(str, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
- * Draws the given string, using the receiver's current font and
+ * Draws the given str, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
* are performed. If isTransparent
is true
,
* then the background of the rectangular area where the text is being
* drawn will not be modified, otherwise it will be filled with the
* receiver's background color.
*
- * @param string the string to be drawn
+ * @param str the str to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param isTransparent if true
the background will be transparent, otherwise it will be opaque
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public void drawText(String string, int x, int y, boolean isTransparent) {
+public void drawText(char[] str, int x, int y, bool isTransparent) {
int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
+ drawText(str, x, y, flags);
}
/**
- * Draws the given string, using the receiver's current font and
+ * Draws the given str, using the receiver's current font and
* foreground color. Tab expansion, line delimiter and mnemonic
* processing are performed according to the specified flags. If
* flags
includes DRAW_TRANSPARENT
,
@@ -1618,44 +1639,44 @@
*
*
*
- * @param string the string to be drawn
+ * @param str the str to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param flags the flags specifying how to process the text
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public void drawText (String string, int x, int y, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (string.length() == 0) return;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+public void drawText (char[] str, int x, int y, int flags) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (str is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (str.length is 0) return;
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if (OS.GTK_VERSION < OS.buildVERSION(2, 8, 0)) {
//TODO - honor flags
checkGC(FOREGROUND | FONT);
- cairo_font_extents_t extents = new cairo_font_extents_t();
+ cairo_font_extents_t* extents = new cairo_font_extents_t();
Cairo.cairo_font_extents(cairo, extents);
double baseline = y + extents.ascent;
Cairo.cairo_move_to(cairo, x, baseline);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- Cairo.cairo_show_text(cairo, buffer);
+ char[] buffer = str.dup;
+ Cairo.cairo_show_text(cairo, buffer.ptr);
Cairo.cairo_new_path(cairo);
return;
}
}
- setString(string, flags);
- if (cairo != 0) {
- if ((flags & SWT.DRAW_TRANSPARENT) == 0) {
+ setString(str, flags);
+ if (cairo !is null) {
+ if ((flags & SWT.DRAW_TRANSPARENT) is 0) {
checkGC(BACKGROUND);
- int[] width = new int[1], height = new int[1];
- OS.pango_layout_get_size(data.layout, width, height);
- Cairo.cairo_rectangle(cairo, x, y, OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
+ int width, height;
+ OS.pango_layout_get_size(data.layout, &width, &height);
+ Cairo.cairo_rectangle(cairo, x, y, OS.PANGO_PIXELS(width), OS.PANGO_PIXELS(height));
Cairo.cairo_fill(cairo);
}
checkGC(FOREGROUND | FONT);
@@ -1664,27 +1685,27 @@
return;
}
checkGC(FOREGROUND | FONT | BACKGROUND_BG);
- GdkColor background = null;
- if ((flags & SWT.DRAW_TRANSPARENT) == 0) background = data.background;
+ GdkColor* background = null;
+ if ((flags & SWT.DRAW_TRANSPARENT) is 0) background = data.background;
if (!data.xorMode) {
OS.gdk_draw_layout_with_colors(data.drawable, handle, x, y, data.layout, null, background);
} else {
- int /*long*/ layout = data.layout;
- int[] w = new int[1], h = new int[1];
- OS.pango_layout_get_size(layout, w, h);
- int width = OS.PANGO_PIXELS(w[0]);
- int height = OS.PANGO_PIXELS(h[0]);
- int /*long*/ pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
- if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
- if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- GdkColor black = new GdkColor();
+ auto layout = data.layout;
+ int w, h;
+ OS.pango_layout_get_size(layout, &w, &h);
+ int width = OS.PANGO_PIXELS(w);
+ int height = OS.PANGO_PIXELS(h);
+ auto pixmap = OS.gdk_pixmap_new(cast(GdkDrawable*)OS.GDK_ROOT_PARENT(), width, height, -1);
+ if (pixmap is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto gdkGC = OS.gdk_gc_new(cast(GdkDrawable*)pixmap);
+ if (gdkGC is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ GdkColor* black = new GdkColor();
OS.gdk_gc_set_foreground(gdkGC, black);
- OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height);
+ OS.gdk_draw_rectangle(cast(GdkDrawable*)pixmap, gdkGC, 1, 0, 0, width, height);
OS.gdk_gc_set_foreground(gdkGC, data.foreground);
- OS.gdk_draw_layout_with_colors(pixmap, gdkGC, 0, 0, layout, null, background);
+ OS.gdk_draw_layout_with_colors(cast(GdkDrawable*)pixmap, gdkGC, 0, 0, layout, null, background);
OS.g_object_unref(gdkGC);
- OS.gdk_draw_drawable(data.drawable, handle, pixmap, 0, 0, x, y, width, height);
+ OS.gdk_draw_drawable(data.drawable, handle, cast(GdkDrawable*)pixmap, 0, 0, x, y, width, height);
OS.g_object_unref(pixmap);
}
}
@@ -1699,12 +1720,15 @@
*
* @see #hashCode
*/
-public boolean equals(Object object) {
- if (object == this) return true;
- if (!(object instanceof GC)) return false;
- return handle == ((GC)object).handle;
+public override int opEquals(Object object) {
+ if (object is this) return true;
+ if ( auto gc = cast(GC)object){
+ return handle is gc.handle;
+ }
+ return false;
}
+
/**
* Fills the interior of a circular or elliptical arc within
* the specified rectangular area, with the receiver's background
@@ -1738,7 +1762,7 @@
* @see #drawArc
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -1748,14 +1772,14 @@
y = y + height;
height = -height;
}
- if (width == 0 || height == 0 || arcAngle == 0) return;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if (width == height) {
+ if (width is 0 || height is 0 || arcAngle is 0) return;
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if (width is height) {
if (arcAngle >= 0) {
- Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
} else {
- Cairo.cairo_arc(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
}
Cairo.cairo_line_to(cairo, x + width / 2f, y + height / 2f);
} else {
@@ -1763,9 +1787,9 @@
Cairo.cairo_translate(cairo, x + width / 2f, y + height / 2f);
Cairo.cairo_scale(cairo, width / 2f, height / 2f);
if (arcAngle >= 0) {
- Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
} else {
- Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+ Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * cast(float)Compatibility.PI / 180, -(startAngle + arcAngle) * cast(float)Compatibility.PI / 180);
}
Cairo.cairo_line_to(cairo, 0, 0);
Cairo.cairo_restore(cairo);
@@ -1796,9 +1820,9 @@
*
* @see #drawRectangle(int, int, int, int)
*/
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if ((width == 0) || (height == 0)) return;
+public void fillGradientRectangle(int x, int y, int width, int height, bool vertical) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if ((width is 0) || (height is 0)) return;
/* Rewrite this to use GdkPixbuf */
@@ -1809,7 +1833,7 @@
RGB fromRGB, toRGB;
fromRGB = foregroundRGB;
toRGB = backgroundRGB;
- boolean swapColors = false;
+ bool swapColors = false;
if (width < 0) {
x += width; width = -width;
if (! vertical) swapColors = true;
@@ -1822,13 +1846,13 @@
fromRGB = backgroundRGB;
toRGB = foregroundRGB;
}
- if (fromRGB.equals(toRGB)) {
+ if (fromRGB ==/*eq*/ toRGB ) {
fillRectangle(x, y, width, height);
return;
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- int /*long*/ pattern;
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ cairo_pattern_t* pattern;
if (vertical) {
pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 0.0, 1.0);
} else {
@@ -1868,7 +1892,7 @@
* @see #drawOval
*/
public void fillOval(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -1878,15 +1902,15 @@
y = y + height;
height = -height;
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if (width == height) {
- Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, 0, 2 * (float)Compatibility.PI);
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if (width is height) {
+ Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, 0, 2 * cast(float)Compatibility.PI);
} else {
Cairo.cairo_save(cairo);
Cairo.cairo_translate(cairo, x + width / 2f, y + height / 2f);
Cairo.cairo_scale(cairo, width / 2f, height / 2f);
- Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, 2 * (float)Compatibility.PI);
+ Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, 2 * cast(float)Compatibility.PI);
Cairo.cairo_restore(cairo);
}
Cairo.cairo_fill(cairo);
@@ -1919,14 +1943,14 @@
* @since 3.1
*/
public void fillPath (Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (path is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (path.handle is null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
initCairo();
checkGC(FILL);
- int /*long*/ cairo = data.cairo;
- int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
- if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto cairo = data.cairo;
+ auto copy = Cairo.cairo_copy_path(path.handle);
+ if (copy is null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_append_path(cairo, copy);
Cairo.cairo_path_destroy(copy);
Cairo.cairo_fill(cairo);
@@ -1952,16 +1976,16 @@
* @see #drawPolygon
*/
public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
checkGC(FILL);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
drawPolyline(cairo, pointArray, true);
Cairo.cairo_fill(cairo);
return;
}
- OS.gdk_draw_polygon(data.drawable, handle, 1, pointArray, pointArray.length / 2);
+ OS.gdk_draw_polygon(data.drawable, handle, 1, cast(GdkPoint*)pointArray.ptr, pointArray.length / 2);
}
/**
@@ -1980,7 +2004,7 @@
* @see #drawRectangle(int, int, int, int)
*/
public void fillRectangle(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -1990,8 +2014,8 @@
y = y + height;
height = -height;
}
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
Cairo.cairo_rectangle(cairo, x, y, width, height);
Cairo.cairo_fill(cairo);
return;
@@ -2015,8 +2039,8 @@
* @see #drawRectangle(int, int, int, int)
*/
public void fillRectangle(Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
fillRectangle(rect.x, rect.y, rect.width, rect.height);
}
@@ -2038,7 +2062,7 @@
* @see #drawRoundRectangle
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
int nx = x;
int ny = y;
@@ -2056,8 +2080,8 @@
}
if (naw < 0) naw = 0 - naw;
if (nah < 0) nah = 0 - nah;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
+ auto cairo = data.cairo;
+ if (cairo !is null) {
float naw2 = naw / 2f;
float nah2 = nah / 2f;
float fw = nw / naw2;
@@ -2077,7 +2101,7 @@
}
int naw2 = naw / 2;
int nah2 = nah / 2;
- int /*long*/ drawable = data.drawable;
+ auto drawable = data.drawable;
if (nw > naw) {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 1, nx, ny, naw, nah, 5760, 5760);
@@ -2107,10 +2131,10 @@
int i=0, j=0;
int mnemonic=-1;
while (i < buffer.length) {
- if ((buffer [j++] = buffer [i++]) == '&') {
- if (i == buffer.length) {continue;}
- if (buffer [i] == '&') {i++; continue;}
- if (mnemonic == -1) mnemonic = j;
+ if ((buffer [j++] = buffer [i++]) is '&') {
+ if (i is buffer.length) {continue;}
+ if (buffer [i] is '&') {i++; continue;}
+ if (mnemonic is -1) mnemonic = j;
j--;
}
}
@@ -2134,9 +2158,9 @@
*
*/
public int getAdvanceWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtent([ch]).x;
}
/**
@@ -2164,9 +2188,9 @@
*
* @since 3.1
*/
-public boolean getAdvanced() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.cairo != 0;
+public bool getAdvanced() {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.cairo !is null;
}
/**
@@ -2181,7 +2205,7 @@
* @since 3.1
*/
public int getAlpha() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.alpha;
}
@@ -2202,8 +2226,8 @@
* @since 3.1
*/
public int getAntialias() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0) return SWT.DEFAULT;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null) return SWT.DEFAULT;
int antialias = Cairo.cairo_get_antialias(data.cairo);
switch (antialias) {
case Cairo.CAIRO_ANTIALIAS_DEFAULT: return SWT.DEFAULT;
@@ -2224,7 +2248,7 @@
*
*/
public Color getBackground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Color.gtk_new(data.device, data.background);
}
@@ -2243,7 +2267,7 @@
* @since 3.1
*/
public Pattern getBackgroundPattern() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.backgroundPattern;
}
@@ -2264,9 +2288,9 @@
*
*/
public int getCharWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtent([ch]).x;
}
/**
@@ -2282,30 +2306,30 @@
*
*/
public Rectangle getClipping() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
/* Calculate visible bounds in device space */
int x = 0, y = 0, width = 0, height = 0;
- int[] w = new int[1], h = new int[1];
- OS.gdk_drawable_get_size(data.drawable, w, h);
- width = w[0];
- height = h[0];
+ int w, h;
+ OS.gdk_drawable_get_size(data.drawable, &w, &h);
+ width = w;
+ height = h;
/* Intersect visible bounds with clipping in device space and then convert then to user space */
- int /*long*/ cairo = data.cairo;
- int /*long*/ clipRgn = data.clipRgn;
- int /*long*/ damageRgn = data.damageRgn;
- if (clipRgn != 0 || damageRgn != 0 || cairo != 0) {
- int /*long*/ rgn = OS.gdk_region_new();
- GdkRectangle rect = new GdkRectangle();
+ auto cairo = data.cairo;
+ auto clipRgn = data.clipRgn;
+ auto damageRgn = data.damageRgn;
+ if (clipRgn !is null || damageRgn !is null || cairo !is null) {
+ auto rgn = OS.gdk_region_new();
+ GdkRectangle* rect = new GdkRectangle();
rect.width = width;
rect.height = height;
OS.gdk_region_union_with_rect(rgn, rect);
- if (damageRgn != 0) {
+ if (damageRgn !is null) {
OS.gdk_region_intersect (rgn, damageRgn);
}
/* Intersect visible bounds with clipping */
- if (clipRgn != 0) {
+ if (clipRgn !is null) {
/* Convert clipping to device space if needed */
- if (data.clippingTransform != null) {
+ if (data.clippingTransform !is null) {
clipRgn = convertRgn(clipRgn, data.clippingTransform);
OS.gdk_region_intersect(rgn, clipRgn);
OS.gdk_region_destroy(clipRgn);
@@ -2314,10 +2338,10 @@
}
}
/* Convert to user space */
- if (cairo != 0) {
+ if (cairo !is null) {
double[] matrix = new double[6];
- Cairo.cairo_get_matrix(cairo, matrix);
- Cairo.cairo_matrix_invert(matrix);
+ Cairo.cairo_get_matrix(cairo, cast(cairo_matrix_t*)matrix.ptr);
+ Cairo.cairo_matrix_invert(cast(cairo_matrix_t*)matrix.ptr);
clipRgn = convertRgn(rgn, matrix);
OS.gdk_region_destroy(rgn);
rgn = clipRgn;
@@ -2347,39 +2371,39 @@
*
*/
public void getClipping(Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int /*long*/ clipping = region.handle;
+ auto clipping = region.handle;
OS.gdk_region_subtract(clipping, clipping);
- int /*long*/ cairo = data.cairo;
- int /*long*/ clipRgn = data.clipRgn;
- if (clipRgn == 0) {
- int[] width = new int[1], height = new int[1];
- OS.gdk_drawable_get_size(data.drawable, width, height);
- GdkRectangle rect = new GdkRectangle();
- rect.width = width[0];
- rect.height = height[0];
+ auto cairo = data.cairo;
+ auto clipRgn = data.clipRgn;
+ if (clipRgn is null) {
+ int width,height;
+ OS.gdk_drawable_get_size(data.drawable, &width, &height);
+ GdkRectangle* rect = new GdkRectangle();
+ rect.width = width;
+ rect.height = height;
OS.gdk_region_union_with_rect(clipping, rect);
} else {
/* Convert clipping to device space if needed */
- if (data.clippingTransform != null) {
- int /*long*/ rgn = convertRgn(clipRgn, data.clippingTransform);
+ if (data.clippingTransform !is null) {
+ auto rgn = convertRgn(clipRgn, data.clippingTransform);
OS.gdk_region_union(clipping, rgn);
OS.gdk_region_destroy(rgn);
} else {
OS.gdk_region_union(clipping, clipRgn);
}
}
- if (data.damageRgn != 0) {
+ if (data.damageRgn !is null) {
OS.gdk_region_intersect(clipping, data.damageRgn);
}
/* Convert to user space */
- if (cairo != 0) {
+ if (cairo !is null) {
double[] matrix = new double[6];
- Cairo.cairo_get_matrix(cairo, matrix);
- Cairo.cairo_matrix_invert(matrix);
- int /*long*/ rgn = convertRgn(clipping, matrix);
+ Cairo.cairo_get_matrix(cairo, cast(cairo_matrix_t*)matrix.ptr);
+ Cairo.cairo_matrix_invert(cast(cairo_matrix_t*)matrix.ptr);
+ auto rgn = convertRgn(clipping, matrix);
OS.gdk_region_subtract(clipping, clipping);
OS.gdk_region_union(clipping, rgn);
OS.gdk_region_destroy(rgn);
@@ -2399,10 +2423,10 @@
* @since 3.1
*/
public int getFillRule() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int /*long*/ cairo = data.cairo;
- if (cairo == 0) return SWT.FILL_EVEN_ODD;
- return Cairo.cairo_get_fill_rule(cairo) == Cairo.CAIRO_FILL_RULE_WINDING ? SWT.FILL_WINDING : SWT.FILL_EVEN_ODD;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ auto cairo = data.cairo;
+ if (cairo is null) return SWT.FILL_EVEN_ODD;
+ return Cairo.cairo_get_fill_rule(cairo) is Cairo.CAIRO_FILL_RULE_WINDING ? SWT.FILL_WINDING : SWT.FILL_EVEN_ODD;
}
/**
@@ -2416,7 +2440,7 @@
*
*/
public Font getFont() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Font.gtk_new(data.device, data.font);
}
@@ -2432,12 +2456,12 @@
*
*/
public FontMetrics getFontMetrics() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.context == 0) createLayout();
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.context is null) createLayout();
checkGC(FONT);
- int /*long*/ context = data.context;
- int /*long*/ lang = OS.pango_context_get_language(context);
- int /*long*/ metrics = OS.pango_context_get_metrics(context, data.font, lang);
+ auto context = data.context;
+ auto lang = OS.pango_context_get_language(context);
+ auto metrics = OS.pango_context_get_metrics(context, data.font, lang);
FontMetrics fm = new FontMetrics();
fm.ascent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_ascent(metrics));
fm.descent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_descent(metrics));
@@ -2457,7 +2481,7 @@
*
*/
public Color getForeground() {
- if (handle == 0) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
return Color.gtk_new(data.device, data.foreground);
}
@@ -2476,7 +2500,7 @@
* @since 3.1
*/
public Pattern getForegroundPattern() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.foregroundPattern;
}
@@ -2501,7 +2525,7 @@
* @since 3.2
*/
public GCData getGCData() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data;
}
@@ -2519,7 +2543,7 @@
* @since 3.1
*/
public int getInterpolation() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.interpolation;
}
@@ -2535,11 +2559,10 @@
* @since 3.3
*/
public LineAttributes getLineAttributes() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
float[] dashes = null;
- if (data.lineDashes != null) {
- dashes = new float[data.lineDashes.length];
- System.arraycopy(data.lineDashes, 0, dashes, 0, dashes.length);
+ if (data.lineDashes !is null) {
+ dashes = data.lineDashes.dup;
}
return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, data.lineDashesOffset, data.lineMiterLimit);
}
@@ -2558,7 +2581,7 @@
* @since 3.1
*/
public int getLineCap() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineCap;
}
@@ -2575,11 +2598,11 @@
* @since 3.1
*/
public int[] getLineDash() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.lineDashes == null) return null;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.lineDashes is null) return null;
int[] lineDashes = new int[data.lineDashes.length];
for (int i = 0; i < lineDashes.length; i++) {
- lineDashes[i] = (int)data.lineDashes[i];
+ lineDashes[i] = cast(int)data.lineDashes[i];
}
return lineDashes;
}
@@ -2598,7 +2621,7 @@
* @since 3.1
*/
public int getLineJoin() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineJoin;
}
@@ -2615,7 +2638,7 @@
*
*/
public int getLineStyle() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineStyle;
}
@@ -2632,8 +2655,8 @@
*
*/
public int getLineWidth() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (int)data.lineWidth;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return cast(int)data.lineWidth;
}
/**
@@ -2655,7 +2678,7 @@
* @since 2.1.2
*/
public int getStyle () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.style;
}
@@ -2676,18 +2699,18 @@
* @since 3.1
*/
public int getTextAntialias() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0) return SWT.DEFAULT;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null) return SWT.DEFAULT;
int antialias = Cairo.CAIRO_ANTIALIAS_DEFAULT;
- if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
- int /*long*/ options = Cairo.cairo_font_options_create();
+ if (OS.GTK_VERSION < OS.buildVERSION(2, 8, 0)) {
+ auto options = Cairo.cairo_font_options_create();
Cairo.cairo_get_font_options(data.cairo, options);
antialias = Cairo.cairo_font_options_get_antialias(options);
Cairo.cairo_font_options_destroy(options);
} else {
- if (data.context != 0) {
- int /*long*/ options = OS.pango_cairo_context_get_font_options(data.context);
- if (options != 0) antialias = Cairo.cairo_font_options_get_antialias(options);
+ if (data.context !is null) {
+ auto options = OS.pango_cairo_context_get_font_options(data.context);
+ if (options !is null) antialias = Cairo.cairo_font_options_get_antialias(options);
}
}
switch (antialias) {
@@ -2718,12 +2741,12 @@
* @since 3.1
*/
public void getTransform(Transform transform) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transform == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (transform is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- Cairo.cairo_get_matrix(cairo, transform.handle);
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ Cairo.cairo_get_matrix(cairo, cast(cairo_matrix_t*)transform.handle.ptr);
} else {
transform.setElements(1, 0, 0, 1, 0, 0);
}
@@ -2743,8 +2766,8 @@
* ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public boolean getXORMode() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public bool getXORMode() {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.xorMode;
}
@@ -2763,23 +2786,23 @@
* @see #equals
*/
public int hashCode() {
- return (int)/*64*/handle;
+ return cast(int)/*64*/handle;
}
-void init(Drawable drawable, GCData data, int /*long*/ gdkGC) {
- if (data.foreground != null) data.state &= ~FOREGROUND;
- if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG);
- if (data.font != 0) data.state &= ~FONT;
+void init(Drawable drawable, GCData data, GdkGC* gdkGC) {
+ if (data.foreground !is null) data.state &= ~FOREGROUND;
+ if (data.background !is null) data.state &= ~(BACKGROUND | BACKGROUND_BG);
+ if (data.font !is null) data.state &= ~FONT;
Image image = data.image;
- if (image != null) {
+ if (image !is null) {
image.memGC = this;
/*
* The transparent pixel mask might change when drawing on
* the image. Destroy it so that it is regenerated when
* necessary.
*/
- if (image.transparentPixel != -1) image.destroyMask();
+ if (image.transparentPixel !is -1) image.destroyMask();
}
this.drawable = drawable;
this.data = data;
@@ -2788,34 +2811,34 @@
void initCairo() {
data.device.checkCairo();
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) return;
- int /*long*/ xDisplay = OS.GDK_DISPLAY();
- int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system());
- int /*long*/ xDrawable = 0;
+ auto cairo = data.cairo;
+ if (cairo !is null) return;
+ auto xDisplay = OS.GDK_DISPLAY();
+ auto xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system());
+ XID xDrawable;
int translateX = 0, translateY = 0;
- int /*long*/ drawable = data.drawable;
- if (data.image != null) {
+ auto drawable = data.drawable;
+ if (data.image !is null) {
xDrawable = OS.GDK_PIXMAP_XID(drawable);
} else {
- int[] x = new int[1], y = new int[1];
- int /*long*/ [] real_drawable = new int /*long*/ [1];
- OS.gdk_window_get_internal_paint_info(drawable, real_drawable, x, y);
- xDrawable = OS.gdk_x11_drawable_get_xid(real_drawable[0]);
- translateX = -x[0];
- translateY = -y[0];
+ int x, y;
+ GdkDrawable* real_drawable;
+ OS.gdk_window_get_internal_paint_info(cast(GdkWindow*)drawable, &real_drawable, &x, &y);
+ xDrawable = OS.gdk_x11_drawable_get_xid(real_drawable);
+ translateX = -x;
+ translateY = -y;
}
- int[] w = new int[1], h = new int[1];
- OS.gdk_drawable_get_size(drawable, w, h);
- int width = w[0], height = h[0];
- int /*long*/ surface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height);
- if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int w, h;
+ OS.gdk_drawable_get_size(drawable, &w, &h);
+ int width = w, height = h;
+ auto surface = Cairo.cairo_xlib_surface_create(cast(dwt.internal.gtk.c.cairotypes.Display*)xDisplay, xDrawable, xVisual, width, height);
+ if (surface is null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_surface_set_device_offset(surface, translateX, translateY);
data.cairo = cairo = Cairo.cairo_create(surface);
Cairo.cairo_surface_destroy(surface);
- if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (cairo is null) SWT.error(SWT.ERROR_NO_HANDLES);
data.disposeCairo = true;
- Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD);
+ Cairo.cairo_set_fill_rule(cairo, cast(cairo_fill_rule_t) Cairo.CAIRO_FILL_RULE_EVEN_ODD);
data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET);
setCairoClip(cairo, data.clipRgn);
}
@@ -2834,9 +2857,9 @@
* ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public boolean isClipped() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.clipRgn != 0;
+public bool isClipped() {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.clipRgn !is null;
}
/**
@@ -2849,13 +2872,13 @@
*
* @return true
when the GC is disposed and false
otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
+public bool isDisposed() {
+ return handle is null;
}
-boolean isIdentity(double[] matrix) {
- if (matrix == null) return true;
- return matrix[0] == 1 && matrix[1] == 0 && matrix[2] == 0 && matrix[3] == 1 && matrix[4] == 0 && matrix[5] == 0;
+bool isIdentity(double[] matrix) {
+ if (matrix is null) return true;
+ return matrix[0] is 1 && matrix[1] is 0 && matrix[2] is 0 && matrix[3] is 1 && matrix[4] is 0 && matrix[5] is 0;
}
/**
@@ -2900,22 +2923,22 @@
*
* @since 3.1
*/
-public void setAdvanced(boolean advanced) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (advanced && data.cairo != 0) return;
+public void setAdvanced(bool advanced) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (advanced && data.cairo !is null) return;
if (advanced) {
try {
initCairo();
} catch (SWTException e) {}
} else {
if (!data.disposeCairo) return;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) Cairo.cairo_destroy(cairo);
- data.cairo = 0;
+ auto cairo = data.cairo;
+ if (cairo !is null) Cairo.cairo_destroy(cairo);
+ data.cairo = null;
data.interpolation = SWT.DEFAULT;
data.backgroundPattern = data.foregroundPattern = null;
data.state = 0;
- setClipping(0);
+ setClipping(cast(GdkRegion*)null);
}
}
@@ -2939,8 +2962,8 @@
* @since 3.1
*/
public void setAlpha(int alpha) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0 && (alpha & 0xff) == 0xff) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null && (alpha & 0xff) is 0xff) return;
initCairo();
data.alpha = alpha & 0xff;
data.state &= ~(BACKGROUND | FOREGROUND | BACKGROUND_BG);
@@ -2975,8 +2998,8 @@
* @since 3.1
*/
public void setAntialias(int antialias) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0 && antialias == SWT.DEFAULT) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null && antialias is SWT.DEFAULT) return;
int mode = 0;
switch (antialias) {
case SWT.DEFAULT: mode = Cairo.CAIRO_ANTIALIAS_DEFAULT; break;
@@ -2987,8 +3010,8 @@
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
initCairo();
- int /*long*/ cairo = data.cairo;
- Cairo.cairo_set_antialias(cairo, mode);
+ auto cairo = data.cairo;
+ Cairo.cairo_set_antialias(cairo,cast(cairo_antialias_t) mode);
}
/**
@@ -3007,8 +3030,8 @@
*
*/
public void setBackground(Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
data.background = color.handle;
data.backgroundPattern = null;
@@ -3040,96 +3063,95 @@
* @since 3.1
*/
public void setBackgroundPattern(Pattern pattern) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pattern != null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (data.cairo == 0 && pattern == null) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pattern !is null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (data.cairo is null && pattern is null) return;
initCairo();
- if (data.backgroundPattern == pattern) return;
+ if (data.backgroundPattern is pattern) return;
data.backgroundPattern = pattern;
data.state &= ~BACKGROUND;
}
-static void setCairoFont(int /*long*/ cairo, Font font) {
+static void setCairoFont(cairo_t* cairo, Font font) {
setCairoFont(cairo, font.handle);
}
-static void setCairoFont(int /*long*/ cairo, int /*long*/ font) {
- int /*long*/ family = OS.pango_font_description_get_family(font);
- int length = OS.strlen(family);
- byte[] buffer = new byte[length + 1];
- OS.memmove(buffer, family, length);
+static void setCairoFont(cairo_t* cairo, PangoFontDescription* font) {
+ auto family = OS.pango_font_description_get_family(font);
+ int len = /*OS.*/strlen(family);
+ char[] buffer = new char[len + 1];
+ memmove(buffer.ptr, family, len);
//TODO - convert font height from pango to cairo
double height = OS.PANGO_PIXELS(OS.pango_font_description_get_size(font)) * 96 / 72;
int pangoStyle = OS.pango_font_description_get_style(font);
int pangoWeight = OS.pango_font_description_get_weight(font);
int slant = Cairo.CAIRO_FONT_SLANT_NORMAL;
- if (pangoStyle == OS.PANGO_STYLE_ITALIC) slant = Cairo.CAIRO_FONT_SLANT_ITALIC;
- if (pangoStyle == OS.PANGO_STYLE_OBLIQUE) slant = Cairo.CAIRO_FONT_SLANT_OBLIQUE;
+ if (pangoStyle is OS.PANGO_STYLE_ITALIC) slant = Cairo.CAIRO_FONT_SLANT_ITALIC;
+ if (pangoStyle is OS.PANGO_STYLE_OBLIQUE) slant = Cairo.CAIRO_FONT_SLANT_OBLIQUE;
int weight = Cairo.CAIRO_FONT_WEIGHT_NORMAL;
- if (pangoWeight == OS.PANGO_WEIGHT_BOLD) weight = Cairo.CAIRO_FONT_WEIGHT_BOLD;
- Cairo.cairo_select_font_face(cairo, buffer, slant, weight);
+ if (pangoWeight is OS.PANGO_WEIGHT_BOLD) weight = Cairo.CAIRO_FONT_WEIGHT_BOLD;
+ Cairo.cairo_select_font_face(cairo, buffer.ptr, cast(cairo_font_slant_t)slant, cast(cairo_font_weight_t)weight);
Cairo.cairo_set_font_size(cairo, height);
}
-static void setCairoClip(int /*long*/ cairo, int /*long*/ clipRgn) {
+static void setCairoClip(cairo_t* cairo, GdkRegion* clipRgn) {
Cairo.cairo_reset_clip(cairo);
- if (clipRgn == 0) return;
- if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ if (clipRgn is null) return;
+ if (OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
OS.gdk_cairo_region(cairo, clipRgn);
} else {
- int[] nRects = new int[1];
- int /*long*/[] rects = new int /*long*/[1];
- OS.gdk_region_get_rectangles(clipRgn, rects, nRects);
- GdkRectangle rect = new GdkRectangle();
- for (int i=0; i
*/
public void setClipping(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
@@ -3158,12 +3180,12 @@
y = y + height;
height = -height;
}
- GdkRectangle rect = new GdkRectangle();
+ GdkRectangle* rect = new GdkRectangle();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
- int /*long*/ clipRgn = OS.gdk_region_new();
+ auto clipRgn = OS.gdk_region_new();
OS.gdk_region_union_with_rect(clipRgn, rect);
setClipping(clipRgn);
OS.gdk_region_destroy(clipRgn);
@@ -3196,14 +3218,14 @@
* @since 3.1
*/
public void setClipping(Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path != null && path.isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- setClipping(0);
- if (path != null) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (path !is null && path.isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ setClipping(cast(GdkRegion*)null);
+ if (path !is null) {
initCairo();
- int /*long*/ cairo = data.cairo;
- int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
- if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto cairo = data.cairo;
+ auto copy = Cairo.cairo_copy_path(path.handle);
+ if (copy is null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_append_path(cairo, copy);
Cairo.cairo_path_destroy(copy);
Cairo.cairo_clip(cairo);
@@ -3224,9 +3246,9 @@
*
*/
public void setClipping(Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) {
- setClipping(0);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect is null) {
+ setClipping(cast(GdkRegion*)null);
} else {
setClipping(rect.x, rect.y, rect.width, rect.height);
}
@@ -3248,9 +3270,9 @@
*
*/
public void setClipping(Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region != null && region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setClipping(region != null ? region.handle : 0);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region !is null && region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setClipping(region !is null ? region.handle : cast(GdkRegion*)null);
}
/**
@@ -3269,8 +3291,8 @@
*
*/
public void setFont(Font font) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (font == null) font = data.device.systemFont;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (font is null) font = data.device.systemFont;
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
data.font = font.handle;
data.state &= ~FONT;
@@ -3294,7 +3316,7 @@
* @since 3.1
*/
public void setFillRule(int rule) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int cairo_mode = Cairo.CAIRO_FILL_RULE_EVEN_ODD;
switch (rule) {
case SWT.FILL_WINDING:
@@ -3306,9 +3328,9 @@
}
//TODO - need fill rule in X, GDK has no API
initCairo();
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- Cairo.cairo_set_fill_rule(cairo, cairo_mode);
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ Cairo.cairo_set_fill_rule(cairo,cast(cairo_fill_rule_t) cairo_mode);
}
}
@@ -3327,8 +3349,8 @@
*
*/
public void setForeground(Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
data.foreground = color.handle;
data.foregroundPattern = null;
@@ -3359,11 +3381,11 @@
* @since 3.1
*/
public void setForegroundPattern(Pattern pattern) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pattern != null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (data.cairo == 0 && pattern == null) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pattern !is null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (data.cairo is null && pattern is null) return;
initCairo();
- if (data.foregroundPattern == pattern) return;
+ if (data.foregroundPattern is pattern) return;
data.foregroundPattern = pattern;
data.state &= ~FOREGROUND;
}
@@ -3395,8 +3417,8 @@
* @since 3.1
*/
public void setInterpolation(int interpolation) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0 && interpolation == SWT.DEFAULT) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null && interpolation is SWT.DEFAULT) return;
switch (interpolation) {
case SWT.DEFAULT:
case SWT.NONE:
@@ -3435,15 +3457,15 @@
* @since 3.3
*/
public void setLineAttributes(LineAttributes attributes) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (attributes is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
int mask = 0;
float lineWidth = attributes.width;
- if (lineWidth != data.lineWidth) {
+ if (lineWidth !is data.lineWidth) {
mask |= LINE_WIDTH | DRAW_OFFSET;
}
int lineStyle = attributes.style;
- if (lineStyle != data.lineStyle) {
+ if (lineStyle !is data.lineStyle) {
mask |= LINE_STYLE;
switch (lineStyle) {
case SWT.LINE_SOLID:
@@ -3453,14 +3475,14 @@
case SWT.LINE_DASHDOTDOT:
break;
case SWT.LINE_CUSTOM:
- if (attributes.dash == null) lineStyle = SWT.LINE_SOLID;
+ if (attributes.dash is null) lineStyle = SWT.LINE_SOLID;
break;
default:
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
}
int join = attributes.join;
- if (join != data.lineJoin) {
+ if (join !is data.lineJoin) {
mask |= LINE_JOIN;
switch (join) {
case SWT.CAP_ROUND:
@@ -3472,7 +3494,7 @@
}
}
int cap = attributes.join;
- if (cap != data.lineCap) {
+ if (cap !is data.lineCap) {
mask |= LINE_CAP;
switch (cap) {
case SWT.JOIN_MITER:
@@ -3485,38 +3507,36 @@
}
float[] dashes = attributes.dash;
float[] lineDashes = data.lineDashes;
- if (dashes != null && dashes.length > 0) {
- boolean changed = lineDashes == null || lineDashes.length != dashes.length;
+ if (dashes !is null && dashes.length > 0) {
+ bool changed = lineDashes is null || lineDashes.length !is dashes.length;
for (int i = 0; i < dashes.length; i++) {
float dash = dashes[i];
if (dash <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (!changed && lineDashes[i] != dash) changed = true;
+ if (!changed && lineDashes[i] !is dash) changed = true;
}
if (changed) {
- float[] newDashes = new float[dashes.length];
- System.arraycopy(dashes, 0, newDashes, 0, dashes.length);
- dashes = newDashes;
+ dashes = dashes.dup;
mask |= LINE_STYLE;
} else {
dashes = lineDashes;
}
} else {
- if (lineDashes != null && lineDashes.length > 0) {
+ if (lineDashes !is null && lineDashes.length > 0) {
mask |= LINE_STYLE;
} else {
dashes = lineDashes;
}
}
float dashOffset = attributes.dashOffset;
- if (dashOffset != data.lineDashesOffset) {
+ if (dashOffset !is data.lineDashesOffset) {
mask |= LINE_STYLE;
}
float miterLimit = attributes.miterLimit;
- if (miterLimit != data.lineMiterLimit) {
+ if (miterLimit !is data.lineMiterLimit) {
mask |= LINE_MITERLIMIT;
}
initCairo();
- if (mask == 0) return;
+ if (mask is 0) return;
data.lineWidth = lineWidth;
data.lineStyle = lineStyle;
data.lineCap = cap;
@@ -3544,8 +3564,8 @@
* @since 3.1
*/
public void setLineCap(int cap) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.lineCap == cap) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.lineCap is cap) return;
switch (cap) {
case SWT.CAP_ROUND:
case SWT.CAP_FLAT:
@@ -3576,14 +3596,14 @@
* @since 3.1
*/
public void setLineDash(int[] dashes) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
float[] lineDashes = data.lineDashes;
- if (dashes != null && dashes.length > 0) {
- boolean changed = data.lineStyle != SWT.LINE_CUSTOM || lineDashes == null || lineDashes.length != dashes.length;
+ if (dashes !is null && dashes.length > 0) {
+ bool changed = data.lineStyle !is SWT.LINE_CUSTOM || lineDashes is null || lineDashes.length !is dashes.length;
for (int i = 0; i < dashes.length; i++) {
int dash = dashes[i];
if (dash <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (!changed && lineDashes[i] != dash) changed = true;
+ if (!changed && lineDashes[i] !is dash) changed = true;
}
if (!changed) return;
data.lineDashes = new float[dashes.length];
@@ -3592,7 +3612,7 @@
}
data.lineStyle = SWT.LINE_CUSTOM;
} else {
- if (data.lineStyle == SWT.LINE_SOLID && (lineDashes == null || lineDashes.length == 0)) return;
+ if (data.lineStyle is SWT.LINE_SOLID && (lineDashes is null || lineDashes.length is 0)) return;
data.lineDashes = null;
data.lineStyle = SWT.LINE_SOLID;
}
@@ -3616,8 +3636,8 @@
* @since 3.1
*/
public void setLineJoin(int join) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.lineJoin == join) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.lineJoin is join) return;
switch (join) {
case SWT.JOIN_MITER:
case SWT.JOIN_ROUND:
@@ -3646,8 +3666,8 @@
*
*/
public void setLineStyle(int lineStyle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.lineStyle == lineStyle) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.lineStyle is lineStyle) return;
switch (lineStyle) {
case SWT.LINE_SOLID:
case SWT.LINE_DASH:
@@ -3656,7 +3676,7 @@
case SWT.LINE_DASHDOTDOT:
break;
case SWT.LINE_CUSTOM:
- if (data.lineDashes == null) lineStyle = SWT.LINE_SOLID;
+ if (data.lineDashes is null) lineStyle = SWT.LINE_SOLID;
break;
default:
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -3684,50 +3704,47 @@
*
*/
public void setLineWidth(int lineWidth) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.lineWidth == lineWidth) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.lineWidth is lineWidth) return;
data.lineWidth = lineWidth;
data.state &= ~(LINE_WIDTH | DRAW_OFFSET);
}
-void setString(String string, int flags) {
- if (data.layout == 0) createLayout();
- if (string == data.string && (flags & ~SWT.DRAW_TRANSPARENT) == (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) {
+void setString(char[] str, int flags) {
+ if (data.layout is null) createLayout();
+ if (str is data.str && (flags & ~SWT.DRAW_TRANSPARENT) is (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) {
return;
}
- byte[] buffer;
- int mnemonic, length = string.length ();
- int /*long*/ layout = data.layout;
- char[] text = new char[length];
- string.getChars(0, length, text, 0);
- if ((flags & SWT.DRAW_MNEMONIC) != 0 && (mnemonic = fixMnemonic(text)) != -1) {
+ char[] buffer;
+ int mnemonic, len = str.length ;
+ auto layout = data.layout;
+ char[] text = str.dup;
+ if ((flags & SWT.DRAW_MNEMONIC) !is 0 && (mnemonic = fixMnemonic(text)) !is -1) {
char[] text1 = new char[mnemonic - 1];
- System.arraycopy(text, 0, text1, 0, text1.length);
- byte[] buffer1 = Converter.wcsToMbcs(null, text1, false);
+ text1[] = text[0 .. text1.length];
+ char[] buffer1 = text1.dup;
char[] text2 = new char[text.length - mnemonic];
- System.arraycopy(text, mnemonic - 1, text2, 0, text2.length);
- byte[] buffer2 = Converter.wcsToMbcs(null, text2, false);
- buffer = new byte[buffer1.length + buffer2.length];
- System.arraycopy(buffer1, 0, buffer, 0, buffer1.length);
- System.arraycopy(buffer2, 0, buffer, buffer1.length, buffer2.length);
- int /*long*/ attr_list = OS.pango_attr_list_new();
- int /*long*/ attr = OS.pango_attr_underline_new(OS.PANGO_UNDERLINE_LOW);
- PangoAttribute attribute = new PangoAttribute();
- OS.memmove(attribute, attr, PangoAttribute.sizeof);
- attribute.start_index = buffer1.length;
- attribute.end_index = buffer1.length + 1;
- OS.memmove(attr, attribute, PangoAttribute.sizeof);
+ text2[] = text[0 .. text2.length];
+ char[] buffer2 = text2.dup;
+ buffer = new char[buffer1.length + buffer2.length];
+ buffer[0 .. buffer1.length] = buffer1[];
+ buffer[buffer1.length .. buffer1.length+buffer2.length] =
+ buffer2[];
+ auto attr_list = OS.pango_attr_list_new();
+ auto attr = OS.pango_attr_underline_new(cast(PangoUnderline)OS.PANGO_UNDERLINE_LOW);
+ attr.start_index = buffer1.length;
+ attr.end_index = buffer1.length + 1;
OS.pango_attr_list_insert(attr_list, attr);
OS.pango_layout_set_attributes(layout, attr_list);
OS.pango_attr_list_unref(attr_list);
} else {
- buffer = Converter.wcsToMbcs(null, text, false);
- OS.pango_layout_set_attributes(layout, 0);
+ buffer = text.dup;
+ OS.pango_layout_set_attributes(layout, null);
}
- OS.pango_layout_set_text(layout, buffer, buffer.length);
- OS.pango_layout_set_single_paragraph_mode(layout, (flags & SWT.DRAW_DELIMITER) == 0);
- OS.pango_layout_set_tabs(layout, (flags & SWT.DRAW_TAB) != 0 ? 0 : data.device.emptyTab);
- data.string = string;
+ OS.pango_layout_set_text(layout, buffer.ptr, buffer.length);
+ OS.pango_layout_set_single_paragraph_mode(layout, (flags & SWT.DRAW_DELIMITER) is 0);
+ OS.pango_layout_set_tabs(layout, (flags & SWT.DRAW_TAB) !is 0 ? null : data.device.emptyTab);
+ data.str = str;
data.stringWidth = data.stringHeight = -1;
data.drawFlags = flags;
}
@@ -3761,8 +3778,8 @@
* @since 3.1
*/
public void setTextAntialias(int antialias) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (data.cairo == 0 && antialias == SWT.DEFAULT) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.cairo is null && antialias is SWT.DEFAULT) return;
int mode = 0;
switch (antialias) {
case SWT.DEFAULT: mode = Cairo.CAIRO_ANTIALIAS_DEFAULT; break;
@@ -3773,12 +3790,12 @@
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
initCairo();
- int /*long*/ options = Cairo.cairo_font_options_create();
- Cairo.cairo_font_options_set_antialias(options, mode);
- if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ auto options = Cairo.cairo_font_options_create();
+ Cairo.cairo_font_options_set_antialias(options,cast(cairo_antialias_t) mode);
+ if (OS.GTK_VERSION < OS.buildVERSION(2, 8, 0)) {
Cairo.cairo_set_font_options(data.cairo, options);
} else {
- if (data.context == 0) createLayout();
+ if (data.context is null) createLayout();
OS.pango_cairo_context_set_font_options(data.context, options);
}
Cairo.cairo_font_options_destroy(options);
@@ -3811,13 +3828,13 @@
* @since 3.1
*/
public void setTransform(Transform transform) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transform != null && transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (data.cairo == 0 && transform == null) return;
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (transform !is null && transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (data.cairo is null && transform is null) return;
initCairo();
- int /*long*/ cairo = data.cairo;
- if (transform != null) {
- Cairo.cairo_set_matrix(cairo, transform.handle);
+ auto cairo = data.cairo;
+ if (transform !is null) {
+ Cairo.cairo_set_matrix(cairo,cast(cairo_matrix_t*) transform.handle.ptr);
} else {
Cairo.cairo_identity_matrix(cairo);
}
@@ -3845,60 +3862,60 @@
*
* @deprecated this functionality is not supported on some platforms
*/
-public void setXORMode(boolean xor) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- OS.gdk_gc_set_function(handle, xor ? OS.GDK_XOR : OS.GDK_COPY);
+public void setXORMode(bool xor) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ OS.gdk_gc_set_function(handle, cast(GdkFunction)(xor ? OS.GDK_XOR : OS.GDK_COPY));
data.xorMode = xor;
}
/**
- * Returns the extent of the given string. No tab
+ * Returns the extent of the given str. No tab
* expansion or carriage return processing will be performed.
*
- * The extent of a string is the width and height of
+ * The extent of a str is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
*
*
- * @param string the string to measure
- * @return a point containing the extent of the string
+ * @param str the str to measure
+ * @return a point containing the extent of the str
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public Point stringExtent(String string) {
- return textExtent(string, 0);
+public Point stringExtent(char[] str) {
+ return textExtent(str, 0);
}
/**
- * Returns the extent of the given string. Tab expansion and
+ * Returns the extent of the given str. Tab expansion and
* carriage return processing are performed.
*
- * The extent of a string is the width and height of
+ * The extent of a str is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
*
*
- * @param string the string to measure
- * @return a point containing the extent of the string
+ * @param str the str to measure
+ * @return a point containing the extent of the str
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+public Point textExtent(char[] str) {
+ return textExtent(str, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
- * Returns the extent of the given string. Tab expansion, line
+ * Returns the extent of the given str. Tab expansion, line
* delimiter and mnemonic processing are performed according to
* the specified flags, which can be a combination of:
*
@@ -3912,56 +3929,57 @@
* - transparent background
*
*
- * The extent of a string is the width and height of
+ * The extent of a str is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
*
*
- * @param string the string to measure
+ * @param str the str to measure
* @param flags the flags specifying how to process the text
- * @return a point containing the extent of the string
+ * @return a point containing the extent of the str
*
* @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the string is null
+ * - ERROR_NULL_ARGUMENT - if the str is null
*
* @exception SWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
*/
-public Point textExtent(String string, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+public Point textExtent(char[] str, int flags) {
+ if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (str is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ auto cairo = data.cairo;
+ if (cairo !is null) {
+ if (OS.GTK_VERSION < OS.buildVERSION(2, 8, 0)) {
//TODO - honor flags
checkGC(FONT);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- cairo_font_extents_t font_extents = new cairo_font_extents_t();
+ char[] buffer = str.dup;
+ cairo_font_extents_t* font_extents = new cairo_font_extents_t();
Cairo.cairo_font_extents(cairo, font_extents);
- cairo_text_extents_t extents = new cairo_text_extents_t();
- Cairo.cairo_text_extents(cairo, buffer, extents);
- return new Point((int)extents.width, (int)font_extents.height);
+ cairo_text_extents_t* extents = new cairo_text_extents_t();
+ Cairo.cairo_text_extents(cairo, buffer.ptr, extents);
+ return new Point(cast(int)extents.width, cast(int)font_extents.height);
}
}
- setString(string, flags);
+ setString(str, flags);
checkGC(FONT);
- if (data.stringWidth != -1) return new Point(data.stringWidth, data.stringHeight);
- int[] width = new int[1], height = new int[1];
- OS.pango_layout_get_size(data.layout, width, height);
- return new Point(data.stringWidth = OS.PANGO_PIXELS(width[0]), data.stringHeight = OS.PANGO_PIXELS(height[0]));
+ if (data.stringWidth !is -1) return new Point(data.stringWidth, data.stringHeight);
+ int width, height;
+ OS.pango_layout_get_size(data.layout, &width, &height);
+ return new Point(data.stringWidth = OS.PANGO_PIXELS(width), data.stringHeight = OS.PANGO_PIXELS(height));
}
/**
- * Returns a string containing a concise, human-readable
+ * Returns a str containing a concise, human-readable
* description of the receiver.
*
- * @return a string representation of the receiver
+ * @return a str representation of the receiver
*/
-public String toString () {
+public char[] toString () {
if (isDisposed()) return "GC {*DISPOSED*}";
- return "GC {" + handle + "}";
+ return Format( "GC {{{}}", handle );
}
}
-+++/
\ No newline at end of file
+
+
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/graphics/GCData.d
--- a/dwt/graphics/GCData.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/graphics/GCData.d Mon Jan 07 23:29:21 2008 +0100
@@ -35,7 +35,7 @@
public PangoFontDescription* font;
public Pattern foregroundPattern;
public Pattern backgroundPattern;
- public int /*long*/ clipRgn;
+ public GdkRegion* clipRgn;
public float lineWidth;
public int lineStyle = SWT.LINE_SOLID;
public float[] lineDashes;
@@ -47,9 +47,9 @@
public int alpha = 0xFF;
public int interpolation = SWT.DEFAULT;
- public int /*long*/ context;
- public int /*long*/ layout;
- public int /*long*/ damageRgn;
+ public PangoContext* context;
+ public PangoLayout* layout;
+ public GdkRegion* damageRgn;
public Image image;
public GdkDrawable* drawable;
public cairo_t* cairo;
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/graphics/TextLayout.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/TextLayout.d Mon Jan 07 23:29:21 2008 +0100
@@ -0,0 +1,1808 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+module dwt.graphics.TextLayout;
+
+import dwt.internal.cairo.Cairo;
+import dwt.internal.gtk.c.cairotypes;
+import dwt.internal.gtk.c.pangotypes;
+import dwt.internal.gtk.c.gdktypes;
+import dwt.internal.gtk.OS;
+import dwt.internal.Converter;
+import dwt.SWT;
+import dwt.graphics.Color;
+import dwt.graphics.Device;
+import dwt.graphics.Font;
+import dwt.graphics.FontMetrics;
+import dwt.graphics.GC;
+import dwt.graphics.GCData;
+import dwt.graphics.GlyphMetrics;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.graphics.Resource;
+import dwt.graphics.TextStyle;
+
+import tango.text.convert.Format;
+import tango.stdc.stringz;
+import tango.stdc.string;
+import tango.text.convert.Utf;
+import Math = tango.math.Math;
+
+/**
+ * TextLayout
is a graphic object that represents
+ * styled text.
+ *
+ * Instances of this class provide support for drawing, cursor
+ * navigation, hit testing, text wrapping, alignment, tab expansion
+ * line breaking, etc. These are aspects required for rendering internationalized text.
+ *
+ * Application code must explicitly invoke the TextLayout#dispose()
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ *
+ *
+ * @since 3.0
+ */
+public final class TextLayout : Resource {
+
+ static class StyleItem {
+ TextStyle style;
+ int start;
+
+ public char[] toString () {
+ return Format( "StyleItem {{{}, {}}", start, style );
+ }
+ }
+
+ Font font;
+ char[] text;
+ int ascent, descent;
+ int[] segments;
+ int[] tabs;
+ StyleItem[] styles;
+ PangoLayout* layout;
+ PangoContext* context;
+ PangoAttrList* attrList;
+ int[] invalidOffsets;
+ static const wchar LTR_MARK = '\u200E', RTL_MARK = '\u200F', ZWS = '\u200B', ZWNBS = '\uFEFF';
+
+/**
+ * Constructs a new instance of this class on the given device.
+ *
+ * You must dispose the text layout when it is no longer required.
+ *
+ *
+ * @param device the device on which to allocate the text layout
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if device is null and there is no current device
+ *
+ *
+ * @see #dispose()
+ */
+public this (Device device) {
+ if (device is null) device = Device.getDevice();
+ if (device is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ context = OS.gdk_pango_context_get();
+ if (context is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.pango_context_set_language(context, OS.gtk_get_default_language());
+ OS.pango_context_set_base_dir(context, cast(PangoDirection) OS.PANGO_DIRECTION_LTR);
+ OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
+ layout = OS.pango_layout_new(context);
+ if (layout is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.pango_layout_set_wrap(layout, cast(PangoWrapMode)OS.PANGO_WRAP_WORD_CHAR);
+ OS.pango_layout_set_tabs(layout, device.emptyTab);
+ if (OS.GTK_VERSION >= OS.buildVERSION(2, 4, 0)) {
+ OS.pango_layout_set_auto_dir(layout, false);
+ }
+ text = "";
+ ascent = descent = -1;
+ styles = new StyleItem[2];
+ styles[0] = new StyleItem();
+ styles[1] = new StyleItem();
+ if (device.tracking) device.new_Object(this);
+}
+
+void checkLayout() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+}
+
+void computeRuns () {
+ if (attrList !is null) return;
+ char[] segmentsText = getSegmentsText();
+ OS.pango_layout_set_text (layout, toStringz(segmentsText), segmentsText.length);
+ if (styles.length == 2 && styles[0].style == null && ascent == -1 && descent == -1 && segments == null) return;
+ auto ptr = OS.pango_layout_get_text(layout);
+ attrList = OS.pango_attr_list_new();
+ //PangoAttribute* attribute = new PangoAttribute();
+ wchar[] charsW = null;
+ wchar[] segmentsTextW = toString16( segmentsText );
+ int segementsWLength = segmentsTextW.length;
+ if ((ascent != -1 || descent != -1) && segementsWLength > 0) {
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ PangoRectangle* rect = new PangoRectangle();
+ if (ascent != -1) rect.y = -(ascent * OS.PANGO_SCALE);
+ rect.height = (Math.max(0, ascent) + Math.max(0, descent)) * OS.PANGO_SCALE;
+ int lineCount = OS.pango_layout_get_line_count(layout);
+ charsW = new wchar[segementsWLength + lineCount * 2];
+ int oldPos = 0, count = 0;
+ do {
+ int bytePos = OS.pango_layout_iter_get_index(iter);
+ /* Note: The length in bytes of ZWS and ZWNBS are both equals to 3 */
+ int offset = count * 6;
+ PangoAttribute* attr = OS.pango_attr_shape_new (rect, rect);
+ attr.start_index = bytePos + offset;
+ attr.end_index = bytePos + offset + 3;
+ OS.pango_attr_list_insert(attrList, attr);
+ attr = OS.pango_attr_shape_new (rect, rect);
+ attr.start_index = bytePos + offset + 3;
+ attr.end_index = bytePos + offset + 6;
+ OS.pango_attr_list_insert(attrList, attr);
+ int pos = OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos);
+ charsW[pos + count * 2] = ZWS;
+ charsW[pos + count * 2 + 1] = ZWNBS;
+ charsW[ oldPos + count*2 .. oldPos + count*2 + pos - oldPos ] =
+ segmentsTextW[ oldPos .. pos ];
+ //segmentsTextW.getChars(oldPos, pos, chars, oldPos + count * 2);
+ oldPos = pos;
+ count++;
+ } while (OS.pango_layout_iter_next_line(iter));
+ OS.pango_layout_iter_free (iter);
+ charsW[ oldPos + count*2 .. oldPos + count*2 + segementsWLength - oldPos ] =
+ segmentsTextW[ oldPos .. segementsWLength ];
+ //segmentsTextW.getChars(oldPos, segementsWLength, chars, oldPos + count * 2);
+ char[] buffer = .toString( charsW );// Converter.wcsToMbcs(null, chars, false);
+ OS.pango_layout_set_text (layout, buffer.ptr, buffer.length);
+ ptr = OS.pango_layout_get_text(layout);
+ } else {
+ charsW = segmentsTextW.dup;
+ }
+ int offsetCount = 0;
+ for (int i = 0; i < charsW.length; i++) {
+ wchar c = charsW[i];
+ if (c == LTR_MARK || c == RTL_MARK || c == ZWNBS || c == ZWS) {
+ offsetCount++;
+ }
+ }
+ invalidOffsets = new int[offsetCount];
+ offsetCount = 0;
+ for (int i = 0; i < charsW.length; i++) {
+ wchar c = charsW[i];
+ if (c == LTR_MARK || c == RTL_MARK || c == ZWNBS || c == ZWS) {
+ invalidOffsets[offsetCount++] = i;
+ }
+ }
+ int slen = strlen(ptr);
+ for (int i = 0; i < styles.length - 1; i++) {
+ StyleItem styleItem = styles[i];
+ TextStyle style = styleItem.style;
+ if (style == null) continue;
+ int start = translateOffset(styleItem.start);
+ int end = translateOffset(styles[i+1].start - 1);
+ int byteStart = (OS.g_utf8_offset_to_pointer(ptr, start) - ptr);
+ int byteEnd = (OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr);
+ byteStart = Math.min(byteStart, slen);
+ byteEnd = Math.min(byteEnd, slen);
+ Font font = style.font;
+ if (font != null && !font.isDisposed()) {
+ auto attr = OS.pango_attr_font_desc_new (font.handle);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ if (style.underline) {
+ auto attr = OS.pango_attr_underline_new(cast(PangoUnderline)OS.PANGO_UNDERLINE_SINGLE);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ if (style.strikeout) {
+ auto attr = OS.pango_attr_strikethrough_new(true);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ Color foreground = style.foreground;
+ if (foreground != null && !foreground.isDisposed()) {
+ GdkColor* fg = foreground.handle;
+ auto attr = OS.pango_attr_foreground_new(fg.red, fg.green, fg.blue);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ Color background = style.background;
+ if (background != null && !background.isDisposed()) {
+ GdkColor* bg = background.handle;
+ auto attr = OS.pango_attr_background_new(bg.red, bg.green, bg.blue);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ GlyphMetrics metrics = style.metrics;
+ if (metrics != null) {
+ PangoRectangle* rect = new PangoRectangle();
+ rect.y = -(metrics.ascent * OS.PANGO_SCALE);
+ rect.height = (metrics.ascent + metrics.descent) * OS.PANGO_SCALE;
+ rect.width = metrics.width * OS.PANGO_SCALE;
+ auto attr = OS.pango_attr_shape_new (rect, rect);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ int rise = style.rise;
+ if (rise != 0) {
+ auto attr = OS.pango_attr_rise_new (rise * OS.PANGO_SCALE);
+ attr.start_index = byteStart;
+ attr.end_index = byteEnd;
+ OS.pango_attr_list_insert(attrList, attr);
+ }
+ }
+ OS.pango_layout_set_attributes(layout, attrList);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the text layout. Applications must dispose of all allocated text layouts.
+ */
+public void dispose() {
+ if (layout is null) return;
+ font = null;
+ text = null;
+ styles = null;
+ freeRuns();
+ if (layout !is null) OS.g_object_unref(layout);
+ layout = null;
+ if (context !is null) OS.g_object_unref(context);
+ context = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ *
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the gc is null
+ *
+ */
+public void draw(GC gc, int x, int y) {
+ draw(gc, x, y, -1, -1, null, null);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ *
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the gc is null
+ *
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+ draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ *
+ * The parameter flags
can include one of SWT.DELIMITER_SELECTION
+ * or SWT.FULL_SELECTION
to specify the selection behavior on all lines except
+ * for the last line, and can also include SWT.LAST_LINE_SELECTION
to extend
+ * the specified selection behavior to the last line.
+ *
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ * @param flags drawing options
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the gc is null
+ *
+ *
+ * @since 3.3
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
+ checkLayout ();
+ computeRuns();
+ if (gc is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (selectionForeground !is null && selectionForeground.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (selectionBackground !is null && selectionBackground.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ gc.checkGC(GC.FOREGROUND);
+ int length = text.length;
+ bool hasSelection = selectionStart <= selectionEnd && selectionStart != -1 && selectionEnd != -1;
+ GCData data = gc.data;
+ auto cairo = data.cairo;
+ if (flags != 0 && (hasSelection || (flags & SWT.LAST_LINE_SELECTION) != 0)) {
+ PangoLogAttr* attrs;
+ int nAttrs;
+ PangoLogAttr* logAttr = new PangoLogAttr();
+ PangoRectangle* rect = new PangoRectangle();
+ int lineCount = OS.pango_layout_get_line_count(layout);
+ auto ptr = OS.pango_layout_get_text(layout);
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (selectionBackground == null) selectionBackground = device.getSystemColor(SWT.COLOR_LIST_SELECTION);
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ Cairo.cairo_save(cairo);
+ GdkColor* color = selectionBackground.handle;
+ Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / cast(float)0xFFFF, (color.green & 0xFFFF) / cast(float)0xFFFF, (color.blue & 0xFFFF) / cast(float)0xFFFF, data.alpha / cast(float)0xFF);
+ } else {
+ OS.gdk_gc_set_foreground(gc.handle, selectionBackground.handle);
+ }
+ int lineIndex = 0;
+ do {
+ int lineEnd;
+ OS.pango_layout_iter_get_line_extents(iter, null, rect);
+ if (OS.pango_layout_iter_next_line(iter)) {
+ int bytePos = OS.pango_layout_iter_get_index(iter);
+ lineEnd = OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos);
+ } else {
+ lineEnd = OS.g_utf8_strlen(ptr, -1);
+ }
+ bool extent = false;
+ if (lineIndex == lineCount - 1 && (flags & SWT.LAST_LINE_SELECTION) != 0) {
+ extent = true;
+ } else {
+ if (attrs is null) OS.pango_layout_get_log_attrs(layout, &attrs, &nAttrs);
+ *logAttr = attrs[lineEnd];
+ if (!logAttr.is_line_break) {
+ if (selectionStart <= lineEnd && lineEnd <= selectionEnd) extent = true;
+ } else {
+ if (selectionStart <= lineEnd && lineEnd < selectionEnd && (flags & SWT.FULL_SELECTION) != 0) {
+ extent = true;
+ }
+ }
+ }
+ if (extent) {
+ int lineX = x + OS.PANGO_PIXELS(rect.x) + OS.PANGO_PIXELS(rect.width);
+ int lineY = y + OS.PANGO_PIXELS(rect.y);
+ int height = OS.PANGO_PIXELS(rect.height);
+ if (ascent != -1 && descent != -1) {
+ height = Math.max (height, ascent + descent);
+ }
+ int width = (flags & SWT.FULL_SELECTION) != 0 ? 0x7fffffff : height / 3;
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ Cairo.cairo_rectangle(cairo, lineX, lineY, width, height);
+ Cairo.cairo_fill(cairo);
+ } else {
+ OS.gdk_draw_rectangle(data.drawable, gc.handle, 1, lineX, lineY, width, height);
+ }
+ }
+ lineIndex++;
+ } while (lineIndex < lineCount);
+ OS.pango_layout_iter_free(iter);
+ if (attrs !is null) OS.g_free(attrs);
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ Cairo.cairo_restore(cairo);
+ } else {
+ OS.gdk_gc_set_foreground(gc.handle, data.foreground);
+ }
+ }
+ if (length == 0) return;
+ if (!hasSelection) {
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ } else {
+ OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+ }
+ } else {
+ selectionStart = Math.min(Math.max(0, selectionStart), length - 1);
+ selectionEnd = Math.min(Math.max(0, selectionEnd), length - 1);
+ length = OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1);
+ selectionStart = translateOffset(selectionStart);
+ selectionEnd = translateOffset(selectionEnd);
+ if (selectionForeground == null) selectionForeground = device.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+ if (selectionBackground == null) selectionBackground = device.getSystemColor(SWT.COLOR_LIST_SELECTION);
+ bool fullSelection = selectionStart == 0 && selectionEnd == length - 1;
+ if (fullSelection) {
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ auto ptr = OS.pango_layout_get_text(layout);
+ drawWithCairo(cairo, x, y, 0, strlen(ptr), fullSelection, selectionBackground.handle, selectionForeground.handle);
+ } else {
+ OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+ }
+ } else {
+ auto ptr = OS.pango_layout_get_text(layout);
+ int byteSelStart = (OS.g_utf8_offset_to_pointer(ptr, selectionStart) - ptr);
+ int byteSelEnd = (OS.g_utf8_offset_to_pointer(ptr, selectionEnd + 1) - ptr);
+ int slen = strlen(ptr);
+ byteSelStart = Math.min(byteSelStart, slen);
+ byteSelEnd = Math.min(byteSelEnd, slen);
+ if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) {
+ drawWithCairo(cairo, x, y, byteSelStart, byteSelEnd, fullSelection, selectionBackground.handle, selectionForeground.handle);
+ } else {
+ Region clipping = new Region();
+ gc.getClipping(clipping);
+ OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+ int[] ranges = [byteSelStart, byteSelEnd];
+ auto rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges.ptr, ranges.length / 2);
+ if (rgn !is null) {
+ OS.gdk_gc_set_clip_region(gc.handle, rgn);
+ OS.gdk_region_destroy(rgn);
+ }
+ OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+ gc.setClipping(clipping);
+ clipping.dispose();
+ }
+ }
+ }
+}
+
+void drawWithCairo(cairo_t* cairo, int x, int y, int byteSelStart, int byteSelEnd, bool fullSelection, GdkColor* selectionBackground, GdkColor* selectionForeground) {
+ Cairo.cairo_save(cairo);
+ if (!fullSelection) {
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ }
+ int[] ranges = [byteSelStart, byteSelEnd];
+ auto rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges.ptr, ranges.length / 2);
+ if (rgn !is null) {
+ OS.gdk_cairo_region(cairo, rgn);
+ Cairo.cairo_clip(cairo);
+ OS.gdk_cairo_set_source_color(cairo, selectionBackground);
+ Cairo.cairo_paint(cairo);
+ OS.gdk_region_destroy(rgn);
+ }
+ OS.gdk_cairo_set_source_color(cairo, selectionForeground);
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ Cairo.cairo_restore(cairo);
+}
+
+void freeRuns() {
+ if (attrList is null) return;
+ OS.pango_layout_set_attributes(layout, null );
+ OS.pango_attr_list_unref(attrList);
+ attrList = null;
+ invalidOffsets = null;
+}
+
+/**
+ * Returns the receiver's horizontal text alignment, which will be one
+ * of SWT.LEFT
, SWT.CENTER
or
+ * SWT.RIGHT
.
+ *
+ * @return the alignment used to positioned text horizontally
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getAlignment() {
+ checkLayout();
+ auto alignment = OS.pango_layout_get_alignment(layout);
+ switch ( cast(int)alignment) {
+ case OS.PANGO_ALIGN_CENTER: return SWT.CENTER;
+ case OS.PANGO_ALIGN_RIGHT: return SWT.RIGHT;
+ }
+ return SWT.LEFT;
+}
+
+/**
+ * Returns the ascent of the receiver.
+ *
+ * @return the ascent
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getDescent()
+ * @see #setDescent(int)
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getAscent () {
+ checkLayout();
+ return ascent;
+}
+
+/**
+ * Returns the bounds of the receiver.
+ *
+ * @return the bounds of the receiver
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public Rectangle getBounds() {
+ checkLayout();
+ computeRuns();
+ int w, h;
+ OS.pango_layout_get_size(layout, &w, &h);
+ int wrapWidth = OS.pango_layout_get_width(layout);
+ int width = OS.PANGO_PIXELS(wrapWidth != -1 ? wrapWidth : w);
+ int height = OS.PANGO_PIXELS(h);
+ if (ascent != -1 && descent != -1) {
+ height = Math.max (height, ascent + descent);
+ }
+ return new Rectangle(0, 0, width, height);
+}
+
+/**
+ * Returns the bounds for the specified range of characters. The
+ * bounds is the smallest rectangle that encompasses all characters
+ * in the range. The start and end offsets are inclusive and will be
+ * clamped if out of range.
+ *
+ * @param start the start offset
+ * @param end the end offset
+ * @return the bounds of the character range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public Rectangle getBounds(int start, int end) {
+ checkLayout();
+ computeRuns();
+ int length = text.length;
+ if (length == 0) return new Rectangle(0, 0, 0, 0);
+ if (start > end) return new Rectangle(0, 0, 0, 0);
+ start = Math.min(Math.max(0, start), length - 1);
+ end = Math.min(Math.max(0, end), length - 1);
+ start = translateOffset(start);
+ end = translateOffset(end);
+ auto ptr = OS.pango_layout_get_text(layout);
+ int byteStart = (OS.g_utf8_offset_to_pointer (ptr, start) - ptr);
+ int byteEnd = (OS.g_utf8_offset_to_pointer (ptr, end + 1) - ptr);
+ int slen = strlen(ptr);
+ byteStart = Math.min(byteStart, slen);
+ byteEnd = Math.min(byteEnd, slen);
+ int[] ranges = [byteStart, byteEnd];
+ auto clipRegion = OS.gdk_pango_layout_get_clip_region(layout, 0, 0, ranges.ptr, 1);
+ if (clipRegion is null) return new Rectangle(0, 0, 0, 0);
+ GdkRectangle* rect = new GdkRectangle();
+
+ /*
+ * Bug in Pango. The region returned by gdk_pango_layout_get_clip_region()
+ * includes areas from lines outside of the requested range. The fix
+ * is to subtract these areas from the clip region.
+ */
+ PangoRectangle* pangoRect = new PangoRectangle();
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ auto linesRegion = OS.gdk_region_new();
+ if (linesRegion is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ int lineEnd = 0;
+ do {
+ OS.pango_layout_iter_get_line_extents(iter, null, pangoRect);
+ if (OS.pango_layout_iter_next_line(iter)) {
+ lineEnd = OS.pango_layout_iter_get_index(iter) - 1;
+ } else {
+ lineEnd = slen;
+ }
+ if (byteStart > lineEnd) continue;
+ rect.x = OS.PANGO_PIXELS(pangoRect.x);
+ rect.y = OS.PANGO_PIXELS(pangoRect.y);
+ rect.width = OS.PANGO_PIXELS(pangoRect.width);
+ rect.height = OS.PANGO_PIXELS(pangoRect.height);
+ OS.gdk_region_union_with_rect(linesRegion, rect);
+ } while (lineEnd + 1 <= byteEnd);
+ OS.gdk_region_intersect(clipRegion, linesRegion);
+ OS.gdk_region_destroy(linesRegion);
+ OS.pango_layout_iter_free(iter);
+
+ OS.gdk_region_get_clipbox(clipRegion, rect);
+ OS.gdk_region_destroy(clipRegion);
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Returns the descent of the receiver.
+ *
+ * @return the descent
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getAscent()
+ * @see #setAscent(int)
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getDescent () {
+ checkLayout();
+ return descent;
+}
+
+/**
+ * Returns the default font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public Font getFont () {
+ checkLayout();
+ return font;
+}
+
+/**
+* Returns the receiver's indent.
+*
+* @return the receiver's indent
+*
+* @exception SWTException
+* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+*
+*
+* @since 3.2
+*/
+public int getIndent () {
+ checkLayout();
+ return OS.PANGO_PIXELS(OS.pango_layout_get_indent(layout));
+}
+
+/**
+* Returns the receiver's justification.
+*
+* @return the receiver's justification
+*
+* @exception SWTException
+* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+*
+*
+* @since 3.2
+*/
+public bool getJustify () {
+ checkLayout();
+ return cast(bool) OS.pango_layout_get_justify(layout);
+}
+
+/**
+ * Returns the embedding level for the specified character offset. The
+ * embedding level is usually used to determine the directionality of a
+ * character in bidirectional text.
+ *
+ * @param offset the character offset
+ * @return the embedding level
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the character offset is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ */
+public int getLevel(int offset) {
+ checkLayout();
+ computeRuns();
+ int length = text.length;
+ if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ offset = translateOffset(offset);
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ int level = 0;
+ PangoItem* item = new PangoItem();
+ PangoLayoutRun* run = new PangoLayoutRun();
+ auto ptr = OS.pango_layout_get_text(layout);
+ auto byteOffset = OS.g_utf8_offset_to_pointer(ptr, offset) - ptr;
+ int slen = strlen(ptr);
+ byteOffset = Math.min(byteOffset, slen);
+ do {
+ auto runPtr = OS.pango_layout_iter_get_run(iter);
+ if (runPtr !is null) {
+ memmove(run, runPtr, PangoLayoutRun.sizeof);
+ memmove(item, run.item, PangoItem.sizeof);
+ if (item.offset <= byteOffset && byteOffset < item.offset + item.length) {
+ level = item.analysis.level;
+ break;
+ }
+ }
+ } while (OS.pango_layout_iter_next_run(iter));
+ OS.pango_layout_iter_free(iter);
+ return level;
+}
+
+/**
+ * Returns the bounds of the line for the specified line index.
+ *
+ * @param lineIndex the line index
+ * @return the line bounds
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the line index is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public Rectangle getLineBounds(int lineIndex) {
+ checkLayout();
+ computeRuns();
+ int lineCount = OS.pango_layout_get_line_count(layout);
+ if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ for (int i = 0; i < lineIndex; i++) OS.pango_layout_iter_next_line(iter);
+ PangoRectangle* rect = new PangoRectangle();
+ OS.pango_layout_iter_get_line_extents(iter, null, rect);
+ OS.pango_layout_iter_free(iter);
+ int x = OS.PANGO_PIXELS(rect.x);
+ int y = OS.PANGO_PIXELS(rect.y);
+ int width = OS.PANGO_PIXELS(rect.width);
+ int height = OS.PANGO_PIXELS(rect.height);
+ if (ascent != -1 && descent != -1) {
+ height = Math.max (height, ascent + descent);
+ }
+ return new Rectangle(x, y, width, height);
+}
+
+/**
+ * Returns the receiver's line count. This includes lines caused
+ * by wrapping.
+ *
+ * @return the line count
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getLineCount() {
+ checkLayout ();
+ computeRuns();
+ return OS.pango_layout_get_line_count(layout);
+}
+
+/**
+ * Returns the index of the line that contains the specified
+ * character offset.
+ *
+ * @param offset the character offset
+ * @return the line index
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the character offset is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getLineIndex(int offset) {
+ checkLayout ();
+ computeRuns();
+ int length = text.length;
+ if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ offset = translateOffset(offset);
+ int line = 0;
+ auto ptr = OS.pango_layout_get_text(layout);
+ auto byteOffset = OS.g_utf8_offset_to_pointer(ptr,offset) - ptr;
+ int slen = strlen(ptr);
+ byteOffset = Math.min(byteOffset, slen);
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ while (OS.pango_layout_iter_next_line(iter)) {
+ if (OS.pango_layout_iter_get_index(iter) > byteOffset) break;
+ line++;
+ }
+ OS.pango_layout_iter_free(iter);
+ return line;
+}
+
+/**
+ * Returns the font metrics for the specified line index.
+ *
+ * @param lineIndex the line index
+ * @return the font metrics
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the line index is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public FontMetrics getLineMetrics (int lineIndex) {
+ checkLayout ();
+ computeRuns();
+ int lineCount = OS.pango_layout_get_line_count(layout);
+ if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ int ascent = 0, descent = 0;
+ PangoLayoutLine* line = new PangoLayoutLine();
+ memmove(line, OS.pango_layout_get_line(layout, lineIndex), PangoLayoutLine.sizeof);
+ if (line.runs is null) {
+ auto font = this.font != null ? this.font.handle : device.systemFont.handle;
+ auto lang = OS.pango_context_get_language(context);
+ auto metrics = OS.pango_context_get_metrics(context, font, lang);
+ ascent = OS.pango_font_metrics_get_ascent(metrics);
+ descent = OS.pango_font_metrics_get_descent(metrics);
+ OS.pango_font_metrics_unref(metrics);
+ } else {
+ PangoRectangle* rect = new PangoRectangle();
+ OS.pango_layout_line_get_extents(OS.pango_layout_get_line(layout, lineIndex), null, rect);
+ ascent = -rect.y;
+ descent = rect.height - ascent;
+ }
+ ascent = Math.max(this.ascent, OS.PANGO_PIXELS(ascent));
+ descent = Math.max(this.descent, OS.PANGO_PIXELS(descent));
+ return FontMetrics.gtk_new(ascent, descent, 0, 0, ascent + descent);
+}
+
+/**
+ * Returns the line offsets. Each value in the array is the
+ * offset for the first character in a line except for the last
+ * value, which contains the length of the text.
+ *
+ * @return the line offsets
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int[] getLineOffsets() {
+ checkLayout();
+ computeRuns();
+ int lineCount = OS.pango_layout_get_line_count(layout);
+ int[] offsets = new int [lineCount + 1];
+ auto ptr = OS.pango_layout_get_text(layout);
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ int i = 0;
+ do {
+ int bytePos = OS.pango_layout_iter_get_index(iter);
+ int pos = OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos);
+ offsets[i++] = untranslateOffset(pos);
+ } while (OS.pango_layout_iter_next_line(iter));
+ OS.pango_layout_iter_free(iter);
+ offsets[lineCount] = text.length;
+ return offsets;
+}
+
+/**
+ * Returns the location for the specified character offset. The
+ * trailing
argument indicates whether the offset
+ * corresponds to the leading or trailing edge of the cluster.
+ *
+ * @param offset the character offset
+ * @param trailing the trailing flag
+ * @return the location of the character offset
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getOffset(Point, int[])
+ * @see #getOffset(int, int, int[])
+ */
+public Point getLocation(int offset, bool trailing) {
+ checkLayout();
+ computeRuns();
+ int length = text.length;
+ if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ offset = translateOffset(offset);
+ auto ptr = OS.pango_layout_get_text(layout);
+ int byteOffset = (OS.g_utf8_offset_to_pointer(ptr, offset) - ptr);
+ int slen = strlen(ptr);
+ byteOffset = Math.min(byteOffset, slen);
+ PangoRectangle* pos = new PangoRectangle();
+ OS.pango_layout_index_to_pos(layout, byteOffset, pos);
+ int x = trailing ? pos.x + pos.width : pos.x;
+ int y = pos.y;
+ return new Point(OS.PANGO_PIXELS(x), OS.PANGO_PIXELS(y));
+}
+
+/**
+ * Returns the next offset for the specified offset and movement
+ * type. The movement is one of SWT.MOVEMENT_CHAR
,
+ * SWT.MOVEMENT_CLUSTER
, SWT.MOVEMENT_WORD
,
+ * SWT.MOVEMENT_WORD_END
or SWT.MOVEMENT_WORD_START
.
+ *
+ * @param offset the start offset
+ * @param movement the movement type
+ * @return the next offset
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the offset is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getPreviousOffset(int, int)
+ */
+public int getNextOffset (int offset, int movement) {
+ return _getOffset(offset, movement, true);
+}
+
+int _getOffset (int offset, int movement, bool forward) {
+ checkLayout();
+ computeRuns();
+ int length = text.length;
+ if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ if (forward) {
+ if (offset == length) return length;
+ } else {
+ if (offset == 0) return 0;
+ }
+ int step = forward ? 1 : -1;
+ if ((movement & SWT.MOVEMENT_CHAR) != 0) return offset + step;
+ PangoLogAttr* attrs;
+ int nAttrs;
+ OS.pango_layout_get_log_attrs(layout, &attrs, &nAttrs);
+ if (attrs is null) return offset + step;
+ length = OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1);
+ offset = translateOffset(offset);
+ PangoLogAttr* logAttr = new PangoLogAttr();
+ offset = validateOffset(offset, step);
+ while (0 < offset && offset < length) {
+ *logAttr = attrs[ offset ];
+ if (((movement & SWT.MOVEMENT_CLUSTER) != 0) && logAttr.is_cursor_position) break;
+ if ((movement & SWT.MOVEMENT_WORD) != 0) {
+ if (forward) {
+ if (logAttr.is_word_end) break;
+ } else {
+ if (logAttr.is_word_start) break;
+ }
+ }
+ if ((movement & SWT.MOVEMENT_WORD_START) != 0) {
+ if (logAttr.is_word_start) break;
+ }
+ if ((movement & SWT.MOVEMENT_WORD_END) != 0) {
+ if (logAttr.is_word_end) break;
+ }
+ offset = validateOffset(offset, step);
+ }
+ OS.g_free(attrs);
+ return Math.min(Math.max(0, untranslateOffset(offset)), text.length);
+}
+
+/**
+ * Returns the character offset for the specified point.
+ * For a typical character, the trailing argument will be filled in to
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1). When the point is over a cluster composed
+ * of multiple characters, the trailing argument will be filled with the
+ * position of the character in the cluster that is closest to
+ * the point.
+ *
+ * @param point the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the trailing length is less than
1
+ * - ERROR_NULL_ARGUMENT - if the point is null
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getLocation(int, bool)
+ */
+public int getOffset(Point point, int[] trailing) {
+ checkLayout();
+ if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return getOffset(point.x, point.y, trailing);
+}
+
+/**
+ * Returns the character offset for the specified point.
+ * For a typical character, the trailing argument will be filled in to
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1). When the point is over a cluster composed
+ * of multiple characters, the trailing argument will be filled with the
+ * position of the character in the cluster that is closest to
+ * the point.
+ *
+ * @param x the x coordinate of the point
+ * @param y the y coordinate of the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the trailing length is less than
1
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getLocation(int, bool)
+ */
+public int getOffset(int x, int y, int[] trailing) {
+ checkLayout();
+ computeRuns();
+ if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ /*
+ * Feature in GTK. pango_layout_xy_to_index() returns the
+ * logical end/start offset of a line when the coordinates are outside
+ * the line bounds. In SWT the correct behavior is to return the closest
+ * visual offset. The fix is to clamp the coordinates inside the
+ * line bounds.
+ */
+ auto iter = OS.pango_layout_get_iter(layout);
+ if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
+ PangoRectangle* rect = new PangoRectangle();
+ do {
+ OS.pango_layout_iter_get_line_extents(iter, null, rect);
+ rect.y = OS.PANGO_PIXELS(rect.y);
+ rect.height = OS.PANGO_PIXELS(rect.height);
+ if (rect.y <= y && y < rect.y + rect.height) {
+ rect.x = OS.PANGO_PIXELS(rect.x);
+ rect.width = OS.PANGO_PIXELS(rect.width);
+ if (x >= rect.x + rect.width) x = rect.x + rect.width - 1;
+ if (x < rect.x) x = rect.x;
+ break;
+ }
+ } while (OS.pango_layout_iter_next_line(iter));
+ OS.pango_layout_iter_free(iter);
+
+ int index;
+ int piTrailing;
+ OS.pango_layout_xy_to_index(layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, &index, &piTrailing);
+ auto ptr = OS.pango_layout_get_text(layout);
+ int offset = OS.g_utf8_pointer_to_offset(ptr, ptr + index);
+ if (trailing !is null) trailing[0] = piTrailing;
+ return untranslateOffset(offset);
+}
+
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getOrientation() {
+ checkLayout();
+ int baseDir = OS.pango_context_get_base_dir(context);
+ return baseDir == OS.PANGO_DIRECTION_RTL ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
+}
+
+/**
+ * Returns the previous offset for the specified offset and movement
+ * type. The movement is one of SWT.MOVEMENT_CHAR
,
+ * SWT.MOVEMENT_CLUSTER
or SWT.MOVEMENT_WORD
,
+ * SWT.MOVEMENT_WORD_END
or SWT.MOVEMENT_WORD_START
.
+ *
+ * @param offset the start offset
+ * @param movement the movement type
+ * @return the previous offset
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the offset is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getNextOffset(int, int)
+ */
+public int getPreviousOffset (int index, int movement) {
+ return _getOffset(index, movement, false);
+}
+
+/**
+ * Gets the ranges of text that are associated with a TextStyle
.
+ *
+ * @return the ranges, an array of offsets representing the start and end of each
+ * text style.
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getStyles()
+ *
+ * @since 3.2
+ */
+public int[] getRanges () {
+ checkLayout();
+ int[] result = new int[styles.length * 2];
+ int count = 0;
+ for (int i=0; i
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int[] getSegments() {
+ checkLayout();
+ return segments;
+}
+
+char[] getSegmentsText() {
+ if (segments is null) return text;
+ int nSegments = segments.length;
+ if (nSegments <= 1) return text;
+ int len = text.length;
+ if (len == 0) return text;
+ if (nSegments == 2) {
+ if (segments[0] == 0 && segments[1] == len) return text;
+ }
+ char[] oldChars = text[0..len].dup;
+ char[] newChars = new char[len + nSegments];
+ int charCount = 0, segmentCount = 0;
+ wchar separator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK;
+ while (charCount < len) {
+ if (segmentCount < nSegments && charCount == segments[segmentCount]) {
+ newChars[charCount + segmentCount++] = separator;
+ } else {
+ newChars[charCount + segmentCount] = oldChars[charCount++];
+ }
+ }
+ if (segmentCount < nSegments) {
+ segments[segmentCount] = charCount;
+ newChars[charCount + segmentCount++] = separator;
+ }
+ return newChars[ 0 .. Math.min(charCount + segmentCount, newChars.length) ];
+}
+
+/**
+ * Returns the line spacing of the receiver.
+ *
+ * @return the line spacing
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getSpacing () {
+ checkLayout();
+ return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout));
+}
+
+/**
+ * Gets the style of the receiver at the specified character offset.
+ *
+ * @param offset the text offset
+ * @return the style or null
if not set
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the character offset is out of range
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public TextStyle getStyle (int offset) {
+ checkLayout();
+ int length = text.length;
+ if (!(0 <= offset && offset < length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+ for (int i=1; i offset) {
+ return styles[i - 1].style;
+ }
+ }
+ return null;
+}
+
+/**
+ * Gets all styles of the receiver.
+ *
+ * @return the styles
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #getRanges()
+ *
+ * @since 3.2
+ */
+public TextStyle[] getStyles () {
+ checkLayout();
+ TextStyle[] result = new TextStyle[styles.length];
+ int count = 0;
+ for (int i=0; i
+ * ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int[] getTabs() {
+ checkLayout();
+ return tabs;
+}
+
+/**
+ * Gets the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public char[] getText () {
+ checkLayout ();
+ return text;
+}
+
+/**
+ * Returns the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public int getWidth () {
+ checkLayout ();
+ int width = OS.pango_layout_get_width(layout);
+ return width != -1 ? OS.PANGO_PIXELS(width) : -1;
+}
+
+/**
+ * Returns true
if the text layout has been disposed,
+ * and false
otherwise.
+ *
+ * This method gets the dispose state for the text layout.
+ * When a text layout has been disposed, it is an error to
+ * invoke any other method using the text layout.
+ *
+ *
+ * @return true
when the text layout is disposed and false
otherwise
+ */
+public bool isDisposed () {
+ return layout is null;
+}
+
+/**
+ * Sets the text alignment for the receiver. The alignment controls
+ * how a line of text is positioned horizontally. The argument should
+ * be one of SWT.LEFT
, SWT.RIGHT
or SWT.CENTER
.
+ *
+ * The default alignment is SWT.LEFT
. Note that the receiver's
+ * width must be set in order to use SWT.RIGHT
or SWT.CENTER
+ * alignment.
+ *
+ *
+ * @param alignment the new alignment
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #setWidth(int)
+ */
+public void setAlignment (int alignment) {
+ checkLayout();
+ int mask = SWT.LEFT | SWT.CENTER | SWT.RIGHT;
+ alignment &= mask;
+ if (alignment == 0) return;
+ if ((alignment & SWT.LEFT) != 0) alignment = SWT.LEFT;
+ if ((alignment & SWT.RIGHT) != 0) alignment = SWT.RIGHT;
+ int al = OS.PANGO_ALIGN_LEFT;
+ switch (alignment) {
+ case SWT.CENTER: al = OS.PANGO_ALIGN_CENTER; break;
+ case SWT.RIGHT: al = OS.PANGO_ALIGN_RIGHT; break;
+ }
+ OS.pango_layout_set_alignment(layout, cast(PangoAlignment) al);
+}
+
+/**
+ * Sets the ascent of the receiver. The ascent is distance in pixels
+ * from the baseline to the top of the line and it is applied to all
+ * lines. The default value is -1
which means that the
+ * ascent is calculated from the line fonts.
+ *
+ * @param ascent the new ascent
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the ascent is less than
-1
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setAscent (int ascent) {
+ checkLayout();
+ if (ascent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (this.ascent == ascent) return;
+ freeRuns();
+ this.ascent = ascent;
+}
+
+/**
+ * Sets the descent of the receiver. The descent is distance in pixels
+ * from the baseline to the bottom of the line and it is applied to all
+ * lines. The default value is -1
which means that the
+ * descent is calculated from the line fonts.
+ *
+ * @param descent the new descent
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the descent is less than
-1
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setDescent (int descent) {
+ checkLayout();
+ if (descent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (this.descent == descent) return;
+ freeRuns();
+ this.descent = descent;
+}
+
+/**
+ * Sets the default font which will be used by the receiver
+ * to draw and measure text. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead. Note that a text
+ * style can override the default font.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the font has been disposed
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setFont (Font font) {
+ checkLayout ();
+ if (font !is null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (this.font is font) return;
+ if (font !is null && font == this.font ) return;
+ this.font = font;
+ OS.pango_layout_set_font_description(layout, font !is null ? font.handle : null);
+}
+
+
+/**
+ * Sets the indent of the receiver. This indent it applied of the first line of
+ * each paragraph.
+ *
+ * @param indent new indent
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @since 3.2
+ */
+public void setIndent (int indent) {
+ checkLayout();
+ if (indent < 0) return;
+ OS.pango_layout_set_indent(layout, indent * OS.PANGO_SCALE);
+}
+
+/**
+ * Sets the justification of the receiver. Note that the receiver's
+ * width must be set in order to use justification.
+ *
+ * @param justify new justify
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @since 3.2
+ */
+public void setJustify (bool justify) {
+ checkLayout();
+ OS.pango_layout_set_justify(layout, justify);
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
+ *
+ * @param orientation new orientation style
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setOrientation(int orientation) {
+ checkLayout();
+ int mask = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+ orientation &= mask;
+ if (orientation == 0) return;
+ if ((orientation & SWT.LEFT_TO_RIGHT) != 0) orientation = SWT.LEFT_TO_RIGHT;
+ int baseDir = orientation == SWT.RIGHT_TO_LEFT ? OS.PANGO_DIRECTION_RTL : OS.PANGO_DIRECTION_LTR;
+ if (OS.pango_context_get_base_dir(context) == baseDir) return;
+ OS.pango_context_set_base_dir(context,cast(PangoDirection) baseDir);
+ OS.pango_layout_context_changed(layout);
+}
+
+/**
+ * Sets the line spacing of the receiver. The line spacing
+ * is the space left between lines.
+ *
+ * @param spacing the new line spacing
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the spacing is negative
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setSpacing (int spacing) {
+ checkLayout();
+ if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE);
+}
+
+/**
+ * Sets the offsets of the receiver's text segments. Text segments are used to
+ * override the default behaviour of the bidirectional algorithm.
+ * Bidirectional reordering can happen within a text segment but not
+ * between two adjacent segments.
+ *
+ * Each text segment is determined by two consecutive offsets in the
+ * segments
arrays. The first element of the array should
+ * always be zero and the last one should always be equals to length of
+ * the text.
+ *
+ *
+ * @param segments the text segments offset
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setSegments(int[] segments) {
+ checkLayout();
+ if (this.segments == null && segments == null) return;
+ if (this.segments != null && segments !=null) {
+ if (this.segments.length == segments.length) {
+ int i;
+ for (i = 0; i
+ * ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setStyle (TextStyle style, int start, int end) {
+ checkLayout();
+ int length = text.length;
+ if (length == 0) return;
+ if (start > end) return;
+ start = Math.min(Math.max(0, start), length - 1);
+ end = Math.min(Math.max(0, end), length - 1);
+
+ /*
+ * Bug in Pango. Pango 1.2.2 will cause a segmentation fault if a style
+ * is not applied for a whole ligature. The fix is to applied the
+ * style for the whole ligature.
+ *
+ * NOTE that fix only LamAlef ligatures.
+ */
+ if (start > 0 && isAlef(text[start]) && isLam(text[start - 1])) {
+ start--;
+ }
+ if (end < length - 1 && isLam(text[end]) && isAlef(text[end + 1])) {
+ end++;
+ }
+
+ int low = -1;
+ int high = styles.length;
+ while (high - low > 1) {
+ int index = (high + low) / 2;
+ if (styles[index + 1].start > start) {
+ high = index;
+ } else {
+ low = index;
+ }
+ }
+ if (0 <= high && high < styles.length) {
+ StyleItem item = styles[high];
+ if (item.start is start && styles[high + 1].start - 1 == end) {
+ if (style is null) {
+ if (item.style is null) return;
+ } else {
+ if (style==item.style) return;
+ }
+ }
+ }
+ freeRuns();
+ int modifyStart = high;
+ int modifyEnd = modifyStart;
+ while (modifyEnd < styles.length) {
+ if (styles[modifyEnd + 1].start > end) break;
+ modifyEnd++;
+ }
+ if (modifyStart is modifyEnd) {
+ int styleStart = styles[modifyStart].start;
+ int styleEnd = styles[modifyEnd + 1].start - 1;
+ if (styleStart is start && styleEnd is end) {
+ styles[modifyStart].style = style;
+ return;
+ }
+ if (styleStart !is start && styleEnd !is end) {
+ StyleItem[] newStyles = new StyleItem[styles.length + 2];
+ newStyles[ 0 .. modifyStart + 1] = styles[ 0 .. modifyStart + 1 ];
+ StyleItem item = new StyleItem();
+ item.start = start;
+ item.style = style;
+ newStyles[modifyStart + 1] = item;
+ item = new StyleItem();
+ item.start = end + 1;
+ item.style = styles[modifyStart].style;
+ newStyles[modifyStart + 2] = item;
+ newStyles[ modifyStart + 3 .. modifyStart + 3 + styles.length - modifyEnd - 1] =
+ styles[ modifyStart + 1 .. modifyStart + 1 + styles.length - modifyEnd - 1 ];
+ styles = newStyles;
+ return;
+ }
+ }
+ if (start is styles[modifyStart].start) modifyStart--;
+ if (end is styles[modifyEnd + 1].start - 1) modifyEnd++;
+ int newLength = styles.length + 1 - (modifyEnd - modifyStart - 1);
+ StyleItem[] newStyles = new StyleItem[newLength];
+ newStyles[ 0 .. modifyStart + 1 ] = styles[ 0 .. modifyStart + 1 ];
+ StyleItem item = new StyleItem();
+ item.start = start;
+ item.style = style;
+ newStyles[modifyStart + 1] = item;
+ styles[modifyEnd].start = end + 1;
+ newStyles[ modifyStart + 2 .. modifyStart + 2 + styles.length - modifyEnd ] =
+ styles[ modifyEnd .. modifyEnd + styles.length - modifyEnd ];
+ styles = newStyles;
+}
+
+/**
+ * Sets the receiver's tab list. Each value in the tab list specifies
+ * the space in pixels from the origin of the text layout to the respective
+ * tab stop. The last tab stop width is repeated continuously.
+ *
+ * @param tabs the new tab list
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setTabs(int[] tabs) {
+ checkLayout();
+ if (this.tabs == null && tabs == null) return;
+ if (this.tabs!= null && tabs != null) {
+ if (this.tabs.length == tabs.length) {
+ int i;
+ for (i = 0; i
+ * ERROR_NULL_ARGUMENT - if the text is null
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ */
+public void setText (char[] text) {
+ checkLayout ();
+ if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (text==/*eq*/this.text) return;
+ freeRuns();
+ this.text = text;
+ styles = new StyleItem[2];
+ styles[0] = new StyleItem();
+ styles[1] = new StyleItem();
+ styles[styles.length - 1].start = text.length;
+}
+
+/**
+ * Sets the line width of the receiver, which determines how
+ * text should be wrapped and aligned. The default value is
+ * -1
which means wrapping is disabled.
+ *
+ * @param width the new width
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the width is
0
or less than -1
+ *
+ * @exception SWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @see #setAlignment(int)
+ */
+public void setWidth (int width) {
+ checkLayout ();
+ if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ freeRuns();
+ OS.pango_layout_set_width(layout, width == -1 ? -1 : width * OS.PANGO_SCALE);
+}
+
+static final bool isLam(int ch) {
+ return ch == 0x0644;
+}
+
+static final bool isAlef(int ch) {
+ switch (ch) {
+ case 0x0622:
+ case 0x0623:
+ case 0x0625:
+ case 0x0627:
+ case 0x0649:
+ case 0x0670:
+ case 0x0671:
+ case 0x0672:
+ case 0x0673:
+ case 0x0675:
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public char[] toString () {
+ if (isDisposed()) return "TextLayout {*DISPOSED*}";
+ return Format( "TextLayout {{{}}", layout );
+}
+
+/*
+ * Translate a client offset to an internal offset
+ */
+int translateOffset(int offset) {
+ int length = text.length;
+ if (length == 0) return offset;
+ if (invalidOffsets is null) return offset;
+ for (int i = 0; i < invalidOffsets.length; i++) {
+ if (offset < invalidOffsets[i]) break;
+ offset++;
+ }
+ return offset;
+}
+
+/*
+ * Translate an internal offset to a client offset
+ */
+int untranslateOffset(int offset) {
+ int length = text.length;
+ if (length == 0) return offset;
+ if (invalidOffsets is null) return offset;
+ for (int i = 0; i < invalidOffsets.length; i++) {
+ if (offset == invalidOffsets[i]) {
+ offset++;
+ continue;
+ }
+ if (offset < invalidOffsets[i]) {
+ return offset - i;
+ }
+ }
+ return offset - invalidOffsets.length;
+}
+
+int validateOffset(int offset, int step) {
+ if (invalidOffsets is null) return offset + step;
+ int i = step > 0 ? 0 : invalidOffsets.length - 1;
+ do {
+ offset += step;
+ while (0 <= i && i < invalidOffsets.length) {
+ if (invalidOffsets[i] == offset) break;
+ i += step;
+ }
+ } while (0 <= i && i < invalidOffsets.length);
+ return offset;
+}
+
+}
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/internal/cairo/Cairo.d
--- a/dwt/internal/cairo/Cairo.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/internal/cairo/Cairo.d Mon Jan 07 23:29:21 2008 +0100
@@ -33,6 +33,11 @@
int width,
int height);
}
+private int CAIRO_VERSION_ENCODE(int major, int minor, int micro) {
+ return ((major) * 10000)
+ + ((minor) * 100)
+ + ((micro) * 1);
+}
template NameOfFunc(alias f) {
// Note: highly dependent on the .stringof formatting
@@ -126,8 +131,8 @@
mixin ForwardGtkCairoCFunc!(.cairo_path_data_t_sizeof );
mixin ForwardGtkCairoCFunc!(.cairo_path_t_sizeof );
mixin ForwardGtkCairoCFunc!(.cairo_text_extents_t_sizeof );
+ +/
mixin ForwardGtkCairoCFunc!(.CAIRO_VERSION_ENCODE);
- +/
mixin ForwardGtkCairoCFunc!(.cairo_append_path);
mixin ForwardGtkCairoCFunc!(.cairo_arc);
mixin ForwardGtkCairoCFunc!(.cairo_arc_negative);
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/internal/gtk/OS.d
--- a/dwt/internal/gtk/OS.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/internal/gtk/OS.d Mon Jan 07 23:29:21 2008 +0100
@@ -28,6 +28,81 @@
dwt.internal.gtk.c.gdkpixbuf;
// temporary added, because was not yet available
+
+struct XRenderPictureAttributes{
+ int repeat;
+ uint alpha_map;
+ int alpha_x_origin;
+ int alpha_y_origin;
+ int clip_x_origin;
+ int clip_y_origin;
+ uint clip_mask;
+ int graphics_exposures;
+ int subwindow_mode;
+ int poly_edge;
+ int poly_mode;
+ uint dither;
+ int component_alpha;
+}
+struct XRenderDirectFormat {
+ short red;
+ short redMask;
+ short green;
+ short greenMask;
+ short blue;
+ short blueMask;
+ short alpha;
+ short alphaMask;
+}
+struct XRenderPictFormat {
+ uint id;
+ int type;
+ int depth;
+ XRenderDirectFormat direct;
+ uint colormap;
+}
+
+struct XTransform {
+ int [3][3] matrix;
+}
+ struct XRectangle {
+ short x;
+ short y;
+ ushort width;
+ ushort height;
+ }
+private extern (C) uint XRenderCreatePicture(void *, uint, XRenderPictFormat *, uint, XRenderPictureAttributes *);
+private extern (C) XRenderPictFormat * XRenderFindStandardFormat (dwt.internal.gtk.c.cairotypes.Display *dpy, int format);
+private extern (C) XRenderPictFormat * XRenderFindVisualFormat (dwt.internal.gtk.c.cairotypes.Display *dpy, void *visual);
+private extern (C) void XRenderSetPictureTransform (void *dpy,uint picture, XTransform *transform);
+private extern (C) void XRenderSetPictureClipRectangles(void *, uint, int, int, XRectangle *, int);
+private extern (C) void XRenderFreePicture(void *, uint);
+private extern (C) void XRenderComposite(void *, int, uint, uint, uint, int, int, int, int, int, int, uint, uint);
+
+private extern (C) cairo_font_options_t * pango_cairo_context_get_font_options(void *);
+private extern (C) void pango_cairo_context_set_font_options(void *, cairo_font_options_t *);
+//void function(GtkWidget* widget, gchar* firstPropertyName, ... )gtk_widget_style_get;
+private void gtk_widget_style_get1( GtkWidget* widget, gchar* firstPropertyName, int* res ){
+ gtk_widget_style_get( widget, firstPropertyName, res, null );
+}
+
+
+private extern(C) PangoLayout *pango_cairo_create_layout (cairo_t *cr);
+private extern(C) void pango_cairo_layout_path (cairo_t *cr,
+ PangoLayout *layout);
+
+private extern(C) void gdk_pango_context_set_colormap (PangoContext *context,
+ GdkColormap *colormap);
+
+private extern(C) void pango_cairo_show_layout(cairo_t *cr, PangoLayout *layout);
+
+private extern(C) GdkRegion *gdk_pango_layout_get_clip_region(PangoLayout *layout,
+ gint x_origin,
+ gint y_origin,
+ gint *index_ranges,
+ gint n_ranges);
+
+
private extern(C) GdkWindow* GDK_ROOT_PARENT();
private extern(C) GdkPixbuf* gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
int width, int height);
@@ -62,6 +137,10 @@
extern (C) XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler);
extern (C) XErrorHandler XSetErrorHandler(XErrorHandler);
+int PANGO_PIXELS( int v ){
+ return (v+512) >> 10;
+}
+
template NameOfFunc(alias f) {
// Note: highly dependent on the .stringof formatting
@@ -695,6 +774,17 @@
public static const int VisibilityFullyObscured = 2;
public static const int VisibilityNotify = 15;
public static const int SYSTEM_TRAY_REQUEST_DOCK = 0;
+
+/** X render natives and constants */
+public static const int PictStandardARGB32 = 0;
+public static const int PictStandardRGB24 = 1;
+public static const int PictStandardA8 = 2;
+public static const int PictStandardA4 = 3;
+public static const int PictStandardA1 = 4;
+public static const int PictOpSrc = 1;
+public static const int PictOpOver = 3;
+
+
/++
// mixin ForwardGtkOsCFunc!(localeconv_decimal_point);
// mixin ForwardGtkOsCFunc!(realpath);
@@ -735,10 +825,10 @@
mixin ForwardGtkOsCFunc!(.gdk_x11_atom_to_xatom);
mixin ForwardGtkOsCFunc!(.gdk_x11_colormap_get_xcolormap);
mixin ForwardGtkOsCFunc!(.gdk_x11_drawable_get_xdisplay);
+ +/
mixin ForwardGtkOsCFunc!(.gdk_x11_drawable_get_xid);
- mixin ForwardGtkOsCFunc!(.gdk_x11_screen_lookup_visual);
- mixin ForwardGtkOsCFunc!(.gdk_x11_screen_get_window_manager_name);
- +/
+ //mixin ForwardGtkOsCFunc!(.gdk_x11_screen_lookup_visual);
+ //mixin ForwardGtkOsCFunc!(.gdk_x11_screen_get_window_manager_name);
mixin ForwardGtkOsCFunc!(.gdk_x11_visual_get_xvisual);
/+
mixin ForwardGtkOsCFunc!(.gdk_pixmap_foreign_new);
@@ -751,7 +841,6 @@
+/
mixin ForwardGtkOsCFunc!(.XRenderQueryExtension);
mixin ForwardGtkOsCFunc!(.XRenderQueryVersion);
- /+
mixin ForwardGtkOsCFunc!(.XRenderCreatePicture);
mixin ForwardGtkOsCFunc!(.XRenderSetPictureClipRectangles);
mixin ForwardGtkOsCFunc!(.XRenderSetPictureTransform);
@@ -759,8 +848,7 @@
mixin ForwardGtkOsCFunc!(.XRenderComposite);
mixin ForwardGtkOsCFunc!(.XRenderFindStandardFormat);
mixin ForwardGtkOsCFunc!(.XRenderFindVisualFormat);
-// mixin ForwardGtkOsCFunc!(Call );
- +/
+ //mixin ForwardGtkOsCFunc!(Call );
mixin ForwardGtkOsCFunc!(.GDK_DISPLAY);
mixin ForwardGtkOsCFunc!(.GDK_ROOT_PARENT);
/+
@@ -799,8 +887,9 @@
mixin ForwardGtkOsCFunc!(.G_TYPE_INT);
mixin ForwardGtkOsCFunc!(.G_OBJECT_TYPE );
mixin ForwardGtkOsCFunc!(.G_TYPE_STRING);
+ +/
mixin ForwardGtkOsCFunc!(.PANGO_PIXELS);
- mixin ForwardGtkOsCFunc!(.PANGO_TYPE_FONT_DESCRIPTION); +/
+ //mixin ForwardGtkOsCFunc!(.PANGO_TYPE_FONT_DESCRIPTION);
mixin ForwardGtkOsCFunc!(.g_cclosure_new);
mixin ForwardGtkOsCFunc!(.g_closure_ref);
@@ -965,8 +1054,8 @@
mixin ForwardGtkOsCFunc!(.gdk_keyval_to_lower);
mixin ForwardGtkOsCFunc!(.gdk_keyval_to_unicode);
mixin ForwardGtkOsCFunc!(.gdk_pango_context_get);
-// mixin ForwardGtkOsCFunc!(.gdk_pango_context_set_colormap);
-// mixin ForwardGtkOsCFunc!(.gdk_pango_layout_get_clip_region);
+ mixin ForwardGtkOsCFunc!(.gdk_pango_context_set_colormap);
+ mixin ForwardGtkOsCFunc!(.gdk_pango_layout_get_clip_region);
mixin ForwardGtkOsCFunc!(.gdk_pixbuf_copy_area);
mixin ForwardGtkOsCFunc!(.gdk_pixbuf_get_from_drawable);
mixin ForwardGtkOsCFunc!(.gdk_pixbuf_get_has_alpha);
@@ -1660,8 +1749,7 @@
mixin ForwardGtkOsCFunc!(.gtk_widget_show_now);
mixin ForwardGtkOsCFunc!(.gtk_widget_size_allocate);
mixin ForwardGtkOsCFunc!(.gtk_widget_size_request);
- mixin ForwardGtkOsCFunc!(.gtk_widget_style_get);
- mixin ForwardGtkOsCFunc!(.gtk_widget_style_get);
+ mixin ForwardGtkOsCFunc!(.gtk_widget_style_get1); // 1=get one property, see above
mixin ForwardGtkOsCFunc!(.gtk_widget_translate_coordinates);
mixin ForwardGtkOsCFunc!(.gtk_widget_unrealize);
mixin ForwardGtkOsCFunc!(.gtk_window_activate_default);
@@ -1707,12 +1795,12 @@
// mixin ForwardGtkOsCFunc!(.pango_cairo_font_map_get_default);
// mixin ForwardGtkOsCFunc!(.pango_cairo_font_map_new);
// mixin ForwardGtkOsCFunc!(.pango_cairo_font_map_create_context);
-// mixin ForwardGtkOsCFunc!(.pango_cairo_create_layout);
-// mixin ForwardGtkOsCFunc!(.pango_cairo_context_get_font_options);
-// mixin ForwardGtkOsCFunc!(.pango_cairo_context_set_font_options);
+ mixin ForwardGtkOsCFunc!(.pango_cairo_create_layout);
+ mixin ForwardGtkOsCFunc!(.pango_cairo_context_get_font_options);
+ mixin ForwardGtkOsCFunc!(.pango_cairo_context_set_font_options);
// mixin ForwardGtkOsCFunc!(.pango_cairo_font_map_set_resolution);
-// mixin ForwardGtkOsCFunc!(.pango_cairo_layout_path);
-// mixin ForwardGtkOsCFunc!(.pango_cairo_show_layout);
+ mixin ForwardGtkOsCFunc!(.pango_cairo_layout_path);
+ mixin ForwardGtkOsCFunc!(.pango_cairo_show_layout);
mixin ForwardGtkOsCFunc!(.pango_context_get_base_dir);
mixin ForwardGtkOsCFunc!(.pango_context_get_language);
mixin ForwardGtkOsCFunc!(.pango_context_get_metrics);
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/internal/gtk/c/cairotypes.d
--- a/dwt/internal/gtk/c/cairotypes.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/internal/gtk/c/cairotypes.d Mon Jan 07 23:29:21 2008 +0100
@@ -443,7 +443,14 @@
* matrix), but otherwise will remain unchanged.
* doubleascent;
*/
-public struct cairo_font_extents_t{}
+public struct cairo_font_extents_t{
+ double ascent;
+ double descent;
+ double height;
+ double max_x_advance;
+ double max_y_advance;
+}
+
// double ascent;
// cairo-Scaled-Fonts.html
// double descent;
@@ -468,7 +475,14 @@
* but otherwise will remain unchanged.
* doublex_bearing;
*/
-public struct cairo_text_extents_t{}
+public struct cairo_text_extents_t{
+ double x_bearing;
+ double y_bearing;
+ double width;
+ double height;
+ double x_advance;
+ double y_advance;
+}
// double xBearing;
// cairo-Scaled-Fonts.html
// double yBearing;
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/internal/gtk/c/pangotypes.d
--- a/dwt/internal/gtk/c/pangotypes.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/internal/gtk/c/pangotypes.d Mon Jan 07 23:29:21 2008 +0100
@@ -6,7 +6,7 @@
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
-
+
gtkD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -519,7 +519,12 @@
* gintoffset;
* the offset of the segment from the beginning of the
*/
-public struct PangoItem{}
+public struct PangoItem{
+ int offset;
+ int length;
+ int num_chars;
+ PangoAnalysis analysis;
+}
// int offset;
// pango-Text-Processing.html
// int length;
@@ -553,7 +558,14 @@
* GSList*extra_attrs;
* extra attributes for this segment.
*/
-public struct PangoAnalysis{}
+public struct PangoAnalysis{
+ void * shape_engine;
+ void * lang_engine;
+ void * font;
+ char level;
+ void * language;
+ GSList * extra_attrs;
+}
// PangoEngineShape *shapeEngine;
// pango-Text-Processing.html
// PangoEngineLang *langEngine;
@@ -588,7 +600,20 @@
* guintis_cursor_position:1;
* if set, cursor can appear in front of character.
*/
-public struct PangoLogAttr{}
+public struct PangoLogAttr{
+ uint flags;
+ bool is_line_break (){ return (flags & (1<< 0)) != 0; }
+ bool is_mandatory_break (){ return (flags & (1<< 1)) != 0; }
+ bool is_char_break (){ return (flags & (1<< 2)) != 0; }
+ bool is_white (){ return (flags & (1<< 3)) != 0; }
+ bool is_cursor_position (){ return (flags & (1<< 4)) != 0; }
+ bool is_word_start (){ return (flags & (1<< 5)) != 0; }
+ bool is_word_end (){ return (flags & (1<< 6)) != 0; }
+ bool is_sentence_boundary (){ return (flags & (1<< 7)) != 0; }
+ bool is_sentence_start (){ return (flags & (1<< 8)) != 0; }
+ bool is_sentence_end (){ return (flags & (1<< 9)) != 0; }
+ bool backspace_deletes_character(){ return (flags & (1<<10)) != 0; }
+}
// uint isLineBreak : 1; /+* Can break line inn front of character +/
// pango-Text-Processing.html
// uint isMandatoryBreak : 1; /+* Must break line inn front of character +/
@@ -670,7 +695,12 @@
* intheight;
* height of the rectangle.
*/
-public struct PangoRectangle{}
+public struct PangoRectangle{
+ int x;
+ int y;
+ int width;
+ int height;
+}
// int x;
// pango-Glyph-Storage.html
// int y;
@@ -800,7 +830,10 @@
* PangoItem*item;
* a PangoItem structure that provides information
*/
-public struct PangoGlyphItem{}
+public struct PangoGlyphItem {
+ PangoItem * item;
+ PangoGlyphString * glyphs;
+}
// PangoItem *item;
// pango-Glyph-Storage.html
// PangoGlyphString *glyphs;
@@ -1017,8 +1050,8 @@
public struct PangoAttribute
{
PangoAttrClass *klass;
- uint startIndex; /+* inn bytes +/
- uint endIndex; /+* inn bytes. The character at this index is not included +/
+ uint start_index; /+* inn bytes +/
+ uint end_index; /+* inn bytes. The character at this index is not included +/
}
@@ -1267,7 +1300,15 @@
* guintresolved_dir:3;
* the resolved PangoDirection of the line
*/
-public struct PangoLayoutLine{}
+public struct PangoLayoutLine{
+ void * layout;
+ int start_index;
+ int length;
+ GSList * runs;
+ uint flags;
+ //uint is_paragraph_start;
+ //uint resolved_dir;
+}
// PangoLayout *layout;
// pango-Layout-Objects.html
// int startIndex; /+* start of line as byte index into layout->text +/
diff -r 3c2d10c00f61 -r bc06000c0816 dwt/widgets/Event.d
--- a/dwt/widgets/Event.d Mon Jan 07 09:39:59 2008 +0100
+++ b/dwt/widgets/Event.d Mon Jan 07 23:29:21 2008 +0100
@@ -10,16 +10,14 @@
*******************************************************************************/
module dwt.widgets.Event;
+import dwt.graphics.GC;
+import dwt.graphics.Rectangle;
+
import tango.text.convert.Format;
/// PORTING_TYPE
class Display{}
class Widget{}
-class GC{}
-class Rectangle{
- this(int,int,int,int){}
- int x, y, width, height;
-}
/**
diff -r 3c2d10c00f61 -r bc06000c0816 todo.txt
--- a/todo.txt Mon Jan 07 09:39:59 2008 +0100
+++ b/todo.txt Mon Jan 07 23:29:21 2008 +0100
@@ -32,7 +32,7 @@
graphics/Font // OK
graphics/FontData // OK
graphics/FontMetrics // OK
-graphics/GC
+graphics/GC // OK
graphics/GCData // OK
graphics/GlyphMetrics // OK
graphics/Image // OK
@@ -51,7 +51,7 @@
graphics/Region // OK
graphics/Resource // OK
graphics/RGB // OK
-graphics/TextLayout
+graphics/TextLayout // OK (problems char/wchar)
graphics/TextStyle // OK
graphics/Transform // OK