[dia] warnings: general warnings cleanup



commit 9997374f67b5f8f16b7811e1bb7e3555926ee3dd
Author: Zander Brown <zbrown gnome org>
Date:   Mon Dec 9 11:07:03 2019 +0000

    warnings: general warnings cleanup

 app/dia-line-width-area.c      |   2 +-
 app/display.c                  |  15 +-
 app/display.h                  |  29 +-
 app/grid.c                     |   2 +-
 app/grid.h                     |   2 +-
 lib/diarenderer.c              |  37 +--
 lib/diasvgrenderer.c           | 190 ++++++-------
 lib/diatransform.c             |  14 +-
 lib/diatransform.h             |  21 +-
 lib/geometry.h                 |  15 +-
 objects/AADL/aadlbus.c         |   8 +-
 objects/AADL/aadldata.c        |   8 +-
 objects/AADL/aadlport.c        |   4 +-
 objects/Database/table.c       |   2 +-
 objects/ER/entity.c            |   2 +-
 objects/ER/relationship.c      |   2 +-
 objects/Misc/grid_object.c     |   2 +-
 objects/UML/association.c      |  11 +-
 objects/UML/fork.c             |  12 +-
 objects/custom/custom_object.c | 598 +++++++++++++++++++++++------------------
 20 files changed, 550 insertions(+), 426 deletions(-)
---
diff --git a/app/dia-line-width-area.c b/app/dia-line-width-area.c
index 3acda66f..27e1ef87 100644
--- a/app/dia-line-width-area.c
+++ b/app/dia-line-width-area.c
@@ -246,7 +246,7 @@ dia_line_width_area_init (DiaLineWidthArea *self)
 
 
 GtkWidget *
-dia_line_width_area_new ()
+dia_line_width_area_new (void)
 {
   GtkWidget *event_box;
 
diff --git a/app/display.c b/app/display.c
index 989ee408..e81ae7a2 100644
--- a/app/display.c
+++ b/app/display.c
@@ -288,8 +288,8 @@ new_display(Diagram *dia)
 
 void
 ddisplay_transform_coords_double (DDisplay *ddisp,
-                                  coord     x,
-                                  coord     y,
+                                  double    x,
+                                  double    y,
                                   double   *xi,
                                   double   *yi)
 {
@@ -304,8 +304,8 @@ ddisplay_transform_coords_double (DDisplay *ddisp,
 
 void
 ddisplay_transform_coords (DDisplay *ddisp,
-                           coord     x,
-                           coord     y,
+                           double    x,
+                           double    y,
                            int      *xi,
                            int      *yi)
 {
@@ -338,8 +338,8 @@ void
 ddisplay_untransform_coords (DDisplay *ddisp,
                              int       xi,
                              int       yi,
-                             coord    *x,
-                             coord    *y)
+                             double   *x,
+                             double   *y)
 {
   DiaRectangle *visible = &ddisp->visible;
   int width = dia_interactive_renderer_get_width_pixels (DIA_INTERACTIVE_RENDERER (ddisp->renderer));
@@ -580,8 +580,9 @@ ddisplay_update_scrollbars(DDisplay *ddisp)
   g_signal_emit_by_name (G_OBJECT (ddisp->vsbdata), "changed");
 }
 
+
 void
-ddisplay_set_origo (DDisplay *ddisp, coord x, coord y)
+ddisplay_set_origo (DDisplay *ddisp, double x, double y)
 {
   DiaRectangle *extents = &ddisp->diagram->data->extents;
   DiaRectangle *visible = &ddisp->visible;
diff --git a/app/display.h b/app/display.h
index 07539aab..34ba089d 100644
--- a/app/display.h
+++ b/app/display.h
@@ -125,15 +125,21 @@ DDisplay *new_display(Diagram *dia);
 DDisplay *copy_display(DDisplay *orig_ddisp);
 /* Normal destroy is done through shell widget destroy event. */
 void ddisplay_really_destroy(DDisplay *ddisp);
-void ddisplay_transform_coords_double(DDisplay *ddisp,
-                                     coord x, coord y,
-                                     double *xi, double *yi);
-void ddisplay_transform_coords(DDisplay *ddisp,
-                              coord x, coord y,
-                              int *xi, int *yi);
-void ddisplay_untransform_coords(DDisplay *ddisp,
-                                int xi, int yi,
-                                coord *x, coord *y);
+void ddisplay_transform_coords_double (DDisplay *ddisp,
+                                       double    x,
+                                       double    y,
+                                       double   *xi,
+                                       double   *yi);
+void ddisplay_transform_coords        (DDisplay *ddisp,
+                                       double    x,
+                                       double    y,
+                                       int      *xi,
+                                       int      *yi);
+void ddisplay_untransform_coords      (DDisplay *ddisp,
+                                       int       xi,
+                                       int       yi,
+                                       double   *x,
+                                       double   *y);
 real ddisplay_transform_length(DDisplay *ddisp, real len);
 real ddisplay_untransform_length(DDisplay *ddisp, real len);
 void ddisplay_add_update_pixels(DDisplay *ddisp, Point *point,
@@ -144,8 +150,9 @@ void ddisplay_add_update_with_border(DDisplay *ddisp, const DiaRectangle *rect,
 void ddisplay_add_update(DDisplay *ddisp, const DiaRectangle *rect);
 void ddisplay_flush(DDisplay *ddisp);
 void ddisplay_update_scrollbars(DDisplay *ddisp);
-void ddisplay_set_origo(DDisplay *ddisp,
-                       coord x, coord y);
+void ddisplay_set_origo                 (DDisplay *ddisp,
+                                         double    x,
+                                         double    y);
 void ddisplay_zoom(DDisplay *ddisp, Point *point,
                   real zoom_factor);
 void ddisplay_zoom_middle(DDisplay *ddisp, real magnify);
diff --git a/app/grid.c b/app/grid.c
index 9011e4ee..36027574 100644
--- a/app/grid.c
+++ b/app/grid.c
@@ -463,7 +463,7 @@ guidelines_draw (DDisplay *ddisp, DiaRectangle *update)
 
 
 void
-snap_to_grid (DDisplay *ddisp, coord *x, coord *y)
+snap_to_grid (DDisplay *ddisp, double *x, double *y)
 {
   /* First snap to guides - only if they are visible and the setting is
    * turned on. */
diff --git a/app/grid.h b/app/grid.h
index 910d88b7..5cce6a67 100644
--- a/app/grid.h
+++ b/app/grid.h
@@ -33,7 +33,7 @@ struct _Grid {
 void grid_draw(DDisplay *ddisp, DiaRectangle *update);
 void pagebreak_draw(DDisplay *ddisp, DiaRectangle *update);
 void guidelines_draw(DDisplay *ddisp, DiaRectangle *update);
-void snap_to_grid(DDisplay *ddisp, coord *x, coord *y);
+void snap_to_grid(DDisplay *ddisp, double *x, double *y);
 
 gboolean grid_step (DDisplay *ddisp, GtkOrientation orientation,
                    real *start, int *ipos, gboolean *is_major);
diff --git a/lib/diarenderer.c b/lib/diarenderer.c
index 8d82aaab..ab059461 100644
--- a/lib/diarenderer.c
+++ b/lib/diarenderer.c
@@ -864,7 +864,7 @@ bezier_add_lines(BezierApprox *bezier,
   Point r[4];
   Point s[4];
   Point middle;
-  coord delta;
+  double delta;
   real v_len_sq;
 
   /* Check if almost flat: */
@@ -963,24 +963,27 @@ approximate_bezier (BezierApprox *bezier,
     g_warning("first BezPoint must be a BEZ_MOVE_TO");
   curve[3] = points[0].p1;
   bezier_add_point(bezier, &points[0].p1);
-  for (i = 1; i < numpoints; i++)
+  for (i = 1; i < numpoints; i++) {
     switch (points[i].type) {
-    case BEZ_MOVE_TO:
-      g_warning("only first BezPoint can be a BEZ_MOVE_TO");
-      curve[3] = points[i].p1;
-      break;
-    case BEZ_LINE_TO:
-      bezier_add_point(bezier, &points[i].p1);
-      curve[3] = points[i].p1;
-      break;
-    case BEZ_CURVE_TO:
-      curve[0] = curve[3];
-      curve[1] = points[i].p1;
-      curve[2] = points[i].p2;
-      curve[3] = points[i].p3;
-      bezier_add_curve(bezier, curve);
-      break;
+      case BEZ_MOVE_TO:
+        g_warning("only first BezPoint can be a BEZ_MOVE_TO");
+        curve[3] = points[i].p1;
+        break;
+      case BEZ_LINE_TO:
+        bezier_add_point(bezier, &points[i].p1);
+        curve[3] = points[i].p1;
+        break;
+      case BEZ_CURVE_TO:
+        curve[0] = curve[3];
+        curve[1] = points[i].p1;
+        curve[2] = points[i].p2;
+        curve[3] = points[i].p3;
+        bezier_add_curve(bezier, curve);
+        break;
+      default:
+        g_return_if_reached ();
     }
+  }
 }
 
 /*!
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index a94cf25a..31beeb47 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -238,17 +238,18 @@ set_linecaps(DiaRenderer *self, LineCaps mode)
   DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
 
   switch(mode) {
-  case LINECAPS_BUTT:
-    renderer->linecap = "butt";
-    break;
-  case LINECAPS_ROUND:
-    renderer->linecap = "round";
-    break;
-  case LINECAPS_PROJECTING:
-    renderer->linecap = "square";
-    break;
-  default:
-    renderer->linecap = "butt";
+    case LINECAPS_BUTT:
+      renderer->linecap = "butt";
+      break;
+    case LINECAPS_ROUND:
+      renderer->linecap = "round";
+      break;
+    case LINECAPS_PROJECTING:
+      renderer->linecap = "square";
+      break;
+    case LINECAPS_DEFAULT:
+    default:
+      renderer->linecap = "butt";
   }
 }
 
@@ -262,17 +263,18 @@ set_linejoin(DiaRenderer *self, LineJoin mode)
   DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
 
   switch(mode) {
-  case LINEJOIN_MITER:
-    renderer->linejoin = "miter";
-    break;
-  case LINEJOIN_ROUND:
-    renderer->linejoin = "round";
-    break;
-  case LINEJOIN_BEVEL:
-    renderer->linejoin = "bevel";
-    break;
-  default:
-    renderer->linejoin = "miter";
+    case LINEJOIN_MITER:
+      renderer->linejoin = "miter";
+      break;
+    case LINEJOIN_ROUND:
+      renderer->linejoin = "round";
+      break;
+    case LINEJOIN_BEVEL:
+      renderer->linejoin = "bevel";
+      break;
+    case LINECAPS_DEFAULT:
+    default:
+      renderer->linejoin = "miter";
   }
 }
 
@@ -294,51 +296,52 @@ set_linestyle(DiaRenderer *self, LineStyle mode, real dash_length)
     dash_length = 0.001;
   dot_length = dash_length*0.2;
 
-  g_free(renderer->linestyle);
-  switch(mode) {
-  case LINESTYLE_SOLID:
-    renderer->linestyle = NULL;
-    break;
-  case LINESTYLE_DASHED:
-    dia_svg_dtostr(dash_length_buf, dash_length);
-    renderer->linestyle = g_strdup_printf("%s", dash_length_buf);
-    break;
-  case LINESTYLE_DASH_DOT:
-    hole_width = (dash_length - dot_length) / 2.0;
-
-    dia_svg_dtostr(dash_length_buf, dash_length);
-    dia_svg_dtostr(dot_length_buf, dot_length);
-    dia_svg_dtostr(hole_width_buf, hole_width);
-
-    renderer->linestyle = g_strdup_printf("%s %s %s %s",
-                                         dash_length_buf,
-                                         hole_width_buf,
-                                         dot_length_buf,
-                                         hole_width_buf );
-    break;
-  case LINESTYLE_DASH_DOT_DOT:
-    hole_width = (dash_length - 2.0*dot_length) / 3.0;
-
-    dia_svg_dtostr(dash_length_buf, dash_length);
-    dia_svg_dtostr(dot_length_buf, dot_length);
-    dia_svg_dtostr(hole_width_buf, hole_width);
-
-    renderer->linestyle = g_strdup_printf("%s %s %s %s %s %s",
-                                         dash_length_buf,
-                                         hole_width_buf,
-                                         dot_length_buf,
-                                         hole_width_buf,
-                                         dot_length_buf,
-                                         hole_width_buf );
-    break;
-  case LINESTYLE_DOTTED:
+  g_free (renderer->linestyle);
+  switch (mode) {
+    case LINESTYLE_SOLID:
+      renderer->linestyle = NULL;
+      break;
+    case LINESTYLE_DASHED:
+      dia_svg_dtostr(dash_length_buf, dash_length);
+      renderer->linestyle = g_strdup_printf("%s", dash_length_buf);
+      break;
+    case LINESTYLE_DASH_DOT:
+      hole_width = (dash_length - dot_length) / 2.0;
+
+      dia_svg_dtostr(dash_length_buf, dash_length);
+      dia_svg_dtostr(dot_length_buf, dot_length);
+      dia_svg_dtostr(hole_width_buf, hole_width);
+
+      renderer->linestyle = g_strdup_printf("%s %s %s %s",
+              dash_length_buf,
+              hole_width_buf,
+              dot_length_buf,
+              hole_width_buf );
+      break;
+    case LINESTYLE_DASH_DOT_DOT:
+      hole_width = (dash_length - 2.0*dot_length) / 3.0;
+
+      dia_svg_dtostr(dash_length_buf, dash_length);
+      dia_svg_dtostr(dot_length_buf, dot_length);
+      dia_svg_dtostr(hole_width_buf, hole_width);
+
+      renderer->linestyle = g_strdup_printf("%s %s %s %s %s %s",
+              dash_length_buf,
+              hole_width_buf,
+              dot_length_buf,
+              hole_width_buf,
+              dot_length_buf,
+              hole_width_buf );
+      break;
+    case LINESTYLE_DOTTED:
 
-    dia_svg_dtostr(dot_length_buf, dot_length);
+      dia_svg_dtostr(dot_length_buf, dot_length);
 
-    renderer->linestyle = g_strdup_printf("%s", dot_length_buf);
-    break;
-  default:
-    renderer->linestyle = NULL;
+      renderer->linestyle = g_strdup_printf("%s", dot_length_buf);
+      break;
+    case LINESTYLE_DEFAULT:
+    default:
+      renderer->linestyle = NULL;
   }
 }
 
@@ -703,35 +706,38 @@ _bezier(DiaRenderer *self,
                   dia_svg_dtostr(p1x_buf, (gdouble) points[0].p1.x),
                   dia_svg_dtostr(p1y_buf, (gdouble) points[0].p1.y) );
 
-  for (i = 1; i < numpoints; i++)
+  for (i = 1; i < numpoints; i++) {
     switch (points[i].type) {
-    case BEZ_MOVE_TO:
-      if (!dia_renderer_is_capable_of (self, RENDER_HOLES)) {
-        g_warning("only first BezPoint should be a BEZ_MOVE_TO");
-        g_string_printf (str, "M %s %s",
-                         dia_svg_dtostr (p1x_buf, (gdouble) points[i].p1.x),
-                         dia_svg_dtostr (p1y_buf, (gdouble) points[i].p1.y) );
-      } else {
-        g_string_append_printf(str, "M %s %s",
-                       dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
-                       dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y) );
-      }
-      break;
-    case BEZ_LINE_TO:
-      g_string_append_printf(str, " L %s,%s",
-                       dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
-                       dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y) );
-      break;
-    case BEZ_CURVE_TO:
-      g_string_append_printf(str, " C %s,%s %s,%s %s,%s",
-                       dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
-                       dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y),
-                       dia_svg_dtostr(p2x_buf, (gdouble) points[i].p2.x),
-                       dia_svg_dtostr(p2y_buf, (gdouble) points[i].p2.y),
-                       dia_svg_dtostr(p3x_buf, (gdouble) points[i].p3.x),
-                       dia_svg_dtostr(p3y_buf, (gdouble) points[i].p3.y) );
-      break;
+      case BEZ_MOVE_TO:
+        if (!dia_renderer_is_capable_of (self, RENDER_HOLES)) {
+          g_warning("only first BezPoint should be a BEZ_MOVE_TO");
+          g_string_printf (str, "M %s %s",
+                          dia_svg_dtostr (p1x_buf, (gdouble) points[i].p1.x),
+                          dia_svg_dtostr (p1y_buf, (gdouble) points[i].p1.y) );
+        } else {
+          g_string_append_printf(str, "M %s %s",
+              dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
+              dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y) );
+        }
+        break;
+      case BEZ_LINE_TO:
+        g_string_append_printf(str, " L %s,%s",
+        dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
+        dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y) );
+        break;
+      case BEZ_CURVE_TO:
+        g_string_append_printf(str, " C %s,%s %s,%s %s,%s",
+        dia_svg_dtostr(p1x_buf, (gdouble) points[i].p1.x),
+        dia_svg_dtostr(p1y_buf, (gdouble) points[i].p1.y),
+        dia_svg_dtostr(p2x_buf, (gdouble) points[i].p2.x),
+        dia_svg_dtostr(p2y_buf, (gdouble) points[i].p2.y),
+        dia_svg_dtostr(p3x_buf, (gdouble) points[i].p3.x),
+        dia_svg_dtostr(p3y_buf, (gdouble) points[i].p3.y) );
+        break;
+      default:
+        g_return_if_reached ();
     }
+  }
   if (fill) {
     xmlSetProp(node, (const xmlChar *)"fill-rule", (const xmlChar *) "evenodd");
     g_string_append(str, "z");
diff --git a/lib/diatransform.c b/lib/diatransform.c
index 35982290..5ac873d2 100644
--- a/lib/diatransform.c
+++ b/lib/diatransform.c
@@ -117,10 +117,13 @@ dia_untransform_length(DiaTransform *t, real len)
   return len / *(t->factor);
 }
 
+
 void
 dia_transform_coords (DiaTransform *t,
-                      coord x, coord y,
-                      int *xi, int *yi)
+                      double        x,
+                      double        y,
+                      int          *xi,
+                      int          *yi)
 {
   g_return_if_fail (DIA_IS_TRANSFORM (t));
   g_return_if_fail (t != NULL && t->factor != NULL);
@@ -129,10 +132,13 @@ dia_transform_coords (DiaTransform *t,
   *yi = ROUND ( (y - t->visible->top) * *(t->factor));
 }
 
+
 void
 dia_transform_coords_double (DiaTransform *t,
-                             coord x, coord y,
-                             double *xd, double *yd)
+                             double        x,
+                             double        y,
+                             double       *xd,
+                             double       *yd)
 {
   g_return_if_fail (DIA_IS_TRANSFORM (t));
   g_return_if_fail (t != NULL && t->factor != NULL);
diff --git a/lib/diatransform.h b/lib/diatransform.h
index e6c9f77d..8cfb624e 100644
--- a/lib/diatransform.h
+++ b/lib/diatransform.h
@@ -15,11 +15,22 @@ G_BEGIN_DECLS
 
 GType dia_transform_get_type (void) G_GNUC_CONST;
 
-DiaTransform *dia_transform_new (DiaRectangle *rect, real* zoom);
-real dia_transform_length (DiaTransform *transform, real len);
-void dia_transform_coords (DiaTransform *transform, coord x, coord y, int *xi, int *yi);
-void dia_transform_coords_double (DiaTransform *transform, coord x, coord y, double *xd, double *yd);
-real dia_untransform_length(DiaTransform *t, real len);
+DiaTransform *dia_transform_new           (DiaRectangle *rect,
+                                           double       *zoom);
+real          dia_transform_length        (DiaTransform *transform,
+                                           double        len);
+void          dia_transform_coords        (DiaTransform *transform,
+                                           double        x,
+                                           double        y,
+                                           int          *xi,
+                                           int          *yi);
+void          dia_transform_coords_double (DiaTransform *transform,
+                                           double        x,
+                                           double        y,
+                                           double       *xd,
+                                           double       *yd);
+real          dia_untransform_length      (DiaTransform *t,
+                                           real          len);
 
 G_END_DECLS
 
diff --git a/lib/geometry.h b/lib/geometry.h
index 8601db90..f5bb516b 100644
--- a/lib/geometry.h
+++ b/lib/geometry.h
@@ -76,12 +76,11 @@ G_BEGIN_DECLS
    |
    V  y
  */
-typedef real coord;
 
 /*! \brief A two dimensional position */
 struct _Point {
-  coord x; /*!< horizontal */
-  coord y; /*!< vertical */
+  double x; /*!< horizontal */
+  double y; /*!< vertical */
 };
 
 /**
@@ -94,13 +93,13 @@ struct _Point {
  * A rectangle given by upper left and lower right corner
  */
 struct _DiaRectangle {
-  coord left; /*!< x1 */
-  coord top; /*!< y1 */
-  coord right; /*!< x2 */
-  coord bottom; /*!< y2 */
+  double left; /*!< x1 */
+  double top; /*!< y1 */
+  double right; /*!< x2 */
+  double bottom; /*!< y2 */
 };
 
-/*! \brief A rectangle for fixed point e.g. pixel coordinates */
+/*! \brief A rectangle for fixed point e.g. pixel doubleinates */
 struct _IntRectangle {
   int left; /*!< x1 */
   int top; /*!< y1 */
diff --git a/objects/AADL/aadlbus.c b/objects/AADL/aadlbus.c
index 22b64eb3..3daf4632 100644
--- a/objects/AADL/aadlbus.c
+++ b/objects/AADL/aadlbus.c
@@ -102,12 +102,12 @@ aadlbus_project_point_on_nearest_border(Aadlbox *aadlbox,Point *p,
   real h = element->height;
 
   /* top left corner */
-  coord x1 = element->corner.x;
-  coord y1 = element->corner.y;
+  double x1 = element->corner.x;
+  double y1 = element->corner.y;
 
   /* bottom right corner */
-  coord x2 = element->corner.x + w;
-  coord y2 = element->corner.y + h;
+  double x2 = element->corner.x + w;
+  double y2 = element->corner.y + h;
 
 
   if ( p->x >= x1 + w*AADL_BUS_ARROW_SIZE_FACTOR
diff --git a/objects/AADL/aadldata.c b/objects/AADL/aadldata.c
index 329102b0..0f90c0b9 100644
--- a/objects/AADL/aadldata.c
+++ b/objects/AADL/aadldata.c
@@ -70,12 +70,12 @@ aadlbox_project_point_on_rectangle(DiaRectangle *rectangle,Point *p,real *angle)
 {
 
   /* top left corner */
-  coord x1 = rectangle->left;
-  coord y1 = rectangle->top;
+  double x1 = rectangle->left;
+  double y1 = rectangle->top;
 
   /* bottom right corner */
-  coord x2 = rectangle->right;
-  coord y2 = rectangle->bottom;
+  double x2 = rectangle->right;
+  double y2 = rectangle->bottom;
 
   /* _ outside box: */
 
diff --git a/objects/AADL/aadlport.c b/objects/AADL/aadlport.c
index 46af35d2..5ed4ab5a 100644
--- a/objects/AADL/aadlport.c
+++ b/objects/AADL/aadlport.c
@@ -46,8 +46,8 @@
 void
 rotate_around_origin (Point *p, real angle)   /* FIXME: no namespace */
 {
-  coord x = p->x;
-  coord y = p->y;
+  double x = p->x;
+  double y = p->y;
 
   p->x = x * cos(angle) - y * sin(angle) ;
   p->y = x * sin(angle) + y * cos(angle) ;
diff --git a/objects/Database/table.c b/objects/Database/table.c
index 818b42d6..fdb37cc3 100644
--- a/objects/Database/table.c
+++ b/objects/Database/table.c
@@ -1194,7 +1194,7 @@ table_update_positions (Table *table)
   ConnectionPoint * connections = table->connections;
   Element * elem = &table->element;
   GList * list;
-  coord x, y;
+  double x, y;
   real pointspacing;
   gint i;
   gint pointswide;
diff --git a/objects/ER/entity.c b/objects/ER/entity.c
index 3f0ee093..cecc4829 100644
--- a/objects/ER/entity.c
+++ b/objects/ER/entity.c
@@ -231,7 +231,7 @@ entity_draw (Entity *entity, DiaRenderer *renderer)
   Point ul_corner, lr_corner;
   Point p;
   Element *elem;
-  coord diff;
+  double diff;
 
   assert(entity != NULL);
   assert(renderer != NULL);
diff --git a/objects/ER/relationship.c b/objects/ER/relationship.c
index 861d5bc4..c35af14f 100644
--- a/objects/ER/relationship.c
+++ b/objects/ER/relationship.c
@@ -244,7 +244,7 @@ relationship_draw (Relationship *relationship, DiaRenderer *renderer)
   Point lc, rc;
   Point p;
   Element *elem;
-  coord diff;
+  double diff;
   Alignment left_align;
 
   assert(relationship != NULL);
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index 91b494a5..58b87282 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -242,7 +242,7 @@ grid_object_update_data(Grid_Object *grid_object)
   real cell_width = (elem->width - 2.0 * inset) / grid_object->grid_cols;
   real cell_height = (elem->height - 2.0 * inset) / grid_object->grid_rows;
   int i, j;
-  coord left, top;
+  double left, top;
 
   extra->border_trans = grid_object->border_line_width / 2.0;
   element_update_boundingbox(elem);
diff --git a/objects/UML/association.c b/objects/UML/association.c
index ba873f20..e202b070 100644
--- a/objects/UML/association.c
+++ b/objects/UML/association.c
@@ -175,7 +175,8 @@ static void association_set_state(Association *assoc,
 static DiaObject *association_load(ObjectNode obj_node, int version, DiaContext *ctx);
 
 static void association_update_data(Association *assoc);
-static coord get_aggregate_pos_diff(AssociationEnd *end, const Association *assoc);
+static double get_aggregate_pos_diff (AssociationEnd *end,
+                                      const Association *assoc);
 
 static ObjectTypeOps association_type_ops =
 {
@@ -766,11 +767,11 @@ association_update_data(Association *assoc)
   association_update_data_end(assoc, 1);
 }
 
-static coord
-get_aggregate_pos_diff(AssociationEnd *end, const Association *assoc)
+static double
+get_aggregate_pos_diff (AssociationEnd *end, const Association *assoc)
 {
-  coord width=0;
-  if(end->arrow){
+  double width = 0;
+  if (end->arrow){
     width = ASSOCIATION_TRIANGLESIZE;
   }
   switch(end->aggregate){
diff --git a/objects/UML/fork.c b/objects/UML/fork.c
index 8048160f..bfe48ba6 100644
--- a/objects/UML/fork.c
+++ b/objects/UML/fork.c
@@ -159,12 +159,16 @@ fork_select(Fork *branch, Point *clicked_point, DiaRenderer *interactive_rendere
   element_update_handles(&branch->element);
 }
 
+
 static ObjectChange*
-fork_move_handle(Fork *branch, Handle *handle,
-                Point *to, ConnectionPoint *cp,
-                HandleMoveReason reason, ModifierKeys modifiers)
+fork_move_handle (Fork             *branch,
+                  Handle           *handle,
+                  Point            *to,
+                  ConnectionPoint  *cp,
+                  HandleMoveReason  reason,
+                  ModifierKeys      modifiers)
 {
-  coord dx;
+  double dx;
   Point c;
 
   assert(branch!=NULL);
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 227e3c9e..4f25d69e 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -402,12 +402,20 @@ custom_set_props(Custom *custom, GPtrArray *props)
   custom_update_data(custom, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
 }
 
+
 static void
-transform_subshape_coord(Custom *custom, GraphicElementSubShape* subshape,
-                         const Point *p1, Point *out)
+transform_subshape_coord (Custom                 *custom,
+                          GraphicElementSubShape *subshape,
+                          const Point            *p1,
+                          Point                  *out)
 {
-  real scale, width, height, xoffs, yoffs;
-  coord cx, cy;
+  double scale;
+  double width;
+  double height;
+  double xoffs;
+  double yoffs;
+  double cx;
+  double cy;
   DiaRectangle orig_bounds, new_bounds;
 
   if (subshape->default_scale == 0.0) {
@@ -551,8 +559,9 @@ transform_rect(Custom *custom, const DiaRectangle *r1, DiaRectangle *out)
   }
 }
 
-static real
-custom_distance_from(Custom *custom, Point *point)
+
+static double
+custom_distance_from (Custom *custom, Point *point)
 {
   static GArray *arr = NULL, *barr = NULL;
   Point p1, p2;
@@ -561,120 +570,143 @@ custom_distance_from(Custom *custom, Point *point)
   GList *tmp;
   real min_dist = G_MAXFLOAT, dist = G_MAXFLOAT;
 
-  if (!arr)
-    arr = g_array_new(FALSE, FALSE, sizeof(Point));
-  if (!barr)
-    barr = g_array_new(FALSE, FALSE, sizeof(BezPoint));
+  if (!arr) {
+    arr = g_array_new (FALSE, FALSE, sizeof(Point));
+  }
+  if (!barr) {
+    barr = g_array_new (FALSE, FALSE, sizeof(BezPoint));
+  }
 
   for (tmp = custom->info->display_list; tmp != NULL; tmp = tmp->next) {
     GraphicElement *el = tmp->data;
     real line_width = el->any.s.line_width * custom->border_width;
 
     switch (el->type) {
-    case GE_LINE:
-      transform_coord(custom, &el->line.p1, &p1);
-      transform_coord(custom, &el->line.p2, &p2);
-      dist = distance_line_point(&p1, &p2, line_width, point);
-      break;
-    case GE_POLYLINE:
-      transform_coord(custom, &el->polyline.points[0], &p1);
-      dist = G_MAXFLOAT;
-      for (i = 1; i < el->polyline.npoints; i++) {
-       real seg_dist;
-
-       transform_coord(custom, &el->polyline.points[i], &p2);
-       seg_dist = distance_line_point(&p1, &p2, line_width, point);
-       p1 = p2;
-       dist = MIN(dist, seg_dist);
-       if (dist == 0.0)
-         break;
-      }
-      break;
-    case GE_POLYGON:
-      g_array_set_size(arr, el->polygon.npoints);
-      for (i = 0; i < el->polygon.npoints; i++)
-       transform_coord(custom, &el->polygon.points[i],
-                       &g_array_index(arr, Point, i));
-      dist = distance_polygon_point((Point *)arr->data, el->polygon.npoints,
-                                   line_width, point);
-      break;
-    case GE_RECT:
-      transform_coord(custom, &el->rect.corner1, &p1);
-      transform_coord(custom, &el->rect.corner2, &p2);
-      if (p1.x < p2.x) {
-       rect.left = p1.x - line_width/2;  rect.right = p2.x + line_width/2;
-      } else {
-       rect.left = p2.x - line_width/2;  rect.right = p1.x + line_width/2;
-      }
-      if (p1.y < p2.y) {
-       rect.top = p1.y - line_width/2;  rect.bottom = p2.y + line_width/2;
-      } else {
-       rect.top = p2.y - line_width/2;  rect.bottom = p1.y + line_width/2;
-      }
-      dist = distance_rectangle_point(&rect, point);
-      break;
-    case GE_IMAGE:
-      p2.x = el->image.topleft.x + el->image.width;
-      p2.y = el->image.topleft.y + el->image.height;
-      transform_coord(custom, &el->image.topleft, &p1);
-      transform_coord(custom, &p2, &p2);
-
-      rect.left   = p1.x;
-      rect.top    = p1.y;
-      rect.right  = p2.x;
-      rect.bottom = p2.y;
-      dist = distance_rectangle_point(&rect, point);
-      break;
-    case GE_TEXT:
-      text_set_height (el->text.object, custom_transform_length (custom, el->text.s.font_height));
-      custom_reposition_text(custom, &el->text);
-      dist = text_distance_from(el->text.object, point);
-      text_set_position(el->text.object, &el->text.anchor);
-      break;
-    case GE_ELLIPSE:
-      transform_coord(custom, &el->ellipse.center, &p1);
-      dist = distance_ellipse_point(&p1,
-                                   el->ellipse.width * fabs(custom->xscale),
-                                   el->ellipse.height * fabs(custom->yscale),
-                                   line_width, point);
-      break;
-    case GE_PATH:
-      g_array_set_size(barr, el->path.npoints);
-      for (i = 0; i < el->path.npoints; i++)
-       switch (g_array_index(barr,BezPoint,i).type=el->path.points[i].type) {
-       case BEZ_CURVE_TO:
-         transform_coord(custom, &el->path.points[i].p3,
-                         &g_array_index(barr, BezPoint, i).p3);
-         transform_coord(custom, &el->path.points[i].p2,
-                         &g_array_index(barr, BezPoint, i).p2);
-       case BEZ_MOVE_TO:
-       case BEZ_LINE_TO:
-         transform_coord(custom, &el->path.points[i].p1,
-                         &g_array_index(barr, BezPoint, i).p1);
-       }
-      dist = distance_bez_line_point((BezPoint *)barr->data, el->path.npoints,
-                                    line_width, point);
-      break;
-    case GE_SHAPE:
-      g_array_set_size(barr, el->path.npoints);
-      for (i = 0; i < el->path.npoints; i++)
-       switch (g_array_index(barr,BezPoint,i).type=el->path.points[i].type) {
-       case BEZ_CURVE_TO:
-         transform_coord(custom, &el->path.points[i].p3,
-                         &g_array_index(barr, BezPoint, i).p3);
-         transform_coord(custom, &el->path.points[i].p2,
-                         &g_array_index(barr, BezPoint, i).p2);
-       case BEZ_MOVE_TO:
-       case BEZ_LINE_TO:
-         transform_coord(custom, &el->path.points[i].p1,
-                         &g_array_index(barr, BezPoint, i).p1);
-       }
-      dist = distance_bez_shape_point((BezPoint *)barr->data, el->path.npoints,
-                                     line_width, point);
-      break;
-    case GE_SUBSHAPE:
-      /* subshapes are supposed to be always in bounds, no need to calculate distance */
-      break;
+      case GE_LINE:
+        transform_coord (custom, &el->line.p1, &p1);
+        transform_coord (custom, &el->line.p2, &p2);
+        dist = distance_line_point (&p1, &p2, line_width, point);
+        break;
+      case GE_POLYLINE:
+        transform_coord (custom, &el->polyline.points[0], &p1);
+        dist = G_MAXFLOAT;
+        for (i = 1; i < el->polyline.npoints; i++) {
+          real seg_dist;
+
+          transform_coord (custom, &el->polyline.points[i], &p2);
+          seg_dist = distance_line_point (&p1, &p2, line_width, point);
+          p1 = p2;
+          dist = MIN (dist, seg_dist);
+          if (dist == 0.0) {
+            break;
+          }
+        }
+        break;
+      case GE_POLYGON:
+        g_array_set_size (arr, el->polygon.npoints);
+        for (i = 0; i < el->polygon.npoints; i++) {
+          transform_coord (custom, &el->polygon.points[i],
+                           &g_array_index (arr, Point, i));
+        }
+        dist = distance_polygon_point ((Point *)arr->data, el->polygon.npoints,
+              line_width, point);
+        break;
+      case GE_RECT:
+        transform_coord (custom, &el->rect.corner1, &p1);
+        transform_coord (custom, &el->rect.corner2, &p2);
+        if (p1.x < p2.x) {
+          rect.left = p1.x - line_width/2;  rect.right = p2.x + line_width/2;
+        } else {
+          rect.left = p2.x - line_width/2;  rect.right = p1.x + line_width/2;
+        }
+        if (p1.y < p2.y) {
+          rect.top = p1.y - line_width/2;  rect.bottom = p2.y + line_width/2;
+        } else {
+          rect.top = p2.y - line_width/2;  rect.bottom = p1.y + line_width/2;
+        }
+        dist = distance_rectangle_point (&rect, point);
+        break;
+      case GE_IMAGE:
+        p2.x = el->image.topleft.x + el->image.width;
+        p2.y = el->image.topleft.y + el->image.height;
+        transform_coord (custom, &el->image.topleft, &p1);
+        transform_coord (custom, &p2, &p2);
+
+        rect.left   = p1.x;
+        rect.top    = p1.y;
+        rect.right  = p2.x;
+        rect.bottom = p2.y;
+        dist = distance_rectangle_point (&rect, point);
+        break;
+      case GE_TEXT:
+        text_set_height (el->text.object,
+                         custom_transform_length (custom, el->text.s.font_height));
+        custom_reposition_text (custom, &el->text);
+        dist = text_distance_from (el->text.object, point);
+        text_set_position (el->text.object, &el->text.anchor);
+        break;
+      case GE_ELLIPSE:
+        transform_coord (custom, &el->ellipse.center, &p1);
+        dist = distance_ellipse_point (&p1,
+                                       el->ellipse.width * fabs (custom->xscale),
+                                       el->ellipse.height * fabs (custom->yscale),
+                                       line_width, point);
+        break;
+      case GE_PATH:
+        g_array_set_size (barr, el->path.npoints);
+        for (i = 0; i < el->path.npoints; i++) {
+          switch (g_array_index (barr,BezPoint,i).type = el->path.points[i].type) {
+            case BEZ_CURVE_TO:
+              transform_coord (custom,
+                               &el->path.points[i].p3,
+                               &g_array_index (barr, BezPoint, i).p3);
+              transform_coord (custom,
+                               &el->path.points[i].p2,
+                               &g_array_index (barr, BezPoint, i).p2);
+            case BEZ_MOVE_TO:
+            case BEZ_LINE_TO:
+              transform_coord (custom,
+                               &el->path.points[i].p1,
+                               &g_array_index (barr, BezPoint, i).p1);
+            default:
+              g_return_val_if_reached (G_MAXFLOAT);
+          }
+        }
+        dist = distance_bez_line_point ((BezPoint *) barr->data,
+                                        el->path.npoints,
+                                        line_width,
+                                        point);
+        break;
+      case GE_SHAPE:
+        g_array_set_size (barr, el->path.npoints);
+        for (i = 0; i < el->path.npoints; i++) {
+          switch (g_array_index (barr, BezPoint , i).type = el->path.points[i].type) {
+            case BEZ_CURVE_TO:
+              transform_coord (custom,
+                               &el->path.points[i].p3,
+                               &g_array_index (barr, BezPoint, i).p3);
+              transform_coord (custom,
+                               &el->path.points[i].p2,
+                               &g_array_index (barr, BezPoint, i).p2);
+            case BEZ_MOVE_TO:
+            case BEZ_LINE_TO:
+              transform_coord (custom,
+                               &el->path.points[i].p1,
+                               &g_array_index (barr, BezPoint, i).p1);
+            default:
+              g_return_val_if_reached (G_MAXFLOAT);
+          }
+        }
+        dist = distance_bez_shape_point ((BezPoint *) barr->data,
+                                         el->path.npoints,
+                                         line_width,
+                                         point);
+        break;
+      case GE_SUBSHAPE:
+        /* subshapes are supposed to be always in bounds, no need to calculate distance */
+        break;
+      default:
+        g_return_val_if_reached (G_MAXFLOAT);
     }
     min_dist = MIN(min_dist, dist);
     if (min_dist == 0.0)
@@ -699,10 +731,14 @@ custom_select(Custom *custom, Point *clicked_point,
   element_update_handles(&custom->element);
 }
 
+
 static void
-custom_adjust_scale(Custom *custom, Handle *handle,
-                  Point *to, ConnectionPoint *cp,
-                  HandleMoveReason reason, ModifierKeys modifiers)
+custom_adjust_scale (Custom           *custom,
+                     Handle           *handle,
+                     Point            *to,
+                     ConnectionPoint  *cp,
+                     HandleMoveReason  reason,
+                     ModifierKeys      modifiers)
 {
   static int uniform_scale = FALSE;
   static Point orig_pos;
@@ -710,21 +746,21 @@ custom_adjust_scale(Custom *custom, Handle *handle,
   float delta_max = 0.0f;
 
   switch (reason) {
-  case HANDLE_MOVE_USER:
-    if (!uniform_scale) {
-      orig_pos.x = to->x;
-      orig_pos.y = to->y;
-    }
+    case HANDLE_MOVE_USER:
+      if (!uniform_scale) {
+        orig_pos.x = to->x;
+        orig_pos.y = to->y;
+      }
 
-    if ((modifiers & MODIFIER_SHIFT) != 0) {
-      if (!uniform_scale) /* transition */
-        custom->old_subscale = MAX(custom->subscale, 0.0);
-      uniform_scale = TRUE;
-    } else {
-      uniform_scale = FALSE;
-    }
+      if ((modifiers & MODIFIER_SHIFT) != 0) {
+        if (!uniform_scale) /* transition */
+          custom->old_subscale = MAX(custom->subscale, 0.0);
+        uniform_scale = TRUE;
+      } else {
+        uniform_scale = FALSE;
+      }
 
-    delta_max = (to->x - orig_pos.x);
+      delta_max = (to->x - orig_pos.x);
 
 #ifdef USE_DELTA_MAX
     /* This may yield some awkard effects for new-comers.
@@ -734,26 +770,33 @@ custom_adjust_scale(Custom *custom, Handle *handle,
        delta_max = (to->y - orig_pos.y);
 #endif
 
-    if (uniform_scale)
-      custom->subscale =
-        custom->old_subscale + (SUBSCALE_ACCELERATION * delta_max);
+      if (uniform_scale)
+        custom->subscale =
+          custom->old_subscale + (SUBSCALE_ACCELERATION * delta_max);
 
-    if( custom->subscale < SUBSCALE_MININUM_SCALE )
-      custom->subscale = SUBSCALE_MININUM_SCALE;
+      if( custom->subscale < SUBSCALE_MININUM_SCALE )
+        custom->subscale = SUBSCALE_MININUM_SCALE;
 
-    break;
-  case HANDLE_MOVE_USER_FINAL:
-    uniform_scale = FALSE;
-    break;
-  default:
-    break;
+      break;
+    case HANDLE_MOVE_USER_FINAL:
+      uniform_scale = FALSE;
+      break;
+    case HANDLE_MOVE_CONNECTED:
+    case HANDLE_MOVE_CREATE:
+    case HANDLE_MOVE_CREATE_FINAL:
+    default:
+      break;
   }
 }
 
+
 static ObjectChange*
-custom_move_handle(Custom *custom, Handle *handle,
-                  Point *to, ConnectionPoint *cp,
-                  HandleMoveReason reason, ModifierKeys modifiers)
+custom_move_handle (Custom           *custom,
+                    Handle           *handle,
+                    Point            *to,
+                    ConnectionPoint  *cp,
+                    HandleMoveReason  reason,
+                    ModifierKeys      modifiers)
 {
   AnchorShape horiz = ANCHOR_MIDDLE, vert = ANCHOR_MIDDLE;
   Point corner;
@@ -769,35 +812,48 @@ custom_move_handle(Custom *custom, Handle *handle,
   height = custom->element.height;
 
   switch (reason) {
-  case HANDLE_MOVE_USER:
-  case HANDLE_MOVE_USER_FINAL:
-  case HANDLE_MOVE_CONNECTED : /* silence gcc */
-  case HANDLE_MOVE_CREATE : /* silence gcc */
-  case HANDLE_MOVE_CREATE_FINAL : /* silence gcc */
-    custom_adjust_scale(custom, handle, to, cp, reason, modifiers);
+    case HANDLE_MOVE_USER:
+    case HANDLE_MOVE_USER_FINAL:
+    case HANDLE_MOVE_CONNECTED : /* silence gcc */
+    case HANDLE_MOVE_CREATE : /* silence gcc */
+    case HANDLE_MOVE_CREATE_FINAL : /* silence gcc */
+      custom_adjust_scale (custom, handle, to, cp, reason, modifiers);
+    default:
+      g_return_val_if_reached (NULL);
   }
 
   element_move_handle(&custom->element, handle->id, to, cp, reason, modifiers);
 
   switch (handle->id) {
-  case HANDLE_RESIZE_NW:
-    horiz = ANCHOR_END; vert = ANCHOR_END; break;
-  case HANDLE_RESIZE_N:
-    vert = ANCHOR_END; break;
-  case HANDLE_RESIZE_NE:
-    horiz = ANCHOR_START; vert = ANCHOR_END; break;
-  case HANDLE_RESIZE_E:
-    horiz = ANCHOR_START; break;
-  case HANDLE_RESIZE_SE:
-    horiz = ANCHOR_START; vert = ANCHOR_START; break;
-  case HANDLE_RESIZE_S:
-    vert = ANCHOR_START; break;
-  case HANDLE_RESIZE_SW:
-    horiz = ANCHOR_END; vert = ANCHOR_START; break;
-  case HANDLE_RESIZE_W:
-    horiz = ANCHOR_END; break;
-  default:
-    break;
+    case HANDLE_RESIZE_NW:
+      horiz = ANCHOR_END; vert = ANCHOR_END; break;
+    case HANDLE_RESIZE_N:
+      vert = ANCHOR_END; break;
+    case HANDLE_RESIZE_NE:
+      horiz = ANCHOR_START; vert = ANCHOR_END; break;
+    case HANDLE_RESIZE_E:
+      horiz = ANCHOR_START; break;
+    case HANDLE_RESIZE_SE:
+      horiz = ANCHOR_START; vert = ANCHOR_START; break;
+    case HANDLE_RESIZE_S:
+      vert = ANCHOR_START; break;
+    case HANDLE_RESIZE_SW:
+      horiz = ANCHOR_END; vert = ANCHOR_START; break;
+    case HANDLE_RESIZE_W:
+      horiz = ANCHOR_END; break;
+    case HANDLE_MOVE_STARTPOINT:
+    case HANDLE_MOVE_ENDPOINT:
+    case HANDLE_CUSTOM1:
+    case HANDLE_CUSTOM2:
+    case HANDLE_CUSTOM3:
+    case HANDLE_CUSTOM4:
+    case HANDLE_CUSTOM5:
+    case HANDLE_CUSTOM6:
+    case HANDLE_CUSTOM7:
+    case HANDLE_CUSTOM8:
+    case HANDLE_CUSTOM9:
+    default:
+      break;
   }
   custom_update_data(custom, horiz, vert);
 
@@ -1069,6 +1125,8 @@ custom_draw_element (GraphicElement *el,
           case BEZ_LINE_TO:
             transform_coord (custom, &el->path.points[i].p1,
                              &g_array_index (barr, BezPoint, i).p1);
+          default:
+            g_return_if_reached ();
       }
       if (el->any.s.stroke != DIA_SVG_COLOUR_NONE) {
         dia_renderer_draw_bezier (renderer,
@@ -1093,6 +1151,8 @@ custom_draw_element (GraphicElement *el,
             transform_coord (custom,
                              &el->path.points[i].p1,
                              &g_array_index (barr, BezPoint, i).p1);
+          default:
+            g_return_if_reached ();
       }
       if (custom->show_background && el->any.s.fill != DIA_SVG_COLOUR_NONE) {
         dia_renderer_draw_beziergon(renderer,
@@ -1123,6 +1183,8 @@ custom_draw_element (GraphicElement *el,
         custom->current_subshape = NULL;
       }
       break;
+    default:
+      g_return_if_reached ();
   }
 }
 
@@ -1278,54 +1340,61 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
 
   /* if aspect ratio should be fixed, make sure xscale == yscale */
   switch (info->aspect_type) {
-  case SHAPE_ASPECT_FREE:
-    break;
-  case SHAPE_ASPECT_FIXED:
-    if (custom->xscale != custom->yscale) {
-      /* depending on the moving handle let one scale take precedence */
-      if (ANCHOR_MIDDLE != horiz && ANCHOR_MIDDLE != vert)
-        custom->xscale = custom->yscale = (custom->xscale + custom->yscale) / 2;
-      else if (ANCHOR_MIDDLE == horiz)
-        custom->xscale = custom->yscale;
-      else
-        custom->yscale = custom->xscale;
-
-      elem->width = custom->xscale * (info->shape_bounds.right -
-                                     info->shape_bounds.left);
-      elem->height = custom->yscale * (info->shape_bounds.bottom -
-                                      info->shape_bounds.top);
-    }
-    break;
-  case SHAPE_ASPECT_RANGE:
-    if (custom->xscale / custom->yscale < info->aspect_min) {
-      custom->xscale = custom->yscale * info->aspect_min;
-      elem->width = custom->xscale * (info->shape_bounds.right -
-                                     info->shape_bounds.left);
-    }
-    if (custom->xscale / custom->yscale > info->aspect_max) {
-      custom->yscale = custom->xscale / info->aspect_max;
-      elem->height = custom->yscale * (info->shape_bounds.bottom -
-                                      info->shape_bounds.top);
-    }
-    break;
+    case SHAPE_ASPECT_FREE:
+      break;
+    case SHAPE_ASPECT_FIXED:
+      if (custom->xscale != custom->yscale) {
+        /* depending on the moving handle let one scale take precedence */
+        if (ANCHOR_MIDDLE != horiz && ANCHOR_MIDDLE != vert)
+          custom->xscale = custom->yscale = (custom->xscale + custom->yscale) / 2;
+        else if (ANCHOR_MIDDLE == horiz)
+          custom->xscale = custom->yscale;
+        else
+          custom->yscale = custom->xscale;
+
+        elem->width = custom->xscale * (info->shape_bounds.right -
+                info->shape_bounds.left);
+        elem->height = custom->yscale * (info->shape_bounds.bottom -
+                info->shape_bounds.top);
+      }
+      break;
+    case SHAPE_ASPECT_RANGE:
+      if (custom->xscale / custom->yscale < info->aspect_min) {
+        custom->xscale = custom->yscale * info->aspect_min;
+        elem->width = custom->xscale * (info->shape_bounds.right -
+                info->shape_bounds.left);
+      }
+      if (custom->xscale / custom->yscale > info->aspect_max) {
+        custom->yscale = custom->xscale / info->aspect_max;
+        elem->height = custom->yscale * (info->shape_bounds.bottom -
+                info->shape_bounds.top);
+      }
+      break;
+    default:
+      g_return_if_reached ();
   }
 
   /* move shape if necessary ... */
   switch (horiz) {
-  case ANCHOR_START:
-    break;
-  case ANCHOR_MIDDLE:
-    elem->corner.x = center.x - elem->width/2; break;
-  case ANCHOR_END:
-    elem->corner.x = bottom_right.x - elem->width; break;
+    case ANCHOR_START:
+      break;
+    case ANCHOR_MIDDLE:
+      elem->corner.x = center.x - elem->width/2; break;
+    case ANCHOR_END:
+      elem->corner.x = bottom_right.x - elem->width; break;
+    default:
+      g_return_if_reached ();
   }
+
   switch (vert) {
-  case ANCHOR_START:
-    break;
-  case ANCHOR_MIDDLE:
-    elem->corner.y = center.y - elem->height/2; break;
-  case ANCHOR_END:
-    elem->corner.y = bottom_right.y - elem->height; break;
+    case ANCHOR_START:
+      break;
+    case ANCHOR_MIDDLE:
+      elem->corner.y = center.y - elem->height/2; break;
+    case ANCHOR_END:
+      elem->corner.y = bottom_right.y - elem->height; break;
+    default:
+      g_return_if_reached ();
   }
 
   /* update transformation coefficients after the possible resize ... */
@@ -1349,17 +1418,19 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
   /* reposition the text element to the new text bounding box ... */
   if (info->has_text) {
     DiaRectangle tb;
-    transform_rect(custom, &info->text_bounds, &tb);
+    transform_rect (custom, &info->text_bounds, &tb);
     switch (custom->text->alignment) {
-    case ALIGN_LEFT:
-      p.x = tb.left+custom->padding;
-      break;
-    case ALIGN_RIGHT:
-      p.x = tb.right-custom->padding;
-      break;
-    case ALIGN_CENTER:
-      p.x = (tb.left + tb.right) / 2;
-      break;
+      case ALIGN_LEFT:
+        p.x = tb.left+custom->padding;
+        break;
+      case ALIGN_RIGHT:
+        p.x = tb.right-custom->padding;
+        break;
+      case ALIGN_CENTER:
+        p.x = (tb.left + tb.right) / 2;
+        break;
+      default:
+        g_return_if_reached ();
     }
     /* align the text to be close to the shape ... */
     txs = text_get_string_copy(custom->text);
@@ -1442,19 +1513,22 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
         el->path.s.line_width * lwfactor;
       extra.start_long = extra.end_long = 0;
 
-      g_array_set_size(barr, el->path.npoints);
-      for (i = 0; i < el->path.npoints; i++)
-        switch (g_array_index(barr,BezPoint,i).type=el->path.points[i].type) {
-        case BEZ_CURVE_TO:
-          transform_coord(custom, &el->path.points[i].p3,
-                          &g_array_index(barr, BezPoint, i).p3);
-          transform_coord(custom, &el->path.points[i].p2,
-                          &g_array_index(barr, BezPoint, i).p2);
-        case BEZ_MOVE_TO:
-        case BEZ_LINE_TO:
-          transform_coord(custom, &el->path.points[i].p1,
-                          &g_array_index(barr, BezPoint, i).p1);
+      g_array_set_size (barr, el->path.npoints);
+      for (i = 0; i < el->path.npoints; i++) {
+        switch (g_array_index (barr, BezPoint, i).type = el->path.points[i].type) {
+          case BEZ_CURVE_TO:
+            transform_coord (custom, &el->path.points[i].p3,
+                             &g_array_index (barr, BezPoint, i).p3);
+            transform_coord (custom, &el->path.points[i].p2,
+                             &g_array_index (barr, BezPoint, i).p2);
+          case BEZ_MOVE_TO:
+          case BEZ_LINE_TO:
+            transform_coord (custom, &el->path.points[i].p1,
+                             &g_array_index (barr, BezPoint, i).p1);
+          default:
+            g_return_if_reached ();
         }
+      }
 
       polybezier_bbox(&g_array_index(barr,BezPoint,0),el->path.npoints,
                       &extra,el->type==GE_SHAPE,&rect);
@@ -1535,17 +1609,19 @@ custom_reposition_text(Custom *custom, GraphicElementText *text)
   Point p;
   DiaRectangle tb;
 
-  transform_rect(custom, &text->text_bounds, &tb);
+  transform_rect (custom, &text->text_bounds, &tb);
   switch (text->object->alignment) {
-  case ALIGN_LEFT:
-    p.x = tb.left;
-    break;
-  case ALIGN_RIGHT:
-    p.x = tb.right;
-    break;
-  case ALIGN_CENTER:
-    p.x = (tb.left + tb.right) / 2;
-    break;
+    case ALIGN_LEFT:
+      p.x = tb.left;
+      break;
+    case ALIGN_RIGHT:
+      p.x = tb.right;
+      break;
+    case ALIGN_CENTER:
+      p.x = (tb.left + tb.right) / 2;
+      break;
+    default:
+      g_return_if_reached ();
   }
   /* align the text to be close to the shape ... */
 
@@ -1750,6 +1826,7 @@ custom_load_using_properties(ObjectNode obj_node, int version,DiaContext *ctx)
   return obj;
 }
 
+
 struct CustomObjectChange {
   ObjectChange objchange;
 
@@ -1757,31 +1834,40 @@ struct CustomObjectChange {
   gboolean old_val;
 };
 
+
 static void
-custom_change_apply(struct CustomObjectChange *change, Custom *custom)
+custom_change_apply (struct CustomObjectChange *change, Custom *custom)
 {
   switch (change->type) {
-  case CHANGE_FLIPH:
-    custom->flip_h = !change->old_val;
-    break;
-  case CHANGE_FLIPV:
-    custom->flip_v = !change->old_val;
-    break;
+    case CHANGE_FLIPH:
+      custom->flip_h = !change->old_val;
+      break;
+    case CHANGE_FLIPV:
+      custom->flip_v = !change->old_val;
+      break;
+    default:
+      g_return_if_reached ();
   }
 }
+
+
 static void
-custom_change_revert(struct CustomObjectChange *change, Custom *custom)
+custom_change_revert (struct CustomObjectChange *change,
+                      Custom                    *custom)
 {
   switch (change->type) {
-  case CHANGE_FLIPH:
-    custom->flip_h = change->old_val;
-    break;
-  case CHANGE_FLIPV:
-    custom->flip_v = change->old_val;
-    break;
+    case CHANGE_FLIPH:
+      custom->flip_h = change->old_val;
+      break;
+    case CHANGE_FLIPV:
+      custom->flip_v = change->old_val;
+      break;
+    default:
+      g_return_if_reached ();
   }
 }
 
+
 static ObjectChange *
 custom_flip_h_callback (DiaObject *obj, Point *clicked, gpointer data)
 {


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