mirror of https://github.com/GNOME/gimp.git
parent
cd70fa440e
commit
adfadca186
|
@ -1,3 +1,8 @@
|
|||
Fri Sep 3 23:26:38 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/gtkwrapbox.[ch]
|
||||
* app/gtk[hv]wrapbox.c: gle sync
|
||||
|
||||
Fri Sep 3 23:17:44 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* plug-ins/common/mkgen.pl: autogen .cvsignore too
|
||||
|
|
|
@ -24,12 +24,17 @@
|
|||
|
||||
|
||||
/* --- prototypes --- */
|
||||
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 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 --- */
|
||||
|
@ -79,6 +84,8 @@ gtk_hwrap_box_class_init (GtkHWrapBoxClass *class)
|
|||
|
||||
widget_class->size_request = gtk_hwrap_box_size_request;
|
||||
widget_class->size_allocate = gtk_hwrap_box_size_allocate;
|
||||
|
||||
wrap_box_class->rlist_line_children = reverse_list_row_children;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,12 +95,12 @@ gtk_hwrap_box_init (GtkHWrapBox *hwbox)
|
|||
hwbox->max_child_height = 0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
GtkWidget*
|
||||
gtk_hwrap_box_new (gboolean homogeneous)
|
||||
{
|
||||
GtkHWrapBox *hwbox;
|
||||
|
||||
hwbox = GTK_HWRAP_BOX (gtk_widget_new (gtk_hwrap_box_get_type (), NULL));
|
||||
hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL));
|
||||
|
||||
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
|
||||
|
||||
|
@ -262,38 +269,36 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
|
|||
requisition->width = layout_width;
|
||||
requisition->height = layout_height;
|
||||
}
|
||||
|
||||
/*<h2v-off>*/
|
||||
|
||||
/* g_print ("ratio for width %d height %d = %f\n",
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio); */
|
||||
/*<h2v-on>*/
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio);
|
||||
*/
|
||||
}
|
||||
while (row_inc);
|
||||
|
||||
/*<h2v-off>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
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",
|
||||
requisition->width,
|
||||
requisition->height); */
|
||||
/*<h2v-on>*/
|
||||
requisition->width,
|
||||
requisition->height);
|
||||
*/
|
||||
}
|
||||
|
||||
static GSList*
|
||||
list_row_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
guint row_width,
|
||||
guint *max_height,
|
||||
gboolean *can_vexpand)
|
||||
reverse_list_row_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line)
|
||||
{
|
||||
GSList *slist = NULL;
|
||||
guint width = 0;
|
||||
guint width = 0, row_width = area->width;
|
||||
GtkWrapBoxChild *child = *child_p;
|
||||
|
||||
*max_height = 0;
|
||||
*can_vexpand = FALSE;
|
||||
*max_child_size = 0;
|
||||
*expand_line = FALSE;
|
||||
|
||||
while (child && !GTK_WIDGET_VISIBLE (child->widget))
|
||||
{
|
||||
|
@ -308,8 +313,8 @@ list_row_children (GtkWrapBox *wbox,
|
|||
|
||||
get_child_requisition (wbox, child->widget, &child_requisition);
|
||||
width += child_requisition.width;
|
||||
*max_height = MAX (*max_height, child_requisition.height);
|
||||
*can_vexpand |= child->vexpand;
|
||||
*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;
|
||||
|
@ -322,8 +327,8 @@ list_row_children (GtkWrapBox *wbox,
|
|||
if (width + wbox->hspacing + child_requisition.width > row_width)
|
||||
break;
|
||||
width += wbox->hspacing + child_requisition.width;
|
||||
*max_height = MAX (*max_height, child_requisition.height);
|
||||
*can_vexpand |= child->vexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.height);
|
||||
*expand_line |= child->vexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
n++;
|
||||
}
|
||||
|
@ -332,7 +337,7 @@ list_row_children (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (slist);
|
||||
return slist;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -500,7 +505,13 @@ layout_rows (GtkWrapBox *wbox,
|
|||
guint children_per_line;
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = list_row_children (wbox, &next_child, area->width, &min_height, &vexpand);
|
||||
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)
|
||||
{
|
||||
|
@ -516,19 +527,20 @@ layout_rows (GtkWrapBox *wbox,
|
|||
line_list = line;
|
||||
n_lines++;
|
||||
|
||||
slist = list_row_children (wbox,
|
||||
&next_child,
|
||||
area->width,
|
||||
&min_height,
|
||||
&vexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_height,
|
||||
&vexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
}
|
||||
|
||||
|
||||
if (total_height > area->height)
|
||||
shrink_height = total_height - area->height;
|
||||
else
|
||||
shrink_height = 0;
|
||||
|
||||
if (1) /* reverse and shrink */
|
||||
if (1) /* reverse lines and shrink */
|
||||
{
|
||||
Line *prev = NULL, *last = NULL;
|
||||
gfloat n_shrink_lines = n_lines;
|
||||
|
@ -632,8 +644,9 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
|
|||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("got: width %d, height %d\n",
|
||||
allocation->width,
|
||||
allocation->height); */
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
*/
|
||||
/*<h2v-on>*/
|
||||
|
||||
layout_rows (wbox, &area);
|
||||
|
|
|
@ -24,12 +24,17 @@
|
|||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
|
||||
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
|
||||
static void gtk_vwrap_box_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
|
||||
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
|
||||
static void gtk_vwrap_box_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static GSList* reverse_list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_width,
|
||||
gboolean *can_hexpand);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
|
@ -79,6 +84,8 @@ gtk_vwrap_box_class_init (GtkVWrapBoxClass *class)
|
|||
|
||||
widget_class->size_request = gtk_vwrap_box_size_request;
|
||||
widget_class->size_allocate = gtk_vwrap_box_size_allocate;
|
||||
|
||||
wrap_box_class->rlist_line_children = reverse_list_col_children;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,12 +95,12 @@ gtk_vwrap_box_init (GtkVWrapBox *vwbox)
|
|||
vwbox->max_child_width = 0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
GtkWidget*
|
||||
gtk_vwrap_box_new (gboolean homogeneous)
|
||||
{
|
||||
GtkVWrapBox *vwbox;
|
||||
|
||||
vwbox = GTK_VWRAP_BOX (gtk_widget_new (gtk_vwrap_box_get_type (), NULL));
|
||||
vwbox = GTK_VWRAP_BOX (gtk_widget_new (GTK_TYPE_VWRAP_BOX, NULL));
|
||||
|
||||
GTK_WRAP_BOX (vwbox)->homogeneous = homogeneous ? TRUE : FALSE;
|
||||
|
||||
|
@ -262,38 +269,36 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
|
|||
requisition->height = layout_height;
|
||||
requisition->width = layout_width;
|
||||
}
|
||||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("ratio for width %d height %d = %f\n",
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio); */
|
||||
/*<h2v-on>*/
|
||||
|
||||
/* g_print ("ratio for height %d width %d = %f\n",
|
||||
(gint) layout_height,
|
||||
(gint) layout_width,
|
||||
ratio);
|
||||
*/
|
||||
}
|
||||
while (col_inc);
|
||||
|
||||
/*<h2v-off>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
/* g_print ("choosen: width %d, height %d\n",
|
||||
requisition->width,
|
||||
requisition->height); */
|
||||
/*<h2v-on>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
|
||||
/* g_print ("choosen: height %d, width %d\n",
|
||||
requisition->height,
|
||||
requisition->width);
|
||||
*/
|
||||
}
|
||||
|
||||
static GSList*
|
||||
list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
guint col_height,
|
||||
guint *max_width,
|
||||
gboolean *can_hexpand)
|
||||
reverse_list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line)
|
||||
{
|
||||
GSList *slist = NULL;
|
||||
guint height = 0;
|
||||
guint height = 0, col_height = area->height;
|
||||
GtkWrapBoxChild *child = *child_p;
|
||||
|
||||
*max_width = 0;
|
||||
*can_hexpand = FALSE;
|
||||
*max_child_size = 0;
|
||||
*expand_line = FALSE;
|
||||
|
||||
while (child && !GTK_WIDGET_VISIBLE (child->widget))
|
||||
{
|
||||
|
@ -308,8 +313,8 @@ list_col_children (GtkWrapBox *wbox,
|
|||
|
||||
get_child_requisition (wbox, child->widget, &child_requisition);
|
||||
height += child_requisition.height;
|
||||
*max_width = MAX (*max_width, child_requisition.width);
|
||||
*can_hexpand |= child->hexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.width);
|
||||
*expand_line |= child->hexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
*child_p = child->next;
|
||||
child = *child_p;
|
||||
|
@ -322,8 +327,8 @@ list_col_children (GtkWrapBox *wbox,
|
|||
if (height + wbox->vspacing + child_requisition.height > col_height)
|
||||
break;
|
||||
height += wbox->vspacing + child_requisition.height;
|
||||
*max_width = MAX (*max_width, child_requisition.width);
|
||||
*can_hexpand |= child->hexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.width);
|
||||
*expand_line |= child->hexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
n++;
|
||||
}
|
||||
|
@ -332,7 +337,7 @@ list_col_children (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (slist);
|
||||
return slist;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -500,7 +505,13 @@ layout_cols (GtkWrapBox *wbox,
|
|||
guint children_per_line;
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = list_col_children (wbox, &next_child, area->height, &min_width, &hexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
|
||||
children_per_line = g_slist_length (slist);
|
||||
while (slist)
|
||||
{
|
||||
|
@ -516,19 +527,20 @@ layout_cols (GtkWrapBox *wbox,
|
|||
line_list = line;
|
||||
n_lines++;
|
||||
|
||||
slist = list_col_children (wbox,
|
||||
&next_child,
|
||||
area->height,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
}
|
||||
|
||||
|
||||
if (total_width > area->width)
|
||||
shrink_width = total_width - area->width;
|
||||
else
|
||||
shrink_width = 0;
|
||||
|
||||
if (1) /* reverse and shrink */
|
||||
if (1) /* reverse lines and shrink */
|
||||
{
|
||||
Line *prev = NULL, *last = NULL;
|
||||
gfloat n_shrink_lines = n_lines;
|
||||
|
@ -632,8 +644,9 @@ gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
|||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("got: width %d, height %d\n",
|
||||
allocation->width,
|
||||
allocation->height); */
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
*/
|
||||
/*<h2v-on>*/
|
||||
|
||||
layout_cols (wbox, &area);
|
||||
|
|
|
@ -137,6 +137,8 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
|
|||
container_class->child_type = gtk_wrap_box_child_type;
|
||||
container_class->set_child_arg = gtk_wrap_box_set_child_arg;
|
||||
container_class->get_child_arg = gtk_wrap_box_get_child_arg;
|
||||
|
||||
class->rlist_line_children = NULL;
|
||||
|
||||
gtk_object_add_arg_type ("GtkWrapBox::homogeneous",
|
||||
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
|
||||
|
@ -599,6 +601,54 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
guint*
|
||||
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
|
||||
guint *_n_lines)
|
||||
{
|
||||
GtkWrapBoxChild *next_child = NULL;
|
||||
GtkAllocation area, *allocation;
|
||||
gboolean expand_line;
|
||||
GSList *slist;
|
||||
guint max_child_size, border, n_lines = 0, *lines = NULL;
|
||||
|
||||
if (_n_lines)
|
||||
*_n_lines = 0;
|
||||
g_return_val_if_fail (GTK_IS_WRAP_BOX (wbox), NULL);
|
||||
|
||||
allocation = >K_WIDGET (wbox)->allocation;
|
||||
border = GTK_CONTAINER (wbox)->border_width;
|
||||
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);
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
&area,
|
||||
&max_child_size,
|
||||
&expand_line);
|
||||
while (slist)
|
||||
{
|
||||
guint l = n_lines++;
|
||||
|
||||
lines = g_renew (guint, lines, n_lines);
|
||||
lines[l] = g_slist_length (slist);
|
||||
g_slist_free (slist);
|
||||
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
&area,
|
||||
&max_child_size,
|
||||
&expand_line);
|
||||
}
|
||||
|
||||
if (_n_lines)
|
||||
*_n_lines = n_lines;
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_wrap_box_map (GtkWidget *widget)
|
||||
{
|
||||
|
@ -659,7 +709,7 @@ gtk_wrap_box_expose (GtkWidget *widget,
|
|||
gtk_widget_intersect (child->widget, &event->area, &child_event.area))
|
||||
gtk_widget_event (child->widget, (GdkEvent*) &child_event);
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -64,6 +64,12 @@ struct _GtkWrapBox
|
|||
struct _GtkWrapBoxClass
|
||||
{
|
||||
GtkContainerClass parent_class;
|
||||
|
||||
GSList* (*rlist_line_children) (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line);
|
||||
};
|
||||
struct _GtkWrapBoxChild
|
||||
{
|
||||
|
@ -114,6 +120,8 @@ void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
|
|||
gboolean hfill,
|
||||
gboolean vexpand,
|
||||
gboolean vfill);
|
||||
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
|
||||
guint *n_lines);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -24,12 +24,17 @@
|
|||
|
||||
|
||||
/* --- prototypes --- */
|
||||
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 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 --- */
|
||||
|
@ -79,6 +84,8 @@ gtk_hwrap_box_class_init (GtkHWrapBoxClass *class)
|
|||
|
||||
widget_class->size_request = gtk_hwrap_box_size_request;
|
||||
widget_class->size_allocate = gtk_hwrap_box_size_allocate;
|
||||
|
||||
wrap_box_class->rlist_line_children = reverse_list_row_children;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,12 +95,12 @@ gtk_hwrap_box_init (GtkHWrapBox *hwbox)
|
|||
hwbox->max_child_height = 0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
GtkWidget*
|
||||
gtk_hwrap_box_new (gboolean homogeneous)
|
||||
{
|
||||
GtkHWrapBox *hwbox;
|
||||
|
||||
hwbox = GTK_HWRAP_BOX (gtk_widget_new (gtk_hwrap_box_get_type (), NULL));
|
||||
hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL));
|
||||
|
||||
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
|
||||
|
||||
|
@ -262,38 +269,36 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
|
|||
requisition->width = layout_width;
|
||||
requisition->height = layout_height;
|
||||
}
|
||||
|
||||
/*<h2v-off>*/
|
||||
|
||||
/* g_print ("ratio for width %d height %d = %f\n",
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio); */
|
||||
/*<h2v-on>*/
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio);
|
||||
*/
|
||||
}
|
||||
while (row_inc);
|
||||
|
||||
/*<h2v-off>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
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",
|
||||
requisition->width,
|
||||
requisition->height); */
|
||||
/*<h2v-on>*/
|
||||
requisition->width,
|
||||
requisition->height);
|
||||
*/
|
||||
}
|
||||
|
||||
static GSList*
|
||||
list_row_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
guint row_width,
|
||||
guint *max_height,
|
||||
gboolean *can_vexpand)
|
||||
reverse_list_row_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line)
|
||||
{
|
||||
GSList *slist = NULL;
|
||||
guint width = 0;
|
||||
guint width = 0, row_width = area->width;
|
||||
GtkWrapBoxChild *child = *child_p;
|
||||
|
||||
*max_height = 0;
|
||||
*can_vexpand = FALSE;
|
||||
*max_child_size = 0;
|
||||
*expand_line = FALSE;
|
||||
|
||||
while (child && !GTK_WIDGET_VISIBLE (child->widget))
|
||||
{
|
||||
|
@ -308,8 +313,8 @@ list_row_children (GtkWrapBox *wbox,
|
|||
|
||||
get_child_requisition (wbox, child->widget, &child_requisition);
|
||||
width += child_requisition.width;
|
||||
*max_height = MAX (*max_height, child_requisition.height);
|
||||
*can_vexpand |= child->vexpand;
|
||||
*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;
|
||||
|
@ -322,8 +327,8 @@ list_row_children (GtkWrapBox *wbox,
|
|||
if (width + wbox->hspacing + child_requisition.width > row_width)
|
||||
break;
|
||||
width += wbox->hspacing + child_requisition.width;
|
||||
*max_height = MAX (*max_height, child_requisition.height);
|
||||
*can_vexpand |= child->vexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.height);
|
||||
*expand_line |= child->vexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
n++;
|
||||
}
|
||||
|
@ -332,7 +337,7 @@ list_row_children (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (slist);
|
||||
return slist;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -500,7 +505,13 @@ layout_rows (GtkWrapBox *wbox,
|
|||
guint children_per_line;
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = list_row_children (wbox, &next_child, area->width, &min_height, &vexpand);
|
||||
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)
|
||||
{
|
||||
|
@ -516,19 +527,20 @@ layout_rows (GtkWrapBox *wbox,
|
|||
line_list = line;
|
||||
n_lines++;
|
||||
|
||||
slist = list_row_children (wbox,
|
||||
&next_child,
|
||||
area->width,
|
||||
&min_height,
|
||||
&vexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_height,
|
||||
&vexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
}
|
||||
|
||||
|
||||
if (total_height > area->height)
|
||||
shrink_height = total_height - area->height;
|
||||
else
|
||||
shrink_height = 0;
|
||||
|
||||
if (1) /* reverse and shrink */
|
||||
if (1) /* reverse lines and shrink */
|
||||
{
|
||||
Line *prev = NULL, *last = NULL;
|
||||
gfloat n_shrink_lines = n_lines;
|
||||
|
@ -632,8 +644,9 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
|
|||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("got: width %d, height %d\n",
|
||||
allocation->width,
|
||||
allocation->height); */
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
*/
|
||||
/*<h2v-on>*/
|
||||
|
||||
layout_rows (wbox, &area);
|
||||
|
|
|
@ -24,12 +24,17 @@
|
|||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
|
||||
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
|
||||
static void gtk_vwrap_box_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
|
||||
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
|
||||
static void gtk_vwrap_box_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static GSList* reverse_list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_width,
|
||||
gboolean *can_hexpand);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
|
@ -79,6 +84,8 @@ gtk_vwrap_box_class_init (GtkVWrapBoxClass *class)
|
|||
|
||||
widget_class->size_request = gtk_vwrap_box_size_request;
|
||||
widget_class->size_allocate = gtk_vwrap_box_size_allocate;
|
||||
|
||||
wrap_box_class->rlist_line_children = reverse_list_col_children;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,12 +95,12 @@ gtk_vwrap_box_init (GtkVWrapBox *vwbox)
|
|||
vwbox->max_child_width = 0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
GtkWidget*
|
||||
gtk_vwrap_box_new (gboolean homogeneous)
|
||||
{
|
||||
GtkVWrapBox *vwbox;
|
||||
|
||||
vwbox = GTK_VWRAP_BOX (gtk_widget_new (gtk_vwrap_box_get_type (), NULL));
|
||||
vwbox = GTK_VWRAP_BOX (gtk_widget_new (GTK_TYPE_VWRAP_BOX, NULL));
|
||||
|
||||
GTK_WRAP_BOX (vwbox)->homogeneous = homogeneous ? TRUE : FALSE;
|
||||
|
||||
|
@ -262,38 +269,36 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
|
|||
requisition->height = layout_height;
|
||||
requisition->width = layout_width;
|
||||
}
|
||||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("ratio for width %d height %d = %f\n",
|
||||
(gint) layout_width,
|
||||
(gint) layout_height,
|
||||
ratio); */
|
||||
/*<h2v-on>*/
|
||||
|
||||
/* g_print ("ratio for height %d width %d = %f\n",
|
||||
(gint) layout_height,
|
||||
(gint) layout_width,
|
||||
ratio);
|
||||
*/
|
||||
}
|
||||
while (col_inc);
|
||||
|
||||
/*<h2v-off>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
|
||||
/* g_print ("choosen: width %d, height %d\n",
|
||||
requisition->width,
|
||||
requisition->height); */
|
||||
/*<h2v-on>*/
|
||||
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
|
||||
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
|
||||
/* g_print ("choosen: height %d, width %d\n",
|
||||
requisition->height,
|
||||
requisition->width);
|
||||
*/
|
||||
}
|
||||
|
||||
static GSList*
|
||||
list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
guint col_height,
|
||||
guint *max_width,
|
||||
gboolean *can_hexpand)
|
||||
reverse_list_col_children (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line)
|
||||
{
|
||||
GSList *slist = NULL;
|
||||
guint height = 0;
|
||||
guint height = 0, col_height = area->height;
|
||||
GtkWrapBoxChild *child = *child_p;
|
||||
|
||||
*max_width = 0;
|
||||
*can_hexpand = FALSE;
|
||||
*max_child_size = 0;
|
||||
*expand_line = FALSE;
|
||||
|
||||
while (child && !GTK_WIDGET_VISIBLE (child->widget))
|
||||
{
|
||||
|
@ -308,8 +313,8 @@ list_col_children (GtkWrapBox *wbox,
|
|||
|
||||
get_child_requisition (wbox, child->widget, &child_requisition);
|
||||
height += child_requisition.height;
|
||||
*max_width = MAX (*max_width, child_requisition.width);
|
||||
*can_hexpand |= child->hexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.width);
|
||||
*expand_line |= child->hexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
*child_p = child->next;
|
||||
child = *child_p;
|
||||
|
@ -322,8 +327,8 @@ list_col_children (GtkWrapBox *wbox,
|
|||
if (height + wbox->vspacing + child_requisition.height > col_height)
|
||||
break;
|
||||
height += wbox->vspacing + child_requisition.height;
|
||||
*max_width = MAX (*max_width, child_requisition.width);
|
||||
*can_hexpand |= child->hexpand;
|
||||
*max_child_size = MAX (*max_child_size, child_requisition.width);
|
||||
*expand_line |= child->hexpand;
|
||||
slist = g_slist_prepend (slist, child);
|
||||
n++;
|
||||
}
|
||||
|
@ -332,7 +337,7 @@ list_col_children (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (slist);
|
||||
return slist;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -500,7 +505,13 @@ layout_cols (GtkWrapBox *wbox,
|
|||
guint children_per_line;
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = list_col_children (wbox, &next_child, area->height, &min_width, &hexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
|
||||
children_per_line = g_slist_length (slist);
|
||||
while (slist)
|
||||
{
|
||||
|
@ -516,19 +527,20 @@ layout_cols (GtkWrapBox *wbox,
|
|||
line_list = line;
|
||||
n_lines++;
|
||||
|
||||
slist = list_col_children (wbox,
|
||||
&next_child,
|
||||
area->height,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
area,
|
||||
&min_width,
|
||||
&hexpand);
|
||||
slist = g_slist_reverse (slist);
|
||||
}
|
||||
|
||||
|
||||
if (total_width > area->width)
|
||||
shrink_width = total_width - area->width;
|
||||
else
|
||||
shrink_width = 0;
|
||||
|
||||
if (1) /* reverse and shrink */
|
||||
if (1) /* reverse lines and shrink */
|
||||
{
|
||||
Line *prev = NULL, *last = NULL;
|
||||
gfloat n_shrink_lines = n_lines;
|
||||
|
@ -632,8 +644,9 @@ gtk_vwrap_box_size_allocate (GtkWidget *widget,
|
|||
|
||||
/*<h2v-off>*/
|
||||
/* g_print ("got: width %d, height %d\n",
|
||||
allocation->width,
|
||||
allocation->height); */
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
*/
|
||||
/*<h2v-on>*/
|
||||
|
||||
layout_cols (wbox, &area);
|
||||
|
|
|
@ -137,6 +137,8 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
|
|||
container_class->child_type = gtk_wrap_box_child_type;
|
||||
container_class->set_child_arg = gtk_wrap_box_set_child_arg;
|
||||
container_class->get_child_arg = gtk_wrap_box_get_child_arg;
|
||||
|
||||
class->rlist_line_children = NULL;
|
||||
|
||||
gtk_object_add_arg_type ("GtkWrapBox::homogeneous",
|
||||
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
|
||||
|
@ -599,6 +601,54 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
|
|||
}
|
||||
}
|
||||
|
||||
guint*
|
||||
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
|
||||
guint *_n_lines)
|
||||
{
|
||||
GtkWrapBoxChild *next_child = NULL;
|
||||
GtkAllocation area, *allocation;
|
||||
gboolean expand_line;
|
||||
GSList *slist;
|
||||
guint max_child_size, border, n_lines = 0, *lines = NULL;
|
||||
|
||||
if (_n_lines)
|
||||
*_n_lines = 0;
|
||||
g_return_val_if_fail (GTK_IS_WRAP_BOX (wbox), NULL);
|
||||
|
||||
allocation = >K_WIDGET (wbox)->allocation;
|
||||
border = GTK_CONTAINER (wbox)->border_width;
|
||||
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);
|
||||
|
||||
next_child = wbox->children;
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
&area,
|
||||
&max_child_size,
|
||||
&expand_line);
|
||||
while (slist)
|
||||
{
|
||||
guint l = n_lines++;
|
||||
|
||||
lines = g_renew (guint, lines, n_lines);
|
||||
lines[l] = g_slist_length (slist);
|
||||
g_slist_free (slist);
|
||||
|
||||
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
|
||||
&next_child,
|
||||
&area,
|
||||
&max_child_size,
|
||||
&expand_line);
|
||||
}
|
||||
|
||||
if (_n_lines)
|
||||
*_n_lines = n_lines;
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_wrap_box_map (GtkWidget *widget)
|
||||
{
|
||||
|
@ -659,7 +709,7 @@ gtk_wrap_box_expose (GtkWidget *widget,
|
|||
gtk_widget_intersect (child->widget, &event->area, &child_event.area))
|
||||
gtk_widget_event (child->widget, (GdkEvent*) &child_event);
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -64,6 +64,12 @@ struct _GtkWrapBox
|
|||
struct _GtkWrapBoxClass
|
||||
{
|
||||
GtkContainerClass parent_class;
|
||||
|
||||
GSList* (*rlist_line_children) (GtkWrapBox *wbox,
|
||||
GtkWrapBoxChild **child_p,
|
||||
GtkAllocation *area,
|
||||
guint *max_child_size,
|
||||
gboolean *expand_line);
|
||||
};
|
||||
struct _GtkWrapBoxChild
|
||||
{
|
||||
|
@ -114,6 +120,8 @@ void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
|
|||
gboolean hfill,
|
||||
gboolean vexpand,
|
||||
gboolean vfill);
|
||||
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
|
||||
guint *n_lines);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue