NetSurf
|
#include "utils/config.h"
#include <assert.h>
#include <string.h>
#include <swis.h>
#include <oslib/font.h>
#include <oslib/hourglass.h>
#include <oslib/osfile.h>
#include <oslib/osfind.h>
#include <oslib/pdriver.h>
#include <oslib/wimp.h>
#include <rufl.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "netsurf/browser_window.h"
#include "netsurf/plotters.h"
#include "netsurf/content.h"
#include "content/content.h"
#include "riscos/gui.h"
#include "riscos/window.h"
#include "riscos/dialog.h"
#include "riscos/menus.h"
#include "riscos/print.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/filetype.h"
#include "riscos/font.h"
Go to the source code of this file.
Macros | |
#define | ICON_PRINT_TO_BOTTOM 1 |
#define | ICON_PRINT_SHEETS 2 |
#define | ICON_PRINT_SHEETS_VALUE 3 |
#define | ICON_PRINT_SHEETS_DOWN 4 |
#define | ICON_PRINT_SHEETS_UP 5 |
#define | ICON_PRINT_SHEETS_TEXT 6 |
#define | ICON_PRINT_FG_IMAGES 7 |
#define | ICON_PRINT_BG_IMAGES 8 |
#define | ICON_PRINT_IN_BACKGROUND 9 |
#define | ICON_PRINT_UPRIGHT 10 |
#define | ICON_PRINT_SIDEWAYS 11 |
#define | ICON_PRINT_COPIES 12 |
#define | ICON_PRINT_COPIES_DOWN 13 |
#define | ICON_PRINT_COPIES_UP 14 |
#define | ICON_PRINT_CANCEL 15 |
#define | ICON_PRINT_PRINT 16 |
#define | ICON_PRINT_TEXT_BLACK 20 |
Functions | |
static bool | ro_gui_print_click (wimp_pointer *pointer) |
Handle mouse clicks in print dialog. More... | |
static bool | ro_gui_print_apply (wimp_w w) |
Handle click on the Print button in the print dialog. More... | |
static void | print_update_sheets_shaded_state (bool on) |
Set shaded state of sheets. More... | |
static void | print_send_printsave (struct hlcache_handle *h) |
Send a message_PRINT_SAVE. More... | |
static bool | print_send_printtypeknown (wimp_message *m) |
Send a message_PRINT_TYPE_KNOWN. More... | |
static bool | print_document (struct gui_window *g, const char *filename) |
Print a document. More... | |
static const char * | print_declare_fonts (struct hlcache_handle *h) |
Declare fonts to the printer driver. More... | |
static void | print_fonts_callback (void *context, const char *font_name, unsigned int font_size, const uint8_t *s8, const uint32_t *s32, unsigned int n, int x, int y) |
Callback for print_fonts_plot_text(). More... | |
void | ro_gui_print_init (void) |
Initialise the print dialog. More... | |
void | ro_gui_print_prepare (struct gui_window *g) |
Prepares all aspects of the print dialog prior to opening. More... | |
void | ro_print_save_bounce (wimp_message *m) |
Handle a bounced message_PRINT_SAVE. More... | |
void | ro_print_error (wimp_message *m) |
Handle message_PRINT_ERROR. More... | |
void | ro_print_type_odd (wimp_message *m) |
Handle message_PRINT_TYPE_ODD. More... | |
bool | ro_print_ack (wimp_message *m) |
Handle message_DATASAVE_ACK for the printing protocol. More... | |
void | ro_print_dataload_bounce (wimp_message *m) |
Handle a bounced dataload message. More... | |
void | ro_print_cleanup (void) |
Cleanup after printing. More... | |
static nserror | print_fonts_plot_clip (const struct redraw_context *ctx, const struct rect *clip) |
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) |
static nserror | print_fonts_plot_disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius) |
static nserror | print_fonts_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) |
static nserror | print_fonts_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) |
static nserror | print_fonts_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n) |
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]) |
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) |
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) |
text plotting during RO print font listing. More... | |
Variables | |
struct gui_window * | ro_print_current_window = NULL |
bool | print_text_black = false |
bool | print_active = false |
static int | print_prev_message = 0 |
static bool | print_in_background = false |
static float | print_scale = 1.0 |
static int | print_num_copies = 1 |
static bool | print_bg_images = false |
static int | print_max_sheets = -1 |
static bool | print_sideways = false |
static char ** | print_fonts_list = 0 |
List of fonts in current print. More... | |
static unsigned int | print_fonts_count |
Number of entries in print_fonts_list. More... | |
static const char * | print_fonts_error |
Error in print_fonts_plot_text() or print_fonts_callback(). More... | |
static const struct plotter_table | print_fonts_plotters |
Plotter table for print_declare_fonts(). More... | |
|
static |
Declare fonts to the printer driver.
h | handle to content being printed |
Definition at line 926 of file print.c.
References content_redraw_data::background_colour, clip(), content_get_height(), content_get_width(), content_redraw(), content_redraw_data::height, redraw_context::interactive, NSLOG, print_fonts_count, print_fonts_error, print_fonts_list, print_fonts_plotters, content_redraw_data::repeat_x, content_redraw_data::repeat_y, content_redraw_data::scale, content_redraw_data::width, content_redraw_data::x, and content_redraw_data::y.
Referenced by print_document().
|
static |
Print a document.
g | gui_window containing the document to print |
filename | name of file to print to |
Definition at line 521 of file print.c.
References content_redraw_data::background_colour, browser_window_get_content(), gui_window::bw, clip(), content_get_height(), content_get_type(), content_get_width(), CONTENT_HTML, content_redraw(), content_reformat(), height, content_redraw_data::height, redraw_context::interactive, NSLOG, print_active, print_bg_images, print_declare_fonts(), print_max_sheets, print_num_copies, print_scale, print_sideways, content_redraw_data::repeat_x, content_redraw_data::repeat_y, ro_gui_current_redraw_gui, ro_gui_window_invalidate_area(), ro_plot_origin_x, ro_plot_origin_y, ro_plotters, ro_warn_user(), content_redraw_data::scale, width, content_redraw_data::width, content_redraw_data::x, and content_redraw_data::y.
Referenced by ro_print_ack(), ro_print_save_bounce(), and ro_print_type_odd().
|
static |
Callback for print_fonts_plot_text().
The font name is added to print_fonts_list.
Definition at line 999 of file print.c.
References messages_get(), print_fonts_count, print_fonts_error, and print_fonts_list.
Referenced by print_fonts_plot_text().
|
static |
Definition at line 789 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 840 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 783 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 797 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 805 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 830 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 821 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 813 of file print.c.
References NSERROR_OK.
|
static |
text plotting during RO print font listing.
ctx | The current redraw context. |
fstyle | plot style for this text |
x | x coordinate |
y | y coordinate |
text | UTF-8 string to plot |
length | length of string, in bytes |
Definition at line 863 of file print.c.
References NSERROR_INVALID, NSERROR_OK, nsfont_read_style(), NSLOG, print_fonts_callback(), print_fonts_error, and text().
|
static |
Send a message_PRINT_SAVE.
h | handle to content to print. |
Definition at line 288 of file print.c.
References content_get_title(), NSLOG, print_prev_message, ro_content_filetype(), ro_print_cleanup(), and ro_warn_user().
Referenced by ro_gui_print_apply().
|
static |
Send a message_PRINT_TYPE_KNOWN.
m | message to reply to |
Definition at line 326 of file print.c.
References NSLOG, and ro_warn_user().
Referenced by ro_print_type_odd().
|
static |
Set shaded state of sheets.
on | whether to turn shading on or off |
Definition at line 272 of file print.c.
References dialog_print, ICON_PRINT_SHEETS_DOWN, ICON_PRINT_SHEETS_TEXT, ICON_PRINT_SHEETS_UP, ICON_PRINT_SHEETS_VALUE, ro_gui_set_caret_first(), and ro_gui_set_icon_shaded_state().
Referenced by ro_gui_print_click(), and ro_gui_print_prepare().
|
static |
Handle click on the Print button in the print dialog.
Definition at line 238 of file print.c.
References browser_window_get_content(), gui_window::bw, dialog_print, ICON_PRINT_BG_IMAGES, ICON_PRINT_COPIES, ICON_PRINT_IN_BACKGROUND, ICON_PRINT_SHEETS, ICON_PRINT_SHEETS_VALUE, ICON_PRINT_SIDEWAYS, ICON_PRINT_TEXT_BLACK, print_bg_images, print_in_background, print_max_sheets, print_num_copies, print_send_printsave(), print_sideways, print_text_black, ro_gui_get_icon_selected_state(), ro_gui_get_icon_string(), and ro_print_current_window.
Referenced by ro_gui_print_init().
|
static |
Handle mouse clicks in print dialog.
pointer | wimp_pointer block |
Definition at line 218 of file print.c.
References ICON_PRINT_SHEETS, ICON_PRINT_TO_BOTTOM, and print_update_sheets_shaded_state().
Referenced by ro_gui_print_init().
void ro_gui_print_init | ( | void | ) |
Initialise the print dialog.
Definition at line 119 of file print.c.
References dialog_print, ICON_PRINT_BG_IMAGES, ICON_PRINT_CANCEL, ICON_PRINT_COPIES, ICON_PRINT_COPIES_DOWN, ICON_PRINT_COPIES_UP, ICON_PRINT_FG_IMAGES, ICON_PRINT_IN_BACKGROUND, ICON_PRINT_PRINT, ICON_PRINT_SHEETS, ICON_PRINT_SHEETS_DOWN, ICON_PRINT_SHEETS_TEXT, ICON_PRINT_SHEETS_UP, ICON_PRINT_SHEETS_VALUE, ICON_PRINT_SIDEWAYS, ICON_PRINT_TEXT_BLACK, ICON_PRINT_TO_BOTTOM, ICON_PRINT_UPRIGHT, ro_gui_dialog_create(), ro_gui_print_apply(), ro_gui_print_click(), ro_gui_wimp_event_register_cancel(), ro_gui_wimp_event_register_checkbox(), ro_gui_wimp_event_register_mouse_click(), ro_gui_wimp_event_register_numeric_field(), ro_gui_wimp_event_register_ok(), ro_gui_wimp_event_register_radio(), ro_gui_wimp_event_register_text_field(), and ro_gui_wimp_event_set_help_prefix().
Referenced by ro_gui_dialog_init().
void ro_gui_print_prepare | ( | struct gui_window * | g | ) |
Prepares all aspects of the print dialog prior to opening.
g | parent window |
Definition at line 158 of file print.c.
References dialog_print, ICON_PRINT_BG_IMAGES, ICON_PRINT_COPIES, ICON_PRINT_FG_IMAGES, ICON_PRINT_IN_BACKGROUND, ICON_PRINT_PRINT, ICON_PRINT_SHEETS, ICON_PRINT_SHEETS_VALUE, ICON_PRINT_SIDEWAYS, ICON_PRINT_TEXT_BLACK, ICON_PRINT_TO_BOTTOM, ICON_PRINT_UPRIGHT, NSLOG, print_bg_images, print_prev_message, print_update_sheets_shaded_state(), ro_gui_set_icon_integer(), ro_gui_set_icon_selected_state(), ro_gui_set_icon_shaded_state(), ro_gui_set_window_title(), ro_gui_wimp_event_memorise(), and ro_print_current_window.
Referenced by ro_gui_window_action_print(), and ro_gui_window_menu_warning().
bool ro_print_ack | ( | wimp_message * | m | ) |
Handle message_DATASAVE_ACK for the printing protocol.
m | the message to handle |
We cheat here and, instead of giving Printers what it asked for (a copy of the file so it can poke us later via a broadcast of PrintTypeOdd), we give it a file that it can print itself without having to bother us further. For PostScript printers (type 0) we give it a PostScript file. Otherwise, we give it a PrintOut file.
This method has a couple of advantages:
Definition at line 429 of file print.c.
References NSLOG, print_document(), print_prev_message, ro_print_cleanup(), ro_print_current_window, ro_warn_user(), and type.
Referenced by ro_msg_datasave_ack().
void ro_print_cleanup | ( | void | ) |
Cleanup after printing.
Definition at line 502 of file print.c.
References dialog_print, print_max_sheets, print_prev_message, print_text_black, ro_gui_dialog_close(), ro_gui_menu_destroy(), and ro_print_current_window.
Referenced by print_send_printsave(), ro_gui_user_message(), ro_print_ack(), ro_print_dataload_bounce(), ro_print_error(), ro_print_save_bounce(), and ro_print_type_odd().
void ro_print_dataload_bounce | ( | wimp_message * | m | ) |
Handle a bounced dataload message.
m | the message to handle |
Definition at line 488 of file print.c.
References print_prev_message, and ro_print_cleanup().
Referenced by ro_gui_user_message().
void ro_print_error | ( | wimp_message * | m | ) |
Handle message_PRINT_ERROR.
m | the message containing the error |
Definition at line 370 of file print.c.
References print_prev_message, ro_print_cleanup(), and ro_warn_user().
Referenced by ro_gui_user_message().
void ro_print_save_bounce | ( | wimp_message * | m | ) |
Handle a bounced message_PRINT_SAVE.
m | the bounced message |
Definition at line 351 of file print.c.
References print_document(), print_prev_message, ro_print_cleanup(), and ro_print_current_window.
Referenced by ro_gui_user_message().
void ro_print_type_odd | ( | wimp_message * | m | ) |
Handle message_PRINT_TYPE_ODD.
m | the message to handle |
Definition at line 391 of file print.c.
References print_document(), print_in_background, print_prev_message, print_send_printtypeknown(), ro_print_cleanup(), and ro_print_current_window.
Referenced by ro_gui_user_message().
bool print_active = false |
Definition at line 81 of file print.c.
Referenced by image_redraw_tinct(), nsfont_paint(), and print_document().
|
static |
Definition at line 89 of file print.c.
Referenced by print_document(), ro_gui_print_apply(), and ro_gui_print_prepare().
|
static |
Number of entries in print_fonts_list.
Definition at line 95 of file print.c.
Referenced by print_declare_fonts(), and print_fonts_callback().
|
static |
Error in print_fonts_plot_text() or print_fonts_callback().
Definition at line 97 of file print.c.
Referenced by print_declare_fonts(), print_fonts_callback(), and print_fonts_plot_text().
|
static |
List of fonts in current print.
Definition at line 93 of file print.c.
Referenced by print_declare_fonts(), and print_fonts_callback().
|
static |
Plotter table for print_declare_fonts().
All the functions do nothing except for print_fonts_plot_text, which records the fonts used.
Definition at line 905 of file print.c.
Referenced by print_declare_fonts().
|
static |
Definition at line 86 of file print.c.
Referenced by ro_gui_print_apply(), and ro_print_type_odd().
|
static |
Definition at line 90 of file print.c.
Referenced by print_document(), ro_gui_print_apply(), and ro_print_cleanup().
|
static |
Definition at line 88 of file print.c.
Referenced by print_document(), and ro_gui_print_apply().
|
static |
Definition at line 85 of file print.c.
Referenced by print_send_printsave(), ro_gui_print_prepare(), ro_print_ack(), ro_print_cleanup(), ro_print_dataload_bounce(), ro_print_error(), ro_print_save_bounce(), and ro_print_type_odd().
|
static |
Definition at line 87 of file print.c.
Referenced by ami_print(), ami_print_event(), ami_print_ui(), and print_document().
|
static |
Definition at line 91 of file print.c.
Referenced by print_document(), and ro_gui_print_apply().
bool print_text_black = false |
Definition at line 80 of file print.c.
Referenced by ro_gui_print_apply(), and ro_print_cleanup().
struct gui_window* ro_print_current_window = NULL |
landscape format pages
be somewhat more intelligent and try not to crop pages half way up a line of text
make use of print stylesheets
Definition at line 79 of file print.c.
Referenced by ro_gui_print_apply(), ro_gui_print_prepare(), ro_gui_user_message(), ro_print_ack(), ro_print_cleanup(), ro_print_save_bounce(), and ro_print_type_odd().