1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010 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.
33 #include "adg-internal.h"
34 #include "adg-dress-builtins.h"
35 #include "adg-color-style.h"
36 #include "adg-line-style.h"
37 #include "adg-font-style.h"
38 #include "adg-dim-style.h"
39 #include "adg-arrow.h"
40 #include "adg-ruled-fill.h"
41 #include "adg-table-style.h"
45 * ADG_DRESS_UNDEFINED:
47 * A value reperesenting an undefined #AdgDress.
53 * The default builtin #AdgDress color.
54 * This is a pass-through dress, that is it does not change
55 * the cairo context when it is applied.
57 * This dress will be resolved to an #AdgColorStyle instance.
60 _adg_dress_color(void)
62 static AdgDress dress
= 0;
64 if (G_UNLIKELY(dress
== 0)) {
65 dress
= adg_dress_new_full("color", NULL
, ADG_TYPE_COLOR_STYLE
);
72 * ADG_DRESS_COLOR_BACKGROUND:
74 * The default builtin #AdgDress color to be used as the #AdgCanvas
75 * background. The fallback style is a full opaque white.
77 * This dress will be resolved to an #AdgColorStyle instance.
80 _adg_dress_color_background(void)
82 static AdgDress dress
= 0;
84 if (G_UNLIKELY(dress
== 0)) {
85 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
86 "blue", 1., "green", 1.,
89 dress
= adg_dress_new("color-background", fallback
);
90 g_object_unref(fallback
);
97 * ADG_DRESS_COLOR_STROKE:
99 * The default builtin #AdgDress color for #AdgStroke entities.
100 * The fallback style is a full opaque black.
102 * This dress will be resolved to an #AdgColorStyle instance.
105 _adg_dress_color_stroke(void)
107 static AdgDress dress
= 0;
109 if (G_UNLIKELY(dress
== 0)) {
110 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
, NULL
);
112 dress
= adg_dress_new("color-stroke", fallback
);
113 g_object_unref(fallback
);
120 * ADG_DRESS_COLOR_DIMENSION:
122 * The builtin #AdgDress color used by default in #AdgDimStyle.
123 * The fallback style is a %0.25 blue at %0.5 opacity.
125 * This dress will be resolved to an #AdgColorStyle instance.
128 _adg_dress_color_dimension(void)
130 static AdgDress dress
= 0;
132 if (G_UNLIKELY(dress
== 0)) {
133 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
137 dress
= adg_dress_new("color-dimension", fallback
);
138 g_object_unref(fallback
);
145 * ADG_DRESS_COLOR_TABLE:
147 * The builtin #AdgDress color used by default for rendering
148 * #AdgTable and derived objects. The fallback style is a
149 * full opaque %0.4 red
151 * This dress will be resolved to an #AdgColorStyle instance.
154 _adg_dress_color_table(void)
156 static AdgDress dress
= 0;
158 if (G_UNLIKELY(dress
== 0)) {
159 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
162 dress
= adg_dress_new("color-table", fallback
);
163 g_object_unref(fallback
);
170 * ADG_DRESS_COLOR_HATCH:
172 * The builtin #AdgDress color used by default in #AdgHatch entities.
173 * The fallback style is a full opaque %0.25 gray.
175 * This dress will be resolved to an #AdgColorStyle instance.
178 _adg_dress_color_hatch(void)
180 static AdgDress dress
= 0;
182 if (G_UNLIKELY(dress
== 0)) {
183 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
188 dress
= adg_dress_new("color-hatch", fallback
);
189 g_object_unref(fallback
);
198 * The default builtin #AdgDress line.
199 * This is a pass-through dress, that is it does not change
200 * the cairo context when it is applied.
202 * This dress will be resolved to an #AdgLineStyle instance.
205 _adg_dress_line(void)
207 static AdgDress dress
= 0;
209 if (G_UNLIKELY(dress
== 0)) {
210 dress
= adg_dress_new_full("line", NULL
, ADG_TYPE_LINE_STYLE
);
217 * ADG_DRESS_LINE_STROKE:
219 * The builtin #AdgDress line type to be used by default
220 * for rendering #AdgStroke entities. The fallback style is
221 * a line with #ADG_DRESS_COLOR_STROKE color and a thickness
224 * This dress will be resolved to an #AdgLineStyle instance.
227 _adg_dress_line_stroke(void)
229 static AdgDress dress
= 0;
231 if (G_UNLIKELY(dress
== 0)) {
232 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
233 "color-dress", ADG_DRESS_COLOR_STROKE
,
236 dress
= adg_dress_new("line-stroke", fallback
);
237 g_object_unref(fallback
);
244 * ADG_DRESS_LINE_DIMENSION:
246 * The builtin #AdgDress line type used by default
247 * for rendering base and extension lines of dimensions.
248 * The fallback style is a line with a thickness of %0.75
249 * and a pass-through color dress.
251 * This dress will be resolved to an #AdgLineStyle instance.
254 _adg_dress_line_dimension(void)
256 static AdgDress dress
= 0;
258 if (G_UNLIKELY(dress
== 0)) {
259 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
260 "width", 0.75, NULL
);
262 dress
= adg_dress_new("line-dimension", fallback
);
263 g_object_unref(fallback
);
270 * ADG_DRESS_LINE_HATCH:
272 * The builtin #AdgDress line type used by the default #AdgRuledFill
273 * style implementation. The fallback style is a line with
274 * #ADG_DRESS_COLOR_HATCH color and a thickness of %1.
276 * This dress will be resolved to an #AdgLineStyle instance.
279 _adg_dress_line_hatch(void)
281 static AdgDress dress
= 0;
283 if (G_UNLIKELY(dress
== 0)) {
284 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
285 "color-dress", ADG_DRESS_COLOR_HATCH
,
288 dress
= adg_dress_new("line-hatch", fallback
);
289 g_object_unref(fallback
);
296 * ADG_DRESS_LINE_GRID:
298 * The builtin #AdgDress line type used for rendering the grid
299 * of #AdgTable entities, that is the frame of the cells.
300 * The fallback style is a line with a thickness of %1 and a
301 * pass-through color dress, rendered without antialiasing.
303 * This dress will be resolved to an #AdgLineStyle instance.
306 _adg_dress_line_grid(void)
308 static AdgDress dress
= 0;
310 if (G_UNLIKELY(dress
== 0)) {
311 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
312 "antialias", CAIRO_ANTIALIAS_NONE
,
315 dress
= adg_dress_new("line-grid", fallback
);
316 g_object_unref(fallback
);
323 * ADG_DRESS_LINE_FRAME:
325 * The builtin #AdgDress line type used for rendering the frame
326 * of #AdgTable entities, that is the frame around the whole table.
327 * The fallback style is a line with a thickness of %2 and a
328 * pass-through color dress, rendered without antialiasing.
330 * This dress will be resolved to an #AdgLineStyle instance.
333 _adg_dress_line_frame(void)
335 static AdgDress dress
= 0;
337 if (G_UNLIKELY(dress
== 0)) {
338 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
339 "antialias", CAIRO_ANTIALIAS_NONE
,
342 dress
= adg_dress_new("line-frame", fallback
);
343 g_object_unref(fallback
);
352 * The default builtin #AdgDress font. The fallback style is
353 * a %Sans %14 font with a pass-through color dress.
355 * This dress will be resolved to an #AdgFontStyle instance.
358 _adg_dress_text(void)
360 static AdgDress dress
= 0;
362 if (G_UNLIKELY(dress
== 0)) {
363 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
367 dress
= adg_dress_new("text", fallback
);
368 g_object_unref(fallback
);
375 * ADG_DRESS_TEXT_VALUE:
377 * The builtin #AdgDress font used for rendering the nominal
378 * value of a dimension. The fallback style is %Sans %12 %bold
379 * with a pass-through color dress.
381 * This dress will be resolved to an #AdgFontStyle instance.
384 _adg_dress_text_value(void)
386 static AdgDress dress
= 0;
388 if (G_UNLIKELY(dress
== 0)) {
389 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
391 "weight", CAIRO_FONT_WEIGHT_BOLD
,
394 dress
= adg_dress_new("text-value", fallback
);
395 g_object_unref(fallback
);
402 * ADG_DRESS_TEXT_LIMIT:
404 * The builtin #AdgDress font used to render the limits of either
405 * the min and max values of a dimension. The fallback style
406 * is a %Sans %8 with a pass-through color dress.
408 * This dress will be resolved to an #AdgFontStyle instance.
411 _adg_dress_text_limit(void)
413 static AdgDress dress
= 0;
415 if (G_UNLIKELY(dress
== 0)) {
416 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
420 dress
= adg_dress_new("text-limit", fallback
);
421 g_object_unref(fallback
);
428 * ADG_DRESS_DIMENSION:
430 * The default builtin #AdgDress for dimensions. The fallback
431 * style is the default #AdgDimStyle implementation with
432 * #AdgArrow markers (as returned by adg_arrow_new() on both sides.
434 * This dress will be resolved to an #AdgDimStyle instance.
437 _adg_dress_dimension(void)
439 static AdgDress dress
= 0;
441 if (G_UNLIKELY(dress
== 0)) {
442 AdgMarker
*arrow
= (AdgMarker
*) adg_arrow_new();
443 AdgStyle
*fallback
= g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
445 adg_dim_style_set_marker1((AdgDimStyle
*) fallback
, arrow
);
446 adg_marker_set_pos(arrow
, 1);
447 adg_dim_style_set_marker2((AdgDimStyle
*) fallback
, arrow
);
449 dress
= adg_dress_new("dimension", fallback
);
450 g_object_unref(fallback
);
451 g_object_unref(arrow
);
460 * The default builtin #AdgDress for filling.
461 * This is a pass-through dress, that is it does not change
462 * the cairo context when it is applied.
464 * This dress will be resolved to an #AdgFillStyle derived instance.
467 _adg_dress_fill(void)
469 static AdgDress dress
= 0;
471 if (G_UNLIKELY(dress
== 0)) {
472 dress
= adg_dress_new_full("fill", NULL
, ADG_TYPE_FILL_STYLE
);
479 * ADG_DRESS_FILL_HATCH:
481 * The builtin dress used by default by #AdgHatch instances.
482 * The fallback style is the default implementation of the
483 * #AdgRuledFill instance.
485 * This dress will be resolved to an #AdgFillStyle derived instance.
488 _adg_dress_fill_hatch(void)
490 static AdgDress dress
= 0;
492 if (G_UNLIKELY(dress
== 0)) {
493 AdgStyle
*fallback
= g_object_new(ADG_TYPE_RULED_FILL
,
494 "line-dress", ADG_DRESS_LINE_HATCH
,
497 dress
= adg_dress_new_full("fill-hatch", fallback
, ADG_TYPE_FILL_STYLE
);
498 g_object_unref(fallback
);
507 * The default builtin #AdgDress for tables. The fallback style
508 * is the default implementation of the #AdgTableStyle instance.
510 * This dress will be resolved to an #AdgTableStyle derived instance.
513 _adg_dress_table(void)
515 static AdgDress dress
= 0;
517 if (G_UNLIKELY(dress
== 0)) {
518 AdgStyle
*fallback
= g_object_new(ADG_TYPE_TABLE_STYLE
, NULL
);
519 dress
= adg_dress_new_full("table", fallback
, ADG_TYPE_TABLE_STYLE
);
520 g_object_unref(fallback
);