* added GDK_PIXBUF_LIBS in order to create pixbuf.dll
[dia.git] / lib / orth_conn.h
blob1fd87ceb890908a1cf9af73d39e548ba5c439b7e
1 /* Dia -- an diagram creation/manipulation program -*- c -*-
2 * Copyright (C) 1998 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 ORTH_CONN_H
19 #define ORTH_CONN_H
21 #include "diatypes.h"
22 #include "object.h"
23 #include "boundingbox.h"
25 typedef enum {
26 HORIZONTAL,
27 VERTICAL
28 } Orientation;
30 #define FLIP_ORIENT(x) (((x)==HORIZONTAL)?VERTICAL:HORIZONTAL)
32 #define HANDLE_MIDPOINT (HANDLE_CUSTOM1)
34 /* This is a subclass of Object used to help implementing objects
35 * that connect points with orthogonal line-segments.
37 struct _OrthConn {
38 /* Object must be first because this is a 'subclass' of it. */
39 Object object;
41 int numpoints; /* >= 3 */
42 Point *points; /* [numpoints] */
44 int numorient; /* always numpoints-1 */
45 Orientation *orientation; /*[numpoints - 1]*/
47 int numhandles; /* should be == numorient */
48 Handle **handles; /*[numpoints - 1] */
49 /* Each line segment has one handle. The first and last handles
50 * are placed in the end of their segment, the other in the middle.
51 * The end handles are connectable, the others not. (That would be
52 * problematic, as they can only move freely in one direction.)
53 * The array of pointers is ordered in segment order.
55 PolyBBExtras extra_spacing;
58 void orthconn_update_data(OrthConn *orth);
59 void orthconn_update_boundingbox(OrthConn *orth);
60 void orthconn_simple_draw(OrthConn *orth, DiaRenderer *renderer,
61 real width);
62 void orthconn_init(OrthConn *orth, Point *startpoint);
63 void orthconn_destroy(OrthConn *orth);
64 void orthconn_copy(OrthConn *from, OrthConn *to);
65 void orthconn_save(OrthConn *orth, ObjectNode obj_node);
66 void orthconn_load(OrthConn *orth, ObjectNode obj_node); /* NOTE: Does object_init() */
67 void orthconn_move_handle(OrthConn *orth, Handle *id,
68 Point *to, HandleMoveReason reason);
69 void orthconn_move(OrthConn *orth, Point *to);
70 real orthconn_distance_from(OrthConn *orth, Point *point,
71 real line_width);
72 Handle* orthconn_get_middle_handle(OrthConn *orth);
74 int orthconn_can_delete_segment(OrthConn *orth, Point *clickedpoint);
75 int orthconn_can_add_segment(OrthConn *orth, Point *clickedpoint);
76 ObjectChange *orthconn_delete_segment(OrthConn *orth, Point *clickedpoint);
77 ObjectChange *orthconn_add_segment(OrthConn *orth, Point *clickedpoint);
79 /* base property stuff... */
80 #define ORTHCONN_COMMON_PROPERTIES \
81 OBJECT_COMMON_PROPERTIES, \
82 { "orth_points", PROP_TYPE_POINTARRAY, 0, "orthconn points", NULL}, \
83 { "orth_orient", PROP_TYPE_ENUMARRAY, 0, "orthconn orientations", NULL} \
85 #define ORTHCONN_COMMON_PROPERTIES_OFFSETS \
86 OBJECT_COMMON_PROPERTIES_OFFSETS, \
87 { "orth_points", PROP_TYPE_POINTARRAY, \
88 offsetof(OrthConn,points), offsetof(OrthConn,numpoints)}, \
89 { "orth_orient", PROP_TYPE_ENUMARRAY, \
90 offsetof(OrthConn,orientation), offsetof(OrthConn,numorient)} \
92 #endif /* ORTH_CONN_H */