static void moblin_netbook_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x1, gint x2, gint y) { cairo_t *cr; if (DETAIL ("vscale") || DETAIL ("hscale")) return; cr = gdk_cairo_create (window); cairo_set_line_width (cr, LINE_WIDTH); cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); moblin_netbook_set_border_color (cr, style, state_type); cairo_move_to (cr, x1, y + LINE_WIDTH / 2.0); cairo_line_to (cr, x2, y + LINE_WIDTH / 2.0); cairo_stroke (cr); cairo_destroy (cr); }
//------------------------------------------------ // Complete a database read operation. // static void get_cb(int return_value, ev2citrusleaf_bin* bins, int n_bins, uint32_t generation, uint32_t expiration, void* pv_udata) { int k = (int)(uint64_t)pv_udata; int b = k % g_config.num_bases; switch (return_value) { case EV2CITRUSLEAF_OK: // Not 100% sure we only get bins if return value is OK. TODO - check. validate_data(b, k, bins, n_bins); // Invalid data will log complaints, but won't exit event loop. break; case EV2CITRUSLEAF_FAIL_TIMEOUT: DETAIL("GET TIMEOUT: base %2d, key %d", b, k); g_bases[b].num_get_timeouts++; // Otherwise ok... break; case EV2CITRUSLEAF_FAIL_NOTFOUND: DETAIL("NOT FOUND: base %2d, key %d", b, k); g_bases[b].num_not_found++; // Otherwise ok... break; default: LOG("ERROR: return-value %d, base %2d, key %d", return_value, b, k); // Won't exit event loop. break; } }
static void clearlooks_style_draw_flat_box (DRAW_ARGS) { if (detail && state_type == GTK_STATE_SELECTED && ( !strncmp ("cell_even", detail, 9) || !strncmp ("cell_odd", detail, 8))) { WidgetParameters params; ClearlooksStyle *clearlooks_style; ClearlooksColors *colors; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE clearlooks_style = CLEARLOOKS_STYLE (style); clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); colors = &clearlooks_style->colors; cr = ge_gdk_drawable_to_cairo (window, area); /* XXX: We could expose the side details by setting params->corners accordingly * or adding another option. */ STYLE_FUNCTION (draw_selected_cell) (cr, colors, ¶ms, x, y, width, height); cairo_destroy (cr); } else if (DETAIL ("tooltip")) { WidgetParameters params; ClearlooksStyle *clearlooks_style; ClearlooksColors *colors; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE clearlooks_style = CLEARLOOKS_STYLE (style); clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); colors = &clearlooks_style->colors; cr = ge_gdk_drawable_to_cairo (window, area); STYLE_FUNCTION (draw_tooltip) (cr, colors, ¶ms, x, y, width, height); cairo_destroy (cr); } else if ((CLEARLOOKS_STYLE (style)->style == CL_STYLE_GLOSSY || CLEARLOOKS_STYLE (style)->style == CL_STYLE_GUMMY) && ((DETAIL("checkbutton") || DETAIL("radiobutton")) && state_type == GTK_STATE_PRELIGHT)) { /* XXX: Don't draw any check/radiobutton bg in GLOSSY or GUMMY mode. */ } else { clearlooks_parent_class->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } }
static void clearlooks_style_draw_check (DRAW_ARGS) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); WidgetParameters params; CheckboxParameters checkbox; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_ALL; checkbox.shadow_type = shadow_type; checkbox.in_cell = DETAIL("cellcheck"); checkbox.in_menu = (widget && widget->parent && GTK_IS_MENU(widget->parent)); STYLE_FUNCTION(draw_checkbox) (cr, &clearlooks_style->colors, ¶ms, &checkbox, x, y, width, height); cairo_destroy (cr); }
static void clearlooks_style_draw_extension (DRAW_ARGS, GtkPositionType gap_side) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); if (DETAIL ("tab")) { WidgetParameters params; TabParameters tab; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); tab.gap_side = (ClearlooksGapSide)gap_side; switch (gap_side) { case CL_GAP_BOTTOM: params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT; break; case CL_GAP_TOP: params.corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT; break; case CL_GAP_RIGHT: params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; break; case CL_GAP_LEFT: params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; } STYLE_FUNCTION(draw_tab) (cr, colors, ¶ms, &tab, x, y, width, height); } else { clearlooks_parent_class->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side); } cairo_destroy (cr); }
/* this function is copied from the mist gtk engine */ static void moblin_netbook_draw_layout (GtkStyle *style, GdkWindow *window, GtkStateType state_type, gboolean use_text, GdkRectangle *area, GtkWidget *widget, const char *detail, int x, int y, PangoLayout *layout) { GdkGC *gc; gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type]; if (area) { gdk_gc_set_clip_rectangle (gc, area); } if (DETAIL ("accellabel") && state_type == GTK_STATE_NORMAL) { cairo_t *cr; cr = moblin_netbook_cairo_create (window, area); cairo_set_source_rgba (cr, style->fg[state_type].red / 65535.0, style->fg[state_type].green / 65535.0, style->fg[state_type].blue / 65535.0, 0.5); cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, layout); cairo_stroke (cr); cairo_destroy (cr); } else gdk_draw_layout (window, gc, x, y, layout); if (area) { gdk_gc_set_clip_rectangle (gc, NULL); } }
static void moblin_netbook_draw_focus (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height) { cairo_t *cr; gint line_width; MoblinNetbookStyle *mb_style = MOBLIN_NETBOOK_STYLE (style); /* button draws it's own focus */ if (DETAIL ("button")) return; cr = gdk_cairo_create (window); if (widget) gtk_widget_style_get (widget, "focus-line-width", &line_width, NULL); else line_width = 1; cairo_translate (cr, line_width / 2.0, line_width / 2.0); width -= line_width; height -= line_width; if (mb_style->shadow) { width -= 1; height -= 1; } moblin_netbook_rounded_rectangle (cr, x, y, width, height, line_width); cairo_set_line_width (cr, line_width); gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]); cairo_stroke (cr); cairo_destroy (cr); }
static void clearlooks_style_draw_shadow_gap (DRAW_ARGS, GtkPositionType gap_side, gint gap_x, gint gap_width) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); const ClearlooksColors *colors; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); colors = &clearlooks_style->colors; if (DETAIL ("frame")) { WidgetParameters params; FrameParameters frame; frame.shadow = shadow_type; frame.gap_side = gap_side; frame.gap_x = gap_x; frame.gap_width = gap_width; 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); } else { clearlooks_parent_class->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); } cairo_destroy (cr); }
/* This function is a home-grown (probably flawed) function * inspired by the metal, ThinIce, & Wonderland GTK2 engines */ void reverse_engineer_arrow_box (GtkWidget *widget, const gchar * detail, GtkArrowType arrow_type, gint *x, gint *y, gint *width, gint *height) { if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) { reverse_engineer_stepper_box (widget, arrow_type, x, y, width, height); } else if (DETAIL("spinbutton")) { reverse_engineer_spin_button (widget, arrow_type, x, y, width, height); } #if GTK2 else if (DETAIL("menuitem")) { *width += 2; *height += 2; *x -= 1; } else if (DETAIL("arrow")) { *width += 2; *height += 2; *x -= 1; *y -= 1; } #endif #if GTK1 else if (DETAIL("menuitem")) { *width += 2; *height += 2; *x -= 1; *y += 0; } else if (DETAIL("arrow")) { *y += 1; } #endif }
//------------------------------------------------ // Complete a database write operation. // static void put_cb(int return_value, ev2citrusleaf_bin* bins, int n_bins, uint32_t generation, uint32_t expiration, void* pv_udata) { int k = (int)(uint64_t)pv_udata; int b = k % g_config.num_bases; switch (return_value) { case EV2CITRUSLEAF_OK: break; case EV2CITRUSLEAF_FAIL_TIMEOUT: DETAIL("PUT TIMEOUT: base %2d, key %d", b, k); g_bases[b].num_put_timeouts++; // Otherwise ok... Likely leads to EV2CITRUSLEAF_FAIL_NOTFOUND on get. break; default: LOG("ERROR: return-value %d, base %2d, key %d", return_value, b, k); // Won't exit event loop... break; } }
static void clearlooks_style_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x1, gint x2, gint y) { const ClearlooksColors *colors; cairo_t *cr; SeparatorParameters separator; ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); (void) state_type; (void) widget; CHECK_ARGS colors = &clearlooks_style->colors; cr = ge_gdk_drawable_to_cairo (window, area); separator.horizontal = TRUE; if (!DETAIL ("menuitem")) STYLE_FUNCTION(draw_separator) (cr, colors, NULL, &separator, x1, y, x2-x1+1, 2); else STYLE_FUNCTION(draw_menu_item_separator) (cr, colors, NULL, &separator, x1, y, x2-x1+1, 2); cairo_destroy (cr); }
void tmo_durand02(pfs::Array2Df& R, pfs::Array2Df& G, pfs::Array2Df& B, float sigma_s, float sigma_r, float baseContrast, int downsample, bool color_correction, pfs::Progress &ph) { int w = R.getCols(); int h = R.getRows(); int size = w*h; pfs::Array2Df I(w,h); // intensities pfs::Array2Df BASE(w,h); // base layer pfs::Array2Df DETAIL(w,h); // detail layer float min_pos = 1e10f; // minimum positive value (to avoid log(0)) for (int i = 0 ; i < size ; i++) { I(i) = 1.0f/61.0f * ( 20.0f*R(i) + 40.0f*G(i) + B(i) ); if ( I(i) < min_pos && I(i) > 0.0f ) { min_pos = I(i); } } for (int i = 0 ; i < size ; i++) { float L = I(i); if ( L <= 0.0f ) { L = min_pos; } R(i) /= L; G(i) /= L; B(i) /= L; I(i) = std::log( L ); } #ifdef HAVE_FFTW3F fastBilateralFilter( I, BASE, sigma_s, sigma_r, downsample, ph ); #else bilateralFilter( &I, &BASE, sigma_s, sigma_r, ph ); #endif //!! FIX: find minimum and maximum luminance, but skip 1% of outliers float maxB; float minB; findMaxMinPercentile(&BASE, 0.01f, 0.99f, minB, maxB); float compressionfactor = baseContrast / (maxB - minB); // Color correction factor const float k1 = 1.48f; const float k2 = 0.82f; const float s = ( (1 + k1)*pow(compressionfactor,k2) )/( 1 + k1*pow(compressionfactor,k2) ); for (int i = 0 ; i < size ; i++) { DETAIL(i) = I(i) - BASE(i); I(i) = BASE(i) * compressionfactor + DETAIL(i); //!! FIX: this to keep the output in normalized range 0.01 - 1.0 //intensitites are related only to minimum luminance because I //would say this is more stable over time than using maximum //luminance and is also robust against random peaks of very high //luminance I(i) -= 4.3f+minB*compressionfactor; if ( color_correction ) { R(i) = decode( std::pow( R(i), s ) * std::exp( I(i) ) ); G(i) = decode( std::pow( G(i), s ) * std::exp( I(i) ) ); B(i) = decode( std::pow( B(i), s ) * std::exp( I(i) ) ); } else { R(i) *= decode( std::exp( I(i) ) ); G(i) *= decode( std::exp( I(i) ) ); B(i) *= decode( std::exp( I(i) ) ); } } if (!ph.canceled()) { ph.setValue( 100 ); } }
static void moblin_netbook_draw_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) { cairo_t *cr; MoblinNetbookStyle *mb_style = MOBLIN_NETBOOK_STYLE (style); gdouble radius = mb_style->radius; DEBUG; if (shadow_type == GTK_SHADOW_NONE) return; SANITIZE_SIZE; cr = moblin_netbook_cairo_create (window, area); /* initilise the background in the corners to the colour of the widget */ if (widget) { cairo_rectangle (cr, x, y, width, height); if (mb_style->shadow) moblin_netbook_rounded_rectangle (cr, x, y, width - 1, height - 1, radius); else moblin_netbook_rounded_rectangle (cr, x, y, width, height, radius); gdk_cairo_set_source_color (cr, &widget->style->bg[state_type]); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill (cr); } /* FIXME: for RTL */ if (widget && DETAIL ("entry") && (GTK_IS_SPIN_BUTTON (widget) || GTK_IS_COMBO_BOX_ENTRY (widget->parent))) width += 10; if (widget && DETAIL ("entry") && GTK_IS_COMBO_BOX_ENTRY (widget->parent)) { GtkWidget *button; g_object_set_data (G_OBJECT (widget->parent), "moblin-netbook-combo-entry", widget); button = g_object_get_data (G_OBJECT (widget->parent), "moblin-netbook-combo-button"); if (button) { if (GTK_WIDGET_HAS_FOCUS (button)) state_type = GTK_STATE_PRELIGHT; else /* try and keep the button and entry in the same state */ gtk_widget_set_state (button, state_type); } width += 10; } cairo_translate (cr, 0.5, 0.5); width--; height--; cairo_set_line_width (cr, 1.0); if (mb_style->shadow != 0.0) { /* outer shadow */ moblin_netbook_rounded_rectangle (cr, x, y, width, height, radius + 1.0); cairo_set_source_rgba (cr, 0, 0, 0, mb_style->shadow); cairo_stroke (cr); /* reduce size for outer shadow */ height--; width--; } /* border */ moblin_netbook_rounded_rectangle (cr, x, y, width, height, radius); moblin_netbook_set_border_color (cr, style, state_type); cairo_stroke (cr); cairo_destroy (cr); }
static void moblin_netbook_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, GtkArrowType arrow_type, gboolean fill, gint x, gint y, gint width, gint height) { cairo_t *cr; DEBUG; cr = moblin_netbook_cairo_create (window, area); cairo_set_line_width (cr, 2); cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); gdk_cairo_set_source_color (cr, &style->fg[state_type]); /* add padding around scrollbar buttons */ if (DETAIL ("vscrollbar") || DETAIL ("hscrollbar")) { x += 3; width -= 4; y += 3; height -= 4; } /* ensure we have odd number of pixels for width or height to allow for * correct centering */ if (width % 2) width--; if (height % 2) height--; switch (arrow_type) { case GTK_ARROW_UP: y = y + height / 2 - (width * 0.12) - 1; height = width * 0.6; cairo_move_to (cr, x, y + height); cairo_line_to (cr, x + width / 2, y); cairo_line_to (cr, x + width, y + height); break; case GTK_ARROW_DOWN: y = y + height / 2 - (width * 0.12); height = width * 0.6; cairo_move_to (cr, x, y); cairo_line_to (cr, x + width / 2, y + height); cairo_line_to (cr, x + width, y); break; case GTK_ARROW_LEFT: x = x + width / 2 - (height * 0.12) - 1; width = height * 0.6; cairo_move_to (cr, x + width, y); cairo_line_to (cr, x, y + height / 2); cairo_line_to (cr, x + width, y + height); break; case GTK_ARROW_RIGHT: x = x + width / 2 - (height * 0.12); width = height * 0.6; cairo_move_to (cr, x, y); cairo_line_to (cr, x + width, y + height / 2); cairo_line_to (cr, x, y + height); break; case GTK_ARROW_NONE: break; } cairo_stroke (cr); cairo_destroy (cr); }
static void clearlooks_style_draw_slider (DRAW_ARGS, GtkOrientation orientation) { 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 ("hscale") || DETAIL ("vscale")) { WidgetParameters params; SliderParameters slider; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); slider.horizontal = (orientation == GTK_ORIENTATION_HORIZONTAL); slider.lower = FALSE; slider.fill_level = FALSE; if (clearlooks_style->style == CL_STYLE_GLOSSY) /* XXX! */ params.corners = CR_CORNER_ALL; STYLE_FUNCTION(draw_slider_button) (cr, &clearlooks_style->colors, ¶ms, &slider, x, y, width, height); } else if (DETAIL ("slider")) { WidgetParameters params; ScrollBarParameters scrollbar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; scrollbar.has_color = FALSE; scrollbar.horizontal = (orientation == GTK_ORIENTATION_HORIZONTAL); scrollbar.junction = clearlooks_scrollbar_get_junction (widget); if (clearlooks_style->colorize_scrollbar) { scrollbar.color = colors->spot[1]; scrollbar.has_color = TRUE; } /* Set scrollbar color */ if (clearlooks_style->has_scrollbar_color) { ge_gdk_color_to_cairo (&clearlooks_style->scrollbar_color, &scrollbar.color); scrollbar.has_color = TRUE; } if ((clearlooks_style->style == CL_STYLE_GLOSSY || clearlooks_style->style == CL_STYLE_GUMMY) && !scrollbar.has_color) scrollbar.color = colors->bg[0]; STYLE_FUNCTION(draw_scrollbar_slider) (cr, colors, ¶ms, &scrollbar, x, y, width, height); } else { clearlooks_parent_class->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); } cairo_destroy (cr); }
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); }
static void clearlooks_style_draw_handle (DRAW_ARGS, GtkOrientation orientation) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; cairo_t *cr; gboolean is_horizontal; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); /* Evil hack to work around broken orientation for toolbars */ is_horizontal = (width > height); if (DETAIL ("handlebox")) { WidgetParameters params; HandleParameters handle; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); handle.type = CL_HANDLE_TOOLBAR; handle.horizontal = is_horizontal; /* Is this ever true? -Daniel */ if (GE_IS_TOOLBAR (widget) && shadow_type != GTK_SHADOW_NONE) { ToolbarParameters toolbar; clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y); toolbar.style = clearlooks_style->toolbarstyle; cairo_save (cr); STYLE_FUNCTION(draw_toolbar) (cr, colors, ¶ms, &toolbar, x, y, width, height); cairo_restore (cr); } STYLE_FUNCTION(draw_handle) (cr, colors, ¶ms, &handle, x, y, width, height); } else if (DETAIL ("paned")) { WidgetParameters params; HandleParameters handle; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); handle.type = CL_HANDLE_SPLITTER; handle.horizontal = orientation == GTK_ORIENTATION_HORIZONTAL; STYLE_FUNCTION(draw_handle) (cr, colors, ¶ms, &handle, x, y, width, height); } else { WidgetParameters params; HandleParameters handle; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); handle.type = CL_HANDLE_TOOLBAR; handle.horizontal = is_horizontal; /* Is this ever true? -Daniel */ if (GE_IS_TOOLBAR (widget) && shadow_type != GTK_SHADOW_NONE) { ToolbarParameters toolbar; clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y); toolbar.style = clearlooks_style->toolbarstyle; cairo_save (cr); STYLE_FUNCTION(draw_toolbar) (cr, colors, ¶ms, &toolbar, x, y, width, height); cairo_restore (cr); } STYLE_FUNCTION(draw_handle) (cr, colors, ¶ms, &handle, x, y, width, height); } cairo_destroy (cr); }
static void clearlooks_style_draw_box_gap (DRAW_ARGS, GtkPositionType gap_side, gint gap_x, gint gap_width) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); if (DETAIL ("notebook")) { WidgetParameters params; FrameParameters frame; gboolean start, end; frame.shadow = shadow_type; frame.gap_side = gap_side; frame.gap_x = gap_x; frame.gap_width = gap_width; frame.border = &colors->shade[5]; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); clearlooks_get_notebook_tab_position (widget, &start, &end); params.corners = CR_CORNER_ALL; switch (gap_side) { case GTK_POS_LEFT: if (start) params.corners ^= CR_CORNER_TOPLEFT; if (end) params.corners ^= CR_CORNER_BOTTOMLEFT; break; case GTK_POS_RIGHT: if (start) params.corners ^= CR_CORNER_TOPRIGHT; if (end) params.corners ^= CR_CORNER_BOTTOMRIGHT; break; case GTK_POS_TOP: if (ge_widget_is_ltr (widget)) { if (start) params.corners ^= CR_CORNER_TOPLEFT; if (end) params.corners ^= CR_CORNER_TOPRIGHT; } else { if (start) params.corners ^= CR_CORNER_TOPRIGHT; if (end) params.corners ^= CR_CORNER_TOPLEFT; } break; case GTK_POS_BOTTOM: if (ge_widget_is_ltr (widget)) { if (start) params.corners ^= CR_CORNER_BOTTOMLEFT; if (end) params.corners ^= CR_CORNER_BOTTOMRIGHT; } else { if (start) params.corners ^= CR_CORNER_BOTTOMRIGHT; if (end) params.corners ^= CR_CORNER_BOTTOMLEFT; } break; } /* Fill the background with bg[NORMAL] */ ge_cairo_rounded_rectangle (cr, x, y, width, height, params.radius, params.corners); ge_cairo_set_color (cr, &colors->bg[GTK_STATE_NORMAL]); cairo_fill (cr); STYLE_FUNCTION(draw_frame) (cr, colors, ¶ms, &frame, x, y, width, height); } else { clearlooks_parent_class->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); } cairo_destroy (cr); }
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); }
static void moblin_netbook_draw_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) { cairo_t *cr; MoblinNetbookStyle *mb_style = MOBLIN_NETBOOK_STYLE (style); gint radius = mb_style->radius; DEBUG; if (DETAIL ("paned") || DETAIL ("buttondefault")) return; /* we want hover and focused widgets to look the same */ if (widget && GTK_WIDGET_HAS_FOCUS (widget)) state_type = GTK_STATE_PRELIGHT; /* scrollbar troughs are a plain rectangle */ if (widget && GTK_IS_SCROLLBAR (widget) && DETAIL ("trough")) { cr = moblin_netbook_cairo_create (window, area); cairo_rectangle (cr, x, y, width, height); gdk_cairo_set_source_color (cr, &style->base[state_type]); cairo_fill (cr); cairo_destroy (cr); return; } SANITIZE_SIZE; /*** treeview headers ***/ if (widget && GTK_IS_TREE_VIEW (widget->parent)) { cr = moblin_netbook_cairo_create (window, area); cairo_rectangle (cr, x, y, width, height); gdk_cairo_set_source_color (cr, &style->bg[state_type]); cairo_fill (cr); cairo_destroy (cr); gtk_paint_vline (style, window, state_type, area, widget, detail, y + 5, y + height - 5, x + width - 1); return; } /*** spin buttons ***/ if (DETAIL ("spinbutton_down") || DETAIL ("spinbutton_up")) return; if (DETAIL ("spinbutton")) { /* FIXME: for RTL */ width += 10; x -= 10; /* always draw button as shadow out to match the entry */ shadow_type = GTK_SHADOW_OUT; /* draw the buttons with the same state type as the entry */ state_type = widget->state; } /*** combo boxes ***/ if (DETAIL ("button") && widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent)) { GtkWidget *entry; entry = g_object_get_data (G_OBJECT (widget->parent), "moblin-netbook-combo-entry"); g_object_set_data (G_OBJECT (widget->parent), "moblin-netbook-combo-button", widget); /* always draw combo box entry buttons as shadow out to match the entry */ shadow_type = GTK_SHADOW_OUT; if (GTK_IS_ENTRY (entry)) { gtk_widget_queue_draw (entry); } /* FIXME: RTL */ width += 10; x -= 10; } if (widget && (DETAIL ("trough") || DETAIL ("trough-fill-level") || DETAIL ("trough-fill-level-full")) && GTK_IS_SCALE (widget)) { if (mb_style->shadow) { width--; height--; } if (width > height) { y = y + (height / 2.0 - 2); height = 4; } else { x = x + (width / 2.0 - 2); width = 4; } } /* scrollbar buttons */ if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) { x += 2; y += 2; width -= 4; height -= 4; } /* scrollbar slider */ if (DETAIL ("slider")) { if (widget && GTK_IS_HSCROLLBAR (widget)) { y += 2; height -= 4; } else { x += 2; width -= 4; } } cr = moblin_netbook_cairo_create (window, area); cairo_set_line_width (cr, LINE_WIDTH); /* special "fill" indicator */ if (DETAIL ("trough-fill-level-full") || DETAIL ("trough-fill-level")) { gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]); if (width > height) cairo_rectangle (cr, x, y + 1, width, height - 2); else cairo_rectangle (cr, x + 1, y, width - 2, height); cairo_fill (cr); cairo_destroy (cr); return; } if (mb_style->shadow) { if (shadow_type == GTK_SHADOW_OUT) { /* outer shadow */ moblin_netbook_rounded_rectangle (cr, x, y, width, height, radius + 1); cairo_set_source_rgba (cr, 0, 0, 0, mb_style->shadow); cairo_fill (cr); /* reduce size for outer shadow */ height--; width--; } else if (shadow_type == GTK_SHADOW_IN) { x++; y++; width--; height--; } } /* fill */ moblin_netbook_rounded_rectangle (cr, x, y, width, height, radius); if (DETAIL ("light-switch-trough")) { cairo_pattern_t *crp; crp = cairo_pattern_create_linear (x, y, x, height); /* FIXME: these colours really should not be defined here */ if (state_type == GTK_STATE_SELECTED) { cairo_pattern_add_color_stop_rgb (crp, 0, 0.365, 0.820, 0.953); cairo_pattern_add_color_stop_rgb (crp, 1, 0.627, 0.894, 0.973); } else { cairo_pattern_add_color_stop_rgb (crp, 0, 0.937, 0.941, 0.929); cairo_pattern_add_color_stop_rgb (crp, 1, 1.0, 1.0, 1.0); } cairo_set_source (cr, crp); } else gdk_cairo_set_source_color (cr, &style->bg[state_type]); cairo_fill (cr); /* extra hilight for "button" widgets, also used as focus rectangle since * state_type is set to prelight for focused widgets (see above) */ if (state_type == GTK_STATE_PRELIGHT && DETAIL ("button") && !(widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent))) { cairo_set_line_width (cr, 2.0); moblin_netbook_rounded_rectangle (cr, x + 2, y + 2, width - 4, height - 4, radius - 1); gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]); cairo_stroke (cr); cairo_set_line_width (cr, 1.0); } if (shadow_type != GTK_SHADOW_NONE) { /* border */ moblin_netbook_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius); moblin_netbook_set_border_color (cr, style, state_type); cairo_stroke (cr); } /* add a grip to handles */ if (DETAIL ("light-switch-handle") || DETAIL ("hscale")) { gdk_cairo_set_source_color (cr, &style->mid[state_type]); moblin_netbook_draw_grip (cr, FALSE, x, y, width, height); } else if (DETAIL ("vscale")) { gdk_cairo_set_source_color (cr, &style->mid[state_type]); moblin_netbook_draw_grip (cr, TRUE, x, y, width, height); } cairo_destroy (cr); }