void cl_draw_inset (GtkStyle *style, GdkWindow *window, GtkWidget *widget, GdkRectangle *area, gint x, gint y, gint width, gint height, int tl, int tr, int bl, int br ) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style); ClearlooksStyle *clwindowstyle; /* style of the window this widget is on */ GtkStateType windowstate; CLRectangle r; cl_rectangle_init (&r, NULL, style->black_gc, tl, tr, bl, br); r.gradient_type = CL_GRADIENT_VERTICAL; cl_get_window_style_state(widget, (GtkStyle**)&clwindowstyle, &windowstate); g_assert (clwindowstyle != NULL); if (GTK_WIDGET_HAS_DEFAULT (widget)) { r.bordergc = style->mid_gc[GTK_STATE_NORMAL]; } else { cl_rectangle_set_gradient (&r.border_gradient, &clwindowstyle->inset_dark[windowstate], &clwindowstyle->inset_light[windowstate]); } cl_rectangle_set_clip_rectangle (&r, area); cl_draw_rectangle (window, widget, style, x, y, width, height, &r); cl_rectangle_reset_clip_rectangle (&r); }
wxSize wxButton::DoGetBestSize() const { // the default button in wxGTK is bigger than the other ones because of an // extra border around it, but we don't want to take it into account in // our size calculations (otherwsie the result is visually ugly), so // always return the size of non default button from here const bool isDefault = GTK_WIDGET_HAS_DEFAULT(m_widget); if ( isDefault ) { // temporarily unset default flag GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_DEFAULT ); } wxSize ret( wxControl::DoGetBestSize() ); if ( isDefault ) { // set it back again GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); } ret.x += 10; // add a few pixels for sloppy (but common) themes if (!HasFlag(wxBU_EXACTFIT)) { wxSize defaultSize = GetDefaultSize(); if (ret.x < defaultSize.x) ret.x = defaultSize.x; if (ret.y < defaultSize.y) ret.y = defaultSize.y; } CacheBestSize(ret); return ret; }
/* This function is based on a portion of EnGradient's draw_box */ void draw_default_triangle(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) { GdkPoint points1[3]; /* dark */ GdkPoint points2[3]; /* light */ points1[0].x = x+2; points1[0].y = y+2; points1[1].x = x+10; points1[1].y = y+2; points1[2].x = x+2; points1[2].y = y+10; points2[0].x = x+3; points2[0].y = y+3; points2[1].x = x+10; points2[1].y = y+3; points2[2].x = x+3; points2[2].y = y+10; if (area) { gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); gdk_gc_set_clip_rectangle(style->light_gc[state_type], area); gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area); } /* Paint a triangle here instead of in "buttondefault" which is drawn _behind_ the current button */ if (GTK_WIDGET_HAS_DEFAULT (widget)) { gdk_draw_polygon(window, style->dark_gc[state_type], FALSE, points1, 3); gdk_draw_polygon(window, style->light_gc[state_type], FALSE, points2, 3); gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED], TRUE, points2, 3); } if (area) { gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); } }
void _gtk_button_paint (GtkButton *button, GdkRectangle *area, GtkStateType state_type, GtkShadowType shadow_type, const gchar *main_detail, const gchar *default_detail) { GtkWidget *widget; gint width, height; gint x, y; gint border_width; GtkBorder default_border; GtkBorder default_outside_border; gboolean interior_focus; gint focus_width; gint focus_pad; if (GTK_WIDGET_DRAWABLE (button)) { widget = GTK_WIDGET (button); border_width = GTK_CONTAINER (widget)->border_width; gtk_button_get_props (button, &default_border, &default_outside_border, &interior_focus); gtk_widget_style_get (GTK_WIDGET (widget), "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); x = widget->allocation.x + border_width; y = widget->allocation.y + border_width; width = widget->allocation.width - border_width * 2; height = widget->allocation.height - border_width * 2; if (GTK_WIDGET_HAS_DEFAULT (widget) && GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) { if(!uxtheme_dll) gtk_paint_box (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, area, widget, "buttondefault", x, y, width, height); x += default_border.left; y += default_border.top; width -= default_border.left + default_border.right; height -= default_border.top + default_border.bottom; } else if (GTK_WIDGET_CAN_DEFAULT (widget)) { x += default_outside_border.left; y += default_outside_border.top; width -= default_outside_border.left + default_outside_border.right; height -= default_outside_border.top + default_outside_border.bottom; } if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget)) { x += focus_width + focus_pad; y += focus_width + focus_pad; width -= 2 * (focus_width + focus_pad); height -= 2 * (focus_width + focus_pad); } if ((button->relief != GTK_RELIEF_NONE) || ((GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL) && (GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))) gtk_paint_box (widget->style, widget->window, state_type, shadow_type, area, widget, "button", x, y, width, height); if (GTK_WIDGET_HAS_FOCUS (widget)) { if (uxtheme_dll) gtk_paint_box (widget->style, widget->window, state_type, shadow_type, area, widget, "buttondefault", x, y, width, height); if (interior_focus) { x += widget->style->xthickness + focus_pad; y += widget->style->ythickness + focus_pad; width -= 2 * (widget->style->xthickness + focus_pad); height -= 2 * (widget->style->xthickness + focus_pad); } else { x -= focus_width + focus_pad; y -= focus_width + focus_pad; width += 2 * (focus_width + focus_pad); height += 2 * (focus_width + focus_pad); } if(!uxtheme_dll) gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), area, widget, "button", x, y, width, height); } } }
void cl_draw_combobox_button (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) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style); gboolean is_active = FALSE; gboolean draw_inset = FALSE; CLRectangle r; cl_rectangle_set_button (&r, style, state_type, GTK_WIDGET_HAS_DEFAULT (widget), GTK_WIDGET_HAS_FOCUS (widget), CL_CORNER_NONE, CL_CORNER_ROUND, CL_CORNER_NONE, CL_CORNER_ROUND); if (state_type == GTK_STATE_ACTIVE) is_active = TRUE; else r.fillgc = NULL; /* Seriously, why can't non-gtk-apps at least try to be decent citizens? Take this fscking OpenOffice.org 1.9 for example. The morons responsible for this utter piece of crap give the clip size wrong values! :'( */ if (area) { area->x = x; area->y = y; area->width = width; area->height = height; } x--; width++; /* Draw "sunken" look when border thickness is more than 2 pixels. */ if (GTK_IS_COMBO(widget->parent)) draw_inset = (widget->parent->style->xthickness > 2 && widget->parent->style->ythickness > 2); else draw_inset = (style->xthickness > 2 && style->ythickness > 2); if (draw_inset) { cl_draw_inset (style, window, widget, area, x, y, width, height, CL_CORNER_NONE, CL_CORNER_ROUND, CL_CORNER_NONE, CL_CORNER_ROUND); x++; y++; height-=2; width-=2; } else { x++; width--; } if (area) cl_rectangle_set_clip_rectangle (&r, area); cl_draw_rectangle (window, widget, style, x, y, width, height, &r); if (!is_active) { int tmp_height = (float)height*0.25; gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+2,width-4,tmp_height, &clearlooks_style->button_g1[state_type], &clearlooks_style->button_g2[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2, y+2+tmp_height, width-4, height-3-tmp_height*2, &clearlooks_style->button_g2[state_type], &clearlooks_style->button_g3[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+height-tmp_height-1,width-4,tmp_height, &clearlooks_style->button_g3[state_type], &clearlooks_style->button_g4[state_type]); gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); } cl_draw_shadow (window, widget, style, x, y, width, height, &r); if (area) cl_rectangle_reset_clip_rectangle (&r); }
/* Draw spinbuttons. */ void cl_draw_spinbutton(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) { CLRectangle r; GdkRectangle new_area; int tl = CL_CORNER_NONE, tr = CL_CORNER_NONE, bl = CL_CORNER_NONE, br = CL_CORNER_NONE; if (area == NULL) { new_area.x = x; new_area.y = y; new_area.width = width; new_area.height = height; area = &new_area; } if (!strcmp (detail, "spinbutton")) /* draws the 'back' of the spinbutton */ { GdkGC *bg_gc = cl_get_window_bg_gc(widget); gdk_gc_set_clip_rectangle (bg_gc, area); gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1); gdk_gc_set_clip_rectangle (bg_gc, NULL); if (style->xthickness > 2 && style->ythickness > 2) cl_draw_inset (style, window, widget, area, x, y, width, height, CL_CORNER_NONE, CL_CORNER_ROUND, CL_CORNER_NONE, CL_CORNER_ROUND); return; } if (!strcmp (detail, "spinbutton_up")) { tr = CL_CORNER_ROUND; (style->xthickness > 2 && style->ythickness > 2) ? y++ : height++; } if (!strcmp (detail, "spinbutton_down")) { br = CL_CORNER_ROUND; if (style->xthickness > 2 && style->ythickness > 2) height--; } cl_rectangle_set_button (&r, style, state_type, GTK_WIDGET_HAS_DEFAULT (widget), GTK_WIDGET_HAS_FOCUS (widget), tl, tr, bl, br); width--; cl_rectangle_set_clip_rectangle (&r, area); cl_draw_rectangle (window, widget, style, x, y, width, height, &r); cl_draw_shadow (window, widget, style, x, y, width, height, &r); cl_rectangle_reset_clip_rectangle (&r); }
/* Draw a normal (toggle)button. Not spinbuttons.*/ void cl_draw_button(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) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style); int my_state_type = (state_type == GTK_STATE_ACTIVE) ? 2 : 0; GdkGC *bg_gc = NULL; gboolean is_active = FALSE; CLRectangle r; /* Get the background color of the window we're on */ bg_gc = cl_get_window_bg_gc(widget); cl_rectangle_set_button (&r, style, state_type, GTK_WIDGET_HAS_DEFAULT (widget), GTK_WIDGET_HAS_FOCUS (widget), CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND); if (state_type == GTK_STATE_ACTIVE) is_active = TRUE; if (GTK_IS_TOGGLE_BUTTON(widget) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) && state_type == GTK_STATE_PRELIGHT) { cl_rectangle_set_gradient (&r.fill_gradient, &clearlooks_style->shade[1], &clearlooks_style->shade[1]); r.topleft = clearlooks_style->shade_gc[3]; r.bottomright = clearlooks_style->shade_gc[1]; is_active = TRUE; } if (!is_active) r.fillgc = NULL; if (!GTK_IS_NOTEBOOK (widget->parent)) { gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1); /* Draw "sunken" look when border thickness is more than 2 pixels. */ if (style->xthickness > 2 && style->ythickness > 2) cl_draw_inset (style, window, widget, area, x, y, width, height, CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND); } /* Draw "sunken" look when border thickness is more than 2 pixels.*/ if (style->xthickness > 2 && style->ythickness > 2) { x++; y++; height-=2; width-=2; } /* Don't draw the normal gradient for normal buttons. */ cl_rectangle_set_clip_rectangle (&r, area); cl_draw_rectangle (window, widget, style, x, y, width, height, &r); if (!is_active) { int tmp_height = (float)height*0.25; gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+2,width-4,tmp_height, &clearlooks_style->button_g1[state_type], &clearlooks_style->button_g2[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2, y+2+tmp_height, width-4, height-3-tmp_height*2, &clearlooks_style->button_g2[state_type], &clearlooks_style->button_g3[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+height-tmp_height-1,width-4,tmp_height, &clearlooks_style->button_g3[state_type], &clearlooks_style->button_g4[state_type]); gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); } cl_draw_shadow (window, widget, style, x, y, width, height, &r); cl_rectangle_reset_clip_rectangle (&r); }