NetSurf
window.c
Go to the documentation of this file.
1/*
2 * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
3 * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
4 * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
5 * Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
6 * Copyright 2005 Richard Wilson <info@tinct.net>
7 * Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
8 * Copyright 2010-2014 Stephen Fryatt <stevef@netsurf-browser.org>
9 *
10 * This file is part of NetSurf, http://www.netsurf-browser.org/
11 *
12 * NetSurf is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
15 *
16 * NetSurf is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25/**
26 * \file
27 * Implementation of RISC OS browser window handling.
28 */
29
30#include <assert.h>
31#include <ctype.h>
32#include <math.h>
33#include <stdio.h>
34#include <stdbool.h>
35#include <stdint.h>
36#include <time.h>
37#include <string.h>
38#include <limits.h>
39#include <oslib/colourtrans.h>
40#include <oslib/osbyte.h>
41#include <oslib/osfile.h>
42#include <oslib/osspriteop.h>
43#include <oslib/wimp.h>
44#include <oslib/wimpspriteop.h>
45#include <nsutils/time.h>
46
47#include "netsurf/inttypes.h"
48#include "utils/nsoption.h"
49#include "utils/log.h"
50#include "utils/talloc.h"
51#include "utils/file.h"
52#include "utils/utf8.h"
53#include "utils/utils.h"
54#include "utils/messages.h"
55#include "utils/string.h"
56#include "utils/nsurl.h"
57#include "netsurf/content.h"
59#include "netsurf/plotters.h"
60#include "netsurf/window.h"
61#include "netsurf/bitmap.h"
62#include "netsurf/url_db.h"
63#include "netsurf/form.h"
64#include "netsurf/keypress.h"
67#include "desktop/searchweb.h"
68
69#include "riscos/bitmap.h"
70#include "riscos/buffer.h"
71#include "riscos/cookies.h"
72#include "riscos/dialog.h"
75#include "riscos/pageinfo.h"
76#include "riscos/gui.h"
78#include "riscos/help.h"
79#include "riscos/hotlist.h"
80#include "riscos/menus.h"
81#include "riscos/mouse.h"
82#include "riscos/oslib_pre7.h"
83#include "riscos/save.h"
86#include "riscos/toolbar.h"
87#include "riscos/url_complete.h"
88#include "riscos/url_suggest.h"
89#include "riscos/wimp.h"
90#include "riscos/wimp_event.h"
91#include "riscos/wimputils.h"
92#include "riscos/window.h"
93#include "riscos/ucstables.h"
94#include "riscos/filetype.h"
95
96
97#ifndef wimp_KEY_END
98#define wimp_KEY_END wimp_KEY_COPY
99#endif
100
101#ifndef wimp_WINDOW_GIVE_SHADED_ICON_INFO
102 /* RISC OS 5+. Requires OSLib trunk. */
103#define wimp_WINDOW_GIVE_SHADED_ICON_INFO ((wimp_extra_window_flags) 0x10u)
104#endif
105
106#define SCROLL_VISIBLE_PADDING 32
107
108#define SCROLL_TOP INT_MIN
109#define SCROLL_PAGE_UP (INT_MIN + 1)
110#define SCROLL_PAGE_DOWN (INT_MAX - 1)
111#define SCROLL_BOTTOM INT_MAX
112
113/** Remembers which iconised sprite numbers are in use */
114static bool iconise_used[64];
115static int iconise_next = 0;
116
117/** Whether a pressed mouse button has become a drag */
120
121/** List of all browser windows. */
122static struct gui_window *window_list = 0;
123/** GUI window which is being redrawn. Valid only during redraw. */
125/** Form control which gui_form_select_menu is for. */
127/** The browser window menu handle. */
128static wimp_menu *ro_gui_browser_window_menu = NULL;
129/** Menu of options for form select controls. */
130static wimp_menu *gui_form_select_menu = NULL;
131/** Main content object under menu, or 0 if none. */
133/** Object under menu, or 0 if no object. */
135/** URL of link under menu, or 0 if no link. */
137
138static float scale_snap_to[] = {0.10, 0.125, 0.25, 0.333, 0.5, 0.75,
139 1.0,
140 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0};
141#define SCALE_SNAP_TO_SIZE (sizeof scale_snap_to) / (sizeof(float))
142
143/** An entry in ro_gui_pointer_table. */
145 bool wimp_area; /** The pointer is in the Wimp's sprite area. */
146 char sprite_name[16];
149};
150
151/**
152 * Map from gui_pointer_shape to pointer sprite data. Must be ordered as
153 * enum gui_pointer_shape. */
155 { true, "ptr_default", 0, 0 },
156 { false, "ptr_point", 6, 0 },
157 { false, "ptr_caret", 4, 9 },
158 { false, "ptr_menu", 6, 4 },
159 { false, "ptr_ud", 6, 7 },
160 { false, "ptr_ud", 6, 7 },
161 { false, "ptr_lr", 7, 6 },
162 { false, "ptr_lr", 7, 6 },
163 { false, "ptr_ld", 7, 7 },
164 { false, "ptr_ld", 7, 7 },
165 { false, "ptr_rd", 7, 7 },
166 { false, "ptr_rd", 6, 7 },
167 { false, "ptr_cross", 7, 7 },
168 { false, "ptr_move", 8, 0 },
169 { false, "ptr_wait", 7, 10 },
170 { false, "ptr_help", 0, 0 },
171 { false, "ptr_nodrop", 0, 0 },
172 { false, "ptr_nt_allwd", 10, 10 },
173 { false, "ptr_progress", 0, 0 },
174};
175
177 int x0;
178 int y0;
179 int x1;
180 int y1;
182 struct gui_window *g;
184};
185
187#define MARGIN 4
188
189
190/**
191 * Place the caret in a browser window.
192 *
193 * \param g window with caret
194 * \param x coordinates of caret
195 * \param y coordinates of caret
196 * \param height height of caret
197 * \param clip clip rectangle, or NULL if none
198 */
199static void
201 int x,
202 int y,
203 int height,
204 const struct rect *clip)
205{
206 os_error *error;
207
208 error = xwimp_set_caret_position(g->window, -1,
209 x * 2, -(y + height) * 2, height * 2, -1);
210 if (error) {
211 NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
212 error->errnum, error->errmess);
213 ro_warn_user("WimpError", error->errmess);
214 }
215}
216
217
218/**
219 * Updates a windows extent.
220 *
221 * \param g the gui_window to update
222 * \param width the minimum width, or -1 to use window width
223 * \param height the minimum height, or -1 to use window height
224 */
225static void gui_window_set_extent(struct gui_window *g, int width, int height)
226{
227 int screen_width;
228 int toolbar_height = 0;
229 wimp_window_state state;
230 os_error *error;
231
232 if (g->toolbar) {
233 toolbar_height = ro_toolbar_full_height(g->toolbar);
234 }
235
236 /* get the current state */
237 if ((height == -1) || (width == -1)) {
238 state.w = g->window;
239 error = xwimp_get_window_state(&state);
240 if (error) {
241 NSLOG(netsurf, INFO,
242 "xwimp_get_window_state: 0x%x: %s",
243 error->errnum,
244 error->errmess);
245 ro_warn_user("WimpError", error->errmess);
246 return;
247 }
248 if (width == -1)
249 width = state.visible.x1 - state.visible.x0;
250 if (height == -1) {
251 height = state.visible.y1 - state.visible.y0;
252 height -= toolbar_height;
253 }
254 }
255
256 /* the top-level framed window is a total pain. to get it to maximise
257 * to the top of the screen we need to fake it having a suitably large
258 * extent */
260 ro_gui_screen_size(&screen_width, &height);
261 if (g->toolbar)
265 }
267 int w, h;
268 browser_window_get_extents(g->bw, true, &w, &h);
269 width = max(width, w * 2);
270 height = max(height, h * 2);
271 }
272 os_box extent = { 0, -height, width, toolbar_height };
273 error = xwimp_set_extent(g->window, &extent);
274 if (error) {
275 NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
276 error->errnum, error->errmess);
277 ro_warn_user("WimpError", error->errmess);
278 return;
279 }
280}
281
282
283/**
284 * Open a window
285 *
286 * opens a window using the given wimp_open, handling toolbars and resizing.
287 *
288 * \param open the window open event information
289 */
290static void ro_gui_window_open(wimp_open *open)
291{
292 struct gui_window *g;
293 int width = open->visible.x1 - open->visible.x0;
294 int height = open->visible.y1 - open->visible.y0;
295 browser_scrolling h_scroll;
296 browser_scrolling v_scroll;
297 int toolbar_height = 0;
298 float new_scale = 0;
299 wimp_window_state state;
300 os_error *error;
301 wimp_w parent;
302 bits linkage;
303 bool have_content;
304
305 g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
306
307 if (open->next == wimp_TOP && g->iconise_icon >= 0) {
308 /* window is no longer iconised, release its sprite number */
309 iconise_used[g->iconise_icon] = false;
310 g->iconise_icon = -1;
311 }
312
313 have_content = browser_window_has_content(g->bw);
314
315 /* get the current flags/nesting state */
316 state.w = g->window;
317 error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
318 if (error) {
319 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
320 error->errnum, error->errmess);
321 ro_warn_user("WimpError", error->errmess);
322 return;
323 }
324
325 /* account for toolbar height, if present */
326 if (g->toolbar)
327 toolbar_height = ro_toolbar_full_height(g->toolbar);
328 height -= toolbar_height;
329
330 /* work with the state from now on so we can modify flags */
331 state.visible = open->visible;
332 state.xscroll = open->xscroll;
333 state.yscroll = open->yscroll;
334 state.next = open->next;
335
336 browser_window_get_scrollbar_type(g->bw, &h_scroll, &v_scroll);
337
338 /* handle 'auto' scroll bars' and non-fitting scrollbar removal */
339 if ((h_scroll != BW_SCROLLING_NO) && (v_scroll != BW_SCROLLING_NO)) {
340 int size;
341
342 /* windows lose scrollbars when containing a frameset */
343 bool no_hscroll = false;
344 bool no_vscroll = browser_window_is_frameset(g->bw);
345
346 /* hscroll */
347 size = ro_get_hscroll_height(NULL);
348 size -= 2; /* 1px border on both sides */
349 if (!no_hscroll) {
350 if (!(state.flags & wimp_WINDOW_HSCROLL)) {
351 height -= size;
352 state.visible.y0 += size;
353 if (have_content) {
355 }
356 }
357 state.flags |= wimp_WINDOW_HSCROLL;
358 } else {
359 if (state.flags & wimp_WINDOW_HSCROLL) {
360 height += size;
361 state.visible.y0 -= size;
362 if (have_content) {
364 }
365 }
366 state.flags &= ~wimp_WINDOW_HSCROLL;
367 }
368
369 /* vscroll */
370 size = ro_get_vscroll_width(NULL);
371 size -= 2; /* 1px border on both sides */
372 if (!no_vscroll) {
373 if (!(state.flags & wimp_WINDOW_VSCROLL)) {
374 width -= size;
375 state.visible.x1 -= size;
376 if (have_content) {
378 }
379 }
380 state.flags |= wimp_WINDOW_VSCROLL;
381 } else {
382 if (state.flags & wimp_WINDOW_VSCROLL) {
383 width += size;
384 state.visible.x1 += size;
385 if (have_content) {
387 }
388 }
389 state.flags &= ~wimp_WINDOW_VSCROLL;
390 }
391 }
392
393 /* reformat or change extent if necessary */
394 if (have_content &&
395 (g->old_width != width || g->old_height != height)) {
396 /* Ctrl-resize of a top-level window scales the content size */
397 if ((g->old_width > 0) &&
398 (g->old_width != width) &&
400 new_scale = (browser_window_get_scale(g->bw) * width) / g->old_width;
401 }
403 }
404 if (g->update_extent ||
405 g->old_width != width ||
406 g->old_height != height) {
407 g->old_width = width;
408 g->old_height = height;
409 g->update_extent = false;
411 }
412
413 /* first resize stops any flickering by making the URL window on top */
415
416 /* Windows containing framesets can only be scrolled via the core, which
417 * is implementing frame scrollbars itself. The x and y offsets are
418 * therefore fixed.
419 */
420
422 state.xscroll = 0;
423 state.yscroll = toolbar_height;
424 }
425
426 error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
427 if (error) {
428 NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
429 error->errnum, error->errmess);
430 ro_warn_user("WimpError", error->errmess);
431 return;
432 }
433
434 /* update the toolbar */
435 if (g->status_bar)
437 if (g->toolbar) {
438 ro_toolbar_process(g->toolbar, -1, false);
439 /* second resize updates to the new URL bar width */
441 }
442
443 /* set the new scale from a ctrl-resize. this must be done at the end as
444 * it may cause a frameset recalculation based on the new window size.
445 */
446 if (new_scale > 0) {
447 ro_gui_window_set_scale(g, new_scale);
448 }
449}
450
451
452/**
453 * Update the extent of the inside of a browser window to that of the
454 * current content.
455 *
456 * \param g gui_window to update the extent of
457 */
459{
460 os_error *error;
461 wimp_window_info info;
462
463 assert(g);
464
465 info.w = g->window;
466 error = xwimp_get_window_info_header_only(&info);
467 if (error) {
468 NSLOG(netsurf, INFO,
469 "xwimp_get_window_info_header_only: 0x%x: %s",
470 error->errnum,
471 error->errmess);
472 ro_warn_user("WimpError", error->errmess);
473 return;
474 }
475
476 /* scroll on toolbar height change */
477 if (g->toolbar) {
478 int scroll = ro_toolbar_height(g->toolbar) - info.extent.y1;
479 info.yscroll += scroll;
480 }
481
482 /* Handle change of extents */
483 g->update_extent = true;
485}
486
487
488/**
489 * Update a window and its toolbar
490 *
491 * makes a window and toolbar reflect a new theme: used as a callback
492 * by the toolbar module when a theme change affects a toolbar.
493 *
494 * \param data void pointer to the window's gui_window struct
495 * \param ok true if the bar still exists; else false.
496 */
497static void ro_gui_window_update_theme(void *data, bool ok)
498{
499 struct gui_window *g = (struct gui_window *) data;
500
501 if (g != NULL && g->toolbar != NULL) {
502 if (ok) {
504 } else {
505 g->toolbar = NULL;
506 }
507 }
508}
509
510
511/**
512 * Update a window to reflect a change in toolbar size: used as a callback by
513 * the toolbar module when a toolbar height changes.
514 *
515 * \param data void pointer the window's gui_window struct
516 */
517static void ro_gui_window_update_toolbar(void *data)
518{
519 struct gui_window *g = (struct gui_window *) data;
520
521 if (g != NULL) {
523 }
524}
525
526
527/**
528 * Update the toolbar buttons for a given browser window to reflect the
529 * current state of its contents.
530 *
531 * Note that the parameters to this function are arranged so that it can be
532 * supplied to the toolbar module as an button state update callback.
533 *
534 * \param g The browser window to update.
535 */
537{
538 struct browser_window *bw;
539 struct toolbar *toolbar;
540
541 if (g == NULL || g->toolbar == NULL)
542 return;
543
544 bw = g->bw;
545 toolbar = g->toolbar;
546
549
552
555
558
561
564
567
570
573
575}
576
577
578/**
579 * Add a hotlist entry for a browser window.
580 *
581 * \param g The browser window to act on.
582 */
584{
585 nsurl *url;
586
587 if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
588 browser_window_has_content(g->bw) == false)
589 return;
590
592
595}
596
597
598/**
599 * Remove a hotlist entry for a browser window.
600 *
601 * \param g The browser window to act on.
602 */
604{
605 nsurl *url;
606
607 if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
608 browser_window_has_content(g->bw) == false)
609 return;
610
612
614}
615
616
617/**
618 * Open a local history pane for a browser window.
619 *
620 * \param gw The browser window to act on.
621 */
623{
624 nserror res;
625
626 if ((gw == NULL) || (gw->bw == NULL)) {
627 return;
628 }
629
630 res = ro_gui_local_history_present(gw->window, gw->bw);
631
632 if (res != NSERROR_OK) {
634 }
635}
636
637
638/**
639 * Perform a Navigate Home action on a browser window.
640 *
641 * \param g The browser window to act on.
642 */
644{
645 static const char *addr = NETSURF_HOMEPAGE;
646 nsurl *url;
647 nserror error;
648
649 if (g == NULL || g->bw == NULL)
650 return;
651
652 if (nsoption_charp(homepage_url) != NULL) {
653 addr = nsoption_charp(homepage_url);
654 }
655
656 error = nsurl_create(addr, &url);
657 if (error == NSERROR_OK) {
658 error = browser_window_navigate(g->bw,
659 url,
660 NULL,
662 NULL,
663 NULL,
664 NULL);
666 }
667 if (error != NSERROR_OK) {
669 }
670}
671
672
673/**
674 * Open a text search dialogue for a browser window.
675 *
676 * \param g The browser window to act on.
677 */
679{
680 if (g == NULL || g->bw == NULL || !browser_window_can_search(g->bw))
681 return;
682
685}
686
687
688/**
689 * Open a zoom dialogue for a browser window.
690 *
691 * \param g The browser window to act on.
692 */
694{
695 if (g == NULL)
696 return;
697
700}
701
702
703/**
704 * Open a save dialogue for a browser window contents.
705 *
706 * \param g The browser window to act on.
707 * \param save_type The type of save to open.
708 */
709static void
711{
712 struct hlcache_handle *h;
713
714 if (g == NULL || g->bw == NULL || !browser_window_has_content(g->bw))
715 return;
716
718 if (h == NULL)
719 return;
720
721 ro_gui_save_prepare(save_type, h, NULL, NULL, NULL);
723}
724
725
726/**
727 * Open a print dialogue for a browser window.
728 *
729 * \param g The browser window to act on.
730 */
732{
733 if (g != NULL) {
736 }
737}
738
739
740/**
741 * Prepare the page info window for use.
742 *
743 * \param g The GUI window block to use.
744 */
746{
748 char icon_buf[20] = "file_xxx";
749 char enc_buf[40];
750 const char *icon = icon_buf;
751 const char *title, *url;
752 lwc_string *mime;
753 const char *enc = "-";
754
755 assert(h);
756
757 title = content_get_title(h);
758 if (title == NULL)
759 title = "-";
761 if (url == NULL)
762 url = "-";
763 mime = content_get_mime_type(h);
764
765 sprintf(icon_buf, "file_%x", ro_content_filetype(h));
766 if (!ro_gui_wimp_sprite_exists(icon_buf))
767 sprintf(icon_buf, "file_xxx");
768
769 if (content_get_type(h) == CONTENT_HTML) {
771 snprintf(enc_buf, sizeof enc_buf, "%s (%s)",
774 enc = enc_buf;
775 } else {
776 enc = messages_get("EncodingUnk");
777 }
778 }
779
781 icon, true);
783 title, true);
785 url, true);
787 enc, true);
789 lwc_string_data(mime), true);
790
791 lwc_string_unref(mime);
792}
793
794
795/**
796 * Open a page info box for a browser window.
797 *
798 * \param g The browser window to act on.
799 */
801{
802 if (g == NULL || g->bw == NULL ||
803 browser_window_has_content(g->bw) == false)
804 return;
805
808}
809
810
811/**
812 * Process Mouse_Click events in a toolbar's button bar.
813 *
814 * This does not handle other clicks in a toolbar: these are handled
815 * by the toolbar module itself.
816 *
817 * \param data The GUI window associated with the click.
818 * \param action_type The action type to be handled.
819 * \param action The action to process.
820 */
821static void
823 toolbar_action_type action_type,
824 union toolbar_action action)
825{
826 struct gui_window *g = data;
827 nserror err;
828
829 if (g == NULL)
830 return;
831
832
833 if (action_type == TOOLBAR_ACTION_URL) {
834 switch (action.url) {
837 {
838 gui_save_type save_type;
839 nserror err;
840 nsurl *url;
841
843 break;
844
846 save_type = GUI_SAVE_LINK_URL;
847 else
848 save_type = GUI_SAVE_LINK_TEXT;
849
850 err = browser_window_get_url(g->bw, true, &url);
851 if (err != NSERROR_OK) {
852 /* Fall back to access (won't get fragment). */
853 url = nsurl_ref(
855 }
856
857 ro_gui_drag_save_link(save_type, url,
859
861 }
862 break;
863
866 break;
867
870 break;
871
875
876 default:
877 break;
878 }
879
880 return;
881 }
882
883
884 /* By now, the only valid action left is a button click. If it isn't
885 * one of those, give up.
886 */
887
888 if (action_type != TOOLBAR_ACTION_BUTTON)
889 return;
890
891 switch (action.button) {
893 if (g->bw != NULL)
895 break;
896
898 if (g->bw != NULL)
900 break;
901
903 if (g->bw != NULL)
905 break;
906
908 if (g->bw != NULL)
910 break;
911
913 if (g->bw != NULL)
915 break;
916
918 if (g->bw != NULL)
919 browser_window_reload(g->bw, false);
920 break;
921
923 if (g->bw != NULL)
924 browser_window_reload(g->bw, true);
925 break;
926
929 break;
930
933 break;
934
937 break;
938
941 break;
942
945 break;
946
949 break;
950
953 break;
954
957 break;
958
961 break;
962
965 break;
966
968 err = browser_window_navigate_up(g->bw, false);
969 if (err != NSERROR_OK) {
971 }
972 break;
973
975 err = browser_window_navigate_up(g->bw, true);
976 if (err != NSERROR_OK) {
978 }
979 break;
980
981 default:
982 break;
983 }
984
986}
987
988
989/**
990 * Launch a new url in the given window.
991 *
992 * \param g gui_window to update
993 * \param url1 url to be launched
994 */
995static void ro_gui_window_launch_url(struct gui_window *g, const char *url_s)
996{
997 nserror error;
998 nsurl *url;
999
1000 if (url_s == NULL) {
1001 return;
1002 }
1003
1005
1006 error = search_web_omni(url_s, SEARCH_WEB_OMNI_NONE, &url);
1007 if (error != NSERROR_OK) {
1009 } else {
1011
1013 NULL, BW_NAVIGATE_HISTORY,
1014 NULL, NULL, NULL);
1016 }
1017}
1018
1019
1020/**
1021 * Open a new browser window.
1022 *
1023 * \param g The browser window to act on.
1024 */
1026{
1027 nserror error;
1028
1029 if (g == NULL || g->bw == NULL)
1030 return;
1031
1034 NULL, g->bw, NULL);
1035
1036 if (error != NSERROR_OK) {
1038 }
1039}
1040
1041
1042/**
1043 * Scroll a browser window.
1044 *
1045 * the scroll is either via the core or directly using the normal
1046 * Wimp_OpenWindow interface.
1047 *
1048 * Scroll steps are supplied in terms of the (extended) Scroll Event direction
1049 * values returned by Wimp_Poll. Special values of 0x7fffffff and 0x80000000
1050 * are added to mean "Home" and "End".
1051 *
1052 * \param g The GUI Window to be scrolled.
1053 * \param scroll_x The X scroll step to be applied.
1054 * \param scroll_y The Y scroll step to be applied.
1055 */
1056static void
1058 wimp_scroll_direction scroll_x,
1059 wimp_scroll_direction scroll_y)
1060{
1061 int visible_x, visible_y;
1062 int step_x = 0, step_y = 0;
1063 int toolbar_y;
1064 wimp_window_state state;
1065 wimp_pointer pointer;
1066 os_error *error;
1067 os_coord pos;
1068 bool handled = false;
1069 struct toolbar *toolbar;
1070
1071 if (g == NULL)
1072 return;
1073
1074 /* Get the current window, toolbar and pointer details. */
1075
1076 state.w = g->window;
1077 error = xwimp_get_window_state(&state);
1078 if (error) {
1079 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
1080 error->errnum, error->errmess);
1081 return;
1082 }
1083
1085 assert(g == NULL || g->toolbar == NULL || g->toolbar == toolbar);
1086
1087 toolbar_y = (toolbar == NULL) ? 0 : ro_toolbar_full_height(toolbar);
1088
1089 visible_x = state.visible.x1 - state.visible.x0 - 32;
1090 visible_y = state.visible.y1 - state.visible.y0 - 32 - toolbar_y;
1091
1092 error = xwimp_get_pointer_info(&pointer);
1093 if (error) {
1094 NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
1095 error->errnum, error->errmess);
1096 ro_warn_user("WimpError", error->errmess);
1097 return;
1098 }
1099
1100 /* Turn the scroll requirement from Scroll Event codes into coordinates
1101 * that the core can understand.
1102 */
1103
1104 switch (scroll_x) {
1105 case wimp_SCROLL_PAGE_LEFT:
1106 step_x = SCROLL_PAGE_DOWN;
1107 break;
1108 case wimp_SCROLL_AUTO_LEFT:
1109 case wimp_SCROLL_COLUMN_LEFT:
1110 step_x = -16;
1111 break;
1112 case wimp_SCROLL_AUTO_RIGHT:
1113 case wimp_SCROLL_COLUMN_RIGHT:
1114 step_x = 16;
1115 break;
1116 case wimp_SCROLL_PAGE_RIGHT:
1117 step_x = SCROLL_PAGE_UP;
1118 break;
1119 case 0x80000000:
1120 step_x = SCROLL_BOTTOM;
1121 break;
1122 case 0x7fffffff:
1123 step_x = SCROLL_TOP;
1124 break;
1125 default:
1126 step_x = (32 * (scroll_x / 4));
1127 break;
1128 }
1129
1130 switch (scroll_y) {
1131 case wimp_SCROLL_PAGE_UP:
1132 step_y = SCROLL_PAGE_UP;
1133 break;
1134 case wimp_SCROLL_AUTO_UP:
1135 case wimp_SCROLL_LINE_UP:
1136 step_y = -16;
1137 break;
1138 case wimp_SCROLL_AUTO_DOWN:
1139 case wimp_SCROLL_LINE_DOWN:
1140 step_y = 16;
1141 break;
1142 case wimp_SCROLL_PAGE_DOWN:
1143 step_y = SCROLL_PAGE_DOWN;
1144 break;
1145 case 0x80000000:
1146 step_y = SCROLL_BOTTOM;
1147 break;
1148 case 0x7fffffff:
1149 step_y = SCROLL_TOP;
1150 break;
1151 default:
1152 step_y = -(32 * (scroll_y / 4));
1153 break;
1154 }
1155
1156 /* If no scrolling is required, there's no point trying to do any. */
1157
1158 if (step_x == 0 && step_y == 0)
1159 return;
1160
1161 /* If the pointer is over the window being scrolled, then try to get
1162 * the core to do the scrolling on the object under the pointer.
1163 */
1164
1165 if (pointer.w == g->window &&
1166 ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
1168 pos.x,
1169 pos.y,
1170 step_x,
1171 step_y);
1172
1173 /* If the core didn't do the scrolling, handle it via the Wimp.
1174 * Windows which contain frames can only be scrolled by the core,
1175 * because it implements frame scroll bars.
1176 */
1177
1178 if (!handled && (browser_window_is_frameset(g->bw) == false)) {
1179 switch (step_x) {
1180 case SCROLL_TOP:
1181 state.xscroll -= 0x10000000;
1182 break;
1183 case SCROLL_BOTTOM:
1184 state.xscroll += 0x10000000;
1185 break;
1186 case SCROLL_PAGE_UP:
1187 state.xscroll += visible_x;
1188 break;
1189 case SCROLL_PAGE_DOWN:
1190 state.xscroll -= visible_x;
1191 break;
1192 default:
1193 state.xscroll += 2 * step_x;
1194 break;
1195 }
1196
1197 switch (step_y) {
1198 case SCROLL_TOP:
1199 state.yscroll += 0x10000000;
1200 break;
1201 case SCROLL_BOTTOM:
1202 state.yscroll -= 0x10000000;
1203 break;
1204 case SCROLL_PAGE_UP:
1205 state.yscroll += visible_y;
1206 break;
1207 case SCROLL_PAGE_DOWN:
1208 state.yscroll -= visible_y;
1209 break;
1210 default:
1211 state.yscroll -= 2 * step_y;
1212 break;
1213 }
1214
1215 error = xwimp_open_window((wimp_open *) &state);
1216 if (error) {
1217 NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
1218 error->errnum, error->errmess);
1219 }
1220 }
1221}
1222
1223/**
1224 * handle scale kepresses within RISC OS
1225 */
1226static bool handle_local_keypress_scale(struct gui_window *gw, uint32_t c)
1227{
1228 float cscale; /* current scale */
1229 float scale; /* new scale */
1230
1231 cscale = browser_window_get_scale(gw->bw);
1232
1233 scale = cscale;
1234
1235 if (ro_gui_shift_pressed() && c == 17) {
1236 scale = cscale - 0.1;
1237 } else if (ro_gui_shift_pressed() && c == 23) {
1238 scale = cscale + 0.1;
1239 } else if (c == 17) {
1240 for (int i = SCALE_SNAP_TO_SIZE - 1; i >= 0; i--) {
1241 if (scale_snap_to[i] < cscale) {
1242 scale = scale_snap_to[i];
1243 break;
1244 }
1245 }
1246 } else {
1247 for (unsigned int i = 0; i < SCALE_SNAP_TO_SIZE; i++) {
1248 if (scale_snap_to[i] > cscale) {
1249 scale = scale_snap_to[i];
1250 break;
1251 }
1252 }
1253 }
1254
1255 if (scale < scale_snap_to[0]) {
1256 scale = scale_snap_to[0];
1257 }
1258
1259 if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1]) {
1260 scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
1261 }
1262
1263 if (cscale != scale) {
1264 ro_gui_window_set_scale(gw, scale);
1265 }
1266
1267 return true;
1268}
1269
1270/**
1271 * Handle keypresses within the RISC OS GUI
1272 *
1273 * this is to be called after the core has been given a chance to act,
1274 * or on keypresses in the toolbar where the core doesn't get
1275 * involved.
1276 *
1277 * \param *g The gui window to which the keypress applies.
1278 * \param *key The keypress data.
1279 * \param is_toolbar true if the keypress is from a toolbar else false.
1280 * \return true if the keypress was claimed; else false.
1281 */
1282static bool
1284 wimp_key *key,
1285 bool is_toolbar)
1286{
1287 struct browser_window_features cont;
1288 os_error *ro_error;
1289 wimp_pointer pointer;
1290 os_coord pos;
1291 uint32_t c = (uint32_t) key->c;
1292 wimp_scroll_direction xscroll = wimp_SCROLL_NONE;
1293 wimp_scroll_direction yscroll = wimp_SCROLL_NONE;
1294 nsurl *url;
1295
1296 if (g == NULL)
1297 return false;
1298
1299 ro_error = xwimp_get_pointer_info(&pointer);
1300 if (ro_error) {
1301 NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s\n",
1302 ro_error->errnum, ro_error->errmess);
1303 ro_warn_user("WimpError", ro_error->errmess);
1304 return false;
1305 }
1306
1307 if (!ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
1308 return false;
1309
1310 browser_window_get_features(g->bw, pos.x, pos.y, &cont);
1311
1312 switch (c) {
1313 case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
1314 {
1315 nserror error = nsurl_create(
1316 "https://www.netsurf-browser.org/documentation/",
1317 &url);
1318 if (error == NSERROR_OK) {
1320 url,
1321 NULL,
1322 NULL,
1323 NULL);
1324 nsurl_unref(url);
1325 }
1326 if (error != NSERROR_OK) {
1328 }
1329 return true;
1330 }
1331 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F1:
1333 return true;
1334
1335 case IS_WIMP_KEY + wimp_KEY_F2:
1336 if (g->toolbar == NULL)
1337 return false;
1339 ro_toolbar_set_url(g->toolbar, "www.", true, true);
1341 ro_gui_url_complete_keypress(g->toolbar, wimp_KEY_DOWN);
1342 return true;
1343
1344 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F2:
1345 /* Close window. */
1349 return true;
1350
1351 case 19: /* Ctrl + S */
1352 case IS_WIMP_KEY + wimp_KEY_F3:
1354 return true;
1355
1356 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F3:
1358 return true;
1359
1360 case IS_WIMP_KEY + wimp_KEY_SHIFT + wimp_KEY_F3:
1362 return true;
1363
1364 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F3:
1366 return true;
1367
1368 case 6: /* Ctrl + F */
1369 case IS_WIMP_KEY + wimp_KEY_F4: /* Search */
1371 return true;
1372
1373 case IS_WIMP_KEY + wimp_KEY_F5: /* Reload */
1374 if (g->bw != NULL)
1375 browser_window_reload(g->bw, false);
1376 return true;
1377
1378 case 18: /* Ctrl+R (Full reload) */
1379 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F5:
1380 if (g->bw != NULL)
1381 browser_window_reload(g->bw, true);
1382 return true;
1383
1384 case IS_WIMP_KEY + wimp_KEY_F6: /* Hotlist */
1386 return true;
1387
1388 case IS_WIMP_KEY + wimp_KEY_F7: /* Show local history */
1390 return true;
1391
1392 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F7:
1393 /* Show global history */
1395 return true;
1396
1397 case IS_WIMP_KEY + wimp_KEY_F8: /* View source */
1398 ro_gui_view_source((cont.main != NULL) ? cont.main :
1400 return true;
1401
1402 case IS_WIMP_KEY + wimp_KEY_F9:
1403 /* Dump content for debugging. */
1405 return true;
1406
1407 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F9:
1408 urldb_dump();
1409 return true;
1410
1411 case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F9:
1412 talloc_report_full(0, stderr);
1413 return true;
1414
1415 case IS_WIMP_KEY + wimp_KEY_F11: /* Zoom */
1417 return true;
1418
1419 case IS_WIMP_KEY + wimp_KEY_SHIFT + wimp_KEY_F11:
1420 /* Toggle display of box outlines. */
1422
1424 return true;
1425
1426 case wimp_KEY_RETURN:
1427 if (is_toolbar) {
1428 const char *toolbar_url;
1429 toolbar_url = ro_toolbar_get_url(g->toolbar);
1430 ro_gui_window_launch_url(g, toolbar_url);
1431 }
1432 return true;
1433
1434 case wimp_KEY_ESCAPE:
1437 return true;
1438 }
1439
1440 if (g->bw != NULL)
1442 return true;
1443
1444 case 14: /* CTRL+N */
1446 return true;
1447
1448 case 17: /* CTRL+Q (Zoom out) */
1449 case 23: /* CTRL+W (Zoom in) */
1450 if (browser_window_has_content(g->bw) == true) {
1451 return handle_local_keypress_scale(g, c);
1452 }
1453 break;
1454
1455 case IS_WIMP_KEY + wimp_KEY_PRINT:
1457 return true;
1458
1459 case IS_WIMP_KEY | wimp_KEY_LEFT:
1460 case IS_WIMP_KEY | wimp_KEY_RIGHT:
1461 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_LEFT:
1462 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_RIGHT:
1463 case IS_WIMP_KEY | wimp_KEY_UP:
1464 case IS_WIMP_KEY | wimp_KEY_DOWN:
1465 case IS_WIMP_KEY | wimp_KEY_PAGE_UP:
1466 case IS_WIMP_KEY | wimp_KEY_PAGE_DOWN:
1467 case wimp_KEY_HOME:
1468 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_UP:
1470 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
1471 if (is_toolbar)
1472 return false;
1473 break;
1474 default:
1475 return false; /* This catches any keys we don't want to claim */
1476 }
1477
1478 /* Any keys that exit from the above switch() via break should be
1479 * processed as scroll actions in the browser window. */
1480
1481 switch (c) {
1482 case IS_WIMP_KEY | wimp_KEY_LEFT:
1483 xscroll = wimp_SCROLL_COLUMN_LEFT;
1484 break;
1485 case IS_WIMP_KEY | wimp_KEY_RIGHT:
1486 xscroll = wimp_SCROLL_COLUMN_RIGHT;
1487 break;
1488 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_LEFT:
1489 xscroll = 0x7fffffff;
1490 break;
1491 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_RIGHT:
1492 xscroll = 0x80000000;
1493 break;
1494 case IS_WIMP_KEY | wimp_KEY_UP:
1495 yscroll = wimp_SCROLL_LINE_UP;
1496 break;
1497 case IS_WIMP_KEY | wimp_KEY_DOWN:
1498 yscroll = wimp_SCROLL_LINE_DOWN;
1499 break;
1500 case IS_WIMP_KEY | wimp_KEY_PAGE_UP:
1501 yscroll = wimp_SCROLL_PAGE_UP;
1502 break;
1503 case IS_WIMP_KEY | wimp_KEY_PAGE_DOWN:
1504 yscroll = wimp_SCROLL_PAGE_DOWN;
1505 break;
1506 case wimp_KEY_HOME:
1507 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_UP:
1508 yscroll = 0x7fffffff;
1509 break;
1511 case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
1512 yscroll = 0x80000000;
1513 break;
1514 }
1515
1516 ro_gui_window_scroll_action(g, xscroll, yscroll);
1517
1518 return true;
1519}
1520
1521
1522/**
1523 * Callback handler for keypresses within browser window toolbars.
1524 *
1525 * \param data Client data, pointing to the GUI Window.
1526 * \param key The keypress data.
1527 * \return true if the keypress was handled; else false.
1528 */
1529static bool ro_gui_window_toolbar_keypress(void *data, wimp_key *key)
1530{
1531 struct gui_window *g = (struct gui_window *) data;
1532
1533 if (g != NULL) {
1534 return ro_gui_window_handle_local_keypress(g, key, true);
1535 }
1536
1537 return false;
1538}
1539
1540
1541/**
1542 * Save a new toolbar button configuration
1543 *
1544 * used as a callback by the toolbar module when a buttonbar edit has
1545 * finished.
1546 *
1547 * \param data void pointer to the window's gui_window struct
1548 * \param config pointer to a malloc()'d button config string.
1549 */
1550static void ro_gui_window_save_toolbar_buttons(void *data, char *config)
1551{
1552 nsoption_set_charp(toolbar_browser, config);
1554}
1555
1556
1557/**
1558 * toolbar callbacks for a browser window.
1559 */
1563 (void (*)(void *)) ro_gui_window_update_toolbar_buttons,
1567};
1568
1569
1570/**
1571 * Handle wimp closing event
1572 *
1573 * \param w The window handle the event occoured on
1574 */
1575static void ro_gui_window_close(wimp_w w)
1576{
1577 struct gui_window *g;
1578 wimp_pointer pointer;
1579 os_error *error;
1580 char *temp_name;
1581 char *filename = NULL;
1582 struct nsurl *url;
1583 bool destroy;
1584
1585 error = xwimp_get_pointer_info(&pointer);
1586 if (error) {
1587 NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
1588 error->errnum, error->errmess);
1589 ro_warn_user("WimpError", error->errmess);
1590 return;
1591 }
1592
1594
1595 if (pointer.buttons & wimp_CLICK_ADJUST) {
1596 destroy = !ro_gui_shift_pressed();
1597
1599 if (url != NULL) {
1600 netsurf_nsurl_to_path(url, &filename);
1601 }
1602 if (filename != NULL) {
1603 temp_name = malloc(strlen(filename) + 32);
1604 if (temp_name) {
1605 char *r;
1606 sprintf(temp_name, "Filer_OpenDir %s",
1607 filename);
1608 r = temp_name + strlen(temp_name);
1609 while (r > temp_name) {
1610 if (*r == '.') {
1611 *r = '\0';
1612 break;
1613 }
1614 r--;
1615 }
1616 error = xos_cli(temp_name);
1617 if (error) {
1618 NSLOG(netsurf, INFO,
1619 "xos_cli: 0x%x: %s",
1620 error->errnum,
1621 error->errmess);
1622 ro_warn_user("MiscError", error->errmess);
1623 return;
1624 }
1625 free(temp_name);
1626 }
1627 free(filename);
1628 } else {
1629 /* this is pointless if we are about to close the
1630 * window */
1631 if (!destroy && url != NULL)
1632 browser_window_navigate_up(g->bw, false);
1633 }
1634 } else {
1635 destroy = true;
1636 }
1637
1638 if (destroy) {
1640 }
1641}
1642
1643/**
1644 * Wrapper for calls to browser_window_redraw for a wimp_draw rectangle.
1645 *
1646 * \param[in] gui_win Window to render.
1647 * \param[in] wimp_rect The area of gui_win to render into.
1648 * \param[in] use_buffer Whether to use buffered rendering.
1649 */
1651 const struct gui_window *gui_win,
1652 const wimp_draw *wimp_rect,
1653 bool use_buffer)
1654{
1655 struct redraw_context ctx = {
1656 .interactive = true,
1657 .background_images = true,
1658 .plot = &ro_plotters
1659 };
1660 struct rect clip;
1661
1662 /* OS's redraw request coordinates are in screen coordinates,
1663 * with an origin at the bottom left of the screen.
1664 * Find the coordinate of the top left of the document in terms
1665 * of OS screen coordinates.
1666 * NOTE: OS units are 2 per px. */
1667 ro_plot_origin_x = wimp_rect->box.x0 - wimp_rect->xscroll;
1668 ro_plot_origin_y = wimp_rect->box.y1 - wimp_rect->yscroll;
1669
1670 /* Adjust clip rect for origin. */
1671 ro_plot_clip_rect.x0 = wimp_rect->clip.x0 - ro_plot_origin_x;
1672 ro_plot_clip_rect.y0 = ro_plot_origin_y - wimp_rect->clip.y0;
1673 ro_plot_clip_rect.x1 = wimp_rect->clip.x1 - ro_plot_origin_x;
1674 ro_plot_clip_rect.y1 = ro_plot_origin_y - wimp_rect->clip.y1;
1675
1676 /* Convert OS redraw rectangle request coordinates into NetSurf
1677 * coordinates. NetSurf coordinates have origin at top left of
1678 * document and units are in px. */
1679 clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
1680 clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
1681 clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
1682 clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
1683
1684 if (use_buffer) {
1685 ro_gui_buffer_open(wimp_rect);
1686 }
1687
1688 browser_window_redraw(gui_win->bw, 0, 0, &clip, &ctx);
1689
1690 if (use_buffer) {
1692 }
1693}
1694
1695/**
1696 * Handle a Redraw_Window_Request for a browser window.
1697 *
1698 * \param redraw The redraw event
1699 */
1700static void ro_gui_window_redraw(wimp_draw *redraw)
1701{
1702 osbool more;
1703 struct gui_window *g;
1704 os_error *error;
1705
1707
1708 /* We cannot render locked contents. If the browser window is not
1709 * ready for redraw, do nothing. Else, in the case of buffered
1710 * rendering we'll show random data. */
1712 return;
1713 }
1714
1716
1717 error = xwimp_redraw_window(redraw, &more);
1718 if (error) {
1719 NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
1720 error->errnum, error->errmess);
1721 ro_warn_user("WimpError", error->errmess);
1722 return;
1723 }
1724 while (more) {
1727
1728 /* Check to see if there are more rectangles to draw and
1729 * get next one */
1730 error = xwimp_get_rectangle(redraw, &more);
1731 /* RISC OS 3.7 returns an error here if enough buffer was
1732 claimed to cause a new dynamic area to be created. It
1733 doesn't actually stop anything working, so we mask it out
1734 for now until a better fix is found. This appears to be a
1735 bug in RISC OS. */
1736 if (error && !(ro_gui_current_redraw_gui->
1737 option.buffer_everything &&
1738 error->errnum == error_WIMP_GET_RECT)) {
1739 NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
1740 error->errnum, error->errmess);
1741 ro_warn_user("WimpError", error->errmess);
1743 return;
1744 }
1745 }
1747}
1748
1749
1750/**
1751 * Process Scroll_Request events in a browser window.
1752 *
1753 * \param scroll The wimp scroll event data block.
1754 */
1755static void ro_gui_window_scroll(wimp_scroll *scroll)
1756{
1757 float cscale, scale, inc;
1758 struct gui_window *g = ro_gui_window_lookup(scroll->w);
1759
1760 if (g == NULL) {
1761 return;
1762 }
1763
1764 if ((browser_window_has_content(g->bw) == false) ||
1765 (ro_gui_shift_pressed() == false)) {
1766 ro_gui_window_scroll_action(g, scroll->xmin, scroll->ymin);
1767 return;
1768 }
1769
1770 /* extended scroll request with shift held down; change zoom */
1771 cscale = browser_window_get_scale(g->bw);
1772
1773 if (scroll->ymin & 3) {
1774 inc = 0.02; /* RO5 sends the msg 5 times;
1775 * don't ask me why
1776 *
1777 * @todo this is liable to break if
1778 * HID is configured optimally for
1779 * frame scrolling. *5 appears to be
1780 * an artifact of non-HID mode scrolling.
1781 */
1782 } else {
1783 inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
1784 }
1785
1786 if (scroll->ymin > 0) {
1787 scale = cscale + inc;
1790 }
1791 } else {
1792 scale = cscale - inc;
1793 if (scale < scale_snap_to[0]) {
1794 scale = scale_snap_to[0];
1795 }
1796 }
1797 if (scale != cscale) {
1799 }
1800}
1801
1802
1803/**
1804 * Process Pointer Leaving Window events in a browser window.
1805 *
1806 * These arrive via the termination callback handler from ro_mouse's
1807 * mouse tracking.
1808 *
1809 * \param leaving The wimp pointer leaving event data block.
1810 * \param data The GUI window that the pointer is leaving.
1811 */
1812static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
1813{
1814 struct gui_window *g = (struct gui_window *)data;
1815
1816 if (g != NULL) {
1818 }
1819}
1820
1821
1822/**
1823 * Process Pointer Entering Window events in a browser window.
1824 *
1825 * \param entering The wimp pointer entering event data block.
1826 */
1827static void ro_gui_window_pointer_entering(wimp_entering *entering)
1828{
1829 struct gui_window *g = ro_gui_window_lookup(entering->w);
1830
1831 if (g != NULL) {
1834 g);
1835 }
1836}
1837
1838
1839/**
1840 * Process Key_Pressed events in a browser window.
1841 *
1842 * \param key The wimp keypress block for the event.
1843 * \return true if the event was handled, else false.
1844 */
1845static bool ro_gui_window_keypress(wimp_key *key)
1846{
1847 struct gui_window *g;
1848 uint32_t c = (uint32_t) key->c;
1849
1850 g = (struct gui_window *) ro_gui_wimp_event_get_user_data(key->w);
1851 if (g == NULL) {
1852 return false;
1853 }
1854
1855 /* First send the key to the browser window, eg. form fields. */
1856
1857 if ((unsigned)c < 0x20 ||
1858 (0x7f <= c && c <= 0x9f) ||
1859 (c & IS_WIMP_KEY)) {
1860 /* Munge control keys into unused control chars */
1861 /* We can't map onto 1->26 (reserved for ctrl+<qwerty>
1862 That leaves 27->31 and 128->159 */
1863 switch (c & ~IS_WIMP_KEY) {
1864 case wimp_KEY_TAB:
1865 c = 9;
1866 break;
1867
1868 case wimp_KEY_SHIFT | wimp_KEY_TAB:
1869 c = 11;
1870 break;
1871
1872 /* cursor movement keys */
1873 case wimp_KEY_HOME:
1874 case wimp_KEY_CONTROL | wimp_KEY_LEFT:
1876 break;
1877
1878 case wimp_KEY_END:
1879 if (os_version >= RISCOS5) {
1880 c = NS_KEY_LINE_END;
1881 } else {
1883 }
1884 break;
1885
1886 case wimp_KEY_CONTROL | wimp_KEY_RIGHT:
1887 c = NS_KEY_LINE_END;
1888 break;
1889
1890 case wimp_KEY_CONTROL | wimp_KEY_UP:
1892 break;
1893
1894 case wimp_KEY_CONTROL | wimp_KEY_DOWN:
1895 c = NS_KEY_TEXT_END;
1896 break;
1897
1898 case wimp_KEY_SHIFT | wimp_KEY_LEFT:
1899 c = NS_KEY_WORD_LEFT ;
1900 break;
1901
1902 case wimp_KEY_SHIFT | wimp_KEY_RIGHT:
1904 break;
1905
1906 case wimp_KEY_SHIFT | wimp_KEY_UP:
1907 c = NS_KEY_PAGE_UP;
1908 break;
1909
1910 case wimp_KEY_SHIFT | wimp_KEY_DOWN:
1911 c = NS_KEY_PAGE_DOWN;
1912 break;
1913
1914 case wimp_KEY_LEFT:
1915 c = NS_KEY_LEFT;
1916 break;
1917
1918 case wimp_KEY_RIGHT:
1919 c = NS_KEY_RIGHT;
1920 break;
1921
1922 case wimp_KEY_UP:
1923 c = NS_KEY_UP;
1924 break;
1925
1926 case wimp_KEY_DOWN:
1927 c = NS_KEY_DOWN;
1928 break;
1929
1930 /* editing */
1931 case wimp_KEY_CONTROL | wimp_KEY_END:
1933 break;
1934
1935 case wimp_KEY_DELETE:
1936 if (ro_gui_ctrl_pressed()) {
1938 } else if (os_version < RISCOS5) {
1940 }
1941 break;
1942
1943 case wimp_KEY_F8:
1944 c = NS_KEY_UNDO;
1945 break;
1946
1947 case wimp_KEY_F9:
1948 c = NS_KEY_REDO;
1949 break;
1950
1951 default:
1952 break;
1953 }
1954 }
1955
1956 if (!(c & IS_WIMP_KEY)) {
1957 if (browser_window_key_press(g->bw, c)) {
1958 return true;
1959 }
1960 }
1961
1962 return ro_gui_window_handle_local_keypress(g, key, false);
1963}
1964
1965
1966/**
1967 * Handle Mouse_Click events in a browser window.
1968 *
1969 * This should never see Menu clicks, as these will be routed to the
1970 * menu handlers.
1971 *
1972 * \param pointer details of mouse click
1973 * \return true if click handled, false otherwise
1974 */
1975static bool ro_gui_window_click(wimp_pointer *pointer)
1976{
1977 struct gui_window *g;
1978 os_coord pos;
1979
1980 /* We should never see Menu clicks. */
1981
1982 if (pointer->buttons == wimp_CLICK_MENU) {
1983 return false;
1984 }
1985
1986 g = (struct gui_window *) ro_gui_wimp_event_get_user_data(pointer->w);
1987
1988 /* try to close url-completion */
1990
1991 /* set input focus */
1992 if (pointer->buttons & (wimp_SINGLE_SELECT | wimp_SINGLE_ADJUST))
1993 gui_window_place_caret(g, -100, -100, 0, NULL);
1994
1995 if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos)) {
1997 ro_gui_mouse_click_state(pointer->buttons,
1998 wimp_BUTTON_DOUBLE_CLICK_DRAG),
1999 pos.x, pos.y);
2000 }
2001
2002 return true;
2003}
2004
2005
2006/**
2007 * Prepare or reprepare a form select menu
2008 *
2009 * setting up the menu handle globals in the process.
2010 *
2011 * \param g The RISC OS gui window the menu is in.
2012 * \param control The form control needing a menu.
2013 * \return true if the menu is OK to be opened; else false.
2014 */
2015static bool
2017 struct form_control *control)
2018{
2019 unsigned int item, entries;
2020 char *text_convert, *temp;
2021 struct form_option *option;
2022 bool reopen = true;
2023 nserror err;
2024
2025 assert(control);
2026
2027 /* enumerate the entries */
2028 entries = 0;
2029 option = form_select_get_option(control, entries);
2030 while (option != NULL) {
2031 entries++;
2032 option = form_select_get_option(control, entries);
2033 }
2034
2035 if (entries == 0) {
2036 /* no menu to display */
2038 return false;
2039 }
2040
2041 /* free riscos menu if there already is one */
2042 if ((gui_form_select_menu) && (control != gui_form_select_control)) {
2043 for (item = 0; ; item++) {
2044 free(gui_form_select_menu->entries[item].data.
2045 indirected_text.text);
2046 if (gui_form_select_menu->entries[item].menu_flags &
2047 wimp_MENU_LAST)
2048 break;
2049 }
2050 free(gui_form_select_menu->title_data.indirected_text.text);
2053 }
2054
2055 /* allocate new riscos menu */
2056 if (!gui_form_select_menu) {
2057 reopen = false;
2058 gui_form_select_menu = malloc(wimp_SIZEOF_MENU(entries));
2059 if (!gui_form_select_menu) {
2060 ro_warn_user("NoMemory", 0);
2062 return false;
2063 }
2064 err = utf8_to_local_encoding(messages_get("SelectMenu"), 0,
2065 &text_convert);
2066 if (err != NSERROR_OK) {
2067 /* badenc should never happen */
2068 assert(err != NSERROR_BAD_ENCODING);
2069 NSLOG(netsurf, INFO, "utf8_to_local_encoding failed");
2070 ro_warn_user("NoMemory", 0);
2072 return false;
2073 }
2074 gui_form_select_menu->title_data.indirected_text.text =
2075 text_convert;
2077 }
2078
2079 /* initialise menu entries from form control */
2080 for (item = 0; item < entries; item++) {
2081 option = form_select_get_option(control, item);
2082 gui_form_select_menu->entries[item].menu_flags = 0;
2083 if (option->selected)
2084 gui_form_select_menu->entries[item].menu_flags =
2085 wimp_MENU_TICKED;
2086 if (!reopen) {
2087
2088 /* convert spaces to hard spaces to stop things
2089 * like 'Go Home' being treated as if 'Home' is a
2090 * keyboard shortcut and right aligned in the menu.
2091 */
2092
2093 temp = cnv_space2nbsp(option->text);
2094 if (!temp) {
2095 NSLOG(netsurf, INFO, "cnv_space2nbsp failed");
2096 ro_warn_user("NoMemory", 0);
2098 return false;
2099 }
2100
2101 err = utf8_to_local_encoding(temp,
2102 0, &text_convert);
2103 if (err != NSERROR_OK) {
2104 /* A bad encoding should never happen,
2105 * so assert this */
2106 assert(err != NSERROR_BAD_ENCODING);
2107 NSLOG(netsurf, INFO, "utf8_to_enc failed");
2108 ro_warn_user("NoMemory", 0);
2110 return false;
2111 }
2112
2113 free(temp);
2114
2115 gui_form_select_menu->entries[item].data.indirected_text.text =
2116 text_convert;
2117 gui_form_select_menu->entries[item].data.indirected_text.size =
2118 strlen(gui_form_select_menu->entries[item].
2119 data.indirected_text.text) + 1;
2120 }
2121 }
2122
2123 gui_form_select_menu->entries[0].menu_flags |=
2124 wimp_MENU_TITLE_INDIRECTED;
2125 gui_form_select_menu->entries[item - 1].menu_flags |= wimp_MENU_LAST;
2126
2127 return true;
2128}
2129
2130
2131/**
2132 * Return boolean flags to show what RISC OS types we can sensibly convert
2133 * the given object into.
2134 *
2135 * \todo This should probably be somewhere else but in window.c, and
2136 * should probably even be done in content_().
2137 *
2138 * \param h The object to test.
2139 * \param export_draw true on exit if a drawfile would be possible.
2140 * \param export_sprite true on exit if a sprite would be possible.
2141 * \return true if valid data is returned; else false.
2142 */
2143static bool
2145 bool *export_draw,
2146 bool *export_sprite)
2147{
2148 bool found_type = false;
2149
2150 if (export_draw != NULL) {
2151 *export_draw = false;
2152 }
2153 if (export_sprite != NULL) {
2154 *export_sprite = false;
2155 }
2156
2157 if (h != NULL && content_get_type(h) == CONTENT_IMAGE) {
2158 switch (ro_content_native_type(h)) {
2159 case osfile_TYPE_SPRITE:
2160 /* bitmap types (Sprite export possible) */
2161 found_type = true;
2162 if (export_sprite != NULL) {
2163 *export_sprite = true;
2164 }
2165 break;
2166
2167 case osfile_TYPE_DRAW:
2168 /* vector types (Draw export possible) */
2169 found_type = true;
2170 if (export_draw != NULL) {
2171 *export_draw = true;
2172 }
2173 break;
2174
2175 default:
2176 break;
2177 }
2178 }
2179
2180 return found_type;
2181}
2182
2183
2184/**
2185 * Prepare the browser window menu for (re-)opening
2186 *
2187 * \param w The window owning the menu.
2188 * \param i The icon owning the menu.
2189 * \param menu The menu about to be opened.
2190 * \param pointer Pointer to the relevant wimp event block, or
2191 * NULL for an Adjust click.
2192 * \return true if the event was handled; else false.
2193 */
2194static bool
2196 wimp_i i,
2197 wimp_menu *menu,
2198 wimp_pointer *pointer)
2199{
2200 struct gui_window *g;
2201 struct browser_window *bw;
2202 struct toolbar *toolbar;
2203 struct browser_window_features cont;
2204 bool export_sprite, export_draw, have_content;
2205 os_coord pos;
2206 browser_editor_flags editor_flags;
2207
2209 toolbar = g->toolbar;
2210 bw = g->bw;
2211 have_content = browser_window_has_content(g->bw);
2212 editor_flags = browser_window_get_editor_flags(bw);
2213
2214 /* If this is the form select menu, handle it now and then exit.
2215 * Otherwise, carry on to the main browser window menu.
2216 */
2217
2218 if (menu == gui_form_select_menu) {
2221 }
2222
2223 if (menu != ro_gui_browser_window_menu) {
2224 return false;
2225 }
2226
2227 /* If this is a new opening for the browser window menu (ie. not for a
2228 * toolbar menu), get details of the object under the pointer.
2229 */
2230 if (pointer != NULL && g->window == w) {
2232
2233 current_menu_main = NULL;
2234 current_menu_object = NULL;
2235 current_menu_url = NULL;
2236
2237 if (ro_gui_window_to_window_pos(g, pointer->pos.x,
2238 pointer->pos.y, &pos)) {
2239 browser_window_get_features(bw, pos.x, pos.y, &cont);
2240
2241 current_menu_main = cont.main;
2243 current_menu_url = cont.link;
2244 }
2245 }
2246
2247 /* Shade menu entries according to the state of the window and object
2248 * under the pointer.
2249 */
2250
2251 /* Toolbar (Sub)Menu */
2252
2257
2262
2267
2272
2273 /* Page Submenu */
2274
2277
2278 ro_gui_menu_set_entry_shaded(menu, BROWSER_PAGE_INFO, !have_content);
2279
2280 ro_gui_menu_set_entry_shaded(menu, BROWSER_PRINT, !have_content);
2281
2283
2286
2287
2289
2293 !have_content);
2294
2295 ro_gui_menu_set_entry_shaded(menu, BROWSER_SAVE, !have_content);
2297 !have_content);
2301
2308
2309
2310
2311 /* Object Submenu */
2312
2314 current_menu_object == NULL &&
2315 current_menu_url == NULL);
2316
2318 current_menu_url == NULL);
2319
2321 current_menu_object == NULL);
2323 current_menu_object == NULL);
2325 current_menu_object == NULL);
2326
2328 /* Not yet implemented */
2329
2331 current_menu_object == NULL);
2332
2334 current_menu_object == NULL);
2336 current_menu_object == NULL);
2338 current_menu_object == NULL);
2339
2340 if (current_menu_object != NULL) {
2342 &export_draw, &export_sprite);
2343 } else {
2346 &export_draw, &export_sprite);
2347 }
2348
2350 (!have_content && current_menu_object == NULL)
2351 || !(export_sprite || export_draw));
2352
2354 (!have_content && current_menu_object == NULL)
2355 || !export_sprite);
2356
2358 (!have_content && current_menu_object == NULL)
2359 || !export_draw);
2360
2361
2362 /* Selection Submenu */
2363
2366
2368 ~editor_flags & BW_EDITOR_CAN_COPY);
2369
2371 ~editor_flags & BW_EDITOR_CAN_COPY);
2372
2374 ~editor_flags & BW_EDITOR_CAN_CUT);
2375
2377 ~editor_flags & BW_EDITOR_CAN_PASTE);
2378
2380 ~editor_flags & BW_EDITOR_CAN_COPY);
2381
2382
2383 /* Navigate Submenu */
2384
2387
2390
2393
2396
2399
2400
2401
2402 /* View Submenu */
2403
2405 g != NULL && nsoption_bool(foreground_images));
2406
2408 g != NULL && nsoption_bool(background_images));
2409
2411 g == NULL || g->option.buffer_everything);
2413 g != NULL &&
2416
2419 g != NULL && g->option.buffer_everything);
2420
2422
2424 nsoption_int(window_screen_width) == 0);
2426 ((nsoption_int(window_screen_width) == 0) ||
2427 nsoption_bool(window_stagger)));
2428
2430 nsoption_bool(window_size_clone));
2431
2433 nsoption_int(window_screen_width) == 0);
2434
2435
2436 /* Utilities Submenu */
2437
2438 ro_gui_menu_set_entry_shaded(menu, HOTLIST_ADD_URL, !have_content);
2439
2441 (bw == NULL ||
2442 !(have_content || browser_window_back_available(bw) ||
2444
2445
2446 /* Help Submenu */
2447
2450 nsoption_bool(interactive_help));
2451
2452 return true;
2453}
2454
2455
2456/**
2457 * Process selections from a form select menu, passing them back to the core.
2458 *
2459 * \param g The browser window affected by the menu.
2460 * \param selection The menu selection.
2461 */
2462static void
2464 wimp_selection *selection)
2465{
2466 assert(g != NULL);
2467
2468 if (selection->items[0] >= 0) {
2470 selection->items[0]);
2471 }
2472}
2473
2474
2475/**
2476 * Prepare the object info window for use
2477 *
2478 * \param object the object for which information is to be displayed
2479 * \param target_url corresponding url, if any
2480 */
2481static void
2483 nsurl *target_url)
2484{
2485 char icon_buf[20] = "file_xxx";
2486 const char *url;
2487 lwc_string *mime;
2488 const char *target = "-";
2489
2490 sprintf(icon_buf, "file_%.3x",ro_content_filetype(object));
2491 if (!ro_gui_wimp_sprite_exists(icon_buf)) {
2492 sprintf(icon_buf, "file_xxx");
2493 }
2494
2496 if (url == NULL) {
2497 url = "-";
2498 }
2499 mime = content_get_mime_type(object);
2500
2501 if (target_url != NULL) {
2502 target = nsurl_access(target_url);
2503 }
2504
2506 icon_buf, true);
2508 url, true);
2510 target, true);
2512 lwc_string_data(mime), true);
2513
2514 lwc_string_unref(mime);
2515}
2516
2517
2518/**
2519 * callback to handle window paste operation
2520 *
2521 * \param pw context containing browser window
2522 */
2523static void ro_gui_window_paste_cb(void *pw)
2524{
2525 struct browser_window *bw = pw;
2526
2528}
2529
2530
2531/**
2532 * Handle selections from a browser window menu
2533 *
2534 * \param w The window owning the menu.
2535 * \param i The icon owning the menu.
2536 * \param menu The menu from which the selection was made.
2537 * \param selection The wimp menu selection data.
2538 * \param action The selected menu action.
2539 * \return true if action accepted; else false.
2540 */
2541static bool
2543 wimp_i i,
2544 wimp_menu *menu,
2545 wimp_selection *selection,
2546 menu_action action)
2547{
2548 struct gui_window *g;
2549 struct browser_window *bw;
2550 struct hlcache_handle *h;
2551 struct toolbar *toolbar;
2552 wimp_window_state state;
2553 nsurl *url;
2554 nserror error = NSERROR_OK;
2555
2557 toolbar = g->toolbar;
2558 bw = g->bw;
2560
2561 /* If this is a form menu from the core, handle it now and then exit.
2562 * Otherwise, carry on to the main browser window menu.
2563 */
2564 if (menu == gui_form_select_menu && w == g->window) {
2566
2567 return true;
2568 }
2569
2570 /* We're now safe to assume that this is either the browser or
2571 * toolbar window menu.
2572 */
2573
2574 switch (action) {
2575
2576 /* help actions */
2577 case HELP_OPEN_CONTENTS:
2578 error = nsurl_create("https://www.netsurf-browser.org/documentation/", &url);
2579 if (error == NSERROR_OK) {
2581 url,
2582 NULL,
2583 NULL,
2584 NULL);
2586 }
2587 break;
2588
2589 case HELP_OPEN_GUIDE:
2590 error = nsurl_create("https://www.netsurf-browser.org/documentation/guide", &url);
2591 if (error == NSERROR_OK) {
2593 url,
2594 NULL,
2595 NULL,
2596 NULL);
2598 }
2599 break;
2600
2602 error = nsurl_create("https://www.netsurf-browser.org/documentation/info", &url);
2603 if (error == NSERROR_OK) {
2605 url,
2606 NULL,
2607 NULL,
2608 NULL);
2610 }
2611 break;
2612
2613 case HELP_OPEN_CREDITS:
2614 error = nsurl_create("about:credits", &url);
2615 if (error == NSERROR_OK) {
2617 url,
2618 NULL,
2619 NULL,
2620 NULL);
2622 }
2623 break;
2624
2625 case HELP_OPEN_LICENCE:
2626 error = nsurl_create("about:licence", &url);
2627 if (error == NSERROR_OK) {
2629 url,
2630 NULL,
2631 NULL,
2632 NULL);
2634 }
2635 break;
2636
2640 nsoption_set_bool(interactive_help, true);
2641 } else {
2642 nsoption_set_bool(interactive_help,
2643 !nsoption_bool(interactive_help));
2644 }
2645 break;
2646
2647 /* history actions */
2648 case HISTORY_SHOW_LOCAL:
2650 break;
2653 break;
2654
2655 /* hotlist actions */
2656 case HOTLIST_ADD_URL:
2658 break;
2659 case HOTLIST_SHOW:
2661 break;
2662
2663 /* cookies actions */
2664 case COOKIES_SHOW:
2666 break;
2667
2668 case COOKIES_DELETE:
2671 break;
2672
2673 /* page actions */
2674 case BROWSER_PAGE_INFO:
2676 break;
2677 case BROWSER_PRINT:
2679 break;
2680 case BROWSER_NEW_WINDOW:
2682 break;
2684 if (current_menu_main != NULL) {
2686 } else if (h != NULL) {
2688 }
2689 break;
2690
2691 /* object actions */
2693 if (current_menu_object != NULL) {
2698 false);
2699 }
2700 break;
2702 if (current_menu_object != NULL) {
2704 browser_window_reload(bw, false);
2705 }
2706 break;
2707
2708 /* link actions */
2710 if (current_menu_url != NULL) {
2712 NULL,
2713 NULL,
2715 NULL);
2718 false);
2719 }
2720 break;
2722 if (current_menu_url != NULL) {
2724 NULL,
2725 NULL,
2727 NULL);
2730 false);
2731 }
2732 break;
2734 if (current_menu_url != NULL) {
2736 NULL,
2737 NULL,
2739 NULL);
2742 false);
2743 }
2744 break;
2745
2747 if (current_menu_url != NULL) {
2749 bw,
2753 NULL,
2754 NULL,
2755 NULL);
2756 }
2757 break;
2758
2760 if (current_menu_url != NULL) {
2761 error = browser_window_create(
2765 bw,
2766 NULL);
2767 }
2768 break;
2769
2770
2771 /* save actions */
2773 if (current_menu_object != NULL) {
2776 NULL,
2777 NULL,
2778 NULL);
2781 false);
2782 }
2783 break;
2785 if (current_menu_object != NULL) {
2788 NULL,
2789 NULL,
2790 NULL);
2793 false);
2794 }
2795 break;
2797 if (current_menu_object != NULL) {
2800 NULL,
2801 NULL,
2802 NULL);
2805 false);
2806 }
2807 break;
2808 case BROWSER_SAVE:
2810 break;
2813 break;
2816 break;
2817 case BROWSER_EXPORT_PDF:
2819 break;
2822 break;
2825 break;
2828 break;
2831 break;
2832
2833 /* selection actions */
2835 if (h != NULL) {
2837 NULL,
2839 NULL,
2840 NULL);
2843 false);
2844 }
2845 break;
2848 break;
2851 break;
2854 break;
2857 break;
2860 break;
2861
2862 /* navigation actions */
2865 break;
2867 if (bw != NULL)
2869 break;
2871 if (bw != NULL)
2873 break;
2875 if (bw != NULL && h != NULL)
2876 browser_window_navigate_up(g->bw, false);
2877 break;
2879 if (bw != NULL)
2881 break;
2883 if (bw != NULL)
2885 break;
2886
2887 /* browser window/display actions */
2888 case BROWSER_SCALE_VIEW:
2890 break;
2891 case BROWSER_FIND_TEXT:
2893 break;
2895 if (g != NULL)
2896 nsoption_set_bool(foreground_images,
2897 !nsoption_bool(foreground_images));
2898 break;
2900 if (g != NULL)
2901 nsoption_set_bool(background_images,
2902 !nsoption_bool(background_images));
2903 break;
2905 if (g != NULL)
2908 break;
2909 case BROWSER_BUFFER_ALL:
2910 if (g != NULL)
2913 break;
2914 case BROWSER_SAVE_VIEW:
2915 if (bw != NULL) {
2918 }
2919 break;
2921 if (g != NULL) {
2922 os_error *oserror;
2923
2924 ro_gui_screen_size(&nsoption_int(window_screen_width),
2925 &nsoption_int(window_screen_height));
2926 state.w = w;
2927 oserror = xwimp_get_window_state(&state);
2928 if (oserror) {
2929 NSLOG(netsurf, INFO,
2930 "xwimp_get_window_state: 0x%x: %s",
2931 oserror->errnum,
2932 oserror->errmess);
2933 ro_warn_user("WimpError", oserror->errmess);
2934 }
2935 nsoption_set_int(window_x, state.visible.x0);
2936 nsoption_set_int(window_y, state.visible.y0);
2937 nsoption_set_int(window_width,
2938 state.visible.x1 - state.visible.x0);
2939 nsoption_set_int(window_height,
2940 state.visible.y1 - state.visible.y0);
2942 }
2943 break;
2945 nsoption_set_bool(window_stagger,
2946 !nsoption_bool(window_stagger));
2948 break;
2950 nsoption_set_bool(window_size_clone,
2951 !nsoption_bool(window_size_clone));
2953 break;
2955 nsoption_set_int(window_screen_width, 0);
2956 nsoption_set_int(window_screen_height, 0);
2958 break;
2959
2960 /* toolbar actions */
2961 case TOOLBAR_BUTTONS:
2962 assert(toolbar);
2965 break;
2967 assert(toolbar);
2972 break;
2973 case TOOLBAR_THROBBER:
2974 assert(toolbar);
2977 break;
2978 case TOOLBAR_EDIT:
2979 assert(toolbar);
2981 break;
2982
2983 default:
2984 return false;
2985 }
2986
2987 if (error != NSERROR_OK) {
2989 }
2990
2991 return true;
2992}
2993
2994
2995/**
2996 * Handle submenu warnings for a browser window menu
2997 *
2998 * \param w The window owning the menu.
2999 * \param i The icon owning the menu.
3000 * \param menu The menu to which the warning applies.
3001 * \param selection The wimp menu selection data.
3002 * \param action The selected menu action.
3003 */
3004static void
3006 wimp_i i,
3007 wimp_menu *menu,
3008 wimp_selection *selection,
3009 menu_action action)
3010{
3011 struct gui_window *g;
3012 struct hlcache_handle *h;
3013 bool export;
3014
3015 if (menu != ro_gui_browser_window_menu) {
3016 return;
3017 }
3018
3021
3022 switch (action) {
3023 case BROWSER_PAGE_INFO:
3024 if (h != NULL) {
3026 }
3027 break;
3028
3029 case BROWSER_FIND_TEXT:
3030 if (h != NULL &&
3034 }
3035 break;
3036
3037 case BROWSER_SCALE_VIEW:
3038 if (h != NULL) {
3040 }
3041 break;
3042
3043 case BROWSER_PRINT:
3044 if (h != NULL) {
3046 }
3047 break;
3048
3050 if (current_menu_object != NULL) {
3053 }
3054 break;
3055
3057 if (current_menu_object != NULL) {
3060 NULL,
3061 NULL,
3062 NULL);
3063 }
3064 break;
3065
3070 NULL, NULL);
3071 break;
3072
3074 if (h != NULL)
3078 break;
3079
3081 if (h != NULL)
3085 break;
3086
3088 if (h != NULL)
3092 break;
3093
3095 if (current_menu_object != NULL)
3100 break;
3101
3103 if (current_menu_object != NULL)
3108 break;
3109
3111 if (current_menu_object != NULL)
3116 break;
3117
3118 case BROWSER_SAVE:
3119 if (h != NULL)
3120 ro_gui_save_prepare(GUI_SAVE_SOURCE, h, NULL, NULL, NULL);
3121 break;
3122
3124 if (h != NULL)
3125 ro_gui_save_prepare(GUI_SAVE_COMPLETE, h, NULL, NULL, NULL);
3126 break;
3127
3129 if (h != NULL)
3130 ro_gui_save_prepare(GUI_SAVE_DRAW, h, NULL, NULL, NULL);
3131 break;
3132
3133 case BROWSER_EXPORT_PDF:
3134 if (h != NULL)
3135 ro_gui_save_prepare(GUI_SAVE_PDF, h, NULL, NULL, NULL);
3136 break;
3137
3139 if (h != NULL)
3140 ro_gui_save_prepare(GUI_SAVE_TEXT, h, NULL, NULL, NULL);
3141 break;
3142
3144 if (current_menu_url != NULL)
3146 current_menu_url, NULL);
3147 break;
3148
3150 if (current_menu_url != NULL)
3152 current_menu_url, NULL);
3153 break;
3154
3156 if (current_menu_url != NULL)
3158 current_menu_url, NULL);
3159 break;
3160
3162 if (current_menu_object != NULL) {
3164 NULL, &export);
3165
3166 if (export)
3169 NULL, NULL, NULL);
3170 } else if (h != NULL) {
3171 ro_gui_window_content_export_types(h, NULL, &export);
3172
3173 if (export)
3175 h, NULL, NULL, NULL);
3176 }
3177 break;
3178
3180 if (current_menu_object != NULL) {
3182 &export, NULL);
3183
3184 if (export)
3187 NULL, NULL, NULL);
3188 } else if (h != NULL) {
3189 ro_gui_window_content_export_types(h, &export, NULL);
3190
3191 if (export)
3193 h, NULL, NULL, NULL);
3194 }
3195 break;
3196
3197 default:
3198 break;
3199 }
3200}
3201
3202
3203/**
3204 * Handle the closure of a browser window menu
3205 *
3206 * \param w The window owning the menu.
3207 * \param i The icon owning the menu.
3208 * \param menu The menu that is being closed.
3209 */
3210static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
3211{
3212 if (menu == ro_gui_browser_window_menu) {
3213 current_menu_object = NULL;
3214 current_menu_url = NULL;
3215 } else if (menu == gui_form_select_menu) {
3217 }
3218}
3219
3220
3221/**
3222 * Clones a browser window's options.
3223 *
3224 * \param new_gui the new gui window
3225 * \param old_gui the gui window to clone from, or NULL for default
3226 */
3227static void
3229 struct gui_window *old_gui)
3230{
3231 assert(new_gui);
3232
3233 /* Clone the basic options
3234 */
3235 if (!old_gui) {
3238 } else {
3239 new_gui->option = old_gui->option;
3240 }
3241
3242 /* Set up the toolbar
3243 */
3244 if (new_gui->toolbar) {
3246 nsoption_bool(toolbar_show_buttons));
3248 nsoption_bool(toolbar_show_address));
3250 nsoption_bool(toolbar_show_throbber));
3251 if ((old_gui) && (old_gui->toolbar)) {
3254 old_gui->toolbar));
3257 old_gui->toolbar));
3260 old_gui->toolbar));
3261 ro_toolbar_process(new_gui->toolbar, -1, true);
3262 }
3263 }
3264}
3265
3266
3267/**
3268 * Create and open a new browser window.
3269 *
3270 * \param bw bw to create gui_window for
3271 * \param existing an existing gui_window, may be NULL
3272 * \param flags flags for gui window creation
3273 * \return gui window, or NULL on error
3274 */
3276 struct gui_window *existing,
3278{
3279 int screen_width, screen_height;
3280 static int window_count = 2;
3281 wimp_window window;
3282 wimp_window_state state;
3283 os_error *error;
3284 bool open_centred = true;
3285 struct gui_window *g;
3286
3287 g = malloc(sizeof *g);
3288 if (!g) {
3289 ro_warn_user("NoMemory", 0);
3290 return 0;
3291 }
3292 g->bw = bw;
3293 g->toolbar = 0;
3294 g->status_bar = 0;
3295 g->old_width = 0;
3296 g->old_height = 0;
3297 g->update_extent = true;
3298 g->active = false;
3299 strcpy(g->title, "NetSurf");
3300 g->iconise_icon = -1;
3301
3302 /* Set the window position */
3303 if (existing != NULL &&
3304 flags & GW_CREATE_CLONE &&
3305 nsoption_bool(window_size_clone)) {
3306 state.w = existing->window;
3307 error = xwimp_get_window_state(&state);
3308 if (error) {
3309 NSLOG(netsurf, INFO,
3310 "xwimp_get_window_state: 0x%x: %s",
3311 error->errnum,
3312 error->errmess);
3313 ro_warn_user("WimpError", error->errmess);
3314 }
3315 window.visible.x0 = state.visible.x0;
3316 window.visible.x1 = state.visible.x1;
3317 window.visible.y0 = state.visible.y0 - 48;
3318 window.visible.y1 = state.visible.y1 - 48;
3319 open_centred = false;
3320 } else {
3321 int win_width, win_height;
3322 ro_gui_screen_size(&screen_width, &screen_height);
3323
3324 /* Check if we have a preferred position */
3325 if ((nsoption_int(window_screen_width) != 0) &&
3326 (nsoption_int(window_screen_height) != 0)) {
3327 win_width = (nsoption_int(window_width) *
3328 screen_width) /
3329 nsoption_int(window_screen_width);
3330 win_height = (nsoption_int(window_height) *
3331 screen_height) /
3332 nsoption_int(window_screen_height);
3333 window.visible.x0 = (nsoption_int(window_x) *
3334 screen_width) /
3335 nsoption_int(window_screen_width);
3336 window.visible.y0 = (nsoption_int(window_y) *
3337 screen_height) /
3338 nsoption_int(window_screen_height);
3339 if (nsoption_bool(window_stagger)) {
3340 window.visible.y0 += 96 -
3341 (48 * (window_count % 5));
3342 }
3343 open_centred = false;
3344 if (win_width < 100)
3345 win_width = 100;
3346 if (win_height < 100)
3347 win_height = 100;
3348 } else {
3349
3350 /* Base how we define the window height/width
3351 on the compile time options set */
3352 win_width = screen_width * 3 / 4;
3353 if (1600 < win_width)
3354 win_width = 1600;
3355 win_height = win_width * 3 / 4;
3356
3357 window.visible.x0 = (screen_width - win_width) / 2;
3358 window.visible.y0 = ((screen_height - win_height) / 2) +
3359 96 - (48 * (window_count % 5));
3360 }
3361 window.visible.x1 = window.visible.x0 + win_width;
3362 window.visible.y1 = window.visible.y0 + win_height;
3363 }
3364
3365 /* General flags for a non-movable, non-resizable, no-title bar window */
3366 window.xscroll = 0;
3367 window.yscroll = 0;
3368 window.next = wimp_TOP;
3369 window.flags = wimp_WINDOW_MOVEABLE |
3370 wimp_WINDOW_NEW_FORMAT |
3371 wimp_WINDOW_VSCROLL |
3372 wimp_WINDOW_HSCROLL |
3373 wimp_WINDOW_IGNORE_XEXTENT |
3374 wimp_WINDOW_IGNORE_YEXTENT |
3375 wimp_WINDOW_SCROLL_REPEAT;
3376 window.title_fg = wimp_COLOUR_BLACK;
3377 window.title_bg = wimp_COLOUR_LIGHT_GREY;
3378 window.work_fg = wimp_COLOUR_LIGHT_GREY;
3379 window.work_bg = wimp_COLOUR_TRANSPARENT;
3380 window.scroll_outer = wimp_COLOUR_DARK_GREY;
3381 window.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
3382 window.highlight_bg = wimp_COLOUR_CREAM;
3383 window.extra_flags = wimp_WINDOW_USE_EXTENDED_SCROLL_REQUEST |
3385 window.extent.x0 = 0;
3386 window.extent.y0 = -(window.visible.y1 - window.visible.y0);
3387 window.extent.x1 = window.visible.x1 - window.visible.x0;
3388 window.extent.y1 = 0;
3389 window.title_flags = wimp_ICON_TEXT |
3390 wimp_ICON_INDIRECTED |
3391 wimp_ICON_HCENTRED;
3392 window.work_flags = wimp_BUTTON_DOUBLE_CLICK_DRAG <<
3393 wimp_ICON_BUTTON_TYPE_SHIFT;
3394 window.sprite_area = wimpspriteop_AREA;
3395 window.xmin = 1;
3396 window.ymin = 1;
3397 window.title_data.indirected_text.text = g->title;
3398 window.title_data.indirected_text.validation = (char *) -1;
3399 window.title_data.indirected_text.size = 255;
3400 window.icon_count = 0;
3401
3402 /* Add in flags */
3403 window.flags |= wimp_WINDOW_SIZE_ICON |
3404 wimp_WINDOW_BACK_ICON |
3405 wimp_WINDOW_CLOSE_ICON |
3406 wimp_WINDOW_TITLE_ICON |
3407 wimp_WINDOW_TOGGLE_ICON;
3408
3409 if (open_centred) {
3410 int scroll_width = ro_get_vscroll_width(NULL);
3411 window.visible.x0 -= scroll_width;
3412 }
3413
3414 error = xwimp_create_window(&window, &g->window);
3415 if (error) {
3416 NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
3417 error->errnum, error->errmess);
3418 ro_warn_user("WimpError", error->errmess);
3419 free(g);
3420 return 0;
3421 }
3422
3423 /* Link into window list */
3424 g->prev = 0;
3425 g->next = window_list;
3426 if (window_list)
3427 window_list->prev = g;
3428 window_list = g;
3429 window_count++;
3430
3431 /* Add in a toolbar and status bar */
3433 nsoption_int(toolbar_status_size));
3434 g->toolbar = ro_toolbar_create(NULL, g->window,
3437 "HelpToolbar");
3438 if (g->toolbar != NULL) {
3441 nsoption_charp(toolbar_browser));
3445 }
3446
3447 /* Register event handlers. Do this quickly, as some of the things
3448 * that follow will indirectly look up our user data: this MUST
3449 * be set first!
3450 */
3468 true, false);
3477
3478 /* Set the window options */
3479 ro_gui_window_clone_options(g, existing);
3481
3482 /* Open the window at the top of the stack */
3483 state.w = g->window;
3484 error = xwimp_get_window_state(&state);
3485 if (error) {
3486 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
3487 error->errnum, error->errmess);
3488 ro_warn_user("WimpError", error->errmess);
3489 return g;
3490 }
3491
3492 state.next = wimp_TOP;
3493
3495
3496 /* Claim the caret */
3499 } else {
3500 gui_window_place_caret(g, -100, -100, 0, NULL);
3501 }
3502
3503 return g;
3504}
3505
3506
3507/**
3508 * Remove all pending update boxes for a window
3509 *
3510 * \param g gui_window
3511 */
3513{
3514 struct update_box *cur;
3515
3516 for (cur = pending_updates; cur != NULL; cur = cur->next) {
3517 if (cur->g == g) {
3518 cur->g = NULL;
3519 }
3520 }
3521}
3522
3523
3524/**
3525 * Close a browser window and free any related resources.
3526 *
3527 * \param g gui_window to destroy
3528 */
3529static void gui_window_destroy(struct gui_window *g)
3530{
3531 os_error *error;
3532 wimp_w w;
3533
3534 assert(g);
3535
3536 /* stop any tracking */
3538
3539 /* remove from list */
3540 if (g->prev)
3541 g->prev->next = g->next;
3542 else
3543 window_list = g->next;
3544 if (g->next)
3545 g->next->prev = g->prev;
3546
3547 /* destroy toolbar */
3548 if (g->toolbar)
3550 if (g->status_bar)
3552
3553 w = g->window;
3556 if (current_menu_window == w)
3559
3560 /* delete window */
3561 error = xwimp_delete_window(w);
3562 if (error) {
3563 NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
3564 error->errnum, error->errmess);
3565 ro_warn_user("WimpError", error->errmess);
3566 }
3568
3569 free(g);
3570}
3571
3572
3573/**
3574 * Set the title of a browser window.
3575 *
3576 * \param g gui_window to update
3577 * \param title new window title, copied
3578 */
3579static void gui_window_set_title(struct gui_window *g, const char *title)
3580{
3581 float scale;
3582 assert(g);
3583 assert(title);
3584
3585 scale = browser_window_get_scale(g->bw);
3586
3587 if (scale != 1.0) {
3588 int scale_disp = scale * 100;
3589
3590 if (ABS((float)scale_disp - scale * 100) >= 0.05) {
3591 snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
3592 title, scale * 100);
3593 } else {
3594 snprintf(g->title, sizeof g->title, "%s (%i%%)",
3595 title, scale_disp);
3596 }
3597 } else {
3598 strncpy(g->title, title, sizeof(g->title) - 1);
3599 g->title[sizeof(g->title)-1] = 0;
3600 }
3601
3603}
3604
3605
3606/**
3607 * Get the scroll position of a browser window.
3608 *
3609 * \param g gui_window
3610 * \param sx receives x ordinate of point at top-left of window
3611 * \param sy receives y ordinate of point at top-left of window
3612 * \return true iff successful
3613 */
3614static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
3615{
3616 wimp_window_state state;
3617 os_error *error;
3618 int toolbar_height = 0;
3619
3620 assert(g);
3621
3622 state.w = g->window;
3623 error = xwimp_get_window_state(&state);
3624 if (error) {
3625 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
3626 error->errnum, error->errmess);
3627 ro_warn_user("WimpError", error->errmess);
3628 return false;
3629 }
3630
3631 if (g->toolbar) {
3632 toolbar_height = ro_toolbar_full_height(g->toolbar);
3633 }
3634 *sx = state.xscroll / 2;
3635 *sy = -(state.yscroll - toolbar_height) / 2;
3636 return true;
3637}
3638
3639
3640/**
3641 * Set the scroll position of a riscos browser window.
3642 *
3643 * Scrolls the viewport to ensure the specified rectangle of the
3644 * content is shown.
3645 *
3646 * \param g gui window to scroll
3647 * \param rect The rectangle to ensure is shown.
3648 * \return NSERROR_OK on success or apropriate error code.
3649 */
3650static nserror
3652{
3653 wimp_window_state state;
3654 os_error *error;
3655 int toolbar_height = 0;
3656
3657 assert(g);
3658
3659 state.w = g->window;
3660 error = xwimp_get_window_state(&state);
3661 if (error) {
3662 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
3663 error->errnum, error->errmess);
3664 ro_warn_user("WimpError", error->errmess);
3665 return NSERROR_BAD_PARAMETER;
3666 }
3667
3668 if (g->toolbar) {
3669 toolbar_height = ro_toolbar_full_height(g->toolbar);
3670 }
3671
3672 if ((rect->x0 == rect->x1) && (rect->y0 == rect->y1)) {
3673 /* scroll to top */
3674 state.xscroll = rect->x0 * 2;
3675 state.yscroll = (-rect->y0 * 2) + toolbar_height;
3676 } else {
3677 /* scroll area into view with padding */
3678 int x0, y0, x1, y1;
3679 int cx0, cy0, width, height;
3680 int padding_available;
3681 int correction;
3682
3683 x0 = rect->x0 * 2 ;
3684 y0 = rect->y0 * 2 ;
3685 x1 = rect->x1 * 2 ;
3686 y1 = rect->y1 * 2 ;
3687
3688 cx0 = state.xscroll;
3689 cy0 = -state.yscroll + toolbar_height;
3690 width = state.visible.x1 - state.visible.x0;
3691 height = state.visible.y1 - state.visible.y0 - toolbar_height;
3692
3693 /* make sure we're visible */
3694 correction = (x1 - cx0 - width);
3695 if (correction > 0) {
3696 cx0 += correction;
3697 }
3698 correction = (y1 - cy0 - height);
3699 if (correction > 0) {
3700 cy0 += correction;
3701 }
3702 if (x0 < cx0) {
3703 cx0 = x0;
3704 }
3705 if (y0 < cy0) {
3706 cy0 = y0;
3707 }
3708
3709 /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
3710 padding_available = (width - x1 + x0) / 2;
3711 if (padding_available > 0) {
3712 if (padding_available > SCROLL_VISIBLE_PADDING) {
3713 padding_available = SCROLL_VISIBLE_PADDING;
3714 }
3715 correction = (cx0 + width - x1);
3716 if (correction < padding_available) {
3717 cx0 += padding_available;
3718 }
3719 correction = (x0 - cx0);
3720 if (correction < padding_available) {
3721 cx0 -= padding_available;
3722 }
3723 }
3724 padding_available = (height - y1 + y0) / 2;
3725 if (padding_available > 0) {
3726 if (padding_available > SCROLL_VISIBLE_PADDING) {
3727 padding_available = SCROLL_VISIBLE_PADDING;
3728 }
3729 correction = (cy0 + height - y1);
3730 if (correction < padding_available) {
3731 cy0 += padding_available;
3732 }
3733 correction = (y0 - cy0);
3734 if (correction < padding_available) {
3735 cy0 -= padding_available;
3736 }
3737 }
3738
3739 state.xscroll = cx0;
3740 state.yscroll = -cy0 + toolbar_height;
3741 }
3743
3744 return NSERROR_OK;
3745}
3746
3747
3748/**
3749 * Find the current dimensions of a browser window's content area.
3750 *
3751 * \param gw gui window to measure
3752 * \param width receives width of window
3753 * \param height receives height of window
3754 * \return NSERROR_OK and width and height updated
3755 */
3756static nserror
3758{
3759 /* use the cached window sizes */
3760 *width = gw->old_width / 2;
3761 *height = gw->old_height / 2;
3762
3763 return NSERROR_OK;
3764}
3765
3766
3767/**
3768 * Set the status bar of a browser window.
3769 *
3770 * \param g gui_window to update
3771 * \param text new status text
3772 */
3773static void riscos_window_set_status(struct gui_window *g, const char *text)
3774{
3775 if (g->status_bar) {
3777 }
3778}
3779
3780
3781/**
3782 * Update the interface to reflect start of page loading.
3783 *
3784 * \param g window with start of load
3785 */
3787{
3790 if (g->toolbar != NULL)
3792 g->active = true;
3793}
3794
3795
3796/**
3797 * Update the interface to reflect page loading stopped.
3798 *
3799 * \param g window with start of load
3800 */
3802{
3805 if (g->toolbar != NULL)
3807 g->active = false;
3808}
3809
3810
3811/**
3812 * Update the interface to reflect change in page info status
3813 *
3814 * \param gw window with start of load
3815 */
3817{
3818 if (gw->toolbar != NULL) {
3820 }
3821}
3822
3823
3824/**
3825 * set favicon
3826 */
3827static void
3829{
3830 if (g == NULL || g->toolbar == NULL)
3831 return;
3832
3834}
3835
3836
3837/**
3838 * Remove the caret, if present.
3839 *
3840 * \param g window with caret
3841 */
3843{
3844 wimp_caret caret;
3845 os_error *error;
3846
3847 error = xwimp_get_caret_position(&caret);
3848 if (error) {
3849 NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
3850 error->errnum, error->errmess);
3851 ro_warn_user("WimpError", error->errmess);
3852 return;
3853 }
3854
3855 if (caret.w == g->window) {
3856 /* we have the caret: hide caret, but keep input focus */
3857 gui_window_place_caret(g, -100, -100, 0, NULL);
3858 }
3859}
3860
3861
3862/**
3863 * Called when the gui_window has new content.
3864 *
3865 * \param g the gui_window that has new content
3866 */
3868{
3873}
3874
3875
3876/**
3877 * Completes scrolling of a browser window
3878 *
3879 * \param drag The DragEnd event data block.
3880 * \param data gui window block pointer.
3881 */
3882static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
3883{
3884 wimp_pointer pointer;
3885 os_error *error;
3886 os_coord pos;
3887 struct gui_window *g = (struct gui_window *) data;
3888
3889 if (!g)
3890 return;
3891
3892 error = xwimp_drag_box((wimp_drag*)-1);
3893 if (error) {
3894 NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
3895 error->errnum, error->errmess);
3896 ro_warn_user("WimpError", error->errmess);
3897 }
3898
3899 error = xwimp_get_pointer_info(&pointer);
3900 if (error) {
3901 NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
3902 error->errnum, error->errmess);
3903 ro_warn_user("WimpError", error->errmess);
3904 return;
3905 }
3906
3907 error = xwimpspriteop_set_pointer_shape("ptr_default", 0x31, 0, 0, 0, 0);
3908 if (error) {
3909 NSLOG(netsurf, INFO,
3910 "xwimpspriteop_set_pointer_shape: 0x%x: %s",
3911 error->errnum,
3912 error->errmess);
3913 ro_warn_user("WimpError", error->errmess);
3914 }
3915
3916 if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0, &pos)) {
3917 browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
3918 }
3919}
3920
3921
3922/**
3923 * Starts drag scrolling of a browser window
3924 *
3925 * \param g the window to scroll
3926 */
3928{
3929 wimp_window_info_base info;
3930 wimp_pointer pointer;
3931 os_error *error;
3932 wimp_drag drag;
3933 int height;
3934 int width;
3935
3936 error = xwimp_get_pointer_info(&pointer);
3937 if (error) {
3938 NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
3939 error->errnum, error->errmess);
3940 ro_warn_user("WimpError", error->errmess);
3941 return false;
3942 }
3943
3944 info.w = g->window;
3945 error = xwimp_get_window_info_header_only((wimp_window_info*)&info);
3946 if (error) {
3947 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x : %s",
3948 error->errnum, error->errmess);
3949 ro_warn_user("WimpError", error->errmess);
3950 return false;
3951 }
3952
3953 width = info.extent.x1 - info.extent.x0;
3954 height = info.extent.y1 - info.extent.y0;
3955
3956 drag.type = wimp_DRAG_USER_POINT;
3957 drag.bbox.x1 = pointer.pos.x + info.xscroll;
3958 drag.bbox.y0 = pointer.pos.y + info.yscroll;
3959 drag.bbox.x0 = drag.bbox.x1 - (width - (info.visible.x1 - info.visible.x0));
3960 drag.bbox.y1 = drag.bbox.y0 + (height - (info.visible.y1 - info.visible.y0));
3961
3962 if (g->toolbar) {
3963 int tbar_height = ro_toolbar_full_height(g->toolbar);
3964 drag.bbox.y0 -= tbar_height;
3965 drag.bbox.y1 -= tbar_height;
3966 }
3967
3968 error = xwimp_drag_box(&drag);
3969 if (error) {
3970 NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
3971 error->errnum, error->errmess);
3972 ro_warn_user("WimpError", error->errmess);
3973 return false;
3974 }
3975
3977 NULL, g);
3978 return true;
3979}
3980
3981
3982/**
3983 * Platform-dependent part of starting drag operation.
3984 *
3985 * \param g gui window containing the drag
3986 * \param type type of drag the core is performing
3987 * \param rect rectangle to constrain pointer to (relative to drag start coord)
3988 * \return true iff succesful
3989 */
3990static bool
3993 const struct rect *rect)
3994{
3995 wimp_pointer pointer;
3996 wimp_drag drag;
3997 float scale = browser_window_get_scale(g->bw);
3998
3999 if (rect != NULL) {
4000 /* We have a box to constrain the pointer to, for the drag
4001 * duration */
4002 os_error *error = xwimp_get_pointer_info(&pointer);
4003 if (error) {
4004 NSLOG(netsurf, INFO,
4005 "xwimp_get_pointer_info 0x%x : %s",
4006 error->errnum,
4007 error->errmess);
4008 ro_warn_user("WimpError", error->errmess);
4009 return false;
4010 }
4011
4012 drag.type = wimp_DRAG_USER_POINT;
4013 drag.bbox.x0 = pointer.pos.x +
4014 (int)(rect->x0 * 2 * scale);
4015 drag.bbox.y0 = pointer.pos.y +
4016 (int)(rect->y0 * 2 * scale);
4017 drag.bbox.x1 = pointer.pos.x +
4018 (int)(rect->x1 * 2 * scale);
4019 drag.bbox.y1 = pointer.pos.y +
4020 (int)(rect->y1 * 2 * scale);
4021
4022 error = xwimp_drag_box(&drag);
4023 if (error) {
4024 NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
4025 error->errnum, error->errmess);
4026 ro_warn_user("WimpError", error->errmess);
4027 return false;
4028 }
4029 }
4030
4031 switch (type) {
4033 /* Dragging a core scrollbar */
4036 NULL, g);
4037 break;
4038
4039 default:
4040 /* Not handled here yet */
4041 break;
4042 }
4043
4044 return true;
4045}
4046
4047
4048/**
4049 * Save the specified content as a link.
4050 *
4051 * \param g The window containing the content
4052 * \param url The url of the link
4053 * \param title The title of the link
4054 */
4055static nserror
4057{
4060 return NSERROR_OK;
4061}
4062
4063
4064/**
4065 * Display a menu of options for a form select control.
4066 *
4067 * \param g gui window containing form control
4068 * \param control form control of type GADGET_SELECT
4069 */
4070static void
4072 struct form_control *control)
4073{
4074 os_error *error;
4075 wimp_pointer pointer;
4076
4077 /* The first time the menu is opened, control bypasses the normal
4078 * Menu Prepare event and so we prepare here. On any re-opens,
4079 * ro_gui_window_prepare_form_select_menu() is called from the
4080 * normal wimp event.
4081 */
4082
4084 return;
4085
4086 error = xwimp_get_pointer_info(&pointer);
4087 if (error) {
4088 NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
4089 error->errnum, error->errmess);
4090 ro_warn_user("WimpError", error->errmess);
4092 return;
4093 }
4094
4095 gui_form_select_control = control;
4097 pointer.pos.x, pointer.pos.y, g->window);
4098}
4099
4100
4101/**
4102 * Import text file into window
4103 *
4104 * \param g gui window containing textarea
4105 * \param filename pathname of file to be imported
4106 * \return true iff successful
4107 */
4108static bool
4109ro_gui_window_import_text(struct gui_window *g, const char *filename)
4110{
4111 fileswitch_object_type obj_type;
4112 os_error *error;
4113 char *buf, *utf8_buf, *sp;
4114 int size;
4115 nserror ret;
4116 const char *ep;
4117 char *p;
4118
4119 error = xosfile_read_stamped(filename, &obj_type, NULL, NULL,
4120 &size, NULL, NULL);
4121 if (error) {
4122 NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s",
4123 error->errnum, error->errmess);
4124 ro_warn_user("FileError", error->errmess);
4125 return true; /* was for us, but it didn't work! */
4126 }
4127
4128 /* Allocate one byte more than needed to ensure that the buffer is
4129 * always terminated, regardless of file contents.
4130 */
4131
4132 buf = calloc(size + 1, sizeof(char));
4133 if (!buf) {
4134 ro_warn_user("NoMemory", NULL);
4135 return true;
4136 }
4137
4138 error = xosfile_load_stamped(filename, (byte*)buf,
4139 NULL, NULL, NULL, NULL, NULL);
4140
4141 if (error) {
4142 NSLOG(netsurf, INFO, "xosfile_load_stamped: 0x%x:%s",
4143 error->errnum, error->errmess);
4144 ro_warn_user("LoadError", error->errmess);
4145 free(buf);
4146 return true;
4147 }
4148
4149 ret = utf8_from_local_encoding(buf, size, &utf8_buf);
4150 if (ret != NSERROR_OK) {
4151 /* bad encoding shouldn't happen */
4152 assert(ret != NSERROR_BAD_ENCODING);
4153 NSLOG(netsurf, INFO, "utf8_from_local_encoding failed");
4154 free(buf);
4155 ro_warn_user("NoMemory", NULL);
4156 return true;
4157 }
4158 size = strlen(utf8_buf);
4159
4160 ep = utf8_buf + size;
4161 p = utf8_buf;
4162
4163 /* skip leading whitespace */
4164 while (isspace(*p)) p++;
4165
4166 sp = p;
4167 while (*p && *p != '\r' && *p != '\n')
4168 p += utf8_next(p, ep - p, 0);
4169 *p = '\0';
4170
4171 if (p > sp)
4173
4174 free(buf);
4175 free(utf8_buf);
4176 return true;
4177}
4178
4179
4180/**
4181 * process miscellaneous window events
4182 *
4183 * \param gw The window receiving the event.
4184 * \param event The event code.
4185 * \return NSERROR_OK when processed ok
4186 */
4187static nserror
4189{
4190 switch (event) {
4193 break;
4194
4197 break;
4198
4201 break;
4202
4205 break;
4206
4209 break;
4210
4213 break;
4214
4216 /* from textselection */
4218 break;
4219
4222 break;
4223
4224 default:
4225 break;
4226 }
4227 return NSERROR_OK;
4228}
4229
4230
4231/**
4232 * RISC OS browser window operation table
4233 */
4236 .destroy = gui_window_destroy,
4237 .invalidate = ro_gui_window_invalidate_area,
4238 .get_scroll = gui_window_get_scroll,
4239 .set_scroll = gui_window_set_scroll,
4240 .get_dimensions = gui_window_get_dimensions,
4241 .event = ro_gui_window_event,
4242
4243 .set_title = gui_window_set_title,
4244 .set_url = ro_gui_window_set_url,
4245 .set_icon = gui_window_set_icon,
4246 .set_status = riscos_window_set_status,
4247 .set_pointer = gui_window_set_pointer,
4248 .place_caret = gui_window_place_caret,
4249 .save_link = gui_window_save_link,
4250 .drag_start = gui_window_drag_start,
4251 .create_form_select_menu = gui_window_create_form_select_menu,
4252
4253 /* from save */
4254 .drag_save_object = gui_drag_save_object,
4255 .drag_save_selection =gui_drag_save_selection,
4256};
4257
4259
4260
4261/* exported interface documented in riscos/window.h */
4263{
4264 /* Build the browser window menu. */
4265
4266 static const struct ns_menu browser_definition = {
4267 "NetSurf", {
4268 { "Page", BROWSER_PAGE, 0 },
4269 { "Page.PageInfo",BROWSER_PAGE_INFO, &dialog_pageinfo },
4270 { "Page.Save", BROWSER_SAVE, &dialog_saveas },
4271 { "Page.SaveComp", BROWSER_SAVE_COMPLETE, &dialog_saveas },
4272 { "Page.Export", NO_ACTION, 0 },
4273#ifdef WITH_DRAW_EXPORT
4274 { "Page.Export.Draw", BROWSER_EXPORT_DRAW, &dialog_saveas },
4275#endif
4276#ifdef WITH_PDF_EXPORT
4277 { "Page.Export.PDF", BROWSER_EXPORT_PDF, &dialog_saveas },
4278#endif
4279 { "Page.Export.Text", BROWSER_EXPORT_TEXT, &dialog_saveas },
4280 { "Page.SaveURL", NO_ACTION, 0 },
4281 { "Page.SaveURL.URI", BROWSER_SAVE_URL_URI, &dialog_saveas },
4282 { "Page.SaveURL.URL", BROWSER_SAVE_URL_URL, &dialog_saveas },
4283 { "Page.SaveURL.LinkText", BROWSER_SAVE_URL_TEXT, &dialog_saveas },
4284 { "_Page.Print", BROWSER_PRINT, &dialog_print },
4285 { "Page.NewWindow", BROWSER_NEW_WINDOW, 0 },
4286 { "Page.FindText", BROWSER_FIND_TEXT, &dialog_search },
4287 { "Page.ViewSrc", BROWSER_VIEW_SOURCE, 0 },
4288 { "Object", BROWSER_OBJECT, 0 },
4289 { "Object.Object", BROWSER_OBJECT_OBJECT, 0 },
4290 { "Object.Object.ObjInfo", BROWSER_OBJECT_INFO, &dialog_objinfo },
4291 { "Object.Object.ObjSave", BROWSER_OBJECT_SAVE, &dialog_saveas },
4292 { "Object.Object.Export", BROWSER_OBJECT_EXPORT, 0 },
4293 { "Object.Object.Export.Sprite", BROWSER_OBJECT_EXPORT_SPRITE, &dialog_saveas },
4294#ifdef WITH_DRAW_EXPORT
4295 { "Object.Object.Export.ObjDraw", BROWSER_OBJECT_EXPORT_DRAW, &dialog_saveas },
4296#endif
4297 { "Object.Object.SaveURL", NO_ACTION, 0 },
4298 { "Object.Object.SaveURL.URI", BROWSER_OBJECT_SAVE_URL_URI, &dialog_saveas },
4299 { "Object.Object.SaveURL.URL", BROWSER_OBJECT_SAVE_URL_URL, &dialog_saveas },
4300 { "Object.Object.SaveURL.LinkText", BROWSER_OBJECT_SAVE_URL_TEXT, &dialog_saveas },
4301 { "Object.Object.ObjPrint", BROWSER_OBJECT_PRINT, 0 },
4302 { "Object.Object.ObjReload", BROWSER_OBJECT_RELOAD, 0 },
4303 { "Object.Link", BROWSER_OBJECT_LINK, 0 },
4304 { "Object.Link.LinkSave", BROWSER_LINK_SAVE, 0 },
4305 { "Object.Link.LinkSave.URI", BROWSER_LINK_SAVE_URI, &dialog_saveas },
4306 { "Object.Link.LinkSave.URL", BROWSER_LINK_SAVE_URL, &dialog_saveas },
4307 { "Object.Link.LinkSave.LinkText", BROWSER_LINK_SAVE_TEXT, &dialog_saveas },
4308 { "_Object.Link.LinkDload", BROWSER_LINK_DOWNLOAD, 0 },
4309 { "Object.Link.LinkNew", BROWSER_LINK_NEW_WINDOW, 0 },
4310 { "Selection", BROWSER_SELECTION, 0 },
4311 { "_Selection.SelSave", BROWSER_SELECTION_SAVE, &dialog_saveas },
4312 { "Selection.Copy", BROWSER_SELECTION_COPY, 0 },
4313 { "Selection.Cut", BROWSER_SELECTION_CUT, 0 },
4314 { "_Selection.Paste", BROWSER_SELECTION_PASTE, 0 },
4315 { "Selection.Clear", BROWSER_SELECTION_CLEAR, 0 },
4316 { "Selection.SelectAll", BROWSER_SELECTION_ALL, 0 },
4317 { "Navigate", NO_ACTION, 0 },
4318 { "Navigate.Home", BROWSER_NAVIGATE_HOME, 0 },
4319 { "Navigate.Back", BROWSER_NAVIGATE_BACK, 0 },
4320 { "Navigate.Forward", BROWSER_NAVIGATE_FORWARD, 0 },
4321 { "_Navigate.UpLevel", BROWSER_NAVIGATE_UP, 0 },
4322 { "Navigate.Reload", BROWSER_NAVIGATE_RELOAD_ALL, 0 },
4323 { "Navigate.Stop", BROWSER_NAVIGATE_STOP, 0 },
4324 { "View", NO_ACTION, 0 },
4325 { "View.ScaleView", BROWSER_SCALE_VIEW, &dialog_zoom },
4326 { "View.Images", NO_ACTION, 0 },
4327 { "View.Images.ForeImg", BROWSER_IMAGES_FOREGROUND, 0 },
4328 { "View.Images.BackImg", BROWSER_IMAGES_BACKGROUND, 0 },
4329 { "View.Toolbars", NO_ACTION, 0 },
4330 { "View.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
4331 { "View.Toolbars.ToolAddress", TOOLBAR_ADDRESS_BAR, 0 },
4332 { "_View.Toolbars.ToolThrob", TOOLBAR_THROBBER, 0 },
4333 { "View.Toolbars.EditToolbar", TOOLBAR_EDIT, 0 },
4334 { "_View.Render", NO_ACTION, 0 },
4335 { "View.Render.RenderAnims", BROWSER_BUFFER_ANIMS, 0 },
4336 { "View.Render.RenderAll", BROWSER_BUFFER_ALL, 0 },
4337 { "_View.OptDefault", BROWSER_SAVE_VIEW, 0 },
4338 { "View.Window", NO_ACTION, 0 },
4339 { "View.Window.WindowSave", BROWSER_WINDOW_DEFAULT, 0 },
4340 { "View.Window.WindowStagr", BROWSER_WINDOW_STAGGER, 0 },
4341 { "_View.Window.WindowSize", BROWSER_WINDOW_COPY, 0 },
4342 { "View.Window.WindowReset", BROWSER_WINDOW_RESET, 0 },
4343 { "Utilities", NO_ACTION, 0 },
4344 { "Utilities.Hotlist", HOTLIST_SHOW, 0 },
4345 { "Utilities.Hotlist.HotlistAdd", HOTLIST_ADD_URL, 0 },
4346 { "Utilities.Hotlist.HotlistShow", HOTLIST_SHOW, 0 },
4347 { "Utilities.History", HISTORY_SHOW_GLOBAL, 0 },
4348 { "Utilities.History.HistLocal", HISTORY_SHOW_LOCAL, 0 },
4349 { "Utilities.History.HistGlobal", HISTORY_SHOW_GLOBAL, 0 },
4350 { "Utilities.Cookies", COOKIES_SHOW, 0 },
4351 { "Utilities.Cookies.ShowCookies", COOKIES_SHOW, 0 },
4352 { "Utilities.Cookies.DeleteCookies", COOKIES_DELETE, 0 },
4353 { "Help", HELP_OPEN_CONTENTS, 0 },
4354 { "Help.HelpContent", HELP_OPEN_CONTENTS, 0 },
4355 { "Help.HelpGuide", HELP_OPEN_GUIDE, 0 },
4356 { "_Help.HelpInfo", HELP_OPEN_INFORMATION, 0 },
4357 { "Help.HelpCredits", HELP_OPEN_CREDITS, 0 },
4358 { "_Help.HelpLicence", HELP_OPEN_LICENCE, 0 },
4359 { "Help.HelpInter", HELP_LAUNCH_INTERACTIVE, 0 },
4360 {NULL, 0, 0}
4361 }
4362 };
4364 ro_gui_menu_define_menu(&browser_definition);
4365
4366}
4367
4368
4369/* exported interface documented in riscos/window.h */
4370nserror
4372{
4373 bool use_buffer;
4374 int x0, y0, x1, y1;
4375 struct update_box *cur;
4376 wimp_window_info info;
4377 os_error *error;
4378
4379 assert(g);
4380
4381 if (rect == NULL) {
4382 info.w = g->window;
4383 error = xwimp_get_window_info_header_only(&info);
4384 if (error) {
4385 NSLOG(netsurf, INFO,
4386 "xwimp_get_window_info_header_only: 0x%x: %s",
4387 error->errnum,
4388 error->errmess);
4389 ro_warn_user("WimpError", error->errmess);
4390 return NSERROR_INVALID;
4391 }
4392
4393 error = xwimp_force_redraw(g->window,
4394 info.extent.x0, info.extent.y0,
4395 info.extent.x1, info.extent.y1);
4396 if (error) {
4397 NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
4398 error->errnum, error->errmess);
4399 ro_warn_user("WimpError", error->errmess);
4400 return NSERROR_INVALID;
4401 }
4402 return NSERROR_OK;
4403 }
4404
4405 x0 = floorf(rect->x0 * 2 );
4406 y0 = -ceilf(rect->y1 * 2 );
4407 x1 = ceilf(rect->x1 * 2 ) + 1;
4408 y1 = -floorf(rect->y0 * 2 ) + 1;
4409 use_buffer =
4411
4412 /* try to optimise buffered redraws */
4413 if (use_buffer) {
4414 for (cur = pending_updates; cur != NULL; cur = cur->next) {
4415 if ((cur->g != g) || (!cur->use_buffer)) {
4416 continue;
4417 }
4418 if ((((cur->x0 - x1) < MARGIN) ||
4419 ((cur->x1 - x0) < MARGIN)) &&
4420 (((cur->y0 - y1) < MARGIN) ||
4421 ((cur->y1 - y0) < MARGIN))) {
4422 cur->x0 = min(cur->x0, x0);
4423 cur->y0 = min(cur->y0, y0);
4424 cur->x1 = max(cur->x1, x1);
4425 cur->y1 = max(cur->y1, y1);
4426 return NSERROR_OK;
4427 }
4428 }
4429 }
4430 cur = malloc(sizeof(struct update_box));
4431 if (!cur) {
4432 NSLOG(netsurf, INFO, "No memory for malloc.");
4433 return NSERROR_NOMEM;
4434 }
4435
4436 cur->x0 = x0;
4437 cur->y0 = y0;
4438 cur->x1 = x1;
4439 cur->y1 = y1;
4440 cur->next = pending_updates;
4441 pending_updates = cur;
4442 cur->g = g;
4443 cur->use_buffer = use_buffer;
4444
4445 return NSERROR_OK;
4446}
4447
4448
4449/* exported function documented in riscos/window.h */
4451{
4452 size_t idn_url_l;
4453 char *idn_url_s = NULL;
4454
4455 if (g->toolbar) {
4456 if (nsoption_bool(display_decoded_idn) == true) {
4457 if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) != NSERROR_OK)
4458 idn_url_s = NULL;
4459 }
4460
4461 ro_toolbar_set_url(g->toolbar, idn_url_s ? idn_url_s : nsurl_access(url), true, false);
4462
4463 if (idn_url_s)
4464 free(idn_url_s);
4465
4467 }
4468
4469 return NSERROR_OK;
4470}
4471
4472
4473/* exported interface documented in riscos/window.h */
4474void ro_gui_window_set_scale(struct gui_window *g, float scale)
4475{
4476 browser_window_set_scale(g->bw, scale, true);
4477}
4478
4479
4480/* exported interface documented in riscos/window.h */
4481bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
4482{
4483 os_error *error;
4484 os_coord pos;
4485
4486 /* Ignore directories etc. */
4487 if (0x1000 <= message->data.data_xfer.file_type)
4488 return false;
4489
4490 if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
4491 message->data.data_xfer.pos.y, &pos))
4492 return false;
4493
4494 if (browser_window_drop_file_at_point(g->bw, pos.x, pos.y,
4495 message->data.data_xfer.file_name) == false)
4496 return false;
4497
4498 /* send DataLoadAck */
4499 message->action = message_DATA_LOAD_ACK;
4500 message->your_ref = message->my_ref;
4501 error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
4502 if (error) {
4503 NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s\n",
4504 error->errnum, error->errmess);
4505 ro_warn_user("WimpError", error->errmess);
4506 }
4507
4508 return true;
4509}
4510
4511
4512/* exported interface documented in riscos/window.h */
4513void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
4514{
4515 os_coord pos;
4516 struct gui_window *g = (struct gui_window *) data;
4517
4518 if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos)) {
4520 g->bw,
4521 ro_gui_mouse_drag_state(pointer->buttons,
4522 wimp_BUTTON_DOUBLE_CLICK_DRAG),
4523 pos.x,
4524 pos.y);
4525 }
4526}
4527
4528
4529/* exported interface documented in riscos/window.h */
4530void
4531ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
4532{
4533 /* sadly there is no 'legal' way to get the sprite into
4534 * the Wimp sprite pool other than via a filing system */
4535 const char *temp_fname = "Pipe:$._tmpfile";
4536 struct browser_window *bw = g->bw;
4537 osspriteop_header *overlay = NULL;
4538 osspriteop_header *sprite_header;
4539 struct bitmap *bitmap;
4540 osspriteop_area *area;
4541 int width = 34, height = 34;
4542 struct hlcache_handle *h;
4543 os_error *error;
4544 int len, id;
4545
4546 assert(bw);
4547
4549 if (!h) return;
4550
4551 /* if an overlay sprite is defined, locate it and gets its dimensions
4552 * so that we can produce a thumbnail with the same dimensions */
4553 if (!ro_gui_wimp_get_sprite("ic_netsfxx", &overlay)) {
4554 error = xosspriteop_read_sprite_info(osspriteop_PTR,
4555 (osspriteop_area *)0x100,
4556 (osspriteop_id)overlay, &width, &height, NULL,
4557 NULL);
4558 if (error) {
4559 NSLOG(netsurf, INFO,
4560 "xosspriteop_read_sprite_info: 0x%x: %s",
4561 error->errnum,
4562 error->errmess);
4563 ro_warn_user("MiscError", error->errmess);
4564 overlay = NULL;
4565 } else if (sprite_bpp(overlay) != 8) {
4566 NSLOG(netsurf, INFO, "overlay sprite is not 8bpp");
4567 overlay = NULL;
4568 }
4569 }
4570
4571 /* create the thumbnail sprite */
4574 if (!bitmap) {
4575 NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
4576 return;
4577 }
4579 if (overlay) {
4581 }
4584 if (!area) {
4585 NSLOG(netsurf, INFO, "Thumbnail conversion failed.");
4586 return;
4587 }
4588
4589 /* choose a suitable sprite name */
4590 id = 0;
4591 while (iconise_used[id])
4592 if ((unsigned)++id >= NOF_ELEMENTS(iconise_used)) {
4593 id = iconise_next;
4594 if ((unsigned)++iconise_next >=
4596 iconise_next = 0;
4597 break;
4598 }
4599
4600 sprite_header = (osspriteop_header *)(area + 1);
4601 len = sprintf(sprite_header->name, "ic_netsf%.2d", id);
4602
4603 error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
4604 area, temp_fname);
4605 if (error) {
4606 NSLOG(netsurf, INFO, "xosspriteop_save_sprite_file: 0x%x:%s",
4607 error->errnum, error->errmess);
4608 ro_warn_user("MiscError", error->errmess);
4609 free(area);
4610 return;
4611 }
4612
4613 error = xwimpspriteop_merge_sprite_file(temp_fname);
4614 if (error) {
4615 NSLOG(netsurf, INFO,
4616 "xwimpspriteop_merge_sprite_file: 0x%x:%s",
4617 error->errnum,
4618 error->errmess);
4619 ro_warn_user("WimpError", error->errmess);
4620 remove(temp_fname);
4621 free(area);
4622 return;
4623 }
4624
4625 memcpy(wi->sprite_name, sprite_header->name + 3, len - 2); /* inc NUL */
4626 strncpy(wi->title, g->title, sizeof(wi->title));
4627 wi->title[sizeof(wi->title) - 1] = '\0';
4628
4629 if (wimptextop_string_width(wi->title, 0) > 182) {
4630 /* work around bug in Pinboard where it will fail to display
4631 * the icon if the text is very wide */
4632 if (strlen(wi->title) > 10)
4633 wi->title[10] = '\0'; /* pinboard does this anyway */
4634 while (wimptextop_string_width(wi->title, 0) > 182)
4635 wi->title[strlen(wi->title) - 1] = '\0';
4636 }
4637
4638 wi->size = sizeof(wimp_full_message_window_info);
4639 wi->your_ref = wi->my_ref;
4640 error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)wi,
4641 wi->sender);
4642 if (error) {
4643 NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
4644 error->errnum, error->errmess);
4645 ro_warn_user("WimpError", error->errmess);
4646 }
4647 else {
4648 g->iconise_icon = id;
4649 iconise_used[id] = true;
4650 }
4651
4652 free(area);
4653}
4654
4655
4656/* exported interface documented in riscos/window.h */
4657bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
4658{
4659 if (message->data.data_xfer.file_type == osfile_TYPE_TEXT &&
4661 message->data.data_xfer.file_name)) {
4662 os_error *error;
4663
4664 /* send DataLoadAck */
4665 message->action = message_DATA_LOAD_ACK;
4666 message->your_ref = message->my_ref;
4667 error = xwimp_send_message(wimp_USER_MESSAGE, message,
4668 message->sender);
4669 if (error) {
4670 NSLOG(netsurf, INFO,
4671 "xwimp_send_message: 0x%x: %s\n",
4672 error->errnum,
4673 error->errmess);
4674 ro_warn_user("WimpError", error->errmess);
4675 }
4676 return true;
4677 }
4678 return false;
4679}
4680
4681
4682/* exported interface documented in riscos/window.h */
4683bool ro_gui_window_check_menu(wimp_menu *menu)
4684{
4685 return (ro_gui_browser_window_menu == menu) ? true : false;
4686}
4687
4688
4689/* exported interface documented in riscos/window.h */
4691{
4692 struct gui_window *g;
4693 for (g = window_list; g; g = g->next) {
4695 }
4696}
4697
4698/* exported interface documented in riscos/window.h */
4700{
4701 osbool more;
4702 bool use_buffer;
4703 wimp_draw update;
4704 os_error *error;
4705 struct update_box *cur;
4706 struct gui_window *g;
4707
4708 for (cur = pending_updates; cur != NULL; cur = cur->next) {
4709 g = cur->g;
4710 if (!g)
4711 continue;
4712
4713 use_buffer = cur->use_buffer;
4714
4715 update.w = g->window;
4716 update.box.x0 = cur->x0;
4717 update.box.y0 = cur->y0;
4718 update.box.x1 = cur->x1;
4719 update.box.y1 = cur->y1;
4720
4721 error = xwimp_update_window(&update, &more);
4722 if (error) {
4723 NSLOG(netsurf, INFO, "xwimp_update_window: 0x%x: %s",
4724 error->errnum, error->errmess);
4725 ro_warn_user("WimpError", error->errmess);
4726 continue;
4727 }
4728
4729 /* Set the current redraw gui_window to get options from */
4731
4732 while (more) {
4733 ro_gui_window__redraw_rect(g, &update, use_buffer);
4734
4735 error = xwimp_get_rectangle(&update, &more);
4736 /* RISC OS 3.7 returns an error here if enough buffer
4737 * was claimed to cause a new dynamic area to be
4738 * created. It doesn't actually stop anything working,
4739 * so we mask it out for now until a better fix is
4740 * found. This appears to be a bug in RISC OS. */
4741 if (error && !(use_buffer &&
4742 error->errnum == error_WIMP_GET_RECT)) {
4743 NSLOG(netsurf, INFO,
4744 "xwimp_get_rectangle: 0x%x: %s",
4745 error->errnum,
4746 error->errmess);
4747 ro_warn_user("WimpError", error->errmess);
4749 continue;
4750 }
4751 }
4752
4753 /* Reset the current redraw gui_window to prevent
4754 * thumbnails from retaining options */
4756 }
4757 while (pending_updates) {
4758 cur = pending_updates;
4760 free(cur);
4761 }
4762}
4763
4764
4765/* exported interface documented in riscos/window.h */
4767{
4768 while (window_list) {
4769 struct gui_window *cur = window_list;
4771
4773 }
4774}
4775
4776
4777/* exported interface documented in riscos/window.h */
4779{
4780 struct gui_window *g;
4781
4782 for (g = window_list; g; g = g->next) {
4783 if (!g->active)
4784 continue;
4785 if (g->toolbar != NULL)
4787 }
4788}
4789
4790
4791/* exported interface documented in riscos/window.h */
4793{
4794 float cscale;
4795
4796 if (gui == NULL)
4797 return;
4798
4799 cscale = browser_window_get_scale(gui->bw);
4800
4801 /* Save the basic options */
4802 nsoption_set_int(scale, cscale * 100);
4805
4806 /* Set up the toolbar */
4807 if (gui->toolbar != NULL) {
4808 nsoption_set_bool(toolbar_show_buttons,
4810 nsoption_set_bool(toolbar_show_address,
4812 nsoption_set_bool(toolbar_show_throbber,
4814 }
4815 if (gui->status_bar != NULL) {
4816 nsoption_set_int(toolbar_status_size,
4818 }
4819}
4820
4821
4822/* exported interface documented in riscos/window.h */
4824{
4825 struct gui_window *g;
4826 for (g = window_list; g; g = g->next) {
4827 if (g->window == window) {
4828 return g;
4829 }
4830 }
4831 return NULL;
4832}
4833
4834
4835/* exported interface documented in riscos/window.h */
4837{
4838 struct gui_window *g = NULL;
4839 struct toolbar *toolbar;
4840 wimp_w parent;
4841
4843
4844 if (toolbar != NULL) {
4847 }
4848
4849 return g;
4850}
4851
4852
4853/* exported interface documented in riscos/window.h */
4854bool
4855ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
4856{
4857 wimp_window_state state;
4858 os_error *error;
4859
4860 assert(g);
4861
4862 state.w = g->window;
4863 error = xwimp_get_window_state(&state);
4864 if (error) {
4865 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s",
4866 error->errnum, error->errmess);
4867 ro_warn_user("WimpError", error->errmess);
4868 return false;
4869 }
4870 pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 ;
4871 pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 ;
4872 return true;
4873}
4874
4875
4876/* exported interface documented in riscos/window.h */
4878ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type)
4879{
4880 browser_mouse_state state = 0; /* Blank state with nothing set */
4881 static struct {
4882 enum { CLICK_SINGLE, CLICK_DOUBLE, CLICK_TRIPLE } type;
4883 uint64_t time;
4884 } last_click;
4885
4886 switch (type) {
4887 case wimp_BUTTON_CLICK_DRAG:
4888 /* Handle single clicks. */
4889
4890 /* We fire core PRESS and CLICK events together for "action on
4891 * press" behaviour. */
4892 if (buttons & (wimp_CLICK_SELECT)) /* Select click */
4894 if (buttons & (wimp_CLICK_ADJUST)) /* Adjust click */
4896 break;
4897
4898 case wimp_BUTTON_DOUBLE_CLICK_DRAG:
4899 /* Handle single, double, and triple clicks. */
4900
4901 /* Single clicks: Fire PRESS and CLICK events together
4902 * for "action on press" behaviour. */
4903 if (buttons & (wimp_SINGLE_SELECT)) {
4904 /* Select single click */
4906 } else if (buttons & (wimp_SINGLE_ADJUST)) {
4907 /* Adjust single click */
4909 }
4910
4911 /* Double clicks: Fire PRESS, CLICK, and DOUBLE_CLICK
4912 * events together for "action on 2nd press" behaviour. */
4913 if (buttons & (wimp_DOUBLE_SELECT)) {
4914 /* Select double click */
4917 } else if (buttons & (wimp_DOUBLE_ADJUST)) {
4918 /* Adjust double click */
4921 }
4922
4923 /* Need to consider what we have and decide whether to fire
4924 * triple click instead */
4925 if ((state == (BROWSER_MOUSE_PRESS_1 |
4927 (state == (BROWSER_MOUSE_PRESS_2 |
4929 /* WIMP told us single click, but maybe we want to call
4930 * it a triple click */
4931
4932 if (last_click.type == CLICK_DOUBLE) {
4933 uint64_t ms_now;
4934 nsu_getmonotonic_ms(&ms_now);
4935
4936 if (ms_now < (last_click.time + 500)) {
4937 /* Triple click! Fire PRESS, CLICK, and
4938 * TRIPLE_CLICK events together for
4939 * "action on 3nd press" behaviour. */
4940 last_click.type = CLICK_TRIPLE;
4942 } else {
4943 /* Single click */
4944 last_click.type = CLICK_SINGLE;
4945 }
4946 } else {
4947 /* Single click */
4948 last_click.type = CLICK_SINGLE;
4949 }
4950 } else if ((state == (BROWSER_MOUSE_PRESS_1 |
4953 (state == (BROWSER_MOUSE_PRESS_2 |
4956 /* Wimp told us double click, but we may want to
4957 * call it single click */
4958
4959 if (last_click.type == CLICK_TRIPLE) {
4960 state &= ~BROWSER_MOUSE_DOUBLE_CLICK;
4961 last_click.type = CLICK_SINGLE;
4962 } else {
4963 last_click.type = CLICK_DOUBLE;
4964 nsu_getmonotonic_ms(&last_click.time);
4965 }
4966 } else {
4967 last_click.type = CLICK_SINGLE;
4968 }
4969 break;
4970 }
4971
4972 /* Check if a drag has started */
4973 if (buttons & (wimp_DRAG_SELECT)) {
4974 /* A drag was _started_ with Select; Fire DRAG_1. */
4975 state |= BROWSER_MOUSE_DRAG_1;
4976 mouse_drag_select = true;
4977 }
4978 if (buttons & (wimp_DRAG_ADJUST)) {
4979 /* A drag was _started_ with Adjust; Fire DRAG_2. */
4980 state |= BROWSER_MOUSE_DRAG_2;
4981 mouse_drag_adjust = true;
4982 }
4983
4984 /* Set modifier key state */
4988
4989 return state;
4990}
4991
4992
4993/* exported interface documented in riscos/window.h */
4995ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type)
4996{
4997 browser_mouse_state state = 0; /* Blank state with nothing set */
4998
4999 /* If mouse buttons aren't held, turn off drags */
5000 if (!(buttons & (wimp_CLICK_SELECT | wimp_CLICK_ADJUST))) {
5001 mouse_drag_select = false;
5002 mouse_drag_adjust = false;
5003 }
5004
5005 /* If there's a drag happening, set DRAG_ON and record which button
5006 * the drag is happening with, i.e. HOLDING_1 or HOLDING_2 */
5007 if (mouse_drag_select) {
5009 }
5010 if (mouse_drag_adjust) {
5012 }
5013
5014 /* Set modifier key state */
5018
5019 return state;
5020}
5021
5022
5023/* exported interface documented in riscos/window.h */
5025{
5026 int shift = 0;
5027 xosbyte1(osbyte_SCAN_KEYBOARD, 0 ^ 0x80, 0, &shift);
5028 return (shift == 0xff);
5029}
5030
5031
5032/* exported interface documented in riscos/window.h */
5034{
5035 int ctrl = 0;
5036 xosbyte1(osbyte_SCAN_KEYBOARD, 1 ^ 0x80, 0, &ctrl);
5037 return (ctrl == 0xff);
5038}
5039
5040
5041/* exported interface documented in riscos/window.h */
5043{
5044 int alt = 0;
5045 xosbyte1(osbyte_SCAN_KEYBOARD, 2 ^ 0x80, 0, &alt);
5046 return (alt == 0xff);
5047}
5048
5049
5050/* exported interface documented in riscos/window.h */
5052{
5053 static gui_pointer_shape curr_pointer = GUI_POINTER_DEFAULT;
5054 struct ro_gui_pointer_entry *entry;
5055 os_error *error;
5056
5057 if (shape == curr_pointer)
5058 return;
5059
5060 assert(shape < sizeof ro_gui_pointer_table /
5061 sizeof ro_gui_pointer_table[0]);
5062
5063 entry = &ro_gui_pointer_table[shape];
5064
5065 if (entry->wimp_area) {
5066 /* pointer in the Wimp's sprite area */
5067 error = xwimpspriteop_set_pointer_shape(entry->sprite_name,
5068 1, entry->xactive, entry->yactive, 0, 0);
5069 if (error) {
5070 NSLOG(netsurf, INFO,
5071 "xwimpspriteop_set_pointer_shape: 0x%x: %s",
5072 error->errnum,
5073 error->errmess);
5074 ro_warn_user("WimpError", error->errmess);
5075 }
5076 } else {
5077 /* pointer in our own sprite area */
5078 error = xosspriteop_set_pointer_shape(osspriteop_USER_AREA,
5080 (osspriteop_id) entry->sprite_name,
5081 1, entry->xactive, entry->yactive, 0, 0);
5082 if (error) {
5083 NSLOG(netsurf, INFO,
5084 "xosspriteop_set_pointer_shape: 0x%x: %s",
5085 error->errnum,
5086 error->errmess);
5087 ro_warn_user("WimpError", error->errmess);
5088 }
5089 }
5090
5091 curr_pointer = shape;
5092}
void gui_start_selection(struct gui_window *g)
Definition: clipboard.c:87
menu_action
Definition: scaffolding.h:77
@ BROWSER_WINDOW_STAGGER
Definition: scaffolding.h:149
@ BROWSER_NAVIGATE_HOME
Definition: scaffolding.h:131
@ BROWSER_SCALE_VIEW
Definition: scaffolding.h:141
@ BROWSER_PAGE_INFO
Definition: scaffolding.h:104
@ BROWSER_OBJECT_SAVE
Definition: scaffolding.h:115
@ BROWSER_NAVIGATE_FORWARD
Definition: scaffolding.h:133
@ BROWSER_BUFFER_ALL
Definition: scaffolding.h:146
@ BROWSER_BUFFER_ANIMS
Definition: scaffolding.h:145
@ HELP_OPEN_LICENCE
Definition: scaffolding.h:87
@ TOOLBAR_ADDRESS_BAR
Definition: scaffolding.h:171
@ BROWSER_OBJECT_RELOAD
Definition: scaffolding.h:112
@ BROWSER_OBJECT_EXPORT_SPRITE
Definition: scaffolding.h:116
@ BROWSER_WINDOW_RESET
Definition: scaffolding.h:151
@ BROWSER_WINDOW_COPY
Definition: scaffolding.h:150
@ BROWSER_OBJECT_SAVE_URL_URI
Definition: scaffolding.h:117
@ COOKIES_SHOW
Definition: scaffolding.h:99
@ BROWSER_SAVE_VIEW
Definition: scaffolding.h:147
@ BROWSER_IMAGES_BACKGROUND
Definition: scaffolding.h:144
@ BROWSER_OBJECT
Definition: scaffolding.h:110
@ BROWSER_NEW_WINDOW
Definition: scaffolding.h:106
@ BROWSER_NAVIGATE_BACK
Definition: scaffolding.h:132
@ BROWSER_PRINT
Definition: scaffolding.h:105
@ BROWSER_NAVIGATE_STOP
Definition: scaffolding.h:137
@ HISTORY_SHOW_LOCAL
Definition: scaffolding.h:91
@ BROWSER_SAVE_URL_TEXT
Definition: scaffolding.h:126
@ BROWSER_NAVIGATE_UP
Definition: scaffolding.h:134
@ HOTLIST_ADD_URL
Definition: scaffolding.h:95
@ BROWSER_OBJECT_SAVE_URL_URL
Definition: scaffolding.h:118
@ HELP_OPEN_GUIDE
Definition: scaffolding.h:84
@ HOTLIST_SHOW
Definition: scaffolding.h:96
@ BROWSER_PAGE
Definition: scaffolding.h:103
@ BROWSER_SAVE
Definition: scaffolding.h:120
@ BROWSER_FIND_TEXT
Definition: scaffolding.h:142
@ BROWSER_OBJECT_INFO
Definition: scaffolding.h:111
@ BROWSER_NAVIGATE_RELOAD_ALL
Definition: scaffolding.h:136
@ BROWSER_IMAGES_FOREGROUND
Definition: scaffolding.h:143
@ TOOLBAR_BUTTONS
Definition: scaffolding.h:170
@ BROWSER_OBJECT_SAVE_URL_TEXT
Definition: scaffolding.h:119
@ BROWSER_SAVE_COMPLETE
Definition: scaffolding.h:121
@ HELP_OPEN_INFORMATION
Definition: scaffolding.h:85
@ HISTORY_SHOW_GLOBAL
Definition: scaffolding.h:92
@ TOOLBAR_EDIT
Definition: scaffolding.h:173
@ BROWSER_WINDOW_DEFAULT
Definition: scaffolding.h:148
@ BROWSER_SAVE_URL_URI
Definition: scaffolding.h:124
@ BROWSER_EXPORT_DRAW
Definition: scaffolding.h:122
@ BROWSER_VIEW_SOURCE
Definition: scaffolding.h:107
@ COOKIES_DELETE
Definition: scaffolding.h:100
@ BROWSER_SAVE_URL_URL
Definition: scaffolding.h:125
@ BROWSER_EXPORT_TEXT
Definition: scaffolding.h:123
@ HELP_OPEN_CONTENTS
Definition: scaffolding.h:83
@ TOOLBAR_THROBBER
Definition: scaffolding.h:172
@ HELP_LAUNCH_INTERACTIVE
Definition: scaffolding.h:88
nserror browser_window_history_forward(struct browser_window *bw, bool new_window)
Go forward in the history.
nserror browser_window_history_back(struct browser_window *bw, bool new_window)
Go back in the history.
Interface to browser history operations.
Browser window creation and manipulation interface.
nserror browser_window_schedule_reformat(struct browser_window *bw)
Reformat the browser window contents in a safe context.
bool browser_window_redraw_ready(struct browser_window *bw)
Check whether browser window is ready for redraw.
bool browser_window_can_select(struct browser_window *bw)
Find out if given browser window content is selectable.
nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
Redraw an area of a window.
float browser_window_get_scale(struct browser_window *bw)
Gets the scale of a browser window.
bool browser_window_has_content(struct browser_window *bw)
Find out if a browser window is currently showing a content.
bool browser_window_back_available(struct browser_window *bw)
Check availability of Back action for a given browser window.
nserror browser_window_get_scrollbar_type(struct browser_window *bw, browser_scrolling *h, browser_scrolling *v)
Get the browser window's scrollbar details.
nserror browser_window_debug(struct browser_window *bw, enum content_debug op)
Set debug options on a window.
nserror browser_window_get_url(struct browser_window *bw, bool fragment, struct nsurl **url_out)
Access a browser window's URL.
bool browser_window_can_search(struct browser_window *bw)
Find out if given browser window can be searched.
void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks in a browser window.
bool browser_window_scroll_at_point(struct browser_window *bw, int x, int y, int scrx, int scry)
Send a scroll request to a browser window at a particular point.
bool browser_window_up_available(struct browser_window *bw)
Return true if a browser window can navigate upwards.
void browser_window_destroy(struct browser_window *bw)
Close and destroy a browser window.
nserror browser_window_navigate_up(struct browser_window *bw, bool new_window)
Navigate to a browser_window's parent URL.
nserror browser_window_reload(struct browser_window *bw, bool all)
Reload the page in a browser window.
browser_editor_flags
@ BW_EDITOR_CAN_PASTE
Can paste, input.
@ BW_EDITOR_CAN_CUT
Selection not read-only.
@ BW_EDITOR_CAN_COPY
Have selection.
browser_scrolling
@ BW_SCROLLING_NO
struct nsurl * browser_window_access_url(const struct browser_window *bw)
Access a browser window's URL.
bool browser_window_reload_available(struct browser_window *bw)
Check availability of Reload action for a given browser window.
bool browser_window_forward_available(struct browser_window *bw)
Check availability of Forward action for a given browser window.
char * browser_window_get_selection(struct browser_window *bw)
Get the current selection from a root browser window, ownership passed to caller, who must free() it.
const char * browser_window_get_title(struct browser_window *bw)
Get the title of a browser_window.
nserror browser_window_get_extents(struct browser_window *bw, bool scaled, int *width, int *height)
Get a browser window's content extents.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
void browser_window_stop(struct browser_window *bw)
Stop all fetching activity in a browser window.
bool browser_window_is_frameset(struct browser_window *bw)
Find out if a browser window contains a frameset.
nserror browser_window_set_scale(struct browser_window *bw, float scale, bool absolute)
Sets the scale of a browser window.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
browser_editor_flags browser_window_get_editor_flags(struct browser_window *bw)
Check whether browser window can accept a cut/copy/paste, or has a selection that could be saved.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_CREATE_CLONE
New gui_window to be clone of "existing" gui_window.
bool browser_window_stop_available(struct browser_window *bw)
Check availability of Stop action for a given browser window.
bool browser_window_drop_file_at_point(struct browser_window *bw, int x, int y, char *file)
Drop a file onto a browser window at a particular point, or determine if a file may be dropped onto t...
@ BW_NAVIGATE_DOWNLOAD
download rather than render the uri
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
void browser_window_mouse_track(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle non-click mouse action in a browser window.
void ro_gui_buffer_close(void)
Closes any open buffer and flushes the contents to screen.
Definition: buffer.c:370
void ro_gui_buffer_open(const wimp_draw *redraw)
Opens a buffer for writing to.
Definition: buffer.c:84
Screen buffering (interface).
@ TOOLBAR_BUTTON_BOOKMARK_OPEN
Definition: button_bar.h:49
@ TOOLBAR_BUTTON_SEARCH
Definition: button_bar.h:52
@ TOOLBAR_BUTTON_HISTORY_GLOBAL
Definition: button_bar.h:45
@ TOOLBAR_BUTTON_SCALE
Definition: button_bar.h:51
@ TOOLBAR_BUTTON_HOME
Definition: button_bar.h:43
@ TOOLBAR_BUTTON_HISTORY_LOCAL
Definition: button_bar.h:44
@ TOOLBAR_BUTTON_BACK_NEW
Definition: button_bar.h:35
@ TOOLBAR_BUTTON_UP
Definition: button_bar.h:36
@ TOOLBAR_BUTTON_SAVE_COMPLETE
Definition: button_bar.h:47
@ TOOLBAR_BUTTON_BACK
Definition: button_bar.h:34
@ TOOLBAR_BUTTON_FORWARD_NEW
Definition: button_bar.h:39
@ TOOLBAR_BUTTON_BOOKMARK_ADD
Definition: button_bar.h:50
@ TOOLBAR_BUTTON_RELOAD
Definition: button_bar.h:41
@ TOOLBAR_BUTTON_SAVE_SOURCE
Definition: button_bar.h:46
@ TOOLBAR_BUTTON_UP_NEW
Definition: button_bar.h:37
@ TOOLBAR_BUTTON_FORWARD
Definition: button_bar.h:38
@ TOOLBAR_BUTTON_RELOAD_ALL
Definition: button_bar.h:42
@ TOOLBAR_BUTTON_PRINT
Definition: button_bar.h:48
@ TOOLBAR_BUTTON_STOP
Definition: button_bar.h:40
static const struct button_bar_buttons brower_toolbar_buttons[]
Definition: button_bar.h:82
@ CONTENT_IMAGE
All images.
Definition: content_type.h:67
@ CONTENT_HTML
content is HTML
Definition: content_type.h:58
@ CONTENT_TEXTPLAIN
content is plain text
Definition: content_type.h:61
@ CONTENT_DEBUG_REDRAW
Debug redraw operations.
Definition: content_type.h:38
@ CONTENT_ENCODING_NORMAL
The content encoding.
Definition: content_type.h:45
@ CONTENT_ENCODING_SOURCE
The content encoding source.
Definition: content_type.h:48
bool cookie_manager_keypress(uint32_t key)
Key press handling.
Cookie Manager (interface).
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out)
Generate a nsurl from a search term.
Definition: searchweb.c:318
wimp_w dialog_zoom
Definition: dialog.c:76
void ro_gui_dialog_close_persistent(wimp_w parent)
Close persistent dialogs associated with a window.
Definition: dialog.c:638
wimp_w dialog_print
Definition: dialog.c:78
wimp_w parent
Definition: dialog.c:88
wimp_w dialog_saveas
Definition: dialog.c:75
void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer)
Open a persistent dialog box relative to the pointer.
Definition: dialog.c:591
void ro_gui_save_options(void)
Save the current options.
Definition: dialog.c:670
wimp_w dialog_search
Definition: dialog.c:78
void ro_gui_dialog_prepare_zoom(struct gui_window *g)
Prepares the Scale view dialog.
Definition: dialog.c:689
wimp_w dialog_pageinfo
Definition: dialog.c:76
wimp_w dialog_objinfo
Definition: dialog.c:76
void gui_drag_save_selection(struct gui_window *g, const char *selection)
Definition: drag.c:303
void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, gui_save_type type)
Definition: drag.c:298
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_BAD_ENCODING
The character set is unknown.
Definition: errors.h:45
@ NSERROR_BAD_PARAMETER
Bad Parameter.
Definition: errors.h:48
@ NSERROR_INVALID
Invalid data.
Definition: errors.h:49
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
Form handling public interface.
struct form_option * form_select_get_option(struct form_control *control, int item)
get a form select menus option.
Definition: form.c:1844
nserror form_select_process_selection(struct form_control *control, int item)
Process a selection from a form select menu.
Definition: form.c:1834
#define NOF_ELEMENTS(array)
Definition: search.c:67
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
Definition: utf8.c:89
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
Definition: utf8.c:80
osspriteop_area * riscos_bitmap_convert_8bpp(struct bitmap *bitmap)
Convert a bitmap to 8bpp.
Definition: bitmap.c:633
void riscos_bitmap_destroy(void *vbitmap)
Free a bitmap.
Definition: bitmap.c:202
void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
Definition: bitmap.c:431
void * riscos_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.c:125
nserror riscos_bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
Render content into bitmap.
Definition: bitmap.c:724
nserror ro_gui_global_history_present(void)
make the global history window visible.
RISc OS global history interface.
void ro_gui_hotlist_remove_page(nsurl *url)
Remove a URL from the hotlist.
Definition: hotlist.c:789
nserror ro_gui_hotlist_present(void)
make the cookie window visible.
Definition: hotlist.c:539
void ro_gui_hotlist_add_page(nsurl *url)
Add a URL to the hotlist.
Definition: hotlist.c:667
Hotlist (interface).
nserror ro_gui_local_history_present(wimp_w parent, struct browser_window *bw)
make the local history window visible.
RISC OS local history interface.
void ro_mouse_drag_start(void(*drag_end)(wimp_dragged *dragged, void *data), void(*drag_track)(wimp_pointer *pointer, void *data), void(*drag_cancel)(void *data), void *data)
Start a drag, providing a function to be called when the Wimp_DragEnd event is received and optionall...
Definition: mouse.c:115
void ro_mouse_track_start(void(*poll_end)(wimp_leaving *leaving, void *data), void(*poll_track)(wimp_pointer *pointer, void *data), void *data)
Start tracking the mouse in a window, providing a function to be called on null polls and optionally ...
Definition: mouse.c:177
void ro_mouse_kill(void *data)
Kill any tracking events if the data pointers match the supplied pointer.
Definition: mouse.c:248
Mouse dragging and tracking support interface for RISC OS.
void ro_gui_selection_prepare_paste(wimp_w w, ro_gui_selection_prepare_paste_cb cb, void *pw)
Prepare to paste data from another application.
Text selection import/export (interface).
@ THEME_STYLE_BROWSER_TOOLBAR
Definition: theme.h:33
Browser window handling (interface).
struct gui_window * window_list
Definition: window.c:147
#define NO_ACTION
Definition: idna.c:695
Generic bitmap handling interface.
@ BITMAP_CLEAR
memory should be wiped to 0
Definition: bitmap.h:39
@ BITMAP_OPAQUE
image is opaque
Definition: bitmap.h:38
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
const char * content_get_title(struct hlcache_handle *h)
Retrieve title associated with content.
Definition: content.c:1106
void content_invalidate_reuse_data(struct hlcache_handle *h)
Invalidate content reuse data.
Definition: content.c:1229
const char * content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op)
Retrieve the encoding of a content.
Definition: content.c:1321
lwc_string * content_get_mime_type(struct hlcache_handle *h)
Retrieve mime-type of content.
Definition: content.c:1073
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Definition: content.c:1061
browser_mouse_state
Mouse state.
Definition: mouse.h:43
@ BROWSER_MOUSE_PRESS_1
button 1 pressed
Definition: mouse.h:50
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
Definition: mouse.h:57
@ BROWSER_MOUSE_PRESS_2
button 2 pressed
Definition: mouse.h:52
@ BROWSER_MOUSE_TRIPLE_CLICK
button triple clicked
Definition: mouse.h:62
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
Definition: mouse.h:55
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
Definition: mouse.h:80
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
Definition: mouse.h:60
@ BROWSER_MOUSE_MOD_3
3rd modifier key pressed (eg.
Definition: mouse.h:82
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
Definition: mouse.h:78
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
Definition: mouse.h:65
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
Definition: mouse.h:75
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
Definition: mouse.h:73
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
Definition: mouse.h:70
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Definition: mouse.h:67
gui_pointer_shape
Definition: mouse.h:89
@ GUI_POINTER_DEFAULT
Definition: mouse.h:90
Target independent plotting interface.
Interface to platform-specific graphical user interface window operations.
gui_window_create_flags
Window creation control flags.
Definition: window.h:66
@ GW_CREATE_CLONE
Clone existing window.
Definition: window.h:68
gui_save_type
Definition: window.h:39
@ GUI_SAVE_OBJECT_ORIG
Definition: window.h:45
@ GUI_SAVE_DRAW
Definition: window.h:41
@ GUI_SAVE_TEXT
Definition: window.h:43
@ GUI_SAVE_SOURCE
Definition: window.h:40
@ GUI_SAVE_LINK_TEXT
Definition: window.h:49
@ GUI_SAVE_LINK_URI
Definition: window.h:47
@ GUI_SAVE_TEXT_SELECTION
Definition: window.h:52
@ GUI_SAVE_OBJECT_NATIVE
Definition: window.h:46
@ GUI_SAVE_LINK_URL
Definition: window.h:48
@ GUI_SAVE_COMPLETE
Definition: window.h:44
@ GUI_SAVE_PDF
Definition: window.h:42
gui_drag_type
Definition: window.h:56
@ GDRAGGING_SCROLLBAR
Definition: window.h:58
gui_window_event
Window events.
Definition: window.h:80
@ GW_EVENT_SCROLL_START
Starts drag scrolling of a browser window.
Definition: window.h:113
@ GW_EVENT_PAGE_INFO_CHANGE
Page status has changed and so the padlock should be updated.
Definition: window.h:129
@ GW_EVENT_REMOVE_CARET
Remove the caret, if present.
Definition: window.h:98
@ GW_EVENT_NEW_CONTENT
Called when the gui_window has new content.
Definition: window.h:118
@ GW_EVENT_STOP_THROBBER
stop the navigation throbber.
Definition: window.h:108
@ GW_EVENT_UPDATE_EXTENT
Update the extent of the inside of a browser window to that of the current content.
Definition: window.h:93
@ GW_EVENT_START_SELECTION
selection started
Definition: window.h:123
@ GW_EVENT_START_THROBBER
start the navigation throbber.
Definition: window.h:103
Netsurf additional integer type formatting macros.
Interface to key press operations.
@ NS_KEY_REDO
Definition: keypress.h:71
@ NS_KEY_DELETE_LINE_START
Definition: keypress.h:68
@ NS_KEY_LINE_START
Definition: keypress.h:57
@ NS_KEY_RIGHT
Definition: keypress.h:51
@ NS_KEY_LEFT
Definition: keypress.h:50
@ NS_KEY_SELECT_ALL
Definition: keypress.h:32
@ NS_KEY_PASTE
Definition: keypress.h:43
@ NS_KEY_COPY_SELECTION
Definition: keypress.h:33
@ NS_KEY_DOWN
Definition: keypress.h:53
@ NS_KEY_CUT_SELECTION
Definition: keypress.h:44
@ NS_KEY_WORD_LEFT
Definition: keypress.h:61
@ NS_KEY_DELETE_LINE_END
Definition: keypress.h:67
@ NS_KEY_PAGE_UP
Definition: keypress.h:65
@ NS_KEY_PAGE_DOWN
Definition: keypress.h:66
@ NS_KEY_UNDO
Definition: keypress.h:70
@ NS_KEY_TEXT_START
Definition: keypress.h:59
@ NS_KEY_LINE_END
Definition: keypress.h:58
@ NS_KEY_TEXT_END
Definition: keypress.h:60
@ NS_KEY_DELETE_RIGHT
Definition: keypress.h:55
@ NS_KEY_CLEAR_SELECTION
Definition: keypress.h:45
@ NS_KEY_WORD_RIGHT
Definition: keypress.h:63
@ NS_KEY_DELETE_LEFT
Definition: keypress.h:35
@ NS_KEY_UP
Definition: keypress.h:52
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
Definition: textinput.c:107
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
void ro_gui_menu_destroy(void)
Forcibly close any menu or transient dialogue box that is currently open.
Definition: menus.c:288
void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
Display a menu.
Definition: menus.c:211
void ro_gui_menu_init_structure(wimp_menu *menu, int entries)
Initialise the basic state of a menu structure so all entries are indirected text with no flags,...
Definition: menus.c:682
void ro_gui_menu_set_entry_ticked(wimp_menu *menu, menu_action action, bool ticked)
Sets an action within a menu as having a specific ticked status.
Definition: menus.c:831
void ro_gui_menu_refresh(wimp_menu *menu)
Update the current menu by sending it a Menu Prepare event through wimp_event and then reopening it i...
Definition: menus.c:475
void ro_gui_menu_set_entry_shaded(wimp_menu *menu, menu_action action, bool shaded)
Sets an action within a menu as having a specific ticked status.
Definition: menus.c:804
wimp_menu * ro_gui_menu_define_menu(const struct ns_menu *menu)
Creates a wimp_menu and adds it to the list to handle actions for.
Definition: menus.c:510
@ BROWSER_SELECTION_SAVE
Definition: menus.h:93
@ BROWSER_SELECTION
Definition: menus.h:92
@ BROWSER_SELECTION_CUT
Definition: menus.h:95
@ BROWSER_OBJECT_LINK
Definition: menus.h:61
@ BROWSER_EXPORT_PDF
Definition: menus.h:80
@ BROWSER_LINK_SAVE_TEXT
Definition: menus.h:87
@ BROWSER_OBJECT_PRINT
Definition: menus.h:63
@ BROWSER_SELECTION_CLEAR
Definition: menus.h:97
@ BROWSER_LINK_NEW_WINDOW
Definition: menus.h:67
@ BROWSER_LINK_SAVE
Definition: menus.h:65
@ BROWSER_OBJECT_EXPORT_DRAW
Definition: menus.h:73
@ BROWSER_LINK_DOWNLOAD
Definition: menus.h:66
@ BROWSER_OBJECT_EXPORT
Definition: menus.h:71
@ HELP_OPEN_CREDITS
Definition: menus.h:35
@ BROWSER_LINK_SAVE_URI
Definition: menus.h:85
@ BROWSER_LINK_SAVE_URL
Definition: menus.h:86
@ BROWSER_SELECTION_COPY
Definition: menus.h:94
@ BROWSER_SELECTION_ALL
Definition: menus.h:98
@ BROWSER_OBJECT_OBJECT
Definition: menus.h:60
@ BROWSER_SELECTION_PASTE
Definition: menus.h:96
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
NetSurf URL handling (interface).
nserror nsurl_get_utf8(const nsurl *url, char **url_s, size_t *url_l)
Get a UTF-8 string (for human readable IDNs) from a NetSurf URL object.
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Backward compatible defines to make NetSurf buildable with pre-OSLib 7 releases.
nserror ro_gui_cookies_present(const char *search_term)
make the cookie window visible.
Definition: cookies.c:449
Interface to riscos cookie viewing using riscos core window.
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
Definition: filetype.c:243
int ro_content_native_type(struct hlcache_handle *c)
Determine the native RISC OS filetype to export a content as.
Definition: filetype.c:263
RISC OS filetpe interface.
void ro_gui_screen_size(int *width, int *height)
Find screen size in OS units.
Definition: gui.c:2343
void ro_gui_view_source(struct hlcache_handle *c)
Send the source of a content to a text editor.
Definition: gui.c:1942
int width
Definition: gui.c:160
osspriteop_area * gui_sprites
Sprite area containing pointer and hotlist sprites.
Definition: gui.c:118
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
Definition: gui.c:2077
void ro_gui_dump_browser_window(struct browser_window *bw)
Send the debug dump of a content to a text editor.
Definition: gui.c:2353
int height
Definition: gui.c:161
int os_version
Definition: gui.c:97
#define ICON_PAGEINFO_ICON
Definition: gui.h:188
int ro_plot_origin_x
Definition: plotters.c:40
int ro_plot_origin_y
Definition: plotters.c:41
wimp_w current_menu_window
Window that owns the current menu.
Definition: menus.c:100
struct rect ro_plot_clip_rect
Definition: plotters.c:42
#define ICON_OBJINFO_URL
Definition: gui.h:190
const struct plotter_table ro_plotters
RISC OS plotter operation table.
Definition: plotters.c:727
#define ICON_OBJINFO_ICON
Definition: gui.h:193
#define ICON_PAGEINFO_URL
Definition: gui.h:185
void ro_gui_print_prepare(struct gui_window *g)
Prepares all aspects of the print dialog prior to opening.
Definition: print.c:158
#define RISCOS5
Definition: gui.h:26
#define ICON_PAGEINFO_TYPE
Definition: gui.h:187
void ro_gui_search_prepare(struct browser_window *g)
Open the search dialog.
Definition: search.c:292
#define ICON_OBJINFO_TYPE
Definition: gui.h:192
#define ICON_OBJINFO_TARGET
Definition: gui.h:191
#define ICON_PAGEINFO_ENC
Definition: gui.h:186
#define ICON_PAGEINFO_TITLE
Definition: gui.h:184
bool ro_gui_interactive_help_available(void)
Checks if interactive help is running.
Definition: help.c:285
void ro_gui_interactive_help_start(void)
Launches interactive help.
Definition: help.c:327
Interactive help (interface).
nserror ro_gui_pageinfo_present(struct gui_window *gw)
make the pageinfo window visible.
Definition: pageinfo.c:291
Interface to page info core window for RISC OS.
File/object/selection saving (Interface).
void ro_toolbar_update_hotlist(struct toolbar *toolbar)
Update the state of a toolbar's URL Bar hotlist icon to reflect any changes to the URL or the hotlist...
Definition: toolbar.c:1645
bool ro_toolbar_add_buttons(struct toolbar *toolbar, const struct button_bar_buttons buttons[], char *button_order)
Add a button bar to a toolbar, and configure the buttons.
Definition: toolbar.c:273
int ro_toolbar_height(struct toolbar *toolbar)
Return the current height of a toolbar, allowing for available window space.
Definition: toolbar.c:1519
bool ro_toolbar_get_display_throbber(struct toolbar *toolbar)
Return true or false depending on whether the given toolbar is set to display the throbber.
Definition: toolbar.c:1763
void ro_toolbar_destroy(struct toolbar *toolbar)
Destroy a toolbar after use.
Definition: toolbar.c:947
int ro_toolbar_full_height(struct toolbar *toolbar)
Return the full height that a toolbar could grow to, if space is available.
Definition: toolbar.c:1527
bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat)
Process a toolbar, updating its contents for a size or content change.
Definition: toolbar.c:588
void ro_toolbar_set_site_favicon(struct toolbar *toolbar, struct hlcache_handle *h)
Update the favicon in a browser window toolbar to the supplied content, or revert to using filetype-b...
Definition: toolbar.c:1669
bool ro_toolbar_add_throbber(struct toolbar *toolbar)
Add a throbber to a toolbar.
Definition: toolbar.c:308
bool ro_toolbar_rebuild(struct toolbar *toolbar)
(Re-)build a toolbar to use the specified (or current) theme.
Definition: toolbar.c:346
const char * ro_toolbar_get_url(struct toolbar *toolbar)
Return a pointer to the URL contained in a browser toolbar.
Definition: toolbar.c:1619
struct toolbar * ro_toolbar_window_lookup(wimp_w w)
Find the toolbar using a given RO window handle for its pane.
Definition: toolbar.c:1489
struct toolbar * ro_toolbar_create(struct theme_descriptor *descriptor, wimp_w parent, theme_style style, toolbar_flags bar_flags, const struct toolbar_callbacks *callbacks, void *client_data, const char *help)
Create a new toolbar, ready to have widgets added and to be attached to a window.
Definition: toolbar.c:219
void ro_toolbar_set_content_favicon(struct toolbar *toolbar, struct gui_window *g)
Update the favicon in a browser window toolbar to reflect the RISC OS filetype of the content within ...
Definition: toolbar.c:1680
void ro_toolbar_stop_throbbing(struct toolbar *toolbar)
Stops a toolbar throbber, if there is one active.
Definition: toolbar.c:1543
void ro_toolbar_set_display_buttons(struct toolbar *toolbar, bool display)
Set the display button bar state for a toolbar.
Definition: toolbar.c:1703
void ro_toolbar_set_url(struct toolbar *toolbar, const char *url, bool is_utf8, bool set_caret)
Set the content of a toolbar's URL field.
Definition: toolbar.c:1609
bool ro_toolbar_toggle_edit(struct toolbar *toolbar)
Toggle toolbar edit mode on the given toolbar.
Definition: toolbar.c:1780
bool ro_toolbar_get_display_url(struct toolbar *toolbar)
Return true or false depending on whether the given toolbar is set to display the URL bar.
Definition: toolbar.c:1754
void ro_toolbar_page_info_change(struct toolbar *toolbar)
Update the page information indicator.
Definition: toolbar.c:1551
void ro_toolbar_set_display_throbber(struct toolbar *toolbar, bool display)
Set the display throbber state for a toolbar.
Definition: toolbar.c:1731
void ro_toolbar_update_urlsuggest(struct toolbar *toolbar)
Update the state of the URL suggestion pop-up menu icon on a toolbar.
Definition: toolbar.c:1692
struct toolbar * ro_toolbar_parent_window_lookup(wimp_w w)
Find the toolbar associated with a given RO window handle.
Definition: toolbar.c:1475
void ro_toolbar_throb(struct toolbar *toolbar)
Animate a toolbar throbber, if there is one active.
Definition: toolbar.c:1561
void ro_toolbar_set_button_shaded_state(struct toolbar *toolbar, button_bar_action action, bool shaded)
Set the shaded state of a toolbar button.
Definition: toolbar.c:1586
void ro_toolbar_set_display_url(struct toolbar *toolbar, bool display)
Set the display URL bar state for a toolbar.
Definition: toolbar.c:1717
bool ro_toolbar_take_caret(struct toolbar *toolbar)
Give a toolbar input focus, placing the caret into the URL bar if one is present.
Definition: toolbar.c:1598
bool ro_toolbar_get_display_buttons(struct toolbar *toolbar)
Return true or false depending on whether the given toolbar is set to display the button bar.
Definition: toolbar.c:1745
wimp_w ro_toolbar_get_parent_window(struct toolbar *toolbar)
Return the RO window handle of the parent window for a toolbar.
Definition: toolbar.c:1503
bool ro_toolbar_add_url(struct toolbar *toolbar)
Add a URL bar to a toolbar.
Definition: toolbar.c:327
void ro_toolbar_start_throbbing(struct toolbar *toolbar)
Starts a toolbar throbber, if there is one active.
Definition: toolbar.c:1535
Window toolbars (interface).
toolbar_action_type
Widget action types that the toolbar can pass on to clients.
Definition: toolbar.h:43
@ TOOLBAR_ACTION_BUTTON
Definition: toolbar.h:45
@ TOOLBAR_ACTION_URL
Definition: toolbar.h:46
#define ro_toolbar_menu_throbber_tick(toolbar)
Definition: toolbar.h:92
#define ro_toolbar_menu_edit_tick(toolbar)
Definition: toolbar.h:97
#define ro_toolbar_menu_option_shade(toolbar)
Definition: toolbar.h:82
#define ro_toolbar_menu_buttons_tick(toolbar)
Definition: toolbar.h:85
#define ro_toolbar_menu_url_tick(toolbar)
Definition: toolbar.h:89
#define ro_toolbar_menu_edit_shade(toolbar)
Definition: toolbar.h:95
@ TOOLBAR_FLAGS_NONE
Definition: toolbar.h:34
#define wimp_KEY_END
Definition: window.c:98
static bool mouse_drag_adjust
Definition: window.c:119
static struct form_control * gui_form_select_control
Form control which gui_form_select_menu is for.
Definition: window.c:126
static nserror ro_gui_window_event(struct gui_window *gw, enum gui_window_event event)
process miscellaneous window events
Definition: window.c:4188
static nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
Save the specified content as a link.
Definition: window.c:4056
static void ro_gui_window_pointer_entering(wimp_entering *entering)
Process Pointer Entering Window events in a browser window.
Definition: window.c:1827
static void ro_gui_window__redraw_rect(const struct gui_window *gui_win, const wimp_draw *wimp_rect, bool use_buffer)
Wrapper for calls to browser_window_redraw for a wimp_draw rectangle.
Definition: window.c:1650
static bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handle selections from a browser window menu.
Definition: window.c:2542
static void ro_gui_window_prepare_objectinfo(struct hlcache_handle *object, nsurl *target_url)
Prepare the object info window for use.
Definition: window.c:2482
static void ro_gui_window_paste_cb(void *pw)
callback to handle window paste operation
Definition: window.c:2523
enum browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type)
Returns the state of the mouse buttons and modifiers keys for a mouse action, suitable for passing to...
Definition: window.c:4878
static const struct toolbar_callbacks ro_gui_window_toolbar_callbacks
toolbar callbacks for a browser window.
Definition: window.c:1560
static void gui_window_destroy(struct gui_window *g)
Close a browser window and free any related resources.
Definition: window.c:3529
static bool ro_gui_window_import_text(struct gui_window *g, const char *filename)
Import text file into window.
Definition: window.c:4109
static void gui_window_remove_caret(struct gui_window *g)
Remove the caret, if present.
Definition: window.c:3842
bool ro_gui_shift_pressed(void)
Returns true iff one or more Shift keys is held down.
Definition: window.c:5024
static void ro_gui_window_scroll_action(struct gui_window *g, wimp_scroll_direction scroll_x, wimp_scroll_direction scroll_y)
Scroll a browser window.
Definition: window.c:1057
static nserror gui_window_get_dimensions(struct gui_window *gw, int *width, int *height)
Find the current dimensions of a browser window's content area.
Definition: window.c:3757
static void gui_window_page_info_change(struct gui_window *gw)
Update the interface to reflect change in page info status.
Definition: window.c:3816
static void gui_window_update_extent(struct gui_window *g)
Update the extent of the inside of a browser window to that of the current content.
Definition: window.c:458
static void ro_gui_window_action_save(struct gui_window *g, gui_save_type save_type)
Open a save dialogue for a browser window contents.
Definition: window.c:710
static void ro_gui_window_process_form_select_menu(struct gui_window *g, wimp_selection *selection)
Process selections from a form select menu, passing them back to the core.
Definition: window.c:2463
static bool ro_gui_window_toolbar_keypress(void *data, wimp_key *key)
Callback handler for keypresses within browser window toolbars.
Definition: window.c:1529
static float scale_snap_to[]
Definition: window.c:138
static void ro_gui_window_update_theme(void *data, bool ok)
Update a window and its toolbar.
Definition: window.c:497
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
set the pointer shape
Definition: window.c:5051
static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Create and open a new browser window.
Definition: window.c:3275
void ro_gui_throb(void)
Animate the "throbbers" of all browser windows.
Definition: window.c:4778
static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
Process Pointer Leaving Window events in a browser window.
Definition: window.c:1812
static void gui_window_start_throbber(struct gui_window *g)
Update the interface to reflect start of page loading.
Definition: window.c:3786
void ro_gui_window_set_scale(struct gui_window *g, float scale)
Set a gui_window's scale.
Definition: window.c:4474
struct gui_window * ro_gui_toolbar_lookup(wimp_w window)
Convert a toolbar RISC OS window handle to a gui_window.
Definition: window.c:4836
static struct gui_window_table window_table
RISC OS browser window operation table.
Definition: window.c:4234
static void gui_window_set_title(struct gui_window *g, const char *title)
Set the title of a browser window.
Definition: window.c:3579
static void ro_gui_window_action_home(struct gui_window *g)
Perform a Navigate Home action on a browser window.
Definition: window.c:643
nserror ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect)
Cause an area of a window to be invalidated.
Definition: window.c:4371
void ro_gui_window_update_boxes(void)
Redraw any pending update boxes.
Definition: window.c:4699
#define SCROLL_BOTTOM
Definition: window.c:111
bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
Convert x,y screen co-ordinates into window co-ordinates.
Definition: window.c:4855
static void ro_gui_window_clone_options(struct gui_window *new_gui, struct gui_window *old_gui)
Clones a browser window's options.
Definition: window.c:3228
static void riscos_window_set_status(struct gui_window *g, const char *text)
Set the status bar of a browser window.
Definition: window.c:3773
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
Handle Message_DataLoad (file dragged in) for a toolbar.
Definition: window.c:4657
static bool ro_gui_window_content_export_types(struct hlcache_handle *h, bool *export_draw, bool *export_sprite)
Return boolean flags to show what RISC OS types we can sensibly convert the given object into.
Definition: window.c:2144
static void ro_gui_window_prepare_pageinfo(struct gui_window *g)
Prepare the page info window for use.
Definition: window.c:745
struct gui_window * ro_gui_current_redraw_gui
GUI window which is being redrawn.
Definition: window.c:124
static void ro_gui_window_action_page_info(struct gui_window *g)
Open a page info box for a browser window.
Definition: window.c:800
static void ro_gui_window_action_add_bookmark(struct gui_window *g)
Add a hotlist entry for a browser window.
Definition: window.c:583
browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type)
Returns the state of the mouse buttons and modifiers keys whilst dragging, for passing to the OS-inde...
Definition: window.c:4995
#define SCROLL_VISIBLE_PADDING
Definition: window.c:106
static bool iconise_used[64]
Remembers which iconised sprite numbers are in use.
Definition: window.c:114
bool ro_gui_ctrl_pressed(void)
Returns true iff one or more Ctrl keys is held down.
Definition: window.c:5033
static void ro_gui_window_scroll(wimp_scroll *scroll)
Process Scroll_Request events in a browser window.
Definition: window.c:1755
struct ro_gui_pointer_entry ro_gui_pointer_table[]
Map from gui_pointer_shape to pointer sprite data.
Definition: window.c:154
static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
Completes scrolling of a browser window.
Definition: window.c:3882
static void gui_window_stop_throbber(struct gui_window *g)
Update the interface to reflect page loading stopped.
Definition: window.c:3801
static nsurl * current_menu_url
URL of link under menu, or 0 if no link.
Definition: window.c:136
static bool gui_window_scroll_start(struct gui_window *g)
Starts drag scrolling of a browser window.
Definition: window.c:3927
static void gui_window_set_extent(struct gui_window *g, int width, int height)
Updates a windows extent.
Definition: window.c:225
#define SCROLL_PAGE_UP
Definition: window.c:109
static void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handle submenu warnings for a browser window menu.
Definition: window.c:3005
void ro_gui_window_redraw_all(void)
Redraws the content for all windows.
Definition: window.c:4690
static bool ro_gui_window_keypress(wimp_key *key)
Process Key_Pressed events in a browser window.
Definition: window.c:1845
static void ro_gui_window_action_search(struct gui_window *g)
Open a text search dialogue for a browser window.
Definition: window.c:678
static wimp_menu * gui_form_select_menu
Menu of options for form select controls.
Definition: window.c:130
bool ro_gui_window_check_menu(wimp_menu *menu)
Check if a particular menu handle is a browser window menu.
Definition: window.c:4683
struct gui_window_table * riscos_window_table
Definition: window.c:4258
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip)
Place the caret in a browser window.
Definition: window.c:200
static bool ro_gui_window_click(wimp_pointer *pointer)
Handle Mouse_Click events in a browser window.
Definition: window.c:1975
static void ro_gui_window_action_local_history(struct gui_window *gw)
Open a local history pane for a browser window.
Definition: window.c:622
static void ro_gui_window_close(wimp_w w)
Handle wimp closing event.
Definition: window.c:1575
bool ro_gui_alt_pressed(void)
Returns true iff one or more Alt keys is held down.
Definition: window.c:5042
static void ro_gui_window_action_print(struct gui_window *g)
Open a print dialogue for a browser window.
Definition: window.c:731
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
Get the scroll position of a browser window.
Definition: window.c:3614
static void ro_gui_window_update_toolbar_buttons(struct gui_window *g)
Update the toolbar buttons for a given browser window to reflect the current state of its contents.
Definition: window.c:536
static wimp_menu * ro_gui_browser_window_menu
The browser window menu handle.
Definition: window.c:128
static int iconise_next
Definition: window.c:115
static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
Set the scroll position of a riscos browser window.
Definition: window.c:3651
static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
set favicon
Definition: window.c:3828
static void ro_gui_window_update_toolbar(void *data)
Update a window to reflect a change in toolbar size: used as a callback by the toolbar module when a ...
Definition: window.c:517
static void ro_gui_window_action_new_window(struct gui_window *g)
Open a new browser window.
Definition: window.c:1025
void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
Window is being iconised.
Definition: window.c:4531
static void gui_window_new_content(struct gui_window *g)
Called when the gui_window has new content.
Definition: window.c:3867
static bool mouse_drag_select
Whether a pressed mouse button has become a drag.
Definition: window.c:118
#define MARGIN
Definition: window.c:187
void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
Handle pointer movements in a browser window.
Definition: window.c:4513
struct gui_window * ro_gui_window_lookup(wimp_w window)
Convert a RISC OS window handle to a gui_window.
Definition: window.c:4823
#define SCROLL_PAGE_DOWN
Definition: window.c:110
static void ro_gui_window_toolbar_click(void *data, toolbar_action_type action_type, union toolbar_action action)
Process Mouse_Click events in a toolbar's button bar.
Definition: window.c:822
static void ro_gui_window_remove_update_boxes(struct gui_window *g)
Remove all pending update boxes for a window.
Definition: window.c:3512
static void ro_gui_window_save_toolbar_buttons(void *data, char *config)
Save a new toolbar button configuration.
Definition: window.c:1550
static void ro_gui_window_redraw(wimp_draw *redraw)
Handle a Redraw_Window_Request for a browser window.
Definition: window.c:1700
static bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
Prepare the browser window menu for (re-)opening.
Definition: window.c:2195
struct update_box * pending_updates
Definition: window.c:186
static struct hlcache_handle * current_menu_main
Main content object under menu, or 0 if none.
Definition: window.c:132
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
Handle Message_DataLoad (file dragged in) for a window.
Definition: window.c:4481
static void ro_gui_window_launch_url(struct gui_window *g, const char *url_s)
Launch a new url in the given window.
Definition: window.c:995
static void ro_gui_window_action_zoom(struct gui_window *g)
Open a zoom dialogue for a browser window.
Definition: window.c:693
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect)
Platform-dependent part of starting drag operation.
Definition: window.c:3991
static bool ro_gui_window_prepare_form_select_menu(struct gui_window *g, struct form_control *control)
Prepare or reprepare a form select menu.
Definition: window.c:2016
static bool handle_local_keypress_scale(struct gui_window *gw, uint32_t c)
handle scale kepresses within RISC OS
Definition: window.c:1226
static void ro_gui_window_open(wimp_open *open)
Open a window.
Definition: window.c:290
#define SCROLL_TOP
Definition: window.c:108
static void gui_window_create_form_select_menu(struct gui_window *g, struct form_control *control)
Display a menu of options for a form select control.
Definition: window.c:4071
void ro_gui_window_quit(void)
Destroy all browser windows.
Definition: window.c:4766
#define wimp_WINDOW_GIVE_SHADED_ICON_INFO
Definition: window.c:103
static bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key, bool is_toolbar)
Handle keypresses within the RISC OS GUI.
Definition: window.c:1283
static void ro_gui_window_action_remove_bookmark(struct gui_window *g)
Remove a hotlist entry for a browser window.
Definition: window.c:603
static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
Handle the closure of a browser window menu.
Definition: window.c:3210
static struct hlcache_handle * current_menu_object
Object under menu, or 0 if no object.
Definition: window.c:134
nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
Set the contents of a window's address bar.
Definition: window.c:4450
#define SCALE_SNAP_TO_SIZE
Definition: window.c:141
void ro_gui_window_default_options(struct gui_window *gui)
Makes a browser window's options the default.
Definition: window.c:4792
void ro_gui_window_initialise(void)
Initialise the browser window module and its menus.
Definition: window.c:4262
void ro_gui_drag_save_link(gui_save_type save_type, const nsurl *url, const char *title, struct gui_window *g)
Initiates drag saving of a link/URL file.
Definition: save.c:1234
void ro_gui_save_prepare(gui_save_type save_type, struct hlcache_handle *h, char *s, const nsurl *url, const char *title)
Prepares the save box to reflect gui_save_type and a content, and opens it.
Definition: save.c:437
core web search facilities interface.
@ SEARCH_WEB_OMNI_NONE
no changes to default operation
Definition: searchweb.h:50
byte sprite_bpp(const osspriteop_header *s)
Returns the bit depth of a sprite.
Definition: sprite.c:249
Content for image/x-riscos-sprite (RISC OS interface).
unsigned int ro_gui_status_bar_get_width(struct status_bar *sb)
Get the proportional width the status bar is currently using.
Definition: status_bar.c:202
void ro_gui_status_bar_resize(struct status_bar *sb)
Resize a status bar following a change in the dimensions of the parent window.
Definition: status_bar.c:346
void ro_gui_status_bar_set_text(struct status_bar *sb, const char *text)
Set the text to display in the status bar.
Definition: status_bar.c:316
struct status_bar * ro_gui_status_bar_create(wimp_w parent, unsigned int width)
Create a new status bar.
Definition: status_bar.c:118
void ro_gui_status_bar_destroy(struct status_bar *sb)
Destroy a status bar and free all associated resources.
Definition: status_bar.c:161
UTF8 status bar (interface).
Interface to utility string handling.
char * cnv_space2nbsp(const char *s)
Converts NUL terminated UTF-8 encoded string s containing zero or more spaces (char 32) or TABs (char...
Definition: utils.c:67
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
Page features at a specific spatial location.
struct hlcache_handle * object
Object at position or NULL.
struct hlcache_handle * main
handle of top level content.
struct nsurl * link
URL of a link or NULL.
Browser window data.
int x
Window dimensions.
struct browser_window * bw
char * text
Definition: widget.h:182
struct fbtk_widget_s * next
Definition: widget.h:121
Form control.
Definition: form_internal.h:73
Option in a select.
Definition: form.h:33
bool selected
Definition: form.h:35
char * text
NUL terminated.
Definition: form.h:38
Graphical user interface window function table.
Definition: window.h:137
struct gui_window *(* create)(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Create and open a gui window for a browsing context.
Definition: window.h:164
first entry in window list
Definition: gui.c:297
struct gui_window * prev
Previous in linked list.
Definition: gui.h:159
int old_width
Width when last opened / os units.
Definition: gui.h:86
GtkLabel * status_bar
statusbar
Definition: window.c:125
struct fbtk_widget_s * toolbar
Definition: gui.h:46
bool update_extent
Update the extent on next opening.
Definition: gui.h:88
struct gui_window * next
list for cleanup
Definition: gui.h:159
int state
Definition: window.cpp:73
bool active
Whether the throbber should be active.
Definition: gui.h:89
struct gui_window * gui
Definition: window.c:89
char * url
Definition: gui.h:154
bool buffer_animations
Use screen buffering for animations.
Definition: gui.h:99
struct fbtk_widget_s * window
Definition: gui.h:33
RECT redraw
Area needing redraw.
Definition: window.h:70
bool buffer_everything
Use screen buffering for everything.
Definition: gui.h:100
float scale
Definition: gui.h:155
int old_height
Height when last opened / os units.
Definition: gui.h:87
struct gui_window::@47 option
Options.
int iconise_icon
ID number of icon when window is iconised.
Definition: gui.h:93
char * title
Definition: gui.h:153
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Definition: gui.c:315
High-level cache handle.
Definition: hlcache.c:66
Definition: menus.h:159
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
An entry in ro_gui_pointer_table.
Definition: window.c:144
char sprite_name[16]
The pointer is in the Wimp's sprite area.
Definition: window.c:146
int xactive
Definition: window.c:147
bool wimp_area
Definition: window.c:145
int yactive
Definition: window.c:148
struct button_bar * buttons
Details for the button bar.
Definition: toolbar.c:96
struct url_bar * url
Details for the URL bar.
Definition: toolbar.c:101
bool use_buffer
Definition: window.c:181
int x1
Definition: window.c:179
struct update_box * next
Definition: window.c:183
int x0
Definition: window.c:177
int y1
Definition: window.c:180
int y0
Definition: window.c:178
struct gui_window * g
Definition: window.c:182
void talloc_report_full(const void *ptr, FILE *f)
Definition: talloc.c:1017
Interface to time operations.
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
Union to hold the different widget action data that can be passed from widget via toolbar to client.
Definition: toolbar.h:54
url_bar_action url
Definition: toolbar.h:56
button_bar_action button
Definition: toolbar.h:55
@ TOOLBAR_URL_DRAG_FAVICON
Definition: url_bar.h:36
@ TOOLBAR_URL_ADJUST_PGINFO
Definition: url_bar.h:40
@ TOOLBAR_URL_SELECT_PGINFO
Definition: url_bar.h:39
@ TOOLBAR_URL_DRAG_URL
Definition: url_bar.h:35
@ TOOLBAR_URL_SELECT_HOTLIST
Definition: url_bar.h:37
@ TOOLBAR_URL_ADJUST_HOTLIST
Definition: url_bar.h:38
void ro_gui_url_complete_start(struct toolbar *toolbar)
Should be called when the caret is placed into a URL completion icon.
Definition: url_complete.c:76
bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
Handles a keypress for URL completion.
Definition: url_complete.c:100
void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
Move and resize the url completion window to match the toolbar.
Definition: url_complete.c:398
bool ro_gui_url_complete_close(void)
Try to close the current url completion window.
Definition: url_complete.c:497
Central repository for URL data (interface).
Unified URL information database public interface.
void urldb_dump(void)
Dump URL database to stderr.
Definition: urldb.c:4481
URL Suggestion Menu (interface).
nserror netsurf_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl.
Definition: file.c:301
Default operations table for files.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:331
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:313
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
Definition: nsoption.h:348
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
Definition: nsoption.h:344
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Definition: nsoption.h:372
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:304
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
Definition: utf8.c:129
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
#define ABS(x)
Definition: utils.h:36
#define min(x, y)
Definition: utils.h:46
#define max(x, y)
Definition: utils.h:50
os_error * ro_gui_wimp_get_sprite(const char *name, osspriteop_header **sprite)
Locate a sprite in the Wimp sprite pool, returning a pointer to it.
Definition: wimp.c:896
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
Set the contents of a text or sprite icon to a string.
Definition: wimp.c:269
int ro_get_hscroll_height(wimp_w w)
Gets the horizontal scrollbar height.
Definition: wimp.c:58
void ro_gui_set_window_title(wimp_w w, const char *text)
Set a window title.
Definition: wimp.c:675
int ro_get_title_height(wimp_w w)
Gets the title bar height.
Definition: wimp.c:82
bool ro_gui_wimp_sprite_exists(const char *sprite)
Check if a sprite is present in the Wimp sprite pool.
Definition: wimp.c:862
int ro_get_vscroll_width(wimp_w w)
Gets the vertical scrollbar width.
Definition: wimp.c:70
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_keypress(wimp_w w, bool(*callback)(wimp_key *key))
Register a function to be called for all keypresses within a particular window.
Definition: wimp_event.c:1461
bool ro_gui_wimp_event_register_redraw_window(wimp_w w, void(*callback)(wimp_draw *redraw))
Register a function to be called for all window redraw operations.
Definition: wimp_event.c:1507
void ro_gui_wimp_event_finalise(wimp_w w)
Free any resources associated with a window.
Definition: wimp_event.c:296
void * ro_gui_wimp_event_get_user_data(wimp_w w)
Gets the user data associated with a window.
Definition: wimp_event.c:486
bool ro_gui_wimp_event_register_menu_selection(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a))
Register a function to be called following a menu selection.
Definition: wimp_event.c:1581
bool ro_gui_wimp_event_register_mouse_click(wimp_w w, bool(*callback)(wimp_pointer *pointer))
Register a function to be called for all mouse-clicks to icons in a window that don't have registered...
Definition: wimp_event.c:1439
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_pointer *p))
Register a function to be called before a menu is (re-)opened.
Definition: wimp_event.c:1559
bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user)
Sets the user data associated with a window.
Definition: wimp_event.c:467
bool ro_gui_wimp_event_register_menu_close(wimp_w w, void(*callback)(wimp_w w, wimp_i i, wimp_menu *m))
Register a function to be called before a menu is finally closed.
Definition: wimp_event.c:1624
bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w, void(*callback)(wimp_entering *entering))
Register a function to be called for all pointer entering window requests.
Definition: wimp_event.c:1539
bool ro_gui_wimp_event_register_close_window(wimp_w w, void(*callback)(wimp_w w))
Register a function to be called after the window has been closed.
Definition: wimp_event.c:1492
bool ro_gui_wimp_event_register_scroll_window(wimp_w w, void(*callback)(wimp_scroll *scroll))
Register a function to be called for all window scroll requests.
Definition: wimp_event.c:1523
bool ro_gui_wimp_event_register_open_window(wimp_w w, void(*callback)(wimp_open *open))
Register a function to be called for all window opening requests.
Definition: wimp_event.c:1477
bool ro_gui_wimp_event_register_menu_warning(wimp_w w, void(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a))
Register a function to be called when a sub-menu warning is received.
Definition: wimp_event.c:1603
bool ro_gui_wimp_event_register_menu(wimp_w w, wimp_menu *m, bool menu_auto, bool position_ibar)
Register a window menu to be (semi-)automatically handled.
Definition: wimp_event.c:1270
Automated RISC OS WIMP event handling (interface).
#define IS_WIMP_KEY
Definition: wimp_event.h:37
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_WIMP_OPEN(pstate)
Definition: wimputils.h:39
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plot.c:857
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357