]> Pileus Git - ~andy/gtk/blob - docs/styles.txt
stylecontext: Do invalidation on first resize container
[~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_reset_rc_styles ()
23   Descends through a widget hierarchy and sets the rc style
24   on all widgets that don't have a user style set.
25
26 gtk_widget_ensure_style ()
27   Ensure that the widget either has a user style set, or an rc lookup
28   has been performed.
29
30 gtk_rc_get_style ()
31   Return an rc style for a widget if there is one.
32
33 gtk_widget_set_name ()
34   Change widget name, and perform a new rc lookup if no user style
35   is set.
36
37 gtk_widget_realize ()
38   Besides realizing the widget this function will:
39   - perform an rc lookup if necessary,
40   - attach a widget's style.
41
42 gtk_widget_get_style ()
43   Return a widgets style, this function will perform an rc lookup
44   if necessary.
45
46 gtk_widget_set_parent ()
47   This function will perform rc lookups recursively for all widgets
48   that do not have a user style set.
49
50 gtk_style_copy ()
51   This function can be used to copy a widget's style.
52   The style can subsequently be changed (e.g., by modifications to the
53   red/green/blue values of a certain color) and then be applied to the
54   widget via gtk_widget_set_style().
55
56
57 GtkWidget::style_set
58   This signal will be emitted for a widget once its style changes with
59   an additional argument previous_style which will hold the widget->style
60   value from a previous emission.
61   The initial emission of this signal is guaranteed to happen prior
62   to any GtkWidget::size_request emission, and will have the previous_style
63   argument set to NULL.
64   The GtkWidgetClass implements a default handler for this signal that
65   will set the widget's window's background of widgets that provide their
66   own windows according to the new style.
67   Derived widgets need to override this default handler, if:
68   - their size requisition depends on the current style.
69     (e.g., on the style's fonts)
70   - they set the background of widget->window to something other than.
71     style->bg. (e.g., GtkListItem)
72   - the widget provides windows other than widget->window.
73   - the widget has any other stored dependencies on the style.
74                    
75
76
77 Flag indications:
78
79 !GTK_RC_STYLE && !GTK_USER_STYLE:
80   The widget has its default style set, no rc lookup has been
81   performed, the widget has not been size requested yet and is
82   therefore not yet realized.
83
84 GTK_USER_STYLE:
85   GTK_RC_STYLE is not set.
86   The widget has a user style assigned, and its default style has been
87   saved.
88
89 GTK_RC_STYLE:
90   GTK_USER_STYLE is not set.
91   If the widget has a saved default style, it has been assigned an
92   rc style. If the widget does not have a saved default style, it still
93   has its default style but an rc lookup has already been performed.
94
95
96         - Tim Janik <timj@gimp.org>
97           1998/02/27