forked from AuroraMiddleware/gtk
a1a252ce46
Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
600 lines
17 KiB
C
600 lines
17 KiB
C
/* GTK - The GIMP Toolkit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser 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
|
|
* 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.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include "gtkframe.h"
|
|
#include "gtklabel.h"
|
|
|
|
#define LABEL_PAD 1
|
|
#define LABEL_SIDE_PAD 2
|
|
|
|
enum {
|
|
ARG_0,
|
|
ARG_LABEL,
|
|
ARG_LABEL_XALIGN,
|
|
ARG_LABEL_YALIGN,
|
|
ARG_SHADOW
|
|
};
|
|
|
|
|
|
static void gtk_frame_class_init (GtkFrameClass *klass);
|
|
static void gtk_frame_init (GtkFrame *frame);
|
|
static void gtk_frame_set_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id);
|
|
static void gtk_frame_get_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id);
|
|
static void gtk_frame_paint (GtkWidget *widget,
|
|
GdkRectangle *area);
|
|
static gint gtk_frame_expose (GtkWidget *widget,
|
|
GdkEventExpose *event);
|
|
static void gtk_frame_size_request (GtkWidget *widget,
|
|
GtkRequisition *requisition);
|
|
static void gtk_frame_size_allocate (GtkWidget *widget,
|
|
GtkAllocation *allocation);
|
|
static void gtk_frame_map (GtkWidget *widget);
|
|
static void gtk_frame_unmap (GtkWidget *widget);
|
|
static void gtk_frame_remove (GtkContainer *container,
|
|
GtkWidget *child);
|
|
static void gtk_frame_forall (GtkContainer *container,
|
|
gboolean include_internals,
|
|
GtkCallback callback,
|
|
gpointer callback_data);
|
|
|
|
static void gtk_frame_compute_child_allocation (GtkFrame *frame,
|
|
GtkAllocation *child_allocation);
|
|
static void gtk_frame_real_compute_child_allocation (GtkFrame *frame,
|
|
GtkAllocation *child_allocation);
|
|
|
|
static GtkBinClass *parent_class = NULL;
|
|
|
|
|
|
GtkType
|
|
gtk_frame_get_type (void)
|
|
{
|
|
static GtkType frame_type = 0;
|
|
|
|
if (!frame_type)
|
|
{
|
|
static const GtkTypeInfo frame_info =
|
|
{
|
|
"GtkFrame",
|
|
sizeof (GtkFrame),
|
|
sizeof (GtkFrameClass),
|
|
(GtkClassInitFunc) gtk_frame_class_init,
|
|
(GtkObjectInitFunc) gtk_frame_init,
|
|
/* reserved_1 */ NULL,
|
|
/* reserved_2 */ NULL,
|
|
(GtkClassInitFunc) NULL,
|
|
};
|
|
|
|
frame_type = gtk_type_unique (gtk_bin_get_type (), &frame_info);
|
|
}
|
|
|
|
return frame_type;
|
|
}
|
|
|
|
static void
|
|
gtk_frame_class_init (GtkFrameClass *class)
|
|
{
|
|
GtkObjectClass *object_class;
|
|
GtkWidgetClass *widget_class;
|
|
GtkContainerClass *container_class;
|
|
|
|
object_class = GTK_OBJECT_CLASS (class);
|
|
widget_class = GTK_WIDGET_CLASS (class);
|
|
container_class = GTK_CONTAINER_CLASS (class);
|
|
|
|
parent_class = gtk_type_class (gtk_bin_get_type ());
|
|
|
|
gtk_object_add_arg_type ("GtkFrame::label", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_LABEL);
|
|
gtk_object_add_arg_type ("GtkFrame::label_xalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_XALIGN);
|
|
gtk_object_add_arg_type ("GtkFrame::label_yalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_YALIGN);
|
|
gtk_object_add_arg_type ("GtkFrame::shadow", GTK_TYPE_SHADOW_TYPE, GTK_ARG_READWRITE, ARG_SHADOW);
|
|
|
|
object_class->set_arg = gtk_frame_set_arg;
|
|
object_class->get_arg = gtk_frame_get_arg;
|
|
|
|
widget_class->expose_event = gtk_frame_expose;
|
|
widget_class->size_request = gtk_frame_size_request;
|
|
widget_class->size_allocate = gtk_frame_size_allocate;
|
|
widget_class->map = gtk_frame_map;
|
|
widget_class->unmap = gtk_frame_unmap;
|
|
|
|
container_class->remove = gtk_frame_remove;
|
|
container_class->forall = gtk_frame_forall;
|
|
|
|
class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
|
|
}
|
|
|
|
static void
|
|
gtk_frame_init (GtkFrame *frame)
|
|
{
|
|
frame->label_widget = NULL;
|
|
frame->shadow_type = GTK_SHADOW_ETCHED_IN;
|
|
frame->label_xalign = 0.0;
|
|
frame->label_yalign = 0.5;
|
|
}
|
|
|
|
static void
|
|
gtk_frame_set_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id)
|
|
{
|
|
GtkFrame *frame;
|
|
|
|
frame = GTK_FRAME (object);
|
|
|
|
switch (arg_id)
|
|
{
|
|
case ARG_LABEL:
|
|
gtk_frame_set_label (frame, GTK_VALUE_STRING (*arg));
|
|
break;
|
|
case ARG_LABEL_XALIGN:
|
|
gtk_frame_set_label_align (frame, GTK_VALUE_FLOAT (*arg), frame->label_yalign);
|
|
break;
|
|
case ARG_LABEL_YALIGN:
|
|
gtk_frame_set_label_align (frame, frame->label_xalign, GTK_VALUE_FLOAT (*arg));
|
|
break;
|
|
case ARG_SHADOW:
|
|
gtk_frame_set_shadow_type (frame, GTK_VALUE_ENUM (*arg));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_frame_get_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id)
|
|
{
|
|
GtkFrame *frame;
|
|
|
|
frame = GTK_FRAME (object);
|
|
|
|
switch (arg_id)
|
|
{
|
|
case ARG_LABEL:
|
|
GTK_VALUE_STRING (*arg) = gtk_frame_get_label (frame);
|
|
break;
|
|
case ARG_LABEL_XALIGN:
|
|
GTK_VALUE_FLOAT (*arg) = frame->label_xalign;
|
|
break;
|
|
case ARG_LABEL_YALIGN:
|
|
GTK_VALUE_FLOAT (*arg) = frame->label_yalign;
|
|
break;
|
|
case ARG_SHADOW:
|
|
GTK_VALUE_ENUM (*arg) = frame->shadow_type;
|
|
break;
|
|
default:
|
|
arg->type = GTK_TYPE_INVALID;
|
|
break;
|
|
}
|
|
}
|
|
|
|
GtkWidget*
|
|
gtk_frame_new (const gchar *label)
|
|
{
|
|
GtkFrame *frame;
|
|
|
|
frame = gtk_type_new (gtk_frame_get_type ());
|
|
|
|
gtk_frame_set_label (frame, label);
|
|
|
|
return GTK_WIDGET (frame);
|
|
}
|
|
|
|
static void
|
|
gtk_frame_remove (GtkContainer *container,
|
|
GtkWidget *child)
|
|
{
|
|
GtkFrame *frame = GTK_FRAME (container);
|
|
|
|
if (frame->label_widget == child)
|
|
gtk_frame_set_label_widget (frame, NULL);
|
|
else
|
|
GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
|
|
}
|
|
|
|
static void
|
|
gtk_frame_forall (GtkContainer *container,
|
|
gboolean include_internals,
|
|
GtkCallback callback,
|
|
gpointer callback_data)
|
|
{
|
|
GtkBin *bin = GTK_BIN (container);
|
|
GtkFrame *frame = GTK_FRAME (container);
|
|
|
|
if (bin->child)
|
|
(* callback) (bin->child, callback_data);
|
|
|
|
if (frame->label_widget)
|
|
(* callback) (frame->label_widget, callback_data);
|
|
}
|
|
|
|
void
|
|
gtk_frame_set_label (GtkFrame *frame,
|
|
const gchar *label)
|
|
{
|
|
g_return_if_fail (frame != NULL);
|
|
g_return_if_fail (GTK_IS_FRAME (frame));
|
|
|
|
if (!label)
|
|
{
|
|
gtk_frame_set_label_widget (frame, NULL);
|
|
}
|
|
else
|
|
{
|
|
GtkWidget *child = gtk_label_new (label);
|
|
gtk_widget_show (child);
|
|
|
|
gtk_frame_set_label_widget (frame, child);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* gtk_frame_get_label:
|
|
* @frame: a #GtkFrame
|
|
*
|
|
* If the frame's label widget is a #GtkLabel, return the
|
|
* text in the label widget. (The frame will have a #GtkLabel
|
|
* for the label widget if a non-%NULL argument was passed
|
|
* to gtk_frame_new().)
|
|
*
|
|
* Return value: the text in the label, or %NULL if there
|
|
* was no label widget or the lable widget was not
|
|
* a #GtkLabel. This value must be freed with g_free().
|
|
**/
|
|
G_CONST_RETURN gchar *
|
|
gtk_frame_get_label (GtkFrame *frame)
|
|
{
|
|
g_return_val_if_fail (frame != NULL, NULL);
|
|
g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
|
|
|
|
if (frame->label_widget && GTK_IS_LABEL (frame->label_widget))
|
|
return gtk_label_get_text (GTK_LABEL (frame->label_widget));
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* gtk_frame_set_label_widget:
|
|
* @frame: a #GtkFrame
|
|
* @label_widget: the new label widget
|
|
*
|
|
* Set the label widget for the frame. This is the widget that
|
|
* will appear embedded in the top edge of the frame as a
|
|
* title.
|
|
**/
|
|
void
|
|
gtk_frame_set_label_widget (GtkFrame *frame,
|
|
GtkWidget *label_widget)
|
|
{
|
|
gboolean need_resize = FALSE;
|
|
|
|
g_return_if_fail (frame != NULL);
|
|
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);
|
|
|
|
if (frame->label_widget == label_widget)
|
|
return;
|
|
|
|
if (frame->label_widget)
|
|
{
|
|
need_resize = GTK_WIDGET_VISIBLE (frame->label_widget);
|
|
gtk_widget_unparent (frame->label_widget);
|
|
}
|
|
|
|
frame->label_widget = label_widget;
|
|
|
|
if (label_widget)
|
|
{
|
|
frame->label_widget = label_widget;
|
|
gtk_widget_set_parent (label_widget, GTK_WIDGET (frame));
|
|
need_resize |= GTK_WIDGET_VISIBLE (label_widget);
|
|
}
|
|
|
|
if (GTK_WIDGET_VISIBLE (frame) && need_resize)
|
|
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
|
}
|
|
|
|
void
|
|
gtk_frame_set_label_align (GtkFrame *frame,
|
|
gfloat xalign,
|
|
gfloat yalign)
|
|
{
|
|
g_return_if_fail (frame != NULL);
|
|
g_return_if_fail (GTK_IS_FRAME (frame));
|
|
|
|
xalign = CLAMP (xalign, 0.0, 1.0);
|
|
yalign = CLAMP (yalign, 0.0, 1.0);
|
|
|
|
if ((xalign != frame->label_xalign) || (yalign != frame->label_yalign))
|
|
{
|
|
frame->label_xalign = xalign;
|
|
frame->label_yalign = yalign;
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
|
}
|
|
}
|
|
|
|
void
|
|
gtk_frame_set_shadow_type (GtkFrame *frame,
|
|
GtkShadowType type)
|
|
{
|
|
g_return_if_fail (frame != NULL);
|
|
g_return_if_fail (GTK_IS_FRAME (frame));
|
|
|
|
if ((GtkShadowType) frame->shadow_type != type)
|
|
{
|
|
frame->shadow_type = type;
|
|
|
|
if (GTK_WIDGET_DRAWABLE (frame))
|
|
{
|
|
gtk_widget_queue_clear (GTK_WIDGET (frame));
|
|
}
|
|
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_frame_paint (GtkWidget *widget,
|
|
GdkRectangle *area)
|
|
{
|
|
GtkFrame *frame;
|
|
gint x, y, width, height;
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
{
|
|
frame = GTK_FRAME (widget);
|
|
|
|
x = frame->child_allocation.x - widget->style->xthickness;
|
|
y = frame->child_allocation.y - widget->style->ythickness;
|
|
width = frame->child_allocation.width + 2 * widget->style->xthickness;
|
|
height = frame->child_allocation.height + 2 * widget->style->ythickness;
|
|
|
|
if (frame->label_widget)
|
|
{
|
|
GtkRequisition child_requisition;
|
|
gfloat xalign;
|
|
gint height_extra;
|
|
gint x2;
|
|
|
|
gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
|
xalign = frame->label_xalign;
|
|
else
|
|
xalign = 1 - frame->label_xalign;
|
|
|
|
height_extra = MAX (0, child_requisition.height - widget->style->xthickness);
|
|
y -= height_extra * (1 - frame->label_yalign);
|
|
height += height_extra * (1 - frame->label_yalign);
|
|
|
|
x2 = widget->style->xthickness + (frame->child_allocation.width - child_requisition.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
|
|
|
|
gtk_paint_shadow_gap (widget->style, widget->window,
|
|
GTK_STATE_NORMAL, frame->shadow_type,
|
|
area, widget, "frame",
|
|
x, y, width, height,
|
|
GTK_POS_TOP,
|
|
x2, child_requisition.width + 2 * LABEL_PAD);
|
|
}
|
|
else
|
|
gtk_paint_shadow (widget->style, widget->window,
|
|
GTK_STATE_NORMAL, frame->shadow_type,
|
|
area, widget, "frame",
|
|
x, y, width, height);
|
|
}
|
|
}
|
|
|
|
static gboolean
|
|
gtk_frame_expose (GtkWidget *widget,
|
|
GdkEventExpose *event)
|
|
{
|
|
GtkBin *bin = GTK_BIN (widget);
|
|
GtkFrame *frame = GTK_FRAME (widget);
|
|
GdkEventExpose child_event;
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
{
|
|
gtk_frame_paint (widget, &event->area);
|
|
|
|
if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child))
|
|
{
|
|
child_event = *event;
|
|
if (gtk_widget_intersect (bin->child, &event->area, &child_event.area))
|
|
gtk_widget_event (bin->child, (GdkEvent*) &child_event);
|
|
}
|
|
|
|
if (frame->label_widget && GTK_WIDGET_NO_WINDOW (frame->label_widget))
|
|
{
|
|
child_event = *event;
|
|
if (gtk_widget_intersect (frame->label_widget, &event->area, &child_event.area))
|
|
gtk_widget_event (frame->label_widget, (GdkEvent*) &child_event);
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static void
|
|
gtk_frame_size_request (GtkWidget *widget,
|
|
GtkRequisition *requisition)
|
|
{
|
|
GtkFrame *frame = GTK_FRAME (widget);
|
|
GtkBin *bin = GTK_BIN (widget);
|
|
GtkRequisition child_requisition;
|
|
|
|
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
|
|
{
|
|
gtk_widget_size_request (frame->label_widget, &child_requisition);
|
|
|
|
requisition->width = child_requisition.width + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
|
|
requisition->height =
|
|
MAX (0, child_requisition.height - GTK_WIDGET (widget)->style->xthickness);
|
|
}
|
|
else
|
|
{
|
|
requisition->width = 0;
|
|
requisition->height = 0;
|
|
}
|
|
|
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
|
{
|
|
gtk_widget_size_request (bin->child, &child_requisition);
|
|
|
|
requisition->width = MAX (requisition->width, child_requisition.width);
|
|
requisition->height += child_requisition.height;
|
|
}
|
|
|
|
requisition->width += (GTK_CONTAINER (widget)->border_width +
|
|
GTK_WIDGET (widget)->style->xthickness) * 2;
|
|
requisition->height += (GTK_CONTAINER (widget)->border_width +
|
|
GTK_WIDGET (widget)->style->ythickness) * 2;
|
|
}
|
|
|
|
static void
|
|
gtk_frame_size_allocate (GtkWidget *widget,
|
|
GtkAllocation *allocation)
|
|
{
|
|
GtkFrame *frame = GTK_FRAME (widget);
|
|
GtkBin *bin = GTK_BIN (widget);
|
|
GtkAllocation new_allocation;
|
|
|
|
widget->allocation = *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_MAPPED (widget) &&
|
|
(new_allocation.x != frame->child_allocation.x ||
|
|
new_allocation.y != frame->child_allocation.y ||
|
|
new_allocation.width != frame->child_allocation.width ||
|
|
new_allocation.height != frame->child_allocation.height))
|
|
gtk_widget_queue_clear (widget);
|
|
|
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
|
gtk_widget_size_allocate (bin->child, &new_allocation);
|
|
|
|
frame->child_allocation = new_allocation;
|
|
|
|
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
|
|
{
|
|
GtkRequisition child_requisition;
|
|
GtkAllocation child_allocation;
|
|
gfloat xalign;
|
|
|
|
gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
|
xalign = frame->label_xalign;
|
|
else
|
|
xalign = 1 - frame->label_xalign;
|
|
|
|
child_allocation.x = frame->child_allocation.x + LABEL_SIDE_PAD +
|
|
(frame->child_allocation.width - child_requisition.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_PAD;
|
|
child_allocation.width = child_requisition.width;
|
|
|
|
child_allocation.y = frame->child_allocation.y - child_requisition.height;
|
|
child_allocation.height = child_requisition.height;
|
|
|
|
gtk_widget_size_allocate (frame->label_widget, &child_allocation);
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_frame_map (GtkWidget *widget)
|
|
{
|
|
GtkFrame *frame = GTK_FRAME (widget);
|
|
|
|
if (frame->label_widget &&
|
|
GTK_WIDGET_VISIBLE (frame->label_widget) &&
|
|
!GTK_WIDGET_MAPPED (frame->label_widget))
|
|
gtk_widget_map (frame->label_widget);
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->map)
|
|
(* GTK_WIDGET_CLASS (parent_class)->map) (widget);
|
|
}
|
|
|
|
static void
|
|
gtk_frame_unmap (GtkWidget *widget)
|
|
{
|
|
GtkFrame *frame = GTK_FRAME (widget);
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->unmap)
|
|
(* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
|
|
|
|
if (frame->label_widget && GTK_WIDGET_MAPPED (frame->label_widget))
|
|
gtk_widget_unmap (frame->label_widget);
|
|
}
|
|
|
|
static void
|
|
gtk_frame_compute_child_allocation (GtkFrame *frame,
|
|
GtkAllocation *child_allocation)
|
|
{
|
|
g_return_if_fail (frame != NULL);
|
|
g_return_if_fail (GTK_IS_FRAME (frame));
|
|
g_return_if_fail (child_allocation != NULL);
|
|
|
|
GTK_FRAME_GET_CLASS (frame)->compute_child_allocation (frame, child_allocation);
|
|
}
|
|
|
|
static void
|
|
gtk_frame_real_compute_child_allocation (GtkFrame *frame,
|
|
GtkAllocation *child_allocation)
|
|
{
|
|
GtkWidget *widget = GTK_WIDGET (frame);
|
|
GtkAllocation *allocation = &widget->allocation;
|
|
GtkRequisition child_requisition;
|
|
gint top_margin;
|
|
|
|
if (frame->label_widget)
|
|
{
|
|
gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
|
|
top_margin = MAX (child_requisition.height, widget->style->ythickness);
|
|
}
|
|
else
|
|
top_margin = widget->style->ythickness;
|
|
|
|
child_allocation->x = (GTK_CONTAINER (frame)->border_width +
|
|
widget->style->xthickness);
|
|
child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2);
|
|
|
|
child_allocation->y = (GTK_CONTAINER (frame)->border_width + top_margin);
|
|
child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y -
|
|
(gint)GTK_CONTAINER (frame)->border_width -
|
|
(gint)widget->style->ythickness));
|
|
|
|
child_allocation->x += allocation->x;
|
|
child_allocation->y += allocation->y;
|
|
}
|