Re: add line width to uml small package



Here is a new patch with more UML objects with the configurable line width:

note
large_package
class
object
class.h
class_dialog
usecase
actor
small_package

I'd like to know if this is the correct way. I'll continue with the others and send another patch.

thanks

Pablo Gra\~na wrote:
Thanks for your comment! I'll use PROP_STD_LINE_WIDTH_OPTIONAL and see how to initialize the line width correctly.

My intention here was to get some feedback. Your comment encourages me to go on adding the line width to the rest of the UML objects.

I'll send a new patch soon.

thanks a lot

Hans Breuer wrote:
At 24.09.2008 00:50, Pablo Gra\~na wrote:
Hi

I am attaching a patch to make the line width configurable in the uml small package. Is this ok? Do you think this is worth commiting in the repo? If that is the case, I will continue with the rest of the UML objects.


The current version of your patch will complain for older files not containing the linewidth attribute. There is PROP_STD_LINE_WIDTH_OPTIONAL to be used as well as some extra code intializing to the former line width the older version.

Also I hesitate to include more partial style in the UML module. IMO adding the line width property should be done for all UML objects in one step.

-------- 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/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/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/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/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;
 }
 
-
-
-
-
-


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