[gtkada] Changing the color of a label
Preben Randhol
randhol at pvv.org
Thu Jun 19 14:46:04 CEST 2003
Jean-Pierre Rosen <rosen.adalog at wanadoo.fr> wrote on 19/06/2003 (14:29) :
> I want a label with a white background instead of the standard grey.
> I parsed the RM, but all I found looked complicated...
> Is there a simple way to do this?
There are two ways but it depends on what GtkAda version you use.
1) [Gtkada 2.0] use the markup in the label to do it (it is in cvs
now) however this will only make the background of the letters
white (I mean not the entire space the label might be stretched
to.
Example:
Set_Markup (Label,
"<span background=""white"" >"
& "This label has <i>markup</i>!</span>");
2) [GtkAda 1.X-2.0] put a Evenbox first and then put the label in the
Eventbox. Now you can set the background of the Eventbox. Labels
don't have backgrounds. (I think this works in GtkAda 2.0 too, but
I haven't checked.)
Example for GtkAda 1.x:
Gtk_New (Background_Eventbox);
Set_Border_Width (Background_Eventbox, 1);
Add (Some_Box, Background_Eventbox);
Gtk_New (Title_Label, "Title");
Set_Alignment (Title_Label, 0.0, 0.5);
Set_Justify (Title_Label, Justify_Left);
Set_Padding (Title_Label, 3, 1);
Set_Line_Wrap (Title_Label, False);
Add (Background_Eventbox, Title_Label);
Background_Eventbox_Style :=
Copy (Get_Style (Background_Eventbox));
-- Now you can set the background colour on the Eventbox.
HTH
--
Preben Randhol -------------- http://www.pvv.org/~randhol/Ada95 --
«For me, Ada95 puts back the joy in programming.»
More information about the gtkada
mailing list