{
x = GTK_CONTAINER (alignment)->border_width;
y = GTK_CONTAINER (alignment)->border_width;
- width = allocation->width - 2 * x;
- height = allocation->height - 2 * y;
+ width = MAX (allocation->width - 2 * x, 0);
+ height = MAX (allocation->height - 2 * y, 0);
if (width > bin->child->requisition.width)
child_allocation.width = (bin->child->requisition.width *
child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->xthickness);
child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->ythickness);
- child_allocation.width = widget->allocation.width - child_allocation.x * 2 -
- border_width * 2;
- child_allocation.height = widget->allocation.height - child_allocation.y * 2 -
- border_width * 2;
+ child_allocation.width = MAX (0, widget->allocation.width - child_allocation.x * 2 -
+ border_width * 2);
+ child_allocation.height = MAX (0, widget->allocation.height - child_allocation.y * 2 -
+ border_width * 2);
if (GTK_WIDGET_CAN_DEFAULT (button))
{
DEFAULT_LEFT_POS);
child_allocation.y += (GTK_WIDGET (widget)->style->klass->ythickness +
DEFAULT_TOP_POS);
- child_allocation.width -= (GTK_WIDGET (widget)->style->klass->xthickness * 2 +
- DEFAULT_SPACING);
- child_allocation.height -= (GTK_WIDGET (widget)->style->klass->xthickness * 2 +
- DEFAULT_SPACING);
+ child_allocation.width = MAX (0, child_allocation.width -
+ (GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
+ child_allocation.height = MAX (0, child_allocation.height -
+ (GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
}
gtk_widget_size_allocate (button->child, &child_allocation);
CHECK_BUTTON_CLASS (widget)->indicator_size +
CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1);
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1;
- child_allocation.width = (allocation->width - child_allocation.x -
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x -
GTK_CONTAINER (widget)->border_width - 1);
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
gtk_widget_size_allocate (button->child, &child_allocation);
}
clist->title_window = NULL;
clist->column_title_area.x = 0;
clist->column_title_area.y = 0;
- clist->column_title_area.width = 0;
- clist->column_title_area.height = 0;
+ clist->column_title_area.width = 1;
+ clist->column_title_area.height = 1;
clist->clist_window = NULL;
- clist->clist_window_width = 0;
- clist->clist_window_height = 0;
+ clist->clist_window_width = 1;
+ clist->clist_window_height = 1;
clist->hoffset = 0;
clist->voffset = 0;
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
/* column-title window */
+
+ attributes.x = clist->column_title_area.x;
+ attributes.y = clist->column_title_area.y;
+ attributes.width = clist->column_title_area.width;
+ attributes.height = clist->column_title_area.height;
+
clist->title_window = gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (clist->title_window, clist);
gtk_widget_set_parent_window (clist->column[i].button, clist->title_window);
/* clist-window */
+ attributes.x = clist->internal_allocation.x + widget->style->klass->xthickness;
+ attributes.y = clist->internal_allocation.y + widget->style->klass->ythickness +
+ clist->column_title_area.height;
+ attributes.width = clist->internal_allocation.width;
+ attributes.height = clist->internal_allocation.height;
+
clist->clist_window = gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (clist->clist_window, clist);
{
clist->column[i].window = gdk_window_new (clist->title_window, &attributes, attributes_mask);
gdk_window_set_user_data (clist->column[i].window, clist);
- gdk_window_show (clist->column[i].window);
}
+ /* This is slightly less efficient than creating them with the
+ * right size to begin with, but easier
+ */
+ size_allocate_title_buttons (clist);
+
/* GCs */
clist->fg_gc = gdk_gc_new (widget->window);
clist->bg_gc = gdk_gc_new (widget->window);
allocation->y + GTK_CONTAINER (widget)->border_width,
allocation->width - GTK_CONTAINER (widget)->border_width * 2,
allocation->height - GTK_CONTAINER (widget)->border_width * 2);
+ }
- /* use internal allocation structure for all the math
- * because it's easier than always subtracting the container
- * border width */
- clist->internal_allocation.x = 0;
- clist->internal_allocation.y = 0;
- clist->internal_allocation.width = allocation->width -
- GTK_CONTAINER (widget)->border_width * 2;
- clist->internal_allocation.height = allocation->height -
- GTK_CONTAINER (widget)->border_width * 2;
+ /* use internal allocation structure for all the math
+ * because it's easier than always subtracting the container
+ * border width */
+ clist->internal_allocation.x = 0;
+ clist->internal_allocation.y = 0;
+ clist->internal_allocation.width = MAX (0, allocation->width -
+ GTK_CONTAINER (widget)->border_width * 2);
+ clist->internal_allocation.height = MAX (0, allocation->height -
+ GTK_CONTAINER (widget)->border_width * 2);
- /* allocate clist window assuming no scrollbars */
- clist_allocation.x = clist->internal_allocation.x + widget->style->klass->xthickness;
- clist_allocation.y = clist->internal_allocation.y + widget->style->klass->ythickness +
- clist->column_title_area.height;
- clist_allocation.width = clist->internal_allocation.width -
- (2 * widget->style->klass->xthickness);
- clist_allocation.height = clist->internal_allocation.height -
- (2 * widget->style->klass->ythickness) -
- clist->column_title_area.height;
-
- /*
- * here's where we decide to show/not show the scrollbars
- */
- vscrollbar_vis = 0;
- hscrollbar_vis = 0;
-
- for (i = 0; i <= 1; i++)
+ /* allocate clist window assuming no scrollbars */
+ clist_allocation.x = clist->internal_allocation.x + widget->style->klass->xthickness;
+ clist_allocation.y = clist->internal_allocation.y + widget->style->klass->ythickness +
+ clist->column_title_area.height;
+ clist_allocation.width = MAX (0, clist->internal_allocation.width -
+ (2 * widget->style->klass->xthickness));
+ clist_allocation.height = MAX (0, clist->internal_allocation.height -
+ (2 * widget->style->klass->ythickness) -
+ clist->column_title_area.height);
+
+ /*
+ * here's where we decide to show/not show the scrollbars
+ */
+ vscrollbar_vis = 0;
+ hscrollbar_vis = 0;
+
+ for (i = 0; i <= 1; i++)
+ {
+ if (LIST_HEIGHT (clist) <= clist_allocation.height &&
+ clist->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
- if (LIST_HEIGHT (clist) <= clist_allocation.height &&
- clist->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
- {
- vscrollbar_vis = 0;
- }
- else
- {
- if (!vscrollbar_vis)
- {
- vscrollbar_vis = 1;
- clist_allocation.width -= clist->vscrollbar->requisition.width +
- SCROLLBAR_SPACING (clist);
- }
- }
-
- if (LIST_WIDTH (clist) <= clist_allocation.width &&
- clist->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ vscrollbar_vis = 0;
+ }
+ else
+ {
+ if (!vscrollbar_vis)
{
- hscrollbar_vis = 0;
- }
- else
+ vscrollbar_vis = 1;
+ clist_allocation.width = MAX (0,
+ clist_allocation.width - clist->vscrollbar->requisition.width +
+ SCROLLBAR_SPACING (clist));
+ }
+ }
+
+ if (LIST_WIDTH (clist) <= clist_allocation.width &&
+ clist->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ {
+ hscrollbar_vis = 0;
+ }
+ else
+ {
+ if (!hscrollbar_vis)
{
- if (!hscrollbar_vis)
- {
- hscrollbar_vis = 1;
- clist_allocation.height -= clist->hscrollbar->requisition.height +
- SCROLLBAR_SPACING (clist);
- }
- }
+ hscrollbar_vis = 1;
+ clist_allocation.height = MAX (0,
+ clist_allocation.height - clist->hscrollbar->requisition.height +
+ SCROLLBAR_SPACING (clist));
+ }
}
-
- clist->clist_window_width = clist_allocation.width;
- clist->clist_window_height = clist_allocation.height;
-
+ }
+
+ clist->clist_window_width = clist_allocation.width;
+ clist->clist_window_height = clist_allocation.height;
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
gdk_window_move_resize (clist->clist_window,
clist_allocation.x,
clist_allocation.y,
clist_allocation.width,
clist_allocation.height);
-
- /* position the window which holds the column title buttons */
- clist->column_title_area.x = widget->style->klass->xthickness;
- clist->column_title_area.y = widget->style->klass->ythickness;
- clist->column_title_area.width = clist_allocation.width;
-
+ }
+
+ /* position the window which holds the column title buttons */
+ clist->column_title_area.x = widget->style->klass->xthickness;
+ clist->column_title_area.y = widget->style->klass->ythickness;
+ clist->column_title_area.width = clist_allocation.width;
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
gdk_window_move_resize (clist->title_window,
clist->column_title_area.x,
clist->column_title_area.y,
clist->column_title_area.width,
clist->column_title_area.height);
+ }
+
+ /* column button allocation */
+ size_allocate_columns (clist);
- /* column button allocation */
- size_allocate_columns (clist);
- size_allocate_title_buttons (clist);
- adjust_scrollbars (clist);
-
- /* allocate the vscrollbar */
- if (vscrollbar_vis)
- {
- if (!GTK_WIDGET_VISIBLE (clist->vscrollbar))
- gtk_widget_show (clist->vscrollbar);
-
- child_allocation.x = clist->internal_allocation.x +
- clist->internal_allocation.width -
- clist->vscrollbar->requisition.width;
- child_allocation.y = clist->internal_allocation.y;
- child_allocation.width = clist->vscrollbar->requisition.width;
- child_allocation.height = clist->internal_allocation.height -
- (hscrollbar_vis ? (clist->hscrollbar->requisition.height + SCROLLBAR_SPACING (clist)) : 0);
-
- gtk_widget_size_allocate (clist->vscrollbar, &child_allocation);
- }
- else
- {
- if (GTK_WIDGET_VISIBLE (clist->vscrollbar))
- gtk_widget_hide (clist->vscrollbar);
- }
+ if (GTK_WIDGET_REALIZED (widget))
+ size_allocate_title_buttons (clist);
- if (hscrollbar_vis)
- {
- if (!GTK_WIDGET_VISIBLE (clist->hscrollbar))
- gtk_widget_show (clist->hscrollbar);
+ adjust_scrollbars (clist);
+
+ /* allocate the vscrollbar */
+ if (vscrollbar_vis)
+ {
+ if (!GTK_WIDGET_VISIBLE (clist->vscrollbar))
+ gtk_widget_show (clist->vscrollbar);
- child_allocation.x = clist->internal_allocation.x;
- child_allocation.y = clist->internal_allocation.y +
- clist->internal_allocation.height -
- clist->hscrollbar->requisition.height;
- child_allocation.width = clist->internal_allocation.width -
- (vscrollbar_vis ? (clist->vscrollbar->requisition.width + SCROLLBAR_SPACING (clist)) : 0);
- child_allocation.height = clist->hscrollbar->requisition.height;
-
- gtk_widget_size_allocate (clist->hscrollbar, &child_allocation);
- }
- else
- {
- if (GTK_WIDGET_VISIBLE (clist->hscrollbar))
- gtk_widget_hide (clist->hscrollbar);
- }
+ child_allocation.x = clist->internal_allocation.x +
+ clist->internal_allocation.width -
+ clist->vscrollbar->requisition.width;
+ child_allocation.y = clist->internal_allocation.y;
+ child_allocation.width = clist->vscrollbar->requisition.width;
+ child_allocation.height = MAX (0, clist->internal_allocation.height -
+ (hscrollbar_vis ? (clist->hscrollbar->requisition.height + SCROLLBAR_SPACING (clist)) : 0));
+
+ gtk_widget_size_allocate (clist->vscrollbar, &child_allocation);
+ }
+ else
+ {
+ if (GTK_WIDGET_VISIBLE (clist->vscrollbar))
+ gtk_widget_hide (clist->vscrollbar);
+ }
+
+ if (hscrollbar_vis)
+ {
+ if (!GTK_WIDGET_VISIBLE (clist->hscrollbar))
+ gtk_widget_show (clist->hscrollbar);
+
+ child_allocation.x = clist->internal_allocation.x;
+ child_allocation.y = clist->internal_allocation.y +
+ clist->internal_allocation.height -
+ clist->hscrollbar->requisition.height;
+ child_allocation.width = MAX (0, clist->internal_allocation.width -
+ (vscrollbar_vis ? (clist->vscrollbar->requisition.width + SCROLLBAR_SPACING (clist)) : 0));
+ child_allocation.height = clist->hscrollbar->requisition.height;
+
+ gtk_widget_size_allocate (clist->hscrollbar, &child_allocation);
+ }
+ else
+ {
+ if (GTK_WIDGET_VISIBLE (clist->hscrollbar))
+ gtk_widget_hide (clist->hscrollbar);
}
/* set the vscrollbar adjustments */
static void gtk_drawing_area_realize (GtkWidget *widget);
static void gtk_drawing_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+static void gtk_drawing_area_send_configure (GtkDrawingArea *darea);
guint
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+ gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
}
static void
gtk_drawing_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GdkEventConfigure event;
-
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_DRAWING_AREA (widget));
g_return_if_fail (allocation != NULL);
allocation->x, allocation->y,
allocation->width, allocation->height);
- event.type = GDK_CONFIGURE;
- event.window = widget->window;
- event.x = allocation->x;
- event.y = allocation->y;
- event.width = allocation->width;
- event.height = allocation->height;
-
- gtk_widget_event (widget, (GdkEvent*) &event);
+ gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
}
}
+
+static void
+gtk_drawing_area_send_configure (GtkDrawingArea *darea)
+{
+ GtkWidget *widget;
+ GdkEventConfigure event;
+
+ widget = GTK_WIDGET (darea);
+
+ event.type = GDK_CONFIGURE;
+ event.window = widget->window;
+ event.x = widget->allocation.x;
+ event.y = widget->allocation.y;
+ event.width = widget->allocation.width;
+ event.height = widget->allocation.height;
+
+ gtk_widget_event (widget, (GdkEvent*) &event);
+}
{
GtkEntry *entry;
GtkEditable *editable;
+ gint offset;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
allocation->width - (widget->style->klass->xthickness + INNER_BORDER) * 2,
widget->requisition.height - (widget->style->klass->ythickness + INNER_BORDER) * 2);
- entry->scroll_offset = 0;
+ /* Display as much text as we can */
+ offset = MAX(0, entry->char_offset[entry->nchars] -
+ (allocation->width -
+ (widget->style->klass->xthickness + INNER_BORDER) * 2));
+
+ if (entry->scroll_offset > offset)
+ entry->scroll_offset = offset;
+
+ /* And make sure the cursor is on screen */
gtk_entry_adjust_scroll (entry);
+
#ifdef USE_XIM
if (editable->ic && (gdk_ic_get_style (editable->ic) & GdkIMPreeditPosition))
{
child_allocation.x = 0;
child_allocation.y = 0;
- child_allocation.width = allocation->width - GTK_CONTAINER (widget)->border_width * 2;
- child_allocation.height = allocation->height - GTK_CONTAINER (widget)->border_width * 2;
+ child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0);
+ child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0);
if (GTK_WIDGET_REALIZED (widget))
{
}
else
{
- child_allocation.width = widget->allocation.width - 2 * border_width;
- child_allocation.height = widget->allocation.height - 2 * border_width;
+ child_allocation.width = MAX (0, widget->allocation.width - 2 * border_width);
+ child_allocation.height = MAX (0, widget->allocation.height - 2 * border_width);
if (hb->handle_position == GTK_POS_LEFT ||
hb->handle_position == GTK_POS_RIGHT)
}
else if (nexpand_children > 0)
{
- width = allocation->width - widget->requisition.width;
+ width = (gint)allocation->width - (gint)widget->requisition.width;
extra = width / nexpand_children;
}
else
x = allocation->x + GTK_CONTAINER (box)->border_width;
child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width;
- child_allocation.height = allocation->height - GTK_CONTAINER (box)->border_width * 2;
+ child_allocation.height = MAX (0, allocation->height - GTK_CONTAINER (box)->border_width * 2);
children = box->children;
while (children)
if (child->fill)
{
- child_allocation.width = child_width - child->padding * 2;
+ child_allocation.width = MAX (0, child_width - child->padding * 2);
child_allocation.x = x + child->padding;
}
else
if (child->fill)
{
- child_allocation.width = child_width - child->padding * 2;
+ child_allocation.width = MAX (0, child_width - child->padding * 2);
child_allocation.x = x + child->padding - child_width;
}
else
paned->groove_rectangle.height);
}
- child1_allocation.height = child2_allocation.height = allocation->height - border_width * 2;
+ child1_allocation.height = child2_allocation.height = MAX (0, allocation->height - border_width * 2);
child1_allocation.width = paned->child1_size;
child1_allocation.x = border_width;
child1_allocation.y = child2_allocation.y = border_width;
paned->groove_rectangle.height = allocation->height;
child2_allocation.x = paned->groove_rectangle.x + paned->gutter_size / 2 + 1;
- child2_allocation.width = allocation->width
- - child2_allocation.x - border_width;
+ child2_allocation.width = MAX (0, allocation->width
+ - child2_allocation.x - border_width);
/* Now allocate the childen, making sure, when resizing not to
* overlap the windows */
g_return_val_if_fail (GTK_IS_LIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- g_print ("gtk_list_motion_notify\n");
+ /* g_print ("gtk_list_motion_notify\n"); */
return FALSE;
}
{
child_allocation.x = GTK_CONTAINER (list)->border_width;
child_allocation.y = GTK_CONTAINER (list)->border_width;
- child_allocation.width = allocation->width - child_allocation.x * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
children = list->children;
GtkWidget *widget;
widget = NULL;
- if (event->any.window)
+ if (event && event->any.window)
gdk_window_get_user_data (event->any.window, (void**) &widget);
return widget;
widget->style->klass->xthickness);
child_allocation.y = (GTK_CONTAINER (menu)->border_width +
widget->style->klass->ythickness);
- child_allocation.width = allocation->width - child_allocation.x * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
children = menu_shell->children;
while (children)
child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
widget->style->klass->ythickness +
BORDER_SPACING);
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
children = menu_shell->children;
while (children)
widget->style->klass->xthickness +
BORDER_SPACING);
child_allocation.y = GTK_CONTAINER (widget)->border_width;
- child_allocation.width = allocation->width - child_allocation.x * 2;
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size;
child_allocation.width -= (GTK_MENU_ITEM (widget)->toggle_size +
GTK_MENU_ITEM (widget)->accelerator_size);
{
child_allocation.x = GTK_CONTAINER (widget)->border_width;
child_allocation.y = GTK_CONTAINER (widget)->border_width;
- child_allocation.width = allocation->width - child_allocation.x * 2;
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
if (notebook->show_tabs || notebook->show_border)
{
child_allocation.x += widget->style->klass->xthickness;
child_allocation.y += widget->style->klass->ythickness;
- child_allocation.width -= widget->style->klass->xthickness * 2;
- child_allocation.height -= widget->style->klass->ythickness * 2;
+ child_allocation.width = MAX (0,
+ child_allocation.width - widget->style->klass->xthickness * 2);
+ child_allocation.height = MAX (0,
+ child_allocation.height - widget->style->klass->ythickness * 2);
if (notebook->show_tabs && notebook->children)
{
case GTK_POS_TOP:
child_allocation.y += notebook->cur_page->requisition.height;
case GTK_POS_BOTTOM:
- child_allocation.height -= notebook->cur_page->requisition.height;
+ child_allocation.height = MAX (0,
+ child_allocation.height - notebook->cur_page->requisition.height);
break;
case GTK_POS_LEFT:
child_allocation.x += notebook->cur_page->requisition.width;
case GTK_POS_RIGHT:
- child_allocation.width -= notebook->cur_page->requisition.width;
+ child_allocation.width = MAX (0,
+ child_allocation.width - notebook->cur_page->requisition.width);
break;
}
}
allocation->x = GTK_CONTAINER (widget)->border_width;
allocation->y = GTK_CONTAINER (widget)->border_width;
- allocation->width = widget->allocation.width - allocation->x * 2;
- allocation->height = widget->allocation.height - allocation->y * 2;
+ allocation->width = MAX (0, widget->allocation.width - allocation->x * 2);
+ allocation->height = MAX (0, widget->allocation.height - allocation->y * 2);
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
- allocation->width -= scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window);
+ allocation->width = MAX (0,
+ allocation->width - (scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window)));
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
- allocation->height -= scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window);
+ allocation->height = MAX (0,
+ allocation->height - (scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window)));
}
static void
for (col = 0; col < table->ncols; col++)
{
extra = width / (table->ncols - col);
- table->cols[col].allocation = extra;
+ table->cols[col].allocation = MAX (0, extra);
width -= extra;
}
}
if (table->cols[col].shrink)
{
extra = width / nshrink;
- table->cols[col].allocation -= extra;
+ table->cols[col].allocation = MAX (0, table->cols[col].allocation - extra);
width -= extra;
nshrink -= 1;
for (row = 0; row < table->nrows; row++)
{
extra = height / (table->nrows - row);
- table->rows[row].allocation = extra;
+ table->rows[row].allocation = MAX (0, extra);
height -= extra;
}
}
if (table->rows[row].shrink)
{
extra = height / nshrink;
- table->rows[row].allocation -= extra;
+ table->rows[row].allocation = MAX (0, table->rows[row].allocation - extra);
height -= extra;
nshrink -= 1;
if (child->xfill)
{
- allocation.width = max_width - child->xpadding * 2;
+ allocation.width = MAX (0, max_width - child->xpadding * 2);
allocation.x = x + (max_width - allocation.width) / 2;
}
else
if (child->yfill)
{
- allocation.height = max_height - child->ypadding * 2;
+ allocation.height = MAX (0, max_height - child->ypadding * 2);
allocation.y = y + (max_height - allocation.height) / 2;
}
else
{
child_allocation.x = GTK_CONTAINER (tree)->border_width;
child_allocation.y = GTK_CONTAINER (tree)->border_width;
- child_allocation.width = allocation->width - child_allocation.x * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
children = tree->children;
gtk_widget_size_allocate (item->pixmaps_box, &child_allocation);
child_allocation.y = GTK_CONTAINER (widget)->border_width;
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
child_allocation.x += item->pixmaps_box->requisition.width+DEFAULT_DELTA;
child_allocation.width =
- allocation->width - (child_allocation.x + border_width);
+ MAX (0, allocation->width - (child_allocation.x + border_width));
gtk_widget_size_allocate (bin->child, &child_allocation);
}
}
else if (nexpand_children > 0)
{
- height = allocation->height - widget->requisition.height;
+ height = (gint)allocation->height - (gint)widget->requisition.height;
extra = height / nexpand_children;
}
else
y = allocation->y + GTK_CONTAINER (box)->border_width;
child_allocation.x = allocation->x + GTK_CONTAINER (box)->border_width;
- child_allocation.width = allocation->width - GTK_CONTAINER (box)->border_width * 2;
+ child_allocation.width = MAX (0, allocation->width - GTK_CONTAINER (box)->border_width * 2);
children = box->children;
while (children)
if (child->fill)
{
- child_allocation.height = child_height - child->padding * 2;
+ child_allocation.height = MAX (0, child_height - child->padding * 2);
child_allocation.y = y + child->padding;
}
else
if (child->fill)
{
- child_allocation.height = child_height - child->padding * 2;
+ child_allocation.height = MAX (0, child_height - child->padding * 2);
child_allocation.y = y + child->padding - child_height;
}
else
child_allocation.y = GTK_WIDGET (viewport)->style->klass->ythickness;
}
- child_allocation.width = allocation->width - child_allocation.x * 2 - border_width * 2;
- child_allocation.height = allocation->height - child_allocation.y * 2 - border_width * 2;
+ child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2 - border_width * 2);
+ child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2 - border_width * 2);
if (GTK_WIDGET_REALIZED (widget))
{
paned->groove_rectangle.height);
}
- child1_allocation.width = child2_allocation.width = allocation->width - border_width * 2;
+ child1_allocation.width = child2_allocation.width = MAX (0, allocation->width - border_width * 2);
child1_allocation.height = paned->child1_size;
child1_allocation.x = child2_allocation.x = border_width;
child1_allocation.y = border_width;
paned->groove_rectangle.width = allocation->width;
child2_allocation.y = paned->groove_rectangle.y + paned->gutter_size / 2 + 1;
- child2_allocation.height = allocation->height
- - child2_allocation.y - border_width;
+ child2_allocation.height = MAX (0, allocation->height
+ - child2_allocation.y - border_width);
/* Now allocate the childen, making sure, when resizing not to
* overlap the windows */
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- gtk_window_move_resize (widget);
window = GTK_WINDOW (widget);
if (window->bin.child &&
!GTK_WIDGET_MAPPED (window->bin.child))
gtk_widget_map (window->bin.child);
- gtk_window_set_hints (widget, &widget->requisition);
gdk_window_show (widget->window);
}
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+ gtk_window_set_hints (widget, &widget->requisition);
}
static void
gtk_widget_map (window->bin.child);
if (window->resize_count > 0)
- window->resize_count -= 1;
+ window->resize_count -= 1;
window->handling_resize = FALSE;
g_return_val_if_fail ((x != NULL) || (y != NULL), FALSE);
widget = GTK_WIDGET (window);
-
- if ((*x != -1) && (*y != -1))
- gdk_window_move (widget->window, *x, *y);
-
+
if ((widget->requisition.width == 0) ||
(widget->requisition.height == 0))
{
widget->requisition.height = 200;
}
+ if (!GTK_WIDGET_REALIZED (window))
+ {
+ GtkAllocation allocation;
+
+ allocation.x = 0;
+ allocation.y = 0;
+ allocation.width = widget->requisition.width;
+ allocation.height = widget->requisition.height;
+
+ gtk_widget_size_allocate (widget, &allocation);
+
+ return FALSE;
+ }
+
gdk_window_get_geometry (widget->window, NULL, NULL, &width, &height, NULL);
if ((window->auto_shrink &&
(height < widget->requisition.height))
{
window->resize_count += 1;
- gdk_window_resize (widget->window,
- widget->requisition.width,
- widget->requisition.height);
+ if ((*x != -1) && (*y != -1))
+ gdk_window_move_resize (widget->window, *x, *y,
+ widget->requisition.width,
+ widget->requisition.height);
+ else
+ gdk_window_resize (widget->window,
+ widget->requisition.width,
+ widget->requisition.height);
}
else
{
GSList *resize_containers;
GSList *node;
+ if ((*x != -1) && (*y != -1))
+ gdk_window_move (widget->window, *x, *y);
+
resize_widgets = GTK_CONTAINER (window)->resize_widgets;
GTK_CONTAINER (window)->resize_widgets = NULL;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
+ window = GTK_WINDOW (widget);
return_val = FALSE;
- if (GTK_WIDGET_REALIZED (widget))
- {
- window = GTK_WINDOW (widget);
-
- /* Remember old size, to know if we have to reset hints */
- width = widget->requisition.width;
- height = widget->requisition.height;
- gtk_widget_size_request (widget, &widget->requisition);
-
- if (GTK_WIDGET_MAPPED (widget) &&
- (width != widget->requisition.width ||
- height != widget->requisition.height))
- gtk_window_set_hints (widget, &widget->requisition);
-
- x = -1;
- y = -1;
- width = widget->requisition.width;
- height = widget->requisition.height;
-
- if (window->use_uposition)
- switch (window->position)
- {
- case GTK_WIN_POS_CENTER:
- x = (gdk_screen_width () - width) / 2;
- y = (gdk_screen_height () - height) / 2;
- gtk_widget_set_uposition (widget, x, y);
- break;
- case GTK_WIN_POS_MOUSE:
- gdk_window_get_pointer (NULL, &x, &y, NULL);
-
- x -= width / 2;
- y -= height / 2;
-
- screen_width = gdk_screen_width ();
- screen_height = gdk_screen_height ();
-
- if (x < 0)
- x = 0;
- else if (x > (screen_width - width))
- x = screen_width - width;
-
- if (y < 0)
- y = 0;
- else if (y > (screen_height - height))
- y = screen_height - height;
-
- gtk_widget_set_uposition (widget, x, y);
- break;
- }
-
- gtk_signal_emit (GTK_OBJECT (widget), window_signals[MOVE_RESIZE],
- &x, &y, width, height, &return_val);
- }
+ /* Remember old size, to know if we have to reset hints */
+ width = widget->requisition.width;
+ height = widget->requisition.height;
+ gtk_widget_size_request (widget, &widget->requisition);
+
+ if ((width != widget->requisition.width ||
+ height != widget->requisition.height))
+ gtk_window_set_hints (widget, &widget->requisition);
+
+ x = -1;
+ y = -1;
+ width = widget->requisition.width;
+ height = widget->requisition.height;
+
+ if (window->use_uposition)
+ switch (window->position)
+ {
+ case GTK_WIN_POS_CENTER:
+ x = (gdk_screen_width () - width) / 2;
+ y = (gdk_screen_height () - height) / 2;
+ gtk_widget_set_uposition (widget, x, y);
+ break;
+ case GTK_WIN_POS_MOUSE:
+ gdk_window_get_pointer (NULL, &x, &y, NULL);
+
+ x -= width / 2;
+ y -= height / 2;
+
+ screen_width = gdk_screen_width ();
+ screen_height = gdk_screen_height ();
+
+ if (x < 0)
+ x = 0;
+ else if (x > (screen_width - width))
+ x = screen_width - width;
+
+ if (y < 0)
+ y = 0;
+ else if (y > (screen_height - height))
+ y = screen_height - height;
+
+ gtk_widget_set_uposition (widget, x, y);
+ break;
+ }
+
+ gtk_signal_emit (GTK_OBJECT (widget), window_signals[MOVE_RESIZE],
+ &x, &y, width, height, &return_val);
return return_val;
}