Custom CellRenderer - ProgressBar



Good day,

I have a problem to render progress bar in my custom cell renderer class
properly. Gtk+-2.4.x (Gtkmm-2.4.x) doesn't have it implemented, so, I
should do it myself.

First, I used code from Gtk+-2.6 to draw progress in my column, but that
looks ugly: no shadows, no paddings...

 gc = gdk_gc_new (window);

 x = cell_area->x + cell->xpad;
 y = cell_area->y + cell->ypad;

 w = cell_area->width - cell->xpad * 2;
 h = cell_area->height - cell->ypad * 2;

 gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]);
 gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);

 x += widget->style->xthickness;
 y += widget->style->ythickness;
 w -= widget->style->xthickness * 2;
 h -= widget->style->ythickness * 2;
 gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_NORMAL]);
 gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);

 gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]);
 perc_w = w * MAX (0, cellprogress->priv->value) / 100;
 gdk_draw_rectangle (window, gc, TRUE, is_rtl ? (x + w - perc_w) : x, y, perc_w, h);


Now, I' am trying to use GtkProgressBar sources to draw indicator more
precisely.

 gtk_paint_box (widget->style,
 window,
 GTK_STATE_NORMAL, GTK_SHADOW_IN,
 NULL, widget, "trough",
 x, y, w, h);

 gtk_paint_box (widget->style,
 window,
 GTK_STATE_SELECTED, GTK_SHADOW_OUT,
 NULL, widget, "bar",
 x, y, perc_w, h);

Have to use GTK_STATE_SELECTED (originally GTK_STATE_PRELIGHT) to draw
progress indicator.

Looks fine, but it doesn't use color gradient like natural
GtkProgressBar does.

In last attempt I used GtkStyle grabbed from "signal_realized" for
GtkProgressBar created elsewhere. And passed it to gtk_paint_box -
unfortunately, no effect.

Could someone help me, please?

thanks in advance,
-andrew









[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]