docs: updated copyright to 2012
[adg.git] / src / adg / adg-dress-builtins.c
blob62386b695246ce650acf82e0b6c26ebaa011b185
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012 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.
31 * Since: 1.0
32 **/
35 #include "adg-internal.h"
36 #include "adg-text-internal.h"
38 #include "adg-model.h"
39 #include "adg-trail.h"
40 #include "adg-marker.h"
41 #include "adg-pattern.h"
42 #include "adg-dress.h"
43 #include "adg-color-style.h"
44 #include "adg-line-style.h"
45 #include "adg-fill-style.h"
46 #include "adg-dim-style.h"
47 #include "adg-table-style.h"
48 #include "adg-arrow.h"
49 #include "adg-ruled-fill.h"
51 #include "adg-dress-builtins.h"
54 /**
55 * ADG_DRESS_UNDEFINED:
57 * A value reperesenting an undefined #AdgDress.
59 * Since: 1.0
60 **/
62 /**
63 * ADG_DRESS_COLOR:
65 * The default builtin #AdgDress color.
66 * This is a pass-through dress, that is it does not change
67 * the cairo context when it is applied.
69 * This dress will be resolved to an #AdgColorStyle instance.
71 * Since: 1.0
72 **/
73 AdgDress
74 _adg_dress_color(void)
76 static AdgDress dress = 0;
78 if (G_UNLIKELY(dress == 0)) {
79 dress = adg_dress_new_full("color", NULL, ADG_TYPE_COLOR_STYLE);
82 return dress;
85 /**
86 * ADG_DRESS_COLOR_BACKGROUND:
88 * The default builtin #AdgDress color to be used as the #AdgCanvas
89 * background. The fallback style is a full opaque white.
91 * This dress will be resolved to an #AdgColorStyle instance.
93 * Since: 1.0
94 **/
95 AdgDress
96 _adg_dress_color_background(void)
98 static AdgDress dress = 0;
100 if (G_UNLIKELY(dress == 0)) {
101 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
102 "blue", 1., "green", 1.,
103 "red", 1., NULL);
105 dress = adg_dress_new("color-background", fallback);
106 g_object_unref(fallback);
109 return dress;
113 * ADG_DRESS_COLOR_STROKE:
115 * The default builtin #AdgDress color for #AdgStroke entities.
116 * The fallback style is a full opaque black.
118 * This dress will be resolved to an #AdgColorStyle instance.
120 * Since: 1.0
122 AdgDress
123 _adg_dress_color_stroke(void)
125 static AdgDress dress = 0;
127 if (G_UNLIKELY(dress == 0)) {
128 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE, NULL);
130 dress = adg_dress_new("color-stroke", fallback);
131 g_object_unref(fallback);
134 return dress;
138 * ADG_DRESS_COLOR_DIMENSION:
140 * The builtin #AdgDress color used by default in #AdgDimStyle.
141 * The fallback style is a somewhat full opaque blue.
143 * This dress will be resolved to an #AdgColorStyle instance.
145 * Since: 1.0
147 AdgDress
148 _adg_dress_color_dimension(void)
150 static AdgDress dress = 0;
152 if (G_UNLIKELY(dress == 0)) {
153 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
154 "red", 0.,
155 "green", 0.4,
156 "blue", 0.6,
157 NULL);
159 dress = adg_dress_new("color-dimension", fallback);
160 g_object_unref(fallback);
163 return dress;
167 * ADG_DRESS_COLOR_ANNOTATION:
169 * The builtin #AdgDress color used for rendering helper entities
170 * such as #AdgToyText, #AdgTable and #AdgTitleBlock. The fallback
171 * style is a full opaque greenish variant.
173 * This dress will be resolved to an #AdgColorStyle instance.
175 * Since: 1.0
177 AdgDress
178 _adg_dress_color_annotation(void)
180 static AdgDress dress = 0;
182 if (G_UNLIKELY(dress == 0)) {
183 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
184 "red", 0.4,
185 "green", 0.4,
186 "blue", 0.2,
187 NULL);
189 dress = adg_dress_new("color-annotation", fallback);
190 g_object_unref(fallback);
193 return dress;
197 * ADG_DRESS_COLOR_FILL:
199 * The builtin #AdgDress color used by default by #AdgFillStyle
200 * based styles. The fallback style is a full opaque %0.25 gray.
202 * This dress will be resolved to an #AdgColorStyle instance.
204 * Since: 1.0
206 AdgDress
207 _adg_dress_color_fill(void)
209 static AdgDress dress = 0;
211 if (G_UNLIKELY(dress == 0)) {
212 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
213 "red", 0.25,
214 "green", 0.25,
215 "blue", 0.25, NULL);
217 dress = adg_dress_new("color-fill", fallback);
218 g_object_unref(fallback);
221 return dress;
225 * ADG_DRESS_LINE:
227 * The default builtin #AdgDress line.
228 * This is a pass-through dress, that is it does not change
229 * the cairo context when it is applied.
231 * This dress will be resolved to an #AdgLineStyle instance.
233 * Since: 1.0
235 AdgDress
236 _adg_dress_line(void)
238 static AdgDress dress = 0;
240 if (G_UNLIKELY(dress == 0)) {
241 dress = adg_dress_new_full("line", NULL, ADG_TYPE_LINE_STYLE);
244 return dress;
248 * ADG_DRESS_LINE_STROKE:
250 * The builtin #AdgDress line type to be used by default
251 * for rendering #AdgStroke entities. The fallback style is
252 * a line with #ADG_DRESS_COLOR_STROKE color and a thickness
253 * of %1.5.
255 * This dress will be resolved to an #AdgLineStyle instance.
257 * Since: 1.0
259 AdgDress
260 _adg_dress_line_stroke(void)
262 static AdgDress dress = 0;
264 if (G_UNLIKELY(dress == 0)) {
265 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
266 "color-dress", ADG_DRESS_COLOR_STROKE,
267 "width", 1.5, NULL);
269 dress = adg_dress_new("line-stroke", fallback);
270 g_object_unref(fallback);
273 return dress;
277 * ADG_DRESS_LINE_DIMENSION:
279 * The builtin #AdgDress line type used by default
280 * for rendering base and extension lines of dimensions.
281 * The fallback style is a line with a thickness of %0.5
282 * and a pass-through color dress.
284 * This dress will be resolved to an #AdgLineStyle instance.
286 * Since: 1.0
288 AdgDress
289 _adg_dress_line_dimension(void)
291 static AdgDress dress = 0;
293 if (G_UNLIKELY(dress == 0)) {
294 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
295 "width", 0.5, NULL);
297 dress = adg_dress_new("line-dimension", fallback);
298 g_object_unref(fallback);
301 return dress;
305 * ADG_DRESS_LINE_FILL:
307 * The builtin #AdgDress line type used by #AdgFillStyle
308 * based styles. The fallback style is a line with
309 * #ADG_DRESS_COLOR_FILL color and a thickness of %0.5.
311 * This dress will be resolved to an #AdgLineStyle instance.
313 * Since: 1.0
315 AdgDress
316 _adg_dress_line_fill(void)
318 static AdgDress dress = 0;
320 if (G_UNLIKELY(dress == 0)) {
321 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
322 "color-dress", ADG_DRESS_COLOR_FILL,
323 "width", 0.5, NULL);
325 dress = adg_dress_new("line-fill", fallback);
326 g_object_unref(fallback);
329 return dress;
333 * ADG_DRESS_LINE_GRID:
335 * The builtin #AdgDress line type used for rendering the grid
336 * of #AdgTable entities, that is the frame of the cells.
337 * The fallback style is a line with a thickness of %1 and a
338 * pass-through color dress, rendered without antialiasing.
340 * This dress will be resolved to an #AdgLineStyle instance.
342 * Since: 1.0
344 AdgDress
345 _adg_dress_line_grid(void)
347 static AdgDress dress = 0;
349 if (G_UNLIKELY(dress == 0)) {
350 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
351 "antialias", CAIRO_ANTIALIAS_NONE,
352 "width", 1., NULL);
354 dress = adg_dress_new("line-grid", fallback);
355 g_object_unref(fallback);
358 return dress;
362 * ADG_DRESS_LINE_FRAME:
364 * The builtin #AdgDress line type used for rendering the frame
365 * of #AdgTable entities, that is the frame around the whole table.
366 * The fallback style is a line with a thickness of %2 and a
367 * #ADG_DRESS_COLOR_ANNOTATION color dress, rendered without
368 * antialiasing.
370 * This dress will be resolved to an #AdgLineStyle instance.
372 * Since: 1.0
374 AdgDress
375 _adg_dress_line_frame(void)
377 static AdgDress dress = 0;
379 if (G_UNLIKELY(dress == 0)) {
380 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
381 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
382 "antialias", CAIRO_ANTIALIAS_NONE,
383 "width", 2., NULL);
385 dress = adg_dress_new("line-frame", fallback);
386 g_object_unref(fallback);
389 return dress;
393 * ADG_DRESS_FONT:
395 * The default builtin #AdgDress font. The fallback style is
396 * a %Sans %14 font with a pass-through color dress.
398 * This dress will be resolved to an #AdgFontStyle instance.
400 * Since: 1.0
402 AdgDress
403 _adg_dress_font(void)
405 static AdgDress dress = 0;
407 if (G_UNLIKELY(dress == 0)) {
408 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
409 "family", "Serif",
410 "size", 14., NULL);
412 dress = adg_dress_new("font", fallback);
413 g_object_unref(fallback);
416 return dress;
420 * ADG_DRESS_FONT_TEXT:
422 * The builtin #AdgDress font used by default for rendering
423 * common text such as #AdgToyText or the value of #AdgTable
424 * entities. The fallback style is %Sans %12 %bold with an
425 * #ADG_DRESS_COLOR_ANNOTATION color dress.
427 * This dress will be resolved to an #AdgFontStyle instance.
429 * Since: 1.0
431 AdgDress
432 _adg_dress_font_text(void)
434 static AdgDress dress = 0;
436 if (G_UNLIKELY(dress == 0)) {
437 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
438 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
439 "family", "Sans",
440 "weight", CAIRO_FONT_WEIGHT_BOLD,
441 "size", 12., NULL);
443 dress = adg_dress_new("font-text", fallback);
444 g_object_unref(fallback);
447 return dress;
451 * ADG_DRESS_FONT_ANNOTATION:
453 * The builtin #AdgDress font used for rendering auxiliary text,
454 * such as the titles on #AdgTable entities. The fallback style
455 * is a %Sans %8 with an #ADG_DRESS_COLOR_ANNOTATION color dress.
457 * This dress will be resolved to an #AdgFontStyle instance.
459 * Since: 1.0
461 AdgDress
462 _adg_dress_font_annotation(void)
464 static AdgDress dress = 0;
466 if (G_UNLIKELY(dress == 0)) {
467 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
468 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
469 "family", "Sans",
470 "size", 8., NULL);
472 dress = adg_dress_new("font-annotation", fallback);
473 g_object_unref(fallback);
476 return dress;
480 * ADG_DRESS_FONT_QUOTE_TEXT:
482 * The builtin #AdgDress font used for rendering regular text
483 * on dimension entities, such as the nominal value and the
484 * notes of a quote. The fallback style is %Sans %12 %bold with
485 * a pass-through color dress.
487 * This dress will be resolved to an #AdgFontStyle instance.
489 * Since: 1.0
491 AdgDress
492 _adg_dress_font_quote_text(void)
494 static AdgDress dress = 0;
496 if (G_UNLIKELY(dress == 0)) {
497 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
498 "family", "Sans",
499 "weight", CAIRO_FONT_WEIGHT_BOLD,
500 "size", 12., NULL);
502 dress = adg_dress_new("font-quote-text", fallback);
503 g_object_unref(fallback);
506 return dress;
510 * ADG_DRESS_FONT_QUOTE_ANNOTATION:
512 * The builtin #AdgDress font used for rendering auxiliary text
513 * on dimension entities, such as the min and max limits of a
514 * quote. The fallback style is a %Sans %8 with a pass-through
515 * color dress.
517 * This dress will be resolved to an #AdgFontStyle instance.
519 * Since: 1.0
521 AdgDress
522 _adg_dress_font_quote_annotation(void)
524 static AdgDress dress = 0;
526 if (G_UNLIKELY(dress == 0)) {
527 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
528 "family", "Sans",
529 "size", 8., NULL);
531 dress = adg_dress_new("font-quote-annotation", fallback);
532 g_object_unref(fallback);
535 return dress;
539 * ADG_DRESS_DIMENSION:
541 * The default builtin #AdgDress for dimensions. The fallback
542 * style is the default #AdgDimStyle implementation with
543 * #AdgArrow markers (as returned by adg_arrow_new() on both sides.
545 * This dress will be resolved to an #AdgDimStyle instance.
547 * Since: 1.0
549 AdgDress
550 _adg_dress_dimension(void)
552 static AdgDress dress = 0;
554 if (G_UNLIKELY(dress == 0)) {
555 AdgMarker *arrow = (AdgMarker *) adg_arrow_new();
556 AdgStyle *fallback = g_object_new(ADG_TYPE_DIM_STYLE, NULL);
558 adg_dim_style_set_marker1((AdgDimStyle *) fallback, arrow);
559 adg_marker_set_pos(arrow, 1);
560 adg_dim_style_set_marker2((AdgDimStyle *) fallback, arrow);
562 dress = adg_dress_new("dimension", fallback);
563 g_object_unref(fallback);
564 g_object_unref(arrow);
567 return dress;
571 * ADG_DRESS_FILL:
573 * The default builtin #AdgDress for filling.
574 * This is a pass-through dress, that is it does not change
575 * the cairo context when it is applied.
577 * This dress will be resolved to an #AdgFillStyle derived instance.
579 * Since: 1.0
581 AdgDress
582 _adg_dress_fill(void)
584 static AdgDress dress = 0;
586 if (G_UNLIKELY(dress == 0)) {
587 dress = adg_dress_new_full("fill", NULL, ADG_TYPE_FILL_STYLE);
590 return dress;
594 * ADG_DRESS_FILL_HATCH:
596 * The builtin dress used by default by #AdgHatch instances.
597 * The fallback style is the default implementation of the
598 * #AdgRuledFill instance.
600 * This dress will be resolved to an #AdgFillStyle derived instance.
602 * Since: 1.0
604 AdgDress
605 _adg_dress_fill_hatch(void)
607 static AdgDress dress = 0;
609 if (G_UNLIKELY(dress == 0)) {
610 AdgStyle *fallback = g_object_new(ADG_TYPE_RULED_FILL,
611 "line-dress", ADG_DRESS_LINE_FILL,
612 NULL);
614 dress = adg_dress_new_full("fill-hatch", fallback, ADG_TYPE_FILL_STYLE);
615 g_object_unref(fallback);
618 return dress;
622 * ADG_DRESS_TABLE:
624 * The default builtin #AdgDress for tables. The fallback style
625 * is the default implementation of the #AdgTableStyle instance.
627 * This dress will be resolved to an #AdgTableStyle derived instance.
629 * Since: 1.0
631 AdgDress
632 _adg_dress_table(void)
634 static AdgDress dress = 0;
636 if (G_UNLIKELY(dress == 0)) {
637 AdgStyle *fallback = g_object_new(ADG_TYPE_TABLE_STYLE, NULL);
638 dress = adg_dress_new_full("table", fallback, ADG_TYPE_TABLE_STYLE);
639 g_object_unref(fallback);
642 return dress;