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 /*! \file diagramdata.h -- Describing the base class of diagrams */
34 * \brief Helper to create new diagram
36 struct _NewDiagramData
{
38 gfloat tmargin
, bmargin
, lmargin
, rmargin
;
42 gint fitwidth
, fitheight
;
43 Color bg_color
, pagebreak_color
, grid_color
;
45 gchar
*unit
, *font_unit
;
48 GType
diagram_data_get_type (void) G_GNUC_CONST
;
50 #define DIA_TYPE_DIAGRAM_DATA (diagram_data_get_type ())
51 #define DIA_DIAGRAM_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIA_TYPE_DIAGRAM_DATA, DiagramData))
52 #define DIA_DIAGRAM_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIA_TYPE_DIAGRAM_DATA, DiagramDataClass))
53 #define DIA_IS_DIAGRAM_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIA_TYPE_DIAGRAM_DATA))
54 #define DIA_DIAGRAM_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIA_TYPE_DIAGRAM_DATA, DiagramDataClass))
57 * \brief Base class for diagrams. This is the only stuff plug-ins should see about diagrams.
60 GObject parent_instance
; /*!< inheritance in C */
62 Rectangle extents
; /*!< The extents of the diagram */
64 Color bg_color
; /*!< The diagrams background color */
66 PaperInfo paper
; /*!< info about the page info for the diagram */
67 gboolean is_compressed
; /*!< TRUE if by default it should be save compressed.
68 The user can override this in Save As... */
70 GPtrArray
*layers
; /*!< Layers ordered by decreasing z-order */
71 Layer
*active_layer
; /*!< The active layer, Defensive programmers check for NULL */
73 guint selected_count_private
; /*!< kept for binary compatibility and sanity, don't use ! */
74 GList
*selected
; /*!< List of objects that are selected,
75 all from the active layer! */
77 /** List of text fields that can be edited in the diagram.
78 * Updated by text_register_focusable. */
80 /** Units and font units used in this diagram. Default cm and point */
81 gchar
*unit
, *font_unit
;
85 * \brief DiagramData vtable
87 typedef struct _DiagramDataClass
{
88 GObjectClass parent_class
;
91 void (* object_add
) (DiagramData
*, Layer
*, DiaObject
*);
92 void (* object_remove
) (DiagramData
*, Layer
*, DiaObject
*);
97 * \brief A diagram consists of layers holding objects
99 * \todo : make this a GObject as well
103 Rectangle extents
; /*!< The extents of the layer */
105 GList
*objects
; /*!< List of objects in the layer,
106 sorted by decreasing z-valued,
107 objects can ONLY be connected to objects
108 in the same layer! */
111 gboolean connectable
; /*!< Whether the layer can currently be connected to.
112 The selected layer is by default connectable */
114 DiagramData
*parent_diagram
; /*!< Back-pointer to the diagram. This
115 must only be set by functions internal
116 to the diagram, and accessed via
117 layer_get_parent_diagram() */
120 /*! bounding box debug helper : set to !0 to see the caclulated bounding boxes */
121 DIAVAR
int render_bounding_boxes
;
123 Layer
*new_layer (char *name
, DiagramData
*parent
);
124 void layer_destroy(Layer
*layer
);
126 void data_raise_layer(DiagramData
*data
, Layer
*layer
);
127 void data_lower_layer(DiagramData
*data
, Layer
*layer
);
129 void data_add_layer(DiagramData
*data
, Layer
*layer
);
130 void data_add_layer_at(DiagramData
*data
, Layer
*layer
, int pos
);
131 void data_set_active_layer(DiagramData
*data
, Layer
*layer
);
132 void data_delete_layer(DiagramData
*data
, Layer
*layer
);
133 void data_select(DiagramData
*data
, DiaObject
*obj
);
134 void data_unselect(DiagramData
*data
, DiaObject
*obj
);
135 void data_remove_all_selected(DiagramData
*data
);
136 gboolean
data_update_extents(DiagramData
*data
); /* returns true if changed. */
137 GList
*data_get_sorted_selected(DiagramData
*data
);
138 GList
*data_get_sorted_selected_remove(DiagramData
*data
);
139 void data_set_unit(DiagramData
*data
, gchar
*unit
);
140 gchar
*data_get_unit(DiagramData
*data
);
141 float data_get_unit_multiplier(DiagramData
*data
);
142 void data_set_font_unit(DiagramData
*data
, gchar
*unit
);
143 gchar
*data_get_font_unit(DiagramData
*data
);
144 float data_get_font_unit_multiplier(DiagramData
*data
);
145 void data_emit(DiagramData
*data
,Layer
*layer
,DiaObject
* obj
,const char *signal_name
);
149 typedef void (*ObjectRenderer
)(DiaObject
*obj
, DiaRenderer
*renderer
,
152 void data_render(DiagramData
*data
, DiaRenderer
*renderer
, Rectangle
*update
,
153 ObjectRenderer obj_renderer
/* Can be NULL */,
155 void layer_render(Layer
*layer
, DiaRenderer
*renderer
, Rectangle
*update
,
156 ObjectRenderer obj_renderer
/* Can be NULL */,
160 int layer_object_index(Layer
*layer
, DiaObject
*obj
);
161 void layer_add_object(Layer
*layer
, DiaObject
*obj
);
162 void layer_add_object_at(Layer
*layer
, DiaObject
*obj
, int pos
);
163 void layer_add_objects(Layer
*layer
, GList
*obj_list
);
164 void layer_add_objects_first(Layer
*layer
, GList
*obj_list
);
165 void layer_remove_object(Layer
*layer
, DiaObject
*obj
);
166 void layer_remove_objects(Layer
*layer
, GList
*obj_list
);
167 GList
*layer_find_objects_intersecting_rectangle(Layer
*layer
, Rectangle
*rect
);
168 GList
*layer_find_objects_in_rectangle(Layer
*layer
, Rectangle
*rect
);
169 DiaObject
*layer_find_closest_object(Layer
*layer
, Point
*pos
, real maxdist
);
170 DiaObject
*layer_find_closest_object_except(Layer
*layer
, Point
*pos
,
171 real maxdist
, GList
*avoid
);
172 real
layer_find_closest_connectionpoint(Layer
*layer
,
173 ConnectionPoint
**closest
,
176 int layer_update_extents(Layer
*layer
); /* returns true if changed. */
177 void layer_replace_object_with_list(Layer
*layer
, DiaObject
*obj
,
179 void layer_set_object_list(Layer
*layer
, GList
*list
);
180 DiagramData
*layer_get_parent_diagram(Layer
*layer
);
181 /* Make sure all objects that are in the layer and not in the new
182 list eventually gets destroyed. */
186 #endif /* DIAGRAMDATA_H */