doc: updated italian translations
[adg.git] / src / adg / adg-dress-builtins.c
blob7b845da2b2a04834183e9ac6a0b732e3485d5a34
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-dash.h"
45 #include "adg-line-style.h"
46 #include "adg-fill-style.h"
47 #include "adg-dim-style.h"
48 #include "adg-table-style.h"
49 #include "adg-arrow.h"
50 #include "adg-ruled-fill.h"
52 #include "adg-dress-builtins.h"
54 #define MM *2.83464566927
57 /**
58 * ADG_DRESS_UNDEFINED:
60 * A value reperesenting an undefined #AdgDress.
62 * Since: 1.0
63 **/
65 /**
66 * ADG_DRESS_COLOR:
68 * The default builtin #AdgDress color.
69 * This is a pass-through dress, that is it does not change
70 * the cairo context when it is applied.
72 * This dress will be resolved to an #AdgColorStyle instance.
74 * Since: 1.0
75 **/
76 AdgDress
77 _adg_dress_color(void)
79 static AdgDress dress = 0;
81 if (G_UNLIKELY(dress == 0)) {
82 dress = adg_dress_new_full("color", NULL, ADG_TYPE_COLOR_STYLE);
85 return dress;
88 /**
89 * ADG_DRESS_COLOR_BACKGROUND:
91 * The default builtin #AdgDress color to be used as the #AdgCanvas
92 * background. The fallback style is a full opaque white.
94 * This dress will be resolved to an #AdgColorStyle instance.
96 * Since: 1.0
97 **/
98 AdgDress
99 _adg_dress_color_background(void)
101 static AdgDress dress = 0;
103 if (G_UNLIKELY(dress == 0)) {
104 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
105 "blue", 1., "green", 1.,
106 "red", 1., NULL);
108 dress = adg_dress_new("color-background", fallback);
109 g_object_unref(fallback);
112 return dress;
116 * ADG_DRESS_COLOR_STROKE:
118 * The default builtin #AdgDress color for #AdgStroke entities.
119 * The fallback style is a full opaque black.
121 * This dress will be resolved to an #AdgColorStyle instance.
123 * Since: 1.0
125 AdgDress
126 _adg_dress_color_stroke(void)
128 static AdgDress dress = 0;
130 if (G_UNLIKELY(dress == 0)) {
131 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE, NULL);
133 dress = adg_dress_new("color-stroke", fallback);
134 g_object_unref(fallback);
137 return dress;
141 * ADG_DRESS_COLOR_DIMENSION:
143 * The builtin #AdgDress color used by default in #AdgDimStyle.
144 * The fallback style is a somewhat full opaque blue.
146 * This dress will be resolved to an #AdgColorStyle instance.
148 * Since: 1.0
150 AdgDress
151 _adg_dress_color_dimension(void)
153 static AdgDress dress = 0;
155 if (G_UNLIKELY(dress == 0)) {
156 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
157 "red", 0.,
158 "green", 0.4,
159 "blue", 0.6,
160 NULL);
162 dress = adg_dress_new("color-dimension", fallback);
163 g_object_unref(fallback);
166 return dress;
170 * ADG_DRESS_COLOR_ANNOTATION:
172 * The builtin #AdgDress color used for rendering helper entities
173 * such as #AdgToyText, #AdgTable and #AdgTitleBlock. The fallback
174 * style is a full opaque greenish variant.
176 * This dress will be resolved to an #AdgColorStyle instance.
178 * Since: 1.0
180 AdgDress
181 _adg_dress_color_annotation(void)
183 static AdgDress dress = 0;
185 if (G_UNLIKELY(dress == 0)) {
186 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
187 "red", 0.4,
188 "green", 0.4,
189 "blue", 0.2,
190 NULL);
192 dress = adg_dress_new("color-annotation", fallback);
193 g_object_unref(fallback);
196 return dress;
200 * ADG_DRESS_COLOR_FILL:
202 * The builtin #AdgDress color used by default by #AdgFillStyle
203 * based styles. The fallback style is a full opaque %0.25 gray.
205 * This dress will be resolved to an #AdgColorStyle instance.
207 * Since: 1.0
209 AdgDress
210 _adg_dress_color_fill(void)
212 static AdgDress dress = 0;
214 if (G_UNLIKELY(dress == 0)) {
215 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
216 "red", 0.25,
217 "green", 0.25,
218 "blue", 0.25, NULL);
220 dress = adg_dress_new("color-fill", fallback);
221 g_object_unref(fallback);
224 return dress;
228 * ADG_DRESS_COLOR_AXIS:
230 * The default builtin #AdgDress color for stroking #ADG_DRESS_LINE_AXIS
231 * lines. The fallback color is green.
233 * This dress will be resolved to an #AdgColorStyle instance.
235 * Since: 1.0
237 AdgDress
238 _adg_dress_color_axis(void)
240 static AdgDress dress = 0;
242 if (G_UNLIKELY(dress == 0)) {
243 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
244 "red", 0.,
245 "green", 0.75,
246 "blue", 0.25, NULL);
248 dress = adg_dress_new("color-axis", fallback);
249 g_object_unref(fallback);
252 return dress;
256 * ADG_DRESS_COLOR_HIDDEN:
258 * The default builtin #AdgDress color for stroking #ADG_DRESS_LINE_HIDDEN
259 * lines. The fallback color is gray.
261 * This dress will be resolved to an #AdgColorStyle instance.
263 * Since: 1.0
265 AdgDress
266 _adg_dress_color_hidden(void)
268 static AdgDress dress = 0;
270 if (G_UNLIKELY(dress == 0)) {
271 AdgStyle *fallback = g_object_new(ADG_TYPE_COLOR_STYLE,
272 "red", 0.5,
273 "green", 0.5,
274 "blue", 0.5, NULL);
276 dress = adg_dress_new("color-hidden", fallback);
277 g_object_unref(fallback);
280 return dress;
284 * ADG_DRESS_LINE:
286 * The default builtin #AdgDress line.
287 * This is a pass-through dress, that is it does not change
288 * the cairo context when it is applied.
290 * This dress will be resolved to an #AdgLineStyle instance.
292 * Since: 1.0
294 AdgDress
295 _adg_dress_line(void)
297 static AdgDress dress = 0;
299 if (G_UNLIKELY(dress == 0)) {
300 dress = adg_dress_new_full("line", NULL, ADG_TYPE_LINE_STYLE);
303 return dress;
307 * ADG_DRESS_LINE_STROKE:
309 * The builtin #AdgDress line type to be used by default
310 * for rendering #AdgStroke entities. The fallback style is
311 * a line with #ADG_DRESS_COLOR_STROKE color and a thickness
312 * of %1.5.
314 * This dress will be resolved to an #AdgLineStyle instance.
316 * Since: 1.0
318 AdgDress
319 _adg_dress_line_stroke(void)
321 static AdgDress dress = 0;
323 if (G_UNLIKELY(dress == 0)) {
324 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
325 "color-dress", ADG_DRESS_COLOR_STROKE,
326 "width", 1.5, NULL);
328 dress = adg_dress_new("line-stroke", fallback);
329 g_object_unref(fallback);
332 return dress;
336 * ADG_DRESS_LINE_DIMENSION:
338 * The builtin #AdgDress line type used by default
339 * for rendering base and extension lines of dimensions.
340 * The fallback style is a line with a thickness of %0.5
341 * and a pass-through color dress.
343 * This dress will be resolved to an #AdgLineStyle instance.
345 * Since: 1.0
347 AdgDress
348 _adg_dress_line_dimension(void)
350 static AdgDress dress = 0;
352 if (G_UNLIKELY(dress == 0)) {
353 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
354 "width", 0.5, NULL);
356 dress = adg_dress_new("line-dimension", fallback);
357 g_object_unref(fallback);
360 return dress;
364 * ADG_DRESS_LINE_FILL:
366 * The builtin #AdgDress line type used by #AdgFillStyle
367 * based styles. The fallback style is a line with
368 * #ADG_DRESS_COLOR_FILL color and a thickness of %0.5.
370 * This dress will be resolved to an #AdgLineStyle instance.
372 * Since: 1.0
374 AdgDress
375 _adg_dress_line_fill(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_FILL,
382 "width", 0.5, NULL);
384 dress = adg_dress_new("line-fill", fallback);
385 g_object_unref(fallback);
388 return dress;
392 * ADG_DRESS_LINE_GRID:
394 * The builtin #AdgDress line type used for rendering the grid
395 * of #AdgTable entities, that is the frame of the cells.
396 * The fallback style is a line with a thickness of %1 and a
397 * pass-through color dress, rendered without antialiasing.
399 * This dress will be resolved to an #AdgLineStyle instance.
401 * Since: 1.0
403 AdgDress
404 _adg_dress_line_grid(void)
406 static AdgDress dress = 0;
408 if (G_UNLIKELY(dress == 0)) {
409 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
410 "antialias", CAIRO_ANTIALIAS_NONE,
411 "width", 1., NULL);
413 dress = adg_dress_new("line-grid", fallback);
414 g_object_unref(fallback);
417 return dress;
421 * ADG_DRESS_LINE_FRAME:
423 * The builtin #AdgDress line type used for rendering the frame
424 * of #AdgTable entities, that is the frame around the whole table.
425 * The fallback style is a line with a thickness of %2 and a
426 * #ADG_DRESS_COLOR_ANNOTATION color dress, rendered without
427 * antialiasing.
429 * This dress will be resolved to an #AdgLineStyle instance.
431 * Since: 1.0
433 AdgDress
434 _adg_dress_line_frame(void)
436 static AdgDress dress = 0;
438 if (G_UNLIKELY(dress == 0)) {
439 AdgStyle *fallback = g_object_new(ADG_TYPE_LINE_STYLE,
440 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
441 "antialias", CAIRO_ANTIALIAS_NONE,
442 "width", 2., NULL);
444 dress = adg_dress_new("line-frame", fallback);
445 g_object_unref(fallback);
448 return dress;
452 * ADG_DRESS_LINE_AXIS:
454 * The builtin #AdgDress line type used for rendering axis and
455 * centerlines.
457 * This dress will be resolved to an #AdgLineStyle instance.
459 * Since: 1.0
461 AdgDress
462 _adg_dress_line_axis(void)
464 static AdgDress dress = 0;
466 if (G_UNLIKELY(dress == 0)) {
467 AdgDash *dash;
468 AdgStyle *fallback;
470 dash = adg_dash_new_with_dashes(4, 2 MM, 2 MM, 10 MM, 2 MM);
471 fallback = g_object_new(ADG_TYPE_LINE_STYLE,
472 "dash", dash,
473 "color-dress", ADG_DRESS_COLOR_AXIS,
474 "width", 0.25 MM, NULL);
475 adg_dash_destroy(dash);
477 dress = adg_dress_new("line-axis", fallback);
478 g_object_unref(fallback);
481 return dress;
485 * ADG_DRESS_LINE_HIDDEN:
487 * The builtin #AdgDress line type used for rendering hidden
488 * lines and edges.
490 * This dress will be resolved to an #AdgLineStyle instance.
492 * Since: 1.0
494 AdgDress
495 _adg_dress_line_hidden(void)
497 static AdgDress dress = 0;
499 if (G_UNLIKELY(dress == 0)) {
500 AdgDash *dash;
501 AdgStyle *fallback;
503 dash = adg_dash_new_with_dashes(2, 6 MM, 6 MM);
504 fallback = g_object_new(ADG_TYPE_LINE_STYLE,
505 "dash", dash,
506 "color-dress", ADG_DRESS_COLOR_HIDDEN,
507 "width", 0.25 MM, NULL);
508 adg_dash_destroy(dash);
510 dress = adg_dress_new("line-hidden", fallback);
511 g_object_unref(fallback);
514 return dress;
518 * ADG_DRESS_FONT:
520 * The default builtin #AdgDress font. The fallback style is
521 * a %Sans %14 font with a pass-through color dress.
523 * This dress will be resolved to an #AdgFontStyle instance.
525 * Since: 1.0
527 AdgDress
528 _adg_dress_font(void)
530 static AdgDress dress = 0;
532 if (G_UNLIKELY(dress == 0)) {
533 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
534 "family", "Serif",
535 "size", 14., NULL);
537 dress = adg_dress_new("font", fallback);
538 g_object_unref(fallback);
541 return dress;
545 * ADG_DRESS_FONT_TEXT:
547 * The builtin #AdgDress font used by default for rendering
548 * common text such as #AdgToyText or the value of #AdgTable
549 * entities. The fallback style is %Sans %12 %bold with an
550 * #ADG_DRESS_COLOR_ANNOTATION color dress.
552 * This dress will be resolved to an #AdgFontStyle instance.
554 * Since: 1.0
556 AdgDress
557 _adg_dress_font_text(void)
559 static AdgDress dress = 0;
561 if (G_UNLIKELY(dress == 0)) {
562 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
563 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
564 "family", "Sans",
565 "weight", CAIRO_FONT_WEIGHT_BOLD,
566 "size", 12., NULL);
568 dress = adg_dress_new("font-text", fallback);
569 g_object_unref(fallback);
572 return dress;
576 * ADG_DRESS_FONT_ANNOTATION:
578 * The builtin #AdgDress font used for rendering auxiliary text,
579 * such as the titles on #AdgTable entities. The fallback style
580 * is a %Sans %8 with an #ADG_DRESS_COLOR_ANNOTATION color dress.
582 * This dress will be resolved to an #AdgFontStyle instance.
584 * Since: 1.0
586 AdgDress
587 _adg_dress_font_annotation(void)
589 static AdgDress dress = 0;
591 if (G_UNLIKELY(dress == 0)) {
592 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
593 "color-dress", ADG_DRESS_COLOR_ANNOTATION,
594 "family", "Sans",
595 "size", 8., NULL);
597 dress = adg_dress_new("font-annotation", fallback);
598 g_object_unref(fallback);
601 return dress;
605 * ADG_DRESS_FONT_QUOTE_TEXT:
607 * The builtin #AdgDress font used for rendering regular text
608 * on dimension entities, such as the nominal value and the
609 * notes of a quote. The fallback style is %Sans %12 %bold with
610 * a pass-through color dress.
612 * This dress will be resolved to an #AdgFontStyle instance.
614 * Since: 1.0
616 AdgDress
617 _adg_dress_font_quote_text(void)
619 static AdgDress dress = 0;
621 if (G_UNLIKELY(dress == 0)) {
622 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
623 "family", "Sans",
624 "weight", CAIRO_FONT_WEIGHT_BOLD,
625 "size", 12., NULL);
627 dress = adg_dress_new("font-quote-text", fallback);
628 g_object_unref(fallback);
631 return dress;
635 * ADG_DRESS_FONT_QUOTE_ANNOTATION:
637 * The builtin #AdgDress font used for rendering auxiliary text
638 * on dimension entities, such as the min and max limits of a
639 * quote. The fallback style is a %Sans %8 with a pass-through
640 * color dress.
642 * This dress will be resolved to an #AdgFontStyle instance.
644 * Since: 1.0
646 AdgDress
647 _adg_dress_font_quote_annotation(void)
649 static AdgDress dress = 0;
651 if (G_UNLIKELY(dress == 0)) {
652 AdgStyle *fallback = g_object_new(ADG_TYPE_BEST_FONT_STYLE,
653 "family", "Sans",
654 "size", 8., NULL);
656 dress = adg_dress_new("font-quote-annotation", fallback);
657 g_object_unref(fallback);
660 return dress;
664 * ADG_DRESS_DIMENSION:
666 * The default builtin #AdgDress for dimensions. The fallback
667 * style is the default #AdgDimStyle implementation with
668 * #AdgArrow markers (as returned by adg_arrow_new() on both sides.
670 * This dress will be resolved to an #AdgDimStyle instance.
672 * Since: 1.0
674 AdgDress
675 _adg_dress_dimension(void)
677 static AdgDress dress = 0;
679 if (G_UNLIKELY(dress == 0)) {
680 AdgMarker *arrow = (AdgMarker *) adg_arrow_new();
681 AdgStyle *fallback = g_object_new(ADG_TYPE_DIM_STYLE, NULL);
683 adg_dim_style_set_marker1((AdgDimStyle *) fallback, arrow);
684 adg_marker_set_pos(arrow, 1);
685 adg_dim_style_set_marker2((AdgDimStyle *) fallback, arrow);
687 dress = adg_dress_new("dimension", fallback);
688 g_object_unref(fallback);
689 g_object_unref(arrow);
692 return dress;
696 * ADG_DRESS_FILL:
698 * The default builtin #AdgDress for filling.
699 * This is a pass-through dress, that is it does not change
700 * the cairo context when it is applied.
702 * This dress will be resolved to an #AdgFillStyle derived instance.
704 * Since: 1.0
706 AdgDress
707 _adg_dress_fill(void)
709 static AdgDress dress = 0;
711 if (G_UNLIKELY(dress == 0)) {
712 dress = adg_dress_new_full("fill", NULL, ADG_TYPE_FILL_STYLE);
715 return dress;
719 * ADG_DRESS_FILL_HATCH:
721 * The builtin dress used by default by #AdgHatch instances.
722 * The fallback style is the default implementation of the
723 * #AdgRuledFill instance.
725 * This dress will be resolved to an #AdgFillStyle derived instance.
727 * Since: 1.0
729 AdgDress
730 _adg_dress_fill_hatch(void)
732 static AdgDress dress = 0;
734 if (G_UNLIKELY(dress == 0)) {
735 AdgStyle *fallback = g_object_new(ADG_TYPE_RULED_FILL,
736 "line-dress", ADG_DRESS_LINE_FILL,
737 NULL);
739 dress = adg_dress_new_full("fill-hatch", fallback, ADG_TYPE_FILL_STYLE);
740 g_object_unref(fallback);
743 return dress;
747 * ADG_DRESS_TABLE:
749 * The default builtin #AdgDress for tables. The fallback style
750 * is the default implementation of the #AdgTableStyle instance.
752 * This dress will be resolved to an #AdgTableStyle derived instance.
754 * Since: 1.0
756 AdgDress
757 _adg_dress_table(void)
759 static AdgDress dress = 0;
761 if (G_UNLIKELY(dress == 0)) {
762 AdgStyle *fallback = g_object_new(ADG_TYPE_TABLE_STYLE, NULL);
763 dress = adg_dress_new_full("table", fallback, ADG_TYPE_TABLE_STYLE);
764 g_object_unref(fallback);
767 return dress;