1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ 2 /* this file is part of evince, a gnome document viewer 3 * 4 * Copyright (C) 2004 Red Hat, Inc 5 * 6 * Evince is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * Evince is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21 #if !defined (EVINCE_COMPILATION) 22 #error "This is a private header." 23 #endif 24 25 #ifndef __EV_VIEW_PRIVATE_H__ 26 #define __EV_VIEW_PRIVATE_H__ 27 28 #include "ev-view.h" 29 #include "ev-document-model.h" 30 #include "ev-pixbuf-cache.h" 31 #include "ev-page-cache.h" 32 #include "ev-jobs.h" 33 #include "ev-image.h" 34 #include "ev-form-field.h" 35 #include "ev-selection.h" 36 #include "ev-view-cursor.h" 37 38 #define DRAG_HISTORY 10 39 40 /* Information for middle clicking and moving around the doc */ 41 typedef struct { 42 gboolean in_drag; 43 GdkPoint start; 44 gdouble hadj; 45 gdouble vadj; 46 guint drag_timeout_id; 47 guint release_timeout_id; 48 GdkPoint buffer[DRAG_HISTORY]; 49 GdkPoint momentum; 50 gboolean in_notify; 51 } DragInfo; 52 53 /* Autoscrolling */ 54 typedef struct { 55 gboolean autoscrolling; 56 guint last_y; 57 guint start_y; 58 guint timeout_id; 59 } AutoScrollInfo; 60 61 /* Information for handling selection */ 62 typedef struct { 63 gboolean in_drag; 64 GdkPoint start; 65 GList *selections; 66 EvSelectionStyle style; 67 } SelectionInfo; 68 69 /* Information for handling images DND */ 70 typedef struct { 71 gboolean in_drag; 72 GdkPoint start; 73 EvImage *image; 74 } ImageDNDInfo; 75 76 typedef enum { 77 EV_PAN_ACTION_NONE, 78 EV_PAN_ACTION_NEXT, 79 EV_PAN_ACTION_PREV 80 } EvPanAction; 81 82 /* Annotation popup windows */ 83 typedef struct { 84 GtkWidget *window; 85 guint page; 86 87 /* Current position */ 88 gint x; 89 gint y; 90 91 /* EvView root position */ 92 gint parent_x; 93 gint parent_y; 94 95 /* Document coords */ 96 gdouble orig_x; 97 gdouble orig_y; 98 99 gboolean visible; 100 gboolean moved; 101 } EvViewWindowChild; 102 103 typedef enum { 104 SCROLL_TO_KEEP_POSITION, 105 SCROLL_TO_PAGE_POSITION, 106 SCROLL_TO_CENTER, 107 SCROLL_TO_FIND_LOCATION, 108 } PendingScroll; 109 110 typedef struct _EvHeightToPageCache { 111 gint rotation; 112 gboolean dual_even_left; 113 gdouble *height_to_page; 114 gdouble *dual_height_to_page; 115 } EvHeightToPageCache; 116 117 /* Information for handling annotations */ 118 typedef struct { 119 GdkPoint start; 120 GdkPoint stop; 121 gboolean adding_annot; 122 EvAnnotationType type; 123 EvAnnotation *annot; 124 } AddingAnnotInfo; 125 126 typedef struct { 127 GdkPoint start; 128 EvPoint cursor_offset; 129 gboolean annot_clicked; 130 gboolean moving_annot; 131 EvAnnotation *annot; 132 } MovingAnnotInfo; 133 134 /* Information for handling link preview thumbnails */ 135 typedef struct { 136 EvJob *job; 137 gdouble left; 138 gdouble top; 139 GtkWidget *popover; 140 EvLink *link; 141 guint delay_timeout_id; 142 } EvLinkPreview; 143 144 struct _EvView { 145 GtkContainer layout; 146 147 /* Container */ 148 GList *children; 149 150 EvDocument *document; 151 152 /* Find */ 153 EvJobFind *find_job; 154 GList **find_pages; /* Backwards compatibility */ 155 gint find_page; 156 gint find_result; 157 gboolean jump_to_find_result; 158 gboolean highlight_find_results; 159 160 EvDocumentModel *model; 161 EvPixbufCache *pixbuf_cache; 162 gsize pixbuf_cache_size; 163 EvPageCache *page_cache; 164 EvHeightToPageCache *height_to_page_cache; 165 EvViewCursor cursor; 166 EvJobRender *current_job; 167 168 GtkRequisition requisition; 169 gboolean internal_size_request; 170 171 /* Scrolling */ 172 GtkAdjustment *hadjustment; 173 GtkAdjustment *vadjustment; 174 /* GtkScrollablePolicy needs to be checked when 175 * driving the scrollable adjustment values */ 176 guint hscroll_policy : 1; 177 guint vscroll_policy : 1; 178 179 gint scroll_x; 180 gint scroll_y; 181 182 guint update_cursor_idle_id; 183 184 /* Delta sum for emulating normal scrolling */ 185 gdouble total_delta; 186 PendingScroll pending_scroll; 187 gboolean pending_resize; 188 EvPoint pending_point; 189 190 /* Current geometry */ 191 192 gint start_page; 193 gint end_page; 194 gint current_page; 195 196 gint rotation; 197 gdouble scale; 198 gint spacing; 199 200 gboolean loading; 201 gboolean can_zoom_in; 202 gboolean can_zoom_out; 203 gboolean continuous; 204 gboolean dual_even_left; 205 gboolean fullscreen; 206 EvSizingMode sizing_mode; 207 EvPageLayout page_layout; 208 GtkWidget *loading_window; 209 guint loading_timeout; 210 gboolean allow_links_change_zoom; 211 212 /* Common for button press handling */ 213 int pressed_button; 214 215 /* Key bindings propagation */ 216 gboolean key_binding_handled; 217 218 /* Information for middle clicking and dragging around. */ 219 DragInfo drag_info; 220 221 /* Autoscrolling */ 222 AutoScrollInfo scroll_info; 223 224 /* Selection */ 225 GdkPoint motion; 226 guint selection_update_id; 227 guint selection_scroll_id; 228 229 SelectionInfo selection_info; 230 231 /* Copy link address selection */ 232 EvLinkAction *link_selected; 233 234 /* Image DND */ 235 ImageDNDInfo image_dnd_info; 236 237 /* Annotations */ 238 GList *window_children; 239 EvViewWindowChild *window_child_focus; 240 AddingAnnotInfo adding_annot_info; 241 MovingAnnotInfo moving_annot_info; 242 GHashTable *annot_window_map; 243 gboolean enable_spellchecking; 244 245 /* Focus */ 246 EvMapping *focused_element; 247 guint focused_element_page; 248 guint child_focus_idle_id; 249 250 /* Synctex */ 251 EvMapping *synctex_result; 252 253 /* Accessibility */ 254 AtkObject *accessible; 255 256 /* Caret navigation */ 257 gboolean caret_enabled; 258 gint cursor_offset; 259 gint cursor_page; 260 gdouble cursor_line_offset; 261 gboolean cursor_visible; 262 guint cursor_blink_timeout_id; 263 guint cursor_blink_time; 264 265 /* Gestures */ 266 GtkGesture *pan_gesture; 267 GtkGesture *zoom_gesture; 268 gdouble prev_zoom_gesture_scale; 269 EvPanAction pan_action; 270 271 /* Current zoom center */ 272 gdouble zoom_center_x; 273 gdouble zoom_center_y; 274 275 /* Link preview */ 276 EvLinkPreview link_preview; 277 }; 278 279 struct _EvViewClass { 280 GtkContainerClass parent_class; 281 282 void (*scroll) (EvView *view, 283 GtkScrollType scroll, 284 GtkOrientation orientation); 285 void (*handle_link) (EvView *view, 286 gint old_page, 287 EvLink *link); 288 void (*external_link) (EvView *view, 289 EvLinkAction *action); 290 void (*popup_menu) (EvView *view, 291 GList *items); 292 void (*selection_changed) (EvView *view); 293 void (*sync_source) (EvView *view, 294 EvSourceLink *link); 295 void (*annot_added) (EvView *view, 296 EvAnnotation *annot); 297 void (*annot_changed) (EvView *view, 298 EvAnnotation *annot); 299 void (*annot_removed) (EvView *view, 300 EvAnnotation *annot); 301 void (*layers_changed) (EvView *view); 302 gboolean (*move_cursor) (EvView *view, 303 GtkMovementStep step, 304 gint count, 305 gboolean extend_selection); 306 void (*activate) (EvView *view); 307 }; 308 309 void _get_page_size_for_scale_and_rotation (EvDocument *document, 310 gint page, 311 gdouble scale, 312 gint rotation, 313 gint *page_width, 314 gint *page_height); 315 void _ev_view_transform_view_point_to_doc_point (EvView *view, 316 GdkPoint *view_point, 317 GdkRectangle *page_area, 318 GtkBorder *border, 319 double *doc_point_x, 320 double *doc_point_y); 321 void _ev_view_transform_view_rect_to_doc_rect (EvView *view, 322 GdkRectangle *view_rect, 323 GdkRectangle *page_area, 324 GtkBorder *border, 325 EvRectangle *doc_rect); 326 void _ev_view_transform_doc_point_to_view_point (EvView *view, 327 int page, 328 EvPoint *doc_point, 329 GdkPoint *view_point); 330 void _ev_view_transform_doc_point_by_rotation_scale (EvView *view, 331 int page, 332 EvPoint *doc_point, 333 GdkPoint *view_point); 334 void _ev_view_transform_doc_rect_to_view_rect (EvView *view, 335 int page, 336 EvRectangle *doc_rect, 337 GdkRectangle *view_rect); 338 void _ev_view_get_selection_colors (EvView *view, 339 GdkRGBA *bg_color, 340 GdkRGBA *fg_color); 341 gint _ev_view_get_caret_cursor_offset_at_doc_point (EvView *view, 342 gint page, 343 gdouble doc_x, 344 gdouble doc_y); 345 void _ev_view_clear_selection (EvView *view); 346 void _ev_view_set_selection (EvView *view, 347 GdkPoint *start_point, 348 GdkPoint *end_point); 349 350 void _ev_view_set_focused_element (EvView *view, 351 EvMapping *element_mapping, 352 gint page); 353 void _ev_view_focus_form_field (EvView *view, 354 EvFormField *field); 355 356 void _ev_view_ensure_rectangle_is_visible (EvView *view, 357 GdkRectangle *rect); 358 359 #endif /* __EV_VIEW_PRIVATE_H__ */ 360 361