[gtkada] Setting a label's text color
Marc A. Criley
marccriley at earthlink.net
Sun Dec 23 13:43:26 CET 2001
(Apologies if you see this twice, I had some subscription problems.)
I understand how to set the background color of a label, but I'm having
trouble with setting the color of the label's text.
I used GLADE to build the GUI, and have the label residing within an
Event_Box. I then copy the Style of the Event_Box, make the desired
changes, and then Set_Style the modified style. Here's the relevant code
(incomplete, because I'm still just trying to get this to work right):
procedure Set_Logging_Status (Active : in Boolean)
is
Fg_Color : Color.Gdk_Color;
Bkg_Color : Color.Gdk_Color;
CM : Color.Gdk_Colormap;
Label_Style : Style.Gtk_Style;
begin
Fg_Color := Color.Parse("White");
Bkg_Color := Color.Parse("Red");
CM := Widget.Get_Default_Colormap;
Color.Alloc(CM, Fg_Color);
Color.Alloc(CM, Bkg_Color);
Label_Style :=
Style.Copy(Event_Box.Get_Style(Data.Enabled_Eventbox));
Style.Set_Foreground(Label_Style, Enums.State_Normal, Fg_Color);
Style.Set_Background(Label_Style, Enums.State_Normal, Bkg_Color);
Event_Box.Set_Style(Data.Enabled_Eventbox, Label_Style);
end Set_Logging_Status;
While this does change the embedded label's background color to red, the
label's text color remains black (no matter what color I've chosen for the
foreground). I have also tried using the Style.Set_Text procedure that is
analogous to Set_Background, but it seems to have no effect.
More information about the gtkada
mailing list