diff options
Diffstat (limited to 'frontends/riscos/print.c')
-rw-r--r-- | frontends/riscos/print.c | 316 |
1 files changed, 189 insertions, 127 deletions
diff --git a/frontends/riscos/print.c b/frontends/riscos/print.c index 465627eea..b390c693d 100644 --- a/frontends/riscos/print.c +++ b/frontends/riscos/print.c @@ -41,6 +41,7 @@ #include "content/content.h" #include "riscos/gui.h" +#include "riscos/window.h" #include "riscos/dialog.h" #include "riscos/menus.h" #include "riscos/print.h" @@ -95,7 +96,6 @@ static unsigned int print_fonts_count; /** Error in print_fonts_plot_text() or print_fonts_callback(). */ static const char *print_fonts_error; -void gui_window_redraw_window(struct gui_window *g); static bool ro_gui_print_click(wimp_pointer *pointer); static bool ro_gui_print_apply(wimp_w w); @@ -104,39 +104,12 @@ static void print_send_printsave(struct hlcache_handle *h); static bool print_send_printtypeknown(wimp_message *m); static bool print_document(struct gui_window *g, const char *filename); static const char *print_declare_fonts(struct hlcache_handle *h); -static bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); -static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style); -static bool print_fonts_plot_polygon(const int *p, unsigned int n, const plot_style_t *style); -static bool print_fonts_plot_clip(const struct rect *clip); -static bool print_fonts_plot_text(int x, int y, const char *text, size_t length, - const plot_font_style_t *fstyle); -static bool print_fonts_plot_disc(int x, int y, int radius, const plot_style_t *style); -static bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style); -static bool print_fonts_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, - bitmap_flags_t flags); -static bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width, - colour c, const float transform[6]); static void print_fonts_callback(void *context, const char *font_name, unsigned int font_size, const char *s8, unsigned short *s16, unsigned int n, int x, int y); -/** Plotter for print_declare_fonts(). All the functions do nothing except for - * print_fonts_plot_text, which records the fonts used. */ -static const struct plotter_table print_fonts_plotters = { - .rectangle = print_fonts_plot_rectangle, - .line = print_fonts_plot_line, - .polygon = print_fonts_plot_polygon, - .clip = print_fonts_plot_clip, - .text = print_fonts_plot_text, - .disc = print_fonts_plot_disc, - .arc = print_fonts_plot_arc, - .bitmap = print_fonts_plot_bitmap, - .path = print_fonts_plot_path, - .option_knockout = false, -}; /** @@ -196,7 +169,8 @@ void ro_gui_print_prepare(struct gui_window *g) /* Read Printer Driver name */ error = xpdriver_info(0, 0, 0, 0, &desc, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); printers_exists = false; } @@ -333,7 +307,8 @@ void print_send_printsave(struct hlcache_handle *h) e = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, (wimp_message *)&m, 0); if (e) { - LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + e->errnum, e->errmess); ro_warn_user("WimpError", e->errmess); ro_print_cleanup(); } @@ -357,7 +332,8 @@ bool print_send_printtypeknown(wimp_message *m) m->action = message_PRINT_TYPE_KNOWN; e = xwimp_send_message(wimp_USER_MESSAGE, m, m->sender); if (e) { - LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + e->errnum, e->errmess); ro_warn_user("WimpError", e->errmess); return false; } @@ -463,7 +439,8 @@ bool ro_print_ack(wimp_message *m) /* read printer driver type */ error = xpdriver_info(&info_type, 0, 0, 0, 0, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); ro_print_cleanup(); return true; @@ -488,7 +465,8 @@ bool ro_print_ack(wimp_message *m) error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, m, m->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); /* and delete temporary file */ xosfile_delete(m->data.data_xfer.file_name, @@ -560,7 +538,8 @@ bool print_document(struct gui_window *g, const char *filename) /* read printer driver features */ error = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -568,7 +547,8 @@ bool print_document(struct gui_window *g, const char *filename) /* read page size */ error = xpdriver_page_size(0, 0, &left, &bottom, &right, &top); if (error) { - LOG("xpdriver_page_size: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_page_size: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -591,7 +571,8 @@ bool print_document(struct gui_window *g, const char *filename) error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR | osfind_ERROR_IF_ABSENT, filename, 0, &fhandle); if (error) { - LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -599,7 +580,8 @@ bool print_document(struct gui_window *g, const char *filename) /* select print job */ error = xpdriver_select_jobw(fhandle, "NetSurf", &old_job); if (error) { - LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_select_jobw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); xosfind_closew(fhandle); return false; @@ -659,18 +641,23 @@ bool print_document(struct gui_window *g, const char *filename) /* give page rectangle */ error = xpdriver_give_rectangle(0, &b, &t, &p, os_COLOUR_WHITE); if (error) { - LOG("xpdriver_give_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_give_rectangle: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto error; } - LOG("given rectangle: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1); + NSLOG(netsurf, INFO, "given rectangle: [(%d, %d), (%d, %d)]", + b.x0, b.y0, b.x1, b.y1); /* and redraw the document */ error = xpdriver_draw_page(print_num_copies, &b, 0, 0, &more, 0); if (error) { - LOG("xpdriver_draw_page: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_draw_page: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto error; } @@ -684,7 +671,9 @@ bool print_document(struct gui_window *g, const char *filename) .plot = &ro_plotters }; - LOG("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1); + NSLOG(netsurf, INFO, + "redrawing area: [(%d, %d), (%d, %d)]", b.x0, + b.y0, b.x1, b.y1); clip.x0 = (b.x0 - ro_plot_origin_x) / 2; clip.y0 = (ro_plot_origin_y - b.y1) / 2; clip.x1 = (b.x1 - ro_plot_origin_x) / 2; @@ -706,7 +695,10 @@ bool print_document(struct gui_window *g, const char *filename) error = xpdriver_get_rectangle(&b, &more, 0); if (error) { - LOG("xpdriver_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_get_rectangle: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto error; } @@ -728,14 +720,16 @@ bool print_document(struct gui_window *g, const char *filename) error = (os_error *) _swix(PDriver_EndJob, _IN(0), (int) fhandle); if (error) { - LOG("xpdriver_end_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_end_jobw: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto error; } error = xosfind_closew(fhandle); if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -743,7 +737,10 @@ bool print_document(struct gui_window *g, const char *filename) if (old_job) { error = xpdriver_select_jobw(old_job, 0, 0); if (error) { - LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_select_jobw: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("PrintError", error->errmess); /* the printing succeeded anyway */ return true; @@ -756,7 +753,7 @@ bool print_document(struct gui_window *g, const char *filename) if (content_get_type(h) == CONTENT_HTML) content_reformat(h, false, saved_width, saved_height); - gui_window_redraw_window(g); + ro_gui_window_invalidate_area(g, NULL); return true; @@ -780,6 +777,145 @@ error: } + + +static nserror +print_fonts_plot_clip(const struct redraw_context *ctx, const struct rect *clip) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_arc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius, int angle1, int angle2) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_disc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_line(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *line) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_rectangle(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *rect) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_polygon(const struct redraw_context *ctx, + const plot_style_t *style, + const int *p, + unsigned int n) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_path(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const float *p, + unsigned int n, + const float transform[6]) +{ + return NSERROR_OK; +} + +static nserror +print_fonts_plot_bitmap(const struct redraw_context *ctx, + struct bitmap *bitmap, + int x, int y, + int width, + int height, + colour bg, + bitmap_flags_t flags) +{ + return NSERROR_OK; +} + +/** + * text plotting during RO print font listing. + * + * \param ctx The current redraw context. + * \param fstyle plot style for this text + * \param x x coordinate + * \param y y coordinate + * \param text UTF-8 string to plot + * \param length length of string, in bytes + * \return NSERROR_OK on success else error code. + */ +static nserror +print_fonts_plot_text(const struct redraw_context *ctx, + const struct plot_font_style *fstyle, + int x, + int y, + const char *text, + size_t length) +{ + const char *font_family; + unsigned int font_size; + rufl_style font_style; + rufl_code code; + + nsfont_read_style(fstyle, &font_family, &font_size, &font_style); + + code = rufl_paint_callback(font_family, font_style, font_size, + text, length, 0, 0, print_fonts_callback, 0); + if (code != rufl_OK) { + if (code == rufl_FONT_MANAGER_ERROR) { + NSLOG(netsurf, INFO, + "rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); + print_fonts_error = rufl_fm_error->errmess; + } else { + NSLOG(netsurf, INFO, "rufl_paint_callback: 0x%x", + code); + } + return NSERROR_INVALID; + } + if (print_fonts_error) + return NSERROR_INVALID; + + return NSERROR_OK; +} + + +/** + * Plotter table for print_declare_fonts(). + * + * All the functions do nothing except for print_fonts_plot_text, + * which records the fonts used. +*/ +static const struct plotter_table print_fonts_plotters = { + .rectangle = print_fonts_plot_rectangle, + .line = print_fonts_plot_line, + .polygon = print_fonts_plot_polygon, + .clip = print_fonts_plot_clip, + .text = print_fonts_plot_text, + .disc = print_fonts_plot_disc, + .arc = print_fonts_plot_arc, + .bitmap = print_fonts_plot_bitmap, + .path = print_fonts_plot_path, + .option_knockout = false, +}; + + /** * Declare fonts to the printer driver. * @@ -824,18 +960,22 @@ const char *print_declare_fonts(struct hlcache_handle *h) } for (i = 0; i != print_fonts_count; ++i) { - LOG("%u %s", i, print_fonts_list[i]); + NSLOG(netsurf, INFO, "%u %s", i, print_fonts_list[i]); error = xpdriver_declare_font(0, print_fonts_list[i], pdriver_KERNED); if (error) { - LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_declare_font: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto end; } } error = xpdriver_declare_font(0, 0, 0); if (error) { - LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_declare_font: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto end; } @@ -850,84 +990,6 @@ end: } -bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) -{ - return true; -} - - -bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) -{ - return true; -} - -bool print_fonts_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) -{ - return true; -} - - -bool print_fonts_plot_clip(const struct rect *clip) -{ - return true; -} - -bool print_fonts_plot_disc(int x, int y, int radius, const plot_style_t *style) -{ - return true; -} - -bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2, - const plot_style_t *style) -{ - return true; -} - -bool print_fonts_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, bitmap_flags_t flags) -{ - return true; -} - -bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width, - colour c, const float transform[6]) -{ - return true; -} - - -/** - * Plotter for text plotting during font listing. - */ - -bool print_fonts_plot_text(int x, int y, const char *text, size_t length, - const plot_font_style_t *fstyle) -{ - const char *font_family; - unsigned int font_size; - rufl_style font_style; - rufl_code code; - - nsfont_read_style(fstyle, &font_family, &font_size, &font_style); - - code = rufl_paint_callback(font_family, font_style, font_size, - text, length, 0, 0, print_fonts_callback, 0); - if (code != rufl_OK) { - if (code == rufl_FONT_MANAGER_ERROR) { - LOG("rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); - print_fonts_error = rufl_fm_error->errmess; - } else { - LOG("rufl_paint_callback: 0x%x", code); - } - return false; - } - if (print_fonts_error) - return false; - - return true; -} - - /** * Callback for print_fonts_plot_text(). * |