Commit c5d2de6b by Graydon Hoare

[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
parent e314a036
......@@ -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 \
......
......@@ -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 \
......
......@@ -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);
......
......@@ -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 ();
......
......@@ -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());
}
}
......@@ -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
......
......@@ -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)
{
q.postEvent (new KeyEvent (awtComponent, id, when, mods,
keyCode, keyChar, keyLocation));
int keyCode, char keyChar, int 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)
......
......@@ -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 ()
{
......
......@@ -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,
......
......@@ -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
......
......@@ -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));
......
......@@ -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;
create (list.getRows ());
setMultipleMode (list.isMultipleMode ());
}
native void create ();
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 ());
}
......
......@@ -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 ());
}
}
......@@ -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)
......
......@@ -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)
{
......
......@@ -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 ();
}
/**
......
......@@ -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 ();
}
/**
......
......@@ -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
}
......@@ -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)
{
......
......@@ -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");
}
}
/**
......
......@@ -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);
}
/**
......
......@@ -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;
}
......
......@@ -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);
}
}
}
......
......@@ -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();
}
}
......
......@@ -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 );
}
......
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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); }
......
......@@ -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
}
}
}
......@@ -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); }
......
......@@ -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();
}
}
......@@ -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;
......@@ -532,6 +533,19 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
* 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.
*
......@@ -546,6 +560,32 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
* 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()
{
......@@ -578,6 +620,23 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
* 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.
*
* @return The current value of the 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;
}
/**
......
......@@ -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();
}
}
......@@ -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
}
}
}
......@@ -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)
{
}
//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 Container contentPane;
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 String getUIClassID()
{ return "RootPaneUI"; }
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)
{
}
}
protected Component glassPane;
protected JLayeredPane layeredPane;
protected JMenuBar menuBar;
protected Container contentPane;
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";
}
}
......@@ -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);
}
/**
......
......@@ -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)
JViewport vp = JScrollPane.this.getViewport();
if (vp != null && event.getSource() == vp)
{
BoundedRangeModel vmod = vsb.getModel();
if (vmod != null)
ypos = vmod.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);
}
if (hsb != null)
else
{
BoundedRangeModel hmod = hsb.getModel();
if (hmod != null)
xpos = hmod.getValue();
// 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);
}
}
}
*/
}
}
......@@ -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);
}
/**
......
......@@ -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)
{
......
......@@ -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); }
......
/* 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
......@@ -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));
......
......@@ -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;
}
}
......@@ -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);
}
/**
......
......@@ -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));
}
}
......@@ -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
......
......@@ -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)
......
......@@ -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)
{
......
......@@ -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()
......
......@@ -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.
}
......
......@@ -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));
}
}
......@@ -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[] {
......
/* 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)
{
}
}
}
/* 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)
{
}
}
}
/* 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)
{
}
}
}
......@@ -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");
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment