Re: Re: Not understanding the principles of drawing areas and primitives etc... Colors?
- From: "Leo -" <insomninja gmail com>
- To: gtk-list gnome org
- Subject: Re: Re: Not understanding the principles of drawing areas and primitives etc... Colors?
- Date: Sat, 11 Mar 2006 17:29:52 +0100
I think I can grasp the GC idea; it's just a way to reduce the number
of parameters sent to certain functions, but where do I "get" the
colors from?
When I check up on gdk_gc_set_foreground etc. they require a gdkColor
parameter, and following that link (clicking gdkColor) gets me to a page
about colormaps and, my impression is that I need to set up a
"palette", link it to the widget, add my colors etc. etc., before I can
actually draw on my widget.
Is that really the case?
Whether it is or not, it would be nice if somebody could give me a (c
language) source snippet on how to set up colors and colormaps for a
widget
and then draw a red line on it...
2006/3/9, Paul Davis <paul linuxaudiosystems com
>:
On Thu, 2006-03-09 at 19:39 +0100, Leo - wrote:
> I want to be able to draw lines on a gtkDrawingArea, with a color the
> user selects (r,g,b),
> however I don't understand how I would do.
> The whole business with gdkGC's and gdcColors seems very alien. If
> somebody could
> point me to a tutorial (the scribble one isn't enough since that one
> doesn't use color).
no tutorial here, but a brief lecture.
there are many different possible parameters for many drawing
primitives. in your case of line drawing, we have things like:
* is the line dashed?
* if dashed, what are the stroke & gap sizes?
* the pen width
* the color of the line
for other drawing primitives, there are many more.
rather than constantly pass all these parameters into every drawing
function, most drawing kits based on the X Window System instead using a
Graphics Context (or GC) which contains a set of values that can be used
by any drawing primitive. This is more efficient in other ways too, but
you probably don't need to worry about them. You generally work with a
fixed number of
> What I simply want to do is something like line(gtkDrawingArea* da,
> int x1, int y1, int x2, int y2, r, g, b)
just grab a suitable GC, such as
Glib::RefPtr<GC> gc = get_style()->get_fg_gc();
change its foreground color, specifically for whatever state
the drawing area is in right now (widgets in GTK can be in one of
several possible states):
gc.set_foreground_gdk (redColor, get_state());
and draw on the window:
get_window()->draw_line (gc, x1, y1, x2, y2);
the precise details might be slightly off, i am writing from memory.
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]