📄 gtkstyle.c
字号:
static voidgtk_default_draw_polygon (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, gchar *detail, GdkPoint *points, gint npoints, gboolean fill){ static const gdouble pi_over_4 = M_PI_4; static const gdouble pi_3_over_4 = M_PI_4 * 3; GdkGC *gc1; GdkGC *gc2; GdkGC *gc3; GdkGC *gc4; gdouble angle; gint xadjust; gint yadjust; gint i; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); g_return_if_fail (points != NULL); switch (shadow_type) { case GTK_SHADOW_IN: gc1 = style->bg_gc[state_type]; gc2 = style->dark_gc[state_type]; gc3 = style->light_gc[state_type]; gc4 = style->black_gc; break; case GTK_SHADOW_ETCHED_IN: gc1 = style->light_gc[state_type]; gc2 = style->dark_gc[state_type]; gc3 = style->dark_gc[state_type]; gc4 = style->light_gc[state_type]; break; case GTK_SHADOW_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; gc3 = style->black_gc; gc4 = style->bg_gc[state_type]; break; case GTK_SHADOW_ETCHED_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; gc3 = style->light_gc[state_type]; gc4 = style->dark_gc[state_type]; break; default: return; } if (area) { gdk_gc_set_clip_rectangle (gc1, area); gdk_gc_set_clip_rectangle (gc2, area); gdk_gc_set_clip_rectangle (gc3, area); gdk_gc_set_clip_rectangle (gc4, area); } if (fill) gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints); npoints--; for (i = 0; i < npoints; i++) { if ((points[i].x == points[i+1].x) && (points[i].y == points[i+1].y)) { angle = 0; } else { angle = atan2 (points[i+1].y - points[i].y, points[i+1].x - points[i].x); } if ((angle > -pi_3_over_4) && (angle < pi_over_4)) { if (angle > -pi_over_4) { xadjust = 0; yadjust = 1; } else { xadjust = 1; yadjust = 0; } gdk_draw_line (window, gc1, points[i].x-xadjust, points[i].y-yadjust, points[i+1].x-xadjust, points[i+1].y-yadjust); gdk_draw_line (window, gc3, points[i].x, points[i].y, points[i+1].x, points[i+1].y); } else { if ((angle < -pi_3_over_4) || (angle > pi_3_over_4)) { xadjust = 0; yadjust = 1; } else { xadjust = 1; yadjust = 0; } gdk_draw_line (window, gc4, points[i].x+xadjust, points[i].y+yadjust, points[i+1].x+xadjust, points[i+1].y+yadjust); gdk_draw_line (window, gc2, points[i].x, points[i].y, points[i+1].x, points[i+1].y); } } if (area) { gdk_gc_set_clip_rectangle (gc1, NULL); gdk_gc_set_clip_rectangle (gc2, NULL); gdk_gc_set_clip_rectangle (gc3, NULL); gdk_gc_set_clip_rectangle (gc4, NULL); }}static voidgtk_default_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, gchar *detail, GtkArrowType arrow_type, gboolean fill, gint x, gint y, gint width, gint height){ GdkGC *gc1; GdkGC *gc2; GdkGC *gc3; GdkGC *gc4; gint half_width; gint half_height; GdkPoint points[3]; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); switch (shadow_type) { case GTK_SHADOW_IN: gc1 = style->bg_gc[state_type]; gc2 = style->dark_gc[state_type]; gc3 = style->light_gc[state_type]; gc4 = style->black_gc; break; case GTK_SHADOW_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; gc3 = style->black_gc; gc4 = style->bg_gc[state_type]; break; case GTK_SHADOW_ETCHED_IN: gc1 = style->light_gc[state_type]; gc2 = style->dark_gc[state_type]; gc3 = NULL; gc4 = NULL; break; case GTK_SHADOW_ETCHED_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; gc3 = NULL; gc4 = NULL; break; default: return; } 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); half_width = width / 2; half_height = height / 2; if (area) { gdk_gc_set_clip_rectangle (gc1, area); gdk_gc_set_clip_rectangle (gc2, area); if ((gc3) && (gc4)) { gdk_gc_set_clip_rectangle (gc3, area); gdk_gc_set_clip_rectangle (gc4, area); } } switch (arrow_type) { case GTK_ARROW_UP: if (fill) { points[0].x = x + half_width; points[0].y = y; points[1].x = x; points[1].y = y + height - 1; points[2].x = x + width - 1; points[2].y = y + height - 1; gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); } switch (shadow_type) { case GTK_SHADOW_IN: case GTK_SHADOW_OUT: gdk_draw_line (window, gc1, x + 1, y + height - 2, x + width - 2, y + height - 2); gdk_draw_line (window, gc3, x + 0, y + height - 1, x + width - 1, y + height - 1); gdk_draw_line (window, gc1, x + width - 2, y + height - 1, x + half_width, y + 1); gdk_draw_line (window, gc3, x + width - 1, y + height - 1, x + half_width, y); gdk_draw_line (window, gc4, x + half_width, y + 1, x + 1, y + height - 1); gdk_draw_line (window, gc2, x + half_width, y, x, y + height - 1); break; case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: gdk_draw_line (window, gc1, x + half_width, y + 1, x + 1, y + height - 1); gdk_draw_line (window, gc1, x + 1, y + height - 1, x + width - 1, y + height - 1); gdk_draw_line (window, gc1, x + width - 1, y + height - 1, x + half_width + 1, y + 1); points[0].x = x + half_width; points[0].y = y; points[1].x = x; points[1].y = y + height - 2; points[2].x = x + width - 2; points[2].y = y + height - 2; gdk_draw_polygon (window, gc2, FALSE, points, 3); break; default: break; } break; case GTK_ARROW_DOWN: if (fill) { points[0].x = x + width - 1; points[0].y = y; points[1].x = x; points[1].y = y; points[2].x = x + half_width; points[2].y = y + height - 1; gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); } switch (shadow_type) { case GTK_SHADOW_IN: case GTK_SHADOW_OUT: gdk_draw_line (window, gc4, x + width - 2, y + 1, x + 1, y + 1); gdk_draw_line (window, gc2, x + width - 1, y, x, y); gdk_draw_line (window, gc4, x + 1, y, x + half_width, y + height - 2); gdk_draw_line (window, gc2, x, y, x + half_width, y + height - 1); gdk_draw_line (window, gc1, x + half_width, y + height - 2, x + width - 2, y); gdk_draw_line (window, gc3, x + half_width, y + height - 1, x + width - 1, y); break; case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: gdk_draw_line (window, gc1, x + width - 1, y + 1, x + 1, y + 1); gdk_draw_line (window, gc1, x + 1, y + 1, x + half_width + 1, y + height - 1); gdk_draw_line (window, gc1, x + half_width + 1, y + height - 2, x + width - 1, y); points[0].x = x + width - 2; points[0].y = y; points[1].x = x; points[1].y = y; points[2].x = x + half_width; points[2].y = y + height - 2; gdk_draw_polygon (window, gc2, FALSE, points, 3); break; default: break; } break; case GTK_ARROW_LEFT: if (fill) { points[0].x = x; points[0].y = y + half_height; points[1].x = x + width - 1; points[1].y = y + height - 1; points[2].x = x + width - 1; points[2].y = y; gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); } switch (shadow_type) { case GTK_SHADOW_IN: case GTK_SHADOW_OUT: gdk_draw_line (window, gc1, x + 1, y + half_height, x + width - 1, y + height - 1); gdk_draw_line (window, gc3, x, y + half_height, x + width - 1, y + height - 1); gdk_draw_line (window, gc1, x + width - 2, y + height - 1, x + width - 2, y + 1); gdk_draw_line (window, gc3,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -