summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/java/awt/peer/gtk/GdkGraphics.java')
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GdkGraphics.java114
1 files changed, 105 insertions, 9 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
index 8ea6817f33e..c374ba21826 100644
--- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -64,7 +64,7 @@ public class GdkGraphics extends Graphics
static final int GDK_COPY = 0, GDK_XOR = 2;
- native int[] initState (GtkComponentPeer component);
+ native void initState (GtkComponentPeer component);
native void initState (int width, int height);
native void copyState (GdkGraphics g);
@@ -84,15 +84,15 @@ public class GdkGraphics extends Graphics
initState (width, height);
color = Color.black;
clip = new Rectangle (0, 0, width, height);
- font = new Font ("Dialog", Font.PLAIN, 10);
+ font = new Font ("Dialog", Font.PLAIN, 12);
}
GdkGraphics (GtkComponentPeer component)
{
this.component = component;
- int rgb[] = initState (component);
- color = new Color (rgb[0], rgb[1], rgb[2]);
- font = component.awtComponent.getFont();
+ initState (component);
+ color = component.awtComponent.getForeground ();
+ font = component.awtComponent.getFont ();
Dimension d = component.awtComponent.getSize ();
clip = new Rectangle (0, 0, d.width, d.height);
}
@@ -126,6 +126,11 @@ public class GdkGraphics extends Graphics
native public void dispose ();
native void copyPixmap (Graphics g, int x, int y, int width, int height);
+ native void copyAndScalePixmap (Graphics g, boolean flip_x, boolean flip_y,
+ int src_x, int src_y,
+ int src_width, int src_height,
+ int dest_x, int dest_y,
+ int dest_width, int dest_height);
public boolean drawImage (Image img, int x, int y,
Color bgcolor, ImageObserver observer)
{
@@ -161,7 +166,10 @@ public class GdkGraphics extends Graphics
{
if (img instanceof GtkOffScreenImage)
{
- throw new RuntimeException ();
+ copyAndScalePixmap (img.getGraphics (), false, false,
+ 0, 0, img.getWidth (null), img.getHeight (null),
+ x, y, width, height);
+ return true;
}
GtkImage image = (GtkImage) img;
@@ -186,7 +194,60 @@ public class GdkGraphics extends Graphics
{
if (img instanceof GtkOffScreenImage)
{
- throw new RuntimeException ();
+ int dx_start, dy_start, d_width, d_height;
+ int sx_start, sy_start, s_width, s_height;
+ boolean x_flip = false;
+ 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;
@@ -238,13 +299,48 @@ public class GdkGraphics extends Graphics
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- // System.out.println ("drawRoundRect called [UNIMPLEMENTED]");
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
+ drawArc (x, y, arcWidth, arcHeight, 90, 90);
+ drawArc (xx, y, arcWidth, arcHeight, 0, 90);
+ drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ drawArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ int y1 = y + arcHeight / 2;
+ int y2 = y + height - arcHeight / 2;
+ drawLine (x, y1, x, y2);
+ drawLine (x + width, y1, x + width, y2);
+
+ int x1 = x + arcWidth / 2;
+ int x2 = x + width - arcWidth / 2;
+ drawLine (x1, y, x2, y);
+ drawLine (x1, y + height, x2, y + height);
}
public void fillRoundRect (int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- // System.out.println ("fillRoundRect called [UNIMPLEMENTED]");
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
+ fillArc (x, y, arcWidth, arcHeight, 90, 90);
+ fillArc (xx, y, arcWidth, arcHeight, 0, 90);
+ fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ fillArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
+ fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
}
public Shape getClip ()
OpenPOWER on IntegriCloud