[gtkada] Setting a label's text color
Preben Randhol
randhol at pvv.org
Mon Dec 24 00:32:24 CET 2001
"Marc A. Criley" <marccriley at earthlink.net> wrote on 23/12/2001 (14:44) :
> (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.
The colour of the label must be set in the label. The reason you cannot
set the background is that a label doesn't have a background (therefore
the Event_box). This means that you cannot set the forground of the
label by setting the forground colour in the event box. Look below
> 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);
-- Add this line:
Label.Set_Style(Data.Your-Label-Object-here, Label_Style);
> end Set_Logging_Status;
--
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
«For me, Ada95 puts back the joy in programming.»
More information about the gtkada
mailing list