Commit ca3bb0c2 by Graydon Hoare Committed by Graydon Hoare

2004-01-22 Graydon Hoare <graydon@redhat.com>

	* gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java:
	* gnu/java/awt/peer/gtk/GdkGlyphVector.java:
	Predicate static initialization on GtkToolkit.useGraphics2D().
	* java/awt/Component.java (processPaintEvent): Consume event.
	* javax/swing/AbstractButton.java: Reimplement, document.
	* javax/swing/DefaultButtonModel.java: Reimplement, document.
	* javax/swing/JComponent.java (paint): Use double buffer.
	(listenerList): Enable member.
	* javax/swing/ToggleButtonModel.java: Remove incorrect constructor.
	* javax/swing/JToggleButton.java
	(JToggleButton): Modify model constructor.
	* javax/swing/SwingUtilities.java
	(layoutCompoundLabel): Adjust arithmetic.
	* javax/swing/plaf/basic/BasicButtonUI.java: Reimplement, document.
	* javax/swing/plaf/basic/BasicGraphicsUtils.java
	(getPreferredButtonSize): Include margins in calculation.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals):
	Receive up events from subordinate layout component.

From-SVN: r76344
parent 1fd05073
2004-01-22 Graydon Hoare <graydon@redhat.com>
* gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java:
* gnu/java/awt/peer/gtk/GdkGlyphVector.java:
Predicate static initialization on GtkToolkit.useGraphics2D().
* java/awt/Component.java (processPaintEvent): Consume event.
* javax/swing/AbstractButton.java: Reimplement, document.
* javax/swing/DefaultButtonModel.java: Reimplement, document.
* javax/swing/JComponent.java (paint): Use double buffer.
(listenerList): Enable member.
* javax/swing/ToggleButtonModel.java: Remove incorrect constructor.
* javax/swing/JToggleButton.java
(JToggleButton): Modify model constructor.
* javax/swing/SwingUtilities.java
(layoutCompoundLabel): Adjust arithmetic.
* javax/swing/plaf/basic/BasicButtonUI.java: Reimplement, document.
* javax/swing/plaf/basic/BasicGraphicsUtils.java
(getPreferredButtonSize): Include margins in calculation.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals):
Receive up events from subordinate layout component.
2004-01-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Component.java (show): Set visible to true before
......
......@@ -70,6 +70,8 @@ public class GdkClasspathFontPeer extends ClasspathFontPeer
{
System.loadLibrary("gtkpeer");
}
if (GtkToolkit.useGraphics2D ())
initStaticState ();
}
native static void initStaticState ();
......
......@@ -60,6 +60,8 @@ public class GdkGlyphVector extends GlyphVector
{
System.loadLibrary("gtkpeer");
}
if (GtkToolkit.useGraphics2D ())
initStaticState ();
}
native static void initStaticState ();
......
......@@ -4252,6 +4252,7 @@ p * <li>the set of backward traversal keys
default:
throw new IllegalArgumentException("unknown paint event");
}
event.consume ();
}
finally
{
......
......@@ -46,6 +46,7 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
......@@ -56,6 +57,7 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.image.ImageObserver;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
......@@ -271,13 +273,16 @@ public abstract class JComponent extends Container implements Serializable
super();
super.setLayout(new FlowLayout());
listenerList = new EventListenerList();
//eventMask |= AWTEvent.COMP_KEY_EVENT_MASK;
enableEvents( AWTEvent.KEY_EVENT_MASK );
// enableEvents( AWTEvent.KEY_EVENT_MASK );
//updateUI(); // get a proper ui
}
// protected EventListenerList listenerList
protected EventListenerList listenerList;
public boolean contains(int x, int y)
{
//return dims.contains(x,y);
......@@ -701,11 +706,29 @@ public abstract class JComponent extends Container implements Serializable
public void paint(Graphics g)
{
// System.out.println("SWING_PAINT:" + this);
Graphics g2 = g;
Image im = null;
Rectangle r = getBounds ();
// System.err.println(this + ".paint(...), bounds = " + r);
if (use_double_buffer)
{
im = createImage (r.width, r.height);
g2 = im.getGraphics ();
g2.clearRect (0, 0, r.width, r.height);
}
paintBorder(g2);
paintComponent(g2);
paintChildren(g2);
paintBorder(g);
paintComponent(g);
paintChildren(g);
if (use_double_buffer)
{
// always draw at 0,0, because regardless of your current bounds,
// the graphics object you were passed was positioned so the origin
// was at the upper left corner of your bounds.
g.drawImage (im, 0, 0, (ImageObserver)null);
}
}
protected void paintBorder(Graphics g)
......@@ -729,7 +752,7 @@ public abstract class JComponent extends Container implements Serializable
protected void paintChildren(Graphics g)
{
// Paint this component's children.
//super.paintChildren(g);
super.paint(g);
}
protected void paintComponent(Graphics g)
......
......@@ -74,7 +74,7 @@ public class JToggleButton extends AbstractButton implements Accessible
super(text, icon);
// Create the model
setModel(new ToggleButtonModel(this));
setModel(new ToggleButtonModel());
model.setSelected(selected);
}
......
......@@ -97,8 +97,8 @@ public class SwingUtilities implements SwingConstants
// view rect 'vr' already ok,
// we need to compute ir (icon rect) and tr (text-rect)
int next_x = 0;//vr.x;
int next_y = 0;//vr.y;
int next_x = vr.x;
int next_y = vr.y;
ir.height = ir.width = ir.y = ir.x = 0;
......@@ -115,10 +115,10 @@ public class SwingUtilities implements SwingConstants
}
tr.x = next_x;
tr.y = vr.y + (vr.height/2);
tr.y = vr.y; // + (vr.height/2);
tr.width = fm.stringWidth(text);
tr.height = fm.getHeight() + fm.getAscent()/2;
tr.height = fm.getHeight(); // + fm.getAscent()/2;
return text;
}
......
......@@ -40,11 +40,6 @@ package javax.swing;
public class ToggleButtonModel extends DefaultButtonModel
{
ToggleButtonModel(JComponent c)
{
super(c);
}
public void setPressed(boolean b)
{
if (! isEnabled())
......
......@@ -595,6 +595,7 @@ public class BasicGraphicsUtils
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Insets insets = b.getInsets();
Insets margin = b.getMargin();
/* For determining the ideal size, do not assume a size restriction. */
viewRect = new Rectangle(0, 0,
......@@ -620,7 +621,6 @@ public class BasicGraphicsUtils
viewRect, iconRect, textRect,
textIconGap);
/* +------------------------+ +------------------------+
* | | | |
* | ICON | | CONTENTCONTENTCONTENT |
......@@ -630,7 +630,11 @@ public class BasicGraphicsUtils
*/
contentRect = textRect.union(iconRect);
return new Dimension(insets.left + contentRect.width + insets.right,
insets.top + contentRect.height + insets.bottom);
return new Dimension(insets.left + margin.left
+ contentRect.width
+ insets.right + margin.right,
insets.top + margin.top
+ contentRect.height
+ insets.bottom + margin.bottom);
}
}
......@@ -228,12 +228,25 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals
{
void *ptr = NSA_GET_PTR (env, obj);
jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
GtkWidget* vbox, *layout;
GList* children;
g_assert (gref);
gdk_threads_enter ();
gtk_widget_realize (ptr);
/* Receive events from the GtkLayout too */
children = gtk_container_get_children(GTK_CONTAINER(ptr));
vbox = children->data;
g_assert(GTK_IS_VBOX(vbox));
children = gtk_container_get_children(GTK_CONTAINER(vbox));
layout = children->data;
g_assert(GTK_IS_LAYOUT(layout));
g_signal_connect (GTK_OBJECT (layout), "event",
G_CALLBACK (pre_event_handler), *gref);
/* Connect signals for window event support. */
g_signal_connect (G_OBJECT (ptr), "delete-event",
G_CALLBACK (window_delete_cb), *gref);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment