📄 msw_style.c
字号:
if (detail && strcmp (detail, "option") == 0) /* Menu item */ { if (shadow == GTK_SHADOW_IN) draw_part (window, style->fg_gc[state], area, x, y, RADIO_TEXT); } else { if (xp_theme_draw (window, shadow == GTK_SHADOW_IN ? XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON : XP_THEME_ELEMENT_RADIO_BUTTON, style, x, y, width, height, state, area)) { } else { draw_part (window, style->black_gc, area, x, y, RADIO_BLACK); draw_part (window, style->dark_gc[state], area, x, y, RADIO_DARK); draw_part (window, style->mid_gc[state], area, x, y, RADIO_MID); draw_part (window, style->light_gc[state], area, x, y, RADIO_LIGHT); draw_part (window, style->base_gc[state], area, x, y, RADIO_BASE); if (shadow == GTK_SHADOW_IN) draw_part (window, style->text_gc[state], area, x, y, RADIO_TEXT); } }}static voiddraw_varrow (GdkWindow *window, GdkGC *gc, GtkShadowType shadow_type, GdkRectangle *area, GtkArrowType arrow_type, gint x, gint y, gint width, gint height){ gint steps, extra; gint y_start, y_increment; gint i; if (area) gdk_gc_set_clip_rectangle (gc, area); width = width + width % 2 - 1; /* Force odd */ steps = 1 + width / 2; extra = height - steps; if (arrow_type == GTK_ARROW_DOWN) { y_start = y; y_increment = 1; } else { y_start = y + height - 1; y_increment = -1; } for (i = extra; i < height; i++) { gdk_draw_line (window, gc, x + (i - extra), y_start + i * y_increment, x + width - (i - extra) - 1, y_start + i * y_increment); } if (area) gdk_gc_set_clip_rectangle (gc, NULL);}static voiddraw_harrow (GdkWindow *window, GdkGC *gc, GtkShadowType shadow_type, GdkRectangle *area, GtkArrowType arrow_type, gint x, gint y, gint width, gint height){ gint steps, extra; gint x_start, x_increment; gint i; if (area) gdk_gc_set_clip_rectangle (gc, area); height = height + height % 2 - 1; /* Force odd */ steps = 1 + height / 2; extra = width - steps; if (arrow_type == GTK_ARROW_RIGHT) { x_start = x; x_increment = 1; } else { x_start = x + width - 1; x_increment = -1; } for (i = extra; i < width; i++) { gdk_draw_line (window, gc, x_start + i * x_increment, y + (i - extra), x_start + i * x_increment, y + height - (i - extra) - 1); } if (area) gdk_gc_set_clip_rectangle (gc, NULL);}/* This function makes up for some brokeness in gtkrange.c * where we never get the full arrow of the stepper button * and the type of button in a single drawing function. * * It doesn't work correctly when the scrollbar is squished * to the point we don't have room for full-sized steppers. */static voidreverse_engineer_stepper_box (GtkWidget *range, GtkArrowType arrow_type, gint *x, gint *y, gint *width, gint *height){ gint slider_width = 14, stepper_size = 14; gint box_width; gint box_height; if (range) { gtk_widget_style_get (range, "slider_width", &slider_width, "stepper_size", &stepper_size, NULL); } if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) { box_width = slider_width; box_height = stepper_size; } else { box_width = stepper_size; box_height = slider_width; } *x = *x - (box_width - *width) / 2; *y = *y - (box_height - *height) / 2; *width = box_width; *height = box_height;}static XpThemeElement to_xp_arrow(GtkArrowType arrow_type){ XpThemeElement xp_arrow; switch (arrow_type) { case GTK_ARROW_UP: xp_arrow = XP_THEME_ELEMENT_ARROW_UP; break; case GTK_ARROW_DOWN: xp_arrow = XP_THEME_ELEMENT_ARROW_DOWN; break; case GTK_ARROW_LEFT: xp_arrow = XP_THEME_ELEMENT_ARROW_LEFT; break; default: xp_arrow = XP_THEME_ELEMENT_ARROW_RIGHT; break; } return xp_arrow;}static voiddraw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state, GtkShadowType shadow, GdkRectangle *area, GtkWidget *widget, const gchar *detail, GtkArrowType arrow_type, gboolean fill, gint x, gint y, gint width, gint height){ const gchar * name; name = gtk_widget_get_name (widget); sanitize_size (window, &width, &height); if (detail && strcmp (detail, "spinbutton") == 0) { if (xp_theme_is_drawable(XP_THEME_ELEMENT_SPIN_BUTTON_UP)) { return; } else { x += (width - 7) / 2; if (arrow_type == GTK_ARROW_UP) y += (height - 4) / 2; else y += (1 + height - 4) / 2; draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type, x, y, 7, 4); } } else if (detail && (!strcmp (detail, "vscrollbar") || !strcmp (detail, "hscrollbar"))) { gboolean is_disabled = FALSE; GtkScrollbar * scrollbar = GTK_SCROLLBAR(widget); gint box_x = x; gint box_y = y; gint box_width = width; gint box_height = height; reverse_engineer_stepper_box (widget, arrow_type, &box_x, &box_y, &box_width, &box_height); if (scrollbar->range.adjustment->page_size >= (scrollbar->range.adjustment->upper-scrollbar->range.adjustment->lower)) is_disabled = TRUE; if (xp_theme_draw(window, to_xp_arrow(arrow_type), style, box_x, box_y, box_width, box_height, state, area)) { } else if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) { x += (width - 7) / 2; y += (height - 5) / 2; draw_varrow (window, is_disabled ? style->text_aa_gc[state] : style->fg_gc[state], shadow, area, arrow_type, x, y, 7, 5); } else { y += (height - 7) / 2; x += (width - 5) / 2; draw_harrow (window, is_disabled ? style->text_aa_gc[state] : style->fg_gc[state], shadow, area, arrow_type, x, y, 5, 7); } } else { /* draw the toolbar chevrons - waiting for GTK 2.4 */ if (name && !strcmp (name, "gtk-toolbar-arrow")) { if (xp_theme_draw(window, XP_THEME_ELEMENT_REBAR_CHEVRON, style, x, y, width, height, state, area)) return; } /* probably a gtk combo box on a toolbar */ else if (0 /*widget->parent && GTK_IS_BUTTON (widget->parent)*/) { if (xp_theme_draw(window, XP_THEME_ELEMENT_COMBOBUTTON, style, x-3, widget->allocation.y+1, width+5, widget->allocation.height-4, state, area)) return; } if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) { x += (width - 7) / 2; y += (height - 5) / 2; draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type, x, y, 7, 5); } else { x += (width - 5) / 2; y += (height - 7) / 2; draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type, x, y, 5, 7); } }}static voidoption_menu_get_props (GtkWidget *widget, GtkRequisition *indicator_size, GtkBorder *indicator_spacing){ GtkRequisition *tmp_size = NULL; GtkBorder *tmp_spacing = NULL; if (widget) gtk_widget_style_get (widget, "indicator_size", &tmp_size, "indicator_spacing", &tmp_spacing, NULL); if (tmp_size) { *indicator_size = *tmp_size; g_free (tmp_size); } else *indicator_size = default_option_indicator_size; if (tmp_spacing) { *indicator_spacing = *tmp_spacing; g_free (tmp_spacing); } else *indicator_spacing = default_option_indicator_spacing;}static gboolean is_toolbar_child(GtkWidget * wid){ while(wid) { if(GTK_IS_TOOLBAR(wid) || GTK_IS_HANDLE_BOX(wid)) return TRUE; else wid = wid->parent; } return FALSE;}static voiddraw_box (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height){ if (detail && (!strcmp (detail, "button") || !strcmp (detail, "buttondefault"))) { if (GTK_IS_TREE_VIEW (widget->parent) || GTK_IS_CLIST (widget->parent)) { if (xp_theme_draw(window, XP_THEME_ELEMENT_LIST_HEADER, style, x, y, width, height, state_type, area)) return; } else if (is_toolbar_child (widget->parent)) { if (xp_theme_draw(window, XP_THEME_ELEMENT_TOOLBAR_BUTTON, style, x, y, width, height, state_type, area)) return; } else { gboolean is_default = !strcmp (detail, "buttondefault"); if (xp_theme_draw(window, is_default ? XP_THEME_ELEMENT_DEFAULT_BUTTON : XP_THEME_ELEMENT_BUTTON, style, x, y, width, height, state_type, area)) return; } } else if (detail && !strcmp (detail, "spinbutton")) { if (xp_theme_is_drawable(XP_THEME_ELEMENT_SPIN_BUTTON_UP)) { return; } } else if (detail && (!strcmp (detail, "spinbutton_up") || !strcmp (detail, "spinbutton_down"))) { if (xp_theme_draw(window, (! strcmp (detail, "spinbutton_up")) ? XP_THEME_ELEMENT_SPIN_BUTTON_UP : XP_THEME_ELEMENT_SPIN_BUTTON_DOWN, style, x, y, width, height, state_type, area)) { return; } } else if (detail && !strcmp (detail, "slider")) { if (GTK_IS_SCROLLBAR(widget)) { GtkScrollbar * scrollbar = GTK_SCROLLBAR(widget); gboolean is_v = GTK_IS_VSCROLLBAR(widget); if (xp_theme_draw(window, is_v ? XP_THEME_ELEMENT_SCROLLBAR_V : XP_THEME_ELEMENT_SCROLLBAR_H, style, x, y, width, height, state_type, area)) { XpThemeElement gripper = (is_v ? XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V : XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H); /* Do not display grippers on tiny scroll bars, the limit imposed is rather arbitrary, perhaps we can fetch the gripper geometry from somewhere and use that... */ if ((gripper == XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H && width < 16) || (gripper == XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V && height < 16)) { return; } xp_theme_draw(window, gripper, style, x, y, width, height, state_type, area); return; } else { if (scrollbar->range.adjustment->page_size >= (scrollbar->range.adjustment->upper-scrollbar->range.adjustment->lower)) return; } } } else if (detail && !strcmp (detail, "bar")) { if (widget && GTK_IS_PROGRESS_BAR (widget)) { GtkProgressBar *progress_bar = GTK_PROGRESS_BAR(widget); XpThemeElement xp_progress_bar = map_gtk_progress_bar_to_xp (progress_bar, FALSE); if (xp_theme_draw (window, xp_progress_bar, style, x, y, width, height, state_type, area)) { return; } } } else if (detail && strcmp (detail, "menuitem") == 0) { shadow_type = GTK_SHADOW_NONE; if (xp_theme_draw (window, XP_THEME_ELEMENT_MENU_ITEM, style, x, y, width, height, state_type, area)) { return; } } else if (detail && !strcmp (detail, "trough")) { if (widget && GTK_IS_PROGRESS_BAR (widget)) { GtkProgressBar *progress_bar = GTK_PROGRESS_BAR(widget); XpThemeElement xp_progress_bar = map_gtk_progress_bar_to_xp (progress_bar, TRUE); if (xp_theme_draw (window, xp_progress_bar, style, x, y, width, height, state_type, area)) { return; } else { /* Blank in classic Windows */ } } else if (widget && GTK_IS_SCROLLBAR(widget)) { gboolean is_vertical = GTK_IS_VSCROLLBAR(widget); if (GTK_IS_RANGE(widget) && xp_theme_draw(window, is_vertical ? XP_THEME_ELEMENT_TROUGH_V : XP_THEME_ELEMENT_TROUGH_H, style, x, y, width, height, state_type, area)) { return; } else { GdkGCValues gc_values; GdkGC *gc; GdkPixmap *pixmap; sanitize_size (window, &width, &height); pixmap = gdk_pixmap_new (window, 2, 2, -1); gdk_draw_point (pixmap, style->bg_gc[GTK_STATE_NORMAL], 0, 0); gdk_draw_point (pixmap, style->bg_gc[GTK_STATE_NORMAL], 1, 1); gdk_draw_point (pixmap, style->light_gc[GTK_STATE_NORMAL], 1, 0); gdk_draw_point (pixmap, style->light_gc[GTK_STATE_NORMAL], 0, 1); gc_values.fill = GDK_TILED; gc_values.tile = pixmap; gc_values.ts_x_origin = x; gc_values.ts_y_origin = y; gc = gdk_gc_new_with_values (window, &gc_values, GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN | GDK_GC_FILL | GDK_GC_TILE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -