Re: A simple GdkDrawingArea question



I have seen that, but it only uses some premade graphic contexts like
widget->style->white_gc. With that you can't use whatever color you
like. Maybe I've made the wrong question. Mainly my headache comes
from one question:
¿How can I make a graphic context with a custom foreground and background color?
I've tried that:

typedef struct _colors {
   GdkColor fg;
   GdkColor bg;
} colors;

GdkGC *graphic_context;
/* Color is a variable of type colors defined above, it contains a gdkcolor */
GdkColor color_fg = color.fg;
GdkColor color_bg = color.bg;
graphic_context = gdk_gc_new(widget->window);

gdk_gc_set_background(graphic_context, &color_bg);
gdk_gc_set_foreground(graphic_context, &color_fg);

It doesn't work. I gen strange values on the GdkGc colors.

I've tried this too:

GdkGCValues val;

val.foreground = color.fg;
val.background = color.bg;
graphic_context =
gdk_gc_new_with_values(widget->window,&val2,GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);

It doesn't work too. I get the same strange values.

Is there any example where I can see how to draw a custom polygon (for
example a blue rectangle or something like that)


On Thu, 28 Oct 2004 08:33:39 -0600 (MDT), Ian Strascina
<istrasci cs nmsu edu> wrote:
> On Thu, 28 Oct 2004, [ISO-8859-1] José Antonio Sánchez wrote:
> 
> 
> 
> > I followed the tutorial found on the gtk page to draw a simple widget
> > on screen, but it uses graphic contexts from the widget background and
> > foreground definition (widget->style->white_gc or
> > widget->style->fg_gc[GTK_WIDGET_STATE (widget)]. But that's not what I
> > want.
> >
> > I've been playing with the graphic contexts, with the gdk colors and
> > so. But I really don't need all of this. All I want is to draw a not
> > filled rectangle from one color (for example black or white) with a
> > text inside (in the same color as the rectangle) over a background of
> > another color. For example, draw a black rectangle with black text
> > over a red background.
> > I have written this on GtkCairo because it's easier, it doesn't use
> > graphic contexts, only colors to draw some figures, but I don't want
> > to include all the GtkCairo and Cairo itself on my application only to
> > do that.
> > Could someone tell me how could I make that, or instead, give me a
> > link to a good tutorial of GtkDrawingArea or Graphic contexts usage?
> > Thanks in advance.
> > _______________________________________________
> > gtk-list mailing list
> > gtk-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-list
> 
> I don't know if this will help your cause or not, but here is a link to a
> page about GtkDrawingArea:
> 
>         http://www.gtk.org/tutorial/sec-thedrawingareawidget.html
> 
> I don't know if it is specific to your problem, but I hope it helps...
> 
>         - Ian
> 
> -------------------------------------------------------------------------------
> "Mostly, when you see programmers, they aren't doing anything...
>   One of the attractive things about programmers is that you cannot tell
>   whether or not they are working simply by looking at them...  Very often
>   they're sitting there seemingly drinking coffee and gossiping, or just
>   staring into space...  What the programmer is trying to do is get a handle
>   on all the individual and unrelated ideas that are scampering around in
>   his head..."  -- Charles M. Strauss
> -------------------------------------------------------------------------------
>



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