Commit ccba4f07 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-08-05 Kristian Høgsberg <krh@redhat.com>

        * glib/poppler-page.cc:
        * glib/poppler-page.h:
        * poppler/TextOutputDev.cc:
        * poppler/TextOutputDev.h: Propagate selection colors to the glib API.
parent 43e97129
2005-08-05 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-page.cc:
* glib/poppler-page.h:
* poppler/TextOutputDev.cc:
* poppler/TextOutputDev.h: Propagate selection colors to the glib API.
2005-08-04 Brad Hards <bradh@frogmouth.net>
* poppler/ArthurOutputDev.cc: Fix problem with drawing filled objects
......
......@@ -478,12 +478,35 @@ poppler_page_set_selection_alpha (PopplerPage *page,
#endif
/**
* poppler_page_render_selection:
* @page: the #PopplerPage for which to render selection
* @scale: scale to use for rendering
* @pixbuf: pixbuf to render to
* @selection: start and end point of selection as a rectangle
* @old_selection: previous selection
* @glyph_color: color to use for drawing glyphs
* @background_color: color to use for the selection background
*
* Render the selection specified by @selection for @page into
* @pixbuf. The selection will be rendered at @scale, using
* @glyph_color for the glyphs and @background_color for the selection
* background. The colors are specified as 24 bit words,
* specifically, the red component in bits 16-23, the green component
* in bits 8-15 and the blue component in bits 0-7.
*
* If non-NULL, @old_selection specifies the selection that is already
* rendered in @pixbuf, in which case this function will (some day)
* only render the changed part of the selection.
**/
void
poppler_page_render_selection (PopplerPage *page,
gdouble scale,
GdkPixbuf *pixbuf,
poppler_page_render_selection (PopplerPage *page,
gdouble scale,
GdkPixbuf *pixbuf,
PopplerRectangle *selection,
PopplerRectangle *old_selection)
PopplerRectangle *old_selection,
guint32 glyph_color,
guint32 background_color)
{
TextOutputDev *text_dev;
OutputDev *output_dev;
......@@ -491,12 +514,24 @@ poppler_page_render_selection (PopplerPage *page,
PDFRectangle pdf_selection(selection->x1, selection->y1,
selection->x2, selection->y2);
GfxColor gfx_background_color = {
((background_color >> 16) & 0xff) / 255.0,
((background_color >> 8) & 0xff) / 255.0,
((background_color >> 0) & 0xff) / 255.0
};
GfxColor gfx_glyph_color = {
((glyph_color >> 16) & 0xff) / 255.0,
((glyph_color >> 8) & 0xff) / 255.0,
((glyph_color >> 0) & 0xff) / 255.0
};
text_dev = poppler_page_get_text_output_dev (page);
output_dev = page->document->output_dev;
poppler_page_prepare_output_dev (page, scale, TRUE, &data);
text_dev->drawSelection (output_dev, scale, &pdf_selection);
text_dev->drawSelection (output_dev, scale, &pdf_selection,
&gfx_glyph_color, &gfx_background_color);
poppler_page_copy_to_pixbuf (page, pixbuf, &data);
......@@ -519,6 +554,17 @@ destroy_thumb_data (guchar *pixels, gpointer data)
gfree (pixels);
}
/**
* poppler_page_get_thumbnail:
* @page: the #PopperPage to get the thumbnail for
*
* Get the embedded thumbnail for the specified page. If the document
* doesn't have an embedded thumbnail for the page, this function
* returns %NULL.
*
* Return value: the tumbnail as a #GdkPixbuf or %NULL if the document
* doesn't have a thumbnail for this page.
**/
GdkPixbuf *
poppler_page_get_thumbnail (PopplerPage *page)
{
......@@ -541,9 +587,10 @@ poppler_page_get_thumbnail (PopplerPage *page)
* @width: return location for width
* @height: return location for height
*
* Returns %TRUE if @page has a thumbnail associated with it. It also fills in
* @width and @height with the width and height of the thumbnail. The values of
* width and height are not changed if no appropriate thumbnail exists.
* Returns %TRUE if @page has a thumbnail associated with it. It also
* fills in @width and @height with the width and height of the
* thumbnail. The values of width and height are not changed if no
* appropriate thumbnail exists.
*
* Return value: %TRUE, if @page has a thumbnail associated with it.
**/
......
......@@ -67,7 +67,9 @@ void poppler_page_render_selection (PopplerPage *page,
gdouble scale,
GdkPixbuf *pixbuf,
PopplerRectangle *selection,
PopplerRectangle *old_selection);
PopplerRectangle *old_selection,
guint32 glyph_color,
guint32 background_color);
/* A rectangle on a page, with coordinates in PDF points. */
......
......@@ -29,7 +29,6 @@
#include "GlobalParams.h"
#include "UnicodeMap.h"
#include "UnicodeTypeTable.h"
#include "GfxState.h"
#include "TextOutputDev.h"
#include "Page.h"
......@@ -3195,8 +3194,8 @@ public:
TextSelectionPainter(TextPage *page,
double scale,
OutputDev *out,
GfxColor &box_color,
GfxColor &glyph_color);
GfxColor *box_color,
GfxColor *glyph_color);
~TextSelectionPainter();
virtual void visitBlock (TextBlock *block,
......@@ -3214,15 +3213,15 @@ public:
private:
OutputDev *out;
GfxColor box_color, glyph_color;
GfxColor *box_color, *glyph_color;
GfxState *state;
};
TextSelectionPainter::TextSelectionPainter(TextPage *page,
double scale,
OutputDev *out,
GfxColor &box_color,
GfxColor &glyph_color)
GfxColor *box_color,
GfxColor *glyph_color)
: TextSelectionVisitor(page),
out(out),
box_color(box_color),
......@@ -3256,7 +3255,7 @@ void TextSelectionPainter::visitLine (TextLine *line,
double x1, y1, x2, y2, margin;
int i;
state->setFillColor(&box_color);
state->setFillColor(box_color);
out->updateFillColor(state);
margin = (line->yMax - line->yMin) / 8;
......@@ -3281,7 +3280,7 @@ void TextSelectionPainter::visitWord (TextWord *word, int begin, int end,
GooString *string;
int i;
state->setFillColor(&glyph_color);
state->setFillColor(glyph_color);
out->updateFillColor(state);
state->setFont(word->font->gfxFont, word->fontSize);
out->updateFont(state);
......@@ -3510,10 +3509,9 @@ void TextPage::visitSelection(TextSelectionVisitor *visitor,
void TextPage::drawSelection(OutputDev *out,
double scale,
PDFRectangle *selection)
PDFRectangle *selection,
GfxColor *glyph_color, GfxColor *box_color)
{
GfxColor box_color = { 0x7c / 255.0, 0x99 / 255.0, 0xad / 255.0 };
GfxColor glyph_color = { 1.0, 1.0, 1.0 };
TextSelectionPainter painter(this, scale, out, box_color, glyph_color);
visitSelection(&painter, selection);
......@@ -4082,8 +4080,9 @@ GooString *TextOutputDev::getText(double xMin, double yMin,
void TextOutputDev::drawSelection(OutputDev *out,
double scale,
PDFRectangle *selection) {
text->drawSelection(out, scale, selection);
PDFRectangle *selection,
GfxColor *glyph_color, GfxColor *box_color) {
text->drawSelection(out, scale, selection, glyph_color, box_color);
}
GooList *TextOutputDev::getSelectionRegion(PDFRectangle *selection,
......
......@@ -17,6 +17,7 @@
#include <stdio.h>
#include "goo/gtypes.h"
#include "GfxFont.h"
#include "GfxState.h"
#include "OutputDev.h"
class GooString;
......@@ -424,7 +425,8 @@ public:
void drawSelection(OutputDev *out,
double scale,
PDFRectangle *selection);
PDFRectangle *selection,
GfxColor *glyph_color, GfxColor *box_color);
GooList *getSelectionRegion(PDFRectangle *selection, double scale);
......@@ -584,7 +586,8 @@ public:
double *xMin, double *yMin,
double *xMax, double *yMax);
void drawSelection(OutputDev *out, double scale, PDFRectangle *selection);
void drawSelection(OutputDev *out, double scale, PDFRectangle *selection,
GfxColor *glyph_color, GfxColor *box_color);
GooList *getSelectionRegion(PDFRectangle *selection, double scale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment