[dia] Bug 86238 - width line in UML objects (and fonts)
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Bug 86238 - width line in UML objects (and fonts)
- Date: Sat, 18 Sep 2010 15:42:33 +0000 (UTC)
commit 9ac7c0aa4b2c1edc001fb5f9e2e0ce1803bae103
Author: Hans Breuer <hans breuer org>
Date: Sat Sep 18 17:37:20 2010 +0200
Bug 86238 - width line in UML objects (and fonts)
Finally almost every UML shape should allow to change it's
line width, font and font size.
Also the ordering of properties in the dialogs are improved.
objects/UML/actor.c | 6 +-
objects/UML/association.c | 117 ++++++++++++++++++++++-----------------
objects/UML/classicon.c | 21 +++++--
objects/UML/component_feature.c | 19 ++++---
objects/UML/constraint.c | 56 +++++++++++--------
objects/UML/dependency.c | 80 ++++++++++++++------------
objects/UML/generalization.c | 73 ++++++++++++++-----------
objects/UML/implements.c | 61 +++++++++++---------
objects/UML/large_package.c | 52 ++++++++++-------
objects/UML/message.c | 60 +++++++++++---------
objects/UML/node.c | 20 +++++--
objects/UML/note.c | 12 ++--
objects/UML/object.c | 40 ++++++++------
objects/UML/realizes.c | 72 +++++++++++++-----------
objects/UML/small_package.c | 12 ++--
objects/UML/state.c | 46 ++++++++++-----
objects/UML/usecase.c | 18 +++---
17 files changed, 436 insertions(+), 329 deletions(-)
---
diff --git a/objects/UML/actor.c b/objects/UML/actor.c
index 1932cb2..f960356 100644
--- a/objects/UML/actor.c
+++ b/objects/UML/actor.c
@@ -117,13 +117,13 @@ static ObjectOps actor_ops = {
static PropDescription actor_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_WIDTH_OPTIONAL,
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
+ { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_STD_FILL_COLOUR_OPTIONAL,
- { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
PROP_DESC_END
};
@@ -138,11 +138,11 @@ actor_describe_props(Actor *actor)
static PropOffset actor_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Actor, line_width) },
{"text",PROP_TYPE_TEXT,offsetof(Actor,text)},
{"text_font",PROP_TYPE_FONT,offsetof(Actor,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Actor,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Actor,attrs.color)},
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Actor, line_width) },
{"line_colour",PROP_TYPE_COLOUR,offsetof(Actor,line_color)},
{"fill_colour",PROP_TYPE_COLOUR,offsetof(Actor,fill_color)},
{ NULL, 0, 0 },
diff --git a/objects/UML/association.c b/objects/UML/association.c
index 713ac2d..67481dc 100644
--- a/objects/UML/association.c
+++ b/objects/UML/association.c
@@ -139,15 +139,16 @@ struct _Association {
Color text_color;
Color line_color;
+
+ DiaFont *font;
+ real font_height;
+ real line_width;
};
-#define ASSOCIATION_WIDTH 0.1
-#define ASSOCIATION_TRIANGLESIZE 0.8
-#define ASSOCIATION_DIAMONDLEN 1.4
-#define ASSOCIATION_DIAMONDWIDTH 0.7
-#define ASSOCIATION_FONTHEIGHT 0.8
-#define ASSOCIATION_END_SPACE 0.2
-static DiaFont *assoc_font = NULL;
+#define ASSOCIATION_TRIANGLESIZE (assoc->font_height)
+#define ASSOCIATION_DIAMONDLEN (assoc->font_height*14./8.)
+#define ASSOCIATION_DIAMONDWIDTH (assoc->font_height*7./8.)
+#define ASSOCIATION_END_SPACE (assoc->font_height/4)
static real association_distance_from(Association *assoc, Point *point);
static void association_select(Association *assoc, Point *clicked_point,
@@ -177,7 +178,7 @@ static DiaObject *association_load(ObjectNode obj_node, int version,
const char *filename);
static void association_update_data(Association *assoc);
-static coord get_aggregate_pos_diff(AssociationEnd *end);
+static coord get_aggregate_pos_diff(AssociationEnd *end, const Association *assoc);
static ObjectTypeOps association_type_ops =
{
@@ -231,6 +232,9 @@ static PropEnumData prop_assoc_type_data[] = {
};
static PropDescription association_props[] = {
+ PROP_STD_NOTEBOOK_BEGIN,
+ PROP_NOTEBOOK_PAGE("assoc", PROP_FLAG_DONT_MERGE, N_("General")),
+ ORTHCONN_COMMON_PROPERTIES,
{ "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Name"), NULL, NULL },
{ "direction", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Direction"), NULL, prop_assoc_direction_data },
@@ -264,11 +268,15 @@ static PropDescription association_props[] = {
N_(" "), NULL, 0 },
PROP_MULTICOL_END("sides"),
- ORTHCONN_COMMON_PROPERTIES,
+ PROP_NOTEBOOK_PAGE("style", PROP_FLAG_DONT_MERGE, N_("Style")),
/* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_LINE_WIDTH_OPTIONAL,
PROP_STD_LINE_COLOUR_OPTIONAL,
-
+ PROP_STD_NOTEBOOK_END,
+
PROP_DESC_END
};
@@ -293,6 +301,9 @@ static PropOffset association_offsets[] = {
PROP_OFFSET_MULTICOL_END("sides"),
ORTHCONN_COMMON_PROPERTIES_OFFSETS,
+ { "text_font", PROP_TYPE_FONT, offsetof(Association, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Association, font_height) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Association, line_width) },
{ "line_colour",PROP_TYPE_COLOUR,offsetof(Association, line_color) },
{ "text_colour", PROP_TYPE_COLOUR, offsetof(Association, text_color) },
{ NULL, 0, 0 }
@@ -328,7 +339,7 @@ static real
association_distance_from(Association *assoc, Point *point)
{
OrthConn *orth = &assoc->orth;
- return orthconn_distance_from(orth, point, ASSOCIATION_WIDTH);
+ return orthconn_distance_from(orth, point, assoc->line_width);
}
static void
@@ -376,9 +387,9 @@ assoc_get_direction_poly (Association *assoc, Point* poly)
poly[0].x -= assoc->text_width/2.0;
poly[0].y = assoc->text_pos.y;
poly[1].x = poly[0].x;
- poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+ poly[1].y = poly[0].y - assoc->font_height*0.5;
+ poly[2].x = poly[0].x + assoc->font_height*0.5;
+ poly[2].y = poly[0].y - assoc->font_height*0.5*0.5;
return TRUE;
} else if (assoc->direction == ASSOC_LEFT) {
poly[0].x = assoc->text_pos.x - 0.2;
@@ -386,9 +397,9 @@ assoc_get_direction_poly (Association *assoc, Point* poly)
poly[0].x -= assoc->text_width/2.0;
poly[0].y = assoc->text_pos.y;
poly[1].x = poly[0].x;
- poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+ poly[1].y = poly[0].y - assoc->font_height*0.5;
+ poly[2].x = poly[0].x - assoc->font_height*0.5;
+ poly[2].y = poly[0].y - assoc->font_height*0.5*0.5;
return TRUE;
}
}
@@ -409,7 +420,7 @@ association_draw(Association *assoc, DiaRenderer *renderer)
points = &orth->points[0];
n = orth->numpoints;
- renderer_ops->set_linewidth(renderer, ASSOCIATION_WIDTH);
+ renderer_ops->set_linewidth(renderer, assoc->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
renderer_ops->set_linejoin(renderer, LINEJOIN_MITER);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -439,12 +450,12 @@ association_draw(Association *assoc, DiaRenderer *renderer)
endarrow.type = ARROW_NONE;
}
renderer_ops->draw_polyline_with_arrows(renderer, points, n,
- ASSOCIATION_WIDTH,
+ assoc->line_width,
&assoc->line_color,
&startarrow, &endarrow);
/* Name: */
- renderer_ops->set_font(renderer, assoc_font, ASSOCIATION_FONTHEIGHT);
+ renderer_ops->set_font(renderer, assoc->font, assoc->font_height);
if (assoc->name != NULL) {
pos = assoc->text_pos;
@@ -471,7 +482,7 @@ association_draw(Association *assoc, DiaRenderer *renderer)
end->text_align,
&assoc->text_color);
g_free (role_name);
- pos.y += ASSOCIATION_FONTHEIGHT;
+ pos.y += assoc->font_height;
}
if (end->multiplicity != NULL) {
renderer_ops->draw_string(renderer, end->multiplicity,
@@ -532,11 +543,11 @@ association_set_state(Association *assoc, AssociationState *state)
assoc->descent = 0.0;
if (assoc->name != NULL) {
assoc->text_width =
- dia_font_string_width(assoc->name, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_string_width(assoc->name, assoc->font, assoc->font_height);
assoc->ascent =
- dia_font_ascent(assoc->name, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_ascent(assoc->name, assoc->font, assoc->font_height);
assoc->descent =
- dia_font_descent(assoc->name, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_descent(assoc->name, assoc->font, assoc->font_height);
}
assoc->direction = state->direction;
@@ -558,21 +569,21 @@ association_set_state(Association *assoc, AssociationState *state)
end->multi_descent = 0.0;
if (end->role != NULL && *end->role) {
end->text_width =
- dia_font_string_width(end->role, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_string_width(end->role, assoc->font, assoc->font_height);
end->role_ascent =
- dia_font_ascent(end->role, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_ascent(end->role, assoc->font, assoc->font_height);
end->role_descent =
- dia_font_ascent(end->role, assoc_font, ASSOCIATION_FONTHEIGHT);
+ dia_font_ascent(end->role, assoc->font, assoc->font_height);
}
if (end->multiplicity != NULL) {
end->text_width = MAX(end->text_width,
dia_font_string_width(end->multiplicity,
- assoc_font,
- ASSOCIATION_FONTHEIGHT) );
+ assoc->font,
+ assoc->font_height) );
end->role_ascent = dia_font_ascent(end->multiplicity,
- assoc_font,ASSOCIATION_FONTHEIGHT);
+ assoc->font,assoc->font_height);
end->role_descent = dia_font_descent(end->multiplicity,
- assoc_font,ASSOCIATION_FONTHEIGHT);
+ assoc->font,assoc->font_height);
}
}
@@ -625,10 +636,10 @@ association_update_data_end(Association *assoc, int endnum)
end->text_pos.y -= end->role_descent;
if (points[fp].x < points[sp].x) {
end->text_align = ALIGN_LEFT;
- end->text_pos.x += (get_aggregate_pos_diff(end) + ASSOCIATION_END_SPACE);
+ end->text_pos.x += (get_aggregate_pos_diff(end, assoc) + ASSOCIATION_END_SPACE);
} else {
end->text_align = ALIGN_RIGHT;
- end->text_pos.x -= (get_aggregate_pos_diff(end) + ASSOCIATION_END_SPACE);
+ end->text_pos.x -= (get_aggregate_pos_diff(end, assoc) + ASSOCIATION_END_SPACE);
}
break;
case VERTICAL:
@@ -639,9 +650,9 @@ association_update_data_end(Association *assoc, int endnum)
end->text_pos.y += end->role_ascent;
if (points[fp].y > points[sp].y) {
if (end->role!=NULL && *end->role)
- end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
+ end->text_pos.y -= assoc->font_height;
if (end->multiplicity!=NULL)
- end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
+ end->text_pos.y -= assoc->font_height;
}
end->text_align = ALIGN_LEFT;
@@ -652,7 +663,7 @@ association_update_data_end(Association *assoc, int endnum)
- (end->text_align == ALIGN_LEFT ? 0 : end->text_width);
rect.right = rect.left + end->text_width;
rect.top = end->text_pos.y - end->role_ascent;
- rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT;
+ rect.bottom = rect.top + 2*assoc->font_height;
rectangle_union(&obj->bounding_box, &rect);
@@ -694,13 +705,13 @@ association_update_data(Association *assoc)
extra->start_trans =
extra->start_long = (assoc->end[0].aggregate == AGGREGATE_NONE?
- ASSOCIATION_WIDTH/2.0:
- (ASSOCIATION_WIDTH + ASSOCIATION_DIAMONDLEN)/2.0);
- extra->middle_trans = ASSOCIATION_WIDTH/2.0;
+ assoc->line_width/2.0:
+ (assoc->line_width + ASSOCIATION_DIAMONDLEN)/2.0);
+ extra->middle_trans = assoc->line_width/2.0;
extra->end_trans =
extra->end_long = (assoc->end[1].aggregate == AGGREGATE_NONE?
- ASSOCIATION_WIDTH/2.0:
- (ASSOCIATION_WIDTH + ASSOCIATION_DIAMONDLEN)/2.0);
+ assoc->line_width/2.0:
+ (assoc->line_width + ASSOCIATION_DIAMONDLEN)/2.0);
if (assoc->end[0].arrow)
extra->start_trans = MAX(extra->start_trans, ASSOCIATION_TRIANGLESIZE);
@@ -744,7 +755,7 @@ association_update_data(Association *assoc)
rect.left -= assoc->text_width/2.0;
rect.right = rect.left + assoc->text_width;
rect.top = assoc->text_pos.y - assoc->ascent;
- rect.bottom = rect.top + ASSOCIATION_FONTHEIGHT;
+ rect.bottom = rect.top + assoc->font_height;
rectangle_union(&obj->bounding_box, &rect);
@@ -752,7 +763,8 @@ association_update_data(Association *assoc)
association_update_data_end(assoc, 1);
}
-static coord get_aggregate_pos_diff(AssociationEnd *end)
+static coord
+get_aggregate_pos_diff(AssociationEnd *end, const Association *assoc)
{
coord width=0;
if(end->arrow){
@@ -781,9 +793,6 @@ association_create(Point *startpoint,
int i;
int user_d;
- if (assoc_font == NULL)
- assoc_font = dia_font_new_from_style(DIA_FONT_MONOSPACE, ASSOCIATION_FONTHEIGHT);
-
assoc = g_malloc0(sizeof(Association));
orth = &assoc->orth;
obj = &orth->object;
@@ -794,7 +803,12 @@ association_create(Point *startpoint,
orthconn_init(orth, startpoint);
+ /* old defaults */
+ assoc->font_height = 0.8;
+ assoc->font = dia_font_new_from_style(DIA_FONT_MONOSPACE, assoc->font_height);
+
assoc->text_color = color_black;
+ assoc->line_width = 0.1; /* old default */
assoc->line_color = attributes_get_foreground();
assoc->name = NULL;
assoc->assoc_type = AGGREGATE_NORMAL;
@@ -882,7 +896,7 @@ association_destroy(Association *assoc)
int i;
orthconn_destroy(&assoc->orth);
-
+ dia_font_unref(assoc->font);
g_free(assoc->name);
for (i=0;i<2;i++) {
@@ -909,7 +923,10 @@ association_copy(Association *assoc)
newassoc->direction = assoc->direction;
newassoc->show_direction = assoc->show_direction;
newassoc->assoc_type = assoc->assoc_type;
+ newassoc->font = dia_font_copy (assoc->font);
+ newassoc->font_height = assoc->font_height;
newassoc->text_color = assoc->text_color;
+ newassoc->line_width = assoc->line_width;
newassoc->line_color = assoc->line_color;
for (i=0;i<2;i++) {
newassoc->end[i] = assoc->end[i];
@@ -994,14 +1011,14 @@ association_load(ObjectNode obj_node, int version, const char *filename)
assoc->end[i].text_width = 0.0;
if (assoc->end[i].role != NULL) {
assoc->end[i].text_width =
- dia_font_string_width(assoc->end[i].role, assoc_font,
- ASSOCIATION_FONTHEIGHT);
+ dia_font_string_width(assoc->end[i].role, assoc->font,
+ assoc->font_height);
}
if (assoc->end[i].multiplicity != NULL) {
assoc->end[i].text_width =
MAX(assoc->end[i].text_width,
dia_font_string_width(assoc->end[i].multiplicity,
- assoc_font, ASSOCIATION_FONTHEIGHT) );
+ assoc->font, assoc->font_height) );
}
composite = data_next(composite);
}
diff --git a/objects/UML/classicon.c b/objects/UML/classicon.c
index 8a941da..049cb55 100644
--- a/objects/UML/classicon.c
+++ b/objects/UML/classicon.c
@@ -52,6 +52,8 @@ struct _Classicon {
TextAttributes attrs;
Color line_color;
Color fill_color;
+
+ real line_width;
};
enum CLassIconStereotype {
@@ -61,7 +63,6 @@ enum CLassIconStereotype {
};
-#define CLASSICON_LINEWIDTH 0.1
#define CLASSICON_RADIOUS 1
#define CLASSICON_FONTHEIGHT 0.8
#define CLASSICON_MARGIN 0.5
@@ -134,8 +135,6 @@ static PropEnumData prop_classicon_type_data[] = {
static PropDescription classicon_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
/* how it used to be before 0.96+SVN */
{ "stereotype", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Stereotype"), NULL, prop_classicon_type_data},
/* one name, one type: but breaks forward-compatibiliy so kind of reverted */
@@ -146,7 +145,10 @@ static PropDescription classicon_props[] = {
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
- { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -162,8 +164,6 @@ classicon_describe_props(Classicon *classicon)
static PropOffset classicon_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Classicon,line_color) },
- { "fill_colour",PROP_TYPE_COLOUR,offsetof(Classicon,fill_color) },
/* backward compatibility */
{ "stereotype", PROP_TYPE_ENUM, offsetof(Classicon, stereotype) },
/* one name, one type! */
@@ -172,7 +172,10 @@ static PropOffset classicon_offsets[] = {
{ "text",PROP_TYPE_TEXT,offsetof(Classicon,text)},
{ "text_font",PROP_TYPE_FONT,offsetof(Classicon,attrs.font)},
{ PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Classicon,attrs.height)},
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Classicon, line_width) },
{ "text_colour",PROP_TYPE_COLOUR,offsetof(Classicon,attrs.color)},
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Classicon,line_color) },
+ { "fill_colour",PROP_TYPE_COLOUR,offsetof(Classicon,fill_color) },
{ NULL, 0, 0 },
};
@@ -272,7 +275,7 @@ classicon_draw(Classicon *icon, DiaRenderer *renderer)
2*r, 2*r,
&icon->fill_color);
- renderer_ops->set_linewidth(renderer, CLASSICON_LINEWIDTH);
+ renderer_ops->set_linewidth(renderer, icon->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
renderer_ops->draw_ellipse(renderer,
@@ -435,6 +438,10 @@ classicon_create(Point *startpoint,
int i;
cicon = g_malloc0(sizeof(Classicon));
+
+ /* old default */
+ cicon->line_width = 0.1;
+
elem = &cicon->element;
obj = &elem->object;
diff --git a/objects/UML/component_feature.c b/objects/UML/component_feature.c
index 156518e..9183bab 100644
--- a/objects/UML/component_feature.c
+++ b/objects/UML/component_feature.c
@@ -73,9 +73,9 @@ struct _Compfeat {
Handle text_handle;
Color line_color;
+ real line_width;
};
-#define COMPPROP_WIDTH 0.1
#define COMPPROP_FONTHEIGHT 0.8
#define COMPPROP_DIAMETER 0.8
#define COMPPROP_DEFAULTLEN 2.0
@@ -156,7 +156,6 @@ static PropEnumData prop_compfeat_type_data[] = {
static PropDescription compfeat_props[] = {
ORTHCONN_COMMON_PROPERTIES,
- PROP_STD_LINE_COLOUR_OPTIONAL,
{ "role", PROP_TYPE_ENUM, PROP_FLAG_NO_DEFAULTS, NULL, NULL, prop_compfeat_type_data },
{ "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
PROP_STD_TEXT_FONT,
@@ -164,6 +163,8 @@ static PropDescription compfeat_props[] = {
PROP_STD_TEXT_COLOUR,
PROP_STD_TEXT_ALIGNMENT,
{ "text_pos", PROP_TYPE_POINT, 0, NULL, NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -224,7 +225,6 @@ compfeat_describe_props(Compfeat *compfeat)
static PropOffset compfeat_offsets[] = {
ORTHCONN_COMMON_PROPERTIES_OFFSETS,
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Compfeat, line_color) },
{ "role", PROP_TYPE_ENUM, offsetof(Compfeat, role) },
{ "text", PROP_TYPE_TEXT, offsetof(Compfeat, text) },
{ "text_font", PROP_TYPE_FONT, offsetof(Compfeat, attrs.font) },
@@ -232,6 +232,8 @@ static PropOffset compfeat_offsets[] = {
{ "text_colour", PROP_TYPE_COLOUR, offsetof(Compfeat, attrs.color) },
{ "text_alignment", PROP_TYPE_ENUM, offsetof(Compfeat, attrs.alignment) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Compfeat, text_pos) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Compfeat, line_width) },
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Compfeat, line_color) },
{ NULL, 0, 0 }
};
@@ -261,7 +263,7 @@ static real
compfeat_distance_from(Compfeat *compfeat, Point *point)
{
OrthConn *orth = &compfeat->orth;
- return orthconn_distance_from(orth, point, COMPPROP_WIDTH);
+ return orthconn_distance_from(orth, point, compfeat->line_width);
}
static void
@@ -332,7 +334,7 @@ compfeat_draw(Compfeat *compfeat, DiaRenderer *renderer)
points = &orth->points[0];
n = orth->numpoints;
- renderer_ops->set_linewidth(renderer, COMPPROP_WIDTH);
+ renderer_ops->set_linewidth(renderer, compfeat->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -353,7 +355,7 @@ compfeat_draw(Compfeat *compfeat, DiaRenderer *renderer)
endarrow.width = COMPPROP_DIAMETER;
endarrow.type = compprop_arrow[compfeat->role];
renderer_ops->draw_polyline_with_arrows(renderer, points, n,
- COMPPROP_WIDTH,
+ compfeat->line_width,
&compfeat->line_color,
&startarrow, &endarrow);
@@ -376,6 +378,7 @@ compfeat_create(Point *startpoint,
compfeat = g_new0(Compfeat, 1);
compfeat->role = compfeat->roletmp = GPOINTER_TO_INT(user_data);
+ compfeat->line_width = 0.1;
orth = &compfeat->orth;
obj = &orth->object;
@@ -452,8 +455,8 @@ compfeat_update_data(Compfeat *compfeat)
/* Boundingbox: */
extra->start_long =
extra->start_trans =
- extra->end_long = COMPPROP_WIDTH + COMPPROP_DIAMETER;
- extra->end_trans = COMPPROP_WIDTH + COMPPROP_DIAMETER;
+ extra->end_long = compfeat->line_width + COMPPROP_DIAMETER;
+ extra->end_trans = compfeat->line_width + COMPPROP_DIAMETER;
orthconn_update_boundingbox(orth);
text_calc_boundingbox(compfeat->text, &rect);
diff --git a/objects/UML/constraint.c b/objects/UML/constraint.c
index 9f46301..4f956f5 100644
--- a/objects/UML/constraint.c
+++ b/objects/UML/constraint.c
@@ -50,20 +50,20 @@ struct _Constraint {
Color text_color;
Color line_color;
+
+ DiaFont *font;
+ real font_height;
+ real line_width;
};
-#define CONSTRAINT_WIDTH 0.1
#define CONSTRAINT_DASHLEN 0.4
-#define CONSTRAINT_FONTHEIGHT 0.8
-#define CONSTRAINT_ARROWLEN 0.8
-#define CONSTRAINT_ARROWWIDTH 0.5
+#define CONSTRAINT_ARROWLEN (constraint->font_height)
+#define CONSTRAINT_ARROWWIDTH (constraint->font_height*5./8.)
#define HANDLE_MOVE_TEXT (HANDLE_CUSTOM1)
-static DiaFont *constraint_font = NULL;
-
static ObjectChange* constraint_move_handle(Constraint *constraint, Handle *handle,
Point *to, ConnectionPoint *cp,
HandleMoveReason reason, ModifierKeys modifiers);
@@ -127,8 +127,11 @@ static PropDescription constraint_props[] = {
N_("Constraint:"), NULL, NULL },
{ "text_pos", PROP_TYPE_POINT, 0, NULL, NULL, NULL},
/* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -145,7 +148,10 @@ static PropOffset constraint_offsets[] = {
CONNECTION_COMMON_PROPERTIES_OFFSETS,
{ "constraint", PROP_TYPE_STRING, offsetof(Constraint, text) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Constraint, text_pos) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Constraint, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Constraint, font_height) },
{ "text_colour",PROP_TYPE_COLOUR,offsetof(Constraint, text_color)},
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Constraint, line_width) },
{ "line_colour",PROP_TYPE_COLOUR,offsetof(Constraint, line_color)},
{ NULL, 0, 0 }
};
@@ -176,7 +182,7 @@ constraint_distance_from(Constraint *constraint, Point *point)
endpoints = &constraint->connection.endpoints[0];
dist = distance_line_point(&endpoints[0], &endpoints[1],
- CONSTRAINT_WIDTH, point);
+ constraint->line_width, point);
return dist;
}
@@ -254,7 +260,7 @@ constraint_draw(Constraint *constraint, DiaRenderer *renderer)
endpoints = &constraint->connection.endpoints[0];
- renderer_ops->set_linewidth(renderer, CONSTRAINT_WIDTH);
+ renderer_ops->set_linewidth(renderer, constraint->line_width);
renderer_ops->set_dashlength(renderer, CONSTRAINT_DASHLEN);
renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -265,12 +271,12 @@ constraint_draw(Constraint *constraint, DiaRenderer *renderer)
renderer_ops->draw_line_with_arrows(renderer,
&endpoints[0], &endpoints[1],
- CONSTRAINT_WIDTH,
+ constraint->line_width,
&constraint->line_color,
NULL, &arrow);
- renderer_ops->set_font(renderer, constraint_font,
- CONSTRAINT_FONTHEIGHT);
+ renderer_ops->set_font(renderer, constraint->font,
+ constraint->font_height);
renderer_ops->draw_string(renderer,
constraint->brtext,
&constraint->text_pos, ALIGN_LEFT,
@@ -288,18 +294,19 @@ constraint_create(Point *startpoint,
DiaObject *obj;
Point defaultlen = { 1.0, 1.0 };
- if (constraint_font == NULL) {
- constraint_font =
- dia_font_new_from_style (DIA_FONT_MONOSPACE, CONSTRAINT_FONTHEIGHT);
- }
-
constraint = g_malloc0(sizeof(Constraint));
+ /* old defaults */
+ constraint->font_height = 0.8;
+ constraint->font =
+ dia_font_new_from_style (DIA_FONT_MONOSPACE, constraint->font_height);
+ constraint->line_width = 0.1;
+
conn = &constraint->connection;
conn->endpoints[0] = *startpoint;
conn->endpoints[1] = *startpoint;
point_add(&conn->endpoints[1], &defaultlen);
-
+
obj = &conn->object;
obj->type = &constraint_type;
@@ -332,6 +339,7 @@ static void
constraint_destroy(Constraint *constraint)
{
connection_destroy(&constraint->connection);
+ dia_font_unref(constraint->font);
g_free(constraint->brtext);
g_free(constraint->text);
}
@@ -360,8 +368,8 @@ constraint_update_data(Constraint *constraint)
obj->position = conn->endpoints[0];
constraint->text_width = dia_font_string_width(constraint->brtext,
- constraint_font,
- CONSTRAINT_FONTHEIGHT);
+ constraint->font,
+ constraint->font_height);
constraint->text_handle.pos = constraint->text_pos;
@@ -372,8 +380,8 @@ constraint_update_data(Constraint *constraint)
extra->start_long =
extra->start_trans =
- extra->end_long = CONSTRAINT_WIDTH/2.0;
- extra->end_trans = MAX(CONSTRAINT_WIDTH,CONSTRAINT_ARROWLEN)/2.0;
+ extra->end_long = constraint->line_width/2.0;
+ extra->end_trans = MAX(constraint->line_width,CONSTRAINT_ARROWLEN)/2.0;
connection_update_boundingbox(conn);
@@ -382,8 +390,8 @@ constraint_update_data(Constraint *constraint)
rect.right = rect.left + constraint->text_width;
rect.top = constraint->text_pos.y -
dia_font_ascent(constraint->brtext,
- constraint_font, CONSTRAINT_FONTHEIGHT);
- rect.bottom = rect.top + CONSTRAINT_FONTHEIGHT;
+ constraint->font, constraint->font_height);
+ rect.bottom = rect.top + constraint->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
diff --git a/objects/UML/dependency.c b/objects/UML/dependency.c
index ba16ce4..ec52b45 100644
--- a/objects/UML/dependency.c
+++ b/objects/UML/dependency.c
@@ -54,16 +54,16 @@ struct _Dependency {
char *name;
char *stereotype; /* excluding << and >> */
char *st_stereotype; /* including << and >> */
+
+ DiaFont *font;
+ real font_height;
+ real line_width;
};
-#define DEPENDENCY_WIDTH 0.1
-#define DEPENDENCY_ARROWLEN 0.8
-#define DEPENDENCY_ARROWWIDTH 0.5
+#define DEPENDENCY_ARROWLEN (dep->font_height)
+#define DEPENDENCY_ARROWWIDTH (dep->font_height*5./8.)
#define DEPENDENCY_DASHLEN 0.4
-#define DEPENDENCY_FONTHEIGHT 0.8
-
-static DiaFont *dep_font = NULL;
static real dependency_distance_from(Dependency *dep, Point *point);
static void dependency_select(Dependency *dep, Point *clicked_point,
@@ -130,15 +130,18 @@ static ObjectOps dependency_ops = {
static PropDescription dependency_props[] = {
ORTHCONN_COMMON_PROPERTIES,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_LINE_COLOUR_OPTIONAL,
{ "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Name:"), NULL, NULL },
{ "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Stereotype:"), NULL, NULL },
{ "draw_arrow", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
N_("Show arrow:"), NULL, NULL },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -153,11 +156,14 @@ dependency_describe_props(Dependency *dependency)
static PropOffset dependency_offsets[] = {
ORTHCONN_COMMON_PROPERTIES_OFFSETS,
- { "text_colour", PROP_TYPE_COLOUR, offsetof(Dependency, text_color) },
- { "line_colour", PROP_TYPE_COLOUR, offsetof(Dependency, line_color) },
{ "name", PROP_TYPE_STRING, offsetof(Dependency, name) },
{ "stereotype", PROP_TYPE_STRING, offsetof(Dependency, stereotype) },
{ "draw_arrow", PROP_TYPE_BOOL, offsetof(Dependency, draw_arrow) },
+ { "text_colour", PROP_TYPE_COLOUR, offsetof(Dependency, text_color) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Dependency, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Dependency, font_height) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Dependency, line_width) },
+ { "line_colour", PROP_TYPE_COLOUR, offsetof(Dependency, line_color) },
{ NULL, 0, 0 }
};
@@ -182,7 +188,7 @@ static real
dependency_distance_from(Dependency *dep, Point *point)
{
OrthConn *orth = &dep->orth;
- return orthconn_distance_from(orth, point, DEPENDENCY_WIDTH);
+ return orthconn_distance_from(orth, point, dep->line_width);
}
static void
@@ -232,7 +238,7 @@ dependency_draw(Dependency *dep, DiaRenderer *renderer)
points = &orth->points[0];
n = orth->numpoints;
- renderer_ops->set_linewidth(renderer, DEPENDENCY_WIDTH);
+ renderer_ops->set_linewidth(renderer, dep->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED);
renderer_ops->set_dashlength(renderer, DEPENDENCY_DASHLEN);
renderer_ops->set_linejoin(renderer, LINEJOIN_MITER);
@@ -244,11 +250,11 @@ dependency_draw(Dependency *dep, DiaRenderer *renderer)
renderer_ops->draw_polyline_with_arrows(renderer,
points, n,
- DEPENDENCY_WIDTH,
+ dep->line_width,
&dep->line_color,
NULL, &arrow);
- renderer_ops->set_font(renderer, dep_font, DEPENDENCY_FONTHEIGHT);
+ renderer_ops->set_font(renderer, dep->font, dep->font_height);
pos = dep->text_pos;
if (dep->st_stereotype != NULL && dep->st_stereotype[0] != '\0') {
@@ -257,7 +263,7 @@ dependency_draw(Dependency *dep, DiaRenderer *renderer)
&pos, dep->text_align,
&dep->text_color);
- pos.y += DEPENDENCY_FONTHEIGHT;
+ pos.y += dep->font_height;
}
if (dep->name != NULL && dep->name[0] != '\0') {
@@ -288,21 +294,21 @@ dependency_update_data(Dependency *dep)
dep->text_width = 0.0;
if (dep->name)
- dep->text_width = dia_font_string_width(dep->name, dep_font,
- DEPENDENCY_FONTHEIGHT);
+ dep->text_width = dia_font_string_width(dep->name, dep->font,
+ dep->font_height);
if (dep->stereotype)
dep->text_width = MAX(dep->text_width,
- dia_font_string_width(dep->stereotype, dep_font,
- DEPENDENCY_FONTHEIGHT));
+ dia_font_string_width(dep->stereotype, dep->font,
+ dep->font_height));
extra->start_trans =
extra->start_long =
- extra->middle_trans = DEPENDENCY_WIDTH/2.0;
+ extra->middle_trans = dep->line_width/2.0;
extra->end_trans =
extra->end_long = (dep->draw_arrow?
- (DEPENDENCY_WIDTH + DEPENDENCY_ARROWLEN)/2.0:
- DEPENDENCY_WIDTH/2.0);
+ (dep->line_width + DEPENDENCY_ARROWLEN)/2.0:
+ dep->line_width/2.0);
orthconn_update_boundingbox(orth);
@@ -323,8 +329,8 @@ dependency_update_data(Dependency *dep)
dep->text_pos.y = points[i].y;
if (dep->name)
dep->text_pos.y -= dia_font_descent(dep->name,
- dep_font,
- DEPENDENCY_FONTHEIGHT);
+ dep->font,
+ dep->font_height);
break;
case VERTICAL:
dep->text_align = ALIGN_LEFT;
@@ -333,8 +339,8 @@ dependency_update_data(Dependency *dep)
0.5*(points[i].y+points[i+1].y);
if (dep->name)
dep->text_pos.y -= dia_font_descent(dep->name,
- dep_font,
- DEPENDENCY_FONTHEIGHT);
+ dep->font,
+ dep->font_height);
break;
}
@@ -346,9 +352,9 @@ dependency_update_data(Dependency *dep)
rect.top = dep->text_pos.y;
if (dep->name)
rect.top -= dia_font_ascent(dep->name,
- dep_font,
- DEPENDENCY_FONTHEIGHT);
- rect.bottom = rect.top + 2*DEPENDENCY_FONTHEIGHT;
+ dep->font,
+ dep->font_height);
+ rect.bottom = rect.top + 2*dep->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
@@ -408,12 +414,14 @@ dependency_create(Point *startpoint,
Dependency *dep;
OrthConn *orth;
DiaObject *obj;
-
- if (dep_font == NULL) {
- dep_font = dia_font_new_from_style(DIA_FONT_MONOSPACE, DEPENDENCY_FONTHEIGHT);
- }
dep = g_new0(Dependency, 1);
+
+ /* old defaults */
+ dep->font_height = 0.8;
+ dep->font = dia_font_new_from_style(DIA_FONT_MONOSPACE, dep->font_height);
+ dep->line_width = 0.1;
+
orth = &dep->orth;
obj = (DiaObject *)dep;
@@ -445,7 +453,7 @@ dependency_destroy(Dependency *dep)
g_free(dep->name);
g_free(dep->stereotype);
g_free(dep->st_stereotype);
-
+ dia_font_unref(dep->font);
orthconn_destroy(&dep->orth);
}
@@ -463,5 +471,3 @@ dependency_load(ObjectNode obj_node, int version, const char *filename)
}
return obj;
}
-
-
diff --git a/objects/UML/generalization.c b/objects/UML/generalization.c
index 80ff36e..1902952 100644
--- a/objects/UML/generalization.c
+++ b/objects/UML/generalization.c
@@ -46,8 +46,12 @@ struct _Generalization {
Alignment text_align;
real text_width;
- Color text_color;
- Color line_color;
+ DiaFont *font;
+ real font_height;
+ Color text_color;
+
+ real line_width;
+ Color line_color;
char *name;
char *stereotype; /* excluding << and >> */
@@ -55,10 +59,7 @@ struct _Generalization {
};
#define GENERALIZATION_WIDTH 0.1
-#define GENERALIZATION_TRIANGLESIZE 0.8
-#define GENERALIZATION_FONTHEIGHT 0.8
-
-static DiaFont *genlz_font = NULL;
+#define GENERALIZATION_TRIANGLESIZE (genlz->font_height)
static real generalization_distance_from(Generalization *genlz, Point *point);
static void generalization_select(Generalization *genlz, Point *clicked_point,
@@ -126,13 +127,16 @@ static ObjectOps generalization_ops = {
static PropDescription generalization_props[] = {
ORTHCONN_COMMON_PROPERTIES,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_LINE_COLOUR_OPTIONAL,
{ "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
N_("Name:"), NULL, NULL },
{ "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
N_("Stereotype:"), NULL, NULL },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -147,10 +151,13 @@ generalization_describe_props(Generalization *generalization)
static PropOffset generalization_offsets[] = {
ORTHCONN_COMMON_PROPERTIES_OFFSETS,
- {"text_colour",PROP_TYPE_COLOUR,offsetof(Generalization,text_color)},
- {"line_colour",PROP_TYPE_COLOUR,offsetof(Generalization,line_color)},
{ "name", PROP_TYPE_STRING, offsetof(Generalization, name) },
{ "stereotype", PROP_TYPE_STRING, offsetof(Generalization, stereotype) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Generalization, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Generalization, font_height) },
+ {"text_colour",PROP_TYPE_COLOUR,offsetof(Generalization,text_color)},
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Generalization, line_width) },
+ {"line_colour",PROP_TYPE_COLOUR,offsetof(Generalization,line_color)},
{ NULL, 0, 0 }
};
@@ -175,7 +182,7 @@ static real
generalization_distance_from(Generalization *genlz, Point *point)
{
OrthConn *orth = &genlz->orth;
- return orthconn_distance_from(orth, point, GENERALIZATION_WIDTH);
+ return orthconn_distance_from(orth, point, genlz->line_width);
}
static void
@@ -225,7 +232,7 @@ generalization_draw(Generalization *genlz, DiaRenderer *renderer)
points = &orth->points[0];
n = orth->numpoints;
- renderer_ops->set_linewidth(renderer, GENERALIZATION_WIDTH);
+ renderer_ops->set_linewidth(renderer, genlz->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
renderer_ops->set_linejoin(renderer, LINEJOIN_MITER);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -236,11 +243,11 @@ generalization_draw(Generalization *genlz, DiaRenderer *renderer)
renderer_ops->draw_polyline_with_arrows(renderer,
points, n,
- GENERALIZATION_WIDTH,
+ genlz->line_width,
&genlz->line_color,
&arrow, NULL);
- renderer_ops->set_font(renderer, genlz_font, GENERALIZATION_FONTHEIGHT);
+ renderer_ops->set_font(renderer, genlz->font, genlz->font_height);
pos = genlz->text_pos;
if (genlz->st_stereotype != NULL && genlz->st_stereotype[0] != '\0') {
@@ -249,7 +256,7 @@ generalization_draw(Generalization *genlz, DiaRenderer *renderer)
&pos, genlz->text_align,
&genlz->text_color);
- pos.y += GENERALIZATION_FONTHEIGHT;
+ pos.y += genlz->font_height;
}
if (genlz->name != NULL && genlz->name[0] != '\0') {
@@ -285,33 +292,33 @@ generalization_update_data(Generalization *genlz)
ascent = 0.0;
if (genlz->name) {
- genlz->text_width = dia_font_string_width(genlz->name, genlz_font,
- GENERALIZATION_FONTHEIGHT);
+ genlz->text_width = dia_font_string_width(genlz->name, genlz->font,
+ genlz->font_height);
descent = dia_font_descent(genlz->name,
- genlz_font,GENERALIZATION_FONTHEIGHT);
+ genlz->font,genlz->font_height);
ascent = dia_font_ascent(genlz->name,
- genlz_font,GENERALIZATION_FONTHEIGHT);
+ genlz->font,genlz->font_height);
}
if (genlz->stereotype) {
genlz->text_width = MAX(genlz->text_width,
dia_font_string_width(genlz->stereotype,
- genlz_font,
- GENERALIZATION_FONTHEIGHT));
+ genlz->font,
+ genlz->font_height));
if (!genlz->name) {
descent = dia_font_descent(genlz->stereotype,
- genlz_font,GENERALIZATION_FONTHEIGHT);
+ genlz->font,genlz->font_height);
}
ascent = dia_font_ascent(genlz->stereotype,
- genlz_font,GENERALIZATION_FONTHEIGHT);
+ genlz->font,genlz->font_height);
}
extra = &orth->extra_spacing;
- extra->start_trans = GENERALIZATION_WIDTH/2.0 + GENERALIZATION_TRIANGLESIZE;
+ extra->start_trans = genlz->line_width/2.0 + GENERALIZATION_TRIANGLESIZE;
extra->start_long =
extra->middle_trans =
extra->end_trans =
- extra->end_long = GENERALIZATION_WIDTH/2.0;
+ extra->end_long = genlz->line_width/2.0;
orthconn_update_boundingbox(orth);
@@ -344,7 +351,7 @@ generalization_update_data(Generalization *genlz)
rect.left -= genlz->text_width/2.0;
rect.right = rect.left + genlz->text_width;
rect.top = genlz->text_pos.y - ascent;
- rect.bottom = rect.top + 2*GENERALIZATION_FONTHEIGHT;
+ rect.bottom = rect.top + 2*genlz->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
@@ -406,11 +413,13 @@ generalization_create(Point *startpoint,
OrthConn *orth;
DiaObject *obj;
- if (genlz_font == NULL) {
- genlz_font = dia_font_new_from_style(DIA_FONT_MONOSPACE, GENERALIZATION_FONTHEIGHT);
- }
-
genlz = g_new0(Generalization, 1);
+
+ /* old defaults */
+ genlz->font_height = 0.8;
+ genlz->font = dia_font_new_from_style(DIA_FONT_MONOSPACE, genlz->font_height);
+ genlz->line_width = 0.1;
+
orth = &genlz->orth;
obj = (DiaObject *)genlz;
@@ -440,7 +449,7 @@ generalization_destroy(Generalization *genlz)
g_free(genlz->name);
g_free(genlz->stereotype);
g_free(genlz->st_stereotype);
-
+ dia_font_unref(genlz->font);
orthconn_destroy(&genlz->orth);
}
diff --git a/objects/UML/implements.c b/objects/UML/implements.c
index ab773b7..02b1e9a 100644
--- a/objects/UML/implements.c
+++ b/objects/UML/implements.c
@@ -46,8 +46,12 @@ struct _Implements {
Point circle_center; /* Calculated from diameter*/
- Color text_color;
- Color line_color;
+ DiaFont *font;
+ real font_height;
+ Color text_color;
+
+ real line_width;
+ Color line_color;
gchar *text;
Point text_pos;
@@ -56,14 +60,10 @@ struct _Implements {
};
#define IMPLEMENTS_WIDTH 0.1
-#define IMPLEMENTS_FONTHEIGHT 0.8
#define HANDLE_CIRCLE_SIZE (HANDLE_CUSTOM1)
#define HANDLE_MOVE_TEXT (HANDLE_CUSTOM2)
-
-static DiaFont *implements_font = NULL;
-
static ObjectChange* implements_move_handle(Implements *implements, Handle *handle,
Point *to, ConnectionPoint *cp,
HandleMoveReason reason, ModifierKeys modifiers);
@@ -124,15 +124,17 @@ static ObjectOps implements_ops = {
static PropDescription implements_props[] = {
CONNECTION_COMMON_PROPERTIES,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
/* how it used to be before 0.96+SVN */
{ "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Interface:"), NULL, NULL },
/* new name matching "same name, same type" rule - reverted, forward compatibility seems more important */
{ "name", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Interface:"), NULL, NULL },
-
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
{ "text_pos", PROP_TYPE_POINT, 0, NULL, NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
{ "diameter", PROP_TYPE_REAL, 0, NULL, NULL, NULL },
PROP_DESC_END
};
@@ -147,10 +149,13 @@ implements_describe_props(Implements *implements)
static PropOffset implements_offsets[] = {
CONNECTION_COMMON_PROPERTIES_OFFSETS,
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Implements, line_color) },
- { "text_colour",PROP_TYPE_COLOUR,offsetof(Implements, text_color) },
{ "text", PROP_TYPE_STRING, offsetof(Implements, text) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Implements, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Implements, font_height) },
+ { "text_colour",PROP_TYPE_COLOUR,offsetof(Implements, text_color) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Implements, text_pos) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Implements, line_width) },
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Implements, line_color) },
{ "diameter", PROP_TYPE_REAL, offsetof(Implements, circle_diameter) },
{ NULL, 0, 0 }
};
@@ -178,7 +183,7 @@ implements_distance_from(Implements *implements, Point *point)
endpoints = &implements->connection.endpoints[0];
dist1 = distance_line_point( &endpoints[0], &endpoints[1],
- IMPLEMENTS_WIDTH, point);
+ implements->line_width, point);
dist2 = distance_point_point( &implements->circle_center, point)
- implements->circle_diameter/2.0;
if (dist2<0)
@@ -264,7 +269,7 @@ implements_draw(Implements *implements, DiaRenderer *renderer)
endpoints = &implements->connection.endpoints[0];
- renderer_ops->set_linewidth(renderer, IMPLEMENTS_WIDTH);
+ renderer_ops->set_linewidth(renderer, implements->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -282,7 +287,7 @@ implements_draw(Implements *implements, DiaRenderer *renderer)
&implements->line_color);
- renderer_ops->set_font(renderer, implements_font, IMPLEMENTS_FONTHEIGHT);
+ renderer_ops->set_font(renderer, implements->font, implements->font_height);
if (implements->text)
renderer_ops->draw_string(renderer,
implements->text,
@@ -301,13 +306,14 @@ implements_create(Point *startpoint,
DiaObject *obj;
Point defaultlen = { 1.0, 1.0 };
- if (implements_font == NULL) {
- implements_font =
- dia_font_new_from_style(DIA_FONT_MONOSPACE, IMPLEMENTS_FONTHEIGHT);
- }
-
implements = g_malloc0(sizeof(Implements));
+ /* old defaults */
+ implements->font_height = 0.8;
+ implements->font =
+ dia_font_new_from_style(DIA_FONT_MONOSPACE, implements->font_height);
+ implements->line_width = 0.1;
+
conn = &implements->connection;
conn->endpoints[0] = *startpoint;
conn->endpoints[1] = *startpoint;
@@ -352,6 +358,7 @@ static void
implements_destroy(Implements *implements)
{
connection_destroy(&implements->connection);
+ dia_font_unref(implements->font);
g_free(implements->text);
}
@@ -369,8 +376,8 @@ implements_update_data(Implements *implements)
implements->text_width = 0.0;
if (implements->text)
implements->text_width = dia_font_string_width(implements->text,
- implements_font,
- IMPLEMENTS_FONTHEIGHT);
+ implements->font,
+ implements->font_height);
if (connpoint_is_autogap(conn->endpoint_handles[0].connected_to) ||
connpoint_is_autogap(conn->endpoint_handles[1].connected_to)) {
@@ -401,8 +408,8 @@ implements_update_data(Implements *implements)
/* Boundingbox: */
extra->start_long =
extra->start_trans =
- extra->end_long = IMPLEMENTS_WIDTH/2.0;
- extra->end_trans = (IMPLEMENTS_WIDTH + implements->circle_diameter)/2.0;
+ extra->end_long = implements->line_width/2.0;
+ extra->end_trans = (implements->line_width + implements->circle_diameter)/2.0;
connection_update_boundingbox(conn);
@@ -412,9 +419,9 @@ implements_update_data(Implements *implements)
rect.top = implements->text_pos.y;
if (implements->text)
rect.top -= dia_font_ascent(implements->text,
- implements_font,
- IMPLEMENTS_FONTHEIGHT);
- rect.bottom = rect.top + IMPLEMENTS_FONTHEIGHT;
+ implements->font,
+ implements->font_height);
+ rect.bottom = rect.top + implements->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
diff --git a/objects/UML/large_package.c b/objects/UML/large_package.c
index c71ddaf..68db381 100644
--- a/objects/UML/large_package.c
+++ b/objects/UML/large_package.c
@@ -58,6 +58,8 @@ struct _LargePackage {
Color line_color;
Color fill_color;
+ real font_height;
+
real topwidth;
real topheight;
};
@@ -66,7 +68,6 @@ struct _LargePackage {
* older versions.
*/
#define LARGEPACKAGE_BORDERWIDTH 0.1
-#define LARGEPACKAGE_FONTHEIGHT 0.8
static real largepackage_distance_from(LargePackage *pkg, Point *point);
static void largepackage_select(LargePackage *pkg, Point *clicked_point,
@@ -128,15 +129,17 @@ static ObjectOps largepackage_ops = {
static PropDescription largepackage_props[] = {
ELEMENT_COMMON_PROPERTIES,
+ { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
+ N_("Name"), NULL, NULL },
+ { "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
+ N_("Stereotype"), NULL, NULL },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
PROP_STD_LINE_WIDTH_OPTIONAL,
PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_STD_FILL_COLOUR_OPTIONAL,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- { "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Stereotype"), NULL, NULL },
- { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Name"), NULL, NULL },
PROP_DESC_END
};
@@ -151,12 +154,14 @@ largepackage_describe_props(LargePackage *largepackage)
static PropOffset largepackage_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
+ {"stereotype", PROP_TYPE_STRING, offsetof(LargePackage , stereotype) },
+ {"name", PROP_TYPE_STRING, offsetof(LargePackage , name) },
+ { "text_font", PROP_TYPE_FONT, offsetof(LargePackage, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(LargePackage, font_height) },
+ {"text_colour",PROP_TYPE_COLOUR,offsetof(LargePackage,text_color)},
{ PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(LargePackage, line_width) },
{"line_colour",PROP_TYPE_COLOUR,offsetof(LargePackage,line_color)},
{"fill_colour",PROP_TYPE_COLOUR,offsetof(LargePackage,fill_color)},
- {"text_colour",PROP_TYPE_COLOUR,offsetof(LargePackage,text_color)},
- {"stereotype", PROP_TYPE_STRING, offsetof(LargePackage , stereotype) },
- {"name", PROP_TYPE_STRING, offsetof(LargePackage , name) },
{ NULL, 0, 0 },
};
@@ -264,12 +269,12 @@ largepackage_draw(LargePackage *pkg, DiaRenderer *renderer)
&pkg->line_color);
- renderer_ops->set_font(renderer, pkg->font, LARGEPACKAGE_FONTHEIGHT);
+ renderer_ops->set_font(renderer, pkg->font, pkg->font_height);
p1.x = x + 0.1;
- p1.y = y - LARGEPACKAGE_FONTHEIGHT -
+ p1.y = y - pkg->font_height -
dia_font_descent(pkg->st_stereotype,
- pkg->font, LARGEPACKAGE_FONTHEIGHT) - 0.1;
+ pkg->font, pkg->font_height) - 0.1;
@@ -277,7 +282,7 @@ largepackage_draw(LargePackage *pkg, DiaRenderer *renderer)
renderer_ops->draw_string(renderer, pkg->st_stereotype, &p1,
ALIGN_LEFT, &pkg->text_color);
}
- p1.y += LARGEPACKAGE_FONTHEIGHT;
+ p1.y += pkg->font_height;
if (pkg->name)
renderer_ops->draw_string(renderer, pkg->name, &p1,
@@ -295,18 +300,18 @@ largepackage_update_data(LargePackage *pkg)
pkg->st_stereotype = string_to_stereotype(pkg->stereotype);
}
- pkg->topheight = LARGEPACKAGE_FONTHEIGHT + 0.1*2;
+ pkg->topheight = pkg->font_height + 0.1*2;
pkg->topwidth = 2.0;
if (pkg->name != NULL)
pkg->topwidth = MAX(pkg->topwidth,
dia_font_string_width(pkg->name, pkg->font,
- LARGEPACKAGE_FONTHEIGHT)+2*0.1);
+ pkg->font_height)+2*0.1);
if (pkg->st_stereotype != NULL && pkg->st_stereotype[0] != '\0') {
pkg->topwidth = MAX(pkg->topwidth,
dia_font_string_width(pkg->st_stereotype, pkg->font,
- LARGEPACKAGE_FONTHEIGHT)+2*0.1);
- pkg->topheight += LARGEPACKAGE_FONTHEIGHT;
+ pkg->font_height)+2*0.1);
+ pkg->topheight += pkg->font_height;
}
if (elem->width < (pkg->topwidth + 0.2))
@@ -358,15 +363,17 @@ largepackage_create(Point *startpoint,
pkg->text_color = color_black;
pkg->line_color = attributes_get_foreground();
pkg->fill_color = attributes_get_background();
- pkg->font = dia_font_new_from_style(DIA_FONT_MONOSPACE,
- LARGEPACKAGE_FONTHEIGHT);
-
+ /* old defaults */
+ pkg->font_height = 0.8;
+ pkg->font = dia_font_new_from_style(DIA_FONT_MONOSPACE, pkg->font_height);
+ pkg->line_width = 0.1;
+
pkg->stereotype = NULL;
pkg->st_stereotype = NULL;
pkg->name = g_strdup("");
pkg->topwidth = 2.0;
- pkg->topheight = LARGEPACKAGE_FONTHEIGHT*2 + 0.1*2;
+ pkg->topheight = pkg->font_height*2 + 0.1*2;
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &pkg->connections[i];
@@ -389,6 +396,7 @@ largepackage_destroy(LargePackage *pkg)
g_free(pkg->stereotype);
g_free(pkg->st_stereotype);
g_free(pkg->name);
+ dia_font_unref(pkg->font);
element_destroy(&pkg->element);
}
diff --git a/objects/UML/message.c b/objects/UML/message.c
index 7d62574..ec086eb 100644
--- a/objects/UML/message.c
+++ b/objects/UML/message.c
@@ -64,19 +64,19 @@ struct _Message {
Color text_color;
Color line_color;
+ DiaFont *font;
+ real font_height;
+ real line_width;
+
MessageType type;
};
-#define MESSAGE_WIDTH 0.1
#define MESSAGE_DASHLEN 0.4
-#define MESSAGE_FONTHEIGHT 0.8
-#define MESSAGE_ARROWLEN 0.8
-#define MESSAGE_ARROWWIDTH 0.5
+#define MESSAGE_ARROWLEN (message->font_height)
+#define MESSAGE_ARROWWIDTH (message->font_height*5./8.)
#define HANDLE_MOVE_TEXT (HANDLE_CUSTOM1)
-static DiaFont *message_font = NULL;
-
static ObjectChange* message_move_handle(Message *message, Handle *handle,
Point *to, ConnectionPoint *cp,
HandleMoveReason reason, ModifierKeys modifiers);
@@ -146,18 +146,20 @@ static PropEnumData prop_message_type_data[] = {
static PropDescription message_props[] = {
CONNECTION_COMMON_PROPERTIES,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_LINE_COLOUR_OPTIONAL,
/* how it used to be before 0.96+SVN */
{ "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
/* new name matching "same name, same type" rule */
{ "message", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
-
{ "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Message type:"), NULL, prop_message_type_data },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
{ "text_pos", PROP_TYPE_POINT, 0,
"text_pos:", NULL,NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -172,14 +174,17 @@ message_describe_props(Message *mes)
static PropOffset message_offsets[] = {
CONNECTION_COMMON_PROPERTIES_OFFSETS,
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Message,line_color) },
- { "text_colour",PROP_TYPE_COLOUR,offsetof(Message,text_color) },
/* backward compatibility */
{ "text", PROP_TYPE_STRING, offsetof(Message, text) },
/* new name matching "same name, same type" rule */
{ "message", PROP_TYPE_STRING, offsetof(Message, text) },
{ "type", PROP_TYPE_ENUM, offsetof(Message, type) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Message, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Message, font_height) },
+ { "text_colour",PROP_TYPE_COLOUR,offsetof(Message,text_color) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Message,text_pos) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Message, line_width) },
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Message,line_color) },
{ NULL, 0, 0 }
};
@@ -207,7 +212,7 @@ message_distance_from(Message *message, Point *point)
endpoints = &message->connection.endpoints[0];
- dist = distance_line_point(&endpoints[0], &endpoints[1], MESSAGE_WIDTH, point);
+ dist = distance_line_point(&endpoints[0], &endpoints[1], message->line_width, point);
return dist;
}
@@ -296,7 +301,7 @@ message_draw(Message *message, DiaRenderer *renderer)
endpoints = &message->connection.endpoints[0];
- renderer_ops->set_linewidth(renderer, MESSAGE_WIDTH);
+ renderer_ops->set_linewidth(renderer, message->line_width);
renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);
@@ -331,12 +336,12 @@ message_draw(Message *message, DiaRenderer *renderer)
renderer_ops->draw_line_with_arrows(renderer,
&p1, &p2,
- MESSAGE_WIDTH,
+ message->line_width,
&message->line_color,
&arrow, NULL);
- renderer_ops->set_font(renderer, message_font,
- MESSAGE_FONTHEIGHT);
+ renderer_ops->set_font(renderer, message->font,
+ message->font_height);
if (message->type==MESSAGE_CREATE)
mname = g_strdup_printf ("%s%s%s", UML_STEREOTYPE_START, "create", UML_STEREOTYPE_END);
@@ -369,13 +374,14 @@ message_create(Point *startpoint,
LineBBExtras *extra;
DiaObject *obj;
- if (message_font == NULL) {
- message_font =
- dia_font_new_from_style (DIA_FONT_SANS, MESSAGE_FONTHEIGHT);
- }
-
message = g_malloc0(sizeof(Message));
+ /* old defaults */
+ message->font_height = 0.8;
+ message->font =
+ dia_font_new_from_style (DIA_FONT_SANS, message->font_height);
+ message->line_width = 0.1;
+
conn = &message->connection;
conn->endpoints[0] = *startpoint;
conn->endpoints[1] = *startpoint;
@@ -404,8 +410,8 @@ message_create(Point *startpoint,
extra->start_long =
extra->start_trans =
- extra->end_long = MESSAGE_WIDTH/2.0;
- extra->end_trans = MAX(MESSAGE_WIDTH,MESSAGE_ARROWLEN)/2.0;
+ extra->end_long = message->line_width/2.0;
+ extra->end_trans = MAX(message->line_width,MESSAGE_ARROWLEN)/2.0;
message_update_data(message);
@@ -441,14 +447,14 @@ message_update_data(Message *message)
connection_update_boundingbox(conn);
message->text_width =
- dia_font_string_width(message->text, message_font, MESSAGE_FONTHEIGHT);
+ dia_font_string_width(message->text, message->font, message->font_height);
/* Add boundingbox for text: */
rect.left = message->text_pos.x-message->text_width/2;
rect.right = rect.left + message->text_width;
rect.top = message->text_pos.y -
- dia_font_ascent(message->text, message_font, MESSAGE_FONTHEIGHT);
- rect.bottom = rect.top + MESSAGE_FONTHEIGHT;
+ dia_font_ascent(message->text, message->font, message->font_height);
+ rect.bottom = rect.top + message->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
diff --git a/objects/UML/node.c b/objects/UML/node.c
index 2c342dc..910fe99 100644
--- a/objects/UML/node.c
+++ b/objects/UML/node.c
@@ -52,6 +52,8 @@ struct _Node
Color line_color;
Color fill_color;
+
+ real line_width;
};
static const double NODE_BORDERWIDTH = 0.1;
@@ -121,8 +123,6 @@ static ObjectOps node_ops =
static PropDescription node_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
@@ -130,6 +130,9 @@ static PropDescription node_props[] = {
{ "name", PROP_TYPE_TEXT, PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
/* new name matching "same name, same type" rule */
{ "text", PROP_TYPE_TEXT, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -146,8 +149,6 @@ node_describe_props(Node *node)
static PropOffset node_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- {"line_colour",PROP_TYPE_COLOUR,offsetof(Node,line_color)},
- {"fill_colour",PROP_TYPE_COLOUR,offsetof(Node,fill_color)},
/* backward compatibility */
{"name",PROP_TYPE_TEXT,offsetof(Node,name)},
/* new name matching "same name, same type" rule */
@@ -155,6 +156,9 @@ static PropOffset node_offsets[] = {
{"text_font",PROP_TYPE_FONT,offsetof(Node,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Node,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Node,attrs.color)},
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Node, line_width) },
+ {"line_colour",PROP_TYPE_COLOUR,offsetof(Node,line_color)},
+ {"fill_colour",PROP_TYPE_COLOUR,offsetof(Node,fill_color)},
{ NULL, 0, 0 },
};
@@ -245,7 +249,7 @@ static void node_draw(Node *node, DiaRenderer *renderer)
h = elem->height;
renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
- renderer_ops->set_linewidth(renderer, NODE_BORDERWIDTH);
+ renderer_ops->set_linewidth(renderer, node->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
/* Draw outer box */
@@ -331,6 +335,10 @@ static DiaObject *node_create(Point *startpoint, void *user_data, Handle **handl
int i;
node = g_malloc0(sizeof(Node));
+
+ /* old defaults */
+ node->line_width = 0.1;
+
elem = &node->element;
obj = &elem->object;
@@ -359,7 +367,7 @@ static DiaObject *node_create(Point *startpoint, void *user_data, Handle **handl
node->connections[i].connected = NULL;
}
node->connections[8].flags = CP_FLAGS_MAIN;
- elem->extra_spacing.border_trans = NODE_BORDERWIDTH/2.0;
+ elem->extra_spacing.border_trans = node->line_width/2.0;
node_update_data(node);
*handle1 = NULL;
diff --git a/objects/UML/note.c b/objects/UML/note.c
index 2295895..0c71de3 100644
--- a/objects/UML/note.c
+++ b/objects/UML/note.c
@@ -115,13 +115,13 @@ static ObjectOps note_ops = {
static PropDescription note_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_WIDTH_OPTIONAL,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
{ "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -136,13 +136,13 @@ note_describe_props(Note *note)
static PropOffset note_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Note, line_width)},
- {"line_colour",PROP_TYPE_COLOUR,offsetof(Note,line_color)},
- {"fill_colour",PROP_TYPE_COLOUR,offsetof(Note,fill_color)},
{"text",PROP_TYPE_TEXT,offsetof(Note,text)},
{"text_font",PROP_TYPE_FONT,offsetof(Note,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Note,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Note,attrs.color)},
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Note, line_width)},
+ {"line_colour",PROP_TYPE_COLOUR,offsetof(Note,line_color)},
+ {"fill_colour",PROP_TYPE_COLOUR,offsetof(Note,fill_color)},
{ NULL, 0, 0 },
};
diff --git a/objects/UML/object.c b/objects/UML/object.c
index 0079083..e15541c 100644
--- a/objects/UML/object.c
+++ b/objects/UML/object.c
@@ -143,14 +143,8 @@ static ObjectOps objet_ops = {
static PropDescription objet_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_WIDTH_OPTIONAL,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
- { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_NOTEBOOK_BEGIN,
+ PROP_NOTEBOOK_PAGE("assoc", PROP_FLAG_DONT_MERGE, N_("General")),
{ "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Stereotype"), NULL, NULL },
{ "exstate", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
@@ -161,9 +155,20 @@ static PropDescription objet_props[] = {
{ "is_active", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
N_("Active object"),NULL,NULL},
{ "show_attribs", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
- N_("Show attributes"),NULL,NULL},
+ N_("Show attributes"),NULL,NULL},
{ "multiple", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
- N_("Multiple instance"),NULL,NULL},
+ N_("Multiple instance"),NULL,NULL},
+
+ PROP_NOTEBOOK_PAGE("style", PROP_FLAG_DONT_MERGE, N_("Style")),
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
+ PROP_STD_NOTEBOOK_END,
PROP_DESC_END
};
@@ -178,21 +183,22 @@ objet_describe_props(Objet *ob)
static PropOffset objet_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Objet, line_width) },
- { "text_font",PROP_TYPE_FONT,offsetof(Objet, text_attrs.font) },
- { PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Objet, text_attrs.height) },
- { "text_colour",PROP_TYPE_COLOUR,offsetof(Objet, text_attrs.color) },
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Objet, line_color) },
- { "fill_colour",PROP_TYPE_COLOUR,offsetof(Objet, fill_color) },
{ "name", PROP_TYPE_STRING, offsetof(Objet, exstate) },
{ "stereotype", PROP_TYPE_STRING, offsetof(Objet, stereotype) },
{ "text", PROP_TYPE_TEXT, offsetof(Objet, text) },
{ "exstate", PROP_TYPE_STRING, offsetof(Objet, exstate) },
- { "attribstr", PROP_TYPE_MULTISTRING, offsetof(Objet, attrib)},
{ "attrib", PROP_TYPE_TEXT, offsetof(Objet, attributes)},
+ { "attribstr", PROP_TYPE_MULTISTRING, offsetof(Objet, attrib)},
{ "is_active", PROP_TYPE_BOOL, offsetof(Objet,is_active)},
{ "show_attribs", PROP_TYPE_BOOL, offsetof(Objet, show_attributes)},
{ "multiple", PROP_TYPE_BOOL, offsetof(Objet, is_multiple)},
+
+ { PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Objet, text_attrs.height) },
+ { "text_colour",PROP_TYPE_COLOUR,offsetof(Objet, text_attrs.color) },
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Objet, line_color) },
+ { "fill_colour",PROP_TYPE_COLOUR,offsetof(Objet, fill_color) },
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Objet, line_width) },
+ { "text_font",PROP_TYPE_FONT,offsetof(Objet, text_attrs.font) },
{ NULL, 0, 0 },
};
diff --git a/objects/UML/realizes.c b/objects/UML/realizes.c
index 8a1eddf..1bfe58b 100644
--- a/objects/UML/realizes.c
+++ b/objects/UML/realizes.c
@@ -48,18 +48,18 @@ struct _Realizes {
Color text_color;
Color line_color;
+ DiaFont *font;
+ real font_height;
+ real line_width;
+
char *name;
char *stereotype; /* excluding << and >> */
char *st_stereotype; /* including << and >> */
};
-#define REALIZES_WIDTH 0.1
-#define REALIZES_TRIANGLESIZE 0.8
+#define REALIZES_TRIANGLESIZE (realize->font_height)
#define REALIZES_DASHLEN 0.4
-#define REALIZES_FONTHEIGHT 0.8
-
-static DiaFont *realize_font = NULL;
static real realizes_distance_from(Realizes *realize, Point *point);
static void realizes_select(Realizes *realize, Point *clicked_point,
@@ -127,13 +127,16 @@ static ObjectOps realizes_ops = {
static PropDescription realizes_props[] = {
ORTHCONN_COMMON_PROPERTIES,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
- PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
{ "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Name:"), NULL, NULL },
{ "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Stereotype:"), NULL, NULL },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_FONT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_HEIGHT_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -148,10 +151,13 @@ realizes_describe_props(Realizes *realizes)
static PropOffset realizes_offsets[] = {
ORTHCONN_COMMON_PROPERTIES_OFFSETS,
- { "line_colour", PROP_TYPE_COLOUR, offsetof(Realizes, line_color) },
- { "text_colour", PROP_TYPE_COLOUR, offsetof(Realizes, text_color) },
{ "name", PROP_TYPE_STRING, offsetof(Realizes, name) },
{ "stereotype", PROP_TYPE_STRING, offsetof(Realizes, stereotype) },
+ { "text_font", PROP_TYPE_FONT, offsetof(Realizes, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Realizes, font_height) },
+ { "text_colour", PROP_TYPE_COLOUR, offsetof(Realizes, text_color) },
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(Realizes, line_width) },
+ { "line_colour", PROP_TYPE_COLOUR, offsetof(Realizes, line_color) },
{ NULL, 0, 0 }
};
@@ -177,7 +183,7 @@ static real
realizes_distance_from(Realizes *realize, Point *point)
{
OrthConn *orth = &realize->orth;
- return orthconn_distance_from(orth, point, REALIZES_WIDTH);
+ return orthconn_distance_from(orth, point, realize->line_width);
}
static void
@@ -225,7 +231,7 @@ realizes_draw(Realizes *realize, DiaRenderer *renderer)
points = &orth->points[0];
n = orth->numpoints;
- renderer_ops->set_linewidth(renderer, REALIZES_WIDTH);
+ renderer_ops->set_linewidth(renderer, realize->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED);
renderer_ops->set_dashlength(renderer, REALIZES_DASHLEN);
renderer_ops->set_linejoin(renderer, LINEJOIN_MITER);
@@ -235,11 +241,11 @@ realizes_draw(Realizes *realize, DiaRenderer *renderer)
arrow.width = REALIZES_TRIANGLESIZE;
arrow.length = REALIZES_TRIANGLESIZE;
renderer_ops->draw_polyline_with_arrows(renderer, points, n,
- REALIZES_WIDTH,
+ realize->line_width,
&realize->line_color,
&arrow, NULL);
- renderer_ops->set_font(renderer, realize_font, REALIZES_FONTHEIGHT);
+ renderer_ops->set_font(renderer, realize->font, realize->font_height);
pos = realize->text_pos;
if (realize->st_stereotype != NULL && realize->st_stereotype[0] != '\0') {
@@ -248,7 +254,7 @@ realizes_draw(Realizes *realize, DiaRenderer *renderer)
&pos, realize->text_align,
&realize->text_color);
- pos.y += REALIZES_FONTHEIGHT;
+ pos.y += realize->font_height;
}
if (realize->name != NULL && realize->name[0] != '\0') {
@@ -280,21 +286,21 @@ realizes_update_data(Realizes *realize)
}
if (realize->name)
- realize->text_width = dia_font_string_width(realize->name, realize_font,
- REALIZES_FONTHEIGHT);
+ realize->text_width = dia_font_string_width(realize->name, realize->font,
+ realize->font_height);
if (realize->stereotype)
realize->text_width = MAX(realize->text_width,
dia_font_string_width(realize->stereotype,
- realize_font,
- REALIZES_FONTHEIGHT));
+ realize->font,
+ realize->font_height));
extra = &orth->extra_spacing;
- extra->start_trans = REALIZES_WIDTH/2.0 + REALIZES_TRIANGLESIZE;
+ extra->start_trans = realize->line_width/2.0 + REALIZES_TRIANGLESIZE;
extra->start_long =
extra->middle_trans =
extra->end_trans =
- extra->end_long = REALIZES_WIDTH/2.0;
+ extra->end_long = realize->line_width/2.0;
orthconn_update_boundingbox(orth);
@@ -315,7 +321,7 @@ realizes_update_data(Realizes *realize)
realize->text_pos.y = points[i].y;
if (realize->name)
realize->text_pos.y -=
- dia_font_descent(realize->name,realize_font, REALIZES_FONTHEIGHT);
+ dia_font_descent(realize->name,realize->font, realize->font_height);
break;
case VERTICAL:
realize->text_align = ALIGN_LEFT;
@@ -323,7 +329,7 @@ realizes_update_data(Realizes *realize)
realize->text_pos.y = 0.5*(points[i].y+points[i+1].y);
if (realize->name)
realize->text_pos.y -=
- dia_font_descent(realize->name, realize_font, REALIZES_FONTHEIGHT);
+ dia_font_descent(realize->name, realize->font, realize->font_height);
break;
}
@@ -334,8 +340,8 @@ realizes_update_data(Realizes *realize)
rect.right = rect.left + realize->text_width;
rect.top = realize->text_pos.y;
if (realize->name)
- rect.top -= dia_font_ascent(realize->name,realize_font, REALIZES_FONTHEIGHT);
- rect.bottom = rect.top + 2*REALIZES_FONTHEIGHT;
+ rect.top -= dia_font_ascent(realize->name,realize->font, realize->font_height);
+ rect.bottom = rect.top + 2*realize->font_height;
rectangle_union(&obj->bounding_box, &rect);
}
@@ -396,12 +402,13 @@ realizes_create(Point *startpoint,
DiaObject *obj;
PolyBBExtras *extra;
- if (realize_font == NULL) {
- realize_font =
- dia_font_new_from_style (DIA_FONT_MONOSPACE, REALIZES_FONTHEIGHT);
- }
-
realize = g_malloc0(sizeof(Realizes));
+ /* old defaults */
+ realize->font_height = 0.8;
+ realize->font =
+ dia_font_new_from_style (DIA_FONT_MONOSPACE, realize->font_height);
+ realize->line_width = 0.1;
+
orth = &realize->orth;
obj = &orth->object;
extra = &orth->extra_spacing;
@@ -420,11 +427,11 @@ realizes_create(Point *startpoint,
realize->st_stereotype = NULL;
realize->text_width = 0;
- extra->start_trans = REALIZES_WIDTH/2.0 + REALIZES_TRIANGLESIZE;
+ extra->start_trans = realize->line_width/2.0 + REALIZES_TRIANGLESIZE;
extra->start_long =
extra->middle_trans =
extra->end_trans =
- extra->end_long = REALIZES_WIDTH/2.0;
+ extra->end_long = realize->line_width/2.0;
realizes_update_data(realize);
@@ -439,6 +446,7 @@ realizes_destroy(Realizes *realize)
g_free(realize->name);
g_free(realize->stereotype);
g_free(realize->st_stereotype);
+ dia_font_unref(realize->font);
orthconn_destroy(&realize->orth);
}
diff --git a/objects/UML/small_package.c b/objects/UML/small_package.c
index d3eef1d..119e06e 100644
--- a/objects/UML/small_package.c
+++ b/objects/UML/small_package.c
@@ -124,15 +124,15 @@ static ObjectOps smallpackage_ops = {
static PropDescription smallpackage_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_WIDTH_OPTIONAL,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
{ "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Stereotype"), NULL, NULL },
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR,
{ "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -147,14 +147,14 @@ smallpackage_describe_props(SmallPackage *smallpackage)
static PropOffset smallpackage_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(SmallPackage, line_width) },
- {"line_colour", PROP_TYPE_COLOUR, offsetof(SmallPackage, line_color) },
- {"fill_colour", PROP_TYPE_COLOUR, offsetof(SmallPackage, fill_color) },
{"stereotype", PROP_TYPE_STRING, offsetof(SmallPackage , stereotype) },
{"text",PROP_TYPE_TEXT,offsetof(SmallPackage,text)},
{"text_font",PROP_TYPE_FONT,offsetof(SmallPackage,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(SmallPackage,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(SmallPackage,attrs.color)},
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(SmallPackage, line_width) },
+ {"line_colour", PROP_TYPE_COLOUR, offsetof(SmallPackage, line_color) },
+ {"fill_colour", PROP_TYPE_COLOUR, offsetof(SmallPackage, fill_color) },
{ NULL, 0, 0 },
};
diff --git a/objects/UML/state.c b/objects/UML/state.c
index 4a4eca9..53122ce 100644
--- a/objects/UML/state.c
+++ b/objects/UML/state.c
@@ -66,6 +66,8 @@ struct _State {
Color line_color;
Color fill_color;
+ real line_width;
+
gchar* entry_action;
gchar* do_action;
gchar* exit_action;
@@ -145,16 +147,20 @@ static PropDescription state_props[] = {
Warning: break this and you'll get angry UML users after you. */
{ "type", PROP_TYPE_INT, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL,
"hack", NULL, NULL },
-
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
- PROP_STD_TEXT_FONT,
- PROP_STD_TEXT_HEIGHT,
- PROP_STD_TEXT_COLOUR_OPTIONAL,
- { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+
{ "entry_action", PROP_TYPE_STRING, PROP_FLAG_OPTIONAL | PROP_FLAG_VISIBLE, N_("Entry action"), NULL, NULL },
{ "do_action", PROP_TYPE_STRING, PROP_FLAG_OPTIONAL | PROP_FLAG_VISIBLE, N_("Do action"), NULL, NULL },
{ "exit_action", PROP_TYPE_STRING, PROP_FLAG_OPTIONAL | PROP_FLAG_VISIBLE, N_("Exit action"), NULL, NULL },
+
+ PROP_STD_TEXT_FONT,
+ PROP_STD_TEXT_HEIGHT,
+ PROP_STD_TEXT_COLOUR_OPTIONAL,
+ { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
+
PROP_DESC_END
};
@@ -169,12 +175,7 @@ state_describe_props(State *state)
static PropOffset state_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- {"line_colour",PROP_TYPE_COLOUR,offsetof(State,line_color)},
- {"fill_colour",PROP_TYPE_COLOUR,offsetof(State,fill_color)},
- {"text",PROP_TYPE_TEXT,offsetof(State,text)},
- {"text_font",PROP_TYPE_FONT,offsetof(State,attrs.font)},
- {PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(State,attrs.height)},
- {"text_colour",PROP_TYPE_COLOUR,offsetof(State,attrs.color)},
+
{"entry_action",PROP_TYPE_STRING,offsetof(State,entry_action)},
{"do_action",PROP_TYPE_STRING,offsetof(State,do_action)},
{"exit_action",PROP_TYPE_STRING,offsetof(State,exit_action)},
@@ -182,7 +183,16 @@ static PropOffset state_offsets[] = {
if sizeof(enum) != sizeof(int), we're toast. -- CC
*/
{ "type", PROP_TYPE_INT, offsetof(State, state_type) },
-
+
+ {"text",PROP_TYPE_TEXT,offsetof(State,text)},
+ {"text_font",PROP_TYPE_FONT,offsetof(State,attrs.font)},
+ {PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(State,attrs.height)},
+ {"text_colour",PROP_TYPE_COLOUR,offsetof(State,attrs.color)},
+
+ { PROP_STDNAME_LINE_WIDTH,PROP_TYPE_LENGTH,offsetof(State, line_width) },
+ {"line_colour",PROP_TYPE_COLOUR,offsetof(State,line_color)},
+ {"fill_colour",PROP_TYPE_COLOUR,offsetof(State,fill_color)},
+
{ NULL, 0, 0 },
};
@@ -278,7 +288,7 @@ state_draw(State *state, DiaRenderer *renderer)
h = elem->height;
renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
- renderer_ops->set_linewidth(renderer, STATE_LINEWIDTH);
+ renderer_ops->set_linewidth(renderer, state->line_width);
renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
if (state->state_type!=STATE_NORMAL) {
@@ -387,7 +397,7 @@ state_update_data(State *state)
elem->width = w;
elem->height = h;
- extra->border_trans = STATE_LINEWIDTH / 2.0;
+ extra->border_trans = state->line_width / 2.0;
/* Update connections: */
element_update_connections_rectangle(elem, state->connections);
@@ -413,6 +423,10 @@ state_create(Point *startpoint,
int i;
state = g_malloc0(sizeof(State));
+
+ /* old default */
+ state->line_width = 0.1;
+
elem = &state->element;
obj = &elem->object;
diff --git a/objects/UML/usecase.c b/objects/UML/usecase.c
index bb999b8..eb5123e 100644
--- a/objects/UML/usecase.c
+++ b/objects/UML/usecase.c
@@ -129,17 +129,17 @@ static ObjectOps usecase_ops = {
static PropDescription usecase_props[] = {
ELEMENT_COMMON_PROPERTIES,
- PROP_STD_LINE_WIDTH_OPTIONAL,
- PROP_STD_LINE_COLOUR_OPTIONAL,
- PROP_STD_FILL_COLOUR_OPTIONAL,
- { "text_outside", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
- N_("Text outside"), NULL, NULL },
{ "collaboration", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
N_("Collaboration"), NULL, NULL },
+ { "text_outside", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
+ N_("Text outside"), NULL, NULL },
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
{ "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ PROP_STD_LINE_WIDTH_OPTIONAL,
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+ PROP_STD_FILL_COLOUR_OPTIONAL,
PROP_DESC_END
};
@@ -155,15 +155,15 @@ usecase_describe_props(Usecase *usecase)
static PropOffset usecase_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Usecase, line_width)},
- {"line_colour", PROP_TYPE_COLOUR, offsetof(Usecase, line_color) },
- {"fill_colour", PROP_TYPE_COLOUR, offsetof(Usecase, fill_color) },
- {"text_outside", PROP_TYPE_BOOL, offsetof(Usecase, text_outside) },
{"collaboration", PROP_TYPE_BOOL, offsetof(Usecase, collaboration) },
+ {"text_outside", PROP_TYPE_BOOL, offsetof(Usecase, text_outside) },
{"text",PROP_TYPE_TEXT,offsetof(Usecase,text)},
{"text_font",PROP_TYPE_FONT,offsetof(Usecase,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Usecase,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Usecase,attrs.color)},
+ {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Usecase, line_width)},
+ {"line_colour", PROP_TYPE_COLOUR, offsetof(Usecase, line_color) },
+ {"fill_colour", PROP_TYPE_COLOUR, offsetof(Usecase, fill_color) },
{ NULL, 0, 0 },
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]