📄 dw_gtk_scrolled_window.c
字号:
GTK_WIDGET_CLASS(parent_class)->size_allocate (widget, allocation); widget->allocation = *allocation; DEBUG_MSG (2, "Dw_gtk_scrolled_window_size_allocate: %d x %d\n", allocation->width, allocation->height); if (old_allocation.width != allocation->width || old_allocation.height != allocation->height) { viewport = GTK_DW_VIEWPORT (GTK_BIN(GTK_BIN(widget)->child)->child); /* It may be that scrollbars are not needed anymore. See Dw_gtk_viewport_calc_size for more details. */ if (allocation->width > old_allocation.width) viewport->hscrollbar_used = FALSE; if (allocation->height > old_allocation.height) viewport->vscrollbar_used = FALSE; Dw_gtk_viewport_calc_size (viewport); } scrolled = GTK_DW_SCROLLED_WINDOW (widget); if (scrolled->gadget && GTK_WIDGET_VISIBLE (scrolled->gadget)) { /* Raise the gagdet, otherwise it may be hidden. */ if (GTK_WIDGET_REALIZED (scrolled->gadget)) gdk_window_raise (scrolled->gadget->window); /* Allocate the gadget. */ gtk_widget_size_request (scrolled->gadget, &child_requisition); gx = allocation->x + allocation->width - child_requisition.width; gy = allocation->y + allocation->height - child_requisition.height; child_allocation.x = MAX (gx, 1); child_allocation.y = MAX (gy, 1); child_allocation.width = child_requisition.width; child_allocation.height = child_requisition.height; gtk_widget_size_allocate (scrolled->gadget, &child_allocation); /* Re-allocate the scrollbars, when necessary */ hscrollbar = GTK_SCROLLED_WINDOW(scrolled)->hscrollbar; if (GTK_WIDGET_VISIBLE (hscrollbar) && hscrollbar->allocation.x + hscrollbar->allocation.width > gx) { child_allocation = hscrollbar->allocation; child_allocation.width = MAX (gx - hscrollbar->allocation.x, 1); gtk_widget_size_allocate (hscrollbar, &child_allocation); } vscrollbar = GTK_SCROLLED_WINDOW(scrolled)->vscrollbar; if (GTK_WIDGET_VISIBLE (vscrollbar) && vscrollbar->allocation.y + vscrollbar->allocation.height > gy) { child_allocation = vscrollbar->allocation; child_allocation.height = MAX (gy - vscrollbar->allocation.y, 1); gtk_widget_size_allocate (vscrollbar, &child_allocation); } }}/* * Standard Gtk+ function */static void Dw_gtk_scrolled_window_remove (GtkContainer *container, GtkWidget *widget){ GtkDwScrolledWindow *scrolled = GTK_DW_SCROLLED_WINDOW (container); gboolean widget_was_visible; if (widget == scrolled->gadget) { widget_was_visible = GTK_WIDGET_VISIBLE (widget); gtk_widget_unparent (widget); scrolled->gadget = NULL; } else GTK_CONTAINER_CLASS(parent_class)->remove (container, widget);}/* * Standard Gtk+ function */static void Dw_gtk_scrolled_window_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data){ GtkDwScrolledWindow *scrolled = GTK_DW_SCROLLED_WINDOW (container); GTK_CONTAINER_CLASS(parent_class)->forall (container, include_internals, callback, callback_data); if (scrolled->gadget) callback (scrolled->gadget, callback_data);}/* * Adds the gadget widget. */void a_Dw_gtk_scrolled_window_add_gadget (GtkDwScrolledWindow *scrolled, GtkWidget *gadget){ g_return_if_fail (scrolled->gadget == NULL); scrolled->gadget = gadget; gtk_widget_set_parent (gadget, GTK_WIDGET (scrolled)); gtk_widget_queue_resize (GTK_WIDGET (scrolled));}/* * Sets the top-level DwWidget. The old top-level DwWidget is destroyed. */void a_Dw_gtk_scrolled_window_set_dw (GtkDwScrolledWindow *scrolled, DwWidget *widget){ GtkWidget *viewport; DwWidget *old_child; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; if ((old_child = GTK_DW_VIEWPORT (viewport)->child)) gtk_object_destroy (GTK_OBJECT (old_child)); a_Dw_gtk_viewport_add_dw (GTK_DW_VIEWPORT (viewport), widget);}/* * Gets the top-level DwWidget. */DwWidget* a_Dw_gtk_scrolled_window_get_dw (GtkDwScrolledWindow *scrolled){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; return GTK_DW_VIEWPORT(viewport)->child;}/* * See a_Dw_gtk_viewport_set_anchor. */void a_Dw_gtk_scrolled_window_set_anchor (GtkDwScrolledWindow *scrolled, const gchar *anchor){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; a_Dw_gtk_viewport_set_anchor (GTK_DW_VIEWPORT (viewport), anchor);}/* * The scrolling position is remembered setting this value in the history-URL */gint a_Dw_gtk_scrolled_window_get_scrolling_position_x (GtkDwScrolledWindow *scrolled){ GtkLayout *viewport = GTK_LAYOUT(GTK_BIN(GTK_BIN(scrolled)->child)->child); return ((int) viewport->hadjustment->value);}/* * The scrolling position is remembered setting this value in the history-URL */gint a_Dw_gtk_scrolled_window_get_scrolling_position_y (GtkDwScrolledWindow *scrolled){ GtkLayout *viewport = GTK_LAYOUT(GTK_BIN(GTK_BIN(scrolled)->child)->child); return ((int) viewport->vadjustment->value);}/* * See a_Dw_gtk_viewport_set_scrolling_position. */void a_Dw_gtk_scrolled_window_set_scrolling_position (GtkDwScrolledWindow *scrolled, gint32 x, gint32 y){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; a_Dw_gtk_viewport_set_scrolling_position (GTK_DW_VIEWPORT (viewport), x, y);}/* * See also Dw_gtk_scrolled_window_init. * Called before possible change, save the old value. */static void Dw_gtk_scrolled_window_changed1 (GtkDwScrolledWindow *scrolled){ scrolled->old_vadjustment_value = scrolled->vadjustment->value;}/* * See also Dw_gtk_scrolled_window_init. * Called after possible change, compare old and new values. */static void Dw_gtk_scrolled_window_changed2 (GtkDwScrolledWindow *scrolled){ GtkWidget *viewport; if (scrolled->old_vadjustment_value != scrolled->vadjustment->value) { viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; Dw_gtk_viewport_remove_anchor (GTK_DW_VIEWPORT (viewport)); }}/* * Convenience function. See a_Findtext_search. */gboolean a_Dw_gtk_scrolled_window_search (GtkDwScrolledWindow *scrolled, gchar *string, gboolean case_sens){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; return a_Findtext_search (GTK_DW_VIEWPORT(viewport)->findtext_state, string, case_sens);}/* * Convenience function. See a_Findtext_reset_search. */void a_Dw_gtk_scrolled_window_reset_search (GtkDwScrolledWindow *scrolled){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; a_Findtext_reset_search (GTK_DW_VIEWPORT(viewport)->findtext_state);}/* * Convenience function. See a_Dw_gtk_viewport_widget_at_viewport_point. */DwWidget* a_Dw_gtk_scrolled_window_widget_at_viewport_point ( GtkDwScrolledWindow *scrolled, gint32 vx, gint32 vy){ GtkWidget *viewport; viewport = GTK_BIN(GTK_BIN(scrolled)->child)->child; return a_Dw_gtk_viewport_widget_at_viewport_point (GTK_DW_VIEWPORT(viewport), vx, vy);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -