|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gnu.glib.Struct
org.gnu.glib.GObject
org.gnu.gtk.GtkObject
org.gnu.gtk.Widget
public class Widget
GtkWidget is the base class of all widgets.
Constructor Summary | |
---|---|
Widget(org.gnu.glib.Handle handle)
Create a new Widget with a handle to a native resource returned from a call to the native libraries. |
Method Summary | |
---|---|
boolean |
activate()
For widgets that can be activated (buttons, menu items, etc.) this method activiates them. |
void |
addAccelerator(AccelGroup group,
int accelKey,
ModifierType accelMods,
AccelFlags accelFlags)
|
void |
addEvents(EventMask events)
Adds the events in the bitfield events to the event mask for widget. |
void |
addListener(ConfigureListener listener)
Register an object to receive configure event notification. |
void |
addListener(DragDestinationListener listener)
Deprecated. Use addListener(DragTargetListener) instead. |
void |
addListener(DragOriginListener listener)
|
void |
addListener(DragSourceListener listener)
Deprecated. Use addListener(DragOriginListener) instead. |
void |
addListener(DragTargetListener listener)
|
void |
addListener(ExposeListener listener)
Register an object to receive expose event notification. |
void |
addListener(FocusListener listener)
Register an object to receive focus event notification. |
void |
addListener(KeyListener listener)
Register an object to receive key event notification. |
void |
addListener(LifeCycleListener listener)
Register an object to receive life cycle event notification. |
void |
addListener(MouseListener listener)
Register an object to receive mouse event notification. |
void |
addListener(MouseMotionListener listener)
Register an object to receive mouse motion event notification. |
boolean |
canActivateAccel(int signalId)
|
Context |
createContext()
Creates a new Context with the appropriate Colormap, FontDescription, and base direction for drawing text for this widget. |
Layout |
createLayout(java.lang.String text)
Creates a new Layout with the appropriate Colormap, FontDescription and base direction for drawing text for this widget. |
void |
draw()
Causes the entire widget to be redrawn. |
void |
drawArea(int x,
int y,
int width,
int height)
Causes the specified area to be redrawn |
void |
drawArea(Rectangle area)
Causes the specified area to be redrawn. |
static void |
finish(DragContext context,
boolean success,
boolean delete)
Deprecated. Use DragContext.finish(boolean, boolean, int) |
AtkObject |
getAccessible()
Returns the accessible object associated with this widget. |
Allocation |
getAllocation()
|
boolean |
getCanFocus()
Find out the current value of the "can-focus" property |
Colormap |
getColormap()
Returns the Colormap that will be used to render this widget. |
Context |
getContext()
Gets a Context with the appropriate Colormap, FontDescription and base direction for this widget. |
static void |
getData(Widget widget,
DragContext context,
Atom target)
Deprecated. Use getDragData(DragContext, Atom, int) |
Display |
getDisplay()
|
void |
getDragData(DragContext context,
Atom target,
int time)
|
java.lang.Class |
getEventListenerClass(java.lang.String signal)
|
EventType |
getEventType(java.lang.String signal)
|
ExtensionMode |
getExtensionEvents()
Retrieves the extension events the widget will receive. |
RcStyle |
getModifierStyle()
Retruns the Widget's RcStyle . |
java.lang.String |
getName()
Returns the name for the widget. |
Widget |
getParent()
Returns the parent container for this widget |
Window |
getParentWindow()
Returns the widget's parent window. |
Point |
getPointer()
Returns the location of the mouse pointer in widget coordinates. |
Window |
getRootWindow()
Get the root window where this widget is located. |
Screen |
getScreen()
|
boolean |
getSensitive()
Gets the sensitivity of the widget. |
Style |
getStyle()
Returns the Widgets Style . |
Widget |
getToplevel()
Returns the topmost widget in the container hierarchy. |
static Type |
getType()
Retrieve the runtime type used by the GLib library. |
static Widget |
getWidget(org.gnu.glib.Handle handle)
Creates a new Widget with a handle to a native resource returned from a call to the native libraries. |
Window |
getWindow()
Return the widget's Gdk window, if it has one. |
void |
grabDefault()
Causes the widget to become the default widget. |
void |
grabFocus()
Causes the widget to gain focus within its' TOPLEVEL. |
boolean |
hasFocus()
Determines if the widget has focus within its' TOPLEVEL. |
boolean |
hasScreen()
|
void |
hide()
Cause this Widget to not be visible. |
void |
hideAll()
Cause this Widget and all of its' children to not be visible. |
void |
highlight()
|
static void |
highlight(Widget widget)
Deprecated. Use highlight() . |
Rectangle |
intersect(Rectangle area)
Computes the intersection of the widget's area and area . |
boolean |
isAncestor(Widget ancestor)
Determines whether this widget is somewhere inside of ancestor. |
static Widget |
makeWidget(org.gnu.glib.Handle handle)
Create a Java-GNOME Widget subclass from an existing native GTK+ handle. |
void |
modifyStyle(RcStyle style)
Modifies style values on the Widget. |
void |
popColormap()
Pops the top colormap off of the stack of colormaps. |
void |
pushColormap(Colormap colormap)
Pushes a Colormap onto the stack of colormaps. |
void |
realize()
Creates a native window resource associated with this widget. |
boolean |
removeAccelerator(AccelGroup group,
int accelKey,
ModifierType accelMods)
|
void |
removeListener(ConfigureListener listener)
Unregister an object that was receiving configure event notification. |
void |
removeListener(DragDestinationListener listener)
Deprecated. Use removeListener(DragTargetListener) instead. |
void |
removeListener(DragOriginListener listener)
|
void |
removeListener(DragSourceListener listener)
Deprecated. Use removeListener(DragOriginListener) |
void |
removeListener(DragTargetListener listener)
|
void |
removeListener(ExposeListener listener)
Unregister an object that was receiving expose event notification. |
void |
removeListener(FocusListener listener)
Unregister an object that was receiving focus event notification. |
void |
removeListener(KeyListener listener)
Unregister an object that was receiving key event notification. |
void |
removeListener(LifeCycleListener listener)
Unregister an object that was receiving life cycle event notification. |
void |
removeListener(MouseListener listener)
Unregister an object that was receiving mouse event notification. |
void |
removeListener(MouseMotionListener listener)
Unregister an object that was receiving mouse motion event notification. |
void |
reparent(Widget newParent)
Moves a widget from one Container to another. |
void |
setBackgroundColor(StateType state,
Color color)
Sets the background color for a widget in a particular state. |
void |
setBaseColor(StateType state,
Color color)
Sets the base color used for a widget in a particular state. |
void |
setCanFocus(boolean canFocus)
Tell this Widget whether or not it is allowed to accept focus. |
void |
setColormap(Colormap colormap)
Set the Colormap that will be used to render this widget. |
void |
setDoubleBuffered(boolean doubleBuffered)
Enables/Disables double buffering for this widget. |
void |
setDragDestination(DestDefaults flags,
TargetEntry[] targets,
DragAction actions)
Sets up the widget so that is can receive drops as part of drag drop events and specifies what sort of drops it will accept |
void |
setDragIcon(Widget widget,
Colormap cmap,
Pixmap pixmap,
Bitmap mask)
|
void |
setDragIconPixbuf(Widget widget,
Pixbuf pixbuf)
|
void |
setDragIconStock(Widget widget,
java.lang.String stockId)
|
void |
setDragSource(ModifierType buttons,
TargetEntry[] targets,
DragAction actions)
Sets up the widget so that it can be the source of drag and drop operations. |
void |
setEvents(EventMask events)
Sets the event mask for a widget. |
void |
setExtensionEvents(ExtensionMode mode)
Sets the extension events mask to mode. |
void |
setFont(FontDescription fontDesc)
Sets the font to use for the widget. |
void |
setForegroundColor(StateType state,
Color color)
Sets the foreground color for a widget in a particular state. |
void |
setMinimumSize(int width,
int height)
Sets the minimum size of a widget. |
void |
setName(java.lang.String name)
Sets the name for this widget. |
void |
setNoDragDestination()
Removes support for this widget being a drag and drop target |
void |
setNoDragSource()
Removes support for this widget being a drag and drop source. |
void |
setSensitive(boolean sensitive)
Sets the sensitivity of a widget. |
void |
setTextColor(StateType state,
Color color)
Sets the text color for a widget in a particular state. |
void |
shapeCombineMask(Bitmap shapeMask,
int x,
int y)
Sets the shape of this widgets OS window. |
void |
show()
Cause this Widget to be visible. |
void |
showAll()
Cause this Widget and all of its' children to be visible. |
void |
unHighlight()
|
static void |
unHighlight(Widget widget)
Deprecated. Use unHighlight() . |
Methods inherited from class org.gnu.gtk.GtkObject |
---|
destroy, sink |
Methods inherited from class org.gnu.glib.Struct |
---|
equals, getHandle, getNullHandle, hashCode |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Widget(org.gnu.glib.Handle handle)
handle
- The handle that represents a pointer to a native resource.Method Detail |
---|
public static Widget getWidget(org.gnu.glib.Handle handle)
handle
- The handle that represents a pointer to a native resource.public void show()
public void showAll()
public void hide()
public void hideAll()
public void realize()
public void draw()
public void drawArea(Rectangle area)
area
- The area to be redrawn.public void drawArea(int x, int y, int width, int height)
x
- The x coordinate for the area to be redrawn.y
- The y coordinate for the area to be redrawn.width
- The width of the area to be redrawn.height
- The height of the area to be redrawn.public boolean activate()
public void reparent(Widget newParent)
newParent
- The widget that will be the new parent.public Widget getParent()
public Window getParentWindow()
public Window getWindow()
if you want to be sure of getting to a Gdk
Window.
,
for more about custom Widgets.
public void setEvents(EventMask events)
events
- public void addEvents(EventMask events)
events
- public void setExtensionEvents(ExtensionMode mode)
mode
- extension events to receive.public ExtensionMode getExtensionEvents()
public Rectangle intersect(Rectangle area)
area
.
area
- The area to use to compute the intersection.
public boolean hasFocus()
public void grabFocus()
public boolean getCanFocus()
setCanFocus(boolean)
public void setCanFocus(boolean canFocus)
selectable
, then you won't be able
to Copy and Paste any text you select from it.
canFocus
- public void grabDefault()
public void setName(java.lang.String name)
name
- The name for the widget.public java.lang.String getName()
public void setSensitive(boolean sensitive)
sensitive
- true to make the widget sensitive.public boolean getSensitive()
public Widget getToplevel()
public Colormap getColormap()
public void setColormap(Colormap colormap)
colormap
- The colormap to be used.public Point getPointer()
public boolean isAncestor(Widget ancestor)
ancestor
- The possible parent widgetpublic void pushColormap(Colormap colormap)
colormap
- The Colormap to push onto the stack.public void popColormap()
public void shapeCombineMask(Bitmap shapeMask, int x, int y)
shapeMask
- Shape to be added or null to remove an existing shape.x
- X Position of the shape mask with respect to the window.y
- Y Position of the shape mask with respect to the window.public void setForegroundColor(StateType state, Color color)
state
- The widget state to modify.color
- The color to set the foreground.public void setBackgroundColor(StateType state, Color color)
Note that some widgets draw on their parent container's window and thus
may not draw any background themselves. This is the case for e.g.
Label
. To modify the background of such widgets, you have to set
the background color on their parent; if you want to set the background
of a rectangular area around a label, try placing the label in an
EventBox
widget and setting the background color on that
state
- The widget state to modify.color
- The color to set the background.public void setTextColor(StateType state, Color color)
Note that some widgets draw on their parent container's window and thus
may not draw any background themselves. This is the case for e.g.
Label
. To modify the background of such widgets, you have to set
the background color on their parent; if you want to set the background
of a rectangular area around a label, try placing the label in an
EventBox
widget and setting the background color on that
state
- The widget state to modify.color
- The color to set the text.public void setBaseColor(StateType state, Color color)
state
- The widget state to modify.color
- The color to set.public void setFont(FontDescription fontDesc)
fontDesc
- The font description to use.public void modifyStyle(RcStyle style)
style
- The style to apply to the Widgetpublic RcStyle getModifierStyle()
RcStyle
.
public Style getStyle()
Style
.
public Context createContext()
public Context getContext()
public Layout createLayout(java.lang.String text)
text
- The text used for the layout.
public void setDoubleBuffered(boolean doubleBuffered)
doubleBuffered
- Set if the widget should be double buffered.public AtkObject getAccessible()
public boolean canActivateAccel(int signalId)
public Screen getScreen()
public boolean hasScreen()
public Display getDisplay()
public Window getRootWindow()
Window
at the top.
public void addAccelerator(AccelGroup group, int accelKey, ModifierType accelMods, AccelFlags accelFlags)
public boolean removeAccelerator(AccelGroup group, int accelKey, ModifierType accelMods)
public void setMinimumSize(int width, int height)
In most cases Window.setDefaultSize()
is a better choice
for toplevel windows than this method. Setting the default size will
still allow users to shrink the window. Setting the minimum size will
force them to leave the window at least as large as the request.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can change the appropriate size for a given widget. So, it's basically impossible to hardcode a size that will always be correct.
If the minimum size in a given direction is -1 then the "natural" size for the widget will be used instead.
width
- The minimum width size to use.height
- The minimum height size to use.public java.lang.Class getEventListenerClass(java.lang.String signal)
getEventListenerClass
in class GObject
public EventType getEventType(java.lang.String signal)
getEventType
in class GObject
public void addListener(LifeCycleListener listener)
listener
- The object that has implemented the LifeCycleListener
interface that is to receive the life cycle events.public void removeListener(LifeCycleListener listener)
listener
- The object that is to no longer receive life cycle events.public void addListener(FocusListener listener)
listener
- The object that has implemented the FocusListener interface
that is to receive the focus events.public void removeListener(FocusListener listener)
listener
- The object that is to no longer receive focus events.public void addListener(ConfigureListener listener)
listener
- The object that has implemented the ConfigureListener
interface that is to receive the configure events.public void removeListener(ConfigureListener listener)
listener
- The object that is to no longer receive configure events.public void addListener(KeyListener listener)
An important thing to notice is that some widgets don't receive
low-level events (such as a key-press event) by default. So if
you want to capture events from them, you should add them to an
EventBox
, and capture events on the EventBox
.
The reason why this happens is that some widgets, for efficiency, don't have their own X window, which is necessary to receive events. These are the widgets that don't have their own X window:
Alignment
Arrow
Bin
Box
Image
Item
Label
Pixmap
ScrolledWindow
Separator
Table
AspectFrame
Frame
VBox
HBox
VSeparator
HSeparator
listener
- The object that has implemented the KeyListener interface that
is to receive the key events.public void removeListener(KeyListener listener)
listener
- The object that is to no longer receive key events.public void addListener(MouseListener listener)
An important thing to notice is that some widgets don't receive
low-level events (such as a mouse-click event) by default. So if
you want to capture events from them, you should add them to an
EventBox
, and capture events on the EventBox
.
The reason why this happens is that some widgets, for efficiency, don't have their own X window, which is necessary to receive events. These are the widgets that don't have their own X window:
Alignment
Arrow
Bin
Box
Image
Item
Label
Pixmap
ScrolledWindow
Separator
Table
AspectFrame
Frame
VBox
HBox
VSeparator
HSeparator
listener
- The object that has implemented the MouseListener interface
that is to receive the mouse events.public void removeListener(MouseListener listener)
listener
- The object that is to no longer receive mouse events.public static Type getType()
public static Widget makeWidget(org.gnu.glib.Handle handle) throws java.lang.ClassNotFoundException
handle
- The handle that represents a pointer to a native resource.
java.lang.ClassNotFoundException
- if a Java-GNOME class cannot be found for the specified
handle.public Allocation getAllocation()
public void setDragSource(ModifierType buttons, TargetEntry[] targets, DragAction actions)
buttons
- Buttons which can start the dragtargets
- An array of names of drag and drop operations accepted (these
are made up by the application designers. Widgets must set as
drag sources and destinations with one of these the same)actions
- Drag action - determines which events will be called.public void setNoDragSource()
public void setDragIcon(Widget widget, Colormap cmap, Pixmap pixmap, Bitmap mask)
public void setDragIconPixbuf(Widget widget, Pixbuf pixbuf)
public void setDragIconStock(Widget widget, java.lang.String stockId)
public void setDragDestination(DestDefaults flags, TargetEntry[] targets, DragAction actions)
flags
- public void getDragData(DragContext context, Atom target, int time)
public void setNoDragDestination()
public static void getData(Widget widget, DragContext context, Atom target)
getDragData(DragContext, Atom, int)
public static void finish(DragContext context, boolean success, boolean delete)
DragContext.finish(boolean, boolean, int)
public static void highlight(Widget widget)
highlight()
.
public void highlight()
public static void unHighlight(Widget widget)
unHighlight()
.
public void unHighlight()
public void addListener(DragDestinationListener listener)
addListener(DragTargetListener)
instead.
listener
- The object that has implemented the DragDestinationListener
interfacepublic void addListener(DragTargetListener listener)
public void removeListener(DragDestinationListener listener)
removeListener(DragTargetListener)
instead.
listener
- The object that is to no longer receive dragDestination eventspublic void removeListener(DragTargetListener listener)
public void addListener(DragSourceListener listener)
addListener(DragOriginListener)
instead.
listener
- The object that has implemented the DragSourceListener
interfacepublic void addListener(DragOriginListener listener)
public void removeListener(DragSourceListener listener)
removeListener(DragOriginListener)
listener
- The object that is to no longer receive drag source eventspublic void removeListener(DragOriginListener listener)
public void addListener(ExposeListener listener)
listener
- The object that has implemented the ExposeListener interface
that is to receive the expose events.public void removeListener(ExposeListener listener)
listener
- The object that is to no longer receive expose events.public void addListener(MouseMotionListener listener)
An important thing to notice is that some widgets don't receive
low-level events (such as a mouse-enter event) by default. So if
you want to capture events from them, you should add them to an
EventBox
, and capture events on the EventBox
.
The reason why this happens is that some widgets, for efficiency, don't have their own X window, which is necessary to receive events. These are the widgets that don't have their own X window:
Alignment
Arrow
Bin
Box
Image
Item
Label
Pixmap
ScrolledWindow
Separator
Table
AspectFrame
Frame
VBox
HBox
VSeparator
HSeparator
listener
- The object that has implemented the MouseMotionListener
interface that is to receive the mouse motion events.public void removeListener(MouseMotionListener listener)
listener
- The object that is to no longer receive mouse motion events.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |