📄 msw_style.c
字号:
if (area) gdk_gc_set_clip_rectangle (gc, area); gdk_draw_rectangle (window, gc, TRUE, x, y, width, height); g_object_unref (gc); g_object_unref (pixmap); return; } } else if (widget && GTK_IS_SCALE(widget)) { gboolean is_vertical = GTK_IS_VSCALE(widget); parent_class->draw_box (style, window, state_type, GTK_SHADOW_NONE, area, widget, detail, x, y, width, height); if(is_vertical) parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, (2 * x + width)/2, y, 1, height); else parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, x, (2 * y + height)/2, width, 1); return; } } else if (detail && strcmp (detail, "optionmenu") == 0) { if (xp_theme_draw(window, XP_THEME_ELEMENT_EDIT_TEXT, style, x, y, width, height, state_type, area)) { return; } } else if (detail && (strcmp (detail, "vscrollbar") == 0 || strcmp (detail, "hscrollbar") == 0)) { GtkScrollbar * scrollbar = GTK_SCROLLBAR(widget); if (shadow_type == GTK_SHADOW_IN) shadow_type = GTK_SHADOW_ETCHED_IN; if (scrollbar->range.adjustment->page_size >= (scrollbar->range.adjustment->upper-scrollbar->range.adjustment->lower)) shadow_type = GTK_SHADOW_OUT; } else if (detail && strcmp (detail, "handlebox_bin") == 0) { if (xp_theme_draw(window, XP_THEME_ELEMENT_REBAR, style, x, y, width, height, state_type, area)) { return; } } else { const gchar * name = gtk_widget_get_name (widget); if (name && !strcmp (name, "gtk-tooltips")) { if (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, height, state_type, area)) { return; } else { HBRUSH brush; gint xoff, yoff; GdkDrawable *drawable; RECT rect; HDC hdc; if (!GDK_IS_WINDOW(window)) { xoff = 0; yoff = 0; drawable = window; } else { gdk_window_get_internal_paint_info(window, &drawable, &xoff, &yoff); } rect.left = x - xoff; rect.top = y - yoff; rect.right = rect.left + width; rect.bottom = rect.top + height; hdc = gdk_win32_hdc_get(window, style->dark_gc[state_type], 0); brush = GetSysColorBrush(COLOR_3DDKSHADOW); if (brush) FrameRect(hdc, &rect, brush); InflateRect(&rect, -1, -1); FillRect(hdc, &rect, (HBRUSH) (COLOR_INFOBK+1)); return; } } } parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); if (detail && strcmp (detail, "optionmenu") == 0) { GtkRequisition indicator_size; GtkBorder indicator_spacing; gint vline_x; option_menu_get_props (widget, &indicator_size, &indicator_spacing); sanitize_size (window, &width, &height); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) vline_x = x + indicator_size.width + indicator_spacing.left + indicator_spacing.right; else vline_x = x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness; parent_class->draw_vline (style, window, state_type, area, widget, detail, y + style->ythickness + 1, y + height - style->ythickness - 3, vline_x); }}static voiddraw_tab (GtkStyle *style, GdkWindow *window, GtkStateType state, GtkShadowType shadow, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height){ GtkRequisition indicator_size; GtkBorder indicator_spacing; gint arrow_height; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); if (detail && ! strcmp (detail, "optionmenutab")) { if (xp_theme_draw(window, XP_THEME_ELEMENT_COMBOBUTTON, style, x-5, widget->allocation.y+1, width+10, widget->allocation.height-2, state, area)) { return; } } if (widget) gtk_widget_style_get (widget, "indicator_size", &indicator_size, NULL); option_menu_get_props (widget, &indicator_size, &indicator_spacing); x += (width - indicator_size.width) / 2; arrow_height = (indicator_size.width + 1) / 2; y += (height - arrow_height) / 2; draw_varrow (window, style->black_gc, shadow, area, GTK_ARROW_DOWN, x, y, indicator_size.width, arrow_height);}/* this is an undefined magic value that, according to the mozilla folks, worked for all the various themes that they tried */#define XP_EDGE_SIZE 2static voiddraw_extension(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, GtkPositionType gap_side){ if (detail && !strcmp(detail, "tab")) { GtkNotebook *notebook = GTK_NOTEBOOK(widget); GtkPositionType pos_type = gtk_notebook_get_tab_pos(notebook); if (pos_type == GTK_POS_TOP && state_type == GTK_STATE_NORMAL) height += XP_EDGE_SIZE;#if 0 /* FIXME: pos != TOP to be implemented */ else if (pos_type == GTK_POS_BOTTOM) y -= XP_EDGE_SIZE; else if (pos_type == GTK_POS_RIGHT) width += XP_EDGE_SIZE; else if (pos_type == GTK_POS_LEFT) height -= XP_EDGE_SIZE;#endif if (pos_type == GTK_POS_TOP && xp_theme_draw (window, gtk_notebook_get_current_page(notebook)==0 ? XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE : XP_THEME_ELEMENT_TAB_ITEM, style, x, y, width, height, state_type, area)) { return; } } parent_class->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);}static voiddraw_box_gap (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, GtkPositionType gap_side, gint gap_x, gint gap_width){ if (detail && !strcmp(detail, "notebook")) { GtkNotebook *notebook = GTK_NOTEBOOK(widget); /* FIXME: pos != TOP to be implemented */ if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP && xp_theme_draw(window, XP_THEME_ELEMENT_TAB_PANE, style, x, y, width, height, state_type, area)) { return; } } parent_class->draw_box_gap(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);}static voiddraw_flat_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, "checkbutton")) { if (state_type == GTK_STATE_PRELIGHT) { return; } } parent_class->draw_flat_box(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);}static voiddraw_shadow (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, "entry")) { if (xp_theme_draw(window, XP_THEME_ELEMENT_EDIT_TEXT, style, x, y, width, height, state_type, area)) { return; } } parent_class->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);}static voiddraw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x1, gint x2, gint y){ if (detail && !strcmp(detail, "menuitem")) { if (xp_theme_draw(window, XP_THEME_ELEMENT_MENU_SEPARATOR, style, x1, y, x2, style->ythickness, state_type, area)) { return; } } parent_class->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);}static voiddraw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint y1, gint y2, gint x){ parent_class->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);}static voiddraw_resize_grip (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, GdkWindowEdge edge, gint x, gint y, gint width, gint height){ if (detail && !strcmp(detail, "statusbar")) {#if 0 /* DAL: TODO: find out why this regressed */ if (xp_theme_draw(window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width, height, state_type, area)) return;#endif } parent_class->draw_resize_grip (style, window, state_type, area, widget, detail, edge, x, y, width, height);}static voiddraw_handle (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, GtkOrientation orientation){ if (is_toolbar_child (widget)) { XpThemeElement hndl; sanitize_size (window, &width, &height); if (orientation == GTK_ORIENTATION_VERTICAL) hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V; else hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H; if (xp_theme_draw (window, hndl, style, x, y, width, height, state_type, area)) { return; } /* grippers are just flat boxes when they're not a toolbar */ parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } else if (!GTK_IS_PANED (widget)) { /* TODO: Draw handle boxes as double lines: || */ parent_class->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); }}static GdkPixbuf *render_icon (GtkStyle *style, const GtkIconSource *source, GtkTextDirection direction, GtkStateType state, GtkIconSize size, GtkWidget *widget, const gchar *detail){ if (gtk_icon_source_get_state_wildcarded (source) && state == GTK_STATE_INSENSITIVE) { GdkPixbuf *normal, *insensitive; int i, j, w, h, rs; guchar *pixels, *row; normal = parent_class->render_icon (style, source, direction, GTK_STATE_NORMAL, size, widget, detail); /* copy and add alpha channel at the same time */ insensitive = gdk_pixbuf_add_alpha (normal, FALSE, 0, 0, 0); g_object_unref (normal); /* remove all colour */ gdk_pixbuf_saturate_and_pixelate (insensitive, insensitive, 0.0, FALSE); /* make partially transparent */ w = gdk_pixbuf_get_width (insensitive); h = gdk_pixbuf_get_height (insensitive); rs = gdk_pixbuf_get_rowstride (insensitive); pixels = gdk_pixbuf_get_pixels (insensitive); for (j=0; j<h; j++) { row = pixels + j * rs; for (i=0; i<w; i++) { row[i*4 + 3] = (guchar)(row[i*4 + 3] * 0.6); } } return insensitive; } else { return parent_class->render_icon (style, source, direction, state, size, widget, detail); }}static voidmsw_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style){ setup_system_font (style); setup_menu_settings (gtk_settings_get_default ()); setup_system_styles (style); parent_class->init_from_rc(style, rc_style);}static voidmsw_style_class_init (MswStyleClass *klass){ GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); parent_class = g_type_class_peek_parent (klass); style_class->init_from_rc = msw_style_init_from_rc; style_class->draw_arrow = draw_arrow; style_class->draw_box = draw_box; style_class->draw_check = draw_check; style_class->draw_option = draw_option; style_class->draw_tab = draw_tab; style_class->draw_flat_box = draw_flat_box; style_class->draw_expander = draw_expander; style_class->draw_extension = draw_extension; style_class->draw_box_gap = draw_box_gap; style_class->draw_shadow = draw_shadow; style_class->draw_hline = draw_hline; style_class->draw_vline = draw_vline; style_class->draw_handle = draw_handle; style_class->draw_resize_grip = draw_resize_grip; style_class->render_icon = render_icon;}GType msw_type_style = 0;voidmsw_style_register_type (GTypeModule *module){ static const GTypeInfo object_info = { sizeof (MswStyleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) msw_style_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (MswStyle), 0, /* n_preallocs */ (GInstanceInitFunc) NULL, }; msw_type_style = g_type_module_register_type (module, GTK_TYPE_STYLE, "MswStyle", &object_info, 0);}voidmsw_style_init (void){ xp_theme_init (); msw_style_setup_system_settings (); setup_msw_rc_style ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -