[multiple changes]

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

	* java/awt/Container.java
	(remove): Set component's parent to null only after we removed the
	component from its parent's layout manager.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(GtkComponentPeer): Set bounds regardless of whether awtComponent
	is valid.
	* gnu/java/awt/peer/gtk/GtkListPeer.java
	(getSize): Change native method declaration.
	(minimumSize): Pass visible row count into getSize().
	(preferredSize): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize): Use scroll window's
	natural size. Use visible row count to determine the final height
	value to return.

2004-05-21  Graydon Hoare  <graydon@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(setClip): Minor correction to order of operations.

	* javax/swing/JScrollPane.java: Extend sketchy implementation.
	* javax/swing/ScrollPaneLayout.java: Likewise.
	* javax/swing/JViewPort.java: Likewise.
	* javax/swing/ViewportLayout.java: Likewise.

	* javax/swing/JComponent.java: Rewrite.
	* javax/swing/RepaintManager.java: Likewise.

	* javax/swing/JLayeredPane.java: Change validate() to revalidate().
	* javax/swing/JList.java
	(setSelectedIndices):
	(getSelectedIndices):
	(getSelectedValues): New functions.
	(getPreferredScrollableViewportSize): Return preferred size.
	(getScrollableUnitIncrement):
	(getScrollableBlockIncrement): Initial implementations.
	* javax/swing/JRootPane.java: Clean up slightly.
	(getUI):
	(setUI):
	(updateUI):
	(getUIClassID):
	(isValidateRoot): Add overrides from JComponent.
	* javax/swing/JScrollBar.java: Set default orientation to VERTICAL.
	* javax/swing/UIManager.java (getDimension): Return the dimension.

	* javax/swing/plaf/basic/BasicButtonUI.java: Set component opaque.
	* javax/swing/plaf/basic/BasicLabelUI.java: Likewise.
	* javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
	* javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise.
	* javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise.
	* javax/swing/plaf/basic/BasicSliderUI.java: Likewise.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise.
	* javax/swing/plaf/basic/BasicRootPaneUI.java:
	Likewise, and set background.
	* javax/swing/plaf/basic/BasicListUI.java:
	Likewise, and improve a bit.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	Likewise, and adjust calculations.
	* javax/swing/plaf/basic/BasicViewportUI.java:
	Likewise, and improve a bit.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(Button.margin): Shrink.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
	Hack to set horizontal always, workaround pango.

	* jni/gtk-peer/gtkcairopeer.h: Change to match pattern API.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
	Synchronize more often, check cairo status after ops,
	handle changes to cairo pattern API, check for disposal.

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

	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(BasicMenuItemUI): Create propertyChangeListener.
	(getPath):Implemented.
	(installListeners): Add propertyChangeListener to menuItem.
	(uninstallListeners): Remove propertyChangeListener from menuItem.
	(update): Implemented.
	* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
	(mouseEntered): Take insets of popup menu into account when
	calculating position of popup menu.

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

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JMenuBar.java:
	Started implementation.
	* javax/swing/JPopupMenu.java:
	(setVisible): Fixed location of lightweight/mediumweight
	popup menu.
	(show): Fixed location of PopupMenu.
	* javax/swing/plaf/basic/BasicMenuBarUI.java:
	New file. UI Delegate for JMenuBar.
	* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
	(mouseEntered): Corrected position of the submenu.

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

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Remove calls
	to _gtk_accel_group_attach.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
	Likewise.

	* gnu/java/awt/peer/gtk/GtkButtonPeer.java: Give gtkSetFont
	package access.  Don't override setFont.
	* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java: Likewise.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Give
	gtkWidgetRequestFocus package access.
	* gnu/java/awt/peer/gtk/GtkLabelPeer.java: Don't override
	setFont.
	* gnu/java/awt/peer/gtk/GtkListPeer.java: Override gtkSetFont.
	Give gtkWidgetRequestFocus package access.
	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java: Give
	gtkWidgetRequestFocus package access.  Don't override setFont.
	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Don't override
	setFont.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
	(gtkSetLabel): Move call to gtk_bin_get_child into GDK critical
	region.
	(gtkSetFont): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c (gtkSetFont):
	Implement.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
	(gtkSetFont): Whitespace fix.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(gtkWidgetSetUsize): Remove method.

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

	* java/awt/image/MemoryImageSource.java
	(newPixels(int,int,int,int,boolean)): Set only the specified
	rectangle of pixels.
	(newPixels(byte[],ColorModel,int,int)): Implement.
	(newPixels(int[],ColorModel,int,int)): Implement.

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

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JMenu.java: Started
	implementation.
	* javax/swing/JPopupMenu.java:
	(insert): If specified index is -1, then
	add component at the end.
	(isPopupTrigger): Reimplemented.
	(JPopupMenu.LightWeightPopup): setBounds
	of the lightWeightPopup before adding it
	to the layeredPane.
	(javax/swing/plaf/basic/BasicIconFactory.java):
	(getMenuArrowIcon): Implemented.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(getPreferredSize): Add size of the arrow icon
	if this menu item is instance of JMenu.
	(paintMenuItem): Paint arrow icon if this
	menu item is a submenu.
	* javax/swing/plaf/basic/BasicMenuUI.java:
	New File. UI Delegate for JMenu.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java (postKeyEvent):
	Post KEY_TYPED events.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(generates_key_typed_event): Remove function.

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

	* javax/swing/JRootPane.java
	(JRootPane.RootLayout): Reimplemented to
	set bounds of contentPane and menuBar.
	(setJMenuBar): Add menu bar to the layered pane.
	(createLayeredPane): Set layout of layeredPane
	to null.
	* javax/swing/JLayeredPane.java:
	(addImpl): Calculate index of the component in the
	layeredPane according to the specified position within
	the layer.

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

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(setPixels): Change color model to the default model after
	converting pixels.
	* java/awt/image/MemoryImageSource.java
	(newPixels): Set only the specified rectangle of pixels.

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

	* libgcj.spec.in (lib): Add -l-java-awt -l-java-applet
	-l-java-beans -l-javax-accessibility -l-javax-swing.

	* java/awt/AWTEvent.java (toString): Print source's name rather
	than the source itself.

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

	* gnu/java/awt/peer/gtk/GtkToolkit.java (loadSystemColors): Make
	native.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
	(gdk_color_to_java_color): New function.
	* jni/gtk-peer/gtkpeer.h: Add SystemColor defines.

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

	* java/awt/image/RGBImageFilter.java:
	Initialize origmodel as null.
	(makeColor): Fix pixel component order.
	(filterRGBPixels): Fix pixel iteration.
	(setPixels): Add extra checks for index color model. Convert pixels
	to default color model if necessary.
	(convertColorModelToDefault): New override method for byte pixels.
	(convertColorModelToDefault): For int pixels, fix pixel iteration.
	(makeColorbyDefaultCM): New override method for byte pixels.
	(makeColorbyDefaultCM): For int pixel, add color model as argument.
	(makeColor): Fix pixel component order.

2004-05-11  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	Comment out more parts of Box.Filler.

2004-05-11  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	Remove reference to AccessibleAWTComponent so
	it compiles again.

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

	* gnu/java/awt/peer/gtk/GtkListPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Update
	implementation of list peer to use GtkTreeView instead of
	deprecated GtkCList.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(gtkWidgetDispatchKeyEvent): Remove keyChar parameter.
	(handleEvent): Remove keyChar argument to
	gtkWidgetDispatchKeyEvent calls.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Fix
	compiler warnings.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c:
	Likewise.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(gtkWidgetRequestFocus): Mark protected.
	(GtkComponentPeer): Only set the peer's bounds if its component
	is valid.
	* java/awt/Component.java (static): Set the default keyboard
	focus manager.
	(requestFocus(), requestFocus(boolean), requestFocusInWindow(),
	requestFocusInWindow(temporary)): Don't request focus if the
	component is not showing.  Get tree lock before traversing
	component hierarchy.
	* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
	Only set the global focus owner if it is not a Window.
	(processKeyEvent): Consume keystrokes associated with the focus
	traversal keystroke.
	(focusPreviousComponent, focusNextComponent, upFocusCycle,
	downFocusCycle): Call requestFocusInWindow instead of
	requestFocus.
	* java/awt/EventDispatchThread.java (run): Move setting of
	default keyboard focus manager to Component.java.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(awt_keycode_to_keysym): New function.
	(gtkWidgetDispatchKeyEvent): Finish implementation.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(pre_event_handler): Add FIXME comment.

	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
	(gtkWidgetRequestFocus): New method.
	* java/awt/TextArea.java (TextArea): Set focus traversal keys to
	disable Tab and Shift-Tab keystrokes.
	(addNotify, appendText, insertText, replaceText): Simplify peer
	retrieval code.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
	(connectSignals): Remove connections to "commit" signals.
	Remove C++-style comments.

	* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
	(handleEvent): Activate GTK button when the space bar key is
	pressed.
	(gtkActivate): New method.

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

	* java/awt/image/CropImageFilter.java
	(setPixels): Implement for byte array pixels.
	* java/awt/image/ReplicateScaleFilter.java
	(setPixels): Implement for byte array pixels.
	(replicatePixels): Overload for byte array pixels.

2004-05-06  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	(getAccessibleContext): Return an instance of the
	correct class.

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

	* gnu/java/awt/peer/gtk/GdkGraphics.java
	(drawImage): When component is null, use SystemColor.window as
	the default bgcolor.
	* gnu/java/awt/peer/gtk/GtkImage.java
	(setPixels): We can avoid iterating through the pixel rows only
	when height is 1.
	* java/awt/Image.java
	(getScaledInstance): Partially implement.
	* java/awt/image/CropImageFilter.java
	(setProperties): Fix "filter" property.
	(setPixels): Implement.
	* java/awt/image/ReplicateScaleFilter.java
	(setDimensions): Use scaled dimensions.
	(setPixels): Implement.
	(replicatePixels): New method.

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

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(convertPixels): If either pixels or model is null, return null.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
	(Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels): If jpixels
	is null, do nothing and return.

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

	* gnu/java/awt/peer/gtk/GtkDialogPeer.java:
	(getGraphics): Like GtkFramePeer, the Graphics
	object needs to be translate to account for
	window decorations.
	(postMouseEvent): New method. Account for
	translation.
	(postExposeEvent): ditto.
	* javax/swing/Box.java: Stubbed.
	* javax/swing/JDialog.java: Ran through jalopy
	to fix indentation.
	(JDialog): Call SwingUtilities' getOwnerFrame
	for null owners.
	(setLayout): Check isRootPaneCheckingEnabled
	* javax/swing/JOptionPane.java: Re-implemented.
	* javax/swing/SwingUtilities.java:
	(getOwnerFrame): Static method to grab a default
	owner frame for Dialogs that don't specify owners.
	* javax/swing/event/SwingPropertyChangeSupport.java:
	(firePropertyChange): Fix early exit condition.
	* javax/swing/plaf/basic/BasicLabelUI.java:
	(paint): Avoid painting text if it is null
	or empty.
	* javax/swing/plaf/basic/BasicOptionPaneUI.java:
	Implement.

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

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JPopupMenu.java:
	Started implementation.
	* javax/swing/JWindow.java
	(JWindow): call super() if parent for window
	is not specified.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	New File. UI Delegate for JPopupMenu.

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

	* javax/swing/JApplet.java: Indicated that JApplet
	implements RootPaneContainer and made method of this
	interface public.
	* javax/swing/JFrame.java: Ditto.
	* javax/swing/JWindow.java: Ditto.

2004-04-29  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(nativeSetBounds): Call gdk_window_move in addition to
	gtk_window_move.

	* java/applet/Applet.java (preferredSize): Call parent's
	preferredSize if the applet stub is null.
	(minimumSize): Likewise for parent's minimumSize.

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

	* javax/swing/JMenuItem.java
	(createActionPropertyChangeListener): Implemented.
	(processMouseEvent): Ditto.
	(fireMenuDragMouseEntered): Ditto.
	(fireMenuDragMouseExited): Ditto.
	(fireMenuDragMouseDragged): Ditto.
	(fireMenuDragMouseReleased): Ditto.
	(menuSelectionChanged): Ditto.
	(getSubElements): Ditto.
	(getComponent): Ditto.
	(addMenuDragMouseListener): Ditto.
	(removeMenuDragMouseListener):Ditto.
	(addMenuKeyListener): Ditto.
	(removeMenuKeyListener): Ditto.
	* javax/swing/plaf/basic/BasicMenuItemUI.java
	(doClick): Imlemented.
	* javax/swing/plaf/basic/BasicMenuItemUI.MouseInputHandler:
	Don't handle mouse events here. Pass them to
	MenuSelectionManager.

2004-04-26  Olga Rodimina  <rodimina@redhat.com>
	Used correct version of jalopy configuration
	file to fix style in the files below.

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

	* javax/swing/JCheckBoxMenuItem.java:
	Fixed style and removed unnecessary comments.
	* javax/swing/JMenuItem.java: Ditto.
	* javax/swing/JRadioButtonMenuItem.java: Ditto.
	* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java: Ditto.
	* javax/swing/plaf/basic/BasicMenuItemUI.java: Ditto.
	* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java: Ditto.

2004-04-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Change FIXME comment to
	C-style.

	* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Add FIXME comment.

	* java/awt/ContainerOrderFocusTraversalPolicy.java
	(getComponentAfter): Start from current component and work up
	the component hierarchy until an acceptable component is found.
	Synchronize on tree lock.
	(getComponentBefore): Likewise.

2004-04-22  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Remove
	focus-related debugging messages.
	* java/awt/DefaultKeyboardFocusManager.java: Likewise.
	* java/awt/EventDispatchThread.java: Likewise.
	* java/awt/KeyboardFocusManager.java: Likewise.
	* java/awt/Window.java: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Change
	new C++-style comments to C-style comments.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(handleEvent): Dispatch key press and key release events to
	backing widget.
	(requestFocus): Post a FOCUS_GAINED event to the event queue.
	(gtkWidgetRequestFocus): New method.
	(gtkWidgetDispatchKeyEvent): Likewise.
	* java/awt/Component.java (requestFocus, requestFocus(boolean),
	requestFocusInWindow, requestFocusInWindow(boolean),
	getFocusCycleRootAncestor, nextFocus, transferFocus,
	transferFocusBackward, transferFocusUpCycle, hasFocus,
	isFocusOwner): Implement and document focus-handling methods.
	(setFocusTraversalKeys): Inherit focus traversal keys when
	keystrokes argument is null.  Fix focus-handling documentation
	throughout class.
	* java/awt/Container.java (setFocusTraversalKeys,
	getFocusTraversalKeys, areFocusTraversalKeysSet,
	isFocusCycleRoot, setFocusTraversalPolicy,
	getFocusTraversalPolicy, isFocusTraversalPolicySet,
	setFocusCycleRoot, isFocusCycleRoot, transferFocusDownCycle):
	Implement and document focus-handling methods.
	(transferFocusBackward): Remove method.
	(readObject, writeObject): Implement and document serialization
	methods.
	* java/awt/ContainerOrderFocusTraversalPolicy.java: Implement
	and document.
	* java/awt/DefaultFocusTraversalPolicy.java: Implement and
	document.
	* java/awt/DefaultKeyboardFocusManager.java: Implement and
	partially document.
	* java/awt/EventDispatchThread.java (run): Set default keyboard
	focus manager.  Attempt to dispatch each event to the keyboard
	focus manager before normal dispatch.
	* java/awt/KeyboardFocusManager.java: Implement and partially
	document.
	* java/awt/Window.java (Window): Set focusCycleRoot to true.
	(show): Focus initial component when window is shown for the
	first time.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(pre_event_handler): Replace complex key press and key release
	logic with simple callbacks into GtkComponentPeer.
	* jni/gtk-peer/gtkpeer.h: Fix FOCUS_GAINED/FOCUS_LOST reversal.

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

	* javax/swing/MenuSelectionManager.java
	(componentForPoint): Added new method.
	(defaultManager): New Method. Implemented.
	(getSelectedPath): Ditto.
	(isComponentPartOfCurrentMenu): Ditto.
	(processKeyEvent): Added new method.
	(processMouseEvent): New Method. Implemented.
	(setSelectedPath): Ditto.
	(getPath): Ditto.

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

	* java/awt/Container.java:
	(remove): Set the component's parent to null.
	(getComponentAt): Implement.
	* javax/swing/JComponent.java:
	(JComponent): Initialize defaultLocale
	(getDefaultLocale): Implement.
	(setDefaultLocale): ditto.
	* javax/swing/JSlider.java:
	(JSlider): Fix calculation of value.
	* javax/swing/JSplitPane.java: Implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Change SplitPane's default divider size.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	(paint): Remove unused code.
	* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
	Added comments and ran through jalopy.
	(setBasicSplitPaneUI): Get reference to hidden divider
	and set up one touch buttons if necessary.
	(setBorder): Fire propertyChangeEvent only if
	borders are different.
	(getPreferredSize): Defer to layout manager.
	(propertyChange): Implement.
	(oneTouchExpandableChanged): ditto.
	(createLeftOneTouchButton): Use BasicArrowButton.
	(createRightOneTouchButton): ditto.
	(moveDividerTo): New method. Moves the divider
	to a set location based on the last divider location.
	(BasicSplitPaneDivider::MouseHandler): Implement.
	(BasicSplitPaneDivider::OneTouchButton): Removed.
	(BasicSplitPaneDivider::DragController): Implement.
	(BasicSplitPaneDivider::VerticalDragController):
	ditto.
	(BasicSplitPaneDivider::DividerLayout): ditto.
	* javax/swing/plaf/basic/BasicSplitPaneUI.java: Reimplement.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
	(calculateLayoutInfo): Don't show component if it's
	null.
	(paintTab): Fix title paint logic.

From-SVN: r82314
This commit is contained in:
Graydon Hoare 2004-05-27 06:17:44 +00:00
parent e314a036a8
commit c5d2de6b4c
97 changed files with 17329 additions and 5544 deletions

View file

@ -1,3 +1,559 @@
2004-05-25 David Jee <djee@redhat.com>
* java/awt/Container.java
(remove): Set component's parent to null only after we removed the
component from its parent's layout manager.
2004-05-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(GtkComponentPeer): Set bounds regardless of whether awtComponent
is valid.
* gnu/java/awt/peer/gtk/GtkListPeer.java
(getSize): Change native method declaration.
(minimumSize): Pass visible row count into getSize().
(preferredSize): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
(Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize): Use scroll window's
natural size. Use visible row count to determine the final height
value to return.
2004-05-21 Graydon Hoare <graydon@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(setClip): Minor correction to order of operations.
* javax/swing/JScrollPane.java: Extend sketchy implementation.
* javax/swing/ScrollPaneLayout.java: Likewise.
* javax/swing/JViewPort.java: Likewise.
* javax/swing/ViewportLayout.java: Likewise.
* javax/swing/JComponent.java: Rewrite.
* javax/swing/RepaintManager.java: Likewise.
* javax/swing/JLayeredPane.java: Change validate() to revalidate().
* javax/swing/JList.java
(setSelectedIndices):
(getSelectedIndices):
(getSelectedValues): New functions.
(getPreferredScrollableViewportSize): Return preferred size.
(getScrollableUnitIncrement):
(getScrollableBlockIncrement): Initial implementations.
* javax/swing/JRootPane.java: Clean up slightly.
(getUI):
(setUI):
(updateUI):
(getUIClassID):
(isValidateRoot): Add overrides from JComponent.
* javax/swing/JScrollBar.java: Set default orientation to VERTICAL.
* javax/swing/UIManager.java (getDimension): Return the dimension.
* javax/swing/plaf/basic/BasicButtonUI.java: Set component opaque.
* javax/swing/plaf/basic/BasicLabelUI.java: Likewise.
* javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
* javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise.
* javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise.
* javax/swing/plaf/basic/BasicSliderUI.java: Likewise.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise.
* javax/swing/plaf/basic/BasicRootPaneUI.java:
Likewise, and set background.
* javax/swing/plaf/basic/BasicListUI.java:
Likewise, and improve a bit.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Likewise, and adjust calculations.
* javax/swing/plaf/basic/BasicViewportUI.java:
Likewise, and improve a bit.
* javax/swing/plaf/basic/BasicLookAndFeel.java
(Button.margin): Shrink.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
Hack to set horizontal always, workaround pango.
* jni/gtk-peer/gtkcairopeer.h: Change to match pattern API.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
Synchronize more often, check cairo status after ops,
handle changes to cairo pattern API, check for disposal.
2004-05-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(BasicMenuItemUI): Create propertyChangeListener.
(getPath):Implemented.
(installListeners): Add propertyChangeListener to menuItem.
(uninstallListeners): Remove propertyChangeListener from menuItem.
(update): Implemented.
* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
(mouseEntered): Take insets of popup menu into account when
calculating position of popup menu.
2004-05-18 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added new file.
* Makefile.in: Regenerate.
* javax/swing/JMenuBar.java:
Started implementation.
* javax/swing/JPopupMenu.java:
(setVisible): Fixed location of lightweight/mediumweight
popup menu.
(show): Fixed location of PopupMenu.
* javax/swing/plaf/basic/BasicMenuBarUI.java:
New file. UI Delegate for JMenuBar.
* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
(mouseEntered): Corrected position of the submenu.
2004-05-18 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Remove calls
to _gtk_accel_group_attach.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
Likewise.
* gnu/java/awt/peer/gtk/GtkButtonPeer.java: Give gtkSetFont
package access. Don't override setFont.
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java: Likewise.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Give
gtkWidgetRequestFocus package access.
* gnu/java/awt/peer/gtk/GtkLabelPeer.java: Don't override
setFont.
* gnu/java/awt/peer/gtk/GtkListPeer.java: Override gtkSetFont.
Give gtkWidgetRequestFocus package access.
* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java: Give
gtkWidgetRequestFocus package access. Don't override setFont.
* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Don't override
setFont.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(gtkSetLabel): Move call to gtk_bin_get_child into GDK critical
region.
(gtkSetFont): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c (gtkSetFont):
Implement.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
(gtkSetFont): Whitespace fix.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(gtkWidgetSetUsize): Remove method.
2004-05-18 David Jee <djee@redhat.com>
* java/awt/image/MemoryImageSource.java
(newPixels(int,int,int,int,boolean)): Set only the specified
rectangle of pixels.
(newPixels(byte[],ColorModel,int,int)): Implement.
(newPixels(int[],ColorModel,int,int)): Implement.
2004-05-18 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added new file.
* Makefile.in: Regenerate.
* javax/swing/JMenu.java: Started
implementation.
* javax/swing/JPopupMenu.java:
(insert): If specified index is -1, then
add component at the end.
(isPopupTrigger): Reimplemented.
(JPopupMenu.LightWeightPopup): setBounds
of the lightWeightPopup before adding it
to the layeredPane.
(javax/swing/plaf/basic/BasicIconFactory.java):
(getMenuArrowIcon): Implemented.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(getPreferredSize): Add size of the arrow icon
if this menu item is instance of JMenu.
(paintMenuItem): Paint arrow icon if this
menu item is a submenu.
* javax/swing/plaf/basic/BasicMenuUI.java:
New File. UI Delegate for JMenu.
2004-05-17 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (postKeyEvent):
Post KEY_TYPED events.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(generates_key_typed_event): Remove function.
2004-05-17 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JRootPane.java
(JRootPane.RootLayout): Reimplemented to
set bounds of contentPane and menuBar.
(setJMenuBar): Add menu bar to the layered pane.
(createLayeredPane): Set layout of layeredPane
to null.
* javax/swing/JLayeredPane.java:
(addImpl): Calculate index of the component in the
layeredPane according to the specified position within
the layer.
2004-05-17 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkImagePainter.java
(setPixels): Change color model to the default model after
converting pixels.
* java/awt/image/MemoryImageSource.java
(newPixels): Set only the specified rectangle of pixels.
2004-05-13 Thomas Fitzsimmons <fitzsim@redhat.com>
* libgcj.spec.in (lib): Add -l-java-awt -l-java-applet
-l-java-beans -l-javax-accessibility -l-javax-swing.
* java/awt/AWTEvent.java (toString): Print source's name rather
than the source itself.
2004-05-12 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkToolkit.java (loadSystemColors): Make
native.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
(gdk_color_to_java_color): New function.
* jni/gtk-peer/gtkpeer.h: Add SystemColor defines.
2004-05-12 David Jee <djee@redhat.com>
* java/awt/image/RGBImageFilter.java:
Initialize origmodel as null.
(makeColor): Fix pixel component order.
(filterRGBPixels): Fix pixel iteration.
(setPixels): Add extra checks for index color model. Convert pixels
to default color model if necessary.
(convertColorModelToDefault): New override method for byte pixels.
(convertColorModelToDefault): For int pixels, fix pixel iteration.
(makeColorbyDefaultCM): New override method for byte pixels.
(makeColorbyDefaultCM): For int pixel, add color model as argument.
(makeColor): Fix pixel component order.
2004-05-11 Kim Ho <kho@redhat.com>
* javax/swing/Box.java:
Comment out more parts of Box.Filler.
2004-05-11 Kim Ho <kho@redhat.com>
* javax/swing/Box.java:
Remove reference to AccessibleAWTComponent so
it compiles again.
2004-05-10 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkListPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Update
implementation of list peer to use GtkTreeView instead of
deprecated GtkCList.
2004-05-07 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(gtkWidgetDispatchKeyEvent): Remove keyChar parameter.
(handleEvent): Remove keyChar argument to
gtkWidgetDispatchKeyEvent calls.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Fix
compiler warnings.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c:
Likewise.
2004-05-06 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(gtkWidgetRequestFocus): Mark protected.
(GtkComponentPeer): Only set the peer's bounds if its component
is valid.
* java/awt/Component.java (static): Set the default keyboard
focus manager.
(requestFocus(), requestFocus(boolean), requestFocusInWindow(),
requestFocusInWindow(temporary)): Don't request focus if the
component is not showing. Get tree lock before traversing
component hierarchy.
* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
Only set the global focus owner if it is not a Window.
(processKeyEvent): Consume keystrokes associated with the focus
traversal keystroke.
(focusPreviousComponent, focusNextComponent, upFocusCycle,
downFocusCycle): Call requestFocusInWindow instead of
requestFocus.
* java/awt/EventDispatchThread.java (run): Move setting of
default keyboard focus manager to Component.java.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(awt_keycode_to_keysym): New function.
(gtkWidgetDispatchKeyEvent): Finish implementation.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(pre_event_handler): Add FIXME comment.
* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
(gtkWidgetRequestFocus): New method.
* java/awt/TextArea.java (TextArea): Set focus traversal keys to
disable Tab and Shift-Tab keystrokes.
(addNotify, appendText, insertText, replaceText): Simplify peer
retrieval code.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
(connectSignals): Remove connections to "commit" signals.
Remove C++-style comments.
* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(handleEvent): Activate GTK button when the space bar key is
pressed.
(gtkActivate): New method.
2004-05-06 David Jee <djee@redhat.com>
* java/awt/image/CropImageFilter.java
(setPixels): Implement for byte array pixels.
* java/awt/image/ReplicateScaleFilter.java
(setPixels): Implement for byte array pixels.
(replicatePixels): Overload for byte array pixels.
2004-05-06 Kim Ho <kho@redhat.com>
* javax/swing/Box.java:
(getAccessibleContext): Return an instance of the
correct class.
2004-05-05 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java
(drawImage): When component is null, use SystemColor.window as
the default bgcolor.
* gnu/java/awt/peer/gtk/GtkImage.java
(setPixels): We can avoid iterating through the pixel rows only
when height is 1.
* java/awt/Image.java
(getScaledInstance): Partially implement.
* java/awt/image/CropImageFilter.java
(setProperties): Fix "filter" property.
(setPixels): Implement.
* java/awt/image/ReplicateScaleFilter.java
(setDimensions): Use scaled dimensions.
(setPixels): Implement.
(replicatePixels): New method.
2004-05-05 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkImagePainter.java
(convertPixels): If either pixels or model is null, return null.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
(Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels): If jpixels
is null, do nothing and return.
2004-05-03 Kim Ho <kho@redhat.com>
* gnu/java/awt/peer/gtk/GtkDialogPeer.java:
(getGraphics): Like GtkFramePeer, the Graphics
object needs to be translate to account for
window decorations.
(postMouseEvent): New method. Account for
translation.
(postExposeEvent): ditto.
* javax/swing/Box.java: Stubbed.
* javax/swing/JDialog.java: Ran through jalopy
to fix indentation.
(JDialog): Call SwingUtilities' getOwnerFrame
for null owners.
(setLayout): Check isRootPaneCheckingEnabled
* javax/swing/JOptionPane.java: Re-implemented.
* javax/swing/SwingUtilities.java:
(getOwnerFrame): Static method to grab a default
owner frame for Dialogs that don't specify owners.
* javax/swing/event/SwingPropertyChangeSupport.java:
(firePropertyChange): Fix early exit condition.
* javax/swing/plaf/basic/BasicLabelUI.java:
(paint): Avoid painting text if it is null
or empty.
* javax/swing/plaf/basic/BasicOptionPaneUI.java:
Implement.
2004-05-03 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added new file.
* Makefile.in: Regenerate.
* javax/swing/JPopupMenu.java:
Started implementation.
* javax/swing/JWindow.java
(JWindow): call super() if parent for window
is not specified.
* javax/swing/plaf/basic/BasicPopupMenuUI.java:
New File. UI Delegate for JPopupMenu.
2004-04-30 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JApplet.java: Indicated that JApplet
implements RootPaneContainer and made method of this
interface public.
* javax/swing/JFrame.java: Ditto.
* javax/swing/JWindow.java: Ditto.
2004-04-29 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(nativeSetBounds): Call gdk_window_move in addition to
gtk_window_move.
* java/applet/Applet.java (preferredSize): Call parent's
preferredSize if the applet stub is null.
(minimumSize): Likewise for parent's minimumSize.
2004-04-27 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JMenuItem.java
(createActionPropertyChangeListener): Implemented.
(processMouseEvent): Ditto.
(fireMenuDragMouseEntered): Ditto.
(fireMenuDragMouseExited): Ditto.
(fireMenuDragMouseDragged): Ditto.
(fireMenuDragMouseReleased): Ditto.
(menuSelectionChanged): Ditto.
(getSubElements): Ditto.
(getComponent): Ditto.
(addMenuDragMouseListener): Ditto.
(removeMenuDragMouseListener):Ditto.
(addMenuKeyListener): Ditto.
(removeMenuKeyListener): Ditto.
* javax/swing/plaf/basic/BasicMenuItemUI.java
(doClick): Imlemented.
* javax/swing/plaf/basic/BasicMenuItemUI.MouseInputHandler:
Don't handle mouse events here. Pass them to
MenuSelectionManager.
2004-04-26 Olga Rodimina <rodimina@redhat.com>
Used correct version of jalopy configuration
file to fix style in the files below.
2004-04-26 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JCheckBoxMenuItem.java:
Fixed style and removed unnecessary comments.
* javax/swing/JMenuItem.java: Ditto.
* javax/swing/JRadioButtonMenuItem.java: Ditto.
* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java: Ditto.
* javax/swing/plaf/basic/BasicMenuItemUI.java: Ditto.
* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java: Ditto.
2004-04-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Change FIXME comment to
C-style.
* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Add FIXME comment.
* java/awt/ContainerOrderFocusTraversalPolicy.java
(getComponentAfter): Start from current component and work up
the component hierarchy until an acceptable component is found.
Synchronize on tree lock.
(getComponentBefore): Likewise.
2004-04-22 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Remove
focus-related debugging messages.
* java/awt/DefaultKeyboardFocusManager.java: Likewise.
* java/awt/EventDispatchThread.java: Likewise.
* java/awt/KeyboardFocusManager.java: Likewise.
* java/awt/Window.java: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Change
new C++-style comments to C-style comments.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(handleEvent): Dispatch key press and key release events to
backing widget.
(requestFocus): Post a FOCUS_GAINED event to the event queue.
(gtkWidgetRequestFocus): New method.
(gtkWidgetDispatchKeyEvent): Likewise.
* java/awt/Component.java (requestFocus, requestFocus(boolean),
requestFocusInWindow, requestFocusInWindow(boolean),
getFocusCycleRootAncestor, nextFocus, transferFocus,
transferFocusBackward, transferFocusUpCycle, hasFocus,
isFocusOwner): Implement and document focus-handling methods.
(setFocusTraversalKeys): Inherit focus traversal keys when
keystrokes argument is null. Fix focus-handling documentation
throughout class.
* java/awt/Container.java (setFocusTraversalKeys,
getFocusTraversalKeys, areFocusTraversalKeysSet,
isFocusCycleRoot, setFocusTraversalPolicy,
getFocusTraversalPolicy, isFocusTraversalPolicySet,
setFocusCycleRoot, isFocusCycleRoot, transferFocusDownCycle):
Implement and document focus-handling methods.
(transferFocusBackward): Remove method.
(readObject, writeObject): Implement and document serialization
methods.
* java/awt/ContainerOrderFocusTraversalPolicy.java: Implement
and document.
* java/awt/DefaultFocusTraversalPolicy.java: Implement and
document.
* java/awt/DefaultKeyboardFocusManager.java: Implement and
partially document.
* java/awt/EventDispatchThread.java (run): Set default keyboard
focus manager. Attempt to dispatch each event to the keyboard
focus manager before normal dispatch.
* java/awt/KeyboardFocusManager.java: Implement and partially
document.
* java/awt/Window.java (Window): Set focusCycleRoot to true.
(show): Focus initial component when window is shown for the
first time.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(pre_event_handler): Replace complex key press and key release
logic with simple callbacks into GtkComponentPeer.
* jni/gtk-peer/gtkpeer.h: Fix FOCUS_GAINED/FOCUS_LOST reversal.
2004-04-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/MenuSelectionManager.java
(componentForPoint): Added new method.
(defaultManager): New Method. Implemented.
(getSelectedPath): Ditto.
(isComponentPartOfCurrentMenu): Ditto.
(processKeyEvent): Added new method.
(processMouseEvent): New Method. Implemented.
(setSelectedPath): Ditto.
(getPath): Ditto.
2004-04-19 Kim Ho <kho@redhat.com>
* java/awt/Container.java:
(remove): Set the component's parent to null.
(getComponentAt): Implement.
* javax/swing/JComponent.java:
(JComponent): Initialize defaultLocale
(getDefaultLocale): Implement.
(setDefaultLocale): ditto.
* javax/swing/JSlider.java:
(JSlider): Fix calculation of value.
* javax/swing/JSplitPane.java: Implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Change SplitPane's default divider size.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
(paint): Remove unused code.
* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
Added comments and ran through jalopy.
(setBasicSplitPaneUI): Get reference to hidden divider
and set up one touch buttons if necessary.
(setBorder): Fire propertyChangeEvent only if
borders are different.
(getPreferredSize): Defer to layout manager.
(propertyChange): Implement.
(oneTouchExpandableChanged): ditto.
(createLeftOneTouchButton): Use BasicArrowButton.
(createRightOneTouchButton): ditto.
(moveDividerTo): New method. Moves the divider
to a set location based on the last divider location.
(BasicSplitPaneDivider::MouseHandler): Implement.
(BasicSplitPaneDivider::OneTouchButton): Removed.
(BasicSplitPaneDivider::DragController): Implement.
(BasicSplitPaneDivider::VerticalDragController):
ditto.
(BasicSplitPaneDivider::DividerLayout): ditto.
* javax/swing/plaf/basic/BasicSplitPaneUI.java: Reimplement.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
(calculateLayoutInfo): Don't show component if it's
null.
(paintTab): Fix title paint logic.
2004-05-26 Jerry Quinn <jlquinn@optonline.net>
PR libgcj/8321

View file

@ -1325,9 +1325,12 @@ javax/swing/plaf/basic/BasicCheckBoxUI.java \
javax/swing/plaf/basic/BasicGraphicsUtils.java \
javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicMenuUI.java \
javax/swing/plaf/basic/BasicMenuBarUI.java \
javax/swing/plaf/basic/BasicMenuItemUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicPopupMenuUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \

View file

@ -1004,9 +1004,12 @@ javax/swing/plaf/basic/BasicCheckBoxUI.java \
javax/swing/plaf/basic/BasicGraphicsUtils.java \
javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicMenuUI.java \
javax/swing/plaf/basic/BasicMenuBarUI.java \
javax/swing/plaf/basic/BasicMenuItemUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicPopupMenuUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \
@ -4667,9 +4670,12 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicLabelUI.P \
.deps/javax/swing/plaf/basic/BasicListUI.P \
.deps/javax/swing/plaf/basic/BasicLookAndFeel.P \
.deps/javax/swing/plaf/basic/BasicMenuBarUI.P \
.deps/javax/swing/plaf/basic/BasicMenuItemUI.P \
.deps/javax/swing/plaf/basic/BasicMenuUI.P \
.deps/javax/swing/plaf/basic/BasicOptionPaneUI.P \
.deps/javax/swing/plaf/basic/BasicPanelUI.P \
.deps/javax/swing/plaf/basic/BasicPopupMenuUI.P \
.deps/javax/swing/plaf/basic/BasicProgressBarUI.P \
.deps/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.P \
.deps/javax/swing/plaf/basic/BasicRadioButtonUI.P \

View file

@ -46,6 +46,7 @@ import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.SystemColor;
import java.awt.image.ImageObserver;
import java.text.AttributedCharacterIterator;
@ -149,7 +150,10 @@ public class GdkGraphics extends Graphics
return true;
}
return drawImage (img, x, y, component.getBackground (), observer);
if (component != null)
return drawImage (img, x, y, component.getBackground (), observer);
else
return drawImage (img, x, y, SystemColor.window, observer);
}
public boolean drawImage (Image img, int x, int y, int width, int height,
@ -168,8 +172,12 @@ public class GdkGraphics extends Graphics
public boolean drawImage (Image img, int x, int y, int width, int height,
ImageObserver observer)
{
return drawImage (img, x, y, width, height, component.getBackground (),
observer);
if (component != null)
return drawImage (img, x, y, width, height, component.getBackground (),
observer);
else
return drawImage (img, x, y, width, height, SystemColor.window,
observer);
}
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
@ -191,8 +199,12 @@ public class GdkGraphics extends Graphics
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer)
{
return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
component.getBackground (), observer);
if (component != null)
return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
component.getBackground (), observer);
else
return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
SystemColor.window, observer);
}
native public void drawLine (int x1, int y1, int x2, int y2);

View file

@ -823,13 +823,13 @@ public class GdkGraphics2D extends Graphics2D
public void setClip (int x, int y, int width, int height)
{
clip = new Rectangle2D.Double ((double)x, (double)y,
(double)width, (double)height);
setClip(clip);
setClip(new Rectangle2D.Double ((double)x, (double)y,
(double)width, (double)height));
}
public void setClip (Shape s)
{
clip = s;
if (s != null)
{
cairoNewPath ();

View file

@ -54,9 +54,10 @@ public class GtkButtonPeer extends GtkComponentPeer
public native void connectJObject ();
public native void connectSignals ();
native void gtkSetFont(String name, int style, int size);
native void gtkSetFont (String name, int style, int size);
native void gtkSetLabel(String label);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkActivate ();
public GtkButtonPeer (Button b)
{
@ -87,8 +88,11 @@ public class GtkButtonPeer extends GtkComponentPeer
{
KeyEvent ke = (KeyEvent) e;
if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE)
postActionEvent (((Button)awtComponent).getActionCommand (),
ke.getModifiers ());
{
postActionEvent (((Button) awtComponent).getActionCommand (),
ke.getModifiers ());
gtkActivate ();
}
}
super.handleEvent (e);
@ -100,9 +104,4 @@ public class GtkButtonPeer extends GtkComponentPeer
args.add ("label", ((Button)component).getLabel ());
}
public void setFont (Font f)
{
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
}

View file

@ -56,7 +56,7 @@ 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);
native void gtkSetFont (String name, int style, int size);
public native void gtkSetLabel (String label);
public GtkCheckboxPeer (Checkbox c)
@ -87,11 +87,6 @@ public class GtkCheckboxPeer extends GtkComponentPeer
gtkSetLabel (label);
}
public void setFont (Font f)
{
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
public void setCheckboxGroup (CheckboxGroup group)
{
GtkCheckboxGroupPeer gp

View file

@ -54,12 +54,14 @@ import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.ItemSelectable;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.PaintEvent;
@ -91,6 +93,9 @@ 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 gtkWidgetRequestFocus ();
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
int keyCode, int keyLocation);
native void gtkSetFont (String name, int style, int size);
native void gtkWidgetQueueDrawArea(int x, int y, int width, int height);
native void addExposeFilter();
@ -138,10 +143,10 @@ public class GtkComponentPeer extends GtkGenericPeer
awtComponent.getX(),
awtComponent.getY(),
dims[0], dims[1]);
}
}
Rectangle bounds = awtComponent.getBounds ();
setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
} catch (RuntimeException ex) { ; }
}
@ -222,6 +227,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public void handleEvent (AWTEvent event)
{
int id = event.getID();
KeyEvent ke = null;
switch (id)
{
@ -251,6 +257,16 @@ public class GtkComponentPeer extends GtkGenericPeer
}
}
break;
case KeyEvent.KEY_PRESSED:
ke = (KeyEvent) event;
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (),
ke.getKeyCode (), ke.getKeyLocation ());
break;
case KeyEvent.KEY_RELEASED:
ke = (KeyEvent) event;
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (),
ke.getKeyCode (), ke.getKeyLocation ());
break;
}
}
@ -335,7 +351,11 @@ public class GtkComponentPeer extends GtkGenericPeer
new Rectangle (x, y, width, height)));
}
native public void requestFocus ();
public void requestFocus ()
{
gtkWidgetRequestFocus ();
postFocusEvent (FocusEvent.FOCUS_GAINED, false);
}
public void reshape (int x, int y, int width, int height)
{
@ -453,10 +473,28 @@ public class GtkComponentPeer extends GtkGenericPeer
}
protected void postKeyEvent (int id, long when, int mods,
int keyCode, char keyChar, int keyLocation)
int keyCode, char keyChar, int keyLocation)
{
q.postEvent (new KeyEvent (awtComponent, id, when, mods,
keyCode, keyChar, keyLocation));
KeyEvent keyEvent = new KeyEvent (awtComponent, id, when, mods,
keyCode, keyChar, keyLocation);
// Also post a KEY_TYPED event if keyEvent is a key press that
// doesn't represent an action or modifier key.
if (keyEvent.getID () == KeyEvent.KEY_PRESSED
&& (!keyEvent.isActionKey ()
&& keyCode != KeyEvent.VK_SHIFT
&& keyCode != KeyEvent.VK_CONTROL
&& keyCode != KeyEvent.VK_ALT))
{
synchronized (q)
{
q.postEvent (keyEvent);
q.postEvent (new KeyEvent (awtComponent, KeyEvent.KEY_TYPED, when, mods,
KeyEvent.VK_UNDEFINED, keyChar, keyLocation));
}
}
else
q.postEvent (keyEvent);
}
protected void postFocusEvent (int id, boolean temporary)

View file

@ -41,7 +41,10 @@ package gnu.java.awt.peer.gtk;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Graphics;
import java.awt.peer.DialogPeer;
import java.awt.Rectangle;
import java.awt.event.PaintEvent;
public class GtkDialogPeer extends GtkWindowPeer
implements DialogPeer
@ -50,6 +53,33 @@ public class GtkDialogPeer extends GtkWindowPeer
{
super (dialog);
}
public Graphics getGraphics ()
{
Graphics g;
if (GtkToolkit.useGraphics2D ())
g = new GdkGraphics2D (this);
else
g = new GdkGraphics (this);
g.translate (-insets.left, -insets.top);
return g;
}
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
{
super.postMouseEvent (id, when, mods,
x + insets.left, y + insets.top,
clickCount, popupTrigger);
}
protected void postExposeEvent (int x, int y, int width, int height)
{
q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
new Rectangle (x + insets.left,
y + insets.top,
width, height)));
}
void create ()
{

View file

@ -241,7 +241,7 @@ public class GtkImage extends Image implements ImageConsumer
return;
}
if (scansize == width)
if (scansize == width && height == 1)
{
System.arraycopy (pixels, offset,
pixelCache, y * this.width + x,

View file

@ -119,6 +119,11 @@ public class GtkImagePainter implements Runnable, ImageConsumer
static int[]
convertPixels (int[] pixels, ColorModel model)
{
if (pixels == null || model == null)
{
return null;
}
if (model.equals (ColorModel.getRGBdefault ()))
return pixels;
@ -133,6 +138,11 @@ public class GtkImagePainter implements Runnable, ImageConsumer
static int[]
convertPixels (byte[] pixels, ColorModel model)
{
if (pixels == null || model == null)
{
return null;
}
int ret[] = new int[pixels.length];
for (int i = 0; i < pixels.length; i++)
@ -178,8 +188,8 @@ public class GtkImagePainter implements Runnable, ImageConsumer
setPixels (int x, int y, int width, int height, ColorModel model,
byte[] pixels, int offset, int scansize)
{
setPixels (x, y, width, height, model, convertPixels (pixels, model),
offset, scansize);
setPixels (x, y, width, height, ColorModel.getRGBdefault(),
convertPixels (pixels, model), offset, scansize);
}
public void

View file

@ -47,7 +47,7 @@ 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 gtkSetFont (String name, int style, int size);
native void nativeSetAlignment (float alignment);
native public void setText (String text);
@ -63,11 +63,6 @@ public class GtkLabelPeer extends GtkComponentPeer
super (l);
}
public void setFont (Font f)
{
gtkSetFont(f.getName(), f.getStyle(), f.getSize());
}
public void setAlignment (int alignment)
{
nativeSetAlignment (getGtkAlignment (alignment));

View file

@ -48,13 +48,22 @@ import java.awt.peer.ListPeer;
public class GtkListPeer extends GtkComponentPeer
implements ListPeer
{
// native void create (ComponentPeer parent, String [] items, boolean mode);
void create ()
{
List list = (List) awtComponent;
native void create ();
create (list.getRows ());
setMultipleMode (list.isMultipleMode ());
}
native void create (int rows);
native void connectJObject ();
native void connectSignals ();
native void gtkSetFont (String name, int style, int size);
native void gtkWidgetRequestFocus ();
native void getSize (int rows, int dims[]);
native void getSize (int rows, int visibleRows, int dims[]);
public GtkListPeer (List list)
{
@ -100,7 +109,8 @@ public class GtkListPeer extends GtkComponentPeer
{
int dims[] = new int[2];
getSize (rows, dims);
int visibleRows = ((List) awtComponent).getRows();
getSize (rows, visibleRows, dims);
return new Dimension (dims[0], dims[1]);
}
@ -108,7 +118,8 @@ public class GtkListPeer extends GtkComponentPeer
{
int dims[] = new int[2];
getSize (rows, dims);
int visibleRows = ((List) awtComponent).getRows();
getSize (rows, visibleRows, dims);
return new Dimension (dims[0], dims[1]);
}
@ -129,19 +140,19 @@ public class GtkListPeer extends GtkComponentPeer
{
if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ())
{
/* Only generate the ActionEvent on the second click of
a multiple click */
// Only generate the ActionEvent on the second click of a
// multiple click.
MouseEvent me = (MouseEvent) e;
if (!me.isConsumed ()
&& (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0
&& me.getClickCount() == 2)
{
String selectedItem = ((List)awtComponent).getSelectedItem ();
String selectedItem = ((List) awtComponent).getSelectedItem ();
/* Double-click only generates an Action event
if something is selected */
// Double-click only generates an Action event if
// something is selected.
if (selectedItem != null)
postActionEvent (((List)awtComponent).getSelectedItem (),
postActionEvent (((List) awtComponent).getSelectedItem (),
me.getModifiers ());
}
}
@ -151,9 +162,10 @@ public class GtkListPeer extends GtkComponentPeer
KeyEvent ke = (KeyEvent) e;
if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_ENTER)
{
String selectedItem = ((List)awtComponent).getSelectedItem ();
String selectedItem = ((List) awtComponent).getSelectedItem ();
/* Enter only generates an Action event if something is selected */
// Enter only generates an Action event if something is
// selected.
if (selectedItem != null)
postActionEvent (selectedItem, ke.getModifiers ());
}

View file

@ -50,6 +50,7 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
native void create (int width, int height, int scrollbarVisibility);
native void gtkSetFont (String name, int style, int size);
native void gtkWidgetRequestFocus ();
void create ()
{
@ -171,9 +172,4 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
{
insert (str, pos);
}
public void setFont (Font f)
{
gtkSetFont (f.getName (), f.getStyle (), f.getSize ());
}
}

View file

@ -154,11 +154,6 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
setEchoChar (c);
}
public void setFont (Font f)
{
gtkSetFont (f.getName (), f.getStyle (), f.getSize ());
}
public void handleEvent (AWTEvent e)
{
if (e.getID () == KeyEvent.KEY_PRESSED)

View file

@ -428,9 +428,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return q;
}
protected void loadSystemColors (int[] systemColors)
{
}
protected native void loadSystemColors (int[] systemColors);
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
{

View file

@ -483,7 +483,7 @@ public class Applet extends Panel
*/
public Dimension preferredSize()
{
return getDimensions ();
return stub == null ? super.preferredSize () : getDimensions ();
}
/**
@ -494,7 +494,7 @@ public class Applet extends Panel
*/
public Dimension minimumSize()
{
return getDimensions ();
return stub == null ? super.minimumSize () : getDimensions ();
}
/**

View file

@ -231,15 +231,15 @@ public abstract class AWTEvent extends EventObject
}
/**
* Returns a string representation of this event. This is in the format
* <code>getClass().getName() + '[' + paramString() + "] on "
* + source</code>.
* Create a string that represents this event in the format
* <code>classname[eventstring] on sourcecomponentname</code>.
*
* @return a string representation of this event
* @return a string representing this event
*/
public String toString()
public String toString ()
{
return getClass().getName() + "[" + paramString() + "] on " + source;
return getClass ().getName () + "[" + paramString () + "] on "
+ ((Component) source).getName ();
}
/**

View file

@ -383,18 +383,18 @@ public abstract class Component
boolean focusable = true;
/**
* Tracks whether this component uses default focus traversal, or has a
* different policy.
* Tracks whether this component's {@link #isFocusTraversable}
* method has been overridden.
*
* @see #isFocusTraversableOverridden()
* @since 1.4
*/
int isFocusTraversableOverridden;
/**
* The focus traversal keys, if not inherited from the parent or default
* keyboard manager. These sets will contain only AWTKeyStrokes that
* represent press and release events to use as focus control.
* The focus traversal keys, if not inherited from the parent or
* default keyboard focus manager. These sets will contain only
* AWTKeyStrokes that represent press and release events to use as
* focus control.
*
* @see #getFocusTraversalKeys(int)
* @see #setFocusTraversalKeys(int, Set)
@ -556,6 +556,12 @@ public abstract class Component
*/
transient BufferStrategy bufferStrategy;
/**
* true if requestFocus was called on this component when its
* top-level ancestor was not focusable.
*/
private transient FocusEvent pendingFocusRequest = null;
/**
* The system properties that affect image updating.
*/
@ -566,6 +572,8 @@ public abstract class Component
{
incrementalDraw = Boolean.getBoolean ("awt.image.incrementalDraw");
redrawRate = Long.getLong ("awt.image.redrawrate");
// Set the default KeyboardFocusManager.
KeyboardFocusManager.setCurrentKeyboardFocusManager (null);
}
// Public and protected API.
@ -2963,6 +2971,7 @@ public abstract class Component
{
if (focusListener == null)
return;
switch (e.id)
{
case FocusEvent.FOCUS_GAINED:
@ -3411,13 +3420,18 @@ public abstract class Component
}
/**
* Sets the focus traversal keys for a given type of focus events. Normally,
* the default values should match the operating system's native choices. To
* disable a given traversal, use <code>Collections.EMPTY_SET</code>. The
* event dispatcher will consume PRESSED, RELEASED, and TYPED events for the
* specified key, although focus can only transfer on PRESSED or RELEASED.
* Sets the focus traversal keys for one of the three focus
* traversal directions supported by Components: {@link
* #KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS}, {@link
* #KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS}, or {@link
* #KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS}. Normally, the
* default values should match the operating system's native
* choices. To disable a given traversal, use
* <code>Collections.EMPTY_SET</code>. The event dispatcher will
* consume PRESSED, RELEASED, and TYPED events for the specified
* key, although focus can only transfer on PRESSED or RELEASED.
*
* <p>The defauts are:
* <p>The defaults are:
* <table>
* <th><td>Identifier</td><td>Meaning</td><td>Default</td></th>
* <tr><td>KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS</td>
@ -3430,10 +3444,13 @@ public abstract class Component
* <td>Go up a traversal cycle</td><td>None</td></tr>
* </table>
*
* <p>Specifying null allows inheritance from the parent, or from the current
* KeyboardFocusManager default set. If not null, the set must contain only
* AWTKeyStrokes that are not already focus keys and are not KEY_TYPED
* events.
* If keystrokes is null, this component's focus traversal key set
* is inherited from one of its ancestors. If none of its ancestors
* has its own set of focus traversal keys, the focus traversal keys
* are set to the defaults retrieved from the current
* KeyboardFocusManager. If not null, the set must contain only
* AWTKeyStrokes that are not already focus keys and are not
* KEY_TYPED events.
*
* @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or
* UP_CYCLE_TRAVERSAL_KEYS
@ -3448,7 +3465,24 @@ public abstract class Component
public void setFocusTraversalKeys(int id, Set keystrokes)
{
if (keystrokes == null)
throw new IllegalArgumentException();
{
Container parent = getParent ();
while (parent != null)
{
if (parent.areFocusTraversalKeysSet (id))
{
keystrokes = parent.getFocusTraversalKeys (id);
break;
}
parent = parent.getParent ();
}
if (keystrokes == null)
keystrokes = KeyboardFocusManager.getCurrentKeyboardFocusManager ().
getDefaultFocusTraversalKeys (id);
}
Set sa;
Set sb;
String name;
@ -3476,50 +3510,60 @@ public abstract class Component
name = "upCycleFocusTraversalKeys";
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
}
int i = keystrokes.size();
Iterator iter = keystrokes.iterator();
int i = keystrokes.size ();
Iterator iter = keystrokes.iterator ();
while (--i >= 0)
{
Object o = iter.next();
if (! (o instanceof AWTKeyStroke)
|| sa.contains(o) || sb.contains(o)
Object o = iter.next ();
if (!(o instanceof AWTKeyStroke)
|| sa.contains (o) || sb.contains (o)
|| ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
}
if (focusTraversalKeys == null)
focusTraversalKeys = new Set[3];
keystrokes = Collections.unmodifiableSet(new HashSet(keystrokes));
firePropertyChange(name, focusTraversalKeys[id], keystrokes);
keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
firePropertyChange (name, focusTraversalKeys[id], keystrokes);
focusTraversalKeys[id] = keystrokes;
}
/**
* Returns the set of keys for a given focus traversal action, as defined
* in <code>setFocusTraversalKeys</code>. If not set, this is inherited from
* the parent component, which may have gotten it from the
* KeyboardFocusManager.
* Returns the set of keys for a given focus traversal action, as
* defined in <code>setFocusTraversalKeys</code>. If not set, this
* is inherited from the parent component, which may have gotten it
* from the KeyboardFocusManager.
*
* @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or
* UP_CYCLE_TRAVERSAL_KEYS
* @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
* or UP_CYCLE_TRAVERSAL_KEYS
* @throws IllegalArgumentException if id is invalid
* @see #setFocusTraversalKeys(int, Set)
* @see #setFocusTraversalKeys (int, Set)
* @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
* @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
* @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
* @since 1.4
*/
public Set getFocusTraversalKeys(int id)
public Set getFocusTraversalKeys (int id)
{
if (id < KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
|| id > KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException();
Set s = null;
if (focusTraversalKeys != null)
s = focusTraversalKeys[id];
if (s == null && parent != null)
s = parent.getFocusTraversalKeys(id);
s = parent.getFocusTraversalKeys (id);
return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalKeys(id)) : s;
}
@ -3528,269 +3572,417 @@ public abstract class Component
* Tests whether the focus traversal keys for a given action are explicitly
* set or inherited.
*
* @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or
* UP_CYCLE_TRAVERSAL_KEYS
* @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
* or UP_CYCLE_TRAVERSAL_KEYS
* @return true if that set is explicitly specified
* @throws IllegalArgumentException if id is invalid
* @see #getFocusTraversalKeys(int)
* @see #getFocusTraversalKeys (int)
* @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
* @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
* @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
* @since 1.4
*/
public boolean areFocusTraversalKeysSet(int id)
public boolean areFocusTraversalKeysSet (int id)
{
if (id < KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
|| id > KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException();
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
return focusTraversalKeys != null && focusTraversalKeys[id] != null;
}
/**
* Sets whether focus traversal keys are enabled, which consumes traversal
* keys and performs the focus event automatically.
* Enable or disable focus traversal keys on this Component. If
* they are, then the keyboard focus manager consumes and acts on
* key press and release events that trigger focus traversal, and
* discards the corresponding key typed events. If focus traversal
* keys are disabled, then all key events that would otherwise
* trigger focus traversal are sent to this Component.
*
* @param focusTraversalKeysEnabled the new value of the flag
* @see #getFocusTraversalKeysEnabled()
* @see #setFocusTraversalKeys(int, Set)
* @see #getFocusTraversalKeys(int)
* @see #getFocusTraversalKeysEnabled ()
* @see #setFocusTraversalKeys (int, Set)
* @see #getFocusTraversalKeys (int)
* @since 1.4
*/
public void setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)
public void setFocusTraversalKeysEnabled (boolean focusTraversalKeysEnabled)
{
firePropertyChange("focusTraversalKeysEnabled",
this.focusTraversalKeysEnabled,
focusTraversalKeysEnabled);
firePropertyChange ("focusTraversalKeysEnabled",
this.focusTraversalKeysEnabled,
focusTraversalKeysEnabled);
this.focusTraversalKeysEnabled = focusTraversalKeysEnabled;
}
/**
* Tests whether focus traversal keys are enabled. If they are, then focus
* traversal keys are consumed and focus events performed automatically,
* without the component seeing the keystrokes.
* Check whether or not focus traversal keys are enabled on this
* Component. If they are, then the keyboard focus manager consumes
* and acts on key press and release events that trigger focus
* traversal, and discards the corresponding key typed events. If
* focus traversal keys are disabled, then all key events that would
* otherwise trigger focus traversal are sent to this Component.
*
* @return true if focus traversal is enabled
* @see #setFocusTraversalKeysEnabled(boolean)
* @see #setFocusTraversalKeys(int, Set)
* @see #getFocusTraversalKeys(int)
* @return true if focus traversal keys are enabled
* @see #setFocusTraversalKeysEnabled (boolean)
* @see #setFocusTraversalKeys (int, Set)
* @see #getFocusTraversalKeys (int)
* @since 1.4
*/
public boolean getFocusTraversalKeysEnabled()
public boolean getFocusTraversalKeysEnabled ()
{
return focusTraversalKeysEnabled;
}
/**
* Requests that this component be given focus. A <code>FOCUS_GAINED</code>
* event will be fired if and only if this request is successful. To be
* successful, the component must be displayable, visible, and focusable,
* and the top-level Window must be able to receive focus. Thus, this
* request may fail, or be delayed until the window receives focus. It is
* recommended that <code>requestFocusInWindow</code> be used where
* possible to be more platform-independent.
* Request that this Component be given the keyboard input focus and
* that its top-level ancestor become the focused Window.
*
* @see #requestFocusInWindow()
* For the request to be granted, the Component must be focusable,
* displayable and showing and the top-level Window to which it
* belongs must be focusable. If the request is initially denied on
* the basis that the top-level Window is not focusable, the request
* will be remembered and granted when the Window does become
* focused.
*
* Never assume that this Component is the focus owner until it
* receives a FOCUS_GAINED event.
*
* The behaviour of this method is platform-dependent.
* {@link #requestFocusInWindow} should be used instead.
*
* @see #requestFocusInWindow ()
* @see FocusEvent
* @see #addFocusListener(FocusListener)
* @see #isFocusable()
* @see #isDisplayable()
* @see KeyboardFocusManager#clearGlobalFocusOwner()
* @see #addFocusListener (FocusListener)
* @see #isFocusable ()
* @see #isDisplayable ()
* @see KeyboardFocusManager#clearGlobalFocusOwner ()
*/
public void requestFocus()
public void requestFocus ()
{
// If there's no peer then this component can't get the focus. We
// treat it as a silent rejection of the request.
if (peer != null)
peer.requestFocus();
if (isDisplayable ()
&& isShowing ()
&& isFocusable ())
{
synchronized (getTreeLock ())
{
// Find this Component's top-level ancestor.
Container parent = getParent ();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
if (peer != null)
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
peer.requestFocus ();
else
{
// Either our peer hasn't been created yet or we're a
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED));
}
}
else
pendingFocusRequest = new FocusEvent(this, FocusEvent.FOCUS_GAINED);
}
}
}
/**
* Requests that this component be given focus. A <code>FOCUS_GAINED</code>
* event will be fired if and only if this request is successful. To be
* successful, the component must be displayable, visible, and focusable,
* and the top-level Window must be able to receive focus. Thus, this
* request may fail, or be delayed until the window receives focus. It is
* recommended that <code>requestFocusInWindow</code> be used where
* possible to be more platform-independent.
* Request that this Component be given the keyboard input focus and
* that its top-level ancestor become the focused Window.
*
* <p>If the return value is false, the request is guaranteed to fail. If
* it is true, it will likely succeed unless the action is vetoed or
* something in the native windowing system intervenes. The temporary flag,
* and thus this method in general, is not designed for public use; rather
* it is a hook for lightweight components to notify their container in
* an attempt to reduce the amount of repainting necessary.
* For the request to be granted, the Component must be focusable,
* displayable and showing and the top-level Window to which it
* belongs must be focusable. If the request is initially denied on
* the basis that the top-level Window is not focusable, the request
* will be remembered and granted when the Window does become
* focused.
*
* Never assume that this Component is the focus owner until it
* receives a FOCUS_GAINED event.
*
* The behaviour of this method is platform-dependent.
* {@link #requestFocusInWindow} should be used instead.
*
* If the return value is false, the request is guaranteed to fail.
* If the return value is true, the request will succeed unless it
* is vetoed or something in the native windowing system intervenes,
* preventing this Component's top-level ancestor from becoming
* focused. This method is meant to be called by derived
* lightweight Components that want to avoid unnecessary repainting
* when they know a given focus transfer need only be temporary.
*
* @param temporary true if the focus request is temporary
* @return true if the request has a chance of success
* @see #requestFocusInWindow()
* @see #requestFocusInWindow ()
* @see FocusEvent
* @see #addFocusListener(FocusListener)
* @see #isFocusable()
* @see #isDisplayable()
* @see KeyboardFocusManager#clearGlobalFocusOwner()
* @see #addFocusListener (FocusListener)
* @see #isFocusable ()
* @see #isDisplayable ()
* @see KeyboardFocusManager#clearGlobalFocusOwner ()
* @since 1.4
*/
protected boolean requestFocus(boolean temporary)
protected boolean requestFocus (boolean temporary)
{
// XXX Implement correctly.
requestFocus();
if (isDisplayable ()
&& isShowing ()
&& isFocusable ())
{
synchronized (getTreeLock ())
{
// Find this Component's top-level ancestor.
Container parent = getParent ();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
if (peer != null)
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
peer.requestFocus ();
else
{
// Either our peer hasn't been created yet or we're a
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
else
// FIXME: need to add a focus listener to our top-level
// ancestor, so that we can post this event when it becomes
// the focused window.
pendingFocusRequest = new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary);
}
}
// Always return true.
return true;
}
/**
* Requests that this component be given focus, if it resides in the
* top-level window which already has focus. A <code>FOCUS_GAINED</code>
* event will be fired if and only if this request is successful. To be
* successful, the component must be displayable, visible, and focusable,
* and the top-level Window must be focused.
* Request that this component be given the keyboard input focus, if
* its top-level ancestor is the currently focused Window. A
* <code>FOCUS_GAINED</code> event will be fired if and only if this
* request is successful. To be successful, the component must be
* displayable, showing, and focusable, and its ancestor top-level
* Window must be focused.
*
* <p>If the return value is false, the request is guaranteed to fail. If
* it is true, it will likely succeed unless the action is vetoed or
* something in the native windowing system intervenes. The temporary flag,
* and thus this method in general, is not designed for public use; rather
* it is a hook for lightweight components to notify their container in
* an attempt to reduce the amount of repainting necessary.
* If the return value is false, the request is guaranteed to fail.
* If the return value is true, the request will succeed unless it
* is vetoed or something in the native windowing system intervenes,
* preventing this Component's top-level ancestor from becoming
* focused.
*
* @return true if the request has a chance of success
* @see #requestFocus()
* @see #requestFocus ()
* @see FocusEvent
* @see #addFocusListener(FocusListener)
* @see #isFocusable()
* @see #isDisplayable()
* @see KeyboardFocusManager#clearGlobalFocusOwner()
* @see #addFocusListener (FocusListener)
* @see #isFocusable ()
* @see #isDisplayable ()
* @see KeyboardFocusManager#clearGlobalFocusOwner ()
* @since 1.4
*/
public boolean requestFocusInWindow()
public boolean requestFocusInWindow ()
{
// XXX Implement correctly.
requestFocus();
return true;
return requestFocusInWindow (false);
}
/**
* Requests that this component be given focus, if it resides in the
* top-level window which already has focus. A <code>FOCUS_GAINED</code>
* event will be fired if and only if this request is successful. To be
* successful, the component must be displayable, visible, and focusable,
* and the top-level Window must be focused.
* Request that this component be given the keyboard input focus, if
* its top-level ancestor is the currently focused Window. A
* <code>FOCUS_GAINED</code> event will be fired if and only if this
* request is successful. To be successful, the component must be
* displayable, showing, and focusable, and its ancestor top-level
* Window must be focused.
*
* <p>If the return value is false, the request is guaranteed to fail. If
* it is true, it will likely succeed unless the action is vetoed or
* something in the native windowing system intervenes. The temporary flag,
* and thus this method in general, is not designed for public use; rather
* it is a hook for lightweight components to notify their container in
* an attempt to reduce the amount of repainting necessary.
* If the return value is false, the request is guaranteed to fail.
* If the return value is true, the request will succeed unless it
* is vetoed or something in the native windowing system intervenes,
* preventing this Component's top-level ancestor from becoming
* focused. This method is meant to be called by derived
* lightweight Components that want to avoid unnecessary repainting
* when they know a given focus transfer need only be temporary.
*
* @param temporary true if the focus request is temporary
* @return true if the request has a chance of success
* @see #requestFocus()
* @see #requestFocus ()
* @see FocusEvent
* @see #addFocusListener(FocusListener)
* @see #isFocusable()
* @see #isDisplayable()
* @see KeyboardFocusManager#clearGlobalFocusOwner()
* @see #addFocusListener (FocusListener)
* @see #isFocusable ()
* @see #isDisplayable ()
* @see KeyboardFocusManager#clearGlobalFocusOwner ()
* @since 1.4
*/
protected boolean requestFocusInWindow(boolean temporary)
protected boolean requestFocusInWindow (boolean temporary)
{
// XXX Implement correctly.
requestFocus();
return true;
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Window focusedWindow = manager.getFocusedWindow ();
if (isDisplayable ()
&& isShowing ()
&& isFocusable ())
{
if (focusedWindow != null)
{
synchronized (getTreeLock ())
{
Container parent = getParent ();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
Window toplevel = (Window) parent;
// Check if top-level ancestor is currently focused window.
if (focusedWindow == toplevel)
{
if (peer != null)
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
peer.requestFocus ();
else
{
// Either our peer hasn't been created yet or we're a
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
else
return false;
}
}
return true;
}
return false;
}
/**
* Transfers focus to the next component in the focus traversal order, as
* though this were the current focus owner.
* Transfers focus to the next component in the focus traversal
* order, as though this were the current focus owner.
*
* @see #requestFocus()
* @since 1.1
*/
public void transferFocus()
public void transferFocus ()
{
Component next;
if (parent == null)
next = findNextFocusComponent(null);
else
next = parent.findNextFocusComponent(this);
if (next != null && next != this)
next.requestFocus();
nextFocus ();
}
/**
* Returns the root container that owns the focus cycle where this component
* resides. A focus cycle root is in two cycles, one as the ancestor, and
* one as the focusable element; this call always returns the ancestor.
* Returns the root container that owns the focus cycle where this
* component resides. A focus cycle root is in two cycles, one as
* the ancestor, and one as the focusable element; this call always
* returns the ancestor.
*
* @return the ancestor container that owns the focus cycle
* @since 1.4
*/
public Container getFocusCycleRootAncestor()
public Container getFocusCycleRootAncestor ()
{
// XXX Implement.
throw new Error("not implemented");
if (this instanceof Window
&& ((Container) this).isFocusCycleRoot ())
return (Container) this;
Container parent = getParent ();
while (parent != null
&& !parent.isFocusCycleRoot ())
parent = parent.getParent ();
return parent;
}
/**
* Tests if the container is the ancestor of the focus cycle that this
* component belongs to.
* Tests if the container is the ancestor of the focus cycle that
* this component belongs to.
*
* @param c the container to test
* @return true if c is the focus cycle root
* @since 1.4
*/
public boolean isFocusCycleRoot(Container c)
public boolean isFocusCycleRoot (Container c)
{
return c == getFocusCycleRootAncestor();
return c == getFocusCycleRootAncestor ();
}
/**
* AWT 1.0 focus event processor.
* AWT 1.0 focus event processor. Transfers focus to the next
* component in the focus traversal order, as though this were the
* current focus owner.
*
* @deprecated use {@link #transferFocus()} instead
* @deprecated use {@link #transferFocus ()} instead
*/
public void nextFocus()
public void nextFocus ()
{
transferFocus();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.focusNextComponent (this);
}
/**
* Transfers focus to the previous component in the focus traversal order, as
* though this were the current focus owner.
* Transfers focus to the previous component in the focus traversal
* order, as though this were the current focus owner.
*
* @see #requestFocus()
* @see #requestFocus ()
* @since 1.4
*/
public void transferFocusBackward()
public void transferFocusBackward ()
{
// XXX Implement.
throw new Error("not implemented");
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.focusPreviousComponent (this);
}
/**
* Transfers focus to the focus cycle root of this component. However, if
* this is a Window, the default focus owner in the window in the current
* focus cycle is focused instead.
* Transfers focus to the focus cycle root of this component.
* However, if this is a Window, the default focus owner in the
* window in the current focus cycle is focused instead.
*
* @see #requestFocus()
* @see #isFocusCycleRoot()
* @see #requestFocus ()
* @see #isFocusCycleRoot ()
* @since 1.4
*/
public void transferFocusUpCycle()
public void transferFocusUpCycle ()
{
// XXX Implement.
throw new Error("not implemented");
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.upFocusCycle (this);
}
/**
* Tests if this component is the focus owner. Use {@link #isFocusOwner()}
* instead.
* Tests if this component is the focus owner. Use {@link
* #isFocusOwner ()} instead.
*
* @return true if this component owns focus
* @since 1.2
*/
public boolean hasFocus()
public boolean hasFocus ()
{
return isFocusOwner();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Component focusOwner = manager.getFocusOwner ();
return this == focusOwner;
}
/**
@ -3801,8 +3993,7 @@ public abstract class Component
*/
public boolean isFocusOwner()
{
// XXX Implement.
throw new Error("not implemented");
return hasFocus ();
}
/**
@ -4337,6 +4528,8 @@ p * <li>the set of backward traversal keys
* making the request. This is overridden by Container; when called for an
* ordinary component there is no child and so we always return null.
*
* FIXME: is this still needed, in light of focus traversal policies?
*
* @param child the component making the request
* @return the next component to focus on
*/
@ -4897,23 +5090,23 @@ p * <li>the set of backward traversal keys
* Tests whether this component can accept focus.
*
* @return true if this is focus traversable
* @see #getAccessibleStateSet()
* @see #getAccessibleStateSet ()
* @see AccessibleState#FOCUSABLE
* @see AccessibleState#FOCUSED
*/
public boolean isFocusTraversable()
public boolean isFocusTraversable ()
{
return Component.this.isFocusTraversable();
return Component.this.isFocusTraversable ();
}
/**
* Requests focus for this component.
*
* @see #isFocusTraversable()
* @see #isFocusTraversable ()
*/
public void requestFocus()
public void requestFocus ()
{
Component.this.requestFocus();
Component.this.requestFocus ();
}
/**

View file

@ -46,10 +46,16 @@ import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.Collections;
import java.util.EventListener;
import java.util.Iterator;
import java.util.HashSet;
import java.util.Set;
import javax.accessibility.Accessible;
import javax.swing.SwingUtilities;
@ -93,6 +99,21 @@ public class Container extends Component
transient ContainerListener containerListener;
transient PropertyChangeSupport changeSupport;
/** The focus traversal policy that determines how focus is
transferred between this Container and its children. */
private FocusTraversalPolicy focusTraversalPolicy;
/**
* The focus traversal keys, if not inherited from the parent or default
* keyboard manager. These sets will contain only AWTKeyStrokes that
* represent press and release events to use as focus control.
*
* @see #getFocusTraversalKeys(int)
* @see #setFocusTraversalKeys(int, Set)
* @since 1.4
*/
transient Set[] focusTraversalKeys;
/**
* Default constructor for subclasses.
*/
@ -397,6 +418,8 @@ public class Container extends Component
if (layoutMgr != null)
layoutMgr.removeLayoutComponent(r);
r.parent = null;
// Post event to notify of adding the container.
ContainerEvent ce = new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
@ -853,6 +876,11 @@ public class Container extends Component
{
return locate (x, y);
}
public Component getComponentAt(int index)
{
return component[index];
}
/**
* Returns the component located at the specified point. This is done
@ -1068,9 +1096,89 @@ public class Container extends Component
throw new IllegalArgumentException ();
if (keystrokes == null)
throw new IllegalArgumentException ();
{
Container parent = getParent ();
throw new Error ("not implemented");
while (parent != null)
{
if (parent.areFocusTraversalKeysSet (id))
{
keystrokes = parent.getFocusTraversalKeys (id);
break;
}
parent = parent.getParent ();
}
if (keystrokes == null)
keystrokes = KeyboardFocusManager.getCurrentKeyboardFocusManager ().
getDefaultFocusTraversalKeys (id);
}
Set sa;
Set sb;
Set sc;
String name;
switch (id)
{
case KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS:
sa = getFocusTraversalKeys
(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
sb = getFocusTraversalKeys
(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
sc = getFocusTraversalKeys
(KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
name = "forwardFocusTraversalKeys";
break;
case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:
sa = getFocusTraversalKeys
(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
sb = getFocusTraversalKeys
(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
sc = getFocusTraversalKeys
(KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
name = "backwardFocusTraversalKeys";
break;
case KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS:
sa = getFocusTraversalKeys
(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
sb = getFocusTraversalKeys
(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
sc = getFocusTraversalKeys
(KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
name = "upCycleFocusTraversalKeys";
break;
case KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS:
sa = getFocusTraversalKeys
(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
sb = getFocusTraversalKeys
(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
sc = getFocusTraversalKeys
(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
name = "downCycleFocusTraversalKeys";
break;
default:
throw new IllegalArgumentException ();
}
int i = keystrokes.size ();
Iterator iter = keystrokes.iterator ();
while (--i >= 0)
{
Object o = iter.next ();
if (!(o instanceof AWTKeyStroke)
|| sa.contains (o) || sb.contains (o) || sc.contains (o)
|| ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
throw new IllegalArgumentException ();
}
if (focusTraversalKeys == null)
focusTraversalKeys = new Set[3];
keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
firePropertyChange (name, focusTraversalKeys[id], keystrokes);
focusTraversalKeys[id] = keystrokes;
}
/**
@ -1085,7 +1193,7 @@ public class Container extends Component
*
* @since 1.4
*/
public Set getFocusTraversalKeys(int id)
public Set getFocusTraversalKeys (int id)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@ -1093,9 +1201,18 @@ public class Container extends Component
id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
return null;
Set s = null;
if (focusTraversalKeys != null)
s = focusTraversalKeys[id];
if (s == null && parent != null)
s = parent.getFocusTraversalKeys (id);
return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalKeys(id)) : s;
}
/**
* Returns whether the Set of focus traversal keys for the given focus
* traversal operation has been explicitly defined for this Container.
@ -1110,7 +1227,7 @@ public class Container extends Component
*
* @since 1.4
*/
public boolean areFocusTraversalKeysSet(int id)
public boolean areFocusTraversalKeysSet (int id)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@ -1118,43 +1235,148 @@ public class Container extends Component
id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
return focusTraversalKeys != null && focusTraversalKeys[id] != null;
}
/**
* Check whether the given Container is the focus cycle root of this
* Container's focus traversal cycle. If this Container is a focus
* cycle root itself, then it will be in two different focus cycles
* -- it's own, and that of its ancestor focus cycle root's. In
* that case, if <code>c</code> is either of those containers, this
* method will return true.
*
* @param c the candidate Container
*
* @return true if c is the focus cycle root of the focus traversal
* cycle to which this Container belongs, false otherwise
*
* @since 1.4
*/
public boolean isFocusCycleRoot (Container c)
{
if (this == c
&& isFocusCycleRoot ())
return true;
Container ancestor = getFocusCycleRootAncestor ();
if (c == ancestor)
return true;
return false;
}
public boolean isFocusCycleRoot(Container c)
/**
* If this Container is a focus cycle root, set the focus traversal
* policy that determines the focus traversal order for its
* children. If non-null, this policy will be inherited by all
* inferior focus cycle roots. If <code>policy</code> is null, this
* Container will inherit its policy from the closest ancestor focus
* cycle root that's had its policy set.
*
* @param policy the new focus traversal policy for this Container or null
*
* @since 1.4
*/
public void setFocusTraversalPolicy (FocusTraversalPolicy policy)
{
return false;
focusTraversalPolicy = policy;
}
public void transferFocusBackward()
/**
* Return the focus traversal policy that determines the focus
* traversal order for this Container's children. This method
* returns null if this Container is not a focus cycle root. If the
* focus traversal policy has not been set explicitly, then this
* method will return an ancestor focus cycle root's policy instead.
*
* @return this Container's focus traversal policy or null
*
* @since 1.4
*/
public FocusTraversalPolicy getFocusTraversalPolicy ()
{
if (!isFocusCycleRoot ())
return null;
if (focusTraversalPolicy == null)
{
Container ancestor = getFocusCycleRootAncestor ();
if (ancestor != this)
return ancestor.getFocusTraversalPolicy ();
else
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
return manager.getDefaultFocusTraversalPolicy ();
}
}
else
return focusTraversalPolicy;
}
public void setFocusTraversalPolicy(FocusTraversalPolicy policy)
/**
* Check whether this Container's focus traversal policy has been
* explicitly set. If it has not, then this Container will inherit
* its focus traversal policy from one of its ancestor focus cycle
* roots.
*
* @return true if focus traversal policy is set, false otherwise
*/
public boolean isFocusTraversalPolicySet ()
{
return focusTraversalPolicy == null;
}
public FocusTraversalPolicy getFocusTraversalPolicy()
/**
* Set whether or not this Container is the root of a focus
* traversal cycle. This Container's focus traversal policy
* determines the order of focus traversal. Some policies prevent
* the focus from being transferred between two traversal cycles
* until an up or down traversal operation is performed. In that
* case, normal traversal (not up or down) is limited to this
* Container and all of this Container's descendents that are not
* descendents of inferior focus cycle roots. In the default case
* however, ContainerOrderFocusTraversalPolicy is in effect, and it
* supports implicit down-cycle traversal operations.
*
* @return true if this is a focus cycle root, false otherwise
*
* @since 1.4
*/
public void setFocusCycleRoot (boolean focusCycleRoot)
{
return null;
this.focusCycleRoot = focusCycleRoot;
}
public boolean isFocusTraversalPolicySet()
/**
* Check whether this Container is a focus cycle root.
*
* @return true if this is a focus cycle root, false otherwise
*
* @since 1.4
*/
public boolean isFocusCycleRoot ()
{
return false;
return focusCycleRoot;
}
public void setFocusCycleRoot(boolean focusCycleRoot)
{
}
public boolean isFocusCycleRoot()
{
return false;
}
public void transferFocusDownCycle()
/**
* Transfer focus down one focus traversal cycle. If this Container
* is a focus cycle root, then its default component becomes the
* focus owner, and this Container becomes the current focus cycle
* root. No traversal will occur if this Container is not a focus
* cycle root.
*
* @since 1.4
*/
public void transferFocusDownCycle ()
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.downFocusCycle (this);
}
/**
@ -1371,6 +1593,61 @@ public class Container extends Component
}
}
/**
* Deserialize this Container:
* <ol>
* <li>Read from the stream the default serializable fields.</li>
* <li>Read a list of serializable ContainerListeners as optional
* data. If the list is null, no listeners will be registered.</li>
* <li>Read this Container's FocusTraversalPolicy as optional data.
* If this is null, then this Container will use a
* DefaultFocusTraversalPolicy.</li>
* </ol>
*
* @param s the stream to read from
* @throws ClassNotFoundException if deserialization fails
* @throws IOException if the stream fails
*/
private void readObject (ObjectInputStream s)
throws ClassNotFoundException, IOException
{
s.defaultReadObject ();
String key = (String) s.readObject ();
while (key != null)
{
Object object = s.readObject ();
if ("containerL".equals (key))
addContainerListener((ContainerListener) object);
// FIXME: under what key is the focus traversal policy stored?
else if ("focusTraversalPolicy".equals (key))
setFocusTraversalPolicy ((FocusTraversalPolicy) object);
key = (String) s.readObject();
}
}
/**
* Serialize this Container:
* <ol>
* <li>Write to the stream the default serializable fields.</li>
* <li>Write the list of serializable ContainerListeners as optional
* data.</li>
* <li>Write this Container's FocusTraversalPolicy as optional data.</li>
* </ol>
*
* @param s the stream to write to
* @throws IOException if the stream fails
*/
private void writeObject (ObjectOutputStream s) throws IOException
{
s.defaultWriteObject ();
AWTEventMulticaster.save (s, "containerL", containerListener);
if (focusTraversalPolicy instanceof Serializable)
s.writeObject (focusTraversalPolicy);
else
s.writeObject (null);
}
// Nested classes.
/* The following classes are used in concert with the

View file

@ -41,7 +41,23 @@ package java.awt;
import java.io.Serializable;
/**
* ContainerOrderFocusTraversalPolicy defines a focus traversal order
* based on the order in which Components were packed in a Container.
* This policy performs a pre-order traversal of the Component
* hierarchy starting from a given focus cycle root. Portions of the
* hierarchy that are not visible and displayable are skipped.
*
* By default, this policy transfers focus down-cycle implicitly.
* That is, if a forward traversal is requested on a focus cycle root
* and the focus cycle root has focusable children, the focus will
* automatically be transfered down to the lower focus cycle.
*
* The default implementation of accept accepts only Components that
* are visible, displayable, enabled and focusable. Derived classes
* can override these acceptance criteria by overriding accept.
*
* @author Michael Koch
* @author Thomas Fitzsimmons <fitzsim@redhat.com>
* @since 1.4
*/
public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
@ -52,12 +68,15 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
*/
static final long serialVersionUID = 486933713763926351L;
/**
* True if implicit down cycling is enabled.
*/
private boolean implicitDownCycleTraversal = true;
/**
* Creates the <code>ContainerOrderFocusTraversalPolicy</code> object.
*/
public ContainerOrderFocusTraversalPolicy()
public ContainerOrderFocusTraversalPolicy ()
{
// Nothing to do here
}
@ -66,37 +85,196 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
* Returns the Component that should receive the focus after current.
* root must be a focus cycle root of current.
*
* @exception IllegalArgumentException If root is not a focus cycle
* root of current, or if either root or current is null.
*/
public Component getComponentAfter(Container root, Component current)
{
if (root == null
|| current == null)
throw new IllegalArgumentException ();
return null;
}
/**
* Returns the Component that should receive the focus before current.
* root must be a focus cycle root of current.
* @param root a focus cycle root of current
* @param current a (possibly indirect) child of root, or root itself
*
* @return the next Component in the focus traversal order for root,
* or null if no acceptable Component exists.
*
* @exception IllegalArgumentException If root is not a focus cycle
* root of current, or if either root or current is null.
*/
public Component getComponentBefore(Container root, Component current)
public Component getComponentAfter (Container root, Component current)
{
if (root == null
|| current == null)
throw new IllegalArgumentException ();
if (root == null)
throw new IllegalArgumentException ("focus cycle root is null");
if (current == null)
throw new IllegalArgumentException ("current component is null");
return null;
if (!root.isFocusCycleRoot ())
throw new IllegalArgumentException ("root is not a focus cycle root");
Container ancestor = current.getFocusCycleRootAncestor ();
Container prevAncestor = ancestor;
while (ancestor != root)
{
ancestor = current.getFocusCycleRootAncestor ();
if (ancestor == prevAncestor)
{
// We've reached the top focus cycle root ancestor. Check
// if it is root.
if (ancestor != root)
throw new IllegalArgumentException ("the given container is not"
+ " a focus cycle root of the"
+ " current component");
else
break;
}
prevAncestor = ancestor;
}
// FIXME: is this the right thing to do here? It moves the context
// for traversal up one focus traversal cycle. We'll need a test
// for this.
if ((Component) root == current)
root = current.getFocusCycleRootAncestor ();
// Check if we've reached the top of the component hierarchy. If
// so then we want to loop around to the first component in the
// focus traversal cycle.
if (current instanceof Window)
return getFirstComponent ((Container) current);
Container parent = current.getParent ();
synchronized (parent.getTreeLock ())
{
Component[] components = parent.getComponents ();
int componentIndex = 0;
int numComponents = parent.getComponentCount ();
// Find component's index.
for (int i = 0; i < numComponents; i++)
{
if (components[i] == current)
componentIndex = i;
}
// Search forward for the next acceptable component.
for (int i = componentIndex + 1; i < numComponents; i++)
{
if (accept (components[i]))
return components[i];
if (components[i] instanceof Container)
{
Component result = getFirstComponent ((Container) components[i]);
if (result != null
&& implicitDownCycleTraversal)
return result;
}
}
// No focusable components after current in its Container. So go
// to the next Component after current's Container (parent).
Component result = getComponentAfter (root, parent);
return result;
}
}
/**
* Returns the Component that should receive the focus before
* <code>current</code>. <code>root</code> must be a focus cycle
* root of current.
*
* @param root a focus cycle root of current
* @param current a (possibly indirect) child of root, or root itself
*
* @return the previous Component in the focus traversal order for
* root, or null if no acceptable Component exists.
*
* @exception IllegalArgumentException If root is not a focus cycle
* root of current, or if either root or current is null.
*/
public Component getComponentBefore (Container root, Component current)
{
if (root == null)
throw new IllegalArgumentException ("focus cycle root is null");
if (current == null)
throw new IllegalArgumentException ("current component is null");
if (!root.isFocusCycleRoot ())
throw new IllegalArgumentException ("root is not a focus cycle root");
Container ancestor = current.getFocusCycleRootAncestor ();
Container prevAncestor = ancestor;
while (ancestor != root)
{
ancestor = current.getFocusCycleRootAncestor ();
if (ancestor == prevAncestor)
{
// We've reached the top focus cycle root ancestor. Check
// if it is root.
if (ancestor != root)
throw new IllegalArgumentException ("the given container is not"
+ " a focus cycle root of the"
+ " current component");
else
break;
}
prevAncestor = ancestor;
}
// FIXME: is this the right thing to do here? It moves the context
// for traversal up one focus traversal cycle. We'll need a test
// for this.
if ((Component) root == current)
root = current.getFocusCycleRootAncestor ();
// Check if we've reached the top of the component hierarchy. If
// so then we want to loop around to the last component in the
// focus traversal cycle.
if (current instanceof Window)
return getLastComponent ((Container) current);
Container parent = current.getParent ();
synchronized (parent.getTreeLock ())
{
Component[] components = parent.getComponents ();
int componentIndex = 0;
int numComponents = parent.getComponentCount ();
// Find component's index.
for (int i = 0; i < numComponents; i++)
{
if (components[i] == current)
componentIndex = i;
}
// Search backward for the next acceptable component.
for (int i = componentIndex - 1; i >= 0; i--)
{
if (accept (components[i]))
return components[i];
if (components[i] instanceof Container)
{
Component result = getLastComponent ((Container) components[i]);
if (result != null)
return result;
}
}
// No focusable components before current in its Container. So go
// to the previous Component before current's Container (parent).
Component result = getComponentBefore (root, parent);
return result;
}
}
/**
* Returns the first Component of root that should receive the focus.
*
* @param root a focus cycle root
*
* @return the first Component in the focus traversal order for
* root, or null if no acceptable Component exists.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getFirstComponent(Container root)
@ -117,18 +295,16 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
{
Component component = componentArray [i];
if (accept (component))
return component;
if (component instanceof Container)
{
Component result = getLastComponent ((Container) component);
Component result = getFirstComponent ((Container) component);
if (result != null)
return result;
}
else
{
if (accept (component))
return component;
}
}
return null;
@ -137,9 +313,14 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
/**
* Returns the last Component of root that should receive the focus.
*
* @param root a focus cycle root
*
* @return the last Component in the focus traversal order for
* root, or null if no acceptable Component exists.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getLastComponent(Container root)
public Component getLastComponent (Container root)
{
if (root == null)
throw new IllegalArgumentException ();
@ -153,10 +334,13 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
Component[] componentArray = root.getComponents ();
for (int i = componentArray.length - 1; i >= 0; i++)
for (int i = componentArray.length - 1; i >= 0; i--)
{
Component component = componentArray [i];
if (accept (component))
return component;
if (component instanceof Container)
{
Component result = getLastComponent ((Container) component);
@ -164,11 +348,6 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
if (result != null)
return result;
}
else
{
if (accept (component))
return component;
}
}
return null;
@ -177,28 +356,58 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
/**
* Returns the default Component of root that should receive the focus.
*
* @param root a focus cycle root
*
* @return the default Component in the focus traversal order for
* root, or null if no acceptable Component exists.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getDefaultComponent(Container root)
public Component getDefaultComponent (Container root)
{
return getFirstComponent (root);
}
public void setImplicitDownCycleTraversal(boolean value)
/**
* Set whether or not implicit down cycling is enabled. If it is,
* then initiating a forward focus traversal operation onto a focus
* cycle root, the focus will be implicitly transferred into the
* root container's focus cycle.
*
* @param value the setting for implicit down cycling
*/
public void setImplicitDownCycleTraversal (boolean value)
{
implicitDownCycleTraversal = value;
}
public boolean getImplicitDownCycleTraversal()
/**
* Check whether or not implicit down cycling is enabled. If it is,
* then initiating a forward focus traversal operation onto a focus
* cycle root, the focus will be implicitly transferred into the
* root container's focus cycle.
*
* @return true if the focus will be transferred down-cycle
* implicitly
*/
public boolean getImplicitDownCycleTraversal ()
{
return implicitDownCycleTraversal;
}
protected boolean accept(Component current)
/**
* Check whether the given Component is an acceptable target for the
* keyboard input focus.
*
* @param current the Component to check
*
* @return true if current is acceptable, false otherwise
*/
protected boolean accept (Component current)
{
return (current.visible
&& current.isDisplayable()
&& current.isDisplayable ()
&& current.enabled
&& current.focusable);
}
} // class ContainerOrderFocusTraversalPolicy
}

View file

@ -39,17 +39,73 @@ exception statement from your version. */
package java.awt;
/**
* STUB CLASS ONLY
* DefaultFocusTraversalPolicy is the default focus traversal policy
* used by Containers.
*
* This policy sharpens ContainerOrderFocusTraversalPolicy's
* acceptance criteria, to reject those Components that have
* unfocusable peers. Despite this extra strictness, this policy will
* always accept a Component that has explicitly been set focusable by
* any means.
*
* This AWT implementation assumes that the peers of the following
* Components are not focusable: Canvas, Panel, Label, ScrollPane,
* Scrollbar, Window, and any lightweight Component.
*
* A Component's focusability is independent of the focusability of
* its peer.
*
* @author Thomas Fitzsimmons <fitzsim@redhat.com>
* @since 1.4
*/
public class DefaultFocusTraversalPolicy
extends ContainerOrderFocusTraversalPolicy
{
public DefaultFocusTraversalPolicy()
/**
* Construct a default focus traversal policy.
*/
public DefaultFocusTraversalPolicy ()
{
}
protected boolean accept(Component comp)
/**
* Check whether a given Component would be acceptable as a focus
* owner. The Component must be displayable, visible and enabled to
* be acceptable. If the Component's focus traversability has been
* overridden, by overriding Component.isFocusTraversable or
* Component.isFocusable, or by calling Component.setFocusable, then
* the Component will be accepted if it is focusable. If the
* Component uses the default focus traversable behaviour, then
* <code>comp</code> will always be rejected if it is a Canvas,
* Panel, Label, ScrollPane, Scrollbar, Window or lightweight
* Component.
*
* @param comp the Component to check
*
* @return true if the Component is an acceptable target for
* keyboard input focus, false otherwise
*/
protected boolean accept (Component comp)
{
throw new Error("not implemented");
if (comp.visible
&& comp.isDisplayable ()
&& comp.enabled)
{
if (comp.isFocusTraversableOverridden != 0
&& comp.isFocusTraversable ())
return true;
else
{
if (!(comp instanceof Canvas
|| comp instanceof Panel
|| comp instanceof Label
|| comp instanceof ScrollPane
|| comp instanceof Scrollbar
|| comp instanceof Window
|| comp.isLightweight ()))
return true;
}
}
return false;
}
} // class DefaultFocusTraversalPolicy
}

View file

@ -38,59 +38,423 @@ exception statement from your version. */
package java.awt;
import java.awt.event.KeyEvent;
import java.util.*;
import java.awt.event.*;
/**
* STUB CLASS ONLY
*/
// FIXME: finish documentation
public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
public DefaultKeyboardFocusManager()
/**
* This class models a request to delay the dispatch of events that
* arrive after a certain time, until a certain component becomes
* the focus owner.
*/
private class EventDelayRequest implements Comparable
{
/** A {@link java.util.List} of {@link java.awt.event.KeyEvent}s
that are being delayed, pending this request's {@link
Component} receiving the keyboard focus. */
private LinkedList enqueuedKeyEvents = new LinkedList ();
/** An event timestamp. All events that arrive after this time
should be queued in the {@link #enqueuedKeyEvents} {@link
java.util.List}. */
public long timestamp;
/** When this {@link Component} becomes focused, all events
between this EventDelayRequest and the next one in will be
dispatched from {@link #enqueuedKeyEvents}. */
public Component focusedComp;
/**
* Construct a new EventDelayRequest.
*
* @param timestamp events that arrive after this time will be
* delayed
* @param focusedComp the Component that needs to receive focus
* before events are dispatched
*/
public EventDelayRequest (long timestamp, Component focusedComp)
{
this.timestamp = timestamp;
this.focusedComp = focusedComp;
}
public int compareTo (Object o)
{
if (!(o instanceof EventDelayRequest))
throw new ClassCastException ();
EventDelayRequest request = (EventDelayRequest) o;
if (request.timestamp < timestamp)
return -1;
else if (request.timestamp == timestamp)
return 0;
else
return 1;
}
public boolean equals (Object o)
{
if (!(o instanceof EventDelayRequest) || o == null)
return false;
EventDelayRequest request = (EventDelayRequest) o;
return (request.timestamp == timestamp
&& request.focusedComp == focusedComp);
}
public void enqueueEvent (KeyEvent e)
{
KeyEvent last = (KeyEvent) enqueuedKeyEvents.getLast ();
if (last != null && e.getWhen () < last.getWhen ())
throw new RuntimeException ("KeyEvents enqueued out-of-order");
if (e.getWhen () <= timestamp)
throw new RuntimeException ("KeyEvents enqueued before starting timestamp");
enqueuedKeyEvents.add (e);
}
public void dispatchEvents ()
{
int size = enqueuedKeyEvents.size ();
for (int i = 0; i < size; i++)
{
KeyEvent e = (KeyEvent) enqueuedKeyEvents.remove (0);
dispatchKeyEvent (e);
}
}
public void discardEvents ()
{
enqueuedKeyEvents.clear ();
}
}
/** The {@link java.util.SortedSet} of current {@link
#EventDelayRequest}s. */
private SortedSet delayRequests = new TreeSet ();
public DefaultKeyboardFocusManager ()
{
}
public boolean dispatchEvent(AWTEvent e)
public boolean dispatchEvent (AWTEvent e)
{
throw new Error("not implemented");
if (e instanceof WindowEvent)
{
Window target = (Window) e.getSource ();
if (e.id == WindowEvent.WINDOW_ACTIVATED)
setGlobalActiveWindow (target);
else if (e.id == WindowEvent.WINDOW_GAINED_FOCUS)
setGlobalFocusedWindow (target);
else if (e.id != WindowEvent.WINDOW_LOST_FOCUS
&& e.id != WindowEvent.WINDOW_DEACTIVATED)
return false;
target.dispatchEvent (e);
return true;
}
else if (e instanceof FocusEvent)
{
Component target = (Component) e.getSource ();
if (e.id == FocusEvent.FOCUS_GAINED
&& !(target instanceof Window))
{
if (((FocusEvent) e).isTemporary ())
setGlobalFocusOwner (target);
else
setGlobalPermanentFocusOwner (target);
}
if (!(target instanceof Window))
target.dispatchEvent (e);
return true;
}
else if (e instanceof KeyEvent)
{
// Loop through all registered KeyEventDispatchers, giving
// each a chance to handle this event.
Iterator i = keyEventDispatchers.iterator ();
while (i.hasNext ())
{
KeyEventDispatcher dispatcher = (KeyEventDispatcher) i.next ();
if (dispatcher.dispatchKeyEvent ((KeyEvent) e))
return true;
}
// processKeyEvent checks if this event represents a focus
// traversal key stroke.
Component focusOwner = getGlobalPermanentFocusOwner ();
processKeyEvent (focusOwner, (KeyEvent) e);
if (e.isConsumed ())
return true;
if (enqueueKeyEvent ((KeyEvent) e))
// This event was enqueued for dispatch at a later time.
return true;
else
// This event wasn't handled by any of the registered
// KeyEventDispatchers, and wasn't enqueued for dispatch
// later, so send it to the default dispatcher.
return dispatchKeyEvent ((KeyEvent) e);
}
return false;
}
public boolean dispatchKeyEvent(KeyEvent e)
private boolean enqueueKeyEvent (KeyEvent e)
{
throw new Error("not implemented");
Iterator i = delayRequests.iterator ();
boolean oneEnqueued = false;
while (i.hasNext ())
{
EventDelayRequest request = (EventDelayRequest) i.next ();
if (e.getWhen () > request.timestamp)
{
request.enqueueEvent (e);
oneEnqueued = true;
}
}
return oneEnqueued;
}
public boolean postProcessKeyEvent(KeyEvent e)
public boolean dispatchKeyEvent (KeyEvent e)
{
throw new Error("not implemented");
Component focusOwner = getGlobalPermanentFocusOwner ();
focusOwner.dispatchEvent (e);
// Loop through all registered KeyEventPostProcessors, giving
// each a chance to process this event.
Iterator i = keyEventPostProcessors.iterator ();
while (i.hasNext ())
{
KeyEventPostProcessor processor = (KeyEventPostProcessor) i.next ();
if (processor.postProcessKeyEvent ((KeyEvent) e))
return true;
}
// The event hasn't been consumed yet. Check if it is an
// MenuShortcut.
if (postProcessKeyEvent (e))
return true;
// Always return true.
return true;
}
public void processKeyEvent(Component comp, KeyEvent e)
public boolean postProcessKeyEvent (KeyEvent e)
{
throw new Error("not implemented");
// Check if this event represents a menu shortcut.
// MenuShortcuts are activated by Ctrl- KeyEvents.
int modifiers = e.getModifiers ();
if ((modifiers & KeyEvent.CTRL_MASK) != 0
|| (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)
{
Window focusedWindow = getGlobalFocusedWindow ();
if (focusedWindow instanceof Frame)
{
MenuBar menubar = ((Frame) focusedWindow).getMenuBar ();
if (menubar != null)
{
// If there's a menubar, loop through all menu items,
// checking whether each one has a shortcut, and if
// so, whether this key event should activate it.
int numMenus = menubar.getMenuCount ();
for (int i = 0; i < numMenus; i++)
{
Menu menu = menubar.getMenu (i);
int numItems = menu.getItemCount ();
for (int j = 0; j < numItems; j++)
{
MenuItem item = menu.getItem (j);
MenuShortcut shortcut = item.getShortcut ();
if (shortcut != null)
{
// Dispatch a new ActionEvent if this is a
// Shift- KeyEvent and the shortcut requires
// the Shift modifier, or if the shortcut
// doesn't require the Shift modifier.
if ((shortcut.usesShiftModifier ()
&& ((modifiers & KeyEvent.SHIFT_MASK) != 0
|| (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)
|| !shortcut.usesShiftModifier ())
&& shortcut.getKey () == e.getKeyCode ())
{
item.dispatchEvent (new ActionEvent (item,
ActionEvent.ACTION_PERFORMED,
item.getActionCommand (),
modifiers));
// The event was dispatched.
return true;
}
}
}
}
}
}
}
return false;
}
protected void enqueueKeyEvents(long after, Component comp)
public void processKeyEvent (Component comp, KeyEvent e)
{
throw new Error("not implemented");
AWTKeyStroke eventKeystroke = AWTKeyStroke.getAWTKeyStrokeForEvent (e);
// For every focus traversal keystroke, we need to also consume
// the other two key event types for the same key (e.g. if
// KEY_PRESSED TAB is a focus traversal keystroke, we also need to
// consume KEY_RELEASED and KEY_TYPED TAB key events).
AWTKeyStroke oppositeKeystroke = AWTKeyStroke.getAWTKeyStroke (e.getKeyCode (),
e.getModifiers (),
!(e.id == KeyEvent.KEY_RELEASED));
Set forwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
Set backwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
Set upKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
Set downKeystrokes = null;
if (comp instanceof Container)
downKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
if (forwardKeystrokes.contains (eventKeystroke))
{
focusNextComponent (comp);
e.consume ();
}
else if (backwardKeystrokes.contains (eventKeystroke))
{
focusPreviousComponent (comp);
e.consume ();
}
else if (upKeystrokes.contains (eventKeystroke))
{
upFocusCycle (comp);
e.consume ();
}
else if (comp instanceof Container
&& downKeystrokes.contains (eventKeystroke))
{
downFocusCycle ((Container) comp);
e.consume ();
}
else if (forwardKeystrokes.contains (oppositeKeystroke)
|| backwardKeystrokes.contains (oppositeKeystroke)
|| upKeystrokes.contains (oppositeKeystroke)
|| (comp instanceof Container &&
downKeystrokes.contains (oppositeKeystroke)))
e.consume ();
}
protected void dequeueKeyEvents(long after, Component comp)
protected void enqueueKeyEvents (long after, Component untilFocused)
{
throw new Error("not implemented");
delayRequests.add (new EventDelayRequest (after, untilFocused));
}
protected void discardKeyEvents(Component comp)
protected void dequeueKeyEvents (long after, Component untilFocused)
{
throw new Error("not implemented");
// FIXME: need synchronization on delayRequests and enqueuedKeyEvents.
// Remove the KeyEvent with the oldest timestamp, which should be
// the first element in the SortedSet.
if (after < 0)
{
int size = delayRequests.size ();
if (size > 0)
delayRequests.remove (delayRequests.first ());
}
else
{
EventDelayRequest template = new EventDelayRequest (after, untilFocused);
if (delayRequests.contains (template))
{
EventDelayRequest actual = (EventDelayRequest) delayRequests.tailSet (template).first ();
delayRequests.remove (actual);
actual.dispatchEvents ();
}
}
}
public void focusPreviousComponent(Component comp)
protected void discardKeyEvents (Component comp)
{
throw new Error("not implemented");
// FIXME: need synchronization on delayRequests and enqueuedKeyEvents.
Iterator i = delayRequests.iterator ();
while (i.hasNext ())
{
EventDelayRequest request = (EventDelayRequest) i.next ();
if (request.focusedComp == comp
|| (comp instanceof Container
&& ((Container) comp).isAncestorOf (request.focusedComp)))
request.discardEvents ();
}
}
public void focusNextComponent(Component comp)
public void focusPreviousComponent (Component comp)
{
throw new Error("not implemented");
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component previous = policy.getComponentBefore (focusCycleRoot, focusComp);
previous.requestFocusInWindow ();
}
public void upFocusCycle(Component comp)
public void focusNextComponent (Component comp)
{
throw new Error("not implemented");
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component next = policy.getComponentAfter (focusCycleRoot, focusComp);
next.requestFocusInWindow ();
}
public void downFocusCycle(Container cont)
public void upFocusCycle (Component comp)
{
throw new Error("not implemented");
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
if (focusCycleRoot instanceof Window)
{
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (focusCycleRoot);
defaultComponent.requestFocusInWindow ();
}
else
{
Container parentFocusCycleRoot = focusCycleRoot.getFocusCycleRootAncestor ();
focusCycleRoot.requestFocusInWindow ();
setGlobalCurrentFocusCycleRoot (parentFocusCycleRoot);
}
}
public void downFocusCycle (Container cont)
{
if (cont == null)
return;
if (cont.isFocusCycleRoot (cont))
{
FocusTraversalPolicy policy = cont.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (cont);
defaultComponent.requestFocusInWindow ();
setGlobalCurrentFocusCycleRoot (cont);
}
}
} // class DefaultKeyboardFocusManager

View file

@ -67,7 +67,17 @@ class EventDispatchThread extends Thread
// We are interrupted when we should finish executing
return;
}
queue.dispatchEvent(evt);
KeyboardFocusManager manager;
manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
// Try to dispatch this event to the current keyboard focus
// manager. It will dispatch all FocusEvents, all
// WindowEvents related to focus, and all KeyEvents,
// returning true. Otherwise, it returns false and we
// dispatch the event normally.
if (!manager.dispatchEvent (evt))
queue.dispatchEvent(evt);
}
catch (InterruptedException ie)
{

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import java.awt.image.AreaAveragingScaleFilter;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.ReplicateScaleFilter;
@ -179,7 +180,20 @@ public abstract class Image
*/
public Image getScaledInstance(int width, int height, int flags)
{
throw new Error("not implemented");
switch (flags)
{
case SCALE_DEFAULT:
case SCALE_FAST:
case SCALE_REPLICATE:
ImageProducer producer =
new FilteredImageSource(this.getSource(),
new ReplicateScaleFilter(width, height));
return Toolkit.getDefaultToolkit().createImage(producer);
case SCALE_SMOOTH:
case SCALE_AREA_AVERAGING:
default:
throw new Error("not implemented");
}
}
/**

View file

@ -39,34 +39,66 @@ exception statement from your version. */
package java.awt;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
// FIXME: finish documentation
/**
*
* FIXME: discuss applet contexts and thread groups and codebases
* being insulated.
*
* FIXME: discuss where default focus traversal key sets apply
* (inherited by child Components etc.)
*
* @author Eric Blake <ebb9@email.byu.edu>
* @author Thomas Fitzsimmons <fitzsim@redhat.com>
* @since 1.4
* @status partially updated to 1.4, needs documentation.
*/
public abstract class KeyboardFocusManager
implements KeyEventDispatcher, KeyEventPostProcessor
{
/** Identifies {@link AWTKeyStroke}s that move the focus forward in
the focus cycle. */
public static final int FORWARD_TRAVERSAL_KEYS = 0;
/** Identifies {@link AWTKeyStroke}s that move the focus backward in
the focus cycle. */
public static final int BACKWARD_TRAVERSAL_KEYS = 1;
/** Identifies {@link AWTKeyStroke}s that move the focus up to the
parent focus cycle root. */
public static final int UP_CYCLE_TRAVERSAL_KEYS = 2;
/** Identifies {@link AWTKeyStroke}s that move the focus down to the
child focus cycle root. */
public static final int DOWN_CYCLE_TRAVERSAL_KEYS = 3;
/** The set of {@link AWTKeyStroke}s that cause focus to be moved to
the next focusable Component in the focus cycle. */
private static final Set DEFAULT_FORWARD_KEYS;
/** The set of {@link AWTKeyStroke}s that cause focus to be moved to
the previous focusable Component in the focus cycle. */
private static final Set DEFAULT_BACKWARD_KEYS;
/** Populate the DEFAULT_FORWARD_KEYS and DEFAULT_BACKWARD_KEYS
{@link java.util.Set}s. */
static
{
Set s = new HashSet();
@ -83,232 +115,402 @@ public abstract class KeyboardFocusManager
DEFAULT_BACKWARD_KEYS = Collections.unmodifiableSet(s);
}
private static KeyboardFocusManager current
= new DefaultKeyboardFocusManager();
/** The global object {@link java.util.Map}s. */
// XXX Not implemented correctly. I think a good implementation here may
// be to have permanentFocusOwner be null, and fall back to focusOwner,
// unless a temporary focus change is in effect.
private static Component focusOwner;
private static Component permanentFocusOwner;
/** For security reasons, {@link java.applet.Applet}s in different
codebases must be insulated from one another. Since {@link
KeyboardFocusManager}s have the ability to return {@link
Component}s from a given {@link java.applet.Applet}, each
codebase must have an independent {@link KeyboardFocusManager}.
Since each codebase has its own {@link ThreadGroup} in which its
{@link Applet}s run, it makes sense to partition {@link
KeyboardFocusManager}s according to {@link
java.lang.ThreadGroup}. Thus, currentKeyboardFocusManagers is a
{@link java.util.Map} keyed on {@link java.lang.ThreadGroup}. */
private static Map currentKeyboardFocusManagers = new HashMap ();
private static Window focusedWindow;
private static Window activeWindow;
private static Container focusCycleRoot;
/** {@link java.applet.Applet}s in one codebase must not be allowed
to access {@link Component}s in {@link java.applet.Applet}s in
other codebases. To enforce this restriction, we key the
following {@link java.util.Map}s on {@link java.lang.ThreadGroup}s (which
are per-codebase). For example, if {@link
java.lang.ThreadGroup} A calls {@link #setGlobalFocusOwner},
passing {@link Component} C, currentFocusOwners[A] is assigned
C, and all other currentFocusOwners values are nullified. Then
if {@link java.lang.ThreadGroup} A subsequently calls {@link
#getGlobalFocusOwner}, it will return currentFocusOwners[A],
that is, {@link Component} C. If another {@link
java.lang.ThreadGroup} K calls {@link #getGlobalFocusOwner}, it
will return currentFocusOwners[K], that is, null.
Since this is a static field, we ensure that there is only one
focused {@link Component} per class loader. */
private static Map currentFocusOwners = new HashMap ();
/** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
that stores the {@link Component} that owns the permanent
keyboard focus. @see currentFocusOwners */
private static Map currentPermanentFocusOwners = new HashMap ();
/** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
that stores the focused {@link Window}. @see
currentFocusOwners */
private static Map currentFocusedWindows = new HashMap ();
/** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
that stores the active {@link Window}. @see
currentFocusOwners */
private static Map currentActiveWindows = new HashMap ();
/** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
that stores the focus cycle root {@link Container}. @see
currentFocusOwners */
private static Map currentFocusCycleRoots = new HashMap ();
/** The default {@link FocusTraveralPolicy} that focus-managing
{@link Container}s will use to define their initial focus
traversal policy. */
private FocusTraversalPolicy defaultPolicy;
private Set[] defaultFocusKeys = new Set[] {
/** An array that stores the {@link #FORWARD_TRAVERSAL_KEYS}, {@link
#BACKWARD_TRAVERSAL_KEYS}, {@link #UP_CYCLE_TRAVERSAL_KEYS} and
{@link #DOWN_CYCLE_TRAVERSAL_KEYS} {@link AWTKeyStroke}s {@link
java.util.Set}s. */
private Set[] defaultFocusKeys = new Set[]
{
DEFAULT_FORWARD_KEYS, DEFAULT_BACKWARD_KEYS,
Collections.EMPTY_SET, Collections.EMPTY_SET
};
private final PropertyChangeSupport propertyChangeSupport
= new PropertyChangeSupport(this);
private final VetoableChangeSupport vetoableChangeSupport
= new VetoableChangeSupport(this);
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport (this);
private final VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport (this);
/** A list of {@link KeyEventDispatcher}s that process {@link
KeyEvent}s before they are processed the default keyboard focus
manager. */
private final ArrayList keyEventDispatchers = new ArrayList();
/** A list of {@link KeyEventPostProcessor}s that process unconsumed
{@link KeyEvent}s. */
private final ArrayList keyEventPostProcessors = new ArrayList();
public KeyboardFocusManager()
/**
* Construct a KeyboardFocusManager.
*/
public KeyboardFocusManager ()
{
}
public static KeyboardFocusManager getCurrentKeyboardFocusManager()
/**
* Retrieve the keyboard focus manager associated with the {@link
* java.lang.ThreadGroup} to which the calling thread belongs.
*
* @return the keyboard focus manager associated with the current
* thread group
*/
public static KeyboardFocusManager getCurrentKeyboardFocusManager ()
{
// XXX Need a way to divide this into contexts.
return current;
ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
return (KeyboardFocusManager) currentKeyboardFocusManagers.get (currentGroup);
}
public static void setCurrentKeyboardFocusManager(KeyboardFocusManager m)
/**
* Set the keyboard focus manager associated with the {@link
* java.lang.ThreadGroup} to which the calling thread belongs.
*
* @param m the keyboard focus manager for the current thread group
*/
public static void setCurrentKeyboardFocusManager (KeyboardFocusManager m)
{
SecurityManager sm = System.getSecurityManager();
SecurityManager sm = System.getSecurityManager ();
if (sm != null)
sm.checkPermission(new AWTPermission("replaceKeyboardFocusManager"));
// XXX Need a way to divide this into contexts.
current = m == null ? new DefaultKeyboardFocusManager() : m;
sm.checkPermission (new AWTPermission ("replaceKeyboardFocusManager"));
ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
KeyboardFocusManager manager;
if (m == null)
manager = new DefaultKeyboardFocusManager ();
else
manager = m;
currentKeyboardFocusManagers.put (currentGroup, manager);
}
public Component getFocusOwner()
/**
* Retrieve the {@link Component} that has the keyboard focus, or
* null if the focus owner was not set by a thread in the current
* {@link java.lang.ThreadGroup}.
*
* @return the keyboard focus owner or null
*/
public Component getFocusOwner ()
{
// XXX Need an easy way to test if this thread is in the context of the
// global focus owner, to avoid creating the exception in the first place.
try
{
return getGlobalFocusOwner();
}
catch (SecurityException e)
{
return null;
}
return (Component) getObject (currentFocusOwners);
}
protected Component getGlobalFocusOwner()
/**
* Retrieve the {@link Component} that has the keyboard focus,
* regardless of whether or not it was set by a thread in the
* current {@link java.lang.ThreadGroup}. If there is no temporary
* focus owner in effect then this method will return the same value
* as {@link #getGlobalPermanentFocusOwner}.
*
* @return the keyboard focus owner
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*/
protected Component getGlobalFocusOwner ()
{
// XXX Need a way to test if this thread is in the context of the focus
// owner, and throw a SecurityException if that is the case.
// XXX Implement.
return focusOwner;
// Check if there is a temporary focus owner.
Component focusOwner = (Component) getGlobalObject (currentFocusOwners);
return (focusOwner == null) ? getGlobalPermanentFocusOwner () : focusOwner;
}
protected void setGlobalFocusOwner(Component owner)
/**
* Set the {@link Component} that will be returned by {@link
* #getFocusOwner} (when it is called from the current {@link
* java.lang.ThreadGroup}) and {@link #getGlobalFocusOwner}. This
* method does not actually transfer the keyboard focus.
*
* @param owner the Component to return from getFocusOwner and
* getGlobalFocusOwner
*
* @see Component.requestFocus ()
* @see Component.requestFocusInWindow ()
*/
protected void setGlobalFocusOwner (Component owner)
{
// XXX Should this send focus events to the components involved?
if (owner == null || owner.focusable)
setGlobalObject (currentFocusOwners, owner, "focusOwner");
}
/**
* Clear the global focus owner and deliver a FOCUS_LOST event to
* the previously-focused {@link Component}. Until another {@link
* Component} becomes the keyboard focus owner, key events will be
* discarded by top-level windows.
*/
public void clearGlobalFocusOwner ()
{
synchronized (currentFocusOwners)
{
firePropertyChange("focusOwner", focusOwner, owner);
try
Component focusOwner = getGlobalFocusOwner ();
Component permanentFocusOwner = getGlobalPermanentFocusOwner ();
setGlobalFocusOwner (null);
setGlobalPermanentFocusOwner (null);
// Inform the old focus owner that it has lost permanent
// focus.
if (focusOwner != null)
{
fireVetoableChange("focusOwner", focusOwner, owner);
focusOwner = owner;
// We can't cache the event queue, because of
// bootstrapping issues. We need to set the default
// KeyboardFocusManager in EventQueue before the event
// queue is started.
EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
if (focusOwner != permanentFocusOwner)
q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, true));
else
q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, false));
}
catch (PropertyVetoException e)
if (focusOwner != permanentFocusOwner)
{
EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
q.postEvent (new FocusEvent (permanentFocusOwner, FocusEvent.FOCUS_LOST, false));
}
}
}
public void clearGlobalFocusOwner()
/**
* Retrieve the {@link Component} that has the permanent keyboard
* focus, or null if the focus owner was not set by a thread in the
* current {@link java.lang.ThreadGroup}.
*
* @return the keyboard focus owner or null
*/
public Component getPermanentFocusOwner ()
{
// XXX Is this enough?
setGlobalFocusOwner(null);
return (Component) getObject (currentPermanentFocusOwners);
}
public Component getPermanentFocusOwner()
/**
* Retrieve the {@link Component} that has the permanent keyboard
* focus, regardless of whether or not it was set by a thread in the
* current {@link java.lang.ThreadGroup}.
*
* @return the keyboard focus owner
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*/
protected Component getGlobalPermanentFocusOwner ()
{
// XXX Need an easy way to test if this thread is in the context of the
// global focus owner, to avoid creating the exception in the first place.
try
{
return getGlobalPermanentFocusOwner();
}
catch (SecurityException e)
{
return null;
}
return (Component) getGlobalObject (currentPermanentFocusOwners);
}
protected Component getGlobalPermanentFocusOwner()
/**
* Set the {@link Component} that will be returned by {@link
* #getPermanentFocusOwner} (when it is called from the current
* {@link java.lang.ThreadGroup}) and {@link
* #getGlobalPermanentFocusOwner}. This method does not actually
* transfer the keyboard focus.
*
* @param focusOwner the Component to return from
* getPermanentFocusOwner and getGlobalPermanentFocusOwner
*
* @see Component.requestFocus ()
* @see Component.requestFocusInWindow ()
*/
protected void setGlobalPermanentFocusOwner (Component focusOwner)
{
// XXX Need a way to test if this thread is in the context of the focus
// owner, and throw a SecurityException if that is the case.
// XXX Implement.
return permanentFocusOwner == null ? focusOwner : permanentFocusOwner;
}
protected void setGlobalPermanentFocusOwner(Component focusOwner)
{
// XXX Should this send focus events to the components involved?
if (focusOwner == null || focusOwner.focusable)
{
firePropertyChange("permanentFocusOwner", permanentFocusOwner,
focusOwner);
try
{
fireVetoableChange("permanentFocusOwner", permanentFocusOwner,
focusOwner);
permanentFocusOwner = focusOwner;
}
catch (PropertyVetoException e)
{
}
}
setGlobalObject (currentPermanentFocusOwners, focusOwner,
"permanentFocusOwner");
}
public Window getFocusedWindow()
/**
* Retrieve the {@link Window} that is or contains the keyboard
* focus owner, or null if the focused window was not set by a
* thread in the current {@link java.lang.ThreadGroup}.
*
* @return the focused window or null
*/
public Window getFocusedWindow ()
{
// XXX Need an easy way to test if this thread is in the context of the
// global focus owner, to avoid creating the exception in the first place.
try
{
return getGlobalFocusedWindow();
}
catch (SecurityException e)
{
return null;
}
return (Window) getObject (currentFocusedWindows);
}
protected Window getGlobalFocusedWindow()
/**
* Retrieve the {@link Window} that is or contains the focus owner,
* regardless of whether or not the {@link Window} was set focused
* by a thread in the current {@link java.lang.ThreadGroup}.
*
* @return the focused window
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*/
protected Window getGlobalFocusedWindow ()
{
// XXX Need a way to test if this thread is in the context of the focus
// owner, and throw a SecurityException if that is the case.
// XXX Implement.
return focusedWindow;
return (Window) getGlobalObject (currentFocusedWindows);
}
protected void setGlobalFocusedWindow(Window window)
/**
* Set the {@link Window} that will be returned by {@link
* #getFocusedWindow} (when it is called from the current {@link
* java.lang.ThreadGroup}) and {@link #getGlobalFocusedWindow}.
* This method does not actually cause <code>window</code> to become
* the focused {@link Window}.
*
* @param window the Window to return from getFocusedWindow and
* getGlobalFocusedWindow
*/
protected void setGlobalFocusedWindow (Window window)
{
// XXX Should this send focus events to the windows involved?
if (window == null || window.focusable)
{
firePropertyChange("focusedWindow", focusedWindow, window);
try
{
fireVetoableChange("focusedWindow", focusedWindow, window);
focusedWindow = window;
}
catch (PropertyVetoException e)
{
}
}
setGlobalObject (currentFocusedWindows, window, "focusedWindow");
}
/**
* Retrieve the active {@link Window}, or null if the active window
* was not set by a thread in the current {@link
* java.lang.ThreadGroup}.
*
* @return the active window or null
*/
public Window getActiveWindow()
{
// XXX Need an easy way to test if this thread is in the context of the
// global focus owner, to avoid creating the exception in the first place.
try
{
return getGlobalActiveWindow();
}
catch (SecurityException e)
{
return null;
}
return (Window) getObject (currentActiveWindows);
}
/**
* Retrieve the active {@link Window}, regardless of whether or not
* the {@link Window} was made active by a thread in the current
* {@link java.lang.ThreadGroup}.
*
* @return the active window
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*/
protected Window getGlobalActiveWindow()
{
// XXX Need a way to test if this thread is in the context of the focus
// owner, and throw a SecurityException if that is the case.
// XXX Implement.
return activeWindow;
return (Window) getGlobalObject (currentActiveWindows);
}
/**
* Set the {@link Window} that will be returned by {@link
* #getActiveWindow} (when it is called from the current {@link
* java.lang.ThreadGroup}) and {@link #getGlobalActiveWindow}. This
* method does not actually cause <code>window</code> to be made
* active.
*
* @param window the Window to return from getActiveWindow and
* getGlobalActiveWindow
*/
protected void setGlobalActiveWindow(Window window)
{
// XXX Should this send focus events to the windows involved?
firePropertyChange("activeWindow", activeWindow, window);
try
{
fireVetoableChange("activeWindow", activeWindow, window);
activeWindow = window;
}
catch (PropertyVetoException e)
{
}
setGlobalObject (currentActiveWindows, window, "activeWindow");
}
public FocusTraversalPolicy getDefaultFocusTraversalPolicy()
/**
* Retrieve the default {@link FocusTraversalPolicy}.
* Focus-managing {@link Container}s use the returned object to
* define their initial focus traversal policy.
*
* @return a non-null default FocusTraversalPolicy object
*/
public FocusTraversalPolicy getDefaultFocusTraversalPolicy ()
{
if (defaultPolicy == null)
defaultPolicy = new DefaultFocusTraversalPolicy();
defaultPolicy = new DefaultFocusTraversalPolicy ();
return defaultPolicy;
}
public void setDefaultFocusTraversalPolicy(FocusTraversalPolicy policy)
/**
* Set the {@link FocusTraversalPolicy} returned by {@link
* #getDefaultFocusTraversalPolicy}. Focus-managing {@link
* Container}s created after this call will use policy as their
* initial focus traversal policy. Existing {@link Container}s'
* focus traversal policies will not be affected by calls to this
* method.
*
* @param policy the FocusTraversalPolicy that will be returned by
* subsequent calls to getDefaultFocusTraversalPolicy
* @throws IllegalArgumentException if policy is null
*/
public void setDefaultFocusTraversalPolicy (FocusTraversalPolicy policy)
{
if (policy == null)
throw new IllegalArgumentException();
firePropertyChange("defaultFocusTraversalPolicy", defaultPolicy, policy);
throw new IllegalArgumentException ();
firePropertyChange ("defaultFocusTraversalPolicy", defaultPolicy, policy);
defaultPolicy = policy;
}
public void setDefaultFocusTraversalKeys(int id, Set keystrokes)
/**
* Set the default {@link java.util.Set} of focus traversal keys for
* one of the focus traversal directions.
*
* @param id focus traversal direction identifier
* @param keystrokes set of AWTKeyStrokes
*
* @see #FORWARD_TRAVERSAL_KEYS
* @see #BACKWARD_TRAVERSAL_KEYS
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
public void setDefaultFocusTraversalKeys (int id, Set keystrokes)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
if (keystrokes == null)
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
Set sa;
Set sb;
Set sc;
@ -340,56 +542,82 @@ public abstract class KeyboardFocusManager
type = "downCycleDefaultFocusTraversalKeys";
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
}
int i = keystrokes.size();
Iterator iter = keystrokes.iterator();
int i = keystrokes.size ();
Iterator iter = keystrokes.iterator ();
while (--i >= 0)
{
Object o = iter.next();
if (! (o instanceof AWTKeyStroke)
|| sa.contains(o) || sb.contains(o) || sc.contains(o)
Object o = iter.next ();
if (!(o instanceof AWTKeyStroke)
|| sa.contains (o) || sb.contains (o) || sc.contains (o)
|| ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
}
keystrokes = Collections.unmodifiableSet(new HashSet(keystrokes));
firePropertyChange(type, defaultFocusKeys[id], keystrokes);
keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
firePropertyChange (type, defaultFocusKeys[id], keystrokes);
defaultFocusKeys[id] = keystrokes;
}
public Set getDefaultFocusTraversalKeys(int id)
/**
* Retrieve the default {@link java.util.Set} of focus traversal
* keys for one of the focus traversal directions.
*
* @param id focus traversal direction identifier
*
* @return the default set of AWTKeyStrokes
*
* @see #FORWARD_TRAVERSAL_KEYS
* @see #BACKWARD_TRAVERSAL_KEYS
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
public Set getDefaultFocusTraversalKeys (int id)
{
if (id < FORWARD_TRAVERSAL_KEYS || id > DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException();
throw new IllegalArgumentException ();
return defaultFocusKeys[id];
}
public Container getCurrentFocusCycleRoot()
/**
* Retrieve the current focus cycle root, or null if the focus owner
* was not set by a thread in the current {@link
* java.lang.ThreadGroup}.
*
* @return the current focus cycle root or null
*/
public Container getCurrentFocusCycleRoot ()
{
// XXX Need an easy way to test if this thread is in the context of the
// global focus owner, to avoid creating the exception in the first place.
try
{
return getGlobalCurrentFocusCycleRoot();
}
catch (SecurityException e)
{
return null;
}
return (Container) getObject (currentFocusCycleRoots);
}
protected Container getGlobalCurrentFocusCycleRoot()
/**
* Retrieve the current focus cycle root, regardless of whether or
* not it was made set by a thread in the current {@link
* java.lang.ThreadGroup}.
*
* @return the current focus cycle root
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*/
protected Container getGlobalCurrentFocusCycleRoot ()
{
// XXX Need a way to test if this thread is in the context of the focus
// owner, and throw a SecurityException if that is the case.
// XXX Implement.
return focusCycleRoot;
return (Container) getGlobalObject (currentFocusCycleRoots);
}
public void setGlobalCurrentFocusCycleRoot(Container cycleRoot)
/**
* Set the {@link Container} that will be returned by {@link
* #getCurrentFocusCycleRoot} (when it is called from the current
* {@link java.lang.ThreadGroup}) and {@link
* #getGlobalCurrentFocusCycleRoot}. This method does not actually
* make <code>cycleRoot</code> the current focus cycle root.
*
* @param cycleRoot the focus cycle root to return from
* getCurrentFocusCycleRoot and getGlobalCurrentFocusCycleRoot
*/
public void setGlobalCurrentFocusCycleRoot (Container cycleRoot)
{
firePropertyChange("currentFocusCycleRoot", focusCycleRoot, cycleRoot);
focusCycleRoot = cycleRoot;
setGlobalObject (currentFocusCycleRoots, cycleRoot, "currentFocusCycleRoot");
}
public void addPropertyChangeListener(PropertyChangeListener l)
@ -484,73 +712,196 @@ public abstract class KeyboardFocusManager
keyEventDispatchers.remove(dispatcher);
}
protected List getKeyEventDispatchers()
protected List getKeyEventDispatchers ()
{
return (List) keyEventDispatchers.clone();
return (List) keyEventDispatchers.clone ();
}
public void addKeyEventPostProcessor(KeyEventPostProcessor postProcessor)
public void addKeyEventPostProcessor (KeyEventPostProcessor postProcessor)
{
if (postProcessor != null)
keyEventPostProcessors.add(postProcessor);
keyEventPostProcessors.add (postProcessor);
}
public void removeKeyEventPostProcessor(KeyEventPostProcessor postProcessor)
public void removeKeyEventPostProcessor (KeyEventPostProcessor postProcessor)
{
keyEventPostProcessors.remove(postProcessor);
keyEventPostProcessors.remove (postProcessor);
}
protected List getKeyEventPostProcessors()
protected List getKeyEventPostProcessors ()
{
return (List) keyEventPostProcessors.clone();
return (List) keyEventPostProcessors.clone ();
}
public abstract boolean dispatchEvent(AWTEvent e);
public abstract boolean dispatchEvent (AWTEvent e);
public final void redispatchEvent(Component target, AWTEvent e)
public final void redispatchEvent (Component target, AWTEvent e)
{
throw new Error("not implemented");
e.setSource (target);
dispatchEvent (e);
}
public abstract boolean dispatchKeyEvent(KeyEvent e);
public abstract boolean dispatchKeyEvent (KeyEvent e);
public abstract boolean postProcessKeyEvent(KeyEvent e);
public abstract boolean postProcessKeyEvent (KeyEvent e);
public abstract void processKeyEvent(Component focused, KeyEvent e);
public abstract void processKeyEvent (Component focused, KeyEvent e);
protected abstract void enqueueKeyEvents(long after, Component untilFocused);
protected abstract void enqueueKeyEvents (long after, Component untilFocused);
protected abstract void dequeueKeyEvents(long after, Component untilFocused);
protected abstract void dequeueKeyEvents (long after, Component untilFocused);
protected abstract void discardKeyEvents(Component comp);
protected abstract void discardKeyEvents (Component comp);
public abstract void focusNextComponent(Component comp);
public abstract void focusNextComponent (Component comp);
public abstract void focusPreviousComponent(Component comp);
public abstract void focusPreviousComponent (Component comp);
public abstract void upFocusCycle(Component comp);
public abstract void upFocusCycle (Component comp);
public abstract void downFocusCycle(Container cont);
public abstract void downFocusCycle (Container cont);
public final void focusNextComponent()
public final void focusNextComponent ()
{
focusNextComponent(focusOwner);
focusNextComponent (null);
}
public final void focusPreviousComponent()
public final void focusPreviousComponent ()
{
focusPreviousComponent(focusOwner);
focusPreviousComponent (null);
}
public final void upFocusCycle()
public final void upFocusCycle ()
{
upFocusCycle(focusOwner);
upFocusCycle (null);
}
public final void downFocusCycle()
public final void downFocusCycle ()
{
Component focusOwner = getGlobalFocusOwner ();
if (focusOwner instanceof Container
&& ((Container) focusOwner).isFocusCycleRoot())
downFocusCycle((Container) focusOwner);
&& ((Container) focusOwner).isFocusCycleRoot ())
downFocusCycle ((Container) focusOwner);
}
} // class KeyboardFocusManager
/**
* Retrieve an object from one of the global object {@link
* java.util.Map}s, if the object was set by the a thread in the
* current {@link java.lang.ThreadGroup}. Otherwise, return null.
*
* @param globalMap one of the global object Maps
*
* @return a global object set by the current ThreadGroup, or null
*
* @see getFocusOwner
* @see getPermanentFocusOwner
* @see getFocusedWindow
* @see getActiveWindow
* @see getCurrentFocusCycleRoot
*/
private Object getObject (Map globalMap)
{
ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
return globalMap.get (currentGroup);
}
/**
* Retrieve an object from one of the global object {@link
* java.util.Map}s, regardless of whether or not the object was set
* by a thread in the current {@link java.lang.ThreadGroup}.
*
* @param globalMap one of the global object Maps
*
* @return a global object set by the current ThreadGroup, or null
*
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*
* @see getGlobalFocusOwner
* @see getGlobalPermanentFocusOwner
* @see getGlobalFocusedWindow
* @see getGlobalActiveWindow
* @see getGlobalCurrentFocusCycleRoot
*/
private Object getGlobalObject (Map globalMap)
{
ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
KeyboardFocusManager managerForCallingThread
= (KeyboardFocusManager) currentKeyboardFocusManagers.get (currentGroup);
if (this != managerForCallingThread)
throw new SecurityException ("Attempted to retrieve an object from a "
+ "keyboard focus manager that isn't "
+ "associated with the current thread group.");
synchronized (globalMap)
{
Collection globalObjects = globalMap.values ();
Iterator i = globalObjects.iterator ();
Component globalObject;
while (i.hasNext ())
{
globalObject = (Component) i.next ();
if (globalObject != null)
return globalObject;
}
}
// No Object was found.
return null;
}
/**
* Set an object in one of the global object {@link java.util.Map}s,
* that will be returned by subsequent calls to getGlobalObject on
* the same {@link java.util.Map}.
*
* @param globalMap one of the global object Maps
* @param newObject the object to set
* @param property the property that will change
*
* @see setGlobalFocusOwner
* @see setGlobalPermanentFocusOwner
* @see setGlobalFocusedWindow
* @see setGlobalActiveWindow
* @see setGlobalCurrentFocusCycleRoot
*/
private void setGlobalObject (Map globalMap,
Object newObject,
String property)
{
synchronized (globalMap)
{
// Save old object.
Object oldObject = getGlobalObject (globalMap);
// Nullify old object.
Collection threadGroups = globalMap.keySet ();
Iterator i = threadGroups.iterator ();
while (i.hasNext ())
{
ThreadGroup oldThreadGroup = (ThreadGroup) i.next ();
if (globalMap.get (oldThreadGroup) != null)
{
globalMap.put (oldThreadGroup, null);
// There should only be one object set at a time, so
// we can short circuit.
break;
}
}
ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
firePropertyChange (property, oldObject, newObject);
try
{
fireVetoableChange (property, oldObject, newObject);
// Set new object.
globalMap.put (currentGroup, newObject);
}
catch (PropertyVetoException e)
{
}
}
}
}

View file

@ -39,6 +39,9 @@ package java.awt;
import java.awt.peer.ComponentPeer;
import java.awt.peer.TextAreaPeer;
import java.awt.event.KeyEvent;
import java.util.HashSet;
import java.util.Set;
/**
@ -193,11 +196,19 @@ public class TextArea extends TextComponent implements java.io.Serializable
this.rows = rows;
this.columns = columns;
this.scrollbarVisibility = scrollbarVisibility;
}
/*
* Instance Variables
*/
// TextAreas need to receive tab key events so we override the
// default forward and backward traversal key sets.
Set s = new HashSet ();
s.add (AWTKeyStroke.getAWTKeyStroke (KeyEvent.VK_TAB,
KeyEvent.CTRL_DOWN_MASK));
setFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, s);
s = new HashSet ();
s.add (AWTKeyStroke.getAWTKeyStroke (KeyEvent.VK_TAB,
KeyEvent.SHIFT_DOWN_MASK
| KeyEvent.CTRL_DOWN_MASK));
setFocusTraversalKeys (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, s);
}
/**
* Retrieve the number of columns that this text area would prefer
@ -431,10 +442,8 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public void addNotify ()
{
if (getPeer () != null)
return;
setPeer ((ComponentPeer) getToolkit().createTextArea (this));
if (getPeer () == null)
setPeer ((ComponentPeer) getToolkit().createTextArea (this));
}
/**
@ -458,10 +467,9 @@ public class TextArea extends TextComponent implements java.io.Serializable
public void appendText (String str)
{
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.insert (str, peer.getText().length ());
if (peer != null)
peer.insert (str, peer.getText().length ());
}
/**
@ -489,10 +497,9 @@ public class TextArea extends TextComponent implements java.io.Serializable
public void insertText (String str, int pos)
{
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.insert (str, pos);
if (peer != null)
peer.insert (str, pos);
}
/**
@ -530,10 +537,9 @@ public class TextArea extends TextComponent implements java.io.Serializable
public void replaceText (String str, int start, int end)
{
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.replaceRange (str, start, end);
if (peer != null)
peer.replaceRange (str, start, end);
}
/**

View file

@ -83,6 +83,8 @@ public class Window extends Container implements Accessible
private transient GraphicsConfiguration graphicsConfiguration;
private transient AccessibleContext accessibleContext;
private transient boolean shown;
/**
* This (package access) constructor is used by subclasses that want
* to build windows that do not have parents. Eg. toplevel
@ -92,6 +94,9 @@ public class Window extends Container implements Accessible
Window()
{
visible = false;
// Windows are the only Containers that default to being focus
// cycle roots.
focusCycleRoot = true;
setLayout(new BorderLayout());
}
@ -242,6 +247,23 @@ public class Window extends Container implements Accessible
validate();
super.show();
toFront();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.setGlobalFocusedWindow (this);
if (!shown)
{
FocusTraversalPolicy policy = getFocusTraversalPolicy ();
Component initialFocusOwner = null;
if (policy != null)
initialFocusOwner = policy.getInitialComponent (this);
if (initialFocusOwner != null)
initialFocusOwner.requestFocusInWindow (false);
shown = true;
}
}
public void hide()
@ -627,9 +649,16 @@ public class Window extends Container implements Accessible
* @return The component that has focus, or <code>null</code> if no
* component has focus.
*/
public Component getFocusOwner()
public Component getFocusOwner ()
{
// FIXME
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Window activeWindow = manager.getActiveWindow ();
// The currently-focused Component belongs to the active Window.
if (activeWindow == this)
return manager.getFocusOwner ();
return null;
}

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt.image;
import java.util.Hashtable;
import java.awt.Rectangle;
/**
* <br>
@ -92,7 +93,7 @@ public class CropImageFilter extends ImageFilter
*/
public void setProperties(Hashtable props)
{
// props.put("filters", "ReplicateScaleFilter");
props.put("filters", "CropImageFilter");
consumer.setProperties(props);
}
@ -113,7 +114,27 @@ public class CropImageFilter extends ImageFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
Rectangle filterBounds = new Rectangle(this.x, this.y,
this.width, this.height);
Rectangle pixelBounds = new Rectangle(x, y, w, h);
if (filterBounds.intersects(pixelBounds))
{
Rectangle bounds = filterBounds.intersection(pixelBounds);
byte[] cropped = new byte[bounds.width * bounds.height];
for (int i = 0; i < bounds.height; i++)
{
int start = (bounds.y - pixelBounds.y + i) * scansize + offset;
for (int j = 0; j < bounds.width; j++)
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
consumer.setPixels(bounds.x, bounds.y,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
}
}
/**
@ -133,7 +154,27 @@ public class CropImageFilter extends ImageFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
Rectangle filterBounds = new Rectangle(this.x, this.y,
this.width, this.height);
Rectangle pixelBounds = new Rectangle(x, y, w, h);
if (filterBounds.intersects(pixelBounds))
{
Rectangle bounds = filterBounds.intersection(pixelBounds);
int[] cropped = new int[bounds.width * bounds.height];
for (int i = 0; i < bounds.height; i++)
{
int start = (bounds.y - pixelBounds.y + i) * scansize + offset;
for (int j = 0; j < bounds.width; j++)
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
consumer.setPixels(bounds.x, bounds.y,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
}
}
}

View file

@ -257,9 +257,15 @@ public class MemoryImageSource implements ImageProducer
ic.setProperties( props );
}
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
int[] pixelbuf = new int[w * h];
for (int row = y; row < h; row++)
System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w);
ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w );
} else {
ic.setPixels( 0, 0, width, height, cm, pixelb, offset, scansize );
byte[] pixelbuf = new byte[w * h];
for (int row = y; row < h; row++)
System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w);
ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w );
}
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
@ -296,9 +302,15 @@ public class MemoryImageSource implements ImageProducer
ic.setProperties( props );
}
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
int[] pixelbuf = new int[w * h];
for (int row = y; row < h; row++)
System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w);
ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w );
} else {
ic.setPixels( 0, 0, width, height, cm, pixelb, offset, scansize );
byte[] pixelbuf = new byte[w * h];
for (int row = y; row < h; row++)
System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w);
ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w );
}
if( framenotify == true )
ic.imageComplete( ImageConsumer.SINGLEFRAME );
@ -313,9 +325,14 @@ public class MemoryImageSource implements ImageProducer
int scansize)
{
pixeli = null;
pixelb = newpix;
cm = newmodel;
this.offset = offset;
this.scansize = scansize;
if( animated == true )
{
//FIXME
newPixels();
}
}
@ -325,9 +342,14 @@ public class MemoryImageSource implements ImageProducer
int scansize)
{
pixelb = null;
pixeli = newpix;
cm = newmodel;
this.offset = offset;
this.scansize = scansize;
if( animated == true )
{
//FIXME
newPixels();
}
}

View file

@ -46,7 +46,7 @@ package java.awt.image;
*/
public abstract class RGBImageFilter extends ImageFilter
{
protected ColorModel origmodel = ColorModel.getRGBdefault();
protected ColorModel origmodel;
protected ColorModel newmodel;
@ -126,7 +126,7 @@ public abstract class RGBImageFilter extends ImageFilter
private int makeColor( byte a, byte r, byte g, byte b )
{
return ( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (b << 8) | 0xff & g );
return ( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (g << 8) | 0xff & b );
}
/**
@ -149,11 +149,15 @@ public abstract class RGBImageFilter extends ImageFilter
int off,
int scansize)
{
int xp, yp;
int xp, yp, i;
i = 0;
for( xp = x; xp < ( x + w); xp++ )
for( yp = y; yp < (y + h); yp++ )
pixels[ off + yp * scansize + xp ] = filterRGB( xp, yp, pixels[ off + yp * scansize + xp ] );
{
pixels[i] = filterRGB( xp, yp, pixels[i] );
i++;
}
}
@ -172,15 +176,19 @@ public abstract class RGBImageFilter extends ImageFilter
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
ColorModel model, byte[] pixels,
int offset, int scansize)
{
if( model == origmodel ) {
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
} else {
//FIXME
//convert to proper CM
int pixelsi[] = new int[ pixels.length / 4 ];
filterRGBPixels( x, y, w, h, pixelsi, offset, scansize );
}
else
{
int intPixels[] =
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, intPixels, offset, scansize );
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, offset, scansize);
}
}
@ -199,35 +207,53 @@ public abstract class RGBImageFilter extends ImageFilter
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
ColorModel model, int[] pixels,
int offset, int scansize)
{
if( model == origmodel ) {
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
} else {
}
else
{
//FIXME: Store the filtered pixels in a separate temporary buffer?
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, pixels, offset, scansize );
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
}
}
private void convertColorModelToDefault( int x, int y, int w, int h,
ColorModel model, int pixels[], int offset, int scansize)
{
int xp, yp;
private int[] convertColorModelToDefault(int x, int y, int w, int h,
ColorModel model, byte pixels[],
int offset, int scansize)
{
int intPixels[] = new int[pixels.length];
for (int i = 0; i < pixels.length; i++)
intPixels[i] = makeColorbyDefaultCM(model, pixels[i]);
return intPixels;
}
for( xp = x; xp < ( x + w); xp++ )
for( yp = y; yp < (y + h); yp++ )
pixels[ offset + yp * scansize + xp ] = makeColorbyDefaultCM( pixels[ offset + yp * scansize + xp ] );
}
private int makeColorbyDefaultCM( int rgb )
{
return makeColor( origmodel.getRed( rgb ), origmodel.getGreen( rgb ), origmodel.getGreen( rgb ), origmodel.getBlue( rgb ) );
}
private void convertColorModelToDefault(int x, int y, int w, int h,
ColorModel model, int pixels[],
int offset, int scansize)
{
for (int i = 0; i < pixels.length; i++)
pixels[i] = makeColorbyDefaultCM(model, pixels[i]);
}
private int makeColorbyDefaultCM(ColorModel model, byte rgb)
{
return makeColor( model.getAlpha( rgb ) * 4, model.getRed( rgb ) * 4, model.getGreen( rgb ) * 4, model.getBlue( rgb ) * 4 );
}
private int makeColorbyDefaultCM(ColorModel model, int rgb)
{
return makeColor( model.getAlpha( rgb ), model.getRed( rgb ), model.getGreen( rgb ), model.getBlue( rgb ) );
}
private int makeColor( int a, int r, int g, int b )
{
return (int)( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (b << 8) | 0xff & g );
return (int)( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (g << 8) | 0xff & b );
}

View file

@ -104,7 +104,27 @@ public class ReplicateScaleFilter extends ImageFilter
*/
public void setDimensions(int width, int height)
{
consumer.setDimensions(width, height);
srcWidth = width;
srcHeight = height;
/* If either destHeight or destWidth is < 0, the image should
maintain its original aspect ratio. When both are < 0,
just maintain the original width and height. */
if (destWidth < 0 && destHeight < 0)
{
destWidth = width;
destHeight = height;
}
else if (destWidth < 0)
{
destWidth = (int) (width * ((double) destHeight / srcHeight));
}
else if (destHeight < 0)
{
destHeight = (int) (height * ((double) destWidth / srcWidth));
}
consumer.setDimensions(destWidth, destHeight);
}
/**
@ -136,7 +156,18 @@ public class ReplicateScaleFilter extends ImageFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
int destScansize = (int) Math.round(scansize / rx);
byte[] destPixels = replicatePixels(x, y, w, h,
model, pixels, offset, scansize,
rx, ry, destScansize);
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
/**
@ -156,8 +187,58 @@ public class ReplicateScaleFilter extends ImageFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
int destScansize = (int) Math.round(scansize / rx);
int[] destPixels = replicatePixels(x, y, w, h,
model, pixels, offset, scansize,
rx, ry, destScansize);
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
protected byte[] replicatePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, byte[] srcPixels,
int srcOffset, int srcScansize,
double rx, double ry, int destScansize)
{
byte[] destPixels =
new byte[(int) Math.ceil(srcw/rx) * (int) Math.ceil(srch/ry)];
int a, b;
for (int i = 0; i < destPixels.length; i++)
{
a = (int) ((int) ( ((double) i) / destScansize) * ry) * srcScansize;
b = (int) ((i % destScansize) * rx);
if ((a + b + srcOffset) < srcPixels.length)
destPixels[i] = srcPixels[a + b + srcOffset];
}
return destPixels;
}
protected int[] replicatePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, int[] srcPixels,
int srcOffset, int srcScansize,
double rx, double ry, int destScansize)
{
int[] destPixels =
new int[(int) Math.ceil(srcw/rx) * (int) Math.ceil(srch/ry)];
int a, b;
for (int i = 0; i < destPixels.length; i++)
{
a = (int) ((int) ( ((double) i) / destScansize) * ry) * srcScansize;
b = (int) ((i % destScansize) * rx);
if ((a + b + srcOffset) < srcPixels.length)
destPixels[i] = srcPixels[a + b + srcOffset];
}
return destPixels;
}
}

View file

@ -39,6 +39,12 @@ exception statement from your version. */
package javax.swing;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import java.awt.LayoutManager;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.AWTError;
/**
* Needs some work I guess....
@ -49,8 +55,127 @@ public class Box extends JComponent implements Accessible
{
private static final long serialVersionUID = 1525417495883046342L;
public Box(int a)
protected class AccessibleBox extends AccessibleAWTContainer
{
setLayout(new BoxLayout(this, a));
protected AccessibleBox()
{
}
public AccessibleRole getAccessibleRole()
{
return null;
}
}
public static class Filler extends JComponent implements Accessible
{
protected class AccessibleBoxFiller// extends AccessibleAWTComponent
{
protected AccessibleBoxFiller()
{
}
public AccessibleRole getAccessibleRole()
{
return null;
}
}
protected AccessibleContext accessibleContext;
private transient Dimension min, pref, max;
public Filler(Dimension min, Dimension pref, Dimension max)
{
changeShape(min, pref, max);
}
public void changeShape(Dimension min, Dimension pref, Dimension max)
{
this.min = min;
this.pref = pref;
this.max = max;
}
public AccessibleContext getAccessibleContext()
{
// if (accessibleContext == null)
// accessibleContext = new AccessibleBoxFiller();
return accessibleContext;
}
public Dimension getMaximumSize()
{
return max;
}
public Dimension getMinimumSize()
{
return min;
}
public Dimension getPreferredSize()
{
return pref;
}
}
public Box(int axis)
{
setLayout(new BoxLayout(this, axis));
}
public static Component createGlue()
{
return null;
}
public static Box createHorizontalBox()
{
return null;
}
public static Component createHorizontalGlue()
{
return null;
}
public static Component createHorizontalStrut(int width)
{
return null;
}
public static Component createRigidArea(Dimension d)
{
return null;
}
public static Box createVerticalBox()
{
return null;
}
public static Component createVerticalGlue()
{
return null;
}
public static Component createVerticalStrut(int height)
{
return null;
}
public void setLayout(LayoutManager l)
{
throw new AWTError("Not allowed to set layout managers for boxes.");
}
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleBox();
return accessibleContext;
}
}

View file

@ -49,7 +49,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import javax.accessibility.AccessibleContext;
public class JApplet extends Applet
public class JApplet extends Applet implements RootPaneContainer
{
public final static int HIDE_ON_CLOSE = 0;
@ -87,20 +87,20 @@ public class JApplet extends Applet
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -109,19 +109,19 @@ public class JApplet extends Applet
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -39,135 +39,210 @@ package javax.swing;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.3 $
*/
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "CheckBoxMenuItemUI";
private boolean state;
private Object[] selectedObjects;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JCheckBoxMenuItem object.
*/
public JCheckBoxMenuItem()
{
this(null, null);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JCheckBoxMenuItem(Icon icon)
{
this(null, icon);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text)
{
this(text, null);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JCheckBoxMenuItem(Action action)
{
this();
setAction(action);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, Icon icon)
{
this(text, icon, false);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param state DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, boolean state)
{
this(text, null, state);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param state DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, Icon icon, boolean state)
{
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
this.state = state;
} // JCheckBoxMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public boolean getState()
{
return state;
} // getState()
}
/**
* DOCUMENT ME!
*
* @param state DOCUMENT ME!
*/
public synchronized void setState(boolean state)
{
this.state = state;
} // setState()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public Object[] getSelectedObjects()
{
return selectedObjects;
} // getSelectedObjects()
}
/**
* DOCUMENT ME!
*/
public void requestFocus()
{
// TODO
} // requestFocus()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JCheckBoxMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJCheckBoxMenuItem(this);
}
accessibleContext = new AccessibleJCheckBoxMenuItem(this);
return accessibleContext;
} // getAccessibleContext()
}
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.3 $
*/
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJCheckBoxMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJCheckBoxMenuItem(JCheckBoxMenuItem component)
{
super(component);
// TODO
} // AccessibleJCheckBoxMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.CHECK_BOX;
} // getAccessibleRole()
} // AccessibleJCheckBoxMenuItem
} // JCheckBoxMenuItem
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,6 @@ 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;
import java.awt.BorderLayout;
@ -45,251 +44,518 @@ import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.LayoutManager;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.IllegalComponentStateException;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
/**
* Unlike JComponent derivatives, JDialog inherits from
* java.awt.Dialog. But also lets a look-and-feel component to its work.
* Unlike JComponent derivatives, JDialog inherits from java.awt.Dialog. But
* also lets a look-and-feel component to its work.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
* @author Ronald Veldema (rveldema_AT_cs.vu.nl)
*/
public class JDialog extends Dialog implements Accessible, WindowConstants
public class JDialog extends Dialog implements Accessible, WindowConstants,
RootPaneContainer
{
protected AccessibleContext accessibleContext;
private int close_action = HIDE_ON_CLOSE;
/** DOCUMENT ME! */
protected AccessibleContext accessibleContext;
/***************************************************
*
*
* constructors
*
*
*************/
/** The single RootPane in the Dialog. */
protected JRootPane rootPane;
public JDialog(Frame owner)
{
this(owner, "dialog");
}
public JDialog(Frame owner,
String s)
{
this(owner, s, true);
}
public JDialog(Frame owner,
String s,
boolean modeld)
{
super(owner, s, modeld);
}
/** Whether checking is enabled on the RootPane */
protected boolean rootPaneCheckingEnabled = true;
public JDialog(Frame owner,
// String s,
boolean modeld)
{
super(owner, "JDialog", modeld);
}
/** The default action taken when closed. */
private int close_action = HIDE_ON_CLOSE;
/** Whether JDialogs are decorated by the L&F. */
private static boolean decorated = false;
/**
* Creates a new non-modal JDialog with no title
* using a shared Frame as the owner.
*/
public JDialog()
{
this(SwingUtilities.getOwnerFrame(), "", false, null);
}
/**
* Creates a new non-modal JDialog with no title
* using the given owner.
*
* @param owner The owner of the JDialog.
*/
public JDialog(Dialog owner)
{
this(owner, "dialog");
this(owner, "", false, null);
}
public JDialog(Dialog owner,
String s)
{
this(owner, s, true);
}
public JDialog(Dialog owner,
String s,
boolean modeld)
{
super(owner, s, modeld);
}
/**
* Creates a new JDialog with no title using the
* given modal setting and owner.
*
* @param owner The owner of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Dialog owner, boolean modal)
{
this(owner, "", modal, null);
}
/***************************************************
*
*
* methods, this part is shared with JDialog, JFrame
*
*
*************/
/**
* Creates a new non-modal JDialog using the
* given title and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
*/
public JDialog(Dialog owner, String title)
{
this(owner, title, false, null);
}
private boolean checking;
protected JRootPane rootPane;
/**
* Creates a new JDialog using the given modal
* settings, title, and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Dialog owner, String title, boolean modal)
{
this(owner, title, modal, null);
}
void setLocationRelativeTo(Component c)
{
}
/**
* Creates a new JDialog using the given modal
* settings, title, owner and graphics configuration.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
* @param gc The Graphics Configuration to use.
*/
public JDialog(Dialog owner, String title, boolean modal,
GraphicsConfiguration gc)
{
super(owner, title, modal, gc);
dialogInit();
}
/**
* Creates a new non-modal JDialog with no title
* using the given owner.
*
* @param owner The owner of the JDialog.
*/
public JDialog(Frame owner)
{
this(owner, "", false, null);
}
protected void frameInit()
{
super.setLayout(new BorderLayout(1, 1));
getRootPane(); // will do set/create
}
/**
* Creates a new JDialog with no title using the
* given modal setting and owner.
*
* @param owner The owner of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Frame owner, boolean modal)
{
this(owner, "", modal, null);
}
/**
* Creates a new non-modal JDialog using the
* given title and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
*/
public JDialog(Frame owner, String title)
{
this(owner, title, false, null);
}
/**
* Creates a new JDialog using the given modal
* settings, title, and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Frame owner, String title, boolean modal)
{
this(owner, title, modal, null);
}
/**
* Creates a new JDialog using the given modal
* settings, title, owner and graphics configuration.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
* @param gc The Graphics Configuration to use.
*/
public JDialog(Frame owner, String title, boolean modal,
GraphicsConfiguration gc)
{
super((owner == null) ? SwingUtilities.getOwnerFrame() : owner,
title, modal, gc);
dialogInit();
}
/**
* This method is called to initialize the
* JDialog. It sets the layout used, the locale,
* and creates the RootPane.
*/
protected void dialogInit()
{
// FIXME: Do a check on GraphicsEnvironment.isHeadless()
setRootPaneCheckingEnabled(false);
setLocale(JComponent.getDefaultLocale());
getRootPane(); // will do set/create
setRootPaneCheckingEnabled(true);
invalidate();
}
/**
* This method returns whether JDialogs will have their
* window decorations provided by the Look and Feel.
*
* @return Whether the window decorations are L&F provided.
*/
public static boolean isDefaultLookAndFeelDecorated()
{
return decorated;
}
/**
* This method sets whether JDialogs will have their
* window decorations provided by the Look and Feel.
*
* @param defaultLookAndFeelDecorated Whether the window
* decorations are L&F provided.
*/
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
{
decorated = defaultLookAndFeelDecorated;
}
/**
* This method returns the preferred size of
* the JDialog.
*
* @return The preferred size.
*/
public Dimension getPreferredSize()
{
Dimension d = super.getPreferredSize();
return d;
}
JMenuBar getJMenuBar()
{ return getRootPane().getJMenuBar(); }
void setJMenuBar(JMenuBar menubar)
{ getRootPane().setJMenuBar(menubar); }
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
rootPane = root;
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }
protected void addImpl(Component comp, Object constraints, int index)
{ super.addImpl(comp, constraints, index); }
public void remove(Component comp)
{ getContentPane().remove(comp); }
protected boolean isRootPaneCheckingEnabled()
{ return checking; }
protected void setRootPaneCheckingEnabled(boolean enabled)
{ checking = enabled; }
public void update(Graphics g)
{ paint(g); }
protected void processKeyEvent(KeyEvent e)
{ super.processKeyEvent(e); }
/////////////////////////////////////////////////////////////////////////////////
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
switch (e.getID())
{
case WindowEvent.WINDOW_CLOSING:
{
switch(close_action)
{
case EXIT_ON_CLOSE:
{
System.exit(0);
break;
}
case DISPOSE_ON_CLOSE:
{
dispose();
break;
}
case HIDE_ON_CLOSE:
{
setVisible(false);
break;
}
case DO_NOTHING_ON_CLOSE:
break;
}
break;
}
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
break;
}
}
/**
* This method returns the JMenuBar used
* in this JDialog.
*
* @return The JMenuBar in the JDialog.
*/
public JMenuBar getJMenuBar()
{
return getRootPane().getJMenuBar();
}
/**
* Defines what happens when this frame is closed. Can be one off
* <code>EXIT_ON_CLOSE</code>,
* <code>DISPOSE_ON_CLOSE</code>,
* <code>HIDE_ON_CLOSE</code> or
* <code>DO_NOTHING_ON_CLOSE</code>.
* The default is <code>HIDE_ON_CLOSE</code>.
* When <code>EXIT_ON_CLOSE</code> is specified this method calls
* <code>SecurityManager.checkExit(0)</code> which might throw a
* <code>SecurityException</code>. When the specified operation is
* not one of the above a <code>IllegalArgumentException</code> is
* thrown.
* This method sets the JMenuBar used
* in this JDialog.
*
* @param menubar The JMenuBar to use.
*/
public void setJMenuBar(JMenuBar menubar)
{
getRootPane().setJMenuBar(menubar);
}
/**
* This method sets the LayoutManager used in the JDialog.
* This method will throw an Error if rootPaneChecking is
* enabled.
*
* @param manager The LayoutManager to use.
*/
public void setLayout(LayoutManager manager)
{
if (isRootPaneCheckingEnabled())
throw new Error("rootPaneChecking is enabled - cannot set layout.");
super.setLayout(manager);
}
/**
* This method sets the JLayeredPane used in the JDialog.
* If the given JLayeredPane is null, then this method
* will throw an Error.
*
* @param layeredPane The JLayeredPane to use.
*/
public void setLayeredPane(JLayeredPane layeredPane)
{
if (layeredPane == null)
throw new IllegalComponentStateException("layeredPane cannot be null.");
getRootPane().setLayeredPane(layeredPane);
}
/**
* This method returns the JLayeredPane used with this JDialog.
*
* @return The JLayeredPane used with this JDialog.
*/
public JLayeredPane getLayeredPane()
{
return getRootPane().getLayeredPane();
}
/**
* This method returns the JRootPane used with this JDialog.
*
* @return The JRootPane used with this JDialog.
*/
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
/**
* This method sets the JRootPane used with this JDialog.
*
* @param root The JRootPane to use.
*/
protected void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
rootPane = root;
rootPane.show();
add(rootPane);
}
/**
* This method creates a new JRootPane.
*
* @return A new JRootPane.
*/
protected JRootPane createRootPane()
{
return new JRootPane();
}
/**
* This method returns the ContentPane
* in the JRootPane.
*
* @return The ContentPane in the JRootPane.
*/
public Container getContentPane()
{
return getRootPane().getContentPane();
}
/**
* This method sets the ContentPane to use with this
* JDialog. If the ContentPane given is null, this method
* will throw an exception.
*
* @param contentPane The ContentPane to use with the JDialog.
*/
public void setContentPane(Container contentPane)
{
if (contentPane == null)
throw new IllegalComponentStateException("contentPane cannot be null.");
getRootPane().setContentPane(contentPane);
}
/**
* This method returns the GlassPane for this JDialog.
*
* @return The GlassPane for this JDialog.
*/
public Component getGlassPane()
{
return getRootPane().getGlassPane();
}
/**
* This method sets the GlassPane for this JDialog.
*
* @param glassPane The GlassPane for this JDialog.
*/
public void setGlassPane(Component glassPane)
{
getRootPane().setGlassPane(glassPane);
}
/**
* This method is called when a component is added to the
* the JDialog. Calling this method with rootPaneCheckingEnabled
* will cause an Error to be thrown.
*
* @param comp The component to add.
* @param constraints The constraints.
* @param index The position of the component.
*/
protected void addImpl(Component comp, Object constraints, int index)
{
if (isRootPaneCheckingEnabled())
throw new Error("rootPaneChecking is enabled - adding components disallowed.");
super.addImpl(comp, constraints, index);
}
/**
* This method removes a component from the JDialog.
*
* @param comp The component to remove.
*/
public void remove(Component comp)
{
// The path changes if the component == root.
if (comp == rootPane)
super.remove(rootPane);
else
getContentPane().remove(comp);
}
/**
* This method returns whether rootPane checking is enabled.
*
* @return Whether rootPane checking is enabled.
*/
protected boolean isRootPaneCheckingEnabled()
{
return rootPaneCheckingEnabled;
}
/**
* This method sets whether rootPane checking is enabled.
*
* @param enabled Whether rootPane checking is enabled.
*/
protected void setRootPaneCheckingEnabled(boolean enabled)
{
rootPaneCheckingEnabled = enabled;
}
/**
* This method simply calls paint and returns.
*
* @param g The Graphics object to paint with.
*/
public void update(Graphics g)
{
paint(g);
}
/**
* This method handles window events. This allows the JDialog
* to honour its default close operation.
*
* @param e The WindowEvent.
*/
protected void processWindowEvent(WindowEvent e)
{
// System.out.println("PROCESS_WIN_EV-1: " + e);
super.processWindowEvent(e);
// System.out.println("PROCESS_WIN_EV-2: " + e);
switch (e.getID())
{
case WindowEvent.WINDOW_CLOSING:
{
switch (getDefaultCloseOperation())
{
case DISPOSE_ON_CLOSE:
{
dispose();
break;
}
case HIDE_ON_CLOSE:
{
setVisible(false);
break;
}
case DO_NOTHING_ON_CLOSE:
break;
}
break;
}
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
break;
}
}
/**
* This method sets the action to take
* when the JDialog is closed.
*
* @param operation The action to take.
*/
public void setDefaultCloseOperation(int operation)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null && operation == EXIT_ON_CLOSE)
sm.checkExit(0);
if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE
&& operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE)
throw new IllegalArgumentException("operation = " + operation);
close_action = operation;
if (operation == DO_NOTHING_ON_CLOSE ||
operation == HIDE_ON_CLOSE ||
operation == DISPOSE_ON_CLOSE)
close_action = operation;
else
throw new IllegalArgumentException("Default close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
}
/**
* This method returns the action taken when
* the JDialog is closed.
*
* @return The action to take.
*/
public int getDefaultCloseOperation()
{ return close_action; }
{
return close_action;
}
protected String paramString()
{ return "JDialog"; }
/**
* This method returns a String describing the JDialog.
*
* @return A String describing the JDialog.
*/
protected String paramString()
{
return "JDialog";
}
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
}

View file

@ -57,7 +57,7 @@ import javax.accessibility.AccessibleContext;
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JFrame extends Frame implements WindowConstants
public class JFrame extends Frame implements WindowConstants, RootPaneContainer
{
protected AccessibleContext accessibleContext;
@ -121,20 +121,20 @@ public class JFrame extends Frame implements WindowConstants
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -143,19 +143,19 @@ public class JFrame extends Frame implements WindowConstants
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
public Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -329,7 +329,7 @@ public class JLayeredPane extends JComponent implements Accessible
throw new IllegalArgumentException ();
super.swapComponents (curr, targ);
validate();
revalidate();
repaint();
}
@ -537,7 +537,7 @@ public class JLayeredPane extends JComponent implements Accessible
{
componentToLayer.put (c, getObjectForLayer (layer));
setPosition(c, position);
validate();
revalidate();
repaint();
}
@ -562,13 +562,13 @@ public class JLayeredPane extends JComponent implements Accessible
else
layer = DEFAULT_LAYER;
int newIdx = insertIndexForLayer(layer.intValue (), -1);
int newIdx = insertIndexForLayer(layer.intValue (), index);
componentToLayer.put (comp, layer);
incrLayer (layer);
super.addImpl(comp, null, newIdx);
validate();
revalidate();
repaint();
}
}

View file

@ -40,6 +40,7 @@ package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.Vector;
import javax.accessibility.Accessible;
@ -531,6 +532,19 @@ public class JList extends JComponent implements Accessible, Scrollable
selectionModel.setSelectionInterval(a, a);
}
/**
* For each element <code>a[i]</code> of the provided array
* <code>a</code>, calls {@link #setSelectedIndex} on <code>a[i]</code>.
*
* @see #setSelectionMode
* @see #selectionModel
*/
public void setSelectedIndices(int [] a)
{
for (int i = 0; i < a.length; ++i)
setSelectedIndex(a[i]);
}
/**
* Returns the minimum index of an element in the list which is currently
* selected.
@ -545,6 +559,32 @@ public class JList extends JComponent implements Accessible, Scrollable
return selectionModel.getMinSelectionIndex();
}
/**
* Returns the indices of values in the {@link #model} property which are
* selected.
*
* @return An array of model indices, each of which is selected according
* to the {@link #selection} property
*/
public int[] getSelectedIndices()
{
int lo, hi, n, i, j;
if (selectionModel.isSelectionEmpty())
return new int[0];
lo = selectionModel.getMinSelectionIndex();
hi = selectionModel.getMaxSelectionIndex();
n = 0;
for (i = lo; i < hi; ++i)
if (selectionModel.isSelectedIndex(i))
n++;
int [] v = new int[n];
j = 0;
for (i = lo; i < hi; ++i)
if (selectionModel.isSelectedIndex(i))
v[j++] = i;
return v;
}
/**
* Indicates whether the list element at a given index value is
* currently selected.
@ -568,6 +608,8 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @return The first selected element, or <code>null</code> if no element
* is selected.
*
* @see getSelectedValues
*/
public Object getSelectedValue()
{
@ -577,6 +619,23 @@ public class JList extends JComponent implements Accessible, Scrollable
return getModel().getElementAt(index);
}
/**
* Returns all the values in the list's {@link #model} property which
* are selected, according to the list's {@link #selectionModel} property.
*
* @return An array containing all the selected values
*
* @see getSelectedValue
*/
public Object[] getSelectedValues()
{
int [] idx = getSelectedIndices();
Object [] v = new Object[idx.length];
for (int i = 0; i < idx.length; ++i)
v[i] = getModel().getElementAt(i);
return v;
}
/**
* Gets the value of the {@link #selectionBackground} property.
*
@ -720,6 +779,8 @@ public class JList extends JComponent implements Accessible, Scrollable
if (model != null)
model.addListDataListener(listListener);
firePropertyChange(MODEL_PROPERTY_CHANGED, old, m);
revalidate();
repaint();
}
@ -744,6 +805,8 @@ public class JList extends JComponent implements Accessible, Scrollable
if (selectionModel != null)
selectionModel.addListSelectionListener(listListener);
firePropertyChange(SELECTION_MODEL_PROPERTY_CHANGED, old, l);
revalidate();
repaint();
}
/**
@ -842,11 +905,11 @@ public class JList extends JComponent implements Accessible, Scrollable
* {@link Scrollable} interface, which interacts with {@link
* ScrollPaneLayout} and {@link Viewport} to define scrollable objects.
*
* @return The preferred size, or <code>null</code>
* @return The preferred size
*/
public Dimension getPreferredScrollableViewportSize()
{
return null;
return getPreferredSize();
}
/**
@ -875,6 +938,71 @@ public class JList extends JComponent implements Accessible, Scrollable
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction)
{
ListUI lui = this.getUI();
if (orientation == SwingConstants.VERTICAL)
{
if (direction > 0)
{
// Scrolling down
Point bottomLeft = new Point(visibleRect.x,
visibleRect.y + visibleRect.height);
int curIdx = lui.locationToIndex(this, bottomLeft);
Rectangle curBounds = lui.getCellBounds(this, curIdx, curIdx);
if (curBounds.y + curBounds.height == bottomLeft.y)
{
// we are at the exact bottom of the current cell, so we
// are being asked to scroll to the end of the next one
if (curIdx + 1 < model.getSize())
{
// there *is* a next item in the list
Rectangle nxtBounds = lui.getCellBounds(this, curIdx + 1, curIdx + 1);
return nxtBounds.height;
}
else
{
// no next item, no advance possible
return 0;
}
}
else
{
// we are part way through an existing cell, so we are being
// asked to scroll to the bottom of it
return (curBounds.y + curBounds.height) - bottomLeft.y;
}
}
else
{
// scrolling up
Point topLeft = new Point(visibleRect.x, visibleRect.y);
int curIdx = lui.locationToIndex(this, topLeft);
Rectangle curBounds = lui.getCellBounds(this, curIdx, curIdx);
if (curBounds.y == topLeft.y)
{
// we are at the exact top of the current cell, so we
// are being asked to scroll to the top of the previous one
if (curIdx > 0)
{
// there *is* a previous item in the list
Rectangle nxtBounds = lui.getCellBounds(this, curIdx - 1, curIdx - 1);
return -nxtBounds.height;
}
else
{
// no previous item, no advance possible
return 0;
}
}
else
{
// we are part way through an existing cell, so we are being
// asked to scroll to the top of it
return curBounds.y - topLeft.y;
}
}
}
// FIXME: handle horizontal scrolling (also wrapping?)
return 1;
}
@ -904,7 +1032,10 @@ public class JList extends JComponent implements Accessible, Scrollable
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction)
{
return 1;
if (orientation == VERTICAL)
return visibleRect.height * direction;
else
return visibleRect.width * direction;
}
/**

File diff suppressed because it is too large Load diff

View file

@ -35,13 +35,392 @@ 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;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleSelection;
import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleValue;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuBarUI;
import javax.swing.plaf.MenuItemUI;
public class JMenuBar extends JComponent
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.1 $
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
JMenuBar()
{
}
private transient SingleSelectionModel selectionModel;
private boolean paintBorder;
private Insets margin;
/**
* Creates a new JMenuBar object.
*/
public JMenuBar()
{
selectionModel = new DefaultSingleSelectionModel();
paintBorder = true;
updateUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu add(JMenu c)
{
c.setAlignmentX(Component.LEFT_ALIGNMENT);
super.add(c);
return c;
}
/**
* DOCUMENT ME!
*/
public void addNotify()
{
// FIXME: Should register this menu bar with the keyboard manager
super.addNotify();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component getComponent()
{
return this;
}
/**
* DOCUMENT ME!
*
* @param i DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component getComponentAtIndex(int i)
{
return getComponentAt(i);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getComponentIndex(Component c)
{
Component[] comps = getComponents();
int index = -1;
for (int i = 0; i < comps.length; i++)
{
if (comps[i].equals(c))
{
index = i;
break;
}
}
return index;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu getHelpMenu()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Insets getMargin()
{
if (margin == null)
return new Insets(0, 0, 0, 0);
else
return margin;
}
/**
* DOCUMENT ME!
*
* @param index DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu getMenu(int index)
{
if (getComponentAtIndex(index) instanceof JMenu)
return (JMenu) getComponentAtIndex(index);
else
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getMenuCount()
{
return getComponentCount();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public SingleSelectionModel getSelectionModel()
{
return selectionModel;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public MenuElement[] getSubElements()
{
MenuElement[] subElements = new MenuElement[getComponentCount()];
for (int i = 0; i < getComponentCount(); i++)
subElements[i] = (MenuElement) getMenu(i);
return subElements;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public MenuBarUI getUI()
{
return (MenuBarUI) ui;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getUIClassID()
{
return "MenuBarUI";
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isBorderPainted()
{
return paintBorder;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isManagingFocus()
{
return true;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isSelected()
{
return false;
}
/**
* DOCUMENT ME!
*
* @param isIncluded DOCUMENT ME!
*/
public void menuSelectionChanged(boolean isIncluded)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*
* @param g DOCUMENT ME!
*/
protected void paintBorder(Graphics g)
{
if (paintBorder)
getBorder().paintBorder(this, g, 0, 0, getSize(null).width,
getSize(null).height);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected String paramString()
{
return "JMenuBar";
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent e, MenuElement[] path,
MenuSelectionManager manager)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*/
public void removeNotify()
{
// Must unregister this menu bar with the current keyboard manager.
super.removeNotify();
}
/**
* DOCUMENT ME!
*
* @param b DOCUMENT ME!
*/
public void setBorderPainted(boolean b)
{
paintBorder = b;
}
/**
* DOCUMENT ME!
*
* @param menu DOCUMENT ME!
*/
public void setHelpMenu(JMenu menu)
{
}
/**
* DOCUMENT ME!
*
* @param m DOCUMENT ME!
*/
public void setMargin(Insets m)
{
this.margin = m;
}
/**
* DOCUMENT ME!
*
* @param sel DOCUMENT ME!
*/
public void setSelected(Component sel)
{
}
/**
* DOCUMENT ME!
*
* @param model DOCUMENT ME!
*/
public void setSelectionModel(SingleSelectionModel model)
{
}
/**
* DOCUMENT ME!
*
* @param ui DOCUMENT ME!
*/
public void setUI(MenuBarUI ui)
{
super.setUI(ui);
}
/**
* DOCUMENT ME!
*/
public void updateUI()
{
MenuBarUI ui = ((MenuBarUI) UIManager.getUI(this));
setUI(ui);
invalidate();
}
}

View file

@ -35,20 +35,22 @@ 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;
import java.awt.Component;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.EventListener;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
@ -57,48 +59,79 @@ import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.4 $
*/
public class JMenuItem extends AbstractButton implements Accessible,
MenuElement
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "MenuItemUI";
private KeyStroke accelerator;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JMenuItem object.
*/
public JMenuItem()
{
this(null, null);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JMenuItem(Icon icon)
{
this(null, icon);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JMenuItem(String text)
{
this(text, null);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JMenuItem(Action action)
{
// TODO
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JMenuItem(String text, Icon icon)
{
super(text, icon);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
* @param mnemonic DOCUMENT ME!
*/
public JMenuItem(String text, int mnemonic)
{
super(text, null);
setMnemonic(mnemonic);
} // JMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
@ -107,60 +140,116 @@ public class JMenuItem extends AbstractButton implements Accessible,
throws IOException, ClassNotFoundException
{
// TODO
} // readObject()
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
protected void init(String text, Icon icon)
{
// TODO
} // init()
}
/**
* DOCUMENT ME!
*
* @param ui DOCUMENT ME!
*/
public void setUI(MenuItemUI ui)
{
super.setUI(ui);
} // setUI()
}
/**
* DOCUMENT ME!
*/
public void updateUI()
{
MenuItemUI mi = ((MenuItemUI) UIManager.getUI(this));
setUI(mi);
invalidate();
} // updateUI()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public boolean isArmed()
{
return getModel().isArmed();
} // isArmed()
}
/**
* DOCUMENT ME!
*
* @param armed DOCUMENT ME!
*/
public void setArmed(boolean armed)
{
getModel().setArmed(armed);
} // setArmed()
}
/**
* DOCUMENT ME!
*
* @param enabled DOCUMENT ME!
*/
public void setEnabled(boolean enabled)
{
setEnabled(enabled);
} // setEnabled()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public KeyStroke getAccelerator()
{
return accelerator;
} // getAccelerator()
}
/**
* DOCUMENT ME!
*
* @param keystroke DOCUMENT ME!
*/
public void setAccelerator(KeyStroke keystroke)
{
this.accelerator = keystroke;
} // setAccelerator()
}
/**
* DOCUMENT ME!
*
* @param action DOCUMENT ME!
*/
protected void configurePropertiesFromAction(Action action)
{
super.configurePropertiesFromAction(action);
@ -169,147 +258,371 @@ public class JMenuItem extends AbstractButton implements Accessible,
setAccelerator(null);
else
setAccelerator((KeyStroke) (action.getValue(Action.ACCELERATOR_KEY)));
} // configurePropertiesFromAction()
}
/**
* DOCUMENT ME!
*
* @param action DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
return null;
} // createActionPropertyChangeListener()
return new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent e)
{
Action act = (Action) (e.getSource());
configurePropertiesFromAction(act);
}
};
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// TODO
} // processMouseEvent()
switch (event.getID())
{
case MouseEvent.MOUSE_CLICKED:
doClick();
break;
case MouseEvent.MOUSE_ENTERED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(true);
if (model.isPressed()
&& (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
model.setArmed(true);
else
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_EXITED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(false);
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_PRESSED:
if (event.getSource() instanceof JMenuItem)
{
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setArmed(true);
model.setPressed(true);
}
}
break;
case MouseEvent.MOUSE_RELEASED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setPressed(false);
model.setArmed(false);
manager.clearSelectedPath();
}
}
break;
case MouseEvent.MOUSE_MOVED:
break;
case MouseEvent.MOUSE_DRAGGED:
MenuDragMouseEvent e = new MenuDragMouseEvent((Component) event
.getSource(),
event.getID(),
event.getWhen(),
event.getModifiers(),
event.getX(),
event.getY(),
event.getClickCount(),
event.isPopupTrigger(),
path, manager);
processMenuDragMouseEvent(e);
break;
}
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// TODO
} // processKeyEvent()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void processMenuDragMouseEvent(MenuDragMouseEvent event)
{
} // processMenuDragMouseEvent()
switch (event.getID())
{
case MouseEvent.MOUSE_ENTERED:
fireMenuDragMouseEntered(event);
break;
case MouseEvent.MOUSE_EXITED:
fireMenuDragMouseExited(event);
break;
case MouseEvent.MOUSE_DRAGGED:
fireMenuDragMouseDragged(event);
break;
case MouseEvent.MOUSE_RELEASED:
fireMenuDragMouseReleased(event);
break;
}
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void processMenuKeyEvent(MenuKeyEvent event)
{
// TODO
} // processMenuKeyEvent()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseEntered()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseEntered(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseExited(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseExited()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseExited(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseDragged()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseDragged(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseReleased()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseReleased(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyPressed()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyReleased()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyTyped()
}
/**
* DOCUMENT ME!
*
* @param changed DOCUMENT ME!
*/
public void menuSelectionChanged(boolean changed)
{
// TODO
} // menuSelectionChanged()
if (changed)
model.setArmed(true);
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public MenuElement[] getSubElements()
{
return null; // TODO
} // getSubElements()
return new MenuElement[0];
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public Component getComponent()
{
return null; // TODO
} // getComponent()
return this;
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void addMenuDragMouseListener(MenuDragMouseListener listener)
{
// TODO
} // addMenuDragMouseListener()
listenerList.add(MenuDragMouseListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void removeMenuDragMouseListener(MenuDragMouseListener listener)
{
} // removeMenuDragMouseListener()
listenerList.remove(MenuDragMouseListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void addMenuKeyListener(MenuKeyListener listener)
{
} // addMenuKeyListener()
listenerList.add(MenuKeyListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void removeMenuKeyListener(MenuKeyListener listener)
{
} // removeMenuKeyListener()
listenerList.remove(MenuKeyListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJMenuItem(this);
}
accessibleContext = new AccessibleJMenuItem(this);
return accessibleContext;
} // getAccessibleContext()
}
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.4 $
*/
protected class AccessibleJMenuItem extends AccessibleAbstractButton
implements ChangeListener
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJMenuItem object.
*
* @param component DOCUMENT ME!
*/
AccessibleJMenuItem(JMenuItem component)
{
super(component);
// TODO
} // AccessibleJMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void stateChanged(ChangeEvent event)
{
// TODO
} // stateChanged()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.MENU_ITEM;
} // getAccessibleRole()
} // AccessibleJMenuItem
} // JMenuItem
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -39,118 +39,188 @@ package javax.swing;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.4 $
*/
public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "RadioButtonMenuItemUI";
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JRadioButtonMenuItem object.
*/
public JRadioButtonMenuItem()
{
this(null, null);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JRadioButtonMenuItem(Icon icon)
{
this(null, icon);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text)
{
this(text, null);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JRadioButtonMenuItem(Action action)
{
this();
setAction(action);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, Icon icon)
{
this(text, icon, false);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, boolean selected)
{
this(text, null, selected);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(Icon icon, boolean selected)
{
this(null, icon, selected);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, Icon icon, boolean selected)
{
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
model.setSelected(selected);
} // JRadioButtonMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*/
public void requestFocus()
{
// TODO
} // requestFocus()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JRadioButtonMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJRadioButtonMenuItem(this);
}
return accessibleContext;
} // getAccessibleContext()
accessibleContext = new AccessibleJRadioButtonMenuItem(this);
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
return accessibleContext;
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.4 $
*/
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem
{
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJRadioButtonMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJRadioButtonMenuItem(JRadioButtonMenuItem component)
{
super(component);
// TODO
} // AccessibleJRadioButtonMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.RADIO_BUTTON;
} // getAccessibleRole()
} // AccessibleJRadioButtonMenuItem
} // JRadioButtonMenuItem
}
}
}

View file

@ -43,6 +43,8 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;
import javax.swing.plaf.RootPaneUI;
/**
* This class is where JComponents are added to.
@ -64,42 +66,164 @@ public class JRootPane extends JComponent
static protected class AccessibleJRootPane
{
}
//A custom layout manager
static protected class RootLayout extends BorderLayout
// Custom Layout Manager for JRootPane. It positions contentPane and
// menuBar withing its layeredPane.
protected class RootLayout extends Object implements LayoutManager2
{
public Dimension preferredLayoutSize ( Container c )
{
Dimension p = super.preferredLayoutSize(c);
return p;
}
public void addLayoutComponent(Component comp, Object constraints)
{
}
public void addLayoutComponent(String name, Component comp)
{
}
public float getLayoutAlignmentX(Container target)
{
return target.getAlignmentX();
}
public float getLayoutAlignmentY(Container target)
{
return target.getAlignmentY();
}
public void invalidateLayout(Container target)
{
}
public void layoutContainer(Container c)
{
Dimension menuBarSize;
Dimension containerSize = c.getSize(null);
Dimension contentPaneSize = contentPane.getPreferredSize();
/*
if size of top-level window wasn't set then just set
contentPane and menuBar to its preferred sizes.
Otherwise, if the size of top-level window was specified then
set menuBar to its preferred size and make content pane
to fit into the remaining space
+-------------------------------+
| JLayeredPane |
| +--------------------------+ |
| | menuBar | |
| +--------------------------+ |
| +--------------------------+ |
| |contentPane | |
| | | |
| | | |
| | | |
| +--------------------------+ |
+-------------------------------+
*/
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
contentPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
layeredPane.setSize(maxWidth,
menuBarSize.height + contentPaneSize.height);
}
else
{
contentPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
}
}
else
{
if (menuBar != null)
{
menuBarSize = menuBar.getPreferredSize();
if (menuBarSize.height > containerSize.height)
menuBarSize.height = containerSize.height;
menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
int remainingHeight = containerSize.height - menuBarSize.height;
contentPane.setBounds(0, menuBarSize.height,
containerSize.width,
(containerSize.height - menuBarSize.height));
}
else
contentPane.setBounds(0, 0, containerSize.width,
containerSize.height);
layeredPane.setSize(containerSize.width, containerSize.height);
}
}
public Dimension maximumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension minimumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension preferredLayoutSize(Container c)
{
Dimension menuBarSize;
Dimension prefSize;
Dimension containerSize = c.getSize();
Dimension contentPaneSize = contentPane.getPreferredSize();
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
prefSize = new Dimension(maxWidth,
contentPaneSize.height
+ menuBarSize.height);
}
else
prefSize = contentPaneSize;
}
else
prefSize = c.getSize();
return prefSize;
}
public void removeLayoutComponent(Component comp)
{
}
}
/***********************************************************/
//The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.
protected Component glassPane;
//The layered pane that manages the menu bar and content pane.
protected JLayeredPane layeredPane;
// The menu bar.
protected JMenuBar menuBar;
protected JLayeredPane layeredPane;
protected JMenuBar menuBar;
protected Container contentPane;
/********************************************************/
public String getUIClassID()
{ return "RootPaneUI"; }
void setJMenuBar(JMenuBar m)
{ menuBar = m; }
{
menuBar = m;
getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
}
JMenuBar getJMenuBar()
{ return menuBar; }
public boolean isValidateRoot()
{
return true;
}
public Container getContentPane()
@ -122,7 +246,6 @@ public class JRootPane extends JComponent
int index)
{
super.addImpl(comp, constraints, index);
//System.out.println("don't do that !");
}
public Component getGlassPane()
@ -159,16 +282,12 @@ public class JRootPane extends JComponent
}
/********************************************************/
JRootPane()
{
setLayout(createRootLayout());
setBackground(UIManager.getColor("control"));
getGlassPane();
getLayeredPane();
getContentPane();
setDoubleBuffered(true);
updateUI();
}
@ -182,9 +301,6 @@ public class JRootPane extends JComponent
JPanel p = new JPanel();
p.setName(this.getName()+".contentPane");
p.setLayout(new BorderLayout());
// p.setVisible(true);
System.out.println("Created ContentPane: " + p);
return p;
}
@ -194,14 +310,34 @@ public class JRootPane extends JComponent
p.setName(this.getName()+".glassPane");
p.setLayout(new BorderLayout());
p.setVisible(false);
System.out.println("created the glasspane: "+p);
return p;
}
JLayeredPane createLayeredPane()
{
JLayeredPane l = new JLayeredPane();
l.setLayout(null);
return l;
}
public RootPaneUI getUI()
{
return (RootPaneUI) ui;
}
public void setUI(RootPaneUI ui)
{
super.setUI(ui);
}
public void updateUI()
{
setUI((RootPaneUI) UIManager.getUI(this));
}
public String getUIClassID()
{
return "RootPaneUI";
}
}

View file

@ -169,7 +169,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
protected BoundedRangeModel model;
/** The orientation of the scroll bar. */
protected int orientation = SwingConstants.HORIZONTAL;
protected int orientation = SwingConstants.VERTICAL;
/** How much the thumb moves when moving in a unit. */
protected int unitIncrement = 1;
@ -186,7 +186,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public JScrollBar()
{
this(SwingConstants.HORIZONTAL, 0, 10, 0, 100);
this(SwingConstants.VERTICAL, 0, 10, 0, 100);
}
/**

View file

@ -40,6 +40,8 @@ package javax.swing;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
@ -50,6 +52,7 @@ import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ScrollPaneUI;
import javax.swing.plaf.UIResource;
/**
* <table>
@ -430,7 +433,11 @@ public class JScrollPane
{
JViewport old = viewport;
removeNonNull(old);
if (old != null)
old.removeChangeListener(scrollListener);
viewport = v;
if (v != null)
v.addChangeListener(scrollListener);
addNonNull(v);
revalidate();
repaint();
@ -467,29 +474,64 @@ public class JScrollPane
ChangeListener createScrollListener()
{
return new ChangeListener() {
return new ChangeListener()
{
public void stateChanged(ChangeEvent event)
{
int xpos = 0;
int ypos = 0;
JScrollBar vsb = JScrollPane.this.getVerticalScrollBar();
JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar();
if (vsb != null)
{
BoundedRangeModel vmod = vsb.getModel();
if (vmod != null)
ypos = vmod.getValue();
}
JViewport vp = JScrollPane.this.getViewport();
if (hsb != null)
if (vp != null && event.getSource() == vp)
{
BoundedRangeModel hmod = hsb.getModel();
if (hmod != null)
xpos = hmod.getValue();
// if the viewport changed, we should update the VSB / HSB
// models according to the new vertical and horizontal sizes
Rectangle vr = vp.getViewRect();
Dimension vs = vp.getViewSize();
// System.err.println("got change from viewport, vr=" + vr + ", vs=" + vs);
if (vsb != null
&& (vsb.getMinimum() != 0
|| vsb.getMaximum() != vs.height
|| vsb.getValue() != vr.y
|| vsb.getVisibleAmount() != vr.height))
{
// System.err.println("setting vsb to "
// + "pos=" + vr.y
// + ", ext=" + vr.height
// + ", min=0"
// + ", max=" + vs.height);
vsb.setValue(vr.y, vr.height, 0, vs.height);
}
if (hsb != null
&& (hsb.getMinimum() != 0
|| hsb.getMaximum() != vs.width
|| hsb.getValue() != vr.width
|| hsb.getVisibleAmount() != vr.height))
hsb.setValue(vr.x, vr.width, 0, vs.width);
}
else
{
// otherwise we got a change update from either the VSB or
// HSB model, and we need to update the viewport position to
// match.
int xpos = 0;
int ypos = 0;
if (vsb != null)
ypos = vsb.getValue();
if (hsb != null)
xpos = hsb.getValue();
Point pt = new Point(xpos, ypos);
if (vp != null
&& vp.getViewPosition() != pt)
vp.setViewPosition(pt);
}
if (JScrollPane.this.viewport != null)
JScrollPane.this.viewport.setViewPosition(new Point(xpos, ypos));
}
};
}
@ -528,12 +570,12 @@ public class JScrollPane
public JScrollBar createHorizontalScrollBar()
{
return new JScrollBar(SwingConstants.HORIZONTAL);
return new ScrollBar(SwingConstants.HORIZONTAL);
}
public JScrollBar createVerticalScrollBar()
{
return new JScrollBar(SwingConstants.VERTICAL);
return new ScrollBar(SwingConstants.VERTICAL);
}
public JViewport createViewport()
@ -553,7 +595,7 @@ public class JScrollPane
setUI(b);
}
/*
class ScrollBar
extends JScrollBar
implements UIResource
@ -561,17 +603,37 @@ public class JScrollPane
public ScrollBar(int orientation)
{
super(orientation);
Component view = this.JScrollPane.getViewportView();
if (view == null)
return;
if (! view instanceof Scrollable)
}
public int getBlockIncrement(int direction)
{
Component view = JScrollPane.this.getViewport().getView();
if (view == null || (! (view instanceof Scrollable)))
return super.getBlockIncrement(direction);
else
{
Scrollable s = (Scrollable) view;
s.
return s.getScrollableBlockIncrement(JScrollPane.this.getViewport().getViewRect(),
this.getOrientation(),
direction);
}
}
}
*/
public int getUnitIncrement(int direction)
{
Component view = JScrollPane.this.getViewport().getView();
if (view == null || (! (view instanceof Scrollable)))
return super.getUnitIncrement(direction);
else
{
Scrollable s = (Scrollable) view;
return s.getScrollableUnitIncrement(JScrollPane.this.getViewport().getViewRect(),
this.getOrientation(),
direction);
}
}
}
}

View file

@ -304,7 +304,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
public JSlider(int minimum, int maximum)
{
this(HORIZONTAL, minimum, maximum, (maximum - minimum) / 2);
this(HORIZONTAL, minimum, maximum, (maximum + minimum) / 2);
}
/**

File diff suppressed because it is too large Load diff

View file

@ -114,7 +114,13 @@ public class JViewport extends JComponent
*
* @see #toViewCoordinates
*/
Dimension viewExtent;
Dimension extentSize;
/**
* The width and height of the view in its own coordinate space.
*/
Dimension viewSize;
Point lastPaintPosition;
@ -124,17 +130,35 @@ public class JViewport extends JComponent
updateUI();
}
public Dimension getViewSize()
public Dimension getExtentSize()
{
if (viewExtent == null)
if (extentSize == null)
return getPreferredSize();
else
return viewExtent;
return extentSize;
}
public void setExtentSize(Dimension newSize)
{
extentSize = newSize;
fireStateChanged();
}
public Dimension getViewSize()
{
if (viewSize == null)
return getView().getPreferredSize();
else
return viewSize;
}
public void setViewSize(Dimension newSize)
{
viewExtent = newSize;
viewSize = newSize;
Component view = getView();
if (view != null)
view.setSize(newSize);
fireStateChanged();
}
@ -166,7 +190,7 @@ public class JViewport extends JComponent
public Rectangle getViewRect()
{
return new Rectangle(getViewPosition(),
getViewSize());
getExtentSize());
}
public boolean isBackingStoreEnabled()
@ -207,7 +231,24 @@ public class JViewport extends JComponent
add(v);
fireStateChanged();
}
public void revalidate()
{
fireStateChanged();
super.revalidate();
}
public void reshape(int x, int y, int w, int h)
{
boolean changed =
(x != getX())
|| (y != getY())
|| (w != getWidth())
|| (h != getHeight());
super.reshape(x, y, w, h);
if (changed)
fireStateChanged();
}
public void addImpl(Component comp, Object constraints, int index)
{

View file

@ -58,7 +58,7 @@ import javax.accessibility.AccessibleContext;
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JWindow extends Window implements Accessible
public class JWindow extends Window implements Accessible, RootPaneContainer
{
public final static int HIDE_ON_CLOSE = 0;
public final static int EXIT_ON_CLOSE = 1;
@ -79,8 +79,8 @@ public class JWindow extends Window implements Accessible
*************/
public JWindow()
{
this(null);
{
super();
}
// huuu ?
@ -124,20 +124,20 @@ public class JWindow extends Window implements Accessible
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -146,19 +146,19 @@ public class JWindow extends Window implements Accessible
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -1,5 +1,5 @@
/* MenuSelectionManager.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,6 +38,15 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
@ -48,6 +57,10 @@ public class MenuSelectionManager
protected EventListenerList listenerList = new EventListenerList ();
private static final MenuSelectionManager manager = new MenuSelectionManager();
private Vector selection = new Vector();
protected void fireStateChanged ()
{
ChangeListener[] listeners = getChangeListeners ();
@ -73,4 +86,213 @@ public class MenuSelectionManager
{
return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
}
/**
* Unselects all the menu elements on the selection path
*/
public void clearSelectedPath ()
{
for (int i = 0; i < selection.size (); i++)
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.clear ();
}
public Component componentForPoint (Component source, Point sourcePoint)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Returns shared instance of MenuSelection Manager
*
* @return default Manager
*/
public static MenuSelectionManager defaultManager ()
{
return manager;
}
/**
* Returns path representing current menu selection
*
* @return Current selection path
*/
public MenuElement[] getSelectedPath ()
{
MenuElement[] path = new MenuElement[selection.size ()];
for (int i = 0; i < path.length; i++)
path[i] = (MenuElement) selection.get (i);
return path;
}
/**
* Returns true if specified component is part of current menu
* heirarchy and false otherwise
*
* @param c Component for which to check
* @return True if specified component is part of current menu
*/
boolean isComponentPartOfCurrentMenu (Component c)
{
MenuElement[] subElements;
for (int i = 0; i < selection.size (); i++)
{
subElements = ((MenuElement) selection.get (i)).getSubElements ();
for (int j = 0; j < subElements.length; j++)
{
if ((subElements[j].getComponent ()).equals (c))
return true;
}
}
return false;
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void processKeyEvent (KeyEvent e)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Forwards given mouse event to all of the source subcomponents.
*
* @param event Mouse event
*/
public void processMouseEvent (MouseEvent event)
{
Component c = ((MenuElement) event.getSource ()).getComponent ();
if (selection.size () == 0)
{
((MenuElement) event.getSource ()).processMouseEvent (event,
getPath (c),
manager);
return;
}
// find the index of the source component in the current menu hierarchy
int i = 0;
for (i = 0; i < selection.size (); i++)
{
MenuElement me = (MenuElement) selection.get (i);
if (me.getComponent ().equals (c))
break;
}
// Forward event to all subcomponents of the source
Component subComp;
for (int j = i; j < selection.size (); j++)
{
subComp = ((MenuElement)selection.get (j)).getComponent ();
((MenuElement) selection.get (j)).processMouseEvent (event,
getPath (subComp),
manager);
}
}
/**
* Sets menu selection to the specified path
*
* @param path new selection path
*/
public void setSelectedPath (MenuElement[] path)
{
if (path == null)
{
clearSelectedPath ();
return;
}
int i;
int minSize = path.length; // size of the smaller path.
if (path.length > selection.size ())
{
// if new selected path contains more elements then current
// selection then first add all elements at
// the indexes > selection.size
for (i = selection.size (); i < path.length; i++)
{
selection.add (path[i]);
path[i].menuSelectionChanged (true);
}
minSize = selection.size ();
}
else if (path.length < selection.size ())
{
// if new selected path contains less elements then current
// selection then first remove all elements from the selection
// at the indexes > path.length
for (i = selection.size () - 1; i >= path.length; i--)
{
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.remove (i);
}
minSize = path.length;
}
// Now compare elements in new and current selection path at the
// same location and adjust selection until
// same menu elements will be encountered at the
// same index in both current and new selection path.
MenuElement oldSelection;
for (i = minSize - 1; i >= 0; i--)
{
oldSelection = (MenuElement) selection.get (i);
if (path[i].equals (oldSelection))
break;
oldSelection.menuSelectionChanged (false);
path[i].menuSelectionChanged (true);
selection.setElementAt (path[i], i);
}
}
/**
* Returns path to the specified component
*
* @param c component for which to find path for
*
* @return path to the specified component
*/
private MenuElement[] getPath (Component c)
{
Vector path = new Vector();
path.add (c);
Component parent = c.getParent ();
while (parent instanceof JMenu
|| parent instanceof JPopupMenu
|| parent instanceof JMenuItem
|| parent instanceof JMenuBar)
{
path.add (parent);
parent = parent.getParent ();
}
MenuElement[] pathArray = new MenuElement[path.size ()];
for (int i = 0; i < path.size (); i++)
pathArray[i] = (MenuElement) path.get (path.size () - i - 1);
return pathArray;
}
} // class MenuSelectionManager

View file

@ -35,248 +35,496 @@ 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;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.util.AbstractMap;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
/**
* RepaintManager
* @author Andrew Selkirk
* @version 1.0
* <p>The repaint manager holds a set of dirty regions, invalid components,
* and a double buffer surface. The dirty regions and invalid components
* are used to coalesce multiple revalidate() and repaint() calls in the
* component tree into larger groups to be refreshed "all at once"; the
* double buffer surface is used by root components to paint
* themselves.</p>
*
* <p>In general, painting is very confusing in swing. see <a
* href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
* document</a> for more details.</p>
*
* @author Graydon Hoare (graydon@redhat.com)
*/
public class RepaintManager {
public class RepaintManager
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* <p>A helper class which is placed into the system event queue at
* various times in order to facilitate repainting and layout. There is
* typically only one of these objects active at any time. When the
* {@link RepaintManager} is told to queue a repaint, it checks to see if
* a {@link RepaintWorker} is "live" in the system event queue, and if
* not it inserts one using {@link SwingUtilities.invokeLater}.</p>
*
* <p>When the {@link RepaintWorker} comes to the head of the system
* event queue, its {@link RepaintWorker#run} method is executed by the
* swing paint thread, which revalidates all invalid components and
* repaints any damage in the swing scene.</p>
*/
/**
* dirtyComponents
*/
Hashtable dirtyComponents;
protected class RepaintWorker
implements Runnable
{
boolean live;
public RepaintWorker()
{
live = false;
}
public synchronized void setLive(boolean b)
{
live = b;
}
public synchronized boolean isLive()
{
return live;
}
public void run()
{
RepaintManager rm = RepaintManager.globalManager;
setLive(false);
rm.validateInvalidComponents();
rm.paintDirtyRegions();
}
}
/**
* tmpDirtyComponents
*/
Hashtable tmpDirtyComponents;
/**
* A table storing the dirty regions of components. The keys of this
* table are components, the values are rectangles. Each component maps
* to exactly one rectangle. When more regions are marked as dirty on a
* component, they are union'ed with the existing rectangle.
*
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
Hashtable dirtyComponents;
/**
* invalidComponents
*/
Vector invalidComponents;
/**
* A single, shared instance of the helper class. Any methods which mark
* components as invalid or dirty eventually activate this instance. It
* is added to the event queue if it is not already active, otherwise
* reused.
*
* @see #addDirtyRegion
* @see #addInvalidComponent
*/
RepaintWorker repaintWorker;
/**
* doubleBufferingEnabled
*/
boolean doubleBufferingEnabled;
/**
* The set of components which need revalidation, in the "layout" sense.
* There is no additional information about "what kind of layout" they
* need (as there is with dirty regions), so it is just a vector rather
* than a table.
*
* @see #addInvalidComponent
* @see #removeInvalidComponent
* @see #validateInvalidComponents
*/
Vector invalidComponents;
/**
* doubleBuffer
*/
Image doubleBuffer;
/**
* Whether or not double buffering is enabled on this repaint
* manager. This is merely a hint to clients; the RepaintManager will
* always return an offscreen buffer when one is requested.
*
* @see #getDoubleBufferingEnabled
* @see #setDoubleBufferingEnabled
*/
boolean doubleBufferingEnabled;
/**
* doubleBufferSize
*/
Dimension doubleBufferSize;
/**
* The current offscreen buffer. This is reused for all requests for
* offscreen drawing buffers. It grows as necessary, up to {@link
* #doubleBufferMaximumSize}, but there is only one shared instance.
*
* @see #getOffscreenBuffer
* @see #doubleBufferMaximumSize
*/
Image doubleBuffer;
/**
* doubleBufferMaxSize
*/
private Dimension doubleBufferMaxSize;
/**
* resetDoubleBuffer
*/
private boolean resetDoubleBuffer;
/**
* repaintManagerKey
*/
private static final Object repaintManagerKey = null; // TODO
/**
* tmp
*/
Rectangle tmp;
/**
* The maximum width and height to allocate as a double buffer. Requests
* beyond this size are ignored.
*
* @see #paintDirtyRegions
* @see #getDoubleBufferMaximumSize
* @see #setDoubleBufferMaximumSize
*/
Dimension doubleBufferMaximumSize;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* The global, shared RepaintManager instance. This is reused for all
* components in all windows.
*
* @see #currentManager
* @see #setCurrentManager
*/
private static RepaintManager globalManager;
/**
* Constructor RepaintManager
*/
public RepaintManager() {
// TODO
} // RepaintManager()
/**
* Create a new RepaintManager object.
*/
public RepaintManager()
{
dirtyComponents = new Hashtable();
invalidComponents = new Vector();
repaintWorker = new RepaintWorker();
doubleBufferMaximumSize = new Dimension(2000,2000);
doubleBufferingEnabled = true;
}
/**
* Get the value of the shared {@link #globalManager} instance, possibly
* returning a special manager associated with the specified
* component. The default implementaiton ignores the component parameter.
*
* @param component A component to look up the manager of
*
* @return The current repaint manager
*
* @see #setCurrentManager
*/
public static RepaintManager currentManager(Component component)
{
if (globalManager == null)
globalManager = new RepaintManager();
return globalManager;
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Get the value of the shared {@link #globalManager} instance, possibly
* returning a special manager associated with the specified
* component. The default implementaiton ignores the component parameter.
*
* @param component A component to look up the manager of
*
* @return The current repaint manager
*
* @see #setCurrentManager
*/
public static RepaintManager currentManager(JComponent component)
{
return currentManager((Component)component);
}
/**
* toString
* @returns String
*/
public synchronized String toString() {
return null; // TODO
} // toString()
/**
* Set the value of the shared {@link #globalManager} instance.
*
* @param manager The new value of the shared instance
*
* @see #currentManager
*/
public static void setCurrentManager(RepaintManager manager)
{
globalManager = manager;
}
/**
* currentManager
* @param component TODO
* @returns RepaintManager
*/
public static RepaintManager currentManager(Component component) {
return null; // TODO
} // currentManager()
/**
* Add a component to the {@link #invalidComponents} vector. If the
* {@link #repaintWorker} class is not active, insert it in the system
* event queue.
*
* @param component The component to add
*
* @see #removeInvalidComponent
*/
public synchronized void addInvalidComponent(JComponent component)
{
while ((component.getParent() != null)
&& (component.getParent() instanceof JComponent)
&& (component.isValidateRoot()))
component = (JComponent) component.getParent();
if (invalidComponents.contains(component))
return;
/**
* currentManager
* @param component TODO
* @returns RepaintManager
*/
public static RepaintManager currentManager(JComponent component) {
return null; // TODO
} // currentManager()
invalidComponents.add(component);
component.invalidate();
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
SwingUtilities.invokeLater(repaintWorker);
}
}
/**
* setCurrentManager
* @param manager TODO
*/
public static void setCurrentManager(RepaintManager manager) {
// TODO
} // setCurrentManager()
/**
* Remove a component from the {@link #invalidComponents} vector.
*
* @param component The component to remove
*
* @see #addInvalidComponent
*/
public synchronized void removeInvalidComponent(JComponent component)
{
invalidComponents.removeElement(component);
}
/**
* addInvalidComponent
* @param component TODO
*/
public synchronized void addInvalidComponent(JComponent component) {
// TODO
} // addInvalidComponent()
/**
* Add a region to the set of dirty regions for a specified component.
* This involves union'ing the new region with any existing dirty region
* associated with the component. If the {@link #repaintWorker} class
* is not active, insert it in the system event queue.
*
* @param component The component to add a dirty region for
* @param x The left x coordinate of the new dirty region
* @param y The top y coordinate of the new dirty region
* @param w The width of the new dirty region
* @param h The height of the new dirty region
*
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
public synchronized void addDirtyRegion(JComponent component, int x, int y,
int w, int h)
{
Rectangle r = new Rectangle(x, y, w, h);
if (dirtyComponents.containsKey(component))
r = r.union((Rectangle)dirtyComponents.get(component));
dirtyComponents.put(component, r);
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
SwingUtilities.invokeLater(repaintWorker);
}
}
/**
* Get the dirty region associated with a component, or <code>null</code>
* if the component has no dirty region.
*
* @param component The component to get the dirty region of
*
* @return The dirty region of the component
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
public Rectangle getDirtyRegion(JComponent component)
{
return (Rectangle) dirtyComponents.get(component);
}
/**
* Mark a component as dirty over its entire bounds.
*
* @param component The component to mark as dirty
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
*/
public void markCompletelyDirty(JComponent component)
{
Rectangle r = component.getBounds();
addDirtyRegion(component, r.x, r.y, r.width, r.height);
}
/**
* removeInvalidComponent
* @param component TODO
*/
public synchronized void removeInvalidComponent(JComponent component) {
// TODO
} // removeInvalidComponent()
/**
* Remove all dirty regions for a specified component
*
* @param component The component to mark as clean
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyDirty
*/
public void markCompletelyClean(JComponent component)
{
dirtyComponents.remove(component);
}
/**
* addDirtyRegion
* @param component TODO
* @param x TODO
* @param y TODO
* @param w TODO
* @param h TODO
*/
public synchronized void addDirtyRegion(JComponent component, int x,
int y, int w, int h) {
// TODO
} // addDirtyRegion()
/**
* Return <code>true</code> if the specified component is completely
* contained within its dirty region, otherwise <code>false</code>
*
* @param component The component to check for complete dirtyness
*
* @return Whether the component is completely dirty
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
*/
public boolean isCompletelyDirty(JComponent component)
{
Rectangle dirty = (Rectangle) dirtyComponents.get(component);
if (dirty == null)
return false;
Rectangle r = component.getBounds();
if (r == null)
return true;
return dirty.contains(r);
}
/**
* getDirtyRegion
* @param component TODO
* @returns Rectangle
*/
public Rectangle getDirtyRegion(JComponent component) {
return null; // TODO
} // getDirtyRegion()
/**
* Validate all components which have been marked invalid in the {@link
* #invalidComponents} vector.
*/
public void validateInvalidComponents()
{
for (Enumeration e = invalidComponents.elements(); e.hasMoreElements(); )
{
JComponent comp = (JComponent) e.nextElement();
if (! (comp.isVisible() && comp.isShowing()))
continue;
comp.validate();
}
invalidComponents.clear();
}
/**
* markCompletelyDirty
* @param component TODO
*/
public void markCompletelyDirty(JComponent component) {
// TODO
} // markCompletelyDirty()
/**
* Repaint all regions of all components which have been marked dirty in
* the {@link #dirtyComponents} table.
*/
public void paintDirtyRegions()
{
// step 1: pull out roots and calculate spanning damage
/**
* markCompletelyClean
* @param component TODO
*/
public void markCompletelyClean(JComponent component) {
// TODO
} // markCompletelyClean()
HashMap roots = new HashMap();
for (Enumeration e = dirtyComponents.keys(); e.hasMoreElements(); )
{
JComponent comp = (JComponent) e.nextElement();
if (! (comp.isVisible() && comp.isShowing()))
continue;
Rectangle damaged = getDirtyRegion(comp);
if (damaged.width == 0 || damaged.height == 0)
continue;
JRootPane root = comp.getRootPane();
Rectangle rootDamage = SwingUtilities.convertRectangle(comp, damaged, root);
if (! roots.containsKey(root))
{
roots.put(root, rootDamage);
}
else
{
roots.put(root, ((Rectangle)roots.get(root)).union(rootDamage));
}
}
dirtyComponents.clear();
/**
* isCompletelyDirty
* @param component TODO
* @returns boolean
*/
public boolean isCompletelyDirty(JComponent component) {
return false; // TODO
} // isCompletelyDirty()
// step 2: paint those roots
Iterator i = roots.iterator(AbstractMap.ENTRIES);
while(i.hasNext())
{
AbstractMap.BasicMapEntry ent = (AbstractMap.BasicMapEntry) i.next();
JRootPane root = (JRootPane) ent.getKey();
Rectangle rect = (Rectangle) ent.getValue();
root.paintImmediately(rect);
}
}
/**
* validateInvalidComponents
*/
public void validateInvalidComponents() {
// TODO
} // validateInvalidComponents()
/**
* Get an offscreen buffer for painting a component's image. This image
* may be smaller than the proposed dimensions, depending on the value of
* the {@link #doubleBufferMaximumSize} property.
*
* @param component The component to return an offscreen buffer for
* @param proposedWidth The proposed width of the offscreen buffer
* @param proposedHeight The proposed height of the offscreen buffer
*
* @return A shared offscreen buffer for painting
*
* @see #doubleBuffer
*/
public Image getOffscreenBuffer(Component component, int proposedWidth,
int proposedHeight)
{
if (doubleBuffer == null
|| (((doubleBuffer.getWidth(null) < proposedWidth)
|| (doubleBuffer.getHeight(null) < proposedHeight))
&& (proposedWidth < doubleBufferMaximumSize.width)
&& (proposedHeight < doubleBufferMaximumSize.height)))
{
doubleBuffer = component.createImage(proposedWidth, proposedHeight);
}
return doubleBuffer;
}
/**
* paintDirtyRegions
*/
public void paintDirtyRegions() {
// TODO
} // paintDirtyRegions()
/**
* Get the value of the {@link #doubleBufferMaximumSize} property.
*
* @return The current value of the property
*
* @see #setDoubleBufferMaximumSize
*/
public Dimension getDoubleBufferMaximumSize()
{
return doubleBufferMaximumSize;
}
/**
* getOffscreenBuffer
* @param component TODO
* @param proposedWidth TODO
* @param proposedHeight TODO
* @returns Image
*/
public Image getOffscreenBuffer(Component component,
int proposedWidth, int proposedHeight) {
return null; // TODO
} // getOffscreenBuffer()
/**
* Set the value of the {@link #doubleBufferMaximumSize} property.
*
* @param size The new value of the property
*
* @see #getDoubleBufferMaximumSize
*/
public void setDoubleBufferMaximumSize(Dimension size)
{
doubleBufferMaximumSize = size;
}
/**
* getDoubleBufferMaximumSize
* @returns Dimension
*/
public Dimension getDoubleBufferMaximumSize() {
return null; // TODO
} // getDoubleBufferMaximumSize()
/**
* Set the value of the {@link #doubleBufferingEnabled} property.
*
* @param buffer The new value of the property
*
* @see #getDoubleBufferingEnabled
*/
public void setDoubleBufferingEnabled(boolean buffer)
{
doubleBufferingEnabled = buffer;
}
/**
* setDoubleBufferMaximumSize
* @param size TODO
*/
public void setDoubleBufferMaximumSize(Dimension size) {
// TODO
} // setDoubleBufferMaximumSize()
/**
* setDoubleBufferingEnabled
* @param buffer TODO
*/
public void setDoubleBufferingEnabled(boolean buffer) {
// TODO
} // setDoubleBufferingEnabled()
/**
* isDoubleBufferingEnabled
* @returns boolean
*/
public boolean isDoubleBufferingEnabled() {
return false; // TODO
} // isDoubleBufferingEnabled()
} // RepaintManager
/**
* Get the value of the {@link #doubleBufferingEnabled} property.
*
* @return The current value of the property
*
* @see #setDoubleBufferingEnabled
*/
public boolean isDoubleBufferingEnabled()
{
return doubleBufferingEnabled;
}
public String toString()
{
return "RepaintManager";
}
}

View file

@ -227,7 +227,17 @@ public class ScrollPaneLayout
if (horizontalScrollBar != null)
horizontalScrollBarSize.setSize(horizontalScrollBar.getPreferredSize());
/*
System.err.println("widths: [vp=" + viewportSize.width +
", h=" + columnHeaderSize.width +
", sc=" + horizontalScrollBarSize.width + "]");
System.err.println("heights: [vp=" + viewportSize.height +
", h=" + rowHeaderSize.height +
", sc=" + verticalScrollBarSize.height + "]");
*/
return new Dimension(insetsSize.width
+ viewportSize.width
+ viewportInsetsSize.width
@ -336,9 +346,9 @@ public class ScrollPaneLayout
synchronized (sc.getTreeLock ())
{
Rectangle scrollPaneBounds = sc.getBounds();
Dimension viewportSize = new Dimension(0,0);
Dimension viewSize = new Dimension(0,0);
JViewport viewport = sc.getViewport();
Dimension viewportSize = viewport.getSize();
Dimension viewSize = viewport.getView().getSize();
int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
int y1 = 0, y2 = 0, y3 = 0, y4 = 0;
@ -395,7 +405,7 @@ public class ScrollPaneLayout
rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
if (showVsb)
verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
if (showHsb)
horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));

View file

@ -43,6 +43,7 @@ import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
@ -64,6 +65,8 @@ import java.lang.reflect.InvocationTargetException;
public class SwingUtilities implements SwingConstants
{
private static Frame ownerFrame;
/**
* Calculates the portion of the base rectangle which is inside the
* insets.
@ -830,5 +833,18 @@ public class SwingUtilities implements SwingConstants
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
}
/**
* This method returns the common Frame owner used in JDialogs
* when no owner is provided.
*
* @return The common Frame
*/
static Frame getOwnerFrame()
{
if (ownerFrame == null)
ownerFrame = new Frame();
return ownerFrame;
}
}

View file

@ -178,8 +178,7 @@ public class UIManager implements Serializable
*/
public static Dimension getDimension(Object key)
{
System.out.println("UIManager.getDim");
return new Dimension(200,100);
return (Dimension) getLookAndFeel().getDefaults().get(key);
}
/**

View file

@ -41,37 +41,62 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;
/**
* ViewportLayout
* @author Andrew Selkirk
* @version 1.0
* @author Graydon Hoare
*/
public class ViewportLayout implements LayoutManager, Serializable
{
static final long serialVersionUID = -788225906076097229L;
public ViewportLayout() {
}
public void addLayoutComponent(String name, Component c) {
// ignore
}
public void removeLayoutComponent(Component c) {
// ignore
}
public Dimension preferredLayoutSize(Container parent) {
return null;
}
public Dimension minimumLayoutSize(Container parent) {
return null;
}
public void layoutContainer(Container parent) {
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);
}
}
public ViewportLayout()
{
}
public void addLayoutComponent(String name, Component c)
{
}
public void removeLayoutComponent(Component c)
{
}
public Dimension preferredLayoutSize(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
if (view instanceof Scrollable)
{
Scrollable sc = (Scrollable) view;
Dimension d = sc.getPreferredScrollableViewportSize();
// System.err.println(this + ".preferredLayoutSize() : scrollable -> " + d);
return d;
}
else
return view.getPreferredSize();
}
public Dimension minimumLayoutSize(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
return view.getMinimumSize();
}
public void layoutContainer(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
Rectangle portBounds = vp.getBounds();
Dimension viewMinimum = view.getMinimumSize();
int width = Math.max(portBounds.width,
viewMinimum.width);
int height = Math.max(portBounds.height,
viewMinimum.height);
int x = Math.min(0, portBounds.width - width);
int y = Math.min(0, portBounds.height - height);
// System.err.println(this + ".layoutContainer() : width = " + width + ", height = " + height);
vp.setViewPosition(new Point(x, y));
vp.setViewSize(new Dimension(width, height));
}
}

View file

@ -210,8 +210,9 @@ public final class SwingPropertyChangeSupport
PropertyChangeListener listener;
// Check Values if they are equal
if (event.getOldValue() == null || event.getNewValue() == null ||
event.getOldValue().equals(event.getNewValue()) == true) {
if (event.getOldValue() == null && event.getNewValue() == null ||
(event.getOldValue() != null && event.getNewValue() != null &&
event.getOldValue().equals(event.getNewValue()))) {
return;
} // if

View file

@ -92,6 +92,7 @@ public class BasicButtonUI extends ButtonUI
b.setBackground(defaults.getColor("Button.background"));
b.setMargin(defaults.getInsets("Button.margin"));
b.setBorder(defaults.getBorder("Button.border"));
b.setOpaque(true);
}
protected void uninstallDefaults(AbstractButton b)

View file

@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
@ -48,18 +47,39 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
{
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public static ComponentUI createUI(final JComponent c)
{
return new BasicCheckBoxMenuItemUI();
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null; // TODO
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
super.installDefaults();
@ -68,6 +88,14 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
checkIcon = defaults.getIcon("CheckBoxMenuItem.checkIcon");
}
/**
* DOCUMENT ME!
*
* @param item DOCUMENT ME!
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
MenuSelectionManager manager)
{

View file

@ -82,7 +82,34 @@ public class BasicIconFactory implements Serializable
}
public static Icon getMenuArrowIcon()
{
return new DummyIcon();
return new Icon()
{
public int getIconHeight()
{
return 12;
}
public int getIconWidth()
{
return 12;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.translate(x, y);
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.fillPolygon(new Polygon(new int[] { 3, 9, 3 },
new int[] { 2, 6, 10 },
3));
g.setColor(saved);
g.translate(-x, -y);
}
};
}
public static Icon getCheckBoxIcon()

View file

@ -168,23 +168,20 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
vr.width = 0;
if (vr.height < 0)
vr.height = 0;
Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
String text = layoutCL(b, fm, b.getText(), icon, vr, ir, tr);
if (b.isOpaque())
{
g.setColor(b.getBackground());
g.fillRect(vr.x, vr.y, vr.width, vr.height);
}
if (icon != null)
icon.paintIcon(b, g, ir.x, ir.y);
if (b.isEnabled())
paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
else
paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
if (text != null && ! text.equals(""))
{
if (b.isEnabled())
paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
else
paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
}
g.setFont(saved_font);
}
@ -354,6 +351,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
c.setBackground(defaults.getColor("Label.background"));
c.setFont(defaults.getFont("Label.font"));
c.setBorder(defaults.getBorder("Label.border"));
c.setOpaque(true);
//XXX: There are properties we don't use called disabledForeground
//and disabledShadow.
}

View file

@ -502,6 +502,7 @@ public class BasicListUI extends ListUI
list.setBackground(defaults.getColor("List.background"));
list.setSelectionForeground(defaults.getColor("List.selectionForeground"));
list.setSelectionBackground(defaults.getColor("List.selectionBackground"));
list.setOpaque(true);
}
/**
@ -620,7 +621,8 @@ public class BasicListUI extends ListUI
maybeUpdateLayoutState();
if (list.getModel().getSize() == 0)
return new Dimension(0, 0);
Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1);
int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());
Rectangle bounds = getCellBounds(list, 0, nrows - 1);
return bounds.getSize();
}
@ -696,11 +698,11 @@ public class BasicListUI extends ListUI
public int locationToIndex(JList list, Point location)
{
throw new Error("Not implemented");
return convertYToRow(location.y);
}
public Point indexToLocation(JList list, int index)
{
throw new Error("Not implemented");
return new Point(0, convertRowToY(index));
}
}

View file

@ -249,7 +249,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Button.foreground", new ColorUIResource(Color.black),
"Button.highlight", new ColorUIResource(Color.white),
"Button.light", new ColorUIResource(Color.lightGray.brighter()),
"Button.margin", new InsetsUIResource(2, 14, 2, 14),
"Button.margin", new InsetsUIResource(2, 2, 2, 2),
"Button.shadow", new ColorUIResource(Color.gray),
"Button.textIconGap", new Integer(4),
"Button.textShiftOffset", new Integer(0),
@ -694,7 +694,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"SplitPane.background", new ColorUIResource(Color.lightGray),
"SplitPane.border", new BasicBorders.SplitPaneBorder(null, null),
"SplitPane.dividerSize", new Integer(7),
"SplitPane.dividerSize", new Integer(10),
"SplitPane.highlight", new ColorUIResource(Color.white),
"SplitPane.shadow", new ColorUIResource(Color.gray),
"TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {

View file

@ -0,0 +1,277 @@
/* BasicMenuUI.java
Copyright (C) 2002, 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.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
import javax.swing.plaf.MenuItemUI;
import java.awt.Insets;
import java.awt.GridLayout;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
public class BasicMenuBarUI extends MenuBarUI
{
protected ChangeListener changeListener;
protected ContainerListener containerListener;
protected PropertyChangeListener propertyChangeListener;
protected JMenuBar menuBar;
/**
* Creates a new BasicMenuBarUI object.
*/
public BasicMenuBarUI()
{
changeListener = createChangeListener();
containerListener = createContainerListener();
propertyChangeListener = new PropertyChangeHandler();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ChangeListener createChangeListener()
{
return new ChangeHandler();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ContainerListener createContainerListener()
{
return new ContainerHandler();
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicMenuBarUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMinimumSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getPreferredSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
menuBar.setBackground(defaults.getColor("MenuBar.background"));
menuBar.setBorder(defaults.getBorder("MenuBar.border"));
menuBar.setFont(defaults.getFont("MenuBar.font"));
menuBar.setForeground(defaults.getColor("MenuBar.foreground"));
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
menuBar.addContainerListener(containerListener);
menuBar.addPropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void installUI(JComponent c)
{
super.installUI(c);
menuBar = (JMenuBar) c;
menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.X_AXIS));
installDefaults();
installListeners();
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
menuBar.setBackground(null);
menuBar.setBorder(null);
menuBar.setFont(null);
menuBar.setForeground(null);
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
menuBar.removeContainerListener(containerListener);
menuBar.removePropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void uninstallUI(JComponent c)
{
uninstallDefaults();
uninstallListeners();
menuBar= null;
}
protected class ChangeHandler implements ChangeListener
{
public void stateChanged(ChangeEvent event)
{
}
}
protected class ContainerHandler implements ContainerListener
{
public void componentAdded(ContainerEvent e)
{
}
public void componentRemoved(ContainerEvent e)
{
}
}
protected class PropertyChangeHandler implements PropertyChangeListener
{
public void propertyChange(PropertyChangeEvent e)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,357 @@
/* BasicMenuUI.java
Copyright (C) 2002, 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.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicMenuUI extends BasicMenuItemUI
{
protected ChangeListener changeListener;
protected MenuListener menuListener;
protected PropertyChangeListener propertyChangeListener;
/**
* Creates a new BasicMenuUI object.
*/
public BasicMenuUI()
{
mouseInputListener = createMouseInputListener(menuItem);
menuListener = createMenuListener(menuItem);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ChangeListener createChangeListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuListener createMenuListener(JComponent c)
{
return new MenuHandler();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MouseInputListener createMouseInputListener(JComponent c)
{
return new MouseInputHandler();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected PropertyChangeListener createPropertyChangeListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicMenuUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null;
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
menuItem.setBackground(defaults.getColor("Menu.background"));
menuItem.setBorder(defaults.getBorder("Menu.border"));
menuItem.setFont(defaults.getFont("Menu.font"));
menuItem.setForeground(defaults.getColor("Menu.foreground"));
menuItem.setMargin(defaults.getInsets("Menu.margin"));
acceleratorFont = defaults.getFont("Menu.acceleratorFont");
acceleratorForeground = defaults.getColor("Menu.acceleratorForeground");
acceleratorSelectionForeground = defaults.getColor("Menu.acceleratorSelectionForeground");
arrowIcon = defaults.getIcon("Menu.arrowIcon");
oldBorderPainted = defaults.getBoolean("Menu.borderPainted");
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
((JMenu) menuItem).addMouseListener(mouseInputListener);
((JMenu) menuItem).addMenuListener(menuListener);
}
/**
* DOCUMENT ME!
*
* @param menu DOCUMENT ME!
*/
protected void setupPostTimer(JMenu menu)
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
menuItem.setBackground(null);
menuItem.setBorder(null);
menuItem.setFont(null);
menuItem.setForeground(null);
menuItem.setMargin(null);
acceleratorFont = null;
acceleratorForeground = null;
acceleratorSelectionForeground = null;
arrowIcon = null;
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
protected class MouseInputHandler implements MouseInputListener
{
protected MouseInputHandler()
{
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseDragged(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
public void mouseEntered(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(manager.getPath((Component) e.getSource()));
manager.processMouseEvent(e);
JMenu subMenu = (JMenu) menuItem;
int x = 0;
int y = 0;
// location of the popup menu is relative to the invoker
if (subMenu.isTopLevelMenu())
{
JMenuBar mb = (JMenuBar) subMenu.getParent();
// Subtract menuBar's insets.bottom and popupMenu's insets.top,
// s.t. the space between menu bar and its popup menu is equal to
// menuBar's margin. By default menuBar's margin is Insets(0,0,0,0).
y = subMenu.getHeight() - mb.getInsets().bottom
- subMenu.getPopupMenu().getInsets().top + mb.getMargin().bottom;
}
else
x = subMenu.getWidth();
subMenu.getPopupMenu().show(subMenu, x, y);
}
public void mouseExited(MouseEvent e)
{
}
public void mouseMoved(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
}
protected class MenuHandler implements MenuListener
{
public void menuCanceled(MenuEvent e)
{
}
public void menuDeselected(MenuEvent e)
{
}
public void menuSelected(MenuEvent e)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,362 @@
/* BasicPopupMenuUI.java
Copyright (C) 2002, 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.AWTKeyStroke;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EventListener;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MouseInputListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuItemUI;
import javax.swing.plaf.PopupMenuUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
public class BasicPopupMenuUI extends PopupMenuUI
{
protected JPopupMenu popupMenu;
private static transient MouseInputListener mouseInputListener;
private transient PopupMenuListener popupMenuListener;
/**
* Creates a new BasicPopupMenuUI object.
*/
public BasicPopupMenuUI()
{
popupMenuListener = new PopupMenuHandler();
mouseInputListener = new MouseInputHandler();
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicPopupMenuUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void installUI(JComponent c)
{
super.installUI(c);
popupMenu = (JPopupMenu) c;
popupMenu.setLayout(new GridBagLayout());
popupMenu.setBorderPainted(true);
popupMenu.setDefaultLightWeightPopupEnabled(true);
installDefaults();
installListeners();
}
/**
* DOCUMENT ME!
*/
public void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
popupMenu.setBackground(defaults.getColor("PopupMenu.background"));
popupMenu.setBorder(defaults.getBorder("PopupMenu.border"));
popupMenu.setFont(defaults.getFont("PopupMenu.font"));
popupMenu.setForeground(defaults.getColor("PopupMenu.foreground"));
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
popupMenu.addMouseListener(mouseInputListener);
popupMenu.addMouseMotionListener(mouseInputListener);
popupMenu.addPopupMenuListener(popupMenuListener);
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void uninstallUI(JComponent c)
{
uninstallListeners();
uninstallDefaults();
popupMenu = null;
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
popupMenu.setBackground(null);
popupMenu.setBorder(null);
popupMenu.setFont(null);
popupMenu.setForeground(null);
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMinimumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getPreferredSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isPopupTrigger(MouseEvent e)
{
return false;
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
protected class PopupMenuHandler implements PopupMenuListener
{
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuCanceled(PopupMenuEvent event)
{
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
{
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent event)
{
}
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
protected class MouseInputHandler implements MouseInputListener
{
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseClicked(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseDragged(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseEntered(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseExited(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseMoved(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mousePressed(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseReleased(MouseEvent e)
{
}
}
}

View file

@ -712,6 +712,7 @@ public class BasicProgressBarUI extends ProgressBarUI
progressBar.setForeground(defaults.getColor("ProgressBar.foreground"));
progressBar.setBackground(defaults.getColor("ProgressBar.background"));
progressBar.setBorder(defaults.getBorder("ProgressBar.border"));
progressBar.setOpaque(true);
selectionForeground = defaults.getColor("ProgressBar.selectionForeground");
selectionBackground = defaults.getColor("ProgressBar.selectionBackground");

View file

@ -48,27 +48,55 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
{
/**
* Creates a new BasicRadioButtonMenuItemUI object.
*/
public BasicRadioButtonMenuItemUI()
{
{
super();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
checkIcon = defaults.getIcon("RadioButtonMenuItem.checkIcon");
}
/**
* DOCUMENT ME!
*
* @param b DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent b)
{
return new BasicRadioButtonMenuItemUI();
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null;
// TODO
}
/**
* DOCUMENT ME!
*
* @param item DOCUMENT ME!
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
MenuSelectionManager manager)
{

View file

@ -52,6 +52,8 @@ public class BasicRootPaneUI extends RootPaneUI
public void installUI(JComponent c)
{
c.setOpaque(true);
c.setBackground(javax.swing.UIManager.getColor("control"));
super.installUI(c);
}
}

View file

@ -125,6 +125,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void stateChanged(ChangeEvent e)
{
// System.err.println(this + ".stateChanged()");
calculatePreferredSize();
layoutContainer(scrollbar);
getThumbBounds();
scrollbar.repaint();
}
@ -734,6 +737,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
private void calculatePreferredSize()
{
// System.err.println(this + ".calculatePreferredSize()");
int height;
int width;
height = width = 0;
@ -743,7 +748,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
width += incrButton.getPreferredSize().getWidth();
width += decrButton.getPreferredSize().getWidth();
width += Math.max(200, scrollbar.getVisibleAmount());
width += (scrollbar.getMaximum() - scrollbar.getMinimum());
height = Math.max(incrButton.getPreferredSize().height,
decrButton.getPreferredSize().height);
@ -756,7 +761,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
height += incrButton.getPreferredSize().getHeight();
height += decrButton.getPreferredSize().getHeight();
height += Math.max(200, scrollbar.getVisibleAmount());
height += (scrollbar.getMaximum() - scrollbar.getMinimum());
width = Math.max(incrButton.getPreferredSize().width,
decrButton.getPreferredSize().width);
@ -804,6 +809,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
int value = scrollbar.getValue();
int extent = scrollbar.getVisibleAmount();
// System.err.println(this + ".getThumbBounds()");
if (max == min)
{
thumbRect.x = trackRect.x;
@ -892,8 +899,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollbar.setForeground(defaults.getColor("ScrollBar.foreground"));
scrollbar.setBackground(defaults.getColor("ScrollBar.background"));
scrollbar.setBorder(defaults.getBorder("ScrollBar.border"));
scrollbar.setOpaque(true);
maximumThumbSize = defaults.getDimension("ScrollBar.maximumThumbSize");
minimumThumbSize = defaults.getDimension("ScrollBar.minimumThumbSize");
@ -1046,14 +1053,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
public void paint(Graphics g, JComponent c)
{
layoutContainer(scrollbar);
// Rectangle r = incrButton.getBounds();
// SwingUtilities.paintComponent(g, incrButton, scrollbar, r.x, r.y, r.width,
// r.height);
// r = decrButton.getBounds();
// SwingUtilities.paintComponent(g, decrButton, scrollbar, r.x, r.y, r.width,
// r.height);
paintTrack(g, c, getTrackBounds());
paintThumb(g, c, getThumbBounds());

View file

@ -123,6 +123,7 @@ public class BasicSeparatorUI extends SeparatorUI
shadow = defaults.getColor("Separator.shadow");
highlight = defaults.getColor("Separator.highlight");
s.setOpaque(true);
}
/**

View file

@ -681,6 +681,7 @@ public class BasicSliderUI extends SliderUI
highlightColor = defaults.getColor("Slider.highlight");
focusColor = defaults.getColor("Slider.focus");
slider.setBorder(defaults.getBorder("Slider.border"));
slider.setOpaque(true);
thumbHeight = defaults.getInt("Slider.thumbHeight");
thumbWidth = defaults.getInt("Slider.thumbWidth");

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -223,10 +223,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
Component visible = getVisibleComponent();
Insets insets = getContentBorderInsets(tabPane.getTabPlacement());
visible.setBounds(contentRect.x + insets.left,
contentRect.y + insets.top,
contentRect.width - insets.left - insets.right,
contentRect.height - insets.top - insets.bottom);
if (visible != null)
visible.setBounds(contentRect.x + insets.left,
contentRect.y + insets.top,
contentRect.width - insets.left - insets.right,
contentRect.height - insets.top - insets.bottom);
}
}
@ -1510,6 +1511,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabPane.setFont(defaults.getFont("TabbedPane.font"));
tabPane.setForeground(defaults.getColor("TabbedPane.foreground"));
tabPane.setBackground(defaults.getColor("TabbedPane.background"));
tabPane.setOpaque(true);
highlight = defaults.getColor("TabbedPane.highlight");
lightHighlight = defaults.getColor("TabbedPane.lightHighlight");
@ -1790,7 +1792,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// FIXME: Paint little folding corner and jagged edge clipped tab.
if (icon != null)
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
if (title == null || ! title.equals(""))
if (title != null && ! title.equals(""))
paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
textRect, isSelected);
}

View file

@ -47,6 +47,7 @@ import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import javax.swing.JComponent;
import javax.swing.JViewport;
import javax.swing.ViewportLayout;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
@ -70,7 +71,8 @@ public class BasicViewportUI extends ViewportUI
}
void installDefaults(JComponent c)
{
{
c.setOpaque(true);
}
void uninstallDefaults(JComponent c)
@ -100,6 +102,7 @@ public class BasicViewportUI extends ViewportUI
public void installUI(JComponent c)
{
super.installUI(c);
c.setLayout(new ViewportLayout());
installListeners(c);
}
@ -111,9 +114,8 @@ public class BasicViewportUI extends ViewportUI
public Dimension getPreferredSize(JComponent c)
{
// FIXME: integrate with Scrollable
Dimension d = new Dimension(100,100);
return d;
// let the ViewportLayout decide
return null;
}
public void paint(Graphics g, JComponent c)
@ -129,6 +131,12 @@ public class BasicViewportUI extends ViewportUI
Rectangle viewBounds = view.getBounds();
Rectangle portBounds = v.getBounds();
if (viewBounds.width == 0
|| viewBounds.height == 0
|| portBounds.width == 0
|| portBounds.height == 0)
return;
if (backingStoreImage == null
|| backingStoreWidth != viewBounds.width
|| backingStoreHeight != viewBounds.height)

View file

@ -112,9 +112,10 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeer_setFont
struct peerfont *pfont = NULL;
PangoFontMap *map = NULL;
char const *family_name = NULL;
enum java_awt_font_style style;
gdk_threads_enter ();
enum java_awt_font_style style = (enum java_awt_font_style) style_int;
style = (enum java_awt_font_style) style_int;
g_assert (self != NULL);
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, self);

View file

@ -636,9 +636,12 @@ JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphIsHori
gdk_threads_leave ();
return
return 1;
/* FIXME: Pango doesn't seem to have decided how it will deal
with vertical text. for the time being we inherit this limitation.
((dir == PANGO_DIRECTION_LTR) ||
(dir == PANGO_DIRECTION_RTL));
*/
}

View file

@ -67,7 +67,9 @@ struct state_table *native_graphics2d_state_table;
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState
(JNIEnv *env, jclass clazz)
{
NSA_G2D_INIT (env, clazz);
gdk_threads_enter();
NSA_G2D_INIT (env, clazz);
gdk_threads_leave();
}
/* these public final constants are part of the java2d public API, so we
@ -124,6 +126,32 @@ enum java_awt_rendering_hints_filter
};
static int
peer_is_disposed(JNIEnv *env, jobject obj)
{
static jfieldID fid = NULL;
jclass cls;
jobject peer;
return 0;
if (fid == NULL)
{
cls = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, cls, "component",
"Lgnu/java/awt/peer/gtk/GtkComponentPeer;");
}
g_assert(fid != NULL);
peer = (*env)->GetObjectField(env, obj, fid);
if (peer == NULL || NSA_GET_PTR (env, peer) != NULL)
return 0;
else
{
return 1;
}
}
static void
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
{
@ -220,7 +248,7 @@ init_graphics2d_as_renderable (struct graphics2d *gr)
static void
begin_drawing_operation (struct graphics2d * gr)
{
gdk_threads_enter ();
g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
if (gr->drawbuf)
{
@ -248,6 +276,7 @@ begin_drawing_operation (struct graphics2d * gr)
static void
end_drawing_operation (struct graphics2d * gr)
{
g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
if (gr->drawbuf)
{
gint drawable_width, drawable_height;
@ -268,7 +297,6 @@ end_drawing_operation (struct graphics2d * gr)
if (gr->debug) printf ("copied (%d, %d) pixels from pixbuf to GDK drawable\n",
width, height);
}
gdk_threads_leave ();
}
@ -288,7 +316,7 @@ update_pattern_transform (struct graphics2d *gr)
mat = cairo_matrix_create ();
g_assert (mat != NULL);
cairo_matrix_set_affine (mat, a, b, c, d, tx, ty);
cairo_surface_set_matrix (gr->pattern, mat);
cairo_pattern_set_matrix (gr->pattern, mat);
cairo_matrix_destroy (mat);
}
@ -303,6 +331,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
{
struct graphics2d *g = NULL, *g_old = NULL;
gdk_threads_enter();
g = (struct graphics2d *) malloc (sizeof (struct graphics2d));
g_assert (g != NULL);
memset (g, 0, sizeof(struct graphics2d));
@ -315,7 +344,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
g->drawable = g_old->drawable;
g->debug = g_old->debug;
gdk_threads_enter ();
g_object_ref (g->drawable);
g->cr = cairo_create();
@ -328,9 +356,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
cairo_surface_set_filter (g->surface, CAIRO_FILTER_FAST);
gdk_threads_leave ();
NSA_SET_G2D_PTR (env, obj, g);
gdk_threads_leave();
}
@ -338,9 +365,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
(JNIEnv *env, jobject obj, jint width, jint height)
{
struct graphics2d *gr;
gdk_threads_enter ();
gdk_threads_enter();
gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
g_assert (gr != NULL);
memset (gr, 0, sizeof(struct graphics2d));
@ -362,22 +388,23 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
else
init_graphics2d_as_pixbuf (gr);
gdk_threads_leave ();
if (gr->debug) printf ("constructed offscreen drawable of size (%d,%d)\n",
width, height);
NSA_SET_G2D_PTR (env, obj, gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
(JNIEnv *env, jobject self, jobject other, jint x, jint y)
{
GdkRectangle clipRect;
struct graphics2d *src = NULL, *dst = NULL;
gint s_height, s_width, d_height, d_width, height, width;
cairo_matrix_t *matrix;
GdkGC *gc;
cairo_operator_t tmp_op;
gdk_threads_enter();
if (peer_is_disposed(env, self)) { gdk_threads_leave(); return; }
src = (struct graphics2d *)NSA_GET_G2D_PTR (env, other);
dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
g_assert (src != NULL);
@ -385,14 +412,14 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
if (src->debug) printf ("copying from offscreen drawable\n");
gdk_threads_enter ();
begin_drawing_operation(dst);
gdk_flush();
gdk_drawable_get_size (src->drawable, &s_width, &s_height);
gdk_drawable_get_size (dst->drawable, &d_width, &d_height);
width = min (s_width, d_width);
height = min (s_height, d_height);
gdk_threads_leave ();
begin_drawing_operation(dst);
matrix = cairo_matrix_create ();
cairo_surface_get_matrix (src->surface, matrix);
@ -408,14 +435,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
cairo_surface_set_matrix (src->surface, matrix);
cairo_matrix_destroy (matrix);
gdk_flush();
end_drawing_operation(dst);
gdk_threads_enter ();
gdk_flush ();
gdk_threads_leave ();
if (src->debug) printf ("copied %d x %d pixels from offscreen drawable\n", width, height);
gdk_threads_leave();
}
static jintArray
@ -454,9 +479,10 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__
void *ptr = NULL;
jintArray color;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
ptr = NSA_GET_PTR (env, peer);
g_assert (ptr != NULL);
gdk_threads_enter ();
gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
g_assert (gr != NULL);
@ -480,8 +506,8 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__
color = current_colors_of_widget (widget, env);
gdk_threads_leave ();
NSA_SET_G2D_PTR (env, obj, gr);
gdk_threads_leave();
return color;
}
@ -490,11 +516,13 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
gr = (struct graphics2d *) NSA_DEL_G2D_PTR (env, obj);
if (gr == NULL)
return; /* dispose has been called more than once */
gdk_threads_enter ();
{
gdk_threads_leave();
return; /* dispose has been called more than once */
}
if (gr->surface)
cairo_surface_destroy (gr->surface);
@ -507,15 +535,18 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
g_object_unref (gr->drawable);
if (gr->pattern)
cairo_surface_destroy (gr->pattern);
cairo_pattern_destroy (gr->pattern);
if (gr->pattern_surface)
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
free (gr->pattern_pixels);
if (gr->debug) printf ("disposed of graphics2d\n");
free (gr);
gdk_threads_leave ();
free (gr);
gdk_threads_leave();
}
@ -533,6 +564,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
if (gr->debug) printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
x1, y1,
x2, y2,
@ -623,19 +656,21 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
/* cairo_surface_set_repeat (surf, cyclic ? 1 : 0); */
if (gr->pattern)
cairo_surface_destroy (gr->pattern);
cairo_pattern_destroy (gr->pattern);
if (gr->pattern_surface)
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
{
free (gr->pattern_pixels);
gr->pattern_pixels = NULL;
}
gr->pattern = surf;
free (gr->pattern_pixels);
gr->pattern_pixels = NULL;
gr->pattern_surface = surf;
gr->pattern = cairo_pattern_create_for_surface(surf);
cairo_restore (gr->cr);
cairo_set_pattern (gr->cr, gr->pattern);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
@ -644,6 +679,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
struct graphics2d *gr = NULL;
jint *jpixels = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -651,12 +688,16 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
(*env)->GetArrayLength (env, jarr), w, h, stride);
if (gr->pattern)
cairo_surface_destroy (gr->pattern);
cairo_pattern_destroy (gr->pattern);
if (gr->pattern_surface)
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
free (gr->pattern_pixels);
gr->pattern = NULL;
gr->pattern_surface = NULL;
gr->pattern_pixels = NULL;
gr->pattern_pixels = (char *) malloc (h * stride * 4);
@ -667,13 +708,15 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
memcpy (gr->pattern_pixels, jpixels, h * stride * 4);
(*env)->ReleaseIntArrayElements (env, jarr, jpixels, 0);
gr->pattern = cairo_surface_create_for_image (gr->pattern_pixels,
CAIRO_FORMAT_ARGB32,
w, h, stride * 4);
gr->pattern_surface = cairo_surface_create_for_image (gr->pattern_pixels,
CAIRO_FORMAT_ARGB32,
w, h, stride * 4);
g_assert (gr->pattern_surface != NULL);
cairo_surface_set_repeat (gr->pattern_surface, 1);
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
g_assert (gr->pattern != NULL);
cairo_surface_set_repeat (gr->pattern, 1);
cairo_set_pattern (gr->cr, gr->pattern);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
@ -684,6 +727,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
jint *native_pixels = NULL;
jdouble *native_matrix = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -716,10 +762,11 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
}
end_drawing_operation (gr);
(*env)->ReleaseIntArrayElements (env, java_pixels, native_pixels, 0);
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
(*env)->ReleaseIntArrayElements (env, java_pixels, native_pixels, 0);
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
gdk_threads_leave();
}
JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels
@ -735,6 +782,9 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix
gint total_channels = 4;
jint i, px;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -783,8 +833,8 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix
(jsize)0, (jsize) width*height,
(jint*) native_pixels);
gdk_threads_leave();
return java_pixels;
}
/* passthrough methods to cairo */
@ -793,21 +843,31 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_save\n");
cairo_save (gr->cr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_restore\n");
cairo_restore (gr->cr);
update_pattern_transform (gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
@ -816,6 +876,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
struct graphics2d *gr = NULL;
jdouble *native_matrix = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -840,6 +903,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
update_pattern_transform (gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFont
@ -850,14 +914,15 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFont
cairo_font_t *ft = NULL;
FT_Face face = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
g_assert (pfont != NULL);
gdk_threads_enter ();
face = pango_ft2_font_get_face (pfont->font);
g_assert (face != NULL);
@ -873,8 +938,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFont
(double)PANGO_SCALE);
cairo_font_destroy (ft);
gdk_threads_leave ();
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoShowGlyphs
@ -887,6 +951,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoShowGlyphs
jint i;
jint ncodes, nposns;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -921,12 +988,17 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoShowGlyphs
end_drawing_operation (gr);
free(glyphs);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
(JNIEnv *env, jobject obj, jint op)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_operator %d\n", op);
@ -980,12 +1052,17 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
cairo_set_operator (gr->cr, CAIRO_OPERATOR_XOR);
break;
}
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBColor
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@ -1000,22 +1077,33 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBColor
cairo_set_rgb_color (gr->cr, b, g, r);
else
cairo_set_rgb_color (gr->cr, r, g, b);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetAlpha
(JNIEnv *env, jobject obj, jdouble a)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_alpha %f\n", a);
cairo_set_alpha (gr->cr, a);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
(JNIEnv *env, jobject obj, jint rule)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
if (gr->debug) printf ("cairo_set_fill_rule %d\n", rule);
g_assert (gr != NULL);
@ -1028,22 +1116,32 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD);
break;
}
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
(JNIEnv *env, jobject obj, jdouble width)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_width %f\n", width);
cairo_set_line_width (gr->cr, width);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
(JNIEnv *env, jobject obj, jint cap)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_cap %d\n", cap);
@ -1061,12 +1159,17 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
break;
}
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
(JNIEnv *env, jobject obj, jint join)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_join %d\n", join);
@ -1084,6 +1187,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
break;
}
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
@ -1091,6 +1195,10 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
{
struct graphics2d *gr = NULL;
jdouble *dasharr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_dash\n");
@ -1098,16 +1206,22 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
g_assert (dasharr != NULL);
cairo_set_dash (gr->cr, dasharr, ndash, offset);
(*env)->ReleaseDoubleArrayElements (env, dashes, dasharr, 0);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
(JNIEnv *env, jobject obj, jdouble miter)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_miter_limit %f\n", miter);
cairo_set_miter_limit (gr->cr, miter);
gdk_threads_leave();
}
@ -1115,132 +1229,197 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_new_path\n");
cairo_new_path (gr->cr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoMoveTo
(JNIEnv *env, jobject obj, jdouble x, jdouble y)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_move_to (%f, %f)\n", x, y);
cairo_move_to (gr->cr, x, y);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoLineTo
(JNIEnv *env, jobject obj, jdouble x, jdouble y)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_line_to (%f, %f)\n", x, y);
cairo_line_to (gr->cr, x, y);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoCurveTo
(JNIEnv *env, jobject obj, jdouble x1, jdouble y1, jdouble x2, jdouble y2, jdouble x3, jdouble y3)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_curve_to (%f, %f), (%f, %f), (%f, %f)\n", x1, y1, x2, y2, x3, y3);
cairo_curve_to (gr->cr, x1, y1, x2, y2, x3, y3);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelMoveTo
(JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_move_to (%f, %f)\n", dx, dy);
cairo_rel_move_to (gr->cr, dx, dy);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelLineTo
(JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_line_to (%f, %f)\n", dx, dy);
cairo_rel_line_to (gr->cr, dx, dy);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelCurveTo
(JNIEnv *env, jobject obj, jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2, jdouble dx3, jdouble dy3)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_curve_to (%f, %f), (%f, %f), (%f, %f)\n", dx1, dy1, dx2, dy2, dx3, dy3);
cairo_rel_curve_to (gr->cr, dx1, dy1, dx2, dy2, dx3, dy3);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble width, jdouble height)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rectangle (%f, %f) (%f, %f)\n", x, y, width, height);
cairo_rectangle (gr->cr, x, y, width, height);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClosePath
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_close_path\n");
cairo_close_path (gr->cr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoStroke
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_stroke\n");
begin_drawing_operation (gr);
cairo_stroke (gr->cr);
end_drawing_operation (gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoFill
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_fill\n");
begin_drawing_operation (gr);
cairo_fill (gr->cr);
end_drawing_operation (gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_clip\n");
cairo_init_clip (gr->cr);
cairo_clip (gr->cr);
begin_drawing_operation (gr);
cairo_init_clip (gr->cr);
cairo_clip (gr->cr);
end_drawing_operation (gr);
gdk_threads_leave();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_surface_set_filter %d\n", filter);
@ -1262,4 +1441,5 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetF
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BEST);
break;
}
gdk_threads_leave();
}

View file

@ -96,11 +96,14 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetLabel
void *ptr;
ptr = NSA_GET_PTR (env, obj);
label = gtk_bin_get_child (GTK_BIN(ptr));
text = (*env)->GetStringUTFChars (env, jtext, NULL);
gdk_threads_enter ();
label = gtk_bin_get_child (GTK_BIN (ptr));
gtk_label_set_text (GTK_LABEL(label), text);
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, jtext, text);
@ -112,22 +115,20 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetFont
{
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();
label = gtk_bin_get_child (GTK_BIN (ptr));
if (!label)
return;
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * PANGO_SCALE);
@ -173,3 +174,18 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetForeground
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkActivate
(JNIEnv *env, jobject obj)
{
void *ptr;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_widget_activate (GTK_WIDGET (ptr));
gdk_threads_leave ();
}

View file

@ -39,9 +39,370 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include <gtk/gtkprivate.h>
#include <gdk/gdkkeysyms.h>
static GtkWidget *find_fg_color_widget (GtkWidget *widget);
static GtkWidget *find_bg_color_widget (GtkWidget *widget);
static gboolean focus_in_cb (GtkWidget *widget,
GdkEventFocus *event,
jobject peer);
static gboolean focus_out_cb (GtkWidget *widget,
GdkEventFocus *event,
jobject peer);
/*
* This method returns a GDK keyval that corresponds to one of the
* keysyms in the X keymap table. The return value is only used to
* determine the keyval's corresponding hardware keycode, and doesn't
* reflect an accurate translation of a Java virtual key value to a
* GDK keyval.
*/
#ifdef __GNUC__
__inline
#endif
static guint
awt_keycode_to_keysym (jint keyCode, jint keyLocation)
{
/* GDK_A through GDK_Z */
if (keyCode >= VK_A && keyCode <= VK_Z)
return gdk_keyval_to_lower (keyCode);
/* GDK_0 through GDK_9 */
if (keyCode >= VK_0 && keyCode <= VK_9)
return keyCode;
switch (keyCode)
{
case VK_ENTER:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Enter : GDK_Return;
case VK_BACK_SPACE:
return GDK_BackSpace;
case VK_TAB:
return GDK_Tab;
case VK_CANCEL:
return GDK_Cancel;
case VK_CLEAR:
return GDK_Clear;
case VK_SHIFT:
return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Shift_L : GDK_Shift_R;
case VK_CONTROL:
return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Control_L : GDK_Control_R;
case VK_ALT:
return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Alt_L : GDK_Alt_R;
case VK_PAUSE:
return GDK_Pause;
case VK_CAPS_LOCK:
return GDK_Caps_Lock;
case VK_ESCAPE:
return GDK_Escape;
case VK_SPACE:
return GDK_space;
case VK_PAGE_UP:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Up : GDK_Page_Up;
case VK_PAGE_DOWN:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Down : GDK_Page_Down;
case VK_END:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_End : GDK_End;
case VK_HOME:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Home : GDK_Home;
case VK_LEFT:
return GDK_Left;
case VK_UP:
return GDK_Up;
case VK_RIGHT:
return GDK_Right;
case VK_DOWN:
return GDK_Down;
case VK_COMMA:
return GDK_comma;
case VK_MINUS:
return GDK_minus;
case VK_PERIOD:
return GDK_period;
case VK_SLASH:
return GDK_slash;
/*
case VK_0:
case VK_1:
case VK_2:
case VK_3:
case VK_4:
case VK_5:
case VK_6:
case VK_7:
case VK_8:
case VK_9:
*/
case VK_SEMICOLON:
return GDK_semicolon;
case VK_EQUALS:
return GDK_equal;
/*
case VK_A:
case VK_B:
case VK_C:
case VK_D:
case VK_E:
case VK_F:
case VK_G:
case VK_H:
case VK_I:
case VK_J:
case VK_K:
case VK_L:
case VK_M:
case VK_N:
case VK_O:
case VK_P:
case VK_Q:
case VK_R:
case VK_S:
case VK_T:
case VK_U:
case VK_V:
case VK_W:
case VK_X:
case VK_Y:
case VK_Z:
*/
case VK_OPEN_BRACKET:
return GDK_bracketleft;
case VK_BACK_SLASH:
return GDK_backslash;
case VK_CLOSE_BRACKET:
return GDK_bracketright;
case VK_NUMPAD0:
return GDK_KP_0;
case VK_NUMPAD1:
return GDK_KP_1;
case VK_NUMPAD2:
return GDK_KP_2;
case VK_NUMPAD3:
return GDK_KP_3;
case VK_NUMPAD4:
return GDK_KP_4;
case VK_NUMPAD5:
return GDK_KP_5;
case VK_NUMPAD6:
return GDK_KP_6;
case VK_NUMPAD7:
return GDK_KP_7;
case VK_NUMPAD8:
return GDK_KP_8;
case VK_NUMPAD9:
return GDK_KP_9;
case VK_MULTIPLY:
return GDK_KP_Multiply;
case VK_ADD:
return GDK_KP_Add;
/*
case VK_SEPARATER:
*/
case VK_SEPARATOR:
return GDK_KP_Separator;
case VK_SUBTRACT:
return GDK_KP_Subtract;
case VK_DECIMAL:
return GDK_KP_Decimal;
case VK_DIVIDE:
return GDK_KP_Divide;
case VK_DELETE:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Delete : GDK_Delete;
case VK_NUM_LOCK:
return GDK_Num_Lock;
case VK_SCROLL_LOCK:
return GDK_Scroll_Lock;
case VK_F1:
return GDK_F1;
case VK_F2:
return GDK_F2;
case VK_F3:
return GDK_F3;
case VK_F4:
return GDK_F4;
case VK_F5:
return GDK_F5;
case VK_F6:
return GDK_F6;
case VK_F7:
return GDK_F7;
case VK_F8:
return GDK_F8;
case VK_F9:
return GDK_F9;
case VK_F10:
return GDK_F10;
case VK_F11:
return GDK_F11;
case VK_F12:
return GDK_F12;
case VK_F13:
return GDK_F13;
case VK_F14:
return GDK_F14;
case VK_F15:
return GDK_F15;
case VK_F16:
return GDK_F16;
case VK_F17:
return GDK_F17;
case VK_F18:
return GDK_F18;
case VK_F19:
return GDK_F19;
case VK_F20:
return GDK_F20;
case VK_F21:
return GDK_F21;
case VK_F22:
return GDK_F22;
case VK_F23:
return GDK_F23;
case VK_F24:
return GDK_F24;
case VK_PRINTSCREEN:
return GDK_Print;
case VK_INSERT:
return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Insert : GDK_Insert;
case VK_HELP:
return GDK_Help;
case VK_META:
return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Meta_L : GDK_Meta_R;
case VK_BACK_QUOTE:
return GDK_grave;
case VK_QUOTE:
return GDK_apostrophe;
case VK_KP_UP:
return GDK_KP_Up;
case VK_KP_DOWN:
return GDK_KP_Down;
case VK_KP_LEFT:
return GDK_KP_Left;
case VK_KP_RIGHT:
return GDK_KP_Right;
case VK_DEAD_GRAVE:
return GDK_dead_grave;
case VK_DEAD_ACUTE:
return GDK_dead_acute;
case VK_DEAD_CIRCUMFLEX:
return GDK_dead_circumflex;
case VK_DEAD_TILDE:
return GDK_dead_tilde;
case VK_DEAD_MACRON:
return GDK_dead_macron;
case VK_DEAD_BREVE:
return GDK_dead_breve;
case VK_DEAD_ABOVEDOT:
return GDK_dead_abovedot;
case VK_DEAD_DIAERESIS:
return GDK_dead_diaeresis;
case VK_DEAD_ABOVERING:
return GDK_dead_abovering;
case VK_DEAD_DOUBLEACUTE:
return GDK_dead_doubleacute;
case VK_DEAD_CARON:
return GDK_dead_caron;
case VK_DEAD_CEDILLA:
return GDK_dead_cedilla;
case VK_DEAD_OGONEK:
return GDK_dead_ogonek;
case VK_DEAD_IOTA:
return GDK_dead_iota;
case VK_DEAD_VOICED_SOUND:
return GDK_dead_voiced_sound;
case VK_DEAD_SEMIVOICED_SOUND:
return GDK_dead_semivoiced_sound;
case VK_AMPERSAND:
return GDK_ampersand;
case VK_ASTERISK:
return GDK_asterisk;
case VK_QUOTEDBL:
return GDK_quotedbl;
case VK_LESS:
return GDK_less;
case VK_GREATER:
return GDK_greater;
case VK_BRACELEFT:
return GDK_braceleft;
case VK_BRACERIGHT:
return GDK_braceright;
case VK_AT:
return GDK_at;
case VK_COLON:
return GDK_colon;
case VK_CIRCUMFLEX:
return GDK_asciicircum;
case VK_DOLLAR:
return GDK_dollar;
case VK_EURO_SIGN:
return GDK_EuroSign;
case VK_EXCLAMATION_MARK:
return GDK_exclam;
case VK_INVERTED_EXCLAMATION_MARK:
return GDK_exclamdown;
case VK_LEFT_PARENTHESIS:
return GDK_parenleft;
case VK_NUMBER_SIGN:
return GDK_numbersign;
case VK_PLUS:
return GDK_plus;
case VK_RIGHT_PARENTHESIS:
return GDK_parenright;
case VK_UNDERSCORE:
return GDK_underscore;
/*
case VK_FINAL:
case VK_CONVERT:
case VK_NONCONVERT:
case VK_ACCEPT:
*/
case VK_MODECHANGE:
return GDK_Mode_switch;
/*
case VK_KANA:
*/
case VK_KANJI:
return GDK_Kanji;
/*
case VK_ALPHANUMERIC:
*/
case VK_KATAKANA:
return GDK_Katakana;
case VK_HIRAGANA:
return GDK_Hiragana;
/*
case VK_FULL_WIDTH:
case VK_HALF_WIDTH:
case VK_ROMAN_CHARACTERS:
case VK_ALL_CANDIDATES:
*/
case VK_PREVIOUS_CANDIDATE:
return GDK_PreviousCandidate;
case VK_CODE_INPUT:
return GDK_Codeinput;
/*
case VK_JAPANESE_KATAKANA:
case VK_JAPANESE_HIRAGANA:
case VK_JAPANESE_ROMAN:
*/
case VK_KANA_LOCK:
return GDK_Kana_Lock;
/*
case VK_INPUT_METHOD_ON_OFF:
case VK_CUT:
case VK_COPY:
case VK_PASTE:
case VK_UNDO:
case VK_AGAIN:
case VK_FIND:
case VK_PROPS:
case VK_STOP:
case VK_COMPOSE:
case VK_ALT_GRAPH:
*/
default:
return GDK_VoidSymbol;
}
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
@ -110,6 +471,137 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus
(JNIEnv *env, jobject obj)
{
void *ptr;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_widget_grab_focus (GTK_WIDGET (ptr));
gdk_threads_leave ();
}
/*
* Translate a Java KeyEvent object into a GdkEventKey event, then
* pass it to the GTK main loop for processing.
*/
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent
(JNIEnv *env, jobject obj, jint id, jlong when, jint mods,
jint keyCode, jint keyLocation)
{
void *ptr;
GdkEvent *event = NULL;
GdkKeymapKey *keymap_keys = NULL;
gint n_keys = 0;
guint lookup_keyval = 0;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
if (id == AWT_KEY_PRESSED)
event = gdk_event_new (GDK_KEY_PRESS);
else if (id == AWT_KEY_RELEASED)
event = gdk_event_new (GDK_KEY_RELEASE);
else
{
gdk_threads_leave ();
/* Don't send AWT KEY_TYPED events to GTK. */
return;
}
if (GTK_IS_BUTTON (ptr))
event->key.window = GTK_BUTTON (ptr)->event_window;
else if (GTK_IS_SCROLLED_WINDOW (ptr))
event->key.window = GTK_WIDGET (GTK_SCROLLED_WINDOW (ptr)->container.child)->window;
else
event->key.window = GTK_WIDGET (ptr)->window;
event->key.send_event = 0;
event->key.time = (guint32) when;
if (mods & AWT_SHIFT_MASK)
event->key.state |= GDK_SHIFT_MASK;
if (mods & AWT_CTRL_MASK)
event->key.state |= GDK_CONTROL_MASK;
if (mods & AWT_ALT_MASK)
event->key.state |= GDK_MOD1_MASK;
/* This hack is needed because the AWT has no notion of num lock.
It infers numlock state from the only Java virtual keys that are
affected by it. */
if (keyCode == VK_NUMPAD9
|| keyCode == VK_NUMPAD8
|| keyCode == VK_NUMPAD7
|| keyCode == VK_NUMPAD6
|| keyCode == VK_NUMPAD5
|| keyCode == VK_NUMPAD4
|| keyCode == VK_NUMPAD3
|| keyCode == VK_NUMPAD2
|| keyCode == VK_NUMPAD1
|| keyCode == VK_NUMPAD0
|| keyCode == VK_DECIMAL)
event->key.state |= GDK_MOD2_MASK;
/* These values don't need to be filled in since GTK doesn't use
them. */
event->key.length = 0;
event->key.string = NULL;
lookup_keyval = awt_keycode_to_keysym (keyCode, keyLocation);
if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
lookup_keyval,
&keymap_keys,
&n_keys))
{
/* No matching keymap entry was found. */
g_printerr ("No matching keymap entries were found\n");
gdk_threads_leave ();
return;
}
if (n_keys > 1)
g_printerr ("warning: using hardware keycode from first keymap entry, though multiple entries were found\n");
event->key.hardware_keycode = keymap_keys[0].keycode;
event->key.group = keymap_keys[0].group;
g_free (keymap_keys);
if (!gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
event->key.hardware_keycode,
event->key.state,
event->key.group,
&event->key.keyval,
NULL, NULL, NULL))
{
/* No matching keyval was found. */
g_printerr ("No matching keyval was found\n");
gdk_threads_leave ();
return;
}
/* keyevent = (GdkEventKey *) event; */
/* g_printerr ("generated event: sent: %d time: %d state: %d keyval: %d length: %d string: %s hardware_keycode: %d group: %d\n", keyevent->send_event, keyevent->time, keyevent->state, keyevent->keyval, keyevent->length, keyevent->string, keyevent->hardware_keycode, keyevent->group); */
/* We already received the original key event on the window itself,
so we don't want to resend it. */
if (!GTK_IS_WINDOW (ptr))
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
gtk_widget_event (GTK_WIDGET (GTK_SCROLLED_WINDOW (ptr)->container.child), event);
else
gtk_widget_event (GTK_WIDGET (ptr), event);
}
gdk_threads_leave ();
}
/*
* Find the origin of a widget's window.
*/
@ -734,6 +1226,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignal
g_signal_connect (GTK_OBJECT (ptr), "event",
G_CALLBACK (pre_event_handler), *gref);
g_signal_connect (G_OBJECT (ptr), "focus-in-event",
G_CALLBACK (focus_in_cb), *gref);
g_signal_connect (G_OBJECT (ptr), "focus-out-event",
G_CALLBACK (focus_out_cb), *gref);
gdk_threads_leave ();
}
@ -772,3 +1270,26 @@ find_bg_color_widget (GtkWidget *widget)
return bg_color_widget;
}
static gboolean
focus_in_cb (GtkWidget *widget __attribute((unused)),
GdkEventFocus *event __attribute((unused)),
jobject peer)
{
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postFocusEventID,
AWT_FOCUS_GAINED,
JNI_FALSE);
return FALSE;
}
static gboolean
focus_out_cb (GtkWidget *widget __attribute((unused)),
GdkEventFocus *event __attribute((unused)),
jobject peer)
{
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postFocusEventID,
AWT_FOCUS_LOST,
JNI_FALSE);
return FALSE;
}

View file

@ -806,31 +806,6 @@ keyevent_to_awt_keychar (GdkEvent *event)
}
}
/* Checks if keyval triggers a KEY_TYPED event on the source widget.
This function identifies special keyvals that don't trigger
GtkIMContext "commit" signals, but that do trigger Java KEY_TYPED
events. */
static int
generates_key_typed_event (GdkEvent *event, GtkWidget *source)
{
guint keyval;
if (!GTK_IS_ENTRY (source)
&& !GTK_IS_TEXT_VIEW (source))
return event->key.length ? 1 : 0;
keyval = event->key.keyval;
return (keyval == GDK_Escape
|| keyval == GDK_BackSpace
|| keyval == GDK_Delete
|| keyval == GDK_KP_Delete
|| keyval == GDK_Return
|| keyval == GDK_KP_Enter
|| (keyval == GDK_Tab
&& GTK_IS_TEXT_VIEW(source))) ? 1 : 0;
}
void
awt_event_handler (GdkEvent *event)
{
@ -1055,104 +1030,53 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
}
}
break;
case GDK_FOCUS_CHANGE:
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postFocusEventID,
(jint) (event->focus_change.in) ?
(jint) (event->focus_change.in) ?
AWT_FOCUS_GAINED : AWT_FOCUS_LOST,
JNI_FALSE);
break;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
{
GdkWindow *obj_window;
jobject *focus_obj_ptr = NULL;
int generates_key_typed = 0;
if (GTK_IS_WINDOW (widget))
{
/* GdkEventKey *keyevent = (GdkEventKey *) event; */
/* g_printerr ("key press event: sent: %d time: %d state: %d keyval: %d length: %d string: %s hardware_keycode: %d group: %d\n", keyevent->send_event, keyevent->time, keyevent->state, keyevent->keyval, keyevent->length, keyevent->string, keyevent->hardware_keycode, keyevent->group); */
/* A widget with a grab will get key events */
if (!GTK_IS_WINDOW (widget))
focus_obj_ptr = &peer;
else
{
GtkWindow *window;
/* Check if we have an enabled focused widget in this window.
If not don't handle the event. */
window = GTK_WINDOW (widget);
if (!window->focus_widget
|| !GTK_WIDGET_IS_SENSITIVE (window->focus_widget)
|| !window->focus_widget->window)
return FALSE;
/* TextArea peers are attached to the scrolled window
that contains the GtkTextView, not to the text view
itself. Same for List. */
if (GTK_IS_TEXT_VIEW (window->focus_widget)
|| GTK_IS_CLIST (window->focus_widget))
{
obj_window = gtk_widget_get_parent (window->focus_widget)->window;
}
else if (GTK_IS_BUTTON (window->focus_widget))
/* GtkButton events go to the "event_window" and this is what
we registered when the button was created. */
obj_window = GTK_BUTTON (window->focus_widget)->event_window;
else
obj_window = window->focus_widget->window;
gdk_property_get (obj_window,
gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE),
gdk_atom_intern ("CARDINAL", FALSE),
0,
sizeof (jobject),
FALSE,
NULL,
NULL,
NULL,
(guchar **)&focus_obj_ptr);
/* If the window has no jobject attached we can't send anything */
if (!focus_obj_ptr)
return FALSE;
/* Should we generate an AWT_KEY_TYPED event? */
generates_key_typed = generates_key_typed_event (event, window->focus_widget);
}
if (event->type == GDK_KEY_PRESS)
{
(*gdk_env)->CallVoidMethod (gdk_env, *focus_obj_ptr,
postKeyEventID,
(jint) AWT_KEY_PRESSED,
(jlong) event->key.time,
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postKeyEventID,
(jint) AWT_KEY_PRESSED,
(jlong) event->key.time,
keyevent_state_to_awt_mods (event),
keysym_to_awt_keycode (event),
keyevent_to_awt_keychar (event),
keysym_to_awt_keylocation (event));
if (generates_key_typed)
{
(*gdk_env)->CallVoidMethod (gdk_env, *focus_obj_ptr,
postKeyEventID,
(jint) AWT_KEY_TYPED,
(jlong) event->key.time,
state_to_awt_mods (event->key.state),
VK_UNDEFINED,
keyevent_to_awt_keychar (event),
AWT_KEY_LOCATION_UNKNOWN);
}
/* FIXME: generation of key typed events needs to be moved
to GtkComponentPeer.postKeyEvent. If the key in a key
press event is not an "action" key
(KeyEvent.isActionKey) and is not a modifier key, then
it should generate a key typed event. */
return TRUE;
}
else /* GDK_KEY_RELEASE */
{
(*gdk_env)->CallVoidMethod (gdk_env, *focus_obj_ptr,
postKeyEventID,
(jint) AWT_KEY_RELEASED,
(jlong) event->key.time,
keyevent_state_to_awt_mods (event),
keysym_to_awt_keycode (event),
else
return FALSE;
break;
case GDK_KEY_RELEASE:
if (GTK_IS_WINDOW (widget))
{
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postKeyEventID,
(jint) AWT_KEY_RELEASED,
(jlong) event->key.time,
keyevent_state_to_awt_mods (event),
keysym_to_awt_keycode (event),
keyevent_to_awt_keychar (event),
keysym_to_awt_keylocation (event));
}
}
return TRUE;
}
else
return FALSE;
break;
default:
break;

View file

@ -58,6 +58,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels
g = (struct graphics *) NSA_GET_PTR (env, gc_obj);
if (!jpixels)
return;
elems = (*env)->GetIntArrayElements (env, jpixels, NULL);
num_pixels = (*env)->GetArrayLength (env, jpixels);

View file

@ -1,76 +1,109 @@
/* gtklistpeer.c -- Native implementation of GtkListPeer
Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
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 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.
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.
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. */
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. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include "gnu_java_awt_peer_gtk_GtkListPeer.h"
static void item_select (GtkCList *list __attribute__((unused)),
int row, int col __attribute__((unused)),
GdkEventButton *event __attribute__((unused)),
jobject peer_obj);
static void item_unselect (GtkCList *list __attribute__((unused)),
int row,
int col __attribute__((unused)),
GdkEventButton *event __attribute__((unused)),
jobject peer_obj);
enum
{
COLUMN_STRING,
N_COLUMNS
};
#define CLIST_FROM_SW(obj) (GTK_CLIST(GTK_SCROLLED_WINDOW (obj)->container.child))
#define TREE_VIEW_FROM_SW(obj) \
(GTK_TREE_VIEW (GTK_SCROLLED_WINDOW (obj)->container.child))
JNIEXPORT void JNICALL
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_create
(JNIEnv *env, jobject obj)
(JNIEnv *env, jobject obj, jint rows)
{
GtkWidget *list, *sw;
GtkWidget *sw;
GtkWidget *list;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *list_store;
GtkTreeIter iter;
GtkRequisition req;
gint i;
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
gdk_threads_enter ();
list = gtk_clist_new (1);
gtk_widget_show (list);
list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING);
/* Add the number of rows so that we can calculate the tree view's
size request. */
for (i = 0; i < rows; i++)
{
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
COLUMN_STRING, "",
-1);
}
list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (NULL,
renderer,
"text",
COLUMN_STRING,
NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list), FALSE);
gtk_widget_size_request (GTK_WIDGET (list), &req);
gtk_widget_set_size_request (GTK_WIDGET (list), req.width, req.height);
gtk_container_add (GTK_CONTAINER (sw), list);
/* Remove the blank rows. */
gtk_list_store_clear (list_store);
gtk_widget_show (list);
gtk_widget_show (sw);
gdk_threads_leave ();
NSA_SET_PTR (env, obj, sw);
@ -87,7 +120,6 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_connectJObject
gdk_threads_enter ();
gtk_widget_realize (GTK_WIDGET (ptr));
connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window);
gdk_threads_leave ();
@ -97,50 +129,98 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_connectSignals
(JNIEnv *env, jobject obj)
{
GtkCList *list;
void *ptr = NSA_GET_PTR (env, obj);
jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
void *ptr;
GtkTreeView *list;
jobject *gref;
gref = NSA_GET_GLOBAL_REF (env, obj);
g_assert (gref);
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_widget_realize (GTK_WIDGET (ptr));
/* connect selectable hook */
list = CLIST_FROM_SW (ptr);
g_signal_connect (G_OBJECT (list), "select_row",
GTK_SIGNAL_FUNC (item_select), *gref);
g_signal_connect (G_OBJECT (list), "unselect_row",
GTK_SIGNAL_FUNC (item_unselect), *gref);
/* Connect the superclass signals. */
/* FIXME: Cannot do that here or it will get the sw and not the list.
We must a generic way of doing this. */
/* Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, peer_obj); */
g_signal_connect (GTK_OBJECT (list), "event",
list = TREE_VIEW_FROM_SW (ptr);
g_signal_connect (G_OBJECT (list), "event",
G_CALLBACK (pre_event_handler), *gref);
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_append
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
const char *font_name;
void *ptr;
GtkWidget *list;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter();
list = GTK_WIDGET (TREE_VIEW_FROM_SW (ptr));
font_name = (*env)->GetStringUTFChars (env, name, NULL);
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 (list), font_desc);
pango_font_description_free (font_desc);
(*env)->ReleaseStringUTFChars (env, name, font_name);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkWidgetRequestFocus
(JNIEnv *env, jobject obj)
{
void *ptr;
GtkWidget *list;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
list = GTK_WIDGET (TREE_VIEW_FROM_SW (ptr));
gtk_widget_grab_focus (list);
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_append
(JNIEnv *env, jobject obj, jobjectArray items)
{
void *ptr;
GtkCList *list;
jint count, i;
GtkTreeView *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
jint count;
jint i;
ptr = NSA_GET_PTR (env, obj);
count = (*env)->GetArrayLength (env, items);
gdk_threads_enter ();
list = CLIST_FROM_SW (ptr);
for (i = 0; i < count; i++)
list = TREE_VIEW_FROM_SW (ptr);
list_store = gtk_tree_view_get_model (list);
for (i = 0; i < count; i++)
{
const char *text;
jobject item;
@ -148,11 +228,13 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_append
item = (*env)->GetObjectArrayElement (env, items, i);
text = (*env)->GetStringUTFChars (env, item, NULL);
gtk_clist_append (list, (char **)&text);
gtk_list_store_append (GTK_LIST_STORE (list_store), &iter);
gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
COLUMN_STRING, text,
-1);
(*env)->ReleaseStringUTFChars (env, item, text);
}
gtk_clist_columns_autosize (list);
gdk_threads_leave ();
}
@ -162,12 +244,26 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_add
{
void *ptr;
const char *str;
GtkTreeView *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, text, NULL);
gdk_threads_enter ();
gtk_clist_insert (CLIST_FROM_SW (ptr), index, (char **)&str);
list = TREE_VIEW_FROM_SW (ptr);
list_store = gtk_tree_view_get_model (list);
if (index == -1)
gtk_list_store_append (GTK_LIST_STORE (list_store), &iter);
else
gtk_list_store_insert (GTK_LIST_STORE (list_store), &iter, index);
gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
COLUMN_STRING, str, -1);
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, text, str);
@ -179,22 +275,32 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_delItems
(JNIEnv *env, jobject obj, jint start, jint end)
{
void *ptr;
GtkCList *list;
GtkTreeView *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
jint i;
jint num_items;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
list = CLIST_FROM_SW (ptr);
if (end == -1) /* special case for removing all rows */
gtk_clist_clear (list);
list = TREE_VIEW_FROM_SW (ptr);
list_store = gtk_tree_view_get_model (list);
/* Special case: remove all rows. */
if (end == -1)
gtk_list_store_clear (GTK_LIST_STORE (list_store));
else
{
gtk_clist_freeze (list);
for (i = end; i >= start; i--)
gtk_clist_remove (list, i);
gtk_clist_thaw (list);
i = 0;
num_items = end - start + 1;
gtk_tree_model_iter_nth_child (list_store, &iter, NULL, start);
while (i < num_items)
{
gtk_list_store_remove (GTK_LIST_STORE (list_store), &iter);
i++;
}
}
gdk_threads_leave ();
@ -205,11 +311,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_select
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
GtkTreeView *list;
GtkTreePath *path;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_clist_select_row (CLIST_FROM_SW (ptr), index, 0);
list = TREE_VIEW_FROM_SW (ptr);
path = gtk_tree_path_new_from_indices (index, -1);
gtk_tree_view_set_cursor (list, path, NULL, FALSE);
gdk_threads_leave ();
}
@ -218,40 +330,61 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_deselect
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
GtkTreeView *list;
GtkTreeSelection *selection;
GtkTreePath *path;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_clist_unselect_row (CLIST_FROM_SW (ptr), index, 0);
list = TREE_VIEW_FROM_SW (ptr);
selection = gtk_tree_view_get_selection (list);
path = gtk_tree_path_new_from_indices (index, -1);
gtk_tree_selection_unselect_path (selection, path);
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize
(JNIEnv *env, jobject obj, jint rows, jintArray jdims)
(JNIEnv *env, jobject obj, jint rows, jint visible_rows, jintArray jdims)
{
void *ptr;
jint *dims;
GtkWidget *list;
GtkScrolledWindow *sw;
GtkRequisition myreq;
GtkRequisition current_req;
GtkRequisition natural_req;
dims = (*env)->GetIntArrayElements (env, jdims, NULL);
dims[0] = dims[1] = 0;
if (rows < 3)
rows = 3;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
list = GTK_WIDGET (CLIST_FROM_SW (ptr));
sw = GTK_SCROLLED_WINDOW (ptr);
/* Save the widget's current size request. */
gtk_widget_size_request (GTK_WIDGET (ptr), &current_req);
/* Get the widget's "natural" size request. */
gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1);
gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req);
/* Reset the widget's size request. */
gtk_widget_set_size_request (GTK_WIDGET (ptr),
current_req.width, current_req.height);
dims[0] = natural_req.width;
/* Calculate the final height, by comparing the number of rows
in the list to the number of rows requested by the caller.
FIXME: Is there a GTK method that counts the number of rows
in the list? If so, we don't need to bring visible_rows from
the Java peer. */
if (rows == visible_rows)
dims[1] = natural_req.height;
else
dims[1] = natural_req.height / visible_rows * rows;
gtk_widget_size_request(GTK_WIDGET(sw), &myreq);
dims[1]=myreq.height;
dims[0]=myreq.width;
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
@ -263,31 +396,53 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes
(JNIEnv *env, jobject obj)
{
void *ptr;
GtkCList *list;
jintArray selection;
jint *sel;
GList *child;
jint count, i;
GtkTreeView *list;
GtkTreeSelection *selection;
jintArray result_array;
jint *result_array_iter;
GList *current_row;
GList *rows;
gint *indices;
jint count;
jint i;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
list = CLIST_FROM_SW (ptr);
count = g_list_length (list->selection);
selection = (*env)->NewIntArray (env, count);
sel = (*env)->GetIntArrayElements (env, selection, NULL);
for (i = 0, child = list->selection; i < count; i++)
list = TREE_VIEW_FROM_SW (ptr);
selection = gtk_tree_view_get_selection (list);
count = gtk_tree_selection_count_selected_rows (selection);
if (count > 0)
{
sel[i] = GPOINTER_TO_INT (child->data);
child = g_list_next (child);
current_row = rows = gtk_tree_selection_get_selected_rows (selection, NULL);
result_array = (*env)->NewIntArray (env, count);
result_array_iter = (*env)->GetIntArrayElements (env, result_array, NULL);
for (i = 0; i < count; i++)
{
indices = gtk_tree_path_get_indices (current_row->data);
result_array_iter[i] = indices ? indices[0] : -1;
current_row = g_list_next (current_row);
}
if (rows)
{
g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
g_list_free (rows);
}
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
return result_array;
}
gdk_threads_leave ();
else
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements (env, selection, sel, 0);
return selection;
return (jintArray) NULL;
}
JNIEXPORT void JNICALL
@ -295,11 +450,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_makeVisible
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
GtkTreeView *list;
GtkTreePath *path;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_clist_moveto (CLIST_FROM_SW (ptr), index, 0, 0.5, 0.5);
list = TREE_VIEW_FROM_SW (ptr);
path = gtk_tree_path_new_from_indices (index, -1);
gtk_tree_view_scroll_to_cell (list, path, NULL, FALSE, 0.0, 0.0);
gdk_threads_leave ();
}
@ -308,38 +469,18 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_setMultipleMode
(JNIEnv *env, jobject obj, jboolean mode)
{
void *ptr;
GtkTreeView *list;
GtkTreeSelection *selection;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_clist_set_selection_mode (CLIST_FROM_SW (ptr),
mode ? GTK_SELECTION_MULTIPLE :
GTK_SELECTION_SINGLE);
list = TREE_VIEW_FROM_SW (ptr);
selection = gtk_tree_view_get_selection (list);
gtk_tree_selection_set_mode (selection,
mode ? GTK_SELECTION_MULTIPLE
: GTK_SELECTION_SINGLE);
gdk_threads_leave ();
}
static void
item_select (GtkCList *list __attribute__((unused)),
int row, int col __attribute__((unused)),
GdkEventButton *event __attribute__((unused)),
jobject peer_obj)
{
(*gdk_env)->CallVoidMethod (gdk_env, peer_obj,
postListItemEventID,
row,
(jint) AWT_ITEM_SELECTED);
}
static void
item_unselect (GtkCList *list __attribute__((unused)),
int row,
int col __attribute__((unused)),
GdkEventButton *event __attribute__((unused)),
jobject peer_obj)
{
(*gdk_env)->CallVoidMethod (gdk_env, peer_obj,
postListItemEventID,
row,
(jint) AWT_ITEM_DESELECTED);
}

View file

@ -46,8 +46,11 @@ accel_attach (GtkMenuItem *menu_item,
GtkAccelGroup *accel;
accel = gtk_menu_get_accel_group (GTK_MENU (menu_item->submenu));
/* FIXME: update this to use GTK-2.4 GtkActions. */
#if 0
_gtk_accel_group_attach (accel,
G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET(menu_item))));
#endif
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup
@ -129,7 +132,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addItem
(JNIEnv *env, jobject obj, jobject menuitempeer, jint key, jboolean shift)
{
void *ptr1, *ptr2;
GtkMenu *menu;
GtkWidget *menu;
ptr1 = NSA_GET_PTR (env, obj);
ptr2 = NSA_GET_PTR (env, menuitempeer);
@ -142,7 +145,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addItem
if (key)
{
gtk_widget_add_accelerator (GTK_WIDGET (ptr2), "activate",
gtk_menu_get_accel_group (menu), key,
gtk_menu_get_accel_group (GTK_MENU (menu)), key,
(GDK_CONTROL_MASK
| ((shift) ? GDK_SHIFT_MASK : 0)),
GTK_ACCEL_VISIBLE);

View file

@ -93,7 +93,10 @@ Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_setupAccelGroup
gdk_threads_enter ();
menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu);
gtk_menu_set_accel_group (menu, gtk_accel_group_new ());
/* FIXME: update this to use GTK-2.4 GtkActions. */
#if 0
_gtk_accel_group_attach (gtk_menu_get_accel_group (menu),
G_OBJECT (gtk_widget_get_toplevel (ptr2)));
#endif
gdk_threads_leave ();
}

View file

@ -164,7 +164,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkSetFont
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
gtk_widget_modify_font (GTK_WIDGET(text), font_desc);
gtk_widget_modify_font (GTK_WIDGET (text), font_desc);
pango_font_description_free (font_desc);
@ -173,6 +173,24 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkSetFont
(*env)->ReleaseStringUTFChars (env, name, font_name);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetRequestFocus
(JNIEnv *env, jobject obj)
{
void *ptr;
GtkWidget *text;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
text = GTK_WIDGET (TEXT_FROM_SW (ptr));
gtk_widget_grab_focus (text);
gdk_threads_leave ();
}
JNIEXPORT jint JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getHScrollbarHeight
(JNIEnv *env, jobject obj)

View file

@ -40,10 +40,6 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h"
static void textcomponent_commit_cb (GtkIMContext *context,
const gchar *str,
jobject peer);
static void textcomponent_changed_cb (GtkEditable *editable,
jobject peer);
@ -61,9 +57,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectSignals
if (GTK_IS_ENTRY(ptr))
{
g_signal_connect (GTK_ENTRY (ptr)->im_context, "commit",
G_CALLBACK (textcomponent_commit_cb), *gref);
g_signal_connect (GTK_EDITABLE (ptr), "changed",
G_CALLBACK (textcomponent_changed_cb), *gref);
@ -85,9 +78,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectSignals
if (text)
{
g_signal_connect (text->im_context, "commit",
G_CALLBACK (textcomponent_commit_cb), *gref);
buf = gtk_text_view_get_buffer (text);
if (buf)
g_signal_connect (buf, "changed",
@ -112,8 +102,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getCaretPosition
{
void *ptr;
int pos = 0;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextMark *mark;
GtkTextIter iter;
@ -157,8 +147,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setCaretPosition
(JNIEnv *env, jobject obj, jint pos)
{
void *ptr;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextIter iter;
@ -198,8 +188,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionStart
{
void *ptr;
int pos = 0;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
@ -255,8 +245,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionEnd
{
void *ptr;
int pos = 0;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
@ -311,8 +301,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_select
(JNIEnv *env, jobject obj, jint start, jint end)
{
void *ptr;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextIter iter;
@ -357,8 +347,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setEditable
(JNIEnv *env, jobject obj, jboolean state)
{
void *ptr;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
ptr = NSA_GET_PTR (env, obj);
@ -396,8 +386,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getText
void *ptr;
char *contents = NULL;
jstring jcontents;
GtkEditable *editable; /* type of GtkEntry (TextField) */
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkEditable *editable;
GtkWidget *text = NULL;
GtkTextBuffer *buf;
GtkTextIter start, end;
@ -444,7 +434,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setText
{
void *ptr;
const char *str;
GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkWidget *text = NULL;
GtkTextBuffer *buf;
ptr = NSA_GET_PTR (env, obj);
@ -479,28 +469,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setText
(*env)->ReleaseStringUTFChars (env, contents, str);
}
static void
textcomponent_commit_cb (GtkIMContext *context __attribute__((unused)),
const gchar *str,
jobject peer)
{
/* str is a \0-terminated UTF-8 encoded character. */
gunichar2 *jc = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL);
GdkEvent *event = gtk_get_current_event ();
if (jc)
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postKeyEventID,
(jint) AWT_KEY_TYPED,
(jlong) event->key.time,
keyevent_state_to_awt_mods (event),
VK_UNDEFINED,
(jchar) jc[0],
AWT_KEY_LOCATION_UNKNOWN);
g_free (jc);
gdk_event_free (event);
}
static void
textcomponent_changed_cb (GtkEditable *editable __attribute__((unused)),
jobject peer)

View file

@ -39,6 +39,8 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkToolkit.h"
static jint gdk_color_to_java_color (GdkColor color);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkToolkit_beep
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
@ -88,3 +90,70 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenResolution
return res;
}
#define CONVERT(type, state) \
gdk_color_to_java_color (style->type[GTK_STATE_ ## state])
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors
(JNIEnv *env, jobject obj __attribute__((unused)),
jintArray jcolors)
{
jint *colors;
GtkStyle *style;
colors = (*env)->GetIntArrayElements (env, jcolors, 0);
gdk_threads_enter ();
style = gtk_widget_get_default_style ();
colors[AWT_DESKTOP] = CONVERT (bg, SELECTED);
colors[AWT_ACTIVE_CAPTION] = CONVERT (bg, SELECTED);
colors[AWT_ACTIVE_CAPTION_TEXT] = CONVERT (text, SELECTED);
colors[AWT_ACTIVE_CAPTION_BORDER] = CONVERT (fg, NORMAL);
colors[AWT_INACTIVE_CAPTION] = CONVERT (base, INSENSITIVE);
colors[AWT_INACTIVE_CAPTION_TEXT] = CONVERT (fg, INSENSITIVE);
colors[AWT_INACTIVE_CAPTION_BORDER] = CONVERT (fg, INSENSITIVE);
colors[AWT_WINDOW] = CONVERT (bg, NORMAL);
colors[AWT_WINDOW_BORDER] = CONVERT (fg, NORMAL);
colors[AWT_WINDOW_TEXT] = CONVERT (fg, NORMAL);
colors[AWT_MENU] = CONVERT (bg, NORMAL);
colors[AWT_MENU_TEXT] = CONVERT (fg, NORMAL);
colors[AWT_TEXT] = CONVERT (bg, NORMAL);
colors[AWT_TEXT_TEXT] = CONVERT (fg, NORMAL);
colors[AWT_TEXT_HIGHLIGHT] = CONVERT (bg, SELECTED);
colors[AWT_TEXT_HIGHLIGHT_TEXT] = CONVERT (fg, SELECTED);
colors[AWT_TEXT_INACTIVE_TEXT] = CONVERT (bg, INSENSITIVE);
colors[AWT_CONTROL] = CONVERT (bg, NORMAL);
colors[AWT_CONTROL_TEXT] = CONVERT (fg, NORMAL);
colors[AWT_CONTROL_HIGHLIGHT] = CONVERT (base, ACTIVE);
colors[AWT_CONTROL_LT_HIGHLIGHT] = CONVERT (bg, PRELIGHT);
colors[AWT_CONTROL_SHADOW] = CONVERT (bg, ACTIVE);
colors[AWT_CONTROL_DK_SHADOW] = CONVERT (fg, INSENSITIVE);
colors[AWT_SCROLLBAR] = CONVERT (base, INSENSITIVE);
colors[AWT_INFO] = CONVERT (bg, NORMAL);
colors[AWT_INFO_TEXT] = CONVERT (fg, NORMAL);
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements(env, jcolors, colors, 0);
}
#undef CONVERT
static jint
gdk_color_to_java_color (GdkColor gdk_color)
{
guchar red;
guchar green;
guchar blue;
float factor;
factor = 255.0 / 65535.0;
red = (float) gdk_color.red * factor;
green = (float) gdk_color.green * factor;
blue = (float) gdk_color.blue * factor;
return (jint) (0xff000000 | (red << 16) | (green << 8) | blue);
}

View file

@ -357,6 +357,20 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds
gdk_threads_enter ();
gtk_window_move (GTK_WINDOW(ptr), x, y);
/* The call to gdk_window_move is needed in addition to the call to
gtk_window_move. If gdk_window_move isn't called, then the
following set of operations doesn't give the expected results:
1. show a window
2. manually move it to another position on the screen
3. hide the window
4. reposition the window with Component.setLocation
5. show the window
Instead of being at the position set by setLocation, the window
is reshown at the position to which it was moved manually. */
gdk_window_move (GTK_WIDGET (ptr)->window, x, y);
/* Need to change the widget's request size. */
gtk_widget_set_size_request (GTK_WIDGET(ptr), width, height);
/* Also need to call gtk_window_resize. If the resize is requested

View file

@ -71,7 +71,8 @@ struct graphics2d
GdkWindow *win;
GdkPixbuf *drawbuf;
char *pattern_pixels;
cairo_surface_t *pattern;
cairo_surface_t *pattern_surface;
cairo_pattern_t *pattern;
gboolean debug;
};

View file

@ -361,8 +361,8 @@ struct graphics
#define VK_ALT_GRAPH 65406
#define VK_UNDEFINED 0
#define AWT_FOCUS_LOST 1004
#define AWT_FOCUS_GAINED 1005
#define AWT_FOCUS_GAINED 1004
#define AWT_FOCUS_LOST 1005
#define AWT_WINDOW_OPENED 200
#define AWT_WINDOW_CLOSING 201
@ -385,6 +385,35 @@ struct graphics
#define AWT_STYLE_BOLD 1
#define AWT_STYLE_ITALIC 2
/* From java.awt.SystemColor */
#define AWT_DESKTOP 0
#define AWT_ACTIVE_CAPTION 1
#define AWT_ACTIVE_CAPTION_TEXT 2
#define AWT_ACTIVE_CAPTION_BORDER 3
#define AWT_INACTIVE_CAPTION 4
#define AWT_INACTIVE_CAPTION_TEXT 5
#define AWT_INACTIVE_CAPTION_BORDER 6
#define AWT_WINDOW 7
#define AWT_WINDOW_BORDER 8
#define AWT_WINDOW_TEXT 9
#define AWT_MENU 10
#define AWT_MENU_TEXT 11
#define AWT_TEXT 12
#define AWT_TEXT_TEXT 13
#define AWT_TEXT_HIGHLIGHT 14
#define AWT_TEXT_HIGHLIGHT_TEXT 15
#define AWT_TEXT_INACTIVE_TEXT 16
#define AWT_CONTROL 17
#define AWT_CONTROL_TEXT 18
#define AWT_CONTROL_HIGHLIGHT 19
#define AWT_CONTROL_LT_HIGHLIGHT 20
#define AWT_CONTROL_SHADOW 21
#define AWT_CONTROL_DK_SHADOW 22
#define AWT_SCROLLBAR 23
#define AWT_INFO 24
#define AWT_INFO_TEXT 25
#define AWT_NUM_COLORS 26
extern jmethodID setBoundsCallbackID;
extern jmethodID postActionEventID;