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_PADDING:
84 * A property holding the rendered element's padding as a #GtkBorder. The
85 * padding is defined as the spacing between the inner part of the element border
86 * and its child. It's the innermost spacing property of the padding/border/margin
89 #define GTK_STYLE_PROPERTY_PADDING "padding"
92 * GTK_STYLE_PROPERTY_BORDER_WIDTH:
94 * A property holding the rendered element's border width in pixels as
95 * a #GtkBorder. The border is the intermediary spacing property of the
96 * padding/border/margin series.
98 * gtk_render_frame() uses this property to find out the frame line width,
99 * so #GtkWidget<!-- -->s rendering frames may need to add up this padding when
102 #define GTK_STYLE_PROPERTY_BORDER_WIDTH "border-width"
105 * GTK_STYLE_PROPERTY_MARGIN:
107 * A property holding the rendered element's margin as a #GtkBorder. The
108 * margin is defined as the spacing between the border of the element
109 * and its surrounding elements. It is external to #GtkWidget<!-- -->s's
110 * size allocations, and the most external spacing property of the
111 * padding/border/margin series.
113 #define GTK_STYLE_PROPERTY_MARGIN "margin"
116 * GTK_STYLE_PROPERTY_BORDER_RADIUS:
118 * A property holding the rendered element's border radius in pixels as a #gint.
120 #define GTK_STYLE_PROPERTY_BORDER_RADIUS "border-radius"
123 * GTK_STYLE_PROPERTY_BORDER_STYLE:
125 * A property holding the element's border style as a #GtkBorderStyle.
127 #define GTK_STYLE_PROPERTY_BORDER_STYLE "border-style"
130 * GTK_STYLE_PROPERTY_BORDER_COLOR:
132 * A property holding the element's border color as a #GdkRGBA.
134 #define GTK_STYLE_PROPERTY_BORDER_COLOR "border-color"
137 * GTK_STYLE_PROPERTY_BACKGROUND_IMAGE:
139 * A property holding the element's background as a #cairo_pattern_t.
141 #define GTK_STYLE_PROPERTY_BACKGROUND_IMAGE "background-image"
144 /* Predefined set of CSS classes */
147 * GTK_STYLE_CLASS_CELL:
149 * A CSS class to match content rendered in cell views.
151 #define GTK_STYLE_CLASS_CELL "cell"
154 * GTK_STYLE_CLASS_ENTRY:
156 * A CSS class to match text entries.
158 #define GTK_STYLE_CLASS_ENTRY "entry"
161 * GTK_STYLE_CLASS_BUTTON:
163 * A CSS class to match buttons.
165 #define GTK_STYLE_CLASS_BUTTON "button"
168 * GTK_STYLE_CLASS_CALENDAR:
170 * A CSS class to match calendars.
172 #define GTK_STYLE_CLASS_CALENDAR "calendar"
175 * GTK_STYLE_CLASS_SLIDER:
177 * A CSS class to match sliders.
179 #define GTK_STYLE_CLASS_SLIDER "slider"
182 * GTK_STYLE_CLASS_BACKGROUND:
184 * A CSS class to match the window background.
186 #define GTK_STYLE_CLASS_BACKGROUND "background"
189 * GTK_STYLE_CLASS_RUBBERBAND:
191 * A CSS class to match the rubberband selection rectangle.
193 #define GTK_STYLE_CLASS_RUBBERBAND "rubberband"
196 * GTK_STYLE_CLASS_TOOLTIP:
198 * A CSS class to match tooltip windows.
200 #define GTK_STYLE_CLASS_TOOLTIP "tooltip"
203 * GTK_STYLE_CLASS_MENU:
205 * A CSS class to match popup menus.
207 #define GTK_STYLE_CLASS_MENU "menu"
210 * GTK_STYLE_CLASS_MENUBAR:
212 * A CSS class to menubars.
214 #define GTK_STYLE_CLASS_MENUBAR "menubar"
217 * GTK_STYLE_CLASS_MENUITEM:
219 * A CSS class to match menu items.
221 #define GTK_STYLE_CLASS_MENUITEM "menuitem"
224 * GTK_STYLE_CLASS_TOOLBAR:
226 * A CSS class to match toolbars.
228 #define GTK_STYLE_CLASS_TOOLBAR "toolbar"
231 * GTK_STYLE_CLASS_RADIO:
233 * A CSS class to match radio buttons.
235 #define GTK_STYLE_CLASS_RADIO "radio"
238 * GTK_STYLE_CLASS_CHECK:
240 * A CSS class to match check boxes.
242 #define GTK_STYLE_CLASS_CHECK "check"
245 * GTK_STYLE_CLASS_DEFAULT:
247 * A CSS class to match the default widget.
249 #define GTK_STYLE_CLASS_DEFAULT "default"
252 * GTK_STYLE_CLASS_TROUGH:
254 * A CSS class to match troughs, as in scrollbars and progressbars.
256 #define GTK_STYLE_CLASS_TROUGH "trough"
259 * GTK_STYLE_CLASS_SCROLLBAR:
261 * A CSS class to match scrollbars.
263 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
266 * GTK_STYLE_CLASS_SCALE:
268 * A CSS class to match scale widgets.
270 #define GTK_STYLE_CLASS_SCALE "scale"
273 * GTK_STYLE_CLASS_HEADER:
275 * A CSS class to match a header element.
277 #define GTK_STYLE_CLASS_HEADER "header"
280 * GTK_STYLE_CLASS_ACCELERATOR:
282 * A CSS class to match an accelerator.
284 #define GTK_STYLE_CLASS_ACCELERATOR "accelerator"
287 * GTK_STYLE_CLASS_GRIP:
289 * A widget class defining a resize grip
291 #define GTK_STYLE_CLASS_GRIP "grip"
294 * GTK_STYLE_CLASS_DOCK:
296 * A widget class defining a dock area
298 #define GTK_STYLE_CLASS_DOCK "dock"
301 * GTK_STYLE_CLASS_PROGRESSBAR:
303 * A widget class defining a resize grip
305 #define GTK_STYLE_CLASS_PROGRESSBAR "progressbar"
308 * GTK_STYLE_CLASS_SPINNER:
310 * A widget class defining a spinner
312 #define GTK_STYLE_CLASS_SPINNER "spinner"
315 * GTK_STYLE_CLASS_MARK:
317 * A widget class defining marks in a widget, such as in scales
319 #define GTK_STYLE_CLASS_MARK "mark"
322 * GTK_STYLE_CLASS_EXPANDER:
324 * A widget class defining an expander, such as those in treeviews
326 #define GTK_STYLE_CLASS_EXPANDER "expander"
329 * GTK_STYLE_CLASS_SPINBUTTON:
331 * A widget class defining an spinbutton
333 #define GTK_STYLE_CLASS_SPINBUTTON "spinbutton"
336 * GTK_STYLE_CLASS_NOTEBOOK:
338 * A widget class defining a notebook
340 #define GTK_STYLE_CLASS_NOTEBOOK "notebook"
343 * GTK_STYLE_CLASS_VIEW:
345 * A widget class defining a view, such as iconviews or treeviews
347 #define GTK_STYLE_CLASS_VIEW "view"
350 * GTK_STYLE_CLASS_HIGHLIGHT:
352 * A CSS class defining a highlighted area, such as headings in
355 #define GTK_STYLE_CLASS_HIGHLIGHT "highlight"
358 * GTK_STYLE_CLASS_FRAME:
360 * A CSS class defining a frame delimiting content, such as GtkFrame
361 * or the scrolled window frame around the scrollable area.
363 #define GTK_STYLE_CLASS_FRAME "frame"
366 * GTK_STYLE_CLASS_DND:
368 * A CSS class for a drag-and-drop indicator
370 #define GTK_STYLE_CLASS_DND "dnd"
373 * GTK_STYLE_CLASS_PANE_SEPARATOR:
375 * A CSS class for a pane separator, such as those in #GtkPaned.
377 #define GTK_STYLE_CLASS_PANE_SEPARATOR "pane-separator"
380 * GTK_STYLE_CLASS_INFO:
382 * A widget class for an area displaying an informational message,
383 * such as those in infobars
385 #define GTK_STYLE_CLASS_INFO "info"
388 * GTK_STYLE_CLASS_WARNING:
390 * A widget class for an area displaying a warning message,
391 * such as those in infobars
393 #define GTK_STYLE_CLASS_WARNING "warning"
396 * GTK_STYLE_CLASS_QUESTION:
398 * A widget class for an area displaying a question to the user,
399 * such as those in infobars
401 #define GTK_STYLE_CLASS_QUESTION "question"
404 * GTK_STYLE_CLASS_ERROR:
406 * A widget class for an area displaying an error message,
407 * such as those in infobars
409 #define GTK_STYLE_CLASS_ERROR "error"
412 * GTK_STYLE_CLASS_HORIZONTAL:
414 * A widget class for horizontally layered widgets.
416 #define GTK_STYLE_CLASS_HORIZONTAL "horizontal"
419 * GTK_STYLE_CLASS_VERTICAL:
421 * A widget class for vertically layered widgets.
423 #define GTK_STYLE_CLASS_VERTICAL "vertical"
426 /* Predefined set of widget regions */
429 * GTK_STYLE_REGION_ROW:
431 * A widget region name to define a treeview row.
433 #define GTK_STYLE_REGION_ROW "row"
436 * GTK_STYLE_REGION_COLUMN:
438 * A widget region name to define a treeview column.
440 #define GTK_STYLE_REGION_COLUMN "column"
443 * GTK_STYLE_REGION_COLUMN_HEADER:
445 * A widget region name to define a treeview column header.
447 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
450 * GTK_STYLE_REGION_TAB:
452 * A widget region name to define a notebook tab.
454 #define GTK_STYLE_REGION_TAB "tab"
457 GType gtk_style_context_get_type (void) G_GNUC_CONST;
459 GtkStyleContext * gtk_style_context_new (void);
461 void gtk_style_context_add_provider_for_screen (GdkScreen *screen,
462 GtkStyleProvider *provider,
464 void gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
465 GtkStyleProvider *provider);
467 void gtk_style_context_add_provider (GtkStyleContext *context,
468 GtkStyleProvider *provider,
471 void gtk_style_context_remove_provider (GtkStyleContext *context,
472 GtkStyleProvider *provider);
474 void gtk_style_context_save (GtkStyleContext *context);
475 void gtk_style_context_restore (GtkStyleContext *context);
477 void gtk_style_context_get_property (GtkStyleContext *context,
478 const gchar *property,
481 void gtk_style_context_get_valist (GtkStyleContext *context,
484 void gtk_style_context_get (GtkStyleContext *context,
486 ...) G_GNUC_NULL_TERMINATED;
488 void gtk_style_context_set_state (GtkStyleContext *context,
489 GtkStateFlags flags);
490 GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
492 gboolean gtk_style_context_state_is_running (GtkStyleContext *context,
496 void gtk_style_context_set_path (GtkStyleContext *context,
497 GtkWidgetPath *path);
498 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
500 GList * gtk_style_context_list_classes (GtkStyleContext *context);
502 void gtk_style_context_add_class (GtkStyleContext *context,
503 const gchar *class_name);
504 void gtk_style_context_remove_class (GtkStyleContext *context,
505 const gchar *class_name);
506 gboolean gtk_style_context_has_class (GtkStyleContext *context,
507 const gchar *class_name);
509 GList * gtk_style_context_list_regions (GtkStyleContext *context);
511 void gtk_style_context_add_region (GtkStyleContext *context,
512 const gchar *region_name,
513 GtkRegionFlags flags);
514 void gtk_style_context_remove_region (GtkStyleContext *context,
515 const gchar *region_name);
516 gboolean gtk_style_context_has_region (GtkStyleContext *context,
517 const gchar *region_name,
518 GtkRegionFlags *flags_return);
520 void gtk_style_context_get_style_property (GtkStyleContext *context,
521 const gchar *property_name,
523 void gtk_style_context_get_style_valist (GtkStyleContext *context,
525 void gtk_style_context_get_style (GtkStyleContext *context,
528 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
529 const gchar *stock_id);
530 GdkPixbuf * gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
531 GtkStyleContext *context,
534 void gtk_style_context_set_screen (GtkStyleContext *context,
536 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
538 void gtk_style_context_set_direction (GtkStyleContext *context,
539 GtkTextDirection direction);
540 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context);
542 void gtk_style_context_set_junction_sides (GtkStyleContext *context,
543 GtkJunctionSides sides);
544 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context);
546 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
547 const gchar *color_name,
550 void gtk_style_context_notify_state_change (GtkStyleContext *context,
554 gboolean state_value);
555 void gtk_style_context_cancel_animations (GtkStyleContext *context,
557 void gtk_style_context_scroll_animations (GtkStyleContext *context,
562 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
564 void gtk_style_context_pop_animatable_region (GtkStyleContext *context);
566 /* Some helper functions to retrieve most common properties */
567 void gtk_style_context_get_color (GtkStyleContext *context,
570 void gtk_style_context_get_background_color (GtkStyleContext *context,
573 void gtk_style_context_get_border_color (GtkStyleContext *context,
577 const PangoFontDescription * gtk_style_context_get_font (GtkStyleContext *context,
578 GtkStateFlags state);
580 void gtk_style_context_get_border (GtkStyleContext *context,
583 void gtk_style_context_get_padding (GtkStyleContext *context,
586 void gtk_style_context_get_margin (GtkStyleContext *context,
590 /* Semi-private API */
591 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
595 void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
596 void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
598 gboolean _gtk_style_context_check_region_name (const gchar *str);
601 void gtk_style_context_invalidate (GtkStyleContext *context);
602 void gtk_style_context_reset_widgets (GdkScreen *screen);
604 void gtk_style_context_set_background (GtkStyleContext *context,
608 void gtk_render_check (GtkStyleContext *context,
614 void gtk_render_option (GtkStyleContext *context,
620 void gtk_render_arrow (GtkStyleContext *context,
626 void gtk_render_background (GtkStyleContext *context,
632 void gtk_render_frame (GtkStyleContext *context,
638 void gtk_render_expander (GtkStyleContext *context,
644 void gtk_render_focus (GtkStyleContext *context,
650 void gtk_render_layout (GtkStyleContext *context,
654 PangoLayout *layout);
655 void gtk_render_line (GtkStyleContext *context,
661 void gtk_render_slider (GtkStyleContext *context,
667 GtkOrientation orientation);
668 void gtk_render_frame_gap (GtkStyleContext *context,
674 GtkPositionType gap_side,
677 void gtk_render_extension (GtkStyleContext *context,
683 GtkPositionType gap_side);
684 void gtk_render_handle (GtkStyleContext *context,
690 void gtk_render_activity (GtkStyleContext *context,
697 GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
698 const GtkIconSource *source,
703 #endif /* __GTK_STYLE_CONTEXT_H__ */