gimp/app/widgets/gtkhwrapbox.c

620 lines
16 KiB
C
Raw Normal View History

/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* 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.
*/
#include "config.h"
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "gtkhwrapbox.h"
/* --- prototypes --- */
1999-09-04 14:29:10 +08:00
static void gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass);
static void gtk_hwrap_box_init (GtkHWrapBox *hwbox);
static void gtk_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_hwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static GSList* reverse_list_row_children (GtkWrapBox *wbox,
GtkWrapBoxChild **child_p,
GtkAllocation *area,
guint *max_height,
gboolean *can_vexpand);
/* --- variables --- */
static gpointer parent_class = NULL;
/* --- functions --- */
GtkType
gtk_hwrap_box_get_type (void)
{
static GtkType hwrap_box_type = 0;
if (!hwrap_box_type)
{
static const GtkTypeInfo hwrap_box_info =
{
"GtkHWrapBox",
sizeof (GtkHWrapBox),
sizeof (GtkHWrapBoxClass),
(GtkClassInitFunc) gtk_hwrap_box_class_init,
(GtkObjectInitFunc) gtk_hwrap_box_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
hwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &hwrap_box_info);
}
return hwrap_box_type;
}
static void
gtk_hwrap_box_class_init (GtkHWrapBoxClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWrapBoxClass *wrap_box_class;
object_class = GTK_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
wrap_box_class = GTK_WRAP_BOX_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_WRAP_BOX);
widget_class->size_request = gtk_hwrap_box_size_request;
widget_class->size_allocate = gtk_hwrap_box_size_allocate;
1999-09-04 14:29:10 +08:00
wrap_box_class->rlist_line_children = reverse_list_row_children;
}
static void
gtk_hwrap_box_init (GtkHWrapBox *hwbox)
{
hwbox->max_child_width = 0;
hwbox->max_child_height = 0;
}
1999-09-04 14:29:10 +08:00
GtkWidget*
gtk_hwrap_box_new (gboolean homogeneous)
{
GtkHWrapBox *hwbox;
1999-09-04 14:29:10 +08:00
hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static inline void
get_child_requisition (GtkWrapBox *wbox,
GtkWidget *child,
GtkRequisition *child_requisition)
{
if (wbox->homogeneous)
{
GtkHWrapBox *hwbox = GTK_HWRAP_BOX (wbox);
child_requisition->width = hwbox->max_child_width;
child_requisition->height = hwbox->max_child_height;
}
else
gtk_widget_get_child_requisition (child, child_requisition);
}
static gfloat
get_layout_size (GtkHWrapBox *this,
guint max_width,
guint *width_inc)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (this);
GtkWrapBoxChild *child;
guint n_rows, left_over = 0, total_height = 0;
gboolean last_row_filled = TRUE;
*width_inc = this->max_child_width + 1;
n_rows = 0;
for (child = wbox->children; child; child = child->next)
{
GtkWrapBoxChild *row_child;
GtkRequisition child_requisition;
guint row_width, row_height, n = 1;
if (!GTK_WIDGET_VISIBLE (child->widget))
continue;
get_child_requisition (wbox, child->widget, &child_requisition);
if (!last_row_filled)
*width_inc = MIN (*width_inc, child_requisition.width - left_over);
row_width = child_requisition.width;
row_height = child_requisition.height;
for (row_child = child->next; row_child && n < wbox->child_limit; row_child = row_child->next)
{
if (GTK_WIDGET_VISIBLE (row_child->widget))
{
get_child_requisition (wbox, row_child->widget, &child_requisition);
if (row_width + wbox->hspacing + child_requisition.width > max_width)
break;
row_width += wbox->hspacing + child_requisition.width;
row_height = MAX (row_height, child_requisition.height);
n++;
}
child = row_child;
}
last_row_filled = n >= wbox->child_limit;
left_over = last_row_filled ? 0 : max_width - (row_width + wbox->hspacing);
total_height += (n_rows ? wbox->vspacing : 0) + row_height;
n_rows++;
}
if (*width_inc > this->max_child_width)
*width_inc = 0;
return MAX (total_height, 1);
}
static void
gtk_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkHWrapBox *this = GTK_HWRAP_BOX (widget);
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_width = 0;
guint row_inc = 0;
g_return_if_fail (requisition != NULL);
requisition->width = 0;
requisition->height = 0;
this->max_child_width = 0;
this->max_child_height = 0;
/* size_request all children */
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
gtk_widget_size_request (child->widget, &child_requisition);
this->max_child_width = MAX (this->max_child_width, child_requisition.width);
this->max_child_height = MAX (this->max_child_height, child_requisition.height);
}
/* figure all possible layouts */
ratio_dist = 32768;
layout_width = this->max_child_width;
do
{
gfloat layout_height;
gfloat ratio, dist;
layout_width += row_inc;
layout_height = get_layout_size (this, layout_width, &row_inc);
ratio = layout_width / layout_height; /*<h2v-skip>*/
dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio);
if (dist < ratio_dist)
{
ratio_dist = dist;
requisition->width = layout_width;
requisition->height = layout_height;
}
1999-09-04 14:29:10 +08:00
/* g_print ("ratio for width %d height %d = %f\n",
1999-09-04 14:29:10 +08:00
(gint) layout_width,
(gint) layout_height,
ratio);
*/
}
while (row_inc);
1999-09-04 14:29:10 +08:00
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
/* g_print ("choosen: width %d, height %d\n",
1999-09-04 14:29:10 +08:00
requisition->width,
requisition->height);
*/
}
static GSList*
1999-09-04 14:29:10 +08:00
reverse_list_row_children (GtkWrapBox *wbox,
GtkWrapBoxChild **child_p,
GtkAllocation *area,
guint *max_child_size,
gboolean *expand_line)
{
GSList *slist = NULL;
1999-09-04 14:29:10 +08:00
guint width = 0, row_width = area->width;
GtkWrapBoxChild *child = *child_p;
1999-09-04 14:29:10 +08:00
*max_child_size = 0;
*expand_line = FALSE;
while (child && !GTK_WIDGET_VISIBLE (child->widget))
{
*child_p = child->next;
child = *child_p;
}
if (child)
{
GtkRequisition child_requisition;
guint n = 1;
get_child_requisition (wbox, child->widget, &child_requisition);
width += child_requisition.width;
1999-09-04 14:29:10 +08:00
*max_child_size = MAX (*max_child_size, child_requisition.height);
*expand_line |= child->vexpand;
slist = g_slist_prepend (slist, child);
*child_p = child->next;
child = *child_p;
while (child && n < wbox->child_limit)
{
if (GTK_WIDGET_VISIBLE (child->widget))
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (width + wbox->hspacing + child_requisition.width > row_width ||
added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. 2001-08-29 Michael Natterer <mitch@gimp.org> * configure.in: added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. * app/batch.c * app/file-utils.c * app/gdisplay.c * app/gdisplay_ops.c * app/gimprc.[ch] * app/module_db.c * app/nav_window.c * app/undo_history.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimppalette.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/error-console-dialog.c * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-import-dialog.c * app/tools/gimpbycolorselecttool.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpmenu.c * plug-ins/common/bz2.c * plug-ins/common/compose.c * plug-ins/common/csource.c * plug-ins/common/decompose.c * plug-ins/common/gz.c * plug-ins/common/uniteditor.c * plug-ins/common/wmf.c * plug-ins/common/xbm.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/interp_slib.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gimprc.pdb * app/pdb/fileops_cmds.c * app/pdb/gimprc_cmds.c: removed deprecated stuff like g_basename(), g_dirname(), g_strup() and friends. Added some "const gchar *" declarations while I was on it. Added some G_N_ELEMENTS() macros instead of declaring a useless variable for the number of items. * app/widgets/gtkhwrapbox.[ch] * app/widgets/gtkvwrapbox.[ch] * app/widgets/gtkwrapbox.[ch]: replaced with the latest versions from GLE, ported by the master himself. * app/gui/toolbox.c: changed accordingly. * app/plug_in.c * libgimp/gimp.c * libgimpbase/gimpwire.[ch]: use evil hacks to get binary mode from the new GIOChannel implementation (upstream bugreport already posted).
2001-08-30 01:48:28 +08:00
child->wrapped)
break;
width += wbox->hspacing + child_requisition.width;
1999-09-04 14:29:10 +08:00
*max_child_size = MAX (*max_child_size, child_requisition.height);
*expand_line |= child->vexpand;
slist = g_slist_prepend (slist, child);
n++;
}
*child_p = child->next;
child = *child_p;
}
}
1999-09-04 14:29:10 +08:00
return slist;
}
static void
layout_row (GtkWrapBox *wbox,
GtkAllocation *area,
GSList *children,
guint children_per_line,
gboolean vexpand)
{
GSList *slist;
added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. 2001-08-29 Michael Natterer <mitch@gimp.org> * configure.in: added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. * app/batch.c * app/file-utils.c * app/gdisplay.c * app/gdisplay_ops.c * app/gimprc.[ch] * app/module_db.c * app/nav_window.c * app/undo_history.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimppalette.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/error-console-dialog.c * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-import-dialog.c * app/tools/gimpbycolorselecttool.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpmenu.c * plug-ins/common/bz2.c * plug-ins/common/compose.c * plug-ins/common/csource.c * plug-ins/common/decompose.c * plug-ins/common/gz.c * plug-ins/common/uniteditor.c * plug-ins/common/wmf.c * plug-ins/common/xbm.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/interp_slib.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gimprc.pdb * app/pdb/fileops_cmds.c * app/pdb/gimprc_cmds.c: removed deprecated stuff like g_basename(), g_dirname(), g_strup() and friends. Added some "const gchar *" declarations while I was on it. Added some G_N_ELEMENTS() macros instead of declaring a useless variable for the number of items. * app/widgets/gtkhwrapbox.[ch] * app/widgets/gtkvwrapbox.[ch] * app/widgets/gtkwrapbox.[ch]: replaced with the latest versions from GLE, ported by the master himself. * app/gui/toolbox.c: changed accordingly. * app/plug_in.c * libgimp/gimp.c * libgimpbase/gimpwire.[ch]: use evil hacks to get binary mode from the new GIOChannel implementation (upstream bugreport already posted).
2001-08-30 01:48:28 +08:00
guint n_children = 0, n_expand_children = 0, have_expand_children = 0;
gint total_width = 0;
gfloat x, width, extra;
GtkAllocation child_allocation;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
GtkRequisition child_requisition;
n_children++;
if (child->hexpand)
n_expand_children++;
get_child_requisition (wbox, child->widget, &child_requisition);
total_width += child_requisition.width;
}
width = MAX (1, area->width - (n_children - 1) * wbox->hspacing);
if (width > total_width)
extra = width - total_width;
else
extra = 0;
have_expand_children = n_expand_children && extra;
x = area->x;
if (wbox->homogeneous)
{
width = MAX (1, area->width - (children_per_line - 1) * wbox->hspacing);
width /= ((gdouble) children_per_line);
extra = 0;
}
else if (have_expand_children && wbox->justify != GTK_JUSTIFY_FILL)
{
width = extra;
extra /= ((gdouble) n_expand_children);
}
else
{
if (wbox->justify == GTK_JUSTIFY_FILL)
{
width = extra;
have_expand_children = TRUE;
n_expand_children = n_children;
extra /= ((gdouble) n_expand_children);
}
else if (wbox->justify == GTK_JUSTIFY_CENTER)
{
x += extra / 2;
width = 0;
extra = 0;
}
else if (wbox->justify == GTK_JUSTIFY_LEFT)
{
width = 0;
extra = 0;
}
else if (wbox->justify == GTK_JUSTIFY_RIGHT)
{
x += extra;
width = 0;
extra = 0;
}
}
n_children = 0;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
child_allocation.x = x;
child_allocation.y = area->y;
if (wbox->homogeneous)
{
child_allocation.height = area->height;
child_allocation.width = width;
x += child_allocation.width + wbox->hspacing;
}
else
{
GtkRequisition child_requisition;
get_child_requisition (wbox, child->widget, &child_requisition);
if (child_requisition.height >= area->height)
child_allocation.height = area->height;
else
{
child_allocation.height = child_requisition.height;
if (wbox->line_justify == GTK_JUSTIFY_FILL || child->vfill)
child_allocation.height = area->height;
else if (child->vexpand || wbox->line_justify == GTK_JUSTIFY_CENTER)
child_allocation.y += (area->height - child_requisition.height) / 2;
else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
child_allocation.y += area->height - child_requisition.height;
}
if (have_expand_children)
{
child_allocation.width = child_requisition.width;
if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
{
guint space;
n_expand_children--;
space = extra * n_expand_children;
space = width - space;
width -= space;
if (child->hfill)
child_allocation.width += space;
else
{
child_allocation.x += space / 2;
x += space;
}
}
}
else
{
/* g_print ("child_allocation.x %d += %d * %f ",
child_allocation.x, n_children, extra); */
child_allocation.x += n_children * extra;
/* g_print ("= %d\n",
child_allocation.x); */
child_allocation.width = MIN (child_requisition.width,
area->width - child_allocation.x + area->x);
}
}
x += child_allocation.width + wbox->hspacing;
gtk_widget_size_allocate (child->widget, &child_allocation);
n_children++;
}
}
typedef struct _Line Line;
struct _Line
{
GSList *children;
guint16 min_size;
guint expand : 1;
Line *next;
};
static void
layout_rows (GtkWrapBox *wbox,
GtkAllocation *area)
{
GtkWrapBoxChild *next_child;
guint min_height;
gboolean vexpand;
GSList *slist;
Line *line_list = NULL;
guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height;
guint children_per_line;
next_child = wbox->children;
1999-09-04 14:29:10 +08:00
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
area,
&min_height,
&vexpand);
slist = g_slist_reverse (slist);
children_per_line = g_slist_length (slist);
while (slist)
{
Line *line = g_new (Line, 1);
line->children = slist;
line->min_size = min_height;
total_height += min_height;
line->expand = vexpand;
if (vexpand)
n_expand_lines++;
line->next = line_list;
line_list = line;
n_lines++;
1999-09-04 14:29:10 +08:00
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
area,
&min_height,
&vexpand);
slist = g_slist_reverse (slist);
}
1999-09-04 14:29:10 +08:00
if (total_height > area->height)
shrink_height = total_height - area->height;
else
shrink_height = 0;
1999-09-04 14:29:10 +08:00
if (1) /* reverse lines and shrink */
{
Line *prev = NULL, *last = NULL;
gfloat n_shrink_lines = n_lines;
while (line_list)
{
Line *tmp = line_list->next;
if (shrink_height)
{
Line *line = line_list;
guint shrink_fract = shrink_height / n_shrink_lines + 0.5;
if (line->min_size > shrink_fract)
{
shrink_height -= shrink_fract;
line->min_size -= shrink_fract;
}
else
{
shrink_height -= line->min_size - 1;
line->min_size = 1;
}
}
n_shrink_lines--;
last = line_list;
line_list->next = prev;
prev = line_list;
line_list = tmp;
}
line_list = last;
}
if (n_lines)
{
Line *line;
gfloat y, height, extra = 0;
height = area->height;
height = MAX (n_lines, height - (n_lines - 1) * wbox->vspacing);
if (wbox->homogeneous)
height /= ((gdouble) n_lines);
else if (n_expand_lines)
{
height = MAX (0, height - total_height);
extra = height / ((gdouble) n_expand_lines);
}
else
height = 0;
y = area->y;
line = line_list;
while (line)
{
GtkAllocation row_allocation;
Line *next_line = line->next;
row_allocation.x = area->x;
row_allocation.width = area->width;
if (wbox->homogeneous)
row_allocation.height = height;
else
{
row_allocation.height = line->min_size;
if (line->expand)
row_allocation.height += extra;
}
row_allocation.y = y;
y += row_allocation.height + wbox->vspacing;
layout_row (wbox,
&row_allocation,
line->children,
children_per_line,
line->expand);
g_slist_free (line->children);
g_free (line);
line = next_line;
}
}
}
static void
gtk_hwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. 2001-08-29 Michael Natterer <mitch@gimp.org> * configure.in: added -DG_DISABLE_DEPRECATED and -DGDK_DISABLE_COMPAT_H. * app/batch.c * app/file-utils.c * app/gdisplay.c * app/gdisplay_ops.c * app/gimprc.[ch] * app/module_db.c * app/nav_window.c * app/undo_history.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimppalette.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/error-console-dialog.c * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-import-dialog.c * app/tools/gimpbycolorselecttool.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpmenu.c * plug-ins/common/bz2.c * plug-ins/common/compose.c * plug-ins/common/csource.c * plug-ins/common/decompose.c * plug-ins/common/gz.c * plug-ins/common/uniteditor.c * plug-ins/common/wmf.c * plug-ins/common/xbm.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/interp_slib.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gimprc.pdb * app/pdb/fileops_cmds.c * app/pdb/gimprc_cmds.c: removed deprecated stuff like g_basename(), g_dirname(), g_strup() and friends. Added some "const gchar *" declarations while I was on it. Added some G_N_ELEMENTS() macros instead of declaring a useless variable for the number of items. * app/widgets/gtkhwrapbox.[ch] * app/widgets/gtkvwrapbox.[ch] * app/widgets/gtkwrapbox.[ch]: replaced with the latest versions from GLE, ported by the master himself. * app/gui/toolbox.c: changed accordingly. * app/plug_in.c * libgimp/gimp.c * libgimpbase/gimpwire.[ch]: use evil hacks to get binary mode from the new GIOChannel implementation (upstream bugreport already posted).
2001-08-30 01:48:28 +08:00
gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
widget->allocation = *allocation;
area.x = allocation->x + border;
area.y = allocation->y + border;
area.width = MAX (1, (gint) allocation->width - border * 2);
area.height = MAX (1, (gint) allocation->height - border * 2);
/*<h2v-off>*/
/* g_print ("got: width %d, height %d\n",
1999-09-04 14:29:10 +08:00
allocation->width,
allocation->height);
*/
/*<h2v-on>*/
layout_rows (wbox, &area);
}