diff options
author | Graydon Hoare <graydon@gcc.gnu.org> | 2004-03-17 21:29:02 +0000 |
---|---|---|
committer | Graydon Hoare <graydon@gcc.gnu.org> | 2004-03-17 21:29:02 +0000 |
commit | 86881a7b541b2ec6557b1a315f841b211d14c576 (patch) | |
tree | 02790a2b250b62643a1de68b63bd078238bfaf46 /libjava/gnu | |
parent | ab3533d6559205bee768b8d9e359111d52d10733 (diff) | |
download | gcc-86881a7b541b2ec6557b1a315f841b211d14c576.zip gcc-86881a7b541b2ec6557b1a315f841b211d14c576.tar.gz gcc-86881a7b541b2ec6557b1a315f841b211d14c576.tar.bz2 |
[multiple changes]
2004-03-12 Graydon Hoare <graydon@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java: Clipping fixes.
* javax/swing/JComponent.java (paint): Use persistent double buffer.
* javax/swing/JList.java (ListListener): Revalidate on changes.
* javax/swing/JScrollPane.java: Reimplement.
* javax/swing/JViewport.java: Reimplement.
* javax/swing/ScrollPaneLayout.java: Reimplement.
* javax/swing/ViewportLayout.java: Tidy up.
* javax/swing/plaf/basic/BasicButtonListener.java: Remove printlns.
* javax/swing/plaf/basic/BasicScrollPaneUI.java: Reimplement.
* javax/swing/plaf/basic/BasicSliderUI.java: Handle missing labels.
* javax/swing/plaf/basic/BasicViewportUI.java: Implement in terms of
backing store only.
2004-03-11 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(window_wm_protocols_filter): New function.
(window_focus_in_cb): Remove function.
(window_focus_out_cb): Likewise.
(window_focus_or_active_state_change_cb): New function.
(create): Add filter that removes WM_TAKE_FOCUS client messages.
(connectSignals): Don't attach handlers to focus-in-event or
focus-out-event signals. Handle notify signal.
2004-03-11 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
(gtkSetLabel): New native method declaration.
(setLabel): Use gtkSetLabel.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel): New method.
2004-03-10 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java (setColor): Default to
black when color argument is null.
2004-03-10 Kim Ho <kho@redhat.com>
* java/awt/Container.java: Remove check
for drag events.
2004-03-10 Kim Ho <kho@redhat.com>
* java/awt/Container.java: (visitChild):
Remove candidate clip. Use the component
clip to intersect.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
(handleEvent): Use the PaintEvent's clip.
2004-03-10 Kim Ho <kho@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
(handleEvent): Don't set the clip for the
Graphics object.
2004-03-09 Graydon Hoare <graydon@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
Fix double <-> fixed macros, reset font transform.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c:
Likewise.
2004-03-09�� Kim Ho <kho@redhat.com>
* java/awt/Container.java: (visitChild): Move
the x and y coordinate of the component rectangle
to correct position.
(handleEvent): Forward drag events to the pressed
component.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Fix comments.
(ArrowButtonListener::mousePressed): Stop the
existing timer.
(mouseDragged): Implement.
(TrackListener::mousePressed): Only react if
the press doesn't occur on the thumb, otherwise
just set the offset.
(TrackListener::mouseReleased): Unset the isAdjusting
value.
(createIncreaseIcon): Switch icon.
(createDecreaseIcon): Switch icon.
(calculatePreferredSize): Use width.
(getThumbBounds): Use the top as the lower value.
(layoutVScrollBar): Switch the button locations.
(paintIncreaseHighlight): Paint correct side of thumb.
(paintDecreaseHighlight): ditto.
(valueForYPosition): Use top as the lower value.
* javax/swing/plaf/basic/BasicSliderUI.java:
Fix comments.
(mouseDragged): Implement.
(mousePressed): Only react when the thumb isn't
pressed, otherwise just set offset.
(mouseReleased): Handle a release of the thumb.
(scrollDueToClickInTrack): Stop the timer first.
* javax/swing/JProgressBar.java:
(setString): Fix change condition.
* javax/swing/JSeparator.java:
Remove println's.
2004-03-08 David Jee <djee@redhat.com>
* java/awt/image/AffineTransformOp.java:
(filter): Use Graphics2D interface instead of directly using the
GdkGraphics2D peer.
2004-03-05 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkButtonPeer.java
(handleEvent): Action events are generated upon MOUSE_RELEASED.
* java/awt/Container.java
(acquireComponentForMouseEvent): Fixed.
(handleEvent): Fixed.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(state_to_awt_mods_with_button_states): New method.
(pre_event_handler): Fixed mouse event generation.
2004-03-05 Olga Rodimina <rodimina@redhat.com>
gnu/java/awt/peer/gtk/GdkGraphics2D.java
(GdkGraphics2D (BufferedImage)): Initialize
pixmap associated with specified BufferedImage.
(setPaint): Changed implementation of Texture
Paint to use AffineTransformOp.
* java/awt/image/AffineTransformOp.java
(createCompatibleDestRaster): Throw RasterFormatException
if resulting width or height of raster is 0.
2004-03-04 Olga Rodimina <rodimina@redhat.com>
* java/awt/image/AffineTransformOp.java:
Removed unnecessary field interpolationType.
Formatted some of the lines to be consistent with
the GNU style.
(AffineTransformOp): Create new RenderingHints
containing specified interpolation type.
(createCompatibleDestImage): Implemented.
(createCompatibleDestRaster): Implemented.
(filter): Implemented.
(getBounds2D(BufferedImage)): Implemented.
(getBounds2D(Raster)): Implemented.
(getInterpolationType): Get interpolation value from
rendering hints.
2004-03-04 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setFont): Check if child peers are null.
2004-03-04 Graydon Hoare <graydon@redhat.com>
* testsuite/lib/libjava.exp (libjava_find_lib): Don't include
.libs in -L option.
(libjava_arguments): Add new libraries to argument list.
2004-03-04 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (toolexeclib_LTLIBRARIES): Added lib-java-awt.la,
lib-javax-swing.la, lib-java-applet.la, lib-java-beans.la.
(misc_java_source_files): New macro.
(swing_java_source_files): Likewise.
(awt_java_source_files): Pruned.
(applet_java_source_files): New macro.
(beans_java_source_files): Likewise.
(lib_java_applet_la_SOURCES): Likewise.
(lib_java_awt_la_SOURCES): Likewise.
(lib_javax_swing_la_SOURCES): Likewise.
(lib_java_beans_la_SOURCES): Likewise.
(all_java_object_files): Likewise.
(%.lo: %.java): Use all_java_object_files.
(all_java_source_files): Added new _SOURCES.
(ordinary_java_source_files): Removed awt_java_source_files.
2004-03-02 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added java/awt/image/AffineTransformOp.java
* Makefile.in: Re-generated.
* java/awt/image/AffineTransformOp.java: New Class.
2004-03-01 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(setPaint): Interpret correctly TexturePaint's
anchor rectangle.
(drawImage): Fixed scale factors of the affine
transform.
2004-02-27 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java
(GdkGraphics(Component)): Inherit font from component.
(drawString): Use font style.
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
(gtkSetFont): New native method declaration.
(setFont): New method.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(gtkSetFont): New native method declaration.
(setFont): Call new native method gtkSetFont.
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setFont): For all child components who do not their fonts set,
set their peers' fonts with this container's font.
* gnu/java/awt/peer/gtk/GtkLabelPeer.java:
Move all native method declarations to the top for readability.
(gtkSetFont): New native method declaration.
(setFont): New method.
* java/awt/Component.java
(setFont): Invalidate after setting the font.
* java/awt/Container.java
(invalidateTree): New method.
(setFont): Invalidate the container tree after setting the font.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Use font style.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkSetFont): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
(Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkSetFont): New method.
2004-02-27 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(updateBufferedImage): New helper function.
Updates BufferedImage in memory if it was changed.
(draw): changed to update BufferedImage in memory after
this drawing operation
(fill): Ditto.
(draw3DRect): Ditto.
(fill3DRect): Ditto.
(clearRect): Ditto.
(drawRaster): Ditto.
(drawImage) : Ditto. Update only in case of GtkOffScreenImage with
no affine transformation.
(drawGlyphVector): Ditto.
2004-02-26 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(isBufferedImageGraphics): New Helper function.
Returns true if this graphics2d can be used to draw
into buffered image and false otherwise.
(updateImagePixels): New Helper function.
Updates pixels in the BufferedImage.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(getImagePixels): New function. Returns pixels
of the buffered image associated with
this Graphics2D.
2004-02-26 David Jee <djee@redhat.com>
* java/awt/BorderLayout.java
(layoutContainer): Fix width and height calculations to ensure
that they're non-negative.
* java/awt/Component.java
(setBackground): If c is null, inherit from closest ancestor whose
background color is set.
2004-02-26�� Kim Ho�� <kho@redhat.com>
* Makefile.am: Add new files.
* Makefile.in: Re-generate.
* javax/swing/JProgressBar.java:
(JProgressBar(int, int int)): Throw
IllegalArgumentException if orientation is
invalid.
(JProgressBar(BoundedRangeModel)): Create
ChangeListener and register it. UpdateUI.
(getChangeListeners): Implement.
(setModel): Reset ChangeListener.
* javax/swing/JScrollBar.java: Implement.
* javax/swing/JSeparator.java: Implement.
* javax/swing/JSlider.java:
(JSlider(int, int, int, int)): Throw
IllegalArgumentException if orientation
is invalid.
(getChangeListeners): Fix method name.
* javax/swing/SwingUtilities.java:
(layoutCompoundLabel): If there is no text,
set the text rectangle dimensions to 0.
* javax/swing/plaf/basic/BasicButtonUI.java:
(paint): If there is no text, don't paint it.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Implement.
* javax/swing/plaf/basic/BasicSeparatorUI.java:
Implement.
* javax/swing/plaf/basic/BasicSliderUI.java:
(propertyChange): If the model changes, change
the listeners accordingly.
2004-02-25 Graydon Hoare <graydon@redhat.com>
* javax/swing/AbstractButton.java: Add "final" qualifiers.
* javax/swing/JList.java: Reimplement.
* javax/swing/DefaultListSelectionModel.java: Reimplement.
* javax/swing/plaf/basic/BasicListUI.java: Reimplement.
* javax/swing/plaf/basic/BasicLookAndFeel.java: Add "purple" values.
* javax/swing/ListModel.java: Javadoc.
* javax/swing/ListSelectionModel.java: Add missing methods.
* javax/swing/AbstractListModel.java: Javadoc and corrections.
* javax/swing/DefaultListModel.java: Javadoc and corrections.
* javax/swing/ListModel.java: Javadoc and corrections.
* javax/swing/DefaultListCellRenderer.java: Minor tidying.
2004-02-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFontPeer.java
(GtkFontPeer): Change default size to 12.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getFontPeer): Change default size to 12.
(getClasspathFontPeer): Likewise. Set default name to "Default".
* java/awt/Font.java
(Font(Map)): Call Font(String,Map).
(Font(String,Map)): If attrs is null, initialize it as an empty
HashMap, which will ensure that the Font will get default attributes.
2004-02-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFontPeer.java
(GtkFontPeer(String,int)): Call the new constructor with size 1.
(GtkFontPeer(String,int,int)): New constructor with size attribute.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getFontPeer(String,int)): Call the new overload method with size 1.
(getFontPeer(String,int,int)): New method. Overloaded with size
attribute.
(getClasspathFontPeer): Set the size of the font.
2004-02-24 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(bimage): New field.
(GdkGraphics2D): New Constructor. Constructs Graphics
object that can be used to draw into the Buffered Image.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
(GdkGraphicsEnvironment): Fixed to include public
keyword.
(createGraphics): Implemented.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getLocalGraphicsEnvironment): Implemented.
* java/awt/GraphicsEnvironment.java:
(getLocalGraphicsEnvironment): Implemented.
* java/awt/image/BufferedImage.java:
(createGraphics): Implemented.
2004-02-24 David Jee <djee@redhat.com>
* java/awt/Component.java
(eventTypeEnabled): Add MOUSE_MOVED and MOUSE_DRAGGED event types.
* java/awt/Container.java
(addNotifyContainerChildren): Fix event enabling.
2004-02-23 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
* Makefile.in: Re-generated.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
New Class.
2004-02-19 Kim Ho <kho@redhat.com>
* Makefile.am: Add BasicProgressBarUI
* Makefile.in: Regenerate.
* javax/swing/JProgressBar.java:
Re-implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java
Add constants for JProgressBar.
* javax/swing/plaf/basic/BasicProgressBarUI.java
Implement.
* javax/swing/plaf/basic/BasicSliderUI.java
Change comments.
(calculateGeometry): New method
(paint): Remove unnecessary size calculations.
2004-02-18 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(drawRaster): Fixed small error that caused
imageToUser transformation to be set incorrectly.
(toString): Implemented.
2004-02-18 David Jee <djee@redhat.com>
* java/awt/CardLayout.java
(addLayoutComponent): Show the first component added as the default.
(removeLayoutComponent): After removing, show the next component.
(gotoComponent): If there is only one component, show it and return.
2004-02-18 Kim Ho <kho@redhat.com>
* javax/swing/JSlider.java: Re-order
modifiers.
* javax/swing/JLabel.java: Re-order
modifiers.
* javax/swing/JComponent.java:
(addPropertyChangeListener):
Implement.
(removePropertyChangeListener):
ditto.
(firePropertyChangeEvent):
ditto.
2004-02-17 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Dispatch ComponentEvent via system event queue.
(hide): Likewise.
(move): Likewise.
(resize): Likewise.
(reshape): Likewise.
* java/awt/Window.java
(setBoundsCallback): Likewise.
2004-02-17 David Jee <djee@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds):
Use gtk_widget_set_size_request() instead of the deprecated
gtk_widget_set_usize().
2004-02-17 Kim Ho <kho@redhat.com>
* javax/swing/JSlider.java: Fix comments and
make property strings constants.
(createStandardLabels): Use the labels
preferred size as bounds.
* javax/swing/plaf/basic/BasicSliderUI.java
Fix comments.
(ScrollHandler::actionPerformed): Don't
calculate the timer stop value. Let the
MouseListeners find the stop location.
(getPreferredHorizontalSize): Re-implement.
(getPreferredVerticalSize): ditto.
(getMinimumHorizontalSize): ditto.
(getMinimumVerticalSize): ditto.
(getPreferredSize): ditto.
(getMinimumSize): ditto.
(getMaximumSize): ditto.
(paintTicks): Use doubles to find the
tick location.
(paintHorizontalLabel):�� Use preferredSize
as initial width and height.
(paintVerticalLabel): ditto.
2004-02-17 Kim Ho <kho@redhat.com>
* javax/swing/JLabel.java: Changed
property strings to constants.
(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY):
New property.
(setText): Change mnemonic index if
text is too short.
(setDisplayedMnemonicIndex): Fire property
change event.
(getDisplayedMnemonicIndex): Remove check
against short text.
2004-02-17 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
(drawImage(img,xform,obs)): Invert xform before
passing the xform to cairo.
(drawImage(img,x,y,bgcolor,obs)): Implemented.
(drawImage (img,x,y,w,h,bgcolor,obs)): Partly
implemented.
(drawImage (img,x,y,w,h,obs)): Implemented.
(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
bgcolor,obs)): Partly implemented.
(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,obs)):
Implemented.
* java/awt/image/BufferedImage.java:
(copyData): if dest is null, create raster with same
dimensions as the current image.
2004-02-16 Graydon Hoare <graydon@redhat.com>
* javax/swing/plaf/basic/BasicLabelUI.java
(getPreferredSize): Use layoutCL.
* javax/swing/plaf/basic/BasicGraphicsUtils.java
(getPreferredButtonSize): Start with empty view rect, layout using
component's preferred alignment.
* javax/swing/plaf/basic/BasicLookAndFeel.java: Add some Label and
List defaults.
2004-02-16 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Dispatch COMPONENT_SHOWN ComponentEvent.
(hide): Dispatch COMPONENT_HIDDEN ComponentEvent.
(move): Erase old bounds and repaint new bounds. Dispatch
COMPONENT_MOVED ComponentEvent.
(resize): Erase old bounds and repaint new bounds. Dispatch
COMPONENT_RESIZED ComponentEvent.
(reshape): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
ComponentEvents.
* java/awt/Window.java
(setBoundsCallback): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
ComponentEvents.
2004-02-16 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
(setRenderingHint): Added implementation of
Interpolation rendering hints.
(setRenderingHints): Ditto.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
(drawPixels): fixed to allow user to choose type
of filtering that should be used when displaying images.
(cairoSurfaceSetFilter): New method. Sets filter type for
interpolation of pixel values.
2004-02-16 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(calcCellSizes): Rows or columns with zero sizes should still be
considered for extra space distribution.
2004-02-16 Kim Ho <kho@redhat.com>
* javax/swing/JLabel.java: Re-implement.
* javax/swing/plaf/basic/BasicLabelUI.java
Re-implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Added constant.
2004-02-16�� Kim Ho�� <kho@redhat.com>
* javax/swing/JSlider.java: Fix indentation and comments.
(setModel): Remove null check to conform with Sun's.
(setOrientation): Throw exception if not
HORIZONTAL or VERTICAL.
(getInverted): Use private variable instead of
ComponentOrientation.
(setInverted): ditto.
* javax/swing/plaf/basic/BasicSliderUI.java:
Fix indentation and comments.
(propertyChange): Remove check for inverted slider, handle
in main paint.
(getMinimumSize): Return preferred size.
(getMaximumSize): ditto.
(calculateFocusRect): Don't relocate rectangle.
(drawInverted): Return XOR of the slider's inversion and
the component's orientation.
(paint): Update leftToRightCache
2004-02-13 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(GetLayoutInfo): Fix weight and size distribution. Relocate repeated
code to helper methods.
(sortBySpan): New helper method.
(distributeSizeAndWeight): Likewise.
(calcCellWeights): Likewise.
(calcCellSizes): Add comments.
2004-02-13 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Only do something if component is invisible at the moment.
(hide): Only do something if component is visible at the moment.
(reshape): If lightweight, erase old bounds and repaint new bounds.
2004-02-13�� Kim Ho�� <kho@redhat.com>
* Makefile.am: Updated for new file.
* Makefile.in: Regenerated.
* javax/swing/JSlider.java: Reimplement.
* javax/swing/SwingUtilities.java
(layoutCompoundLabel): Use icon height
instead of width.
(paintComponent): Implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Add JSlider defaults.
* javax/swing/plaf/basic/BasicSliderUI.java:
Implement. New file.
From-SVN: r79607
Diffstat (limited to 'libjava/gnu')
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GdkGraphics.java | 11 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java | 337 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java | 87 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java | 9 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java | 10 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java | 4 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java | 13 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java | 12 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java | 15 | ||||
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkToolkit.java | 29 |
10 files changed, 476 insertions, 51 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java index 9012da2..d36ac2d 100644 --- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java +++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java @@ -91,7 +91,7 @@ public class GdkGraphics extends Graphics this.component = component; int rgb[] = initState (component); color = new Color (rgb[0], rgb[1], rgb[2]); - font = new Font ("Dialog", Font.PLAIN, 10); + font = component.awtComponent.getFont(); Dimension d = component.awtComponent.getSize (); clip = new Rectangle (0, 0, d.width, d.height); } @@ -212,10 +212,10 @@ public class GdkGraphics extends Graphics native public void drawRect(int x, int y, int width, int height); native public void fillRect (int x, int y, int width, int height); - native void drawString (String str, int x, int y, String fname, int size); + native void drawString (String str, int x, int y, String fname, int style, int size); public void drawString (String str, int x, int y) { - drawString (str, x, y, font.getName(), font.getSize()); + drawString (str, x, y, font.getName(), font.getStyle(), font.getSize()); } public void drawString (AttributedCharacterIterator ci, int x, int y) @@ -287,7 +287,10 @@ public class GdkGraphics extends Graphics public void setColor (Color c) { - color = c; + if (c == null) + color = new Color (0, 0, 0); + else + color = c; if (xorColor == null) /* paint mode */ setFGColor (color.getRed (), color.getGreen (), color.getBlue ()); diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java index e985696..8bae336 100644 --- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java +++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java @@ -84,6 +84,7 @@ public class GdkGraphics2D extends Graphics2D private GtkComponentPeer component; private Font font; private RenderingHints hints; + private BufferedImage bimage; private Stack stateStack; @@ -91,6 +92,8 @@ public class GdkGraphics2D extends Graphics2D native private void initState (int width, int height); native private void copyState (GdkGraphics2D g); native public void dispose (); + native private int[] getImagePixels(); + native private void cairoSurfaceSetFilter(int filter); public void finalize () { @@ -179,6 +182,28 @@ public class GdkGraphics2D extends Graphics2D stateStack = new Stack (); } + GdkGraphics2D (BufferedImage bimage) + { + + this.bimage = bimage; + initState (bimage.getWidth(), bimage.getHeight()); + + setColor(Color.black); + setBackground (Color.black); + setPaint (getColor()); + setFont (new Font("SansSerif", Font.PLAIN, 12)); + setTransform (new AffineTransform ()); + setStroke (new BasicStroke ()); + setRenderingHints (getDefaultHints()); + + stateStack = new Stack(); + + // draw current buffered image to the pixmap associated + // with it. + + drawImage (bimage, new AffineTransform (1,0,0,1,0,0), null); + } + //////////////////////////////////// ////// Native Drawing Methods ////// @@ -364,6 +389,58 @@ public class GdkGraphics2D extends Graphics2D } + private void updateBufferedImage() + { + int[] pixels = getImagePixels(); + updateImagePixels(pixels); + } + + + private boolean isBufferedImageGraphics () + { + + if (bimage != null) + return true; + else + return false; + } + + private void updateImagePixels (int[] pixels) + { + + // This function can only be used if + // this graphics object is used to draw into + // buffered image + + if (! isBufferedImageGraphics ()) + return; + + WritableRaster raster = bimage.getRaster(); + DataBuffer db = raster.getDataBuffer (); + + // update pixels in the bufferedImage + + if (raster.getSampleModel ().getDataType () == DataBuffer.TYPE_INT + && db instanceof DataBufferInt + && db.getNumBanks () == 1) + { + + // single bank, ARGB-ints buffer in sRGB space + DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer (); + + for (int i=0; i < pixels.length; i++) + dbi.setElem(i, pixels[i]); + + } + else + { + bimage.getRaster().setPixels (0, 0, raster.getWidth (), + raster.getHeight (), pixels); + } + } + + + ////////////////////////////////////////////////// ////// Implementation of Graphics2D Methods ////// ////////////////////////////////////////////////// @@ -401,6 +478,10 @@ public class GdkGraphics2D extends Graphics2D translate (-0.5,-0.5); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + } public void fill (Shape s) @@ -416,6 +497,10 @@ public class GdkGraphics2D extends Graphics2D walkPath (s.getPathIterator (null)); cairoFill (); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + } public void clip (Shape s) @@ -475,11 +560,21 @@ public class GdkGraphics2D extends Graphics2D { TexturePaint tp = (TexturePaint) paint; BufferedImage img = tp.getImage (); - int pixels[] = img.getRGB(0, 0, img.getWidth (), - img.getHeight (), null, - 0, img.getWidth ()); - setTexturePixels (pixels, img.getWidth (), - img.getHeight (), img.getWidth ()); + + // map the image to the anchor rectangle + + int width = (int) tp.getAnchorRect ().getWidth (); + int height = (int) tp.getAnchorRect ().getHeight (); + + double scaleX = width / (double) img.getWidth (); + double scaleY = width / (double) img.getHeight (); + + AffineTransform at = new AffineTransform (scaleX, 0, 0, scaleY, 0, 0); + AffineTransformOp op = new AffineTransformOp (at, getRenderingHints()); + BufferedImage texture = op.filter(img, null); + int pixels[] = texture.getRGB (0, 0, width, height, null, 0, width); + setTexturePixels (pixels, width, height, width); + } else if (paint instanceof GradientPaint) { @@ -518,6 +613,26 @@ public class GdkGraphics2D extends Graphics2D else transform.concatenate (tx); setTransform (transform); + if (clip != null) + { + // FIXME: this should actuall try to transform the shape + // rather than degrade to bounds. + Rectangle2D r = clip.getBounds2D(); + double[] coords = new double[] { r.getX(), r.getY(), + r.getX() + r.getWidth(), + r.getY() + r.getHeight() }; + try + { + tx.createInverse().transform(coords, 0, coords, 0, 2); + r.setRect(coords[0], coords[1], + coords[2] - coords[0], + coords[3] - coords[1]); + clip = r; + } + catch (java.awt.geom.NoninvertibleTransformException e) + { + } + } } public void rotate(double theta) @@ -645,19 +760,29 @@ public class GdkGraphics2D extends Graphics2D public void setClip (int x, int y, int width, int height) { - cairoNewPath (); - cairoRectangle (x, y, width, height); - cairoClosePath (); - cairoClip (); - clip = new Rectangle2D.Double ((double)x, (double)y, - (double)width, (double)height); + clip = new Rectangle2D.Double ((double)x, (double)y, + (double)width, (double)height); + setClip(clip); } - + public void setClip (Shape s) { - clip (s); + if (s != null) + { + cairoNewPath (); + if (s instanceof Rectangle2D) + { + Rectangle2D r = (Rectangle2D)s; + cairoRectangle (r.getX (), r.getY (), + r.getWidth (), r.getHeight ()); + } + else + walkPath (s.getPathIterator (null)); + cairoClosePath (); + cairoClip (); + } } - + public void draw3DRect(int x, int y, int width, int height, boolean raised) { @@ -708,6 +833,10 @@ public class GdkGraphics2D extends Graphics2D cairoStroke (); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + } public void fill3DRect(int x, int y, int width, @@ -734,6 +863,10 @@ public class GdkGraphics2D extends Graphics2D cairoClosePath (); cairoFill (); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + } @@ -759,6 +892,10 @@ public class GdkGraphics2D extends Graphics2D cairoClosePath (); cairoFill (); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + } public void setBackground(Color c) @@ -849,7 +986,7 @@ public class GdkGraphics2D extends Graphics2D { i2u[0] = 1; i2u[1] = 0; i2u[2] = 0; i2u[3] = 1; - i2u[2] = 0; i2u[3] = 0; + i2u[4] = 0; i2u[5] = 0; } int pixels[] = null; @@ -879,6 +1016,10 @@ public class GdkGraphics2D extends Graphics2D translate (x, y); drawPixels (pixels, r.getWidth (), r.getHeight (), r.getWidth (), i2u); stateRestore (); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + return true; } @@ -908,22 +1049,49 @@ public class GdkGraphics2D extends Graphics2D // we are being asked to flush a double buffer from Gdk GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics (); gdkDrawDrawable (g2, (int)xform.getTranslateX(), (int)xform.getTranslateY()); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + return true; } else { - if (img instanceof BufferedImage) - { - // draw an image which has actually been loaded into memory fully - BufferedImage b = (BufferedImage) img; - return drawRaster (b.getColorModel (), b.getData (), xform); - } - else - { - // begin progressive loading in a separate thread - new PainterThread (this, img, xform); - return false; + + // In this case, xform is an AffineTransform that transforms bounding + // box of the specified image from image space to user space. However + // when we pass this transform to cairo, cairo will use this transform + // to map "user coordinates" to "pixel" coordinates, which is the + // other way around. Therefore to get the "user -> pixel" transform + // that cairo wants from "image -> user" transform that we currently + // have, we will need to invert the transformation matrix. + + AffineTransform invertedXform = new AffineTransform(); + + try + { + invertedXform = xform.createInverse(); + if (img instanceof BufferedImage) + { + // draw an image which has actually been loaded + // into memory fully + BufferedImage b = (BufferedImage) img; + return drawRaster (b.getColorModel (), + b.getData (), + invertedXform); + } + else + { + // begin progressive loading in a separate thread + new PainterThread (this, img, invertedXform); + return false; + } } + catch (NoninvertibleTransformException e) + { + throw new ImagingOpException("Unable to invert transform " + + xform.toString()); + } } } @@ -1061,6 +1229,28 @@ public class GdkGraphics2D extends Graphics2D Object hintValue) { hints.put (hintKey, hintValue); + + if (hintKey.equals(RenderingHints.KEY_INTERPOLATION) + || hintKey.equals(RenderingHints.KEY_ALPHA_INTERPOLATION)) + { + + if (hintValue.equals(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)) + cairoSurfaceSetFilter(0); + + else if (hintValue.equals(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) + cairoSurfaceSetFilter(1); + + else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)) + cairoSurfaceSetFilter(2); + + else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)) + cairoSurfaceSetFilter(3); + + else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT)) + cairoSurfaceSetFilter(4); + + } + } public Object getRenderingHint(RenderingHints.Key hintKey) @@ -1072,6 +1262,27 @@ public class GdkGraphics2D extends Graphics2D { this.hints = new RenderingHints (getDefaultHints ()); this.hints.add (new RenderingHints (hints)); + + if (hints.containsKey(RenderingHints.KEY_INTERPOLATION)) + { + if(hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)) + cairoSurfaceSetFilter(0); + + else if(hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) + cairoSurfaceSetFilter(1); + } + + if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION)) + { + if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)) + cairoSurfaceSetFilter(2); + + else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)) + cairoSurfaceSetFilter(3); + + else if(hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT)) + cairoSurfaceSetFilter(4); + } } public void addRenderingHints(Map hints) @@ -1104,6 +1315,10 @@ public class GdkGraphics2D extends Graphics2D int codes[] = g.getGlyphCodes (0, nglyphs, (int []) null); float posns[] = g.getGlyphPositions (0, nglyphs, (float []) null); cairoShowGlyphs (codes, posns); + + if (isBufferedImageGraphics ()) + updateBufferedImage(); + stateRestore (); } @@ -1124,33 +1339,89 @@ public class GdkGraphics2D extends Graphics2D public boolean drawImage (Image img, int x, int y, Color bgcolor, ImageObserver observer) { - throw new java.lang.UnsupportedOperationException (); + return drawImage (img, x, y, img.getWidth (observer), + img.getHeight (observer), bgcolor, observer); } public boolean drawImage (Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { - throw new java.lang.UnsupportedOperationException (); + + // FIXME: change all the transparent pixels in the image to + // bgcolor. + + return drawImage (img, x, y, width, height, observer); } public boolean drawImage (Image img, int x, int y, int width, int height, ImageObserver observer) { - throw new java.lang.UnsupportedOperationException (); + + double scaleX = width / (double) img.getWidth (observer); + double scaleY = height / (double) img.getHeight (observer); + + return drawImage (img, + new AffineTransform(scaleX, 0f, 0f, scaleY, x, y), + observer); + } public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { - throw new java.lang.UnsupportedOperationException (); + + // FIXME: change all transparent pixels in the image to + // bgcolor + + return drawImage (img, dx1, dy1, dx2, dy2, + sx1, sy1, sx2, sy2, observer); } public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { - throw new java.lang.UnsupportedOperationException (); + + Image subImage; + + int sourceWidth = sx2 - sx1; + int sourceHeight = sy2 - sy1; + + int destWidth = dx2 - dx1; + int destHeight = dy2 - dy1; + + double scaleX = destWidth / (double) sourceWidth; + double scaleY = destHeight / (double) sourceHeight; + + // Get the subimage of the source enclosed in the + // rectangle specified by sx1, sy1, sx2, sy2 + + if (img instanceof BufferedImage) + { + + BufferedImage b = (BufferedImage) img; + subImage = b.getSubimage(sx1,sy1,sx2,sy2); + } + else + { + + // FIXME: This code currently doesn't work. Null Pointer + // exception is thrown in this case. This happens + // because img.getSource() always returns null, since source gets + // never initialized when it is created with the help of + // createImage(int width, int height). + + CropImageFilter filter = new CropImageFilter(sx1,sx2,sx2,sy2); + FilteredImageSource src = new FilteredImageSource(img.getSource(), + filter); + + subImage = Toolkit.getDefaultToolkit().createImage(src); + } + + return drawImage(subImage, new AffineTransform(scaleX, 0, 0, + scaleY, dx1, dy1), + observer); } public void drawOval(int x, int y, int width, int height) @@ -1251,7 +1522,9 @@ public class GdkGraphics2D extends Graphics2D public String toString() { - throw new java.lang.UnsupportedOperationException (); + return getClass ().getName () + + "[font=" + font.toString () + + ",color=" + fg.toString () + "]"; } } diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java new file mode 100644 index 0000000..dbcd2d1 --- /dev/null +++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java @@ -0,0 +1,87 @@ +/* GdkGraphicsEnvironment.java -- information about the graphics environment + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.peer.gtk; + +import java.awt.*; +import java.awt.GraphicsEnvironment; +import java.awt.image.BufferedImage; +import java.util.Locale; + + +public class GdkGraphicsEnvironment extends GraphicsEnvironment +{ + + public GdkGraphicsEnvironment () + { + super(); + } + + public GraphicsDevice[] getScreenDevices () + { + throw new java.lang.UnsupportedOperationException (); + } + + public GraphicsDevice getDefaultScreenDevice () + { + throw new java.lang.UnsupportedOperationException (); + } + + public Graphics2D createGraphics (BufferedImage image) + { + return new GdkGraphics2D (image); + } + + public Font[] getAllFonts () + { + throw new java.lang.UnsupportedOperationException (); + } + + public String[] getAvailableFontFamilyNames () + { + throw new java.lang.UnsupportedOperationException (); + } + + public String[] getAvailableFontFamilyNames (Locale l) + { + throw new java.lang.UnsupportedOperationException (); + } + + +} // class GdkGraphicsEnvironment + diff --git a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java index cf7260c..86c7c37 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java @@ -42,6 +42,7 @@ import java.awt.AWTEvent; import java.awt.Button; import java.awt.Component; import java.awt.Font; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.KeyEvent; import java.awt.peer.ButtonPeer; @@ -69,11 +70,15 @@ public class GtkButtonPeer extends GtkComponentPeer public void handleEvent (AWTEvent e) { - if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ()) + if (e.getID () == MouseEvent.MOUSE_RELEASED && isEnabled ()) { MouseEvent me = (MouseEvent) e; + Point p = me.getPoint(); + p.translate(((Component) me.getSource()).getX(), + ((Component) me.getSource()).getY()); if (!me.isConsumed () - && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0) + && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0 + && awtComponent.getBounds().contains(p)) postActionEvent (((Button)awtComponent).getActionCommand (), me.getModifiers ()); } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java index fba8c8f..2cff9cc 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java @@ -41,6 +41,7 @@ package gnu.java.awt.peer.gtk; import java.awt.Checkbox; import java.awt.CheckboxGroup; import java.awt.Component; +import java.awt.Font; import java.awt.peer.CheckboxPeer; public class GtkCheckboxPeer extends GtkComponentPeer @@ -55,6 +56,8 @@ public class GtkCheckboxPeer extends GtkComponentPeer boolean state); public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group); public native void connectSignals (); + public native void gtkSetFont (String name, int style, int size); + public native void gtkSetLabel (String label); public GtkCheckboxPeer (Checkbox c) { @@ -81,7 +84,12 @@ public class GtkCheckboxPeer extends GtkComponentPeer public void setLabel (String label) { - set ("label", label); + gtkSetLabel (label); + } + + public void setFont (Font f) + { + gtkSetFont(f.getName(), f.getStyle(), f.getSize()); } public void setCheckboxGroup (CheckboxGroup group) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java index 4b29bcc..1a9d963 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -91,6 +91,7 @@ public class GtkComponentPeer extends GtkGenericPeer native void gtkWidgetSetCursor (int type); native void gtkWidgetSetBackground (int red, int green, int blue); native void gtkWidgetSetForeground (int red, int green, int blue); + native void gtkSetFont (String name, int style, int size); native void gtkWidgetQueueDrawArea(int x, int y, int width, int height); native void addExposeFilter(); native void removeExposeFilter(); @@ -234,7 +235,7 @@ public class GtkComponentPeer extends GtkGenericPeer // Some peers like GtkFileDialogPeer are repainted by Gtk itself if (g == null) break; - + g.setClip (((PaintEvent)event).getUpdateRect()); if (id == PaintEvent.PAINT) @@ -403,6 +404,7 @@ public class GtkComponentPeer extends GtkGenericPeer // FIXME: This should really affect the widget tree below me. // Currently this is only handled if the call is made directly on // a text widget, which implements setFont() itself. + gtkSetFont(f.getName(), f.getStyle(), f.getSize()); } public void setForeground (Color c) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java index 361dea7..32ac02f 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java @@ -42,6 +42,7 @@ import java.awt.AWTEvent; import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Font; import java.awt.Graphics; import java.awt.Insets; import java.awt.event.PaintEvent; @@ -92,6 +93,18 @@ public class GtkContainerPeer extends GtkComponentPeer awtComponent.validate (); } + public void setFont(Font f) + { + super.setFont(f); + Component[] components = ((Container) awtComponent).getComponents(); + for (int i = 0; i < components.length; i++) + { + GtkComponentPeer peer = (GtkComponentPeer) components[i].getPeer(); + if (peer != null && ! peer.awtComponent.isFontSet()) + peer.setFont(f); + } + } + public Graphics getGraphics () { if (GtkToolkit.useGraphics2D ()) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java index 8c1ec8f..1ab7bc1 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java @@ -62,11 +62,17 @@ public class GtkFontPeer extends ClasspathFontPeer } } - final private String Xname; // uses %d for font size. + final private String Xname; public GtkFontPeer (String name, int style) { - super(name, style, 12 /* kludge */); + // All fonts get a default size of 12 if size is not specified. + this(name, style, 12); + } + + public GtkFontPeer (String name, int style, int size) + { + super(name, style, size); if (bundle != null) Xname = bundle.getString (name.toLowerCase () + "." + style); @@ -90,7 +96,7 @@ public class GtkFontPeer extends ClasspathFontPeer else spacing = "c"; - Xname = "-*-*-" + weight + "-" + slant + "-normal-*-%d-*-*-*-" + spacing + "-*-*-*"; + Xname = "-*-*-" + weight + "-" + slant + "-normal-*-*-" + size + "-*-*-" + spacing + "-*-*-*"; } } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java index b0a9ff7..cf39372 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java @@ -39,28 +39,35 @@ exception statement from your version. */ package gnu.java.awt.peer.gtk; import java.awt.Component; +import java.awt.Font; import java.awt.Label; import java.awt.peer.LabelPeer; public class GtkLabelPeer extends GtkComponentPeer implements LabelPeer { + native void create (String text, float alignment); + native void gtkSetFont(String name, int style, int size); + native void nativeSetAlignment (float alignment); + + native public void setText (String text); + void create () { Label label = (Label) awtComponent; create (label.getText (), getGtkAlignment (label.getAlignment ())); } - native void create (String text, float alignment); - public GtkLabelPeer (Label l) { super (l); } - native public void setText (String text); + public void setFont (Font f) + { + gtkSetFont(f.getName(), f.getStyle(), f.getSize()); + } - native void nativeSetAlignment (float alignment); public void setAlignment (int alignment) { nativeSetAlignment (getGtkAlignment (alignment)); diff --git a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java index 844fa68..1d961f2 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -47,6 +47,7 @@ import java.awt.im.InputMethodHighlight; import java.awt.image.ColorModel; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; +import java.awt.GraphicsEnvironment; import java.awt.peer.*; import java.net.URL; import java.util.Hashtable; @@ -366,10 +367,18 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit * @deprecated part of the older "logical font" system in earlier AWT * implementations. Our newer Font class uses getClasspathFontPeer. */ - protected FontPeer getFontPeer (String name, int style) + protected FontPeer getFontPeer (String name, int style) { + // All fonts get a default size of 12 if size is not specified. + return getFontPeer(name, style, 12); + } + + /** + * Private method that allows size to be set at initialization time. + */ + private FontPeer getFontPeer (String name, int style, int size) { try { - GtkFontPeer fp = new GtkFontPeer (name, style); + GtkFontPeer fp = new GtkFontPeer (name, style, size); return fp; } catch (MissingResourceException ex) { return null; @@ -388,7 +397,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit return new GdkClasspathFontPeer (name, attrs); else { + // Default values + int size = 12; int style = Font.PLAIN; + if (name == null) + name = "Default"; if (attrs.containsKey (TextAttribute.WEIGHT)) { @@ -404,7 +417,13 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit style += Font.ITALIC; } - return (ClasspathFontPeer) this.getFontPeer (name, style); + if (attrs.containsKey (TextAttribute.SIZE)) + { + Float fsize = (Float) attrs.get (TextAttribute.SIZE); + size = fsize.intValue(); + } + + return (ClasspathFontPeer) this.getFontPeer (name, style, size); } } @@ -431,7 +450,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit public GraphicsEnvironment getLocalGraphicsEnvironment() { - throw new java.lang.UnsupportedOperationException (); + GraphicsEnvironment ge; + ge = new GdkGraphicsEnvironment (); + return ge; } public Font createFont(int format, java.io.InputStream stream) |