[gtkada] Question about Style and Pragmas

Jean-Etienne Doucet doucet at laas.fr
Wed Apr 18 16:00:09 CEST 2001


From: Preben Randhol <randhol at pvv.org>
| 
| Emmanuel Briot <briot at gnat.com> wrote on 18/04/2001 (15:12) :
| 
| > You can of course share a style between widgets, since, like most other
| > things in gtk+, styles are reference counted. When you are done with using a
| > style for a specific line, just call Unref on it. When the reference counter
| > reaches 0, the style is removed from memory.
| > Does this answer your question, or did I incorrectly understand it ?
| 
| Not sure. The reason I ask is that if one do someting like this:
| 
|    Style_1 := Get_Style (Some_Widget_1);
|    Set_Background (Style_1, State_Normal, Colour_1)
|    Set_Style (Some_Widget_1, Style_1);
| 
|    Style_2 := Get_Style (Some_Widget_2);
|    Set_Background (Style_2, State_Normal, Colour_2)
|    Set_Style (Some_Widget_2, Style_2);
| 
| Then both Some_Widget_1 and Some_Widget_2 gets Colour_2. And I don't
| understand this.

It's because Some_Widget_1 and Some_Widget_2 have the *same* style, so
changing it for Some_Widget_2 also changes it for Some_Widget_1.

| I guess I get the Style of the underlying widget in
| this case the window and change this ? As if I do:
| 
|    Style_1 := Copy (Get_Style (Some_Widget_1));
|    Style_2 := Copy (Get_Style (Some_Widget_2));
| 
| it works.

Here you have two different styles, so they don't interfere...

--jed--




More information about the gtkada mailing list