Re: [gtk-list] Re: GtkStyleKey / GtkStyle
- From: Tim Janik <timj gimp org>
- To: gtk-list redhat com
- cc: Jost Boekemeier <jostobfe calvados zrz TU-Berlin DE>
- Subject: Re: [gtk-list] Re: GtkStyleKey / GtkStyle
- Date: Tue, 24 Feb 1998 00:32:06 +0100 (CET)
On Mon, 23 Feb 1998, Jost Boekemeier wrote:
>
> Umm no, I just changed the order of the symbols.
> The size of _GtkStyleKey and _GtkStyle remains the same.
>
> gtk_style_find() creates a GtkStyleKey key, fills in the
> appropriate values (fg, bg, text, .., depth, cmap), calls
> gtk_cache_insert, which then duplicates the key and allocates
> more memory at the end of the structure. This key is then casted to
> GtkStyle and given to gtk_style_init (GtkStyle *style), which reads some
> values (fg, bg) and fills other values into the spaces allocated at the end
> of GtkStyleKey (now GtkStyle).
>
> In other words: GtkStyle /is a/ GtkStyleKey, with some fields added at its end.
> So the current implementation is wrong:
>
>
> struct _GtkStyleKey struct _GtkStyle
> { {
> GdkColor fg[5]; GdkColor fg[5];
> GdkColor bg[5]; GdkColor bg[5];
> GdkColor text[5]; GdkColor light[5];
> GdkColor base[5]; GdkColor dark[5];
> GdkColor mid[5];
> GdkPixmap *bg_pixmap[5]; GdkColor text[5];
> GdkColor base[5];
> GdkFont *font;
> GdkColor black;
> gint depth; GdkColor white;
> GdkColormap *colormap; GdkFont *font;
> GtkStyleClass *klass;
> }; GdkGC *fg_gc[5];
> GdkGC *bg_gc[5];
> GdkGC *light_gc[5];
> GdkGC *dark_gc[5];
> GdkGC *mid_gc[5];
> GdkGC *text_gc[5];
> GdkGC *base_gc[5];
> GdkGC *black_gc;
> GdkGC *white_gc;
>
> GdkPixmap *bg_pixmap[5];
>
> gint ref_count;
> gint attach_count;
>
> gint depth;
> GdkColormap *colormap;
>
> GtkStyleClass *klass;
> };
>
>
> See, I can extract fg[] and bg[], but when I try to get text[0], I get *font,
> which is nonsense.
>
> So the implementation should be:
>
> struct _GtkStyleKey struct _GtkStyle
> { {
> /* inherited from GtkStyleKey */
> GdkColor fg[5]; GdkColor fg[5];
> GdkColor bg[5]; GdkColor bg[5];
> GdkColor text[5]; GdkColor text[5];
> GdkColor base[5]; GdkColor base[5];
>
> GdkPixmap *bg_pixmap[5]; GdkPixmap *bg_pixmap[5];
>
> GdkFont *font; GdkFont *font;
>
> gint depth; gint depth;
> GdkColormap *colormap; GdkColormap *colormap;
> GtkStyleClass *klass; GtkStyleClass *klass;
+ gint ref_count; gint ref_count;
+ gint attach_count; gint attach_count;
> };
>
> /* New entries */
> GdkColor light[5];
> GdkColor dark[5];
> GdkColor mid[5];
>
> GdkColor black;
> GdkColor white;
>
> GdkGC *fg_gc[5];
> GdkGC *bg_gc[5];
> GdkGC *light_gc[5];
> GdkGC *dark_gc[5];
> GdkGC *mid_gc[5];
> GdkGC *text_gc[5];
> GdkGC *base_gc[5];
> GdkGC *black_gc;
> GdkGC *white_gc;
>
- gint ref_count;
- gint attach_count;
> };
>
now you can check whether it is permissable to cast GtkStyleKey* into
GtkStyle*, simply by checking attach_count>0.
also it would be nice if the rest of the colors (GdkColor light...white)
would move be replicated in GtkStyleKey also, this would allow for owens
gtk_widget_force_style() behaviour with the rest of the fields (and
GdkColor.pixel) being only valid if attach_count>0.
> By the way, is there any documentation available? You've written
> nice code, but it is a bit difficult to understand when there is
> no comment what a function does.
what fucntions are you actually talking about?
concerning the style meachanism, there is no decent (actually none)
documentation yet ;)
>
>
> Jost
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]