2004-01-05 Thomas Fitzsimmons <fitzsim@redhat.com>

* gnu/java/awt/peer/gtk/GtkScrollPanePeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c
	(create(int, int)): New method.
	(create): Call new create method.
	(gtkScrolledWindowNew, gtkScrolledWindowSetSize): Remove
	methods.
	(childResized): Remove native implementation.  Implement in
	Java.
	(getHScrollbarHeight, getVScrollbarWidth): Call
	gtk_widget_size_request to get scrollbar dimensions.
	* java/awt/ScrollPane.java (getViewportSize): Reimplement.  Only
	call getVScrollbarWidth and getHScrollbarHeight when vertical
	and horizontal scrollbars respectively are needed.
	(doLayout): Enlarge child if it is smaller than the viewport.

From-SVN: r75446
This commit is contained in:
Thomas Fitzsimmons 2004-01-05 21:35:33 +00:00 committed by Thomas Fitzsimmons
parent 4b6eeb9ac4
commit 6037221c71
4 changed files with 142 additions and 36 deletions

View file

@ -46,15 +46,17 @@ import java.awt.peer.ScrollPanePeer;
public class GtkScrollPanePeer extends GtkContainerPeer
implements ScrollPanePeer
{
native void create ();
native void create (int width, int height);
void create ()
{
create (awtComponent.getWidth (), awtComponent.getHeight ());
}
native void gtkScrolledWindowNew(ComponentPeer parent,
int policy, int w, int h, int[] dims);
native void gtkScrolledWindowSetScrollPosition(int x, int y);
native void gtkScrolledWindowSetHScrollIncrement (int u);
native void gtkScrolledWindowSetVScrollIncrement (int u);
native void gtkScrolledWindowSetSize(int w, int h);
public GtkScrollPanePeer (ScrollPane sp)
{
super (sp);
@ -63,7 +65,24 @@ public class GtkScrollPanePeer extends GtkContainerPeer
}
native void setPolicy (int policy);
native public void childResized (int width, int height);
public void childResized (int width, int height)
{
int dim[] = new int[2];
gtkWidgetGetDimensions (dim);
// If the child is in this range, GTK adds both scrollbars, but
// the AWT doesn't. So set the peer's scroll policy to
// GTK_POLICY_NEVER.
if ((width > dim[0] - getVScrollbarWidth ()
&& width <= dim[0])
&& (height > dim[1] - getHScrollbarHeight ()
&& height <= dim[1]))
setPolicy (ScrollPane.SCROLLBARS_NEVER);
else
setPolicy (((ScrollPane) awtComponent).getScrollbarDisplayPolicy ());
}
native public int getHScrollbarHeight ();
native public int getVScrollbarWidth ();
native public void setScrollPosition (int x, int y);