2009-12-02 08:48:42 +00:00
|
|
|
/* gtkextendedlayout.c
|
2010-04-20 22:53:54 +00:00
|
|
|
* Copyright (C) 2007-2010 Openismus GmbH
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
2010-04-20 22:53:54 +00:00
|
|
|
* Authors:
|
2009-12-02 08:48:42 +00:00
|
|
|
* Mathias Hasselmann <mathias@openismus.com>
|
2010-04-20 22:53:54 +00:00
|
|
|
* Tristan Van Berkom <tristan.van.berkom@gmail.com>
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-04-21 05:32:55 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkextendedlayout
|
2010-04-26 11:34:01 +00:00
|
|
|
* @Short_Description: Height-for-width geometry management
|
2010-04-21 05:32:55 +00:00
|
|
|
* @Title: GtkExtendedLayout
|
|
|
|
*
|
2010-04-26 11:34:01 +00:00
|
|
|
* The extended layout is GTK+'s height-for-width (and width-for-height)
|
2010-05-01 03:21:58 +00:00
|
|
|
* geometry management system. Height-for-width means that a widget can
|
|
|
|
* change how much vertical space it needs, depending on the amount
|
|
|
|
* of horizontal space that it is given (and similar for width-for-height).
|
|
|
|
* The most common example is a label that reflows to fill up the available
|
|
|
|
* width, wraps to fewer lines, and therefore needs less height.
|
|
|
|
*
|
|
|
|
* GTK+'s traditional two-pass <link linkend="size-allocation">size-allocation</link>
|
|
|
|
* algorithm does not allow this flexibility. #GtkWidget provides a default
|
|
|
|
* implementation of the #GtkExtendedLayout interface for existing widgets,
|
|
|
|
* which always requests the same height, regardless of the available width.
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Implementing GtkExtendedLayout</title>
|
|
|
|
* <para>
|
2010-04-24 01:52:55 +00:00
|
|
|
* Some important things to keep in mind when implementing
|
2010-04-21 05:32:55 +00:00
|
|
|
* or using the extended layout.
|
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* The Extended Layout system will query a logical hierarchy in
|
2010-04-21 05:32:55 +00:00
|
|
|
* only one orientation at a time. When widgets are initially queried
|
|
|
|
* for their minimum sizes it is generally done in a dual pass
|
|
|
|
* in the direction chosen by the toplevel.
|
|
|
|
*
|
|
|
|
* For instance when queried in the normal height-for-width mode:
|
|
|
|
* First the default minimum and natural width for each widget
|
2010-04-24 01:52:55 +00:00
|
|
|
* in the interface will computed and collectively returned to
|
|
|
|
* the toplevel by way of gtk_extended_layout_get_desired_width().
|
2010-04-28 14:04:21 +00:00
|
|
|
* Next, the toplevel will use the minimum width to query for the
|
2010-04-24 01:52:55 +00:00
|
|
|
* minimum height contextual to that width using
|
2010-04-28 14:04:21 +00:00
|
|
|
* gtk_extended_layout_get_height_for_width(), which will also be a
|
|
|
|
* highly recursive operation. This minimum-for-minimum size can be
|
2010-04-24 01:52:55 +00:00
|
|
|
* used to set the minimum size constraint on the toplevel.
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
2010-04-28 14:04:21 +00:00
|
|
|
* When allocating, each container can use the minimum and natural
|
2010-04-24 01:52:55 +00:00
|
|
|
* sizes reported by their children to allocate natural sizes and
|
2010-04-21 05:32:55 +00:00
|
|
|
* expose as much content as possible with the given allocation.
|
|
|
|
*
|
|
|
|
* That means that the request operation at allocation time will
|
|
|
|
* usually fire again in contexts of different allocated sizes than
|
2010-04-28 14:04:21 +00:00
|
|
|
* the ones originally queried for. #GtkExtendedLayout caches a
|
|
|
|
* small number of results to avoid re-querying for the same
|
|
|
|
* allocated size in one allocation cycle.
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* A widget that does not actually do height-for-width
|
2010-04-21 05:32:55 +00:00
|
|
|
* or width-for-height size negotiations only has to implement
|
2010-04-24 01:52:55 +00:00
|
|
|
* get_desired_width() and get_desired_height().
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
|
|
|
* If a widget does move content around to smartly use up the
|
|
|
|
* allocated size, then it must support the request properly in
|
|
|
|
* both orientations; even if the request only makes sense in
|
|
|
|
* one orientation.
|
|
|
|
*
|
2010-04-28 14:04:21 +00:00
|
|
|
* For instance, a GtkLabel that does height-for-width word wrapping
|
2010-04-21 05:32:55 +00:00
|
|
|
* will not expect to have get_desired_height() called because that
|
|
|
|
* call is specific to a width-for-height request, in this case the
|
|
|
|
* label must return the heights contextual to its minimum possible
|
|
|
|
* width. By following this rule any widget that handles height-for-width
|
|
|
|
* or width-for-height requests will always be allocated at least
|
|
|
|
* enough space to fit its own content.
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-12-02 08:48:42 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include "gtkextendedlayout.h"
|
2010-04-08 22:52:12 +00:00
|
|
|
#include "gtksizegroup.h"
|
2010-04-13 02:21:46 +00:00
|
|
|
#include "gtkprivate.h"
|
2009-12-02 08:48:42 +00:00
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkalias.h"
|
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
/* With extended layout, a widget may be requested
|
2010-04-18 02:52:27 +00:00
|
|
|
* its width for 2 or maximum 3 heights in one resize
|
2010-04-17 05:51:10 +00:00
|
|
|
*/
|
|
|
|
#define N_CACHED_SIZES 3
|
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
typedef struct
|
2010-04-17 05:51:10 +00:00
|
|
|
{
|
|
|
|
guint age;
|
|
|
|
gint for_size;
|
|
|
|
gint minimum_size;
|
|
|
|
gint natural_size;
|
|
|
|
} DesiredSize;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DesiredSize desired_widths[N_CACHED_SIZES];
|
|
|
|
DesiredSize desired_heights[N_CACHED_SIZES];
|
2010-04-20 22:53:54 +00:00
|
|
|
guint8 cached_width_age;
|
|
|
|
guint8 cached_height_age;
|
2010-04-17 05:51:10 +00:00
|
|
|
} ExtendedLayoutCache;
|
|
|
|
|
|
|
|
static GQuark quark_cache = 0;
|
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
|
2009-12-02 08:48:42 +00:00
|
|
|
GType
|
|
|
|
gtk_extended_layout_get_type (void)
|
|
|
|
{
|
|
|
|
static GType extended_layout_type = 0;
|
|
|
|
|
|
|
|
if (G_UNLIKELY(!extended_layout_type))
|
2010-04-06 06:47:20 +00:00
|
|
|
{
|
|
|
|
extended_layout_type =
|
2010-04-24 01:52:55 +00:00
|
|
|
g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedLayout"),
|
|
|
|
sizeof (GtkExtendedLayoutIface),
|
|
|
|
NULL, 0, NULL, 0);
|
2010-04-06 06:47:20 +00:00
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (extended_layout_type, GTK_TYPE_WIDGET);
|
2010-04-17 05:51:10 +00:00
|
|
|
|
|
|
|
quark_cache = g_quark_from_static_string ("gtk-extended-layout-cache");
|
2010-04-06 06:47:20 +00:00
|
|
|
}
|
2009-12-02 08:48:42 +00:00
|
|
|
|
|
|
|
return extended_layout_type;
|
|
|
|
}
|
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
/* looks for a cached size request for this for_size. If not
|
2010-04-24 01:52:55 +00:00
|
|
|
* found, returns the oldest entry so it can be overwritten
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Note that this caching code was directly derived from
|
2010-04-21 05:32:55 +00:00
|
|
|
* the Clutter toolkit.
|
|
|
|
*/
|
2010-04-13 02:21:46 +00:00
|
|
|
static gboolean
|
2010-04-20 05:24:51 +00:00
|
|
|
get_cached_desired_size (gint for_size,
|
2010-04-24 01:52:55 +00:00
|
|
|
DesiredSize *cached_sizes,
|
|
|
|
DesiredSize **result)
|
2009-12-02 08:48:42 +00:00
|
|
|
{
|
2010-04-13 02:21:46 +00:00
|
|
|
guint i;
|
2009-12-02 08:48:42 +00:00
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
*result = &cached_sizes[0];
|
2009-12-02 08:48:42 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
for (i = 0; i < N_CACHED_SIZES; i++)
|
2010-04-13 02:21:46 +00:00
|
|
|
{
|
2010-04-17 05:51:10 +00:00
|
|
|
DesiredSize *cs;
|
2010-04-11 02:32:55 +00:00
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
cs = &cached_sizes[i];
|
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
if (cs->age > 0 && cs->for_size == for_size)
|
2010-04-13 02:21:46 +00:00
|
|
|
{
|
|
|
|
*result = cs;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (cs->age < (*result)->age)
|
|
|
|
{
|
|
|
|
*result = cs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-04-11 02:32:55 +00:00
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
static void
|
2010-04-17 05:51:10 +00:00
|
|
|
destroy_cache (ExtendedLayoutCache *cache)
|
|
|
|
{
|
|
|
|
g_slice_free (ExtendedLayoutCache, cache);
|
|
|
|
}
|
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
static ExtendedLayoutCache *
|
|
|
|
get_cache (GtkExtendedLayout *layout,
|
|
|
|
gboolean create)
|
2010-04-17 05:51:10 +00:00
|
|
|
{
|
|
|
|
ExtendedLayoutCache *cache;
|
2010-04-28 14:04:21 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
cache = g_object_get_qdata (G_OBJECT (layout), quark_cache);
|
|
|
|
if (!cache && create)
|
|
|
|
{
|
|
|
|
cache = g_slice_new0 (ExtendedLayoutCache);
|
|
|
|
|
|
|
|
cache->cached_width_age = 1;
|
|
|
|
cache->cached_height_age = 1;
|
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
g_object_set_qdata_full (G_OBJECT (layout), quark_cache, cache,
|
|
|
|
(GDestroyNotify)destroy_cache);
|
2010-04-17 05:51:10 +00:00
|
|
|
}
|
2010-04-28 14:04:21 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
2010-04-20 00:41:23 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
static void
|
|
|
|
do_size_request (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_REQUEST_NEEDED (widget))
|
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
gtk_widget_ensure_style (widget);
|
2010-04-17 05:51:10 +00:00
|
|
|
GTK_PRIVATE_UNSET_FLAG (widget, GTK_REQUEST_NEEDED);
|
|
|
|
g_signal_emit_by_name (widget,
|
2010-04-24 01:52:55 +00:00
|
|
|
"size-request",
|
|
|
|
&widget->requisition);
|
2010-04-17 05:51:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
compute_size_for_orientation (GtkExtendedLayout *layout,
|
2010-04-24 01:52:55 +00:00
|
|
|
GtkSizeGroupMode orientation,
|
|
|
|
gint for_size,
|
|
|
|
gint *minimum_size,
|
|
|
|
gint *natural_size)
|
2010-04-17 05:51:10 +00:00
|
|
|
{
|
|
|
|
ExtendedLayoutCache *cache;
|
|
|
|
DesiredSize *cached_size;
|
|
|
|
GtkWidget *widget;
|
|
|
|
gboolean found_in_cache = FALSE;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
|
|
|
|
g_return_if_fail (minimum_size != NULL || natural_size != NULL);
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (layout);
|
|
|
|
cache = get_cache (layout, TRUE);
|
|
|
|
|
|
|
|
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
|
|
|
|
{
|
|
|
|
cached_size = &cache->desired_widths[0];
|
2010-04-24 01:52:55 +00:00
|
|
|
|
|
|
|
if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (layout))
|
|
|
|
found_in_cache = get_cached_desired_size (for_size, cache->desired_widths, &cached_size);
|
2010-04-20 00:41:23 +00:00
|
|
|
else
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
memset (cache->desired_widths, 0, N_CACHED_SIZES * sizeof (DesiredSize));
|
|
|
|
cache->cached_width_age = 1;
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cached_size = &cache->desired_heights[0];
|
2010-04-24 01:52:55 +00:00
|
|
|
|
|
|
|
if (!GTK_WIDGET_HEIGHT_REQUEST_NEEDED (layout))
|
|
|
|
found_in_cache = get_cached_desired_size (for_size, cache->desired_heights, &cached_size);
|
2010-04-20 00:41:23 +00:00
|
|
|
else
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
memset (cache->desired_heights, 0, N_CACHED_SIZES * sizeof (DesiredSize));
|
|
|
|
cache->cached_height_age = 1;
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
}
|
2010-04-28 14:04:21 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
if (!found_in_cache)
|
|
|
|
{
|
|
|
|
gint min_size = 0, nat_size = 0;
|
|
|
|
gint group_size, requisition_size;
|
|
|
|
|
|
|
|
/* Unconditional size request runs but is often unhandled. */
|
|
|
|
do_size_request (widget);
|
|
|
|
|
|
|
|
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
requisition_size = widget->requisition.width;
|
|
|
|
|
|
|
|
if (for_size < 0)
|
|
|
|
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, &min_size, &nat_size);
|
|
|
|
else
|
|
|
|
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_width_for_height (layout, for_size, &min_size, &nat_size);
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
else
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
requisition_size = widget->requisition.height;
|
2010-04-17 05:51:10 +00:00
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
if (for_size < 0)
|
|
|
|
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, &min_size, &nat_size);
|
|
|
|
else
|
|
|
|
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_height_for_width (layout, for_size, &min_size, &nat_size);
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
|
|
|
|
/* Support for dangling "size-request" signals and forward derived
|
|
|
|
* classes that will not default to a ->get_desired_width() that
|
|
|
|
* returns the values in the ->requisition cache.
|
|
|
|
*/
|
|
|
|
min_size = MAX (min_size, requisition_size);
|
|
|
|
nat_size = MAX (nat_size, requisition_size);
|
|
|
|
|
|
|
|
cached_size->minimum_size = min_size;
|
|
|
|
cached_size->natural_size = nat_size;
|
|
|
|
cached_size->for_size = for_size;
|
|
|
|
|
|
|
|
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
cached_size->age = cache->cached_width_age;
|
|
|
|
cache->cached_width_age++;
|
2010-04-17 05:51:10 +00:00
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
GTK_PRIVATE_UNSET_FLAG (layout, GTK_WIDTH_REQUEST_NEEDED);
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
else
|
2010-04-24 01:52:55 +00:00
|
|
|
{
|
|
|
|
cached_size->age = cache->cached_height_age;
|
|
|
|
cache->cached_height_age++;
|
2010-04-17 05:51:10 +00:00
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
GTK_PRIVATE_UNSET_FLAG (layout, GTK_HEIGHT_REQUEST_NEEDED);
|
|
|
|
}
|
2010-04-17 05:51:10 +00:00
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
/* Get size groups to compute the base requisition once one
|
|
|
|
* of the values have been cached, then go ahead and update
|
|
|
|
* the cache with the sizegroup computed value.
|
2010-04-19 00:45:42 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Note this is also where values from gtk_widget_set_size_request()
|
|
|
|
* are considered.
|
2010-04-17 05:51:10 +00:00
|
|
|
*/
|
2010-04-24 01:52:55 +00:00
|
|
|
group_size =
|
|
|
|
_gtk_size_group_bump_requisition (GTK_WIDGET (layout),
|
|
|
|
orientation, cached_size->minimum_size);
|
2010-04-18 02:52:27 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
cached_size->minimum_size = MAX (cached_size->minimum_size, group_size);
|
|
|
|
cached_size->natural_size = MAX (cached_size->natural_size, group_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (minimum_size)
|
|
|
|
*minimum_size = cached_size->minimum_size;
|
2010-04-28 14:04:21 +00:00
|
|
|
|
2010-04-17 05:51:10 +00:00
|
|
|
if (natural_size)
|
|
|
|
*natural_size = cached_size->natural_size;
|
|
|
|
|
|
|
|
g_assert (cached_size->minimum_size <= cached_size->natural_size);
|
|
|
|
|
2010-04-24 01:52:55 +00:00
|
|
|
GTK_NOTE (EXTENDED_LAYOUT,
|
|
|
|
g_print ("[%p] %s\t%s: %d is minimum %d and natural: %d (hit cache: %s)\n",
|
|
|
|
layout, G_OBJECT_TYPE_NAME (layout),
|
|
|
|
orientation == GTK_SIZE_GROUP_HORIZONTAL ?
|
|
|
|
"width for height" : "height for width" ,
|
|
|
|
for_size,
|
|
|
|
cached_size->minimum_size,
|
|
|
|
cached_size->natural_size,
|
|
|
|
found_in_cache ? "yes" : "no"));
|
2010-04-17 05:51:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-04-11 02:32:55 +00:00
|
|
|
/**
|
|
|
|
* gtk_extended_layout_is_height_for_width:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
|
|
|
*
|
|
|
|
* Gets whether the widget prefers a height-for-width layout
|
2010-04-24 01:52:55 +00:00
|
|
|
* or a width-for-height layout.
|
|
|
|
*
|
|
|
|
* <note><para>#GtkBin widgets generally propagate the preference of
|
|
|
|
* their child, container widgets need to request something either in
|
|
|
|
* context of their children or in context of their allocation
|
|
|
|
* capabilities.</para></note>
|
2010-04-11 02:32:55 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget prefers height-for-width, %FALSE if
|
|
|
|
* the widget should be treated with a width-for-height preference.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout)
|
|
|
|
{
|
|
|
|
GtkExtendedLayoutIface *iface;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (layout), FALSE);
|
|
|
|
|
|
|
|
iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
|
|
|
|
if (iface->is_height_for_width)
|
|
|
|
return iface->is_height_for_width (layout);
|
|
|
|
|
|
|
|
/* By default widgets are height-for-width. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_extended_layout_get_desired_width:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
2010-05-12 22:53:43 +00:00
|
|
|
* @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
|
|
|
|
* @natural_width: (out) (allow-none): location to store the natural width, or %NULL
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Retrieves a widget's initial minimum and natural width.
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* <note><para>This call is specific to height-for-width
|
|
|
|
* requests.</para></note>
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
|
2010-04-24 01:52:55 +00:00
|
|
|
gint *minimum_width,
|
|
|
|
gint *natural_width)
|
2010-04-13 02:21:46 +00:00
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
|
|
|
|
-1, minimum_width, natural_width);
|
2010-04-13 02:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_extended_layout_get_desired_height:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
2010-05-12 22:53:43 +00:00
|
|
|
* @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
|
|
|
|
* @natural_height: (out) (allow-none): location to store the natural height, or %NULL
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Retrieves a widget's initial minimum and natural height.
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
2010-05-01 03:21:58 +00:00
|
|
|
* <note><para>This call is specific to width-for-height requests.</para></note>
|
2010-04-21 05:32:55 +00:00
|
|
|
*
|
2010-04-13 02:21:46 +00:00
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
|
2010-04-24 01:52:55 +00:00
|
|
|
gint *minimum_height,
|
|
|
|
gint *natural_height)
|
2010-04-13 02:21:46 +00:00
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
|
|
|
|
-1, minimum_height, natural_height);
|
2010-04-13 02:21:46 +00:00
|
|
|
}
|
|
|
|
|
2010-04-11 02:32:55 +00:00
|
|
|
|
|
|
|
|
2009-12-02 08:48:42 +00:00
|
|
|
/**
|
|
|
|
* gtk_extended_layout_get_width_for_height:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
2010-05-01 03:21:58 +00:00
|
|
|
* @height: the height which is available for allocation
|
2010-05-12 22:53:43 +00:00
|
|
|
* @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
|
|
|
|
* @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Retrieves a widget's desired width if it would be given
|
2010-04-06 06:47:20 +00:00
|
|
|
* the specified @height.
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
2010-04-06 06:47:20 +00:00
|
|
|
* Since: 3.0
|
2009-12-02 08:48:42 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
|
|
|
gint height,
|
|
|
|
gint *minimum_width,
|
|
|
|
gint *natural_width)
|
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
|
|
|
|
height, minimum_width, natural_width);
|
2009-12-02 08:48:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_extended_layout_get_height_for_width:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
2010-05-01 03:21:58 +00:00
|
|
|
* @width: the width which is available for allocation
|
2010-05-12 22:53:43 +00:00
|
|
|
* @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
|
|
|
|
* @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Retrieves a widget's desired height if it would be given
|
2010-04-06 06:47:20 +00:00
|
|
|
* the specified @width.
|
2009-12-02 08:48:42 +00:00
|
|
|
*
|
2010-04-06 06:47:20 +00:00
|
|
|
* Since: 3.0
|
2009-12-02 08:48:42 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
|
|
|
|
gint width,
|
|
|
|
gint *minimum_height,
|
|
|
|
gint *natural_height)
|
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
|
|
|
|
width, minimum_height, natural_height);
|
2009-12-02 08:48:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_extended_layout_get_desired_size:
|
|
|
|
* @layout: a #GtkExtendedLayout instance
|
2010-04-24 01:52:55 +00:00
|
|
|
* @request_natural: Whether to base the contextual request off of the
|
|
|
|
* base natural or the base minimum
|
2010-05-12 22:53:43 +00:00
|
|
|
* @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
|
|
|
|
* @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* Retrieves the minimum and natural size of a widget taking
|
2010-04-13 02:21:46 +00:00
|
|
|
* into account the widget's preference for height-for-width management.
|
|
|
|
*
|
2010-04-20 05:24:51 +00:00
|
|
|
* If request_natural is specified, the non-contextual natural value will
|
|
|
|
* be used to make the contextual request; otherwise the minimum will be used.
|
|
|
|
*
|
2010-04-24 01:52:55 +00:00
|
|
|
* This is used to retrieve a suitable size by container widgets which do
|
|
|
|
* not impose any restrictions on the child placement.
|
2010-04-13 02:21:46 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
|
2010-04-24 01:52:55 +00:00
|
|
|
gboolean request_natural,
|
2010-04-13 02:21:46 +00:00
|
|
|
GtkRequisition *minimum_size,
|
|
|
|
GtkRequisition *natural_size)
|
|
|
|
{
|
|
|
|
gint min_width, nat_width;
|
|
|
|
gint min_height, nat_height;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
|
|
|
|
|
|
|
|
if (gtk_extended_layout_is_height_for_width (layout))
|
|
|
|
{
|
|
|
|
gtk_extended_layout_get_desired_width (layout, &min_width, &nat_width);
|
2010-04-24 01:52:55 +00:00
|
|
|
gtk_extended_layout_get_height_for_width (layout,
|
|
|
|
request_natural ? nat_width : min_width,
|
|
|
|
&min_height, &nat_height);
|
2010-04-13 02:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_extended_layout_get_desired_height (layout, &min_height, &nat_height);
|
2010-04-24 01:52:55 +00:00
|
|
|
gtk_extended_layout_get_width_for_height (layout,
|
|
|
|
request_natural ? nat_height : min_height,
|
|
|
|
&min_width, &nat_width);
|
2010-04-13 02:21:46 +00:00
|
|
|
}
|
|
|
|
|
2010-04-18 22:12:30 +00:00
|
|
|
if (minimum_size)
|
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
minimum_size->width = min_width;
|
2010-04-18 22:12:30 +00:00
|
|
|
minimum_size->height = min_height;
|
|
|
|
}
|
2010-04-28 14:04:21 +00:00
|
|
|
|
2010-04-13 02:21:46 +00:00
|
|
|
if (natural_size)
|
|
|
|
{
|
2010-04-24 01:52:55 +00:00
|
|
|
natural_size->width = nat_width;
|
2010-04-13 02:21:46 +00:00
|
|
|
natural_size->height = nat_height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-02 08:48:42 +00:00
|
|
|
#define __GTK_EXTENDED_LAYOUT_C__
|
|
|
|
#include "gtkaliasdef.c"
|