* added GDK_PIXBUF_LIBS in order to create pixbuf.dll
[dia.git] / lib / diagramdata.h
blob9e2f421f47251f16d683192f7cba8bf5222a0423
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;
39 struct _DiagramData {
40 Rectangle extents; /* The extents of the diagram */
42 Color bg_color;
44 PaperInfo paper; /* info about the page info for the diagram */
46 struct {
47 /* grid line intervals */
48 real width_x, width_y;
49 /* the interval between visible grid lines */
50 guint visible_x, visible_y;
51 } grid;
53 struct {
54 /* sorted arrays of the guides for the diagram */
55 real *hguides, *vguides;
56 guint nhguides, nvguides;
57 } guides;
59 GPtrArray *layers; /* Layers ordered by decreasing z-order */
60 Layer *active_layer;
62 guint selected_count;
63 GList *selected; /* List of objects that are selected,
64 all from the active layer! */
67 struct _Layer {
68 char *name;
69 Rectangle extents; /* The extents of the layer */
71 GList *objects; /* List of objects in the layer,
72 sorted by decreasing z-valued,
73 objects can ONLY be connected to objects
74 in the same layer! */
76 int visible;
78 DiagramData *parent_diagram; /* Back-pointer to the diagram. This
79 must only be set by functions internal
80 to the diagram, and accessed via
81 layer_get_parent_diagram() */
84 #include "object.h"
86 DIAVAR int render_bounding_boxes;
88 DiagramData *new_diagram_data(NewDiagramData *prefs);
89 void diagram_data_destroy(DiagramData *data);
91 Layer *new_layer (char *name, DiagramData *parent);
92 void layer_destroy(Layer *layer);
94 void data_raise_layer(DiagramData *data, Layer *layer);
95 void data_lower_layer(DiagramData *data, Layer *layer);
97 void data_add_layer(DiagramData *data, Layer *layer);
98 void data_add_layer_at(DiagramData *data, Layer *layer, int pos);
99 void data_set_active_layer(DiagramData *data, Layer *layer);
100 void data_delete_layer(DiagramData *data, Layer *layer);
101 void data_select(DiagramData *data, Object *obj);
102 void data_unselect(DiagramData *data, Object *obj);
103 void data_remove_all_selected(DiagramData *data);
104 gboolean data_update_extents(DiagramData *data); /* returns true if changed. */
105 GList *data_get_sorted_selected(DiagramData *data);
106 GList *data_get_sorted_selected_remove(DiagramData *data);
108 typedef void (*ObjectRenderer)(Object *obj, DiaRenderer *renderer,
109 int active_layer,
110 gpointer data);
111 void data_render(DiagramData *data, DiaRenderer *renderer, Rectangle *update,
112 ObjectRenderer obj_renderer /* Can be NULL */,
113 gpointer gdata);
114 void layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
115 ObjectRenderer obj_renderer /* Can be NULL */,
116 gpointer data,
117 int active_layer);
119 int layer_object_index(Layer *layer, Object *obj);
120 void layer_add_object(Layer *layer, Object *obj);
121 void layer_add_object_at(Layer *layer, Object *obj, int pos);
122 void layer_add_objects(Layer *layer, GList *obj_list);
123 void layer_add_objects_first(Layer *layer, GList *obj_list);
124 void layer_remove_object(Layer *layer, Object *obj);
125 void layer_remove_objects(Layer *layer, GList *obj_list);
126 GList *layer_find_objects_intersecting_rectangle(Layer *layer, Rectangle*rect);
127 GList *layer_find_objects_in_rectangle(Layer *layer, Rectangle *rect);
128 Object *layer_find_closest_object(Layer *layer, Point *pos, real maxdist);
129 real layer_find_closest_connectionpoint(Layer *layer,
130 ConnectionPoint **closest,
131 Point *pos,
132 Object *notthis);
133 int layer_update_extents(Layer *layer); /* returns true if changed. */
134 void layer_replace_object_with_list(Layer *layer, Object *obj,
135 GList *list);
136 void layer_set_object_list(Layer *layer, GList *list);
137 DiagramData *layer_get_parent_diagram(Layer *layer);
138 /* Make sure all objects that are in the layer and not in the new
139 list eventually gets destroyed. */
141 #endif /* DIAGRAMDATA_H */