Hi,

sometimes I need to set the height and width of a standard box
(or other elements/shapes) numerically. Is there a way to this
other than edit the dia file with a text editor?

As a quick hack, I solved the problem for the standard box,
but I'm not sure, whether this is an acceptable solution for
dia. E.g. it is possible to enter negative values for height and
width and one cannot change the objects position. diff attached,
please comment.

Cheers,
-- 
W. Martin Borgert
Index: objects/standard/box.c
===================================================================
--- objects/standard/box.c	(revision 3781)
+++ objects/standard/box.c	(working copy)
@@ -140,7 +140,7 @@
   { NULL, 0 }
 };
 static PropDescription box_props[] = {
-  ELEMENT_COMMON_PROPERTIES,
+  ELEMENT_RESIZABLE_COMMON_PROPERTIES,
   PROP_STD_LINE_WIDTH,
   PROP_STD_LINE_COLOUR,
   PROP_STD_FILL_COLOUR,
@@ -357,11 +357,13 @@
   DiaObject *obj = &elem->object;
   real radius;
   
+  elem->height = MAX(elem->height, 0.01);
+  elem->width = MAX(elem->width, 0.01);
+
   if (box->aspect == SQUARE_ASPECT){
     float size = elem->height < elem->width ? elem->height : elem->width;
     elem->height = elem->width = size;
   }
-
   radius = box->corner_radius;
   radius = MIN(radius, elem->width/2);
   radius = MIN(radius, elem->height/2);
Index: lib/element.h
===================================================================
--- lib/element.h	(revision 3781)
+++ lib/element.h	(working copy)
@@ -74,6 +74,15 @@
   { "elem_height", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE  | PROP_FLAG_NO_DEFAULTS, \
     "Element height", "The height of the element", &width_range}
 
+#define ELEMENT_RESIZABLE_COMMON_PROPERTIES \
+  OBJECT_COMMON_PROPERTIES, \
+  { "elem_corner", PROP_TYPE_POINT, PROP_FLAG_NO_DEFAULTS, \
+    "Element corner", "The corner of the element"}, \
+  { "elem_width", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE | PROP_FLAG_NO_DEFAULTS | PROP_FLAG_VISIBLE, \
+    "Element width", "The width of the element", &width_range}, \
+  { "elem_height", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE  | PROP_FLAG_NO_DEFAULTS | PROP_FLAG_VISIBLE, \
+    "Element height", "The height of the element", &width_range}
+
    /* Would like to have the frame, but need to figure out why
       custom_object ext_attributes lose their updates when they're on
       (see http://mail.gnome.org/archives/dia-list/2005-August/msg00053.html)
_______________________________________________
Dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to