Re: Drawing



This is a working example
 
   GdkGC *red_gc;
   GdkColor color;
   GdkGCValues gc_values;
   GtkWidget *area; // Drawing area
   GdkPixmap *pixmap;

   red_gc = gdk_gc_new(widget->window);
   gdk_color_parse("red", &color);
   gdk_colormap_alloc_color(gdk_colormap_get_system(),&color,FALSE,TRUE);
   gdk_gc_set_foreground(red_gc, &color);
   gdk_gc_get_values(red_gc, &gc_values);
  /* to change other attributes */
   gdk_gc_set_line_attributes(red_gc,gc_values.line_width+1,gc_values.line_style,
                              gc_values.cap_style,gc_values.join_style);


 .....
 .....

   /* on a backing pixmap for example */
   gdk_draw_rectangle(pixmap,red_gc,TRUE,0,0,100,100);
 /* and after on a drawing area */
  gdk_draw_drawable(area->window,red_gc,pixmap,0,0,0,0,
                                   100,100);


Bye

On Mon, 17 Jan 2005 15:05:49 +0300, Alexander S.Kresin
<alex belacy belgorod su> wrote:
Hello All,

 please, help me with some basic problems, related to drawing.

 What I want is to draw some things on the drawing_area with a certain
 color - red rectangle, for example.

 this is what I wrote in expose_event handler:

 ...
 GdkDrawable * hWnd = widget->window;
 GkdGC * hDC = widget->style->fg_gc[ GTK_WIDGET_STATE( widget ) ];
 GdkColor color;
 gdk_color_parse( "FF0000", &color );
 gdk_gc_set_foreground( hDC, &color );
 gdk_draw_rectangle( hWnd, hDC, 0, 0, 0, 30, 30 );

 I get this rectangle, but of lilac color, and all other widgets in a
 window became lilac ...

 What I need to have only my rectangle in the drawing_area with a red
 color and then, for example, some line there in any other color ?

Regards,
 Alexander
http://kresin.belgorod.su

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



-- 
-- Cristiano



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