[dia] flowchart: fix warnings
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] flowchart: fix warnings
- Date: Fri, 27 Mar 2020 19:51:18 +0000 (UTC)
commit 7efbbdb9aa91aa2b71f570a9a370f8e03aa1de70
Author: Zander Brown <zbrown gnome org>
Date: Fri Mar 27 19:10:49 2020 +0000
flowchart: fix warnings
objects/flowchart/box.c | 176 +++++++++++++++++++++++--------------
objects/flowchart/ellipse.c | 208 +++++++++++++++++++++++++++-----------------
2 files changed, 240 insertions(+), 144 deletions(-)
---
diff --git a/objects/flowchart/box.c b/objects/flowchart/box.c
index 69ac35b9..9fa87c9d 100644
--- a/objects/flowchart/box.c
+++ b/objects/flowchart/box.c
@@ -185,6 +185,7 @@ static PropOffset box_offsets[] = {
{ NULL, 0, 0 },
};
+
static void
box_get_props(Box *box, GPtrArray *props)
{
@@ -192,16 +193,19 @@ box_get_props(Box *box, GPtrArray *props)
box_offsets,props);
}
+
static void
-box_set_props(Box *box, GPtrArray *props)
+box_set_props (Box *box, GPtrArray *props)
{
- object_set_props_from_offsets(&box->element.object,
- box_offsets,props);
- box_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
+ object_set_props_from_offsets (DIA_OBJECT (box),
+ box_offsets,props);
+ box_update_data (box, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
}
+
static void
-init_default_values() {
+init_default_values (void)
+{
static int defaults_initialized = 0;
if (!defaults_initialized) {
@@ -211,8 +215,9 @@ init_default_values() {
}
}
+
static real
-box_distance_from(Box *box, Point *point)
+box_distance_from (Box *box, Point *point)
{
Element *elem = &box->element;
DiaRectangle rect;
@@ -221,25 +226,28 @@ box_distance_from(Box *box, Point *point)
rect.right = elem->corner.x + elem->width + box->border_width/2;
rect.top = elem->corner.y - box->border_width/2;
rect.bottom = elem->corner.y + elem->height + box->border_width/2;
- return distance_rectangle_point(&rect, point);
+
+ return distance_rectangle_point (&rect, point);
}
+
static void
-box_select(Box *box, Point *clicked_point,
- DiaRenderer *interactive_renderer)
+box_select (Box *box,
+ Point *clicked_point,
+ DiaRenderer *interactive_renderer)
{
real radius;
- text_set_cursor(box->text, clicked_point, interactive_renderer);
- text_grab_focus(box->text, &box->element.object);
+ text_set_cursor (box->text, clicked_point, interactive_renderer);
+ text_grab_focus (box->text, &box->element.object);
- element_update_handles(&box->element);
+ element_update_handles (&box->element);
if (box->corner_radius > 0) {
- Element *elem = (Element *)box;
+ Element *elem = (Element *) box;
radius = box->corner_radius;
- radius = MIN(radius, elem->width/2);
- radius = MIN(radius, elem->height/2);
+ radius = MIN (radius, elem->width/2);
+ radius = MIN (radius, elem->height/2);
radius *= (1-M_SQRT1_2);
elem->resize_handles[0].pos.x += radius;
@@ -253,64 +261,94 @@ box_select(Box *box, Point *clicked_point,
}
}
-static ObjectChange*
-box_move_handle(Box *box, Handle *handle,
- Point *to, ConnectionPoint *cp,
- HandleMoveReason reason, ModifierKeys modifiers)
+
+static ObjectChange *
+box_move_handle (Box *box,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers)
{
AnchorShape horiz = ANCHOR_MIDDLE, vert = ANCHOR_MIDDLE;
Point corner;
real width, height;
- assert(box!=NULL);
- assert(handle!=NULL);
- assert(to!=NULL);
+ g_return_val_if_fail (box != NULL, NULL);
+ g_return_val_if_fail (handle != NULL, NULL);
+ g_return_val_if_fail (to != NULL, NULL);
/* remember ... */
corner = box->element.corner;
width = box->element.width;
height = box->element.height;
- element_move_handle(&box->element, handle->id, to, cp, reason, modifiers);
+ element_move_handle (&box->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;
}
- box_update_data(box, horiz, vert);
+ box_update_data (box, horiz, vert);
- if (width != box->element.width && height != box->element.height)
+ if (width != box->element.width && height != box->element.height) {
return element_change_new (&corner, width, height, &box->element);
+ }
return NULL;
}
+
static ObjectChange*
-box_move(Box *box, Point *to)
+box_move (Box *box, Point *to)
{
box->element.corner = *to;
- box_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
+ box_update_data (box, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
return NULL;
}
+
static void
box_draw (Box *box, DiaRenderer *renderer)
{
@@ -383,20 +421,27 @@ box_update_data(Box *box, AnchorShape horiz, AnchorShape vert)
/* move shape if necessary ... */
switch (horiz) {
- 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:
- 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:
+ default:
+ break;
}
+
switch (vert) {
- 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:
- 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:
+ default:
+ break;
}
p = elem->corner;
@@ -404,14 +449,15 @@ box_update_data(Box *box, AnchorShape horiz, AnchorShape vert)
p.y += elem->height / 2.0 - box->text->height * box->text->numlines / 2 +
box->text->ascent;
switch (box->text->alignment) {
- case ALIGN_LEFT:
- p.x -= (elem->width - box->padding*2 + box->border_width)/2;
- break;
- case ALIGN_RIGHT:
- p.x += (elem->width - box->padding*2 + box->border_width)/2;
- break;
- case ALIGN_CENTER:
- break;
+ case ALIGN_LEFT:
+ p.x -= (elem->width - box->padding*2 + box->border_width)/2;
+ break;
+ case ALIGN_RIGHT:
+ p.x += (elem->width - box->padding*2 + box->border_width)/2;
+ break;
+ case ALIGN_CENTER:
+ default:
+ break;
}
text_set_position(box->text, &p);
diff --git a/objects/flowchart/ellipse.c b/objects/flowchart/ellipse.c
index 46d790e9..642d9858 100644
--- a/objects/flowchart/ellipse.c
+++ b/objects/flowchart/ellipse.c
@@ -163,41 +163,47 @@ ellipse_describe_props(Ellipse *ellipse)
return ellipse_props;
}
+
static PropOffset ellipse_offsets[] = {
ELEMENT_COMMON_PROPERTIES_OFFSETS,
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(Ellipse, border_width) },
- { "line_colour", PROP_TYPE_COLOUR, offsetof(Ellipse, border_color) },
- { "fill_colour", PROP_TYPE_COLOUR, offsetof(Ellipse, inner_color) },
- { "show_background", PROP_TYPE_BOOL, offsetof(Ellipse, show_background) },
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof (Ellipse, border_width) },
+ { "line_colour", PROP_TYPE_COLOUR, offsetof (Ellipse, border_color) },
+ { "fill_colour", PROP_TYPE_COLOUR, offsetof (Ellipse, inner_color) },
+ { "show_background", PROP_TYPE_BOOL, offsetof (Ellipse, show_background) },
{ "line_style", PROP_TYPE_LINESTYLE,
- offsetof(Ellipse, line_style), offsetof(Ellipse, dashlength) },
- { "padding", PROP_TYPE_REAL, offsetof(Ellipse, padding) },
- {"text",PROP_TYPE_TEXT,offsetof(Ellipse,text)},
- {"text_font",PROP_TYPE_FONT,offsetof(Ellipse,text),offsetof(Text,font)},
- {PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Ellipse,text),offsetof(Text,height)},
- {"text_colour",PROP_TYPE_COLOUR,offsetof(Ellipse,text),offsetof(Text,color)},
- {"text_alignment",PROP_TYPE_ENUM,offsetof(Ellipse,text),offsetof(Text,alignment)},
- {PROP_STDNAME_TEXT_FITTING,PROP_TYPE_ENUM,offsetof(Ellipse,text_fitting)},
+ offsetof (Ellipse, line_style), offsetof (Ellipse, dashlength) },
+ { "padding", PROP_TYPE_REAL, offsetof (Ellipse, padding) },
+ { "text", PROP_TYPE_TEXT, offsetof (Ellipse, text) },
+ { "text_font", PROP_TYPE_FONT, offsetof (Ellipse, text), offsetof(Text, font) },
+ { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT,
+ offsetof (Ellipse, text), offsetof (Text, height) },
+ { "text_colour", PROP_TYPE_COLOUR, offsetof (Ellipse, text), offsetof (Text, color) },
+ { "text_alignment", PROP_TYPE_ENUM, offsetof (Ellipse, text), offsetof(Text, alignment) },
+ { PROP_STDNAME_TEXT_FITTING, PROP_TYPE_ENUM, offsetof (Ellipse, text_fitting) },
{ NULL, 0, 0 },
};
+
static void
-ellipse_get_props(Ellipse *ellipse, GPtrArray *props)
+ellipse_get_props (Ellipse *ellipse, GPtrArray *props)
{
- object_get_props_from_offsets(&ellipse->element.object,
- ellipse_offsets,props);
+ object_get_props_from_offsets (DIA_OBJECT (ellipse),
+ ellipse_offsets, props);
}
+
static void
-ellipse_set_props(Ellipse *ellipse, GPtrArray *props)
+ellipse_set_props (Ellipse *ellipse, GPtrArray *props)
{
- object_set_props_from_offsets(&ellipse->element.object,
- ellipse_offsets,props);
- ellipse_update_data(ellipse, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
+ object_set_props_from_offsets (DIA_OBJECT (ellipse),
+ ellipse_offsets, props);
+ ellipse_update_data (ellipse, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
}
+
static void
-init_default_values() {
+init_default_values (void)
+{
static int defaults_initialized = 0;
if (!defaults_initialized) {
@@ -207,10 +213,11 @@ init_default_values() {
}
}
+
/* returns the radius of the ellipse along the ray from the centre of the
* ellipse to the point (px, py) */
static real
-ellipse_radius(Ellipse *ellipse, real px, real py)
+ellipse_radius (Ellipse *ellipse, real px, real py)
{
Element *elem = &ellipse->element;
real w2 = elem->width * elem->width;
@@ -228,14 +235,18 @@ ellipse_radius(Ellipse *ellipse, real px, real py)
px *= px;
py *= py;
- if (px <= 0.0 && py <= 0.0)
+ if (px <= 0.0 && py <= 0.0) {
return 0; /* avoid division by zero */
+ }
+
scale = w2 * h2 / (4*h2*px + 4*w2*py);
- return sqrt((px + py)*scale);
+
+ return sqrt ((px + py) * scale);
}
+
static real
-ellipse_distance_from(Ellipse *ellipse, Point *point)
+ellipse_distance_from (Ellipse *ellipse, Point *point)
{
Element *elem = &ellipse->element;
Point c;
@@ -244,64 +255,94 @@ ellipse_distance_from(Ellipse *ellipse, Point *point)
c.y = elem->corner.y + elem->height/ 2;
return distance_ellipse_point (&c, elem->width, elem->height,
- ellipse->border_width, point);
+ ellipse->border_width, point);
}
+
static void
-ellipse_select(Ellipse *ellipse, Point *clicked_point,
- DiaRenderer *interactive_renderer)
+ellipse_select (Ellipse *ellipse,
+ Point *clicked_point,
+ DiaRenderer *interactive_renderer)
{
- text_set_cursor(ellipse->text, clicked_point, interactive_renderer);
- text_grab_focus(ellipse->text, &ellipse->element.object);
+ text_set_cursor (ellipse->text, clicked_point, interactive_renderer);
+ text_grab_focus (ellipse->text, &ellipse->element.object);
- element_update_handles(&ellipse->element);
+ element_update_handles (&ellipse->element);
}
+
static ObjectChange*
-ellipse_move_handle(Ellipse *ellipse, Handle *handle,
- Point *to, ConnectionPoint *cp,
- HandleMoveReason reason, ModifierKeys modifiers)
+ellipse_move_handle (Ellipse *ellipse,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers)
{
AnchorShape horiz = ANCHOR_MIDDLE, vert = ANCHOR_MIDDLE;
Point corner;
real width, height;
- assert(ellipse!=NULL);
- assert(handle!=NULL);
- assert(to!=NULL);
+ g_return_val_if_fail (ellipse != NULL, NULL);
+ g_return_val_if_fail (handle != NULL, NULL);
+ g_return_val_if_fail (to != NULL, NULL);
/* remember ... */
corner = ellipse->element.corner;
width = ellipse->element.width;
height = ellipse->element.height;
- element_move_handle(&ellipse->element, handle->id, to, cp,
- reason, modifiers);
+ element_move_handle (&ellipse->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;
}
- ellipse_update_data(ellipse, horiz, vert);
+ ellipse_update_data (ellipse, horiz, vert);
- if (width != ellipse->element.width || height != ellipse->element.height)
+ if (width != ellipse->element.width || height != ellipse->element.height) {
return element_change_new (&corner, width, height, &ellipse->element);
+ }
return NULL;
}
@@ -396,20 +437,27 @@ ellipse_update_data(Ellipse *ellipse, AnchorShape horiz, AnchorShape vert)
/* move shape if necessary ... */
switch (horiz) {
- 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:
- 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:
+ default:
+ break;
}
+
switch (vert) {
- 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:
- 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:
+ default:
+ break;
}
p = elem->corner;
@@ -417,16 +465,18 @@ ellipse_update_data(Ellipse *ellipse, AnchorShape horiz, AnchorShape vert)
p.y += elem->height / 2.0 - ellipse->text->height*ellipse->text->numlines/2 +
ellipse->text->ascent;
switch (ellipse->text->alignment) {
- case ALIGN_LEFT:
- p.x -= (elem->width - 2*(ellipse->padding + ellipse->border_width))/2;
- break;
- case ALIGN_RIGHT:
- p.x += (elem->width - 2*(ellipse->padding + ellipse->border_width))/2;
- break;
- case ALIGN_CENTER:
- break;
+ case ALIGN_LEFT:
+ p.x -= (elem->width - 2*(ellipse->padding + ellipse->border_width))/2;
+ break;
+ case ALIGN_RIGHT:
+ p.x += (elem->width - 2*(ellipse->padding + ellipse->border_width))/2;
+ break;
+ case ALIGN_CENTER:
+ break;
+ default:
+ g_return_if_reached ();
}
- text_set_position(ellipse->text, &p);
+ text_set_position (ellipse->text, &p);
/* Update connections: */
c.x = elem->corner.x + elem->width / 2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]