Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-view-private.h File Reference
#include "ev-view.h"
#include "ev-document-model.h"
#include "ev-pixbuf-cache.h"
#include "ev-page-cache.h"
#include "ev-jobs.h"
#include "ev-image.h"
#include "ev-form-field.h"
#include "ev-selection.h"
#include "ev-view-cursor.h"
+ Include dependency graph for ev-view-private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DragInfo
 
struct  AutoScrollInfo
 
struct  SelectionInfo
 
struct  ImageDNDInfo
 
struct  EvViewWindowChild
 
struct  _EvHeightToPageCache
 
struct  AddingAnnotInfo
 
struct  MovingAnnotInfo
 
struct  _EvView
 
struct  _EvViewClass
 

Macros

#define DRAG_HISTORY   10
 

Typedefs

typedef struct _EvHeightToPageCache EvHeightToPageCache
 

Enumerations

enum  EvPanAction { EV_PAN_ACTION_NONE, EV_PAN_ACTION_NEXT, EV_PAN_ACTION_PREV }
 
enum  PendingScroll { SCROLL_TO_KEEP_POSITION, SCROLL_TO_PAGE_POSITION, SCROLL_TO_CENTER, SCROLL_TO_FIND_LOCATION }
 

Functions

void _get_page_size_for_scale_and_rotation (EvDocument *document, gint page, gdouble scale, gint rotation, gint *page_width, gint *page_height)
 
void _ev_view_transform_view_point_to_doc_point (EvView *view, GdkPoint *view_point, GdkRectangle *page_area, GtkBorder *border, double *doc_point_x, double *doc_point_y)
 
void _ev_view_transform_view_rect_to_doc_rect (EvView *view, GdkRectangle *view_rect, GdkRectangle *page_area, GtkBorder *border, EvRectangle *doc_rect)
 
void _ev_view_transform_doc_point_to_view_point (EvView *view, int page, EvPoint *doc_point, GdkPoint *view_point)
 
void _ev_view_transform_doc_rect_to_view_rect (EvView *view, int page, EvRectangle *doc_rect, GdkRectangle *view_rect)
 
void _ev_view_get_selection_colors (EvView *view, GdkRGBA *bg_color, GdkRGBA *fg_color)
 
gint _ev_view_get_caret_cursor_offset_at_doc_point (EvView *view, gint page, gdouble doc_x, gdouble doc_y)
 
void _ev_view_clear_selection (EvView *view)
 
void _ev_view_set_selection (EvView *view, GdkPoint *start_point, GdkPoint *end_point)
 
void _ev_view_set_focused_element (EvView *view, EvMapping *element_mapping, gint page)
 
void _ev_view_focus_form_field (EvView *view, EvFormField *field)
 

Macro Definition Documentation

#define DRAG_HISTORY   10

Definition at line 38 of file ev-view-private.h.

Typedef Documentation

Enumeration Type Documentation

Enumerator
EV_PAN_ACTION_NONE 
EV_PAN_ACTION_NEXT 
EV_PAN_ACTION_PREV 

Definition at line 75 of file ev-view-private.h.

Enumerator
SCROLL_TO_KEEP_POSITION 
SCROLL_TO_PAGE_POSITION 
SCROLL_TO_CENTER 
SCROLL_TO_FIND_LOCATION 

Definition at line 102 of file ev-view-private.h.

Function Documentation

void _ev_view_clear_selection ( EvView view)

Definition at line 9241 of file ev-view.c.

9242 {
9243  clear_selection (view);
9244 }

+ Here is the caller graph for this function:

void _ev_view_focus_form_field ( EvView view,
EvFormField field 
)

Definition at line 2739 of file ev-view.c.

2741 {
2742  GtkWidget *field_widget = NULL;
2743  EvMappingList *form_field_mapping;
2744  EvMapping *mapping;
2745 
2746  _ev_view_set_focused_element (view, NULL, -1);
2747 
2748  if (field->is_read_only)
2749  return;
2750 
2751  if (EV_IS_FORM_FIELD_BUTTON (field)) {
2752  field_widget = ev_view_form_field_button_create_widget (view, field);
2753  } else if (EV_IS_FORM_FIELD_TEXT (field)) {
2754  field_widget = ev_view_form_field_text_create_widget (view, field);
2755  } else if (EV_IS_FORM_FIELD_CHOICE (field)) {
2756  field_widget = ev_view_form_field_choice_create_widget (view, field);
2757  } else if (EV_IS_FORM_FIELD_SIGNATURE (field)) {
2758  /* TODO */
2759  }
2760 
2761  /* Form field doesn't require a widget */
2762  if (!field_widget) {
2763  if (!gtk_widget_has_focus (GTK_WIDGET (view)))
2764  gtk_widget_grab_focus (GTK_WIDGET (view));
2765  return;
2766  }
2767 
2768  g_object_set_data_full (G_OBJECT (field_widget), "form-field",
2769  g_object_ref (field),
2770  (GDestroyNotify)g_object_unref);
2771 
2772  form_field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
2773  field->page->index);
2774  mapping = ev_mapping_list_find (form_field_mapping, field);
2775  _ev_view_set_focused_element (view, mapping, field->page->index);
2776  ev_view_put_to_doc_rect (view, field_widget, field->page->index, &mapping->area);
2777  gtk_widget_show (field_widget);
2778  gtk_widget_grab_focus (field_widget);
2779 }

+ Here is the caller graph for this function:

gint _ev_view_get_caret_cursor_offset_at_doc_point ( EvView view,
gint  page,
gdouble  doc_x,
gdouble  doc_y 
)

Definition at line 4820 of file ev-view.c.

4824 {
4825  EvRectangle *areas = NULL;
4826  guint n_areas = 0;
4827  gint offset = -1;
4828  gint first_line_offset;
4829  gint last_line_offset = -1;
4830  EvRectangle *rect;
4831  guint i;
4832 
4833  ev_page_cache_get_text_layout (view->page_cache, page, &areas, &n_areas);
4834  if (!areas)
4835  return -1;
4836 
4837  i = 0;
4838  while (i < n_areas && offset == -1) {
4839  rect = areas + i;
4840 
4841  first_line_offset = -1;
4842  while (doc_y >= rect->y1 && doc_y <= rect->y2) {
4843  if (first_line_offset == -1) {
4844  if (doc_x <= rect->x1) {
4845  /* Location is before the start of the line */
4846  if (last_line_offset != -1) {
4847  EvRectangle *last = areas + last_line_offset;
4848  gint dx1, dx2;
4849 
4850  /* If there's a previous line, check distances */
4851 
4852  dx1 = doc_x - last->x2;
4853  dx2 = rect->x1 - doc_x;
4854 
4855  if (dx1 < dx2)
4856  offset = last_line_offset;
4857  else
4858  offset = i;
4859  } else {
4860  offset = i;
4861  }
4862 
4863  last_line_offset = i + 1;
4864  break;
4865  }
4866  first_line_offset = i;
4867  }
4868  last_line_offset = i + 1;
4869 
4870  if (doc_x >= rect->x1 && doc_x <= rect->x2) {
4871  /* Location is inside the line. Position the caret before
4872  * or after the character, depending on whether the point
4873  * falls within the left or right half of the bounding box.
4874  */
4875  if (doc_x <= rect->x1 + (rect->x2 - rect->x1) / 2)
4876  offset = i;
4877  else
4878  offset = i + 1;
4879  break;
4880  }
4881 
4882  i++;
4883  rect = areas + i;
4884  }
4885 
4886  if (first_line_offset == -1)
4887  i++;
4888  }
4889 
4890  if (last_line_offset == -1)
4891  return -1;
4892 
4893  if (offset == -1)
4894  offset = last_line_offset;
4895 
4896  return offset;
4897 }

+ Here is the caller graph for this function:

void _ev_view_get_selection_colors ( EvView view,
GdkRGBA *  bg_color,
GdkRGBA *  fg_color 
)

Definition at line 6677 of file ev-view.c.

6680 {
6681  GtkWidget *widget = GTK_WIDGET (view);
6682  GtkStateFlags state;
6683  GtkStyleContext *context;
6684 
6685  context = gtk_widget_get_style_context (widget);
6686  gtk_style_context_save (context);
6687  state = gtk_style_context_get_state (context) |
6688  (gtk_widget_has_focus (widget) ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE);
6689  gtk_style_context_set_state (context, state);
6690 
6691  if (bg_color)
6692  gtk_style_context_get_background_color (context, state, bg_color);
6693 
6694  if (fg_color)
6695  gtk_style_context_get_color (context, state, fg_color);
6696 
6697  gtk_style_context_restore (context);
6698 }

+ Here is the caller graph for this function:

void _ev_view_set_focused_element ( EvView view,
EvMapping element_mapping,
gint  page 
)

Definition at line 2216 of file ev-view.c.

2219 {
2220  GdkRectangle view_rect;
2221  cairo_region_t *region = NULL;
2222 
2223  if (view->focused_element == element_mapping)
2224  return;
2225 
2226  if (view->accessible)
2227  ev_view_accessible_set_focused_element (EV_VIEW_ACCESSIBLE (view->accessible), element_mapping, page);
2228 
2229  if (ev_view_get_focused_area (view, &view_rect))
2230  region = cairo_region_create_rectangle (&view_rect);
2231 
2232  view->focused_element = element_mapping;
2233  view->focused_element_page = page;
2234 
2235  if (ev_view_get_focused_area (view, &view_rect)) {
2236  if (!region)
2237  region = cairo_region_create_rectangle (&view_rect);
2238  else
2239  cairo_region_union_rectangle (region, &view_rect);
2240 
2241  ev_document_model_set_page (view->model, page);
2242  view_rect.x += view->scroll_x;
2243  view_rect.y += view->scroll_y;
2244  ensure_rectangle_is_visible (view, &view_rect);
2245  }
2246 
2247  if (region) {
2248  gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)),
2249  region, TRUE);
2250  cairo_region_destroy (region);
2251  }
2252 }

+ Here is the caller graph for this function:

void _ev_view_set_selection ( EvView view,
GdkPoint *  start_point,
GdkPoint *  end_point 
)

Definition at line 9247 of file ev-view.c.

9250 {
9251  compute_selections (view, EV_SELECTION_STYLE_GLYPH, start_point, end_point);
9252 }

+ Here is the caller graph for this function:

void _ev_view_transform_doc_point_to_view_point ( EvView view,
int  page,
EvPoint doc_point,
GdkPoint *  view_point 
)

Definition at line 1391 of file ev-view.c.

1395 {
1396  GdkRectangle page_area;
1397  GtkBorder border;
1398  double x, y, view_x, view_y;
1399 
1400  switch (view->rotation) {
1401  case 0:
1402  x = doc_point->x;
1403  y = doc_point->y;
1404 
1405  break;
1406  case 90: {
1407  gdouble width;
1408 
1409  get_doc_page_size (view, page, &width, NULL);
1410  x = width - doc_point->y;
1411  y = doc_point->x;
1412  }
1413  break;
1414  case 180: {
1415  gdouble width, height;
1416 
1417  get_doc_page_size (view, page, &width, &height);
1418  x = width - doc_point->x;
1419  y = height - doc_point->y;
1420  }
1421  break;
1422  case 270: {
1423  gdouble height;
1424 
1425  get_doc_page_size (view, page, NULL, &height);
1426  x = doc_point->y;
1427  y = height - doc_point->x;
1428  }
1429  break;
1430  default:
1431  g_assert_not_reached ();
1432  }
1433 
1434  ev_view_get_page_extents (view, page, &page_area, &border);
1435 
1436  view_x = CLAMP ((gint)(x * view->scale + 0.5), 0, page_area.width);
1437  view_y = CLAMP ((gint)(y * view->scale + 0.5), 0, page_area.height);
1438  view_point->x = view_x + page_area.x + border.left;
1439  view_point->y = view_y + page_area.y + border.top;
1440 }

+ Here is the caller graph for this function:

void _ev_view_transform_doc_rect_to_view_rect ( EvView view,
int  page,
EvRectangle doc_rect,
GdkRectangle *  view_rect 
)

Definition at line 1443 of file ev-view.c.

1447 {
1448  GdkRectangle page_area;
1449  GtkBorder border;
1450  double x, y, w, h;
1451 
1452  switch (view->rotation) {
1453  case 0:
1454  x = doc_rect->x1;
1455  y = doc_rect->y1;
1456  w = doc_rect->x2 - doc_rect->x1;
1457  h = doc_rect->y2 - doc_rect->y1;
1458 
1459  break;
1460  case 90: {
1461  gdouble width;
1462 
1463  get_doc_page_size (view, page, &width, NULL);
1464  x = width - doc_rect->y2;
1465  y = doc_rect->x1;
1466  w = doc_rect->y2 - doc_rect->y1;
1467  h = doc_rect->x2 - doc_rect->x1;
1468  }
1469  break;
1470  case 180: {
1471  gdouble width, height;
1472 
1473  get_doc_page_size (view, page, &width, &height);
1474  x = width - doc_rect->x2;
1475  y = height - doc_rect->y2;
1476  w = doc_rect->x2 - doc_rect->x1;
1477  h = doc_rect->y2 - doc_rect->y1;
1478  }
1479  break;
1480  case 270: {
1481  gdouble height;
1482 
1483  get_doc_page_size (view, page, NULL, &height);
1484  x = doc_rect->y1;
1485  y = height - doc_rect->x2;
1486  w = doc_rect->y2 - doc_rect->y1;
1487  h = doc_rect->x2 - doc_rect->x1;
1488  }
1489  break;
1490  default:
1491  g_assert_not_reached ();
1492  }
1493 
1494  ev_view_get_page_extents (view, page, &page_area, &border);
1495 
1496  view_rect->x = (gint)(x * view->scale + 0.5) + page_area.x + border.left;
1497  view_rect->y = (gint)(y * view->scale + 0.5) + page_area.y + border.top;
1498  view_rect->width = (gint)(w * view->scale + 0.5);
1499  view_rect->height = (gint)(h * view->scale + 0.5);
1500 }

+ Here is the caller graph for this function:

void _ev_view_transform_view_point_to_doc_point ( EvView view,
GdkPoint *  view_point,
GdkRectangle *  page_area,
GtkBorder *  border,
double *  doc_point_x,
double *  doc_point_y 
)

Definition at line 1366 of file ev-view.c.

1372 {
1373  *doc_point_x = MAX ((double) (view_point->x - page_area->x - border->left) / view->scale, 0);
1374  *doc_point_y = MAX ((double) (view_point->y - page_area->y - border->right) / view->scale, 0);
1375 }

+ Here is the caller graph for this function:

void _ev_view_transform_view_rect_to_doc_rect ( EvView view,
GdkRectangle *  view_rect,
GdkRectangle *  page_area,
GtkBorder *  border,
EvRectangle doc_rect 
)

Definition at line 1378 of file ev-view.c.

1383 {
1384  doc_rect->x1 = MAX ((double) (view_rect->x - page_area->x - border->left) / view->scale, 0);
1385  doc_rect->y1 = MAX ((double) (view_rect->y - page_area->y - border->right) / view->scale, 0);
1386  doc_rect->x2 = doc_rect->x1 + (double) view_rect->width / view->scale;
1387  doc_rect->y2 = doc_rect->y1 + (double) view_rect->height / view->scale;
1388 }

+ Here is the caller graph for this function:

void _get_page_size_for_scale_and_rotation ( EvDocument document,
gint  page,
gdouble  scale,
gint  rotation,
gint *  page_width,
gint *  page_height 
)

Definition at line 1171 of file ev-view.c.

1177 {
1178  gdouble w, h;
1179  gint width, height;
1180 
1181  ev_document_get_page_size (document, page, &w, &h);
1182 
1183  width = (gint)(w * scale + 0.5);
1184  height = (gint)(h * scale + 0.5);
1185 
1186  if (page_width)
1187  *page_width = (rotation == 0 || rotation == 180) ? width : height;
1188  if (page_height)
1189  *page_height = (rotation == 0 || rotation == 180) ? height : width;
1190 }

+ Here is the caller graph for this function: