From 5f6c2cbff7cd778b6487943d62e71ff9e7b04893 Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Sat, 26 Jul 2008 22:29:15 +0000 Subject: - Compiler warning squash - Changed a lineending \n\r -> \n for a couple of files. - More code style conformance. svn path=/trunk/netsurf/; revision=4762 --- desktop/tree.c | 8 +- desktop/tree.h | 2 +- pdf/font_haru.c | 2 - pdf/pdf_plotters.c | 2 + render/box.c | 1 - render/loosen.c | 9 +- riscos/401login.c | 2 +- riscos/assert.c | 2 +- riscos/bitmap.h | 3 +- riscos/buffer.c | 14 +- riscos/configure.h | 4 - riscos/configure/con_cache.c | 10 +- riscos/configure/con_connect.c | 19 +- riscos/configure/con_content.c | 10 +- riscos/configure/con_fonts.c | 1 + riscos/configure/con_home.c | 10 +- riscos/configure/con_image.c | 28 +- riscos/configure/con_inter.c | 13 +- riscos/configure/con_language.c | 1 + riscos/configure/con_memory.c | 13 +- riscos/configure/con_secure.c | 11 +- riscos/configure/con_theme.c | 20 +- riscos/configure/configure.h | 87 +- riscos/dialog.c | 2 +- riscos/dialog.h | 6 +- riscos/draw.c | 1 - riscos/draw.h | 2 + riscos/gui.c | 34 +- riscos/gui.h | 6 +- riscos/gui/progress_bar.c | 49 +- riscos/gui/progress_bar.h | 8 +- riscos/gui/status_bar.c | 50 +- riscos/gui/status_bar.h | 4 +- riscos/help.c | 12 +- riscos/hotlist.c | 28 +- riscos/image.c | 6 +- riscos/image.h | 3 +- riscos/menus.c | 66 +- riscos/message.c | 21 +- riscos/message.h | 83 +- riscos/options.h | 1 + riscos/plotters.c | 1 + riscos/plugin.c | 2 - riscos/plugin.h | 4 +- riscos/print.c | 63 +- riscos/print.h | 3 + riscos/query.c | 1 + riscos/query.h | 3 +- riscos/save.c | 14 +- riscos/save.h | 2 +- riscos/save_complete.c | 7 +- riscos/save_complete.h | 1 + riscos/save_draw.c | 6 +- riscos/save_draw.h | 1 + riscos/save_pdf.c | 3 +- riscos/save_pdf.h | 3 +- riscos/search.c | 2 - riscos/sprite.c | 2 +- riscos/sprite.h | 2 +- riscos/textarea.c | 4 - riscos/theme.c | 93 +- riscos/thumbnail.c | 2 +- riscos/thumbnail.h | 2 +- riscos/treeview.c | 99 +- riscos/treeview.h | 2 +- riscos/ucstables.c | 34 +- riscos/ucstables.h | 2 +- riscos/wimp.c | 72 +- riscos/wimp_event.c | 2537 ++++++++++++++++++++------------------- riscos/window.c | 2 +- utils/hashtable.c | 56 +- utils/hashtable.h | 1 - 72 files changed, 1968 insertions(+), 1712 deletions(-) diff --git a/desktop/tree.c b/desktop/tree.c index 208483d6f..83b56079f 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -916,7 +916,7 @@ void tree_delete_node(struct tree *tree, struct node *node, bool siblings) { void tree_delete_node_internal(struct tree *tree, struct node *node, bool siblings) { struct node *next, *child; struct node_element *e, *f, *domain, *path; - char *domain_t, *path_t, *name_t; + const char *domain_t, *path_t, *name_t; char *space; assert(node); @@ -939,7 +939,7 @@ void tree_delete_node_internal(struct tree *tree, struct node *node, bool siblin if (e->text) { /* we don't free non-editable titles or URLs */ if ((node->editable) || (node->folder)) - free(e->text); + free((void *)e->text); else { /* only reset non-deleted items */ if (!node->deleted) { @@ -976,7 +976,7 @@ void tree_delete_node_internal(struct tree *tree, struct node *node, bool siblin if (e->data != TREE_ELEMENT_TITLE && e->data != TREE_ELEMENT_URL) { - free(e->text); + free((void *)e->text); e->text = NULL; } } @@ -1128,7 +1128,7 @@ struct node *tree_create_URL_node_shared(struct node *parent, const char *url, const struct url_data *data) { struct node *node; struct node_element *element; - char *title; + const char *title; assert(url && data); diff --git a/desktop/tree.h b/desktop/tree.h index d22efb130..d02f1726e 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -74,7 +74,7 @@ struct node_element { struct node *parent; /* <-- Parent node */ node_element_type type; /* <-- Element type */ struct node_element_box box; /* <-- Element bounding box */ - char *text; /* <-- Text for the element */ + const char *text; /* <-- Text for the element */ struct node_sprite *sprite; /* <-- Sprite for the element */ struct node_element *next; /* <-- Next node element */ node_element_data data; /* <-- Data being represented */ diff --git a/pdf/font_haru.c b/pdf/font_haru.c index 555570ef0..de89d6494 100644 --- a/pdf/font_haru.c +++ b/pdf/font_haru.c @@ -177,8 +177,6 @@ bool haru_nsfont_position_in_string(const struct css_style *style, char *string_nt; HPDF_UINT offset; HPDF_REAL real_width; - HPDF_REAL width; - if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length)) return false; diff --git a/pdf/pdf_plotters.c b/pdf/pdf_plotters.c index c641eef8f..49828a0a6 100644 --- a/pdf/pdf_plotters.c +++ b/pdf/pdf_plotters.c @@ -79,7 +79,9 @@ static HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *conte static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void*user_data); +#ifdef PDF_DEBUG static void pdf_plot_grid(int x_dist,int y_dist,unsigned int colour); +#endif /*PDF Plotter - current doc,page and font*/ static HPDF_Doc pdf_doc; diff --git a/render/box.c b/render/box.c index e6495174e..d248f60d4 100644 --- a/render/box.c +++ b/render/box.c @@ -677,7 +677,6 @@ struct box* box_duplicate_tree(struct box *root, struct content *c) { struct box *new_root;/**< Root of the new box tree*/ int box_number = 0; - struct box *old_addr, *new_addr; struct box_dict_element *box_dict, *box_dict_end; /* 1. Duplicate parent - children structure, list_markers*/ diff --git a/render/loosen.c b/render/loosen.c index 5686d5a3b..a6f3053ff 100644 --- a/render/loosen.c +++ b/render/loosen.c @@ -23,6 +23,7 @@ #include "render/box.h" #include "render/font.h" +#include "render/loosen.h" #include "utils/log.h" #include "utils/talloc.h" @@ -174,11 +175,8 @@ bool loosen_text(struct box *text, int width, struct content *content) */ bool loosen_table(struct box *table, int width, struct content *content) { - struct box *row_group, *row, *cell, *br, *prev, *inline_container; - unsigned int row_sum; - bool first_cell_in_row; - + if (table->min_width <= width) return true; @@ -292,7 +290,6 @@ bool loosen_all_first_pass(struct box *box, int width, int cx, struct content *content) { struct box* c; - int got_width; int x; for (c = box->children; c ; c = c->next) { @@ -342,7 +339,6 @@ bool loosen_all_second_pass(struct box *box, int width, int cx, struct content *content) { struct box *c; - int got_width; int x; for (c = box->children; c; c = c->next) { @@ -378,7 +374,6 @@ bool loosen_all_third_pass(struct box *box, int width, int cx, struct content *content) { struct box *c; - int got_width; int x; for (c = box->children; c; c = c->next) { diff --git a/riscos/401login.c b/riscos/401login.c index cfc256ad8..3cbfcb575 100644 --- a/riscos/401login.c +++ b/riscos/401login.c @@ -19,7 +19,7 @@ #include #include #include -#include "oslib/wimp.h" +#include #include "utils/config.h" #include "content/content.h" #include "content/urldb.h" diff --git a/riscos/assert.c b/riscos/assert.c index a89daeaca..27df37866 100644 --- a/riscos/assert.c +++ b/riscos/assert.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include "oslib/wimp.h" /** diff --git a/riscos/bitmap.h b/riscos/bitmap.h index abd7969a5..8a1eff9b9 100644 --- a/riscos/bitmap.h +++ b/riscos/bitmap.h @@ -19,7 +19,8 @@ #ifndef _NETSURF_RISCOS_BITMAP_H_ #define _NETSURF_RISCOS_BITMAP_H_ -#include +#include +#include "oslib/osspriteop.h" #include "image/bitmap.h" struct osspriteop_area; diff --git a/riscos/buffer.c b/riscos/buffer.c index c770dd163..ebd099a5e 100644 --- a/riscos/buffer.c +++ b/riscos/buffer.c @@ -19,10 +19,10 @@ #include #include #include -#include +#include "swis.h" #include "oslib/colourtrans.h" #include "oslib/os.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "oslib/wimpreadsysinfo.h" #include "riscos/buffer.h" @@ -68,7 +68,8 @@ static os_mode mode; * * \param redraw the current WIMP redraw area to buffer */ -void ro_gui_buffer_open(wimp_draw *redraw) { +void ro_gui_buffer_open(wimp_draw *redraw) +{ int size; int total_size; os_coord sprite_size; @@ -251,8 +252,8 @@ void ro_gui_buffer_open(wimp_draw *redraw) { /** * Closes any open buffer and flushes the contents to screen */ -void ro_gui_buffer_close(void) { - +void ro_gui_buffer_close(void) +{ /* Check we have an open buffer */ if (!buffer) @@ -289,7 +290,8 @@ void ro_gui_buffer_close(void) { /** * Releases any buffer memory depending on cache constraints. */ -static void ro_gui_buffer_free(void) { +static void ro_gui_buffer_free(void) +{ free(buffer); buffer = NULL; } diff --git a/riscos/configure.h b/riscos/configure.h index 94904f230..7157cc77b 100644 --- a/riscos/configure.h +++ b/riscos/configure.h @@ -24,11 +24,7 @@ #ifndef _NETSURF_RISCOS_CONFIGURE_H_ #define _NETSURF_RISCOS_CONFIGURE_H_ -#include #include -#include -#include -#include #include "oslib/os.h" #include "oslib/wimp.h" diff --git a/riscos/configure/con_cache.c b/riscos/configure/con_cache.c index e6a9bc218..11fd8f30a 100644 --- a/riscos/configure/con_cache.c +++ b/riscos/configure/con_cache.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "oslib/hourglass.h" #include "desktop/options.h" #include "riscos/dialog.h" @@ -40,7 +41,8 @@ static bool ro_gui_options_cache_click(wimp_pointer *pointer); static bool ro_gui_options_cache_ok(wimp_w w); -bool ro_gui_options_cache_initialise(wimp_w w) { +bool ro_gui_options_cache_initialise(wimp_w w) +{ /* set the current values */ ro_gui_set_icon_decimal(w, CACHE_MEMORY_SIZE, (option_memory_cache_size * 10) >> 20, 1); @@ -58,7 +60,8 @@ bool ro_gui_options_cache_initialise(wimp_w w) { } -bool ro_gui_options_cache_click(wimp_pointer *pointer) { +bool ro_gui_options_cache_click(wimp_pointer *pointer) +{ switch (pointer->i) { case CACHE_DEFAULT_BUTTON: /* set the default values */ @@ -69,7 +72,8 @@ bool ro_gui_options_cache_click(wimp_pointer *pointer) { return false; } -bool ro_gui_options_cache_ok(wimp_w w) { +bool ro_gui_options_cache_ok(wimp_w w) +{ option_memory_cache_size = (((ro_gui_get_icon_decimal(w, CACHE_MEMORY_SIZE, 1) + 1) << 20) - 1) / 10; diff --git a/riscos/configure/con_connect.c b/riscos/configure/con_connect.c index b864c29e2..bc88c92ec 100644 --- a/riscos/configure/con_connect.c +++ b/riscos/configure/con_connect.c @@ -17,8 +17,8 @@ */ #include -#include -#include +#include "swis.h" +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "desktop/options.h" #include "riscos/configure/configure.h" @@ -62,7 +62,8 @@ static void ro_gui_options_connection_default(wimp_pointer *pointer); static bool ro_gui_options_connection_ok(wimp_w w); static void ro_gui_options_connection_update(wimp_w w, wimp_i i); -bool ro_gui_options_connection_initialise(wimp_w w) { +bool ro_gui_options_connection_initialise(wimp_w w) +{ int proxy_type; /* set the current values */ @@ -123,7 +124,8 @@ bool ro_gui_options_connection_initialise(wimp_w w) { } -void ro_gui_options_connection_update(wimp_w w, wimp_i i) { +void ro_gui_options_connection_update(wimp_w w, wimp_i i) +{ int proxy_type; bool host, user; @@ -142,7 +144,8 @@ void ro_gui_options_connection_update(wimp_w w, wimp_i i) { ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PASSWORD, !user); } -int ro_gui_options_connection_proxy_type(wimp_w w) { +int ro_gui_options_connection_proxy_type(wimp_w w) +{ char *text; int i; @@ -154,7 +157,8 @@ int ro_gui_options_connection_proxy_type(wimp_w w) { assert(false); } -void ro_gui_options_connection_default(wimp_pointer *pointer) { +void ro_gui_options_connection_default(wimp_pointer *pointer) +{ ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_FIELD, proxy_type_menu->entries[0]. data.indirected_text.text); @@ -168,7 +172,8 @@ void ro_gui_options_connection_default(wimp_pointer *pointer) { ro_gui_options_connection_update(pointer->w, -1); } -bool ro_gui_options_connection_ok(wimp_w w) { +bool ro_gui_options_connection_ok(wimp_w w) +{ int proxy_type; proxy_type = ro_gui_options_connection_proxy_type(w); diff --git a/riscos/configure/con_content.c b/riscos/configure/con_content.c index 382a1f1a9..bda7b6d57 100644 --- a/riscos/configure/con_content.c +++ b/riscos/configure/con_content.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" @@ -39,7 +40,8 @@ static void ro_gui_options_content_default(wimp_pointer *pointer); static bool ro_gui_options_content_ok(wimp_w w); -bool ro_gui_options_content_initialise(wimp_w w) { +bool ro_gui_options_content_initialise(wimp_w w) +{ /* set the current values */ ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS, option_block_ads); @@ -66,7 +68,8 @@ bool ro_gui_options_content_initialise(wimp_w w) { } -void ro_gui_options_content_default(wimp_pointer *pointer) { +void ro_gui_options_content_default(wimp_pointer *pointer) +{ /* set the default values */ ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_ADVERTISEMENTS, false); @@ -78,7 +81,8 @@ void ro_gui_options_content_default(wimp_pointer *pointer) { true); } -bool ro_gui_options_content_ok(wimp_w w) { +bool ro_gui_options_content_ok(wimp_w w) +{ option_block_ads = ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS); option_block_popups = ro_gui_get_icon_selected_state(w, diff --git a/riscos/configure/con_fonts.c b/riscos/configure/con_fonts.c index 980a156ba..4fea0629c 100644 --- a/riscos/configure/con_fonts.c +++ b/riscos/configure/con_fonts.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "css/css.h" #include "desktop/options.h" #include "riscos/dialog.h" diff --git a/riscos/configure/con_home.c b/riscos/configure/con_home.c index bbf267b38..a3f272fc9 100644 --- a/riscos/configure/con_home.c +++ b/riscos/configure/con_home.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" @@ -39,7 +40,8 @@ static void ro_gui_options_home_default(wimp_pointer *pointer); static bool ro_gui_options_home_ok(wimp_w w); -bool ro_gui_options_home_initialise(wimp_w w) { +bool ro_gui_options_home_initialise(wimp_w w) +{ int suggestions; /* set the current values */ @@ -66,13 +68,15 @@ bool ro_gui_options_home_initialise(wimp_w w) { } -void ro_gui_options_home_default(wimp_pointer *pointer) { +void ro_gui_options_home_default(wimp_pointer *pointer) +{ /* set the default values */ ro_gui_set_icon_string(pointer->w, HOME_URL_FIELD, ""); ro_gui_set_icon_selected_state(pointer->w, HOME_OPEN_STARTUP, false); } -bool ro_gui_options_home_ok(wimp_w w) { +bool ro_gui_options_home_ok(wimp_w w) +{ if (option_homepage_url) free(option_homepage_url); option_homepage_url = strdup(ro_gui_get_icon_string(w, HOME_URL_FIELD)); diff --git a/riscos/configure/con_image.c b/riscos/configure/con_image.c index ce436afcf..f2583c7d9 100644 --- a/riscos/configure/con_image.c +++ b/riscos/configure/con_image.c @@ -17,8 +17,8 @@ */ #include -#include -#include +#include "swis.h" +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "desktop/options.h" #include "riscos/configure/configure.h" @@ -59,7 +59,8 @@ int example_users = 0; unsigned int tinct_options[] = {tinct_USE_OS_SPRITE_OP, 0, tinct_DITHER, tinct_ERROR_DIFFUSE}; -bool ro_gui_options_image_initialise(wimp_w w) { +bool ro_gui_options_image_initialise(wimp_w w) +{ char pathname[256]; int i; @@ -114,7 +115,8 @@ bool ro_gui_options_image_initialise(wimp_w w) { } -void ro_gui_options_image_finalise(wimp_w w) { +void ro_gui_options_image_finalise(wimp_w w) +{ example_users--; if (example_users == 0) { free(example_images); @@ -123,11 +125,13 @@ void ro_gui_options_image_finalise(wimp_w w) { ro_gui_wimp_event_finalise(w); } -void ro_gui_options_image_update(wimp_w w, wimp_i i) { +void ro_gui_options_image_update(wimp_w w, wimp_i i) +{ ro_gui_redraw_icon(w, IMAGE_CURRENT_DISPLAY); } -void ro_gui_options_image_redraw(wimp_draw *redraw) { +void ro_gui_options_image_redraw(wimp_draw *redraw) +{ osbool more; int origin_x, origin_y; os_error *error; @@ -173,7 +177,8 @@ void ro_gui_options_image_redraw(wimp_draw *redraw) { } } -void ro_gui_options_image_read(wimp_w w, unsigned int *bg, unsigned int *fg) { +void ro_gui_options_image_read(wimp_w w, unsigned int *bg, unsigned int *fg) +{ char *text; int i; @@ -189,7 +194,8 @@ void ro_gui_options_image_read(wimp_w w, unsigned int *bg, unsigned int *fg) { *bg = tinct_options[i]; } -bool ro_gui_options_image_click(wimp_pointer *pointer) { +bool ro_gui_options_image_click(wimp_pointer *pointer) +{ unsigned int old_fg, old_bg, bg, fg; ro_gui_options_image_read(pointer->w, &old_bg, &old_fg); @@ -220,7 +226,8 @@ bool ro_gui_options_image_click(wimp_pointer *pointer) { return false; } -void ro_gui_options_update_shading(wimp_w w) { +void ro_gui_options_update_shading(wimp_w w) +{ bool shaded; shaded = ro_gui_get_icon_selected_state(w, IMAGE_DISABLE_ANIMATION); @@ -231,7 +238,8 @@ void ro_gui_options_update_shading(wimp_w w) { ro_gui_set_icon_shaded_state(w, IMAGE_SPEED_CS, shaded); } -bool ro_gui_options_image_ok(wimp_w w) { +bool ro_gui_options_image_ok(wimp_w w) +{ ro_gui_options_image_read(w, &option_bg_plot_style, &option_fg_plot_style); option_minimum_gif_delay = ro_gui_get_icon_decimal(w, IMAGE_SPEED_FIELD, 2); diff --git a/riscos/configure/con_inter.c b/riscos/configure/con_inter.c index 057ee47cb..cd036fa46 100644 --- a/riscos/configure/con_inter.c +++ b/riscos/configure/con_inter.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "riscos/dialog.h" #include "riscos/gui.h" #include "riscos/options.h" @@ -38,8 +39,8 @@ static void ro_gui_options_interface_default(wimp_pointer *pointer); static bool ro_gui_options_interface_ok(wimp_w w); -bool ro_gui_options_interface_initialise(wimp_w w) { - +bool ro_gui_options_interface_initialise(wimp_w w) +{ /* set the current values */ ro_gui_set_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION, option_strip_extensions); @@ -64,8 +65,8 @@ bool ro_gui_options_interface_initialise(wimp_w w) { } -void ro_gui_options_interface_default(wimp_pointer *pointer) { - +void ro_gui_options_interface_default(wimp_pointer *pointer) +{ ro_gui_set_icon_selected_state(pointer->w, INTERFACE_STRIP_EXTNS_OPTION, true); ro_gui_set_icon_selected_state(pointer->w, @@ -78,8 +79,8 @@ void ro_gui_options_interface_default(wimp_pointer *pointer) { INTERFACE_THUMBNAIL_ICONISE_OPTION, true); } -bool ro_gui_options_interface_ok(wimp_w w) { - +bool ro_gui_options_interface_ok(wimp_w w) +{ option_strip_extensions = ro_gui_get_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION); option_confirm_overwrite = ro_gui_get_icon_selected_state(w, diff --git a/riscos/configure/con_language.c b/riscos/configure/con_language.c index eddbec3c9..9f9d8b94e 100644 --- a/riscos/configure/con_language.c +++ b/riscos/configure/con_language.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" diff --git a/riscos/configure/con_memory.c b/riscos/configure/con_memory.c index f665dde28..65d9bed26 100644 --- a/riscos/configure/con_memory.c +++ b/riscos/configure/con_memory.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "desktop/options.h" #include "riscos/bitmap.h" #include "riscos/options.h" @@ -43,7 +44,8 @@ static bool ro_gui_options_memory_click(wimp_pointer *pointer); static bool ro_gui_options_memory_ok(wimp_w w); static void ro_gui_options_update_shading(wimp_w w); -bool ro_gui_options_memory_initialise(wimp_w w) { +bool ro_gui_options_memory_initialise(wimp_w w) +{ /* set the current values */ ro_gui_set_icon_decimal(w, MEMORY_DIRECT_FIELD, (bitmap_direct_size * 10) >> 20, 1); @@ -77,7 +79,8 @@ bool ro_gui_options_memory_initialise(wimp_w w) { } -bool ro_gui_options_memory_click(wimp_pointer *pointer) { +bool ro_gui_options_memory_click(wimp_pointer *pointer) +{ switch (pointer->i) { case MEMORY_DIRECT_AUTO: ro_gui_options_update_shading(pointer->w); @@ -100,7 +103,8 @@ bool ro_gui_options_memory_click(wimp_pointer *pointer) { return false; } -void ro_gui_options_update_shading(wimp_w w) { +void ro_gui_options_update_shading(wimp_w w) +{ bool shaded; shaded = ro_gui_get_icon_selected_state(w, MEMORY_DIRECT_AUTO); @@ -115,7 +119,8 @@ void ro_gui_options_update_shading(wimp_w w) { ro_gui_set_icon_shaded_state(w, MEMORY_COMPRESSED_TEXT, shaded); } -bool ro_gui_options_memory_ok(wimp_w w) { +bool ro_gui_options_memory_ok(wimp_w w) +{ /* set the option values */ if (ro_gui_get_icon_selected_state(w, MEMORY_DIRECT_AUTO)) option_image_memory_direct = -1; diff --git a/riscos/configure/con_secure.c b/riscos/configure/con_secure.c index 764907c8a..c3b289b45 100644 --- a/riscos/configure/con_secure.c +++ b/riscos/configure/con_secure.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" @@ -39,8 +40,8 @@ static void ro_gui_options_security_default(wimp_pointer *pointer); static bool ro_gui_options_security_ok(wimp_w w); -bool ro_gui_options_security_initialise(wimp_w w) { - +bool ro_gui_options_security_initialise(wimp_w w) +{ /* set the current values */ ro_gui_set_icon_selected_state(w, SECURITY_REFERRER, option_send_referer); @@ -63,13 +64,15 @@ bool ro_gui_options_security_initialise(wimp_w w) { } -void ro_gui_options_security_default(wimp_pointer *pointer) { +void ro_gui_options_security_default(wimp_pointer *pointer) +{ /* set the default values */ ro_gui_set_icon_integer(pointer->w, SECURITY_DURATION_FIELD, 28); ro_gui_set_icon_selected_state(pointer->w, SECURITY_REFERRER, true); } -bool ro_gui_options_security_ok(wimp_w w) { +bool ro_gui_options_security_ok(wimp_w w) +{ option_send_referer = ro_gui_get_icon_selected_state(w, SECURITY_REFERRER); option_expire_url = ro_gui_get_icon_decimal(w, diff --git a/riscos/configure/con_theme.c b/riscos/configure/con_theme.c index a74d820c7..003d67616 100644 --- a/riscos/configure/con_theme.c +++ b/riscos/configure/con_theme.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" #include "utils/config.h" @@ -87,7 +87,8 @@ static bool ro_gui_options_theme_click(wimp_pointer *pointer); static void ro_gui_options_theme_load(void); static void ro_gui_options_theme_free(void); -bool ro_gui_options_theme_initialise(wimp_w w) { +bool ro_gui_options_theme_initialise(wimp_w w) +{ wimp_window_state state; wimp_icon_state icon_state; os_error *error; @@ -167,7 +168,8 @@ bool ro_gui_options_theme_initialise(wimp_w w) { return true; } -void ro_gui_options_theme_finalise(wimp_w w) { +void ro_gui_options_theme_finalise(wimp_w w) +{ os_error *error; ro_gui_options_theme_free(); @@ -184,7 +186,8 @@ void ro_gui_options_theme_finalise(wimp_w w) { ro_gui_wimp_event_finalise(w); } -bool ro_gui_options_theme_ok(wimp_w w) { +bool ro_gui_options_theme_ok(wimp_w w) +{ struct toolbar_display *toolbar; struct theme_descriptor *theme_new = NULL; @@ -211,7 +214,8 @@ bool ro_gui_options_theme_ok(wimp_w w) { return true; } -bool ro_gui_options_theme_click(wimp_pointer *pointer) { +bool ro_gui_options_theme_click(wimp_pointer *pointer) +{ struct theme_descriptor *theme_default; struct toolbar_display *toolbar; @@ -233,7 +237,8 @@ bool ro_gui_options_theme_click(wimp_pointer *pointer) { return false; } -void ro_gui_options_theme_load(void) { +void ro_gui_options_theme_load(void) +{ os_error *error; os_box extent = { 0, 0, 0, 0 }; struct theme_descriptor *descriptor; @@ -385,7 +390,8 @@ void ro_gui_options_theme_load(void) { xwimp_force_redraw(theme_pane, 0, -16384, 16384, 16384); } -void ro_gui_options_theme_free(void) { +void ro_gui_options_theme_free(void) +{ struct toolbar_display *toolbar; struct toolbar_display *next_toolbar; diff --git a/riscos/configure/configure.h b/riscos/configure/configure.h index b8aff9f66..5350be8f4 100644 --- a/riscos/configure/configure.h +++ b/riscos/configure/configure.h @@ -1,43 +1,44 @@ -/* - * Copyright 2005 Richard Wilson - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * Automated RISC OS WIMP event handling (interface). - */ - - -#ifndef _NETSURF_RISCOS_OPTIONS_CONFIGURE_H_ -#define _NETSURF_RISCOS_OPTIONS_CONFIGURE_H_ - -#include - -bool ro_gui_options_cache_initialise(wimp_w w); -bool ro_gui_options_connection_initialise(wimp_w w); -bool ro_gui_options_content_initialise(wimp_w w); -bool ro_gui_options_fonts_initialise(wimp_w w); -bool ro_gui_options_home_initialise(wimp_w w); -bool ro_gui_options_image_initialise(wimp_w w); -void ro_gui_options_image_finalise(wimp_w w); -bool ro_gui_options_interface_initialise(wimp_w w); -bool ro_gui_options_language_initialise(wimp_w w); -bool ro_gui_options_memory_initialise(wimp_w w); -bool ro_gui_options_security_initialise(wimp_w w); -bool ro_gui_options_theme_initialise(wimp_w w); -void ro_gui_options_theme_finalise(wimp_w w); - -#endif +/* + * Copyright 2005 Richard Wilson + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * Automated RISC OS WIMP event handling (interface). + */ + + +#ifndef _NETSURF_RISCOS_OPTIONS_CONFIGURE_H_ +#define _NETSURF_RISCOS_OPTIONS_CONFIGURE_H_ + +#include +#include "oslib/wimp.h" + +bool ro_gui_options_cache_initialise(wimp_w w); +bool ro_gui_options_connection_initialise(wimp_w w); +bool ro_gui_options_content_initialise(wimp_w w); +bool ro_gui_options_fonts_initialise(wimp_w w); +bool ro_gui_options_home_initialise(wimp_w w); +bool ro_gui_options_image_initialise(wimp_w w); +void ro_gui_options_image_finalise(wimp_w w); +bool ro_gui_options_interface_initialise(wimp_w w); +bool ro_gui_options_language_initialise(wimp_w w); +bool ro_gui_options_memory_initialise(wimp_w w); +bool ro_gui_options_security_initialise(wimp_w w); +bool ro_gui_options_theme_initialise(wimp_w w); +void ro_gui_options_theme_finalise(wimp_w w); + +#endif diff --git a/riscos/dialog.c b/riscos/dialog.c index c54ed0a7f..3f1adc89a 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -28,7 +28,7 @@ #include "oslib/colourtrans.h" #include "oslib/osfile.h" #include "oslib/osgbpb.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "rufl.h" #include "utils/config.h" diff --git a/riscos/dialog.h b/riscos/dialog.h index 9b4eb9945..63a53d68c 100644 --- a/riscos/dialog.h +++ b/riscos/dialog.h @@ -21,14 +21,10 @@ #include #include -#include +#include "oslib/wimp.h" #include "riscos/theme.h" - - #include "riscos/gui.h" - - void ro_gui_dialog_init(void); wimp_w ro_gui_dialog_create(const char *template_name); wimp_window * ro_gui_dialog_load_template(const char *template_name); diff --git a/riscos/draw.c b/riscos/draw.c index fcf954131..0d1bf51a4 100644 --- a/riscos/draw.c +++ b/riscos/draw.c @@ -36,7 +36,6 @@ #ifdef WITH_DRAW - /** * Convert a CONTENT_DRAW for display. * diff --git a/riscos/draw.h b/riscos/draw.h index a71a58a84..81c2a1797 100644 --- a/riscos/draw.h +++ b/riscos/draw.h @@ -23,6 +23,8 @@ #ifndef _NETSURF_RISCOS_DRAW_H_ #define _NETSURF_RISCOS_DRAW_H_ +#include + struct content; struct content_draw_data { diff --git a/riscos/gui.c b/riscos/gui.c index 803047257..87c072edc 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -33,23 +33,23 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "oslib/font.h" +#include "oslib/help.h" +#include "oslib/hourglass.h" +#include "oslib/inetsuite.h" +#include "oslib/os.h" +#include "oslib/osbyte.h" +#include "oslib/osfile.h" +#include "oslib/osfscontrol.h" +#include "oslib/osgbpb.h" +#include "oslib/osmodule.h" +#include "oslib/osspriteop.h" +#include "oslib/pdriver.h" +#include "oslib/plugin.h" +#include "oslib/wimp.h" +#include "oslib/wimpspriteop.h" +#include "oslib/uri.h" +#include "rufl.h" #include "utils/config.h" #include "content/content.h" #include "content/urldb.h" diff --git a/riscos/gui.h b/riscos/gui.h index 21df85bbf..f3160c8a6 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -23,9 +23,9 @@ #include #include -#include -#include -#include +#include "oslib/osspriteop.h" +#include "oslib/wimp.h" +#include "rufl.h" #include "desktop/browser.h" #include "content/content_type.h" #include "utils/config.h" diff --git a/riscos/gui/progress_bar.c b/riscos/gui/progress_bar.c index 068f0103b..1195d57bb 100644 --- a/riscos/gui/progress_bar.c +++ b/riscos/gui/progress_bar.c @@ -23,10 +23,10 @@ #include #include #include -#include +#include "swis.h" #include "oslib/colourtrans.h" #include "oslib/os.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" #include "desktop/plotters.h" @@ -99,7 +99,8 @@ static void ro_gui_progress_bar_animate(void *p); * * \param icons the sprite area to use for icons */ -void ro_gui_progress_bar_init(osspriteop_area *icons) { +void ro_gui_progress_bar_init(osspriteop_area *icons) +{ os_error *error; progress_bar_definition.sprite_area = icons; @@ -120,7 +121,8 @@ void ro_gui_progress_bar_init(osspriteop_area *icons) { /** * Create a new progress bar */ -struct progress_bar *ro_gui_progress_bar_create(void) { +struct progress_bar *ro_gui_progress_bar_create(void) +{ struct progress_bar *pb; os_error *error; @@ -149,7 +151,8 @@ struct progress_bar *ro_gui_progress_bar_create(void) { * * \param pb the progress bar to destroy */ -void ro_gui_progress_bar_destroy(struct progress_bar *pb) { +void ro_gui_progress_bar_destroy(struct progress_bar *pb) +{ os_error *error; assert(pb); @@ -172,7 +175,8 @@ void ro_gui_progress_bar_destroy(struct progress_bar *pb) { * \param pb the progress bar to get the window handle of * \return the progress bar's window handle */ -wimp_w ro_gui_progress_bar_get_window(struct progress_bar *pb) { +wimp_w ro_gui_progress_bar_get_window(struct progress_bar *pb) +{ assert(pb); return pb->w; @@ -185,7 +189,8 @@ wimp_w ro_gui_progress_bar_get_window(struct progress_bar *pb) { * \param pb the progress bar to set the icon for * \param icon the icon to use, or NULL for no icon */ -void ro_gui_progress_bar_set_icon(struct progress_bar *pb, const char *icon) { +void ro_gui_progress_bar_set_icon(struct progress_bar *pb, const char *icon) +{ assert(pb); if (!strcmp(icon, pb->icon)) @@ -208,7 +213,8 @@ void ro_gui_progress_bar_set_icon(struct progress_bar *pb, const char *icon) { * \param pb the progress bar to set the value for * \param value the value to use */ -void ro_gui_progress_bar_set_value(struct progress_bar *pb, unsigned int value) { +void ro_gui_progress_bar_set_value(struct progress_bar *pb, unsigned int value) +{ assert(pb); pb->value = value; @@ -224,7 +230,8 @@ void ro_gui_progress_bar_set_value(struct progress_bar *pb, unsigned int value) * \param pb the progress bar to get the value of * \return the current value */ -unsigned int ro_gui_progress_bar_get_value(struct progress_bar *pb) { +unsigned int ro_gui_progress_bar_get_value(struct progress_bar *pb) +{ assert(pb); return pb->value; @@ -237,7 +244,8 @@ unsigned int ro_gui_progress_bar_get_value(struct progress_bar *pb) { * \param pb the progress bar to set the range for * \param range the range to use */ -void ro_gui_progress_bar_set_range(struct progress_bar *pb, unsigned int range) { +void ro_gui_progress_bar_set_range(struct progress_bar *pb, unsigned int range) +{ assert(pb); pb->range = range; @@ -253,7 +261,8 @@ void ro_gui_progress_bar_set_range(struct progress_bar *pb, unsigned int range) * \param pb the progress bar to get the range of * \return the current range */ -unsigned int ro_gui_progress_bar_get_range(struct progress_bar *pb) { +unsigned int ro_gui_progress_bar_get_range(struct progress_bar *pb) +{ assert(pb); return pb->range; @@ -267,7 +276,8 @@ unsigned int ro_gui_progress_bar_get_range(struct progress_bar *pb) { * \param width the new progress bar width * \param height the new progress bar height */ -void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height) { +void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height) +{ wimp_draw redraw; os_error *error; osbool more; @@ -321,8 +331,8 @@ void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height) * * \param redraw the redraw request to process */ -void ro_gui_progress_bar_redraw(wimp_draw *redraw) { - +void ro_gui_progress_bar_redraw(wimp_draw *redraw) +{ struct progress_bar *pb; os_error *error; osbool more; @@ -346,7 +356,8 @@ void ro_gui_progress_bar_redraw(wimp_draw *redraw) { * * \param p the progress bar to animate */ -void ro_gui_progress_bar_animate(void *p) { +void ro_gui_progress_bar_animate(void *p) +{ wimp_draw redraw; os_error *error; osbool more; @@ -377,7 +388,9 @@ void ro_gui_progress_bar_animate(void *p) { * \param height the height of the progress bar * \return the address of the associated icon, or NULL */ -void ro_gui_progress_bar_calculate(struct progress_bar *pb, int width, int height) { +void ro_gui_progress_bar_calculate(struct progress_bar *pb, int width, + int height) +{ os_error *error; int icon_width, icon_height; int icon_x0 = 0, icon_y0 = 0, progress_x0, progress_x1, progress_ymid = 0; @@ -448,7 +461,9 @@ void ro_gui_progress_bar_calculate(struct progress_bar *pb, int width, int heigh * \param redraw the section of the window to redraw * \param pb the progress bar to redraw */ -void ro_gui_progress_bar_redraw_window(wimp_draw *redraw, struct progress_bar *pb) { +void ro_gui_progress_bar_redraw_window(wimp_draw *redraw, + struct progress_bar *pb) +{ os_error *error; osbool more = true; int clip_x0 = 0, clip_y0 = 0, clip_x1 = 0, clip_y1 = 0; diff --git a/riscos/gui/progress_bar.h b/riscos/gui/progress_bar.h index 47fc3acf3..e4cec1369 100644 --- a/riscos/gui/progress_bar.h +++ b/riscos/gui/progress_bar.h @@ -20,13 +20,13 @@ * Progress bar (interface). */ -#include -#include -#include "oslib/wimp.h" - #ifndef _NETSURF_RISCOS_PROGRESS_BAR_H_ #define _NETSURF_RISCOS_PROGRESS_BAR_H_ +#include +#include "oslib/osspriteop.h" +#include "oslib/wimp.h" + struct progress_bar; void ro_gui_progress_bar_init(osspriteop_area *icons); diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c index 95173a479..1ab458c1f 100644 --- a/riscos/gui/status_bar.c +++ b/riscos/gui/status_bar.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include "swis.h" #include "oslib/colourtrans.h" #include "oslib/os.h" #include "oslib/wimp.h" @@ -110,7 +110,8 @@ static void ro_gui_status_position_progress_bar(struct status_bar *sb); * \param parent the window to contain the status bar * \param width the proportional width to use (0...10,000) */ -struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width) { +struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width) +{ struct status_bar *sb; os_error *error; @@ -152,7 +153,8 @@ struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width) { * * \param sb the status bar to destroy */ -void ro_gui_status_bar_destroy(struct status_bar *sb) { +void ro_gui_status_bar_destroy(struct status_bar *sb) +{ os_error *error; assert(sb); @@ -178,7 +180,8 @@ void ro_gui_status_bar_destroy(struct status_bar *sb) { * \param sb the status bar to get the window handle of * \return the status bar's window handle */ -wimp_w ro_gui_status_bar_get_window(struct status_bar *sb) { +wimp_w ro_gui_status_bar_get_window(struct status_bar *sb) +{ assert(sb); return sb->w; @@ -191,7 +194,8 @@ wimp_w ro_gui_status_bar_get_window(struct status_bar *sb) { * \param sb the status bar to get the width of * \return the status bar's width (0...10,000) */ -unsigned int ro_gui_status_bar_get_width(struct status_bar *sb) { +unsigned int ro_gui_status_bar_get_width(struct status_bar *sb) +{ assert(sb); return sb->scale; @@ -204,7 +208,8 @@ unsigned int ro_gui_status_bar_get_width(struct status_bar *sb) { * \param sb the status bar to check the visiblity of * \return whether the status bar is visible */ -void ro_gui_status_bar_set_visible(struct status_bar *sb, bool visible) { +void ro_gui_status_bar_set_visible(struct status_bar *sb, bool visible) +{ os_error *error; assert(sb); @@ -228,7 +233,8 @@ void ro_gui_status_bar_set_visible(struct status_bar *sb, bool visible) { * \param sb the status bar to check the visiblity of * \return whether the status bar is visible */ -bool ro_gui_status_bar_get_visible(struct status_bar *sb) { +bool ro_gui_status_bar_get_visible(struct status_bar *sb) +{ assert(sb); return sb->visible; @@ -242,8 +248,8 @@ bool ro_gui_status_bar_get_visible(struct status_bar *sb) { * \param value the value to use */ void ro_gui_status_bar_set_progress_value(struct status_bar *sb, - unsigned int value) { - + unsigned int value) +{ assert(sb); ro_gui_status_bar_set_progress_range(sb, @@ -259,7 +265,8 @@ void ro_gui_status_bar_set_progress_value(struct status_bar *sb, * \param value the value to use, or 0 to turn off the progress bar */ void ro_gui_status_bar_set_progress_range(struct status_bar *sb, - unsigned int range) { + unsigned int range) +{ unsigned int old_range; os_error *error; @@ -289,7 +296,8 @@ void ro_gui_status_bar_set_progress_range(struct status_bar *sb, * \param icon the icon to use, or NULL for no icon */ void ro_gui_status_bar_set_progress_icon(struct status_bar *sb, - const char *icon) { + const char *icon) +{ assert(sb); ro_gui_progress_bar_set_icon(sb->pb, icon); @@ -301,8 +309,8 @@ void ro_gui_status_bar_set_progress_icon(struct status_bar *sb, * * \param text the UTF8 text to display, or NULL for none */ -void ro_gui_status_bar_set_text(struct status_bar *sb, const char *text) { - +void ro_gui_status_bar_set_text(struct status_bar *sb, const char *text) +{ assert(sb); /* check for no change */ @@ -340,7 +348,8 @@ void ro_gui_status_bar_set_text(struct status_bar *sb, const char *text) { * * \param sb the status bar to resize */ -void ro_gui_status_bar_resize(struct status_bar *sb) { +void ro_gui_status_bar_resize(struct status_bar *sb) +{ int window_width, window_height; int status_width, status_height; int redraw_left, redraw_right; @@ -435,8 +444,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb) { * * \param redraw the redraw request to process */ -void ro_gui_status_bar_redraw(wimp_draw *redraw) { - +void ro_gui_status_bar_redraw(wimp_draw *redraw) +{ struct status_bar *sb; os_error *error; osbool more; @@ -506,7 +515,8 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw) { * * \param pointer details of the mouse click */ -bool ro_gui_status_bar_click(wimp_pointer *pointer) { +bool ro_gui_status_bar_click(wimp_pointer *pointer) +{ wimp_drag drag; os_error *error; @@ -535,7 +545,8 @@ bool ro_gui_status_bar_click(wimp_pointer *pointer) { * * \param open the request to process */ -void ro_gui_status_bar_open(wimp_open *open) { +void ro_gui_status_bar_open(wimp_open *open) +{ struct status_bar *sb; int window_width, status_width; wimp_window_state state; @@ -571,7 +582,8 @@ void ro_gui_status_bar_open(wimp_open *open) { * * \param sb the status bar to update */ -void ro_gui_status_position_progress_bar(struct status_bar *sb) { +void ro_gui_status_position_progress_bar(struct status_bar *sb) +{ wimp_window_state state; os_error *error; int left, right; diff --git a/riscos/gui/status_bar.h b/riscos/gui/status_bar.h index 0c4d35412..8b5bb35aa 100644 --- a/riscos/gui/status_bar.h +++ b/riscos/gui/status_bar.h @@ -20,11 +20,11 @@ * UTF8 status bar (interface). */ -#include - #ifndef _NETSURF_RISCOS_STATUS_BAR_H_ #define _NETSURF_RISCOS_STATUS_BAR_H_ +#include + struct status_bar; struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width); diff --git a/riscos/help.c b/riscos/help.c index fb0aa97de..463cb0d70 100644 --- a/riscos/help.c +++ b/riscos/help.c @@ -86,7 +86,8 @@ static os_t help_time = 0; * * \param message the request message */ -void ro_gui_interactive_help_request(wimp_message *message) { +void ro_gui_interactive_help_request(wimp_message *message) +{ char message_token[32]; char menu_buffer[4]; wimp_selection menu_tree; @@ -209,7 +210,8 @@ void ro_gui_interactive_help_request(wimp_message *message) { * \param token the token to look up */ static void ro_gui_interactive_help_broadcast(wimp_message *message, - char *token) { + char *token) +{ const char *translated_token; help_full_message_reply *reply; char *base_token; @@ -277,7 +279,8 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, * * \return non-zero if interactive help is available, or 0 if not available */ -bool ro_gui_interactive_help_available(void) { +bool ro_gui_interactive_help_available(void) +{ taskmanager_task task; int context = 0; os_t time; @@ -316,7 +319,8 @@ bool ro_gui_interactive_help_available(void) { /** * Launches interactive help. */ -void ro_gui_interactive_help_start(void) { +void ro_gui_interactive_help_start(void) +{ char *help_start; wimp_t task = 0; os_error *error; diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 4608c5647..fee9f2d41 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -74,7 +74,8 @@ static const struct { }; #define ENTRIES_COUNT (sizeof(default_entries) / sizeof(default_entries[0])) -void ro_gui_hotlist_initialise(void) { +void ro_gui_hotlist_initialise(void) +{ FILE *fp; struct node *node; const struct url_data *data; @@ -153,7 +154,8 @@ void ro_gui_hotlist_initialise(void) { /** * Perform a save to the default file */ -void ro_gui_hotlist_save(void) { +void ro_gui_hotlist_save(void) +{ os_error *error; if (!hotlist_tree) @@ -175,7 +177,8 @@ void ro_gui_hotlist_save(void) { * * \param pointer the pointer state */ -bool ro_gui_hotlist_click(wimp_pointer *pointer) { +bool ro_gui_hotlist_click(wimp_pointer *pointer) +{ ro_gui_tree_click(pointer, hotlist_tree); if (pointer->buttons == wimp_CLICK_MENU) ro_gui_menu_create(hotlist_menu, pointer->pos.x, @@ -191,7 +194,8 @@ bool ro_gui_hotlist_click(wimp_pointer *pointer) { * * \param content the content visited */ -void hotlist_visited(struct content *content) { +void hotlist_visited(struct content *content) +{ if ((!content) || (!content->url) || (!hotlist_tree)) return; ro_gui_hotlist_visited(content, hotlist_tree, hotlist_tree->root); @@ -206,7 +210,8 @@ void hotlist_visited(struct content *content) { * \param node the node to update siblings and children of */ void ro_gui_hotlist_visited(struct content *content, struct tree *tree, - struct node *node) { + struct node *node) +{ struct node_element *element; for (; node; node = node->next) { @@ -230,7 +235,8 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree, * * \param node the node to prepare the dialogue for, or NULL */ -void ro_gui_hotlist_prepare_folder_dialog(struct node *node) { +void ro_gui_hotlist_prepare_folder_dialog(struct node *node) +{ const char *name; const char *title; @@ -253,7 +259,8 @@ void ro_gui_hotlist_prepare_folder_dialog(struct node *node) { * * \param node the node to prepare the dialogue for, or NULL */ -void ro_gui_hotlist_prepare_entry_dialog(struct node *node) { +void ro_gui_hotlist_prepare_entry_dialog(struct node *node) +{ struct node_element *element; const char *name; const char *title; @@ -281,7 +288,8 @@ void ro_gui_hotlist_prepare_entry_dialog(struct node *node) { * * \param w the window to apply */ -bool ro_gui_hotlist_dialog_apply(wimp_w w) { +bool ro_gui_hotlist_dialog_apply(wimp_w w) +{ struct node_element *element; struct node *node; char *title; @@ -356,11 +364,11 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) { } else { element = tree_find_element(node, TREE_ELEMENT_URL); if (element) { - free(element->text); + free((void *)element->text); element->text = url; ro_gui_set_icon_string(w, ICON_ENTRY_URL, url); } - free(node->data.text); + free((void *)node->data.text); node->data.text = title; tree_handle_node_changed(hotlist_tree, node, true, false); } diff --git a/riscos/image.c b/riscos/image.c index 2a43e619f..7826ad7e4 100644 --- a/riscos/image.c +++ b/riscos/image.c @@ -17,11 +17,9 @@ */ #include -#include - +#include "swis.h" #include "oslib/colourtrans.h" -#include - +#include "oslib/osspriteop.h" #include "riscos/image.h" #include "riscos/gui.h" #include "riscos/options.h" diff --git a/riscos/image.h b/riscos/image.h index 7a9dc55cc..0997b793d 100644 --- a/riscos/image.h +++ b/riscos/image.h @@ -19,7 +19,8 @@ #ifndef _NETSURF_RISCOS_IMAGE_H_ #define _NETSURF_RISCOS_IMAGE_H_ -#include +#include +#include "oslib/osspriteop.h" struct osspriteop_area; diff --git a/riscos/menus.c b/riscos/menus.c index bee1890c4..7bd248baf 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -460,7 +460,8 @@ void ro_gui_menu_init(void) /** * Display a menu. */ -void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) { +void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) +{ struct gui_window *g; os_error *error; os_coord pos; @@ -531,7 +532,8 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) { * \param w window handle * \param i icon handle */ -void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) { +void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) +{ wimp_window_state state; wimp_icon_state icon_state; os_error *error; @@ -568,7 +570,8 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) { * * \param cleanup Call any terminating functions (sub-window isn't going to be instantly re-opened) */ -void ro_gui_menu_closed(bool cleanup) { +void ro_gui_menu_closed(bool cleanup) +{ struct gui_window *g; struct browser_window *bw; struct content *c; @@ -606,7 +609,8 @@ void ro_gui_menu_closed(bool cleanup) { /** * The content has changed, reset object references */ -void ro_gui_menu_objects_moved(void) { +void ro_gui_menu_objects_moved(void) +{ gui_form_select_control = NULL; current_menu_object_box = NULL; @@ -619,7 +623,8 @@ void ro_gui_menu_objects_moved(void) { /** * Handle menu selection. */ -void ro_gui_menu_selection(wimp_selection *selection) { +void ro_gui_menu_selection(wimp_selection *selection) +{ int i, j; wimp_menu_entry *menu_entry; menu_action action; @@ -718,7 +723,8 @@ void ro_gui_menu_selection(wimp_selection *selection) { /** * Handle Message_MenuWarning. */ -void ro_gui_menu_warning(wimp_message_menu_warning *warning) { +void ro_gui_menu_warning(wimp_message_menu_warning *warning) +{ int i; menu_action action; wimp_menu_entry *menu_entry; @@ -774,7 +780,8 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) { * * \param toolbar the toolbar to update */ -void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) { +void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) +{ assert(toolbar); @@ -829,7 +836,8 @@ bool ro_gui_menu_prepare_url_suggest(void) { * * /param gui the gui_window to update */ -void ro_gui_prepare_navigate(struct gui_window *gui) { +void ro_gui_prepare_navigate(struct gui_window *gui) +{ int suggestions; ro_gui_menu_prepare_action(gui->window, HOTLIST_SHOW, false); @@ -859,7 +867,8 @@ void ro_gui_prepare_navigate(struct gui_window *gui) { * * \param g the gui_window to set the display icons for */ -void ro_gui_menu_prepare_pageinfo(struct gui_window *g) { +void ro_gui_menu_prepare_pageinfo(struct gui_window *g) +{ struct content *c = g->bw->current_content; char icon_buf[20] = "file_xxx"; char enc_buf[40]; @@ -908,7 +917,8 @@ void ro_gui_menu_prepare_pageinfo(struct gui_window *g) { * * \param box the box to set the display icons for */ -void ro_gui_menu_prepare_objectinfo(struct box *box) { +void ro_gui_menu_prepare_objectinfo(struct box *box) +{ char icon_buf[20] = "file_xxx"; const char *url = "-"; const char *target = "-"; @@ -940,7 +950,8 @@ void ro_gui_menu_prepare_objectinfo(struct box *box) { * \param control form control of type GADGET_SELECT */ void gui_create_form_select_menu(struct browser_window *bw, - struct form_control *control) { + struct form_control *control) +{ unsigned int i, entries; char *text_convert, *temp; struct form_option *option; @@ -1063,7 +1074,8 @@ void gui_create_form_select_menu(struct browser_window *bw, * \param menu the data to create the menu with * \return the menu created, or NULL on failure */ -wimp_menu *ro_gui_menu_define_menu(struct ns_menu *menu) { +wimp_menu *ro_gui_menu_define_menu(struct ns_menu *menu) +{ struct menu_definition *definition; int entry; @@ -1108,7 +1120,8 @@ wimp_menu *ro_gui_menu_define_menu(struct ns_menu *menu) { void ro_gui_menu_define_menu_add(struct menu_definition *definition, struct ns_menu *menu, int depth, wimp_menu_entry *parent_entry, int first, int last, - const char *prefix, int prefix_length) { + const char *prefix, int prefix_length) +{ int entry, id, cur_depth; int entries = 0; int matches[last - first + 1]; @@ -1231,7 +1244,8 @@ void ro_gui_menu_define_menu_add(struct menu_definition *definition, * Initialise the basic state of a menu structure so all entries are * indirected text with no flags, no submenu. */ -void ro_gui_menu_init_structure(wimp_menu *menu, int entries) { +void ro_gui_menu_init_structure(wimp_menu *menu, int entries) +{ int i; menu->title_fg = wimp_COLOUR_BLACK; @@ -1261,7 +1275,8 @@ void ro_gui_menu_init_structure(wimp_menu *menu, int entries) { * \param menu the menu to find the definition for * \return the associated definition, or NULL if one could not be found */ -struct menu_definition *ro_gui_menu_find_menu(wimp_menu *menu) { +struct menu_definition *ro_gui_menu_find_menu(wimp_menu *menu) +{ struct menu_definition *definition; if (!menu) @@ -1283,7 +1298,8 @@ struct menu_definition *ro_gui_menu_find_menu(wimp_menu *menu) { * \return the original message key, or NULL if one could not be found */ const char *ro_gui_menu_find_menu_entry_key(wimp_menu *menu, - const char *translated) { + const char *translated) +{ struct menu_definition_entry *entry; struct menu_definition *definition = ro_gui_menu_find_menu(menu); @@ -1305,7 +1321,8 @@ const char *ro_gui_menu_find_menu_entry_key(wimp_menu *menu, * \return the associated menu entry, or NULL if one could not be found */ struct menu_definition_entry *ro_gui_menu_find_entry(wimp_menu *menu, - menu_action action) { + menu_action action) +{ struct menu_definition_entry *entry; struct menu_definition *definition = ro_gui_menu_find_menu(menu); @@ -1326,7 +1343,8 @@ struct menu_definition_entry *ro_gui_menu_find_entry(wimp_menu *menu, * \param menu_entry the menu_entry to find * \return the associated action, or 0 if one could not be found */ -menu_action ro_gui_menu_find_action(wimp_menu *menu, wimp_menu_entry *menu_entry) { +menu_action ro_gui_menu_find_action(wimp_menu *menu, wimp_menu_entry *menu_entry) +{ struct menu_definition_entry *entry; struct menu_definition *definition = ro_gui_menu_find_menu(menu); @@ -1349,7 +1367,8 @@ menu_action ro_gui_menu_find_action(wimp_menu *menu, wimp_menu_entry *menu_entry * \param ticked whether to set the item as ticked */ void ro_gui_menu_set_entry_shaded(wimp_menu *menu, menu_action action, - bool shaded) { + bool shaded) +{ struct menu_definition_entry *entry; struct menu_definition *definition = ro_gui_menu_find_menu(menu); @@ -1375,7 +1394,8 @@ void ro_gui_menu_set_entry_shaded(wimp_menu *menu, menu_action action, * \param ticked whether to set the item as ticked */ void ro_gui_menu_set_entry_ticked(wimp_menu *menu, menu_action action, - bool ticked) { + bool ticked) +{ struct menu_definition_entry *entry = ro_gui_menu_find_entry(menu, action); if (entry) { @@ -2249,7 +2269,8 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, */ void ro_gui_menu_get_window_details(wimp_w w, struct gui_window **g, struct browser_window **bw, struct content **content, - struct toolbar **toolbar, struct tree **tree) { + struct toolbar **toolbar, struct tree **tree) +{ *g = ro_gui_window_lookup(w); if (*g) { *bw = (*g)->bw; @@ -2280,7 +2301,8 @@ void ro_gui_menu_get_window_details(wimp_w w, struct gui_window **g, /** * Calculates a simple checksum for the current menu state */ -int ro_gui_menu_get_checksum(void) { +int ro_gui_menu_get_checksum(void) +{ wimp_selection menu_tree; int i = 0, j, checksum = 0; os_error *error; diff --git a/riscos/message.c b/riscos/message.c index 7a5e01ffe..5a9bb15fa 100644 --- a/riscos/message.c +++ b/riscos/message.c @@ -54,7 +54,8 @@ static void ro_message_free(int ref); * \return true on success, false otherwise */ bool ro_message_send_message(wimp_event_no event, wimp_message *message, - wimp_t task, void (*callback)(wimp_message *message)) { + wimp_t task, void (*callback)(wimp_message *message)) +{ os_error *error; assert(message); @@ -91,7 +92,8 @@ bool ro_message_send_message(wimp_event_no event, wimp_message *message, */ bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *message, wimp_w to_w, wimp_i to_i, void (*callback)(wimp_message *message), - wimp_t *to_t) { + wimp_t *to_t) +{ os_error *error; assert(message); @@ -128,7 +130,8 @@ bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *messag */ bool ro_message_register_handler(wimp_message *message, unsigned int message_code, - void (*callback)(wimp_message *message)) { + void (*callback)(wimp_message *message)) +{ struct active_message *add; assert(message); @@ -149,14 +152,16 @@ bool ro_message_register_handler(wimp_message *message, * \return true on success, false on memory exhaustion */ bool ro_message_register_route(unsigned int message_code, - void (*callback)(wimp_message *message)) { + void (*callback)(wimp_message *message)) +{ assert(callback); return (ro_message_add(message_code, callback) != NULL); } struct active_message *ro_message_add(unsigned int message_code, - void (*callback)(wimp_message *message)) { + void (*callback)(wimp_message *message)) +{ struct active_message *add; assert(callback); @@ -180,7 +185,8 @@ struct active_message *ro_message_add(unsigned int message_code, * \param message the message to attempt to route * \return true if message was routed, false otherwise */ -bool ro_message_handle_message(wimp_event_no event, wimp_message *message) { +bool ro_message_handle_message(wimp_event_no event, wimp_message *message) +{ struct active_message *test; bool handled = false; int ref; @@ -221,7 +227,8 @@ bool ro_message_handle_message(wimp_event_no event, wimp_message *message) { } -void ro_message_free(int ref) { +void ro_message_free(int ref) +{ struct active_message *test; struct active_message *next = current_messages; diff --git a/riscos/message.h b/riscos/message.h index 0411db533..8c1a515f2 100644 --- a/riscos/message.h +++ b/riscos/message.h @@ -1,41 +1,42 @@ -/* - * Copyright 2006 Richard Wilson - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * Automated RISC OS message routing (interface). - */ - - -#ifndef _NETSURF_RISCOS_MESSAGE_H_ -#define _NETSURF_RISCOS_MESSAGE_H_ - -#include "oslib/wimp.h" - -bool ro_message_send_message(wimp_event_no event, wimp_message *message, - wimp_t task, void (*callback)(wimp_message *message)); -bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *message, - wimp_w to_w, wimp_i to_i, void (*callback)(wimp_message *message), - wimp_t *to_t); -bool ro_message_register_handler(wimp_message *message, - unsigned int message_code, - void (*callback)(wimp_message *message)); -bool ro_message_register_route(unsigned int message_code, - void (*callback)(wimp_message *message)); -bool ro_message_handle_message(wimp_event_no event, wimp_message *message); - -#endif +/* + * Copyright 2006 Richard Wilson + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * Automated RISC OS message routing (interface). + */ + + +#ifndef _NETSURF_RISCOS_MESSAGE_H_ +#define _NETSURF_RISCOS_MESSAGE_H_ + +#include +#include "oslib/wimp.h" + +bool ro_message_send_message(wimp_event_no event, wimp_message *message, + wimp_t task, void (*callback)(wimp_message *message)); +bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *message, + wimp_w to_w, wimp_i to_i, void (*callback)(wimp_message *message), + wimp_t *to_t); +bool ro_message_register_handler(wimp_message *message, + unsigned int message_code, + void (*callback)(wimp_message *message)); +bool ro_message_register_route(unsigned int message_code, + void (*callback)(wimp_message *message)); +bool ro_message_handle_message(wimp_event_no event, wimp_message *message); + +#endif diff --git a/riscos/options.h b/riscos/options.h index 8a1f5b9bd..96a0d5a8b 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -25,6 +25,7 @@ #ifndef _NETSURF_RISCOS_OPTIONS_H_ #define _NETSURF_RISCOS_OPTIONS_H_ +#include #include "desktop/options.h" #include "riscos/tinct.h" diff --git a/riscos/plotters.c b/riscos/plotters.c index 512e0572e..18b53701a 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -20,6 +20,7 @@ * Target independent plotting (RISC OS screen implementation). */ +#include #include #include "oslib/colourtrans.h" #include "oslib/draw.h" diff --git a/riscos/plugin.c b/riscos/plugin.c index dd10b3a2d..15a37d5f3 100644 --- a/riscos/plugin.c +++ b/riscos/plugin.c @@ -42,7 +42,6 @@ #include #include #include - #include "oslib/mimemap.h" #include "oslib/os.h" #include "oslib/osfile.h" @@ -50,7 +49,6 @@ #include "oslib/osgbpb.h" #include "oslib/plugin.h" #include "oslib/wimp.h" - #include "utils/config.h" #include "content/content.h" #include "content/fetch.h" diff --git a/riscos/plugin.h b/riscos/plugin.h index 82cda20ee..5bd7b4abc 100644 --- a/riscos/plugin.h +++ b/riscos/plugin.h @@ -20,8 +20,8 @@ #define _NETSURF_RISCOS_PLUGIN_H_ #include -#include -#include +#include "oslib/plugin.h" +#include "oslib/wimp.h" struct box; struct browser_window; diff --git a/riscos/print.c b/riscos/print.c index 66d1774e1..e75bd1d6a 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -113,10 +113,11 @@ static bool print_fonts_plot_disc(int x, int y, int radius, colour c, static bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c); static bool print_fonts_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg); + struct bitmap *bitmap, colour bg, + struct content *content); static bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y); + bool repeat_x, bool repeat_y, struct content *content); static bool print_fonts_plot_group_start(const char *name); static bool print_fonts_plot_group_end(void); static void print_fonts_callback(void *context, @@ -813,30 +814,62 @@ end: } -bool print_fonts_plot_clg(colour c) { return true; } +bool print_fonts_plot_clg(colour c) +{ + return true; +} bool print_fonts_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed) - { return true; } +{ + return true; +} bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed) { return true; } + colour c, bool dotted, bool dashed) +{ + return true; +} bool print_fonts_plot_polygon(int *p, unsigned int n, colour fill) - { return true; } +{ + return true; +} bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c) - { return true; } +{ + return true; +} bool print_fonts_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1) { return true; } -bool print_fonts_plot_disc(int x, int y, int radius, colour colour, bool filled) - { return true; } + int clip_x1, int clip_y1) +{ + return true; +} +bool print_fonts_plot_disc(int x, int y, int radius, colour colour, + bool filled) +{ + return true; +} bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c) - { return true; } +{ + return true; +} bool print_fonts_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg) { return true; } + struct bitmap *bitmap, colour bg, struct content *content) +{ + return true; +} bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y) { return true; } -bool print_fonts_plot_group_start(const char *name) { return true; } -bool print_fonts_plot_group_end(void) { return true; } + bool repeat_x, bool repeat_y, struct content *content) +{ + return true; +} +bool print_fonts_plot_group_start(const char *name) +{ + return true; +} +bool print_fonts_plot_group_end(void) +{ + return true; +} /** diff --git a/riscos/print.h b/riscos/print.h index af4c3b3aa..4859d305a 100644 --- a/riscos/print.h +++ b/riscos/print.h @@ -19,6 +19,9 @@ #ifndef _NETSURF_RISCOS_PRINT_H_ #define _NETSURF_RISCOS_PRINT_H_ +#include +#include "oslib/wimp.h" + struct gui_window; extern struct gui_window *print_current_window; diff --git a/riscos/query.c b/riscos/query.c index 0f440f5e9..7c284ddce 100644 --- a/riscos/query.c +++ b/riscos/query.c @@ -20,6 +20,7 @@ #include #include +#include #include "riscos/dialog.h" #include "riscos/query.h" #include "riscos/wimp.h" diff --git a/riscos/query.h b/riscos/query.h index 09010f995..7105bef8e 100644 --- a/riscos/query.h +++ b/riscos/query.h @@ -18,12 +18,11 @@ #ifndef _NETSURF_RISCOS_QUERY_H #define _NETSURF_RISCOS_QUERY_H + #include #include "oslib/wimp.h" #include "utils/utils.h" -struct gui_query_window; - void ro_gui_query_init(void); void ro_gui_query_window_bring_to_front(query_id id); diff --git a/riscos/save.c b/riscos/save.c index 549b9e003..bdaf92615 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -28,13 +28,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "oslib/dragasprite.h" +#include "oslib/osbyte.h" +#include "oslib/osfile.h" +#include "oslib/osmodule.h" +#include "oslib/osspriteop.h" +#include "oslib/wimp.h" +#include "oslib/wimpspriteop.h" #include "desktop/netsurf.h" #include "desktop/save_text.h" #include "desktop/selection.h" diff --git a/riscos/save.h b/riscos/save.h index 38db2f45a..fd65fa996 100644 --- a/riscos/save.h +++ b/riscos/save.h @@ -23,10 +23,10 @@ #ifndef _NETSURF_RISCOS_SAVE_H_ #define _NETSURF_RISCOS_SAVE_H_ +#include #include "oslib/wimp.h" #include "desktop/gui.h" - wimp_w ro_gui_saveas_create(const char *template_name); void ro_gui_saveas_quit(void); void ro_gui_save_prepare(gui_save_type save_type, struct content *c); diff --git a/riscos/save_complete.c b/riscos/save_complete.c index e04626585..25f45409e 100644 --- a/riscos/save_complete.c +++ b/riscos/save_complete.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include "oslib/osfile.h" #include "utils/config.h" #include "content/content.h" #include "css/css.h" @@ -66,7 +66,7 @@ static bool rewrite_url(xmlNode *n, const char *attr, const char *base); static bool save_complete_list_add(struct content *content); static struct content * save_complete_list_find(const char *url); static bool save_complete_list_check(struct content *content); -static void save_complete_list_dump(void); +/* static void save_complete_list_dump(void); */ static bool save_complete_inventory(const char *path); /** @@ -728,6 +728,8 @@ bool save_complete_list_check(struct content *content) return false; } + +#if 0 /** * Dump save complete list to stderr */ @@ -738,6 +740,7 @@ void save_complete_list_dump(void) fprintf(stderr, "%p : %s\n", entry->content, entry->content->url); } +#endif /** diff --git a/riscos/save_complete.h b/riscos/save_complete.h index 043f357b8..63db0e44d 100644 --- a/riscos/save_complete.h +++ b/riscos/save_complete.h @@ -23,6 +23,7 @@ #ifndef _NETSURF_RISCOS_SAVE_COMPLETE_H_ #define _NETSURF_RISCOS_SAVE_COMPLETE_H_ +#include struct content; void save_complete_init(void); diff --git a/riscos/save_draw.c b/riscos/save_draw.c index 1af1db6f9..f00f36509 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -24,9 +24,9 @@ #include #include -#include -#include -#include +#include "oslib/draw.h" +#include "oslib/osfile.h" +#include "pencil.h" #include "content/content.h" #include "desktop/plotters.h" #include "riscos/bitmap.h" diff --git a/riscos/save_draw.h b/riscos/save_draw.h index d8ce8e8a2..90d81c980 100644 --- a/riscos/save_draw.h +++ b/riscos/save_draw.h @@ -19,6 +19,7 @@ #ifndef _NETSURF_RISCOS_SAVE_DRAW_H_ #define _NETSURF_RISCOS_SAVE_DRAW_H_ +#include struct content; bool save_as_draw(struct content *c, const char *path); diff --git a/riscos/save_pdf.c b/riscos/save_pdf.c index a5d2b010a..a7d0903f4 100644 --- a/riscos/save_pdf.c +++ b/riscos/save_pdf.c @@ -20,7 +20,8 @@ * Export a content as a PDF file (implementation). */ -#include +#include +#include "oslib/osfile.h" #include "content/content.h" #include "desktop/print.h" #include "pdf/pdf_plotters.h" diff --git a/riscos/save_pdf.h b/riscos/save_pdf.h index 69f998764..ed7bae393 100644 --- a/riscos/save_pdf.h +++ b/riscos/save_pdf.h @@ -20,10 +20,9 @@ #define _NETSURF_RISCOS_SAVE_PDF_H_ #include "utils/config.h" +#include "content/content.h" #ifdef WITH_PDF_EXPORT -struct content; - bool save_as_pdf(struct content *c, const char *path); #endif diff --git a/riscos/search.c b/riscos/search.c index 8226fee92..63678828c 100644 --- a/riscos/search.c +++ b/riscos/search.c @@ -23,10 +23,8 @@ #include #include - #include "oslib/hourglass.h" #include "oslib/wimp.h" - #include "utils/config.h" #include "content/content.h" #include "desktop/browser.h" diff --git a/riscos/sprite.c b/riscos/sprite.c index 7867c8b1d..685da088e 100644 --- a/riscos/sprite.c +++ b/riscos/sprite.c @@ -28,7 +28,7 @@ #include #include -#include +#include "oslib/osspriteop.h" #include "utils/config.h" #include "desktop/plotters.h" #include "content/content.h" diff --git a/riscos/sprite.h b/riscos/sprite.h index 8cdfd685d..4b3ba8db3 100644 --- a/riscos/sprite.h +++ b/riscos/sprite.h @@ -24,7 +24,7 @@ #define _NETSURF_RISCOS_SPRITE_H_ #include -#include +#include "oslib/osspriteop.h" struct content; diff --git a/riscos/textarea.c b/riscos/textarea.c index 49b31b704..eaa6961b9 100644 --- a/riscos/textarea.c +++ b/riscos/textarea.c @@ -24,17 +24,13 @@ #include #include #include - #include "swis.h" - #include "oslib/colourtrans.h" #include "oslib/osbyte.h" #include "oslib/serviceinternational.h" #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" - #include "rufl.h" - #include "riscos/gui.h" #include "riscos/oslib_pre7.h" #include "riscos/textarea.h" diff --git a/riscos/theme.c b/riscos/theme.c index 8e57c40ac..a540f3b43 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -30,7 +30,7 @@ #include "oslib/osgbpb.h" #include "oslib/osfile.h" #include "oslib/osfind.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimpspriteop.h" #include "oslib/squash.h" #include "oslib/wimp.h" @@ -129,7 +129,8 @@ static char theme_favicon_sprite[12]; /** * Initialise the theme handler */ -void ro_gui_theme_initialise(void) { +void ro_gui_theme_initialise(void) +{ struct theme_descriptor *descriptor; theme_descriptors = ro_gui_theme_get_available(); @@ -143,7 +144,8 @@ void ro_gui_theme_initialise(void) { /** * Finalise the theme handler */ -void ro_gui_theme_finalise(void) { +void ro_gui_theme_finalise(void) +{ ro_gui_theme_close(theme_current, false); ro_gui_theme_free(theme_descriptors); } @@ -159,7 +161,8 @@ void ro_gui_theme_finalise(void) { * \param leafname the filename of the theme_descriptor to return * \return the requested theme_descriptor, or NULL if not found */ -struct theme_descriptor *ro_gui_theme_find(const char *leafname) { +struct theme_descriptor *ro_gui_theme_find(const char *leafname) +{ struct theme_descriptor *descriptor; if (!leafname) @@ -183,7 +186,8 @@ struct theme_descriptor *ro_gui_theme_find(const char *leafname) { * * \return the requested theme_descriptor, or NULL if not found */ -struct theme_descriptor *ro_gui_theme_get_available(void) { +struct theme_descriptor *ro_gui_theme_get_available(void) +{ struct theme_descriptor *current; struct theme_descriptor *test; @@ -229,7 +233,8 @@ struct theme_descriptor *ro_gui_theme_get_available(void) { * * \param directory the directory to scan */ -static void ro_gui_theme_get_available_in_dir(const char *directory) { +static void ro_gui_theme_get_available_in_dir(const char *directory) +{ int context = 0; int read_count; osgbpb_INFO(100) info; @@ -263,7 +268,8 @@ static void ro_gui_theme_get_available_in_dir(const char *directory) { * \param leafname the theme leafname * \return whether the theme was added */ -bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) { +bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) +{ struct theme_file_header file_header; struct theme_descriptor *current; struct theme_descriptor *test; @@ -358,8 +364,8 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) { * \return false for a badly formed theme, true otherwise */ bool ro_gui_theme_read_file_header(struct theme_descriptor *descriptor, - struct theme_file_header *file_header) { - + struct theme_file_header *file_header) +{ if ((file_header->magic_value != 0x4d54534e) || (file_header->parser_version > 2)) return false; @@ -393,7 +399,8 @@ bool ro_gui_theme_read_file_header(struct theme_descriptor *descriptor, * \param list whether to open all themes in the list * \return whether the operation was successful */ -bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) { +bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) +{ fileswitch_object_type obj_type; squash_output_status status; os_coord dimensions; @@ -560,7 +567,8 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) { * \param descriptor the theme_descriptor to open * \return whether the operation was successful */ -bool ro_gui_theme_apply(struct theme_descriptor *descriptor) { +bool ro_gui_theme_apply(struct theme_descriptor *descriptor) +{ struct theme_descriptor *theme_previous; /* check if the theme is already applied */ @@ -590,7 +598,8 @@ bool ro_gui_theme_apply(struct theme_descriptor *descriptor) { * \param list whether to open all themes in the list * \return whether the operation was successful */ -void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list) { +void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list) +{ if (!descriptor) return; @@ -622,7 +631,8 @@ void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list) { * \param redraw the redraw area * \param toolbar the toolbar to redraw */ -void ro_gui_theme_redraw(wimp_draw *redraw) { +void ro_gui_theme_redraw(wimp_draw *redraw) +{ struct toolbar *toolbar; struct gui_window *g; @@ -706,7 +716,8 @@ void ro_gui_theme_redraw(wimp_draw *redraw) { * \param list whether to open all themes in the list * \return whether the operation was successful */ -void ro_gui_theme_free(struct theme_descriptor *descriptor) { +void ro_gui_theme_free(struct theme_descriptor *descriptor) +{ struct theme_descriptor *next_descriptor; if (!descriptor) @@ -749,7 +760,8 @@ void ro_gui_theme_free(struct theme_descriptor *descriptor) { * \return a new toolbar, or NULL for failure */ struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, - toolbar_type type) { + toolbar_type type) +{ struct toolbar *toolbar; /* Create a new toolbar @@ -854,7 +866,8 @@ struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, * \return whether the operation was successful */ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, - struct toolbar *toolbar) { + struct toolbar *toolbar) +{ wimp_icon_create new_icon; os_error *error; osspriteop_area *sprite_area; @@ -1131,7 +1144,8 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, * \param parent the window to contain the toolbar * \return whether the operation was successful */ -bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent) { +bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent) +{ wimp_outline outline; wimp_window_state state; int height; @@ -1222,7 +1236,8 @@ bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent) { * \param width a specific width to resize to, or -1 to use parent width * \return whether the operation was successful */ -bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { +bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) +{ wimp_caret caret; os_box extent = { 0, 0, 0, 0 }; os_error *error; @@ -1533,7 +1548,8 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { * * \param toolbar the toolbar to destroy */ -void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) { +void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) +{ struct toolbar_icon *icon; struct toolbar_icon *next_icon; if (!toolbar) return; @@ -1572,7 +1588,8 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) { * * \param toolbar the toolbar to toggle editing for */ -void ro_gui_theme_toggle_edit(struct toolbar *toolbar) { +void ro_gui_theme_toggle_edit(struct toolbar *toolbar) +{ int icons = 0; struct toolbar_icon *icon; struct gui_window *g = NULL; @@ -1713,7 +1730,8 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) { * * \param toolbar the toolbar to synchronise */ -void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar) { +void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar) +{ struct toolbar_icon *icon; struct toolbar_icon *icon_edit; @@ -1802,7 +1820,8 @@ void ro_gui_theme_toolbar_editor_click(struct toolbar *toolbar, * * \param drag the details for the drag end */ -void ro_gui_theme_toolbar_editor_drag_end(wimp_dragged *drag) { +void ro_gui_theme_toolbar_editor_drag_end(wimp_dragged *drag) +{ wimp_window_state state; os_error *error; wimp_pointer pointer; @@ -1903,7 +1922,8 @@ void ro_gui_theme_toolbar_editor_drag_end(wimp_dragged *drag) { * \param icon_number RISC OS wimp icon number for the icon (not separators) */ struct toolbar_icon *ro_gui_theme_add_toolbar_icon(struct toolbar *toolbar, - const char *name, int icon_number) { + const char *name, int icon_number) +{ struct toolbar_icon *toolbar_icon; struct toolbar_icon *link_icon; @@ -1948,7 +1968,8 @@ struct toolbar_icon *ro_gui_theme_add_toolbar_icon(struct toolbar *toolbar, * \param icon the toolbar icon to update */ void ro_gui_theme_update_toolbar_icon(struct toolbar *toolbar, - struct toolbar_icon *icon) { + struct toolbar_icon *icon) +{ os_coord dimensions = {0, 0}; os_mode mode; os_error *error = NULL; @@ -2002,7 +2023,8 @@ void ro_gui_theme_update_toolbar_icon(struct toolbar *toolbar, * * \param icon the toolbar icon to destroy */ -void ro_gui_theme_destroy_toolbar_icon(struct toolbar_icon *icon) { +void ro_gui_theme_destroy_toolbar_icon(struct toolbar_icon *icon) +{ free(icon); } @@ -2014,7 +2036,8 @@ void ro_gui_theme_destroy_toolbar_icon(struct toolbar_icon *icon) { */ void ro_gui_theme_link_toolbar_icon(struct toolbar *toolbar, struct toolbar_icon *icon, struct toolbar_icon *link, - bool before) { + bool before) +{ struct toolbar_icon *temp; assert(toolbar); assert(icon); @@ -2049,7 +2072,8 @@ void ro_gui_theme_link_toolbar_icon(struct toolbar *toolbar, * \param icon the toolbar icon to delink */ void ro_gui_theme_delink_toolbar_icon(struct toolbar *toolbar, - struct toolbar_icon *icon) { + struct toolbar_icon *icon) +{ struct toolbar_icon *link; assert(toolbar); assert(icon); @@ -2078,7 +2102,8 @@ void ro_gui_theme_delink_toolbar_icon(struct toolbar *toolbar, * \return the toolbar icon at the specified position, or NULL for no icon */ struct toolbar_icon *ro_gui_theme_toolbar_get_icon(struct toolbar *toolbar, - int x, int y) { + int x, int y) +{ struct toolbar_icon *icon; for (icon = toolbar->icon; icon; icon = icon->next) @@ -2101,7 +2126,8 @@ struct toolbar_icon *ro_gui_theme_toolbar_get_icon(struct toolbar *toolbar, * \return the toolbar icon closest to the specified position, or NULL */ struct toolbar_icon *ro_gui_theme_toolbar_get_insert_icon( - struct toolbar *toolbar, int x, int y, bool *before) { + struct toolbar *toolbar, int x, int y, bool *before) +{ struct toolbar_icon *match = NULL; struct toolbar_icon *icon; int closest = 65536; @@ -2130,7 +2156,8 @@ struct toolbar_icon *ro_gui_theme_toolbar_get_insert_icon( * Sets up a toolbar with icons according to an identifier string */ void ro_gui_theme_add_toolbar_icons(struct toolbar *toolbar, - const char* icons[], const char* ident) { + const char* icons[], const char* ident) +{ struct toolbar_icon *icon; int index = 0; int number = 0; @@ -2173,7 +2200,8 @@ void ro_gui_theme_add_toolbar_icons(struct toolbar *toolbar, /** * Sets the correct help prefix for a toolbar */ -void ro_gui_theme_set_help_prefix(struct toolbar *toolbar) { +void ro_gui_theme_set_help_prefix(struct toolbar *toolbar) +{ if (toolbar->editor) { ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle, "HelpEditToolbar"); @@ -2206,7 +2234,8 @@ void ro_gui_theme_set_help_prefix(struct toolbar *toolbar) { } } -int ro_gui_theme_height_change(struct toolbar *toolbar) { +int ro_gui_theme_height_change(struct toolbar *toolbar) +{ int height, cur_height; cur_height = ro_gui_theme_toolbar_full_height(toolbar); diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c index f8cd37217..244c6268f 100644 --- a/riscos/thumbnail.c +++ b/riscos/thumbnail.c @@ -30,7 +30,7 @@ #include "rufl.h" #include "oslib/colourtrans.h" #include "oslib/osfile.h" -#include +#include "oslib/osspriteop.h" #include "content/content.h" #include "content/urldb.h" #include "desktop/plotters.h" diff --git a/riscos/thumbnail.h b/riscos/thumbnail.h index 6824b2a7a..bea587668 100644 --- a/riscos/thumbnail.h +++ b/riscos/thumbnail.h @@ -21,7 +21,7 @@ * Page thumbnail creation (interface). */ -#include +#include "oslib/osspriteop.h" #include "image/bitmap.h" osspriteop_area *thumbnail_convert_8bpp(struct bitmap *bitmap); diff --git a/riscos/treeview.c b/riscos/treeview.c index ccef58017..819c2f178 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -30,7 +30,7 @@ #include "oslib/colourtrans.h" #include "oslib/dragasprite.h" #include "oslib/osbyte.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "content/urldb.h" #include "desktop/browser.h" @@ -97,7 +97,8 @@ struct node_update { /** * Performs any initialisation for tree rendering */ -bool ro_gui_tree_initialise(void) { +bool ro_gui_tree_initialise(void) +{ if (ro_gui_tree_initialise_sprite("expand", TREE_EXPAND) || ro_gui_tree_initialise_sprite("collapse", TREE_COLLAPSE)) return false; @@ -122,7 +123,8 @@ bool ro_gui_tree_initialise(void) { * \param number the sprite cache number * \return whether an error occurred during initialisation */ -bool ro_gui_tree_initialise_sprite(const char *name, int number) { +bool ro_gui_tree_initialise_sprite(const char *name, int number) +{ char icon_name[12]; os_error *error; @@ -148,7 +150,8 @@ bool ro_gui_tree_initialise_sprite(const char *name, int number) { * \param width the width of the redraw area * \param height the height of the redraw area */ -void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) { +void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) +{ os_error *error; assert(tree); @@ -176,7 +179,8 @@ void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) { * \param x the width of the line * \param x the height of the line */ -void tree_draw_line(int x, int y, int width, int height) { +void tree_draw_line(int x, int y, int width, int height) +{ os_error *error; int y0, y1; @@ -218,7 +222,8 @@ void tree_draw_line(int x, int y, int width, int height) { * \param tree the tree to draw an element for * \param element the element to draw */ -void tree_draw_node_element(struct tree *tree, struct node_element *element) { +void tree_draw_node_element(struct tree *tree, struct node_element *element) +{ os_error *error; int toolbar_height = 0; struct node_element *url_element; @@ -385,7 +390,8 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) { } -void tree_handle_node_changed_callback(void *p) { +void tree_handle_node_changed_callback(void *p) +{ struct node_update *update = p; tree_handle_node_changed(update->tree, update->node, true, false); @@ -399,7 +405,8 @@ void tree_handle_node_changed_callback(void *p) { * \param tree the tree to draw the expansion for * \param element the element to draw the expansion for */ -void tree_draw_node_expansion(struct tree *tree, struct node *node) { +void tree_draw_node_expansion(struct tree *tree, struct node *node) +{ unsigned int type; assert(tree); @@ -428,7 +435,8 @@ void tree_draw_node_expansion(struct tree *tree, struct node *node) { * * \param tree the tree to set the origin for */ -void tree_initialise_redraw(struct tree *tree) { +void tree_initialise_redraw(struct tree *tree) +{ os_error *error; wimp_window_state state; @@ -454,7 +462,8 @@ void tree_initialise_redraw(struct tree *tree) { * * \param element the element to recalculate */ -void tree_recalculate_node_element(struct node_element *element) { +void tree_recalculate_node_element(struct node_element *element) +{ const struct bitmap *bitmap = NULL; struct node_element *url_element; rufl_code code; @@ -510,7 +519,8 @@ void tree_recalculate_node_element(struct node_element *element) { * \param selected the expanded sprite name to use */ void tree_set_node_sprite(struct node *node, const char *sprite, - const char *expanded) { + const char *expanded) +{ assert(node); assert(sprite); assert(expanded); @@ -529,7 +539,8 @@ void tree_set_node_sprite(struct node *node, const char *sprite, * * \param node the node to update */ -void tree_set_node_sprite_folder(struct node *node) { +void tree_set_node_sprite_folder(struct node *node) +{ assert(node->folder); tree_set_node_sprite(node, "small_dir", "small_diro"); @@ -545,7 +556,8 @@ void tree_set_node_sprite_folder(struct node *node) { * \param data the data the node is linked to, or NULL for unlinked data */ void tree_update_URL_node(struct node *node, - const char *url, const struct url_data *data) { + const char *url, const struct url_data *data) +{ struct node_element *element; char buffer[256]; @@ -588,7 +600,7 @@ void tree_update_URL_node(struct node *node, messages_get("TreeUnknown")); if (data->last_visit > 0) buffer[strlen(buffer) - 1] = '\0'; - free(element->text); + free((void *)element->text); element->text = strdup(buffer); } @@ -596,7 +608,7 @@ void tree_update_URL_node(struct node *node, if (element) { snprintf(buffer, 256, messages_get("TreeVisits"), data->visits); - free(element->text); + free((void *)element->text); element->text = strdup(buffer); } } @@ -607,7 +619,8 @@ void tree_update_URL_node(struct node *node, * * \param tree the tree to update the owner of */ -void tree_resized(struct tree *tree) { +void tree_resized(struct tree *tree) +{ os_error *error; wimp_window_state state; @@ -633,7 +646,8 @@ void tree_resized(struct tree *tree) { * \param redraw the area to redraw * \param tree the tree to redraw */ -void ro_gui_tree_redraw(wimp_draw *redraw) { +void ro_gui_tree_redraw(wimp_draw *redraw) +{ struct tree *tree; osbool more; int clip_x0, clip_x1, clip_y0, clip_y1, origin_x, origin_y; @@ -667,7 +681,8 @@ void ro_gui_tree_redraw(wimp_draw *redraw) { * \param tree the tree to handle a click for * \return whether the click was handled */ -bool ro_gui_tree_click(wimp_pointer *pointer, struct tree *tree) { +bool ro_gui_tree_click(wimp_pointer *pointer, struct tree *tree) +{ bool furniture; struct node *node; struct node *last; @@ -935,7 +950,8 @@ bool ro_gui_tree_click(wimp_pointer *pointer, struct tree *tree) { * * \param tree the tree to handle the event for */ -void ro_gui_tree_menu_closed(struct tree *tree) { +void ro_gui_tree_menu_closed(struct tree *tree) +{ assert(tree); if (tree->temp_selection) { @@ -953,7 +969,8 @@ void ro_gui_tree_menu_closed(struct tree *tree) { * * \param pointer the pointer state */ -bool ro_gui_tree_toolbar_click(wimp_pointer* pointer) { +bool ro_gui_tree_toolbar_click(wimp_pointer* pointer) +{ struct node *node; struct toolbar *toolbar = @@ -1016,7 +1033,8 @@ bool ro_gui_tree_toolbar_click(wimp_pointer* pointer) { * \param pointer the pointer data to use for caret positioning (or NULL) */ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element, - wimp_pointer *pointer) { + wimp_pointer *pointer) +{ os_error *error; struct node *parent; int toolbar_height = 0; @@ -1082,7 +1100,8 @@ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element, * * \param tree the tree to stop editing for */ -void ro_gui_tree_stop_edit(struct tree *tree) { +void ro_gui_tree_stop_edit(struct tree *tree) +{ os_error *error; assert(tree); @@ -1115,7 +1134,8 @@ void ro_gui_tree_stop_edit(struct tree *tree) { * \param tree the tree to scroll * \param element the element to display */ -void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element) { +void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element) +{ wimp_window_state state; int x0, x1, y0, y1; os_error *error; @@ -1155,7 +1175,8 @@ void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element) /** * Shows the a tree window. */ -void ro_gui_tree_show(struct tree *tree) { +void ro_gui_tree_show(struct tree *tree) +{ struct toolbar *toolbar; /* we may have failed to initialise */ @@ -1182,7 +1203,8 @@ void ro_gui_tree_show(struct tree *tree) { * * \param open the window state */ -void ro_gui_tree_open(wimp_open *open) { +void ro_gui_tree_open(wimp_open *open) +{ struct tree *tree; os_error *error; int width; @@ -1251,7 +1273,8 @@ void ro_gui_tree_open(wimp_open *open) { * \param tree the tree to handle a keypress for * \return whether the key was processed */ -bool ro_gui_tree_keypress(wimp_key *key) { +bool ro_gui_tree_keypress(wimp_key *key) +{ wimp_window_state state; int y; char *new_string; @@ -1295,7 +1318,7 @@ bool ro_gui_tree_keypress(wimp_key *key) { } textarea_get_text(tree->textarea_handle, new_string, strlen); - free(tree->editing->text); + free((void *)tree->editing->text); tree->editing->text = new_string; ro_gui_tree_stop_edit(tree); tree_recalculate_size(tree); @@ -1381,7 +1404,8 @@ bool ro_gui_tree_keypress(wimp_key *key) { * * \param drag the drag box information */ -void ro_gui_tree_selection_drag_end(wimp_dragged *drag) { +void ro_gui_tree_selection_drag_end(wimp_dragged *drag) +{ wimp_window_state state; wimp_auto_scroll_info scroll; os_error *error; @@ -1458,7 +1482,8 @@ void ro_gui_tree_get_tree_coordinates(struct tree *tree, int x, int y, * * \param drag the drag box information */ -void ro_gui_tree_move_drag_end(wimp_dragged *drag) { +void ro_gui_tree_move_drag_end(wimp_dragged *drag) +{ struct gui_window *g; wimp_pointer pointer; wimp_auto_scroll_info scroll; @@ -1514,7 +1539,8 @@ void ro_gui_tree_move_drag_end(wimp_dragged *drag) { * * \param tree the tree to launch all selected nodes for */ -void ro_gui_tree_launch_selected(struct tree *tree) { +void ro_gui_tree_launch_selected(struct tree *tree) +{ assert(tree); if (tree->root->child) @@ -1527,7 +1553,9 @@ void ro_gui_tree_launch_selected(struct tree *tree) { * * \param node the node to launch all selected nodes for */ -void ro_gui_tree_launch_selected_node(struct tree *tree, struct node *node, bool all) { +void ro_gui_tree_launch_selected_node(struct tree *tree, struct node *node, + bool all) +{ for (; node; node = node->next) { if (((node->selected) || (all)) && (!node->folder)) ro_gui_tree_launch_node(tree, node); @@ -1544,7 +1572,8 @@ void ro_gui_tree_launch_selected_node(struct tree *tree, struct node *node, bool * \param node the node to launch * \return whether the node could be launched */ -bool ro_gui_tree_launch_node(struct tree *tree, struct node *node) { +bool ro_gui_tree_launch_node(struct tree *tree, struct node *node) +{ struct node_element *element; assert(node); @@ -1566,12 +1595,14 @@ bool ro_gui_tree_launch_node(struct tree *tree, struct node *node) { return false; } -int ro_gui_tree_help(int x, int y) { +int ro_gui_tree_help(int x, int y) +{ return -1; } -void ro_gui_tree_update_theme(struct tree *tree) { +void ro_gui_tree_update_theme(struct tree *tree) +{ if ((tree) && (tree->toolbar)) { if (tree->toolbar->editor) if (!ro_gui_theme_update_toolbar(NULL, tree->toolbar->editor)) diff --git a/riscos/treeview.h b/riscos/treeview.h index 7ec562c37..df718fc7a 100644 --- a/riscos/treeview.h +++ b/riscos/treeview.h @@ -24,7 +24,7 @@ #define _NETSURF_RISCOS_TREEVIEW_H_ #include -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "desktop/tree.h" #include "image/bitmap.h" diff --git a/riscos/ucstables.c b/riscos/ucstables.c index 4b2840266..6f7acfbbc 100644 --- a/riscos/ucstables.c +++ b/riscos/ucstables.c @@ -24,10 +24,8 @@ #include #include #include - #include "oslib/osbyte.h" #include "oslib/territory.h" - #include "riscos/ucstables.h" #include "utils/log.h" #include "utils/utf8.h" @@ -50,7 +48,7 @@ 0x201c, 0x201d, 0x201e, 0x2013, 0x2014, 0x2212, 0x0152, 0x0153, \ 0x2020, 0x2021, 0xfb01, 0xfb02 -static int latin1_table[256] = +static const int latin1_table[256] = { common, 0x20ac, 0x0174, 0x0175, -1, -1, 0x0176, 0x0177, -1, -1, -1, -1, -1, @@ -63,7 +61,7 @@ static int latin1_table[256] = 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 }; -static int latin2_table[256] = +static const int latin2_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -82,7 +80,7 @@ static int latin2_table[256] = 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 }; -static int latin3_table[256] = +static const int latin3_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -101,7 +99,7 @@ static int latin3_table[256] = 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9 }; -static int latin4_table[256] = +static const int latin4_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -120,7 +118,7 @@ static int latin4_table[256] = 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9 }; -static int latin5_table[256] = +static const int latin5_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -139,7 +137,7 @@ static int latin5_table[256] = 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF }; -static int latin6_table[256] = +static const int latin6_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -158,7 +156,7 @@ static int latin6_table[256] = 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138 }; -static int latin7_table[256] = +static const int latin7_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -179,7 +177,7 @@ static int latin7_table[256] = 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019 }; -static int latin8_table[256] = +static const int latin8_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -198,7 +196,7 @@ static int latin8_table[256] = 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF }; -static int latin9_table[256] = +static const int latin9_table[256] = { common, -1, 0x0174, 0x0175, -1, -1, 0x0176, 0x0177, -1, -1, -1, -1, -1, @@ -219,7 +217,7 @@ static int latin9_table[256] = 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF }; -static int latin10_table[256] = +static const int latin10_table[256] = { common, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -240,7 +238,7 @@ static int latin10_table[256] = 0x0171, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0119, 0x021B, 0x00FF }; -static int welsh_table[256] = +static const int welsh_table[256] = { common, 0x20ac, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -259,7 +257,7 @@ static int welsh_table[256] = 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF }; -static int greek_table[256] = +static const int greek_table[256] = { common, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -278,7 +276,7 @@ static int greek_table[256] = 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, -1 }; -static int cyrillic_table[256] = +static const int cyrillic_table[256] = { common, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -297,7 +295,7 @@ static int cyrillic_table[256] = 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F }; -static int hebrew_table[256] = +static const int hebrew_table[256] = { common, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -322,9 +320,9 @@ static int hebrew_table[256] = * \param alphabet The RISC OS alphabet number * \return pointer to table, or NULL if not found */ -int *ucstable_from_alphabet(int alphabet) +const int *ucstable_from_alphabet(int alphabet) { - int *ucstable = NULL; + const int *ucstable = NULL; switch (alphabet) { case territory_ALPHABET_LATIN1: diff --git a/riscos/ucstables.h b/riscos/ucstables.h index 9ff248ad9..0be065897 100644 --- a/riscos/ucstables.h +++ b/riscos/ucstables.h @@ -21,4 +21,4 @@ * This is only used if nothing claims Service_International,8 */ -int *ucstable_from_alphabet(int alphabet); +const int *ucstable_from_alphabet(int alphabet); diff --git a/riscos/wimp.c b/riscos/wimp.c index 9463df56b..01ac96202 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -55,7 +55,8 @@ unsigned char last_sprite_found[16]; * * \param w the window to read (or NULL to read a cached value) */ -int ro_get_hscroll_height(wimp_w w) { +int ro_get_hscroll_height(wimp_w w) +{ ro_gui_wimp_cache_furniture_sizes(w); return furniture_sizes.border_widths.y0; } @@ -66,7 +67,8 @@ int ro_get_hscroll_height(wimp_w w) { * * \param w the window to read (or NULL to read a cached value) */ -int ro_get_vscroll_width(wimp_w w) { +int ro_get_vscroll_width(wimp_w w) +{ ro_gui_wimp_cache_furniture_sizes(w); return furniture_sizes.border_widths.x1; } @@ -77,7 +79,8 @@ int ro_get_vscroll_width(wimp_w w) { * * \param w the window to read (or NULL to read a cached value) */ -int ro_get_title_height(wimp_w w) { +int ro_get_title_height(wimp_w w) +{ ro_gui_wimp_cache_furniture_sizes(w); return furniture_sizes.border_widths.y1; } @@ -88,7 +91,8 @@ int ro_get_title_height(wimp_w w) { * \param w the window to cache information from * \return true on success, false on error (default values cached) */ -void ro_gui_wimp_cache_furniture_sizes(wimp_w w) { +void ro_gui_wimp_cache_furniture_sizes(wimp_w w) +{ os_error *error; if (!w) @@ -113,7 +117,8 @@ void ro_gui_wimp_cache_furniture_sizes(wimp_w w) { * * \param mode mode to read EIG factors for, or -1 for current */ -bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig) { +bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig) +{ os_error *error; error = xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, xeig, 0); @@ -140,7 +145,8 @@ bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig) { * \param os_units values to convert * \param mode mode to use EIG factors for, or -1 for current */ -void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode) { +void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode) +{ int xeig = 1, yeig = 1; ro_gui_wimp_read_eig_factors(mode, &xeig, &yeig); @@ -155,7 +161,8 @@ void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode) { * \param pixels values to convert * \param mode mode to use EIG factors for, or -1 for current */ -void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode) { +void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode) +{ int xeig = 1, yeig = 1; ro_gui_wimp_read_eig_factors(mode, &xeig, &yeig); @@ -180,7 +187,8 @@ void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode) { * \param w window handle * \param i icon handle */ -void ro_gui_force_redraw_icon(wimp_w w, wimp_i i) { +void ro_gui_force_redraw_icon(wimp_w w, wimp_i i) +{ wimp_icon_state ic; os_error *error; @@ -212,7 +220,8 @@ void ro_gui_force_redraw_icon(wimp_w w, wimp_i i) { * \param i icon handle * \return string in icon */ -char *ro_gui_get_icon_string(wimp_w w, wimp_i i) { +char *ro_gui_get_icon_string(wimp_w w, wimp_i i) +{ wimp_icon_state ic; os_error *error; @@ -236,7 +245,8 @@ char *ro_gui_get_icon_string(wimp_w w, wimp_i i) { * \param i icon handle * \param text string (UTF-8 encoded) (copied) */ -void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) { +void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) +{ wimp_caret caret; wimp_icon_state ic; os_error *error; @@ -325,7 +335,8 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) { * \param i icon handle * \param text string (in local encoding) (copied) */ -void ro_gui_set_icon_string_le(wimp_w w, wimp_i i, const char *text) { +void ro_gui_set_icon_string_le(wimp_w w, wimp_i i, const char *text) +{ wimp_caret caret; wimp_icon_state ic; os_error *error; @@ -396,7 +407,8 @@ void ro_gui_set_icon_string_le(wimp_w w, wimp_i i, const char *text) { * \param i icon handle * \param value value */ -void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) { +void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) +{ char buffer[20]; // Big enough for 64-bit int setlocale(LC_NUMERIC, ""); @@ -416,7 +428,8 @@ void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) { * \param i icon handle * \param value value */ -void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places) { +void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places) +{ char buffer[20]; // Big enough for 64-bit int setlocale(LC_NUMERIC, ""); @@ -449,7 +462,8 @@ void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places) * \param i icon handle * \param value value */ -int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places) { +int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places) +{ double value; int multiple = 1; @@ -473,7 +487,8 @@ int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places) { * \param i icon handle * \param state selected state */ -void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state) { +void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state) +{ os_error *error; if (ro_gui_get_icon_selected_state(w, i) == state) return; error = xwimp_set_icon_state(w, i, @@ -491,7 +506,8 @@ void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state) { * \param w window handle * \param i icon handle */ -bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) { +bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) +{ os_error *error; wimp_icon_state ic; ic.w = w; @@ -514,7 +530,8 @@ bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) { * \param i icon handle * \param state shaded state */ -void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) { +void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) +{ wimp_caret caret; os_error *error; @@ -561,7 +578,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) { * \param w window handle * \param i icon handle */ -bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i) { +bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i) +{ wimp_icon_state ic; ic.w = w; ic.i = i; @@ -577,7 +595,8 @@ bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i) { * \param i icon handle * \param type button type */ -void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type) { +void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type) +{ os_error *error; error = xwimp_set_icon_state(w, i, wimp_ICON_BUTTON_TYPE, (type << wimp_ICON_BUTTON_TYPE_SHIFT)); @@ -634,7 +653,8 @@ void ro_gui_set_icon_sprite(wimp_w w, wimp_i i, osspriteop_area *area, * \param w window handle * \param text new title (copied) */ -void ro_gui_set_window_title(wimp_w w, const char *text) { +void ro_gui_set_window_title(wimp_w w, const char *text) +{ wimp_window_info_base window; os_error *error; char *title_local_enc; @@ -689,7 +709,8 @@ void ro_gui_set_window_title(wimp_w w, const char *text) { * \w the window to place the caret in * \return true if the caret was placed, false otherwise */ -bool ro_gui_set_caret_first(wimp_w w) { +bool ro_gui_set_caret_first(wimp_w w) +{ int icon, b; wimp_window_state win_state; wimp_window_info_base window; @@ -869,7 +890,8 @@ os_error *ro_gui_wimp_get_sprite(const char *name, osspriteop_header **sprite) */ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill, - os_colour user_colour) { + os_colour user_colour) +{ os_error *error; osbool more; @@ -911,7 +933,8 @@ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill, * \param xor_mask the furniture flags to toggle */ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, - wimp_window_flags xor_mask) { + wimp_window_flags xor_mask) +{ wimp_window_state state; wimp_w parent; bits linkage; @@ -959,7 +982,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, * \param w the window to modify * \param mask the furniture flags to check */ -bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask) { +bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask) +{ wimp_window_state state; os_error *error; diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c index 951c8e96b..8cfe49747 100644 --- a/riscos/wimp_event.c +++ b/riscos/wimp_event.c @@ -1,1249 +1,1288 @@ -/* - * Copyright 2005 Richard Wilson - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * Automated RISC OS WIMP event handling (implementation). - */ - -#include -#include -#include -#include -#include -#include -#include "oslib/os.h" -#include "oslib/osbyte.h" -#include "oslib/serviceinternational.h" -#include "oslib/wimp.h" -#include "desktop/gui.h" -#include "riscos/dialog.h" -#include "riscos/menus.h" -#include "riscos/ucstables.h" -#include "riscos/wimp.h" -#include "riscos/wimp_event.h" -#include "utils/log.h" -#include "utils/utils.h" - -#define WIN_HASH_SIZE 32 -#define WIN_HASH(w) (((unsigned)(w) >> 5) % WIN_HASH_SIZE) - -typedef enum { - EVENT_NUMERIC_FIELD, - EVENT_TEXT_FIELD, - EVENT_UP_ARROW, - EVENT_DOWN_ARROW, - EVENT_MENU_GRIGHT, - EVENT_CHECKBOX, - EVENT_RADIO, - EVENT_BUTTON, - EVENT_CANCEL, - EVENT_OK -} event_type; - -struct event_data_numeric_field { - int stepping; - int min; - int max; - int decimal_places; -}; - -struct event_data_menu_gright { - wimp_i field; - wimp_menu *menu; -}; - -struct icon_event { - event_type type; - wimp_i i; - union { - struct event_data_numeric_field numeric_field; - struct event_data_menu_gright menu_gright; - wimp_i linked_icon; - int radio_group; - void (*callback)(wimp_pointer *pointer); - } data; - union { - char *textual; - bool boolean; - } previous_value; - bool previous_shaded; - struct icon_event *next; -}; - -struct event_window { - wimp_w w; - bool (*ok_click)(wimp_w w); - bool (*mouse_click)(wimp_pointer *pointer); - bool (*keypress)(wimp_key *key); - void (*open_window)(wimp_open *open); - void (*close_window)(wimp_w w); - void (*redraw_window)(wimp_draw *redraw); - void (*menu_selection)(wimp_w w, wimp_i i); - const char *help_prefix; - void *user_data; - struct icon_event *first; - struct event_window *next; - int max_radio_group; -}; - -static void ro_gui_wimp_event_ok_click(struct event_window *window, - wimp_mouse_state state); -static struct event_window *ro_gui_wimp_event_get_window(wimp_w w); -static struct event_window *ro_gui_wimp_event_find_window(wimp_w w); -static struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i, - event_type type); -static void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event); -static struct event_window *ro_gui_wimp_event_remove_window(wimp_w w); - -static struct event_window *ro_gui_wimp_event_windows[WIN_HASH_SIZE]; - -static wimp_w ro_gui_wimp_event_submenu; - -/** - * Memorises the current state of any registered components in a window. - * - * \param w the window to memorise - * \return true on success, false on memory exhaustion or for an unknown window - */ -bool ro_gui_wimp_event_memorise(wimp_w w) { - struct event_window *window; - struct icon_event *event; - bool error = false; - - window = ro_gui_wimp_event_find_window(w); - if (!window) - return false; - - for (event = window->first; event; event = event->next) { - switch (event->type) { - case EVENT_NUMERIC_FIELD: - case EVENT_TEXT_FIELD: - if (event->previous_value.textual) - free(event->previous_value.textual); - event->previous_value.textual = strdup( - ro_gui_get_icon_string(window->w, event->i)); - if (!event->previous_value.textual) { - error = true; - LOG(("Unable to store state for icon %i", event->i)); - } - break; - case EVENT_CHECKBOX: - case EVENT_RADIO: - event->previous_value.boolean = - ro_gui_get_icon_selected_state(window->w, event->i); - break; - default: - break; - } - if (event->type != EVENT_MENU_GRIGHT) - event->previous_shaded = ro_gui_get_icon_shaded_state(window->w, - event->i); - } - return !error; -} - - -/** - * Restore the state of any registered components in a window to their memorised state. - * - * \param w the window to restore - * \return true on success, false for an unknown window - */ -bool ro_gui_wimp_event_restore(wimp_w w) { - struct event_window *window; - struct icon_event *event; - - window = ro_gui_wimp_event_find_window(w); - if (!window) - return false; - - for (event = window->first; event; event = event->next) { - switch (event->type) { - case EVENT_NUMERIC_FIELD: - case EVENT_TEXT_FIELD: - if (event->previous_value.textual) - ro_gui_set_icon_string(window->w, event->i, - event->previous_value.textual); - break; - case EVENT_CHECKBOX: - case EVENT_RADIO: - ro_gui_set_icon_selected_state(window->w, event->i, - event->previous_value.boolean); - break; - default: - break; - } - if (event->type != EVENT_MENU_GRIGHT) - ro_gui_set_icon_shaded_state(window->w, event->i, - event->previous_shaded); - } - return true; -} - - -/** - * Ensures all values are within pre-determined boundaries. - * - * \param w the window to memorise - * \return true on success, false for an unknown window - */ -bool ro_gui_wimp_event_validate(wimp_w w) { - struct event_window *window; - struct icon_event *event; - int value; - - window = ro_gui_wimp_event_find_window(w); - if (!window) - return false; - - for (event = window->first; event; event = event->next) { - switch (event->type) { - case EVENT_NUMERIC_FIELD: - value = ro_gui_get_icon_decimal(window->w, event->i, - event->data.numeric_field.decimal_places); - if (value < event->data.numeric_field.min) - value = event->data.numeric_field.min; - else if (value > event->data.numeric_field.max) - value = event->data.numeric_field.max; - ro_gui_set_icon_decimal(window->w, event->i, value, - event->data.numeric_field.decimal_places); - break; - default: - break; - } - } - return true; -} - - -/** - * Free any resources associated with a window. - * - * \param w the window to free resources for - */ -void ro_gui_wimp_event_finalise(wimp_w w) { - struct event_window *window; - struct icon_event *event; - - LOG(("Removing all events for window 0x%x", (unsigned int)w)); - window = ro_gui_wimp_event_remove_window(w); - if (!window) - return; - - while (window->first) { - event = window->first; - window->first = event->next; - switch (event->type) { - case EVENT_NUMERIC_FIELD: - case EVENT_TEXT_FIELD: - if (event->previous_value.textual) - free(event->previous_value.textual); - event->previous_value.textual = NULL; - break; - default: - break; - } - free(event); - } - free(window); - return; -} - - -/** - * Set the associated help prefix for a given window. - * - * \param w the window to get the prefix for - * \param help_prefix the prefix to associate with the window (used directly) - * \return true on success, or NULL for memory exhaustion - */ -bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->help_prefix = help_prefix; - return true; -} - - -/** - * Get the associated help prefix. - * - * \param w the window to get the prefix for - * \return the associated prefix, or NULL - */ -const char *ro_gui_wimp_event_get_help_prefix(wimp_w w) { - struct event_window *window; - - window = ro_gui_wimp_event_find_window(w); - if (window) - return window->help_prefix; - return NULL; -} - - -/** - * Sets the user data associated with a window. - * - * \param w the window to associate the data with - * \param user the data to associate - */ -bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->user_data = user; - return true; - -} - - -/** - * Gets the user data associated with a window. - * - * \param w the window to retrieve the data for - * \return the associated data, or NULL - */ -void *ro_gui_wimp_event_get_user_data(wimp_w w) { - struct event_window *window; - - window = ro_gui_wimp_event_find_window(w); - if (window) - return window->user_data; - return NULL; -} - - -/** - * Handles a menu selection event. - * - * \param w the window to owning the menu - * \param i the icon owning the menu - * \param menu the menu that has been selected - * \param selection the selection information - * \return true if the event was handled, false otherwise - */ -bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, - wimp_selection *selection) { - struct event_window *window; - struct icon_event *event; - wimp_menu_entry *menu_entry; - wimp_key key; - os_error *error; - wimp_caret caret; - wimp_icon_state ic; - unsigned int button_type; - - window = ro_gui_wimp_event_find_window(w); - if (!window) - return false; - - for (event = window->first; event; event = event->next) - if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i)) - break; - if (!event) - return false; - - menu_entry = &menu->entries[selection->items[0]]; - for (i = 1; selection->items[i] != -1; i++) - menu_entry = &menu_entry->sub_menu-> - entries[selection->items[i]]; - - /* if the entry is already ticked then we do nothing */ - if (menu_entry->menu_flags & wimp_MENU_TICKED) - return true; - - ro_gui_set_icon_string_le(window->w, event->data.menu_gright.field, - menu_entry->data.indirected_text.text); - ro_gui_wimp_event_prepare_menu(window->w, event); - if (window->menu_selection) - window->menu_selection(window->w, event->i); - - /* set the caret for writable icons and send a CTRL+U keypress to - * stimulate activity if needed */ - ic.w = window->w; - ic.i = event->data.menu_gright.field; - error = xwimp_get_icon_state(&ic); - if (error) { - LOG(("xwimp_get_icon_state: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return false; - } - button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE) >> wimp_ICON_BUTTON_TYPE_SHIFT; - if ((button_type != wimp_BUTTON_WRITABLE) && - (button_type != wimp_BUTTON_WRITE_CLICK_DRAG)) - return true; - error = xwimp_get_caret_position(&caret); - if (error) { - LOG(("xwimp_get_caret_position: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return false; - } - if ((caret.w != window->w) || (caret.i != event->data.menu_gright.field)) { - error = xwimp_set_caret_position(window->w, event->data.menu_gright.field, - -1, -1, -1, strlen(menu_entry->data.indirected_text.text)); - if (error) { - LOG(("xwimp_set_caret_position: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - } - } - if (window->keypress) { - key.w = window->w; - key.c = 21; // ctrl+u - window->keypress(&key); - } - return true; -} - - -/** - * Handles a mouse click event in a registered window. - * - * The order of execution is: - * - * 1. Any registered mouse_click routine (see ro_gui_wimp_register_mouse_click()) - * 2. If the current icon is not registered with a type then it is assumed that no - * action is necessary, and the click is deemed to have been handled. - * 3. If the registered mouse_click routine returned false, or there was no registered - * routine then the automated action for the registered icon type is performed - * - * \param pointer the current pointer state - * \return true if the event was handled, false otherwise - */ -bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) { - struct event_window *window; - struct icon_event *event; - wimp_w w; - struct icon_event *search; - int current, step, stepping, min, max, decimal_places; - wimp_window_state open; - wimp_caret caret; - os_error *error; - - w = pointer->w; - window = ro_gui_wimp_event_find_window(w); - if (!window) - return false; - - /* registered routines take priority */ - if ((window->mouse_click) && (window->mouse_click(pointer))) - return true; - - for (event = window->first; event; event = event->next) - if (event->i == pointer->i) - break; - if (!event) - return true; - - switch (event->type) { - case EVENT_NUMERIC_FIELD: - case EVENT_TEXT_FIELD: - break; - case EVENT_UP_ARROW: - case EVENT_DOWN_ARROW: - for (search = window->first; search; search = search->next) - if (search->i == event->data.linked_icon) break; - if (!search) { - LOG(("Incorrect reference.")); - return false; - } - stepping = search->data.numeric_field.stepping; - min = search->data.numeric_field.min; - max = search->data.numeric_field.max; - decimal_places = search->data.numeric_field.decimal_places; - - if (pointer->buttons & wimp_CLICK_ADJUST) - step = -stepping; - else if (pointer->buttons & wimp_CLICK_SELECT) - step = stepping; - else - return true; - if (event->type == EVENT_DOWN_ARROW) - step = -step; - - current = ro_gui_get_icon_decimal(pointer->w, event->data.linked_icon, - decimal_places); - current += step; - if (current < min) - current = min; - if (current > max) - current = max; - ro_gui_set_icon_decimal(pointer->w, event->data.linked_icon, current, - decimal_places); - break; - case EVENT_MENU_GRIGHT: - /* if there's already a menu open then we assume that we are part of it. - * to follow the standard RISC OS behaviour we add a 'send to the back' - * button, then close the menu (which closes us) and then finally - * re-open ourselves. ugh! */ - if (current_menu != NULL) { - open.w = pointer->w; - error = xwimp_get_window_state(&open); - if (error) { - LOG(("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return false; - } - error = xwimp_get_caret_position(&caret); - if (error) { - LOG(("xwimp_get_caret_position: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return false; - } - ro_gui_dialog_add_persistent(current_menu_window, - pointer->w); - ro_gui_menu_closed(false); - gui_poll(true); - error = xwimp_open_window((wimp_open *) &open); - if (error) { - LOG(("xwimp_open_window: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return false; - } - if (caret.w == pointer->w) { - error = xwimp_set_caret_position(caret.w, - caret.i, - caret.pos.x, caret.pos.y, - -1, caret.index); - if (error) { - LOG(("xwimp_set_caret_position: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - } - } - } - /* display the menu */ - ro_gui_wimp_event_prepare_menu(pointer->w, event); - ro_gui_popup_menu(event->data.menu_gright.menu, pointer->w, pointer->i); - break; - case EVENT_CHECKBOX: - break; - case EVENT_RADIO: - for (search = window->first; search; search = search->next) - if ((search->type == EVENT_RADIO) && - (search->data.radio_group == - event->data.radio_group)) - ro_gui_set_icon_selected_state(pointer->w, - search->i, (search == event)); - break; - case EVENT_BUTTON: - if (event->data.callback) - event->data.callback(pointer); - break; - case EVENT_CANCEL: - if (pointer->buttons & wimp_CLICK_SELECT) { - ro_gui_dialog_close(pointer->w); - ro_gui_wimp_event_close_window(pointer->w); - ro_gui_menu_closed(true); - } else { - ro_gui_wimp_event_restore(pointer->w); - } - break; - case EVENT_OK: - ro_gui_wimp_event_ok_click(window, pointer->buttons); - break; - } - return true; -} - - -/** - * Prepare a menu ready for use - * - * /param w the window owning the menu - * /param event the icon event owning the menu - */ -void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event) { - int i; - char *text; - unsigned int button_type; - wimp_icon_state ic; - wimp_menu *menu; - os_error *error; - - /* if the linked icon is not writable then we set the ticked state - * of the menu item that matches the contents */ - ic.w = w; - ic.i = event->data.menu_gright.field; - error = xwimp_get_icon_state(&ic); - if (error) { - LOG(("xwimp_get_icon_state: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return; - } - button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE) - >> wimp_ICON_BUTTON_TYPE_SHIFT; - if ((button_type == wimp_BUTTON_WRITABLE) || - (button_type == wimp_BUTTON_WRITE_CLICK_DRAG)) - return; - text = ro_gui_get_icon_string(w, event->data.menu_gright.field); - menu = event->data.menu_gright.menu; - i = 0; - do { - if (!strcmp(menu->entries[i].data.indirected_text.text, text)) - menu->entries[i].menu_flags |= wimp_MENU_TICKED; - else - menu->entries[i].menu_flags &= ~wimp_MENU_TICKED; - } while (!(menu->entries[i++].menu_flags & wimp_MENU_LAST)); -} - - -/** - * Perform the necessary actions following a click on the OK button. - * - * /param window the window to perform the action on - * /param state the mouse button state - */ -void ro_gui_wimp_event_ok_click(struct event_window *window, wimp_mouse_state state) { - struct icon_event *search; - - for (search = window->first; search; search = search->next) - if (search->type == EVENT_OK) { - if (ro_gui_get_icon_shaded_state(window->w, search->i)) - return; - break; - } - ro_gui_wimp_event_validate(window->w); - - if (window->ok_click) - if (!window->ok_click(window->w)) - return; - - if (state & wimp_CLICK_SELECT) { - ro_gui_dialog_close(window->w); - ro_gui_wimp_event_close_window(window->w); - ro_gui_menu_closed(true); - } else { - ro_gui_wimp_event_memorise(window->w); - } -} - - -/** - * Handle any registered keypresses, and the standard RISC OS ones - * - * \param key the key state - * \return true if keypress handled, false otherwise - */ -bool ro_gui_wimp_event_keypress(wimp_key *key) { - static int *ucstable = NULL; - static int alphabet = 0; - static uint32_t wc = 0; /* buffer for UTF8 alphabet */ - static int shift = 0; - struct event_window *window; - struct icon_event *event; - wimp_pointer pointer; - wimp_key k; - uint32_t c = (uint32_t) key->c; - int t_alphabet; - os_error *error; - - window = ro_gui_wimp_event_find_window(key->w); - if (!window) - return false; - - /* copy key state so we can corrupt it safely */ - memcpy(&k, key, sizeof(wimp_key)); - - /* In order to make sensible use of the 0x80->0xFF ranges specified - * in the RISC OS 8bit alphabets, we must do the following: - * - * + Read the currently selected alphabet - * + Acquire a pointer to the UCS conversion table for this alphabet: - * + Try using ServiceInternational 8 to get the table - * + If that fails, use our internal table (see ucstables.c) - * + If the alphabet is not UTF8 and the conversion table exists: - * + Lookup UCS code in the conversion table - * + If code is -1 (i.e. undefined): - * + Use codepoint 0xFFFD instead - * + If the alphabet is UTF8, we must buffer input, thus: - * + If the keycode is < 0x80: - * + Handle it directly - * + If the keycode is a UTF8 sequence start: - * + Initialise the buffer appropriately - * + Otherwise: - * + OR in relevant bits from keycode to buffer - * + If we've received an entire UTF8 character: - * + Handle UCS code - * + Otherwise: - * + Simply handle the keycode directly, as there's no easy way - * of performing the mapping from keycode -> UCS4 codepoint. - */ - error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &t_alphabet); - if (error) { - LOG(("failed reading alphabet: 0x%x: %s", - error->errnum, error->errmess)); - /* prevent any corruption of ucstable */ - t_alphabet = alphabet; - } - - if (t_alphabet != alphabet) { - osbool unclaimed; - /* Alphabet has changed, so read UCS table location */ - alphabet = t_alphabet; - - error = xserviceinternational_get_ucs_conversion_table( - alphabet, &unclaimed, - (void**)&ucstable); - if (error) { - LOG(("failed reading UCS conversion table: 0x%x: %s", - error->errnum, error->errmess)); - /* try using our own table instead */ - ucstable = ucstable_from_alphabet(alphabet); - } - if (unclaimed) - /* Service wasn't claimed so use our own ucstable */ - ucstable = ucstable_from_alphabet(alphabet); - } - - if (c < 256) { - if (alphabet != 111 /* UTF8 */ && ucstable != NULL) { - /* defined in this alphabet? */ - if (ucstable[c] == -1) - return true; - - /* read UCS4 value out of table */ - k.c = ucstable[c]; - } - else if (alphabet == 111 /* UTF8 */) { - if ((c & 0x80) == 0x00 || (c & 0xC0) == 0xC0) { - /* UTF8 start sequence */ - if ((c & 0xE0) == 0xC0) { - wc = ((c & 0x1F) << 6); - shift = 1; - return true; - } - else if ((c & 0xF0) == 0xE0) { - wc = ((c & 0x0F) << 12); - shift = 2; - return true; - } - else if ((c & 0xF8) == 0xF0) { - wc = ((c & 0x07) << 18); - shift = 3; - return true; - } - /* These next two have been removed - * from RFC3629, but there's no - * guarantee that RISC OS won't - * generate a UCS4 value outside the - * UTF16 plane, so we handle them - * anyway. */ - else if ((c & 0xFC) == 0xF8) { - wc = ((c & 0x03) << 24); - shift = 4; - } - else if ((c & 0xFE) == 0xFC) { - wc = ((c & 0x01) << 30); - shift = 5; - } - else if (c >= 0x80) { - /* If this ever happens, - * RISC OS' UTF8 keyboard - * drivers are broken */ - LOG(("unexpected UTF8 start" - " byte %x (ignoring)", - c)); - return true; - } - /* Anything else is ASCII, so just - * handle it directly. */ - } - else { - if ((c & 0xC0) != 0x80) { - /* If this ever happens, - * RISC OS' UTF8 keyboard - * drivers are broken */ - LOG(("unexpected keycode: " - "%x (ignoring)", c)); - return true; - } - - /* Continuation of UTF8 character */ - wc |= ((c & 0x3F) << (6 * --shift)); - if (shift > 0) - /* partial character */ - return true; - else - /* got entire character, so - * fetch from buffer and - * handle it */ - k.c = wc; - } - } - } else { - k.c |= (1u<<31); - } - - /* registered routines take priority */ - if (window->keypress) - if (window->keypress(&k)) - return true; - - switch (key->c) { - /* Escape performs the CANCEL action (simulated click) */ - case wimp_KEY_ESCAPE: - for (event = window->first; event; event = event->next) { - switch (event->type) { - case EVENT_CANCEL: - pointer.w = key->w; - pointer.i = event->i; - pointer.buttons = wimp_CLICK_SELECT; - ro_gui_wimp_event_mouse_click(&pointer); - return true; - default: - break; - } - } - return false; - /* CTRL+F2 closes a window with a close icon */ - case wimp_KEY_CONTROL + wimp_KEY_F2: - if (!ro_gui_wimp_check_window_furniture(key->w, - wimp_WINDOW_CLOSE_ICON)) - return false; - ro_gui_dialog_close(key->w); - ro_gui_wimp_event_close_window(key->w); - ro_gui_menu_closed(true); - return true; - /* Return performs the OK action */ - case wimp_KEY_RETURN: - if (!window->ok_click) - return false; - /* todo: check we aren't greyed out */ - ro_gui_wimp_event_ok_click(window, wimp_CLICK_SELECT); - return true; - } - return false; -} - - -/** - * Handle any open window requests - * - * \param open the window open request - */ -bool ro_gui_wimp_event_open_window(wimp_open *open) { - struct event_window *window; - - window = ro_gui_wimp_event_find_window(open->w); - if ((window) && (window->open_window)) { - window->open_window(open); - return true; - } - return false; -} - - -/** - * Service any close window handlers - * - * \param w the window being closed - */ -bool ro_gui_wimp_event_close_window(wimp_w w) { - struct event_window *window; - - LOG(("Close event received for window 0x%x", (unsigned int)w)); - if (w == ro_gui_wimp_event_submenu) - ro_gui_wimp_event_submenu = 0; - window = ro_gui_wimp_event_find_window(w); - if ((window) && (window->close_window)) { - window->close_window(w); - return true; - } - return false; -} - - -/** - * Handle any redraw window requests - * - * \param redraw the window redraw request - */ -bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw) { - struct event_window *window; - - window = ro_gui_wimp_event_find_window(redraw->w); - if ((window) && (window->redraw_window)) { - window->redraw_window(redraw); - return true; - } - return false; -} - - -/** - * Register a numeric 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) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_NUMERIC_FIELD); - if (!event) - return false; - event->data.numeric_field.min = min; - event->data.numeric_field.max = max; - event->data.numeric_field.stepping = stepping; - event->data.numeric_field.decimal_places = decimal_places; - - event = ro_gui_wimp_event_get_event(w, up, EVENT_UP_ARROW); - if (!event) - return false; - event->data.linked_icon = i; - - event = ro_gui_wimp_event_get_event(w, down, EVENT_DOWN_ARROW); - if (!event) - return false; - event->data.linked_icon = i; - - return true; -} - - -/** - * Register a text field to be automatically handled - */ -bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_TEXT_FIELD); - if (!event) - return false; - return true; -} - - -/** - * Register an icon menu to be automatically handled - */ -bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, gright, EVENT_MENU_GRIGHT); - if (!event) - return false; - event->data.menu_gright.field = i; - event->data.menu_gright.menu = menu; - - return ro_gui_wimp_event_register_text_field(w, i); -} - - -/** - * Register a checkbox to be automatically handled - */ -bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_CHECKBOX); - if (!event) - return false; - return true; -} - - -/** - * Register a group of radio icons to be automatically handled - */ -bool ro_gui_wimp_event_register_radio(wimp_w w, wimp_i *i) { - struct event_window *window; - struct icon_event *event; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->max_radio_group++; - - while (*i != -1) { - event = ro_gui_wimp_event_get_event(w, *i, EVENT_RADIO); - if (!event) - return false; - event->data.radio_group = window->max_radio_group; - *i++; - } - return true; -} - - -/** - * Register a function to be called when a particular button is pressed. - */ -bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i, - void (*callback)(wimp_pointer *pointer)) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_BUTTON); - if (!event) - return false; - event->data.callback = callback; - return true; -} - - -/** - * Register a function to be called for the Cancel action on a window. - */ -bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i) { - struct icon_event *event; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_CANCEL); - if (!event) - return false; - return true; -} - - -/** - * Register a function to be called for the OK action on a window. - */ -bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, - bool (*callback)(wimp_w w)) { - struct event_window *window; - struct icon_event *event; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->ok_click = callback; - - event = ro_gui_wimp_event_get_event(w, i, EVENT_OK); - if (!event) - return false; - return true; -} - - -/** - * Register a function to be called for all mouse-clicks to icons - * in a window that don't have registered actions. - */ -bool ro_gui_wimp_event_register_mouse_click(wimp_w w, - bool (*callback)(wimp_pointer *pointer)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->mouse_click = callback; - return true; -} - - -/** - * Register a function to be called for all keypresses within a - * particular window. - * - * Important: the character code passed to the callback in key->c - * is UTF-32 (i.e. in the range [0, &10ffff]). WIMP keys (e.g. F1) - * will have bit 31 set. - * - */ -bool ro_gui_wimp_event_register_keypress(wimp_w w, - bool (*callback)(wimp_key *key)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->keypress = callback; - return true; -} - - -/** - * Register a function to be called for all window opening requests. - */ -bool ro_gui_wimp_event_register_open_window(wimp_w w, - void (*callback)(wimp_open *open)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->open_window = callback; - return true; -} - -/** - * Register a function to be called after the window has been closed. - */ -bool ro_gui_wimp_event_register_close_window(wimp_w w, - void (*callback)(wimp_w w)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->close_window = callback; - return true; -} - -/** - * Register a function to be called for all window redraw operations. - */ -bool ro_gui_wimp_event_register_redraw_window(wimp_w w, - void (*callback)(wimp_draw *redraw)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->redraw_window = callback; - return true; -} - -/** - * Register a function to be called following a menu selection. - */ -bool ro_gui_wimp_event_register_menu_selection(wimp_w w, - void (*callback)(wimp_w w, wimp_i i)) { - struct event_window *window; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return false; - window->menu_selection = callback; - return true; -} - - -/** - * Finds the event data associated with a given window handle, or creates a new one. - * - * \param w the window to find data for - */ -struct event_window *ro_gui_wimp_event_get_window(wimp_w w) { - struct event_window *window; - int h; - - assert((int)w != 0); - window = ro_gui_wimp_event_find_window(w); - if (window) - return window; - - LOG(("Creating structure for window 0x%x", (unsigned int)w)); - window = calloc(1, sizeof(struct event_window)); - if (!window) - return NULL; - - h = WIN_HASH(w); - window->w = w; - window->next = ro_gui_wimp_event_windows[h]; - ro_gui_wimp_event_windows[h] = window; - return window; -} - - -/** - * Removes the event data associated with a given handle from the hash tables, - * but does not delete it. - * - * \param w the window to be removed - * \return pointer to the event data or NULL if not found - */ - -struct event_window *ro_gui_wimp_event_remove_window(wimp_w w) { - struct event_window **prev; - int h = WIN_HASH(w); - - /* search hash chain for the window */ - prev = &ro_gui_wimp_event_windows[h]; - while (*prev) { - struct event_window *window = *prev; - - if (window->w == w) { - /* remove from chain */ - *prev = window->next; - return window; - } - prev = &window->next; - } - - /* not found */ - return NULL; -} - -/** - * Find the event data associated with a given window handle - * - * \param w the window to find data for - */ -struct event_window *ro_gui_wimp_event_find_window(wimp_w w) { - struct event_window *window; - int h = WIN_HASH(w); - - /* search hash chain for window */ - for (window = ro_gui_wimp_event_windows[h]; window; window = window->next) { - if (window->w == w) - return window; - } - return NULL; -} - -struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i, event_type type) { - struct event_window *window; - struct icon_event *event; - - window = ro_gui_wimp_event_get_window(w); - if (!window) - return NULL; - - for (event = window->first; event; event = event->next) { - if (event->i == i) { - event->type = type; - return event; - } - } - - event = calloc(1, sizeof(struct icon_event)); - if (!event) - return NULL; - event->i = i; - event->type = type; - event->next = window->first; - window->first = event; - - return event; -} - -/** - * Handle menus being closed - */ -void ro_gui_wimp_event_menus_closed(void) { - ro_gui_wimp_event_register_submenu(0); -} - -/** - * Register a submenu as being opened - */ -void ro_gui_wimp_event_register_submenu(wimp_w w) { - if (ro_gui_wimp_event_submenu) - ro_gui_wimp_event_close_window(ro_gui_wimp_event_submenu); - ro_gui_wimp_event_submenu = w; -} +/* + * Copyright 2005 Richard Wilson + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * Automated RISC OS WIMP event handling (implementation). + */ + +#include +#include +#include +#include +#include +#include +#include "oslib/os.h" +#include "oslib/osbyte.h" +#include "oslib/serviceinternational.h" +#include "oslib/wimp.h" +#include "desktop/gui.h" +#include "riscos/dialog.h" +#include "riscos/menus.h" +#include "riscos/ucstables.h" +#include "riscos/wimp.h" +#include "riscos/wimp_event.h" +#include "utils/log.h" +#include "utils/utils.h" + +#define WIN_HASH_SIZE 32 +#define WIN_HASH(w) (((unsigned)(w) >> 5) % WIN_HASH_SIZE) + +typedef enum { + EVENT_NUMERIC_FIELD, + EVENT_TEXT_FIELD, + EVENT_UP_ARROW, + EVENT_DOWN_ARROW, + EVENT_MENU_GRIGHT, + EVENT_CHECKBOX, + EVENT_RADIO, + EVENT_BUTTON, + EVENT_CANCEL, + EVENT_OK +} event_type; + +struct event_data_numeric_field { + int stepping; + int min; + int max; + int decimal_places; +}; + +struct event_data_menu_gright { + wimp_i field; + wimp_menu *menu; +}; + +struct icon_event { + event_type type; + wimp_i i; + union { + struct event_data_numeric_field numeric_field; + struct event_data_menu_gright menu_gright; + wimp_i linked_icon; + int radio_group; + void (*callback)(wimp_pointer *pointer); + } data; + union { + char *textual; + bool boolean; + } previous_value; + bool previous_shaded; + struct icon_event *next; +}; + +struct event_window { + wimp_w w; + bool (*ok_click)(wimp_w w); + bool (*mouse_click)(wimp_pointer *pointer); + bool (*keypress)(wimp_key *key); + void (*open_window)(wimp_open *open); + void (*close_window)(wimp_w w); + void (*redraw_window)(wimp_draw *redraw); + void (*menu_selection)(wimp_w w, wimp_i i); + const char *help_prefix; + void *user_data; + struct icon_event *first; + struct event_window *next; + int max_radio_group; +}; + +static void ro_gui_wimp_event_ok_click(struct event_window *window, + wimp_mouse_state state); +static struct event_window *ro_gui_wimp_event_get_window(wimp_w w); +static struct event_window *ro_gui_wimp_event_find_window(wimp_w w); +static struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i, + event_type type); +static void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event); +static struct event_window *ro_gui_wimp_event_remove_window(wimp_w w); + +static struct event_window *ro_gui_wimp_event_windows[WIN_HASH_SIZE]; + +static wimp_w ro_gui_wimp_event_submenu; + +/** + * Memorises the current state of any registered components in a window. + * + * \param w the window to memorise + * \return true on success, false on memory exhaustion or for an unknown window + */ +bool ro_gui_wimp_event_memorise(wimp_w w) +{ + struct event_window *window; + struct icon_event *event; + bool error = false; + + window = ro_gui_wimp_event_find_window(w); + if (!window) + return false; + + for (event = window->first; event; event = event->next) { + switch (event->type) { + case EVENT_NUMERIC_FIELD: + case EVENT_TEXT_FIELD: + if (event->previous_value.textual) + free(event->previous_value.textual); + event->previous_value.textual = strdup( + ro_gui_get_icon_string(window->w, event->i)); + if (!event->previous_value.textual) { + error = true; + LOG(("Unable to store state for icon %i", event->i)); + } + break; + case EVENT_CHECKBOX: + case EVENT_RADIO: + event->previous_value.boolean = + ro_gui_get_icon_selected_state(window->w, event->i); + break; + default: + break; + } + if (event->type != EVENT_MENU_GRIGHT) + event->previous_shaded = ro_gui_get_icon_shaded_state(window->w, + event->i); + } + return !error; +} + + +/** + * Restore the state of any registered components in a window to their memorised state. + * + * \param w the window to restore + * \return true on success, false for an unknown window + */ +bool ro_gui_wimp_event_restore(wimp_w w) +{ + struct event_window *window; + struct icon_event *event; + + window = ro_gui_wimp_event_find_window(w); + if (!window) + return false; + + for (event = window->first; event; event = event->next) { + switch (event->type) { + case EVENT_NUMERIC_FIELD: + case EVENT_TEXT_FIELD: + if (event->previous_value.textual) + ro_gui_set_icon_string(window->w, event->i, + event->previous_value.textual); + break; + case EVENT_CHECKBOX: + case EVENT_RADIO: + ro_gui_set_icon_selected_state(window->w, event->i, + event->previous_value.boolean); + break; + default: + break; + } + if (event->type != EVENT_MENU_GRIGHT) + ro_gui_set_icon_shaded_state(window->w, event->i, + event->previous_shaded); + } + return true; +} + + +/** + * Ensures all values are within pre-determined boundaries. + * + * \param w the window to memorise + * \return true on success, false for an unknown window + */ +bool ro_gui_wimp_event_validate(wimp_w w) +{ + struct event_window *window; + struct icon_event *event; + int value; + + window = ro_gui_wimp_event_find_window(w); + if (!window) + return false; + + for (event = window->first; event; event = event->next) { + switch (event->type) { + case EVENT_NUMERIC_FIELD: + value = ro_gui_get_icon_decimal(window->w, event->i, + event->data.numeric_field.decimal_places); + if (value < event->data.numeric_field.min) + value = event->data.numeric_field.min; + else if (value > event->data.numeric_field.max) + value = event->data.numeric_field.max; + ro_gui_set_icon_decimal(window->w, event->i, value, + event->data.numeric_field.decimal_places); + break; + default: + break; + } + } + return true; +} + + +/** + * Free any resources associated with a window. + * + * \param w the window to free resources for + */ +void ro_gui_wimp_event_finalise(wimp_w w) +{ + struct event_window *window; + struct icon_event *event; + + LOG(("Removing all events for window 0x%x", (unsigned int)w)); + window = ro_gui_wimp_event_remove_window(w); + if (!window) + return; + + while (window->first) { + event = window->first; + window->first = event->next; + switch (event->type) { + case EVENT_NUMERIC_FIELD: + case EVENT_TEXT_FIELD: + if (event->previous_value.textual) + free(event->previous_value.textual); + event->previous_value.textual = NULL; + break; + default: + break; + } + free(event); + } + free(window); + return; +} + + +/** + * Set the associated help prefix for a given window. + * + * \param w the window to get the prefix for + * \param help_prefix the prefix to associate with the window (used directly) + * \return true on success, or NULL for memory exhaustion + */ +bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->help_prefix = help_prefix; + return true; +} + + +/** + * Get the associated help prefix. + * + * \param w the window to get the prefix for + * \return the associated prefix, or NULL + */ +const char *ro_gui_wimp_event_get_help_prefix(wimp_w w) +{ + struct event_window *window; + + window = ro_gui_wimp_event_find_window(w); + if (window) + return window->help_prefix; + return NULL; +} + + +/** + * Sets the user data associated with a window. + * + * \param w the window to associate the data with + * \param user the data to associate + */ +bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->user_data = user; + return true; + +} + + +/** + * Gets the user data associated with a window. + * + * \param w the window to retrieve the data for + * \return the associated data, or NULL + */ +void *ro_gui_wimp_event_get_user_data(wimp_w w) +{ + struct event_window *window; + + window = ro_gui_wimp_event_find_window(w); + if (window) + return window->user_data; + return NULL; +} + + +/** + * Handles a menu selection event. + * + * \param w the window to owning the menu + * \param i the icon owning the menu + * \param menu the menu that has been selected + * \param selection the selection information + * \return true if the event was handled, false otherwise + */ +bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, + wimp_selection *selection) +{ + struct event_window *window; + struct icon_event *event; + wimp_menu_entry *menu_entry; + wimp_key key; + os_error *error; + wimp_caret caret; + wimp_icon_state ic; + unsigned int button_type; + + window = ro_gui_wimp_event_find_window(w); + if (!window) + return false; + + for (event = window->first; event; event = event->next) + if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i)) + break; + if (!event) + return false; + + menu_entry = &menu->entries[selection->items[0]]; + for (i = 1; selection->items[i] != -1; i++) + menu_entry = &menu_entry->sub_menu-> + entries[selection->items[i]]; + + /* if the entry is already ticked then we do nothing */ + if (menu_entry->menu_flags & wimp_MENU_TICKED) + return true; + + ro_gui_set_icon_string_le(window->w, event->data.menu_gright.field, + menu_entry->data.indirected_text.text); + ro_gui_wimp_event_prepare_menu(window->w, event); + if (window->menu_selection) + window->menu_selection(window->w, event->i); + + /* set the caret for writable icons and send a CTRL+U keypress to + * stimulate activity if needed */ + ic.w = window->w; + ic.i = event->data.menu_gright.field; + error = xwimp_get_icon_state(&ic); + if (error) { + LOG(("xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE) >> wimp_ICON_BUTTON_TYPE_SHIFT; + if ((button_type != wimp_BUTTON_WRITABLE) && + (button_type != wimp_BUTTON_WRITE_CLICK_DRAG)) + return true; + error = xwimp_get_caret_position(&caret); + if (error) { + LOG(("xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + if ((caret.w != window->w) || (caret.i != event->data.menu_gright.field)) { + error = xwimp_set_caret_position(window->w, event->data.menu_gright.field, + -1, -1, -1, strlen(menu_entry->data.indirected_text.text)); + if (error) { + LOG(("xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + } + } + if (window->keypress) { + key.w = window->w; + key.c = 21; // ctrl+u + window->keypress(&key); + } + return true; +} + + +/** + * Handles a mouse click event in a registered window. + * + * The order of execution is: + * + * 1. Any registered mouse_click routine (see ro_gui_wimp_register_mouse_click()) + * 2. If the current icon is not registered with a type then it is assumed that no + * action is necessary, and the click is deemed to have been handled. + * 3. If the registered mouse_click routine returned false, or there was no registered + * routine then the automated action for the registered icon type is performed + * + * \param pointer the current pointer state + * \return true if the event was handled, false otherwise + */ +bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) +{ + struct event_window *window; + struct icon_event *event; + wimp_w w; + struct icon_event *search; + int current, step, stepping, min, max, decimal_places; + wimp_window_state open; + wimp_caret caret; + os_error *error; + + w = pointer->w; + window = ro_gui_wimp_event_find_window(w); + if (!window) + return false; + + /* registered routines take priority */ + if ((window->mouse_click) && (window->mouse_click(pointer))) + return true; + + for (event = window->first; event; event = event->next) + if (event->i == pointer->i) + break; + if (!event) + return true; + + switch (event->type) { + case EVENT_NUMERIC_FIELD: + case EVENT_TEXT_FIELD: + break; + case EVENT_UP_ARROW: + case EVENT_DOWN_ARROW: + for (search = window->first; search; search = search->next) + if (search->i == event->data.linked_icon) break; + if (!search) { + LOG(("Incorrect reference.")); + return false; + } + stepping = search->data.numeric_field.stepping; + min = search->data.numeric_field.min; + max = search->data.numeric_field.max; + decimal_places = search->data.numeric_field.decimal_places; + + if (pointer->buttons & wimp_CLICK_ADJUST) + step = -stepping; + else if (pointer->buttons & wimp_CLICK_SELECT) + step = stepping; + else + return true; + if (event->type == EVENT_DOWN_ARROW) + step = -step; + + current = ro_gui_get_icon_decimal(pointer->w, event->data.linked_icon, + decimal_places); + current += step; + if (current < min) + current = min; + if (current > max) + current = max; + ro_gui_set_icon_decimal(pointer->w, event->data.linked_icon, current, + decimal_places); + break; + case EVENT_MENU_GRIGHT: + /* if there's already a menu open then we assume that we are part of it. + * to follow the standard RISC OS behaviour we add a 'send to the back' + * button, then close the menu (which closes us) and then finally + * re-open ourselves. ugh! */ + if (current_menu != NULL) { + open.w = pointer->w; + error = xwimp_get_window_state(&open); + if (error) { + LOG(("xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + error = xwimp_get_caret_position(&caret); + if (error) { + LOG(("xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + ro_gui_dialog_add_persistent(current_menu_window, + pointer->w); + ro_gui_menu_closed(false); + gui_poll(true); + error = xwimp_open_window((wimp_open *) &open); + if (error) { + LOG(("xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + if (caret.w == pointer->w) { + error = xwimp_set_caret_position(caret.w, + caret.i, + caret.pos.x, caret.pos.y, + -1, caret.index); + if (error) { + LOG(("xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + } + } + } + /* display the menu */ + ro_gui_wimp_event_prepare_menu(pointer->w, event); + ro_gui_popup_menu(event->data.menu_gright.menu, pointer->w, pointer->i); + break; + case EVENT_CHECKBOX: + break; + case EVENT_RADIO: + for (search = window->first; search; search = search->next) + if ((search->type == EVENT_RADIO) && + (search->data.radio_group == + event->data.radio_group)) + ro_gui_set_icon_selected_state(pointer->w, + search->i, (search == event)); + break; + case EVENT_BUTTON: + if (event->data.callback) + event->data.callback(pointer); + break; + case EVENT_CANCEL: + if (pointer->buttons & wimp_CLICK_SELECT) { + ro_gui_dialog_close(pointer->w); + ro_gui_wimp_event_close_window(pointer->w); + ro_gui_menu_closed(true); + } else { + ro_gui_wimp_event_restore(pointer->w); + } + break; + case EVENT_OK: + ro_gui_wimp_event_ok_click(window, pointer->buttons); + break; + } + return true; +} + + +/** + * Prepare a menu ready for use + * + * /param w the window owning the menu + * /param event the icon event owning the menu + */ +void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event) +{ + int i; + char *text; + unsigned int button_type; + wimp_icon_state ic; + wimp_menu *menu; + os_error *error; + + /* if the linked icon is not writable then we set the ticked state + * of the menu item that matches the contents */ + ic.w = w; + ic.i = event->data.menu_gright.field; + error = xwimp_get_icon_state(&ic); + if (error) { + LOG(("xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return; + } + button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE) + >> wimp_ICON_BUTTON_TYPE_SHIFT; + if ((button_type == wimp_BUTTON_WRITABLE) || + (button_type == wimp_BUTTON_WRITE_CLICK_DRAG)) + return; + text = ro_gui_get_icon_string(w, event->data.menu_gright.field); + menu = event->data.menu_gright.menu; + i = 0; + do { + if (!strcmp(menu->entries[i].data.indirected_text.text, text)) + menu->entries[i].menu_flags |= wimp_MENU_TICKED; + else + menu->entries[i].menu_flags &= ~wimp_MENU_TICKED; + } while (!(menu->entries[i++].menu_flags & wimp_MENU_LAST)); +} + + +/** + * Perform the necessary actions following a click on the OK button. + * + * /param window the window to perform the action on + * /param state the mouse button state + */ +void ro_gui_wimp_event_ok_click(struct event_window *window, + wimp_mouse_state state) +{ + struct icon_event *search; + + for (search = window->first; search; search = search->next) + if (search->type == EVENT_OK) { + if (ro_gui_get_icon_shaded_state(window->w, search->i)) + return; + break; + } + ro_gui_wimp_event_validate(window->w); + + if (window->ok_click) + if (!window->ok_click(window->w)) + return; + + if (state & wimp_CLICK_SELECT) { + ro_gui_dialog_close(window->w); + ro_gui_wimp_event_close_window(window->w); + ro_gui_menu_closed(true); + } else { + ro_gui_wimp_event_memorise(window->w); + } +} + + +/** + * Handle any registered keypresses, and the standard RISC OS ones + * + * \param key the key state + * \return true if keypress handled, false otherwise + */ +bool ro_gui_wimp_event_keypress(wimp_key *key) +{ + static const int *ucstable = NULL; + static int alphabet = 0; + static uint32_t wc = 0; /* buffer for UTF8 alphabet */ + static int shift = 0; + struct event_window *window; + struct icon_event *event; + wimp_pointer pointer; + wimp_key k; + uint32_t c = (uint32_t) key->c; + int t_alphabet; + os_error *error; + + window = ro_gui_wimp_event_find_window(key->w); + if (!window) + return false; + + /* copy key state so we can corrupt it safely */ + memcpy(&k, key, sizeof(wimp_key)); + + /* In order to make sensible use of the 0x80->0xFF ranges specified + * in the RISC OS 8bit alphabets, we must do the following: + * + * + Read the currently selected alphabet + * + Acquire a pointer to the UCS conversion table for this alphabet: + * + Try using ServiceInternational 8 to get the table + * + If that fails, use our internal table (see ucstables.c) + * + If the alphabet is not UTF8 and the conversion table exists: + * + Lookup UCS code in the conversion table + * + If code is -1 (i.e. undefined): + * + Use codepoint 0xFFFD instead + * + If the alphabet is UTF8, we must buffer input, thus: + * + If the keycode is < 0x80: + * + Handle it directly + * + If the keycode is a UTF8 sequence start: + * + Initialise the buffer appropriately + * + Otherwise: + * + OR in relevant bits from keycode to buffer + * + If we've received an entire UTF8 character: + * + Handle UCS code + * + Otherwise: + * + Simply handle the keycode directly, as there's no easy way + * of performing the mapping from keycode -> UCS4 codepoint. + */ + error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &t_alphabet); + if (error) { + LOG(("failed reading alphabet: 0x%x: %s", + error->errnum, error->errmess)); + /* prevent any corruption of ucstable */ + t_alphabet = alphabet; + } + + if (t_alphabet != alphabet) { + osbool unclaimed; + /* Alphabet has changed, so read UCS table location */ + alphabet = t_alphabet; + + error = xserviceinternational_get_ucs_conversion_table( + alphabet, &unclaimed, + (void**)&ucstable); + if (error) { + LOG(("failed reading UCS conversion table: 0x%x: %s", + error->errnum, error->errmess)); + /* try using our own table instead */ + ucstable = ucstable_from_alphabet(alphabet); + } + if (unclaimed) + /* Service wasn't claimed so use our own ucstable */ + ucstable = ucstable_from_alphabet(alphabet); + } + + if (c < 256) { + if (alphabet != 111 /* UTF8 */ && ucstable != NULL) { + /* defined in this alphabet? */ + if (ucstable[c] == -1) + return true; + + /* read UCS4 value out of table */ + k.c = ucstable[c]; + } + else if (alphabet == 111 /* UTF8 */) { + if ((c & 0x80) == 0x00 || (c & 0xC0) == 0xC0) { + /* UTF8 start sequence */ + if ((c & 0xE0) == 0xC0) { + wc = ((c & 0x1F) << 6); + shift = 1; + return true; + } + else if ((c & 0xF0) == 0xE0) { + wc = ((c & 0x0F) << 12); + shift = 2; + return true; + } + else if ((c & 0xF8) == 0xF0) { + wc = ((c & 0x07) << 18); + shift = 3; + return true; + } + /* These next two have been removed + * from RFC3629, but there's no + * guarantee that RISC OS won't + * generate a UCS4 value outside the + * UTF16 plane, so we handle them + * anyway. */ + else if ((c & 0xFC) == 0xF8) { + wc = ((c & 0x03) << 24); + shift = 4; + } + else if ((c & 0xFE) == 0xFC) { + wc = ((c & 0x01) << 30); + shift = 5; + } + else if (c >= 0x80) { + /* If this ever happens, + * RISC OS' UTF8 keyboard + * drivers are broken */ + LOG(("unexpected UTF8 start" + " byte %x (ignoring)", + c)); + return true; + } + /* Anything else is ASCII, so just + * handle it directly. */ + } + else { + if ((c & 0xC0) != 0x80) { + /* If this ever happens, + * RISC OS' UTF8 keyboard + * drivers are broken */ + LOG(("unexpected keycode: " + "%x (ignoring)", c)); + return true; + } + + /* Continuation of UTF8 character */ + wc |= ((c & 0x3F) << (6 * --shift)); + if (shift > 0) + /* partial character */ + return true; + else + /* got entire character, so + * fetch from buffer and + * handle it */ + k.c = wc; + } + } + } else { + k.c |= (1u<<31); + } + + /* registered routines take priority */ + if (window->keypress) + if (window->keypress(&k)) + return true; + + switch (key->c) { + /* Escape performs the CANCEL action (simulated click) */ + case wimp_KEY_ESCAPE: + for (event = window->first; event; event = event->next) { + switch (event->type) { + case EVENT_CANCEL: + pointer.w = key->w; + pointer.i = event->i; + pointer.buttons = wimp_CLICK_SELECT; + ro_gui_wimp_event_mouse_click(&pointer); + return true; + default: + break; + } + } + return false; + /* CTRL+F2 closes a window with a close icon */ + case wimp_KEY_CONTROL + wimp_KEY_F2: + if (!ro_gui_wimp_check_window_furniture(key->w, + wimp_WINDOW_CLOSE_ICON)) + return false; + ro_gui_dialog_close(key->w); + ro_gui_wimp_event_close_window(key->w); + ro_gui_menu_closed(true); + return true; + /* Return performs the OK action */ + case wimp_KEY_RETURN: + if (!window->ok_click) + return false; + /* todo: check we aren't greyed out */ + ro_gui_wimp_event_ok_click(window, wimp_CLICK_SELECT); + return true; + } + return false; +} + + +/** + * Handle any open window requests + * + * \param open the window open request + */ +bool ro_gui_wimp_event_open_window(wimp_open *open) +{ + struct event_window *window; + + window = ro_gui_wimp_event_find_window(open->w); + if ((window) && (window->open_window)) { + window->open_window(open); + return true; + } + return false; +} + + +/** + * Service any close window handlers + * + * \param w the window being closed + */ +bool ro_gui_wimp_event_close_window(wimp_w w) +{ + struct event_window *window; + + LOG(("Close event received for window 0x%x", (unsigned int)w)); + if (w == ro_gui_wimp_event_submenu) + ro_gui_wimp_event_submenu = 0; + window = ro_gui_wimp_event_find_window(w); + if ((window) && (window->close_window)) { + window->close_window(w); + return true; + } + return false; +} + + +/** + * Handle any redraw window requests + * + * \param redraw the window redraw request + */ +bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw) +{ + struct event_window *window; + + window = ro_gui_wimp_event_find_window(redraw->w); + if ((window) && (window->redraw_window)) { + window->redraw_window(redraw); + return true; + } + return false; +} + + +/** + * Register a numeric 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) +{ + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_NUMERIC_FIELD); + if (!event) + return false; + event->data.numeric_field.min = min; + event->data.numeric_field.max = max; + event->data.numeric_field.stepping = stepping; + event->data.numeric_field.decimal_places = decimal_places; + + event = ro_gui_wimp_event_get_event(w, up, EVENT_UP_ARROW); + if (!event) + return false; + event->data.linked_icon = i; + + event = ro_gui_wimp_event_get_event(w, down, EVENT_DOWN_ARROW); + if (!event) + return false; + event->data.linked_icon = i; + + return true; +} + + +/** + * Register a text field to be automatically handled + */ +bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i) { + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_TEXT_FIELD); + if (!event) + return false; + return true; +} + + +/** + * Register an icon menu to be automatically handled + */ +bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, + wimp_i gright, wimp_menu *menu) +{ + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, gright, EVENT_MENU_GRIGHT); + if (!event) + return false; + event->data.menu_gright.field = i; + event->data.menu_gright.menu = menu; + + return ro_gui_wimp_event_register_text_field(w, i); +} + + +/** + * Register a checkbox to be automatically handled + */ +bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i) +{ + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_CHECKBOX); + if (!event) + return false; + return true; +} + + +/** + * Register a group of radio icons to be automatically handled + */ +bool ro_gui_wimp_event_register_radio(wimp_w w, wimp_i *i) +{ + struct event_window *window; + struct icon_event *event; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->max_radio_group++; + + while (*i != -1) { + event = ro_gui_wimp_event_get_event(w, *i, EVENT_RADIO); + if (!event) + return false; + event->data.radio_group = window->max_radio_group; + *i++; + } + return true; +} + + +/** + * Register a function to be called when a particular button is pressed. + */ +bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i, + void (*callback)(wimp_pointer *pointer)) +{ + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_BUTTON); + if (!event) + return false; + event->data.callback = callback; + return true; +} + + +/** + * Register a function to be called for the Cancel action on a window. + */ +bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i) +{ + struct icon_event *event; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_CANCEL); + if (!event) + return false; + return true; +} + + +/** + * Register a function to be called for the OK action on a window. + */ +bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, + bool (*callback)(wimp_w w)) +{ + struct event_window *window; + struct icon_event *event; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->ok_click = callback; + + event = ro_gui_wimp_event_get_event(w, i, EVENT_OK); + if (!event) + return false; + return true; +} + + +/** + * Register a function to be called for all mouse-clicks to icons + * in a window that don't have registered actions. + */ +bool ro_gui_wimp_event_register_mouse_click(wimp_w w, + bool (*callback)(wimp_pointer *pointer)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->mouse_click = callback; + return true; +} + + +/** + * Register a function to be called for all keypresses within a + * particular window. + * + * Important: the character code passed to the callback in key->c + * is UTF-32 (i.e. in the range [0, &10ffff]). WIMP keys (e.g. F1) + * will have bit 31 set. + * + */ +bool ro_gui_wimp_event_register_keypress(wimp_w w, + bool (*callback)(wimp_key *key)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->keypress = callback; + return true; +} + + +/** + * Register a function to be called for all window opening requests. + */ +bool ro_gui_wimp_event_register_open_window(wimp_w w, + void (*callback)(wimp_open *open)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->open_window = callback; + return true; +} + +/** + * Register a function to be called after the window has been closed. + */ +bool ro_gui_wimp_event_register_close_window(wimp_w w, + void (*callback)(wimp_w w)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->close_window = callback; + return true; +} + +/** + * Register a function to be called for all window redraw operations. + */ +bool ro_gui_wimp_event_register_redraw_window(wimp_w w, + void (*callback)(wimp_draw *redraw)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->redraw_window = callback; + return true; +} + +/** + * Register a function to be called following a menu selection. + */ +bool ro_gui_wimp_event_register_menu_selection(wimp_w w, + void (*callback)(wimp_w w, wimp_i i)) +{ + struct event_window *window; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return false; + window->menu_selection = callback; + return true; +} + + +/** + * Finds the event data associated with a given window handle, or creates a new one. + * + * \param w the window to find data for + */ +struct event_window *ro_gui_wimp_event_get_window(wimp_w w) +{ + struct event_window *window; + int h; + + assert((int)w != 0); + window = ro_gui_wimp_event_find_window(w); + if (window) + return window; + + LOG(("Creating structure for window 0x%x", (unsigned int)w)); + window = calloc(1, sizeof(struct event_window)); + if (!window) + return NULL; + + h = WIN_HASH(w); + window->w = w; + window->next = ro_gui_wimp_event_windows[h]; + ro_gui_wimp_event_windows[h] = window; + return window; +} + + +/** + * Removes the event data associated with a given handle from the hash tables, + * but does not delete it. + * + * \param w the window to be removed + * \return pointer to the event data or NULL if not found + */ + +struct event_window *ro_gui_wimp_event_remove_window(wimp_w w) +{ + struct event_window **prev; + int h = WIN_HASH(w); + + /* search hash chain for the window */ + prev = &ro_gui_wimp_event_windows[h]; + while (*prev) { + struct event_window *window = *prev; + + if (window->w == w) { + /* remove from chain */ + *prev = window->next; + return window; + } + prev = &window->next; + } + + /* not found */ + return NULL; +} + +/** + * Find the event data associated with a given window handle + * + * \param w the window to find data for + */ +struct event_window *ro_gui_wimp_event_find_window(wimp_w w) +{ + struct event_window *window; + int h = WIN_HASH(w); + + /* search hash chain for window */ + for (window = ro_gui_wimp_event_windows[h]; window; window = window->next) { + if (window->w == w) + return window; + } + return NULL; +} + +struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i, + event_type type) +{ + struct event_window *window; + struct icon_event *event; + + window = ro_gui_wimp_event_get_window(w); + if (!window) + return NULL; + + for (event = window->first; event; event = event->next) { + if (event->i == i) { + event->type = type; + return event; + } + } + + event = calloc(1, sizeof(struct icon_event)); + if (!event) + return NULL; + event->i = i; + event->type = type; + event->next = window->first; + window->first = event; + + return event; +} + +/** + * Handle menus being closed + */ +void ro_gui_wimp_event_menus_closed(void) +{ + ro_gui_wimp_event_register_submenu(0); +} + +/** + * Register a submenu as being opened + */ +void ro_gui_wimp_event_register_submenu(wimp_w w) +{ + if (ro_gui_wimp_event_submenu) + ro_gui_wimp_event_close_window(ro_gui_wimp_event_submenu); + ro_gui_wimp_event_submenu = w; +} diff --git a/riscos/window.c b/riscos/window.c index 045cabe56..4f80647f5 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -36,7 +36,7 @@ #include "oslib/colourtrans.h" #include "oslib/osbyte.h" #include "oslib/osfile.h" -#include +#include "oslib/osspriteop.h" #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" #include "utils/config.h" diff --git a/utils/hashtable.c b/utils/hashtable.c index ce4ec3755..6a5bce0ba 100644 --- a/utils/hashtable.c +++ b/utils/hashtable.c @@ -42,6 +42,34 @@ struct hash_table { struct hash_entry **chain; }; +/** + * Hash a string, returning a 32bit value. The hash algorithm used is + * Fowler Noll Vo - a very fast and simple hash, ideal for short strings. + * See http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash for more details. + * + * \param datum The string to hash. + * \param len Pointer to unsigned integer to record datum's length in. + * \return The calculated hash value for the datum. + */ + +static inline unsigned int hash_string_fnv(const char *datum, unsigned int *len) +{ + unsigned int z = 0x01000193; + const char *start = datum; + *len = 0; + + if (datum == NULL) + return 0; + + while (*datum) { + z *= 0x01000193; + z ^= *datum++; + } + *len = datum - start; + + return z; +} + /** * Create a new hash table, and return a context for it. The memory consumption @@ -178,34 +206,6 @@ const char *hash_get(struct hash_table *ht, const char *key) return NULL; } -/** - * Hash a string, returning a 32bit value. The hash algorithm used is - * Fowler Noll Vo - a very fast and simple hash, ideal for short strings. - * See http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash for more details. - * - * \param datum The string to hash. - * \param len Pointer to unsigned integer to record datum's length in. - * \return The calculated hash value for the datum. - */ - -unsigned int hash_string_fnv(const char *datum, unsigned int *len) -{ - unsigned int z = 0x01000193; - const char *start = datum; - *len = 0; - - if (datum == NULL) - return 0; - - while (*datum) { - z *= 0x01000193; - z ^= *datum++; - } - *len = datum - start; - - return z; -} - /** * Iterate through all available hash keys. * diff --git a/utils/hashtable.h b/utils/hashtable.h index 2c698b0b3..432ccfe2a 100644 --- a/utils/hashtable.h +++ b/utils/hashtable.h @@ -30,7 +30,6 @@ struct hash_table *hash_create(unsigned int chains); void hash_destroy(struct hash_table *ht); bool hash_add(struct hash_table *ht, const char *key, const char *value); const char *hash_get(struct hash_table *ht, const char *key); -inline unsigned int hash_string_fnv(const char *datum, unsigned int *len); const char *hash_iterate(struct hash_table *ht, unsigned int *c1, unsigned int **c2); -- cgit v1.2.3