[468] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: color handling.
daemon@ATHENA.MIT.EDU (Owen Taylor)
Thu Jul 17 21:08:55 1997
To: gtk-list@redhat.com
From: Owen Taylor <owt1@cornell.edu>
Date: 17 Jul 1997 21:10:15 -0400
In-Reply-To: 's message of Thu, 17 Jul 1997 12:39:01 +0200 (CEST)
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
H
<allan@ns.internet.dk> writes:
> What I need is to draw a table of entries something like a spreadsheet
> on a drawing area. I have made the area and I am able to draw rectangles
> and strings using gdk_draw_rectangle and gdk_draw_string, but I can't
> get the background colors to change the way I need. I need only 4-5
> different background colors and the text need only be in black or white.
> Maybe I should do something with gtkstyle but what ???
X (and thus gtk) only draw the foreground portion of the text, so if
you want different background colors, you'll have fill in the area
behind the text explicitly. (possibly by filling a rectangle after
setting the _foreground_ color.)
You can get the size of a string by doing something like:
gint string_width = gdk_string_width (font,string);
gint string_height = font->ascent + font->descent + 2;
(You may need to play around with this a bit to get things the way
you like it.) Using styles doesn't really help in doing the
drawing, but it might help in keeping track of things. It's
mostly needed if you're writing a widget - the style provides
a way for the user/programmer to control the appearance.
Regards,
Owen
(I found some examples of drawing text and background in the gtktext
widget, but knowing where to look is a function of experience
(and grep.))
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null