1 /* Dia -- an diagram creation/manipulation program 2 * Copyright (C) 1998 Alexander Larsson 3 * 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. 8 * 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. 13 * 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. 17 */ 18 #ifndef DDISPLAY_H 19 #define DDISPLAY_H 20 21 #include <gtk/gtk.h> 22 #include <gtk/gtkimcontext.h> 23 24 typedef struct _DDisplay DDisplay; 25 26 #include "geometry.h" 27 #include "diagram.h" 28 #include "grid.h" 29 #include "menus.h" 30 #include "diarenderer.h" 31 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 */ 35 36 #define DDISPLAY_MAX_ZOOM 2000.0 37 #define DDISPLAY_NORMAL_ZOOM 20.0 38 #define DDISPLAY_MIN_ZOOM 0.2 39 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. */ 42 /* 43 #define DDISPLAY_MAX_ZOOM 100.0 44 #define DDISPLAY_NORMAL_ZOOM 1.0 45 #define DDISPLAY_MIN_ZOOM 0.01 46 */ 47 struct _DDisplay { 48 Diagram *diagram; /* pointer to the associated diagram */ 49 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; /* either decoration or menu button */ 55 GtkWidget *menu_bar; /* widget for the menu bar */ 56 GtkUIManager *ui_manager; /* ui manager used to create the menu bar */ 57 GtkActionGroup *actions; 58 59 /* menu bar widgets */ 60 GtkMenuItem *rulers; 61 62 GtkWidget *zoom_status; 63 GtkWidget *grid_status; 64 GtkWidget *mainpoint_status; 65 GtkWidget *modified_status; 66 67 GtkAccelGroup *accel_group; 68 69 GtkAdjustment *hsbdata; /* horizontal data information */ 70 GtkAdjustment *vsbdata; /* vertical data information */ 71 72 Point origo; /* The origo (lower left) position */ 73 real zoom_factor; /* zoom, 20.0 means 20 pixel == 1 cm */ 74 Rectangle visible; /* The part visible in this display */ 75 76 Grid grid; /* the grid in this display */ 77 78 gboolean show_cx_pts; /* Connection points toggle boolean */ 79 gboolean autoscroll; 80 gboolean mainpoint_magnetism; /* Mainpoints snapped from entire obj*/ 81 82 int aa_renderer; 83 DiaRenderer *renderer; 84 85 GSList *update_areas; /* Update areas list */ 86 GSList *display_areas; /* Display areas list */ 87 guint update_id; /* idle handler ID for redraws */ 88 89 GtkIMContext *im_context; 90 91 /* Preedit String */ 92 gchar *preedit_string; 93 PangoAttrList *preedit_attrs; 94 95 /* Is there another case? Like I see embedded-dia modules, do these do something 96 * in addition??? */ 97 gboolean is_standalone_window; 98 99 /* Points to Integrated UI Toolbar */ 100 GtkToolbar *common_toolbar; 101 102 /* Points to widget containing the diagram if not standalone window */ 103 GtkWidget *container; 104 105 /* Private field, indicates if rulers are shown for this diagram. */ 106 gboolean rulers_are_showing; 107 108 /* Private field, indicates which text, if any, is being edited */ 109 Focus *active_focus; 110 }; 111 112 extern GdkCursor *default_cursor; 113 114 DDisplay *new_display(Diagram *dia); 115 DDisplay *copy_display(DDisplay *orig_ddisp); 116 /* Normal destroy is done through shell widget destroy event. */ 117 void ddisplay_really_destroy(DDisplay *ddisp); 118 void ddisplay_transform_coords_double(DDisplay *ddisp, 119 coord x, coord y, 120 double *xi, double *yi); 121 void ddisplay_transform_coords(DDisplay *ddisp, 122 coord x, coord y, 123 int *xi, int *yi); 124 void ddisplay_untransform_coords(DDisplay *ddisp, 125 int xi, int yi, 126 coord *x, coord *y); 127 real ddisplay_transform_length(DDisplay *ddisp, real len); 128 real ddisplay_untransform_length(DDisplay *ddisp, real len); 129 void ddisplay_add_update_pixels(DDisplay *ddisp, Point *point, 130 int pixel_width, int pixel_height); 131 void ddisplay_add_update_all(DDisplay *ddisp); 132 void ddisplay_add_update_with_border(DDisplay *ddisp, Rectangle *rect, 133 int pixel_border); 134 void ddisplay_add_update(DDisplay *ddisp, Rectangle *rect); 135 void ddisplay_add_display_area(DDisplay *ddisp, 136 int left, int top, 137 int right, int bottom); 138 void ddisplay_flush(DDisplay *ddisp); 139 void ddisplay_update_scrollbars(DDisplay *ddisp); 140 void ddisplay_set_origo(DDisplay *ddisp, 141 coord x, coord y); 142 void ddisplay_zoom(DDisplay *ddisp, Point *point, 143 real zoom_factor); 144 void ddisplay_zoom_centered(DDisplay *ddisp, Point *point, real magnify); 145 void ddisplay_set_snap_to_grid(DDisplay *ddisp, gboolean snap); 146 void ddisplay_set_snap_to_objects(DDisplay *ddisp, gboolean magnetic); 147 void ddisplay_set_renderer(DDisplay *ddisp, int aa_renderer); 148 void ddisplay_resize_canvas(DDisplay *ddisp, 149 int width, 150 int height); 151 152 void ddisplay_render_pixmap(DDisplay *ddisp, Rectangle *update); 153 154 DDisplay *ddisplay_active(void); 155 Diagram *ddisplay_active_diagram(void); 156 157 void ddisplay_close(DDisplay *ddisp); 158 159 void ddisplay_set_title(DDisplay *ddisp, char *title); 160 void ddisplay_set_cursor(DDisplay *ddisp, GdkCursor *cursor); 161 void ddisplay_set_all_cursor(GdkCursor *cursor); 162 163 gboolean display_get_rulers_showing(DDisplay *ddisp); 164 void display_rulers_show (DDisplay *ddisp); 165 void display_rulers_hide (DDisplay *ddisp); 166 167 gboolean ddisplay_scroll(DDisplay *ddisp, Point *delta); 168 gboolean ddisplay_autoscroll(DDisplay *ddisp, int x, int y); 169 void ddisplay_scroll_up(DDisplay *ddisp); 170 void ddisplay_scroll_down(DDisplay *ddisp); 171 void ddisplay_scroll_left(DDisplay *ddisp); 172 void ddisplay_scroll_right(DDisplay *ddisp); 173 gboolean ddisplay_scroll_center_point(DDisplay *ddisp, Point *p); 174 gboolean ddisplay_scroll_to_object(DDisplay *ddisp, DiaObject *obj); 175 gboolean ddisplay_present_object(DDisplay *ddisp, DiaObject *obj); 176 177 void ddisplay_show_all (DDisplay *ddisp); 178 179 void display_update_menu_state(DDisplay *ddisp); 180 void ddisplay_update_statusbar(DDisplay *ddisp); 181 void ddisplay_do_update_menu_sensitivity (DDisplay *ddisp); 182 183 void display_set_active(DDisplay *ddisp); 184 185 void ddisplay_im_context_preedit_reset(DDisplay *ddisp, Focus *focus); 186 187 Focus *ddisplay_active_focus(DDisplay *ddisp); 188 void ddisplay_set_active_focus(DDisplay *ddisp, Focus *focus); 189 190 #endif /* DDISPLAY_H */ 191