2010-11-13 07:23:01 +00:00
|
|
|
|
/* gtkcellareacontext.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2010 Openismus GmbH
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* Tristan Van Berkom <tristanvb@openismus.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-13 07:23:01 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
2021-03-02 03:36:26 +00:00
|
|
|
|
* GtkCellAreaContext:
|
|
|
|
|
*
|
|
|
|
|
* Stores geometrical information for a series of rows in a GtkCellArea
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The `GtkCellAreaContext` object is created by a given `GtkCellArea`
|
|
|
|
|
* implementation via its `GtkCellAreaClass.create_context()` virtual
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* method and is used to store cell sizes and alignments for a series of
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* `GtkTreeModel` rows that are requested and rendered in the same context.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* `GtkCellLayout` widgets can create any number of contexts in which to
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* request and render groups of data rows. However, it’s important that the
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* same context which was used to request sizes for a given `GtkTreeModel`
|
|
|
|
|
* row also be used for the same row when calling other `GtkCellArea` APIs
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* such as gtk_cell_area_render() and gtk_cell_area_event().
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-12-18 00:14:35 +00:00
|
|
|
|
|
2010-11-13 07:23:01 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
|
#include "gtkcellareacontext.h"
|
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
|
|
/* GObjectClass */
|
2010-12-18 00:14:35 +00:00
|
|
|
|
static void gtk_cell_area_context_dispose (GObject *object);
|
|
|
|
|
static void gtk_cell_area_context_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_cell_area_context_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
/* GtkCellAreaContextClass */
|
2010-12-18 00:14:35 +00:00
|
|
|
|
static void gtk_cell_area_context_real_reset (GtkCellAreaContext *context);
|
|
|
|
|
static void gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2019-05-27 02:42:49 +00:00
|
|
|
|
typedef struct _GtkCellAreaContextPrivate GtkCellAreaContextPrivate;
|
2010-11-13 07:23:01 +00:00
|
|
|
|
struct _GtkCellAreaContextPrivate
|
|
|
|
|
{
|
|
|
|
|
GtkCellArea *cell_area;
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int min_width;
|
|
|
|
|
int nat_width;
|
|
|
|
|
int min_height;
|
|
|
|
|
int nat_height;
|
|
|
|
|
int alloc_width;
|
|
|
|
|
int alloc_height;
|
2010-11-13 07:23:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_CELL_AREA,
|
|
|
|
|
PROP_MIN_WIDTH,
|
|
|
|
|
PROP_NAT_WIDTH,
|
|
|
|
|
PROP_MIN_HEIGHT,
|
|
|
|
|
PROP_NAT_HEIGHT
|
|
|
|
|
};
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkCellAreaContext, gtk_cell_area_context, G_TYPE_OBJECT)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_cell_area_context_init (GtkCellAreaContext *context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 00:14:35 +00:00
|
|
|
|
static void
|
2010-11-13 07:23:01 +00:00
|
|
|
|
gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
|
|
/* GObjectClass */
|
|
|
|
|
object_class->dispose = gtk_cell_area_context_dispose;
|
|
|
|
|
object_class->get_property = gtk_cell_area_context_get_property;
|
|
|
|
|
object_class->set_property = gtk_cell_area_context_set_property;
|
|
|
|
|
|
|
|
|
|
/* GtkCellAreaContextClass */
|
2010-11-28 09:52:08 +00:00
|
|
|
|
class->reset = gtk_cell_area_context_real_reset;
|
|
|
|
|
class->allocate = gtk_cell_area_context_real_allocate;
|
2010-11-26 04:23:01 +00:00
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCellAreaContext:area:
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The `GtkCellArea` this context was created by
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_CELL_AREA,
|
|
|
|
|
g_param_spec_object ("area",
|
2010-12-18 00:14:35 +00:00
|
|
|
|
P_("Area"),
|
|
|
|
|
P_("The Cell Area this context was created for"),
|
|
|
|
|
GTK_TYPE_CELL_AREA,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCellAreaContext:minimum-width:
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The minimum width for the `GtkCellArea` in this context
|
|
|
|
|
* for all `GtkTreeModel` rows that this context was requested
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* for using gtk_cell_area_get_preferred_width().
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_MIN_WIDTH,
|
|
|
|
|
g_param_spec_int ("minimum-width",
|
2010-12-18 00:14:35 +00:00
|
|
|
|
P_("Minimum Width"),
|
|
|
|
|
P_("Minimum cached width"),
|
2017-11-18 13:18:11 +00:00
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCellAreaContext:natural-width:
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The natural width for the `GtkCellArea` in this context
|
|
|
|
|
* for all `GtkTreeModel` rows that this context was requested
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* for using gtk_cell_area_get_preferred_width().
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_NAT_WIDTH,
|
|
|
|
|
g_param_spec_int ("natural-width",
|
2010-12-18 00:14:35 +00:00
|
|
|
|
P_("Minimum Width"),
|
|
|
|
|
P_("Minimum cached width"),
|
2017-11-18 13:18:11 +00:00
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCellAreaContext:minimum-height:
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The minimum height for the `GtkCellArea` in this context
|
|
|
|
|
* for all `GtkTreeModel` rows that this context was requested
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* for using gtk_cell_area_get_preferred_height().
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_MIN_HEIGHT,
|
|
|
|
|
g_param_spec_int ("minimum-height",
|
2010-12-18 00:14:35 +00:00
|
|
|
|
P_("Minimum Height"),
|
|
|
|
|
P_("Minimum cached height"),
|
2017-11-18 13:18:11 +00:00
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCellAreaContext:natural-height:
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* The natural height for the `GtkCellArea` in this context
|
|
|
|
|
* for all `GtkTreeModel` rows that this context was requested
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* for using gtk_cell_area_get_preferred_height().
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_NAT_HEIGHT,
|
|
|
|
|
g_param_spec_int ("natural-height",
|
2010-12-18 00:14:35 +00:00
|
|
|
|
P_("Minimum Height"),
|
|
|
|
|
P_("Minimum cached height"),
|
2017-11-18 13:18:11 +00:00
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2010-11-13 07:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
|
* GObjectClass *
|
|
|
|
|
*************************************************************/
|
|
|
|
|
static void
|
|
|
|
|
gtk_cell_area_context_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkCellAreaContext *context = GTK_CELL_AREA_CONTEXT (object);
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
if (priv->cell_area)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (priv->cell_area);
|
|
|
|
|
|
|
|
|
|
priv->cell_area = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_cell_area_context_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_cell_area_context_set_property (GObject *object,
|
2010-12-18 00:14:35 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCellAreaContext *context = GTK_CELL_AREA_CONTEXT (object);
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_CELL_AREA:
|
|
|
|
|
priv->cell_area = g_value_dup_object (value);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_cell_area_context_get_property (GObject *object,
|
2010-12-18 00:14:35 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCellAreaContext *context = GTK_CELL_AREA_CONTEXT (object);
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_CELL_AREA:
|
|
|
|
|
g_value_set_object (value, priv->cell_area);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MIN_WIDTH:
|
|
|
|
|
g_value_set_int (value, priv->min_width);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_NAT_WIDTH:
|
|
|
|
|
g_value_set_int (value, priv->nat_width);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MIN_HEIGHT:
|
|
|
|
|
g_value_set_int (value, priv->min_height);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_NAT_HEIGHT:
|
|
|
|
|
g_value_set_int (value, priv->nat_height);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* GtkCellAreaContextClass *
|
2010-11-13 07:23:01 +00:00
|
|
|
|
*************************************************************/
|
|
|
|
|
static void
|
2010-11-27 07:05:14 +00:00
|
|
|
|
gtk_cell_area_context_real_reset (GtkCellAreaContext *context)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-12-18 00:14:35 +00:00
|
|
|
|
|
2010-12-12 07:42:37 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (context));
|
|
|
|
|
|
2011-06-26 20:52:14 +00:00
|
|
|
|
if (priv->min_width != 0)
|
2010-12-12 07:42:37 +00:00
|
|
|
|
{
|
2011-06-26 20:52:14 +00:00
|
|
|
|
priv->min_width = 0;
|
2010-12-12 07:42:37 +00:00
|
|
|
|
g_object_notify (G_OBJECT (context), "minimum-width");
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 20:52:14 +00:00
|
|
|
|
if (priv->nat_width != 0)
|
2010-12-12 07:42:37 +00:00
|
|
|
|
{
|
2011-06-26 20:52:14 +00:00
|
|
|
|
priv->nat_width = 0;
|
2010-12-12 07:42:37 +00:00
|
|
|
|
g_object_notify (G_OBJECT (context), "natural-width");
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 20:52:14 +00:00
|
|
|
|
if (priv->min_height != 0)
|
2010-12-12 07:42:37 +00:00
|
|
|
|
{
|
2011-06-26 20:52:14 +00:00
|
|
|
|
priv->min_height = 0;
|
2010-12-12 07:42:37 +00:00
|
|
|
|
g_object_notify (G_OBJECT (context), "minimum-height");
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 20:52:14 +00:00
|
|
|
|
if (priv->nat_height != 0)
|
2010-12-12 07:42:37 +00:00
|
|
|
|
{
|
2011-06-26 20:52:14 +00:00
|
|
|
|
priv->nat_height = 0;
|
2010-12-12 07:42:37 +00:00
|
|
|
|
g_object_notify (G_OBJECT (context), "natural-height");
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-27 07:05:14 +00:00
|
|
|
|
priv->alloc_width = 0;
|
|
|
|
|
priv->alloc_height = 0;
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (context));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-26 12:26:24 +00:00
|
|
|
|
gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
2010-11-26 12:26:24 +00:00
|
|
|
|
priv->alloc_width = width;
|
2010-11-13 07:23:01 +00:00
|
|
|
|
priv->alloc_height = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
|
* API *
|
|
|
|
|
*************************************************************/
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_area:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* Fetches the `GtkCellArea` this @context was created by.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2012-02-29 17:19:55 +00:00
|
|
|
|
* This is generally unneeded by layouting widgets; however,
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* it is important for the context implementation itself to
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* fetch information about the area it is being used for.
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* For instance at `GtkCellAreaContextClass.allocate()` time
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* it’s important to know details about any cell spacing
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* that the `GtkCellArea` is configured with in order to
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* compute a proper allocation.
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* Returns: (transfer none): the `GtkCellArea` this context was created by.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
GtkCellArea *
|
|
|
|
|
gtk_cell_area_context_get_area (GtkCellAreaContext *context)
|
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_CELL_AREA_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
|
|
return priv->cell_area;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_reset:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Resets any previously cached request and allocation
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* data.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* When underlying `GtkTreeModel` data changes its
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* important to reset the context if the content
|
|
|
|
|
* size is allowed to shrink. If the content size
|
|
|
|
|
* is only allowed to grow (this is usually an option
|
|
|
|
|
* for views rendering large data stores as a measure
|
|
|
|
|
* of optimization), then only the row that changed
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* or was inserted needs to be (re)requested with
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* gtk_cell_area_get_preferred_width().
|
|
|
|
|
*
|
|
|
|
|
* When the new overall size of the context requires
|
|
|
|
|
* that the allocated size changes (or whenever this
|
|
|
|
|
* allocation changes at all), the variable row
|
|
|
|
|
* sizes need to be re-requested for every row.
|
|
|
|
|
*
|
|
|
|
|
* For instance, if the rows are displayed all with
|
|
|
|
|
* the same width from top to bottom then a change
|
|
|
|
|
* in the allocated width necessitates a recalculation
|
|
|
|
|
* of all the displayed row heights using
|
|
|
|
|
* gtk_cell_area_get_preferred_height_for_width().
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
2010-11-27 07:05:14 +00:00
|
|
|
|
gtk_cell_area_context_reset (GtkCellAreaContext *context)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
2010-11-27 07:05:14 +00:00
|
|
|
|
GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->reset (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_allocate:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
|
|
|
|
* @width: the allocated width for all `GtkTreeModel` rows rendered
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* with @context, or -1
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @height: the allocated height for all `GtkTreeModel` rows rendered
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* with @context, or -1
|
2010-12-18 00:14:35 +00:00
|
|
|
|
*
|
|
|
|
|
* Allocates a width and/or a height for all rows which are to be
|
|
|
|
|
* rendered with @context.
|
|
|
|
|
*
|
|
|
|
|
* Usually allocation is performed only horizontally or sometimes
|
|
|
|
|
* vertically since a group of rows are usually rendered side by
|
|
|
|
|
* side vertically or horizontally and share either the same width
|
|
|
|
|
* or the same height. Sometimes they are allocated in both horizontal
|
|
|
|
|
* and vertical orientations producing a homogeneous effect of the
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* rows. This is generally the case for `GtkTreeView` when
|
|
|
|
|
* `GtkTreeView:fixed-height-mode` is enabled.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-11-26 04:23:01 +00:00
|
|
|
|
void
|
2010-11-26 12:26:24 +00:00
|
|
|
|
gtk_cell_area_context_allocate (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-11-26 04:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
2010-11-28 09:52:08 +00:00
|
|
|
|
GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->allocate (context, width, height);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_preferred_width:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @minimum_width: (out) (optional): location to store the minimum width
|
|
|
|
|
* @natural_width: (out) (optional): location to store the natural width
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* Gets the accumulative preferred width for all rows which have been
|
|
|
|
|
* requested with this context.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* After gtk_cell_area_context_reset() is called and/or before ever
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* requesting the size of a `GtkCellArea`, the returned values are 0.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *minimum_width,
|
|
|
|
|
int *natural_width)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
if (minimum_width)
|
|
|
|
|
*minimum_width = priv->min_width;
|
|
|
|
|
|
|
|
|
|
if (natural_width)
|
|
|
|
|
*natural_width = priv->nat_width;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_preferred_height:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @minimum_height: (out) (optional): location to store the minimum height
|
|
|
|
|
* @natural_height: (out) (optional): location to store the natural height
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* Gets the accumulative preferred height for all rows which have been
|
|
|
|
|
* requested with this context.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* After gtk_cell_area_context_reset() is called and/or before ever
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* requesting the size of a `GtkCellArea`, the returned values are 0.
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *minimum_height,
|
|
|
|
|
int *natural_height)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
if (minimum_height)
|
|
|
|
|
*minimum_height = priv->min_height;
|
|
|
|
|
|
|
|
|
|
if (natural_height)
|
|
|
|
|
*natural_height = priv->nat_height;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-12 15:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_preferred_height_for_width:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-12 15:18:00 +00:00
|
|
|
|
* @width: a proposed width for allocation
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @minimum_height: (out) (optional): location to store the minimum height
|
|
|
|
|
* @natural_height: (out) (optional): location to store the natural height
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* Gets the accumulative preferred height for @width for all rows
|
|
|
|
|
* which have been requested for the same said @width with this context.
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* After gtk_cell_area_context_reset() is called and/or before ever
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* requesting the size of a `GtkCellArea`, the returned values are -1.
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_get_preferred_height_for_width (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int *minimum_height,
|
|
|
|
|
int *natural_height)
|
2010-12-12 15:18:00 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
if (GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_height_for_width)
|
|
|
|
|
GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_height_for_width (context,
|
2010-12-18 00:14:35 +00:00
|
|
|
|
width,
|
|
|
|
|
minimum_height,
|
|
|
|
|
natural_height);
|
2010-12-12 15:18:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_preferred_width_for_height:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-12 15:18:00 +00:00
|
|
|
|
* @height: a proposed height for allocation
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @minimum_width: (out) (optional): location to store the minimum width
|
|
|
|
|
* @natural_width: (out) (optional): location to store the natural width
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* Gets the accumulative preferred width for @height for all rows which
|
|
|
|
|
* have been requested for the same said @height with this context.
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* After gtk_cell_area_context_reset() is called and/or before ever
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* requesting the size of a `GtkCellArea`, the returned values are -1.
|
2010-12-12 15:18:00 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_get_preferred_width_for_height (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int height,
|
|
|
|
|
int *minimum_width,
|
|
|
|
|
int *natural_width)
|
2010-12-18 00:14:35 +00:00
|
|
|
|
{
|
2010-12-12 15:18:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
if (GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_width_for_height)
|
|
|
|
|
GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_width_for_height (context,
|
2010-12-18 00:14:35 +00:00
|
|
|
|
height,
|
|
|
|
|
minimum_width,
|
|
|
|
|
natural_width);
|
2010-12-12 15:18:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_get_allocation:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @width: (out) (optional): location to store the allocated width
|
|
|
|
|
* @height: (out) (optional): location to store the allocated height
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Fetches the current allocation size for @context.
|
|
|
|
|
*
|
|
|
|
|
* If the context was not allocated in width or height, or if the
|
|
|
|
|
* context was recently reset with gtk_cell_area_context_reset(),
|
|
|
|
|
* the returned value will be -1.
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
if (width)
|
|
|
|
|
*width = priv->alloc_width;
|
|
|
|
|
|
|
|
|
|
if (height)
|
|
|
|
|
*height = priv->alloc_height;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_push_preferred_width:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* @minimum_width: the proposed new minimum width for @context
|
|
|
|
|
* @natural_width: the proposed new natural width for @context
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Causes the minimum and/or natural width to grow if the new
|
|
|
|
|
* proposed sizes exceed the current minimum and natural width.
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* This is used by `GtkCellAreaContext` implementations during
|
|
|
|
|
* the request process over a series of `GtkTreeModel` rows to
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* progressively push the requested width over a series of
|
|
|
|
|
* gtk_cell_area_get_preferred_width() requests.
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int minimum_width,
|
|
|
|
|
int natural_width)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-11-13 07:23:01 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (context));
|
|
|
|
|
|
|
|
|
|
if (minimum_width > priv->min_width)
|
|
|
|
|
{
|
|
|
|
|
priv->min_width = minimum_width;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (context), "minimum-width");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (natural_width > priv->nat_width)
|
|
|
|
|
{
|
|
|
|
|
priv->nat_width = natural_width;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (context), "natural-width");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (context));
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 07:29:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_cell_area_context_push_preferred_height:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @context: a `GtkCellAreaContext`
|
2010-12-18 00:14:35 +00:00
|
|
|
|
* @minimum_height: the proposed new minimum height for @context
|
|
|
|
|
* @natural_height: the proposed new natural height for @context
|
2010-12-03 07:29:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Causes the minimum and/or natural height to grow if the new
|
|
|
|
|
* proposed sizes exceed the current minimum and natural height.
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* This is used by `GtkCellAreaContext` implementations during
|
|
|
|
|
* the request process over a series of `GtkTreeModel` rows to
|
2010-12-03 07:29:11 +00:00
|
|
|
|
* progressively push the requested height over a series of
|
|
|
|
|
* gtk_cell_area_get_preferred_height() requests.
|
|
|
|
|
*/
|
2010-11-13 07:23:01 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_cell_area_context_push_preferred_height (GtkCellAreaContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int minimum_height,
|
|
|
|
|
int natural_height)
|
2010-11-13 07:23:01 +00:00
|
|
|
|
{
|
2019-05-27 02:42:49 +00:00
|
|
|
|
GtkCellAreaContextPrivate *priv = gtk_cell_area_context_get_instance_private (context);
|
2010-12-18 00:14:35 +00:00
|
|
|
|
|
2010-11-13 07:23:01 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
|
|
|
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (context));
|
|
|
|
|
|
|
|
|
|
if (minimum_height > priv->min_height)
|
|
|
|
|
{
|
|
|
|
|
priv->min_height = minimum_height;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (context), "minimum-height");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (natural_height > priv->nat_height)
|
|
|
|
|
{
|
|
|
|
|
priv->nat_height = natural_height;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (context), "natural-height");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (context));
|
|
|
|
|
}
|