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.
24 /* #include "object.h" later after declaring types */
30 struct _NewDiagramData
{
32 gfloat tmargin
, bmargin
, lmargin
, rmargin
;
36 gint fitwidth
, fitheight
;
37 Color bg_color
, pagebreak_color
, grid_color
;
41 GType
diagram_data_get_type (void) G_GNUC_CONST
;
43 #define DIA_TYPE_DIAGRAM_DATA (diagram_data_get_type ())
44 #define DIA_DIAGRAM_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIA_TYPE_DIAGRAM_DATA, DiagramData))
45 #define DIA_DIAGRAM_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIA_TYPE_DIAGRAM_DATA, DiagramDataClass))
46 #define DIA_IS_DIAGRAM_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIA_TYPE_DIAGRAM_DATA))
47 #define DIA_DIAGRAM_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIA_TYPE_DIAGRAM_DATA, DiagramDataClass))
52 GObject parent_instance
;
54 Rectangle extents
; /* The extents of the diagram */
57 Color pagebreak_color
;
59 PaperInfo paper
; /* info about the page info for the diagram */
60 gboolean is_compressed
; /* TRUE if by default it should be save compressed.
61 The user can override this in Save As... */
64 /* grid line intervals */
65 real width_x
, width_y
, width_w
;
66 /* the interval between visible grid lines */
67 guint visible_x
, visible_y
;
68 /* the interval between major lines (non-stippled).
69 * if 0, no major lines are drawn (all lines are stippled).
70 * if 1, all lines are solid.
73 /* True if the grid is dynamically calculated.
74 * When true, width_x and width_y are ignored.
77 /* The color of the grid lines.
80 /** True if this grid is a hex grid. */
82 /** Size of each edge on a hex grid. */
87 /* sorted arrays of the guides for the diagram */
88 real
*hguides
, *vguides
;
89 guint nhguides
, nvguides
;
92 GPtrArray
*layers
; /* Layers ordered by decreasing z-order */
95 guint selected_count_private
; /* kept for binary compatibility and sanity, don't use ! */
96 GList
*selected
; /* List of objects that are selected,
97 all from the active layer! */
99 /** List of text fields that can be edited in the diagram.
100 * Updated by text_register_focusable. */
104 typedef struct _DiagramDataClass
{
105 GObjectClass parent_class
;
110 Rectangle extents
; /* The extents of the layer */
112 GList
*objects
; /* List of objects in the layer,
113 sorted by decreasing z-valued,
114 objects can ONLY be connected to objects
115 in the same layer! */
118 gboolean connectable
; /* Whether the layer can currently be connected to.
119 The selected layer is by default connectable */
121 DiagramData
*parent_diagram
; /* Back-pointer to the diagram. This
122 must only be set by functions internal
123 to the diagram, and accessed via
124 layer_get_parent_diagram() */
128 #include "dynamic_obj.h"
130 DIAVAR
int render_bounding_boxes
;
132 DiagramData
*new_diagram_data(NewDiagramData
*prefs
);
133 void diagram_data_destroy(DiagramData
*data
);
135 Layer
*new_layer (char *name
, DiagramData
*parent
);
136 void layer_destroy(Layer
*layer
);
138 void data_raise_layer(DiagramData
*data
, Layer
*layer
);
139 void data_lower_layer(DiagramData
*data
, Layer
*layer
);
141 void data_add_layer(DiagramData
*data
, Layer
*layer
);
142 void data_add_layer_at(DiagramData
*data
, Layer
*layer
, int pos
);
143 void data_set_active_layer(DiagramData
*data
, Layer
*layer
);
144 void data_delete_layer(DiagramData
*data
, Layer
*layer
);
145 void data_select(DiagramData
*data
, DiaObject
*obj
);
146 void data_unselect(DiagramData
*data
, DiaObject
*obj
);
147 void data_remove_all_selected(DiagramData
*data
);
148 gboolean
data_update_extents(DiagramData
*data
); /* returns true if changed. */
149 GList
*data_get_sorted_selected(DiagramData
*data
);
150 GList
*data_get_sorted_selected_remove(DiagramData
*data
);
152 typedef void (*ObjectRenderer
)(DiaObject
*obj
, DiaRenderer
*renderer
,
155 void data_render(DiagramData
*data
, DiaRenderer
*renderer
, Rectangle
*update
,
156 ObjectRenderer obj_renderer
/* Can be NULL */,
158 void layer_render(Layer
*layer
, DiaRenderer
*renderer
, Rectangle
*update
,
159 ObjectRenderer obj_renderer
/* Can be NULL */,
163 int layer_object_index(Layer
*layer
, DiaObject
*obj
);
164 void layer_add_object(Layer
*layer
, DiaObject
*obj
);
165 void layer_add_object_at(Layer
*layer
, DiaObject
*obj
, int pos
);
166 void layer_add_objects(Layer
*layer
, GList
*obj_list
);
167 void layer_add_objects_first(Layer
*layer
, GList
*obj_list
);
168 void layer_remove_object(Layer
*layer
, DiaObject
*obj
);
169 void layer_remove_objects(Layer
*layer
, GList
*obj_list
);
170 GList
*layer_find_objects_intersecting_rectangle(Layer
*layer
, Rectangle
*rect
);
171 GList
*layer_find_objects_in_rectangle(Layer
*layer
, Rectangle
*rect
);
172 DiaObject
*layer_find_closest_object(Layer
*layer
, Point
*pos
, real maxdist
);
173 DiaObject
*layer_find_closest_object_except(Layer
*layer
, Point
*pos
,
174 real maxdist
, GList
*avoid
);
175 real
layer_find_closest_connectionpoint(Layer
*layer
,
176 ConnectionPoint
**closest
,
179 int layer_update_extents(Layer
*layer
); /* returns true if changed. */
180 void layer_replace_object_with_list(Layer
*layer
, DiaObject
*obj
,
182 void layer_set_object_list(Layer
*layer
, GList
*list
);
183 DiagramData
*layer_get_parent_diagram(Layer
*layer
);
184 /* Make sure all objects that are in the layer and not in the new
185 list eventually gets destroyed. */
187 #endif /* DIAGRAMDATA_H */