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-pattern.h"
42 #include "adg-dress.h"
43 #include "adg-color-style.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
58 * ADG_DRESS_UNDEFINED:
60 * A value reperesenting an undefined #AdgDress.
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.
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
);
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.
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.,
108 dress
= adg_dress_new("color-background", fallback
);
109 g_object_unref(fallback
);
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.
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
);
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.
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
,
162 dress
= adg_dress_new("color-dimension", fallback
);
163 g_object_unref(fallback
);
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.
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
,
192 dress
= adg_dress_new("color-annotation", fallback
);
193 g_object_unref(fallback
);
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.
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
,
220 dress
= adg_dress_new("color-fill", fallback
);
221 g_object_unref(fallback
);
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.
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
,
248 dress
= adg_dress_new("color-axis", fallback
);
249 g_object_unref(fallback
);
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.
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
,
276 dress
= adg_dress_new("color-hidden", fallback
);
277 g_object_unref(fallback
);
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.
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
);
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
314 * This dress will be resolved to an #AdgLineStyle instance.
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
,
328 dress
= adg_dress_new("line-stroke", fallback
);
329 g_object_unref(fallback
);
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.
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
,
356 dress
= adg_dress_new("line-dimension", fallback
);
357 g_object_unref(fallback
);
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.
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
,
384 dress
= adg_dress_new("line-fill", fallback
);
385 g_object_unref(fallback
);
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.
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
,
413 dress
= adg_dress_new("line-grid", fallback
);
414 g_object_unref(fallback
);
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
429 * This dress will be resolved to an #AdgLineStyle instance.
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
,
444 dress
= adg_dress_new("line-frame", fallback
);
445 g_object_unref(fallback
);
452 * ADG_DRESS_LINE_AXIS:
454 * The builtin #AdgDress line type used for rendering axis and
457 * This dress will be resolved to an #AdgLineStyle instance.
462 _adg_dress_line_axis(void)
464 static AdgDress dress
= 0;
466 if (G_UNLIKELY(dress
== 0)) {
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
,
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
);
485 * ADG_DRESS_LINE_HIDDEN:
487 * The builtin #AdgDress line type used for rendering hidden
490 * This dress will be resolved to an #AdgLineStyle instance.
495 _adg_dress_line_hidden(void)
497 static AdgDress dress
= 0;
499 if (G_UNLIKELY(dress
== 0)) {
503 dash
= adg_dash_new_with_dashes(2, 6 MM
, 6 MM
);
504 fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
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
);
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.
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
,
537 dress
= adg_dress_new("font", fallback
);
538 g_object_unref(fallback
);
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.
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
,
565 "weight", CAIRO_FONT_WEIGHT_BOLD
,
568 dress
= adg_dress_new("font-text", fallback
);
569 g_object_unref(fallback
);
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.
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
,
597 dress
= adg_dress_new("font-annotation", fallback
);
598 g_object_unref(fallback
);
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.
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
,
624 "weight", CAIRO_FONT_WEIGHT_BOLD
,
627 dress
= adg_dress_new("font-quote-text", fallback
);
628 g_object_unref(fallback
);
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
642 * This dress will be resolved to an #AdgFontStyle instance.
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
,
656 dress
= adg_dress_new("font-quote-annotation", fallback
);
657 g_object_unref(fallback
);
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.
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
);
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.
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
);
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.
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
,
739 dress
= adg_dress_new_full("fill-hatch", fallback
, ADG_TYPE_FILL_STYLE
);
740 g_object_unref(fallback
);
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.
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
);