Re: Adding color to a label?
- From: Vlad Harchev <hvv hippo ru>
- To: Jeff Shipman <shippy cs nmt edu>
- Cc: gtk-list gtk org
- Subject: Re: Adding color to a label?
- Date: Mon, 23 Oct 2000 13:44:16 +0500 (SAMST)
On Sun, 22 Oct 2000, Jeff Shipman wrote:
Hi Jeff,
Here is a C++ code to do this
void widget_set_color(GtkWidget* entry,GdkColor* color,GtkRcFlags
component=GTK_RC_FG)
{
gtk_widget_ensure_style(entry);
GtkStyle* newstyle;
{
newstyle = gtk_style_copy(gtk_widget_get_style(entry));
GdkColor& tcolor = *color;
for(int i=0;i<5;++i) {
if (component & GTK_RC_FG)
newstyle->fg[i] = tcolor;
if (component & GTK_RC_BG)
newstyle->bg[i] = tcolor;
if (component & GTK_RC_TEXT)
newstyle->text[i] = tcolor;
if (component & GTK_RC_BASE)
newstyle->base[i] = tcolor;
};
};
gtk_widget_set_style(entry,newstyle);
};
Use this way:
{
GdkColor red;
gdk_color_parse("red",&red);
widget_set_color(label,&red,~0);
}
It should work for any other widget (just tweak last arg to
widget_set_color).
> Is there a way I can use a GdkColor to set the color
> of a GtkLabel? If not, is there any other way I can
> do it?
>
> --
> Jeff "Shippy" Shipman E-Mail: shippy cs nmt edu
> CS Major / EE Minor ICQ: 1786493
> New Mexico Institute of Mining and Technology
> Homepage: http://www.nmt.edu/~shippy
>
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
Best regards,
-Vlad
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]