1 | /* GTK+ Rsvg Engine |
---|
2 | * Copyright (C) 1998-2000 Red Hat, Inc. |
---|
3 | * Copyright (C) 2002 Dom Lachowicz |
---|
4 | * |
---|
5 | * This library is free software; you can redistribute it and/or |
---|
6 | * modify it under the terms of the GNU Library General Public |
---|
7 | * License as published by the Free Software Foundation; either |
---|
8 | * version 2 of the License, or (at your option) any later version. |
---|
9 | * |
---|
10 | * This library is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | * Library General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU Library General Public |
---|
16 | * License along with this library; if not, write to the |
---|
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
18 | * Boston, MA 02111-1307, USA. |
---|
19 | * |
---|
20 | * Written by Owen Taylor <otaylor@redhat.com>, based on code by |
---|
21 | * Carsten Haitzler <raster@rasterman.com> |
---|
22 | */ |
---|
23 | |
---|
24 | #include <gtk/gtk.h> |
---|
25 | #include <gdk-pixbuf/gdk-pixbuf.h> |
---|
26 | |
---|
27 | /* internals */ |
---|
28 | |
---|
29 | typedef struct _ThemeData ThemeData; |
---|
30 | typedef struct _ThemeImage ThemeImage; |
---|
31 | typedef struct _ThemeMatchData ThemeMatchData; |
---|
32 | typedef struct _ThemePixbuf ThemePixbuf; |
---|
33 | |
---|
34 | enum |
---|
35 | { |
---|
36 | TOKEN_IMAGE = G_TOKEN_LAST + 1, |
---|
37 | TOKEN_FUNCTION, |
---|
38 | TOKEN_FILE, |
---|
39 | TOKEN_STRETCH, |
---|
40 | TOKEN_RECOLORABLE, |
---|
41 | TOKEN_BORDER, |
---|
42 | TOKEN_DETAIL, |
---|
43 | TOKEN_STATE, |
---|
44 | TOKEN_SHADOW, |
---|
45 | TOKEN_GAP_SIDE, |
---|
46 | TOKEN_GAP_FILE, |
---|
47 | TOKEN_GAP_BORDER, |
---|
48 | TOKEN_GAP_START_FILE, |
---|
49 | TOKEN_GAP_START_BORDER, |
---|
50 | TOKEN_GAP_END_FILE, |
---|
51 | TOKEN_GAP_END_BORDER, |
---|
52 | TOKEN_OVERLAY_FILE, |
---|
53 | TOKEN_OVERLAY_BORDER, |
---|
54 | TOKEN_OVERLAY_STRETCH, |
---|
55 | TOKEN_ARROW_DIRECTION, |
---|
56 | TOKEN_D_HLINE, |
---|
57 | TOKEN_D_VLINE, |
---|
58 | TOKEN_D_SHADOW, |
---|
59 | TOKEN_D_POLYGON, |
---|
60 | TOKEN_D_ARROW, |
---|
61 | TOKEN_D_DIAMOND, |
---|
62 | TOKEN_D_OVAL, |
---|
63 | TOKEN_D_STRING, |
---|
64 | TOKEN_D_BOX, |
---|
65 | TOKEN_D_FLAT_BOX, |
---|
66 | TOKEN_D_CHECK, |
---|
67 | TOKEN_D_OPTION, |
---|
68 | TOKEN_D_CROSS, |
---|
69 | TOKEN_D_RAMP, |
---|
70 | TOKEN_D_TAB, |
---|
71 | TOKEN_D_SHADOW_GAP, |
---|
72 | TOKEN_D_BOX_GAP, |
---|
73 | TOKEN_D_EXTENSION, |
---|
74 | TOKEN_D_FOCUS, |
---|
75 | TOKEN_D_SLIDER, |
---|
76 | TOKEN_D_ENTRY, |
---|
77 | TOKEN_D_HANDLE, |
---|
78 | TOKEN_D_STEPPER, |
---|
79 | TOKEN_TRUE, |
---|
80 | TOKEN_FALSE, |
---|
81 | TOKEN_TOP, |
---|
82 | TOKEN_UP, |
---|
83 | TOKEN_BOTTOM, |
---|
84 | TOKEN_DOWN, |
---|
85 | TOKEN_LEFT, |
---|
86 | TOKEN_RIGHT, |
---|
87 | TOKEN_NORMAL, |
---|
88 | TOKEN_ACTIVE, |
---|
89 | TOKEN_PRELIGHT, |
---|
90 | TOKEN_SELECTED, |
---|
91 | TOKEN_INSENSITIVE, |
---|
92 | TOKEN_NONE, |
---|
93 | TOKEN_IN, |
---|
94 | TOKEN_OUT, |
---|
95 | TOKEN_ETCHED_IN, |
---|
96 | TOKEN_ETCHED_OUT, |
---|
97 | TOKEN_ORIENTATION, |
---|
98 | TOKEN_HORIZONTAL, |
---|
99 | TOKEN_VERTICAL |
---|
100 | }; |
---|
101 | |
---|
102 | typedef enum |
---|
103 | { |
---|
104 | COMPONENT_NORTH_WEST = 1 << 0, |
---|
105 | COMPONENT_NORTH = 1 << 1, |
---|
106 | COMPONENT_NORTH_EAST = 1 << 2, |
---|
107 | COMPONENT_WEST = 1 << 3, |
---|
108 | COMPONENT_CENTER = 1 << 4, |
---|
109 | COMPONENT_EAST = 1 << 5, |
---|
110 | COMPONENT_SOUTH_EAST = 1 << 6, |
---|
111 | COMPONENT_SOUTH = 1 << 7, |
---|
112 | COMPONENT_SOUTH_WEST = 1 << 8, |
---|
113 | COMPONENT_ALL = 1 << 9 |
---|
114 | } ThemePixbufComponent; |
---|
115 | |
---|
116 | typedef enum { |
---|
117 | THEME_MATCH_GAP_SIDE = 1 << 0, |
---|
118 | THEME_MATCH_ORIENTATION = 1 << 1, |
---|
119 | THEME_MATCH_STATE = 1 << 2, |
---|
120 | THEME_MATCH_SHADOW = 1 << 3, |
---|
121 | THEME_MATCH_ARROW_DIRECTION = 1 << 4 |
---|
122 | } ThemeMatchFlags; |
---|
123 | |
---|
124 | typedef enum { |
---|
125 | THEME_CONSTANT_ROWS = 1 << 0, |
---|
126 | THEME_CONSTANT_COLS = 1 << 1, |
---|
127 | THEME_MISSING = 1 << 2 |
---|
128 | } ThemeRenderHints; |
---|
129 | |
---|
130 | struct _ThemePixbuf |
---|
131 | { |
---|
132 | gchar *filename; |
---|
133 | GdkPixbuf *pixbuf; |
---|
134 | gboolean stretch; |
---|
135 | gint border_left; |
---|
136 | gint border_right; |
---|
137 | gint border_bottom; |
---|
138 | gint border_top; |
---|
139 | guint hints[3][3]; |
---|
140 | }; |
---|
141 | |
---|
142 | struct _ThemeMatchData |
---|
143 | { |
---|
144 | guint function; /* Mandatory */ |
---|
145 | gchar *detail; |
---|
146 | |
---|
147 | ThemeMatchFlags flags; |
---|
148 | |
---|
149 | GtkPositionType gap_side; |
---|
150 | GtkOrientation orientation; |
---|
151 | GtkStateType state; |
---|
152 | GtkShadowType shadow; |
---|
153 | GtkArrowType arrow_direction; |
---|
154 | }; |
---|
155 | |
---|
156 | struct _ThemeImage |
---|
157 | { |
---|
158 | guint refcount; |
---|
159 | |
---|
160 | ThemePixbuf *background; |
---|
161 | ThemePixbuf *overlay; |
---|
162 | ThemePixbuf *gap_start; |
---|
163 | ThemePixbuf *gap; |
---|
164 | ThemePixbuf *gap_end; |
---|
165 | |
---|
166 | gchar recolorable; |
---|
167 | |
---|
168 | ThemeMatchData match_data; |
---|
169 | }; |
---|
170 | |
---|
171 | |
---|
172 | ThemePixbuf *theme_pixbuf_new (void); |
---|
173 | void theme_pixbuf_destroy (ThemePixbuf *theme_pb); |
---|
174 | void theme_pixbuf_set_filename (ThemePixbuf *theme_pb, |
---|
175 | const char *filename); |
---|
176 | GdkPixbuf * theme_pixbuf_get_pixbuf (ThemePixbuf *theme_pb); |
---|
177 | void theme_pixbuf_set_border (ThemePixbuf *theme_pb, |
---|
178 | gint left, |
---|
179 | gint right, |
---|
180 | gint top, |
---|
181 | gint bottom); |
---|
182 | void theme_pixbuf_set_stretch (ThemePixbuf *theme_pb, |
---|
183 | gboolean stretch); |
---|
184 | void theme_pixbuf_render (ThemePixbuf *theme_pb, |
---|
185 | GdkWindow *window, |
---|
186 | GdkBitmap *mask, |
---|
187 | GdkRectangle *clip_rect, |
---|
188 | guint component_mask, |
---|
189 | gboolean center, |
---|
190 | gint dest_x, |
---|
191 | gint dest_y, |
---|
192 | gint dest_width, |
---|
193 | gint dest_height); |
---|