]> Pileus Git - ~andy/gtk/commitdiff
API: Add API to query width and height when rendering
authorBenjamin Otte <otte@redhat.com>
Tue, 14 Sep 2010 09:39:51 +0000 (11:39 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:34 +0000 (15:11 +0200)
The functions are gtk_widget_get_allocated_width() and
gtk_widget_get_allocated_height().

They are currently identical to using width/height of
gtk_widget_get_allocation(), but are introduced for ease of use (no need
to use a custom struct) and to free people from having to think about
allocation.x and allocation.y (which is where the origin of the cairo
context in GtkWidget::draw is located).

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkwidget.c
gtk/gtkwidget.h

index 162e01bec30eeb5f8980628b04d4e3a1cd63cccc..88012ecf0c562f88ffb527a3faad4db4ed6515c5 100644 (file)
@@ -4893,6 +4893,8 @@ gtk_widget_get_has_tooltip
 gtk_widget_set_has_tooltip
 gtk_widget_trigger_tooltip_query
 gtk_widget_get_window
+gtk_widget_get_allocated_width
+gtk_widget_get_allocated_height
 gtk_widget_get_allocation
 gtk_widget_set_allocation
 gtk_widget_get_app_paintable
index 0c925536109f150d9f68c7ce869570300a100d63..cdec6cbb26bf39183fe7ec9b20d8d4bab3fa5d05 100644 (file)
@@ -4206,6 +4206,8 @@ gtk_widget_event
 gtk_widget_freeze_child_notify
 gtk_widget_get_accessible
 gtk_widget_get_allocation
+gtk_widget_get_allocated_width
+gtk_widget_get_allocated_height
 gtk_widget_get_ancestor
 gtk_widget_get_app_paintable
 #ifndef GTK_DISABLE_DEPRECATED
index 7a8fd33a08768fb3008f659a845de2beb2fa97a6..5500a84b41480ad9b69e07dfb409546270e40e4f 100644 (file)
@@ -11851,6 +11851,42 @@ gtk_widget_set_allocation (GtkWidget           *widget,
   priv->allocation = *allocation;
 }
 
+/**
+ * gtk_widget_get_allocated_width:
+ * @widget: the widget to query
+ *
+ * Returns the width that has currently been allocated to @widget.
+ * This function is intended to be used when implementing handlers
+ * for the GtkWidget::draw function.
+ *
+ * Returns: the width of the @widget
+ **/
+int
+gtk_widget_get_allocated_width (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+  return widget->priv->allocation.width;
+}
+
+/**
+ * gtk_widget_get_allocated_height:
+ * @widget: the widget to query
+ *
+ * Returns the height that has currently been allocated to @widget.
+ * This function is intended to be used when implementing handlers
+ * for the GtkWidget::draw function.
+ *
+ * Returns: the height of the @widget
+ **/
+int
+gtk_widget_get_allocated_height (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+  return widget->priv->allocation.height;
+}
+
 /**
  * gtk_widget_get_requisition:
  * @widget: a #GtkWidget
index 98480c152cd2ce7ecca4509981cc76b86e772a0b..8f4f6c3ad2b870431f629c28b7409848af349395 100644 (file)
@@ -694,6 +694,9 @@ void                  gtk_widget_set_window             (GtkWidget    *widget,
                                                          GdkWindow    *window);
 GdkWindow           * gtk_widget_get_window             (GtkWidget    *widget);
 
+int                   gtk_widget_get_allocated_width    (GtkWidget     *widget);
+int                   gtk_widget_get_allocated_height   (GtkWidget     *widget);
+
 void                  gtk_widget_get_allocation         (GtkWidget     *widget,
                                                          GtkAllocation *allocation);
 void                  gtk_widget_set_allocation         (GtkWidget     *widget,