[gtk+/rendering-cleanup-next: 3/155] API: Add API to query width and height when rendering



commit c59fb83340a68d67d2d1004841c8af4f4744e2f0
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 14 11:39:51 2010 +0200

    API: Add API to query width and height when rendering
    
    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 |    2 +
 gtk/gtk.symbols                      |    2 +
 gtk/gtkwidget.c                      |   36 ++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h                      |    3 ++
 4 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index aff34e8..22fecd4 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -4897,6 +4897,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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 28e3ee1..06aa794 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index cf19af1..eeabc5c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11729,6 +11729,42 @@ gtk_widget_set_allocation (GtkWidget           *widget,
 }
 
 /**
+ * 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
  * @requisition: (out): a pointer to a #GtkRequisition to copy to
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 566a7cc..d17607e 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -671,6 +671,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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]