1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
24 #ifndef __GTK_STYLE_CONTEXT_H__
25 #define __GTK_STYLE_CONTEXT_H__
27 #include <glib-object.h>
28 #include <gtk/gtkstyleprovider.h>
29 #include <gtk/gtkwidgetpath.h>
30 #include <gtk/gtkborder.h>
34 #define GTK_TYPE_STYLE_CONTEXT (gtk_style_context_get_type ())
35 #define GTK_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContext))
36 #define GTK_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
37 #define GTK_IS_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_CONTEXT))
38 #define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT))
39 #define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
41 typedef struct _GtkStyleContext GtkStyleContext;
42 typedef struct _GtkStyleContextClass GtkStyleContextClass;
43 typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate;
45 struct _GtkStyleContext
47 GObject parent_object;
48 GtkStyleContextPrivate *priv;
51 struct _GtkStyleContextClass
53 GObjectClass parent_class;
55 void (* changed) (GtkStyleContext *context);
57 /* Padding for future expansion */
58 void (*_gtk_reserved1) (void);
59 void (*_gtk_reserved2) (void);
60 void (*_gtk_reserved3) (void);
61 void (*_gtk_reserved4) (void);
64 /* Default set of properties that GtkStyleContext may contain */
67 * GTK_STYLE_PROPERTY_BACKGROUND_COLOR:
69 * A property holding the background color of rendered elements as a #GdkRGBA.
71 #define GTK_STYLE_PROPERTY_BACKGROUND_COLOR "background-color"
74 * GTK_STYLE_PROPERTY_COLOR:
76 * A property holding the foreground color of rendered elements as a #GdkRGBA.
78 #define GTK_STYLE_PROPERTY_COLOR "color"
81 * GTK_STYLE_PROPERTY_FONT:
83 * A property holding the font properties used when rendering text
84 * as a #PangoFontDescription.
86 #define GTK_STYLE_PROPERTY_FONT "font"
89 * GTK_STYLE_PROPERTY_PADDING:
91 * A property holding the rendered element's padding as a #GtkBorder. The
92 * padding is defined as the spacing between the inner part of the element border
93 * and its child. It's the innermost spacing property of the padding/border/margin
96 #define GTK_STYLE_PROPERTY_PADDING "padding"
99 * GTK_STYLE_PROPERTY_BORDER_WIDTH:
101 * A property holding the rendered element's border width in pixels as
102 * a #GtkBorder. The border is the intermediary spacing property of the
103 * padding/border/margin series.
105 * gtk_render_frame() uses this property to find out the frame line width,
106 * so #GtkWidget<!-- -->s rendering frames may need to add up this padding when
109 #define GTK_STYLE_PROPERTY_BORDER_WIDTH "border-width"
112 * GTK_STYLE_PROPERTY_MARGIN:
114 * A property holding the rendered element's margin as a #GtkBorder. The
115 * margin is defined as the spacing between the border of the element
116 * and its surrounding elements. It is external to #GtkWidget<!-- -->s's
117 * size allocations, and the most external spacing property of the
118 * padding/border/margin series.
120 #define GTK_STYLE_PROPERTY_MARGIN "margin"
123 * GTK_STYLE_PROPERTY_BORDER_RADIUS:
125 * A property holding the rendered element's border radius in pixels as a #gint.
127 #define GTK_STYLE_PROPERTY_BORDER_RADIUS "border-radius"
130 * GTK_STYLE_PROPERTY_BORDER_STYLE:
132 * A property holding the element's border style as a #GtkBorderStyle.
134 #define GTK_STYLE_PROPERTY_BORDER_STYLE "border-style"
137 * GTK_STYLE_PROPERTY_BORDER_COLOR:
139 * A property holding the element's border color as a #GdkRGBA.
141 #define GTK_STYLE_PROPERTY_BORDER_COLOR "border-color"
144 * GTK_STYLE_PROPERTY_BACKGROUND_IMAGE:
146 * A property holding the element's background as a #cairo_pattern_t.
148 #define GTK_STYLE_PROPERTY_BACKGROUND_IMAGE "background-image"
151 /* Predefined set of CSS classes */
154 * GTK_STYLE_CLASS_CELL:
156 * A CSS class to match content rendered in cell views.
158 #define GTK_STYLE_CLASS_CELL "cell"
161 * GTK_STYLE_CLASS_ENTRY:
163 * A CSS class to match text entries.
165 #define GTK_STYLE_CLASS_ENTRY "entry"
168 * GTK_STYLE_CLASS_BUTTON:
170 * A CSS class to match buttons.
172 #define GTK_STYLE_CLASS_BUTTON "button"
175 * GTK_STYLE_CLASS_CALENDAR:
177 * A CSS class to match calendars.
179 #define GTK_STYLE_CLASS_CALENDAR "calendar"
182 * GTK_STYLE_CLASS_SLIDER:
184 * A CSS class to match sliders.
186 #define GTK_STYLE_CLASS_SLIDER "slider"
189 * GTK_STYLE_CLASS_BACKGROUND:
191 * A CSS class to match the window background.
193 #define GTK_STYLE_CLASS_BACKGROUND "background"
196 * GTK_STYLE_CLASS_RUBBERBAND:
198 * A CSS class to match the rubberband selection rectangle.
200 #define GTK_STYLE_CLASS_RUBBERBAND "rubberband"
203 * GTK_STYLE_CLASS_TOOLTIP:
205 * A CSS class to match tooltip windows.
207 #define GTK_STYLE_CLASS_TOOLTIP "tooltip"
210 * GTK_STYLE_CLASS_MENU:
212 * A CSS class to match popup menus.
214 #define GTK_STYLE_CLASS_MENU "menu"
217 * GTK_STYLE_CLASS_MENUBAR:
219 * A CSS class to menubars.
221 #define GTK_STYLE_CLASS_MENUBAR "menubar"
224 * GTK_STYLE_CLASS_MENUITEM:
226 * A CSS class to match menu items.
228 #define GTK_STYLE_CLASS_MENUITEM "menuitem"
231 * GTK_STYLE_CLASS_TOOLBAR:
233 * A CSS class to match toolbars.
235 #define GTK_STYLE_CLASS_TOOLBAR "toolbar"
238 * GTK_STYLE_CLASS_PRIMARY_TOOLBAR:
240 * A CSS class to match primary toolbars.
242 #define GTK_STYLE_CLASS_PRIMARY_TOOLBAR "primary-toolbar"
245 * GTK_STYLE_CLASS_INLINE_TOOLBAR:
247 * A CSS class to match inline toolbars.
249 #define GTK_STYLE_CLASS_INLINE_TOOLBAR "inline-toolbar"
252 * GTK_STYLE_CLASS_RADIO:
254 * A CSS class to match radio buttons.
256 #define GTK_STYLE_CLASS_RADIO "radio"
259 * GTK_STYLE_CLASS_CHECK:
261 * A CSS class to match check boxes.
263 #define GTK_STYLE_CLASS_CHECK "check"
266 * GTK_STYLE_CLASS_DEFAULT:
268 * A CSS class to match the default widget.
270 #define GTK_STYLE_CLASS_DEFAULT "default"
273 * GTK_STYLE_CLASS_TROUGH:
275 * A CSS class to match troughs, as in scrollbars and progressbars.
277 #define GTK_STYLE_CLASS_TROUGH "trough"
280 * GTK_STYLE_CLASS_SCROLLBAR:
282 * A CSS class to match scrollbars.
284 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
287 * GTK_STYLE_CLASS_SCALE:
289 * A CSS class to match scale widgets.
291 #define GTK_STYLE_CLASS_SCALE "scale"
294 * GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE:
296 * A CSS class to match scale widgets with marks attached,
297 * all the marks are above for horizontal #GtkScale.
298 * left for vertical #GtkScale.
300 #define GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE "scale-has-marks-above"
303 * GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW:
305 * A CSS class to match scale widgets with marks attached,
306 * all the marks are below for horizontal #GtkScale,
307 * right for vertical #GtkScale.
309 #define GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW "scale-has-marks-below"
312 * GTK_STYLE_CLASS_HEADER:
314 * A CSS class to match a header element.
316 #define GTK_STYLE_CLASS_HEADER "header"
319 * GTK_STYLE_CLASS_ACCELERATOR:
321 * A CSS class to match an accelerator.
323 #define GTK_STYLE_CLASS_ACCELERATOR "accelerator"
326 * GTK_STYLE_CLASS_RAISED:
328 * A CSS class to match a raised control, such as a raised
329 * button on a toolbar.
331 #define GTK_STYLE_CLASS_RAISED "raised"
334 * GTK_STYLE_CLASS_GRIP:
336 * A widget class defining a resize grip
338 #define GTK_STYLE_CLASS_GRIP "grip"
341 * GTK_STYLE_CLASS_DOCK:
343 * A widget class defining a dock area
345 #define GTK_STYLE_CLASS_DOCK "dock"
348 * GTK_STYLE_CLASS_PROGRESSBAR:
350 * A widget class defining a resize grip
352 #define GTK_STYLE_CLASS_PROGRESSBAR "progressbar"
355 * GTK_STYLE_CLASS_SPINNER:
357 * A widget class defining a spinner
359 #define GTK_STYLE_CLASS_SPINNER "spinner"
362 * GTK_STYLE_CLASS_MARK:
364 * A widget class defining marks in a widget, such as in scales
366 #define GTK_STYLE_CLASS_MARK "mark"
369 * GTK_STYLE_CLASS_EXPANDER:
371 * A widget class defining an expander, such as those in treeviews
373 #define GTK_STYLE_CLASS_EXPANDER "expander"
376 * GTK_STYLE_CLASS_SPINBUTTON:
378 * A widget class defining an spinbutton
380 #define GTK_STYLE_CLASS_SPINBUTTON "spinbutton"
383 * GTK_STYLE_CLASS_NOTEBOOK:
385 * A widget class defining a notebook
387 #define GTK_STYLE_CLASS_NOTEBOOK "notebook"
390 * GTK_STYLE_CLASS_VIEW:
392 * A widget class defining a view, such as iconviews or treeviews
394 #define GTK_STYLE_CLASS_VIEW "view"
397 * GTK_STYLE_CLASS_SIDEBAR:
399 * A widget class defining a sidebar
401 #define GTK_STYLE_CLASS_SIDEBAR "sidebar"
404 * GTK_STYLE_CLASS_IMAGE:
406 * A widget class defining an image, such as the icon in an entry.
408 #define GTK_STYLE_CLASS_IMAGE "image"
411 * GTK_STYLE_CLASS_HIGHLIGHT:
413 * A CSS class defining a highlighted area, such as headings in
416 #define GTK_STYLE_CLASS_HIGHLIGHT "highlight"
419 * GTK_STYLE_CLASS_FRAME:
421 * A CSS class defining a frame delimiting content, such as GtkFrame
422 * or the scrolled window frame around the scrollable area.
424 #define GTK_STYLE_CLASS_FRAME "frame"
427 * GTK_STYLE_CLASS_DND:
429 * A CSS class for a drag-and-drop indicator
431 #define GTK_STYLE_CLASS_DND "dnd"
434 * GTK_STYLE_CLASS_PANE_SEPARATOR:
436 * A CSS class for a pane separator, such as those in #GtkPaned.
438 #define GTK_STYLE_CLASS_PANE_SEPARATOR "pane-separator"
441 * GTK_STYLE_CLASS_SEPARATOR:
443 * A CSS class for a separator.
445 #define GTK_STYLE_CLASS_SEPARATOR "separator"
448 * GTK_STYLE_CLASS_INFO:
450 * A widget class for an area displaying an informational message,
451 * such as those in infobars
453 #define GTK_STYLE_CLASS_INFO "info"
456 * GTK_STYLE_CLASS_WARNING:
458 * A widget class for an area displaying a warning message,
459 * such as those in infobars
461 #define GTK_STYLE_CLASS_WARNING "warning"
464 * GTK_STYLE_CLASS_QUESTION:
466 * A widget class for an area displaying a question to the user,
467 * such as those in infobars
469 #define GTK_STYLE_CLASS_QUESTION "question"
472 * GTK_STYLE_CLASS_ERROR:
474 * A widget class for an area displaying an error message,
475 * such as those in infobars
477 #define GTK_STYLE_CLASS_ERROR "error"
480 * GTK_STYLE_CLASS_HORIZONTAL:
482 * A widget class for horizontally layered widgets.
484 #define GTK_STYLE_CLASS_HORIZONTAL "horizontal"
487 * GTK_STYLE_CLASS_VERTICAL:
489 * A widget class for vertically layered widgets.
491 #define GTK_STYLE_CLASS_VERTICAL "vertical"
494 /* Predefined set of widget regions */
497 * GTK_STYLE_REGION_ROW:
499 * A widget region name to define a treeview row.
501 #define GTK_STYLE_REGION_ROW "row"
504 * GTK_STYLE_REGION_COLUMN:
506 * A widget region name to define a treeview column.
508 #define GTK_STYLE_REGION_COLUMN "column"
511 * GTK_STYLE_REGION_COLUMN_HEADER:
513 * A widget region name to define a treeview column header.
515 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
518 * GTK_STYLE_REGION_TAB:
520 * A widget region name to define a notebook tab.
522 #define GTK_STYLE_REGION_TAB "tab"
525 GType gtk_style_context_get_type (void) G_GNUC_CONST;
527 GtkStyleContext * gtk_style_context_new (void);
529 void gtk_style_context_add_provider_for_screen (GdkScreen *screen,
530 GtkStyleProvider *provider,
532 void gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
533 GtkStyleProvider *provider);
535 void gtk_style_context_add_provider (GtkStyleContext *context,
536 GtkStyleProvider *provider,
539 void gtk_style_context_remove_provider (GtkStyleContext *context,
540 GtkStyleProvider *provider);
542 void gtk_style_context_save (GtkStyleContext *context);
543 void gtk_style_context_restore (GtkStyleContext *context);
545 void gtk_style_context_get_property (GtkStyleContext *context,
546 const gchar *property,
549 void gtk_style_context_get_valist (GtkStyleContext *context,
552 void gtk_style_context_get (GtkStyleContext *context,
554 ...) G_GNUC_NULL_TERMINATED;
556 void gtk_style_context_set_state (GtkStyleContext *context,
557 GtkStateFlags flags);
558 GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
560 gboolean gtk_style_context_state_is_running (GtkStyleContext *context,
564 void gtk_style_context_set_path (GtkStyleContext *context,
565 GtkWidgetPath *path);
566 const GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
568 GList * gtk_style_context_list_classes (GtkStyleContext *context);
570 void gtk_style_context_add_class (GtkStyleContext *context,
571 const gchar *class_name);
572 void gtk_style_context_remove_class (GtkStyleContext *context,
573 const gchar *class_name);
574 gboolean gtk_style_context_has_class (GtkStyleContext *context,
575 const gchar *class_name);
577 GList * gtk_style_context_list_regions (GtkStyleContext *context);
579 void gtk_style_context_add_region (GtkStyleContext *context,
580 const gchar *region_name,
581 GtkRegionFlags flags);
582 void gtk_style_context_remove_region (GtkStyleContext *context,
583 const gchar *region_name);
584 gboolean gtk_style_context_has_region (GtkStyleContext *context,
585 const gchar *region_name,
586 GtkRegionFlags *flags_return);
588 void gtk_style_context_get_style_property (GtkStyleContext *context,
589 const gchar *property_name,
591 void gtk_style_context_get_style_valist (GtkStyleContext *context,
593 void gtk_style_context_get_style (GtkStyleContext *context,
596 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
597 const gchar *stock_id);
598 GdkPixbuf * gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
599 GtkStyleContext *context,
602 void gtk_style_context_set_screen (GtkStyleContext *context,
604 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
606 void gtk_style_context_set_direction (GtkStyleContext *context,
607 GtkTextDirection direction);
608 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context);
610 void gtk_style_context_set_junction_sides (GtkStyleContext *context,
611 GtkJunctionSides sides);
612 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context);
614 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
615 const gchar *color_name,
618 void gtk_style_context_notify_state_change (GtkStyleContext *context,
622 gboolean state_value);
623 void gtk_style_context_cancel_animations (GtkStyleContext *context,
625 void gtk_style_context_scroll_animations (GtkStyleContext *context,
630 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
632 void gtk_style_context_pop_animatable_region (GtkStyleContext *context);
634 /* Some helper functions to retrieve most common properties */
635 void gtk_style_context_get_color (GtkStyleContext *context,
638 void gtk_style_context_get_background_color (GtkStyleContext *context,
641 void gtk_style_context_get_border_color (GtkStyleContext *context,
644 const PangoFontDescription *
645 gtk_style_context_get_font (GtkStyleContext *context,
646 GtkStateFlags state);
647 void gtk_style_context_get_border (GtkStyleContext *context,
650 void gtk_style_context_get_padding (GtkStyleContext *context,
653 void gtk_style_context_get_margin (GtkStyleContext *context,
657 void gtk_style_context_invalidate (GtkStyleContext *context);
658 void gtk_style_context_reset_widgets (GdkScreen *screen);
660 void gtk_style_context_set_background (GtkStyleContext *context,
664 void gtk_render_check (GtkStyleContext *context,
670 void gtk_render_option (GtkStyleContext *context,
676 void gtk_render_arrow (GtkStyleContext *context,
682 void gtk_render_background (GtkStyleContext *context,
688 void gtk_render_frame (GtkStyleContext *context,
694 void gtk_render_expander (GtkStyleContext *context,
700 void gtk_render_focus (GtkStyleContext *context,
706 void gtk_render_layout (GtkStyleContext *context,
710 PangoLayout *layout);
711 void gtk_render_line (GtkStyleContext *context,
717 void gtk_render_slider (GtkStyleContext *context,
723 GtkOrientation orientation);
724 void gtk_render_frame_gap (GtkStyleContext *context,
730 GtkPositionType gap_side,
733 void gtk_render_extension (GtkStyleContext *context,
739 GtkPositionType gap_side);
740 void gtk_render_handle (GtkStyleContext *context,
746 void gtk_render_activity (GtkStyleContext *context,
752 GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
753 const GtkIconSource *source,
755 void gtk_render_icon (GtkStyleContext *context,
763 #endif /* __GTK_STYLE_CONTEXT_H__ */