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
;
40 Rectangle extents
; /* The extents of the diagram */
44 PaperInfo paper
; /* info about the page info for the diagram */
47 /* grid line intervals */
48 real width_x
, width_y
;
49 /* the interval between visible grid lines */
50 guint visible_x
, visible_y
;
54 /* sorted arrays of the guides for the diagram */
55 real
*hguides
, *vguides
;
56 guint nhguides
, nvguides
;
59 GPtrArray
*layers
; /* Layers ordered by decreasing z-order */
63 GList
*selected
; /* List of objects that are selected,
64 all from the active layer! */
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
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() */
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
,
111 void data_render(DiagramData
*data
, DiaRenderer
*renderer
, Rectangle
*update
,
112 ObjectRenderer obj_renderer
/* Can be NULL */,
114 void layer_render(Layer
*layer
, DiaRenderer
*renderer
, Rectangle
*update
,
115 ObjectRenderer obj_renderer
/* Can be NULL */,
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
,
133 int layer_update_extents(Layer
*layer
); /* returns true if changed. */
134 void layer_replace_object_with_list(Layer
*layer
, Object
*obj
,
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 */