58 |
GtkComponentPeer component; |
GtkComponentPeer component; |
59 |
Font font; |
Font font; |
60 |
Rectangle clip; |
Rectangle clip; |
61 |
|
GtkImage image; |
62 |
|
|
63 |
int xOffset = 0; |
int xOffset = 0; |
64 |
int yOffset = 0; |
int yOffset = 0; |
67 |
|
|
68 |
native void initState (GtkComponentPeer component); |
native void initState (GtkComponentPeer component); |
69 |
native void initState (int width, int height); |
native void initState (int width, int height); |
70 |
|
native void initFromImage (GtkImage image); |
71 |
native void copyState (GdkGraphics g); |
native void copyState (GdkGraphics g); |
72 |
|
|
73 |
GdkGraphics (GdkGraphics g) |
GdkGraphics (GdkGraphics g) |
89 |
font = new Font ("Dialog", Font.PLAIN, 12); |
font = new Font ("Dialog", Font.PLAIN, 12); |
90 |
} |
} |
91 |
|
|
92 |
|
GdkGraphics (GtkImage image) |
93 |
|
{ |
94 |
|
this.image = image; |
95 |
|
initFromImage (image); |
96 |
|
color = Color.black; |
97 |
|
clip = new Rectangle (0, 0, |
98 |
|
image.getWidth(null), image.getHeight(null)); |
99 |
|
font = new Font ("Dialog", Font.PLAIN, 12); |
100 |
|
} |
101 |
|
|
102 |
GdkGraphics (GtkComponentPeer component) |
GdkGraphics (GtkComponentPeer component) |
103 |
{ |
{ |
104 |
this.component = component; |
this.component = component; |
105 |
font = component.awtComponent.getFont (); |
font = component.awtComponent.getFont (); |
106 |
|
color = Color.black; |
107 |
|
|
108 |
if (component.isRealized ()) |
if (component.isRealized ()) |
109 |
initComponentGraphics (); |
initComponentGraphics (); |
148 |
int src_width, int src_height, |
int src_width, int src_height, |
149 |
int dest_x, int dest_y, |
int dest_x, int dest_y, |
150 |
int dest_width, int dest_height); |
int dest_width, int dest_height); |
151 |
|
|
152 |
public boolean drawImage (Image img, int x, int y, |
public boolean drawImage (Image img, int x, int y, |
153 |
Color bgcolor, ImageObserver observer) |
Color bgcolor, ImageObserver observer) |
154 |
{ |
{ |
155 |
if (component != null && ! component.isRealized ()) |
return drawImage(img, x, y, img.getWidth(null), img.getHeight(null), |
156 |
return false; |
bgcolor, observer); |
|
|
|
|
if (img instanceof GtkOffScreenImage) |
|
|
{ |
|
|
int width = img.getWidth (null); |
|
|
int height = img.getHeight (null); |
|
|
copyPixmap (img.getGraphics (), |
|
|
x, y, width, height); |
|
|
return true; |
|
|
} |
|
|
|
|
|
GtkImage image = (GtkImage) img; |
|
|
new GtkImagePainter (image, this, x, y, -1, -1, bgcolor, observer); |
|
|
return image.isLoaded (); |
|
157 |
} |
} |
158 |
|
|
159 |
public boolean drawImage (Image img, int x, int y, ImageObserver observer) |
public boolean drawImage (Image img, int x, int y, ImageObserver observer) |
160 |
{ |
{ |
161 |
if (component != null && ! component.isRealized ()) |
return drawImage (img, x, y, null, observer); |
|
return false; |
|
|
|
|
|
if (img instanceof GtkOffScreenImage) |
|
|
{ |
|
|
int width = img.getWidth (null); |
|
|
int height = img.getHeight (null); |
|
|
copyPixmap (img.getGraphics (), |
|
|
x, y, width, height); |
|
|
return true; |
|
|
} |
|
|
|
|
|
if (component != null) |
|
|
return drawImage (img, x, y, component.getBackground (), observer); |
|
|
else |
|
|
return drawImage (img, x, y, SystemColor.window, observer); |
|
162 |
} |
} |
163 |
|
|
164 |
public boolean drawImage (Image img, int x, int y, int width, int height, |
public boolean drawImage (Image img, int x, int y, int width, int height, |
165 |
Color bgcolor, ImageObserver observer) |
Color bgcolor, ImageObserver observer) |
166 |
{ |
{ |
167 |
if (component != null && ! component.isRealized ()) |
if (img instanceof GtkImage) |
168 |
return false; |
return ((GtkImage)img).drawImage (this, x, y, width, height, |
169 |
|
bgcolor, observer); |
170 |
if (img instanceof GtkOffScreenImage) |
else |
171 |
{ |
return (new GtkImage(img.getSource())).drawImage (this, x, y, |
172 |
copyAndScalePixmap (img.getGraphics (), false, false, |
width, height, |
173 |
0, 0, img.getWidth (null), img.getHeight (null), |
bgcolor, observer); |
|
x, y, width, height); |
|
|
return true; |
|
|
} |
|
|
|
|
|
GtkImage image = (GtkImage) img; |
|
|
new GtkImagePainter (image, this, x, y, width, height, bgcolor, observer); |
|
|
return image.isLoaded (); |
|
174 |
} |
} |
175 |
|
|
176 |
public boolean drawImage (Image img, int x, int y, int width, int height, |
public boolean drawImage (Image img, int x, int y, int width, int height, |
177 |
ImageObserver observer) |
ImageObserver observer) |
178 |
{ |
{ |
179 |
if (component != null && ! component.isRealized ()) |
return drawImage (img, x, y, width, height, null, observer); |
|
return false; |
|
|
|
|
|
if (component != null) |
|
|
return drawImage (img, x, y, width, height, component.getBackground (), |
|
|
observer); |
|
|
else |
|
|
return drawImage (img, x, y, width, height, SystemColor.window, |
|
|
observer); |
|
180 |
} |
} |
181 |
|
|
182 |
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, |
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, |
183 |
int sx1, int sy1, int sx2, int sy2, |
int sx1, int sy1, int sx2, int sy2, |
184 |
Color bgcolor, ImageObserver observer) |
Color bgcolor, ImageObserver observer) |
185 |
{ |
{ |
186 |
if (component != null && ! component.isRealized ()) |
if (img instanceof GtkImage) |
187 |
return false; |
return ((GtkImage)img).drawImage(this, dx1, dy1, dx2, dy2, |
188 |
|
sx1, sy1, sx2, sy2, bgcolor, observer); |
189 |
if (img instanceof GtkOffScreenImage) |
else |
190 |
{ |
return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1, |
191 |
int dx_start, dy_start, d_width, d_height; |
dx2, dy2, |
192 |
int sx_start, sy_start, s_width, s_height; |
sx1, sy1, sx2, sy2, |
193 |
boolean x_flip = false; |
bgcolor, observer); |
|
boolean y_flip = false; |
|
|
|
|
|
if (dx1 < dx2) |
|
|
{ |
|
|
dx_start = dx1; |
|
|
d_width = dx2 - dx1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
dx_start = dx2; |
|
|
d_width = dx1 - dx2; |
|
|
x_flip ^= true; |
|
|
} |
|
|
if (dy1 < dy2) |
|
|
{ |
|
|
dy_start = dy1; |
|
|
d_height = dy2 - dy1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
dy_start = dy2; |
|
|
d_height = dy1 - dy2; |
|
|
y_flip ^= true; |
|
|
} |
|
|
if (sx1 < sx2) |
|
|
{ |
|
|
sx_start = sx1; |
|
|
s_width = sx2 - sx1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
sx_start = sx2; |
|
|
s_width = sx1 - sx2; |
|
|
x_flip ^= true; |
|
|
} |
|
|
if (sy1 < sy2) |
|
|
{ |
|
|
sy_start = sy1; |
|
|
s_height = sy2 - sy1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
sy_start = sy2; |
|
|
s_height = sy1 - sy2; |
|
|
y_flip ^= true; |
|
|
} |
|
|
|
|
|
copyAndScalePixmap (img.getGraphics (), x_flip, y_flip, |
|
|
sx_start, sy_start, s_width, s_height, |
|
|
dx_start, dy_start, d_width, d_height); |
|
|
return true; |
|
|
} |
|
|
|
|
|
GtkImage image = (GtkImage) img; |
|
|
new GtkImagePainter (image, this, dx1, dy1, dx2, dy2, |
|
|
sx1, sy1, sx2, sy2, bgcolor, observer); |
|
|
return image.isLoaded (); |
|
194 |
} |
} |
195 |
|
|
196 |
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, |
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, |
197 |
int sx1, int sy1, int sx2, int sy2, |
int sx1, int sy1, int sx2, int sy2, |
198 |
ImageObserver observer) |
ImageObserver observer) |
199 |
{ |
{ |
200 |
if (component != null && ! component.isRealized ()) |
return drawImage (img, dx1, dy1, dx2, dy2, |
201 |
return false; |
sx1, sy1, sx2, sy2, |
202 |
|
null, observer); |
|
if (component != null) |
|
|
return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, |
|
|
component.getBackground (), observer); |
|
|
else |
|
|
return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, |
|
|
SystemColor.window, observer); |
|
203 |
} |
} |
204 |
|
|
205 |
public native void drawLine(int x1, int y1, int x2, int y2); |
public native void drawLine(int x1, int y1, int x2, int y2); |