* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkframe.h"
#include "gtklabel.h"
#include "gtkprivate.h"
+#include "gtktypebuiltins.h"
#include "gtkintl.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
+#include "gtkwidgetpath.h"
+
+#include "a11y/gtkframeaccessible.h"
+
+/**
+ * SECTION:gtkframe
+ * @Short_description: A bin with a decorative frame and optional label
+ * @Title: GtkFrame
+ *
+ * The frame widget is a Bin that surrounds its child
+ * with a decorative frame and an optional label.
+ * If present, the label is drawn in a gap in the
+ * top side of the frame. The position of the
+ * label can be controlled with gtk_frame_set_label_align().
+ *
+ * <refsect2 id="GtkFrame-BUILDER-UI">
+ * <title>GtkFrame as GtkBuildable</title>
+ * <para>
+ * The GtkFrame implementation of the GtkBuildable interface
+ * supports placing a child in the label position by specifying
+ * "label" as the "type" attribute of a <child> element.
+ * A normal content child can be specified without specifying
+ * a <child> type attribute.
+ * </para>
+ * <example>
+ * <title>A UI definition fragment with GtkFrame</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkFrame">
+ * <child type="label">
+ * <object class="GtkLabel" id="frame-label"/>
+ * </child>
+ * <child>
+ * <object class="GtkEntry" id="frame-content"/>
+ * </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
#define LABEL_PAD 1
#define LABEL_SIDE_PAD 2
-struct _GtkFramePriv
+struct _GtkFramePrivate
{
/* Properties */
GtkWidget *label_widget;
PROP_LABEL,
PROP_LABEL_XALIGN,
PROP_LABEL_YALIGN,
- PROP_SHADOW,
PROP_SHADOW_TYPE,
PROP_LABEL_WIDGET
};
guint param_id,
GValue *value,
GParamSpec *pspec);
-static void gtk_frame_paint (GtkWidget *widget,
- GdkRectangle *area);
-static gint gtk_frame_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gtk_frame_draw (GtkWidget *widget,
+ cairo_t *cr);
static void gtk_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_frame_remove (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
+static GtkWidgetPath * gtk_frame_get_path_for_child (GtkContainer *container,
+ GtkWidget *child);
static void gtk_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation);
GObject *child,
const gchar *type);
-static void gtk_frame_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_frame_get_width (GtkSizeRequest *widget,
+static void gtk_frame_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_frame_get_height (GtkSizeRequest *widget,
+static void gtk_frame_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_frame_get_height_for_width (GtkSizeRequest *layout,
+static void gtk_frame_get_preferred_height_for_width(GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
-static void gtk_frame_get_width_for_height (GtkSizeRequest *layout,
+static void gtk_frame_get_preferred_width_for_height(GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_frame_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_frame_size_request_init))
+ gtk_frame_buildable_init))
static void
gtk_frame_class_init (GtkFrameClass *class)
1.0,
0.5,
GTK_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_SHADOW,
- g_param_spec_enum ("shadow", NULL,
- P_("Deprecated property, use shadow_type instead"),
- GTK_TYPE_SHADOW_TYPE,
- GTK_SHADOW_ETCHED_IN,
- GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHADOW_TYPE,
g_param_spec_enum ("shadow-type",
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE));
- widget_class->expose_event = gtk_frame_expose;
- widget_class->size_allocate = gtk_frame_size_allocate;
+ widget_class->draw = gtk_frame_draw;
+ widget_class->size_allocate = gtk_frame_size_allocate;
+ widget_class->get_preferred_width = gtk_frame_get_preferred_width;
+ widget_class->get_preferred_height = gtk_frame_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_frame_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_frame_get_preferred_width_for_height;
container_class->remove = gtk_frame_remove;
container_class->forall = gtk_frame_forall;
+ container_class->get_path_for_child = gtk_frame_get_path_for_child;
class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
- g_type_class_add_private (class, sizeof (GtkFramePriv));
+ g_type_class_add_private (class, sizeof (GtkFramePrivate));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FRAME_ACCESSIBLE);
}
static void
static void
gtk_frame_init (GtkFrame *frame)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
+ GtkStyleContext *context;
frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame,
GTK_TYPE_FRAME,
- GtkFramePriv);
+ GtkFramePrivate);
priv = frame->priv;
priv->label_widget = NULL;
priv->shadow_type = GTK_SHADOW_ETCHED_IN;
priv->label_xalign = 0.0;
priv->label_yalign = 0.5;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (frame));
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
}
static void
GParamSpec *pspec)
{
GtkFrame *frame = GTK_FRAME (object);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
switch (prop_id)
{
gtk_frame_set_label_align (frame, priv->label_xalign,
g_value_get_float (value));
break;
- case PROP_SHADOW:
case PROP_SHADOW_TYPE:
gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
break;
GParamSpec *pspec)
{
GtkFrame *frame = GTK_FRAME (object);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
switch (prop_id)
{
case PROP_LABEL_YALIGN:
g_value_set_float (value, priv->label_yalign);
break;
- case PROP_SHADOW:
case PROP_SHADOW_TYPE:
g_value_set_enum (value, priv->shadow_type);
break;
GtkWidget *child)
{
GtkFrame *frame = GTK_FRAME (container);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
if (priv->label_widget == child)
gtk_frame_set_label_widget (frame, NULL);
{
GtkBin *bin = GTK_BIN (container);
GtkFrame *frame = GTK_FRAME (container);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
GtkWidget *child;
child = gtk_bin_get_child (bin);
(* callback) (priv->label_widget, callback_data);
}
+static GtkWidgetPath *
+gtk_frame_get_path_for_child (GtkContainer *container,
+ GtkWidget *child)
+{
+ GtkFramePrivate *priv = GTK_FRAME (container)->priv;
+ GtkWidgetPath *path;
+
+ path = GTK_CONTAINER_CLASS (gtk_frame_parent_class)->get_path_for_child (container, child);
+
+ if (child == priv->label_widget)
+ gtk_widget_path_iter_add_class (path,
+ gtk_widget_path_length (path) - 2,
+ GTK_STYLE_CLASS_FRAME);
+
+ return path;
+}
+
/**
* gtk_frame_set_label:
* @frame: a #GtkFrame
* a #GtkLabel. This string is owned by GTK+ and
* must not be modified or freed.
**/
-G_CONST_RETURN gchar *
+const gchar *
gtk_frame_get_label (GtkFrame *frame)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
gtk_frame_set_label_widget (GtkFrame *frame,
GtkWidget *label_widget)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
gboolean need_resize = FALSE;
g_return_if_fail (GTK_IS_FRAME (frame));
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
- g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
+ g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
priv = frame->priv;
* Retrieves the label widget for the frame. See
* gtk_frame_set_label_widget().
*
- * Return value: the label widget, or %NULL if there is none.
+ * Return value: (transfer none): the label widget, or %NULL if there is none.
**/
GtkWidget *
gtk_frame_get_label_widget (GtkFrame *frame)
gfloat xalign,
gfloat yalign)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
g_return_if_fail (GTK_IS_FRAME (frame));
/**
* gtk_frame_get_label_align:
* @frame: a #GtkFrame
- * @xalign: (allow-none): location to store X alignment of frame's label, or %NULL
- * @yalign: (allow-none): location to store X alignment of frame's label, or %NULL
+ * @xalign: (out) (allow-none): location to store X alignment of
+ * frame's label, or %NULL
+ * @yalign: (out) (allow-none): location to store X alignment of
+ * frame's label, or %NULL
*
* Retrieves the X and Y alignment of the frame's label. See
* gtk_frame_set_label_align().
gfloat *xalign,
gfloat *yalign)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
g_return_if_fail (GTK_IS_FRAME (frame));
gtk_frame_set_shadow_type (GtkFrame *frame,
GtkShadowType type)
{
- GtkFramePriv *priv;
+ GtkFramePrivate *priv;
GtkWidget *widget;
g_return_if_fail (GTK_IS_FRAME (frame));
}
static void
-gtk_frame_paint (GtkWidget *widget,
- GdkRectangle *area)
+get_padding_and_border (GtkFrame *frame,
+ GtkBorder *border)
{
- GtkFrame *frame;
- GtkFramePriv *priv;
- gint x, y, width, height;
+ GtkStyleContext *context;
+ GtkStateFlags state;
- if (gtk_widget_is_drawable (widget))
- {
- frame = GTK_FRAME (widget);
- priv = frame->priv;
+ context = gtk_widget_get_style_context (GTK_WIDGET (frame));
+ state = gtk_widget_get_state_flags (GTK_WIDGET (frame));
- x = priv->child_allocation.x - widget->style->xthickness;
- y = priv->child_allocation.y - widget->style->ythickness;
- width = priv->child_allocation.width + 2 * widget->style->xthickness;
- height = priv->child_allocation.height + 2 * widget->style->ythickness;
+ gtk_style_context_get_padding (context, state, border);
- if (priv->label_widget)
- {
- gfloat xalign;
- gint height_extra;
- gint x2;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- xalign = priv->label_xalign;
- else
- xalign = 1 - priv->label_xalign;
-
- height_extra = MAX (0, priv->label_allocation.height - widget->style->ythickness)
- - priv->label_yalign * priv->label_allocation.height;
- y -= height_extra;
- height += height_extra;
-
- x2 = widget->style->xthickness + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
-
- /* If the label is completely over or under the frame we can omit the gap */
- if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
- gtk_paint_shadow (widget->style, widget->window,
- widget->state, priv->shadow_type,
- area, widget, "frame",
- x, y, width, height);
- else
- gtk_paint_shadow_gap (widget->style, widget->window,
- widget->state, priv->shadow_type,
- area, widget, "frame",
- x, y, width, height,
- GTK_POS_TOP,
- x2, priv->label_allocation.width + 2 * LABEL_PAD);
- }
- else
- gtk_paint_shadow (widget->style, widget->window,
- widget->state, priv->shadow_type,
- area, widget, "frame",
- x, y, width, height);
+ if (frame->priv->shadow_type != GTK_SHADOW_NONE)
+ {
+ GtkBorder tmp;
+
+ gtk_style_context_get_border (context, state, &tmp);
+ border->top += tmp.top;
+ border->right += tmp.right;
+ border->bottom += tmp.bottom;
+ border->left += tmp.left;
}
}
static gboolean
-gtk_frame_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_frame_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- if (gtk_widget_is_drawable (widget))
- {
- gtk_frame_paint (widget, &event->area);
+ GtkFrame *frame;
+ GtkFramePrivate *priv;
+ GtkStyleContext *context;
+ gint x, y, width, height;
+ GtkAllocation allocation;
+ GtkBorder padding;
+
+ frame = GTK_FRAME (widget);
+ priv = frame->priv;
- GTK_WIDGET_CLASS (gtk_frame_parent_class)->expose_event (widget, event);
+ gtk_widget_get_allocation (widget, &allocation);
+ get_padding_and_border (frame, &padding);
+ context = gtk_widget_get_style_context (widget);
+
+ x = priv->child_allocation.x - allocation.x - padding.left;
+ y = priv->child_allocation.y - allocation.y - padding.top;
+ width = priv->child_allocation.width + padding.left + padding.right;
+ height = priv->child_allocation.height + padding.top + padding.bottom;
+
+ if (priv->shadow_type != GTK_SHADOW_NONE)
+ {
+ if (priv->label_widget)
+ {
+ gfloat xalign;
+ gint height_extra;
+ gint x2;
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ xalign = priv->label_xalign;
+ else
+ xalign = 1 - priv->label_xalign;
+
+ height_extra = MAX (0, priv->label_allocation.height - padding.top)
+ - priv->label_yalign * priv->label_allocation.height;
+ y -= height_extra;
+ height += height_extra;
+
+ x2 = padding.left + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
+
+ gtk_render_background (context, cr, x, y, width, height);
+
+ /* If the label is completely over or under the frame we can omit the gap */
+ if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
+ gtk_render_frame (context, cr, x, y, width, height);
+ else
+ gtk_render_frame_gap (context, cr,
+ x, y, width, height,
+ GTK_POS_TOP, x2,
+ x2 + priv->label_allocation.width + 2 * LABEL_PAD);
+ }
+ else
+ {
+ gtk_render_background (context, cr, x, y, width, height);
+ gtk_render_frame (context, cr, x, y, width, height);
+ }
+ }
+ else
+ {
+ gtk_render_background (context, cr, x, y, width, height);
}
+ GTK_WIDGET_CLASS (gtk_frame_parent_class)->draw (widget, cr);
+
return FALSE;
}
GtkAllocation *allocation)
{
GtkFrame *frame = GTK_FRAME (widget);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
GtkBin *bin = GTK_BIN (widget);
GtkAllocation new_allocation;
GtkWidget *child;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
gtk_frame_compute_child_allocation (frame, &new_allocation);
/* If the child allocation changed, that means that the frame is drawn
* in a new place, so we must redraw the entire widget.
*/
- if (gtk_widget_get_mapped (widget)
-#if 0
- &&
- (new_allocation.x != priv->child_allocation.x ||
- new_allocation.y != priv->child_allocation.y ||
- new_allocation.width != priv->child_allocation.width ||
- new_allocation.height != priv->child_allocation.height)
-#endif
- )
- gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
+ if (gtk_widget_get_mapped (widget))
+ {
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
+ }
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
+ GtkBorder padding;
gint nat_width, width, height;
gfloat xalign;
+ get_padding_and_border (frame, &padding);
+
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
xalign = priv->label_xalign;
else
xalign = 1 - priv->label_xalign;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width);
+ gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
width = new_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
width = MIN (width, nat_width);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width,
- &height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
+ &height, NULL);
priv->label_allocation.x = priv->child_allocation.x + LABEL_SIDE_PAD +
priv->label_allocation.width = width;
-
- priv->label_allocation.y = priv->child_allocation.y - MAX (height, widget->style->ythickness);
+ priv->label_allocation.y = priv->child_allocation.y - MAX (height, padding.top);
priv->label_allocation.height = height;
gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
gtk_frame_real_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation)
{
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
GtkWidget *widget = GTK_WIDGET (frame);
- GtkAllocation *allocation = &widget->allocation;
+ GtkAllocation allocation;
+ GtkBorder padding;
gint top_margin;
guint border_width;
+ gtk_widget_get_allocation (widget, &allocation);
+ get_padding_and_border (frame, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
if (priv->label_widget)
{
gint nat_width, width, height;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width);
+ gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
- width = widget->allocation.width;
+ width = allocation.width;
width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
- width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ width -= (border_width * 2) + padding.left + padding.right;
width = MIN (width, nat_width);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width,
- &height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
+ &height, NULL);
- top_margin = MAX (height, widget->style->ythickness);
+ top_margin = MAX (height, padding.top);
}
else
- top_margin = widget->style->ythickness;
-
- child_allocation->x = border_width + widget->style->xthickness;
- child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2);
-
+ top_margin = padding.top;
+
+ child_allocation->x = border_width + padding.left;
child_allocation->y = border_width + top_margin;
- child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y -
- border_width -
- (gint)widget->style->ythickness));
-
- child_allocation->x += allocation->x;
- child_allocation->y += allocation->y;
+ child_allocation->width = MAX (1, (gint) (allocation.width - (border_width * 2) -
+ padding.left - padding.right));
+ child_allocation->height = MAX (1, (gint) (allocation.height - child_allocation->y -
+ border_width - padding.bottom));
+
+ child_allocation->x += allocation.x;
+ child_allocation->y += allocation.y;
}
static void
-gtk_frame_get_size (GtkSizeRequest *request,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_size (GtkWidget *request,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
+ GtkFrame *frame = GTK_FRAME (request);
+ GtkFramePrivate *priv = frame->priv;
+ GtkBorder padding;
GtkWidget *widget = GTK_WIDGET (request);
GtkWidget *child;
- GtkFrame *frame = GTK_FRAME (widget);
- GtkFramePriv *priv = frame->priv;
GtkBin *bin = GTK_BIN (widget);
gint child_min, child_nat;
gint minimum, natural;
guint border_width;
+ get_padding_and_border (frame, &padding);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (priv->label_widget,
+ &child_min, &child_nat);
minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
}
else
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->label_widget),
- &child_min, &child_nat);
- minimum = MAX (0, child_min - widget->style->ythickness);
- natural = MAX (0, child_nat - widget->style->ythickness);
+ gtk_widget_get_preferred_height (priv->label_widget,
+ &child_min, &child_nat);
+ minimum = MAX (0, child_min - padding.top);
+ natural = MAX (0, child_nat - padding.top);
}
}
else
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child,
+ &child_min, &child_nat);
minimum = MAX (minimum, child_min);
natural = MAX (natural, child_nat);
}
else
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child,
+ &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
}
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- minimum += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
- natural += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ minimum += (border_width * 2) + padding.left + padding.right;
+ natural += (border_width * 2) + padding.left + padding.right;
}
else
{
- minimum += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
- natural += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
+ minimum += (border_width * 2) + padding.top + padding.bottom;
+ natural += (border_width * 2) + padding.top + padding.bottom;
}
if (minimum_size)
}
static void
-gtk_frame_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_frame_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_frame_get_height_for_width (GtkSizeRequest *request,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_frame_get_preferred_height_for_width (GtkWidget *request,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkWidget *widget = GTK_WIDGET (request);
GtkWidget *child;
GtkFrame *frame = GTK_FRAME (widget);
- GtkFramePriv *priv = frame->priv;
+ GtkFramePrivate *priv = frame->priv;
GtkBin *bin = GTK_BIN (widget);
+ GtkBorder padding;
gint child_min, child_nat, label_width;
gint minimum, natural;
guint border_width;
+ get_padding_and_border (frame, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- minimum = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
- natural = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
- width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ minimum = (border_width * 2) + padding.top + padding.bottom;
+ natural = (border_width * 2) + padding.top + padding.bottom;
+
+ width -= (border_width * 2) + padding.left + padding.right;
label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget),
- label_width, &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget,
+ label_width, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
- width, &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child,
+ width, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
}
static void
-gtk_frame_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- gtk_size_request_get_width (widget, minimum_width, natural_width);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
}
-static void
-gtk_frame_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_frame_get_width;
- iface->get_height = gtk_frame_get_height;
- iface->get_height_for_width = gtk_frame_get_height_for_width;
- iface->get_width_for_height = gtk_frame_get_width_for_height;
-}