more leaks plugged and more *_OPTIONAL
[dia.git] / app / diagram.h
blobb61a7c89983874197038a44ceda50ec6b0834767
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 DIAGRAM_H
19 #define DIAGRAM_H
21 #include <gtk/gtk.h>
23 typedef struct _Diagram Diagram;
25 #include "geometry.h"
26 #include "object.h"
27 #include "handle.h"
28 #include "connectionpoint.h"
29 #include "display.h"
30 #include "diagramdata.h"
31 #include "undo.h"
32 #include "filter.h"
33 #include "menus.h"
35 struct _Diagram {
36 char *filename;
37 int unsaved; /* True if diagram is created but not saved.*/
38 int modified;
39 gboolean autosaved; /* True if the diagram is autosaved since last mod */
40 char *autosavefilename; /* Holds the name of the current autosave file
41 * for this diagram, or NULL. */
43 DiagramData *data;
45 guint display_count;
46 GSList *displays; /* List of all displays showing this diagram */
48 UndoStack *undo;
51 struct _object_extent
53 Object *object;
54 Rectangle *extent;
57 typedef struct _object_extent object_extent;
59 GList *dia_open_diagrams(void); /* Read only! */
61 Diagram *diagram_load(const char *filename, DiaImportFilter *ifilter);
62 int diagram_load_into (Diagram *dest, const char *filename, DiaImportFilter *ifilter);
63 Diagram *new_diagram(const char *filename); /*Note: filename is copied*/
64 void diagram_destroy(Diagram *dia);
65 void diagram_modified(Diagram *dia);
66 void diagram_set_modified(Diagram *dia, int modified);
67 void diagram_add_ddisplay(Diagram *dia, DDisplay *ddisp);
68 void diagram_remove_ddisplay(Diagram *dia, DDisplay *ddisp);
69 void diagram_add_object(Diagram *dia, Object *obj);
70 void diagram_add_object_list(Diagram *dia, GList *list);
71 void diagram_selected_break_external(Diagram *dia);
72 void diagram_remove_all_selected(Diagram *diagram, int delete_empty);
73 void diagram_unselect_object(Diagram *diagram, Object *obj);
74 void diagram_unselect_objects(Diagram *dia, GList *obj_list);
75 void diagram_select(Diagram *diagram, Object *obj);
76 void diagram_select_list(Diagram *diagram, GList *list);
77 int diagram_is_selected(Diagram *diagram, Object *obj);
78 GList *diagram_get_sorted_selected(Diagram *dia);
79 /* Removes selected from objects list, NOT selected list: */
80 GList *diagram_get_sorted_selected_remove(Diagram *dia);
81 void diagram_add_update(Diagram *dia, Rectangle *update);
82 void diagram_add_update_all(Diagram *dia);
83 void diagram_add_update_all_all_and_flush();
84 void diagram_add_update_pixels(Diagram *dia, Point *point,
85 int pixel_width, int pixel_height);
86 void diagram_flush(Diagram *dia);
87 Object *diagram_find_clicked_object(Diagram *dia,
88 Point *pos,
89 real maxdist);
90 Object *diagram_find_clicked_object_except(Diagram *dia,
91 Point *pos,
92 real maxdist,
93 GList *avoid);
94 real diagram_find_closest_handle(Diagram *dia, Handle **handle,
95 Object **obj, Point *pos);
96 real diagram_find_closest_connectionpoint(Diagram *dia,
97 ConnectionPoint **cp,
98 Point *pos,
99 Object *notthis);
100 void diagram_update_extents(Diagram *dia);
101 gint diagram_parent_sort_cb(object_extent ** a, object_extent **b);
103 void diagram_update_menu_sensitivity (Diagram *dia, UpdatableMenuItems *items);
104 void diagram_update_menubar_sensitivity(Diagram *dia, UpdatableMenuItems *items);
105 void diagram_update_popupmenu_sensitivity(Diagram *dia);
107 void diagram_place_under_selected(Diagram *dia);
108 void diagram_place_over_selected(Diagram *dia);
109 void diagram_place_down_selected(Diagram *dia);
110 void diagram_place_up_selected(Diagram *dia);
111 void diagram_group_selected(Diagram *dia);
112 void diagram_ungroup_selected(Diagram *dia);
113 void diagram_parent_selected(Diagram *dia);
114 void diagram_unparent_selected(Diagram *dia);
115 void diagram_unparent_children_selected(Diagram *dia);
117 void diagram_set_filename(Diagram *dia, char *filename);
118 gchar *diagram_get_name(Diagram *dia);
120 int diagram_modified_exists(void);
122 void diagram_redraw_all(void);
124 void diagram_object_modified(Diagram *dia, Object *object);
126 #endif /* DIAGRAM_H */