X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=backend%2Fev-document-misc.c;h=fd6f4493904059138f8fa14e28f86b7f8ab1adbf;hb=1a9964cbdc190840aa6ea2d762be1b8132d3dcbb;hp=4145b8a3687cbb224c3aa3cfe3919da8abf20f2d;hpb=bebd9ceae1ec88ddee03bda8c7572c9cb06f6b77;p=evince.git diff --git a/backend/ev-document-misc.c b/backend/ev-document-misc.c index 4145b8a3..fd6f4493 100644 --- a/backend/ev-document-misc.c +++ b/backend/ev-document-misc.c @@ -12,82 +12,130 @@ GdkPixbuf * ev_document_misc_get_thumbnail_frame (int width, int height, + int rotation, GdkPixbuf *source_pixbuf) { GdkPixbuf *retval; guchar *data; gint rowstride; int i; + int width_r, height_r; + + rotation = rotation % 360; + if (source_pixbuf) g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL); if (source_pixbuf) { - width = gdk_pixbuf_get_width (source_pixbuf); - height = gdk_pixbuf_get_height (source_pixbuf); + width_r = gdk_pixbuf_get_width (source_pixbuf); + height_r = gdk_pixbuf_get_height (source_pixbuf); + } else { + if (rotation == 0 || rotation == 180) { + width_r = width; + height_r = height; + } else if (rotation == 90 || rotation == 270) { + width_r = height; + height_r = width; + } else { + g_assert_not_reached (); + } } /* make sure no one is passing us garbage */ - g_assert (width > 0 && height > 0); + g_assert (width_r >= 0 && height_r >= 0); retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, - width + 4, - height + 4); + width_r + 4, + height_r + 4); /* make it black and fill in the middle */ data = gdk_pixbuf_get_pixels (retval); rowstride = gdk_pixbuf_get_rowstride (retval); gdk_pixbuf_fill (retval, 0x000000ff); - for (i = 1; i < height + 1; i++) - memset (data + (rowstride * i) + 4, 0xffffffff, width * 4); + for (i = 1; i < height_r + 1; i++) + memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4); /* copy the source pixbuf */ if (source_pixbuf) gdk_pixbuf_copy_area (source_pixbuf, 0, 0, - width, - height, + width_r, + height_r, retval, 1, 1); /* Add the corner */ - data [(width + 2) * 4 + 3] = 0; - data [(width + 3) * 4 + 3] = 0; - data [(width + 2) * 4 + (rowstride * 1) + 3] = 0; - data [(width + 3) * 4 + (rowstride * 1) + 3] = 0; + data [(width_r + 2) * 4 + 3] = 0; + data [(width_r + 3) * 4 + 3] = 0; + data [(width_r + 2) * 4 + (rowstride * 1) + 3] = 0; + data [(width_r + 3) * 4 + (rowstride * 1) + 3] = 0; - data [(height + 2) * rowstride + 3] = 0; - data [(height + 3) * rowstride + 3] = 0; - data [(height + 2) * rowstride + 4 + 3] = 0; - data [(height + 3) * rowstride + 4 + 3] = 0; + data [(height_r + 2) * rowstride + 3] = 0; + data [(height_r + 3) * rowstride + 3] = 0; + data [(height_r + 2) * rowstride + 4 + 3] = 0; + data [(height_r + 3) * rowstride + 4 + 3] = 0; return retval; } void -ev_document_misc_get_page_border_size (gint page_width, - gint page_height, - gint *left_border, - gint *right_border, - gint *top_border, - gint *bottom_border) +ev_document_misc_get_page_border_size (gint page_width, + gint page_height, + GtkBorder *border) { - g_assert (left_border); - g_assert (right_border); - g_assert (top_border); - g_assert (bottom_border); + g_assert (border); - *left_border = 1; - *top_border = 1; + border->left = 1; + border->top = 1; if (page_width < 100) { - *right_border = 2; - *bottom_border = 2; + border->right = 2; + border->bottom = 2; } else if (page_width < 500) { - *right_border = 3; - *left_border = 3; + border->right = 3; + border->bottom = 3; } else { - *right_border = 4; - *bottom_border = 4; + border->right = 4; + border->bottom = 4; } } + +void +ev_document_misc_paint_one_page (GdkDrawable *drawable, + GtkWidget *widget, + GdkRectangle *area, + GtkBorder *border, + gboolean highlight) +{ + gdk_draw_rectangle (drawable, + highlight ? + widget->style->text_gc[widget->state] : widget->style->dark_gc[widget->state], + TRUE, + area->x, + area->y, + area->width, + area->height); + gdk_draw_rectangle (drawable, + widget->style->white_gc, + TRUE, + area->x + border->left, + area->y + border->top, + area->width - (border->left + border->right), + area->height - (border->top + border->bottom)); + gdk_draw_rectangle (drawable, + widget->style->mid_gc[widget->state], + TRUE, + area->x, + area->y + area->height - (border->bottom - border->top), + border->bottom - border->top, + border->bottom - border->top); + gdk_draw_rectangle (drawable, + widget->style->mid_gc[widget->state], + TRUE, + area->x + area->width - (border->right - border->left), + area->y, + border->right - border->left, + border->right - border->left); + +}