2006-12-03 Dimitris Glezos <dimitris@glezos.com>
[dia.git] / lib / element.h
blob503acb43f2c1088ebf354816295babe78060f2ec
1 /* Dia -- an diagram creation/manipulation program
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.
19 /* ** \file element.h -- Definition of a diagram - usual rectangular - object with eight handles */
20 #ifndef ELEMENT_H
21 #define ELEMENT_H
23 #include "diatypes.h"
24 #include "object.h"
25 #include "handle.h"
26 #include "connectionpoint.h"
27 #include "boundingbox.h"
29 /*!
30 * \class _Element
31 * \brief Beside OrthCon one of the most use object classes
33 * This is a subclass of DiaObject used to help implementing objects
34 * of a type with 8 handles.
36 struct _Element {
37 DiaObject object; /*!< inheritance */
39 Handle resize_handles[8]; /*!< not only for resizing but may also be used for connections */
41 Point corner;
42 real width;
43 real height;
45 ElementBBExtras extra_spacing;
48 void element_update_handles(Element *elem);
49 void element_update_connections_rectangle(Element *elem,
50 ConnectionPoint* cps);
51 void element_update_boundingbox(Element *elem);
52 void element_init(Element *elem, int num_handles, int num_connections);
53 void element_destroy(Element *elem);
54 void element_copy(Element *from, Element *to);
55 ObjectChange* element_move_handle(Element *elem, HandleId id,
56 Point *to, ConnectionPoint *cp,
57 HandleMoveReason reason,
58 ModifierKeys modifiers);
59 void element_move_handle_aspect(Element *elem, HandleId id,
60 Point *to, real aspect_ratio);
62 void element_save(Element *elem, ObjectNode obj_node);
63 void element_load(Element *elem, ObjectNode obj_node);
65 /* base property stuff ... */
66 static PropNumData width_range = { -G_MAXFLOAT, G_MAXFLOAT, 0.1};
68 #define ELEMENT_COMMON_PROPERTIES \
69 OBJECT_COMMON_PROPERTIES, \
70 { "elem_corner", PROP_TYPE_POINT, 0, \
71 "Element corner", "The corner of the element"}, \
72 { "elem_width", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE, \
73 "Element width", "The width of the element", &width_range}, \
74 { "elem_height", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE, \
75 "Element height", "The height of the element", &width_range}
77 /* Would like to have the frame, but need to figure out why
78 custom_object ext_attributes lose their updates when they're on
79 (see http://mail.gnome.org/archives/dia-list/2005-August/msg00053.html)
82 #define ELEMENT_COMMON_PROPERTIES \
83 OBJECT_COMMON_PROPERTIES, \
84 PROP_FRAME_BEGIN("size",0,N_("Object dimensions")), \
85 { "elem_corner", PROP_TYPE_POINT, 0, \
86 "Element corner", "The corner of the element"}, \
87 { "elem_width", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, \
88 "Element width", "The width of the element", &width_range}, \
89 { "elem_height", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, \
90 "Element height", "The height of the element", &width_range}, \
91 PROP_FRAME_END("size", 0)
93 #define ELEMENT_COMMON_PROPERTIES_OFFSETS \
94 OBJECT_COMMON_PROPERTIES_OFFSETS, \
95 { "elem_corner", PROP_TYPE_POINT, offsetof(Element, corner) }, \
96 { "elem_width", PROP_TYPE_REAL, offsetof(Element, width) }, \
97 { "elem_height", PROP_TYPE_REAL, offsetof(Element, height) }
99 #endif /* ELEMENT_H */