comparison dwt/graphics/GC.d @ 21:4f9c0fea3440

Path
author Frank Benoit <benoit@tionex.de>
date Mon, 07 Jan 2008 09:11:15 +0100
parents b73b14942338
children bc06000c0816
comparison
equal deleted inserted replaced
20:55c4568a2bab 21:4f9c0fea3440
10 *******************************************************************************/ 10 *******************************************************************************/
11 module dwt.graphics.GC; 11 module dwt.graphics.GC;
12 12
13 import dwt.graphics.Image; 13 import dwt.graphics.Image;
14 14
15 class GC{
16 void drawImage(Image, int, int, int, int, int, int, int, int ){}
17 void dispose(){}
18 }
19 /+++
20 15
21 import dwt.internal.cairo.Cairo; 16 import dwt.internal.cairo.Cairo;
22 import dwt.internal.gtk.OS; 17 import dwt.internal.gtk.OS;
23 import dwt.internal.gtk.c.gdktypes; 18 import dwt.internal.gtk.c.gdktypes;
24 import dwt.internal.Converter; 19 import dwt.internal.Converter;
25 import dwt.internal.Compatibility; 20 import dwt.internal.Compatibility;
26 import dwt.SWT; 21 import dwt.SWT;
22 import dwt.graphics.Color;
27 import dwt.graphics.Drawable; 23 import dwt.graphics.Drawable;
28 import dwt.graphics.Resource; 24 import dwt.graphics.Resource;
29 import dwt.graphics.Device; 25 import dwt.graphics.Device;
30 import dwt.graphics.Font; 26 import dwt.graphics.Font;
31 import dwt.graphics.FontMetrics; 27 import dwt.graphics.FontMetrics;
32 import dwt.graphics.GCData; 28 import dwt.graphics.GCData;
33 import dwt.graphics.Image; 29 import dwt.graphics.Image;
34 import dwt.graphics.ImageData; 30 import dwt.graphics.ImageData;
35 import dwt.graphics.Path; 31 //import dwt.graphics.Path;
36 import dwt.graphics.Pattern; 32 import dwt.graphics.Pattern;
37 import dwt.graphics.Point; 33 import dwt.graphics.Point;
38 import dwt.graphics.RGB; 34 import dwt.graphics.RGB;
39 import dwt.graphics.Rectangle; 35 import dwt.graphics.Rectangle;
40 import dwt.graphics.Region; 36 import dwt.graphics.Region;
41 import dwt.graphics.Resource; 37 import dwt.graphics.Resource;
42 import dwt.graphics.Transform; 38 //import dwt.graphics.Transform;
39
40 import dwt.internal.gtk.c.cairotypes;
41
42 class GC{
43 void drawImage(Image, int, int, int, int, int, int, int, int ){}
44 void dispose(){}
45 bool isDisposed(){ return false; }
46 static void setCairoPatternColor(cairo_pattern_t * pattern, int offset, Color c, int alpha) {}
47 static void addCairoString(cairo_t* cairo, char[] str, float x, float y, Font font) {}
48 void initCairo() {}
49 void checkGC (int mask) {}
50 const static int FOREGROUND = 1 << 0;
51 const static int BACKGROUND = 1 << 1;
52 const static int FONT = 1 << 2;
53 const static int LINE_STYLE = 1 << 3;
54 const static int LINE_CAP = 1 << 4;
55 const static int LINE_JOIN = 1 << 5;
56 const static int LINE_WIDTH = 1 << 6;
57 const static int LINE_MITERLIMIT = 1 << 7;
58 const static int BACKGROUND_BG = 1 << 8;
59 const static int DRAW_OFFSET = 1 << 9;
60 const static int DRAW = FOREGROUND | LINE_WIDTH | LINE_STYLE | LINE_CAP | LINE_JOIN | LINE_MITERLIMIT | DRAW_OFFSET;
61 const static int FILL = BACKGROUND;
62
63
64 GCData data;
65 }
66
67 /+++
43 68
44 /** 69 /**
45 * Class <code>GC</code> is where all of the drawing capabilities that are 70 * Class <code>GC</code> is where all of the drawing capabilities that are
46 * supported by SWT are located. Instances are used to draw on either an 71 * supported by SWT are located. Instances are used to draw on either an
47 * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>. 72 * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
175 this.device = data.device = device; 200 this.device = data.device = device;
176 init(drawable, data, gdkGC); 201 init(drawable, data, gdkGC);
177 if (device.tracking) device.new_Object(this); 202 if (device.tracking) device.new_Object(this);
178 } 203 }
179 204
180 static void addCairoString(int /*long*/ cairo, String string, float x, float y, Font font) { 205 static void addCairoString(cairo_t* cairo, String string, float x, float y, Font font) {
181 byte[] buffer = Converter.wcsToMbcs(null, string, true); 206 byte[] buffer = Converter.wcsToMbcs(null, string, true);
182 if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) { 207 if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
183 int /*long*/ layout = OS.pango_cairo_create_layout(cairo); 208 int /*long*/ layout = OS.pango_cairo_create_layout(cairo);
184 if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES); 209 if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
185 OS.pango_layout_set_text(layout, buffer, -1); 210 OS.pango_layout_set_text(layout, buffer, -1);
3063 if (rects[0] != 0) OS.g_free(rects[0]); 3088 if (rects[0] != 0) OS.g_free(rects[0]);
3064 } 3089 }
3065 Cairo.cairo_clip(cairo); 3090 Cairo.cairo_clip(cairo);
3066 } 3091 }
3067 3092
3068 static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c, int alpha) { 3093 static void setCairoPatternColor( cairo_pattern_t* pattern, int offset, Color c, int alpha) {
3069 GdkColor color = c.handle; 3094 GdkColor color = c.handle;
3070 double aa = (alpha & 0xFF) / (double)0xFF; 3095 double aa = (alpha & 0xFF) / (double)0xFF;
3071 double red = ((color.red & 0xFFFF) / (double)0xFFFF); 3096 double red = ((color.red & 0xFFFF) / (double)0xFFFF);
3072 double green = ((color.green & 0xFFFF) / (double)0xFFFF); 3097 double green = ((color.green & 0xFFFF) / (double)0xFFFF);
3073 double blue = ((color.blue & 0xFFFF) / (double)0xFFFF); 3098 double blue = ((color.blue & 0xFFFF) / (double)0xFFFF);