[gtk+/treeview-refactor] Added the majority of the allocate machinery to GtkCellAreaIter[Box].
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] Added the majority of the allocate machinery to GtkCellAreaIter[Box].
- Date: Sat, 30 Oct 2010 14:02:50 +0000 (UTC)
commit ea6df20bbb3d17f2632bfb424816c7386b7217dd
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Oct 30 23:06:26 2010 +0900
Added the majority of the allocate machinery to GtkCellAreaIter[Box].
gtk/gtkcellareabox.c | 13 ++
gtk/gtkcellareabox.h | 2 +-
gtk/gtkcellareaboxiter.c | 191 ++++++++++++++++++++++++--------
gtk/gtkcellareaboxiter.h | 16 +++
gtk/gtkcellareaiter.c | 276 +++++++++++++++++++++++++++++++---------------
gtk/gtkcellareaiter.h | 57 +++++++---
6 files changed, 400 insertions(+), 155 deletions(-)
---
diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c
index 80b271e..becab50 100644
--- a/gtk/gtkcellareabox.c
+++ b/gtk/gtkcellareabox.c
@@ -410,6 +410,19 @@ flush_iters (GtkCellAreaBox *box)
}
}
+
+/* XXX This guy makes an allocation to be stored and retrieved from the iter */
+GtkCellAreaBoxAllocation *
+gtk_cell_area_box_allocate (GtkCellAreaBox *box,
+ GtkCellAreaBoxIter *iter,
+ gint size,
+ gint *n_allocs)
+{
+
+
+}
+
+
/*************************************************************
* GObjectClass *
*************************************************************/
diff --git a/gtk/gtkcellareabox.h b/gtk/gtkcellareabox.h
index 0a0c052..caba7cd 100644
--- a/gtk/gtkcellareabox.h
+++ b/gtk/gtkcellareabox.h
@@ -54,7 +54,6 @@ struct _GtkCellAreaBoxClass
{
GtkCellAreaClass parent_class;
-
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
@@ -77,6 +76,7 @@ gint gtk_cell_area_box_get_spacing (GtkCellAreaBox *box);
void gtk_cell_area_box_set_spacing (GtkCellAreaBox *box,
gint spacing);
+
G_END_DECLS
#endif /* __GTK_CELL_AREA_BOX_H__ */
diff --git a/gtk/gtkcellareaboxiter.c b/gtk/gtkcellareaboxiter.c
index 9f3474d..779315c 100644
--- a/gtk/gtkcellareaboxiter.c
+++ b/gtk/gtkcellareaboxiter.c
@@ -25,24 +25,32 @@
#include "gtkintl.h"
#include "gtkcellareabox.h"
#include "gtkcellareaboxiter.h"
+#include "gtkorientable.h"
/* GObjectClass */
static void gtk_cell_area_box_iter_finalize (GObject *object);
/* GtkCellAreaIterClass */
+static void gtk_cell_area_box_iter_flush_preferred_width (GtkCellAreaIter *iter);
+static void gtk_cell_area_box_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint width);
+static void gtk_cell_area_box_iter_flush_preferred_height (GtkCellAreaIter *iter);
+static void gtk_cell_area_box_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint height);
+static void gtk_cell_area_box_iter_flush_allocation (GtkCellAreaIter *iter);
static void gtk_cell_area_box_iter_sum_preferred_width (GtkCellAreaIter *iter);
static void gtk_cell_area_box_iter_sum_preferred_height_for_width (GtkCellAreaIter *iter,
gint width);
static void gtk_cell_area_box_iter_sum_preferred_height (GtkCellAreaIter *iter);
static void gtk_cell_area_box_iter_sum_preferred_width_for_height (GtkCellAreaIter *iter,
gint height);
-static void gtk_cell_area_box_iter_flush_preferred_width (GtkCellAreaIter *iter);
-static void gtk_cell_area_box_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
+static void gtk_cell_area_box_iter_allocate_width (GtkCellAreaIter *iter,
gint width);
-static void gtk_cell_area_box_iter_flush_preferred_height (GtkCellAreaIter *iter);
-static void gtk_cell_area_box_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
+static void gtk_cell_area_box_iter_allocate_height (GtkCellAreaIter *iter,
gint height);
+
+
/* CachedSize management */
typedef struct {
gint min_size;
@@ -61,6 +69,12 @@ struct _GtkCellAreaBoxIterPrivate
/* Table of per height/width hash tables of per renderer CachedSizes */
GHashTable *widths;
GHashTable *heights;
+
+ /* Allocation info for this iter if any */
+ gint alloc_width;
+ gint alloc_height;
+ gint n_orientation_allocs;
+ GtkCellAreaBoxAllocation *orientation_allocs;
};
G_DEFINE_TYPE (GtkCellAreaBoxIter, gtk_cell_area_box_iter, GTK_TYPE_CELL_AREA_ITER);
@@ -84,6 +98,11 @@ gtk_cell_area_box_iter_init (GtkCellAreaBoxIter *box_iter)
NULL, (GDestroyNotify)g_hash_table_destroy);
priv->heights = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify)g_hash_table_destroy);
+
+ priv->alloc_width = 0;
+ priv->alloc_height = 0;
+ priv->orientation_allocs = NULL;
+ priv->n_orientation_allocs = 0;
}
static void
@@ -95,15 +114,19 @@ gtk_cell_area_box_iter_class_init (GtkCellAreaBoxIterClass *class)
/* GObjectClass */
object_class->finalize = gtk_cell_area_box_iter_finalize;
+ iter_class->flush_preferred_width = gtk_cell_area_box_iter_flush_preferred_width;
+ iter_class->flush_preferred_height_for_width = gtk_cell_area_box_iter_flush_preferred_height_for_width;
+ iter_class->flush_preferred_height = gtk_cell_area_box_iter_flush_preferred_height;
+ iter_class->flush_preferred_width_for_height = gtk_cell_area_box_iter_flush_preferred_width_for_height;
+ iter_class->flush_allocation = gtk_cell_area_box_iter_flush_allocation;
+
iter_class->sum_preferred_width = gtk_cell_area_box_iter_sum_preferred_width;
iter_class->sum_preferred_height_for_width = gtk_cell_area_box_iter_sum_preferred_height_for_width;
iter_class->sum_preferred_height = gtk_cell_area_box_iter_sum_preferred_height;
iter_class->sum_preferred_width_for_height = gtk_cell_area_box_iter_sum_preferred_width_for_height;
- iter_class->flush_preferred_width = gtk_cell_area_box_iter_flush_preferred_width;
- iter_class->flush_preferred_height_for_width = gtk_cell_area_box_iter_flush_preferred_height_for_width;
- iter_class->flush_preferred_height = gtk_cell_area_box_iter_flush_preferred_height;
- iter_class->flush_preferred_width_for_height = gtk_cell_area_box_iter_flush_preferred_width_for_height;
+ iter_class->allocate_width = gtk_cell_area_box_iter_allocate_width;
+ iter_class->allocate_height = gtk_cell_area_box_iter_allocate_height;
g_type_class_add_private (object_class, sizeof (GtkCellAreaBoxIterPrivate));
}
@@ -143,12 +166,83 @@ gtk_cell_area_box_iter_finalize (GObject *object)
g_hash_table_destroy (priv->widths);
g_hash_table_destroy (priv->heights);
+ g_free (priv->orientation_allocs);
+
G_OBJECT_CLASS (gtk_cell_area_box_iter_parent_class)->finalize (object);
}
/*************************************************************
* GtkCellAreaIterClass *
*************************************************************/
+static void
+gtk_cell_area_box_iter_flush_preferred_width (GtkCellAreaIter *iter)
+{
+ GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
+ GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+
+ g_hash_table_remove_all (priv->base_widths);
+
+ GTK_CELL_AREA_ITER_GET_CLASS
+ (gtk_cell_area_box_iter_parent_class)->flush_preferred_width (iter);
+}
+
+static void
+gtk_cell_area_box_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint width)
+{
+ GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
+ GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+
+ /* Flush all sizes for special -1 value */
+ if (width < 0)
+ g_hash_table_remove_all (priv->heights);
+ else
+ g_hash_table_remove (priv->heights, GINT_TO_POINTER (width));
+
+ GTK_CELL_AREA_ITER_GET_CLASS
+ (gtk_cell_area_box_iter_parent_class)->flush_preferred_height_for_width (iter, width);
+}
+
+static void
+gtk_cell_area_box_iter_flush_preferred_height (GtkCellAreaIter *iter)
+{
+ GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
+ GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+
+ g_hash_table_remove_all (priv->base_heights);
+
+ GTK_CELL_AREA_ITER_GET_CLASS
+ (gtk_cell_area_box_iter_parent_class)->flush_preferred_height (iter);
+}
+
+static void
+gtk_cell_area_box_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint height)
+{
+ GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
+ GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+
+ /* Flush all sizes for special -1 value */
+ if (height < 0)
+ g_hash_table_remove_all (priv->widths);
+ else
+ g_hash_table_remove (priv->widths, GINT_TO_POINTER (height));
+
+ GTK_CELL_AREA_ITER_GET_CLASS
+ (gtk_cell_area_box_iter_parent_class)->flush_preferred_width_for_height (iter, height);
+}
+
+static void
+gtk_cell_area_box_iter_flush_allocation (GtkCellAreaIter *iter)
+{
+ GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
+ GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+
+ g_free (priv->orientation_allocs);
+ priv->orientation_allocs = NULL;
+ priv->n_orientation_allocs = 0;
+}
+
typedef struct {
gint min_size;
gint nat_size;
@@ -246,61 +340,51 @@ gtk_cell_area_box_iter_sum_preferred_width_for_height (GtkCellAreaIter *iter,
}
static void
-gtk_cell_area_box_iter_flush_preferred_width (GtkCellAreaIter *iter)
+gtk_cell_area_box_iter_allocate_width (GtkCellAreaIter *iter,
+ gint width)
{
GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
-
- g_hash_table_remove_all (priv->base_widths);
+ GtkCellArea *area;
+ GtkOrientation orientation;
- GTK_CELL_AREA_ITER_GET_CLASS
- (gtk_cell_area_box_iter_parent_class)->flush_preferred_width (iter);
-}
+ area = gtk_cell_area_iter_get_area (iter);
+ orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
-static void
-gtk_cell_area_box_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
- gint width)
-{
- GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
- GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ g_free (priv->orientation_allocs);
- /* Flush all sizes for special -1 value */
- if (width < 0)
- g_hash_table_remove_all (priv->heights);
- else
- g_hash_table_remove (priv->heights, GINT_TO_POINTER (width));
+ priv->orientation_allocs =
+ gtk_cell_area_box_allocate (GTK_CELL_AREA_BOX (area), box_iter, width,
+ &priv->n_orientation_allocs);
+ }
- GTK_CELL_AREA_ITER_GET_CLASS
- (gtk_cell_area_box_iter_parent_class)->flush_preferred_height_for_width (iter, width);
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->allocate_width (iter, width);
}
static void
-gtk_cell_area_box_iter_flush_preferred_height (GtkCellAreaIter *iter)
+gtk_cell_area_box_iter_allocate_height (GtkCellAreaIter *iter,
+ gint height)
{
GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
-
- g_hash_table_remove_all (priv->base_heights);
+ GtkCellArea *area;
+ GtkOrientation orientation;
- GTK_CELL_AREA_ITER_GET_CLASS
- (gtk_cell_area_box_iter_parent_class)->flush_preferred_height (iter);
-}
+ area = gtk_cell_area_iter_get_area (iter);
+ orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
-static void
-gtk_cell_area_box_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
- gint height)
-{
- GtkCellAreaBoxIter *box_iter = GTK_CELL_AREA_BOX_ITER (iter);
- GtkCellAreaBoxIterPrivate *priv = box_iter->priv;
+ if (orientation == GTK_ORIENTATION_VERTICAL)
+ {
+ g_free (priv->orientation_allocs);
- /* Flush all sizes for special -1 value */
- if (height < 0)
- g_hash_table_remove_all (priv->widths);
- else
- g_hash_table_remove (priv->widths, GINT_TO_POINTER (height));
+ priv->orientation_allocs =
+ gtk_cell_area_box_allocate (GTK_CELL_AREA_BOX (area), box_iter, height,
+ &priv->n_orientation_allocs);
+ }
- GTK_CELL_AREA_ITER_GET_CLASS
- (gtk_cell_area_box_iter_parent_class)->flush_preferred_width_for_height (iter, height);
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->allocate_height (iter, height);
}
/*************************************************************
@@ -622,3 +706,18 @@ gtk_cell_area_box_iter_get_heights (GtkCellAreaBoxIter *box_iter,
return heights;
}
+
+G_CONST_RETURN GtkCellAreaBoxAllocation *
+gtk_cell_area_box_iter_get_orientation_allocs (GtkCellAreaBoxIter *iter,
+ gint *n_allocs)
+{
+ GtkCellAreaBoxIterPrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_CELL_AREA_BOX_ITER (iter), NULL);
+
+ priv = iter->priv;
+
+ *n_allocs = priv->n_orientation_allocs;
+
+ return priv->orientation_allocs;
+}
diff --git a/gtk/gtkcellareaboxiter.h b/gtk/gtkcellareaboxiter.h
index ada15a7..631a67c 100644
--- a/gtk/gtkcellareaboxiter.h
+++ b/gtk/gtkcellareaboxiter.h
@@ -29,6 +29,7 @@
#define __GTK_CELL_AREA_BOX_ITER_H__
#include <gtk/gtkcellareaiter.h>
+#include <gtk/gtkcellareabox.h>
#include <gtk/gtkcellrenderer.h>
#include <gtk/gtksizerequest.h>
@@ -112,6 +113,21 @@ GtkRequestedSize *gtk_cell_area_box_iter_get_widths (GtkCellAreaBoxIter
GtkRequestedSize *gtk_cell_area_box_iter_get_heights (GtkCellAreaBoxIter *box_iter,
gint *n_heights);
+/* Private iter/area interaction */
+typedef struct {
+ gint position;
+ gint size;
+} GtkCellAreaBoxAllocation;
+
+GtkCellAreaBoxAllocation *gtk_cell_area_box_allocate (GtkCellAreaBox *box,
+ GtkCellAreaBoxIter *iter,
+ gint size,
+ gint *n_allocs);
+
+G_CONST_RETURN GtkCellAreaBoxAllocation *
+gtk_cell_area_box_iter_get_orientation_allocs (GtkCellAreaBoxIter *iter,
+ gint *n_allocs);
+
G_END_DECLS
#endif /* __GTK_CELL_AREA_BOX_ITER_H__ */
diff --git a/gtk/gtkcellareaiter.c b/gtk/gtkcellareaiter.c
index 4b31364..8ec1b35 100644
--- a/gtk/gtkcellareaiter.c
+++ b/gtk/gtkcellareaiter.c
@@ -46,6 +46,11 @@ static void gtk_cell_area_iter_real_flush_preferred_height_for_width (GtkCe
static void gtk_cell_area_iter_real_flush_preferred_height (GtkCellAreaIter *iter);
static void gtk_cell_area_iter_real_flush_preferred_width_for_height (GtkCellAreaIter *iter,
gint height);
+static void gtk_cell_area_iter_real_flush_allocation (GtkCellAreaIter *iter);
+static void gtk_cell_area_iter_real_allocate_width (GtkCellAreaIter *iter,
+ gint width);
+static void gtk_cell_area_iter_real_allocate_height (GtkCellAreaIter *iter,
+ gint height);
/* CachedSize management */
typedef struct {
@@ -64,6 +69,8 @@ struct _GtkCellAreaIterPrivate
gint nat_width;
gint min_height;
gint nat_height;
+ gint alloc_width;
+ gint alloc_height;
GHashTable *widths;
GHashTable *heights;
@@ -123,6 +130,18 @@ gtk_cell_area_iter_class_init (GtkCellAreaIterClass *class)
class->flush_preferred_height_for_width = gtk_cell_area_iter_real_flush_preferred_height_for_width;
class->flush_preferred_height = gtk_cell_area_iter_real_flush_preferred_height;
class->flush_preferred_width_for_height = gtk_cell_area_iter_real_flush_preferred_width_for_height;
+ class->flush_allocation = gtk_cell_area_iter_real_flush_allocation;
+
+ class->allocate_width = gtk_cell_area_iter_real_allocate_width;
+ class->allocate_height = gtk_cell_area_iter_real_allocate_height;
+
+ class->sum_preferred_width = NULL;
+ class->sum_preferred_height_for_width = NULL;
+ class->sum_preferred_height = NULL;
+ class->sum_preferred_width_for_height = NULL;
+
+ class->allocate_width = NULL;
+ class->allocate_height = NULL;
cell_area_iter_signals[SIGNAL_HEIGHT_CHANGED] =
g_signal_new (I_("height-changed"),
@@ -400,6 +419,34 @@ gtk_cell_area_iter_real_flush_preferred_width_for_height (GtkCellAreaIter *iter,
}
}
+static void
+gtk_cell_area_iter_real_flush_allocation (GtkCellAreaIter *iter)
+{
+ GtkCellAreaIterPrivate *priv = iter->priv;
+
+ priv->alloc_width = 0;
+ priv->alloc_height = 0;
+}
+
+static void
+gtk_cell_area_iter_real_allocate_width (GtkCellAreaIter *iter,
+ gint width)
+{
+ GtkCellAreaIterPrivate *priv = iter->priv;
+
+ priv->alloc_width = width;
+}
+
+static void
+gtk_cell_area_iter_real_allocate_height (GtkCellAreaIter *iter,
+ gint height)
+{
+ GtkCellAreaIterPrivate *priv = iter->priv;
+
+ priv->alloc_height = height;
+}
+
+
/*************************************************************
* API *
*************************************************************/
@@ -416,105 +463,57 @@ gtk_cell_area_iter_get_area (GtkCellAreaIter *iter)
}
void
-gtk_cell_area_iter_get_preferred_width (GtkCellAreaIter *iter,
- gint *minimum_width,
- gint *natural_width)
+gtk_cell_area_iter_flush (GtkCellAreaIter *iter)
{
- GtkCellAreaIterPrivate *priv;
-
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- priv = iter->priv;
-
- if (minimum_width)
- *minimum_width = priv->min_width;
-
- if (natural_width)
- *natural_width = priv->nat_width;
+ gtk_cell_area_iter_flush_preferred_width (iter);
+ gtk_cell_area_iter_flush_preferred_height_for_width (iter, -1);
+ gtk_cell_area_iter_flush_preferred_height (iter);
+ gtk_cell_area_iter_flush_preferred_width_for_height (iter, -1);
+ gtk_cell_area_iter_flush_allocation (iter);
}
void
-gtk_cell_area_iter_get_preferred_height_for_width (GtkCellAreaIter *iter,
- gint for_width,
- gint *minimum_height,
- gint *natural_height)
+gtk_cell_area_iter_flush_preferred_width (GtkCellAreaIter *iter)
{
- GtkCellAreaIterPrivate *priv;
- CachedSize *size;
-
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- priv = iter->priv;
-
- size = g_hash_table_lookup (priv->heights, GINT_TO_POINTER (for_width));
-
- if (size)
- {
- if (minimum_height)
- *minimum_height = size->min_size;
-
- if (natural_height)
- *natural_height = size->nat_size;
- }
- else
- {
- if (minimum_height)
- *minimum_height = -1;
-
- if (natural_height)
- *natural_height = -1;
- }
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_width (iter);
}
void
-gtk_cell_area_iter_get_preferred_height (GtkCellAreaIter *iter,
- gint *minimum_height,
- gint *natural_height)
+gtk_cell_area_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint for_width)
{
- GtkCellAreaIterPrivate *priv;
-
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- priv = iter->priv;
-
- if (minimum_height)
- *minimum_height = priv->min_height;
-
- if (natural_height)
- *natural_height = priv->nat_height;
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_height_for_width (iter, for_width);
}
void
-gtk_cell_area_iter_get_preferred_width_for_height (GtkCellAreaIter *iter,
- gint for_height,
- gint *minimum_width,
- gint *natural_width)
+gtk_cell_area_iter_flush_preferred_height (GtkCellAreaIter *iter)
{
- GtkCellAreaIterPrivate *priv;
- CachedSize *size;
-
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- priv = iter->priv;
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_height (iter);
+}
- size = g_hash_table_lookup (priv->widths, GINT_TO_POINTER (for_height));
+void
+gtk_cell_area_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint for_height)
+{
+ g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- if (size)
- {
- if (minimum_width)
- *minimum_width = size->min_size;
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_width_for_height (iter, for_height);
+}
- if (natural_width)
- *natural_width = size->nat_size;
- }
- else
- {
- if (minimum_width)
- *minimum_width = -1;
+void
+gtk_cell_area_iter_flush_allocation (GtkCellAreaIter *iter)
+{
+ g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- if (natural_width)
- *natural_width = -1;
- }
+ GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_allocation (iter);
}
void
@@ -572,51 +571,150 @@ gtk_cell_area_iter_sum_preferred_width_for_height (GtkCellAreaIter *iter,
}
void
-gtk_cell_area_iter_flush (GtkCellAreaIter *iter)
+gtk_cell_area_iter_allocate_width (GtkCellAreaIter *iter,
+ gint width)
{
+ GtkCellAreaIterClass *class;
+
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- gtk_cell_area_iter_flush_preferred_width (iter);
- gtk_cell_area_iter_flush_preferred_height_for_width (iter, -1);
- gtk_cell_area_iter_flush_preferred_height (iter);
- gtk_cell_area_iter_flush_preferred_width_for_height (iter, -1);
+ class = GTK_CELL_AREA_ITER_GET_CLASS (iter);
+
+ class->allocate_width (iter, width);
}
void
-gtk_cell_area_iter_flush_preferred_width (GtkCellAreaIter *iter)
+gtk_cell_area_iter_allocate_height (GtkCellAreaIter *iter,
+ gint height)
{
+ GtkCellAreaIterClass *class;
+
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_width (iter);
+ class = GTK_CELL_AREA_ITER_GET_CLASS (iter);
+
+ class->allocate_height (iter, height);
}
void
-gtk_cell_area_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
- gint for_width)
+gtk_cell_area_iter_get_preferred_width (GtkCellAreaIter *iter,
+ gint *minimum_width,
+ gint *natural_width)
{
+ GtkCellAreaIterPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_height_for_width (iter, for_width);
+ priv = iter->priv;
+
+ if (minimum_width)
+ *minimum_width = priv->min_width;
+
+ if (natural_width)
+ *natural_width = priv->nat_width;
}
void
-gtk_cell_area_iter_flush_preferred_height (GtkCellAreaIter *iter)
+gtk_cell_area_iter_get_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint for_width,
+ gint *minimum_height,
+ gint *natural_height)
{
+ GtkCellAreaIterPrivate *priv;
+ CachedSize *size;
+
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_height (iter);
+ priv = iter->priv;
+
+ size = g_hash_table_lookup (priv->heights, GINT_TO_POINTER (for_width));
+
+ if (size)
+ {
+ if (minimum_height)
+ *minimum_height = size->min_size;
+
+ if (natural_height)
+ *natural_height = size->nat_size;
+ }
+ else
+ {
+ if (minimum_height)
+ *minimum_height = -1;
+
+ if (natural_height)
+ *natural_height = -1;
+ }
}
void
-gtk_cell_area_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
- gint for_height)
+gtk_cell_area_iter_get_preferred_height (GtkCellAreaIter *iter,
+ gint *minimum_height,
+ gint *natural_height)
{
+ GtkCellAreaIterPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
- GTK_CELL_AREA_ITER_GET_CLASS (iter)->flush_preferred_width_for_height (iter, for_height);
+ priv = iter->priv;
+
+ if (minimum_height)
+ *minimum_height = priv->min_height;
+
+ if (natural_height)
+ *natural_height = priv->nat_height;
}
+void
+gtk_cell_area_iter_get_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint for_height,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GtkCellAreaIterPrivate *priv;
+ CachedSize *size;
+
+ g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
+ priv = iter->priv;
+
+ size = g_hash_table_lookup (priv->widths, GINT_TO_POINTER (for_height));
+
+ if (size)
+ {
+ if (minimum_width)
+ *minimum_width = size->min_size;
+
+ if (natural_width)
+ *natural_width = size->nat_size;
+ }
+ else
+ {
+ if (minimum_width)
+ *minimum_width = -1;
+
+ if (natural_width)
+ *natural_width = -1;
+ }
+}
+
+void
+gtk_cell_area_iter_get_allocation (GtkCellAreaIter *iter,
+ gint *width,
+ gint *height)
+{
+ GtkCellAreaIterPrivate *priv;
+
+ g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
+
+ priv = iter->priv;
+
+ if (width)
+ *width = priv->alloc_width;
+
+ if (height)
+ *height = priv->alloc_height;
+}
void
gtk_cell_area_iter_push_preferred_width (GtkCellAreaIter *iter,
diff --git a/gtk/gtkcellareaiter.h b/gtk/gtkcellareaiter.h
index b2e0e55..67746bb 100644
--- a/gtk/gtkcellareaiter.h
+++ b/gtk/gtkcellareaiter.h
@@ -53,13 +53,14 @@ struct _GtkCellAreaIterClass
{
GObjectClass parent_class;
- /* Subclasses can use this to flush their alignments */
+ /* Subclasses can use this to flush their alignments/allocations */
void (* flush_preferred_width) (GtkCellAreaIter *iter);
void (* flush_preferred_height_for_width) (GtkCellAreaIter *iter,
gint width);
void (* flush_preferred_height) (GtkCellAreaIter *iter);
void (* flush_preferred_width_for_height) (GtkCellAreaIter *iter,
gint height);
+ void (* flush_allocation) (GtkCellAreaIter *iter);
/* These must be invoked after a series of requests before consulting
* the iter values, implementors use this to push the overall
@@ -71,6 +72,13 @@ struct _GtkCellAreaIterClass
void (* sum_preferred_width_for_height) (GtkCellAreaIter *iter,
gint height);
+ /* Store an allocation value for a GtkCellArea contextual to a range of
+ * treemodel rows */
+ void (* allocate_width) (GtkCellAreaIter *iter,
+ gint width);
+ void (* allocate_height) (GtkCellAreaIter *iter,
+ gint height);
+
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
@@ -82,6 +90,32 @@ GType gtk_cell_area_iter_get_type (void) G_GNUC_C
GtkCellArea *gtk_cell_area_iter_get_area (GtkCellAreaIter *iter);
+/* Apis for GtkCellArea clients to flush the cache */
+void gtk_cell_area_iter_flush (GtkCellAreaIter *iter);
+void gtk_cell_area_iter_flush_preferred_width (GtkCellAreaIter *iter);
+void gtk_cell_area_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint for_width);
+void gtk_cell_area_iter_flush_preferred_height (GtkCellAreaIter *iter);
+void gtk_cell_area_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint for_height);
+void gtk_cell_area_iter_flush_allocation (GtkCellAreaIter *iter);
+
+/* Apis for GtkCellArea clients to sum up the results of a series of requests, this
+ * call is required to reduce the processing while calculating the size of each row */
+void gtk_cell_area_iter_sum_preferred_width (GtkCellAreaIter *iter);
+void gtk_cell_area_iter_sum_preferred_height_for_width (GtkCellAreaIter *iter,
+ gint for_width);
+void gtk_cell_area_iter_sum_preferred_height (GtkCellAreaIter *iter);
+void gtk_cell_area_iter_sum_preferred_width_for_height (GtkCellAreaIter *iter,
+ gint for_height);
+
+/* Apis to set an allocation size in one dimension or another, the subclass specific iter
+ * will store allocated positions/sizes for individual cells or groups of cells */
+void gtk_cell_area_iter_allocate_width (GtkCellAreaIter *iter,
+ gint width);
+void gtk_cell_area_iter_allocate_height (GtkCellAreaIter *iter,
+ gint height);
+
/* Apis for GtkCellArea clients to consult cached values for multiple GtkTreeModel rows */
void gtk_cell_area_iter_get_preferred_width (GtkCellAreaIter *iter,
gint *minimum_width,
@@ -97,24 +131,9 @@ void gtk_cell_area_iter_get_preferred_width_for_height (GtkCellAreaIte
gint for_height,
gint *minimum_width,
gint *natural_width);
-
-/* Apis for GtkCellArea clients to sum up the results of a series of requests, this
- * call is required to reduce the processing while calculating the size of each row */
-void gtk_cell_area_iter_sum_preferred_width (GtkCellAreaIter *iter);
-void gtk_cell_area_iter_sum_preferred_height_for_width (GtkCellAreaIter *iter,
- gint for_width);
-void gtk_cell_area_iter_sum_preferred_height (GtkCellAreaIter *iter);
-void gtk_cell_area_iter_sum_preferred_width_for_height (GtkCellAreaIter *iter,
- gint for_height);
-
-/* Apis for GtkCellArea clients to flush the cache */
-void gtk_cell_area_iter_flush (GtkCellAreaIter *iter);
-void gtk_cell_area_iter_flush_preferred_width (GtkCellAreaIter *iter);
-void gtk_cell_area_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
- gint for_width);
-void gtk_cell_area_iter_flush_preferred_height (GtkCellAreaIter *iter);
-void gtk_cell_area_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
- gint for_height);
+void gtk_cell_area_iter_get_allocation (GtkCellAreaIter *iter,
+ gint *width,
+ gint *height);
/* Apis for GtkCellArea implementations to update cached values for multiple GtkTreeModel rows */
void gtk_cell_area_iter_push_preferred_width (GtkCellAreaIter *iter,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]