Re: Changing colors



G'Day !

create a GdkGC *color  -->  fill it in with selected color (either via color
selection dialog, or pre-allocated)  -->  Call line drawing function

here is a way to fill in a color, (mostly from examples in Harlow's book):

penGreen  = GetPen (NewColor (0, 0xffff, 0 ));

GdkGC
*GetPen (GdkColor *c)
{
  GdkGC *gc;

  gc = gdk_gc_new (g->pixmap);

  gdk_gc_set_foreground (gc, c);

  return (gc);
}

GdkColor
*NewColor (long red, long green, long blue)
{
  gdkColor *c = (GdkColor) g_malloc (sizeof (GdkColor));

  c->red = red;
  c->green = green;
  c->blue = blue;

  gdk_color_alloc (gdk_colormap_get_system( ), c );

  return ( c );
}

Now you can call:

gdk_draw_line (pixmap, penGreen,  0,
               pixmap_height - (p * y_grid_scale),  pixmap_width, pixmap_height
- (p *
               y_grid_scale));


Hope this helps ...

cheers,
Jim Parker

Sailboat racing is not a matter of life and death ....  It is far more important
than that !!!


                                                                                                              
                      
                    Marco Quezada                                                                             
                      
                    <mquezada nlxcorp com>          To:     GTK List <gtk-app-devel-list gnome org>           
                      
                    Sent by:                        cc:                                                       
                      
                    gtk-app-devel-list-admin        Subject:     Changing colors                              
                      
                    @gnome.org                                                                                
                      
                                                                                                              
                      
                                                                                                              
                      
                    12/08/00 01:27 PM                                                                         
                      
                                                                                                              
                      
                                                                                                              
                      



Hi all,

I'm trying to change the color of a line inside a drawing area to show
as a grid. I am currently drawing the grid in the following manner where
widget->style->white_gc draws the line in white. How can I have it drawn
in say green?

Thanks.

   q = y_range / y_scale;

   for(p = (int)miny; p <= q; ++p)
   {
        gdk_draw_line (pixmap, widget->style->white_gc,  0,
pixmap_height - (p * y_grid_scale),  pixmap_width, pixmap_height - (p *
y_grid_scale));
   }

--
Marco Quezada
Aerospaceo Engineero
NLX Corporation
22626 Sally Ride Dr.
Sterling, VA, 20164
mquezada nlxcorp com
703-234-2100 x1028
http://www.nlxcorp.com




_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list








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