1 /* Dia -- an diagram creation/manipulation program 2 * Copyright (C) 1998 Alexander Larsson 3 * 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. 8 * 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. 13 * 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. 17 */ 18 19 /* ** \file element.h -- Definition of a diagram - usual rectangular - object with eight handles */ 20 #ifndef ELEMENT_H 21 #define ELEMENT_H 22 23 #include "diatypes.h" 24 #include "object.h" 25 #include "handle.h" 26 #include "connectionpoint.h" 27 #include "boundingbox.h" 28 29 /*! 30 * \class _Element 31 * \brief Beside OrthCon one of the most use object classes 32 * 33 * This is a subclass of DiaObject used to help implementing objects 34 * of a type with 8 handles. 35 */ 36 struct _Element { 37 DiaObject object; /*!< inheritance */ 38 39 Handle resize_handles[8]; /*!< not only for resizing but may also be used for connections */ 40 41 Point corner; 42 real width; 43 real height; 44 45 ElementBBExtras extra_spacing; 46 }; 47 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); 61 62 void element_save(Element *elem, ObjectNode obj_node); 63 void element_load(Element *elem, ObjectNode obj_node); 64 65 /* base property stuff ... */ 66 static PropNumData width_range = { -G_MAXFLOAT, G_MAXFLOAT, 0.1}; 67 68 #define ELEMENT_COMMON_PROPERTIES \ 69 OBJECT_COMMON_PROPERTIES, \ 70 { "elem_corner", PROP_TYPE_POINT, PROP_FLAG_NO_DEFAULTS, \ 71 "Element corner", "The corner of the element"}, \ 72 { "elem_width", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE | PROP_FLAG_NO_DEFAULTS | PROP_FLAG_OPTIONAL, \ 73 "Element width", "The width of the element", &width_range}, \ 74 { "elem_height", PROP_TYPE_REAL, PROP_FLAG_DONT_MERGE | PROP_FLAG_NO_DEFAULTS | PROP_FLAG_OPTIONAL, \ 75 "Element height", "The height of the element", &width_range} 76 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) 80 */ 81 /* 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) 92 */ 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) } 98 99 #endif /* ELEMENT_H */ 100