Re: add line width to uml objects



I finally have the uml objects line width configurable. I attached the patch. Please, let me know what do you think and if it can make it to the sources.

I'll go on with the lines (associations, and such) in a couple of days and send a patch for them.

thanks

Hans Breuer wrote:
At 28.09.2008 14:34, Pablo Gra\~na wrote:
Thanks for the review.

Strange ... the ...->line_with = attributes_get_default_linewith() are there, at least in my sources ... The patch includes:

The patch fragment for note:
@@ -305,13 +307,14 @@

   elem->corner = *startpoint;

+  note->line_width = attributes_get_default_linewidth();

No, apparently I was a bit sleepy this morning ;)

So just keep up the good work.

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert
_______________________________________________
dia-list mailing list
dia-list gnome org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Index: objects/UML/component.c
===================================================================
--- objects/UML/component.c     (revision 4117)
+++ objects/UML/component.c     (working copy)
@@ -50,6 +50,7 @@
   char *st_stereotype;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -120,6 +121,7 @@
 
 static PropDescription component_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,
@@ -142,6 +144,7 @@
 
 static PropOffset component_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Component, line_width)},
   {"line_colour",PROP_TYPE_COLOUR,offsetof(Component,line_color)},
   {"fill_colour",PROP_TYPE_COLOUR,offsetof(Component,fill_color)},
   {"stereotype", PROP_TYPE_STRING, offsetof(Component , stereotype) },
@@ -231,7 +234,7 @@
   h = elem->height;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, COMPONENT_BORDERWIDTH);
+  renderer_ops->set_linewidth(renderer, cmp->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
   p1.x = x + COMPONENT_CWIDTH/2; p1.y = y;
@@ -397,6 +400,7 @@
   obj->flags |= DIA_OBJECT_CAN_PARENT;
 
   elem->corner = *startpoint;
+  cmp->line_width = attributes_get_default_linewidth();
   cmp->line_color = attributes_get_foreground();
   cmp->fill_color = attributes_get_background();
 
@@ -418,7 +422,7 @@
     cmp->connections[i].connected = NULL;
   }
   cmp->connections[10].flags = CP_FLAGS_MAIN;
-  elem->extra_spacing.border_trans = COMPONENT_BORDERWIDTH/2.0;
+  elem->extra_spacing.border_trans = cmp->line_width/2.0;
   cmp->stereotype = NULL;
   cmp->st_stereotype = NULL;
   component_update_data(cmp);
@@ -444,11 +448,16 @@
 static DiaObject *
 component_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&component_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&component_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * COMPONENT_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Component*)obj)->line_width = COMPONENT_BORDERWIDTH;
+
+  return obj;
 }
 
-
-
-
-
Index: objects/UML/note.c
===================================================================
--- objects/UML/note.c  (revision 4117)
+++ objects/UML/note.c  (working copy)
@@ -45,12 +45,12 @@
   Text *text;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
 
 #define NOTE_BORDERWIDTH 0.1
-#define NOTE_CORNERWIDTH 0.05
 #define NOTE_CORNER 0.6
 #define NOTE_MARGIN_X 0.3
 #define NOTE_MARGIN_Y 0.3
@@ -115,6 +115,7 @@
 
 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,
@@ -135,6 +136,7 @@
 
 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)},
@@ -221,7 +223,7 @@
   h = elem->height;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, NOTE_BORDERWIDTH);
+  renderer_ops->set_linewidth(renderer, note->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
   poly[0].x = x;
@@ -247,7 +249,7 @@
   poly[1].y = y + NOTE_CORNER;
   poly[2] = poly[2];
  
-  renderer_ops->set_linewidth(renderer, NOTE_CORNERWIDTH);
+  renderer_ops->set_linewidth(renderer, note->line_width / 2);
   renderer_ops->draw_polyline(renderer, 
                           poly, 3,
                           &note->line_color);
@@ -269,8 +271,8 @@
     note->text->height*note->text->numlines + NOTE_MARGIN_Y + NOTE_CORNER;
 
   p = elem->corner;
-  p.x += NOTE_BORDERWIDTH/2.0 + NOTE_MARGIN_X;
-  p.y += NOTE_BORDERWIDTH/2.0 + NOTE_CORNER + note->text->ascent;
+  p.x += note->line_width/2.0 + NOTE_MARGIN_X;
+  p.y += note->line_width/2.0 + NOTE_CORNER + note->text->ascent;
   text_set_position(note->text, &p);
 
   /* Update connections: */
@@ -305,13 +307,14 @@
 
   elem->corner = *startpoint;
 
+  note->line_width = attributes_get_default_linewidth();
   note->line_color = attributes_get_foreground();
   note->fill_color = attributes_get_background();
 
   font = dia_font_new_from_style (DIA_FONT_MONOSPACE, 0.8);
   p = *startpoint;
-  p.x += NOTE_BORDERWIDTH/2.0 + NOTE_MARGIN_X;
-  p.y += NOTE_BORDERWIDTH/2.0 + NOTE_CORNER + dia_font_ascent("A",font, 0.8);
+  p.x += note->line_width/2.0 + NOTE_MARGIN_X;
+  p.y += note->line_width/2.0 + NOTE_CORNER + dia_font_ascent("A",font, 0.8);
   
   note->text = new_text("", font, 0.8, &p, &color_black, ALIGN_LEFT);
   dia_font_unref(font);
@@ -327,7 +330,7 @@
   }
   note->connections[NUM_CONNECTIONS-1].flags = CP_FLAGS_MAIN;
 
-  elem->extra_spacing.border_trans = NOTE_BORDERWIDTH/2.0;
+  elem->extra_spacing.border_trans = note->line_width/2.0;
   note_update_data(note);
 
   for (i=0;i<8;i++) {
@@ -350,11 +353,16 @@
 static DiaObject *
 note_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&note_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&note_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * NOTE_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Note*)obj)->line_width = NOTE_BORDERWIDTH;
+
+  return obj;
 }
 
-
-
-
-
Index: objects/UML/large_package.c
===================================================================
--- objects/UML/large_package.c (revision 4117)
+++ objects/UML/large_package.c (working copy)
@@ -52,6 +52,8 @@
 
   DiaFont *font;
 
+  real line_width;
+
   Color text_color;
   Color line_color;
   Color fill_color;
@@ -60,6 +62,9 @@
   real topheight;
 };
 
+/* The old border width, kept for compatibility with dia files created with
+ * older versions.
+ */
 #define LARGEPACKAGE_BORDERWIDTH 0.1
 #define LARGEPACKAGE_FONTHEIGHT 0.8
 
@@ -123,6 +128,7 @@
 
 static PropDescription largepackage_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  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 */
@@ -145,6 +151,7 @@
 
 static PropOffset largepackage_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  { 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)},
@@ -231,7 +238,7 @@
   h = elem->height;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, LARGEPACKAGE_BORDERWIDTH);
+  renderer_ops->set_linewidth(renderer, pkg->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
 
@@ -347,6 +354,7 @@
   elem->width = 4.0;
   elem->height = 4.0;
   
+  pkg->line_width = attributes_get_default_linewidth();
   pkg->text_color = color_black;
   pkg->line_color = attributes_get_foreground();
   pkg->fill_color = attributes_get_background();
@@ -366,7 +374,7 @@
     pkg->connections[i].connected = NULL;
   }
   pkg->connections[8].flags = CP_FLAGS_MAIN;
-  pkg->element.extra_spacing.border_trans = LARGEPACKAGE_BORDERWIDTH/2.0;
+  pkg->element.extra_spacing.border_trans = pkg->line_width/2.0;
   largepackage_update_data(pkg);
 
   *handle1 = NULL;
@@ -388,11 +396,16 @@
 static DiaObject *
 largepackage_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&largepackage_type,
-                                      obj_node,version,filename);
+  DiaObject *obj = object_load_using_properties(&largepackage_type,
+                                                obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * LARGEPACKAGE_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((LargePackage*)obj)->line_width = LARGEPACKAGE_BORDERWIDTH;
+
+  return obj;
 }
 
-
-
-
-
Index: objects/UML/class.c
===================================================================
--- objects/UML/class.c (revision 4117)
+++ objects/UML/class.c (working copy)
@@ -130,6 +130,7 @@
 /** Properties of UMLClass */
 static PropDescription umlclass_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_LINE_COLOUR_OPTIONAL,
@@ -249,6 +250,7 @@
 static PropOffset umlclass_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
 
+  { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(UMLClass, line_width) },
   { "text_colour", PROP_TYPE_COLOUR, offsetof(UMLClass, text_color) },
   { "line_colour", PROP_TYPE_COLOUR, offsetof(UMLClass, line_color) },
   { "fill_colour", PROP_TYPE_COLOUR, offsetof(UMLClass, fill_color) },
@@ -818,7 +820,7 @@
 
   if (!umlclass->suppress_attributes) {
     gint i = 0;
-    StartPoint.x += (UMLCLASS_BORDER/2.0 + 0.1);
+    StartPoint.x += (umlclass->line_width/2.0 + 0.1);
     StartPoint.y += 0.1;
 
     list = umlclass->attributes;
@@ -843,7 +845,7 @@
 
       if (attr->class_scope) {
         uml_underline_text(renderer, StartPoint, font, font_height, attstr, line_color, 
-                        UMLCLASS_BORDER, UMLCLASS_UNDERLINEWIDTH );
+                        umlclass->line_width, UMLCLASS_UNDERLINEWIDTH );
       }
 
       if (umlclass->visible_comments && attr->comment != NULL && attr->comment[0] != '\0') {
@@ -911,7 +913,7 @@
     int wrap_pos, last_wrap_pos, ident, wrapping_needed;
     int part_opstr_len = 0, part_opstr_need = 0;
 
-    StartPoint.x += (UMLCLASS_BORDER/2.0 + 0.1);
+    StartPoint.x += (umlclass->line_width/2.0 + 0.1);
     StartPoint.y += 0.1;
 
     list = umlclass->operations;
@@ -982,7 +984,7 @@
           renderer_ops->draw_string(renderer, part_opstr, &StartPoint, ALIGN_LEFT, text_color);
          if (op->class_scope) {
            uml_underline_text(renderer, StartPoint, font, font_height, part_opstr, line_color, 
-                              UMLCLASS_BORDER, UMLCLASS_UNDERLINEWIDTH );
+                              umlclass->line_width, UMLCLASS_UNDERLINEWIDTH );
          }
           last_wrap_pos = wrap_pos;
           wrapsublist = g_list_next( wrapsublist);
@@ -994,7 +996,7 @@
         renderer_ops->draw_string(renderer, opstr, &StartPoint, ALIGN_LEFT, text_color);
        if (op->class_scope) {
          uml_underline_text(renderer, StartPoint, font, font_height, opstr, line_color, 
-                            UMLCLASS_BORDER, UMLCLASS_UNDERLINEWIDTH );
+                            umlclass->line_width, UMLCLASS_UNDERLINEWIDTH );
        }
       }
 
@@ -1107,7 +1109,7 @@
   assert(renderer != NULL);
 
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, UMLCLASS_BORDER);
+  renderer_ops->set_linewidth(renderer, umlclass->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
   
   elem = &umlclass->element;
@@ -1785,6 +1787,7 @@
   
   umlclass->stereotype_string = NULL;
   
+  umlclass->line_width = attributes_get_default_linewidth();
   umlclass->text_color = color_black;
   umlclass->line_color = attributes_get_foreground();
   umlclass->fill_color = attributes_get_background();
@@ -1805,7 +1808,7 @@
   umlclass->connections[UMLCLASS_CONNECTIONPOINTS].connected = NULL;
 #endif
 
-  elem->extra_spacing.border_trans = UMLCLASS_BORDER/2.0;
+  elem->extra_spacing.border_trans = umlclass->line_width/2.0;
   umlclass_update_data(umlclass);
 
   for (i=0;i<8;i++) {
@@ -1942,6 +1945,7 @@
   newumlclass->wrap_after_char = umlclass->wrap_after_char;
   newumlclass->comment_line_length = umlclass->comment_line_length;
   newumlclass->comment_tagging = umlclass->comment_tagging;
+  newumlclass->line_width = umlclass->line_width;
   newumlclass->text_color = umlclass->text_color;
   newumlclass->line_color = umlclass->line_color;
   newumlclass->fill_color = umlclass->fill_color;
@@ -2088,6 +2092,8 @@
                    umlclass->comment_line_length);
   data_add_boolean(new_attribute(obj_node, "comment_tagging"),
                    umlclass->comment_tagging);
+  data_add_real(new_attribute(obj_node, "line_width"), 
+                  umlclass->line_width);
   data_add_color(new_attribute(obj_node, "line_color"), 
                   &umlclass->line_color);
   data_add_color(new_attribute(obj_node, "fill_color"), 
@@ -2221,6 +2227,12 @@
   if (attr_node != NULL)
     umlclass->comment_tagging = data_boolean(attribute_first_data(attr_node));
   
+  /* Loads the line width */
+  umlclass->line_width = UMLCLASS_BORDER;
+  attr_node = object_find_attribute(obj_node, "line_width");
+  if(attr_node != NULL)
+    umlclass->line_width = data_real(attribute_first_data(attr_node));
+
   umlclass->line_color = color_black;
   /* support the old name ... */
   attr_node = object_find_attribute(obj_node, "foreground_color");
@@ -2277,7 +2289,7 @@
 
   umlclass_calculate_data(umlclass);
 
-  elem->extra_spacing.border_trans = UMLCLASS_BORDER/2.0;
+  elem->extra_spacing.border_trans = umlclass->line_width/2.0;
   umlclass_update_data(umlclass);
   
   for (i=0;i<8;i++) {
@@ -2389,4 +2401,3 @@
   /* Check that operations are set up right. */
 }
 
-
Index: objects/UML/object.c
===================================================================
--- objects/UML/object.c        (revision 4117)
+++ objects/UML/object.c        (working copy)
@@ -52,6 +52,7 @@
   char *exstate;  /* used for explicit state */
   Text *attributes;
 
+  real line_width;
   Color text_color;
   Color line_color;
   Color fill_color;
@@ -68,7 +69,6 @@
 
 #define OBJET_BORDERWIDTH 0.1
 #define OBJET_ACTIVEBORDERWIDTH 0.2
-#define OBJET_LINEWIDTH 0.05
 #define OBJET_MARGIN_X 0.5
 #define OBJET_MARGIN_Y 0.5
 #define OBJET_MARGIN_M 0.4
@@ -143,6 +143,7 @@
 
 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_LINE_COLOUR_OPTIONAL, 
@@ -175,6 +176,7 @@
 
 static PropOffset objet_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Objet, line_width) },
   { "text_colour",PROP_TYPE_COLOUR,offsetof(Objet, text_color) },
   { "line_colour",PROP_TYPE_COLOUR,offsetof(Objet, line_color) },
   { "fill_colour",PROP_TYPE_COLOUR,offsetof(Objet, fill_color) },
@@ -269,7 +271,7 @@
   w = elem->width;
   h = elem->height;
   
-  bw = (ob->is_active) ? OBJET_ACTIVEBORDERWIDTH: OBJET_BORDERWIDTH;
+  bw = (ob->is_active) ? OBJET_ACTIVEBORDERWIDTH: ob->line_width;
 
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
   renderer_ops->set_linewidth(renderer, bw);
@@ -327,7 +329,7 @@
   p2.x = p1.x + text_get_max_width(ob->text);
   p2.y = p1.y;
   
-  renderer_ops->set_linewidth(renderer, OBJET_LINEWIDTH);
+  renderer_ops->set_linewidth(renderer, ob->line_width/2);
     
   for (i=0; i<ob->text->numlines; i++) { 
     p1.x = x + (w - text_get_line_width(ob->text, i))/2;
@@ -451,6 +453,7 @@
   elem->corner = *startpoint;
 
   ob->text_color = color_black;
+  ob->line_width = attributes_get_default_linewidth();
   ob->line_color = attributes_get_foreground();
   ob->fill_color = attributes_get_background();
 
@@ -481,7 +484,7 @@
     ob->connections[i].connected = NULL;
   }
   ob->connections[8].flags = CP_FLAGS_MAIN;
-  elem->extra_spacing.border_trans = OBJET_BORDERWIDTH/2.0;
+  elem->extra_spacing.border_trans = ob->line_width/2.0;
   objet_update_data(ob);
 
   for (i=0;i<8;i++) {
@@ -511,8 +514,16 @@
 static DiaObject *
 objet_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&objet_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&objet_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * OBJET_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Objet*)obj)->line_width = OBJET_BORDERWIDTH;
+
+  return obj;
 }
 
-
Index: objects/UML/class.h
===================================================================
--- objects/UML/class.h (revision 4117)
+++ objects/UML/class.h (working copy)
@@ -74,6 +74,7 @@
 
   /* Class info: */
 
+  real line_width;
   real font_height;
   real abstract_font_height;
   real polymorphic_font_height;
Index: objects/UML/class_dialog.c
===================================================================
--- objects/UML/class_dialog.c  (revision 4117)
+++ objects/UML/class_dialog.c  (working copy)
@@ -79,6 +79,7 @@
   GtkSpinButton *wrap_after_char;  
   GtkSpinButton *comment_line_length;
   GtkToggleButton *comment_tagging;
+  GtkSpinButton *line_width;
   DiaColorSelector *text_color;
   DiaColorSelector *line_color;
   DiaColorSelector *fill_color;
@@ -181,6 +182,7 @@
   int comment_line_length;
   int comment_tagging;
   
+  real line_width;
   Color line_color;
   Color fill_color;
   Color text_color;
@@ -314,6 +316,7 @@
   umlclass->visible_comments = prop_dialog->comments_vis->active;
   umlclass->suppress_attributes = prop_dialog->attr_supp->active;
   umlclass->suppress_operations = prop_dialog->op_supp->active;
+  umlclass->line_width = gtk_spin_button_get_value_as_float(prop_dialog->line_width);
   dia_color_selector_get_color(GTK_WIDGET(prop_dialog->text_color), &umlclass->text_color);
   dia_color_selector_get_color(GTK_WIDGET(prop_dialog->line_color), &umlclass->line_color);
   dia_color_selector_get_color(GTK_WIDGET(prop_dialog->fill_color), &umlclass->fill_color);
@@ -362,6 +365,7 @@
   gtk_toggle_button_set_active(prop_dialog->comments_vis, umlclass->visible_comments);
   gtk_toggle_button_set_active(prop_dialog->attr_supp, umlclass->suppress_attributes);
   gtk_toggle_button_set_active(prop_dialog->op_supp, umlclass->suppress_operations);
+  gtk_spin_button_set_value (prop_dialog->line_width, umlclass->line_width);
   dia_color_selector_set_color(GTK_WIDGET(prop_dialog->text_color), &umlclass->text_color);
   dia_color_selector_set_color(GTK_WIDGET(prop_dialog->line_color), &umlclass->line_color);
   dia_color_selector_set_color(GTK_WIDGET(prop_dialog->fill_color), &umlclass->fill_color);
@@ -534,10 +538,12 @@
   GtkWidget *page_label;
   GtkWidget *label;
   GtkWidget *vbox;
+  GtkWidget *line_width;
   GtkWidget *text_color;
   GtkWidget *fill_color;
   GtkWidget *line_color;
   GtkWidget *table;
+  GtkObject *adj;
 
   prop_dialog = umlclass->properties_dialog;
 
@@ -594,33 +600,42 @@
 
 
 
-  table = gtk_table_new (2, 3, TRUE);
+  table = gtk_table_new (2, 4, TRUE);
   gtk_box_pack_start (GTK_BOX (vbox),
                      table, FALSE, TRUE, 0);
   /* should probably be refactored too. */
+  label = gtk_label_new(_("Line Width"));
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 2);
+  adj = gtk_adjustment_new(umlclass->line_width, 0.0, G_MAXFLOAT, 0.1, 1.0, 0.0);
+  line_width = gtk_spin_button_new (GTK_ADJUSTMENT(adj), 1.0, 2);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (line_width), TRUE);
+  prop_dialog->line_width = GTK_SPIN_BUTTON(line_width);
+  gtk_table_attach (GTK_TABLE (table), line_width, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 3, 2);
+
   label = gtk_label_new(_("Text Color"));
   gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 2);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 2);
   text_color = dia_color_selector_new();
   dia_color_selector_set_color(text_color, &umlclass->text_color);
   prop_dialog->text_color = (DiaColorSelector *)text_color;
-  gtk_table_attach (GTK_TABLE (table), text_color, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 3, 2);
+  gtk_table_attach (GTK_TABLE (table), text_color, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 3, 2);
 
   label = gtk_label_new(_("Foreground Color"));
   gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 2);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 2);
   line_color = dia_color_selector_new();
   dia_color_selector_set_color(line_color, &umlclass->line_color);
   prop_dialog->line_color = (DiaColorSelector *)line_color;
-  gtk_table_attach (GTK_TABLE (table), line_color, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 3, 2);
+  gtk_table_attach (GTK_TABLE (table), line_color, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 3, 2);
   
   label = gtk_label_new(_("Background Color"));
   gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 2);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 2);
   fill_color = dia_color_selector_new();
   dia_color_selector_set_color(fill_color, &umlclass->fill_color);
   prop_dialog->fill_color = (DiaColorSelector *)fill_color;
-  gtk_table_attach (GTK_TABLE (table), fill_color, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 3, 2);
+  gtk_table_attach (GTK_TABLE (table), fill_color, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 3, 2);
 
   gtk_widget_show_all (vbox);
   gtk_widget_show (page_label);
Index: objects/UML/lifeline.c
===================================================================
--- objects/UML/lifeline.c      (revision 4117)
+++ objects/UML/lifeline.c      (working copy)
@@ -56,6 +56,7 @@
   int draw_focuscontrol;
   int draw_cross;
   
+  real line_width;
   Color line_color;
   Color fill_color;
 
@@ -71,7 +72,6 @@
 
 #define LIFELINE_CP_DEFAULT_DISTANCE 0.5
 #define LIFELINE_CP_DISTANCE_INCREASE_FACTOR 0.25
-#define LIFELINE_LINEWIDTH 0.05
 #define LIFELINE_BOXWIDTH 0.1
 #define LIFELINE_WIDTH 0.7
 #define LIFELINE_HEIGHT 3.0
@@ -144,6 +144,7 @@
 
 static PropDescription lifeline_props[] = {
   CONNECTION_COMMON_PROPERTIES,
+  PROP_STD_LINE_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   { "rtop", PROP_TYPE_REAL, 0, NULL,NULL,NULL},
@@ -169,6 +170,7 @@
 
 static PropOffset lifeline_offsets[] = {
   CONNECTION_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Lifeline, line_width)},
   { "line_colour",PROP_TYPE_COLOUR,offsetof(Lifeline,line_color)},
   { "fill_colour",PROP_TYPE_COLOUR,offsetof(Lifeline,fill_color)},
   { "draw_focus", PROP_TYPE_BOOL, offsetof(Lifeline, draw_focuscontrol) },
@@ -314,7 +316,7 @@
 
   endpoints = &lifeline->connection.endpoints[0];
   
-  renderer_ops->set_linewidth(renderer, LIFELINE_LINEWIDTH);    
+  renderer_ops->set_linewidth(renderer, lifeline->line_width/2);    
   renderer_ops->set_dashlength(renderer, LIFELINE_DASHLEN);
   renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED);
 
@@ -336,7 +338,7 @@
                           &lifeline->line_color);
 
 
-  renderer_ops->set_linewidth(renderer, LIFELINE_BOXWIDTH);
+  renderer_ops->set_linewidth(renderer, lifeline->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
   p1.x = endpoints[0].x - LIFELINE_WIDTH/2.0;
@@ -560,6 +562,7 @@
 
   connection_init(conn, 4, 7);
 
+  lifeline->line_width = attributes_get_default_linewidth();
   lifeline->line_color = attributes_get_foreground();
   lifeline->fill_color = attributes_get_background();
 
@@ -645,10 +648,10 @@
   extra->start_trans =
     extra->start_long = 
     extra->end_long =
-    extra->end_trans = LIFELINE_LINEWIDTH/2.0;
+    extra->end_trans = lifeline->line_width/2/2.0;
   if (lifeline->draw_focuscontrol) {
     extra->start_trans =
-      extra->end_trans = MAX(LIFELINE_LINEWIDTH/2,(LIFELINE_WIDTH/2+LIFELINE_BOXWIDTH/2));
+      extra->end_trans = MAX(lifeline->line_width/2/2,(LIFELINE_WIDTH/2+lifeline->line_width/2));
   }
   if (lifeline->draw_cross) {
     extra->end_trans += LIFELINE_CROSSLEN;
@@ -704,15 +707,16 @@
 static DiaObject *
 lifeline_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&lifeline_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&lifeline_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * LIFELINE_BOXWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Lifeline*)obj)->line_width = LIFELINE_BOXWIDTH;
+
+  return obj;
 }
 
-
-
-
-
-
-
-
- 
Index: objects/UML/usecase.c
===================================================================
--- objects/UML/usecase.c       (revision 4117)
+++ objects/UML/usecase.c       (working copy)
@@ -50,6 +50,7 @@
   int collaboration;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -128,6 +129,7 @@
 
 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,
@@ -153,6 +155,7 @@
 
 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) },
@@ -263,7 +266,7 @@
 
 
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, USECASE_LINEWIDTH);
+  renderer_ops->set_linewidth(renderer, usecase->line_width);
 
   if (usecase->collaboration)
          renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED);
@@ -322,7 +325,7 @@
 
   elem->width = r.x;
   elem->height = r.y;
-  extra->border_trans = USECASE_LINEWIDTH / 2.0;
+  extra->border_trans = usecase->line_width / 2.0;
 
   if (usecase->text_outside) { 
          elem->width = MAX(elem->width, w);
@@ -417,6 +420,7 @@
   elem->width = USECASE_WIDTH;
   elem->height = USECASE_HEIGHT;
 
+  usecase->line_width = attributes_get_default_linewidth();
   usecase->line_color = attributes_get_foreground();
   usecase->fill_color = attributes_get_background();
 
@@ -461,8 +465,17 @@
 static DiaObject *
 usecase_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&usecase_type,
-                                      obj_node,version,filename);
+  DiaObject *obj = object_load_using_properties(&usecase_type,
+                                                obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * USECASE_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Usecase*)obj)->line_width = USECASE_LINEWIDTH;
+
+  return obj;
 }
 
 
Index: objects/UML/activity.c
===================================================================
--- objects/UML/activity.c      (revision 4117)
+++ objects/UML/activity.c      (working copy)
@@ -48,6 +48,7 @@
   Text *text;
 
   TextAttributes attrs;
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -121,6 +122,7 @@
 static PropDescription activity_props[] = {
   ELEMENT_COMMON_PROPERTIES,
 
+  PROP_STD_LINE_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   PROP_STD_TEXT_FONT,
@@ -142,6 +144,7 @@
 
 static PropOffset state_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(State, line_width)},
   {"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)},
@@ -226,7 +229,7 @@
   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);
 
    p1.x = x;
@@ -263,7 +266,7 @@
 
   elem->width = w;
   elem->height = h;
-  extra->border_trans = STATE_LINEWIDTH / 2.0;
+  extra->border_trans = state->line_width / 2.0;
 
   /* Update connections: */
   state->connections[0].pos = elem->corner;
@@ -322,6 +325,7 @@
   elem->width = STATE_WIDTH;
   elem->height = STATE_HEIGHT;
 
+  state->line_width = attributes_get_default_linewidth();
   state->line_color = attributes_get_foreground();
   state->fill_color = attributes_get_background();
 
@@ -362,8 +366,17 @@
 static DiaObject *
 state_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&activity_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&activity_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * STATE_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((State*)obj)->line_width = STATE_LINEWIDTH;
+
+  return obj;
 }
 
 
Index: objects/UML/state_term.c
===================================================================
--- objects/UML/state_term.c    (revision 4117)
+++ objects/UML/state_term.c    (working copy)
@@ -47,6 +47,7 @@
 
   int is_final;
   
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -121,6 +122,7 @@
 
 static PropDescription state_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  PROP_STD_LINE_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   { "is_final", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
@@ -139,6 +141,7 @@
 
 static PropOffset state_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(State, line_width)},
   { "line_colour",PROP_TYPE_COLOUR,offsetof(State, line_color) },
   { "fill_colour",PROP_TYPE_COLOUR,offsetof(State, fill_color) },
   { "is_final", PROP_TYPE_BOOL, offsetof(State, is_final) },
@@ -217,7 +220,7 @@
   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);
 
    p1.x = x + w/2;
@@ -255,7 +258,7 @@
    
   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);
@@ -293,6 +296,7 @@
   p.x += STATE_WIDTH/2.0;
   p.y += STATE_HEIGHT/2.0;
   
+  state->line_width = attributes_get_default_linewidth();
   state->line_color = attributes_get_foreground();
   state->fill_color = attributes_get_background();
   state->is_final = 0;
@@ -325,8 +329,16 @@
 static DiaObject *
 state_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&state_term_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&state_term_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * STATE_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((State*)obj)->line_width = STATE_LINEWIDTH;
+
+  return obj;
 }
 
-
Index: objects/UML/actor.c
===================================================================
--- objects/UML/actor.c (revision 4117)
+++ objects/UML/actor.c (working copy)
@@ -44,6 +44,7 @@
   Text *text;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -116,6 +117,7 @@
 
 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,
@@ -136,6 +138,7 @@
 
 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)},
@@ -232,7 +235,7 @@
   actor_height = elem->height - actor->text->height;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, ACTOR_LINEWIDTH);
+  renderer_ops->set_linewidth(renderer, actor->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
   r = ACTOR_HEAD(actor_height);
@@ -344,6 +347,7 @@
   elem->width = ACTOR_WIDTH;
   elem->height = ACTOR_HEIGHT;
 
+  actor->line_width = attributes_get_default_linewidth();
   actor->line_color = attributes_get_foreground();
   actor->fill_color = attributes_get_background();
 
@@ -366,7 +370,7 @@
     actor->connections[i].connected = NULL;
   }
   actor->connections[8].flags = CP_FLAGS_MAIN;
-  elem->extra_spacing.border_trans = ACTOR_LINEWIDTH/2.0;
+  elem->extra_spacing.border_trans = actor->line_width/2.0;
   actor_update_data(actor);
 
   for (i=0;i<8;i++) {
@@ -389,8 +393,16 @@
 static DiaObject *
 actor_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&actor_type,
-                                      obj_node,version,filename);
+  DiaObject *obj = object_load_using_properties(&actor_type,
+                                                obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * ACTOR_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Actor*)obj)->line_width = ACTOR_LINEWIDTH;
+
+  return obj;
 }
 
-
Index: objects/UML/classicon.c
===================================================================
--- objects/UML/classicon.c     (revision 4117)
+++ objects/UML/classicon.c     (working copy)
@@ -50,6 +50,7 @@
   int is_object;
   Text *text;
   TextAttributes attrs;
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -134,6 +135,7 @@
 
 static PropDescription classicon_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  PROP_STD_LINE_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   /* backward compatibility */
@@ -161,6 +163,7 @@
 
 static PropOffset classicon_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Classicon, line_width)},
   { "line_colour",PROP_TYPE_COLOUR,offsetof(Classicon,line_color) },
   { "fill_colour",PROP_TYPE_COLOUR,offsetof(Classicon,fill_color) },
   /* backward compatibility */
@@ -272,7 +275,7 @@
                              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,
@@ -445,6 +448,7 @@
   obj->ops = &classicon_ops;
 
   elem->corner = *startpoint;
+  cicon->line_width = attributes_get_default_linewidth();
   cicon->line_color = attributes_get_foreground();
   cicon->fill_color = attributes_get_background();
 
@@ -492,8 +496,17 @@
 static DiaObject *
 classicon_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&classicon_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&classicon_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * CLASSICON_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Classicon*)obj)->line_width = CLASSICON_LINEWIDTH;
+
+  return obj;
 }
 
 
Index: objects/UML/state.c
===================================================================
--- objects/UML/state.c (revision 4117)
+++ objects/UML/state.c (working copy)
@@ -63,6 +63,7 @@
 
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
   
@@ -145,7 +146,8 @@
       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_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   PROP_STD_TEXT_FONT,
@@ -169,6 +171,7 @@
 
 static PropOffset state_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(State, line_width)},
   {"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)},
@@ -278,7 +281,7 @@
   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 +390,7 @@
 
   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);
@@ -422,6 +425,7 @@
   elem->width = STATE_WIDTH;
   elem->height = STATE_HEIGHT;
 
+  state->line_width = attributes_get_default_linewidth();
   state->line_color = attributes_get_foreground();
   state->fill_color = attributes_get_background();
 
@@ -478,6 +482,14 @@
      * is a pain */
     message_warning(_("This diagram uses the State object for initial/final states.\nThat option will go 
away in future versions.\nPlease use the Initial/Final State object instead\n"));
   }
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * STATE_LINEWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    obj->line_width = STATE_LINEWIDTH;
+
   return (DiaObject *)obj;
 }
 
Index: objects/UML/small_package.c
===================================================================
--- objects/UML/small_package.c (revision 4117)
+++ objects/UML/small_package.c (working copy)
@@ -50,10 +50,14 @@
   char *st_stereotype;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
 
+/* The old border width, kept for compatibility with dia files created with
+ * older versions.
+ */
 #define SMALLPACKAGE_BORDERWIDTH 0.1
 #define SMALLPACKAGE_TOPHEIGHT 0.9
 #define SMALLPACKAGE_TOPWIDTH 1.5
@@ -120,6 +124,7 @@
 
 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,
@@ -142,6 +147,7 @@
 
 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) },
@@ -240,10 +246,9 @@
   h = elem->height;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, SMALLPACKAGE_BORDERWIDTH);
+  renderer_ops->set_linewidth(renderer, pkg->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
-
   p1.x = x; p1.y = y;
   p2.x = x+w; p2.y = y+h;
 
@@ -364,8 +369,10 @@
     pkg->connections[i].connected = NULL;
   }
   pkg->connections[8].flags = CP_FLAGS_MAIN;
-  elem->extra_spacing.border_trans = SMALLPACKAGE_BORDERWIDTH/2.0;
+  pkg->line_width = attributes_get_default_linewidth();
 
+  elem->extra_spacing.border_trans = pkg->line_width/2.0;
+
   pkg->line_color = attributes_get_foreground();
   pkg->fill_color = attributes_get_background();
 
@@ -396,12 +403,16 @@
 static DiaObject *
 smallpackage_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&smallpackage_type,
-                                      obj_node,version,filename);
+  DiaObject *obj = object_load_using_properties(&smallpackage_type,
+                                                obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * SMALLPACKAGE_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((SmallPackage*)obj)->line_width = SMALLPACKAGE_BORDERWIDTH;
+
+  return obj;
 }
 
-
-
-
-
-
Index: objects/UML/node.c
===================================================================
--- objects/UML/node.c  (revision 4117)
+++ objects/UML/node.c  (working copy)
@@ -50,6 +50,7 @@
   Text *name;
   TextAttributes attrs;
 
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -121,6 +122,7 @@
 
 static PropDescription node_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  PROP_STD_LINE_WIDTH_OPTIONAL, 
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   PROP_STD_TEXT_FONT,
@@ -145,6 +147,7 @@
 
 static PropOffset node_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {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)},
   /* backward compatibility */
@@ -244,7 +247,7 @@
   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 */
@@ -342,6 +345,7 @@
 
   elem->corner = *startpoint;
 
+  node->line_width = attributes_get_default_linewidth();
   node->line_color = attributes_get_foreground();
   node->fill_color = attributes_get_background();
 
@@ -361,7 +365,7 @@
     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;
@@ -377,6 +381,16 @@
 
 static DiaObject *node_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&node_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&node_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * NODE_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Node*)obj)->line_width = NODE_BORDERWIDTH;
+
+  return obj;
 }
+
Index: objects/UML/branch.c
===================================================================
--- objects/UML/branch.c        (revision 4117)
+++ objects/UML/branch.c        (working copy)
@@ -45,6 +45,7 @@
 {
   Element element;
   ConnectionPoint connections[8];
+  real line_width;
   Color line_color;
   Color fill_color;
 };
@@ -113,6 +114,7 @@
 
 static PropDescription branch_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  PROP_STD_LINE_WIDTH_OPTIONAL,
   PROP_STD_LINE_COLOUR_OPTIONAL, 
   PROP_STD_FILL_COLOUR_OPTIONAL, 
   
@@ -130,6 +132,7 @@
 
 static PropOffset branch_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  {PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Branch, line_width)},
   {"line_colour",PROP_TYPE_COLOUR,offsetof(Branch,line_color)},
   {"fill_colour",PROP_TYPE_COLOUR,offsetof(Branch,fill_color)},
   { NULL, 0, 0 },
@@ -214,7 +217,7 @@
   points[3].x = elem->corner.x + w,   points[3].y = elem->corner.y + 2*h;
   
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-  renderer_ops->set_linewidth(renderer, BRANCH_BORDERWIDTH);
+  renderer_ops->set_linewidth(renderer, branch->line_width);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
   renderer_ops->fill_polygon(renderer, points, 4, &branch->fill_color);
@@ -244,7 +247,7 @@
   branch->connections[3].pos.y = elem->corner.y + elem->height;
   branch->connections[3].directions = DIR_SOUTH;
 
-  extra->border_trans = BRANCH_BORDERWIDTH / 1.4142;  /* not 2.0, it is rotated 45° */
+  extra->border_trans = branch->line_width / 1.4142;  /* not 2.0, it is rotated 45° */
   element_update_boundingbox(elem);
   obj->position = elem->corner;
 
@@ -269,6 +272,7 @@
   elem->corner = *startpoint;
   element_init(elem, 8, 8);
 
+  branch->line_width = attributes_get_default_linewidth();
   branch->line_color = attributes_get_foreground();
   branch->fill_color = attributes_get_background();
 
@@ -278,7 +282,7 @@
       branch->connections[i].object = obj;
       branch->connections[i].connected = NULL;
     }
-  elem->extra_spacing.border_trans = BRANCH_BORDERWIDTH / 2.0;
+  elem->extra_spacing.border_trans = branch->line_width / 2.0;
   branch_update_data(branch);
 
   for (i=0;i<8;i++) {
@@ -297,11 +301,16 @@
 
 static DiaObject *branch_load(ObjectNode obj_node, int version, const char *filename)
 {
-  return object_load_using_properties(&branch_type,
-                                      obj_node,version,filename);
+  DiaObject * obj = object_load_using_properties(&branch_type,
+                                                 obj_node,version,filename);
+  AttributeNode attr;
+  /* For compatibility with previous dia files. If no line_width, use
+   * BRANCH_BORDERWIDTH, that was the previous line width.
+   */
+  attr = object_find_attribute(obj_node, "line_width");
+  if (attr == NULL)
+    ((Branch*)obj)->line_width = BRANCH_BORDERWIDTH;
+
+  return obj;
 }
 
-
-
-
-


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]