]> Pileus Git - ~andy/gtk/blob - gtk/gtkstyle.h
wayland: Remove non-existing gdkscreen-wayland.h from SOURCES
[~andy/gtk] / gtk / gtkstyle.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_STYLE_H__
32 #define __GTK_STYLE_H__
33
34
35 #include <gdk/gdk.h>
36 #include <gtk/gtkenums.h>
37 #include <gtk/gtkwidgetpath.h>
38
39
40 G_BEGIN_DECLS
41
42 #define GTK_TYPE_STYLE              (gtk_style_get_type ())
43 #define GTK_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_STYLE, GtkStyle))
44 #define GTK_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STYLE, GtkStyleClass))
45 #define GTK_IS_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_STYLE))
46 #define GTK_IS_STYLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STYLE))
47 #define GTK_STYLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STYLE, GtkStyleClass))
48
49 /* Some forward declarations needed to rationalize the header
50  * files.
51  */
52 typedef struct _GtkStyle       GtkStyle;
53 typedef struct _GtkStyleClass  GtkStyleClass;
54 typedef struct _GtkThemeEngine GtkThemeEngine;
55 typedef struct _GtkRcStyle     GtkRcStyle;
56 typedef struct _GtkIconSet     GtkIconSet;
57 typedef struct _GtkIconSource  GtkIconSource;
58 typedef struct _GtkRcProperty  GtkRcProperty;
59 typedef struct _GtkSettings    GtkSettings;
60 typedef gboolean (*GtkRcPropertyParser) (const GParamSpec *pspec,
61                                          const GString    *rc_string,
62                                          GValue           *property_value);
63
64 /* We make this forward declaration here, since we pass
65  * GtkWidget's to the draw functions.
66  */
67 typedef struct _GtkWidget      GtkWidget;
68
69 /**
70  * GTK_STYLE_ATTACHED:
71  * @style: a #GtkStyle.
72  *
73  * Returns whether the style is attached to a window.
74  */
75 #define GTK_STYLE_ATTACHED(style)       (GTK_STYLE (style)->attach_count > 0)
76
77 struct _GtkStyle
78 {
79   GObject parent_instance;
80
81   /*< public >*/
82
83   GdkColor fg[5];
84   GdkColor bg[5];
85   GdkColor light[5];
86   GdkColor dark[5];
87   GdkColor mid[5];
88   GdkColor text[5];
89   GdkColor base[5];
90   GdkColor text_aa[5];          /* Halfway between text/base */
91
92   GdkColor black;
93   GdkColor white;
94   PangoFontDescription *font_desc;
95
96   gint xthickness;
97   gint ythickness;
98
99   cairo_pattern_t *background[5];
100
101   /*< private >*/
102
103   gint attach_count;
104
105   GdkVisual *visual;
106   PangoFontDescription *private_font_desc; /* Font description for style->private_font or %NULL */
107
108   /* the RcStyle from which this style was created */
109   GtkRcStyle     *rc_style;
110
111   GSList         *styles;         /* of type GtkStyle* */
112   GArray         *property_cache;
113   GSList         *icon_factories; /* of type GtkIconFactory* */
114 };
115
116 struct _GtkStyleClass
117 {
118   GObjectClass parent_class;
119
120   /* Initialize for a particular visual. style->visual
121    * will have been set at this point. Will typically chain
122    * to parent.
123    */
124   void (*realize)               (GtkStyle               *style);
125
126   /* Clean up for a particular visual. Will typically chain
127    * to parent.
128    */
129   void (*unrealize)             (GtkStyle               *style);
130
131   /* Make style an exact duplicate of src.
132    */
133   void (*copy)                  (GtkStyle               *style,
134                                  GtkStyle               *src);
135
136   /* Create an empty style of the same type as this style.
137    * The default implementation, which does
138    * g_object_new (G_OBJECT_TYPE (style), NULL);
139    * should work in most cases.
140    */
141   GtkStyle *(*clone)             (GtkStyle               *style);
142
143   /* Initialize the GtkStyle with the values in the GtkRcStyle.
144    * should chain to the parent implementation.
145    */
146   void     (*init_from_rc)      (GtkStyle               *style,
147                                  GtkRcStyle             *rc_style);
148
149   void (*set_background)        (GtkStyle               *style,
150                                  GdkWindow              *window,
151                                  GtkStateType            state_type);
152
153
154   GdkPixbuf * (* render_icon)   (GtkStyle               *style,
155                                  const GtkIconSource    *source,
156                                  GtkTextDirection        direction,
157                                  GtkStateType            state,
158                                  GtkIconSize             size,
159                                  GtkWidget              *widget,
160                                  const gchar            *detail);
161
162   /* Drawing functions
163    */
164
165   void (*draw_hline)            (GtkStyle               *style,
166                                  cairo_t                *cr,
167                                  GtkStateType            state_type,
168                                  GtkWidget              *widget,
169                                  const gchar            *detail,
170                                  gint                    x1,
171                                  gint                    x2,
172                                  gint                    y);
173   void (*draw_vline)            (GtkStyle               *style,
174                                  cairo_t                *cr,
175                                  GtkStateType            state_type,
176                                  GtkWidget              *widget,
177                                  const gchar            *detail,
178                                  gint                    y1_,
179                                  gint                    y2_,
180                                  gint                    x);
181   void (*draw_shadow)           (GtkStyle               *style,
182                                  cairo_t                *cr,
183                                  GtkStateType            state_type,
184                                  GtkShadowType           shadow_type,
185                                  GtkWidget              *widget,
186                                  const gchar            *detail,
187                                  gint                    x,
188                                  gint                    y,
189                                  gint                    width,
190                                  gint                    height);
191   void (*draw_arrow)            (GtkStyle               *style,
192                                  cairo_t                *cr,
193                                  GtkStateType            state_type,
194                                  GtkShadowType           shadow_type,
195                                  GtkWidget              *widget,
196                                  const gchar            *detail,
197                                  GtkArrowType            arrow_type,
198                                  gboolean                fill,
199                                  gint                    x,
200                                  gint                    y,
201                                  gint                    width,
202                                  gint                    height);
203   void (*draw_diamond)          (GtkStyle               *style,
204                                  cairo_t                *cr,
205                                  GtkStateType            state_type,
206                                  GtkShadowType           shadow_type,
207                                  GtkWidget              *widget,
208                                  const gchar            *detail,
209                                  gint                    x,
210                                  gint                    y,
211                                  gint                    width,
212                                  gint                    height);
213   void (*draw_box)              (GtkStyle               *style,
214                                  cairo_t                *cr,
215                                  GtkStateType            state_type,
216                                  GtkShadowType           shadow_type,
217                                  GtkWidget              *widget,
218                                  const gchar            *detail,
219                                  gint                    x,
220                                  gint                    y,
221                                  gint                    width,
222                                  gint                    height);
223   void (*draw_flat_box)         (GtkStyle               *style,
224                                  cairo_t                *cr,
225                                  GtkStateType            state_type,
226                                  GtkShadowType           shadow_type,
227                                  GtkWidget              *widget,
228                                  const gchar            *detail,
229                                  gint                    x,
230                                  gint                    y,
231                                  gint                    width,
232                                  gint                    height);
233   void (*draw_check)            (GtkStyle               *style,
234                                  cairo_t                *cr,
235                                  GtkStateType            state_type,
236                                  GtkShadowType           shadow_type,
237                                  GtkWidget              *widget,
238                                  const gchar            *detail,
239                                  gint                    x,
240                                  gint                    y,
241                                  gint                    width,
242                                  gint                    height);
243   void (*draw_option)           (GtkStyle               *style,
244                                  cairo_t                *cr,
245                                  GtkStateType            state_type,
246                                  GtkShadowType           shadow_type,
247                                  GtkWidget              *widget,
248                                  const gchar            *detail,
249                                  gint                    x,
250                                  gint                    y,
251                                  gint                    width,
252                                  gint                    height);
253   void (*draw_tab)              (GtkStyle               *style,
254                                  cairo_t                *cr,
255                                  GtkStateType            state_type,
256                                  GtkShadowType           shadow_type,
257                                  GtkWidget              *widget,
258                                  const gchar            *detail,
259                                  gint                    x,
260                                  gint                    y,
261                                  gint                    width,
262                                  gint                    height);
263   void (*draw_shadow_gap)       (GtkStyle               *style,
264                                  cairo_t                *cr,
265                                  GtkStateType            state_type,
266                                  GtkShadowType           shadow_type,
267                                  GtkWidget              *widget,
268                                  const gchar            *detail,
269                                  gint                    x,
270                                  gint                    y,
271                                  gint                    width,
272                                  gint                    height,
273                                  GtkPositionType         gap_side,
274                                  gint                    gap_x,
275                                  gint                    gap_width);
276   void (*draw_box_gap)          (GtkStyle               *style,
277                                  cairo_t                *cr,
278                                  GtkStateType            state_type,
279                                  GtkShadowType           shadow_type,
280                                  GtkWidget              *widget,
281                                  const gchar            *detail,
282                                  gint                    x,
283                                  gint                    y,
284                                  gint                    width,
285                                  gint                    height,
286                                  GtkPositionType         gap_side,
287                                  gint                    gap_x,
288                                  gint                    gap_width);
289   void (*draw_extension)        (GtkStyle               *style,
290                                  cairo_t                *cr,
291                                  GtkStateType            state_type,
292                                  GtkShadowType           shadow_type,
293                                  GtkWidget              *widget,
294                                  const gchar            *detail,
295                                  gint                    x,
296                                  gint                    y,
297                                  gint                    width,
298                                  gint                    height,
299                                  GtkPositionType         gap_side);
300   void (*draw_focus)            (GtkStyle               *style,
301                                  cairo_t                *cr,
302                                  GtkStateType            state_type,
303                                  GtkWidget              *widget,
304                                  const gchar            *detail,
305                                  gint                    x,
306                                  gint                    y,
307                                  gint                    width,
308                                  gint                    height);
309   void (*draw_slider)           (GtkStyle               *style,
310                                  cairo_t                *cr,
311                                  GtkStateType            state_type,
312                                  GtkShadowType           shadow_type,
313                                  GtkWidget              *widget,
314                                  const gchar            *detail,
315                                  gint                    x,
316                                  gint                    y,
317                                  gint                    width,
318                                  gint                    height,
319                                  GtkOrientation          orientation);
320   void (*draw_handle)           (GtkStyle               *style,
321                                  cairo_t                *cr,
322                                  GtkStateType            state_type,
323                                  GtkShadowType           shadow_type,
324                                  GtkWidget              *widget,
325                                  const gchar            *detail,
326                                  gint                    x,
327                                  gint                    y,
328                                  gint                    width,
329                                  gint                    height,
330                                  GtkOrientation          orientation);
331
332   void (*draw_expander)         (GtkStyle               *style,
333                                  cairo_t                *cr,
334                                  GtkStateType            state_type,
335                                  GtkWidget              *widget,
336                                  const gchar            *detail,
337                                  gint                    x,
338                                  gint                    y,
339                                  GtkExpanderStyle        expander_style);
340   void (*draw_layout)           (GtkStyle               *style,
341                                  cairo_t                *cr,
342                                  GtkStateType            state_type,
343                                  gboolean                use_text,
344                                  GtkWidget              *widget,
345                                  const gchar            *detail,
346                                  gint                    x,
347                                  gint                    y,
348                                  PangoLayout            *layout);
349   void (*draw_resize_grip)      (GtkStyle               *style,
350                                  cairo_t                *cr,
351                                  GtkStateType            state_type,
352                                  GtkWidget              *widget,
353                                  const gchar            *detail,
354                                  GdkWindowEdge           edge,
355                                  gint                    x,
356                                  gint                    y,
357                                  gint                    width,
358                                  gint                    height);
359   void (*draw_spinner)          (GtkStyle               *style,
360                                  cairo_t                *cr,
361                                  GtkStateType            state_type,
362                                  GtkWidget              *widget,
363                                  const gchar            *detail,
364                                  guint                   step,
365                                  gint                    x,
366                                  gint                    y,
367                                  gint                    width,
368                                  gint                    height);
369
370   /* Padding for future expansion */
371   void (*_gtk_reserved1)  (void);
372   void (*_gtk_reserved2)  (void);
373   void (*_gtk_reserved3)  (void);
374   void (*_gtk_reserved4)  (void);
375   void (*_gtk_reserved5)  (void);
376   void (*_gtk_reserved6)  (void);
377   void (*_gtk_reserved7)  (void);
378   void (*_gtk_reserved8)  (void);
379   void (*_gtk_reserved9)  (void);
380   void (*_gtk_reserved10) (void);
381   void (*_gtk_reserved11) (void);
382 };
383
384 #if !defined(GTK_DISABLE_DEPRECATED) || defined(GTK_COMPILATION)
385
386 GType     gtk_style_get_type                 (void) G_GNUC_CONST;
387 GtkStyle* gtk_style_new                      (void);
388 GtkStyle* gtk_style_copy                     (GtkStyle     *style);
389 GtkStyle* gtk_style_attach                   (GtkStyle     *style,
390                                               GdkWindow    *window) G_GNUC_WARN_UNUSED_RESULT;
391 void      gtk_style_detach                   (GtkStyle     *style);
392 void      gtk_style_set_background           (GtkStyle     *style,
393                                               GdkWindow    *window,
394                                               GtkStateType  state_type);
395 void      gtk_style_apply_default_background (GtkStyle     *style,
396                                               cairo_t      *cr,
397                                               GdkWindow    *window,
398                                               GtkStateType  state_type,
399                                               gint          x,
400                                               gint          y,
401                                               gint          width,
402                                               gint          height);
403
404 GtkIconSet* gtk_style_lookup_icon_set        (GtkStyle     *style,
405                                               const gchar  *stock_id);
406 gboolean    gtk_style_lookup_color           (GtkStyle     *style,
407                                               const gchar  *color_name,
408                                               GdkColor     *color);
409
410 GdkPixbuf*  gtk_style_render_icon     (GtkStyle            *style,
411                                        const GtkIconSource *source,
412                                        GtkTextDirection     direction,
413                                        GtkStateType         state,
414                                        GtkIconSize          size,
415                                        GtkWidget           *widget,
416                                        const gchar         *detail);
417
418 void gtk_paint_hline             (GtkStyle           *style,
419                                   cairo_t            *cr,
420                                   GtkStateType        state_type,
421                                   GtkWidget          *widget,
422                                   const gchar        *detail,
423                                   gint                x1,
424                                   gint                x2,
425                                   gint                y);
426 void gtk_paint_vline             (GtkStyle           *style,
427                                   cairo_t            *cr,
428                                   GtkStateType        state_type,
429                                   GtkWidget          *widget,
430                                   const gchar        *detail,
431                                   gint                y1_,
432                                   gint                y2_,
433                                   gint                x);
434 void gtk_paint_shadow            (GtkStyle           *style,
435                                   cairo_t            *cr,
436                                   GtkStateType        state_type,
437                                   GtkShadowType       shadow_type,
438                                   GtkWidget          *widget,
439                                   const gchar        *detail,
440                                   gint                x,
441                                   gint                y,
442                                   gint                width,
443                                   gint                height);
444 void gtk_paint_arrow             (GtkStyle           *style,
445                                   cairo_t            *cr,
446                                   GtkStateType        state_type,
447                                   GtkShadowType       shadow_type,
448                                   GtkWidget          *widget,
449                                   const gchar        *detail,
450                                   GtkArrowType        arrow_type,
451                                   gboolean            fill,
452                                   gint                x,
453                                   gint                y,
454                                   gint                width,
455                                   gint                height);
456 void gtk_paint_diamond           (GtkStyle           *style,
457                                   cairo_t            *cr,
458                                   GtkStateType        state_type,
459                                   GtkShadowType       shadow_type,
460                                   GtkWidget          *widget,
461                                   const gchar        *detail,
462                                   gint                x,
463                                   gint                y,
464                                   gint                width,
465                                   gint                height);
466 void gtk_paint_box               (GtkStyle           *style,
467                                   cairo_t            *cr,
468                                   GtkStateType        state_type,
469                                   GtkShadowType       shadow_type,
470                                   GtkWidget          *widget,
471                                   const gchar        *detail,
472                                   gint                x,
473                                   gint                y,
474                                   gint                width,
475                                   gint                height);
476 void gtk_paint_flat_box          (GtkStyle           *style,
477                                   cairo_t            *cr,
478                                   GtkStateType        state_type,
479                                   GtkShadowType       shadow_type,
480                                   GtkWidget          *widget,
481                                   const gchar        *detail,
482                                   gint                x,
483                                   gint                y,
484                                   gint                width,
485                                   gint                height);
486 void gtk_paint_check             (GtkStyle           *style,
487                                   cairo_t            *cr,
488                                   GtkStateType        state_type,
489                                   GtkShadowType       shadow_type,
490                                   GtkWidget          *widget,
491                                   const gchar        *detail,
492                                   gint                x,
493                                   gint                y,
494                                   gint                width,
495                                   gint                height);
496 void gtk_paint_option            (GtkStyle           *style,
497                                   cairo_t            *cr,
498                                   GtkStateType        state_type,
499                                   GtkShadowType       shadow_type,
500                                   GtkWidget          *widget,
501                                   const gchar        *detail,
502                                   gint                x,
503                                   gint                y,
504                                   gint                width,
505                                   gint                height);
506 void gtk_paint_tab               (GtkStyle           *style,
507                                   cairo_t            *cr,
508                                   GtkStateType        state_type,
509                                   GtkShadowType       shadow_type,
510                                   GtkWidget          *widget,
511                                   const gchar        *detail,
512                                   gint                x,
513                                   gint                y,
514                                   gint                width,
515                                   gint                height);
516 void gtk_paint_shadow_gap        (GtkStyle           *style,
517                                   cairo_t            *cr,
518                                   GtkStateType        state_type,
519                                   GtkShadowType       shadow_type,
520                                   GtkWidget          *widget,
521                                   const gchar        *detail,
522                                   gint                x,
523                                   gint                y,
524                                   gint                width,
525                                   gint                height,
526                                   GtkPositionType     gap_side,
527                                   gint                gap_x,
528                                   gint                gap_width);
529 void gtk_paint_box_gap           (GtkStyle           *style,
530                                   cairo_t            *cr,
531                                   GtkStateType        state_type,
532                                   GtkShadowType       shadow_type,
533                                   GtkWidget          *widget,
534                                   const gchar        *detail,
535                                   gint                x,
536                                   gint                y,
537                                   gint                width,
538                                   gint                height,
539                                   GtkPositionType     gap_side,
540                                   gint                gap_x,
541                                   gint                gap_width);
542 void gtk_paint_extension         (GtkStyle           *style,
543                                   cairo_t            *cr,
544                                   GtkStateType        state_type,
545                                   GtkShadowType       shadow_type,
546                                   GtkWidget          *widget,
547                                   const gchar        *detail,
548                                   gint                x,
549                                   gint                y,
550                                   gint                width,
551                                   gint                height,
552                                   GtkPositionType     gap_side);
553 void gtk_paint_focus             (GtkStyle           *style,
554                                   cairo_t            *cr,
555                                   GtkStateType        state_type,
556                                   GtkWidget          *widget,
557                                   const gchar        *detail,
558                                   gint                x,
559                                   gint                y,
560                                   gint                width,
561                                   gint                height);
562 void gtk_paint_slider            (GtkStyle           *style,
563                                   cairo_t            *cr,
564                                   GtkStateType        state_type,
565                                   GtkShadowType       shadow_type,
566                                   GtkWidget          *widget,
567                                   const gchar        *detail,
568                                   gint                x,
569                                   gint                y,
570                                   gint                width,
571                                   gint                height,
572                                   GtkOrientation      orientation);
573 void gtk_paint_handle            (GtkStyle           *style,
574                                   cairo_t            *cr,
575                                   GtkStateType        state_type,
576                                   GtkShadowType       shadow_type,
577                                   GtkWidget          *widget,
578                                   const gchar        *detail,
579                                   gint                x,
580                                   gint                y,
581                                   gint                width,
582                                   gint                height,
583                                   GtkOrientation      orientation);
584 void gtk_paint_expander          (GtkStyle           *style,
585                                   cairo_t            *cr,
586                                   GtkStateType        state_type,
587                                   GtkWidget          *widget,
588                                   const gchar        *detail,
589                                   gint                x,
590                                   gint                y,
591                                   GtkExpanderStyle    expander_style);
592 void gtk_paint_layout            (GtkStyle           *style,
593                                   cairo_t            *cr,
594                                   GtkStateType        state_type,
595                                   gboolean            use_text,
596                                   GtkWidget          *widget,
597                                   const gchar        *detail,
598                                   gint                x,
599                                   gint                y,
600                                   PangoLayout        *layout);
601 void gtk_paint_resize_grip       (GtkStyle           *style,
602                                   cairo_t            *cr,
603                                   GtkStateType        state_type,
604                                   GtkWidget          *widget,
605                                   const gchar        *detail,
606                                   GdkWindowEdge       edge,
607                                   gint                x,
608                                   gint                y,
609                                   gint                width,
610                                   gint                height);
611 void gtk_paint_spinner           (GtkStyle           *style,
612                                   cairo_t            *cr,
613                                   GtkStateType        state_type,
614                                   GtkWidget          *widget,
615                                   const gchar        *detail,
616                                   guint               step,
617                                   gint                x,
618                                   gint                y,
619                                   gint                width,
620                                   gint                height);
621
622 void gtk_style_get_style_property (GtkStyle    *style,
623                                    GType        widget_type,
624                                    const gchar *property_name,
625                                    GValue      *value);
626 void gtk_style_get_valist         (GtkStyle    *style,
627                                    GType        widget_type,
628                                    const gchar *first_property_name,
629                                    va_list      var_args);
630 void gtk_style_get                (GtkStyle    *style,
631                                    GType        widget_type,
632                                    const gchar *first_property_name,
633                                    ...) G_GNUC_NULL_TERMINATED;
634
635 #endif
636
637 /* --- private API --- */
638 GtkStyle*     _gtk_style_new_for_path        (GdkScreen          *screen,
639                                               GtkWidgetPath      *path);
640 void          _gtk_style_shade               (const GdkColor     *a,
641                                               GdkColor           *b,
642                                               gdouble             k);
643
644 void   gtk_draw_insertion_cursor    (GtkWidget          *widget,
645                                      cairo_t            *cr,
646                                      const GdkRectangle *location,
647                                      gboolean            is_primary,
648                                      GtkTextDirection    direction,
649                                      gboolean            draw_arrow);
650
651 gboolean   gtk_style_has_context    (GtkStyle *style);
652
653
654
655 G_END_DECLS
656
657 #endif /* __GTK_STYLE_H__ */