Commit 86881a7b by Graydon Hoare

[multiple changes]

2004-03-12  Graydon Hoare  <graydon@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java: Clipping fixes.
	* javax/swing/JComponent.java (paint): Use persistent double buffer.
	* javax/swing/JList.java (ListListener): Revalidate on changes.
	* javax/swing/JScrollPane.java: Reimplement.
	* javax/swing/JViewport.java: Reimplement.
	* javax/swing/ScrollPaneLayout.java: Reimplement.
	* javax/swing/ViewportLayout.java: Tidy up.
	* javax/swing/plaf/basic/BasicButtonListener.java: Remove printlns.
	* javax/swing/plaf/basic/BasicScrollPaneUI.java: Reimplement.
	* javax/swing/plaf/basic/BasicSliderUI.java: Handle missing labels.
	* javax/swing/plaf/basic/BasicViewportUI.java: Implement in terms of
	backing store only.

2004-03-11  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(window_wm_protocols_filter): New function.
	(window_focus_in_cb): Remove function.
	(window_focus_out_cb): Likewise.
	(window_focus_or_active_state_change_cb): New function.
	(create): Add filter that removes WM_TAKE_FOCUS client messages.
	(connectSignals): Don't attach handlers to focus-in-event or
	focus-out-event signals.  Handle notify signal.

2004-03-11  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
	(gtkSetLabel): New native method declaration.
	(setLabel): Use gtkSetLabel.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel): New method.

2004-03-10  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java (setColor): Default to
	black when color argument is null.

2004-03-10  Kim Ho  <kho@redhat.com>

	* java/awt/Container.java: Remove check
	for drag events.

2004-03-10  Kim Ho  <kho@redhat.com>

	* java/awt/Container.java: (visitChild):
	Remove candidate clip. Use the component
	clip to intersect.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
	(handleEvent): Use the PaintEvent's clip.

2004-03-10  Kim Ho  <kho@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
	(handleEvent): Don't set the clip for the
	Graphics object.

2004-03-09  Graydon Hoare  <graydon@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
	Fix double <-> fixed macros, reset font transform.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c:
	Likewise.

2004-03-09�� Kim Ho  <kho@redhat.com>

	* java/awt/Container.java: (visitChild): Move
	the x and y coordinate of the component rectangle
	to correct position.
	(handleEvent): Forward drag events to the pressed
	component.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	Fix comments.
	(ArrowButtonListener::mousePressed): Stop the
	existing timer.
	(mouseDragged): Implement.
	(TrackListener::mousePressed): Only react if
	the press doesn't occur on the thumb, otherwise
	just set the offset.
	(TrackListener::mouseReleased): Unset the isAdjusting
	value.
	(createIncreaseIcon): Switch icon.
	(createDecreaseIcon): Switch icon.
	(calculatePreferredSize): Use width.
	(getThumbBounds): Use the top as the lower value.
	(layoutVScrollBar): Switch the button locations.
	(paintIncreaseHighlight): Paint correct side of thumb.
	(paintDecreaseHighlight): ditto.
	(valueForYPosition): Use top as the lower value.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	Fix comments.
	(mouseDragged): Implement.
	(mousePressed): Only react when the thumb isn't
	pressed, otherwise just set offset.
	(mouseReleased): Handle a release of the thumb.
	(scrollDueToClickInTrack): Stop the timer first.
	* javax/swing/JProgressBar.java:
	(setString): Fix change condition.
	* javax/swing/JSeparator.java:
	Remove println's.

2004-03-08  David Jee  <djee@redhat.com>

	* java/awt/image/AffineTransformOp.java:
	(filter): Use Graphics2D interface instead of directly using the
	GdkGraphics2D peer.

2004-03-05  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkButtonPeer.java
	(handleEvent): Action events are generated upon MOUSE_RELEASED.
	* java/awt/Container.java
	(acquireComponentForMouseEvent): Fixed.
	(handleEvent): Fixed.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(state_to_awt_mods_with_button_states): New method.
	(pre_event_handler): Fixed mouse event generation.

2004-03-05  Olga Rodimina  <rodimina@redhat.com>

	gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(GdkGraphics2D (BufferedImage)): Initialize
	pixmap associated with specified BufferedImage.
	(setPaint): Changed implementation of Texture
	Paint to use AffineTransformOp.
	* java/awt/image/AffineTransformOp.java
	(createCompatibleDestRaster): Throw RasterFormatException
	if resulting width or height of raster is 0.

2004-03-04  Olga Rodimina  <rodimina@redhat.com>

	* java/awt/image/AffineTransformOp.java:
	Removed unnecessary field interpolationType.
	Formatted some of the lines to be consistent with
	the GNU style.
	(AffineTransformOp): Create new RenderingHints
	containing specified interpolation type.
	(createCompatibleDestImage): Implemented.
	(createCompatibleDestRaster): Implemented.
	(filter): Implemented.
	(getBounds2D(BufferedImage)): Implemented.
	(getBounds2D(Raster)): Implemented.
	(getInterpolationType): Get interpolation value from
	rendering hints.

2004-03-04  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkContainerPeer.java
	(setFont): Check if child peers are null.

2004-03-04  Graydon Hoare  <graydon@redhat.com>

	* testsuite/lib/libjava.exp (libjava_find_lib): Don't include
	.libs in -L option.
	(libjava_arguments): Add new libraries to argument list.

2004-03-04  Tom Tromey  <tromey@redhat.com>

	* Makefile.in: Rebuilt.
	* Makefile.am (toolexeclib_LTLIBRARIES): Added lib-java-awt.la,
	lib-javax-swing.la, lib-java-applet.la, lib-java-beans.la.
	(misc_java_source_files): New macro.
	(swing_java_source_files): Likewise.
	(awt_java_source_files): Pruned.
	(applet_java_source_files): New macro.
	(beans_java_source_files): Likewise.
	(lib_java_applet_la_SOURCES): Likewise.
	(lib_java_awt_la_SOURCES): Likewise.
	(lib_javax_swing_la_SOURCES): Likewise.
	(lib_java_beans_la_SOURCES): Likewise.
	(all_java_object_files): Likewise.
	(%.lo: %.java): Use all_java_object_files.
	(all_java_source_files): Added new _SOURCES.
	(ordinary_java_source_files): Removed awt_java_source_files.

2004-03-02  Olga Rodimina  <rodimina@redhat.com>

	* Makefile.am: Added java/awt/image/AffineTransformOp.java
	* Makefile.in: Re-generated.
	* java/awt/image/AffineTransformOp.java: New Class.

2004-03-01  Olga Rodimina  <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(setPaint): Interpret correctly TexturePaint's
	anchor rectangle.
	(drawImage): Fixed scale factors of the affine
	transform.

2004-02-27  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java
	(GdkGraphics(Component)): Inherit font from component.
	(drawString): Use font style.
	* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
	(gtkSetFont): New native method declaration.
	(setFont): New method.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(gtkSetFont): New native method declaration.
	(setFont): Call new native method gtkSetFont.
	* gnu/java/awt/peer/gtk/GtkContainerPeer.java
	(setFont): For all child components who do not their fonts set,
        set their peers' fonts with this container's font.
	* gnu/java/awt/peer/gtk/GtkLabelPeer.java:
	Move all native method declarations to the top for readability.
	(gtkSetFont): New native method declaration.
	(setFont): New method.
	* java/awt/Component.java
	(setFont): Invalidate after setting the font.
	* java/awt/Container.java
	(invalidateTree): New method.
	(setFont): Invalidate the container tree after setting the font.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
	(Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Use font style.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont): New method.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkSetFont): New method.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkSetFont): New method.

2004-02-27  Olga Rodimina <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(updateBufferedImage): New helper function.
	Updates BufferedImage in memory if it was changed.
	(draw): changed to update BufferedImage in memory after
	this drawing operation
	(fill): Ditto.
	(draw3DRect): Ditto.
	(fill3DRect): Ditto.
	(clearRect): Ditto.
	(drawRaster): Ditto.
	(drawImage) : Ditto. Update only in case of GtkOffScreenImage with
	no affine transformation.
	(drawGlyphVector): Ditto.

2004-02-26  Olga Rodimina <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(isBufferedImageGraphics): New Helper function.
	Returns true if this graphics2d can be used to draw
	into buffered image and false otherwise.
	(updateImagePixels): New Helper function.
	Updates pixels in the BufferedImage.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
	(getImagePixels): New function. Returns pixels
	of the buffered image associated with
	this Graphics2D.

2004-02-26  David Jee  <djee@redhat.com>

	* java/awt/BorderLayout.java
	(layoutContainer): Fix width and height calculations to ensure
	that they're non-negative.
	* java/awt/Component.java
	(setBackground): If c is null, inherit from closest ancestor whose
	background color is set.

2004-02-26�� Kim Ho�� <kho@redhat.com>

	* Makefile.am: Add new files.
	* Makefile.in: Re-generate.
	* javax/swing/JProgressBar.java:
	(JProgressBar(int, int int)): Throw
	IllegalArgumentException if orientation is
	invalid.
	(JProgressBar(BoundedRangeModel)): Create
	ChangeListener and register it. UpdateUI.
	(getChangeListeners): Implement.
	(setModel): Reset ChangeListener.
	* javax/swing/JScrollBar.java: Implement.
	* javax/swing/JSeparator.java: Implement.
	* javax/swing/JSlider.java:
	(JSlider(int, int, int, int)): Throw
	IllegalArgumentException if orientation
	is invalid.
	(getChangeListeners): Fix method name.
	* javax/swing/SwingUtilities.java:
	(layoutCompoundLabel): If there is no text,
	set the text rectangle dimensions to 0.
	* javax/swing/plaf/basic/BasicButtonUI.java:
	(paint): If there is no text, don't paint it.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	Implement.
	* javax/swing/plaf/basic/BasicSeparatorUI.java:
	Implement.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	(propertyChange): If the model changes, change
	the listeners accordingly.

2004-02-25  Graydon Hoare  <graydon@redhat.com>

	* javax/swing/AbstractButton.java: Add "final" qualifiers.
	* javax/swing/JList.java: Reimplement.
	* javax/swing/DefaultListSelectionModel.java: Reimplement.
	* javax/swing/plaf/basic/BasicListUI.java: Reimplement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java: Add "purple" values.
	* javax/swing/ListModel.java: Javadoc.
	* javax/swing/ListSelectionModel.java: Add missing methods.
	* javax/swing/AbstractListModel.java: Javadoc and corrections.
	* javax/swing/DefaultListModel.java: Javadoc and corrections.
	* javax/swing/ListModel.java: Javadoc and corrections.
	* javax/swing/DefaultListCellRenderer.java: Minor tidying.

2004-02-25  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkFontPeer.java
	(GtkFontPeer): Change default size to 12.
	* gnu/java/awt/peer/gtk/GtkToolkit.java
	(getFontPeer): Change default size to 12.
	(getClasspathFontPeer): Likewise. Set default name to "Default".
	* java/awt/Font.java
	(Font(Map)): Call Font(String,Map).
	(Font(String,Map)): If attrs is null, initialize it as an empty
	HashMap, which will ensure that the Font will get default attributes.

2004-02-25  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkFontPeer.java
	(GtkFontPeer(String,int)): Call the new constructor with size 1.
	(GtkFontPeer(String,int,int)): New constructor with size attribute.
	* gnu/java/awt/peer/gtk/GtkToolkit.java
	(getFontPeer(String,int)): Call the new overload method with size 1.
	(getFontPeer(String,int,int)): New method. Overloaded with size
	attribute.
	(getClasspathFontPeer): Set the size of the font.

2004-02-24  Olga Rodimina  <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(bimage): New field.
	(GdkGraphics2D): New Constructor. Constructs Graphics
	object that can be used to draw into the Buffered Image.
	* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
	(GdkGraphicsEnvironment): Fixed to include public
	keyword.
	(createGraphics): Implemented.
	* gnu/java/awt/peer/gtk/GtkToolkit.java
	(getLocalGraphicsEnvironment): Implemented.
	* java/awt/GraphicsEnvironment.java:
	(getLocalGraphicsEnvironment): Implemented.
	* java/awt/image/BufferedImage.java:
	(createGraphics): Implemented.

2004-02-24  David Jee  <djee@redhat.com>

	* java/awt/Component.java
	(eventTypeEnabled): Add MOUSE_MOVED and MOUSE_DRAGGED event types.
	* java/awt/Container.java
	(addNotifyContainerChildren): Fix event enabling.

2004-02-23  Olga Rodimina  <rodimina@redhat.com>

	* Makefile.am: Added
	gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
	* Makefile.in: Re-generated.
	* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
	New Class.

2004-02-19  Kim Ho  <kho@redhat.com>

	* Makefile.am: Add BasicProgressBarUI
	* Makefile.in: Regenerate.
	* javax/swing/JProgressBar.java:
	Re-implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	Add constants for JProgressBar.
	* javax/swing/plaf/basic/BasicProgressBarUI.java
	Implement.
	* javax/swing/plaf/basic/BasicSliderUI.java
	Change comments.
	(calculateGeometry): New method
	(paint): Remove unnecessary size calculations.

2004-02-18  Olga Rodimina  <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(drawRaster): Fixed small error that caused
	imageToUser transformation to be set incorrectly.
	(toString): Implemented.

2004-02-18  David Jee  <djee@redhat.com>

	* java/awt/CardLayout.java
	(addLayoutComponent): Show the first component added as the default.
	(removeLayoutComponent): After removing, show the next component.
	(gotoComponent): If there is only one component, show it and return.

2004-02-18  Kim Ho  <kho@redhat.com>

	* javax/swing/JSlider.java: Re-order
	modifiers.
	* javax/swing/JLabel.java: Re-order
	modifiers.
	* javax/swing/JComponent.java:
	(addPropertyChangeListener):
	Implement.
	(removePropertyChangeListener):
	ditto.
	(firePropertyChangeEvent):
	ditto.

2004-02-17  David Jee  <djee@redhat.com>

	* java/awt/Component.java
	(show): Dispatch ComponentEvent via system event queue.
	(hide): Likewise.
	(move): Likewise.
	(resize): Likewise.
	(reshape): Likewise.
	* java/awt/Window.java
	(setBoundsCallback): Likewise.

2004-02-17  David Jee  <djee@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds):
	Use gtk_widget_set_size_request() instead of the deprecated
	gtk_widget_set_usize().

2004-02-17  Kim Ho  <kho@redhat.com>

	* javax/swing/JSlider.java: Fix comments and
	make property strings constants.
	(createStandardLabels): Use the labels
	preferred size as bounds.
	* javax/swing/plaf/basic/BasicSliderUI.java
	Fix comments.
	(ScrollHandler::actionPerformed): Don't
	calculate the timer stop value. Let the
	MouseListeners find the stop location.
	(getPreferredHorizontalSize): Re-implement.
	(getPreferredVerticalSize): ditto.
	(getMinimumHorizontalSize): ditto.
	(getMinimumVerticalSize): ditto.
	(getPreferredSize): ditto.
	(getMinimumSize): ditto.
	(getMaximumSize): ditto.
	(paintTicks): Use doubles to find the
	tick location.
	(paintHorizontalLabel):�� Use preferredSize
	as initial width and height.
	(paintVerticalLabel): ditto.

2004-02-17  Kim Ho  <kho@redhat.com>

	* javax/swing/JLabel.java: Changed
	property strings to constants.
	(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY):
	New property.
	(setText): Change mnemonic index if
	text is too short.
	(setDisplayedMnemonicIndex): Fire property
	change event.
	(getDisplayedMnemonicIndex): Remove check
	against short text.

2004-02-17 Olga Rodimina <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
	(drawImage(img,xform,obs)): Invert xform before
	passing the xform to cairo.
	(drawImage(img,x,y,bgcolor,obs)): Implemented.
	(drawImage (img,x,y,w,h,bgcolor,obs)): Partly
	implemented.
	(drawImage (img,x,y,w,h,obs)): Implemented.
	(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
	bgcolor,obs)): Partly implemented.
	(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,obs)):
	Implemented.
	* java/awt/image/BufferedImage.java:
	(copyData): if dest is null, create raster with same
	dimensions as the current image.

2004-02-16  Graydon Hoare  <graydon@redhat.com>

	* javax/swing/plaf/basic/BasicLabelUI.java
	(getPreferredSize): Use layoutCL.
	* javax/swing/plaf/basic/BasicGraphicsUtils.java
	(getPreferredButtonSize): Start with empty view rect, layout using
	component's preferred alignment.
	* javax/swing/plaf/basic/BasicLookAndFeel.java: Add some Label and
	List defaults.

2004-02-16  David Jee  <djee@redhat.com>

	* java/awt/Component.java
	(show): Dispatch COMPONENT_SHOWN ComponentEvent.
	(hide): Dispatch COMPONENT_HIDDEN ComponentEvent.
	(move): Erase old bounds and repaint new bounds. Dispatch
	COMPONENT_MOVED ComponentEvent.
	(resize): Erase old bounds and repaint new bounds. Dispatch
	COMPONENT_RESIZED ComponentEvent.
	(reshape): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
	ComponentEvents.
	* java/awt/Window.java
	(setBoundsCallback): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
	ComponentEvents.

2004-02-16  Olga Rodimina  <rodimina@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
	(setRenderingHint): Added implementation of
	Interpolation rendering hints.
	(setRenderingHints): Ditto.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
	(drawPixels): fixed to allow user to choose type
	of filtering that should be used when displaying images.
	(cairoSurfaceSetFilter): New method. Sets filter type for
	interpolation of pixel values.

2004-02-16  David Jee  <djee@redhat.com>

	* java/awt/GridBagLayout.java
	(calcCellSizes): Rows or columns with zero sizes should still be
	considered for extra space distribution.

2004-02-16  Kim Ho  <kho@redhat.com>

	* javax/swing/JLabel.java: Re-implement.
	* javax/swing/plaf/basic/BasicLabelUI.java
	Re-implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Added constant.

2004-02-16�� Kim Ho�� <kho@redhat.com>

	* javax/swing/JSlider.java: Fix indentation and comments.
	(setModel): Remove null check to conform with Sun's.
	(setOrientation): Throw exception if not
	HORIZONTAL or VERTICAL.
	(getInverted): Use private variable instead of
	ComponentOrientation.
	(setInverted): ditto.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	Fix indentation and comments.
	(propertyChange): Remove check for inverted slider, handle
	in main paint.
	(getMinimumSize): Return preferred size.
	(getMaximumSize): ditto.
	(calculateFocusRect): Don't relocate rectangle.
	(drawInverted): Return XOR of the slider's inversion and
	the component's orientation.
	(paint): Update leftToRightCache

2004-02-13  David Jee  <djee@redhat.com>

	* java/awt/GridBagLayout.java
	(GetLayoutInfo): Fix weight and size distribution. Relocate repeated
	code to helper methods.
	(sortBySpan): New helper method.
	(distributeSizeAndWeight): Likewise.
	(calcCellWeights): Likewise.
	(calcCellSizes): Add comments.

2004-02-13  David Jee  <djee@redhat.com>

	* java/awt/Component.java
        (show): Only do something if component is invisible at the moment.
        (hide): Only do something if component is visible at the moment.
        (reshape): If lightweight, erase old bounds and repaint new bounds.

2004-02-13�� Kim Ho�� <kho@redhat.com>

	* Makefile.am: Updated for new file.
	* Makefile.in: Regenerated.
	* javax/swing/JSlider.java: Reimplement.
	* javax/swing/SwingUtilities.java
	(layoutCompoundLabel): Use icon height
	instead of width.
	(paintComponent): Implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Add JSlider defaults.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	Implement. New file.

From-SVN: r79607
parent ab3533d6
......@@ -227,6 +227,7 @@ gnu/java/awt/peer/gtk/GdkFontMetrics.java \
gnu/java/awt/peer/gtk/GdkGlyphVector.java \
gnu/java/awt/peer/gtk/GdkGraphics.java \
gnu/java/awt/peer/gtk/GdkGraphics2D.java \
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
gnu/java/awt/peer/gtk/GtkArg.java \
gnu/java/awt/peer/gtk/GtkArgList.java \
......@@ -1103,6 +1104,7 @@ java/awt/geom/CubicCurve2D.java \
java/awt/geom/FlatteningPathIterator.java \
java/awt/geom/GeneralPath.java \
java/awt/geom/QuadCurve2D.java \
java/awt/image/AffineTransformOp.java \
java/awt/image/BufferedImage.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
......@@ -1330,9 +1332,13 @@ javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \
javax/swing/plaf/basic/BasicScrollBarUI.java \
javax/swing/plaf/basic/BasicScrollPaneUI.java \
javax/swing/plaf/basic/BasicSeparatorUI.java \
javax/swing/plaf/basic/BasicSliderUI.java \
javax/swing/plaf/basic/BasicSplitPaneDivider.java \
javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
......
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -319,6 +319,7 @@ gnu/java/awt/peer/gtk/GdkFontMetrics.java \
gnu/java/awt/peer/gtk/GdkGlyphVector.java \
gnu/java/awt/peer/gtk/GdkGraphics.java \
gnu/java/awt/peer/gtk/GdkGraphics2D.java \
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
gnu/java/awt/peer/gtk/GtkArg.java \
gnu/java/awt/peer/gtk/GtkArgList.java \
......@@ -785,6 +786,7 @@ java/awt/geom/CubicCurve2D.java \
java/awt/geom/FlatteningPathIterator.java \
java/awt/geom/GeneralPath.java \
java/awt/geom/QuadCurve2D.java \
java/awt/image/AffineTransformOp.java \
java/awt/image/BufferedImage.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
......@@ -1012,9 +1014,13 @@ javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \
javax/swing/plaf/basic/BasicScrollBarUI.java \
javax/swing/plaf/basic/BasicScrollPaneUI.java \
javax/swing/plaf/basic/BasicSeparatorUI.java \
javax/swing/plaf/basic/BasicSliderUI.java \
javax/swing/plaf/basic/BasicSplitPaneDivider.java \
javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
......@@ -2779,6 +2785,7 @@ lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES =
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGlyphVector.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics2D.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkPixbufDecoder.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArg.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArgList.lo \
......@@ -2856,6 +2863,7 @@ lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES =
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkGlyphVector.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkGraphics.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkGraphics2D.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkPixbufDecoder.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GtkArg.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GtkArgList.lo \
......@@ -3073,6 +3081,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/awt/peer/gtk/GdkGlyphVector.P \
.deps/gnu/java/awt/peer/gtk/GdkGraphics.P \
.deps/gnu/java/awt/peer/gtk/GdkGraphics2D.P \
.deps/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.P \
.deps/gnu/java/awt/peer/gtk/GdkPixbufDecoder.P \
.deps/gnu/java/awt/peer/gtk/GtkArg.P \
.deps/gnu/java/awt/peer/gtk/GtkArgList.P \
......@@ -3562,6 +3571,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/im/spi/InputMethod.P \
.deps/java/awt/im/spi/InputMethodContext.P \
.deps/java/awt/im/spi/InputMethodDescriptor.P \
.deps/java/awt/image/AffineTransformOp.P \
.deps/java/awt/image/AreaAveragingScaleFilter.P \
.deps/java/awt/image/BufferStrategy.P \
.deps/java/awt/image/BufferedImage.P \
......@@ -4528,9 +4538,13 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicLookAndFeel.P \
.deps/javax/swing/plaf/basic/BasicOptionPaneUI.P \
.deps/javax/swing/plaf/basic/BasicPanelUI.P \
.deps/javax/swing/plaf/basic/BasicProgressBarUI.P \
.deps/javax/swing/plaf/basic/BasicRadioButtonUI.P \
.deps/javax/swing/plaf/basic/BasicRootPaneUI.P \
.deps/javax/swing/plaf/basic/BasicScrollBarUI.P \
.deps/javax/swing/plaf/basic/BasicScrollPaneUI.P \
.deps/javax/swing/plaf/basic/BasicSeparatorUI.P \
.deps/javax/swing/plaf/basic/BasicSliderUI.P \
.deps/javax/swing/plaf/basic/BasicSplitPaneDivider.P \
.deps/javax/swing/plaf/basic/BasicSplitPaneUI.P \
.deps/javax/swing/plaf/basic/BasicTabbedPaneUI.P \
......@@ -4963,7 +4977,7 @@ maintainer-clean-recursive:
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
......@@ -5005,7 +5019,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
......
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -260,7 +260,7 @@ TAGS: $(HEADERS) $(SOURCES) libgcj-config.h.in $(TAGS_DEPENDENCIES) $(LISP)
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)libgcj-config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags libgcj-config.h.in $$unique $(LISP) -o $$here/TAGS)
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags libgcj-config.h.in $$unique $(LISP))
mostlyclean-tags:
......
......@@ -91,7 +91,7 @@ public class GdkGraphics extends Graphics
this.component = component;
int rgb[] = initState (component);
color = new Color (rgb[0], rgb[1], rgb[2]);
font = new Font ("Dialog", Font.PLAIN, 10);
font = component.awtComponent.getFont();
Dimension d = component.awtComponent.getSize ();
clip = new Rectangle (0, 0, d.width, d.height);
}
......@@ -212,10 +212,10 @@ public class GdkGraphics extends Graphics
native public void drawRect(int x, int y, int width, int height);
native public void fillRect (int x, int y, int width, int height);
native void drawString (String str, int x, int y, String fname, int size);
native void drawString (String str, int x, int y, String fname, int style, int size);
public void drawString (String str, int x, int y)
{
drawString (str, x, y, font.getName(), font.getSize());
drawString (str, x, y, font.getName(), font.getStyle(), font.getSize());
}
public void drawString (AttributedCharacterIterator ci, int x, int y)
......@@ -287,7 +287,10 @@ public class GdkGraphics extends Graphics
public void setColor (Color c)
{
color = c;
if (c == null)
color = new Color (0, 0, 0);
else
color = c;
if (xorColor == null) /* paint mode */
setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
......
/* GdkGraphicsEnvironment.java -- information about the graphics environment
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.*;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import java.util.Locale;
public class GdkGraphicsEnvironment extends GraphicsEnvironment
{
public GdkGraphicsEnvironment ()
{
super();
}
public GraphicsDevice[] getScreenDevices ()
{
throw new java.lang.UnsupportedOperationException ();
}
public GraphicsDevice getDefaultScreenDevice ()
{
throw new java.lang.UnsupportedOperationException ();
}
public Graphics2D createGraphics (BufferedImage image)
{
return new GdkGraphics2D (image);
}
public Font[] getAllFonts ()
{
throw new java.lang.UnsupportedOperationException ();
}
public String[] getAvailableFontFamilyNames ()
{
throw new java.lang.UnsupportedOperationException ();
}
public String[] getAvailableFontFamilyNames (Locale l)
{
throw new java.lang.UnsupportedOperationException ();
}
} // class GdkGraphicsEnvironment
......@@ -42,6 +42,7 @@ import java.awt.AWTEvent;
import java.awt.Button;
import java.awt.Component;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.peer.ButtonPeer;
......@@ -69,11 +70,15 @@ public class GtkButtonPeer extends GtkComponentPeer
public void handleEvent (AWTEvent e)
{
if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ())
if (e.getID () == MouseEvent.MOUSE_RELEASED && isEnabled ())
{
MouseEvent me = (MouseEvent) e;
Point p = me.getPoint();
p.translate(((Component) me.getSource()).getX(),
((Component) me.getSource()).getY());
if (!me.isConsumed ()
&& (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0)
&& (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0
&& awtComponent.getBounds().contains(p))
postActionEvent (((Button)awtComponent).getActionCommand (),
me.getModifiers ());
}
......
......@@ -41,6 +41,7 @@ package gnu.java.awt.peer.gtk;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Component;
import java.awt.Font;
import java.awt.peer.CheckboxPeer;
public class GtkCheckboxPeer extends GtkComponentPeer
......@@ -55,6 +56,8 @@ public class GtkCheckboxPeer extends GtkComponentPeer
boolean state);
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
public native void connectSignals ();
public native void gtkSetFont (String name, int style, int size);
public native void gtkSetLabel (String label);
public GtkCheckboxPeer (Checkbox c)
{
......@@ -81,7 +84,12 @@ public class GtkCheckboxPeer extends GtkComponentPeer
public void setLabel (String label)
{
set ("label", label);
gtkSetLabel (label);
}
public void setFont (Font f)
{
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
public void setCheckboxGroup (CheckboxGroup group)
......
......@@ -91,6 +91,7 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetSetCursor (int type);
native void gtkWidgetSetBackground (int red, int green, int blue);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkSetFont (String name, int style, int size);
native void gtkWidgetQueueDrawArea(int x, int y, int width, int height);
native void addExposeFilter();
native void removeExposeFilter();
......@@ -234,7 +235,7 @@ public class GtkComponentPeer extends GtkGenericPeer
// Some peers like GtkFileDialogPeer are repainted by Gtk itself
if (g == null)
break;
g.setClip (((PaintEvent)event).getUpdateRect());
if (id == PaintEvent.PAINT)
......@@ -403,6 +404,7 @@ public class GtkComponentPeer extends GtkGenericPeer
// FIXME: This should really affect the widget tree below me.
// Currently this is only handled if the call is made directly on
// a text widget, which implements setFont() itself.
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
public void setForeground (Color c)
......
......@@ -42,6 +42,7 @@ import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.PaintEvent;
......@@ -92,6 +93,18 @@ public class GtkContainerPeer extends GtkComponentPeer
awtComponent.validate ();
}
public void setFont(Font f)
{
super.setFont(f);
Component[] components = ((Container) awtComponent).getComponents();
for (int i = 0; i < components.length; i++)
{
GtkComponentPeer peer = (GtkComponentPeer) components[i].getPeer();
if (peer != null && ! peer.awtComponent.isFontSet())
peer.setFont(f);
}
}
public Graphics getGraphics ()
{
if (GtkToolkit.useGraphics2D ())
......
......@@ -62,11 +62,17 @@ public class GtkFontPeer extends ClasspathFontPeer
}
}
final private String Xname; // uses %d for font size.
final private String Xname;
public GtkFontPeer (String name, int style)
{
super(name, style, 12 /* kludge */);
// All fonts get a default size of 12 if size is not specified.
this(name, style, 12);
}
public GtkFontPeer (String name, int style, int size)
{
super(name, style, size);
if (bundle != null)
Xname = bundle.getString (name.toLowerCase () + "." + style);
......@@ -90,7 +96,7 @@ public class GtkFontPeer extends ClasspathFontPeer
else
spacing = "c";
Xname = "-*-*-" + weight + "-" + slant + "-normal-*-%d-*-*-*-" + spacing + "-*-*-*";
Xname = "-*-*-" + weight + "-" + slant + "-normal-*-*-" + size + "-*-*-" + spacing + "-*-*-*";
}
}
......
......@@ -39,28 +39,35 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Component;
import java.awt.Font;
import java.awt.Label;
import java.awt.peer.LabelPeer;
public class GtkLabelPeer extends GtkComponentPeer
implements LabelPeer
{
native void create (String text, float alignment);
native void gtkSetFont(String name, int style, int size);
native void nativeSetAlignment (float alignment);
native public void setText (String text);
void create ()
{
Label label = (Label) awtComponent;
create (label.getText (), getGtkAlignment (label.getAlignment ()));
}
native void create (String text, float alignment);
public GtkLabelPeer (Label l)
{
super (l);
}
native public void setText (String text);
public void setFont (Font f)
{
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
native void nativeSetAlignment (float alignment);
public void setAlignment (int alignment)
{
nativeSetAlignment (getGtkAlignment (alignment));
......
......@@ -47,6 +47,7 @@ import java.awt.im.InputMethodHighlight;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.GraphicsEnvironment;
import java.awt.peer.*;
import java.net.URL;
import java.util.Hashtable;
......@@ -366,10 +367,18 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
* @deprecated part of the older "logical font" system in earlier AWT
* implementations. Our newer Font class uses getClasspathFontPeer.
*/
protected FontPeer getFontPeer (String name, int style)
protected FontPeer getFontPeer (String name, int style) {
// All fonts get a default size of 12 if size is not specified.
return getFontPeer(name, style, 12);
}
/**
* Private method that allows size to be set at initialization time.
*/
private FontPeer getFontPeer (String name, int style, int size)
{
try {
GtkFontPeer fp = new GtkFontPeer (name, style);
GtkFontPeer fp = new GtkFontPeer (name, style, size);
return fp;
} catch (MissingResourceException ex) {
return null;
......@@ -388,7 +397,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return new GdkClasspathFontPeer (name, attrs);
else
{
// Default values
int size = 12;
int style = Font.PLAIN;
if (name == null)
name = "Default";
if (attrs.containsKey (TextAttribute.WEIGHT))
{
......@@ -404,7 +417,13 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
style += Font.ITALIC;
}
return (ClasspathFontPeer) this.getFontPeer (name, style);
if (attrs.containsKey (TextAttribute.SIZE))
{
Float fsize = (Float) attrs.get (TextAttribute.SIZE);
size = fsize.intValue();
}
return (ClasspathFontPeer) this.getFontPeer (name, style, size);
}
}
......@@ -431,7 +450,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public GraphicsEnvironment getLocalGraphicsEnvironment()
{
throw new java.lang.UnsupportedOperationException ();
GraphicsEnvironment ge;
ge = new GdkGraphicsEnvironment ();
return ge;
}
public Font createFont(int format, java.io.InputStream stream)
......
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -241,7 +241,7 @@ TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP))
mostlyclean-tags:
......
......@@ -592,12 +592,13 @@ layoutContainer(Container target)
int x1 = i.left;
int x2 = x1 + w.width + hgap;
int x3 = t.width - i.right - e.width;
int x3 = Math.max(x2 + w.width + hgap, t.width - i.right - e.width);
int ww = t.width - i.right - i.left;
int y1 = i.top;
int y2 = y1 + n.height + vgap;
int y3 = t.height - i.bottom - s.height;
int midh = Math.max(e.height, Math.max(w.height, c.height));
int y3 = Math.max(y2 + midh + vgap, t.height - i.bottom - s.height);
int hh = y3-y2-vgap;
setBounds(center, x2, y2, x3-x2-hgap, hh);
......
......@@ -103,6 +103,11 @@ public class CardLayout implements LayoutManager2, Serializable
public void addLayoutComponent (String name, Component comp)
{
tab.put (name, comp);
// First component added is the default component.
if (tab.size() == 1)
comp.setVisible(true);
else
comp.setVisible(false);
}
/** Cause the first component in the container to be displayed.
......@@ -243,6 +248,8 @@ public class CardLayout implements LayoutManager2, Serializable
if (tab.get (key) == comp)
{
tab.remove (key);
Container parent = comp.getParent();
next(parent);
break;
}
}
......@@ -311,6 +318,13 @@ public class CardLayout implements LayoutManager2, Serializable
int num = parent.ncomponents;
// This is more efficient than calling getComponents().
Component[] comps = parent.component;
if (num == 1)
{
comps[0].setVisible(true);
return;
}
int choice = -1;
if (what == FIRST)
......
......@@ -876,10 +876,16 @@ public abstract class Component
// case lightweight components are not initially painted --
// Container.paint first calls isShowing () before painting itself
// and its children.
this.visible = true;
if (peer != null)
peer.setVisible(true);
invalidate();
if(!isVisible())
{
this.visible = true;
if (peer != null)
peer.setVisible(true);
invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
......@@ -903,10 +909,16 @@ public abstract class Component
*/
public void hide()
{
if (peer != null)
peer.setVisible(false);
this.visible = false;
invalidate();
if (isVisible())
{
if (peer != null)
peer.setVisible(false);
this.visible = false;
invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
......@@ -974,8 +986,11 @@ public abstract class Component
*/
public void setBackground(Color c)
{
// If c is null, inherit from closest ancestor whose bg is set.
if (c == null && parent != null)
c = parent.getBackground();
firePropertyChange("background", background, c);
if (peer != null)
if (peer != null && c != null)
peer.setBackground(c);
background = c;
}
......@@ -1022,6 +1037,7 @@ public abstract class Component
firePropertyChange("font", font, f);
if (peer != null)
peer.setFont(f);
invalidate();
font = f;
}
......@@ -1150,6 +1166,9 @@ public abstract class Component
*/
public void move(int x, int y)
{
int oldx = this.x;
int oldy = this.y;
if (this.x == x && this.y == y)
return;
invalidate ();
......@@ -1157,6 +1176,20 @@ public abstract class Component
this.y = y;
if (peer != null)
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight() && width != 0 && height !=0)
{
parent.repaint(oldx, oldy, width, height);
repaint();
}
if (oldx != x || oldy != y)
{
ComponentEvent ce = new ComponentEvent(this,
ComponentEvent.COMPONENT_MOVED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
......@@ -1220,6 +1253,9 @@ public abstract class Component
*/
public void resize(int width, int height)
{
int oldwidth = this.width;
int oldheight = this.height;
if (this.width == width && this.height == height)
return;
invalidate ();
......@@ -1227,6 +1263,22 @@ public abstract class Component
this.height = height;
if (peer != null)
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight())
{
if (oldwidth != 0 && oldheight != 0 && parent != null)
parent.repaint(x, y, oldwidth, oldheight);
if (width != 0 && height != 0)
repaint();
}
if (oldwidth != width || oldheight != height)
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
......@@ -1315,6 +1367,11 @@ public abstract class Component
*/
public void reshape(int x, int y, int width, int height)
{
int oldx = this.x;
int oldy = this.y;
int oldwidth = this.width;
int oldheight = this.height;
if (this.x == x && this.y == y
&& this.width == width && this.height == height)
return;
......@@ -1325,6 +1382,28 @@ public abstract class Component
this.height = height;
if (peer != null)
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight())
{
if (oldwidth != 0 && oldheight != 0 && parent != null)
parent.repaint(oldx, oldy, oldwidth, oldheight);
if (width != 0 && height != 0)
repaint();
}
if (oldx != x || oldy != y)
{
ComponentEvent ce = new ComponentEvent(this,
ComponentEvent.COMPONENT_MOVED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
if (oldwidth != width || oldheight != height)
{
ComponentEvent ce = new ComponentEvent(this,
ComponentEvent.COMPONENT_RESIZED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
......@@ -4172,6 +4251,8 @@ p * <li>the set of backward traversal keys
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
return (mouseListener != null
|| mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
......
......@@ -502,6 +502,20 @@ public class Container extends Component
}
/**
* Recursively invalidates the container tree.
*/
private void invalidateTree()
{
for (int i = 0; i < ncomponents; i++)
{
Component comp = component[i];
comp.invalidate();
if (comp instanceof Container)
((Container) comp).invalidateTree();
}
}
/**
* Recursively validates the container tree, recomputing any invalid
* layouts.
*/
......@@ -546,7 +560,10 @@ public class Container extends Component
public void setFont(Font f)
{
super.setFont(f);
// FIXME, should invalidate all children with font == null
// FIXME: Although it might make more sense to invalidate only
// those children whose font == null, Sun invalidates all children.
// So we'll do the same.
invalidateTree();
}
/**
......@@ -1234,6 +1251,7 @@ public class Container extends Component
Rectangle oldClip = gfx.getClipBounds();
if (oldClip == null)
oldClip = bounds;
Rectangle clip = oldClip.intersection(bounds);
if (clip.isEmpty()) return;
......@@ -1337,10 +1355,10 @@ public class Container extends Component
// If we're not lightweight, and we just got a lightweight
// child, we need a lightweight dispatcher to feed it events.
if (! this.isLightweight()
&& dispatcher == null)
if (! this.isLightweight())
{
dispatcher = new LightweightDispatcher (this);
if (dispatcher == null)
dispatcher = new LightweightDispatcher (this);
dispatcher.enableEvents (component[i].eventMask);
}
......@@ -1536,6 +1554,9 @@ class LightweightDispatcher implements Serializable
private long eventMask;
private transient Component mouseEventTarget;
private transient Component pressedComponent;
private transient Component lastComponentEntered;
private transient int pressCount;
LightweightDispatcher(Container c)
{
......@@ -1551,46 +1572,37 @@ class LightweightDispatcher implements Serializable
{
int x = me.getX ();
int y = me.getY ();
Component candidate = mouseEventTarget;
while(candidate != null)
{
if (candidate.isShowing())
{
// Convert our point to the candidate's parent's space.
Point cp = SwingUtilities.convertPoint(nativeContainer, x, y, candidate);
// If the event lands inside candidate, we have a hit.
if (candidate.contains(cp.x, cp.y))
{
// If candidate has children, we refine the hit.
if (candidate instanceof Container &&
((Container)candidate).getComponentCount() > 0)
candidate = SwingUtilities.getDeepestComponentAt(candidate, cp.x, cp.y);
break;
}
}
// If candidate isn't showing or doesn't contain point, we back out a level.
candidate = candidate.getParent();
}
if (candidate == null)
// Find the candidate which should receive this event.
Component parent = nativeContainer;
Component candidate = null;
Point p = me.getPoint();
while (candidate == null && parent != null)
{
// We either lost, or never had, a candidate; acquire from our native.
candidate =
SwingUtilities.getDeepestComponentAt(nativeContainer, x, y);
candidate =
SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
if (candidate == null)
{
p = SwingUtilities.convertPoint(parent, p.x, p.y, parent.parent);
parent = parent.parent;
}
}
// If the only candidate we found was the native container itself,
// don't dispatch any event at all. We only care about the lightweight
// children here.
if (candidate == nativeContainer)
candidate = null;
// If our candidate is new, inform the old target we're leaving.
if (mouseEventTarget != null
&& mouseEventTarget.isShowing()
&& mouseEventTarget != candidate)
if (lastComponentEntered != null
&& lastComponentEntered.isShowing()
&& lastComponentEntered != candidate)
{
Point tp =
SwingUtilities.convertPoint(nativeContainer,
x, y, mouseEventTarget);
MouseEvent exited = new MouseEvent (mouseEventTarget,
x, y, lastComponentEntered);
MouseEvent exited = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen (),
me.getModifiers (),
......@@ -1598,22 +1610,23 @@ class LightweightDispatcher implements Serializable
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
mouseEventTarget.dispatchEvent (exited);
mouseEventTarget = null;
lastComponentEntered.dispatchEvent (exited);
lastComponentEntered = null;
}
// If we have a candidate, maybe enter it.
if (candidate != null)
{
mouseEventTarget = candidate;
if (candidate.isLightweight()
&& candidate.isShowing()
&& candidate != nativeContainer
&& candidate != mouseEventTarget)
&& candidate != lastComponentEntered)
{
mouseEventTarget = candidate;
lastComponentEntered = mouseEventTarget;
Point cp = SwingUtilities.convertPoint(nativeContainer,
x, y, candidate);
MouseEvent entered = new MouseEvent (mouseEventTarget,
x, y, lastComponentEntered);
MouseEvent entered = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen (),
me.getModifiers (),
......@@ -1621,9 +1634,29 @@ class LightweightDispatcher implements Serializable
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
mouseEventTarget.dispatchEvent (entered);
lastComponentEntered.dispatchEvent (entered);
}
}
if (me.getID() == MouseEvent.MOUSE_RELEASED
|| me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
// If any of the following events occur while a button is held down,
// they should be dispatched to the same component to which the
// original MOUSE_PRESSED event was dispatched:
// - MOUSE_RELEASED
// - MOUSE_PRESSED: another button pressed while the first is held down
// - MOUSE_DRAGGED
mouseEventTarget = pressedComponent;
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
{
// Don't dispatch CLICKED events whose target is not the same as the
// target for the original PRESSED event.
if (candidate != pressedComponent)
mouseEventTarget = null;
else if (pressCount == 0)
pressedComponent = null;
}
}
boolean handleEvent(AWTEvent e)
......@@ -1634,17 +1667,36 @@ class LightweightDispatcher implements Serializable
if (e instanceof MouseEvent)
{
MouseEvent me = (MouseEvent) e;
acquireComponentForMouseEvent(me);
// Avoid dispatching an ENTERED event twice.
acquireComponentForMouseEvent(me);
// Avoid dispatching ENTERED and EXITED events twice.
if (mouseEventTarget != null
&& mouseEventTarget.isShowing()
&& e.getID() != MouseEvent.MOUSE_ENTERED)
&& e.getID() != MouseEvent.MOUSE_ENTERED
&& e.getID() != MouseEvent.MOUSE_EXITED)
{
MouseEvent newEvt =
SwingUtilities.convertMouseEvent(nativeContainer, me,
mouseEventTarget);
mouseEventTarget.dispatchEvent(newEvt);
switch (e.getID())
{
case MouseEvent.MOUSE_PRESSED:
if (pressCount++ == 0)
pressedComponent = mouseEventTarget;
break;
case MouseEvent.MOUSE_RELEASED:
// Clear our memory of the original PRESSED event, only if
// we're not expecting a CLICKED event after this. If
// there is a CLICKED event after this, it will do clean up.
if (--pressCount == 0
&& mouseEventTarget != pressedComponent)
pressedComponent = null;
break;
}
}
}
else if (e instanceof KeyEvent && focus != null)
......
......@@ -330,16 +330,20 @@ private static final long serialVersionUID = -4206021311591459213L;
}
public Font (Map attrs)
{
this.peer = getPeerFromToolkit (null, attrs);
}
{
this(null, attrs);
}
/* This extra constructor is here to permit ClasspathToolkit and to build
a font with a "logical name" as well as attrs. */
public Font (String name, Map attrs)
{
{
// If attrs is null, setting it to an empty HashMap will give this
// Font default attributes.
if (attrs == null)
attrs = new HashMap();
this.peer = getPeerFromToolkit (name, attrs);
}
}
/*************************************************************************/
......
......@@ -40,6 +40,7 @@ package java.awt;
import java.awt.image.BufferedImage;
import java.util.Locale;
import gnu.java.awt.ClasspathToolkit;
/**
* This descibes the collection of GraphicsDevice and Font objects available
......@@ -70,7 +71,9 @@ public abstract class GraphicsEnvironment
*/
public static GraphicsEnvironment getLocalGraphicsEnvironment()
{
throw new Error("not implemented");
ClasspathToolkit tk;
tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit ());
return tk.getLocalGraphicsEnvironment ();
}
/**
......
......@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
......@@ -784,9 +785,23 @@ public class Window extends Container implements Accessible
if (this.x == x && this.y == y && width == w && height == h)
return;
invalidate();
boolean resized = width != w || height != h;
boolean moved = this.x != x || this.y != y;
this.x = x;
this.y = y;
width = w;
height = h;
if (resized)
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
if (moved)
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
}
/* AffineTransformOp.java -- This class performs affine
* transformation between two images or rasters in 2
* dimensions. Copyright (C) 2004 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.awt.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.*;
/**
* This class performs affine transformation between two images or
* rasters in 2 dimensions.
*
* @author Olga Rodimina <rodimina@redhat.com>
*/
public class AffineTransformOp implements BufferedImageOp, RasterOp
{
public static final int TYPE_BILINEAR = 0;
public static final int TYPE_NEAREST_NEIGHBOR = 1;
private AffineTransform transform;
private RenderingHints hints;
/**
* Construct AffineTransformOp with the given xform and interpolationType.
* Interpolation type can be either TYPE_BILINEAR or TYPE_NEAREST_NEIGHBOR.
*
* @param xform AffineTransform that will applied to the source image
* @param interpolationType type of interpolation used
*/
AffineTransformOp (AffineTransform xform, int interpolationType)
{
this.transform = xform;
if (interpolationType == 0)
hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
else
hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
}
/**
* Construct AffineTransformOp with the given xform and rendering hints.
*
* @param xform AffineTransform that will applied to the source image
* @param hints rendering hints that will be used during transformation
*/
AffineTransformOp (AffineTransform xform, RenderingHints hints)
{
this.transform = xform;
this.hints = hints;
}
/**
* Creates empty BufferedImage with the size equal to that of the
* transformed image and correct number of bands. The newly created
* image is created with the specified ColorModel.
* If the ColorModel is equal to null, then image is created
* with the ColorModel of the source image.
*
* @param src source image
* @param destCM color model for the destination image
* @return new compatible destination image
*/
public BufferedImage createCompatibleDestImage (BufferedImage src,
ColorModel destCM)
{
// if destCm is not specified, use color model of the source image
if (destCM == null)
destCM = src.getColorModel ();
return new BufferedImage (destCM,
createCompatibleDestRaster (src.getRaster ()),
src.isAlphaPremultiplied (),
null);
}
/**
* Creates empty WritableRaster with the size equal to the transformed
* source raster and correct number of bands
*
* @param src source raster
* @throws RasterFormatException if resulting width or height of raster is 0
* @return new compatible raster
*/
public WritableRaster createCompatibleDestRaster (Raster src)
{
Rectangle rect = (Rectangle) getBounds2D (src);
// throw RasterFormatException if resulting width or height of the
// transformed raster is 0
if (rect.getWidth () == 0 || rect.getHeight () == 0)
throw new RasterFormatException("width or height is 0");
return src.createCompatibleWritableRaster ((int) rect.getWidth (),
(int) rect.getHeight ());
}
/**
* Transforms source image using transform specified at the constructor.
* The resulting transformed image is stored in the destination image.
*
* @param src source image
* @param dst destination image
* @return transformed source image
*/
public BufferedImage filter (BufferedImage src, BufferedImage dst)
{
if (dst == src)
throw new IllegalArgumentException ("src image cannot be the same as the dst image");
// If the destination image is null, then BufferedImage is
// created with ColorModel of the source image
if (dst == null)
dst = createCompatibleDestImage(src, src.getColorModel ());
// FIXME: Must check if color models of src and dst images are the same.
// If it is not, then source image should be converted to color model
// of the destination image
Graphics2D gr = (Graphics2D) dst.createGraphics ();
gr.setRenderingHints (hints);
gr.drawImage (src, transform, null);
return dst;
}
/**
* Transforms source raster using transform specified at the constructor.
* The resulting raster is stored in the destination raster.
*
* @param src source raster
* @param dst destination raster
* @return transformed raster
*/
public WritableRaster filter (Raster src, WritableRaster dst)
{
throw new UnsupportedOperationException ("not implemented yet");
}
/**
* Transforms source image using transform specified at the constructor and
* returns bounds of the transformed image.
*
* @param src image to be transformed
* @return bounds of the transformed image.
*/
public Rectangle2D getBounds2D (BufferedImage src)
{
return getBounds2D (src.getRaster());
}
/**
* Returns bounds of the transformed raster.
*
* @param src raster to be transformed
* @return bounds of the transformed raster.
*/
public Rectangle2D getBounds2D (Raster src)
{
// determine new size for the transformed raster.
// Need to calculate transformed coordinates of the lower right
// corner of the raster. The upper left corner is always (0,0)
double x2 = (double) src.getWidth () + src.getMinX ();
double y2 = (double) src.getHeight () + src.getMinY ();
Point2D p2 = getPoint2D (new Point2D.Double (x2,y2), null);
Rectangle2D rect = new Rectangle (0, 0, (int) p2.getX (), (int) p2.getY ());
return rect.getBounds ();
}
/**
* Returns interpolation type used during transformations
*
* @return interpolation type
*/
public int getInterpolationType ()
{
if(hints.containsValue (RenderingHints.VALUE_INTERPOLATION_BILINEAR))
return TYPE_BILINEAR;
else
return TYPE_NEAREST_NEIGHBOR;
}
/**
* Returns location of the transformed source point. The resulting point
* is stored in the dstPt if one is specified.
*
* @param srcPt point to be transformed
* @param dstPt destination point
* @return the location of the transformed source point.
*/
public Point2D getPoint2D (Point2D srcPt, Point2D dstPt)
{
return transform.transform (srcPt, dstPt);
}
/** Returns rendering hints that are used during transformation.
*
* @return rendering hints
*/
public RenderingHints getRenderingHints ()
{
return hints;
}
/** Returns transform used in transformation between source and destination
* image.
*
* @return transform
*/
public AffineTransform getTransform ()
{
return transform;
}
}
......@@ -39,6 +39,7 @@ package java.awt.image;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
......@@ -255,7 +256,8 @@ public class BufferedImage extends Image
public WritableRaster copyData(WritableRaster dest)
{
if (dest == null)
dest = raster.createCompatibleWritableRaster();
dest = raster.createCompatibleWritableRaster(getMinX(), getMinY(),
getWidth(),getHeight());
int x = dest.getMinX();
int y = dest.getMinY();
......@@ -282,8 +284,9 @@ public class BufferedImage extends Image
public Graphics2D createGraphics()
{
throw new UnsupportedOperationException("not implemented");
// will require a lot of effort to implement
GraphicsEnvironment env;
env = GraphicsEnvironment.getLocalGraphicsEnvironment ();
return env.createGraphics (this);
}
public void flush() {
......
......@@ -40,57 +40,64 @@ package javax.swing;
import java.io.Serializable;
import java.util.EventListener;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
/**
* AbstractListModel
* A2uthor Ronald Veldema
* @author Andrew Selkirk
* @version 1.0
*
* @author Ronald Veldema
* @author Andrew Selkirk
* @version 1.0
*/
public abstract class AbstractListModel
implements ListModel, Serializable
public abstract class AbstractListModel implements ListModel, Serializable
{
static final long serialVersionUID = -3285184064379168730L;
/**
* listenerList
*/
protected EventListenerList listenerList = new EventListenerList ();
/**
* Constructor AbstractListModel
*/
public AbstractListModel ()
/** List of ListDataListeners called for each change to the list. */
protected EventListenerList listenerList;
public AbstractListModel()
{
listenerList = new EventListenerList();
}
/**
* addListDataListener
* @param listener TODO
* Add a listener object to this model. The listener will be called
* any time the set of elements in the model is changed.
*
* @param listener The listener to add
*/
public void addListDataListener(ListDataListener listener)
public void addListDataListener(ListDataListener listener)
{
listenerList.add (ListDataListener.class, listener);
listenerList.add(ListDataListener.class, listener);
}
/**
* removeListDataListener
* @param listener TODO
* Add a listener object to this model. The listener will no longer be
* called when the set of elements in the model is changed.
*
* @param listener The listener to remove
*/
public void removeListDataListener(ListDataListener listener)
{
listenerList.remove (ListDataListener.class, listener);
listenerList.remove(ListDataListener.class, listener);
}
/**
* fireContentsChanged
* @param source TODO
* @param startIndex TODO
* @param endIndex TODO
* Call {@link ListDataListener#contentsChanged} on each element of the
* {@link listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.CONTENTS_CHANGED} and represents a
* change to the data elements in the range [startIndex, endIndex]
* inclusive.
*
* @param source The source of the change, typically <code>this</code>
* @param startIndex The index of the first element which changed
* @param endIndex The index of the last element which changed
*/
protected void fireContentsChanged(Object source, int startIndex, int endIndex)
protected void fireContentsChanged(Object source, int startIndex,
int endIndex)
{
// Variables
ListDataEvent event;
......@@ -100,10 +107,10 @@ public abstract class AbstractListModel
// Create Event
event = new ListDataEvent(source, ListDataEvent.CONTENTS_CHANGED,
startIndex, endIndex);
startIndex, endIndex);
// Get Listeners
listeners = getListDataListeners ();
listeners = getListDataListeners();
// Process Listeners
for (index = 0; index < listeners.length; index++)
......@@ -114,12 +121,17 @@ public abstract class AbstractListModel
}
/**
* fireIntervalAdded
* @param source TODO
* @param startIndex TODO
* @param endIndex TODO
* Call {@link ListDataListener#intervalAdded} on each element of the
* {@link listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.INTERVAL_ADDED} and represents an
* addition of the data elements in the range [startIndex, endIndex]
* inclusive.
*
* @param source The source of the change, typically <code>this</code>
* @param startIndex The index of the first new element
* @param endIndex The index of the last new element
*/
protected void fireIntervalAdded (Object source, int startIndex, int endIndex)
protected void fireIntervalAdded(Object source, int startIndex, int endIndex)
{
// Variables
ListDataEvent event;
......@@ -128,27 +140,32 @@ public abstract class AbstractListModel
int index;
// Create Event
event = new ListDataEvent (source, ListDataEvent.INTERVAL_ADDED, startIndex,
endIndex);
event = new ListDataEvent(source, ListDataEvent.INTERVAL_ADDED,
startIndex, endIndex);
// Get Listeners
listeners = getListDataListeners ();
listeners = getListDataListeners();
// Process Listeners
for (index = 0; index < listeners.length; index++)
{
listener = listeners [index];
listener.intervalAdded (event);
listener = listeners[index];
listener.intervalAdded(event);
}
}
/**
* fireIntervalRemoved
* @param source TODO
* @param startIndex TODO
* @param endIndex TODO
* Call {@link ListDataListener#intervalRemoved} on each element of the
* {@link listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.INTERVAL_REMOVED} and represents a
* removal of the data elements in the range [startIndex, endIndex]
* inclusive.
*
* @param source The source of the change, typically <code>this</code>
* @param startIndex The index of the first element removed
* @param endIndex The index of the last element removed
*/
protected void fireIntervalRemoved (Object source, int startIndex,
protected void fireIntervalRemoved(Object source, int startIndex,
int endIndex)
{
// Variables
......@@ -158,35 +175,41 @@ public abstract class AbstractListModel
int index;
// Create Event
event = new ListDataEvent (source, ListDataEvent.INTERVAL_REMOVED,
startIndex, endIndex);
event = new ListDataEvent(source, ListDataEvent.INTERVAL_REMOVED,
startIndex, endIndex);
// Get Listeners
listeners = getListDataListeners ();
listeners = getListDataListeners();
// Process Listeners
for (index = 0; index < listeners.length; index++)
{
listener = listeners [index];
listener.intervalRemoved (event);
listener = listeners[index];
listener.intervalRemoved(event);
}
}
/**
* getListeners
* @param listenerType TODO
* @returns EventListener[]
* Return the subset of {@link EventListener} objects found in this
* object's {@link listenerList} which are elements of the specified
* type.
*
* @param listenerType The type of listeners to select
*
* @return The set of listeners of the specified type
*/
public EventListener[] getListeners (Class listenerType)
public EventListener[] getListeners(Class listenerType)
{
return listenerList.getListeners (listenerType);
return listenerList.getListeners(listenerType);
}
/**
* getListDataListeners
* A synonym for <code>getListeners(ListDataListener.class)</code>.
*
* @return The set of ListDataListeners found in the {@link listenerList}
*/
public ListDataListener[] getListDataListeners ()
public ListDataListener[] getListDataListeners()
{
return (ListDataListener[]) getListeners (ListDataListener.class);
return (ListDataListener[]) getListeners(ListDataListener.class);
}
}
......@@ -42,213 +42,75 @@ import java.awt.Rectangle;
import java.io.Serializable;
import javax.swing.border.Border;
/**
* DefaultListCellRenderer
* @author Andrew Selkirk
* @version 1.0
*
* @author Andrew Selkirk
* @version 1.0
*/
public class DefaultListCellRenderer extends JLabel
implements ListCellRenderer, Serializable
public class DefaultListCellRenderer
extends JLabel implements ListCellRenderer, Serializable
{
static final long serialVersionUID = 7708947179685189462L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* UIResource
*/
public static class UIResource extends DefaultListCellRenderer
implements javax.swing.plaf.UIResource {
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor UIResource
*/
public UIResource() {
// TODO
} // UIResource()
} // UIResource
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* noFocusBorder
*/
protected static Border noFocusBorder = null; // TODO
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor DefaultListCellRenderer
*/
public DefaultListCellRenderer() {
// TODO
} // DefaultListCellRenderer()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getListCellRendererComponent
* @param list TODO
* @param value TODO
* @param index TODO
* @param isSelected TODO
* @param cellHasFocus TODO
* @returns Component
*/
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
return null; // TODO
} // getListCellRendererComponent()
/**
* validate
*/
public void validate() {
// TODO
} // validate()
/**
* revalidate
*/
public void revalidate() {
// TODO
} // revalidate()
/**
* repaint
* @param tm TODO
* @param x TODO
* @param y TODO
* @param w TODO
* @param h TODO
*/
public void repaint(long tm, int x, int y, int w, int h) {
// TODO
} // repaint()
/**
* repaint
* @param rect TODO
*/
public void repaint(Rectangle rect) {
// TODO
} // repaint()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
protected void firePropertyChange(String propertyName,
Object oldValue, Object newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
byte oldValue, byte newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
char oldValue, char newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
short oldValue, short newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
int oldValue, int newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
long oldValue, long newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
float oldValue, float newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
double oldValue, double newValue) {
// TODO
} // firePropertyChange()
/**
* firePropertyChange
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
*/
public void firePropertyChange(String propertyName,
boolean oldValue, boolean newValue) {
// TODO
} // firePropertyChange()
} // DefaultListCellRenderer
public static class UIResource extends DefaultListCellRenderer
implements javax.swing.plaf.UIResource
{
public UIResource()
{
}
}
/** noFocusBorder */
protected static Border noFocusBorder = null; // TODO
/**
* getListCellRendererComponent
*
* @param list TODO
* @param value TODO
* @param index TODO
* @param isSelected TODO
* @param cellHasFocus TODO
*
* @return Component
*/
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
boolean cellHasFocus)
{
String s = value.toString();
setText(s);
setOpaque(true);
if (isSelected)
{
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
else
{
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
return this;
}
public void validate() {}
public void revalidate() {}
public void repaint(long tm, int x, int y, int w, int h) {}
public void repaint(Rectangle rect) {}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue){}
public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {}
public void firePropertyChange(String propertyName, char oldValue, char newValue) {}
public void firePropertyChange(String propertyName, short oldValue, short newValue) {}
public void firePropertyChange(String propertyName, int oldValue, int newValue) {}
public void firePropertyChange(String propertyName, long oldValue, long newValue) {}
public void firePropertyChange(String propertyName, float oldValue, float newValue) {}
public void firePropertyChange(String propertyName, double oldValue, double newValue) {}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
}
......@@ -75,6 +75,7 @@ import javax.swing.event.AncestorListener;
import javax.swing.event.EventListenerList;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.event.SwingPropertyChangeSupport;
/**
* Every component in swing inherits from this class (JLabel, JButton, etc).
......@@ -88,21 +89,26 @@ public abstract class JComponent extends Container implements Serializable
{
static final long serialVersionUID = -5242478962609715464L;
protected EventListenerList listenerList = new EventListenerList();
/**
* accessibleContext
*/
protected AccessibleContext accessibleContext;
Dimension pref,min,max;
Border border;
JToolTip tooltip;
String tool_tip_text;
boolean use_double_buffer, opaque;
protected ComponentUI ui;
Hashtable prop_hash;
EventListenerList listenerList = new EventListenerList();
/**
* accessibleContext
*/
AccessibleContext accessibleContext;
Dimension pref,min,max;
Border border;
JToolTip tooltip;
String tool_tip_text;
boolean use_double_buffer, opaque;
Image doubleBuffer;
int doubleBufferWidth = -1;
int doubleBufferHeight = -1;
ComponentUI ui;
private SwingPropertyChangeSupport changeSupport;
Hashtable prop_hash;
/**
* AccessibleJComponent
......@@ -195,7 +201,7 @@ public abstract class JComponent extends Container implements Serializable
* addPropertyChangeListener
* @param listener TODO
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
public void addPropertyChangeListener(PropertyChangeListener listener) {
// TODO
} // addPropertyChangeListener()
......@@ -318,7 +324,8 @@ public abstract class JComponent extends Container implements Serializable
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
{
listenerList.remove(PropertyChangeListener.class, listener);
if (changeSupport != null)
changeSupport.removePropertyChangeListener(listener);
}
/**
......@@ -350,7 +357,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
listenerList.add(PropertyChangeListener.class, listener);
if (changeSupport == null)
changeSupport = new SwingPropertyChangeSupport(this);
changeSupport.addPropertyChangeListener(listener);
}
/**
......@@ -404,45 +413,68 @@ public abstract class JComponent extends Container implements Serializable
//Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors.
//super.computeVisibleRect(rect);
}
public PropertyChangeListener[] getPropertyChangeListeners(String property)
{
return changeSupport == null ? new PropertyChangeListener[0]
: changeSupport.getPropertyChangeListeners(property);
}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
{
//Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Boolean(oldValue),
new Boolean(newValue));
}
public void firePropertyChange(String propertyName, byte oldValue, byte newValue)
{
// Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Byte(oldValue),
new Byte(newValue));
}
public void firePropertyChange(String propertyName, char oldValue, char newValue)
{
//Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Character(oldValue),
new Character(newValue));
}
public void firePropertyChange(String propertyName, double oldValue, double newValue)
{
//Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Double(oldValue),
new Double(newValue));
}
public void firePropertyChange(String propertyName, float oldValue, float newValue)
{
// Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Float(oldValue),
new Float(newValue));
}
public void firePropertyChange(String propertyName, int oldValue, int newValue)
{
// Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Integer(oldValue),
new Integer(newValue));
}
public void firePropertyChange(String propertyName, long oldValue, long newValue)
{
//Reports a bound property change. protected
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Long(oldValue),
new Long(newValue));
}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
{
// Support for reporting bound property changes.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
public void firePropertyChange(String propertyName, short oldValue, short newValue)
{
// Reports a bound property change.
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Short(oldValue),
new Short(newValue));
}
protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
......@@ -757,14 +789,21 @@ public abstract class JComponent extends Container implements Serializable
public void paint(Graphics g)
{
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 ();
if (doubleBuffer == null
|| doubleBufferWidth != r.width
|| doubleBufferHeight != r.height)
{
doubleBuffer = createImage(r.width, r.height);
doubleBufferWidth = r.width;
doubleBufferHeight = r.height;
}
g2 = doubleBuffer.getGraphics ();
if (this.getBackground() != null)
{
Color save = g2.getColor();
......@@ -785,7 +824,7 @@ public abstract class JComponent extends Container implements Serializable
// 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);
g.drawImage (doubleBuffer, 0, 0, (ImageObserver)null);
}
}
......
......@@ -44,183 +44,163 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.plaf.SeparatorUI;
/**
* JSeparator
* @author Andrew Selkirk
* @version 1.0
* The JSeparator. It is mostly used to divide/space out
* components.
*/
public class JSeparator extends JComponent
implements SwingConstants, Accessible
public class JSeparator extends JComponent implements SwingConstants,
Accessible
{
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleJSeparator
*/
protected class AccessibleJSeparator extends AccessibleJComponent {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJSeparator
* @param component TODO
*/
protected AccessibleJSeparator(JSeparator component) {
super(component);
// TODO
} // AccessibleJSeparator()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.SEPARATOR;
} // getAccessibleRole()
} // AccessibleJSeparator
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* uiClassID
*/
private static final String uiClassID = "SeparatorUI";
/**
* orientation
*/
private int orientation;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor JSeparator
*/
public JSeparator() {
this(HORIZONTAL);
} // JSeparator()
/**
* Constructor JSeparator
* @param value0 TODO
*/
public JSeparator(int orientation) {
this.orientation = orientation;
// TODO
} // JSeparator()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
// TODO
} // writeObject()
/**
* getUI
* @returns SeparatorUI
*/
public SeparatorUI getUI() {
return (SeparatorUI) ui;
} // getUI()
/**
* setUI
* @param ui TODO
*/
public void setUI(SeparatorUI ui) {
super.setUI(ui);
} // setUI()
/**
* updateUI
*/
public void updateUI() {
setUI((SeparatorUI) UIManager.get(this));
invalidate();
} // updateUI()
/**
* getUIClassID
* @returns String
*/
public String getUIClassID() {
return uiClassID;
} // getUIClassID()
/**
* getOrientation
* @returns int
*/
public int getOrientation() {
return orientation;
} // getOrientation()
/**
* setOrientation
* @param orientation TODO
*/
public void setOrientation(int orientation) {
this.orientation = orientation;
// TODO
} // setOrientation()
/**
* paramString
* @returns String
*/
protected String paramString() {
return null; // TODO
} // paramString()
/**
* isFocusTraversable
* @returns boolean
*/
public boolean isFocusTraversable() {
return false;
} // isFocusTraversable()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJSeparator(this);
} // if
return accessibleContext;
} // getAccessibleContext()
} // JSeparator
/**
* AccessibleJSeparator
*/
protected class AccessibleJSeparator extends AccessibleJComponent
{
/**
* Constructor AccessibleJSeparator
*
* @param component TODO
*/
protected AccessibleJSeparator(JSeparator component)
{
super(component);
}
/**
* getAccessibleRole
*
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.SEPARATOR;
}
}
/** The orientation of the JSeparator. */
private transient int orientation = HORIZONTAL;
/**
* Creates a new horizontal JSeparator object.
*/
public JSeparator()
{
this(HORIZONTAL);
}
/**
* Creates a new JSeparator object with the given orientation.
*
* @param orientation The orientation of the JSeparator.
*/
public JSeparator(int orientation)
{
if (orientation != HORIZONTAL && orientation != VERTICAL)
throw new IllegalArgumentException(orientation
+ " is not a valid orientation.");
this.orientation = orientation;
updateUI();
}
/**
* This method returns the UI delegate being
* used with the JSeparator.
*
* @return SeparatorUI The JSeparator's UI delegate.
*/
public SeparatorUI getUI()
{
return (SeparatorUI) ui;
}
/**
* This method sets the UI delegate to use
* with the JSeparator.
*
* @param ui The UI delegate to use.
*/
public void setUI(SeparatorUI ui)
{
super.setUI(ui);
}
/**
* This method resets the UI delegate to the
* default for the current look and feel.
*/
public void updateUI()
{
setUI((SeparatorUI) UIManager.getUI(this));
invalidate();
}
/**
* This method returns the identifier string
* that is used to determine the UI delegate
* from the current look and feel.
*
* @return String The identifier string for the UI.
*/
public String getUIClassID()
{
return "SeparatorUI";
}
/**
* This method returns the JSeparator's orientation.
*
* @return int The JSeparator's orientation.
*/
public int getOrientation()
{
return orientation;
}
/**
* This method changes the JSeparator's orientation.
*
* @param orientation The JSeparator's orientation.
*/
public void setOrientation(int orientation)
{
if (orientation != HORIZONTAL && orientation != VERTICAL)
throw new IllegalArgumentException(orientation
+ " is not a valid orientation.");
this.orientation = orientation;
}
/**
* This method returns a string desribing the JSeparator.
* Normally only used in debugging.
*
* @return String A string describing the JSeparator.
*/
protected String paramString()
{
return "JSeparator";
}
/**
* This method overrides the isFocusTraversable method from
* Component to false. JSeparator cannot be focused on.
*
* @return boolean False.
*/
public boolean isFocusTraversable()
{
return false;
}
/**
* getAccessibleContext
*
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJSeparator(this);
return accessibleContext;
}
}
......@@ -40,103 +40,240 @@ package javax.swing;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import javax.accessibility.Accessible;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ViewportUI;
/**
*
* <pre>
* _
* +-------------------------------+ ...........Y1 \
* | view | . \
* | (this component's child) | . > VY
* | | . / = Y2-Y1
* | +------------------------------+ ....Y2_/
* | | viewport | | .
* | | (this component) | | .
* | | | | .
* | | | | .
* | | | | .
* | | | | .
* | +------------------------------+ ....Y3
* | | .
* | . | . .
* | . | . .
* +---------.---------------------+ ...........Y4
* . . . .
* . . . .
* . . . .
* X1.......X2.....................X3.......X4
* \____ ___/
* \/
* VX = X2-X1
*</pre>
*
* <p>A viewport is, like all swing components, located at some position in
* the swing component tree; that location is exactly the same as any other
* components: the viewport's "bounds".</p>
*
* <p>But in terms of drawing its child, the viewport thinks of itself as
* covering a particular position <em>of the view's coordinate space</em>.
* For example, the {@link javax.JViewPort.getViewPosition} method returns
* the position <code>(VX,VY)</code> shown above, which is an position in
* "view space", even though this is <em>implemented</em> by positioning
* the underlying child at position <code>(-VX,-VY)</code></p>
*
*/
public class JViewport extends JComponent
{
Component c;
JViewport()
{
setOpaque(true);
updateUI();
}
void setView(Component c)
{
if (this.c != null)
remove(c);
this.c = c;
add(c);
}
public String getUIClassID()
{
return "ViewportUI";
}
public void updateUI()
{
ViewportUI vp = (ViewportUI) UIManager.getUI(this);
setUI(vp);
}
Container GetHeavy(Container parent)
{
if (parent == null)
return null;
while (isLightweightComponent(parent))
{
Container p = parent.getParent();
if (p == null)
{
System.out.println("GetHeavy FAILED, no heavy weight component found");
return parent;
}
parent = p;
}
return parent;
}
public static int BACKINGSTORE_SCROLL_MODE = 1;
public static int BLIT_SCROLL_MODE = 2;
public static int SIMPLE_SCROLL_MODE = 3;
ChangeEvent changeEvent = new ChangeEvent(this);
int scrollMode;
boolean scrollUnderway;
boolean isViewSizeSet;
/**
* The width and height of the Viewport's area in terms of view
* coordinates. Typically this will be the same as the width and height
* of the viewport's bounds, unless the viewport transforms units of
* width and height, which it may do, for example if it magnifies or
* rotates its view.
*
* @see #toViewCoordinates
*/
Dimension viewExtent;
Point lastPaintPosition;
JViewport()
{
setOpaque(true);
updateUI();
}
public Dimension getViewSize()
{
if (viewExtent == null)
return getPreferredSize();
else
return viewExtent;
}
public void setViewSize(Dimension newSize)
{
viewExtent = newSize;
fireStateChanged();
}
public Point getViewPosition()
{
Component view = getView();
if (view == null)
return new Point(0,0);
else
{
Point p = view.getLocation();
p.x = -p.x;
p.y = -p.y;
return p;
}
}
public void setViewPosition(Point p)
{
Component view = getView();
if (view != null)
{
Point q = new Point(-p.x, -p.y);
view.setLocation(q);
fireStateChanged();
}
}
public Rectangle getViewRect()
{
return new Rectangle(getViewPosition(),
getViewSize());
}
public boolean isBackingStoreEnabled()
{
return scrollMode == BACKINGSTORE_SCROLL_MODE;
}
public void setBackingStoreEnabled(boolean b)
{
if (b && scrollMode != BACKINGSTORE_SCROLL_MODE)
{
scrollMode = BACKINGSTORE_SCROLL_MODE;
fireStateChanged();
}
}
public void setScrollMode(int mode)
{
scrollMode = mode;
fireStateChanged();
}
public int getScrollMode()
{
return scrollMode;
}
public Component getView()
{
if (ncomponents > 0)
return component[0];
else
return null;
}
public void setView(Component v)
{
add(v);
fireStateChanged();
}
public void paint(Graphics g)
{
paintChildren(g);
System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXX JViewport -----> paint()");
Container parent = GetHeavy(getParent());
System.out.println("parent = " + parent + ", " + getParent());
//parent.paint();
Graphics wg = parent.getGraphics();
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Rectangle r = new Rectangle(x, y, w, h);
int ox = 0;
int oy = 0;
wg.copyArea(r.x,
r.y,
r.width,
r.height,
ox,
oy);
wg.dispose();
}
public void addImpl(Component comp, Object constraints, int index)
{
if (ncomponents > 0)
remove(component[0]);
super.addImpl(comp, constraints, index);
}
public final Insets getInsets()
{
return new Insets(0,0,0,0);
}
public final Insets getInsets(Insets insets)
{
if (insets == null)
return getInsets();
insets.top = 0;
insets.bottom = 0;
insets.left = 0;
insets.right = 0;
return insets;
}
public boolean isOptimizedDrawingEnabled()
{
return false;
}
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) getListeners(ChangeListener.class);
}
public void paint(Graphics g)
{
paintComponent(g);
}
void fireStateChanged()
{
ChangeListener[] listeners = getChangeListeners();
for (int i = 0; i < listeners.length; ++i)
listeners[i].stateChanged(changeEvent);
}
public void addChangeListener(ChangeListener listener)
{
listenerList.add(ChangeListener.class, listener);
}
public void removeChangeListener(ChangeListener listener)
{
listenerList.remove(ChangeListener.class, listener);
}
public String getUIClassID()
{
return "ViewportUI";
}
public void updateUI()
{
setUI((ViewportUI) UIManager.getUI(this));
}
}
/* ListModel.java --
/* ListModel.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -36,13 +36,45 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import javax.swing.event.ListDataListener;
/**
* This is an interface to general list-like data, typically used as the
* model object of a {@link JList} component.
*
* @author Graydon Hoare (graydon&064;redhat.com)
*/
public interface ListModel
{
{
/**
* Return the number of data elements in the list.
*
* @return The number of data elements in the list
*/
int getSize();
/**
* Retrieves a data element at a specified index.
*
* @param index The index of the element to retrieve
*
* @return The data element at the specified index
*/
Object getElementAt(int index);
/**
* Add a listener object to this model. The listener will be called
* any time the set of elements in the model is changed.
*
* @param l The listener to add
*/
void addListDataListener(ListDataListener l);
/**
* Add a listener object to this model. The listener will no longer be
* called when the set of elements in the model is changed.
*
* @param l The listener to remove
*/
void removeListDataListener(ListDataListener l);
}
......@@ -42,24 +42,41 @@ import javax.swing.event.ListSelectionListener;
public interface ListSelectionModel
{
int SINGLE_SELECTION = 0;
int SINGLE_INTERVAL_SELECTION = 1;
int MULTIPLE_INTERVAL_SELECTION = 1;
void setSelectionMode(int a);
int getSelectionMode();
void clearSelection();
int getMinSelectionIndex();
int getMaxSelectionIndex();
boolean isSelectedIndex(int a);
void setSelectionInterval(int index0, int index1);
int SINGLE_SELECTION = 0;
int SINGLE_INTERVAL_SELECTION = 1;
int MULTIPLE_INTERVAL_SELECTION = 2;
void setSelectionMode(int a);
int getSelectionMode();
void clearSelection();
void addListSelectionListener(ListSelectionListener listener);
void removeListSelectionListener(ListSelectionListener listener);
int getMinSelectionIndex();
int getMaxSelectionIndex();
boolean isSelectedIndex(int a);
boolean isSelectionEmpty();
void setSelectionInterval(int index0, int index1);
void addSelectionInterval(int index0,
int index1);
void removeSelectionInterval(int index0,
int index1);
void insertIndexInterval(int index,
int length,
boolean before);
void removeIndexInterval(int index0,
int index1);
int getAnchorSelectionIndex();
void setAnchorSelectionIndex(int index);
int getLeadSelectionIndex();
void setLeadSelectionIndex(int index);
void setValueIsAdjusting(boolean valueIsAdjusting);
boolean getValueIsAdjusting();
void addListSelectionListener(ListSelectionListener listener);
void removeListSelectionListener(ListSelectionListener listener);
}
......@@ -48,6 +48,7 @@ import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.KeyEvent;
......@@ -667,10 +668,19 @@ public class SwingUtilities implements SwingConstants
else
{
iconR.width = icon.getIconWidth();
iconR.height = icon.getIconWidth();
iconR.height = icon.getIconHeight();
}
if (text == null)
{
textIconGap = 0;
textR.width = 0;
textR.height = 0;
}
else
{
textR.width = fm.stringWidth(text);
textR.height = fm.getHeight();
}
textR.width = fm.stringWidth(text);
textR.height = fm.getHeight();
// Work out the position of text and icon, assuming the top-left coord
// starts at (0,0). We will fix that up momentarily, after these
......@@ -776,5 +786,53 @@ public class SwingUtilities implements SwingConstants
{
return java.awt.EventQueue.isDispatchThread();
}
/**
* This method paints the given component at the given position and size.
* The component will be reparented to the container given.
*
* @param g The Graphics object to draw with.
* @param c The Component to draw
* @param p The Container to reparent to.
* @param x The x coordinate to draw at.
* @param y The y coordinate to draw at.
* @param w The width of the drawing area.
* @param h The height of the drawing area.
*/
public static void paintComponent(Graphics g, Component c, Container p,
int x, int y, int w, int h)
{
Container parent = c.getParent();
if (parent != null)
parent.remove(c);
if (p != null)
p.add(c);
Shape savedClip = g.getClip();
g.setClip(x, y, w, h);
g.translate(x, y);
c.paint(g);
g.translate(-x, -y);
g.setClip(savedClip);
}
/**
* This method paints the given component in the given rectangle.
* The component will be reparented to the container given.
*
* @param g The Graphics object to draw with.
* @param c The Component to draw
* @param p The Container to reparent to.
* @param r The rectangle that describes the drawing area.
*/
public static void paintComponent(Graphics g, Component c,
Container p, Rectangle r)
{
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
}
}
......@@ -52,64 +52,26 @@ public class ViewportLayout implements LayoutManager, Serializable
{
static final long serialVersionUID = -788225906076097229L;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor ViewportLayout
*/
public ViewportLayout() {
// TODO
} // ViewportLayout()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* addLayoutComponent
* @param name TODO
* @param c TODO
*/
}
public void addLayoutComponent(String name, Component c) {
// TODO
} // addLayoutComponent()
/**
* removeLayoutComponent
* @param c TODO
*/
// ignore
}
public void removeLayoutComponent(Component c) {
// TODO
} // removeLayoutComponent()
/**
* preferredLayoutSize
* @param parent TODO
* @returns Dimension
*/
// ignore
}
public Dimension preferredLayoutSize(Container parent) {
return null; // TODO
} // preferredLayoutSize()
/**
* minimumLayoutSize
* @param parent TODO
* @returns Dimension
*/
return null;
}
public Dimension minimumLayoutSize(Container parent) {
return null; // TODO
} // minimumLayoutSize()
/**
* layoutContainer
* @param parent TODO
*/
return null;
}
public void layoutContainer(Container parent) {
// TODO
} // layoutContainer()
} // ViewportLayout
if (parent.countComponents() == 1)
{
// This should usually be true, but if it's not it is
// probably nicer if we do not panic.
Component c = parent.getComponent(0);
}
}
}
......@@ -87,15 +87,12 @@ public class BasicButtonListener
}
public void mouseMoved(MouseEvent e)
{
System.err.println("button got mouse move");
}
public void mouseDragged(MouseEvent e)
{
System.err.println("button got mouse drag");
}
public void mouseClicked(MouseEvent e)
{
System.err.println("button got mouse click");
}
/**
......
......@@ -250,7 +250,8 @@ public class BasicButtonUI extends ButtonUI
paintButtonNormal(g, br, c);
paintIcon(g, c, ir);
paintText(g, c, tr, b.getText());
if (text != null)
paintText(g, c, tr, b.getText());
paintFocus(g, c, vr, tr, ir);
}
......
......@@ -597,10 +597,7 @@ public class BasicGraphicsUtils
Insets insets = b.getInsets();
Insets margin = b.getMargin();
/* For determining the ideal size, do not assume a size restriction. */
viewRect = new Rectangle(0, 0,
/* width */ Integer.MAX_VALUE,
/* height */ Integer.MAX_VALUE);
viewRect = new Rectangle();
/* java.awt.Toolkit.getFontMetrics is deprecated. However, it
* seems not obvious how to get to the correct FontMetrics object
......@@ -614,14 +611,13 @@ public class BasicGraphicsUtils
b.getToolkit().getFontMetrics(b.getFont()), // see comment above
b.getText(),
b.getIcon(),
SwingUtilities.TOP, // important:
SwingUtilities.LEFT, // large vrect, stick to the top left
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getVerticalTextPosition(),
b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
textIconGap);
/* +------------------------+ +------------------------+
* | | | |
* | ICON | | CONTENTCONTENTCONTENT |
......@@ -629,6 +625,7 @@ public class BasicGraphicsUtils
* | TEXTTEXTTEXT | | CONTENTCONTENTCONTENT |
* +------------------------+ +------------------------+
*/
contentRect = textRect.union(iconRect);
return new Dimension(insets.left + margin.left
......
......@@ -41,14 +41,14 @@ package javax.swing.plaf.basic;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneLayout;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollPaneUI;
public class BasicScrollPaneUI extends ScrollPaneUI
{
int min_w = 50;
int min_h = 50;
public static ComponentUI createUI(final JComponent c)
{
......@@ -61,33 +61,25 @@ public class BasicScrollPaneUI extends ScrollPaneUI
super.installUI(c);
}
public Dimension getMinimumSize(JComponent c)
{
JScrollPane p = (JScrollPane ) c;
ScrollPaneLayout sl = (ScrollPaneLayout) p.getLayout();
return sl.minimumLayoutSize(c);
}
public Dimension getPreferredSize(JComponent c)
{
JScrollPane p = (JScrollPane ) c;
Dimension d = new Dimension(min_w,
min_h);
Dimension a = p.getViewport().getPreferredSize();
if (a != null)
{
d.width = Math.max(d.width, a.width);
d.height = Math.max(d.height, a.height);
}
System.out.println("BasicScrollPaneUI->preff->"+d);
return d;
ScrollPaneLayout sl = (ScrollPaneLayout) p.getLayout();
return sl.preferredLayoutSize(c);
}
public void paint(Graphics g, JComponent c)
{
System.out.println("BasicScrollPaneUI->paint()->"+c);
JScrollPane p = (JScrollPane ) c;
p.getViewport().paint(g);
// do nothing; the normal painting-of-children algorithm, along with
// ScrollPaneLayout, does all the relevant work.
}
}
......
/* BasicSeparatorUI.java
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SeparatorUI;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.JComponent;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
/**
* The Basic L&F UI delegate for JSeparator.
*/
public class BasicSeparatorUI extends SeparatorUI
{
/** The shadow color. */
protected Color shadow;
/** The highlight color. */
protected Color highlight;
/**
* Creates a new UI delegate for the given JComponent.
*
* @param c The JComponent to create a delegate for.
*
* @return A new BasicSeparatorUI.
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicSeparatorUI();
}
/**
* This method installs the UI for the given JComponent.
* This can include installing defaults, listeners, and
* initializing any instance data.
*
* @param c The JComponent that is having this UI installed.
*/
public void installUI(JComponent c)
{
super.installUI(c);
if (c instanceof JSeparator)
{
JSeparator s = (JSeparator) c;
installDefaults(s);
installListeners(s);
}
}
/**
* Uninstalls the UI for the given JComponent. This
* method reverses what was done when installing
* the UI on the JComponent.
*
* @param c The JComponent that is having this UI uninstalled.
*/
public void uninstallUI(JComponent c)
{
if (c instanceof JSeparator)
{
JSeparator s = (JSeparator) c;
uninstallListeners(s);
uninstallDefaults(s);
}
}
/**
* This method installs the defaults that are given by
* the Basic L&F.
*
* @param s The JSeparator that is being installed.
*/
protected void installDefaults(JSeparator s)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
shadow = defaults.getColor("Separator.shadow");
highlight = defaults.getColor("Separator.highlight");
}
/**
* This method removes the defaults that were given
* by the Basic L&F.
*
* @param s The JSeparator that is being uninstalled.
*/
protected void uninstallDefaults(JSeparator s)
{
shadow = null;
highlight = null;
}
/**
* This method installs any listeners that need
* to be attached to the JSeparator or any of its
* components.
*
* @param s The JSeparator that is being installed.
*/
protected void installListeners(JSeparator s)
{
// Separators don't receive events.
}
/**
* This method uninstalls any listeners that
* were installed during the install UI process.
*
* @param s The JSeparator that is being uninstalled.
*/
protected void uninstallListeners(JSeparator s)
{
// Separators don't receive events.
}
/**
* The separator is made of two lines. The top line will be
* the highlight color (or left line if it's vertical). The bottom
* or right line will be the shadow color. The two lines will
* be centered inside the bounds box. If the separator is horizontal,
* then it will be vertically centered, or if it's vertical, it will
* be horizontally centered.
*
* @param g The Graphics object to paint with
* @param c The JComponent to paint.
*/
public void paint(Graphics g, JComponent c)
{
Rectangle r = new Rectangle();
SwingUtilities.calculateInnerArea(c, r);
Color saved = g.getColor();
int midAB = r.width / 2 + r.x;
int midAD = r.height / 2 + r.y;
JSeparator s;
if (c instanceof JSeparator)
s = (JSeparator) c;
else
return;
if (s.getOrientation() == JSeparator.HORIZONTAL)
{
g.setColor(highlight);
g.drawLine(r.x, midAD, r.x + r.width, midAD);
g.setColor(shadow);
g.drawLine(r.x, midAD + 1, r.x + r.width, midAD + 1);
}
else
{
g.setColor(highlight);
g.drawLine(midAB, r.y, midAB, r.y + r.height);
g.setColor(shadow);
g.drawLine(midAB + 1, r.y, midAB + 1, r.y + r.height);
}
}
/**
* This method returns the preferred size of the
* JComponent.
*
* @param c The JComponent to measure.
*
* @return The preferred size.
*/
public Dimension getPreferredSize(JComponent c)
{
Dimension dims = new Dimension(0, 0);
Insets insets = c.getInsets();
if (c instanceof JSeparator)
{
JSeparator s = (JSeparator) c;
if (s.getOrientation() == JSeparator.HORIZONTAL)
{
dims.height = 2;
dims.width = 40;
}
else
{
dims.width = 2;
dims.height = 40;
}
}
dims.width += insets.left + insets.right;
dims.height += insets.top + insets.bottom;
return dims;
}
/**
* This method returns the minimum size of the
* JComponent.
*
* @param c The JComponent to measure.
*
* @return The minimum size.
*/
public Dimension getMinimumSize(JComponent c)
{
return getPreferredSize(c);
}
/**
* This method returns the maximum size of the
* JComponent.
*
* @param c The JComponent to measure.
*
* @return The maximum size.
*/
public Dimension getMaximumSize(JComponent c)
{
return getPreferredSize(c);
}
}
......@@ -38,36 +38,110 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import javax.swing.JComponent;
import javax.swing.JViewport;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ViewportUI;
public class BasicViewportUI extends ViewportUI
{
public static ComponentUI createUI(final JComponent c)
ChangeListener changeListener;
Image backingStoreImage;
int backingStoreWidth = -1;
int backingStoreHeight = -1;
class ChangeHandler implements ChangeListener
{
public void stateChanged(ChangeEvent event)
{
return new BasicViewportUI();
JViewport v = (JViewport)event.source;
v.repaint();
}
}
public void installUI(final JComponent c)
{
super.installUI(c);
}
void installDefaults(JComponent c)
{
}
void uninstallDefaults(JComponent c)
{
}
void installListeners(JComponent c)
{
((JViewport)c).addChangeListener(changeListener);
}
void uninstallListeners(JComponent c)
{
((JViewport)c).removeChangeListener(changeListener);
}
public BasicViewportUI()
{
changeListener = new ChangeHandler();
}
public static ComponentUI createUI(JComponent c)
{
return new BasicViewportUI();
}
public void installUI(JComponent c)
{
super.installUI(c);
installListeners(c);
}
public void uninstallUI(JComponent c)
{
uninstallListeners(c);
}
public Dimension getPreferredSize(JComponent c)
{
Dimension d = new Dimension(100,100);
System.out.println("BasicViewportUI->preff->"+d);
return d;
}
public Dimension getPreferredSize(JComponent c)
{
// FIXME: integrate with Scrollable
Dimension d = new Dimension(100,100);
return d;
}
public void paint(Graphics g, JComponent c)
{
System.out.println("BasicViewportUI->paint->"+c);
}
public void paint(Graphics g, JComponent c)
{
JViewport v = (JViewport)c;
Component view = v.getView();
if (view == null)
return;
Point pos = v.getViewPosition();
Rectangle viewBounds = view.getBounds();
if (backingStoreImage == null
|| backingStoreWidth != viewBounds.width
|| backingStoreHeight != viewBounds.height)
{
backingStoreImage = v.createImage(viewBounds.width, viewBounds.height);
backingStoreWidth = viewBounds.width;
backingStoreHeight = viewBounds.height;
}
Graphics g2 = backingStoreImage.getGraphics();
view.paint(g2);
g2 = null;
g.drawImage(backingStoreImage,
-pos.x, -pos.y,
(ImageObserver)null);
}
}
......@@ -53,6 +53,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri
jintArray array;
jint *metrics;
struct peerfont *pf = NULL;
FT_Matrix mat;
pf = NSA_GET_FONT_PTR(env, font);
g_assert (pf != NULL);
......@@ -62,14 +63,21 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri
gdk_threads_enter ();
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 63.0))
#define DOUBLE_FROM_26_6(t) (((double)((t) >> 6)) \
+ ((double)((t) & 0x3F) / 63.0))
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
#define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
#define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0)
double pointsize = pango_font_description_get_size (pf->desc);
pointsize /= (double) PANGO_SCALE;
mat.xx = DOUBLE_TO_16_16(1);
mat.xy = DOUBLE_TO_16_16(0);
mat.yx = DOUBLE_TO_16_16(0);
mat.yy = DOUBLE_TO_16_16(1);
FT_Face face = pango_ft2_font_get_face (pf->font);
FT_Set_Transform(face, &mat, NULL);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
......
......@@ -47,10 +47,11 @@ typedef struct {
double height;
} rect_t;
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 63.0))
#define DOUBLE_FROM_26_6(t) (((double)((t) >> 6)) \
+ ((double)((t) & 0x3F) / 63.0))
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
#define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
#define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0)
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_initStaticState
(JNIEnv *env, jclass clazz)
{
......@@ -401,6 +402,21 @@ JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphCharIndex
return idx;
}
static void
assume_pointsize_and_identity_transform(double pointsize,
FT_Face face)
{
FT_Matrix mat;
mat.xx = DOUBLE_TO_16_16(1);
mat.xy = DOUBLE_TO_16_16(0);
mat.yx = DOUBLE_TO_16_16(0);
mat.yy = DOUBLE_TO_16_16(1);
FT_Set_Transform(face, &mat, NULL);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
0, 0);
}
JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allInkExtents
(JNIEnv *env, jobject self)
......@@ -432,10 +448,7 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allInkE
g_assert (gi->glyphs != NULL);
face = pango_ft2_font_get_face (gi->item->analysis.font);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
0, 0);
assume_pointsize_and_identity_transform (pointsize, face);
for (j = 0; j < gi->glyphs->num_glyphs; ++j)
{
......@@ -487,10 +500,7 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allLogi
g_assert (gi->glyphs != NULL);
face = pango_ft2_font_get_face (gi->item->analysis.font);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
0, 0);
assume_pointsize_and_identity_transform (pointsize, face);
for (j = 0; j < gi->glyphs->num_glyphs; ++j)
{
......@@ -541,11 +551,9 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphLo
pointsize = pango_font_description_get_size (vec->desc);
pointsize /= (double) PANGO_SCALE;
face = pango_ft2_font_get_face (font);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
0, 0);
assume_pointsize_and_identity_transform (pointsize, face);
FT_Load_Glyph (face, gi->glyph, FT_LOAD_DEFAULT);
/* FIXME: this is probably not the correct set of metrics;
......@@ -588,10 +596,8 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphIn
pointsize = pango_font_description_get_size (vec->desc);
pointsize /= (double) PANGO_SCALE;
face = pango_ft2_font_get_face (font);
FT_Set_Char_Size( face,
DOUBLE_TO_26_6 (pointsize),
DOUBLE_TO_26_6 (pointsize),
0, 0);
assume_pointsize_and_identity_transform (pointsize, face);
FT_Load_Glyph (face, gi->glyph, FT_LOAD_DEFAULT);
/* FIXME: this needs to change for vertical layouts */
......
......@@ -188,7 +188,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
(JNIEnv *env, jobject obj, jstring str, jint x, jint y,
jstring fname, jint size)
jstring fname, jint style, jint size)
{
struct graphics *g;
const char *cstr;
......@@ -209,6 +209,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * PANGO_SCALE);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
context = gdk_pango_context_get();
pango_context_set_font_description (context, font_desc);
......
......@@ -114,6 +114,15 @@ enum java_awt_geom_path_iterator_winding_rule
java_awt_geom_path_iterator_WIND_NON_ZERO = 1
};
enum java_awt_rendering_hints_filter
{
java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR = 0,
java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR = 1,
java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED = 2,
java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY = 3,
java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT = 4
};
static void
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
......@@ -683,21 +692,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
native_matrix[2], native_matrix[3],
native_matrix[4], native_matrix[5]);
cairo_surface_set_matrix (surf, mat);
if (native_matrix[0] != 1.
|| native_matrix[1] != 0.
|| native_matrix[2] != 0.
|| native_matrix[3] != 1.)
{
cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR);
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR);
}
else
{
cairo_surface_set_filter (surf, CAIRO_FILTER_FAST);
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST);
}
cairo_surface_set_filter (surf, cairo_surface_get_filter(gr->surface));
cairo_show_surface (gr->cr, surf, w, h);
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST);
cairo_matrix_destroy (mat);
cairo_surface_destroy (surf);
}
......@@ -709,6 +705,71 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
}
JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
jintArray java_pixels;
jint* native_pixels;
GdkPixbuf *buf = NULL;
gint width, height;
gint bits_per_sample = 8;
gboolean has_alpha = TRUE;
gint total_channels = 4;
jint i, px;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("getImagePixels\n");
gdk_drawable_get_size (gr->drawable, &width, &height);
buf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha,
bits_per_sample,
width, height);
g_assert (buf != NULL);
g_assert (gdk_pixbuf_get_bits_per_sample (buf) == bits_per_sample);
g_assert (gdk_pixbuf_get_n_channels (buf) == total_channels);
/* copy pixels from drawable to pixbuf */
gdk_pixbuf_get_from_drawable (buf, gr->drawable,
NULL,
0, 0, 0, 0,
width, height);
native_pixels= gdk_pixbuf_get_pixels (buf);
/* NOTE: The pixels we got in the pixbuf are stored
in reversed order. i.e 0xBBGGRRAA.
We need to convert them to 0xAARRGGBB. */
for (i=0; i<width * height; i++)
{
/* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */
px = native_pixels[i];
px = ((px >> 24) & 0xff) | ((px << 8) & 0xffffff00);
px = ((px >> 8) & 0x00ff00ff) | ((px << 8) & 0xff00ff00);
px = ((px >> 16) & 0x0000ffff) | ((px << 16) & 0xffff0000);
native_pixels[i] = px;
}
java_pixels = (*env) -> NewIntArray (env, width * height);
(*env)->SetIntArrayRegion(env, java_pixels,
(jsize)0, (jsize) width*height,
(jint*) native_pixels);
return java_pixels;
}
/* passthrough methods to cairo */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave
......@@ -1157,3 +1218,30 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
cairo_clip (gr->cr);
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
struct graphics2d *gr = NULL;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_surface_set_filter %d\n", filter);
switch ((enum java_awt_rendering_hints_filter) filter)
{
case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST);
break;
case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR);
break;
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST);
break;
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST);
break;
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BEST);
break;
}
}
......@@ -164,6 +164,69 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
NSA_SET_PTR (env, group, native_group);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
const char *font_name;
void *ptr;
GtkWidget *button;
GtkWidget *label;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
button = GTK_WIDGET (ptr);
label = gtk_bin_get_child (GTK_BIN(button));
if (!label)
return;
font_name = (*env)->GetStringUTFChars (env, name, NULL);
gdk_threads_enter();
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * PANGO_SCALE);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, name, font_name);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel
(JNIEnv *env, jobject obj, jstring label)
{
const char *str;
void *ptr;
GtkWidget *label_widget;
ptr = NSA_GET_PTR (env, obj);
label_widget = gtk_bin_get_child (GTK_BIN(ptr));
str = (*env)->GetStringUTFChars (env, label, 0);
gdk_threads_enter ();
gtk_label_set_label (GTK_LABEL (label_widget), str);
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, label, str);
}
static void
item_toggled (GtkToggleButton *item, jobject peer)
{
......
......@@ -260,11 +260,11 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBoun
widget = GTK_WIDGET (ptr);
if (GTK_IS_VIEWPORT (widget->parent))
{
gtk_widget_set_usize (widget, width, height);
gtk_widget_set_size_request (widget, width, height);
}
else
{
gtk_widget_set_usize (widget, width, height);
gtk_widget_set_size_request (widget, width, height);
gtk_layout_move (GTK_LAYOUT (widget->parent), widget, x, y);
}
......@@ -380,6 +380,39 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
const char *font_name;
void *ptr;
GtkWidget *label;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
gdk_threads_enter();
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * PANGO_SCALE);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
gtk_widget_modify_font (GTK_WIDGET(ptr), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, name, font_name);
}
void
set_visible (GtkWidget *widget, jboolean visible)
{
......
......@@ -83,6 +83,27 @@ state_to_awt_mods (guint state)
return result;
}
static jint
state_to_awt_mods_with_button_states (guint state)
{
jint result = 0;
if (state & GDK_SHIFT_MASK)
result |= AWT_SHIFT_MASK;
if (state & GDK_CONTROL_MASK)
result |= AWT_CTRL_MASK;
if (state & GDK_MOD1_MASK)
result |= AWT_ALT_MASK;
if (state & GDK_BUTTON1_MASK)
result |= AWT_BUTTON1_MASK;
if (state & GDK_BUTTON2_MASK)
result |= AWT_BUTTON2_MASK;
if (state & GDK_BUTTON3_MASK)
result |= AWT_BUTTON3_MASK;
return result;
}
/* Modifier key events need special treatment. In Sun's peer
implementation, when a modifier key is pressed, the KEY_PRESSED
event has that modifier in its modifiers list. The corresponding
......@@ -830,6 +851,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
static GdkWindow *button_window = NULL;
static guint button_number = -1;
static jint click_count = 1;
static int hasBeenDragged;
/* If it is not a focus change event, the widget must be realized already.
If not, ignore the event (Gtk+ will do the same). */
......@@ -895,6 +917,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
click_count,
(event->button.button == 3) ? JNI_TRUE :
JNI_FALSE);
hasBeenDragged = FALSE;
break;
case GDK_BUTTON_RELEASE:
{
......@@ -911,10 +934,12 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
click_count,
JNI_FALSE);
/* check to see if the release occured in the window it was pressed
in, and if so, generate an AWT click event */
// Generate an AWT click event only if the release occured in the
// window it was pressed in, and the mouse has not been dragged since
// the last time it was pressed.
gdk_window_get_size (event->any.window, &width, &height);
if (event->button.x >= 0
if (! hasBeenDragged
&& event->button.x >= 0
&& event->button.y >= 0
&& event->button.x <= width
&& event->button.y <= height)
......@@ -933,15 +958,6 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
}
break;
case GDK_MOTION_NOTIFY:
(*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID,
AWT_MOUSE_MOVED,
(jlong)event->motion.time,
state_to_awt_mods (event->motion.state),
(jint)event->motion.x,
(jint)event->motion.y,
0,
JNI_FALSE);
if (event->motion.state & (GDK_BUTTON1_MASK
| GDK_BUTTON2_MASK
| GDK_BUTTON3_MASK
......@@ -952,12 +968,22 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
postMouseEventID,
AWT_MOUSE_DRAGGED,
(jlong)event->motion.time,
state_to_awt_mods (event->motion.state),
state_to_awt_mods_with_button_states (event->motion.state),
(jint)event->motion.x,
(jint)event->motion.y,
0,
JNI_FALSE);
hasBeenDragged = TRUE;
}
else
(*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID,
AWT_MOUSE_MOVED,
(jlong)event->motion.time,
state_to_awt_mods (event->motion.state),
(jint)event->motion.x,
(jint)event->motion.y,
0,
JNI_FALSE);
break;
case GDK_ENTER_NOTIFY:
/* We are not interested in enter events that are due to
......@@ -966,7 +992,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
(*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID,
AWT_MOUSE_ENTERED,
(jlong)event->crossing.time,
state_to_awt_mods (event->crossing.state),
state_to_awt_mods_with_button_states (event->crossing.state),
(jint)event->crossing.x,
(jint)event->crossing.y,
0,
......@@ -980,7 +1006,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
postMouseEventID,
AWT_MOUSE_EXITED,
(jlong)event->crossing.time,
state_to_awt_mods (event->crossing.state),
state_to_awt_mods_with_button_states (event->crossing.state),
(jint)event->crossing.x,
(jint)event->crossing.y,
0,
......
......@@ -70,6 +70,44 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
const char *font_name;
void *ptr;
GtkWidget *label;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
label = gtk_bin_get_child (GTK_BIN(ptr));
if (!label)
return;
font_name = (*env)->GetStringUTFChars (env, name, NULL);
gdk_threads_enter();
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * PANGO_SCALE);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, name, font_name);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText
(JNIEnv *env, jobject obj, jstring text)
{
......
......@@ -44,6 +44,12 @@ exception statement from your version. */
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
static int filter_added = 0;
static GdkFilterReturn window_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
static void window_get_frame_extents (GtkWidget *window,
int *top, int *left,
int *bottom, int *right);
......@@ -59,12 +65,9 @@ static void window_delete_cb (GtkWidget *widget, GdkEvent *event,
static void window_destroy_cb (GtkWidget *widget, GdkEvent *event,
jobject peer);
static void window_show_cb (GtkWidget *widget, jobject peer);
static gboolean window_focus_in_cb (GtkWidget * widget,
GdkEventFocus *event,
jobject peer);
static gboolean window_focus_out_cb (GtkWidget * widget,
GdkEventFocus *event,
jobject peer);
static void window_focus_or_active_state_change_cb (GtkWidget *widget,
GParamSpec *pspec,
jobject peer);
static gboolean window_window_state_cb (GtkWidget *widget,
GdkEvent *event,
jobject peer);
......@@ -147,6 +150,20 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create
insets[2] = bottom;
insets[3] = right;
/* We must filter out WM_TAKE_FOCUS messages. Otherwise we get two
focus in events when a window becomes active and two focus out
events when a window becomes inactive. */
if (!filter_added)
{
GdkAtom wm_protocols_atom =
gdk_x11_xatom_to_atom (gdk_x11_get_xatom_by_name ("WM_PROTOCOLS"));
gdk_add_client_message_filter (wm_protocols_atom,
window_wm_protocols_filter,
NULL);
filter_added = 1;
}
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements (env, jinsets, insets, 0);
......@@ -251,11 +268,8 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals
g_signal_connect (G_OBJECT (ptr), "show",
G_CALLBACK (window_show_cb), *gref);
g_signal_connect (G_OBJECT (ptr), "focus-in-event",
G_CALLBACK (window_focus_in_cb), *gref);
g_signal_connect (G_OBJECT (ptr), "focus-out-event",
G_CALLBACK (window_focus_out_cb), *gref);
g_signal_connect (G_OBJECT (ptr), "notify",
G_CALLBACK (window_focus_or_active_state_change_cb), *gref);
g_signal_connect (G_OBJECT (ptr), "window-state-event",
G_CALLBACK (window_window_state_cb), *gref);
......@@ -661,40 +675,37 @@ window_show_cb (GtkWidget *widget __attribute__((unused)),
(jobject) NULL, (jint) 0);
}
static gboolean
window_focus_in_cb (GtkWidget * widget __attribute__((unused)),
GdkEventFocus *event __attribute__((unused)),
jobject peer)
{
/* FIXME: when hiding then showing, we get two sets of
(LOST_FOCUS/DEACTIVATED, ACTIVATED/GAINED_FOCUS) events. */
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_ACTIVATED,
(jobject) NULL, (jint) 0);
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_GAINED_FOCUS,
(jobject) NULL, (jint) 0);
return TRUE;
}
static gboolean
window_focus_out_cb (GtkWidget * widget __attribute__((unused)),
GdkEventFocus *event __attribute__((unused)),
jobject peer)
static void
window_focus_or_active_state_change_cb (GtkWidget *widget,
GParamSpec *pspec,
jobject peer)
{
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_LOST_FOCUS,
(jobject) NULL, (jint) 0);
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_DEACTIVATED,
(jobject) NULL, (jint) 0);
return TRUE;
if (!strcmp (g_param_spec_get_name (pspec), "is-active"))
{
if (GTK_WINDOW (widget)->is_active)
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_GAINED_FOCUS,
(jobject) NULL, (jint) 0);
else
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_DEACTIVATED,
(jobject) NULL, (jint) 0);
}
else if (!strcmp (g_param_spec_get_name (pspec), "has-toplevel-focus"))
{
if (GTK_WINDOW (widget)->has_toplevel_focus)
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_ACTIVATED,
(jobject) NULL, (jint) 0);
else
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postWindowEventID,
(jint) AWT_WINDOW_LOST_FOCUS,
(jobject) NULL, (jint) 0);
}
}
static gboolean
......@@ -821,3 +832,16 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)),
return FALSE;
}
static GdkFilterReturn
window_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event __attribute__((unused)),
gpointer data __attribute__((unused)))
{
XEvent *xevent = (XEvent *)xev;
if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS"))
return GDK_FILTER_REMOVE;
return GDK_FILTER_CONTINUE;
}
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -172,7 +172,7 @@ RUNTEST = "`if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
AM_RUNTESTFLAGS = INTERPRETER=$(INTERPRETER)
CONFIG_HEADER = ../include/config.h ../gcj/libgcj-config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = ChangeLog Makefile.am Makefile.in
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
......
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