styles.txt 3.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
HANDLING WIDGET STYLES
======================


A widget gets created with a default style.
The global default style can be affected by gtk_widget_set_default_style()
and can be queried by gtk_widget_get_default_style().
The initial style that is assigned to a widget as default style upon
creation can be affected by wrapping the widget's creation as follows:
gtk_widget_push_style (my_style);
widget = gtk_type_new (gtk_button_get_type ());
gtk_widget_pop_style ();

There are certain functions to affect widget styles after a widget's
creation:

gtk_widget_set_style ()
  Save the default style and set a user style.
  This will override a previously set user style or
  previously set rc styles.

22
gtk_widget_reset_rc_styles ()
23
  Descends through a widget hierarchy and sets the rc style
24 25
  on all widgets that don't have a user style set.

26
gtk_widget_ensure_style ()
27
  Ensure that the widget either has a user style set, or an rc lookup
28 29 30 31 32 33 34 35 36 37 38
  has been performed.

gtk_rc_get_style ()
  Return an rc style for a widget if there is one.

gtk_widget_set_name ()
  Change widget name, and perform a new rc lookup if no user style
  is set.

gtk_widget_realize ()
  Besides realizing the widget this function will:
39
  - perform an rc lookup if necessary,
40 41 42 43
  - attach a widget's style.

gtk_widget_get_style ()
  Return a widgets style, this function will perform an rc lookup
44
  if necessary.
45 46 47 48 49 50

gtk_widget_set_parent ()
  This function will perform rc lookups recursively for all widgets
  that do not have a user style set.

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 54 55 56 57
  red/green/blue values of a certain color) and then be applied to the
  widget via gtk_widget_set_style().


GtkWidget::style_set
58
  This signal will be emitted for a widget once its style changes with
59 60
  an additional argument previous_style which will hold the widget->style
  value from a previous emission.
61 62 63 64 65 66
  The initial emission of this signal is guaranteed to happen prior
  to any GtkWidget::size_request emission, and will have the previous_style
  argument set to NULL.
  The GtkWidgetClass implements a default handler for this signal that
  will set the widget's window's background of widgets that provide their
  own windows according to the new style.
67
  Derived widgets need to override this default handler, if:
68 69 70 71 72 73
  - their size requisition depends on the current style.
    (e.g., on the style's fonts)
  - they set the background of widget->window to something other than.
    style->bg. (e.g., GtkListItem)
  - the widget provides windows other than widget->window.
  - the widget has any other stored dependencies on the style.
74 75 76 77 78 79
                   


Flag indications:

!GTK_RC_STYLE && !GTK_USER_STYLE:
80
  The widget has its default style set, no rc lookup has been
81 82
  performed, the widget has not been size requested yet and is
  therefore not yet realized.
83 84 85

GTK_USER_STYLE:
  GTK_RC_STYLE is not set.
86
  The widget has a user style assigned, and its default style has been
87 88 89 90 91
  saved.

GTK_RC_STYLE:
  GTK_USER_STYLE is not set.
  If the widget has a saved default style, it has been assigned an
92 93
  rc style. If the widget does not have a saved default style, it still
  has its default style but an rc lookup has already been performed.
94 95 96 97


	- Tim Janik <timj@gimp.org>
	  1998/02/27