static void clearlooks_style_draw_box (DRAW_ARGS) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); const ClearlooksColors *colors; cairo_t *cr; cr = ge_gdk_drawable_to_cairo (window, area); colors = &clearlooks_style->colors; CHECK_ARGS SANITIZE_SIZE if (DETAIL ("menubar") && !ge_is_panel_widget_item(widget)) { WidgetParameters params; MenuBarParameters menubar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); menubar.style = clearlooks_style->menubarstyle; STYLE_FUNCTION(draw_menubar) (cr, colors, ¶ms, &menubar, x, y, width, height); } else if (DETAIL ("button") && widget && widget->parent && (GE_IS_TREE_VIEW(widget->parent) || GE_IS_CLIST (widget->parent) || ge_object_is_a (G_OBJECT(widget->parent), "ETree"))) /* ECanvas inside ETree */ { WidgetParameters params; ListViewHeaderParameters header; gint columns, column_index; gboolean resizable = TRUE; /* XXX: This makes unknown treeview header CL_ORDER_MIDDLE, in need for something nicer */ columns = 3; column_index = 1; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; if (GE_IS_TREE_VIEW (widget->parent)) { clearlooks_treeview_get_header_index (GTK_TREE_VIEW(widget->parent), widget, &column_index, &columns, &resizable); } else if (GE_IS_CLIST (widget->parent)) { clearlooks_clist_get_header_index (GTK_CLIST(widget->parent), widget, &column_index, &columns); } header.resizable = resizable; if (column_index == 0) header.order = params.ltr ? CL_ORDER_FIRST : CL_ORDER_LAST; else if (column_index == columns-1) header.order = params.ltr ? CL_ORDER_LAST : CL_ORDER_FIRST; else header.order = CL_ORDER_MIDDLE; gtk_style_apply_default_background (style, window, FALSE, state_type, area, x, y, width, height); STYLE_FUNCTION(draw_list_view_header) (cr, colors, ¶ms, &header, x, y, width, height); } else if (DETAIL ("button") || DETAIL ("buttondefault")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (ge_is_in_combo_box(widget)) { if (params.ltr) params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; if (params.xthickness > 2) { if (params.ltr) x--; width++; } } else { params.corners = CR_CORNER_ALL; /* if (!(ge_is_combo_box (widget, FALSE))) */ params.enable_glow = TRUE; } if (GE_IS_TOGGLE_BUTTON (widget) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) params.active = TRUE; STYLE_FUNCTION(draw_button) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } else if (DETAIL ("spinbutton_up") || DETAIL ("spinbutton_down")) { if (state_type == GTK_STATE_ACTIVE) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (style->xthickness == 3) { width++; if (params.ltr) x--; } if (DETAIL ("spinbutton_up")) { height+=2; if (params.ltr) params.corners = CR_CORNER_TOPRIGHT; else params.corners = CR_CORNER_TOPLEFT; } else { if (params.ltr) params.corners = CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_BOTTOMLEFT; } STYLE_FUNCTION(draw_spinbutton_down) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } } else if (DETAIL ("spinbutton")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (params.ltr) params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; if (style->xthickness == 3) { if (params.ltr) x--; width++; } STYLE_FUNCTION(draw_spinbutton) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } else if (detail && g_str_has_prefix (detail, "trough") && GE_IS_SCALE (widget)) { WidgetParameters params; SliderParameters slider; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; slider.lower = DETAIL ("trough-lower"); slider.fill_level = DETAIL ("trough-fill-level") || DETAIL ("trough-fill-level-full"); slider.horizontal = (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL); STYLE_FUNCTION(draw_scale_trough) (cr, &clearlooks_style->colors, ¶ms, &slider, x, y, width, height); } else if (DETAIL ("trough") && widget && GE_IS_PROGRESS_BAR (widget)) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); STYLE_FUNCTION(draw_progressbar_trough) (cr, colors, ¶ms, x, y, width, height); } else if (DETAIL ("trough") && widget && (GE_IS_VSCROLLBAR (widget) || GE_IS_HSCROLLBAR (widget))) { WidgetParameters params; ScrollBarParameters scrollbar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; scrollbar.horizontal = TRUE; scrollbar.junction = clearlooks_scrollbar_get_junction (widget); if (GE_IS_RANGE (widget)) scrollbar.horizontal = GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL; if (scrollbar.horizontal) { x += 2; width -= 4; } else { y += 2; height -= 4; } STYLE_FUNCTION(draw_scrollbar_trough) (cr, colors, ¶ms, &scrollbar, x, y, width, height); } else if (DETAIL ("bar")) { WidgetParameters params; ProgressBarParameters progressbar; gdouble elapsed = 0.0; #ifdef HAVE_ANIMATION if(clearlooks_style->animation && CL_IS_PROGRESS_BAR (widget)) { gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode; if (!activity_mode) clearlooks_animation_progressbar_add ((gpointer)widget); } elapsed = clearlooks_animation_elapsed (widget); #endif clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (widget && GE_IS_PROGRESS_BAR (widget)) { progressbar.orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget)); progressbar.value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget)); progressbar.pulsing = GTK_PROGRESS (widget)->activity_mode; } else { progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT; progressbar.value = 0; progressbar.pulsing = FALSE; } if (!params.ltr) { if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT) progressbar.orientation = GTK_PROGRESS_RIGHT_TO_LEFT; else if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT) progressbar.orientation = GTK_PROGRESS_LEFT_TO_RIGHT; } /* Following is a hack to have a larger clip area, the one passed in * does not allow for the shadow. */ if (area) { GdkRectangle tmp = *area; if (!progressbar.pulsing) { switch (progressbar.orientation) { case GTK_PROGRESS_RIGHT_TO_LEFT: tmp.x -= 1; case GTK_PROGRESS_LEFT_TO_RIGHT: tmp.width += 1; break; case GTK_PROGRESS_BOTTOM_TO_TOP: tmp.y -= 1; case GTK_PROGRESS_TOP_TO_BOTTOM: tmp.height += 1; break; } } else { if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT || progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT) { tmp.x -= 1; tmp.width += 2; } else { tmp.y -= 1; tmp.height += 2; } } cairo_reset_clip (cr); gdk_cairo_rectangle (cr, &tmp); cairo_clip (cr); } STYLE_FUNCTION(draw_progressbar_fill) (cr, colors, ¶ms, &progressbar, x, y, width, height, 10 - (int)(elapsed * 10.0) % 10); } else if (DETAIL ("optionmenu")) { WidgetParameters params; OptionMenuParameters optionmenu; GtkRequisition indicator_size; GtkBorder indicator_spacing; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.enable_glow = TRUE; ge_option_menu_get_props (widget, &indicator_size, &indicator_spacing); if (ge_widget_is_ltr (widget)) optionmenu.linepos = width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - 1; else optionmenu.linepos = (indicator_size.width + indicator_spacing.left + indicator_spacing.right) + 1; STYLE_FUNCTION(draw_optionmenu) (cr, colors, ¶ms, &optionmenu, x, y, width, height); } else if (DETAIL ("menuitem")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (widget && GE_IS_MENU_BAR (widget->parent)) { params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT; height += 1; STYLE_FUNCTION(draw_menubaritem) (cr, colors, ¶ms, x, y, width, height); } else { params.corners = CR_CORNER_ALL; STYLE_FUNCTION(draw_menuitem) (cr, colors, ¶ms, x, y, width, height); } } else if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) /* This can't be "stepper" for scrollbars ... */ { WidgetParameters params; ScrollBarParameters scrollbar; ScrollBarStepperParameters stepper; GdkRectangle this_rectangle; this_rectangle.x = x; this_rectangle.y = y; this_rectangle.width = width; this_rectangle.height = height; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; scrollbar.has_color = FALSE; scrollbar.horizontal = TRUE; scrollbar.junction = clearlooks_scrollbar_get_junction (widget); if (clearlooks_style->colorize_scrollbar || clearlooks_style->has_scrollbar_color) { scrollbar.has_color = TRUE; } scrollbar.horizontal = DETAIL ("hscrollbar"); stepper.stepper = clearlooks_scrollbar_get_stepper (widget, &this_rectangle); STYLE_FUNCTION(draw_scrollbar_stepper) (cr, colors, ¶ms, &scrollbar, &stepper, x, y, width, height); } else if (DETAIL ("toolbar") || DETAIL ("handlebox_bin") || DETAIL ("dockitem_bin")) { WidgetParameters params; ToolbarParameters toolbar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y); toolbar.style = clearlooks_style->toolbarstyle; /* Only draw the shadows on horizontal toolbars */ if (shadow_type != GTK_SHADOW_NONE && height < 2*width ) STYLE_FUNCTION(draw_toolbar) (cr, colors, ¶ms, &toolbar, x, y, width, height); } else if (DETAIL ("trough")) { } else if (DETAIL ("menu")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); STYLE_FUNCTION(draw_menu_frame) (cr, colors, ¶ms, x, y, width, height); } else if (DETAIL ("hseparator") || DETAIL ("vseparator")) { const gchar *new_detail = detail; /* Draw a normal separator, we just use this because it gives more control * over sizing (currently). */ /* This isn't nice ... but it seems like the best cleanest way to me right now. * It will get slightly nicer in the future hopefully. */ if (GE_IS_MENU_ITEM (widget)) new_detail = "menuitem"; if (DETAIL ("hseparator")) { gtk_paint_hline (style, window, state_type, area, widget, new_detail, x, x + width - 1, y + height/2); } else gtk_paint_vline (style, window, state_type, area, widget, new_detail, y, y + height - 1, x + width/2); } else { clearlooks_parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } cairo_destroy (cr); }
gboolean ge_check_hint (GEHint hint, GQuark style_hint, GtkWidget *widget) { static GEHint quark_hint_lookup[GE_HINT_COUNT] = {0}; g_assert ((hint >= 0) && (hint < GE_HINT_COUNT)); /* Initilize lookup table */ if (G_UNLIKELY (quark_hint_lookup[0] == 0)) { guint i = 0; gchar *cur_hint_str = ge_widget_hints; while ((i < GE_HINT_COUNT) && cur_hint_str[0]) { /* Can't use _from_static_string as the engine may be unloaded. */ quark_hint_lookup[i] = g_quark_from_string (cur_hint_str); cur_hint_str += strlen(cur_hint_str) + 1; i++; } g_assert (i == GE_HINT_COUNT && cur_hint_str[0] == '\0'); } if (quark_hint_lookup[hint] == style_hint) return TRUE; /* Try to decide based on other hints, eg. hscale is also a scale. */ if (hint == GE_HINT_SCALE) if (ge_check_hint (GE_HINT_VSCALE, style_hint, widget) || ge_check_hint (GE_HINT_HSCALE, style_hint, widget)) return TRUE; if (hint == GE_HINT_SCROLLBAR) if (ge_check_hint (GE_HINT_VSCROLLBAR, style_hint, widget) || ge_check_hint (GE_HINT_HSCROLLBAR, style_hint, widget)) return TRUE; if (hint == GE_HINT_TREEVIEW) if (ge_check_hint (GE_HINT_TREEVIEW_HEADER, style_hint, widget)) return TRUE; /* These may be caused by applications so we never want to disable them. * TODO: This does not catch the case where the theme uses appears-as-list * and the application turns it off again. Though this case * is even less likely. */ switch (hint) { case GE_HINT_COMBOBOX_ENTRY: if (widget && ge_object_is_a (G_OBJECT (widget), "GtkComboBox")) { gboolean appears_as_list = FALSE; gtk_widget_style_get (widget, "appears-as-list", &appears_as_list, NULL); if (appears_as_list) return TRUE; } break; default: break; } #ifdef ENABLE_WIDGET_CHECKS /* If a style_hint *was* set, and nothing matched, just give up right away. * A theme shall either support it fully, or not at all. */ if (style_hint != 0) return FALSE; /* No widget? Just give up. Nothing we can do. */ if (widget == NULL) return FALSE; /* Try to do something based on the passed in widget pointer. */ switch (hint) { case GE_HINT_TREEVIEW: if (gtk_widget_get_parent (widget) && (ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "GtkTreeView"))) return TRUE; break; case GE_HINT_TREEVIEW_HEADER: if (ge_object_is_a (G_OBJECT (widget), "GtkButton") && gtk_widget_get_parent (widget) && (ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "GtkTreeView") || ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "GtkCList") || ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "GtkCTree"))) return TRUE; if (gtk_widget_get_parent (widget) && ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "ETreeView")) return TRUE; break; case GE_HINT_COMBOBOX_ENTRY: if (ge_is_in_combo_box (widget)) return TRUE; break; case GE_HINT_SPINBUTTON: if (ge_object_is_a (G_OBJECT (widget), "GtkSpinButton")) return TRUE; break; case GE_HINT_STATUSBAR: if (gtk_widget_get_parent (widget) && ge_object_is_a (G_OBJECT (widget), "GtkStatusbar")) return TRUE; break; case GE_HINT_SCALE: if (ge_object_is_a (G_OBJECT (widget), "GtkScale")) return TRUE; break; case GE_HINT_HSCALE: if (ge_object_is_a (G_OBJECT (widget), "GtkHScale")) return TRUE; break; case GE_HINT_VSCALE: if (ge_object_is_a (G_OBJECT (widget), "GtkVScale")) return TRUE; break; case GE_HINT_SCROLLBAR: if (ge_object_is_a (G_OBJECT (widget), "GtkScrollbar")) return TRUE; break; case GE_HINT_HSCROLLBAR: if (ge_object_is_a (G_OBJECT (widget), "GtkHScrollbar")) return TRUE; break; case GE_HINT_VSCROLLBAR: if (ge_object_is_a (G_OBJECT (widget), "GtkVScrollbar")) return TRUE; break; case GE_HINT_PROGRESSBAR: if (ge_object_is_a (G_OBJECT (widget), "GtkProgressBar")) return TRUE; break; case GE_HINT_MENUBAR: if (ge_object_is_a (G_OBJECT (widget), "GtkMenuBar") || ge_object_is_a (G_OBJECT (gtk_widget_get_parent (widget)), "GtkMenuBar")) return TRUE; break; default: break; } #endif return FALSE; }
static void clearlooks_style_draw_shadow (DRAW_ARGS) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; cairo_t *cr = ge_gdk_drawable_to_cairo (window, area); CHECK_ARGS SANITIZE_SIZE if ((DETAIL ("entry") && !(widget && widget->parent && GE_IS_TREE_VIEW (widget->parent))) || (DETAIL ("frame") && ge_is_in_combo_box (widget))) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); /* Override the entries state type, because we are too lame to handle this via * the focus ring, and GtkEntry doesn't even set the INSENSITIVE state ... */ if (state_type == GTK_STATE_NORMAL && widget && GE_IS_ENTRY (widget)) params.state_type = GTK_WIDGET_STATE (widget); if (widget && (ge_is_in_combo_box (widget) || GE_IS_SPIN_BUTTON (widget))) { width += style->xthickness; if (!params.ltr) x -= style->xthickness; if (params.ltr) params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; else params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; } STYLE_FUNCTION (draw_entry) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } else if (DETAIL ("frame") && widget && GE_IS_STATUSBAR (widget->parent)) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); gtk_style_apply_default_background (style, window, TRUE, state_type, area, x, y, width, height); STYLE_FUNCTION (draw_statusbar) (cr, colors, ¶ms, x, y, width, height); } else if (DETAIL ("frame")) { WidgetParameters params; FrameParameters frame; frame.shadow = shadow_type; frame.gap_x = -1; /* No gap will be drawn */ frame.border = &colors->shade[4]; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; if (widget && !g_str_equal ("XfcePanelWindow", gtk_widget_get_name (gtk_widget_get_toplevel (widget)))) STYLE_FUNCTION(draw_frame) (cr, colors, ¶ms, &frame, x, y, width, height); } else if (DETAIL ("scrolled_window") || DETAIL ("viewport") || detail == NULL) { CairoColor *border = (CairoColor*)&colors->shade[5]; cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1); ge_cairo_set_color (cr, border); cairo_set_line_width (cr, 1); cairo_stroke (cr); } else { WidgetParameters params; FrameParameters frame; frame.shadow = shadow_type; frame.gap_x = -1; frame.border = &colors->shade[5]; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_ALL; STYLE_FUNCTION(draw_frame) (cr, colors, ¶ms, &frame, x, y, width, height); } cairo_destroy (cr); }
/* Standard Border Function */ void hc_draw_shadow(GtkStyle * style, cairo_t * cr, GtkStateType state_type, GtkShadowType shadow_type, GtkWidget * widget, const gchar * detail, gint x, gint y, gint width, gint height) { /* Border Uses Foreground Color */ CairoColor foreground = HC_STYLE(style)->color_cube.fg[state_type]; gint line_width; gint clip_x = x, clip_y = y, clip_width = width, clip_height = height; /***********************************************/ /* GTK Sanity Checks */ /***********************************************/ CHECK_ARGS /***********************************************/ /* GTK Special Cases - adjust Size/Offset */ /***********************************************/ line_width = HC_STYLE(style)->edge_thickness; if (CHECK_DETAIL (detail, "menubar") && ge_is_panel_widget_item(widget)) { return; } /* Spin Button */ if ((CHECK_DETAIL(detail, "spinbutton_up")) || (CHECK_DETAIL(detail, "spinbutton_down"))) { /* Overdraw Height By Half The Line Width - Prevents Double line Between buttons */ height += floor(line_width / 2); /* If Down Button Offset By Half Line Width */ if (CHECK_DETAIL(detail, "spinbutton_down")) { y -= floor(line_width / 2); } /* Overdraw Width By Line Width - Prevents Double line Between Entry And Buttons */ width += line_width; /* If LTR Offset X By Line Width */ if (ge_widget_is_ltr (widget)) { x -= line_width; } /* Force Border To Use Foreground Widget State */ if (widget) { foreground = HC_STYLE(style)->color_cube.fg[gtk_widget_get_state(widget)]; } } /* Entry - Force Border To Use Foreground Matching Widget State */ if (CHECK_DETAIL(detail, "entry") && !ge_is_combo(widget)) { foreground = HC_STYLE(style)->color_cube.fg[widget ? gtk_widget_get_state(widget) : GTK_STATE_NORMAL]; } /* Combo Box Button's */ if (CHECK_DETAIL(detail, "button") && ge_is_in_combo_box(widget)) { /* Overdraw Width By Line Width - Prevents Double Line Between Entry and Button. */ width += line_width; /* If LTR Offset X By Line Width */ if (ge_widget_is_ltr (widget)) { x -= line_width; } /* Force Border To Use Foreground Matching Parent State */ if ((widget) && (gtk_widget_get_parent(widget))) { gtk_widget_ensure_style(gtk_widget_get_parent(widget)); ge_gdk_color_to_cairo(>k_widget_get_style(gtk_widget_get_parent(widget))->fg[gtk_widget_get_state (widget)], &foreground); } } /***********************************************/ /* Draw Border */ /***********************************************/ /* Clip Border Too Passed Size */ cairo_rectangle(cr, clip_x, clip_y, clip_width, clip_height); cairo_clip(cr); /* Set Line Style */ ge_cairo_set_color(cr, &foreground); cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT); cairo_set_line_width (cr, line_width); ge_cairo_inner_rectangle (cr, x, y, width, height); cairo_stroke(cr); }