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"
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"
55 * ADG_DRESS_UNDEFINED:
57 * A value reperesenting an undefined #AdgDress.
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.
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
);
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.
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.,
105 dress
= adg_dress_new("color-background", fallback
);
106 g_object_unref(fallback
);
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.
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
);
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.
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
,
159 dress
= adg_dress_new("color-dimension", fallback
);
160 g_object_unref(fallback
);
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.
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
,
189 dress
= adg_dress_new("color-annotation", fallback
);
190 g_object_unref(fallback
);
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.
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
,
217 dress
= adg_dress_new("color-fill", fallback
);
218 g_object_unref(fallback
);
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.
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
);
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
255 * This dress will be resolved to an #AdgLineStyle instance.
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
,
269 dress
= adg_dress_new("line-stroke", fallback
);
270 g_object_unref(fallback
);
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.
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
,
297 dress
= adg_dress_new("line-dimension", fallback
);
298 g_object_unref(fallback
);
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.
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
,
325 dress
= adg_dress_new("line-fill", fallback
);
326 g_object_unref(fallback
);
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.
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
,
354 dress
= adg_dress_new("line-grid", fallback
);
355 g_object_unref(fallback
);
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
370 * This dress will be resolved to an #AdgLineStyle instance.
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
,
385 dress
= adg_dress_new("line-frame", fallback
);
386 g_object_unref(fallback
);
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.
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
,
412 dress
= adg_dress_new("font", fallback
);
413 g_object_unref(fallback
);
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.
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
,
440 "weight", CAIRO_FONT_WEIGHT_BOLD
,
443 dress
= adg_dress_new("font-text", fallback
);
444 g_object_unref(fallback
);
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.
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
,
472 dress
= adg_dress_new("font-annotation", fallback
);
473 g_object_unref(fallback
);
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.
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
,
499 "weight", CAIRO_FONT_WEIGHT_BOLD
,
502 dress
= adg_dress_new("font-quote-text", fallback
);
503 g_object_unref(fallback
);
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
517 * This dress will be resolved to an #AdgFontStyle instance.
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
,
531 dress
= adg_dress_new("font-quote-annotation", fallback
);
532 g_object_unref(fallback
);
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.
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
);
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.
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
);
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.
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
,
614 dress
= adg_dress_new_full("fill-hatch", fallback
, ADG_TYPE_FILL_STYLE
);
615 g_object_unref(fallback
);
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.
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
);