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.
22 * SECTION:adg-dress-builtins
23 * @Section_Id:dress-builtins
24 * @title: Built-in dresses
25 * @short_description: A list of predefined dresses implemented
28 * This is a collection of built-it dresses used internally by
29 * the ADG library to provide some useful defaults.
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-dress.h"
42 #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"
53 #define MM *2.83464566927
57 * ADG_DRESS_UNDEFINED:
59 * A value reperesenting an undefined #AdgDress.
67 * The default builtin #AdgDress color.
68 * This is a pass-through dress, that is it does not change
69 * the cairo context when it is applied.
71 * This dress will be resolved to an #AdgColorStyle instance.
76 _adg_dress_color(void)
78 static AdgDress dress
= 0;
80 if (G_UNLIKELY(dress
== 0)) {
81 dress
= adg_dress_new_full("color", NULL
, ADG_TYPE_COLOR_STYLE
);
88 * ADG_DRESS_COLOR_BACKGROUND:
90 * The default builtin #AdgDress color to be used as the #AdgCanvas
91 * background. The fallback style is a full opaque white.
93 * This dress will be resolved to an #AdgColorStyle instance.
98 _adg_dress_color_background(void)
100 static AdgDress dress
= 0;
102 if (G_UNLIKELY(dress
== 0)) {
103 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
104 "blue", 1., "green", 1.,
107 dress
= adg_dress_new("color-background", fallback
);
108 g_object_unref(fallback
);
115 * ADG_DRESS_COLOR_STROKE:
117 * The default builtin #AdgDress color for #AdgStroke entities.
118 * The fallback style is a full opaque black.
120 * This dress will be resolved to an #AdgColorStyle instance.
125 _adg_dress_color_stroke(void)
127 static AdgDress dress
= 0;
129 if (G_UNLIKELY(dress
== 0)) {
130 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
, NULL
);
132 dress
= adg_dress_new("color-stroke", fallback
);
133 g_object_unref(fallback
);
140 * ADG_DRESS_COLOR_DIMENSION:
142 * The builtin #AdgDress color used by default in #AdgDimStyle.
143 * The fallback style is a somewhat full opaque blue.
145 * This dress will be resolved to an #AdgColorStyle instance.
150 _adg_dress_color_dimension(void)
152 static AdgDress dress
= 0;
154 if (G_UNLIKELY(dress
== 0)) {
155 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
161 dress
= adg_dress_new("color-dimension", fallback
);
162 g_object_unref(fallback
);
169 * ADG_DRESS_COLOR_ANNOTATION:
171 * The builtin #AdgDress color used for rendering helper entities
172 * such as #AdgToyText, #AdgTable and #AdgTitleBlock. The fallback
173 * style is a full opaque greenish variant.
175 * This dress will be resolved to an #AdgColorStyle instance.
180 _adg_dress_color_annotation(void)
182 static AdgDress dress
= 0;
184 if (G_UNLIKELY(dress
== 0)) {
185 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
191 dress
= adg_dress_new("color-annotation", fallback
);
192 g_object_unref(fallback
);
199 * ADG_DRESS_COLOR_FILL:
201 * The builtin #AdgDress color used by default by #AdgFillStyle
202 * based styles. The fallback style is a full opaque %0.25 gray.
204 * This dress will be resolved to an #AdgColorStyle instance.
209 _adg_dress_color_fill(void)
211 static AdgDress dress
= 0;
213 if (G_UNLIKELY(dress
== 0)) {
214 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
219 dress
= adg_dress_new("color-fill", fallback
);
220 g_object_unref(fallback
);
227 * ADG_DRESS_COLOR_AXIS:
229 * The default builtin #AdgDress color for stroking #ADG_DRESS_LINE_AXIS
230 * lines. The fallback color is green.
232 * This dress will be resolved to an #AdgColorStyle instance.
237 _adg_dress_color_axis(void)
239 static AdgDress dress
= 0;
241 if (G_UNLIKELY(dress
== 0)) {
242 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
247 dress
= adg_dress_new("color-axis", fallback
);
248 g_object_unref(fallback
);
255 * ADG_DRESS_COLOR_HIDDEN:
257 * The default builtin #AdgDress color for stroking #ADG_DRESS_LINE_HIDDEN
258 * lines. The fallback color is gray.
260 * This dress will be resolved to an #AdgColorStyle instance.
265 _adg_dress_color_hidden(void)
267 static AdgDress dress
= 0;
269 if (G_UNLIKELY(dress
== 0)) {
270 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
275 dress
= adg_dress_new("color-hidden", fallback
);
276 g_object_unref(fallback
);
285 * The default builtin #AdgDress line.
286 * This is a pass-through dress, that is it does not change
287 * the cairo context when it is applied.
289 * This dress will be resolved to an #AdgLineStyle instance.
294 _adg_dress_line(void)
296 static AdgDress dress
= 0;
298 if (G_UNLIKELY(dress
== 0)) {
299 dress
= adg_dress_new_full("line", NULL
, ADG_TYPE_LINE_STYLE
);
306 * ADG_DRESS_LINE_STROKE:
308 * The builtin #AdgDress line type to be used by default
309 * for rendering #AdgStroke entities. The fallback style is
310 * a line with #ADG_DRESS_COLOR_STROKE color and a thickness
313 * This dress will be resolved to an #AdgLineStyle instance.
318 _adg_dress_line_stroke(void)
320 static AdgDress dress
= 0;
322 if (G_UNLIKELY(dress
== 0)) {
323 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
324 "color-dress", ADG_DRESS_COLOR_STROKE
,
327 dress
= adg_dress_new("line-stroke", fallback
);
328 g_object_unref(fallback
);
335 * ADG_DRESS_LINE_DIMENSION:
337 * The builtin #AdgDress line type used by default
338 * for rendering base and extension lines of dimensions.
339 * The fallback style is a line with a thickness of %0.5
340 * and a pass-through color dress.
342 * This dress will be resolved to an #AdgLineStyle instance.
347 _adg_dress_line_dimension(void)
349 static AdgDress dress
= 0;
351 if (G_UNLIKELY(dress
== 0)) {
352 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
355 dress
= adg_dress_new("line-dimension", fallback
);
356 g_object_unref(fallback
);
363 * ADG_DRESS_LINE_FILL:
365 * The builtin #AdgDress line type used by #AdgFillStyle
366 * based styles. The fallback style is a line with
367 * #ADG_DRESS_COLOR_FILL color and a thickness of %0.5.
369 * This dress will be resolved to an #AdgLineStyle instance.
374 _adg_dress_line_fill(void)
376 static AdgDress dress
= 0;
378 if (G_UNLIKELY(dress
== 0)) {
379 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
380 "color-dress", ADG_DRESS_COLOR_FILL
,
383 dress
= adg_dress_new("line-fill", fallback
);
384 g_object_unref(fallback
);
391 * ADG_DRESS_LINE_GRID:
393 * The builtin #AdgDress line type used for rendering the grid
394 * of #AdgTable entities, that is the frame of the cells.
395 * The fallback style is a line with a thickness of %1 and a
396 * pass-through color dress, rendered without antialiasing.
398 * This dress will be resolved to an #AdgLineStyle instance.
403 _adg_dress_line_grid(void)
405 static AdgDress dress
= 0;
407 if (G_UNLIKELY(dress
== 0)) {
408 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
409 "antialias", CAIRO_ANTIALIAS_NONE
,
412 dress
= adg_dress_new("line-grid", fallback
);
413 g_object_unref(fallback
);
420 * ADG_DRESS_LINE_FRAME:
422 * The builtin #AdgDress line type used for rendering the frame
423 * of #AdgTable entities, that is the frame around the whole table.
424 * The fallback style is a line with a thickness of %2 and a
425 * #ADG_DRESS_COLOR_ANNOTATION color dress, rendered without
428 * This dress will be resolved to an #AdgLineStyle instance.
433 _adg_dress_line_frame(void)
435 static AdgDress dress
= 0;
437 if (G_UNLIKELY(dress
== 0)) {
438 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
439 "color-dress", ADG_DRESS_COLOR_ANNOTATION
,
440 "antialias", CAIRO_ANTIALIAS_NONE
,
443 dress
= adg_dress_new("line-frame", fallback
);
444 g_object_unref(fallback
);
451 * ADG_DRESS_LINE_AXIS:
453 * The builtin #AdgDress line type used for rendering axis and
456 * This dress will be resolved to an #AdgLineStyle instance.
461 _adg_dress_line_axis(void)
463 static AdgDress dress
= 0;
465 if (G_UNLIKELY(dress
== 0)) {
469 dash
= adg_dash_new_with_dashes(4, 2 MM
, 2 MM
, 10 MM
, 2 MM
);
470 fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
472 "color-dress", ADG_DRESS_COLOR_AXIS
,
473 "width", 0.25 MM
, NULL
);
474 adg_dash_destroy(dash
);
476 dress
= adg_dress_new("line-axis", fallback
);
477 g_object_unref(fallback
);
484 * ADG_DRESS_LINE_HIDDEN:
486 * The builtin #AdgDress line type used for rendering hidden
489 * This dress will be resolved to an #AdgLineStyle instance.
494 _adg_dress_line_hidden(void)
496 static AdgDress dress
= 0;
498 if (G_UNLIKELY(dress
== 0)) {
502 dash
= adg_dash_new_with_dashes(2, 6 MM
, 6 MM
);
503 fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
505 "color-dress", ADG_DRESS_COLOR_HIDDEN
,
506 "width", 0.25 MM
, NULL
);
507 adg_dash_destroy(dash
);
509 dress
= adg_dress_new("line-hidden", fallback
);
510 g_object_unref(fallback
);
519 * The default builtin #AdgDress font. The fallback style is
520 * a %Sans %14 font with a pass-through color dress.
522 * This dress will be resolved to an #AdgFontStyle instance.
527 _adg_dress_font(void)
529 static AdgDress dress
= 0;
531 if (G_UNLIKELY(dress
== 0)) {
532 AdgStyle
*fallback
= g_object_new(ADG_TYPE_BEST_FONT_STYLE
,
536 dress
= adg_dress_new("font", fallback
);
537 g_object_unref(fallback
);
544 * ADG_DRESS_FONT_TEXT:
546 * The builtin #AdgDress font used by default for rendering
547 * common text such as #AdgToyText or the value of #AdgTable
548 * entities. The fallback style is %Sans %12 %bold with an
549 * #ADG_DRESS_COLOR_ANNOTATION color dress.
551 * This dress will be resolved to an #AdgFontStyle instance.
556 _adg_dress_font_text(void)
558 static AdgDress dress
= 0;
560 if (G_UNLIKELY(dress
== 0)) {
561 AdgStyle
*fallback
= g_object_new(ADG_TYPE_BEST_FONT_STYLE
,
562 "color-dress", ADG_DRESS_COLOR_ANNOTATION
,
564 "weight", CAIRO_FONT_WEIGHT_BOLD
,
567 dress
= adg_dress_new("font-text", fallback
);
568 g_object_unref(fallback
);
575 * ADG_DRESS_FONT_ANNOTATION:
577 * The builtin #AdgDress font used for rendering auxiliary text,
578 * such as the titles on #AdgTable entities. The fallback style
579 * is a %Sans %8 with an #ADG_DRESS_COLOR_ANNOTATION color dress.
581 * This dress will be resolved to an #AdgFontStyle instance.
586 _adg_dress_font_annotation(void)
588 static AdgDress dress
= 0;
590 if (G_UNLIKELY(dress
== 0)) {
591 AdgStyle
*fallback
= g_object_new(ADG_TYPE_BEST_FONT_STYLE
,
592 "color-dress", ADG_DRESS_COLOR_ANNOTATION
,
596 dress
= adg_dress_new("font-annotation", fallback
);
597 g_object_unref(fallback
);
604 * ADG_DRESS_FONT_QUOTE_TEXT:
606 * The builtin #AdgDress font used for rendering regular text
607 * on dimension entities, such as the nominal value and the
608 * notes of a quote. The fallback style is %Sans %12 %bold with
609 * a pass-through color dress.
611 * This dress will be resolved to an #AdgFontStyle instance.
616 _adg_dress_font_quote_text(void)
618 static AdgDress dress
= 0;
620 if (G_UNLIKELY(dress
== 0)) {
621 AdgStyle
*fallback
= g_object_new(ADG_TYPE_BEST_FONT_STYLE
,
623 "weight", CAIRO_FONT_WEIGHT_BOLD
,
626 dress
= adg_dress_new("font-quote-text", fallback
);
627 g_object_unref(fallback
);
634 * ADG_DRESS_FONT_QUOTE_ANNOTATION:
636 * The builtin #AdgDress font used for rendering auxiliary text
637 * on dimension entities, such as the min and max limits of a
638 * quote. The fallback style is a %Sans %8 with a pass-through
641 * This dress will be resolved to an #AdgFontStyle instance.
646 _adg_dress_font_quote_annotation(void)
648 static AdgDress dress
= 0;
650 if (G_UNLIKELY(dress
== 0)) {
651 AdgStyle
*fallback
= g_object_new(ADG_TYPE_BEST_FONT_STYLE
,
655 dress
= adg_dress_new("font-quote-annotation", fallback
);
656 g_object_unref(fallback
);
663 * ADG_DRESS_DIMENSION:
665 * The default builtin #AdgDress for dimensions. The fallback
666 * style is the default #AdgDimStyle implementation with
667 * #AdgArrow markers (as returned by adg_arrow_new() on both sides.
669 * This dress will be resolved to an #AdgDimStyle instance.
674 _adg_dress_dimension(void)
676 static AdgDress dress
= 0;
678 if (G_UNLIKELY(dress
== 0)) {
679 AdgMarker
*arrow
= (AdgMarker
*) adg_arrow_new();
680 AdgStyle
*fallback
= g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
682 adg_dim_style_set_marker1((AdgDimStyle
*) fallback
, arrow
);
683 adg_marker_set_pos(arrow
, 1);
684 adg_dim_style_set_marker2((AdgDimStyle
*) fallback
, arrow
);
686 dress
= adg_dress_new("dimension", fallback
);
687 g_object_unref(fallback
);
688 g_object_unref(arrow
);
697 * The default builtin #AdgDress for filling.
698 * This is a pass-through dress, that is it does not change
699 * the cairo context when it is applied.
701 * This dress will be resolved to an #AdgFillStyle derived instance.
706 _adg_dress_fill(void)
708 static AdgDress dress
= 0;
710 if (G_UNLIKELY(dress
== 0)) {
711 dress
= adg_dress_new_full("fill", NULL
, ADG_TYPE_FILL_STYLE
);
718 * ADG_DRESS_FILL_HATCH:
720 * The builtin dress used by default by #AdgHatch instances.
721 * The fallback style is the default implementation of the
722 * #AdgRuledFill instance.
724 * This dress will be resolved to an #AdgFillStyle derived instance.
729 _adg_dress_fill_hatch(void)
731 static AdgDress dress
= 0;
733 if (G_UNLIKELY(dress
== 0)) {
734 AdgStyle
*fallback
= g_object_new(ADG_TYPE_RULED_FILL
,
735 "line-dress", ADG_DRESS_LINE_FILL
,
738 dress
= adg_dress_new_full("fill-hatch", fallback
, ADG_TYPE_FILL_STYLE
);
739 g_object_unref(fallback
);
748 * The default builtin #AdgDress for tables. The fallback style
749 * is the default implementation of the #AdgTableStyle instance.
751 * This dress will be resolved to an #AdgTableStyle derived instance.
756 _adg_dress_table(void)
758 static AdgDress dress
= 0;
760 if (G_UNLIKELY(dress
== 0)) {
761 AdgStyle
*fallback
= g_object_new(ADG_TYPE_TABLE_STYLE
, NULL
);
762 dress
= adg_dress_new_full("table", fallback
, ADG_TYPE_TABLE_STYLE
);
763 g_object_unref(fallback
);