static void gtk_form_position_children(GtkForm *form) { GList *tmp_list; for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) gtk_form_position_child(form, tmp_list->data, FALSE); }
static void gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { GList *tmp_list; GtkForm *form; gboolean need_reposition; GtkAllocation cur_alloc; g_return_if_fail(GTK_IS_FORM(widget)); gtk_widget_get_allocation(widget, &cur_alloc); if (cur_alloc.x == allocation->x && cur_alloc.y == allocation->y && cur_alloc.width == allocation->width && cur_alloc.height == allocation->height) return; need_reposition = cur_alloc.width != allocation->width || cur_alloc.height != allocation->height; form = GTK_FORM(widget); if (need_reposition) { tmp_list = form->children; while (tmp_list) { GtkFormChild *child = tmp_list->data; gtk_form_position_child(form, child, TRUE); tmp_list = tmp_list->next; } } if (gtk_widget_get_realized(widget)) { gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); gdk_window_move_resize(GTK_FORM(widget)->bin_window, 0, 0, allocation->width, allocation->height); } gtk_widget_set_allocation(widget, allocation); if (need_reposition) gtk_form_send_configure(form); }
static void gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { GList *tmp_list; GtkForm *form; gboolean need_reposition; g_return_if_fail(GTK_IS_FORM(widget)); if (widget->allocation.x == allocation->x && widget->allocation.y == allocation->y && widget->allocation.width == allocation->width && widget->allocation.height == allocation->height) return; need_reposition = widget->allocation.width != allocation->width || widget->allocation.height != allocation->height; form = GTK_FORM(widget); if (need_reposition) { tmp_list = form->children; while (tmp_list) { GtkFormChild *child = tmp_list->data; gtk_form_position_child(form, child, TRUE); tmp_list = tmp_list->next; } } if (GTK_WIDGET_REALIZED(widget)) { gdk_window_move_resize(widget->window, allocation->x, allocation->y, allocation->width, allocation->height); gdk_window_move_resize(GTK_FORM(widget)->bin_window, 0, 0, allocation->width, allocation->height); } widget->allocation = *allocation; if (need_reposition) gtk_form_send_configure(form); }
void gtk_form_put(GtkForm *form, GtkWidget *child_widget, gint x, gint y) { GtkFormChild *child; g_return_if_fail(GTK_IS_FORM(form)); /* LINTED: avoid warning: conversion to 'unsigned long' */ child = g_new(GtkFormChild, 1); if (child == NULL) return; child->widget = child_widget; child->window = NULL; child->x = x; child->y = y; #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_size_request(child->widget, -1, -1); #else child->widget->requisition.width = 0; child->widget->requisition.height = 0; #endif child->mapped = FALSE; form->children = g_list_append(form->children, child); /* child->window must be created and attached to the widget _before_ * it has been realized, or else things will break with GTK2. Note * that gtk_widget_set_parent() realizes the widget if it's visible * and its parent is mapped. */ if (gtk_widget_get_realized(GTK_WIDGET(form))) gtk_form_attach_child_window(form, child); gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); if (gtk_widget_get_realized(GTK_WIDGET(form)) && !gtk_widget_get_realized(child_widget)) gtk_form_realize_child(form, child); gtk_form_position_child(form, child, TRUE); }
void gtk_form_move(GtkForm *form, GtkWidget *child_widget, gint x, gint y) { GList *tmp_list; GtkFormChild *child; g_return_if_fail(GTK_IS_FORM(form)); for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { child = tmp_list->data; if (child->widget == child_widget) { child->x = x; child->y = y; gtk_form_position_child(form, child, TRUE); return; } } }
static gboolean gtk_form_draw(GtkWidget *widget, cairo_t *cr) { GList *tmp_list = NULL; GtkForm *form = NULL; g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); gtk_form_render_background(widget, cr); form = GTK_FORM(widget); for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { GtkFormChild * const formchild = tmp_list->data; if (!gtk_widget_get_has_window(formchild->widget) && gtk_cairo_should_draw_window(cr, formchild->window)) { /* To get gtk_widget_draw() to work, it is required to call * gtk_widget_size_allocate() in advance with a well-posed * allocation for a given child widget in order to set a * certain private GtkWidget variable, called * widget->priv->alloc_need, to the proper value; otherwise, * gtk_widget_draw() fails and the relevant scrollbar won't * appear on the screen. * * Calling gtk_form_position_child() like this is one of ways * to make sure of that. */ gtk_form_position_child(form, formchild, TRUE); gtk_form_render_background(formchild->widget, cr); } } return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); }