gdk_draw_rectangle problems




I am having trouble getting gdk_draw_rectangle to draw anything
but points...  The code is reading color data from a file, and 
then displaying it in a drawing area as blocks (to make an image
from a simulation).  

I have created several graphics contexts for red, green, and blue, 
and these work ok. Looping  through the data, I use this:

  for (y = 0; y < simul_data.ny; y++) {
      for (time = 0; time < simul_data.nt; time++) which updates the {
          for (x = 0; x < simul_data.nx; x++) {
              update_rect.x = (gint) (gint) x + (gint) x_diff;
              update_rect.y = (gint) (gint) y + (gint) y_diff;
              switch (simul_data.data[time*simul_data.nt+x+y]) {
                case '1':
                  gdk_draw_rectangle (pixmap,
                                      gc_red,
                                      TRUE,
                                      update_rect.x, update_rect.y,
                                      update_rect.width,
                                      update_rect.height);
                  break;
.....etc for the switch statement....

and in the outermost loop there is:

        gtk_widget_draw (draw_area, NULL);

to update everything all at once.  The drawing area is connected
to handlers for configure_event and expose_event as per the 'scribble'
example in the tutorial.  I have checked the values in update_rect
(a GdkRectangle variable) and they are correct, i.e. it should def.
be drawing blocks, not points!!  They are all drawn in the uppermost
left corner, as expected...  The same thing happens when each 
gdk_draw_rectangle is followed by a gtk_widget_draw, except that 
things run much slower.

Can anyone help?  I am quite new to GTK, and this one has me mystified.



Thanks,

Brian



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