⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtk2drawing.c

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 C
📖 第 1 页 / 共 5 页
字号:
    ensure_entry_widget();    gtk_draw_insertion_cursor(gEntryWidget, drawable, cliprect,                              rect, TRUE, direction, FALSE);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,                    GdkRectangle* cliprect, GtkWidgetState* state,                    GtkWidget* widget, GtkTextDirection direction){    GtkStateType bg_state = state->disabled ?                                GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;    gint x, y, width = rect->width, height = rect->height;    GtkStyle* style;    gboolean interior_focus;    gboolean theme_honors_transparency = FALSE;    gint focus_width;    gtk_widget_set_direction(widget, direction);    style = widget->style;    gtk_widget_style_get(widget,                         "interior-focus", &interior_focus,                         "focus-line-width", &focus_width,                         "honors-transparent-bg-hint", &theme_honors_transparency,                         NULL);    /* gtkentry.c uses two windows, one for the entire widget and one for the     * text area inside it. The background of both windows is set to the "base"     * color of the new state in gtk_entry_state_changed, but only the inner     * textarea window uses gtk_paint_flat_box when exposed */    TSOffsetStyleGCs(style, rect->x, rect->y);    /* This gets us a lovely greyish disabledish look */    gtk_widget_set_sensitive(widget, !state->disabled);    /* GTK fills the outer widget window with the base color before drawing the widget.     * Some older themes rely on this behavior, but many themes nowadays use rounded     * corners on their widgets. While most GTK apps are blissfully unaware of this     * problem due to their use of the default window background, we render widgets on     * many kinds of backgrounds on the web.     * If the theme is able to cope with transparency, then we can skip pre-filling     * and notify the theme it will paint directly on the canvas. */    if (theme_honors_transparency) {        g_object_set_data(G_OBJECT(widget), "transparent-bg-hint",                          GINT_TO_POINTER(TRUE));    } else {        gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE,                           cliprect->x, cliprect->y, cliprect->width, cliprect->height);        g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(FALSE));    }    /* Get the position of the inner window, see _gtk_entry_get_borders */    x = XTHICKNESS(style);    y = YTHICKNESS(style);    if (!interior_focus) {        x += focus_width;        y += focus_width;    }    /* Simulate an expose of the inner window */    gtk_paint_flat_box(style, drawable, bg_state, GTK_SHADOW_NONE,                       cliprect, widget, "entry_bg",  rect->x + x,                       rect->y + y, rect->width - 2*x, rect->height - 2*y);    /* Now paint the shadow and focus border.     * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad     * smaller when focused if the focus is not interior, then the focus. */    x = rect->x;    y = rect->y;    if (state->focused && !state->disabled) {        /* This will get us the lit borders that focused textboxes enjoy on         * some themes. */        GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);        if (!interior_focus) {            /* Indent the border a little bit if we have exterior focus                (this is what GTK does to draw native entries) */            x += focus_width;            y += focus_width;            width -= 2 * focus_width;            height -= 2 * focus_width;        }    }    gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,                     cliprect, widget, "entry", x, y, width, height);    if (state->focused && !state->disabled) {        if (!interior_focus) {            gtk_paint_focus(style, drawable,  GTK_STATE_NORMAL, cliprect,                            widget, "entry",                            rect->x, rect->y, rect->width, rect->height);        }        /* Now unset the focus flag. We don't want other entries to look         * like they're focused too! */        GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);    }    return MOZ_GTK_SUCCESS;}static gint moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,                       GdkRectangle* cliprect, GtkWidgetState* state,                       GtkTextDirection direction){    gint xthickness, ythickness;    GtkStyle *style;    GtkStateType state_type;    ensure_tree_view_widget();    ensure_scrolled_window_widget();    gtk_widget_set_direction(gTreeViewWidget, direction);    gtk_widget_set_direction(gScrolledWindowWidget, direction);    /* only handle disabled and normal states, otherwise the whole background     * area will be painted differently with other states */    state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;    /* In GTK the treeview sets the background of the window     * which contains the cells to the treeview base color.     * If we don't set it here the background color will not be correct.*/    gtk_widget_modify_bg(gTreeViewWidget, state_type,                         &gTreeViewWidget->style->base[state_type]);    style = gScrolledWindowWidget->style;    xthickness = XTHICKNESS(style);    ythickness = YTHICKNESS(style);    TSOffsetStyleGCs(gTreeViewWidget->style, rect->x, rect->y);    TSOffsetStyleGCs(style, rect->x, rect->y);    gtk_paint_flat_box(gTreeViewWidget->style, drawable, state_type,                       GTK_SHADOW_NONE, cliprect, gTreeViewWidget, "treeview",                       rect->x + xthickness, rect->y + ythickness,                       rect->width - 2 * xthickness,                       rect->height - 2 * ythickness);    gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,                     cliprect, gScrolledWindowWidget, "scrolled_window",                     rect->x, rect->y, rect->width, rect->height);     return MOZ_GTK_SUCCESS;}static gintmoz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect,                               GdkRectangle* cliprect, GtkWidgetState* state,                               gboolean isSorted, GtkTextDirection direction){    gtk_tree_view_column_set_sort_indicator(GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn),                                            isSorted);    moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,                         gTreeHeaderCellWidget, direction);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,                                     GdkRectangle* cliprect,                                     GtkWidgetState* state, GtkArrowType flags,                                     GtkTextDirection direction){    GdkRectangle arrow_rect;    GtkStateType state_type = ConvertGtkState(state);    GtkShadowType shadow_type = GTK_SHADOW_IN;    GtkArrowType arrow_type = flags;    GtkStyle* style;    ensure_tree_header_cell_widget();    gtk_widget_set_direction(gTreeHeaderSortArrowWidget, direction);    /* hard code these values */    arrow_rect.width = 11;    arrow_rect.height = 11;    arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;    arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;    style = gTreeHeaderSortArrowWidget->style;    TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,                    gTreeHeaderSortArrowWidget, "arrow",  arrow_type, TRUE,                    arrow_rect.x, arrow_rect.y,                    arrow_rect.width, arrow_rect.height);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,                                GdkRectangle* cliprect, GtkWidgetState* state,                                GtkExpanderStyle expander_state,                                GtkTextDirection direction){    GtkStyle *style;    GtkStateType state_type;    ensure_tree_view_widget();    gtk_widget_set_direction(gTreeViewWidget, direction);    style = gTreeViewWidget->style;    /* Because the frame we get is of the entire treeview, we can't get the precise     * event state of one expander, thus rendering hover and active feedback useless. */    state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;    TSOffsetStyleGCs(style, rect->x, rect->y);    gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",                       rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,                       GdkRectangle* cliprect, GtkWidgetState* state,                       GtkExpanderStyle expander_state,                       GtkTextDirection direction){    GtkStyle *style;    GtkStateType state_type = ConvertGtkState(state);    ensure_expander_widget();    gtk_widget_set_direction(gExpanderWidget, direction);    style = gExpanderWidget->style;    TSOffsetStyleGCs(style, rect->x, rect->y);    gtk_paint_expander(style, drawable, state_type, cliprect, gExpanderWidget, "expander",                       rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,                        GdkRectangle* cliprect, GtkWidgetState* state,                        gboolean ishtml, GtkTextDirection direction){    GdkRectangle arrow_rect, real_arrow_rect;    gint arrow_size, separator_width = 0;    gboolean wide_separators = FALSE;    GtkStateType state_type = ConvertGtkState(state);    GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;    GtkStyle* style;    GtkRequisition arrow_req;    ensure_combo_box_widgets();    /* Also sets the direction on gComboBoxButtonWidget, which is then     * inherited by the separator and arrow */    moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,                         gComboBoxButtonWidget, direction);    calculate_button_inner_rect(gComboBoxButtonWidget,                                rect, &arrow_rect, direction, ishtml);    /* Now arrow_rect contains the inner rect ; we want to correct the width     * to what the arrow needs (see gtk_combo_box_size_allocate) */    gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);    if (direction == GTK_TEXT_DIR_LTR)        arrow_rect.x += arrow_rect.width - arrow_req.width;    arrow_rect.width = arrow_req.width;    calculate_arrow_rect(gComboBoxArrowWidget,                         &arrow_rect, &real_arrow_rect, direction);    style = gComboBoxArrowWidget->style;    TSOffsetStyleGCs(style, rect->x, rect->y);    gtk_widget_size_allocate(gComboBoxWidget, rect);    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,                    gComboBoxArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,                    real_arrow_rect.x, real_arrow_rect.y,                    real_arrow_rect.width, real_arrow_rect.height);    /* If there is no separator in the theme, there's nothing left to do. */    if (!gComboBoxSeparatorWidget)        return MOZ_GTK_SUCCESS;    style = gComboBoxSeparatorWidget->style;    TSOffsetStyleGCs(style, rect->x, rect->y);    if (have_2_10)        gtk_widget_style_get(gComboBoxSeparatorWidget,                             "wide-separators", &wide_separators,                             "separator-width", &separator_width,                             NULL);    if (wide_separators) {        if (direction == GTK_TEXT_DIR_LTR)            arrow_rect.x -= separator_width;        else            arrow_rect.x += arrow_rect.width;        gtk_paint_box(style, drawable,                      GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,                      cliprect, gComboBoxSeparatorWidget, "vseparator",                      arrow_rect.x, arrow_rect.y,                      separator_width, arrow_rect.height);    } else {        if (direction == GTK_TEXT_DIR_LTR)            arrow_rect.x -= XTHICKNESS(style);        else            arrow_rect.x += arrow_rect.width;        gtk_paint_vline(style, drawable, GTK_STATE_NORMAL, cliprect,                        gComboBoxSeparatorWidget, "vseparator",                        arrow_rect.y, arrow_rect.y + arrow_rect.height,                        arrow_rect.x);    }    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_downarrow_paint(GdkDrawable* drawable, GdkRectangle* rect,                        GdkRectangle* cliprect, GtkWidgetState* state){    GtkStyle* style;    GtkStateType state_type = ConvertGtkState(state);    GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;    GdkRectangle arrow_rect;    ensure_button_arrow_widget();    style = gButtonArrowWidget->style;    calculate_arrow_rect(gButtonArrowWidget, rect, &arrow_rect,                         GTK_TEXT_DIR_LTR);    TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,                    gButtonArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,                    arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);    return MOZ_GTK_SUCCESS;}static gintmoz_gtk_combo_box_entry_button_paint(GdkDrawable* drawable, GdkRectangle* rect,                                     GdkRectangle* cliprect,                                     GtkWidgetState* state,                                     gboolean input_focus,                                     GtkTextDirection direction){    gint x_displacement, y_displacement;    GdkRectangle arrow_rect, real_arrow_rect;    GtkStateType state_type = ConvertGtkState(state);    GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;    GtkStyle* style;    ensure_combo_box_entry_widgets();    if (input_focus) {        /* Some themes draw a complementary focus ring for the dropdown button         * when the dropdown entry has focus */     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -