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