gtk-1.x styles



Hello.

I'd like to draw a progress bar in a GtkDrawingArea. It should use
exactly the same style as provided in the user selected Gtk Theme.

Right now i solve this as follows: I have a static GdkPixmap which i
draw in and then paste in the GtkDrawingArea. To paint the progress
bar with the right style, i get the style from another existing
ProgressBar in my app:
  style = another_progress_bar->style;

On an expose event (drawing_area) i do (speudo code):

void expose() {
  [make sure that another_progress_bar and drawingarea is realized]

  style = another_progress_bar->style;
  if (!pixmap || drawingarea_was_resized) {
    if (pixmap) gdk_pixmap_unref(pixmap);
    pixmap = gdk_pixmap_new(drawingarea->window, width, height, -1);
  }

  /* paint contents */
  [...]
  gtk_paint_box (style, pixmap,
                 GTK_STATE_NORMAL, GTK_SHADOW_IN,
                 NULL, drawingarea, "trough",
                 x, y, w, h);
  gtk_paint_box (style, bandwidth->pixmap,
                 GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
                 NULL, area, "bar",
                 x+dx, y+dx, w2, h-2*dy);
  [...]

  /* now paste pixmap */
  gdk_draw_pixmap (drawingarea->window,
                   drawingarea->style->black_gc,
                   pixmap, 0,0,0,0, width, height);


This seems to work on most machnies, but crashes on some with the
message:

Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 35768 error_code 3 request_code 2 minor_code 0
Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 49170 error_code 3 request_code 61 minor_code 0 

Its reported that deleting .gtk* in $HOME helped.

Another thing i have noticed: When the drawingarea is shown on screen
the very first time (by switching to the according notebook page),
then i see junk instead of the painted pixmap for a short time.

Anyone has an explanation?

Markus.




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