[CpmlPrimitive] Do not return anything from cpml_primitive_copy()
[adg.git] / adg / adg-dress-builtins.c
blobc7e52d3d6819efedce08c70156176e242411c6cf
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-internal.h"
34 #include "adg-dress-builtins.h"
35 #include "adg-color-style.h"
36 #include "adg-line-style.h"
37 #include "adg-font-style.h"
38 #include "adg-dim-style.h"
39 #include "adg-arrow.h"
40 #include "adg-ruled-fill.h"
41 #include "adg-table-style.h"
44 /**
45 * ADG_DRESS_UNDEFINED:
47 * A value reperesenting an undefined #AdgDress.
48 **/
50 /**
51 * ADG_DRESS_COLOR:
53 * The default builtin #AdgDress color. This is a transparent dress
54 * without a fallback style.
56 * This dress will be resolved to an #AdgColorStyle instance.
57 **/
58 AdgDress
59 _adg_dress_color(void)
61 static AdgDress dress = 0;
63 if (G_UNLIKELY(dress == 0)) {
64 dress = adg_dress_new_full("color", NULL, ADG_TYPE_COLOR_STYLE);
67 return dress;
70 /**
71 * ADG_DRESS_COLOR_STROKE:
73 * The default builtin #AdgDress color for #AdgStroke entities.
74 * The fallback style is the default implementation of #AdgColor
75 * (that is %black).
77 * This dress will be resolved to an #AdgColorStyle instance.
78 **/
79 AdgDress
80 _adg_dress_color_stroke(void)
82 static AdgDress dress = 0;
84 if (G_UNLIKELY(dress == 0)) {
85 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE, NULL);
87 dress = adg_dress_new("color-stroke", fallback);
88 g_object_unref(fallback);
91 return dress;
94 /**
95 * ADG_DRESS_COLOR_DIMENSION:
97 * The builtin #AdgDress color used by default in #AdgDimStyle.
98 * The fallback style is a %0.75 red.
100 * This dress will be resolved to an #AdgColorStyle instance.
102 AdgDress
103 _adg_dress_color_dimension(void)
105 static AdgDress dress = 0;
107 if (G_UNLIKELY(dress == 0)) {
108 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
109 "red", 0.667, NULL);
111 dress = adg_dress_new("color-dimension", fallback);
112 g_object_unref(fallback);
115 return dress;
119 * ADG_DRESS_COLOR_HATCH:
121 * The default builtin #AdgDress color for #AdgHatch entities.
122 * The fallback style is a %0.5 blue.
124 * This dress will be resolved to an #AdgColorStyle instance.
126 AdgDress
127 _adg_dress_color_hatch(void)
129 static AdgDress dress = 0;
131 if (G_UNLIKELY(dress == 0)) {
132 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
133 "blue", 0.333, NULL);
135 dress = adg_dress_new("color-hatch", fallback);
136 g_object_unref(fallback);
139 return dress;
143 * ADG_DRESS_LINE:
145 * The default builtin #AdgDress line. This is a transparent dress
146 * without a fallback style.
148 * This dress will be resolved to an #AdgLineStyle instance.
150 AdgDress
151 _adg_dress_line(void)
153 static AdgDress dress = 0;
155 if (G_UNLIKELY(dress == 0)) {
156 dress = adg_dress_new_full("line", NULL, ADG_TYPE_LINE_STYLE);
159 return dress;
163 * ADG_DRESS_LINE_MEDIUM:
165 * The default generic builtin #AdgDress line type: it is used by
166 * default for rendering #AdgStroke entities. The fallback style
167 * is a default line with a thickness of %1.5.
169 * This dress will be resolved to an #AdgLineStyle instance.
171 AdgDress
172 _adg_dress_line_medium(void)
174 static AdgDress dress = 0;
176 if (G_UNLIKELY(dress == 0)) {
177 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
178 "width", 1.5, NULL);
180 dress = adg_dress_new("line-medium", fallback);
181 g_object_unref(fallback);
184 return dress;
188 * ADG_DRESS_LINE_THIN:
190 * A generic builtin #AdgDress line type for thin lines.
191 * The fallback style is a default line with a thickness of %1.
193 * This dress will be resolved to an #AdgLineStyle instance.
195 AdgDress
196 _adg_dress_line_thin(void)
198 static AdgDress dress = 0;
200 if (G_UNLIKELY(dress == 0)) {
201 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
202 "width", 1., NULL);
204 dress = adg_dress_new("line-thin", fallback);
205 g_object_unref(fallback);
208 return dress;
212 * ADG_DRESS_LINE_THICK:
214 * A generic builtin #AdgDress line type for thick lines.
215 * The fallback style is a default line with a thickness of %2.
217 * This dress will be resolved to an #AdgLineStyle instance.
219 AdgDress
220 _adg_dress_line_thick(void)
222 static AdgDress dress = 0;
224 if (G_UNLIKELY(dress == 0)) {
225 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
226 "width", 2., NULL);
228 dress = adg_dress_new("line-thick", fallback);
229 g_object_unref(fallback);
232 return dress;
236 * ADG_DRESS_LINE_THINNER:
238 * A generic builtin #AdgDress line type for really thin lines:
239 * it is used by default for rendering base and extension lines
240 * of dimension entities. The fallback style is a default line
241 * with a thickness of %0.75.
243 * This dress will be resolved to an #AdgLineStyle instance.
245 AdgDress
246 _adg_dress_line_thinner(void)
248 static AdgDress dress = 0;
250 if (G_UNLIKELY(dress == 0)) {
251 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
252 "width", 0.75, NULL);
254 dress = adg_dress_new("line-thinner", fallback);
255 g_object_unref(fallback);
258 return dress;
262 * ADG_DRESS_LINE_THICKER:
264 * A generic builtin #AdgDress line type for really thick lines.
265 * The fallback style is a default line with a thickness of %2.5.
267 * This dress will be resolved to an #AdgLineStyle instance.
269 AdgDress
270 _adg_dress_line_thicker(void)
272 static AdgDress dress = 0;
274 if (G_UNLIKELY(dress == 0)) {
275 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
276 "width", 2.5, NULL);
278 dress = adg_dress_new("line-thicker", fallback);
279 g_object_unref(fallback);
282 return dress;
286 * ADG_DRESS_LINE_HATCH:
288 * The builtin #AdgDress line type used by the default #AdgRuledFill
289 * style implementation. The fallback style is a default line with
290 * a thickness of %1 and an #ADG_DRESS_COLOR_HATCH color dress.
292 * This dress will be resolved to an #AdgLineStyle instance.
294 AdgDress
295 _adg_dress_line_hatch(void)
297 static AdgDress dress = 0;
299 if (G_UNLIKELY(dress == 0)) {
300 AdgLineStyle *thin_style;
301 AdgStyle *fallback;
303 thin_style = (AdgLineStyle *) adg_dress_get_fallback(ADG_DRESS_LINE_THIN);
304 fallback = g_object_new(ADG_TYPE_LINE_STYLE,
305 "width", adg_line_style_get_width(thin_style),
306 "color-dress", ADG_DRESS_COLOR_HATCH, NULL);
308 dress = adg_dress_new("line-hatch", fallback);
309 g_object_unref(fallback);
312 return dress;
316 * ADG_DRESS_LINE_GRID:
318 * The builtin #AdgDress line type used for rendering grids of
319 * #AdgTable entities. The fallback style is a default line with
320 * a thickness of %1 and no antialiasing.
322 * This dress will be resolved to an #AdgLineStyle instance.
324 AdgDress
325 _adg_dress_line_grid(void)
327 static AdgDress dress = 0;
329 if (G_UNLIKELY(dress == 0)) {
330 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
331 "antialias", CAIRO_ANTIALIAS_NONE,
332 "width", 1., NULL);
334 dress = adg_dress_new("line-grid", fallback);
335 g_object_unref(fallback);
338 return dress;
342 * ADG_DRESS_LINE_FRAME:
344 * The builtin #AdgDress line type used for rendering frames of
345 * #AdgTable entities. The fallback style is a default line with
346 * a thickness of %2 and no antialiasing.
348 * This dress will be resolved to an #AdgLineStyle instance.
350 AdgDress
351 _adg_dress_line_frame(void)
353 static AdgDress dress = 0;
355 if (G_UNLIKELY(dress == 0)) {
356 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
357 "antialias", CAIRO_ANTIALIAS_NONE,
358 "width", 2., NULL);
360 dress = adg_dress_new("line-frame", fallback);
361 g_object_unref(fallback);
364 return dress;
368 * ADG_DRESS_TEXT:
370 * The default builtin #AdgDress font. The fallback style is
371 * %Sans %14.
373 * This dress will be resolved to an #AdgFontStyle instance.
375 AdgDress
376 _adg_dress_text(void)
378 static AdgDress dress = 0;
380 if (G_UNLIKELY(dress == 0)) {
381 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
382 "family", "Serif",
383 "size", 14., NULL);
385 dress = adg_dress_new("text", fallback);
386 g_object_unref(fallback);
389 return dress;
393 * ADG_DRESS_TEXT_VALUE:
395 * The builtin #AdgDress font used to render the nominal value of a
396 * dimension. The fallback style is %Sans %12 %bold.
398 * This dress will be resolved to an #AdgFontStyle instance.
400 AdgDress
401 _adg_dress_text_value(void)
403 static AdgDress dress = 0;
405 if (G_UNLIKELY(dress == 0)) {
406 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
407 "family", "Sans",
408 "weight", CAIRO_FONT_WEIGHT_BOLD,
409 "size", 12., NULL);
411 dress = adg_dress_new("text-value", fallback);
412 g_object_unref(fallback);
415 return dress;
419 * ADG_DRESS_TEXT_LIMIT:
421 * The builtin #AdgDress font used to render the limits of either
422 * the min and max values of a dimension. The fallback style
423 * is a %Sans %8.
425 * This dress will be resolved to an #AdgFontStyle instance.
427 AdgDress
428 _adg_dress_text_limit(void)
430 static AdgDress dress = 0;
432 if (G_UNLIKELY(dress == 0)) {
433 AdgStyle *fallback = g_object_new(ADG_TYPE_FONT_STYLE,
434 "family", "Sans",
435 "size", 8., NULL);
437 dress = adg_dress_new("text-limit", fallback);
438 g_object_unref(fallback);
441 return dress;
445 * ADG_DRESS_DIMENSION:
447 * The default builtin #AdgDress for dimensioning. The fallback
448 * style is the default #AdgDimStyle implementation with #AdgArrow
449 * as markers on both sides.
451 * This dress will be resolved to an #AdgDimStyle instance.
453 AdgDress
454 _adg_dress_dimension(void)
456 static AdgDress dress = 0;
458 if (G_UNLIKELY(dress == 0)) {
459 AdgMarker *arrow = g_object_new(ADG_TYPE_ARROW, NULL);
460 AdgStyle *fallback = g_object_new(ADG_TYPE_DIM_STYLE, NULL);
462 adg_dim_style_use_marker1((AdgDimStyle *) fallback, arrow);
463 adg_marker_set_pos(arrow, 1);
464 adg_dim_style_use_marker2((AdgDimStyle *) fallback, arrow);
466 dress = adg_dress_new("dimension", fallback);
467 g_object_unref(fallback);
468 g_object_unref(arrow);
471 return dress;
475 * ADG_DRESS_FILL:
477 * The default builtin #AdgDress for filling. This is a transparent
478 * dress without a fallback style.
480 * This dress will be resolved to an #AdgFillStyle derived instance.
482 AdgDress
483 _adg_dress_fill(void)
485 static AdgDress dress = 0;
487 if (G_UNLIKELY(dress == 0)) {
488 dress = adg_dress_new_full("fill", NULL, ADG_TYPE_FILL_STYLE);
491 return dress;
495 * ADG_DRESS_FILL_HATCH:
497 * The default builtin #AdgDress used by #AdgHatch instances.
498 * The fallback style is the default implementation of the
499 * #AdgRuledFill instance.
501 * This dress will be resolved to an #AdgFillStyle derived instance.
503 AdgDress
504 _adg_dress_fill_hatch(void)
506 static AdgDress dress = 0;
508 if (G_UNLIKELY(dress == 0)) {
509 AdgStyle *fallback = g_object_new(ADG_TYPE_RULED_FILL,
510 "line-dress", ADG_DRESS_LINE_HATCH,
511 NULL);
513 dress = adg_dress_new_full("fill-hatch", fallback,
514 ADG_TYPE_FILL_STYLE);
515 g_object_unref(fallback);
518 return dress;
522 * ADG_DRESS_TABLE:
524 * The default builtin #AdgDress for tables. The fallback style
525 * is the default implementation of the #AdgTableStyle instance.
527 * This dress will be resolved to an #AdgTableStyle derived instance.
529 AdgDress
530 _adg_dress_table(void)
532 static AdgDress dress = 0;
534 if (G_UNLIKELY(dress == 0)) {
535 AdgStyle *fallback = g_object_new(ADG_TYPE_TABLE_STYLE, NULL);
536 dress = adg_dress_new_full("table", fallback, ADG_TYPE_TABLE_STYLE);
537 g_object_unref(fallback);
540 return dress;