Re: Entry and Text Widgets with color



how to do in GTK 1,2 in a text or entry widget
"default color text  RED_WORD continue with default"

There are two situations here:
1) your message is hard-coded, i.e. at compile time you
know exactly the text you want to show. Then you can use
something as in the code below. A screenshot showing the result
can be seen here:

http://www.demat.ist.utl.pt./~carlos/description/screenshots/screenshot09_3.html

(Try to avoid hard-coding the colors, you might consider giving users 
the chance to set their own colors).

2) your messages come from, say, XHTML files. In this case you
are responsible for changing, say, foreground_color, when a
<b> appears. When </b> shows up, you change again the foreground_color
to the normal foreground color. In this case, you might well
consider to read text to a buffer and insert one character at
a time. From my experience speed is not a problem and the code
might be cleaner. In the end of the day this depends of your
preference and of the way you are reading data from files.
Just try yourself! 

All my Help files are XHTML (except the initial Help->Start
which is hard-coded, in case paths are misconfigured), and 
I wrote a little browser that reads them into GtkText widgets,
(from local, HTTP or FTP connections), I can tell you that
this works very well with GtkText on Gtk1.2.

Carlos
------example-------------
static void static_insert (GtkWidget *text, GdkColor color_foreground,
GdkColor color_bold, GdkColor color_link)
{
/******************
 * insert message *
 ******************/

gamgi_gtk_dialog_text_insert (text, NULL, color_bold,
"\nWelcome to GAMGI!\n\n");

/************
 * get help *
 ************/

gamgi_gtk_dialog_text_insert (text, NULL, color_foreground,
"To get help, users can: 1) browse the documentation at ");

gamgi_gtk_dialog_text_insert (text, NULL, color_link,
"http://www.gamgi.org/ ");

gamgi_gtk_dialog_text_insert (text, NULL, color_foreground,
"or its local copy at ");

gamgi_gtk_dialog_text_insert (text, NULL, color_bold,
"$GAMGI/doc/public_html");

gamgi_gtk_dialog_text_insert (text, NULL, color_foreground,
"; 2) send an e-mail to the mailling list at ");



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