]> Pileus Git - ~andy/gtk/blob - gtk/gtkstylecontext.h
Make DnD code use GtkStyleContext for the highlight rectangle.
[~andy/gtk] / gtk / gtkstylecontext.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
22 #endif
23
24 #ifndef __GTK_STYLE_CONTEXT_H__
25 #define __GTK_STYLE_CONTEXT_H__
26
27 #include <glib-object.h>
28 #include <gtk/gtkstyleprovider.h>
29 #include <gtk/gtkwidgetpath.h>
30 #include <gtk/gtkborder.h>
31
32 G_BEGIN_DECLS
33
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))
40
41 typedef struct _GtkStyleContext GtkStyleContext;
42 typedef struct _GtkStyleContextClass GtkStyleContextClass;
43
44 struct _GtkStyleContext
45 {
46   GObject parent_object;
47   gpointer priv;
48 };
49
50 struct _GtkStyleContextClass
51 {
52   GObjectClass parent_class;
53
54   void (* changed) (GtkStyleContext *context);
55 };
56
57 /* Default set of properties that GtkStyleContext may contain */
58
59 /**
60  * GTK_STYLE_PROPERTY_BACKGROUND_COLOR:
61  *
62  * A property holding the background color of rendered elements as a #GdkRGBA.
63  */
64 #define GTK_STYLE_PROPERTY_BACKGROUND_COLOR "background-color"
65
66 /**
67  * GTK_STYLE_PROPERTY_COLOR:
68  *
69  * A property holding the foreground color of rendered elements as a #GdkRGBA.
70  */
71 #define GTK_STYLE_PROPERTY_COLOR "color"
72
73 /**
74  * GTK_STYLE_PROPERTY_FONT:
75  *
76  * A property holding the font properties used when rendering text
77  * as a #PangoFontDescription.
78  */
79 #define GTK_STYLE_PROPERTY_FONT "font"
80
81 /**
82  * GTK_STYLE_PROPERTY_MARGIN:
83  *
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.
87  */
88 #define GTK_STYLE_PROPERTY_MARGIN "margin"
89
90 /**
91  * GTK_STYLE_PROPERTY_PADDING:
92  *
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
95  * and its child.
96  */
97 #define GTK_STYLE_PROPERTY_PADDING "padding"
98
99 /**
100  * GTK_STYLE_PROPERTY_BORDER_WIDTH:
101  *
102  * A property holding the rendered element's border width in pixels as a #gint.
103  */
104 #define GTK_STYLE_PROPERTY_BORDER_WIDTH "border-width"
105
106 /**
107  * GTK_STYLE_PROPERTY_BORDER_RADIUS:
108  *
109  * A property holding the rendered element's border radius in pixels as a #gint.
110  */
111 #define GTK_STYLE_PROPERTY_BORDER_RADIUS "border-radius"
112
113 /**
114  * GTK_STYLE_PROPERTY_BORDER_STYLE:
115  *
116  * A property holding the element's border style as a #GtkBorderStyle.
117  */
118 #define GTK_STYLE_PROPERTY_BORDER_STYLE "border-style"
119
120 /**
121  * GTK_STYLE_PROPERTY_BORDER_COLOR:
122  *
123  * A property holding the element's border color as a #GdkRGBA.
124  */
125 #define GTK_STYLE_PROPERTY_BORDER_COLOR "border-color"
126
127 /**
128  * GTK_STYLE_PROPERTY_BACKGROUND_IMAGE:
129  *
130  * A property holding the element's background as a #cairo_pattern_t.
131  */
132 #define GTK_STYLE_PROPERTY_BACKGROUND_IMAGE "background-image"
133
134
135 /* Predefined set of CSS classes */
136
137 /**
138  * GTK_STYLE_CLASS_CELL:
139  *
140  * A CSS class to match content rendered in cell views.
141  */
142 #define GTK_STYLE_CLASS_CELL "cell"
143
144 /**
145  * GTK_STYLE_CLASS_ENTRY:
146  *
147  * A CSS class to match text entries.
148  */
149 #define GTK_STYLE_CLASS_ENTRY "entry"
150
151 /**
152  * GTK_STYLE_CLASS_BUTTON:
153  *
154  * A CSS class to match buttons.
155  */
156 #define GTK_STYLE_CLASS_BUTTON "button"
157
158 /**
159  * GTK_STYLE_CLASS_CALENDAR:
160  *
161  * A CSS class to match calendars.
162  */
163 #define GTK_STYLE_CLASS_CALENDAR "calendar"
164
165 /**
166  * GTK_STYLE_CLASS_SLIDER:
167  *
168  * A CSS class to match sliders.
169  */
170 #define GTK_STYLE_CLASS_SLIDER "slider"
171
172 /**
173  * GTK_STYLE_CLASS_BACKGROUND:
174  *
175  * A CSS class to match the window background.
176  */
177 #define GTK_STYLE_CLASS_BACKGROUND "background"
178
179 /**
180  * GTK_STYLE_CLASS_RUBBERBAND:
181  *
182  * A CSS class to match the rubberband selection rectangle.
183  */
184 #define GTK_STYLE_CLASS_RUBBERBAND "rubberband"
185
186 /**
187  * GTK_STYLE_CLASS_TOOLTIP:
188  *
189  * A CSS class to match tooltip windows.
190  */
191 #define GTK_STYLE_CLASS_TOOLTIP "tooltip"
192
193 /**
194  * GTK_STYLE_CLASS_MENU:
195  *
196  * A CSS class to match popup menus.
197  */
198 #define GTK_STYLE_CLASS_MENU "menu"
199
200 /**
201  * GTK_STYLE_CLASS_MENUBAR:
202  *
203  * A CSS class to menubars.
204  */
205 #define GTK_STYLE_CLASS_MENUBAR "menubar"
206
207 /**
208  * GTK_STYLE_CLASS_MENUITEM:
209  *
210  * A CSS class to match menu items.
211  */
212 #define GTK_STYLE_CLASS_MENUITEM "menuitem"
213
214 /**
215  * GTK_STYLE_CLASS_TOOLBAR:
216  *
217  * A CSS class to match toolbars.
218  */
219 #define GTK_STYLE_CLASS_TOOLBAR "toolbar"
220
221 /**
222  * GTK_STYLE_CLASS_RADIO:
223  *
224  * A CSS class to match radio buttons.
225  */
226 #define GTK_STYLE_CLASS_RADIO "radio"
227
228 /**
229  * GTK_STYLE_CLASS_CHECK:
230  *
231  * A CSS class to match check boxes.
232  */
233 #define GTK_STYLE_CLASS_CHECK "check"
234
235 /**
236  * GTK_STYLE_CLASS_DEFAULT:
237  *
238  * A CSS class to match the default widget.
239  */
240 #define GTK_STYLE_CLASS_DEFAULT "default"
241
242 /**
243  * GTK_STYLE_CLASS_TROUGH:
244  *
245  * A CSS class to match troughs, as in scrollbars and progressbars.
246  */
247 #define GTK_STYLE_CLASS_TROUGH "trough"
248
249 /**
250  * GTK_STYLE_CLASS_SCROLLBAR:
251  *
252  * A CSS class to match scrollbars.
253  */
254 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
255
256 /**
257  * GTK_STYLE_CLASS_SCALE:
258  *
259  * A CSS class to match scale widgets.
260  */
261 #define GTK_STYLE_CLASS_SCALE "scale"
262
263 /**
264  * GTK_STYLE_CLASS_HEADER:
265  *
266  * A CSS class to match a header element.
267  */
268 #define GTK_STYLE_CLASS_HEADER "header"
269
270 /**
271  * GTK_STYLE_CLASS_ACCELERATOR:
272  *
273  * A CSS class to match an accelerator.
274  */
275 #define GTK_STYLE_CLASS_ACCELERATOR "accelerator"
276
277 /**
278  * GTK_STYLE_CLASS_GRIP:
279  *
280  * A widget class defining a resize grip
281  */
282 #define GTK_STYLE_CLASS_GRIP "grip"
283
284 /**
285  * GTK_STYLE_CLASS_DOCK:
286  *
287  * A widget class defining a dock area
288  */
289 #define GTK_STYLE_CLASS_DOCK "dock"
290
291 /**
292  * GTK_STYLE_CLASS_PROGRESSBAR:
293  *
294  * A widget class defining a resize grip
295  */
296 #define GTK_STYLE_CLASS_PROGRESSBAR "progressbar"
297
298 /**
299  * GTK_STYLE_CLASS_SPINNER:
300  *
301  * A widget class defining a spinner
302  */
303 #define GTK_STYLE_CLASS_SPINNER "spinner"
304
305 /**
306  * GTK_STYLE_CLASS_MARK:
307  *
308  * A widget class defining marks in a widget, such as in scales
309  */
310 #define GTK_STYLE_CLASS_MARK "mark"
311
312 /**
313  * GTK_STYLE_CLASS_EXPANDER:
314  *
315  * A widget class defining an expander, such as those in treeviews
316  */
317 #define GTK_STYLE_CLASS_EXPANDER "expander"
318
319 /**
320  * GTK_STYLE_CLASS_SPINBUTTON:
321  *
322  * A widget class defining an spinbutton
323  */
324 #define GTK_STYLE_CLASS_SPINBUTTON "spinbutton"
325
326 /**
327  * GTK_STYLE_CLASS_NOTEBOOK:
328  *
329  * A widget class defining a notebook
330  */
331 #define GTK_STYLE_CLASS_NOTEBOOK "notebook"
332
333 /**
334  * GTK_STYLE_CLASS_VIEW:
335  *
336  * A widget class defining a view, such as iconviews or treeviews
337  */
338 #define GTK_STYLE_CLASS_VIEW "view"
339
340 /**
341  * GTK_STYLE_CLASS_HIGHLIGHT:
342  *
343  * A CSS class defining a highlighted area, such as headings in
344  * assistants.
345  */
346 #define GTK_STYLE_CLASS_HIGHLIGHT "highlight"
347
348 /**
349  * GTK_STYLE_CLASS_FRAME:
350  *
351  * A CSS class defining a frame delimiting content, such as GtkFrame
352  * or the scrolled window frame around the scrollable area.
353  */
354 #define GTK_STYLE_CLASS_FRAME "frame"
355
356 /**
357  * GTK_STYLE_CLASS_DND:
358  *
359  * A CSS class for a drag-and-drop indicator
360  */
361 #define GTK_STYLE_CLASS_DND "dnd"
362
363 /**
364  * GTK_STYLE_CLASS_INFO:
365  *
366  * A widget class for an area displaying an informational message,
367  * such as those in infobars
368  */
369 #define GTK_STYLE_CLASS_INFO "info"
370
371 /**
372  * GTK_STYLE_CLASS_WARNING:
373  *
374  * A widget class for an area displaying a warning message,
375  * such as those in infobars
376  */
377 #define GTK_STYLE_CLASS_WARNING "warning"
378
379 /**
380  * GTK_STYLE_CLASS_QUESTION:
381  *
382  * A widget class for an area displaying a question to the user,
383  * such as those in infobars
384  */
385 #define GTK_STYLE_CLASS_QUESTION "question"
386
387 /**
388  * GTK_STYLE_CLASS_ERROR:
389  *
390  * A widget class for an area displaying an error message,
391  * such as those in infobars
392  */
393 #define GTK_STYLE_CLASS_ERROR "error"
394
395
396 /* Predefined set of widget regions */
397
398 /**
399  * GTK_STYLE_REGION_ROW:
400  *
401  * A widget region name to define a treeview row.
402  */
403 #define GTK_STYLE_REGION_ROW "row"
404
405 /**
406  * GTK_STYLE_REGION_COLUMN:
407  *
408  * A widget region name to define a treeview column.
409  */
410 #define GTK_STYLE_REGION_COLUMN "column"
411
412 /**
413  * GTK_STYLE_REGION_COLUMN_HEADER:
414  *
415  * A widget region name to define a treeview column header.
416  */
417 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
418
419 /**
420  * GTK_STYLE_REGION_TAB:
421  *
422  * A widget region name to define a notebook tab.
423  */
424 #define GTK_STYLE_REGION_TAB "tab"
425
426
427 GType gtk_style_context_get_type (void) G_GNUC_CONST;
428
429 GtkStyleContext * gtk_style_context_new (void);
430
431 void gtk_style_context_add_provider_for_screen    (GdkScreen        *screen,
432                                                    GtkStyleProvider *provider,
433                                                    guint             priority);
434 void gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
435                                                    GtkStyleProvider *provider);
436
437 void gtk_style_context_add_provider    (GtkStyleContext  *context,
438                                         GtkStyleProvider *provider,
439                                         guint             priority);
440
441 void gtk_style_context_remove_provider (GtkStyleContext  *context,
442                                         GtkStyleProvider *provider);
443
444 void gtk_style_context_save    (GtkStyleContext *context);
445 void gtk_style_context_restore (GtkStyleContext *context);
446
447 void gtk_style_context_get_property (GtkStyleContext *context,
448                                      const gchar     *property,
449                                      GtkStateFlags    state,
450                                      GValue          *value);
451 void gtk_style_context_get_valist   (GtkStyleContext *context,
452                                      GtkStateFlags    state,
453                                      va_list          args);
454 void gtk_style_context_get          (GtkStyleContext *context,
455                                      GtkStateFlags    state,
456                                      ...) G_GNUC_NULL_TERMINATED;
457
458 void          gtk_style_context_set_state    (GtkStyleContext *context,
459                                               GtkStateFlags    flags);
460 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
461
462 gboolean      gtk_style_context_state_is_running (GtkStyleContext *context,
463                                                   GtkStateType     state,
464                                                   gdouble         *progress);
465
466 void          gtk_style_context_set_path     (GtkStyleContext *context,
467                                               GtkWidgetPath   *path);
468 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
469
470 GList *  gtk_style_context_list_classes (GtkStyleContext *context);
471
472 void     gtk_style_context_add_class    (GtkStyleContext *context,
473                                          const gchar     *class_name);
474 void     gtk_style_context_remove_class (GtkStyleContext *context,
475                                          const gchar     *class_name);
476 gboolean gtk_style_context_has_class    (GtkStyleContext *context,
477                                          const gchar     *class_name);
478
479 GList *  gtk_style_context_list_regions (GtkStyleContext *context);
480
481 void     gtk_style_context_add_region    (GtkStyleContext    *context,
482                                           const gchar        *region_name,
483                                           GtkRegionFlags      flags);
484 void     gtk_style_context_remove_region (GtkStyleContext    *context,
485                                           const gchar        *region_name);
486 gboolean gtk_style_context_has_region    (GtkStyleContext    *context,
487                                           const gchar        *region_name,
488                                           GtkRegionFlags     *flags_return);
489
490 void gtk_style_context_get_style_property (GtkStyleContext *context,
491                                            const gchar     *property_name,
492                                            GValue          *value);
493 void gtk_style_context_get_style_valist   (GtkStyleContext *context,
494                                            va_list          args);
495 void gtk_style_context_get_style          (GtkStyleContext *context,
496                                            ...);
497
498 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
499                                                 const gchar     *stock_id);
500 GdkPixbuf  * gtk_icon_set_render_icon_pixbuf   (GtkIconSet      *icon_set,
501                                                 GtkStyleContext *context,
502                                                 GtkIconSize      size);
503
504 void        gtk_style_context_set_screen (GtkStyleContext *context,
505                                           GdkScreen       *screen);
506 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
507
508 void             gtk_style_context_set_direction (GtkStyleContext  *context,
509                                                   GtkTextDirection  direction);
510 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext  *context);
511
512 void             gtk_style_context_set_junction_sides (GtkStyleContext  *context,
513                                                        GtkJunctionSides  sides);
514 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext  *context);
515
516 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
517                                          const gchar     *color_name,
518                                          GdkRGBA         *color);
519
520 void  gtk_style_context_notify_state_change (GtkStyleContext *context,
521                                              GdkWindow       *window,
522                                              gpointer         region_id,
523                                              GtkStateType     state,
524                                              gboolean         state_value);
525 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
526                                                gpointer         region_id);
527 void gtk_style_context_pop_animatable_region  (GtkStyleContext *context);
528
529 /* Some helper functions to retrieve most common properties */
530 void gtk_style_context_get_color            (GtkStyleContext *context,
531                                              GtkStateFlags    state,
532                                              GdkRGBA         *color);
533 void gtk_style_context_get_background_color (GtkStyleContext *context,
534                                              GtkStateFlags    state,
535                                              GdkRGBA         *color);
536 void gtk_style_context_get_border_color     (GtkStyleContext *context,
537                                              GtkStateFlags    state,
538                                              GdkRGBA         *color);
539
540 const PangoFontDescription * gtk_style_context_get_font (GtkStyleContext *context,
541                                                     GtkStateFlags    state);
542
543 void gtk_style_context_get_border           (GtkStyleContext *context,
544                                              GtkStateFlags    state,
545                                              GtkBorder       *border);
546 void gtk_style_context_get_padding          (GtkStyleContext *context,
547                                              GtkStateFlags    state,
548                                              GtkBorder       *padding);
549 void gtk_style_context_get_margin           (GtkStyleContext *context,
550                                              GtkStateFlags    state,
551                                              GtkBorder       *margin);
552
553 /* Semi-private API */
554 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
555                                                        GType            widget_type,
556                                                        GtkStateFlags    state,
557                                                        GParamSpec      *pspec);
558 void           _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
559 void           _gtk_style_context_coalesce_animation_areas   (GtkStyleContext *context,
560                                                               GtkWidget       *widget);
561
562 void gtk_style_context_invalidate (GtkStyleContext *context);
563 void gtk_style_context_reset_widgets (GdkScreen *screen);
564
565 void gtk_style_context_set_background (GtkStyleContext *context,
566                                        GdkWindow       *window);
567
568 /* Paint methods */
569 void gtk_render_check (GtkStyleContext *context,
570                        cairo_t         *cr,
571                        gdouble          x,
572                        gdouble          y,
573                        gdouble          width,
574                        gdouble          height);
575 void gtk_render_option (GtkStyleContext *context,
576                         cairo_t         *cr,
577                         gdouble          x,
578                         gdouble          y,
579                         gdouble          width,
580                         gdouble          height);
581 void gtk_render_arrow  (GtkStyleContext *context,
582                         cairo_t         *cr,
583                         gdouble          angle,
584                         gdouble          x,
585                         gdouble          y,
586                         gdouble          size);
587 void gtk_render_background (GtkStyleContext *context,
588                             cairo_t         *cr,
589                             gdouble          x,
590                             gdouble          y,
591                             gdouble          width,
592                             gdouble          height);
593 void gtk_render_frame  (GtkStyleContext *context,
594                         cairo_t         *cr,
595                         gdouble          x,
596                         gdouble          y,
597                         gdouble          width,
598                         gdouble          height);
599 void gtk_render_expander (GtkStyleContext *context,
600                           cairo_t         *cr,
601                           gdouble          x,
602                           gdouble          y,
603                           gdouble          width,
604                           gdouble          height);
605 void gtk_render_focus    (GtkStyleContext *context,
606                           cairo_t         *cr,
607                           gdouble          x,
608                           gdouble          y,
609                           gdouble          width,
610                           gdouble          height);
611 void gtk_render_layout   (GtkStyleContext *context,
612                           cairo_t         *cr,
613                           gdouble          x,
614                           gdouble          y,
615                           PangoLayout     *layout);
616 void gtk_render_line     (GtkStyleContext *context,
617                           cairo_t         *cr,
618                           gdouble          x0,
619                           gdouble          y0,
620                           gdouble          x1,
621                           gdouble          y1);
622 void gtk_render_slider   (GtkStyleContext *context,
623                           cairo_t         *cr,
624                           gdouble          x,
625                           gdouble          y,
626                           gdouble          width,
627                           gdouble          height,
628                           GtkOrientation   orientation);
629 void gtk_render_frame_gap (GtkStyleContext *context,
630                            cairo_t         *cr,
631                            gdouble          x,
632                            gdouble          y,
633                            gdouble          width,
634                            gdouble          height,
635                            GtkPositionType  gap_side,
636                            gdouble          xy0_gap,
637                            gdouble          xy1_gap);
638 void gtk_render_extension (GtkStyleContext *context,
639                            cairo_t         *cr,
640                            gdouble          x,
641                            gdouble          y,
642                            gdouble          width,
643                            gdouble          height,
644                            GtkPositionType  gap_side);
645 void gtk_render_handle    (GtkStyleContext *context,
646                            cairo_t         *cr,
647                            gdouble          x,
648                            gdouble          y,
649                            gdouble          width,
650                            gdouble          height);
651 void gtk_render_activity  (GtkStyleContext *context,
652                            cairo_t         *cr,
653                            gdouble          x,
654                            gdouble          y,
655                            gdouble          width,
656                            gdouble          height);
657
658 GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext     *context,
659                                     const GtkIconSource *source,
660                                     GtkIconSize          size);
661
662 G_END_DECLS
663
664 #endif /* __GTK_STYLE_CONTEXT_H__ */