more leaks plugged and more *_OPTIONAL
[dia.git] / app / display.h
blob309541362609bedd4a565324a9666aacfa1a9d48
1 /* Dia -- an diagram creation/manipulation program
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 DDISPLAY_H
19 #define DDISPLAY_H
21 #include <gtk/gtk.h>
22 #include <gtk/gtkimcontext.h>
24 typedef struct _DDisplay DDisplay;
26 #include "geometry.h"
27 #include "diagram.h"
28 #include "grid.h"
29 #include "menus.h"
30 #include "diarenderer.h"
32 /** Defines the pixels per cm, default is 20 pixels = 1 cm */
33 /** This is close to, but not quite the same as, the physical display size
34 * in most cases */
36 #define DDISPLAY_MAX_ZOOM 500.0
37 #define DDISPLAY_NORMAL_ZOOM 20.0
38 #define DDISPLAY_MIN_ZOOM 1.0
40 /* The zoom amount should be uniform. Pixels per cm should be defined by the
41 * renderer alone. But that'd take a lot of fiddling in renderers. */
43 #define DDISPLAY_MAX_ZOOM 100.0
44 #define DDISPLAY_NORMAL_ZOOM 1.0
45 #define DDISPLAY_MIN_ZOOM 0.01
47 struct _DDisplay {
48 Diagram *diagram; /* pointer to the associated diagram */
50 GtkWidget *shell; /* shell widget for this ddisplay */
51 GtkWidget *canvas; /* canvas widget for this ddisplay */
52 GtkWidget *hsb, *vsb; /* widgets for scroll bars */
53 GtkWidget *hrule, *vrule; /* widgets for rulers */
54 GtkWidget *origin; /* widgets for rulers */
55 GtkWidget *menu_bar; /* widget for the menu bar */
56 GtkItemFactory *mbar_item_factory; /* item factory used to create the menu bar */
58 /* menu bar widgets */
59 GtkMenuItem *rulers;
60 GtkMenuItem *visible_grid;
61 GtkMenuItem *snap_to_grid;
62 GtkMenuItem *show_cx_pts_mitem;
63 #ifdef HAVE_LIBART
64 GtkMenuItem *antialiased;
65 #endif
66 UpdatableMenuItems updatable_menu_items;
69 GtkWidget *zoom_status;
70 GtkWidget *grid_status;
71 GtkWidget *modified_status;
73 GtkAccelGroup *accel_group;
75 GtkAdjustment *hsbdata; /* horizontal data information */
76 GtkAdjustment *vsbdata; /* vertical data information */
78 Point origo; /* The origo (lower left) position */
79 real zoom_factor; /* zoom, 20.0 means 20 pixel == 1 cm */
80 Rectangle visible; /* The part visible in this display */
82 Grid grid; /* the grid in this display */
84 gboolean show_cx_pts; /* Connection points toggle boolean */
85 gboolean autoscroll;
87 int aa_renderer;
88 DiaRenderer *renderer;
90 GSList *update_areas; /* Update areas list */
91 GSList *display_areas; /* Display areas list */
92 guint update_id; /* idle handler ID for redraws */
94 GtkIMContext *im_context;
97 extern GdkCursor *default_cursor;
99 DDisplay *new_display(Diagram *dia);
100 /* Normal destroy is done through shell widget destroy event. */
101 void ddisplay_really_destroy(DDisplay *ddisp);
102 void ddisplay_transform_coords_double(DDisplay *ddisp,
103 coord x, coord y,
104 double *xi, double *yi);
105 void ddisplay_transform_coords(DDisplay *ddisp,
106 coord x, coord y,
107 int *xi, int *yi);
108 void ddisplay_untransform_coords(DDisplay *ddisp,
109 int xi, int yi,
110 coord *x, coord *y);
111 real ddisplay_transform_length(DDisplay *ddisp, real len);
112 real ddisplay_untransform_length(DDisplay *ddisp, real len);
113 void ddisplay_add_update_pixels(DDisplay *ddisp, Point *point,
114 int pixel_width, int pixel_height);
115 void ddisplay_add_update_all(DDisplay *ddisp);
116 void ddisplay_add_update(DDisplay *ddisp, Rectangle *rect);
117 void ddisplay_add_display_area(DDisplay *ddisp,
118 int left, int top,
119 int right, int bottom);
120 void ddisplay_flush(DDisplay *ddisp);
121 void ddisplay_update_scrollbars(DDisplay *ddisp);
122 void ddisplay_set_origo(DDisplay *ddisp,
123 coord x, coord y);
124 void ddisplay_zoom(DDisplay *ddisp, Point *point,
125 real zoom_factor);
126 void ddisplay_set_snap_to_grid(DDisplay *ddisp, gboolean snap);
127 void ddisplay_set_renderer(DDisplay *ddisp, int aa_renderer);
128 void ddisplay_resize_canvas(DDisplay *ddisp,
129 int width,
130 int height);
132 void ddisplay_render_pixmap(DDisplay *ddisp, Rectangle *update);
134 DDisplay *ddisplay_active(void);
135 Diagram *ddisplay_active_diagram(void);
137 void ddisplay_close(DDisplay *ddisp);
139 void ddisplay_set_title(DDisplay *ddisp, char *title);
140 void ddisplay_set_cursor(DDisplay *ddisp, GdkCursor *cursor);
141 void ddisplay_set_all_cursor(GdkCursor *cursor);
143 gboolean ddisplay_scroll(DDisplay *ddisp, Point *delta);
144 gboolean ddisplay_autoscroll(DDisplay *ddisp, int x, int y);
145 void ddisplay_scroll_up(DDisplay *ddisp);
146 void ddisplay_scroll_down(DDisplay *ddisp);
147 void ddisplay_scroll_left(DDisplay *ddisp);
148 void ddisplay_scroll_right(DDisplay *ddisp);
149 gboolean ddisplay_scroll_center_point(DDisplay *ddisp, Point *p);
150 gboolean ddisplay_scroll_to_object(DDisplay *ddisp, Object *obj);
152 void display_update_menu_state(DDisplay *ddisp);
153 void ddisplay_update_statusbar(DDisplay *ddisp);
154 void ddisplay_do_update_menu_sensitivity (DDisplay *ddisp);
156 void display_set_active(DDisplay *ddisp);
158 #endif /* DDISPLAY_H */