gnu.java.awt.peer.gtk

Class GtkComponentPeer

Implemented Interfaces:
ComponentPeer
Known Direct Subclasses:
GtkButtonPeer, GtkCanvasPeer, GtkCheckboxPeer, GtkChoicePeer, GtkContainerPeer, GtkLabelPeer, GtkListPeer, GtkScrollbarPeer, GtkTextAreaPeer, GtkTextFieldPeer

public class GtkComponentPeer
extends GtkGenericPeer
implements ComponentPeer

Field Summary

Fields inherited from class gnu.java.awt.peer.gtk.GtkGenericPeer

awtWidget

Constructor Summary

GtkComponentPeer(Component awtComponent)

Method Summary

boolean
canDetermineObscurity()
Returns true if this component peer can determine if the component has been obscured, false otherwise.
int
checkImage(Image image, int width, int height, ImageObserver observer)
Returns the construction status of the specified image.
void
coalescePaintEvent(PaintEvent e)
Coalesces the specified paint event.
void
createBuffers(int numBuffers, BufferCapabilities caps)
Create a number of image buffers that implement a buffering strategy according to the given capabilities.
Image
createImage(int width, int height)
Creates an empty image with the specified width and height.
Image
createImage(ImageProducer producer)
Creates an image by starting the specified image producer.
VolatileImage
createVolatileImage(int width, int height)
A convenience method that creates a volatile image.
void
destroyBuffers()
Destroy the resources created by createBuffers.
void
disable()
Disables the component.
void
enable()
Enables the component.
void
flip(BufferCapabilities.FlipContents contents)
Perform a page flip, leaving the contents of the back buffer in the specified state.
Image
getBackBuffer()
Return the back buffer of this component.
Color
getBackground()
Rectangle
getBounds()
Get the bounds of this component peer.
ColorModel
getColorModel()
Returns the color model of the component.
FontMetrics
getFontMetrics(Font font)
Returns the font metrics for the specified font.
Color
getForeground()
Graphics
getGraphics()
Returns a Graphics object suitable for drawing on this component.
GraphicsConfiguration
getGraphicsConfiguration()
Get the graphics configuration of the component.
Point
getLocationOnScreen()
Returns the location of this component in screen coordinates.
Dimension
getMinimumSize()
Returns the minimum size for the component.
Dimension
getPreferredSize()
Returns the preferred size for the component.
Toolkit
getToolkit()
Returns the toolkit that created this peer.
void
handleEvent(AWTEvent event)
Handles the given event.
boolean
handlesWheelScrolling()
Returns true, if this component can handle wheel scrolling, false otherwise.
void
hide()
Makes the component invisible.
boolean
isFocusTraversable()
Returns true if the component can receive keyboard input focus.
boolean
isFocusable()
Returns true if the component can receive keyboard input focus.
protected boolean
isLightweightDescendant(Component c)
Returns true if the component is a direct (== no intermediate heavyweights) lightweight descendant of this peer's component.
boolean
isObscured()
Returns true if this component has been obscured, false otherwise.
boolean
isReparentSupported()
Check if this component supports being reparented.
void
layout()
Layout this component peer.
Dimension
minimumSize()
Returns the minimum size for the component.
void
paint(Graphics g)
protected void
paintComponent(PaintEvent event)
protected void
postExposeEvent(int x, int y, int width, int height)
protected void
postFocusEvent(int id, boolean temporary)
Referenced from native code.
protected void
postItemEvent(Object item, int stateChange)
protected void
postKeyEvent(int id, long when, int mods, int keyCode, char keyChar, int keyLocation)
protected void
postMouseEvent(int id, long when, int mods, int x, int y, int clickCount, boolean popupTrigger)
protected void
postMouseWheelEvent(int id, long when, int mods, int x, int y, int clickCount, boolean popupTrigger, int type, int amount, int rotation)
Callback for component_scroll_cb.
protected void
postTextEvent()
Dimension
preferredSize()
Returns the preferred size for the component.
boolean
prepareImage(Image image, int width, int height, ImageObserver observer)
Prepares an image for rendering on this component.
void
print(Graphics g)
void
repaint(long tm, int x, int y, int width, int height)
Repaints the specified rectangle of this component.
void
reparent(ContainerPeer parent)
Reparent this component under another container.
void
requestFocus()
Requests that this component receives the focus.
boolean
requestFocus(Component request, boolean temporary, boolean allowWindowFocus, long time)
Requests that this component receives the focus.
boolean
requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
Requests the focus on the component.
void
reshape(int x, int y, int width, int height)
Notifies the peer that the bounds of this component have changed.
void
setBackground(Color c)
Sets the background color of the component.
void
setBounds(int x, int y, int width, int height)
Notifies the peer that the bounds of this component have changed.
void
setBounds(int x, int y, int width, int height, int z)
Set the bounds of this component peer.
void
setCursor(Cursor cursor)
Sets the cursor of the component.
void
setEnabled(boolean b)
Sets the enabled/disabled state of this component.
void
setEventMask(long mask)
Part of an older API, no longer needed.
void
setFont(Font f)
Sets the font of the component.
void
setForeground(Color c)
Sets the foreground color of the component.
void
setVisible(boolean b)
Sets the visibility state of the component.
void
setVisibleNative(boolean b)
void
setVisibleNativeUnlocked(boolean b)
void
show()
Makes the component visible.
String
toString()
Convert this Object to a human-readable String.
protected void
updateComponent(PaintEvent event)
void
updateCursorImmediately()
Updates the cursor.

Methods inherited from class gnu.java.awt.peer.gtk.GtkGenericPeer

dispose, gtkWidgetModifyFont, gtkWidgetModifyFont, postActionEvent

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GtkComponentPeer

protected GtkComponentPeer(Component awtComponent)

Method Details

canDetermineObscurity

public boolean canDetermineObscurity()
Returns true if this component peer can determine if the component has been obscured, false otherwise.
Specified by:
canDetermineObscurity in interface ComponentPeer
Returns:
true if this component peer can determine if the component has been obscured, false otherwise

checkImage

public int checkImage(Image image,
                      int width,
                      int height,
                      ImageObserver observer)
Returns the construction status of the specified image. This is called by Component.checkImage(Image,int,int,ImageObserver).
Specified by:
checkImage in interface ComponentPeer
Parameters:
width - the width of the image
height - the height of the image
Returns:
a bitwise ORed set of ImageObserver flags

coalescePaintEvent

public void coalescePaintEvent(PaintEvent e)
Coalesces the specified paint event.
Specified by:
coalescePaintEvent in interface ComponentPeer
Parameters:
e - the paint event

createBuffers

public void createBuffers(int numBuffers,
                          BufferCapabilities caps)
            throws AWTException
Create a number of image buffers that implement a buffering strategy according to the given capabilities.
Specified by:
createBuffers in interface ComponentPeer
Parameters:
numBuffers - the number of buffers
caps - the buffering capabilities
Throws:
AWTException - if the specified buffering strategy is not implemented
Since:
1.2

createImage

public Image createImage(int width,
                         int height)
Creates an empty image with the specified width and height.
Specified by:
createImage in interface ComponentPeer
Parameters:
width - the width of the image to be created
height - the height of the image to be created
Returns:
the created image

createImage

public Image createImage(ImageProducer producer)
Creates an image by starting the specified image producer. This is called by Component.createImage(ImageProducer).
Specified by:
createImage in interface ComponentPeer
Parameters:
Returns:
the created image

createVolatileImage

public VolatileImage createVolatileImage(int width,
                                         int height)
A convenience method that creates a volatile image. The volatile image is created on the screen device on which this component is displayed, in the device's current graphics configuration.
Specified by:
createVolatileImage in interface ComponentPeer
Parameters:
width - width of the image
height - height of the image
Since:
1.2
See Also:
VolatileImage

destroyBuffers

public void destroyBuffers()
Destroy the resources created by createBuffers.
Specified by:
destroyBuffers in interface ComponentPeer
Since:
1.2

disable

public void disable()
Disables the component. This is called by Component.disable().
Specified by:
disable in interface ComponentPeer

enable

public void enable()
Enables the component. This is called by Component.enable().
Specified by:
enable in interface ComponentPeer

flip

public void flip(BufferCapabilities.FlipContents contents)
Perform a page flip, leaving the contents of the back buffer in the specified state.
Specified by:
flip in interface ComponentPeer
Parameters:
contents - the state in which to leave the back buffer
Since:
1.2

getBackBuffer

public Image getBackBuffer()
Return the back buffer of this component.
Specified by:
getBackBuffer in interface ComponentPeer
Returns:
the back buffer of this component.
Since:
1.2

getBackground

public Color getBackground()

getBounds

public Rectangle getBounds()
Get the bounds of this component peer.
Specified by:
getBounds in interface ComponentPeer
Returns:
component peer bounds
Since:
1.5

getColorModel

public ColorModel getColorModel()
Returns the color model of the component. This is currently not used.
Specified by:
getColorModel in interface ComponentPeer
Returns:
the color model of the component

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for the specified font. This is called by Component.getFontMetrics(Font).
Specified by:
getFontMetrics in interface ComponentPeer
Parameters:
Returns:
the font metrics for the specified font

getForeground

public Color getForeground()

getGraphics

public Graphics getGraphics()
Returns a Graphics object suitable for drawing on this component. This is called by Component.getGraphics().
Specified by:
getGraphics in interface ComponentPeer
Returns:
a graphics object suitable for drawing on this component

getGraphicsConfiguration

public GraphicsConfiguration getGraphicsConfiguration()
Get the graphics configuration of the component. The color model of the component can be derived from the configuration.
Specified by:
getGraphicsConfiguration in interface ComponentPeer
Returns:
the graphics configuration of the component

getLocationOnScreen

public Point getLocationOnScreen()
Returns the location of this component in screen coordinates. This is called by Component.getLocationOnScreen().
Specified by:
getLocationOnScreen in interface ComponentPeer
Returns:
the location of this component in screen coordinates

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size for the component. This is called by Component.getMinimumSize().
Specified by:
getMinimumSize in interface ComponentPeer
Returns:
the minimum size for the component

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size for the component. This is called by Component.getPreferredSize().
Specified by:
getPreferredSize in interface ComponentPeer
Returns:
the preferred size for the component

getToolkit

public Toolkit getToolkit()
Returns the toolkit that created this peer.
Specified by:
getToolkit in interface ComponentPeer
Returns:
the toolkit that created this peer

handleEvent

public void handleEvent(AWTEvent event)
Handles the given event. This is called from Component.dispatchEvent(AWTEvent) to give the peer a chance to react to events for the component.
Specified by:
handleEvent in interface ComponentPeer
Parameters:

handlesWheelScrolling

public boolean handlesWheelScrolling()
Returns true, if this component can handle wheel scrolling, false otherwise.
Specified by:
handlesWheelScrolling in interface ComponentPeer
Returns:
true, if this component can handle wheel scrolling, false otherwise

hide

public void hide()
Makes the component invisible. This is called from Component.hide().
Specified by:
hide in interface ComponentPeer

isFocusTraversable

public boolean isFocusTraversable()
Returns true if the component can receive keyboard input focus. This is called from Component.isFocusTraversable().
Specified by:
isFocusTraversable in interface ComponentPeer

isFocusable

public boolean isFocusable()
Returns true if the component can receive keyboard input focus. This is called from Component.isFocusable().
Specified by:
isFocusable in interface ComponentPeer

isLightweightDescendant

protected boolean isLightweightDescendant(Component c)
Returns true if the component is a direct (== no intermediate heavyweights) lightweight descendant of this peer's component.
Parameters:
c - the component to check
Returns:
true if the component is a direct (== no intermediate heavyweights) lightweight descendant of this peer's component

isObscured

public boolean isObscured()
Returns true if this component has been obscured, false otherwise. This will only work if ComponentPeer.canDetermineObscurity() also returns true.
Specified by:
isObscured in interface ComponentPeer
Returns:
true if this component has been obscured, false otherwise.

isReparentSupported

public boolean isReparentSupported()
Check if this component supports being reparented.
Specified by:
isReparentSupported in interface ComponentPeer
Returns:
true if this component can be reparented, false otherwise.
Since:
1.5

layout

public void layout()
Layout this component peer.
Specified by:
layout in interface ComponentPeer
Since:
1.5

minimumSize

public Dimension minimumSize()
Returns the minimum size for the component. This is called by Component.minimumSize().
Specified by:
minimumSize in interface ComponentPeer
Returns:
the minimum size for the component

paint

public void paint(Graphics g)
Specified by:
paint in interface ComponentPeer

paintComponent

protected void paintComponent(PaintEvent event)

postExposeEvent

protected void postExposeEvent(int x,
                               int y,
                               int width,
                               int height)

postFocusEvent

protected void postFocusEvent(int id,
                              boolean temporary)
Referenced from native code.
Parameters:
id -
temporary -

postItemEvent

protected void postItemEvent(Object item,
                             int stateChange)

postKeyEvent

protected void postKeyEvent(int id,
                            long when,
                            int mods,
                            int keyCode,
                            char keyChar,
                            int keyLocation)

postMouseEvent

protected void postMouseEvent(int id,
                              long when,
                              int mods,
                              int x,
                              int y,
                              int clickCount,
                              boolean popupTrigger)

postMouseWheelEvent

protected void postMouseWheelEvent(int id,
                                   long when,
                                   int mods,
                                   int x,
                                   int y,
                                   int clickCount,
                                   boolean popupTrigger,
                                   int type,
                                   int amount,
                                   int rotation)
Callback for component_scroll_cb.

postTextEvent

protected void postTextEvent()

preferredSize

public Dimension preferredSize()
Returns the preferred size for the component. This is called by Component.getPreferredSize().
Specified by:
preferredSize in interface ComponentPeer
Returns:
the preferred size for the component

prepareImage

public boolean prepareImage(Image image,
                            int width,
                            int height,
                            ImageObserver observer)
Prepares an image for rendering on this component. This is called by Component.prepareImage(Image,int,int,ImageObserver).
Specified by:
prepareImage in interface ComponentPeer
Parameters:
width - the desired width of the rendered image
height - the desired height of the rendered image
Returns:
true if the image has been fully prepared, false otherwise (in which case the image observer receives updates)

print

public void print(Graphics g)
Specified by:
print in interface ComponentPeer

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Repaints the specified rectangle of this component. This is called from Component.repaint(long,int,int,int,int).
Specified by:
repaint in interface ComponentPeer
Parameters:
tm - number of milliseconds to wait with repainting
x - the X coordinate of the upper left corner of the damaged rectangle
y - the Y coordinate of the upper left corner of the damaged rectangle
width - the width of the damaged rectangle
height - the height of the damaged rectangle

reparent

public void reparent(ContainerPeer parent)
Reparent this component under another container.
Specified by:
reparent in interface ComponentPeer
Parameters:
parent -
Since:
1.5

requestFocus

public void requestFocus()
Requests that this component receives the focus. This is called from Component.requestFocus().
Specified by:
requestFocus in interface ComponentPeer

requestFocus

public boolean requestFocus(Component request,
                            boolean temporary,
                            boolean allowWindowFocus,
                            long time)
Requests that this component receives the focus. This is called from Component.requestFocus(). This method is only called for heavyweight component's peers. Lightweight components ask their nearest heavyweight component to request focus. It's up to the heavyweight peer to decide if any of it's lightweight descendants are allowed to receive keyboard input focus or not. If the focus request is finally approved, then the peer must post a FOCUS_GAINED event for the requested component.
Specified by:
requestFocus in interface ComponentPeer
Parameters:
request - the component for which the focus is requested
temporary - indicates if the focus change is temporary (true) or permanent (false)
allowWindowFocus - indicates if it's allowed to change window focus
time - the timestamp

requestFocus

public boolean requestFocus(Component lightweightChild,
                            boolean temporary,
                            boolean focusedWindowChangeAllowed,
                            long time,
                            CausedFocusEvent.Cause cause)
Requests the focus on the component.
Specified by:
requestFocus in interface ComponentPeer

reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)
Notifies the peer that the bounds of this component have changed. This is called by Component.reshape(int,int,int,int).
Specified by:
reshape in interface ComponentPeer
Parameters:
x - the X coordinate of the upper left corner of the component
y - the Y coordinate of the upper left corner of the component
width - the width of the component
height - the height of the component

setBackground

public void setBackground(Color c)
Sets the background color of the component. This is called by Component.setBackground(Color).
Specified by:
setBackground in interface ComponentPeer
Parameters:

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Notifies the peer that the bounds of this component have changed. This is called by Component.setBounds(int,int,int,int).
Specified by:
setBounds in interface ComponentPeer
Parameters:
x - the X coordinate of the upper left corner of the component
y - the Y coordinate of the upper left corner of the component
width - the width of the component
height - the height of the component

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height,
                      int z)
Set the bounds of this component peer.
Specified by:
setBounds in interface ComponentPeer
Parameters:
x - the new x co-ordinate
y - the new y co-ordinate
width - the new width
height - the new height
z - the new stacking level
Since:
1.5

setCursor

public void setCursor(Cursor cursor)
Sets the cursor of the component. This is called by Component.setCursor(Cursor).
Specified by:
setCursor in interface ComponentPeer

setEnabled

public void setEnabled(boolean b)
Sets the enabled/disabled state of this component. This is called by Component.setEnabled(boolean).
Specified by:
setEnabled in interface ComponentPeer
Parameters:

setEventMask

public void setEventMask(long mask)
Part of an older API, no longer needed.
Specified by:
setEventMask in interface ComponentPeer

setFont

public void setFont(Font f)
Sets the font of the component. This is called by Component.setFont(Font).
Specified by:
setFont in interface ComponentPeer
Parameters:

setForeground

public void setForeground(Color c)
Sets the foreground color of the component. This is called by Component.setForeground(Color).
Specified by:
setForeground in interface ComponentPeer
Parameters:

setVisible

public void setVisible(boolean b)
Sets the visibility state of the component. This is called by Component.setVisible(boolean).
Specified by:
setVisible in interface ComponentPeer
Parameters:

setVisibleNative

public void setVisibleNative(boolean b)

setVisibleNativeUnlocked

public void setVisibleNativeUnlocked(boolean b)

show

public void show()
Makes the component visible. This is called by Component.show().
Specified by:
show in interface ComponentPeer

toString

public String toString()
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in interface Object
Returns:
the String representing this Object, which may be null

updateComponent

protected void updateComponent(PaintEvent event)

updateCursorImmediately

public void updateCursorImmediately()
Updates the cursor.
Specified by:
updateCursorImmediately in interface ComponentPeer

GtkComponentPeer.java -- Implements ComponentPeer with GTK Copyright (C) 1998, 1999, 2002, 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.