]> Pileus Git - ~andy/gtk/blob - docs/styles.txt
Updates
[~andy/gtk] / docs / styles.txt
1 HANDLING WIDGET STYLES
2 ======================
3
4
5 A widget gets created with a default style.
6 The global default style can be affected by gtk_widget_set_default_style()
7 and can be queried by gtk_widget_get_default_style().
8 The initial style that is assigned to a widget as default style upon
9 creation can be affected by wrapping the widget's creation as follows:
10 gtk_widget_push_style (my_style);
11 widget = gtk_type_new (gtk_button_get_type ());
12 gtk_widget_pop_style ();
13
14 There are certain functions to affect widget styles after a widget's
15 creation:
16
17 gtk_widget_set_style ()
18   Save the default style and set a user style.
19   This will override a previously set user style or
20   previously set rc styles.
21
22 gtk_widget_set_rc_style ()
23   Set GTK_RC_STYLE to indicate that an rc lookup has been performed.
24   If there is an rc style for a widget, set it and save the default style,
25   restore the default style otherwise.
26   This will override a previously set user style or rc style.
27
28 gtk_widget_reset_rc_styles ()
29   Descends through a widget heirarchy and sets the rc style
30   on all widgets that don't have a user style set.
31
32 gtk_widget_restore_default_style ()
33   Reset the widget's style to the default style, this is only usefull if
34   the widgets default style had been saved by previous calls to
35   gtk_widget_set_style() or gtk_widget_set_rc_style().
36
37 gtk_widget_ensure_style ()
38   Ensure that the widget either has a user style set, or an rc lookup
39   has been performed.
40
41 gtk_rc_get_style ()
42   Return an rc style for a widget if there is one.
43
44 gtk_widget_set_name ()
45   Change widget name, and perform a new rc lookup if no user style
46   is set.
47
48 gtk_widget_realize ()
49   Besides realizing the widget this function will:
50   - perform an rc lookup if neccessary,
51   - attach a widget's style.
52
53 gtk_widget_get_style ()
54   Return a widgets style, this function will perform an rc lookup
55   if neccessary.
56
57 gtk_widget_set_parent ()
58   This function will perform rc lookups recursively for all widgets
59   that do not have a user style set.
60
61 gtk_style_copy ()
62   This function can be used to copy a widget's style.
63   The style can subsequntly be changed (e.g., by modifications to the
64   red/green/blue values of a certain color) and then be applied to the
65   widget via gtk_widget_set_style().
66
67
68 GtkWidget::style_set
69   This signal will be emitted for a widget once its style changes with
70   an additional argument previous_style wich will hold the widget->style
71   avlue from a previous emission.
72   The initial emission of this signal is guaranteed to happen prior
73   to any GtkWidget::size_request emission, and will have the previous_style
74   argument set to NULL.
75   The GtkWidgetClass implements a default handler for this signal that
76   will set the widget's window's background of widgets that provide their
77   own windows according to the new style.
78   Derived widgets need to overide this default handler, if:
79   - their size requisition depends on the current style.
80     (e.g., on the style's fonts)
81   - they set the background of widget->window to something other than.
82     style->bg. (e.g., GtkListItem)
83   - the widget provides windows other than widget->window.
84   - the widget has any other stored dependencies on the style.
85                    
86
87
88 Flag indications:
89
90 !GTK_RC_STYLE && !GTK_USER_STYLE:
91   The widget has its default style set, no rc lookup has been
92   performed, the widget has not been size requested yet and is
93   therefore not yet realized.
94
95 GTK_USER_STYLE:
96   GTK_RC_STYLE is not set.
97   The widget has a user style assigned, and its default style has been
98   saved.
99
100 GTK_RC_STYLE:
101   GTK_USER_STYLE is not set.
102   If the widget has a saved default style, it has been assigned an
103   rc style. If the widget does not have a saved default style, it still
104   has its default style but an rc lookup has already been performed.
105
106
107         - Tim Janik <timj@gimp.org>
108           1998/02/27