- (gtk_cell_area_box_context_parent_class)->reset (context);
-}
-
-static GtkRequestedSize *
-gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
- GtkOrientation orientation,
- gint for_size,
- gint *n_requests)
-{
- GtkCellAreaBoxContextPrivate *priv;
- GtkRequestedSize *requests;
- GArray *array;
- CachedSize *size;
- gint visible_groups = 0;
- gint i, j;
-
- g_return_val_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (box_context), NULL);
-
- priv = box_context->priv;
- array = get_array (box_context, orientation, for_size);
-
- for (i = 0; i < array->len; i++)
- {
- size = &g_array_index (array, CachedSize, i);
-
- if (size->nat_size > 0)
- visible_groups++;
- }
-
- requests = g_new (GtkRequestedSize, visible_groups);
-
- for (j = 0, i = 0; i < array->len; i++)
- {
- size = &g_array_index (array, CachedSize, i);
-
- if (size->nat_size > 0)
- {
- requests[j].data = GINT_TO_POINTER (i);
- requests[j].minimum_size = size->min_size;
- requests[j].natural_size = size->nat_size;
- j++;
- }
- }
-
- if (n_requests)
- *n_requests = visible_groups;
-
- return requests;
-}
-
-static GtkCellAreaBoxAllocation *
-allocate_for_orientation (GtkCellAreaBoxContext *context,
- GtkOrientation orientation,
- gint spacing,
- gint size,
- gint for_size,
- gint *n_allocs)
-{
- GtkCellAreaBoxAllocation *allocs;
- GtkRequestedSize *sizes;
- GArray *array;
- gint n_expand_groups = 0;
- gint i, n_groups, position;
- gint extra_size, extra_extra;
- gint avail_size = size;
-
- sizes = gtk_cell_area_box_context_get_requests (context, orientation, for_size, &n_groups);
- array = get_array (context, orientation, for_size);
- n_expand_groups = count_expand_groups (context);
-
- /* First start by naturally allocating space among groups */
- avail_size -= (n_groups - 1) * spacing;
- for (i = 0; i < n_groups; i++)
- avail_size -= sizes[i].minimum_size;
-
- if (avail_size > 0)
- avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, sizes);
- else
- avail_size = 0;
-
- /* Calculate/distribute expand for groups */
- if (n_expand_groups > 0)
- {
- extra_size = avail_size / n_expand_groups;
- extra_extra = avail_size % n_expand_groups;
- }
- else
- extra_size = extra_extra = 0;
-
- allocs = g_new (GtkCellAreaBoxAllocation, n_groups);
-
- for (position = 0, i = 0; i < n_groups; i++)
- {
- allocs[i].group_idx = GPOINTER_TO_INT (sizes[i].data);
- allocs[i].position = position;
- allocs[i].size = sizes[i].minimum_size;
-
- if (group_expands (context, allocs[i].group_idx))
- {
- allocs[i].size += extra_size;
- if (extra_extra)
- {
- allocs[i].size++;
- extra_extra--;
- }
- }
-
- position += allocs[i].size;
- position += spacing;
- }
-
- if (n_allocs)
- *n_allocs = n_groups;
-
- g_free (sizes);
-
- return allocs;
-}
-
-static void
-gtk_cell_area_box_context_allocate (GtkCellAreaContext *context,
- gint width,
- gint height)
-{
- GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
- GtkCellAreaBoxContextPrivate *priv = box_context->priv;
- GtkCellArea *area;
- GtkOrientation orientation;
- gint spacing;
-
- area = gtk_cell_area_context_get_area (context);
- orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
- spacing = gtk_cell_area_box_get_spacing (GTK_CELL_AREA_BOX (area));
-
- g_free (priv->orientation_allocs);
- priv->orientation_allocs = NULL;
- priv->n_orientation_allocs = 0;
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL && width > 0)
- priv->orientation_allocs = allocate_for_orientation (box_context, orientation,
- spacing, width, height,
- &priv->n_orientation_allocs);
- else if (orientation == GTK_ORIENTATION_VERTICAL && height > 0)
- priv->orientation_allocs = allocate_for_orientation (box_context, orientation,
- spacing, height, width,
- &priv->n_orientation_allocs);
-
- GTK_CELL_AREA_CONTEXT_CLASS (gtk_cell_area_box_context_parent_class)->allocate (context, width, height);