*
* GtkWidget is the base class all widgets in GTK+ derive from. It manages the
* widget lifecycle, states and style.
+ *
* <refsect2 id="style-properties">
* <para>
* <structname>GtkWidget</structname> introduces <firstterm>style
"to widget->requisition. gtk_widget_set_usize() may not work properly.");
#endif /* G_ENABLE_DEBUG */
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), requisition, NULL);
+ gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
}
/**
gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition)
{
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), requisition, NULL);
+ gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
}
static gboolean
{
GtkWidget *ancestor;
GdkWindow *window;
+ GList *dest_list = NULL;
g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
window = src_widget->window;
while (window != ancestor->window)
{
- gint dx, dy;
-
- gdk_window_get_position (window, &dx, &dy);
-
- src_x += dx;
- src_y += dy;
-
- window = gdk_window_get_parent (window);
+ gdouble dx, dy;
+
+ gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
+
+ src_x = dx;
+ src_y = dy;
+
+ window = gdk_window_get_effective_parent (window);
if (!window) /* Handle GtkHandleBox */
return FALSE;
window = dest_widget->window;
while (window != ancestor->window)
{
- gint dx, dy;
-
- gdk_window_get_position (window, &dx, &dy);
-
- src_x -= dx;
- src_y -= dy;
-
- window = gdk_window_get_parent (window);
-
+ dest_list = g_list_prepend (dest_list, window);
+
+ window = gdk_window_get_effective_parent (window);
+
if (!window) /* Handle GtkHandleBox */
- return FALSE;
+ {
+ g_list_free (dest_list);
+ return FALSE;
+ }
+ }
+
+ while (dest_list)
+ {
+ gdouble dx, dy;
+
+ gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
+
+ src_x = dx;
+ src_y = dy;
+
+ dest_list = g_list_remove (dest_list, dest_list->data);
}
/* Translate from window relative to allocation relative */
return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
}
+void
+_gtk_widget_set_has_default (GtkWidget *widget,
+ gboolean has_default)
+{
+ if (has_default)
+ GTK_OBJECT_FLAGS (widget) |= GTK_HAS_DEFAULT;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_DEFAULT);
+}
+
/**
* gtk_widget_grab_default:
* @widget: a #GtkWidget
return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_GRAB) != 0;
}
+void
+_gtk_widget_set_has_grab (GtkWidget *widget,
+ gboolean has_grab)
+{
+ if (has_grab)
+ GTK_OBJECT_FLAGS (widget) |= GTK_HAS_GRAB;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_GRAB);
+}
+
/**
* gtk_widget_set_name:
* @widget: a #GtkWidget
return (GTK_OBJECT_FLAGS (widget) & GTK_TOPLEVEL) != 0;
}
+void
+_gtk_widget_set_is_toplevel (GtkWidget *widget,
+ gboolean is_toplevel)
+{
+ if (is_toplevel)
+ GTK_OBJECT_FLAGS (widget) |= GTK_TOPLEVEL;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_TOPLEVEL);
+}
+
/**
* gtk_widget_is_drawable:
* @widget: a #GtkWidget
gtk_widget_modify_style (widget, rc_style);
}
+/**
+ * gtk_widget_modify_symbolic_color:
+ * @widget: a #GtkWidget
+ * @name: the name of the symbolic color to modify
+ * @color: (allow-none): the color to assign (does not need to be allocated),
+ * or %NULL to undo the effect of previous calls to
+ * of gtk_widget_modify_symbolic_color().
+ *
+ * Sets a symbolic color for a widget.
+ * All other style values are left untouched. See also
+ * gtk_widget_modify_style().
+ *
+ * Since: 2.22
+ **/
+void
+gtk_widget_modify_symbolic_color (GtkWidget *widget,
+ const gchar *name,
+ const GdkColor *color)
+{
+ GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
+
+ _gtk_rc_style_set_symbolic_color (rc_style, name, color);
+
+ gtk_widget_modify_style (widget, rc_style);
+}
+
/**
* gtk_widget_modify_fg:
* @widget: a #GtkWidget
while (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_parent (from_ancestor);
+ from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == NULL)
break;
from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
while (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_parent (to_ancestor);
+ to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == NULL)
break;
to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
{
if (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_parent (from_ancestor);
+ from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == to_window)
break;
if (from_ancestor)
}
if (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_parent (to_ancestor);
+ to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == from_window)
break;
if (to_ancestor)
return widget->window;
}
+static void
+_gtk_widget_set_has_focus (GtkWidget *widget,
+ gboolean has_focus)
+{
+ if (has_focus)
+ GTK_OBJECT_FLAGS (widget) |= GTK_HAS_FOCUS;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_FOCUS);
+}
+
+/**
+ * gtk_widget_send_focus_change:
+ * @widget: a #GtkWidget
+ * @event: a #GdkEvent of type GDK_FOCUS_CHANGE
+ *
+ * Sends the focus change @event to @widget
+ *
+ * This function is not meant to be used by applications. The only time it
+ * should be used is when it is necessary for a #GtkWidget to assign focus
+ * to a widget that is semantically owned by the first widget even though
+ * it's not a direct child - for instance, a search entry in a floating
+ * window similar to the quick search in #GtkTreeView.
+ *
+ * An example of its usage is:
+ *
+ * |[
+ * GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+ *
+ * fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ * fevent->focus_change.in = TRUE;
+ * fevent->focus_change.window = gtk_widget_get_window (widget);
+ * if (fevent->focus_change.window != NULL)
+ * g_object_ref (fevent->focus_change.window);
+ *
+ * gtk_widget_send_focus_change (widget, fevent);
+ *
+ * gdk_event_free (event);
+ * ]|
+ *
+ * Return value: the return value from the event signal emission: %TRUE
+ * if the event was handled, and %FALSE otherwise
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_send_focus_change (GtkWidget *widget,
+ GdkEvent *event)
+{
+ gboolean res;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
+
+ g_object_ref (widget);
+
+ _gtk_widget_set_has_focus (widget, event->focus_change.in);
+
+ res = gtk_widget_event (widget, event);
+
+ g_object_notify (G_OBJECT (widget), "has-focus");
+
+ g_object_unref (widget);
+
+ return res;
+}
+
#define __GTK_WIDGET_C__
#include "gtkaliasdef.c"