including dynamic_obj.h
[dia.git] / lib / diagramdata.h
blobbb2caaf1787342c55b119dc6a2d38bc7a90b5fca
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 DIAGRAMDATA_H
19 #define DIAGRAMDATA_H
21 #include <glib.h>
23 #include "diatypes.h"
24 /* #include "object.h" later after declaring types */
25 #include "color.h"
26 #include "geometry.h"
27 #include "diavar.h"
28 #include "paper.h"
30 struct _NewDiagramData {
31 gchar *papertype;
32 gfloat tmargin, bmargin, lmargin, rmargin;
33 gboolean is_portrait;
34 gfloat scaling;
35 gboolean fitto;
36 gint fitwidth, fitheight;
37 Color bg_color, pagebreak_color, grid_color;
38 int compress_save;
41 struct _DiagramData {
42 Rectangle extents; /* The extents of the diagram */
44 Color bg_color;
45 Color pagebreak_color;
47 PaperInfo paper; /* info about the page info for the diagram */
48 gboolean is_compressed; /* TRUE if by default it should be save compressed.
49 The user can override this in Save As... */
51 struct {
52 /* grid line intervals */
53 real width_x, width_y;
54 /* the interval between visible grid lines */
55 guint visible_x, visible_y;
56 /* the interval between major lines (non-stippled).
57 * if 0, no major lines are drawn (all lines are stippled).
58 * if 1, all lines are solid.
60 guint major_lines;
61 /* True if the grid is dynamically calculated.
62 * When true, width_x and width_y are ignored.
64 gboolean dynamic;
65 /* The color of the grid lines.
67 Color colour;
68 } grid;
70 struct {
71 /* sorted arrays of the guides for the diagram */
72 real *hguides, *vguides;
73 guint nhguides, nvguides;
74 } guides;
76 GPtrArray *layers; /* Layers ordered by decreasing z-order */
77 Layer *active_layer;
79 guint selected_count;
80 GList *selected; /* List of objects that are selected,
81 all from the active layer! */
84 struct _Layer {
85 char *name;
86 Rectangle extents; /* The extents of the layer */
88 GList *objects; /* List of objects in the layer,
89 sorted by decreasing z-valued,
90 objects can ONLY be connected to objects
91 in the same layer! */
93 int visible;
95 DiagramData *parent_diagram; /* Back-pointer to the diagram. This
96 must only be set by functions internal
97 to the diagram, and accessed via
98 layer_get_parent_diagram() */
101 #include "object.h"
102 #include "dynamic_obj.h"
104 DIAVAR int render_bounding_boxes;
106 DiagramData *new_diagram_data(NewDiagramData *prefs);
107 void diagram_data_destroy(DiagramData *data);
109 Layer *new_layer (char *name, DiagramData *parent);
110 void layer_destroy(Layer *layer);
112 void data_raise_layer(DiagramData *data, Layer *layer);
113 void data_lower_layer(DiagramData *data, Layer *layer);
115 void data_add_layer(DiagramData *data, Layer *layer);
116 void data_add_layer_at(DiagramData *data, Layer *layer, int pos);
117 void data_set_active_layer(DiagramData *data, Layer *layer);
118 void data_delete_layer(DiagramData *data, Layer *layer);
119 void data_select(DiagramData *data, Object *obj);
120 void data_unselect(DiagramData *data, Object *obj);
121 void data_remove_all_selected(DiagramData *data);
122 gboolean data_update_extents(DiagramData *data); /* returns true if changed. */
123 GList *data_get_sorted_selected(DiagramData *data);
124 GList *data_get_sorted_selected_remove(DiagramData *data);
126 typedef void (*ObjectRenderer)(Object *obj, DiaRenderer *renderer,
127 int active_layer,
128 gpointer data);
129 void data_render(DiagramData *data, DiaRenderer *renderer, Rectangle *update,
130 ObjectRenderer obj_renderer /* Can be NULL */,
131 gpointer gdata);
132 void layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
133 ObjectRenderer obj_renderer /* Can be NULL */,
134 gpointer data,
135 int active_layer);
137 int layer_object_index(Layer *layer, Object *obj);
138 void layer_add_object(Layer *layer, Object *obj);
139 void layer_add_object_at(Layer *layer, Object *obj, int pos);
140 void layer_add_objects(Layer *layer, GList *obj_list);
141 void layer_add_objects_first(Layer *layer, GList *obj_list);
142 void layer_remove_object(Layer *layer, Object *obj);
143 void layer_remove_objects(Layer *layer, GList *obj_list);
144 GList *layer_find_objects_intersecting_rectangle(Layer *layer, Rectangle*rect);
145 GList *layer_find_objects_in_rectangle(Layer *layer, Rectangle *rect);
146 Object *layer_find_closest_object(Layer *layer, Point *pos, real maxdist);
147 Object *layer_find_closest_object_except(Layer *layer, Point *pos,
148 real maxdist, GList *avoid);
149 real layer_find_closest_connectionpoint(Layer *layer,
150 ConnectionPoint **closest,
151 Point *pos,
152 Object *notthis);
153 int layer_update_extents(Layer *layer); /* returns true if changed. */
154 void layer_replace_object_with_list(Layer *layer, Object *obj,
155 GList *list);
156 void layer_set_object_list(Layer *layer, GList *list);
157 DiagramData *layer_get_parent_diagram(Layer *layer);
158 /* Make sure all objects that are in the layer and not in the new
159 list eventually gets destroyed. */
161 #endif /* DIAGRAMDATA_H */