gtkcsstypesprivate.h 8.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* GTK - The GIMP Toolkit
 * Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

#ifndef __GTK_CSS_TYPES_PRIVATE_H__
#define __GTK_CSS_TYPES_PRIVATE_H__

#include <glib-object.h>
Benjamin Otte's avatar
Benjamin Otte committed
22
#include <gtk/gtkstylecontext.h>
23 24 25

G_BEGIN_DECLS

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
typedef enum { /*< skip >*/
  GTK_CSS_CHANGE_CLASS                    = (1 <<  0),
  GTK_CSS_CHANGE_NAME                     = (1 <<  1),
  GTK_CSS_CHANGE_ID                       = GTK_CSS_CHANGE_NAME,
  GTK_CSS_CHANGE_REGION                   = GTK_CSS_CHANGE_NAME,
  GTK_CSS_CHANGE_POSITION                 = (1 <<  2),
  GTK_CSS_CHANGE_STATE                    = (1 <<  3),
  GTK_CSS_CHANGE_SIBLING_CLASS            = (1 <<  4),
  GTK_CSS_CHANGE_SIBLING_NAME             = (1 <<  5),
  GTK_CSS_CHANGE_SIBLING_POSITION         = (1 <<  6),
  GTK_CSS_CHANGE_SIBLING_STATE            = (1 <<  7),
  GTK_CSS_CHANGE_PARENT_CLASS             = (1 <<  8),
  GTK_CSS_CHANGE_PARENT_NAME              = (1 <<  9),
  GTK_CSS_CHANGE_PARENT_POSITION          = (1 << 10),
  GTK_CSS_CHANGE_PARENT_STATE             = (1 << 11),
  GTK_CSS_CHANGE_PARENT_SIBLING_CLASS     = (1 << 12),
  GTK_CSS_CHANGE_PARENT_SIBLING_NAME      = (1 << 13),
  GTK_CSS_CHANGE_PARENT_SIBLING_POSITION  = (1 << 14),
  GTK_CSS_CHANGE_PARENT_SIBLING_STATE     = (1 << 15),
  /* add more */
} GtkCssChange;

#define GTK_CSS_CHANGE_ANY ((1 << 16) - 1)
#define GTK_CSS_CHANGE_ANY_SELF (GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_STATE)
#define GTK_CSS_CHANGE_ANY_SIBLING (GTK_CSS_CHANGE_SIBLING_CLASS | GTK_CSS_CHANGE_SIBLING_NAME | \
                                    GTK_CSS_CHANGE_SIBLING_POSITION | GTK_CSS_CHANGE_SIBLING_STATE)
#define GTK_CSS_CHANGE_ANY_PARENT (GTK_CSS_CHANGE_PARENT_CLASS | GTK_CSS_CHANGE_PARENT_SIBLING_CLASS | \
                                   GTK_CSS_CHANGE_PARENT_NAME | GTK_CSS_CHANGE_PARENT_SIBLING_NAME | \
                                   GTK_CSS_CHANGE_PARENT_POSITION | GTK_CSS_CHANGE_PARENT_SIBLING_POSITION | \
                                   GTK_CSS_CHANGE_PARENT_STATE | GTK_CSS_CHANGE_PARENT_SIBLING_STATE)

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
enum { /*< skip >*/
  GTK_CSS_PROPERTY_COLOR,
  GTK_CSS_PROPERTY_FONT_SIZE,
  GTK_CSS_PROPERTY_BACKGROUND_COLOR,
  GTK_CSS_PROPERTY_FONT_FAMILY,
  GTK_CSS_PROPERTY_FONT_STYLE,
  GTK_CSS_PROPERTY_FONT_VARIANT,
  GTK_CSS_PROPERTY_FONT_WEIGHT,
  GTK_CSS_PROPERTY_TEXT_SHADOW,
  GTK_CSS_PROPERTY_ICON_SHADOW,
  GTK_CSS_PROPERTY_BOX_SHADOW,
  GTK_CSS_PROPERTY_MARGIN_TOP,
  GTK_CSS_PROPERTY_MARGIN_LEFT,
  GTK_CSS_PROPERTY_MARGIN_BOTTOM,
  GTK_CSS_PROPERTY_MARGIN_RIGHT,
  GTK_CSS_PROPERTY_PADDING_TOP,
  GTK_CSS_PROPERTY_PADDING_LEFT,
  GTK_CSS_PROPERTY_PADDING_BOTTOM,
  GTK_CSS_PROPERTY_PADDING_RIGHT,
  GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
  GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
  GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
  GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
  GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
  GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
  GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
  GTK_CSS_PROPERTY_OUTLINE_STYLE,
  GTK_CSS_PROPERTY_OUTLINE_WIDTH,
  GTK_CSS_PROPERTY_OUTLINE_OFFSET,
  GTK_CSS_PROPERTY_BACKGROUND_CLIP,
  GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
  GTK_CSS_PROPERTY_BACKGROUND_SIZE,
  GTK_CSS_PROPERTY_BACKGROUND_POSITION,
  GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
  GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
  GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
  GTK_CSS_PROPERTY_OUTLINE_COLOR,
  GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
  GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
  GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
  GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
  GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
  GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH,
106 107 108 109
  GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
  GTK_CSS_PROPERTY_TRANSITION_DURATION,
  GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
  GTK_CSS_PROPERTY_TRANSITION_DELAY,
110 111 112 113 114 115 116
  GTK_CSS_PROPERTY_ENGINE,
  GTK_CSS_PROPERTY_TRANSITION,
  GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
  /* add more */
  GTK_CSS_PROPERTY_N_PROPERTIES
};

117 118 119 120 121 122 123 124 125 126 127 128 129 130
/* We encode horizontal and vertical repeat in one enum value.
 * This eases parsing and storage, but you need to be aware that
 * you have to "unpack" this value.
 */
#define GTK_CSS_BACKGROUND_REPEAT_SHIFT (8)
#define GTK_CSS_BACKGROUND_REPEAT_MASK ((1 << GTK_CSS_BACKGROUND_REPEAT_SHIFT) - 1)
#define GTK_CSS_BACKGROUND_HORIZONTAL(repeat) ((repeat) & GTK_CSS_BACKGROUND_REPEAT_MASK)
#define GTK_CSS_BACKGROUND_VERTICAL(repeat) (((repeat) >> GTK_CSS_BACKGROUND_REPEAT_SHIFT) & GTK_CSS_BACKGROUND_REPEAT_MASK)
typedef enum /*< enum >*/
{
  GTK_CSS_BACKGROUND_INVALID, /*< skip >*/
  GTK_CSS_BACKGROUND_REPEAT, /* start at one so we know if a value has been set */
  GTK_CSS_BACKGROUND_SPACE,
  GTK_CSS_BACKGROUND_ROUND,
131
  GTK_CSS_BACKGROUND_NO_REPEAT,
132 133 134
  /* need to hardcode the numer or glib-mkenums makes us into a flags type */
  GTK_CSS_BACKGROUND_REPEAT_X = 1025,
  GTK_CSS_BACKGROUND_REPEAT_Y = 260
135
} GtkCssBackgroundRepeat;
136

137
typedef enum {
138
  GTK_CSS_REPEAT_STYLE_STRETCH,
139 140 141
  GTK_CSS_REPEAT_STYLE_REPEAT,
  GTK_CSS_REPEAT_STYLE_ROUND,
  GTK_CSS_REPEAT_STYLE_SPACE
142
} GtkCssBorderRepeatStyle;
143

144
typedef enum /*< skip >*/ {
Alexander Larsson's avatar
Alexander Larsson committed
145 146 147 148 149
  GTK_CSS_AREA_BORDER_BOX,
  GTK_CSS_AREA_PADDING_BOX,
  GTK_CSS_AREA_CONTENT_BOX
} GtkCssArea;

Benjamin Otte's avatar
Benjamin Otte committed
150 151 152 153 154 155 156 157
/* for the order in arrays */
typedef enum /*< skip >*/ {
  GTK_CSS_TOP,
  GTK_CSS_RIGHT,
  GTK_CSS_BOTTOM,
  GTK_CSS_LEFT
} GtkCssSide;

158 159 160 161 162 163 164
typedef enum /*< skip >*/ {
  GTK_CSS_TOP_LEFT,
  GTK_CSS_TOP_RIGHT,
  GTK_CSS_BOTTOM_RIGHT,
  GTK_CSS_BOTTOM_LEFT
} GtkCssCorner;

Benjamin Otte's avatar
Benjamin Otte committed
165 166 167 168 169 170 171 172 173 174 175 176 177
typedef enum /*< skip >*/ {
  /* CSS term: <number> */
  GTK_CSS_NUMBER,
  /* CSS term: <percentage> */
  GTK_CSS_PERCENT,
  /* CSS term: <length> */
  GTK_CSS_PX,
  GTK_CSS_PT,
  GTK_CSS_EM,
  GTK_CSS_EX,
  GTK_CSS_PC,
  GTK_CSS_IN,
  GTK_CSS_CM,
178 179 180 181 182
  GTK_CSS_MM,
  /* CSS term: <angle> */
  GTK_CSS_RAD,
  GTK_CSS_DEG,
  GTK_CSS_GRAD,
183 184 185 186
  GTK_CSS_TURN,
  /* CSS term: <time> */
  GTK_CSS_S,
  GTK_CSS_MS,
Benjamin Otte's avatar
Benjamin Otte committed
187 188 189
} GtkCssUnit;

typedef struct _GtkCssNumber GtkCssNumber;
190
typedef struct _GtkCssBackgroundSize GtkCssBackgroundSize;
191
typedef struct _GtkCssBorderImageRepeat GtkCssBorderImageRepeat;
192

Benjamin Otte's avatar
Benjamin Otte committed
193 194 195 196 197
struct _GtkCssNumber {
  gdouble        value;
  GtkCssUnit     unit;
};

198 199 200 201 202 203 204
struct _GtkCssBackgroundSize {
  GtkCssNumber width;  /* 0 means auto here */
  GtkCssNumber height; /* 0 means auto here */
  guint cover :1;
  guint contain :1;
};

205
struct _GtkCssBorderImageRepeat {
206 207
  GtkCssBorderRepeatStyle vrepeat;
  GtkCssBorderRepeatStyle hrepeat;
208 209
};

210
#define GTK_TYPE_CSS_BACKGROUND_SIZE _gtk_css_background_size_get_type ()
211
#define GTK_TYPE_CSS_BORDER_IMAGE_REPEAT _gtk_css_border_image_repeat_get_type ()
212

213
GType           _gtk_css_background_size_get_type               (void);
214
GType           _gtk_css_border_image_repeat_get_type           (void);
Benjamin Otte's avatar
Benjamin Otte committed
215

216 217 218
GtkCssChange    _gtk_css_change_for_sibling                      (GtkCssChange       match);
GtkCssChange    _gtk_css_change_for_child                        (GtkCssChange       match);

Benjamin Otte's avatar
Benjamin Otte committed
219 220 221 222
#define GTK_CSS_NUMBER_INIT(_value,_unit) { (_value), (_unit) }
void            _gtk_css_number_init                            (GtkCssNumber       *number,
                                                                 double              value,
                                                                 GtkCssUnit          unit);
223 224 225 226
gboolean        _gtk_css_number_equal                           (const GtkCssNumber *one,
                                                                 const GtkCssNumber *two);
double          _gtk_css_number_get                             (const GtkCssNumber *number,
                                                                 double              one_hundred_percent);
227
gboolean        _gtk_css_number_compute                         (GtkCssNumber       *dest,
Benjamin Otte's avatar
Benjamin Otte committed
228 229 230 231 232
                                                                 const GtkCssNumber *src,
                                                                 GtkStyleContext    *context);
void            _gtk_css_number_print                           (const GtkCssNumber *number,
                                                                 GString            *string);

233 234 235 236

G_END_DECLS

#endif /* __GTK_CSS_TYPES_PRIVATE_H__ */