📄 dw_button.c
字号:
if (button->child) a_Dw_widget_set_ascent (button->child, ascent - (button->relief ? widget->viewport->style->klass->ythickness : 0));}/* * Standard Dw function. */static void Dw_button_set_descent (DwWidget *widget, gint32 descent){ DwButton *button = DW_BUTTON (widget); if (button->child) a_Dw_widget_set_descent (button->child, descent - (button->relief ? widget->viewport->style->klass->ythickness : 0));}/* * Standard Dw function. */static void Dw_button_draw (DwWidget *widget, DwRectangle *area, GdkEventExpose *event){ DwButton *button = DW_BUTTON (widget); GtkStateType state; GtkShadowType shadow; GdkRectangle gdk_area; DwRectangle child_area; if (button->relief) { if (button->sensitive) { if (button->in_button) { if (button->pressed) { state = GTK_STATE_ACTIVE; shadow = GTK_SHADOW_IN; } else { state = GTK_STATE_PRELIGHT; shadow = GTK_SHADOW_OUT; } } else { state = GTK_STATE_NORMAL; shadow = GTK_SHADOW_OUT; } } else { state = GTK_STATE_INSENSITIVE; shadow = GTK_SHADOW_OUT; } gdk_area.x = p_Dw_widget_x_world_to_viewport (widget, area->x + widget->allocation.x); gdk_area.y = p_Dw_widget_y_world_to_viewport (widget, area->y + widget->allocation.y); gdk_area.width = area->width; gdk_area.height = area->height; gtk_paint_box (widget->viewport->style, DW_WIDGET_WINDOW (widget), state, shadow, &gdk_area, widget->viewport, "buttondefault", p_Dw_widget_x_world_to_viewport (widget, widget->allocation.x), p_Dw_widget_y_world_to_viewport (widget, widget->allocation.y), widget->allocation.width, DW_WIDGET_HEIGHT(widget)); } if (button->child && p_Dw_widget_intersect (button->child, area, &child_area)) a_Dw_widget_draw (button->child, &child_area, event);}/* * Standard Dw function. */static gboolean Dw_button_button_press (DwWidget *widget, gint32 x, gint32 y, GdkEventButton *event){ DwButton *button = DW_BUTTON (widget); /* assert it was the left mouse button */ if (event->button != 1) return FALSE; button->pressed = TRUE; if (button->relief) p_Dw_widget_queue_draw (widget); return TRUE;}/* * Standard Dw function. */static gboolean Dw_button_button_release (DwWidget *widget, gint32 x, gint32 y, GdkEventButton *event){ DwButton *button = DW_BUTTON (widget); gint32 cx, cy; /* Notice that button->pressed may have been set to FALSE in * Dw_button_leave_notify. */ if (button->pressed && button->in_button && button->sensitive) { /* simple "click" */ gtk_signal_emit (GTK_OBJECT (widget), button_signals[CLICKED]); /* "clicked_at": like "clicked", but position is passed, relative * to the child widget. */ if (button->child) { cx = x + widget->allocation.x - button->child->allocation.x; cy = y + widget->allocation.y - button->child->allocation.y; /* If position is outside of the child, clip at the child allocation */ if (cx < 0) cx = 0; else if (cx > button->child->allocation.width - 1) cx = button->child->allocation.width - 1; if (cy < 0) cy = 0; else if (cy > (DW_WIDGET_HEIGHT(button->child) - 1)) cy = DW_WIDGET_HEIGHT(button->child) - 1; gtk_signal_emit (GTK_OBJECT (widget), button_signals[CLICKED_AT], cx, cy); } } button->pressed = FALSE; if (button->relief) p_Dw_widget_queue_draw (widget); return TRUE;}/* Standard Dw function. */static gboolean Dw_button_enter_notify (DwWidget *widget, DwWidget *last_widget, GdkEventMotion *event){ DwButton *button = DW_BUTTON (widget); button->in_button = TRUE; if (button->relief) p_Dw_widget_queue_draw (widget); return TRUE;}/* * Standard Dw function. */static gboolean Dw_button_leave_notify (DwWidget *widget, DwWidget *next_widget, GdkEventMotion *event){ DwButton *button = DW_BUTTON (widget); if (button->child == NULL || next_widget != button->child) { button->in_button = FALSE; /* See comment at the beginning. */ button->pressed = FALSE; if (button->relief) p_Dw_widget_queue_draw (widget); } return TRUE;}/* * Standard Dw function. */static void Dw_button_add (DwContainer *container, DwWidget *widget){ DwButton *button = DW_BUTTON (container); g_return_if_fail (button->child == NULL); button->child = widget; p_Dw_widget_set_parent (widget, DW_WIDGET (container));}/* * Standard Dw function. */static void Dw_button_remove (DwContainer *container, DwWidget *widget){ DwButton *button = DW_BUTTON (container); g_return_if_fail (button->child != NULL); g_return_if_fail (widget == button->child); button->child = NULL;}/* * Standard Dw function. */static void Dw_button_forall (DwContainer *container, DwCallback callback, gpointer callback_data){ DwButton *button = DW_BUTTON (container); if (button->child) callback (button->child, callback_data);}/* * An insensitive button does not respond on user interaction. Used * in HTML forms. */void a_Dw_button_set_sensitive (DwButton *button, gboolean sensitive){ button->sensitive = sensitive; if (button->relief) p_Dw_widget_queue_draw (DW_WIDGET (button));}static DwIterator *Dw_button_iterator (DwWidget *widget, gint mask, gboolean at_end){ DwIterator *it = g_new (DwIterator, 1); it->widget = widget; it->mask = mask; it->content.type = (at_end ? DW_CONTENT_END : DW_CONTENT_START); it->next = Dw_button_iterator_next; it->prev = Dw_button_iterator_prev; it->clone = p_Dw_iterator_clone_std; it->compare = Dw_button_iterator_compare; it->free = p_Dw_iterator_free_std; it->highlight = p_Dw_iterator_highlight_std; it->get_allocation = p_Dw_iterator_get_allocation_std_only_widgets; return it;}static gboolean Dw_button_iterator_next (DwIterator *it){ if (it->content.type == DW_CONTENT_START && (it->mask & DW_CONTENT_WIDGET) && DW_BUTTON(it->widget)->child) { it->content.type = DW_CONTENT_WIDGET; it->content.data.widget = DW_BUTTON(it->widget)->child; return TRUE; } else { it->content.type = DW_CONTENT_END; return FALSE; }}static gboolean Dw_button_iterator_prev (DwIterator *it){ if (it->content.type == DW_CONTENT_END && (it->mask & DW_CONTENT_WIDGET) && DW_BUTTON(it->widget)->child) { it->content.type = DW_CONTENT_WIDGET; it->content.data.widget = DW_BUTTON(it->widget)->child; return TRUE; } else { it->content.type = DW_CONTENT_START; return FALSE; }}static gint Dw_button_iterator_compare (DwIterator *it1, DwIterator *it2){ if (it1->content.type == it2->content.type) return 0; switch (it1->content.type) { case DW_CONTENT_START: return -1; case DW_CONTENT_TEXT: if (it2->content.type == DW_CONTENT_START) return +1; else return -1; case DW_CONTENT_END: return +1; default: return 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -