/* GtkCellAreaContextClass */ staticvoid _gtk_cell_area_box_context_reset (GtkCellAreaContext *context); staticvoid _gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *context, int width, int *minimum_height, int *natural_height); staticvoid _gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *context, int height, int *minimum_width, int *natural_width);
/* Internal functions */ staticvoid _gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
GtkOrientation orientation, int for_size, int *minimum_size, int *natural_size); staticvoid free_cache_array (GArray *array); static GArray *group_array_new (GtkCellAreaBoxContext *context); static GArray *get_array (GtkCellAreaBoxContext *context,
GtkOrientation orientation, int for_size); static gboolean group_expands (GtkCellAreaBoxContext *context, int group_idx); staticint count_expand_groups (GtkCellAreaBoxContext *context);
/* CachedSize management */ typedefstruct { int min_size; int nat_size;
} CachedSize;
struct _GtkCellAreaBoxContextPrivate
{ /* Table of per renderer CachedSizes */
GArray *base_widths;
GArray *base_heights;
/* Table of per height/width hash tables of per renderer CachedSizes */
GHashTable *widths;
GHashTable *heights;
/* Whether each group expands */
gboolean *expand;
/* Whether each group is aligned */
gboolean *align;
};
/* Get the last visible aligned group
* (we need to get space at least up till this group) */ for (i = array->len - 1; i >= 0; i--)
{ if (priv->align[i] &&
_gtk_cell_area_box_group_visible (area, i)) break;
}
last_aligned_group_idx = i >= 0 ? i : 0;
for (i = 0; i < array->len; i++)
{
CachedSize *size = &g_array_index (array, CachedSize, i);
if (box_orientation == orientation)
{ if (i > last_aligned_group_idx &&
!_gtk_cell_area_box_group_visible (area, i)) continue;
/* Dont add spacing for 0 size groups, they can be 0 size because *theycontainonlyinvisiblecellsforthisroundofrequests
*/ if (min_size > 0 && size->nat_size > 0)
{
min_size += spacing;
nat_size += spacing;
}
/* When the group dimensions change, all info must be reset *Notethisalreadyclearsthemin/natvaluesontheCachedSizes
*/
gtk_cell_area_context_reset (GTK_CELL_AREA_CONTEXT (box_context));
if (grew)
_gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_HORIZONTAL, -1, NULL, NULL);
}
void
_gtk_cell_area_box_context_push_group_height_for_width (GtkCellAreaBoxContext *box_context, int group_idx, int for_width, int minimum_height, int natural_height)
{
GtkCellAreaBoxContextPrivate *priv;
GArray *group_array;
CachedSize *size;
if (grew)
_gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_VERTICAL, -1, NULL, NULL);
}
void
_gtk_cell_area_box_context_push_group_width_for_height (GtkCellAreaBoxContext *box_context, int group_idx, int for_height, int minimum_width, int natural_width)
{
GtkCellAreaBoxContextPrivate *priv;
GArray *group_array;
CachedSize *size;
size = &g_array_index (group_array, CachedSize, group_idx);
size->min_size = MAX (size->min_size, minimum_width);
size->nat_size = MAX (size->nat_size, natural_width);
}
void
_gtk_cell_area_box_context_get_group_width (GtkCellAreaBoxContext *box_context, int group_idx, int *minimum_width, int *natural_width)
{
GtkCellAreaBoxContextPrivate *priv;
CachedSize *size;
if (minimum_width)
*minimum_width = size->min_size;
if (natural_width)
*natural_width = size->nat_size;
}
void
_gtk_cell_area_box_context_get_group_height_for_width (GtkCellAreaBoxContext *box_context, int group_idx, int for_width, int *minimum_height, int *natural_height)
{
GtkCellAreaBoxContextPrivate *priv;
GArray *group_array;
if (group_array)
{
CachedSize *size = &g_array_index (group_array, CachedSize, group_idx);
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_box_context_get_group_height (GtkCellAreaBoxContext *box_context, int group_idx, int *minimum_height, int *natural_height)
{
GtkCellAreaBoxContextPrivate *priv;
CachedSize *size;
if (minimum_height)
*minimum_height = size->min_size;
if (natural_height)
*natural_height = size->nat_size;
}
void
_gtk_cell_area_box_context_get_group_width_for_height (GtkCellAreaBoxContext *box_context, int group_idx, int for_height, int *minimum_width, int *natural_width)
{
GtkCellAreaBoxContextPrivate *priv;
GArray *group_array;
if (group_array)
{
CachedSize *size = &g_array_index (group_array, CachedSize, group_idx);
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;
}
}
static GtkRequestedSize *
_gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
GtkCellAreaBox *area,
GtkOrientation orientation, int for_size, int *n_requests)
{
GtkCellAreaBoxContextPrivate *priv = box_context->priv;
GtkRequestedSize *requests;
GArray *array;
CachedSize *size; int visible_groups = 0; int last_aligned_group_idx = 0; int i, j;
/* Get the last visible aligned group
* (we need to get space at least up till this group) */ for (i = priv->base_widths->len - 1; i >= 0; i--)
{ if (priv->align[i] &&
_gtk_cell_area_box_group_visible (area, i)) break;
}
last_aligned_group_idx = i >= 0 ? i : 0;
static GtkCellAreaBoxAllocation *
allocate_for_orientation (GtkCellAreaBoxContext *context,
GtkCellAreaBox *area,
GtkOrientation orientation, int spacing, int size, int for_size, int *n_allocs)
{
GtkCellAreaBoxContextPrivate *priv = context->priv;
GtkCellAreaBoxAllocation *allocs;
GtkRequestedSize *sizes; int n_expand_groups = 0; int i, n_groups, position, vis_position; int extra_size, extra_extra; int avail_size = size;
/* 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;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.