- guint32 result;
- result = (0xff0000 | (color->red & 0xff00));
- result <<= 8;
- result |= ((color->green & 0xff00) | (color->blue >> 8));
- return result;
-}
-
-static void
-draw_rubberband (GtkWidget *widget, GdkWindow *window,
- const GdkRectangle *rect, guchar alpha)
-{
- GdkGC *gc;
- GdkPixbuf *pixbuf;
- GdkColor *fill_color_gdk;
- guint fill_color;
-
- fill_color_gdk = gdk_color_copy (>K_WIDGET (widget)->style->base[GTK_STATE_SELECTED]);
- fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 | alpha;
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- rect->width, rect->height);
- gdk_pixbuf_fill (pixbuf, fill_color);
-
- gdk_draw_pixbuf (window, NULL, pixbuf,
- 0, 0,
- rect->x, rect->y,
- rect->width, rect->height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
-
- g_object_unref (pixbuf);
-
- gc = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (gc, fill_color_gdk);
- gdk_draw_rectangle (window, gc, FALSE,
- rect->x, rect->y,
- rect->width - 1,
- rect->height - 1);
- g_object_unref (gc);
-
- gdk_color_free (fill_color_gdk);
-}
-
-
-static void
-highlight_find_results (EvView *view)
-{
- EvDocumentFind *find;
- int i, results = 0;
-
- g_return_if_fail (EV_IS_DOCUMENT_FIND (view->document));
-
- find = EV_DOCUMENT_FIND (view->document);
-
- results = ev_document_find_get_n_results (find, view->current_page);
-
- for (i = 0; i < results; i++) {
- EvRectangle rectangle;
- GdkRectangle view_rectangle;
- guchar alpha;
-
- alpha = (i == view->find_result) ? 0x90 : 0x20;
- ev_document_find_get_result (find, view->current_page,
- i, &rectangle);
- doc_rect_to_view_rect (view, &rectangle, &view_rectangle);
- draw_rubberband (GTK_WIDGET (view), view->bin_window,
- &view_rectangle, alpha);
- }
-}
-#endif
-
-
-static gboolean
-get_page_extents (EvView *view,
- gint page,
- GdkRectangle *page_area,
- GtkBorder *border)
-{
- GtkWidget *widget;
- int width, height;
-
- widget = GTK_WIDGET (view);
-
- /* Quick sanity check */
- if (view->presentation) {
- if (view->current_page != page)
- return FALSE;
- } else if (view->continuous) {
- if (page < view->start_page ||
- page > view->end_page)
- return FALSE;
- } else if (view->dual_page) {
- if (ABS (page - view->current_page) > 1)
- return FALSE;
- } else {
- if (view->current_page != page)
- return FALSE;
- }
-
- /* Get the size of the page */
- ev_page_cache_get_size (view->page_cache, page,
- view->scale,
- &width, &height);
- compute_border (view, width, height, border);
- page_area->width = width + border->left + border->right;
- page_area->height = height + border->top + border->bottom;
-
- if (view->presentation) {
- page_area->x = (MAX (0, widget->allocation.width - width))/2;
- page_area->y = (MAX (0, widget->allocation.height - height))/2;
- } else if (view->continuous) {
- gint max_width, max_height;
- gint x, y;
-
- get_bounding_box_size (view, &max_width, &max_height);
- /* Get the location of the bounding box */
- if (view->dual_page) {
- x = view->spacing + (page % 2) * (max_width + view->spacing);
- y = view->spacing + (page / 2) * (max_height + view->spacing);
- x = x + MAX (0, widget->allocation.width - (max_width * 2 + view->spacing * 3))/2;
- } else {
- x = view->spacing;
- y = view->spacing + page * (max_height + view->spacing);
- x = x + MAX (0, widget->allocation.width - (max_width + view->spacing * 2))/2;
- }
- page_area->x = x;
- page_area->y = y;
- } else {
- gint x, y;
- if (view->dual_page) {
- gint width_2, height_2;
- gint max_width = width;
- gint max_height = height;
- GtkBorder overall_border;
- gint other_page;
-
- other_page = page ^ 1;
-
- /* First, we get the bounding box of the two pages */
- if (other_page < ev_page_cache_get_n_pages (view->page_cache)) {
- ev_page_cache_get_size (view->page_cache,
- page + 1,
- view->scale,
- &width_2, &height_2);
- if (width_2 > width)
- max_width = width_2;
- if (height_2 > height)
- max_height = height_2;
- }
- compute_border (view, max_width, max_height, &overall_border);
-
- /* Find the offsets */
- x = view->spacing;
- y = view->spacing;
-
- /* Adjust for being the left or right page */
- if (page % 2 == 0)
- x = x + max_width - width;
- else
- x = x + (max_width + overall_border.left + overall_border.right) + view->spacing;
-
- y = y + (max_height - height)/2;
-
- /* Adjust for extra allocation */
- x = x + MAX (0, widget->allocation.width -
- ((max_width + overall_border.left + overall_border.right) * 2 + view->spacing * 3))/2;
- y = y + MAX (0, widget->allocation.height - (height + view->spacing * 2))/2;
- } else {
- x = view->spacing;
- y = view->spacing;
-
- /* Adjust for extra allocation */
- x = x + MAX (0, widget->allocation.width - (width + view->spacing * 2))/2;
- y = y + MAX (0, widget->allocation.height - (height + view->spacing * 2))/2;
- }
-
- page_area->x = x;
- page_area->y = y;
- }
-
- return TRUE;
-}
-
-static void
-draw_one_page (EvView *view,
- gint page,
- GdkRectangle *page_area,
- GtkBorder *border,
- GdkRectangle *expose_area)
-{
- gint width, height;
- GdkPixbuf *scaled_image;
- GdkPixbuf *current_pixbuf;
- GdkRectangle overlap;
- GdkRectangle real_page_area;
-
- g_assert (view->document);
-
- if (! gdk_rectangle_intersect (page_area, expose_area, &overlap))
- return;
-
- ev_page_cache_get_size (view->page_cache,
- page, view->scale,
- &width, &height);
-
- ev_document_misc_paint_one_page (view->bin_window,
- GTK_WIDGET (view),
- page_area, border);
-
- /* Render the document itself */
- real_page_area = *page_area;
-
- real_page_area.x += border->left;
- real_page_area.y += border->top;
- real_page_area.width -= (border->left + border->right);
- real_page_area.height -= (border->top + border->bottom);
-
- if (! gdk_rectangle_intersect (&real_page_area, expose_area, &overlap))
- return;
-
- current_pixbuf = ev_pixbuf_cache_get_pixbuf (view->pixbuf_cache, page);
- if (current_pixbuf == NULL)
- scaled_image = NULL;
- else if (width == gdk_pixbuf_get_width (current_pixbuf) &&
- height == gdk_pixbuf_get_height (current_pixbuf))
- scaled_image = g_object_ref (current_pixbuf);
- else
- scaled_image = gdk_pixbuf_scale_simple (current_pixbuf,
- width, height,
- GDK_INTERP_NEAREST);
- if (scaled_image) {
- gdk_draw_pixbuf (view->bin_window,
- GTK_WIDGET (view)->style->fg_gc[GTK_STATE_NORMAL],
- scaled_image,
- overlap.x - real_page_area.x,
- overlap.y - real_page_area.y,
- overlap.x, overlap.y,
- overlap.width, overlap.height,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- g_object_unref (scaled_image);
- }
-}
-
-static void
-ev_view_bin_expose (EvView *view,
- GdkEventExpose *event)
-{
- int i;