More honesty about bug 144394, it's not quite fixed yet.
[dia.git] / app / diagram.h
blobb77c096cd3134e2f8bc4dfe82810049e0ef47683
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 "handle.h"
27 #include "connectionpoint.h"
28 #include "display.h"
29 #include "diagramdata.h"
30 #include "undo.h"
31 #include "filter.h"
32 #include "menus.h"
33 #include "diagrid.h"
35 GType diagram_get_type (void) G_GNUC_CONST;
37 #define DIA_TYPE_DIAGRAM (diagram_get_type ())
38 #define DIA_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIA_TYPE_DIAGRAM, Diagram))
39 #define DIA_DIAGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIA_TYPE_DIAGRAM, DiagramClass))
40 #define DIA_IS_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIA_TYPE_DIAGRAM))
41 #define DIA_DIAGRAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIA_TYPE_DIAGRAM, DiagramClass))
43 struct _Diagram {
44 DiagramData parent_instance;
46 char *filename;
47 int unsaved; /* True if diagram is created but not saved.*/
48 gboolean is_default; /* True if the diagram was created as the default.*/
49 int mollified;
50 gboolean autosaved; /* True if the diagram is autosaved since last mod */
51 char *autosavefilename; /* Holds the name of the current autosave file
52 * for this diagram, or NULL. */
54 Color pagebreak_color; /*!< just to show page breaks */
55 DiaGrid grid; /*!< the display grid */
57 /*! almost completely unused guides (load and save code is there) */
58 struct {
59 /* sorted arrays of the guides for the diagram */
60 real *hguides, *vguides;
61 guint nhguides, nvguides;
62 } guides;
64 DiagramData *data; /*! just for compatibility, now that the Diagram _is_ and not _has_ DiagramData */
66 guint display_count;
67 GSList *displays; /* List of all displays showing this diagram */
69 UndoStack *undo;
72 typedef struct _DiagramClass {
73 DiagramDataClass parent_class;
75 /* signals */
76 void (* removed) (Diagram*);
77 void (* selection_changed) (Diagram*, int);
79 } DiagramClass;
81 GList *dia_open_diagrams(void); /* Read only! */
83 Diagram *diagram_load(const char *filename, DiaImportFilter *ifilter);
84 int diagram_load_into (Diagram *dest, const char *filename, DiaImportFilter *ifilter);
85 Diagram *new_diagram(const char *filename); /*Note: filename is copied*/
86 /** Perform updates related to getting a new current diagram */
87 void diagram_set_current(Diagram *diagram);
88 void diagram_destroy(Diagram *dia);
89 gboolean diagram_is_modified(Diagram *dia);
90 void diagram_modified(Diagram *dia);
91 void diagram_set_modified(Diagram *dia, int modified);
92 void diagram_add_ddisplay(Diagram *dia, DDisplay *ddisp);
93 void diagram_remove_ddisplay(Diagram *dia, DDisplay *ddisp);
94 void diagram_add_object(Diagram *dia, DiaObject *obj);
95 void diagram_add_object_list(Diagram *dia, GList *list);
96 void diagram_selected_break_external(Diagram *dia);
97 void diagram_remove_all_selected(Diagram *diagram, int delete_empty);
98 void diagram_unselect_object(Diagram *dia, DiaObject *obj);
99 void diagram_unselect_objects(Diagram *dia, GList *obj_list);
100 void diagram_select(Diagram *diagram, DiaObject *obj);
101 void diagram_select_list(Diagram *diagram, GList *list);
102 int diagram_is_selected(Diagram *diagram, DiaObject *obj);
103 GList *diagram_get_sorted_selected(Diagram *dia);
104 /* Removes selected from objects list, NOT selected list: */
105 GList *diagram_get_sorted_selected_remove(Diagram *dia);
106 void diagram_add_update(Diagram *dia, Rectangle *update);
107 void diagram_add_update_with_border(Diagram *dia, Rectangle *update,
108 int pixel_border);
109 void diagram_add_update_all(Diagram *dia);
110 void diagram_add_update_all_all_and_flush();
111 void diagram_add_update_pixels(Diagram *dia, Point *point,
112 int pixel_width, int pixel_height);
113 void diagram_flush(Diagram *dia);
114 DiaObject *diagram_find_clicked_object(Diagram *dia,
115 Point *pos,
116 real maxdist);
117 DiaObject *diagram_find_clicked_object_except(Diagram *dia,
118 Point *pos,
119 real maxdist,
120 GList *avoid);
121 real diagram_find_closest_handle(Diagram *dia, Handle **handle,
122 DiaObject **obj, Point *pos);
123 real diagram_find_closest_connectionpoint(Diagram *dia,
124 ConnectionPoint **cp,
125 Point *pos,
126 DiaObject *notthis);
127 void diagram_update_extents(Diagram *dia);
129 void diagram_update_menu_sensitivity (Diagram *dia, UpdatableMenuItems *items);
130 void diagram_update_menubar_sensitivity(Diagram *dia, UpdatableMenuItems *items);
131 void diagram_update_popupmenu_sensitivity(Diagram *dia);
133 void diagram_place_under_selected(Diagram *dia);
134 void diagram_place_over_selected(Diagram *dia);
135 void diagram_place_down_selected(Diagram *dia);
136 void diagram_place_up_selected(Diagram *dia);
137 void diagram_group_selected(Diagram *dia);
138 void diagram_ungroup_selected(Diagram *dia);
139 void diagram_parent_selected(Diagram *dia);
140 void diagram_unparent_selected(Diagram *dia);
141 void diagram_unparent_children_selected(Diagram *dia);
143 void diagram_set_filename(Diagram *dia, const char *filename);
144 gchar *diagram_get_name(Diagram *dia);
146 int diagram_modified_exists(void);
148 void diagram_redraw_all(void);
150 void diagram_object_modified(Diagram *dia, DiaObject *object);
152 #endif /* DIAGRAM_H */