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-ruled-fill.h"
39 #include "adg-arrow.h"
43 * ADG_DRESS_UNDEFINED:
45 * A value reperesenting an undefined #AdgDress.
51 * The default builtin #AdgDress color. This is a transparent dress
52 * without a fallback style.
54 * This dress will be resolved to an #AdgColorStyle instance.
57 _adg_dress_color(void)
59 static AdgDress dress
= 0;
61 if (G_UNLIKELY(dress
== 0)) {
62 dress
= adg_dress_new_full("color", NULL
, ADG_TYPE_COLOR_STYLE
);
69 * ADG_DRESS_COLOR_STROKE:
71 * The default builtin #AdgDress color for #AdgStroke entities.
72 * The fallback style is the default implementation of #AdgColor
75 * This dress will be resolved to an #AdgColorStyle instance.
78 _adg_dress_color_stroke(void)
80 static AdgDress dress
= 0;
82 if (G_UNLIKELY(dress
== 0)) {
83 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
, NULL
);
85 dress
= adg_dress_new("color-stroke", fallback
);
86 g_object_unref(fallback
);
93 * ADG_DRESS_COLOR_DIMENSION:
95 * The builtin #AdgDress color used by default in #AdgDimStyle.
96 * The fallback style is a %0.75 red.
98 * This dress will be resolved to an #AdgColorStyle instance.
101 _adg_dress_color_dimension(void)
103 static AdgDress dress
= 0;
105 if (G_UNLIKELY(dress
== 0)) {
106 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
109 dress
= adg_dress_new("color-dimension", fallback
);
110 g_object_unref(fallback
);
117 * ADG_DRESS_COLOR_HATCH:
119 * The default builtin #AdgDress color for #AdgHatch entities.
120 * The fallback style is a %0.5 blue.
122 * This dress will be resolved to an #AdgColorStyle instance.
125 _adg_dress_color_hatch(void)
127 static AdgDress dress
= 0;
129 if (G_UNLIKELY(dress
== 0)) {
130 AdgStyle
*fallback
= g_object_new(ADG_TYPE_COLOR_STYLE
,
133 dress
= adg_dress_new("color-hatch", fallback
);
134 g_object_unref(fallback
);
143 * The default builtin #AdgDress line. This is a transparent dress
144 * without a fallback style.
146 * This dress will be resolved to an #AdgLineStyle instance.
149 _adg_dress_line(void)
151 static AdgDress dress
= 0;
153 if (G_UNLIKELY(dress
== 0)) {
154 dress
= adg_dress_new_full("line", NULL
, ADG_TYPE_LINE_STYLE
);
161 * ADG_DRESS_LINE_STROKE:
163 * The builtin #AdgDress line used by default by #AdgStroke entities.
164 * The fallback style is a default line with a thickness of %1.75.
166 * This dress will be resolved to an #AdgLineStyle instance.
169 _adg_dress_line_stroke(void)
171 static AdgDress dress
= 0;
173 if (G_UNLIKELY(dress
== 0)) {
174 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
175 "width", 1.75, NULL
);
177 dress
= adg_dress_new("line-stroke", fallback
);
178 g_object_unref(fallback
);
185 * ADG_DRESS_LINE_DIMENSION:
187 * The builtin #AdgDress line type used by base and extension lines
188 * for dimensions. The fallback style is a default line with a
189 * thickness of %0.75.
191 * This dress will be resolved to an #AdgLineStyle instance.
194 _adg_dress_line_dimension(void)
196 static AdgDress dress
= 0;
198 if (G_UNLIKELY(dress
== 0)) {
199 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
200 "width", 0.75, NULL
);
202 dress
= adg_dress_new("line-dimension", fallback
);
203 g_object_unref(fallback
);
210 * ADG_DRESS_LINE_HATCH:
212 * The builtin #AdgDress line type used by the default #AdgRuledFill
213 * style implementation. The fallback style is a default line with
216 * This dress will be resolved to an #AdgLineStyle instance.
219 _adg_dress_line_hatch(void)
221 static AdgDress dress
= 0;
223 if (G_UNLIKELY(dress
== 0)) {
224 AdgStyle
*fallback
= g_object_new(ADG_TYPE_LINE_STYLE
,
225 "color-dress", ADG_DRESS_COLOR_HATCH
,
228 dress
= adg_dress_new("line-hatch", fallback
);
229 g_object_unref(fallback
);
238 * The default builtin #AdgDress font. The fallback style is
241 * This dress will be resolved to an #AdgFontStyle instance.
244 _adg_dress_text(void)
246 static AdgDress dress
= 0;
248 if (G_UNLIKELY(dress
== 0)) {
249 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
253 dress
= adg_dress_new("text", fallback
);
254 g_object_unref(fallback
);
261 * ADG_DRESS_TEXT_VALUE:
263 * The builtin #AdgDress font used to render the nominal value of a
264 * dimension. The fallback style is %Sans %12 %bold.
266 * This dress will be resolved to an #AdgFontStyle instance.
269 _adg_dress_text_value(void)
271 static AdgDress dress
= 0;
273 if (G_UNLIKELY(dress
== 0)) {
274 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
276 "weight", CAIRO_FONT_WEIGHT_BOLD
,
279 dress
= adg_dress_new("text-value", fallback
);
280 g_object_unref(fallback
);
287 * ADG_DRESS_TEXT_LIMIT:
289 * The builtin #AdgDress font used to render the limits of either
290 * the min and max values of a dimension. The fallback style
293 * This dress will be resolved to an #AdgFontStyle instance.
296 _adg_dress_text_limit(void)
298 static AdgDress dress
= 0;
300 if (G_UNLIKELY(dress
== 0)) {
301 AdgStyle
*fallback
= g_object_new(ADG_TYPE_FONT_STYLE
,
305 dress
= adg_dress_new("text-limit", fallback
);
306 g_object_unref(fallback
);
313 * ADG_DRESS_DIMENSION:
315 * The default builtin #AdgDress for dimensioning. The fallback
316 * style is the default #AdgDimStyle implementation with #AdgArrow
317 * as markers on both sides.
319 * This dress will be resolved to an #AdgDimStyle instance.
322 _adg_dress_dimension(void)
324 static AdgDress dress
= 0;
326 if (G_UNLIKELY(dress
== 0)) {
327 AdgMarker
*arrow
= g_object_new(ADG_TYPE_ARROW
, NULL
);
328 AdgStyle
*fallback
= g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
330 adg_dim_style_use_marker1((AdgDimStyle
*) fallback
, arrow
);
331 adg_marker_set_pos(arrow
, 1);
332 adg_dim_style_use_marker2((AdgDimStyle
*) fallback
, arrow
);
334 dress
= adg_dress_new("dimension", fallback
);
335 g_object_unref(fallback
);
336 g_object_unref(arrow
);
345 * The default builtin #AdgDress for filling. This is a transparent
346 * dress without a fallback style.
348 * This dress will be resolved to an #AdgFillStyle derived instance.
351 _adg_dress_fill(void)
353 static AdgDress dress
= 0;
355 if (G_UNLIKELY(dress
== 0)) {
356 dress
= adg_dress_new_full("fill", NULL
, ADG_TYPE_FILL_STYLE
);
363 * ADG_DRESS_FILL_HATCH:
365 * The default builtin #AdgDress for used by #AdgHatch instances.
366 * The fallback style is the default implementation of the
367 * #AdgRuledFill instance.
369 * This dress will be resolved to an #AdgFillStyle derived instance.
372 _adg_dress_fill_hatch(void)
374 static AdgDress dress
= 0;
376 if (G_UNLIKELY(dress
== 0)) {
377 AdgStyle
*fallback
= g_object_new(ADG_TYPE_RULED_FILL
,
378 "line-dress", ADG_DRESS_LINE_HATCH
,
381 dress
= adg_dress_new_full("fill-hatch", fallback
,
382 ADG_TYPE_FILL_STYLE
);
383 g_object_unref(fallback
);