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;
44 struct _GtkStyleContext
46 GObject parent_object;
50 struct _GtkStyleContextClass
52 GObjectClass parent_class;
54 void (* changed) (GtkStyleContext *context);
57 /* Default set of properties that GtkStyleContext may contain */
60 * GTK_STYLE_PROPERTY_BACKGROUND_COLOR:
62 * A property holding the background color of rendered elements as a #GdkRGBA.
64 #define GTK_STYLE_PROPERTY_BACKGROUND_COLOR "background-color"
67 * GTK_STYLE_PROPERTY_COLOR:
69 * A property holding the foreground color of rendered elements as a #GdkRGBA.
71 #define GTK_STYLE_PROPERTY_COLOR "color"
74 * GTK_STYLE_PROPERTY_FONT:
76 * A property holding the font properties used when rendering text
77 * as a #PangoFontDescription.
79 #define GTK_STYLE_PROPERTY_FONT "font"
82 * GTK_STYLE_PROPERTY_MARGIN:
84 * A property holding the rendered element's margin as a #GtkBorder. The
85 * margin is defined as the spacing between the border of the element
86 * and its surrounding elements.
88 #define GTK_STYLE_PROPERTY_MARGIN "margin"
91 * GTK_STYLE_PROPERTY_PADDING:
93 * A property holding the rendered element's padding as a #GtkBorder. The
94 * padding is defined as the spacing between the inner part of the element border
97 #define GTK_STYLE_PROPERTY_PADDING "padding"
100 * GTK_STYLE_PROPERTY_BORDER_WIDTH:
102 * A property holding the rendered element's border width in pixels as a #gint.
104 #define GTK_STYLE_PROPERTY_BORDER_WIDTH "border-width"
107 * GTK_STYLE_PROPERTY_BORDER_RADIUS:
109 * A property holding the rendered element's border radius in pixels as a #gint.
111 #define GTK_STYLE_PROPERTY_BORDER_RADIUS "border-radius"
114 * GTK_STYLE_PROPERTY_BORDER_STYLE:
116 * A property holding the element's border style as a #GtkBorderStyle.
118 #define GTK_STYLE_PROPERTY_BORDER_STYLE "border-style"
121 * GTK_STYLE_PROPERTY_BORDER_COLOR:
123 * A property holding the element's border color as a #GdkRGBA.
125 #define GTK_STYLE_PROPERTY_BORDER_COLOR "border-color"
128 * GTK_STYLE_PROPERTY_BACKGROUND_IMAGE:
130 * A property holding the element's background as a #cairo_pattern_t.
132 #define GTK_STYLE_PROPERTY_BACKGROUND_IMAGE "background-image"
135 /* Predefined set of CSS classes */
138 * GTK_STYLE_CLASS_CELL:
140 * A CSS class to match content rendered in cell views.
142 #define GTK_STYLE_CLASS_CELL "cell"
145 * GTK_STYLE_CLASS_ENTRY:
147 * A CSS class to match text entries.
149 #define GTK_STYLE_CLASS_ENTRY "entry"
152 * GTK_STYLE_CLASS_BUTTON:
154 * A CSS class to match buttons.
156 #define GTK_STYLE_CLASS_BUTTON "button"
159 * GTK_STYLE_CLASS_CALENDAR:
161 * A CSS class to match calendars.
163 #define GTK_STYLE_CLASS_CALENDAR "calendar"
166 * GTK_STYLE_CLASS_SLIDER:
168 * A CSS class to match sliders.
170 #define GTK_STYLE_CLASS_SLIDER "slider"
173 * GTK_STYLE_CLASS_BACKGROUND:
175 * A CSS class to match the window background.
177 #define GTK_STYLE_CLASS_BACKGROUND "background"
180 * GTK_STYLE_CLASS_RUBBERBAND:
182 * A CSS class to match the rubberband selection rectangle.
184 #define GTK_STYLE_CLASS_RUBBERBAND "rubberband"
187 * GTK_STYLE_CLASS_TOOLTIP:
189 * A CSS class to match tooltip windows.
191 #define GTK_STYLE_CLASS_TOOLTIP "tooltip"
194 * GTK_STYLE_CLASS_MENU:
196 * A CSS class to match popup menus.
198 #define GTK_STYLE_CLASS_MENU "menu"
201 * GTK_STYLE_CLASS_MENUBAR:
203 * A CSS class to menubars.
205 #define GTK_STYLE_CLASS_MENUBAR "menubar"
208 * GTK_STYLE_CLASS_MENUITEM:
210 * A CSS class to match menu items.
212 #define GTK_STYLE_CLASS_MENUITEM "menuitem"
215 * GTK_STYLE_CLASS_TOOLBAR:
217 * A CSS class to match toolbars.
219 #define GTK_STYLE_CLASS_TOOLBAR "toolbar"
222 * GTK_STYLE_CLASS_RADIO:
224 * A CSS class to match radio buttons.
226 #define GTK_STYLE_CLASS_RADIO "radio"
229 * GTK_STYLE_CLASS_CHECK:
231 * A CSS class to match check boxes.
233 #define GTK_STYLE_CLASS_CHECK "check"
236 * GTK_STYLE_CLASS_DEFAULT:
238 * A CSS class to match the default widget.
240 #define GTK_STYLE_CLASS_DEFAULT "default"
243 * GTK_STYLE_CLASS_TROUGH:
245 * A CSS class to match troughs, as in scrollbars and progressbars.
247 #define GTK_STYLE_CLASS_TROUGH "trough"
250 * GTK_STYLE_CLASS_SCROLLBAR:
252 * A CSS class to match scrollbars.
254 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
257 * GTK_STYLE_CLASS_SCALE:
259 * A CSS class to match scale widgets.
261 #define GTK_STYLE_CLASS_SCALE "scale"
264 * GTK_STYLE_CLASS_HEADER:
266 * A CSS class to match a header element.
268 #define GTK_STYLE_CLASS_HEADER "header"
271 * GTK_STYLE_CLASS_ACCELERATOR:
273 * A CSS class to match an accelerator.
275 #define GTK_STYLE_CLASS_ACCELERATOR "accelerator"
278 * GTK_STYLE_CLASS_GRIP:
280 * A widget class defining a resize grip
282 #define GTK_STYLE_CLASS_GRIP "grip"
285 * GTK_STYLE_CLASS_DOCK:
287 * A widget class defining a dock area
289 #define GTK_STYLE_CLASS_DOCK "dock"
292 * GTK_STYLE_CLASS_PROGRESSBAR:
294 * A widget class defining a resize grip
296 #define GTK_STYLE_CLASS_PROGRESSBAR "progressbar"
299 * GTK_STYLE_CLASS_SPINNER:
301 * A widget class defining a spinner
303 #define GTK_STYLE_CLASS_SPINNER "spinner"
306 * GTK_STYLE_CLASS_MARK:
308 * A widget class defining marks in a widget, such as in scales
310 #define GTK_STYLE_CLASS_MARK "mark"
313 * GTK_STYLE_CLASS_EXPANDER:
315 * A widget class defining an expander, such as those in treeviews
317 #define GTK_STYLE_CLASS_EXPANDER "expander"
320 * GTK_STYLE_CLASS_SPINBUTTON:
322 * A widget class defining an spinbutton
324 #define GTK_STYLE_CLASS_SPINBUTTON "spinbutton"
327 * GTK_STYLE_CLASS_NOTEBOOK:
329 * A widget class defining a notebook
331 #define GTK_STYLE_CLASS_NOTEBOOK "notebook"
334 * GTK_STYLE_CLASS_VIEW:
336 * A widget class defining a view, such as iconviews or treeviews
338 #define GTK_STYLE_CLASS_VIEW "view"
341 * GTK_STYLE_CLASS_INFO:
343 * A widget class for an area displaying an informational message,
344 * such as those in infobars
346 #define GTK_STYLE_CLASS_INFO "info"
349 * GTK_STYLE_CLASS_WARNING:
351 * A widget class for an area displaying a warning message,
352 * such as those in infobars
354 #define GTK_STYLE_CLASS_WARNING "warning"
357 * GTK_STYLE_CLASS_QUESTION:
359 * A widget class for an area displaying a question to the user,
360 * such as those in infobars
362 #define GTK_STYLE_CLASS_QUESTION "question"
365 * GTK_STYLE_CLASS_ERROR:
367 * A widget class for an area displaying an error message,
368 * such as those in infobars
370 #define GTK_STYLE_CLASS_ERROR "error"
373 /* Predefined set of widget regions */
376 * GTK_STYLE_REGION_ROW:
378 * A widget region name to define a treeview row.
380 #define GTK_STYLE_REGION_ROW "row"
383 * GTK_STYLE_REGION_COLUMN:
385 * A widget region name to define a treeview column.
387 #define GTK_STYLE_REGION_COLUMN "column"
390 * GTK_STYLE_REGION_COLUMN_HEADER:
392 * A widget region name to define a treeview column header.
394 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
397 * GTK_STYLE_REGION_TAB:
399 * A widget region name to define a notebook tab.
401 #define GTK_STYLE_REGION_TAB "tab"
404 GType gtk_style_context_get_type (void) G_GNUC_CONST;
406 GtkStyleContext * gtk_style_context_new (void);
408 void gtk_style_context_add_provider_for_screen (GdkScreen *screen,
409 GtkStyleProvider *provider,
411 void gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
412 GtkStyleProvider *provider);
414 void gtk_style_context_add_provider (GtkStyleContext *context,
415 GtkStyleProvider *provider,
418 void gtk_style_context_remove_provider (GtkStyleContext *context,
419 GtkStyleProvider *provider);
421 void gtk_style_context_save (GtkStyleContext *context);
422 void gtk_style_context_restore (GtkStyleContext *context);
424 void gtk_style_context_get_property (GtkStyleContext *context,
425 const gchar *property,
428 void gtk_style_context_get_valist (GtkStyleContext *context,
431 void gtk_style_context_get (GtkStyleContext *context,
433 ...) G_GNUC_NULL_TERMINATED;
435 void gtk_style_context_set_state (GtkStyleContext *context,
436 GtkStateFlags flags);
437 GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
439 gboolean gtk_style_context_state_is_running (GtkStyleContext *context,
443 void gtk_style_context_set_path (GtkStyleContext *context,
444 GtkWidgetPath *path);
445 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
447 GList * gtk_style_context_list_classes (GtkStyleContext *context);
449 void gtk_style_context_add_class (GtkStyleContext *context,
450 const gchar *class_name);
451 void gtk_style_context_remove_class (GtkStyleContext *context,
452 const gchar *class_name);
453 gboolean gtk_style_context_has_class (GtkStyleContext *context,
454 const gchar *class_name);
456 GList * gtk_style_context_list_regions (GtkStyleContext *context);
458 void gtk_style_context_add_region (GtkStyleContext *context,
459 const gchar *region_name,
460 GtkRegionFlags flags);
461 void gtk_style_context_remove_region (GtkStyleContext *context,
462 const gchar *region_name);
463 gboolean gtk_style_context_has_region (GtkStyleContext *context,
464 const gchar *region_name,
465 GtkRegionFlags *flags_return);
467 void gtk_style_context_get_style_property (GtkStyleContext *context,
468 const gchar *property_name,
470 void gtk_style_context_get_style_valist (GtkStyleContext *context,
472 void gtk_style_context_get_style (GtkStyleContext *context,
475 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
476 const gchar *stock_id);
477 GdkPixbuf * gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
478 GtkStyleContext *context,
481 void gtk_style_context_set_screen (GtkStyleContext *context,
483 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
485 void gtk_style_context_set_direction (GtkStyleContext *context,
486 GtkTextDirection direction);
487 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context);
489 void gtk_style_context_set_junction_sides (GtkStyleContext *context,
490 GtkJunctionSides sides);
491 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context);
493 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
494 const gchar *color_name,
497 void gtk_style_context_notify_state_change (GtkStyleContext *context,
501 gboolean state_value);
502 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
504 void gtk_style_context_pop_animatable_region (GtkStyleContext *context);
506 /* Some helper functions to retrieve most common properties */
507 void gtk_style_context_get_color (GtkStyleContext *context,
510 void gtk_style_context_get_background_color (GtkStyleContext *context,
513 void gtk_style_context_get_border_color (GtkStyleContext *context,
517 const PangoFontDescription * gtk_style_context_get_font (GtkStyleContext *context,
518 GtkStateFlags state);
520 void gtk_style_context_get_border (GtkStyleContext *context,
523 void gtk_style_context_get_padding (GtkStyleContext *context,
526 void gtk_style_context_get_margin (GtkStyleContext *context,
530 /* Semi-private API */
531 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
535 void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
536 void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
539 void gtk_style_context_invalidate (GtkStyleContext *context);
540 void gtk_style_context_reset_widgets (GdkScreen *screen);
542 void gtk_style_context_set_background (GtkStyleContext *context,
546 void gtk_render_check (GtkStyleContext *context,
552 void gtk_render_option (GtkStyleContext *context,
558 void gtk_render_arrow (GtkStyleContext *context,
564 void gtk_render_background (GtkStyleContext *context,
570 void gtk_render_frame (GtkStyleContext *context,
576 void gtk_render_expander (GtkStyleContext *context,
582 void gtk_render_focus (GtkStyleContext *context,
588 void gtk_render_layout (GtkStyleContext *context,
592 PangoLayout *layout);
593 void gtk_render_line (GtkStyleContext *context,
599 void gtk_render_slider (GtkStyleContext *context,
605 GtkOrientation orientation);
606 void gtk_render_frame_gap (GtkStyleContext *context,
612 GtkPositionType gap_side,
615 void gtk_render_extension (GtkStyleContext *context,
621 GtkPositionType gap_side);
622 void gtk_render_handle (GtkStyleContext *context,
628 void gtk_render_activity (GtkStyleContext *context,
635 GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
636 const GtkIconSource *source,
641 #endif /* __GTK_STYLE_CONTEXT_H__ */