Details
enum GtkWidgetFlags
typedef enum
{
GTK_TOPLEVEL = 1 << 4,
GTK_NO_WINDOW = 1 << 5,
GTK_REALIZED = 1 << 6,
GTK_MAPPED = 1 << 7,
GTK_VISIBLE = 1 << 8,
GTK_SENSITIVE = 1 << 9,
GTK_PARENT_SENSITIVE = 1 << 10,
GTK_CAN_FOCUS = 1 << 11,
GTK_HAS_FOCUS = 1 << 12,
/* widget is allowed to receive the default via gtk_widget_grab_default
* and will reserve space to draw the default if possible
*/
GTK_CAN_DEFAULT = 1 << 13,
/* the widget currently is receiving the default action and should be drawn
* appropriately if possible
*/
GTK_HAS_DEFAULT = 1 << 14,
GTK_HAS_GRAB = 1 << 15,
GTK_RC_STYLE = 1 << 16,
GTK_COMPOSITE_CHILD = 1 << 17,
GTK_NO_REPARENT = 1 << 18,
GTK_APP_PAINTABLE = 1 << 19,
/* the widget when focused will receive the default action and have
* HAS_DEFAULT set even if there is a different widget set as default
*/
GTK_RECEIVES_DEFAULT = 1 << 20,
GTK_DOUBLE_BUFFERED = 1 << 21
} GtkWidgetFlags; |
GTK_WIDGET_TYPE()
#define GTK_WIDGET_TYPE(wid) (GTK_OBJECT_TYPE (wid)) |
GTK_WIDGET_STATE()
#define GTK_WIDGET_STATE(wid) (GTK_WIDGET (wid)->state) |
GTK_WIDGET_SAVED_STATE()
#define GTK_WIDGET_SAVED_STATE(wid) (GTK_WIDGET (wid)->saved_state) |
GTK_WIDGET_FLAGS()
#define GTK_WIDGET_FLAGS(wid) (GTK_OBJECT_FLAGS (wid)) |
GTK_WIDGET_TOPLEVEL()
#define GTK_WIDGET_TOPLEVEL(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_TOPLEVEL) != 0) |
GTK_WIDGET_NO_WINDOW()
#define GTK_WIDGET_NO_WINDOW(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_NO_WINDOW) != 0) |
GTK_WIDGET_REALIZED()
#define GTK_WIDGET_REALIZED(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_REALIZED) != 0) |
GTK_WIDGET_MAPPED()
#define GTK_WIDGET_MAPPED(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0) |
GTK_WIDGET_VISIBLE()
#define GTK_WIDGET_VISIBLE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0) |
GTK_WIDGET_DRAWABLE()
#define GTK_WIDGET_DRAWABLE(wid) (GTK_WIDGET_VISIBLE (wid) && GTK_WIDGET_MAPPED (wid)) |
GTK_WIDGET_SENSITIVE()
#define GTK_WIDGET_SENSITIVE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_SENSITIVE) != 0) |
GTK_WIDGET_PARENT_SENSITIVE()
#define GTK_WIDGET_PARENT_SENSITIVE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_PARENT_SENSITIVE) != 0) |
GTK_WIDGET_IS_SENSITIVE()
#define GTK_WIDGET_IS_SENSITIVE(wid) |
GTK_WIDGET_CAN_FOCUS()
#define GTK_WIDGET_CAN_FOCUS(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_CAN_FOCUS) != 0) |
GTK_WIDGET_HAS_FOCUS()
#define GTK_WIDGET_HAS_FOCUS(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_HAS_FOCUS) != 0) |
GTK_WIDGET_CAN_DEFAULT()
#define GTK_WIDGET_CAN_DEFAULT(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_CAN_DEFAULT) != 0) |
GTK_WIDGET_RECEIVES_DEFAULT()
#define GTK_WIDGET_RECEIVES_DEFAULT(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_RECEIVES_DEFAULT) != 0) |
GTK_WIDGET_HAS_DEFAULT()
#define GTK_WIDGET_HAS_DEFAULT(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_HAS_DEFAULT) != 0) |
GTK_WIDGET_HAS_GRAB()
#define GTK_WIDGET_HAS_GRAB(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_HAS_GRAB) != 0) |
GTK_WIDGET_RC_STYLE()
#define GTK_WIDGET_RC_STYLE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_RC_STYLE) != 0) |
GTK_WIDGET_COMPOSITE_CHILD()
#define GTK_WIDGET_COMPOSITE_CHILD(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_COMPOSITE_CHILD) != 0) |
GTK_WIDGET_APP_PAINTABLE()
#define GTK_WIDGET_APP_PAINTABLE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_APP_PAINTABLE) != 0) |
GTK_WIDGET_DOUBLE_BUFFERED()
#define GTK_WIDGET_DOUBLE_BUFFERED(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_DOUBLE_BUFFERED) != 0) |
GTK_WIDGET_SET_FLAGS()
#define GTK_WIDGET_SET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) |= (flag)); }G_STMT_END |
GTK_WIDGET_UNSET_FLAGS()
#define GTK_WIDGET_UNSET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) &= ~(flag)); }G_STMT_END |
struct GtkRequisition
struct GtkRequisition
{
gint width;
gint height;
}; |
struct GtkAllocation
struct GtkAllocation
{
gint x;
gint y;
gint width;
gint height;
}; |
struct GtkSelectionData
struct GtkSelectionData
{
GdkAtom selection;
GdkAtom target;
GdkAtom type;
gint format;
guchar *data;
gint length;
}; |
struct GtkWidgetAuxInfo
struct GtkWidgetAuxInfo
{
gint x;
gint y;
gint width;
gint height;
guint x_set : 1;
guint y_set : 1;
}; |
struct GtkWidgetShapeInfo
struct GtkWidgetShapeInfo
{
gint16 offset_x;
gint16 offset_y;
GdkBitmap *shape_mask;
}; |
enum GtkWidgetHelpType
typedef enum
{
GTK_WIDGET_HELP_TOOLTIP,
GTK_WIDGET_HELP_WHATS_THIS
} GtkWidgetHelpType; |
gtk_widget_new ()
This is a convenience function for creating a widget and setting
its properties in one go. For example you might write:
gtk_widget_new (GTK_TYPE_LABEL, "label", "Hello World", "xalign",
0.0, NULL) to create a left-aligned label. Equivalent to
gtk_object_new(), but returns a widget so you don't have to
cast the object yourself.
gtk_widget_ref ()
Adds a reference to a widget. This function is exactly the same
as calling g_object_ref(), and exists mostly for historical
reasons. It can still be convenient to avoid casting a widget
to a GObject, it saves a small amount of typing.
gtk_widget_destroy ()
Destroys a widget. Equivalent to gtk_object_destroy(), except that
you don't have to cast the widget to GtkObject. When a widget is
destroyed, it will break any references it holds to other objects.
If the widget is inside a container, the widget will be removed
from the container. If the widget is a toplevel (derived from
GtkWindow), it will be removed from the list of toplevels, and the
reference GTK+ holds to it will be removed. Removing a
widget from its container or the list of toplevels results in the
widget being finalized, unless you've added additional references
to the widget with gtk_object_ref().
In most cases, only toplevel widgets (windows) require explicit
destruction, because when you destroy a toplevel its children will
be destroyed as well.
gtk_widget_destroyed ()
This function sets *widget_pointer to NULL if widget_pointer !=
NULL. It's intended to be used as a callback connected to the
"destroy" signal of a widget. You connect gtk_widget_destroyed()
as a signal handler, and pass the address of your widget variable
as user data. Then when the widget is destroyed, the variable will
be set to NULL. Useful for example to avoid multiple copies
of the same dialog.
gtk_widget_set ()
void gtk_widget_set (GtkWidget *widget,
const gchar *first_property_name,
...); |
Warning |
gtk_widget_set is deprecated and should not be used in newly-written code. |
Like gtk_object_set() - there's no reason to use this instead of
gtk_object_set().
gtk_widget_unparent ()
void gtk_widget_unparent (GtkWidget *widget); |
This function is only for use in widget implementations.
Should be called by implementations of the remove method
on GtkContainer, to dissociate a child from the container.
gtk_widget_show ()
Flags a widget to be displayed. Any widget that isn't shown will
not appear on the screen. If you want to show all the widgets in a
container, it's easier to call gtk_widget_show_all() on the
container, instead of individually showing the widgets.
Remember that you have to show the containers containing a widget,
in addition to the widget itself, before it will appear onscreen.
When a toplevel container is shown, it is immediately realized and
mapped; other shown widgets are realized and mapped when their
toplevel container is realized and mapped.
gtk_widget_show_now ()
void gtk_widget_show_now (GtkWidget *widget); |
Shows a widget. If the widget is an unmapped toplevel widget
(i.e. a GtkWindow that has not yet been shown), enter the main
loop and wait for the window to actually be mapped. Be careful;
because the main loop is running, anything can happen during
this function.
gtk_widget_hide ()
Reverses the effects of gtk_widget_show(), causing the widget to be
hidden (invisible to the user).
gtk_widget_show_all ()
void gtk_widget_show_all (GtkWidget *widget); |
Recursively shows a widget, and any child widgets (if the widget is
a container).
gtk_widget_hide_all ()
void gtk_widget_hide_all (GtkWidget *widget); |
Recursively hides a widget and any child widgets.
gtk_widget_map ()
This function is only for use in widget implementations. Causes
a widget to be mapped if it isn't already.
gtk_widget_unmap ()
This function is only for use in widget implementations. Causes
a widget to be unmapped if it's currently mapped.
gtk_widget_realize ()
Creates the GDK (windowing system) resources associated with a
widget. For example, widget->window will be created when a widget
is realized. Normally realization happens implicitly; if you show
a widget and all its parent containers, then the widget will be
realized and mapped automatically.
Realizing a widget requires all
the widget's parent widgets to be realized; calling
gtk_widget_realize() realizes the widget's parents in addition to
widget itself. If a widget is not yet inside a toplevel window
when you realize it, bad things will happen.
This function is primarily used in widget implementations, and
isn't very useful otherwise. Many times when you think you might
need it, a better approach is to connect to a signal that will be
called after the widget is realized automatically, such as
"expose_event". Or simply gtk_signal_connect_after() to the
"realize" signal.
gtk_widget_unrealize ()
void gtk_widget_unrealize (GtkWidget *widget); |
This function is only useful in widget implementations.
Causes a widget to be unrealized (frees all GDK resources
associated with the widget, such as widget->window).
gtk_widget_queue_resize ()
void gtk_widget_queue_resize (GtkWidget *widget); |
This function is only for use in widget implementations.
Flags a widget to have its size renegotiated; should
be called when a widget for some reason has a new size request.
For example, when you change the text in a GtkLabel, GtkLabel
queues a resize to ensure there's enough space for the new text.
gtk_widget_draw ()
Warning |
gtk_widget_draw is deprecated and should not be used in newly-written code. |
DEPRECATED. In GTK+ 1.2, this function would immediately render the
region area of a widget, by invoking the virtual draw method of a
widget. In GTK+ 2.0, the draw method is gone, and instead
gtk_widget_draw() simply invalidates the specified region of the
widget, then updates the invalid region of the widget immediately.
Usually you don't want to update the region immediately for
performance reasons, so in general gtk_widget_queue_draw_area() is
a better choice if you want to draw a region of a widget.
gtk_widget_size_request ()
This function is typically used when implementing a GtkContainer
subclass. Obtains the preferred size of a widget. The container
uses this information to arrange its child widgets and decide what
size allocations to give them with gtk_widget_size_allocate().
You can also call this function from an application, with some
caveats. Most notably, getting a size request requires the widget
to be associated with a screen, because font information may be
needed. Multihead-aware applications should keep this in mind.
Also remember that the size request is not necessarily the size
a widget will actually be allocated.
See also gtk_widget_get_child_requisition().
gtk_widget_get_child_requisition ()
This function is only for use in widget implementations. Obtains
widget->requisition, unless someone has forced a particular
geometry on the widget (e.g. with gtk_widget_set_usize()), in which
case it returns that geometry instead of the widget's requisition.
This function differs from gtk_widget_size_request() in that
it retrieves the last size request value from widget->requisition,
while gtk_widget_size_request() actually calls the "size_request" method
on widget to compute the size request and fill in widget->requisition,
and only then returns widget->requisition.
Because this function does not call the "size_request" method, it
can only be used when you know that widget->requisition is
up-to-date, that is, gtk_widget_size_request() has been called
since the last time a resize was queued. In general, only container
implementations have this information; applications should use
gtk_widget_size_request().
gtk_widget_size_allocate ()
This function is only used by GtkContainer subclasses, to assign a size
and position to their child widgets.
gtk_widget_add_accelerator ()
Install an accelerator for this widget in accel_group, that causes
accel_signal to be emitted if the accelerator is actiavted.
The accel_group needs to be added to the widget's toplevel via
gtk_window_add_accel_group(), and the signal must be of type G_RUN_ACTION.
Accelerators added through this function are not user changable during
runtime. If you want to support accelerators that can be changed by the
user, use gtk_accel_map_add_entry() and gtk_menu_item_set_accel_path()
instead.
gtk_widget_event ()
Rarely-used function. This function is used to emit
the event signals on a widget (those signals should never
be emitted without using this function to do so).
If you want to synthesize an event though, don't use this function;
instead, use gtk_main_do_event() so the event will behave as if
it were in the event queue. Don't synthesize expose events; instead,
use gdk_window_invalidate_rect() to invalidate a region of the
window.
gtk_widget_activate ()
For widgets that can be "activated" (buttons, menu items, etc.)
this function activates them. Activation is what happens when you
press Enter on a widget during key navigation; clicking a button,
selecting a menu item, etc. If widget isn't activatable,
the function returns FALSE.
gtk_widget_reparent ()
Moves a widget from one GtkContainer to another, handling reference
count issues to avoid destroying the widget.
gtk_widget_intersect ()
Computes the intersection of a widget's area and area, storing
the intersection in intersection, and returns TRUE if there was
an intersection. intersection may be NULL if you're only
interested in whether there was an intersection.
gtk_widget_is_focus ()
Determines if the widget is the focus widget within its
toplevel. (This does not mean that the HAS_FOCUS flag is
necessarily set; HAS_FOCUS will only be set if the
toplevel widget additionally has the global input focus.)
gtk_widget_grab_focus ()
void gtk_widget_grab_focus (GtkWidget *widget); |
Causes widget to have the keyboard focus for the GtkWindow it's
inside. widget must be a focusable widget, such as a GtkEntry;
something like GtkFrame won't work. (More precisely, it must have the
GTK_CAN_FOCUS flag set.)
gtk_widget_grab_default ()
void gtk_widget_grab_default (GtkWidget *widget); |
Causes widget to become the default widget. widget must have the
GTK_CAN_DEFAULT flag set; typically you have to set this flag
yourself by calling GTK_WIDGET_SET_FLAGS (widget,
GTK_CAN_DEFAULT). The default widget is activated when the user
presses Enter in a window. Default widgets must be activatable,
that is, gtk_widget_activate() should affect them.
gtk_widget_set_name ()
Widgets can be named, which allows you to refer to them from a
gtkrc file. You can apply a style to widgets with a particular name
in the gtkrc file. See the documentation for gtkrc files (on the
same page as the docs for GtkRcStyle).
gtk_widget_get_name ()
Retrieves the name of a widget. The return value should not be
freed. See gtk_widget_set_name() for the significance of widget
names.
gtk_widget_set_state ()
This function is for use in widget implementations. Sets the state
of a widget (insensitive, prelighted, etc.) Usually you should set
the state using wrapper functions such as gtk_widget_set_sensitive().
gtk_widget_set_sensitive ()
Sets the sensitivity of a widget. A widget is sensitive if the user
can interact with it. Insensitive widgets are "grayed out" and the
user can't interact with them. Insensitive widgets are known as
"inactive" in some other toolkits.
gtk_widget_set_parent ()
This function is useful only when implementing subclasses of GtkContainer.
Sets the container as the parent of widget, and takes care of
some details such as updating the state and style of the child
to reflect its new location. The opposite function is
gtk_widget_unparent().
gtk_widget_set_parent_window ()
gtk_widget_get_parent_window ()
gtk_widget_set_uposition ()
Warning |
gtk_widget_set_uposition is deprecated and should not be used in newly-written code. |
Sets the position of a widget. The funny "u" in the name comes from
the "user position" hint specified by the X window system, and
exists for legacy reasons. This function doesn't work if a widget
is inside a container; it's only really useful on GtkWindow.
Don't use this function to center dialogs over the main application
window; most window managers will do the centering on your behalf
if you call gtk_window_set_transient_for(), and it's really not
possible to get the centering to work correctly in all cases from
application code. But if you insist, use gtk_window_set_position()
to set GTK_WIN_POS_CENTER_ON_PARENT, don't do the centering
manually.
Note that although x and y can be individually unset, the position
is not honoured unless both x and y are set.
gtk_widget_set_usize ()
Warning |
gtk_widget_set_usize is deprecated and should not be used in newly-written code. |
This function is deprecated; use gtk_widget_set_size_request()
instead.
Sets the minimum size of a widget; that is, the widget's size
request will be width by height. You can use this function to
force a widget to be either larger or smaller than it is. The
strange "usize" name dates from the early days of GTK+, and derives
from X Window System terminology. In many cases,
gtk_window_set_default_size() is a better choice for toplevel
windows than this function; setting the default size will still
allow users to shrink the window. Setting the usize will force them
to leave the window at least as large as the usize. When dealing
with window sizes, gtk_window_set_geometry_hints() can be a useful
function as well.
Note the inherent danger of setting any fixed size - themes,
translations into other languages, different fonts, and user action
can all change the appropriate size for a given widget. So, it's
basically impossible to hardcode a size that will always be
correct.
gtk_widget_set_events ()
Sets the event mask (see GdkEventMask) for a widget. The event
mask determines which events a widget will receive. Keep in mind
that different widgets have different default event masks, and by
changing the event mask you may disrupt a widget's functionality,
so be careful. This function must be called while a widget is
unrealized. Consider gtk_widget_add_events() for widgets that are
already realized, or if you want to preserve the existing event
mask. This function can't be used with GTK_NO_WINDOW widgets;
to get events on those widgets, place them inside a GtkEventBox
and receive events on the event box.
gtk_widget_add_events ()
Adds the events in the bitfield events to the event mask for
widget. See gtk_widget_set_events() for details.
gtk_widget_get_toplevel ()
This function returns the topmost widget in the container hierarchy
widget is a part of. If widget has no parent widgets, it will be
returned as the topmost widget. No reference will be added to the
returned widget; it should not be unreferenced.
Note the difference in behavior vs. gtk_widget_get_ancestor();
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) would return
NULL if widget wasn't inside a toplevel window, and if the
window was inside a GtkWindow-derived widget which was in turn
inside the toplevel GtkWindow. While the second case may
seem unlikely, it actually happens when a GtkPlug is embedded
inside a GtkSocket within the same application
To reliably find the toplevel GtkWindow, use
gtk_widget_get_toplevel() and check if the TOPLEVEL flags
is set on the result.
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel))
{
[ Perform action on toplevel. ]
}
gtk_widget_get_ancestor ()
Gets the first ancestor of widget with type widget_type. For example,
gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets the first GtkBox that's
an ancestor of widget. No reference will be added to the returned widget;
it should not be unreferenced. See note about checking for a toplevel
GtkWindow in the docs for gtk_widget_get_toplevel().
gtk_widget_get_colormap ()
Gets the colormap that will be used to render widget. No reference will
be added to the returned colormap; it should not be unreferenced.
gtk_widget_set_colormap ()
Set the colormap for the widget to the given value. Widget must not
have been previously realized. This probably should only be used
from an init() function (i.e. from the constructor for the widget).
gtk_widget_get_visual ()
Gets the visual that will be used to render widget.
gtk_widget_get_events ()
Returns the event mask for the widget (a bitfield containing flags
from the GdkEventMask enumeration). These are the events that the widget
will receive.
gtk_widget_get_pointer ()
Obtains the location of the mouse pointer in widget coordinates.
Widget coordinates are a bit odd; for historical reasons, they are
defined as widget->window coordinates for widgets that are not
GTK_NO_WINDOW widgets, and are relative to widget->allocation.x,
widget->allocation.y for widgets that are GTK_NO_WINDOW widgets.
gtk_widget_is_ancestor ()
Determines whether widget is somewhere inside ancestor, possibly with
intermediate containers.
gtk_widget_translate_coordinates ()
Translate coordinates relative to src_widget's allocation to coordinates
relative to dest_widget's allocations. In order to perform this
operation, both widgets must be realized, and must share a common
toplevel.
gtk_widget_hide_on_delete ()
Utility function; intended to be connected to the "delete_event"
signal on a GtkWindow. The function calls gtk_widget_hide() on its
argument, then returns TRUE. If connected to "delete_event",
the result is that clicking the window manager close button for
will hide but not destroy the window. By default, GTK+ destroys
windows when "delete_event" is received.
gtk_widget_set_style ()
Sets the GtkStyle for a widget (widget->style). You probably don't
want to use this function; it interacts badly with themes, because
themes work by replacing the GtkStyle. Instead, use
gtk_widget_modify_style().
gtk_widget_set_rc_style()
#define gtk_widget_set_rc_style(widget) (gtk_widget_set_style (widget, NULL)) |
Warning |
gtk_widget_set_rc_style is deprecated and should not be used in newly-written code. |
gtk_widget_ensure_style ()
void gtk_widget_ensure_style (GtkWidget *widget); |
Ensures that widget has a style (widget->style). Not a very useful
function; most of the time, if you want the style, the widget is
realized, and realized widgets are guaranteed to have a style
already.
gtk_widget_get_style ()
Simply an accessor function that returns widget->style.
gtk_widget_restore_default_style()
#define gtk_widget_restore_default_style(widget) (gtk_widget_set_style (widget, NULL)) |
Warning |
gtk_widget_restore_default_style is deprecated and should not be used in newly-written code. |
gtk_widget_reset_rc_styles ()
void gtk_widget_reset_rc_styles (GtkWidget *widget); |
gtk_widget_push_colormap ()
Pushes cmap onto a global stack of colormaps; the topmost
colormap on the stack will be used to create all widgets.
Remove cmap with gtk_widget_pop_colormap(). There's little
reason to use this function.
gtk_widget_pop_colormap ()
void gtk_widget_pop_colormap (void); |
Removes a colormap pushed with gtk_widget_push_colormap().
gtk_widget_set_default_colormap ()
void gtk_widget_set_default_colormap (GdkColormap *colormap); |
Sets the default colormap to use when creating widgets.
gtk_widget_push_colormap() is a better function to use if
you only want to affect a few widgets, rather than all widgets.
gtk_widget_get_default_style ()
GtkStyle* gtk_widget_get_default_style (void); |
gtk_widget_get_default_colormap ()
Obtains the default colormap used to create widgets.
gtk_widget_get_default_visual ()
GdkVisual* gtk_widget_get_default_visual (void); |
Obtains the visual of the default colormap. Not really useful;
used to be useful before gdk_colormap_get_visual() existed.
gtk_widget_set_direction ()
Set the reading direction on a particular widget. This direction
controls the primary direction for widgets containing text,
and also the direction in which the children of a container are
packed. The ability to set the direction is present in order
so that correct localization into languages with right-to-left
reading directions can be done. Generally, applications will
let the default reading direction present, except for containers
where the containers are arranged in an order that is explicitely
visual rather than logical (such as buttons for text justificiation).
If the direction is set to GTK_TEXT_DIR_NONE, then the value
set by gtk_widget_set_default_direction() will be used.
enum GtkTextDirection
typedef enum
{
GTK_TEXT_DIR_NONE,
GTK_TEXT_DIR_LTR,
GTK_TEXT_DIR_RTL
} GtkTextDirection; |
gtk_widget_set_default_direction ()
Set the default reading direction for widgets where the
direction has not been explicitly set by gtk_widget_set_direction().
gtk_widget_get_default_direction ()
gtk_widget_shape_combine_mask ()
gtk_widget_path ()
Obtains the full path to widget. The path is simply the name of a
widget and all its parents in the container hierarchy, separated by
periods. The name of a widget comes from
gtk_widget_get_name(). Paths are used to apply styles to a widget
in gtkrc configuration files. Widget names are the type of the
widget by default (e.g. "GtkButton") or can be set to an
application-specific value with gtk_widget_set_name(). By setting
the name of a widget, you allow users or theme authors to apply
styles to that specific widget in their gtkrc
file. path_reversed_p fills in the path in reverse order,
i.e. starting with widget's name instead of starting with the name
of widget's outermost ancestor.
gtk_widget_get_composite_name ()
gtk_widget_modify_style ()
void gtk_widget_modify_style (GtkWidget *widget,
GtkRcStyle *style); |
Modify style values on the widget. Modifications made using this
technique take precedence over style values set via an RC file,
however, they will be overriden if a style is explicitely set on
the widget using gtk_widget_set_style(). The GtkRcStyle structure
is designed so each field can either be set or unset, so it is
possible, using this function, to modify some style values and
leave the others unchanged.
Note that modifications made with this function are not cumulative
with previous calls to gtk_widget_modify_style() or with such
functions as gtk_widget_modify_fg(). If you wish to retain
previous values, you must first call gtk_widget_get_modifier_style(),
make your modifications to the returned style, then call
gtk_widget_modify_style() with that style. On the other hand,
if you first call gtk_widget_modify_style(), subsequent calls
to such functions gtk_widget_modify_fg() will have a cumulative
effect with the initial modifications.
gtk_widget_get_modifier_style ()
GtkRcStyle* gtk_widget_get_modifier_style (GtkWidget *widget); |
Return the current modifier style for the widget. (As set by
gtk_widget_modify_style().) If no style has previously set, a new
GtkRcStyle will be created with all values unset, and set as the
modifier style for the widget. If you make changes to this rc
style, you must call gtk_widget_modify_style(), passing in the
returned rc style, to make sure that your changes take effect.
Caution: passing the style back to gtk_widget_modify_style() will
normally end up destroying it, because gtk_widget_modify_style() copies
the passed-in style and sets the copy as the new modifier style,
thus dropping any reference to the old modifier style. Add a reference
to the modifier style if you want to keep it alive.
gtk_widget_modify_fg ()
Set the foreground color for a widget in a particular state. All
other style values are left untouched. See also
gtk_widget_modify_style().
gtk_widget_modify_bg ()
Set the background color for a widget in a particular state. All
other style values are left untouched. See also
gtk_widget_modify_style().
gtk_widget_modify_text ()
Set the text color for a widget in a particular state. All other
style values are left untouched. The text color is the foreground
color used along with the base color (see gtk_widget_modify_base)
for widgets such as GtkEntry and GtkTextView. See also
gtk_widget_modify_style().
gtk_widget_modify_base ()
Set the base color for a widget in a particular state.
All other style values are left untouched. The base color
is the background color used along with the text color
(see gtk_widget_modify_text) for widgets such as GtkEntry
and GtkTextView. See also gtk_widget_modify_style().
gtk_widget_modify_font ()
Set the font to use for a widget. All other style values are left
untouched. See also gtk_widget_modify_style().
gtk_widget_create_pango_context ()
Create a new pango context with the appropriate colormap,
font description, and base direction for drawing text for
this widget. See also gtk_widget_get_pango_context()
gtk_widget_get_pango_context ()
Get a PangoContext with the appropriate colormap, font description
and base direction for this widget. Unlike the context returned
by gtk_widget_create_pango_context(), this context is owned by
the widget (it can be used as long as widget exists), and will
be updated to match any changes to the widget's attributes.
If you create and keep a PangoLayout using this context, you must
deal with changes to the context by calling pango_layout_context_changed()
on the layout in response to the ::style_set and ::direction_set signals
for the widget.
gtk_widget_create_pango_layout ()
Create a new PangoLayout with the appropriate colormap,
font description, and base direction for drawing text for
this widget.
If you keep a PangoLayout created in this way around, in order
notify the layout of changes to the base direction or font of this
widget, you must call pango_layout_context_changed() in response to
the ::style_set and ::direction_set signals for the widget.
gtk_widget_render_icon ()
A convenience function that uses the theme engine and RC file
settings for widget to look up stock_id and render it to
a pixbuf. stock_id should be a stock icon ID such as
GTK_STOCK_OPEN or GTK_STOCK_OK. size should be a size
such as GTK_ICON_SIZE_MENU. detail should be a string that
identifies the widget or code doing the rendering, so that
theme engines can special-case rendering for that widget or code.
gtk_widget_pop_composite_child ()
void gtk_widget_pop_composite_child (void); |
gtk_widget_push_composite_child ()
void gtk_widget_push_composite_child (void); |
gtk_widget_queue_clear ()
void gtk_widget_queue_clear (GtkWidget *widget); |
Warning |
gtk_widget_queue_clear is deprecated and should not be used in newly-written code. |
DEPRECATED. Use gtk_widget_queue_draw() instead.
gtk_widget_queue_draw_area ()
Invalidates the rectangular area of widget defined by x, y,
width and height by calling gdk_window_invalidate_rect() on the
widget's window and all its child windows. Once the main loop
becomes idle (after the current batch of events has been processed,
roughly), the window will receive expose events for the union of
all regions that have been invalidated.
Normally you would only use this function in widget
implementations. You might also use it, or
gdk_window_invalidate_rect() directly, to schedule a redraw of a
GtkDrawingArea or some portion thereof.
Frequently you can just call gdk_window_invalidate_rect() or
gdk_window_invalidate_region() instead of this function. Those
functions will invalidate only a single window, instead of the
widget and all its children.
The advantage of adding to the invalidated region compared to
simply drawing immediately is efficiency; using an invalid region
ensures that you only have to redraw one time.
gtk_widget_reset_shapes ()
void gtk_widget_reset_shapes (GtkWidget *widget); |
gtk_widget_set_app_paintable ()
gtk_widget_set_double_buffered ()
Widgets are double buffered by default; you can use this function
to turn off the buffering. "Double buffered" simply means that
gdk_window_begin_paint_region() and gdk_window_end_paint() are called
automatically around expose events sent to the
widget. gdk_window_begin_paint() diverts all drawing to a widget's
window to an offscreen buffer, and gdk_window_end_paint() draws the
buffer to the screen. The result is that users see the window
update in one smooth step, and don't see individual graphics
primitives being rendered.
In very simple terms, double buffered widgets don't flicker,
so you would only use this function to turn off double buffering
if you had special needs and really knew what you were doing.
gtk_widget_set_redraw_on_allocate ()
void gtk_widget_set_redraw_on_allocate
(GtkWidget *widget,
gboolean redraw_on_allocate); |
Sets whether a when a widgets size allocation changes, the entire
widget is queued for drawing. By default, this setting is TRUE and
the entire widget is redrawn on every size change. If your widget
leaves the upper left are unchanged when made bigger, turning this
setting on will improve performance.
Note that for NO_WINDOW widgets setting this flag to FALSE turns
off all allocation on resizing: the widget will not even redraw if
its position changes; this is to allow containers that don't draw
anything to avoid excess invalidations. If you set this flag on a
NO_WINDOW widget that _does_ draw on widget->window, you are
responsible for invalidating both the old and new allocation of the
widget when the widget is moved and responsible for invalidating
regions newly when the widget increases size.
gtk_widget_set_composite_name ()
void gtk_widget_set_composite_name (GtkWidget *widget,
const gchar *name); |
gtk_widget_set_scroll_adjustments ()
For widgets that support scrolling, sets the scroll adjustments and
returns TRUE. For widgets that don't support scrolling, does
nothing and returns FALSE. Widgets that don't support scrolling
can be scrolled by placing them in a GtkViewport, which does
support scrolling.
gtk_widget_mnemonic_activate ()
gtk_widget_class_install_style_property ()
void gtk_widget_class_install_style_property
(GtkWidgetClass *klass,
GParamSpec *pspec); |
gtk_widget_class_install_style_property_parser ()
gtk_widget_region_intersect ()
Computes the intersection of a widget's area and region, returning
the intersection. The result may be empty, use gdk_region_empty to
check.
gtk_widget_send_expose ()
Very rarely-used function. This function is used to emit
an expose event signals on a widget. This function is not
normally used directly. The only time it is used is when
propagating an expose event to a child NO_WINDOW widget, and
that is normally done using gtk_container_propagate_expose.
If you want to force an area of a window to be redrawn,
use gdk_window_invalidate_rect() or gdk_window_invalidate_region().
To cause the redraw to be done immediately, follow that call
with a call to gdk_window_procss_updates().
gtk_widget_style_get ()
void gtk_widget_style_get (GtkWidget *widget,
const gchar *first_property_name,
...); |
gtk_widget_style_get_property ()
gtk_widget_style_get_valist ()
void gtk_widget_style_get_valist (GtkWidget *widget,
const gchar *first_property_name,
va_list var_args); |
gtk_widget_get_accessible ()
gtk_widget_child_focus ()
This function is used by custom widget implementations; if you're
writing an app, you'd use gtk_widget_grab_focus() to move the focus
to a particular widget, and gtk_container_set_focus_chain() to
change the focus tab order. So you may want to investigate those
functions instead.
gtk_widget_child_focus() is called by containers as the user moves
around the window using keyboard shortcuts. direction indicates
what kind of motion is taking place (up, down, left, right, tab
forward, tab backward). gtk_widget_child_focus() invokes the
"focus" signal on GtkWidget; widgets override the default handler
for this signal in order to implement appropriate focus behavior.
The "focus" default handler for a widget should return TRUE if
moving in direction left the focus on a focusable location inside
that widget, and FALSE if moving in direction moved the focus
outside the widget. If returning TRUE, widgets normally
call gtk_widget_grab_focus() to place the focus accordingly;
if returning FALSE, they don't modify the current focus location.
This function replaces gtk_container_focus() from GTK+ 1.2. It was
necessary to check that the child was visible, sensitive, and
focusable before calling
gtk_container_focus(). gtk_widget_child_focus() returns FALSE if
the widget is not currently in a focusable state, so there's no
need for those checks.
gtk_widget_child_notify ()
void gtk_widget_child_notify (GtkWidget *widget,
const gchar *child_property); |
gtk_widget_freeze_child_notify ()
void gtk_widget_freeze_child_notify (GtkWidget *widget); |
gtk_widget_get_child_visible ()
Gets the value set with gtk_widget_set_child_visible().
If you feel a need to use this function, your code probably
needs reorganization.
This function is only useful for container implementations and
never should be called by an application.
gtk_widget_get_parent ()
Returns the parent container of widget.
gtk_widget_get_settings ()
Get the settings object holding the settings (global property
settings, RC file information, etc) used for this widget.
gtk_widget_get_size_request ()
Gets the size request that was explicitly set for the widget using
gtk_widget_set_size_request(). A value of -1 stored in width or
height indicates that that dimension has not been set explicitly
and the natural requisition of the widget will be used intead. See
gtk_widget_set_size_request(). To get the size a widget will
actually use, call gtk_widget_size_request() instead of
this function.
gtk_widget_pop_visual()
#define gtk_widget_pop_visual() ((void) 0) |
Warning |
gtk_widget_pop_visual is deprecated and should not be used in newly-written code. |
gtk_widget_push_visual()
#define gtk_widget_push_visual(visual) ((void) 0) |
Warning |
gtk_widget_push_visual is deprecated and should not be used in newly-written code. |
gtk_widget_set_child_visible ()
Sets whether widget should be mapped along with its when its parent
is mapped and widget has been shown with gtk_widget_show().
The child visibility can be set for widget before it is added to
a container with gtk_widget_set_parent(), to avoid mapping
children unnecessary before immediately unmapping them. However
it will be reset to its default state of TRUE when the widget
is removed from a container.
Note that changing the child visibility of a widget does not
queue a resize on the widget. Most of the time, the size of
a widget is computed from all visible children, whether or
not they are mapped. If this is not the case, the container
can queue a resize itself.
This function is only useful for container implementations and
never should be called by an application.
gtk_widget_set_default_visual()
#define gtk_widget_set_default_visual(visual) ((void) 0) |
Warning |
gtk_widget_set_default_visual is deprecated and should not be used in newly-written code. |
gtk_widget_set_size_request ()
Sets the minimum size of a widget; that is, the widget's size
request will be width by height. You can use this function to
force a widget to be either larger or smaller than it normally
would be.
In most cases, gtk_window_set_default_size() is a better choice for
toplevel windows than this function; setting the default size will
still allow users to shrink the window. Setting the size request
will force them to leave the window at least as large as the size
request. When dealing with window sizes,
gtk_window_set_geometry_hints() can be a useful function as well.
Note the inherent danger of setting any fixed size - themes,
translations into other languages, different fonts, and user action
can all change the appropriate size for a given widget. So, it's
basically impossible to hardcode a size that will always be
correct.
The size request of a widget is the smallest size a widget can
accept while still functioning well and drawing itself correctly.
However in some strange cases a widget may be allocated less than
its requested size, and in many cases a widget may be allocated more
space than it requested.
If the size request in a given direction is -1 (unset), then
the "natural" size request of the widget will be used instead.
Widgets can't actually be allocated a size less than 1 by 1, but
you can pass 0,0 to this function to mean "as small as possible."
gtk_widget_set_visual()
#define gtk_widget_set_visual(widget,visual) ((void) 0) |
Warning |
gtk_widget_set_visual is deprecated and should not be used in newly-written code. |
gtk_widget_thaw_child_notify ()
void gtk_widget_thaw_child_notify (GtkWidget *widget); |