Commit 9ad4fefc authored by Claes Sjofors's avatar Claes Sjofors

More gtk print dialog

parent 995e4650
...@@ -1537,7 +1537,7 @@ static void begin_print( GtkPrintOperation *operation, ...@@ -1537,7 +1537,7 @@ static void begin_print( GtkPrintOperation *operation,
wow_sPrintData *print_data = (wow_sPrintData *)user_data; wow_sPrintData *print_data = (wow_sPrintData *)user_data;
int pages; int pages;
brow_PrintGetPages( print_data->brow_ctx, flow_eOrientation_Portrait, &pages); brow_PrintGetPages( print_data->brow_ctx, print_data->orientation, &pages);
gtk_print_operation_set_n_pages( operation, pages); gtk_print_operation_set_n_pages( operation, pages);
} }
...@@ -1557,7 +1557,7 @@ static void draw_page( GtkPrintOperation *operation, ...@@ -1557,7 +1557,7 @@ static void draw_page( GtkPrintOperation *operation,
wow_sPrintData *print_data = (wow_sPrintData *)user_data; wow_sPrintData *print_data = (wow_sPrintData *)user_data;
brow_PrintDrawPage( print_data->brow_ctx, context, print_data->title, page_nr, brow_PrintDrawPage( print_data->brow_ctx, context, print_data->title, page_nr,
flow_eOrientation_Portrait); print_data->orientation);
} }
static void request_page_setup( GtkPrintOperation *operation, static void request_page_setup( GtkPrintOperation *operation,
......
...@@ -78,8 +78,8 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double ...@@ -78,8 +78,8 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double
cairo = gtk_print_context_get_cairo_context (print_ctx); cairo = gtk_print_context_get_cairo_context (print_ctx);
width = gtk_print_context_get_width (print_ctx); width = gtk_print_context_get_width (print_ctx);
cairo_move_to( cairo, 0, 0); cairo_move_to( cairo, print_margin_x, print_margin_y);
cairo_line_to( cairo, width, 0); cairo_line_to( cairo, print_margin_x + width, print_margin_y);
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
cairo_set_line_width( cairo, 0.5); cairo_set_line_width( cairo, 0.5);
cairo_stroke( cairo); cairo_stroke( cairo);
...@@ -98,7 +98,7 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double ...@@ -98,7 +98,7 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double
pango_layout_get_size( layout, NULL, &layout_height); pango_layout_get_size( layout, NULL, &layout_height);
text_height = (gdouble)layout_height / PANGO_SCALE; text_height = (gdouble)layout_height / PANGO_SCALE;
cairo_move_to( cairo, width - 50, -text_height); cairo_move_to( cairo, print_margin_x + width - 90, print_margin_y - text_height);
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout); pango_cairo_show_layout( cairo, layout);
...@@ -117,15 +117,17 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double ...@@ -117,15 +117,17 @@ int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double
pango_layout_get_size( layout, &layout_width, &layout_height); pango_layout_get_size( layout, &layout_width, &layout_height);
text_height = (gdouble)layout_height / PANGO_SCALE; text_height = (gdouble)layout_height / PANGO_SCALE;
cairo_move_to (cairo, width/2 - (gdouble)layout_width/PANGO_SCALE/2, -text_height); cairo_move_to (cairo, print_margin_x + width/2 - (gdouble)layout_width/PANGO_SCALE/2,
print_margin_y - text_height);
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout); pango_cairo_show_layout( cairo, layout);
g_object_unref( layout); g_object_unref( layout);
cairo_rectangle( cairo, 0, 0, (ur_x - ll_x) * ctx->print_zoom_factor, cairo_rectangle( cairo, print_margin_x, print_margin_y, (ur_x - ll_x) * ctx->print_zoom_factor,
(ur_y - ll_y) * ctx->print_zoom_factor); (ur_y - ll_y) * ctx->print_zoom_factor);
//cairo_stroke(cairo);
cairo_clip( cairo); cairo_clip( cairo);
((FlowCtx *)ctx)->current_print = this; ((FlowCtx *)ctx)->current_print = this;
...@@ -171,12 +173,12 @@ int FlowPrintDrawGtk::filled_rect( double x, double y, double width, double heig ...@@ -171,12 +173,12 @@ int FlowPrintDrawGtk::filled_rect( double x, double y, double width, double heig
default: default:
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
} }
cairo_rectangle( cairo, x - page_x, y - page_y, width, height); cairo_rectangle( cairo, print_margin_x + x - page_x, print_margin_y + y - page_y, width, height);
cairo_fill( cairo); cairo_fill( cairo);
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
cairo_set_line_width( cairo, 0.5 * idx); cairo_set_line_width( cairo, 0.5 * idx);
cairo_rectangle( cairo, x - page_x, y - page_y, width, height); cairo_rectangle( cairo, print_margin_x + x - page_x, print_margin_y + y - page_y, width, height);
cairo_stroke( cairo); cairo_stroke( cairo);
return 1; return 1;
...@@ -223,7 +225,7 @@ int FlowPrintDrawGtk::text( double x, double y, char *text, int len, flow_eDrawT ...@@ -223,7 +225,7 @@ int FlowPrintDrawGtk::text( double x, double y, char *text, int len, flow_eDrawT
pango_layout_set_text( layout, textutf8, -1); pango_layout_set_text( layout, textutf8, -1);
pango_layout_set_alignment( layout, PANGO_ALIGN_LEFT); pango_layout_set_alignment( layout, PANGO_ALIGN_LEFT);
pango_layout_get_size( layout, &w, &h); pango_layout_get_size( layout, &w, &h);
cairo_move_to( cairo, x - page_x, y - page_y - 0.8 / PANGO_SCALE * h); cairo_move_to( cairo, print_margin_x + x - page_x, print_margin_y + y - page_y - 0.8 / PANGO_SCALE * h);
cairo_set_source_rgb( cairo, 0, 0, 0); cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout); pango_cairo_show_layout( cairo, layout);
g_free( textutf8); g_free( textutf8);
...@@ -272,7 +274,7 @@ int FlowPrintDrawGtk::pixmap( double x, double y, flow_sPixmapDataElem *data, ...@@ -272,7 +274,7 @@ int FlowPrintDrawGtk::pixmap( double x, double y, flow_sPixmapDataElem *data,
data->height, stride); data->height, stride);
cairo_scale( cairo, scale, scale); cairo_scale( cairo, scale, scale);
//cairo_mask_surface( cairo, surface, (x - page_x)/scale, (y - page_y)/scale); //cairo_mask_surface( cairo, surface, (x - page_x)/scale, (y - page_y)/scale);
cairo_set_source_surface( cairo, surface, (x - page_x)/scale, (y - page_y)/scale); cairo_set_source_surface( cairo, surface, (print_margin_x + x - page_x)/scale, (print_margin_y + y - page_y)/scale);
cairo_paint( cairo); cairo_paint( cairo);
cairo_scale( cairo, 1.0 / scale, 1.0 / scale); cairo_scale( cairo, 1.0 / scale, 1.0 / scale);
......
...@@ -232,7 +232,7 @@ void BrowCtx::print_draw_page( void *context, const char *title, int page, ...@@ -232,7 +232,7 @@ void BrowCtx::print_draw_page( void *context, const char *title, int page,
height = 60 * (ur_y - ll_y); height = 60 * (ur_y - ll_y);
width = 0.70 * height; width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) { if ( orientation == flow_eOrientation_Landscape) {
height = 40 * ( ur_y - ll_y); height = 35 * ( ur_y - ll_y);
width = height / 0.70; width = height / 0.70;
} }
...@@ -265,7 +265,7 @@ void BrowCtx::print_get_pages( flow_eOrientation orientation, int *pages) ...@@ -265,7 +265,7 @@ void BrowCtx::print_get_pages( flow_eOrientation orientation, int *pages)
width = 0.70 * height; width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) { if ( orientation == flow_eOrientation_Landscape) {
// Portrait // Portrait
height = 40 * ( ur_y - ll_y); height = 35 * ( ur_y - ll_y);
width = height / 0.70; width = height / 0.70;
} }
......
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
class FlowPrintDraw : public FlowPrint { class FlowPrintDraw : public FlowPrint {
public: public:
FlowPrintDraw() {} double print_margin_x;
double print_margin_y;
FlowPrintDraw() : print_margin_x(40), print_margin_y(40) {}
virtual ~FlowPrintDraw() {} virtual ~FlowPrintDraw() {}
virtual int print_page( double ll_x, double ll_y, double ur_x, double ur_y) {return 1;} virtual int print_page( double ll_x, double ll_y, double ur_x, double ur_y) {return 1;}
virtual int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight) {return 1;} virtual int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight) {return 1;}
......
...@@ -113,7 +113,7 @@ void EvListGtk::print( const char *title) ...@@ -113,7 +113,7 @@ void EvListGtk::print( const char *title)
} }
CoWowGtk::CreateBrowPrintDialogGtk( print_title, brow->ctx, flow_eOrientation_Landscape, CoWowGtk::CreateBrowPrintDialogGtk( print_title, brow->ctx, flow_eOrientation_Landscape,
GTK_WINDOW(parent_wid), &sts); 0 /* GTK_WINDOW(parent_wid) */, &sts);
if ( sts == WOW__PRINTDIALOGDISABLED) { if ( sts == WOW__PRINTDIALOGDISABLED) {
pwr_tFileName filename; pwr_tFileName filename;
pwr_tCmd cmd; pwr_tCmd cmd;
......
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