[gtk+/gtk-3-0] entry: Add the ability to query frame size in two ways



commit 57fd192679adca81b043d6194ee737d0e82ced9c
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 16 21:49:01 2011 +0200

    entry: Add the ability to query frame size in two ways
    
    TRUE: relative to widget->window
    FALSE: relative to widget
    
    For now, no caller has beeen changed.

 gtk/gtkentry.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 84f7204..283d48e 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -559,6 +559,7 @@ static void         get_text_area_size                 (GtkEntry       *entry,
 							gint           *width,
 							gint           *height);
 static void         get_frame_size                     (GtkEntry       *entry,
+                                                        gboolean        relative_to_window,
 							gint           *x,
 							gint           *y,
 							gint           *width,
@@ -2846,7 +2847,7 @@ gtk_entry_realize (GtkWidget *widget)
 
   get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
 
-  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  get_frame_size (entry, TRUE, &frame_x, &frame_y, NULL, NULL);
   attributes.x += frame_x;
   attributes.y += frame_y;
 
@@ -3067,7 +3068,7 @@ place_windows (GtkEntry *entry)
   GtkAllocation secondary;
   EntryIconInfo *icon_info = NULL;
 
-  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  get_frame_size (entry, TRUE, &frame_x, &frame_y, NULL, NULL);
   get_text_area_size (entry, &x, &y, &width, &height);
   get_icon_allocations (entry, &primary, &secondary);
 
@@ -3119,7 +3120,7 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
   _gtk_entry_get_borders (entry, &xborder, &yborder);
 
   if (gtk_widget_get_realized (widget))
-    get_frame_size (entry, NULL, NULL, NULL, &frame_height);
+    get_frame_size (entry, TRUE, NULL, NULL, NULL, &frame_height);
   else
     frame_height = requisition.height;
 
@@ -3159,6 +3160,7 @@ get_text_area_size (GtkEntry *entry,
 
 static void
 get_frame_size (GtkEntry *entry,
+                gboolean  relative_to_window,
                 gint     *x,
                 gint     *y,
                 gint     *width,
@@ -3173,14 +3175,17 @@ get_frame_size (GtkEntry *entry,
   gtk_widget_get_allocation (widget, &allocation);
 
   if (x)
-    *x = allocation.x;
+    *x = relative_to_window ? allocation.x : 0;
 
   if (y)
     {
       if (priv->is_cell_renderer)
-	*y = allocation.y;
+	*y = 0;
       else
-	*y = allocation.y + (allocation.height - requisition.height) / 2;
+	*y = (allocation.height - requisition.height) / 2;
+
+      if (relative_to_window)
+        *y += allocation.y;
     }
 
   if (width)
@@ -3352,7 +3357,7 @@ gtk_entry_draw_frame (GtkWidget       *widget,
 
   cairo_save (cr);
 
-  get_frame_size (GTK_ENTRY (widget), &frame_x, &frame_y, &width, &height);
+  get_frame_size (GTK_ENTRY (widget), TRUE, &frame_x, &frame_y, &width, &height);
   gtk_widget_get_allocation (widget, &allocation);
 
   cairo_translate (cr, frame_x - allocation.x, frame_y - allocation.y);
@@ -8182,7 +8187,7 @@ gtk_entry_get_icon_at_pos (GtkEntry *entry,
 
   g_return_val_if_fail (GTK_IS_ENTRY (entry), -1);
 
-  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  get_frame_size (entry, TRUE, &frame_x, &frame_y, NULL, NULL);
   x -= frame_x;
   y -= frame_y;
 



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