1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 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-dress-builtins.h"
34 #include "adg-color-style.h"
35 #include "adg-line-style.h"
36 #include "adg-font-style.h"
37 #include "adg-dim-style.h"
38 #include "adg-arrow.h"
39 #include "adg-ruled-fill.h"
40 #include "adg-table-style.h"
44 * ADG_DRESS_UNDEFINED:
46 * A value reperesenting an undefined #AdgDress.
52 * The default builtin #AdgDress color. This is a transparent dress
53 * without a fallback style.
55 * This dress will be resolved to an #AdgColorStyle instance.
58 _adg_dress_color(void)
60 static AdgDress dress
= 0;
62 if (G_UNLIKELY(dress
== 0)) {
63 dress
= adg_dress_new_full("color", NULL
, ADG_TYPE_COLOR_STYLE
);
70 * ADG_DRESS_COLOR_STROKE:
72 * The default builtin #AdgDress color for #AdgStroke entities.
73 * The fallback style is the default implementation of #AdgColor
76 * This dress will be resolved to an #AdgColorStyle instance.
79 _adg_dress_color_stroke(void)
81 static AdgDress dress
= 0;
83 if (G_UNLIKELY(dress
== 0)) {
84 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
, NULL
);
86 dress
= adg_dress_new("color-stroke", fallback
);
87 g_object_unref(fallback
);
94 * ADG_DRESS_COLOR_DIMENSION:
96 * The builtin #AdgDress color used by default in #AdgDimStyle.
97 * The fallback style is a %0.75 red.
99 * This dress will be resolved to an #AdgColorStyle instance.
102 _adg_dress_color_dimension(void)
104 static AdgDress dress
= 0;
106 if (G_UNLIKELY(dress
== 0)) {
107 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
110 dress
= adg_dress_new("color-dimension", fallback
);
111 g_object_unref(fallback
);
118 * ADG_DRESS_COLOR_HATCH:
120 * The default builtin #AdgDress color for #AdgHatch entities.
121 * The fallback style is a %0.5 blue.
123 * This dress will be resolved to an #AdgColorStyle instance.
126 _adg_dress_color_hatch(void)
128 static AdgDress dress
= 0;
130 if (G_UNLIKELY(dress
== 0)) {
131 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
132 "blue", 0.333, NULL
);
134 dress
= adg_dress_new("color-hatch", fallback
);
135 g_object_unref(fallback
);
144 * The default builtin #AdgDress line. This is a transparent dress
145 * without a fallback style.
147 * This dress will be resolved to an #AdgLineStyle instance.
150 _adg_dress_line(void)
152 static AdgDress dress
= 0;
154 if (G_UNLIKELY(dress
== 0)) {
155 dress
= adg_dress_new_full("line", NULL
, ADG_TYPE_LINE_STYLE
);
162 * ADG_DRESS_LINE_MEDIUM:
164 * The default generic builtin #AdgDress line type: it is used by
165 * default for rendering #AdgStroke entities. The fallback style
166 * is a default line with a thickness of %1.5.
168 * This dress will be resolved to an #AdgLineStyle instance.
171 _adg_dress_line_medium(void)
173 static AdgDress dress
= 0;
175 if (G_UNLIKELY(dress
== 0)) {
176 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
179 dress
= adg_dress_new("line-medium", fallback
);
180 g_object_unref(fallback
);
187 * ADG_DRESS_LINE_THIN:
189 * A generic builtin #AdgDress line type for thin lines.
190 * The fallback style is a default line with a thickness of %1.
192 * This dress will be resolved to an #AdgLineStyle instance.
195 _adg_dress_line_thin(void)
197 static AdgDress dress
= 0;
199 if (G_UNLIKELY(dress
== 0)) {
200 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
203 dress
= adg_dress_new("line-thin", fallback
);
204 g_object_unref(fallback
);
211 * ADG_DRESS_LINE_THICK:
213 * A generic builtin #AdgDress line type for thick lines.
214 * The fallback style is a default line with a thickness of %2.
216 * This dress will be resolved to an #AdgLineStyle instance.
219 _adg_dress_line_thick(void)
221 static AdgDress dress
= 0;
223 if (G_UNLIKELY(dress
== 0)) {
224 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
227 dress
= adg_dress_new("line-thick", fallback
);
228 g_object_unref(fallback
);
235 * ADG_DRESS_LINE_THINNER:
237 * A generic builtin #AdgDress line type for really thin lines:
238 * it is used by default for rendering base and extension lines
239 * of dimension entities. The fallback style is a default line
240 * with a thickness of %0.75.
242 * This dress will be resolved to an #AdgLineStyle instance.
245 _adg_dress_line_thinner(void)
247 static AdgDress dress
= 0;
249 if (G_UNLIKELY(dress
== 0)) {
250 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
251 "width", 0.75, NULL
);
253 dress
= adg_dress_new("line-thinner", fallback
);
254 g_object_unref(fallback
);
261 * ADG_DRESS_LINE_THICKER:
263 * A generic builtin #AdgDress line type for really thick lines.
264 * The fallback style is a default line with a thickness of %2.5.
266 * This dress will be resolved to an #AdgLineStyle instance.
269 _adg_dress_line_thicker(void)
271 static AdgDress dress
= 0;
273 if (G_UNLIKELY(dress
== 0)) {
274 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
277 dress
= adg_dress_new("line-thicker", fallback
);
278 g_object_unref(fallback
);
285 * ADG_DRESS_LINE_HATCH:
287 * The builtin #AdgDress line type used by the default #AdgRuledFill
288 * style implementation. The fallback style is a default line with
289 * a thickness of %1 and an #ADG_DRESS_COLOR_HATCH color dress.
291 * This dress will be resolved to an #AdgLineStyle instance.
294 _adg_dress_line_hatch(void)
296 static AdgDress dress
= 0;
298 if (G_UNLIKELY(dress
== 0)) {
299 AdgLineStyle
*thin_style
;
302 thin_style
= (AdgLineStyle
*) adg_dress_get_fallback(ADG_DRESS_LINE_THIN
);
303 fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
304 "width", adg_line_style_get_width(thin_style
),
305 "color-dress", ADG_DRESS_COLOR_HATCH
, NULL
);
307 dress
= adg_dress_new("line-hatch", fallback
);
308 g_object_unref(fallback
);
315 * ADG_DRESS_LINE_GRID:
317 * The builtin #AdgDress line type used for rendering grids of
318 * #AdgTable entities. The fallback style is a default line with
319 * a thickness of %1 and no antialiasing.
321 * This dress will be resolved to an #AdgLineStyle instance.
324 _adg_dress_line_grid(void)
326 static AdgDress dress
= 0;
328 if (G_UNLIKELY(dress
== 0)) {
329 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
330 "antialias", CAIRO_ANTIALIAS_NONE
,
333 dress
= adg_dress_new("line-grid", fallback
);
334 g_object_unref(fallback
);
341 * ADG_DRESS_LINE_FRAME:
343 * The builtin #AdgDress line type used for rendering frames of
344 * #AdgTable entities. The fallback style is a default line with
345 * a thickness of %2 and no antialiasing.
347 * This dress will be resolved to an #AdgLineStyle instance.
350 _adg_dress_line_frame(void)
352 static AdgDress dress
= 0;
354 if (G_UNLIKELY(dress
== 0)) {
355 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
356 "antialias", CAIRO_ANTIALIAS_NONE
,
359 dress
= adg_dress_new("line-frame", fallback
);
360 g_object_unref(fallback
);
369 * The default builtin #AdgDress font. The fallback style is
372 * This dress will be resolved to an #AdgFontStyle instance.
375 _adg_dress_text(void)
377 static AdgDress dress
= 0;
379 if (G_UNLIKELY(dress
== 0)) {
380 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
384 dress
= adg_dress_new("text", fallback
);
385 g_object_unref(fallback
);
392 * ADG_DRESS_TEXT_VALUE:
394 * The builtin #AdgDress font used to render the nominal value of a
395 * dimension. The fallback style is %Sans %12 %bold.
397 * This dress will be resolved to an #AdgFontStyle instance.
400 _adg_dress_text_value(void)
402 static AdgDress dress
= 0;
404 if (G_UNLIKELY(dress
== 0)) {
405 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
407 "weight", CAIRO_FONT_WEIGHT_BOLD
,
410 dress
= adg_dress_new("text-value", fallback
);
411 g_object_unref(fallback
);
418 * ADG_DRESS_TEXT_LIMIT:
420 * The builtin #AdgDress font used to render the limits of either
421 * the min and max values of a dimension. The fallback style
424 * This dress will be resolved to an #AdgFontStyle instance.
427 _adg_dress_text_limit(void)
429 static AdgDress dress
= 0;
431 if (G_UNLIKELY(dress
== 0)) {
432 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
436 dress
= adg_dress_new("text-limit", fallback
);
437 g_object_unref(fallback
);
444 * ADG_DRESS_DIMENSION:
446 * The default builtin #AdgDress for dimensioning. The fallback
447 * style is the default #AdgDimStyle implementation with #AdgArrow
448 * as markers on both sides.
450 * This dress will be resolved to an #AdgDimStyle instance.
453 _adg_dress_dimension(void)
455 static AdgDress dress
= 0;
457 if (G_UNLIKELY(dress
== 0)) {
458 AdgMarker
*arrow
= g_object_new(ADG_TYPE_ARROW
, NULL
);
459 AdgStyle
*fallback
= g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
461 adg_dim_style_use_marker1((AdgDimStyle
*) fallback
, arrow
);
462 adg_marker_set_pos(arrow
, 1);
463 adg_dim_style_use_marker2((AdgDimStyle
*) fallback
, arrow
);
465 dress
= adg_dress_new("dimension", fallback
);
466 g_object_unref(fallback
);
467 g_object_unref(arrow
);
476 * The default builtin #AdgDress for filling. This is a transparent
477 * dress without a fallback style.
479 * This dress will be resolved to an #AdgFillStyle derived instance.
482 _adg_dress_fill(void)
484 static AdgDress dress
= 0;
486 if (G_UNLIKELY(dress
== 0)) {
487 dress
= adg_dress_new_full("fill", NULL
, ADG_TYPE_FILL_STYLE
);
494 * ADG_DRESS_FILL_HATCH:
496 * The default builtin #AdgDress used by #AdgHatch instances.
497 * The fallback style is the default implementation of the
498 * #AdgRuledFill instance.
500 * This dress will be resolved to an #AdgFillStyle derived instance.
503 _adg_dress_fill_hatch(void)
505 static AdgDress dress
= 0;
507 if (G_UNLIKELY(dress
== 0)) {
508 AdgStyle
*fallback
= g_object_new(ADG_TYPE_RULED_FILL
,
509 "line-dress", ADG_DRESS_LINE_HATCH
,
512 dress
= adg_dress_new_full("fill-hatch", fallback
,
513 ADG_TYPE_FILL_STYLE
);
514 g_object_unref(fallback
);
523 * The default builtin #AdgDress for tables. The fallback style
524 * is the default implementation of the #AdgTableStyle instance.
526 * This dress will be resolved to an #AdgTableStyle derived instance.
529 _adg_dress_table(void)
531 static AdgDress dress
= 0;
533 if (G_UNLIKELY(dress
== 0)) {
534 AdgStyle
*fallback
= g_object_new(ADG_TYPE_TABLE_STYLE
, NULL
);
535 dress
= adg_dress_new_full("table", fallback
, ADG_TYPE_TABLE_STYLE
);
536 g_object_unref(fallback
);