📄 gtk2drawing.c
字号:
if (flags & MOZ_GTK_STEPPER_VERTICAL) scrollbar = gVertScrollbarWidget; else scrollbar = gHorizScrollbarWidget; gtk_widget_set_direction(scrollbar, direction); /* Some theme engines (i.e., ClearLooks) check the scrollbar's allocation to determine where it should paint rounded corners on the buttons. We need to trick them into drawing the buttons the way we want them. */ scrollbar->allocation.x = rect->x; scrollbar->allocation.y = rect->y; scrollbar->allocation.width = rect->width; scrollbar->allocation.height = rect->height; if (flags & MOZ_GTK_STEPPER_VERTICAL) { scrollbar->allocation.height *= 5; if (flags & MOZ_GTK_STEPPER_DOWN) { arrow_type = GTK_ARROW_DOWN; if (flags & MOZ_GTK_STEPPER_BOTTOM) scrollbar->allocation.y -= 4 * rect->height; else scrollbar->allocation.y -= rect->height; } else { arrow_type = GTK_ARROW_UP; if (flags & MOZ_GTK_STEPPER_BOTTOM) scrollbar->allocation.y -= 3 * rect->height; } } else { scrollbar->allocation.width *= 5; if (flags & MOZ_GTK_STEPPER_DOWN) { arrow_type = GTK_ARROW_RIGHT; if (flags & MOZ_GTK_STEPPER_BOTTOM) scrollbar->allocation.x -= 4 * rect->width; else scrollbar->allocation.x -= rect->width; } else { arrow_type = GTK_ARROW_LEFT; if (flags & MOZ_GTK_STEPPER_BOTTOM) scrollbar->allocation.x -= 3 * rect->width; } } style = scrollbar->style; TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_box(style, drawable, state_type, shadow_type, cliprect, scrollbar, detail, rect->x, rect->y, rect->width, rect->height); arrow_rect.width = rect->width / 2; arrow_rect.height = rect->height / 2; arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2; arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2; if (state_type == GTK_STATE_ACTIVE) { gtk_widget_style_get(scrollbar, "arrow-displacement-x", &arrow_displacement_x, "arrow-displacement-y", &arrow_displacement_y, NULL); arrow_rect.x += arrow_displacement_x; arrow_rect.y += arrow_displacement_y; } gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect, scrollbar, detail, arrow_type, TRUE, arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, GtkTextDirection direction){ GtkStyle* style; GtkScrollbar *scrollbar; ensure_scrollbar_widget(); if (widget == MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL) scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget); else scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget); gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction); style = GTK_WIDGET(scrollbar)->style; TSOffsetStyleGCs(style, rect->x, rect->y); gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_ACTIVE, cliprect, rect->x, rect->y, rect->width, rect->height); gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect, GTK_WIDGET(scrollbar), "trough", rect->x, rect->y, rect->width, rect->height); if (state->focused) { gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect, GTK_WIDGET(scrollbar), "trough", rect->x, rect->y, rect->width, rect->height); } return MOZ_GTK_SUCCESS;}static gintmoz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, GtkTextDirection direction){ GtkStateType state_type = (state->inHover || state->active) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; GtkShadowType shadow_type = GTK_SHADOW_OUT; GtkStyle* style; GtkScrollbar *scrollbar; GtkAdjustment *adj; gboolean activate_slider; ensure_scrollbar_widget(); if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget); else scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget); gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction); /* Make sure to set the scrollbar range before painting so that everything is drawn properly. At least the bluecurve (and maybe other) themes don't draw the top or bottom black line surrounding the scrollbar if the theme thinks that it's butted up against the scrollbar arrows. Note the increases of the clip rect below. */ /* Changing the cliprect is pretty bogus. This lets themes draw outside the frame, which means we don't invalidate them correctly. See bug 297508. But some themes do seem to need it. So we modify the frame's overflow area to account for what we're doing here; see nsNativeThemeGTK::GetWidgetOverflow. */ adj = gtk_range_get_adjustment(GTK_RANGE(scrollbar)); if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) { cliprect->x -= 1; cliprect->width += 2; adj->page_size = rect->width; } else { cliprect->y -= 1; cliprect->height += 2; adj->page_size = rect->height; } adj->lower = 0; adj->value = state->curpos; adj->upper = state->maxpos; gtk_adjustment_changed(adj); style = GTK_WIDGET(scrollbar)->style; gtk_widget_style_get(GTK_WIDGET(scrollbar), "activate-slider", &activate_slider, NULL); if (activate_slider && state->active) { shadow_type = GTK_SHADOW_IN; state_type = GTK_STATE_ACTIVE; } TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_slider(style, drawable, state_type, shadow_type, cliprect, GTK_WIDGET(scrollbar), "slider", rect->x, rect->y, rect->width, rect->height, (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_spin_paint(GdkDrawable* drawable, GdkRectangle* rect, GtkTextDirection direction){ GtkStyle* style; ensure_spin_widget(); gtk_widget_set_direction(gSpinWidget, direction); style = gSpinWidget->style; TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, gSpinWidget, "spinbutton", rect->x, rect->y, rect->width, rect->height); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_spin_updown_paint(GdkDrawable* drawable, GdkRectangle* rect, gboolean isDown, GtkWidgetState* state, GtkTextDirection direction){ GdkRectangle arrow_rect; GtkStateType state_type = ConvertGtkState(state); GtkShadowType shadow_type = state_type == GTK_STATE_ACTIVE ? GTK_SHADOW_IN : GTK_SHADOW_OUT; GtkStyle* style; ensure_spin_widget(); style = gSpinWidget->style; gtk_widget_set_direction(gSpinWidget, direction); TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gSpinWidget, isDown ? "spinbutton_down" : "spinbutton_up", rect->x, rect->y, rect->width, rect->height); /* hard code these values */ arrow_rect.width = 6; arrow_rect.height = 6; arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2; arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2; arrow_rect.y += isDown ? -1 : 1; gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL, gSpinWidget, "spinbutton", isDown ? GTK_ARROW_DOWN : GTK_ARROW_UP, TRUE, arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, GtkOrientation flags, GtkTextDirection direction){ gint x = 0, y = 0; GtkStateType state_type = ConvertGtkState(state); GtkStyle* style; GtkWidget* widget; ensure_scale_widget(); widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget); gtk_widget_set_direction(widget, direction); style = widget->style; if (flags == GTK_ORIENTATION_HORIZONTAL) { x = XTHICKNESS(style); y++; } else { x++; y = YTHICKNESS(style); } TSOffsetStyleGCs(style, rect->x, rect->y); gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL, cliprect, rect->x, rect->y, rect->width, rect->height); gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect, widget, "trough", rect->x + x, rect->y + y, rect->width - 2*x, rect->height - 2*y); if (state->focused) gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough", rect->x, rect->y, rect->width, rect->height); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, GtkOrientation flags, GtkTextDirection direction){ GtkStateType state_type = ConvertGtkState(state); GtkStyle* style; GtkWidget* widget; gint thumb_width, thumb_height, x, y; ensure_scale_widget(); widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget); gtk_widget_set_direction(widget, direction); style = widget->style; /* determine the thumb size, and position the thumb in the center in the opposite axis */ if (flags == GTK_ORIENTATION_HORIZONTAL) { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height); x = rect->x; y = rect->y + (rect->height - thumb_height) / 2; } else { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width); x = rect->x + (rect->width - thumb_width) / 2; y = rect->y; } TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect, widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale", x, y, thumb_width, thumb_height, flags); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, GtkTextDirection direction){ GtkStateType state_type = ConvertGtkState(state); GtkShadowType shadow_type; GtkStyle* style; ensure_handlebox_widget(); gtk_widget_set_direction(gHandleBoxWidget, direction); style = gHandleBoxWidget->style; shadow_type = GTK_HANDLE_BOX(gHandleBoxWidget)->shadow_type; TSOffsetStyleGCs(style, rect->x, rect->y); gtk_paint_box(style, drawable, state_type, shadow_type, cliprect, gHandleBoxWidget, "handlebox_bin", rect->x, rect->y, rect->width, rect->height); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_hpaned_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state){ GtkStateType hpaned_state = ConvertGtkState(state); ensure_hpaned_widget(); gtk_paint_handle(gHPanedWidget->style, drawable, hpaned_state, GTK_SHADOW_NONE, cliprect, gHPanedWidget, "paned", rect->x, rect->y, rect->width, rect->height, GTK_ORIENTATION_VERTICAL); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_vpaned_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state){ GtkStateType vpaned_state = ConvertGtkState(state); ensure_vpaned_widget(); gtk_paint_handle(gVPanedWidget->style, drawable, vpaned_state, GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned", rect->x, rect->y, rect->width, rect->height, GTK_ORIENTATION_HORIZONTAL); return MOZ_GTK_SUCCESS;}static gintmoz_gtk_caret_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkTextDirection direction){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -