2006-12-05 David Lodge <dave@cirt.net>
[dia.git] / lib / polyshape.h
blobf6a381ea8da39f32eaaebf673ebd4861ca36fd6a
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1999 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef POLYSHAPE_H
19 #define POLYSHAPE_H
21 #include "diatypes.h"
22 #include "object.h"
23 #include "boundingbox.h"
25 #define HANDLE_CORNER (HANDLE_CUSTOM1)
27 /* This is a subclass of DiaObject used to help implementing objects
28 * that form a polygon-like shape of line-segments.
30 struct _PolyShape {
31 /* DiaObject must be first because this is a 'subclass' of it. */
32 DiaObject object;
34 int numpoints; /* >= 3 */
35 Point *points;
37 ElementBBExtras extra_spacing;
40 void polyshape_update_data(PolyShape *poly);
41 void polyshape_update_boundingbox(PolyShape *poly);
42 void polyshape_simple_draw(PolyShape *poly, DiaRenderer *renderer, real width);
43 void polyshape_init(PolyShape *poly, int num_points);
44 void polyshape_set_points(PolyShape *poly, int num_points, Point *points);
45 void polyshape_destroy(PolyShape *poly);
46 void polyshape_copy(PolyShape *from, PolyShape *to);
47 void polyshape_save(PolyShape *poly, ObjectNode obj_node);
48 void polyshape_load(PolyShape *poly, ObjectNode obj_node); /* NOTE: Does object_init() */
49 ObjectChange *polyshape_add_point(PolyShape *poly, int segment, Point *point);
50 ObjectChange *polyshape_remove_point(PolyShape *poly, int point);
51 ObjectChange *polyshape_move_handle(PolyShape *poly, Handle *id,
52 Point *to, ConnectionPoint *cp,
53 HandleMoveReason reason,
54 ModifierKeys modifiers);
55 ObjectChange *polyshape_move(PolyShape *poly, Point *to);
56 real polyshape_distance_from(PolyShape *poly, Point *point,
57 real line_width);
58 Handle *polyshape_closest_handle(PolyShape *poly, Point *point);
59 int polyshape_closest_segment(PolyShape *poly, Point *point,
60 real line_width);
62 #define POLYSHAPE_COMMON_PROPERTIES \
63 OBJECT_COMMON_PROPERTIES, \
64 { "poly_points", PROP_TYPE_POINTARRAY, 0, "polyshape points", NULL} \
66 #define POLYSHAPE_COMMON_PROPERTIES_OFFSETS \
67 OBJECT_COMMON_PROPERTIES_OFFSETS, \
68 { "poly_points", PROP_TYPE_POINTARRAY, \
69 offsetof(PolyShape,points), offsetof(PolyShape,numpoints)} \
71 #endif /* POLY_CONN_H */