[build] Bumped version to 0.5.3
[adg.git] / adg / adg-dress-builtins.c
blobd2e2a489e1ca9496a25b24320ff9ade2349900db
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
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.
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.
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., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 /**
22 * SECTION:adg-dress-builtins
23 * @Section_Id:dress-builtins
24 * @title: Built-in dresses
25 * @short_description: A list of predefined dresses implemented
26 * by the ADG canvas
28 * This is a collection of built-it dresses used internally by
29 * the ADG library to provide some useful defaults.
30 **/
33 #include "adg-dress-builtins.h"
34 #include "adg-color-style.h"
35 #include "adg-line-style.h"
36 #include "adg-font-style.h"
37 #include "adg-dim-style.h"
38 #include "adg-ruled-fill.h"
39 #include "adg-arrow.h"
42 /**
43 * ADG_DRESS_UNDEFINED:
45 * A value reperesenting an undefined #AdgDress.
46 **/
48 /**
49 * ADG_DRESS_COLOR:
51 * The default builtin #AdgDress color. This is a transparent dress
52 * without a fallback style.
54 * This dress will be resolved to an #AdgColorStyle instance.
55 **/
56 AdgDress
57 _adg_dress_color(void)
59 static AdgDress dress = 0;
61 if (G_UNLIKELY(dress == 0)) {
62 dress = adg_dress_new_full("color", NULL, ADG_TYPE_COLOR_STYLE);
65 return dress;
68 /**
69 * ADG_DRESS_COLOR_STROKE:
71 * The default builtin #AdgDress color for #AdgStroke entities.
72 * The fallback style is the default implementation of #AdgColor
73 * (that is %black).
75 * This dress will be resolved to an #AdgColorStyle instance.
76 **/
77 AdgDress
78 _adg_dress_color_stroke(void)
80 static AdgDress dress = 0;
82 if (G_UNLIKELY(dress == 0)) {
83 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE, NULL);
85 dress = adg_dress_new("color-stroke", fallback);
86 g_object_unref(fallback);
89 return dress;
92 /**
93 * ADG_DRESS_COLOR_DIMENSION:
95 * The builtin #AdgDress color used by default in #AdgDimStyle.
96 * The fallback style is a %0.75 red.
98 * This dress will be resolved to an #AdgColorStyle instance.
99 **/
100 AdgDress
101 _adg_dress_color_dimension(void)
103 static AdgDress dress = 0;
105 if (G_UNLIKELY(dress == 0)) {
106 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
107 "red", 0.75, NULL);
109 dress = adg_dress_new("color-dimension", fallback);
110 g_object_unref(fallback);
113 return dress;
117 * ADG_DRESS_COLOR_HATCH:
119 * The default builtin #AdgDress color for #AdgHatch entities.
120 * The fallback style is a %0.5 blue.
122 * This dress will be resolved to an #AdgColorStyle instance.
124 AdgDress
125 _adg_dress_color_hatch(void)
127 static AdgDress dress = 0;
129 if (G_UNLIKELY(dress == 0)) {
130 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
131 "blue", 0.5, NULL);
133 dress = adg_dress_new("color-hatch", fallback);
134 g_object_unref(fallback);
137 return dress;
141 * ADG_DRESS_LINE:
143 * The default builtin #AdgDress line. This is a transparent dress
144 * without a fallback style.
146 * This dress will be resolved to an #AdgLineStyle instance.
148 AdgDress
149 _adg_dress_line(void)
151 static AdgDress dress = 0;
153 if (G_UNLIKELY(dress == 0)) {
154 dress = adg_dress_new_full("line", NULL, ADG_TYPE_LINE_STYLE);
157 return dress;
161 * ADG_DRESS_LINE_STROKE:
163 * The builtin #AdgDress line used by default by #AdgStroke entities.
164 * The fallback style is a default line with a thickness of %1.75.
166 * This dress will be resolved to an #AdgLineStyle instance.
168 AdgDress
169 _adg_dress_line_stroke(void)
171 static AdgDress dress = 0;
173 if (G_UNLIKELY(dress == 0)) {
174 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
175 "width", 1.75, NULL);
177 dress = adg_dress_new("line-stroke", fallback);
178 g_object_unref(fallback);
181 return dress;
185 * ADG_DRESS_LINE_DIMENSION:
187 * The builtin #AdgDress line type used by base and extension lines
188 * for dimensions. The fallback style is a default line with a
189 * thickness of %0.75.
191 * This dress will be resolved to an #AdgLineStyle instance.
193 AdgDress
194 _adg_dress_line_dimension(void)
196 static AdgDress dress = 0;
198 if (G_UNLIKELY(dress == 0)) {
199 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
200 "width", 0.75, NULL);
202 dress = adg_dress_new("line-dimension", fallback);
203 g_object_unref(fallback);
206 return dress;
210 * ADG_DRESS_LINE_HATCH:
212 * The builtin #AdgDress line type used by the default #AdgRuledFill
213 * style implementation. The fallback style is a default line with
214 * a thickness of %1.
216 * This dress will be resolved to an #AdgLineStyle instance.
218 AdgDress
219 _adg_dress_line_hatch(void)
221 static AdgDress dress = 0;
223 if (G_UNLIKELY(dress == 0)) {
224 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
225 "color-dress", ADG_DRESS_COLOR_HATCH,
226 "width", 1., NULL);
228 dress = adg_dress_new("line-hatch", fallback);
229 g_object_unref(fallback);
232 return dress;
236 * ADG_DRESS_TEXT:
238 * The default builtin #AdgDress font. The fallback style is
239 * %Sans %14.
241 * This dress will be resolved to an #AdgFontStyle instance.
243 AdgDress
244 _adg_dress_text(void)
246 static AdgDress dress = 0;
248 if (G_UNLIKELY(dress == 0)) {
249 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
250 "family", "Serif",
251 "size", 14., NULL);
253 dress = adg_dress_new("text", fallback);
254 g_object_unref(fallback);
257 return dress;
261 * ADG_DRESS_TEXT_VALUE:
263 * The builtin #AdgDress font used to render the nominal value of a
264 * dimension. The fallback style is %Sans %12 %bold.
266 * This dress will be resolved to an #AdgFontStyle instance.
268 AdgDress
269 _adg_dress_text_value(void)
271 static AdgDress dress = 0;
273 if (G_UNLIKELY(dress == 0)) {
274 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
275 "family", "Sans",
276 "weight", CAIRO_FONT_WEIGHT_BOLD,
277 "size", 12., NULL);
279 dress = adg_dress_new("text-value", fallback);
280 g_object_unref(fallback);
283 return dress;
287 * ADG_DRESS_TEXT_LIMIT:
289 * The builtin #AdgDress font used to render the limits of either
290 * the min and max values of a dimension. The fallback style
291 * is a %Sans %8.
293 * This dress will be resolved to an #AdgFontStyle instance.
295 AdgDress
296 _adg_dress_text_limit(void)
298 static AdgDress dress = 0;
300 if (G_UNLIKELY(dress == 0)) {
301 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
302 "family", "Sans",
303 "size", 8., NULL);
305 dress = adg_dress_new("text-limit", fallback);
306 g_object_unref(fallback);
309 return dress;
313 * ADG_DRESS_DIMENSION:
315 * The default builtin #AdgDress for dimensioning. The fallback
316 * style is the default #AdgDimStyle implementation with #AdgArrow
317 * as markers on both sides.
319 * This dress will be resolved to an #AdgDimStyle instance.
321 AdgDress
322 _adg_dress_dimension(void)
324 static AdgDress dress = 0;
326 if (G_UNLIKELY(dress == 0)) {
327 AdgMarker *arrow = g_object_new(ADG_TYPE_ARROW, NULL);
328 AdgStyle *fallback = g_object_new(ADG_TYPE_DIM_STYLE, NULL);
330 adg_dim_style_use_marker1((AdgDimStyle *) fallback, arrow);
331 adg_marker_set_pos(arrow, 1);
332 adg_dim_style_use_marker2((AdgDimStyle *) fallback, arrow);
334 dress = adg_dress_new("dimension", fallback);
335 g_object_unref(fallback);
336 g_object_unref(arrow);
339 return dress;
343 * ADG_DRESS_FILL:
345 * The default builtin #AdgDress for filling. This is a transparent
346 * dress without a fallback style.
348 * This dress will be resolved to an #AdgFillStyle derived instance.
350 AdgDress
351 _adg_dress_fill(void)
353 static AdgDress dress = 0;
355 if (G_UNLIKELY(dress == 0)) {
356 dress = adg_dress_new_full("fill", NULL, ADG_TYPE_FILL_STYLE);
359 return dress;
363 * ADG_DRESS_FILL_HATCH:
365 * The default builtin #AdgDress for used by #AdgHatch instances.
366 * The fallback style is the default implementation of the
367 * #AdgRuledFill instance.
369 * This dress will be resolved to an #AdgFillStyle derived instance.
371 AdgDress
372 _adg_dress_fill_hatch(void)
374 static AdgDress dress = 0;
376 if (G_UNLIKELY(dress == 0)) {
377 AdgStyle *fallback = g_object_new(ADG_TYPE_RULED_FILL,
378 "line-dress", ADG_DRESS_LINE_HATCH,
379 NULL);
381 dress = adg_dress_new_full("fill-hatch", fallback,
382 ADG_TYPE_FILL_STYLE);
383 g_object_unref(fallback);
386 return dress;