[AdgTransformationMode] Renamed to AdgTransformMode
[adg.git] / adg / adg-dress-builtins.c
blobd3f7083decc7402bb7a6820e56171f3aac558d0f
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.
21 /**
22 * SECTION:adg-dress-builtins
23 * @Section_Id:dress-builtins
24 * @title: Built-in dresses
25 * @short_description: A list of predefined dresses implemented
26 * by the ADG canvas
28 * This is a collection of built-it dresses used internally by
29 * the ADG library to provide some useful defaults.
30 **/
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"
43 /**
44 * ADG_DRESS_UNDEFINED:
46 * A value reperesenting an undefined #AdgDress.
47 **/
49 /**
50 * ADG_DRESS_COLOR:
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.
56 **/
57 AdgDress
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);
66 return dress;
69 /**
70 * ADG_DRESS_COLOR_STROKE:
72 * The default builtin #AdgDress color for #AdgStroke entities.
73 * The fallback style is the default implementation of #AdgColor
74 * (that is %black).
76 * This dress will be resolved to an #AdgColorStyle instance.
77 **/
78 AdgDress
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);
90 return dress;
93 /**
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.
101 AdgDress
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,
108 "red", 0.667, NULL);
110 dress = adg_dress_new("color-dimension", fallback);
111 g_object_unref(fallback);
114 return dress;
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.
125 AdgDress
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);
138 return dress;
142 * ADG_DRESS_LINE:
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.
149 AdgDress
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);
158 return dress;
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.
170 AdgDress
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,
177 "width", 1.5, NULL);
179 dress = adg_dress_new("line-medium", fallback);
180 g_object_unref(fallback);
183 return dress;
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.
194 AdgDress
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,
201 "width", 1., NULL);
203 dress = adg_dress_new("line-thin", fallback);
204 g_object_unref(fallback);
207 return dress;
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.
218 AdgDress
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,
225 "width", 2., NULL);
227 dress = adg_dress_new("line-thick", fallback);
228 g_object_unref(fallback);
231 return dress;
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.
244 AdgDress
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);
257 return dress;
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.
268 AdgDress
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,
275 "width", 2.5, NULL);
277 dress = adg_dress_new("line-thicker", fallback);
278 g_object_unref(fallback);
281 return dress;
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.
293 AdgDress
294 _adg_dress_line_hatch(void)
296 static AdgDress dress = 0;
298 if (G_UNLIKELY(dress == 0)) {
299 AdgLineStyle *thin_style;
300 AdgStyle *fallback;
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);
311 return dress;
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.
323 AdgDress
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,
331 "width", 1., NULL);
333 dress = adg_dress_new("line-grid", fallback);
334 g_object_unref(fallback);
337 return dress;
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.
349 AdgDress
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,
357 "width", 2., NULL);
359 dress = adg_dress_new("line-frame", fallback);
360 g_object_unref(fallback);
363 return dress;
367 * ADG_DRESS_TEXT:
369 * The default builtin #AdgDress font. The fallback style is
370 * %Sans %14.
372 * This dress will be resolved to an #AdgFontStyle instance.
374 AdgDress
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,
381 "family", "Serif",
382 "size", 14., NULL);
384 dress = adg_dress_new("text", fallback);
385 g_object_unref(fallback);
388 return dress;
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.
399 AdgDress
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,
406 "family", "Sans",
407 "weight", CAIRO_FONT_WEIGHT_BOLD,
408 "size", 12., NULL);
410 dress = adg_dress_new("text-value", fallback);
411 g_object_unref(fallback);
414 return dress;
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
422 * is a %Sans %8.
424 * This dress will be resolved to an #AdgFontStyle instance.
426 AdgDress
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,
433 "family", "Sans",
434 "size", 8., NULL);
436 dress = adg_dress_new("text-limit", fallback);
437 g_object_unref(fallback);
440 return dress;
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.
452 AdgDress
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);
470 return dress;
474 * ADG_DRESS_FILL:
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.
481 AdgDress
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);
490 return dress;
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.
502 AdgDress
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,
510 NULL);
512 dress = adg_dress_new_full("fill-hatch", fallback,
513 ADG_TYPE_FILL_STYLE);
514 g_object_unref(fallback);
517 return dress;
521 * ADG_DRESS_TABLE:
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.
528 AdgDress
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);
539 return dress;