]> Pileus Git - ~andy/gtk/blob - gtk/gtkcsstypesprivate.h
Change FSF Address
[~andy/gtk] / gtk / gtkcsstypesprivate.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011 Benjamin Otte <otte@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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef __GTK_CSS_TYPES_PRIVATE_H__
19 #define __GTK_CSS_TYPES_PRIVATE_H__
20
21 #include <glib-object.h>
22 #include <gtk/gtkstylecontext.h>
23
24 G_BEGIN_DECLS
25
26 typedef enum {
27   GTK_CSS_INHERIT,
28   GTK_CSS_INITIAL
29 } GtkCssSpecialValue;
30
31 /* We encode horizontal and vertical repeat in one enum value.
32  * This eases parsing and storage, but you need to be aware that
33  * you have to "unpack" this value.
34  */
35 #define GTK_CSS_BACKGROUND_REPEAT_SHIFT (8)
36 #define GTK_CSS_BACKGROUND_REPEAT_MASK ((1 << GTK_CSS_BACKGROUND_REPEAT_SHIFT) - 1)
37 #define GTK_CSS_BACKGROUND_HORIZONTAL(repeat) ((repeat) & GTK_CSS_BACKGROUND_REPEAT_MASK)
38 #define GTK_CSS_BACKGROUND_VERTICAL(repeat) (((repeat) >> GTK_CSS_BACKGROUND_REPEAT_SHIFT) & GTK_CSS_BACKGROUND_REPEAT_MASK)
39 typedef enum /*< enum >*/
40 {
41   GTK_CSS_BACKGROUND_INVALID, /*< skip >*/
42   GTK_CSS_BACKGROUND_REPEAT, /* start at one so we know if a value has been set */
43   GTK_CSS_BACKGROUND_SPACE,
44   GTK_CSS_BACKGROUND_ROUND,
45   GTK_CSS_BACKGROUND_NO_REPEAT,
46   /* need to hardcode the numer or glib-mkenums makes us into a flags type */
47   GTK_CSS_BACKGROUND_REPEAT_X = 1025,
48   GTK_CSS_BACKGROUND_REPEAT_Y = 260
49 } GtkCssBackgroundRepeat;
50
51 typedef enum {
52   GTK_CSS_REPEAT_STYLE_STRETCH,
53   GTK_CSS_REPEAT_STYLE_REPEAT,
54   GTK_CSS_REPEAT_STYLE_ROUND,
55   GTK_CSS_REPEAT_STYLE_SPACE
56 } GtkCssBorderRepeatStyle;
57
58 typedef enum {
59   GTK_CSS_AREA_BORDER_BOX,
60   GTK_CSS_AREA_PADDING_BOX,
61   GTK_CSS_AREA_CONTENT_BOX
62 } GtkCssArea;
63
64 /* for the order in arrays */
65 typedef enum /*< skip >*/ {
66   GTK_CSS_TOP,
67   GTK_CSS_RIGHT,
68   GTK_CSS_BOTTOM,
69   GTK_CSS_LEFT
70 } GtkCssSide;
71
72 typedef enum /*< skip >*/ {
73   GTK_CSS_TOP_LEFT,
74   GTK_CSS_TOP_RIGHT,
75   GTK_CSS_BOTTOM_RIGHT,
76   GTK_CSS_BOTTOM_LEFT
77 } GtkCssCorner;
78
79 typedef enum /*< skip >*/ {
80   /* CSS term: <number> */
81   GTK_CSS_NUMBER,
82   /* CSS term: <percentage> */
83   GTK_CSS_PERCENT,
84   /* CSS term: <length> */
85   GTK_CSS_PX,
86   GTK_CSS_PT,
87   GTK_CSS_EM,
88   GTK_CSS_EX,
89   GTK_CSS_PC,
90   GTK_CSS_IN,
91   GTK_CSS_CM,
92   GTK_CSS_MM,
93   /* CSS term: <angle> */
94   GTK_CSS_RAD,
95   GTK_CSS_DEG,
96   GTK_CSS_GRAD,
97   GTK_CSS_TURN
98 } GtkCssUnit;
99
100 typedef struct _GtkCssNumber GtkCssNumber;
101 typedef struct _GtkCssBackgroundSize GtkCssBackgroundSize;
102 typedef struct _GtkCssBorderCornerRadius GtkCssBorderCornerRadius;
103 typedef struct _GtkCssBorderImageRepeat GtkCssBorderImageRepeat;
104
105 struct _GtkCssNumber {
106   gdouble        value;
107   GtkCssUnit     unit;
108 };
109
110 struct _GtkCssBackgroundSize {
111   GtkCssNumber width;  /* 0 means auto here */
112   GtkCssNumber height; /* 0 means auto here */
113   guint cover :1;
114   guint contain :1;
115 };
116
117 struct _GtkCssBorderCornerRadius {
118   GtkCssNumber horizontal;
119   GtkCssNumber vertical;
120 };
121
122 struct _GtkCssBorderImageRepeat {
123   GtkCssBorderRepeatStyle vrepeat;
124   GtkCssBorderRepeatStyle hrepeat;
125 };
126
127 #define GTK_TYPE_CSS_BACKGROUND_SIZE _gtk_css_background_size_get_type ()
128 #define GTK_TYPE_CSS_BORDER_CORNER_RADIUS _gtk_css_border_corner_radius_get_type ()
129 #define GTK_TYPE_CSS_BORDER_IMAGE_REPEAT _gtk_css_border_image_repeat_get_type ()
130 #define GTK_TYPE_CSS_NUMBER _gtk_css_number_get_type ()
131
132 GType           _gtk_css_background_size_get_type               (void);
133 GType           _gtk_css_border_corner_radius_get_type          (void);
134 GType           _gtk_css_border_image_repeat_get_type           (void);
135 GType           _gtk_css_number_get_type                        (void);
136
137 #define GTK_CSS_NUMBER_INIT(_value,_unit) { (_value), (_unit) }
138 void            _gtk_css_number_init                            (GtkCssNumber       *number,
139                                                                  double              value,
140                                                                  GtkCssUnit          unit);
141 gboolean        _gtk_css_number_equal                           (const GtkCssNumber *one,
142                                                                  const GtkCssNumber *two);
143 double          _gtk_css_number_get                             (const GtkCssNumber *number,
144                                                                  double              one_hundred_percent);
145 void            _gtk_css_number_compute                         (GtkCssNumber       *dest,
146                                                                  const GtkCssNumber *src,
147                                                                  GtkStyleContext    *context);
148 void            _gtk_css_number_print                           (const GtkCssNumber *number,
149                                                                  GString            *string);
150
151
152 G_END_DECLS
153
154 #endif /* __GTK_CSS_TYPES_PRIVATE_H__ */