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  cairo = data.cairo; if (cairo != 0) { if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {  checkGC(FOREGROUND | FONT); 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); Cairo.cairo_new_path(cairo); return; } } setString(string, flags); if (cairo != 0) { if ((flags & SWT.DRAW_TRANSPARENT) == 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])); Cairo.cairo_fill(cairo); } checkGC(FOREGROUND | FONT); Cairo.cairo_move_to(cairo, x, y); OS.pango_cairo_show_layout(cairo, data.layout); return; } checkGC(FOREGROUND | FONT | BACKGROUND_BG); GdkColor background = null; if ((flags & SWT.DRAW_TRANSPARENT) == 0) background = data.background; if (!data.xorMode) { OS.gdk_draw_layout_with_colors(data.drawable, handle, x, y, data.layout, null, background); } else { int  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  pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1); if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES); int  gdkGC = OS.gdk_gc_new(pixmap); if (gdkGC == 0) 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_gc_set_foreground(gdkGC, data.foreground); OS.gdk_draw_layout_with_colors(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.g_object_unref(pixmap); }
public void drawText(String string, int x, int y) { drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
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)) {			//TODO - honor flags			checkGC(FOREGROUND | FONT);			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);			Cairo.cairo_new_path(cairo);			return;		}	}	setString(string, flags);	if (cairo != 0) {		if ((flags & SWT.DRAW_TRANSPARENT) == 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]));			Cairo.cairo_fill(cairo);		}		checkGC(FOREGROUND | FONT);		Cairo.cairo_move_to(cairo, x, y);		OS.pango_cairo_show_layout(cairo, data.layout);		return;	}	checkGC(FOREGROUND | FONT | BACKGROUND_BG);	GdkColor background = null;	if ((flags & SWT.DRAW_TRANSPARENT) == 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();		OS.gdk_gc_set_foreground(gdkGC, black);		OS.gdk_draw_rectangle(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.g_object_unref(gdkGC);		OS.gdk_draw_drawable(data.drawable, handle, pixmap, 0, 0, x, y, width, height);		OS.g_object_unref(pixmap);	}}