25#include <oslib/font.h>
26#include <oslib/hourglass.h>
27#include <oslib/osfile.h>
28#include <oslib/osfind.h>
29#include <oslib/pdriver.h>
30#include <oslib/wimp.h>
54#define ICON_PRINT_TO_BOTTOM 1
55#define ICON_PRINT_SHEETS 2
56#define ICON_PRINT_SHEETS_VALUE 3
57#define ICON_PRINT_SHEETS_DOWN 4
58#define ICON_PRINT_SHEETS_UP 5
59#define ICON_PRINT_SHEETS_TEXT 6
60#define ICON_PRINT_FG_IMAGES 7
61#define ICON_PRINT_BG_IMAGES 8
62#define ICON_PRINT_IN_BACKGROUND 9
63#define ICON_PRINT_UPRIGHT 10
64#define ICON_PRINT_SIDEWAYS 11
65#define ICON_PRINT_COPIES 12
66#define ICON_PRINT_COPIES_DOWN 13
67#define ICON_PRINT_COPIES_UP 14
68#define ICON_PRINT_CANCEL 15
69#define ICON_PRINT_PRINT 16
70#define ICON_PRINT_TEXT_BLACK 20
108 const char *font_name,
unsigned int font_size,
109 const uint8_t *s8,
const uint32_t *s32,
unsigned int n,
161 bool printers_exists =
true;
170 error = xpdriver_info(0, 0, 0, 0, &desc, 0, 0, 0);
172 NSLOG(netsurf, INFO,
"xpdriver_info: 0x%x: %s",
173 error->errnum, error->errmess);
174 printers_exists =
false;
220 if (pointer->buttons == wimp_CLICK_MENU)
223 switch (pointer->i) {
290 wimp_full_message_data_xfer m;
298 m.size = ((44+len+3) & ~3);
300 m.action = message_PRINT_SAVE;
302 m.i = m.pos.x = m.pos.y = 0;
306 m.file_name[211] = 0;
307 e = xwimp_send_message(wimp_USER_MESSAGE_RECORDED,
308 (wimp_message *)&m, 0);
310 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
311 e->errnum, e->errmess);
331 m->your_ref = m->my_ref;
332 m->action = message_PRINT_TYPE_KNOWN;
333 e = xwimp_send_message(wimp_USER_MESSAGE, m, m->sender);
335 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
336 e->errnum, e->errmess);
372 pdriver_message_print_error *p = (pdriver_message_print_error*)&m->data;
431 pdriver_info_type info_type;
440 error = xpdriver_info(&info_type, 0, 0, 0, 0, 0, 0, 0);
442 NSLOG(netsurf, INFO,
"xpdriver_info: 0x%x: %s",
443 error->errnum, error->errmess);
448 type = info_type >> 16;
452 m->data.data_xfer.file_name)) {
458 m->your_ref = m->my_ref;
459 m->action = message_DATA_LOAD;
461 if (
type == pdriver_TYPE_PS)
462 m->data.data_xfer.file_type = osfile_TYPE_POSTSCRIPT;
464 m->data.data_xfer.file_type = osfile_TYPE_PRINTOUT;
466 error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, m, m->sender);
468 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
469 error->errnum, error->errmess);
472 xosfile_delete(m->data.data_xfer.file_name,
493 xosfile_delete(m->data.data_xfer.file_name, 0, 0, 0, 0, 0);
524 int saved_width, saved_height;
527 const char *error_message;
528 pdriver_features features;
529 os_fw fhandle, old_job = 0;
539 error = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0);
541 NSLOG(netsurf, INFO,
"xpdriver_info: 0x%x: %s",
542 error->errnum, error->errmess);
548 error = xpdriver_page_size(0, 0, &left, &bottom, &right, &top);
550 NSLOG(netsurf, INFO,
"xpdriver_page_size: 0x%x: %s",
551 error->errnum, error->errmess);
557 width = (top - bottom) / 800;
558 height = (right - left) / 800;
560 width = (right - left) / 800;
561 height = (top - bottom) / 800;
571 error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR |
572 osfind_ERROR_IF_ABSENT, filename, 0, &fhandle);
574 NSLOG(netsurf, INFO,
"xosfind_openoutw: 0x%x: %s",
575 error->errnum, error->errmess);
581 error = xpdriver_select_jobw(fhandle,
"NetSurf", &old_job);
583 NSLOG(netsurf, INFO,
"xpdriver_select_jobw: 0x%x: %s",
584 error->errnum, error->errmess);
586 xosfind_closew(fhandle);
590 rufl_invalidate_cache();
593 if (features & pdriver_FEATURE_DECLARE_FONT) {
611 b.x0 = bottom / 400 -2;
612 b.y0 = left / 400 - 2;
613 b.x1 = top / 400 + 2;
614 b.y1 = right / 400 + 2;
616 t.entries[0][1] = 65536;
617 t.entries[1][0] = -65536;
624 b.x0 = left / 400 -2;
625 b.y0 = bottom / 400 - 2;
626 b.x1 = right / 400 + 2;
627 b.y1 = top / 400 + 2;
628 t.entries[0][0] = 65536;
631 t.entries[1][1] = 65536;
638 xhourglass_percentage((
int) (yscroll * 100 /
642 error = xpdriver_give_rectangle(0, &b, &t, &p, os_COLOUR_WHITE);
645 "xpdriver_give_rectangle: 0x%x: %s",
648 error_message = error->errmess;
652 NSLOG(netsurf, INFO,
"given rectangle: [(%d, %d), (%d, %d)]",
653 b.x0, b.y0, b.x1, b.y1);
659 NSLOG(netsurf, INFO,
"xpdriver_draw_page: 0x%x: %s",
660 error->errnum, error->errmess);
661 error_message = error->errmess;
675 "redrawing area: [(%d, %d), (%d, %d)]", b.x0,
692 error_message =
"redraw error";
696 error = xpdriver_get_rectangle(&b, &more, 0);
699 "xpdriver_get_rectangle: 0x%x: %s",
702 error_message = error->errmess;
721 error = (os_error *) _swix(PDriver_EndJob, _IN(0), (int) fhandle);
723 NSLOG(netsurf, INFO,
"xpdriver_end_jobw: 0x%x: %s",
724 error->errnum, error->errmess);
725 error_message = error->errmess;
729 error = xosfind_closew(fhandle);
731 NSLOG(netsurf, INFO,
"xosfind_closew: 0x%x: %s",
732 error->errnum, error->errmess);
738 error = xpdriver_select_jobw(old_job, 0, 0);
741 "xpdriver_select_jobw: 0x%x: %s",
750 rufl_invalidate_cache();
761 xpdriver_abort_job(fhandle);
762 xosfind_closew(fhandle);
764 xpdriver_select_jobw(old_job, 0, 0);
770 rufl_invalidate_cache();
791 int x,
int y,
int radius,
int angle1,
int angle2)
799 int x,
int y,
int radius)
834 const float transform[6])
870 const char *font_family;
871 unsigned int font_size;
872 rufl_style font_style;
877 code = rufl_paint_callback(font_family, font_style, font_size,
879 if (code != rufl_OK) {
880 if (code == rufl_FONT_MANAGER_ERROR) {
882 "rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s",
883 rufl_fm_error->errnum,
884 rufl_fm_error->errmess);
887 NSLOG(netsurf, INFO,
"rufl_paint_callback: 0x%x",
915 .option_knockout =
false,
931 const char *error_message = 0;
935 .background_images =
false,
959 return "Declaring fonts failed.";
968 "xpdriver_declare_font: 0x%x: %s",
971 error_message = error->errmess;
975 error = xpdriver_declare_font(0, 0, 0);
977 NSLOG(netsurf, INFO,
"xpdriver_declare_font: 0x%x: %s",
978 error->errnum, error->errmess);
979 error_message = error->errmess;
989 return error_message;
1000 const char *font_name,
unsigned int font_size,
1001 const uint8_t *s8,
const uint32_t *s32,
unsigned int n,
Browser window creation and manipulation interface.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
Content handling interface.
void content_reformat(hlcache_handle *h, bool background, int width, int height)
Reformat to new size.
@ CONTENT_HTML
content is HTML
wimp_w ro_gui_dialog_create(const char *template_name)
Create a window from a template.
void ro_gui_dialog_close(wimp_w close)
Close a dialog box.
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
void nsfont_read_style(const plot_font_style_t *fstyle, const char **font_family, unsigned int *font_size, rufl_style *font_style)
Convert a font style to a font family, size and rufl_style.
static nserror print_fonts_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
static const char * print_fonts_error
Error in print_fonts_plot_text() or print_fonts_callback().
#define ICON_PRINT_BG_IMAGES
void ro_print_dataload_bounce(wimp_message *m)
Handle a bounced dataload message.
static bool ro_gui_print_apply(wimp_w w)
Handle click on the Print button in the print dialog.
static bool print_in_background
#define ICON_PRINT_SHEETS_DOWN
static int print_prev_message
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().
#define ICON_PRINT_UPRIGHT
static nserror print_fonts_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
#define ICON_PRINT_CANCEL
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.
#define ICON_PRINT_SHEETS
static nserror print_fonts_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
static void print_update_sheets_shaded_state(bool on)
Set shaded state of sheets.
#define ICON_PRINT_TO_BOTTOM
#define ICON_PRINT_FG_IMAGES
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 bool print_document(struct gui_window *g, const char *filename)
Print a document.
static char ** print_fonts_list
List of fonts in current print.
static nserror print_fonts_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
void ro_print_cleanup(void)
Cleanup after printing.
static const struct plotter_table print_fonts_plotters
Plotter table for print_declare_fonts().
static const char * print_declare_fonts(struct hlcache_handle *h)
Declare fonts to the printer driver.
static int print_max_sheets
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 bool ro_gui_print_click(wimp_pointer *pointer)
Handle mouse clicks in print dialog.
static unsigned int print_fonts_count
Number of entries in print_fonts_list.
#define ICON_PRINT_COPIES_UP
#define ICON_PRINT_TEXT_BLACK
#define ICON_PRINT_COPIES_DOWN
void ro_print_error(wimp_message *m)
Handle message_PRINT_ERROR.
void ro_gui_print_init(void)
Initialise the print dialog.
#define ICON_PRINT_SHEETS_UP
#define ICON_PRINT_SHEETS_TEXT
#define ICON_PRINT_SHEETS_VALUE
static bool print_send_printtypeknown(wimp_message *m)
Send a message_PRINT_TYPE_KNOWN.
static int print_num_copies
#define ICON_PRINT_SIDEWAYS
static void print_send_printsave(struct hlcache_handle *h)
Send a message_PRINT_SAVE.
#define ICON_PRINT_COPIES
void ro_gui_print_prepare(struct gui_window *g)
Prepares all aspects of the print dialog prior to opening.
bool ro_print_ack(wimp_message *m)
Handle message_DATASAVE_ACK for the printing protocol.
static bool print_bg_images
static nserror print_fonts_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
struct gui_window * ro_print_current_window
#define ICON_PRINT_IN_BACKGROUND
static bool print_sideways
void ro_print_save_bounce(wimp_message *m)
Handle a bounced message_PRINT_SAVE.
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])
void ro_print_type_odd(wimp_message *m)
Handle message_PRINT_TYPE_ODD.
Browser window handling (interface).
Public content interface.
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
const char * content_get_title(struct hlcache_handle *h)
Retrieve title associated with content.
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Target independent plotting interface.
unsigned long bitmap_flags_t
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
RISC OS filetpe interface.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
struct gui_window * ro_gui_current_redraw_gui
GUI window which is being redrawn.
const struct plotter_table ro_plotters
RISC OS plotter operation table.
nserror ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect)
Cause an area of a window to be invalidated.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
parameters to content redraw
int height
vertical dimension
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
first entry in window list
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Plot style for stroke/fill plotters.
Plotter operations table.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
bool interactive
Redraw to show interactive features.
uint32_t colour
Colour type: XBGR.
Option reading and saving interface.
void ro_gui_set_window_title(wimp_w w, const char *text)
Set a window title.
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
const char * ro_gui_get_icon_string(wimp_w w, wimp_i i)
Read the contents of a text or sprite icon.
void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state)
Set the selected state of an icon.
bool ro_gui_set_caret_first(wimp_w w)
Places the caret in the first available icon.
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value)
Set the contents of an icon to a number.
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i)
Gets the selected state of an icon.
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i)
Register a text field to be automatically handled.
bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up, wimp_i down, int min, int max, int stepping, int decimal_places)
Register a numeric field to be automatically handled.
bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix)
Set the associated help prefix for a given window.
bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i)
Register a function to be called for the Cancel action on a window.
bool ro_gui_wimp_event_memorise(wimp_w w)
Memorises the current state of any registered components in a window.
bool ro_gui_wimp_event_register_mouse_click(wimp_w w, bool(*callback)(wimp_pointer *pointer))
Register a function to be called for all mouse-clicks to icons in a window that don't have registered...
bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i)
Register a checkbox to be automatically handled.
bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, bool(*callback)(wimp_w w))
Register a function to be called for the OK action on a window.
bool ro_gui_wimp_event_register_radio(wimp_w w, wimp_i *i)
Register a group of radio icons to be automatically handled.
Automated RISC OS WIMP event handling (interface).
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.