📄 gtkstyle.c
字号:
gint parent_relative; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); if (style->engine && style->engine->set_background) { style->engine->set_background (style, window, state_type); return; } if (style->bg_pixmap[state_type]) { if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) { pixmap = NULL; parent_relative = TRUE; } else { pixmap = style->bg_pixmap[state_type]; parent_relative = FALSE; } gdk_window_set_back_pixmap (window, pixmap, parent_relative); } else gdk_window_set_background (window, &style->bg[state_type]);}/* Default functions */voidgtk_style_apply_default_background (GtkStyle *style, GdkWindow *window, gboolean set_bg, GtkStateType state_type, GdkRectangle *area, gint x, gint y, gint width, gint height){ GdkRectangle new_rect, old_rect; if (area) { old_rect.x = x; old_rect.y = y; old_rect.width = width; old_rect.height = height; if (!gdk_rectangle_intersect (area, &old_rect, &new_rect)) return; } else { new_rect.x = x; new_rect.y = y; new_rect.width = width; new_rect.height = height; } if (!style->bg_pixmap[state_type] || gdk_window_get_type (window) == GDK_WINDOW_PIXMAP || (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE)) { GdkGC *gc = style->bg_gc[state_type]; if (style->bg_pixmap[state_type]) { gdk_gc_set_fill (gc, GDK_TILED); gdk_gc_set_tile (gc, style->bg_pixmap[state_type]); } gdk_draw_rectangle (window, gc, TRUE, new_rect.x, new_rect.y, new_rect.width, new_rect.height); if (style->bg_pixmap[state_type]) gdk_gc_set_fill (gc, GDK_SOLID); } else { if (set_bg) { if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) gdk_window_set_back_pixmap (window, NULL, TRUE); else gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE); } gdk_window_clear_area (window, new_rect.x, new_rect.y, new_rect.width, new_rect.height); }}static voidgtk_default_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, gchar *detail, gint x1, gint x2, gint y){ gint thickness_light; gint thickness_dark; gint i; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); thickness_light = style->klass->ythickness / 2; thickness_dark = style->klass->ythickness - thickness_light; if (area) { gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); } if (detail && !strcmp (detail, "label")) { if (state_type == GTK_STATE_INSENSITIVE) gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1); gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y); } else { for (i = 0; i < thickness_dark; i++) { gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i); } y += thickness_dark; for (i = 0; i < thickness_light; i++) { gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); } } if (area) { gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); }}static voidgtk_default_draw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, gchar *detail, gint y1, gint y2, gint x){ gint thickness_light; gint thickness_dark; gint i; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); thickness_light = style->klass->xthickness / 2; thickness_dark = style->klass->xthickness - thickness_light; if (area) { gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); } for (i = 0; i < thickness_dark; i++) { gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1); } x += thickness_dark; for (i = 0; i < thickness_light; i++) { gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i); gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); } if (area) { gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); }}static voidgtk_default_draw_shadow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, gchar *detail, gint x, gint y, gint width, gint height){ GdkGC *gc1 = NULL; GdkGC *gc2 = NULL; gint thickness_light; gint thickness_dark; gint i; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); if ((width == -1) && (height == -1)) gdk_window_get_size (window, &width, &height); else if (width == -1) gdk_window_get_size (window, &width, NULL); else if (height == -1) gdk_window_get_size (window, NULL, &height); switch (shadow_type) { case GTK_SHADOW_NONE: return; case GTK_SHADOW_IN: case GTK_SHADOW_ETCHED_IN: gc1 = style->light_gc[state_type]; gc2 = style->dark_gc[state_type]; break; case GTK_SHADOW_OUT: case GTK_SHADOW_ETCHED_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; break; } if (area) { gdk_gc_set_clip_rectangle (gc1, area); gdk_gc_set_clip_rectangle (gc2, area); if (shadow_type == GTK_SHADOW_IN || shadow_type == GTK_SHADOW_OUT) { gdk_gc_set_clip_rectangle (style->black_gc, area); gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); } } switch (shadow_type) { case GTK_SHADOW_NONE: break; case GTK_SHADOW_IN: gdk_draw_line (window, gc1, x, y + height - 1, x + width - 1, y + height - 1); gdk_draw_line (window, gc1, x + width - 1, y, x + width - 1, y + height - 1); gdk_draw_line (window, style->bg_gc[state_type], x + 1, y + height - 2, x + width - 2, y + height - 2); gdk_draw_line (window, style->bg_gc[state_type], x + width - 2, y + 1, x + width - 2, y + height - 2); gdk_draw_line (window, style->black_gc, x + 1, y + 1, x + width - 2, y + 1); gdk_draw_line (window, style->black_gc, x + 1, y + 1, x + 1, y + height - 2); gdk_draw_line (window, gc2, x, y, x + width - 1, y); gdk_draw_line (window, gc2, x, y, x, y + height - 1); break; case GTK_SHADOW_OUT: gdk_draw_line (window, gc1, x + 1, y + height - 2, x + width - 2, y + height - 2); gdk_draw_line (window, gc1, x + width - 2, y + 1, x + width - 2, y + height - 2); gdk_draw_line (window, gc2, x, y, x + width - 1, y); gdk_draw_line (window, gc2, x, y, x, y + height - 1); gdk_draw_line (window, style->bg_gc[state_type], x + 1, y + 1, x + width - 2, y + 1); gdk_draw_line (window, style->bg_gc[state_type], x + 1, y + 1, x + 1, y + height - 2); gdk_draw_line (window, style->black_gc, x, y + height - 1, x + width - 1, y + height - 1); gdk_draw_line (window, style->black_gc, x + width - 1, y, x + width - 1, y + height - 1); break; case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: thickness_light = 1; thickness_dark = 1; for (i = 0; i < thickness_dark; i++) { gdk_draw_line (window, gc1, x + i, y + height - i - 1, x + width - i - 1, y + height - i - 1); gdk_draw_line (window, gc1, x + width - i - 1, y + i, x + width - i - 1, y + height - i - 1); gdk_draw_line (window, gc2, x + i, y + i, x + width - i - 2, y + i); gdk_draw_line (window, gc2, x + i, y + i, x + i, y + height - i - 2); } for (i = 0; i < thickness_light; i++) { gdk_draw_line (window, gc1, x + thickness_dark + i, y + thickness_dark + i, x + width - thickness_dark - i - 1, y + thickness_dark + i); gdk_draw_line (window, gc1, x + thickness_dark + i, y + thickness_dark + i, x + thickness_dark + i, y + height - thickness_dark - i - 1); gdk_draw_line (window, gc2, x + thickness_dark + i, y + height - thickness_light - i - 1, x + width - thickness_light - 1, y + height - thickness_light - i - 1); gdk_draw_line (window, gc2, x + width - thickness_light - i - 1, y + thickness_dark + i, x + width - thickness_light - i - 1, y + height - thickness_light - 1); } break; } if (area) { gdk_gc_set_clip_rectangle (gc1, NULL); gdk_gc_set_clip_rectangle (gc2, NULL); if (shadow_type == GTK_SHADOW_IN || shadow_type == GTK_SHADOW_OUT) { gdk_gc_set_clip_rectangle (style->black_gc, NULL); gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -