NetSurf
toolbar.c
Go to the documentation of this file.
1/*
2 * Copyright 2004, 2005 Richard Wilson <info@tinct.net>
3 * Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
4 *
5 * This file is part of NetSurf, http://www.netsurf-browser.org/
6 *
7 * NetSurf is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * NetSurf is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/** \file
21 * Window toolbars (implementation).
22 */
23
24#include <alloca.h>
25#include <assert.h>
26#include <stdio.h>
27#include <stdbool.h>
28#include <string.h>
29#include "oslib/dragasprite.h"
30#include "oslib/os.h"
31#include "oslib/osgbpb.h"
32#include "oslib/osfile.h"
33#include "oslib/osfind.h"
34#include "oslib/osspriteop.h"
35#include "oslib/wimpspriteop.h"
36#include "oslib/squash.h"
37#include "oslib/wimp.h"
38#include "oslib/wimpextend.h"
39#include "oslib/wimpspriteop.h"
40
41#include "utils/log.h"
42#include "utils/nsoption.h"
43
44#include "riscos/cookies.h"
45#include "riscos/dialog.h"
47#include "riscos/gui.h"
49#include "riscos/gui/throbber.h"
50#include "riscos/gui/url_bar.h"
51#include "riscos/hotlist.h"
52#include "riscos/menus.h"
53#include "riscos/save.h"
54#include "riscos/theme.h"
55#include "riscos/toolbar.h"
56#include "riscos/url_complete.h"
57#include "riscos/wimp.h"
58#include "riscos/wimp_event.h"
59#include "riscos/wimputils.h"
60#include "riscos/window.h"
61
62
63#define TOOLBAR_WIDGET_GUTTER 8
64#define TOOLBAR_DEFAULT_WIDTH 16384
65
66/* Toolbar rows used to index into the arrays of row-specific data.
67 */
68
69#define TOOLBAR_ROW_TOP 0
70#define TOOLBAR_ROW_DIV1 1
71#define TOOLBAR_ROW_EDIT 2
72#define TOOLBAR_MAX_ROWS 3
73
74/* The toolbar data structure.
75 */
76
77struct toolbar {
78 /** Bar details. */
82
86
87 /** Toolbar and parent window handles. */
90
91 /** Row locations and sizes. */
94
95 /** Details for the button bar. */
98 os_coord buttons_size;
99
100 /** Details for the URL bar. */
101 struct url_bar *url;
103 os_coord url_size;
104
105 /** Details for the throbber. */
110
111 /** Client callback data. */
114
115 /** Details for the toolbar editor. */
118 os_coord editor_size;
119
121
122 /** Interactive help data. */
123
124 const char *help_prefix;
125
126 /** The next bar in the toolbar list. */
127 struct toolbar *next;
128};
129
130
131/* Global variables for the toolbar module.
132 */
133
134/** The list of defined toolbars. */
135static struct toolbar *ro_toolbar_bars = NULL;
136
137/** The Toolber Menu */
138wimp_menu *toolbar_menu;
139
140
141/* A basic window definition for the toolbar and status bar.
142 */
143
144static wimp_window ro_toolbar_window = {
145 {0, 0, 1, 1},
146 0,
147 0,
148 wimp_TOP,
149 wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_MOVEABLE | wimp_WINDOW_NO_BOUNDS |
150 wimp_WINDOW_FURNITURE_WINDOW |
151 wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT,
152 wimp_COLOUR_BLACK,
153 wimp_COLOUR_LIGHT_GREY,
154 wimp_COLOUR_LIGHT_GREY,
155 wimp_COLOUR_VERY_LIGHT_GREY,
156 wimp_COLOUR_DARK_GREY,
157 wimp_COLOUR_MID_LIGHT_GREY,
158 wimp_COLOUR_CREAM,
159 wimp_WINDOW_NEVER3D | 0x16u /* RISC OS 5.03+ */,
160 {0, 0, TOOLBAR_DEFAULT_WIDTH, 16384},
161 0,
162 wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT,
163 wimpspriteop_AREA,
164 1,
165 1,
166 {""},
167 0,
168 { }
169};
170
171static char ro_toolbar_null_string[] = "";
172static char ro_toolbar_line_validation[] = "R2";
173
174/*
175 * Private function prototypes.
176 */
177
180static void ro_toolbar_reformat_widgets(struct toolbar *toolbar);
181
182static void ro_toolbar_redraw(wimp_draw *redraw);
183static bool ro_toolbar_click(wimp_pointer *pointer);
184static bool ro_toolbar_keypress(wimp_key *key);
185static bool ro_toolbar_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
186 wimp_pointer *pointer);
187static void ro_toolbar_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
188 wimp_selection *selection, menu_action action);
189static bool ro_toolbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
190 wimp_selection *selection, menu_action action);
191static const char *ro_toolbar_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos,
192 wimp_mouse_state buttons);
193
194static void ro_toolbar_update_buttons(struct toolbar *toolbar);
195
196
197/* This is an exported interface documented in toolbar.h */
198
200{
201 /* browser toolbar menu */
202 static const struct ns_menu toolbar_definition = {
203 "Toolbar", {
204 { "Toolbars", NO_ACTION, 0 },
205 { "Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
206 { "Toolbars.ToolAddress", TOOLBAR_ADDRESS_BAR, 0 },
207 { "Toolbars.ToolThrob", TOOLBAR_THROBBER, 0 },
208 { "EditToolbar", TOOLBAR_EDIT, 0 },
209 {NULL, 0, 0}
210 }
211 };
213 &toolbar_definition);
214}
215
216
217/* This is an exported interface documented in toolbar.h */
218
219struct toolbar *ro_toolbar_create(struct theme_descriptor *descriptor,
220 wimp_w parent, theme_style style, toolbar_flags bar_flags,
221 const struct toolbar_callbacks *callbacks, void *client_data,
222 const char *help)
223{
224 struct toolbar *toolbar;
225
226 /* Allocate memory for the bar and link it into the list of bars. */
227
228 toolbar = calloc(sizeof(struct toolbar), 1);
229 if (toolbar == NULL) {
230 NSLOG(netsurf, INFO, "No memory for malloc()");
231 ro_warn_user("NoMemory", 0);
232 return NULL;
233 }
234
237
238 /* Store the supplied settings. */
239
240 toolbar->flags = bar_flags;
241 toolbar->theme = descriptor;
246
247 /* Set up the internal widgets: initially, there are none. */
248
249 toolbar->buttons = NULL;
250 toolbar->buttons_display = false;
251
252 toolbar->url = NULL;
253 toolbar->url_display = false;
254
255 toolbar->throbber = NULL;
256 toolbar->throbber_display = false;
257
258 /* Set up the bar editor. */
259
260 toolbar->editor = NULL;
261 toolbar->editor_div1 = -1;
262
263 toolbar->editing = false;
264
265 toolbar->help_prefix = help;
266
267 return toolbar;
268}
269
270
271/* This is an exported interface documented in toolbar.h */
272
274 const struct button_bar_buttons buttons[], char *button_order)
275{
276 if (toolbar == NULL)
277 return false;
278
279 if (toolbar->buttons != NULL)
280 return false;
281
283 if (toolbar->buttons != NULL) {
284 toolbar->buttons_display = true;
286 button_order);
287 }
288
290 if (toolbar->editor != NULL)
292
293 if (toolbar->buttons != NULL && toolbar->editor != NULL)
296 (void (*)(void *))
298 toolbar))
299 return false;
300
301 return (toolbar->buttons == NULL || toolbar->editor == NULL) ?
302 false : true;
303}
304
305
306/* This is an exported interface documented in toolbar.h */
307
309{
310 if (toolbar == NULL)
311 return false;
312
313 if (toolbar->throbber != NULL)
314 return false;
315
317
318 if (toolbar->throbber != NULL)
320
321 return (toolbar->throbber == NULL) ? false : true;
322}
323
324
325/* This is an exported interface documented in toolbar.h */
326
328{
329 if (toolbar == NULL)
330 return false;
331
332 if (toolbar->url != NULL)
333 return false;
334
336
337 if (toolbar->url != NULL)
338 toolbar->url_display = true;
339
340 return (toolbar->url == NULL) ? false : true;
341}
342
343
344/* This is an exported interface documented in toolbar.h */
345
347{
348 os_error *error;
349 wimp_icon_create icon;
350 wimp_w old_window = NULL;
351
352 if (toolbar == NULL)
353 return false;
354
355 /* Start to set up the toolbar window. */
356
357 ro_toolbar_window.sprite_area =
359 ro_toolbar_window.work_bg =
362
363 /* Delete any existing toolbar window... */
364
365 if (toolbar->toolbar_handle != NULL) {
366 old_window = toolbar->toolbar_handle;
367 error = xwimp_delete_window(toolbar->toolbar_handle);
368 if (error)
369 NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
370 error->errnum, error->errmess);
371 toolbar->toolbar_handle = NULL;
372 }
373
374 /* ...and create a new window. */
375
376 error = xwimp_create_window(&ro_toolbar_window,
378 if (error) {
379 NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
380 error->errnum, error->errmess);
381 ro_warn_user("WimpError", error->errmess);
382 return false;
383 }
384
385 /* Set up the toolbar's event handlers. Only set the user activity-
386 * related callbacks if the bar isn't for display purposes. If the
387 * toolbar is being recreated, simply transfer the handlers across
388 * from the old, now-deleted window.
389 */
390
391 if (old_window == NULL) {
395 toolbar);
396
414 toolbar_menu, true, false);
418 }
419 } else {
421 }
422
423 /* The help prefix changes from edit to non-edit mode. */
424
426 (toolbar->editing) ?
427 "HelpEditToolbar" : toolbar->help_prefix);
428
429 /* Place the widgets into the new bar, using the new theme.
430 *
431 * \TODO -- If any widgets fail to rebuild, then we currently just
432 * carry on without them. Not sure if the whole bar
433 * rebuild should fail here?
434 */
435
436 if (toolbar->throbber != NULL) {
439 toolbar->editing)) {
441 toolbar->throbber = NULL;
442 }
443
445 &toolbar->throbber_right, NULL);
446 }
447
448 if (toolbar->buttons != NULL) {
451 toolbar->editing)) {
453 toolbar->buttons = NULL;
454 }
455 }
456
457 if (toolbar->editor != NULL) {
460 toolbar->editing)) {
462 toolbar->editor = NULL;
463 }
464 }
465
466 if (toolbar->url != NULL) {
470 toolbar->editing)) {
472 toolbar->url = NULL;
473 }
474 }
475
476 /* If this is an editor, add in a divider icon and the editor
477 * button bar.
478 */
479
480 if (toolbar->editing) {
481 icon.w = toolbar->toolbar_handle;
482 icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
483 wimp_ICON_VCENTRED | wimp_ICON_BORDER |
484 (wimp_COLOUR_BLACK <<
485 wimp_ICON_FG_COLOUR_SHIFT) |
486 (wimp_COLOUR_VERY_LIGHT_GREY <<
487 wimp_ICON_BG_COLOUR_SHIFT);
488 icon.icon.extent.x0 = 0;
489 icon.icon.extent.x1 = 0;
490 icon.icon.extent.y1 = 0;
491 icon.icon.extent.y0 = 0;
492 icon.icon.data.indirected_text.text = ro_toolbar_null_string;
493 icon.icon.data.indirected_text.validation =
495 icon.icon.data.indirected_text.size = 1;
496 error = xwimp_create_icon(&icon, &toolbar->editor_div1);
497 if (error) {
498 NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
499 error->errnum, error->errmess);
500 ro_warn_user("WimpError", error->errmess);
501 toolbar->editor_div1 = -1;
502 }
503 }
504
505 /* Establish the required dimensions to fit the widgets, then
506 * reflow the bar contents.
507 */
508
510
511 ro_toolbar_process(toolbar, -1, true);
512
513 if (toolbar->parent_handle != NULL)
515
517
518 return true;
519}
520
521
522/* This is an exported interface documented in toolbar.h */
523
525{
526 wimp_outline outline;
527 wimp_window_state state;
528 os_error *error;
529
530 if (toolbar == NULL || toolbar->toolbar_handle == NULL)
531 return false;
532
534
535 /* Only try to attach the toolbar if there's any of it visible to
536 * matter.
537 */
538
539 if (toolbar->current_height > 0) {
540 outline.w = parent;
541 xwimp_get_window_outline(&outline);
542 state.w = parent;
543 xwimp_get_window_state(&state);
544 state.w = toolbar->toolbar_handle;
545 state.visible.x1 = outline.outline.x1 - 2;
546 state.visible.y0 = state.visible.y1 + 2 -
548 state.xscroll = 0;
549 state.yscroll = 0;
550 error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), parent,
551 wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
552 << wimp_CHILD_XORIGIN_SHIFT |
553 wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
554 << wimp_CHILD_YORIGIN_SHIFT |
555 wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
556 << wimp_CHILD_LS_EDGE_SHIFT |
557 wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
558 << wimp_CHILD_BS_EDGE_SHIFT |
559 wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
560 << wimp_CHILD_RS_EDGE_SHIFT |
561 wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
562 << wimp_CHILD_TS_EDGE_SHIFT);
563 if (error) {
564 NSLOG(netsurf, INFO,
565 "xwimp_open_window_nested: 0x%x: %s",
566 error->errnum,
567 error->errmess);
568 ro_warn_user("WimpError", error->errmess);
569 return false;
570 }
571
572 return true;
573 }
574
575 error = xwimp_close_window(toolbar->toolbar_handle);
576 if (error) {
577 NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
578 error->errnum, error->errmess);
579 ro_warn_user("WimpError", error->errmess);
580 return false;
581 }
582 return true;
583}
584
585
586/* This is an exported interface documented in toolbar.h */
587
588bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat)
589{
590 os_error *error;
591 wimp_outline outline;
592 wimp_window_state state;
593 os_box extent;
594 int old_height, old_width;
595
596 if (!toolbar)
597 return false;
598
599 old_height = toolbar->current_height;
600 old_width = toolbar->current_width;
601
602 /* Measure the parent window width if the caller has asked us to
603 * calculate the clip width ourselves. Otherwise, if a clip width
604 * has been specified, set the clip to that.
605 */
606
607 if ((toolbar->parent_handle != NULL) && (width == -1)) {
608 outline.w = toolbar->parent_handle;
609 error = xwimp_get_window_outline(&outline);
610 if (error) {
611 NSLOG(netsurf, INFO,
612 "xwimp_get_window_outline: 0x%x: %s",
613 error->errnum,
614 error->errmess);
615 ro_warn_user("WimpError", error->errmess);
616 return false;
617 }
618
619 toolbar->clip_width = outline.outline.x1 -
620 outline.outline.x0 - 2;
622 } else if (width != -1) {
625 }
626
627 /* Find the parent visible height to clip our toolbar height to
628 */
629
630 if (toolbar->parent_handle != NULL) {
631 state.w = toolbar->parent_handle;
632 error = xwimp_get_window_state(&state);
633 if (error) {
634 NSLOG(netsurf, INFO,
635 "xwimp_get_window_state: 0x%x: %s",
636 error->errnum,
637 error->errmess);
638 ro_warn_user("WimpError", error->errmess);
639 return false;
640 }
641
642 toolbar->clip_height = state.visible.y1 - state.visible.y0 + 2;
643
644 /* We can't obscure the height of the scroll bar as we
645 * lose the resize icon if we do.
646 */
647
650 else
652
653 /* Resize the work area extent and update our position. */
654
655 if (old_height != toolbar->current_height) {
656 extent.x0 = 0;
657 extent.y0 = 0;
658 extent.x1 = TOOLBAR_DEFAULT_WIDTH;
659 extent.y1 = toolbar->current_height - 2;
660 error = xwimp_set_extent(toolbar->toolbar_handle,
661 &extent);
662 if (error) {
663 NSLOG(netsurf, INFO,
664 "xwimp_get_window_state: 0x%x: %s",
665 error->errnum,
666 error->errmess);
667 ro_warn_user("WimpError", error->errmess);
668 }
669
671 }
672 } else {
675 }
676
677 /* Reflow the widgets into the toolbar if the dimensions have
678 * changed or we have been asked to anyway. */
679
680 if (toolbar->current_width != old_width || reformat)
682
683 return true;
684}
685
686
687/**
688 * Update the widgets currently on view in a toolbar. This can be used
689 * generally, but is primarily offered to widgets as a way for them
690 * to force an update.
691 *
692 * \param *toolbar The toolbar to update.
693 */
694
696{
697 int old_height;
698
699 if (toolbar == NULL)
700 return;
701
702 old_height = toolbar->full_height;
703
706
707 /* If the toolbar height has changed, we need to tell the client. */
708
709 if (toolbar->full_height != old_height)
711}
712
713
714/**
715 * Get the minimum dimenstions required by the toolbar widgets after
716 * these have changed. The minimum dimensions are assumed not to change
717 * unless we change theme (ie. we rebuild the bar) or we knowingly
718 * alter a widget (eg. we add or remove button-bar buttons).
719 *
720 *
721 * \param *toolbar The toolbar to refresh.
722 */
723
725{
726 int width, height;
727 int row_width, row_height;
728
729 if (toolbar == NULL)
730 return;
731
732 /* Process the toolbar editor and any associated divider rows.
733 */
734
735 if (toolbar->editor != NULL && toolbar->editing) {
736 width = 0;
737 height = 0;
739
742
745 + height;
746
751 } else {
752 toolbar->editor_size.x = 0;
753 toolbar->editor_size.y = 0;
754
759 }
760
761 /* Process the top row icons. */
762
763 row_width = 0;
764 row_height = 0;
765
766 /* If the editor is active, any button bar if forced into view. */
767
768 if (toolbar->buttons != NULL &&
770 width = 0;
771 height = 0;
773
774 row_width += width;
777
778 if (height > row_height)
779 row_height = height;
780 } else {
781 toolbar->buttons_size.x = 0;
782 toolbar->buttons_size.y = 0;
783 }
784
785 if (toolbar->url != NULL && toolbar->url_display) {
786 width = 0;
787 height = 0;
789
790 if (row_width > 0)
791 row_width += TOOLBAR_WIDGET_GUTTER;
792 row_width += width;
793
796
797 if (height > row_height)
798 row_height = height;
799 } else {
800 toolbar->url_size.x = 0;
801 toolbar->url_size.y = 0;
802 }
803
804 if (toolbar->throbber != NULL && toolbar->throbber_display) {
805 width = 0;
806 height = 0;
808
809 if (row_width > 0)
810 row_width += TOOLBAR_WIDGET_GUTTER;
811 row_width += width;
812
815
816 if (height > row_height)
817 row_height = height;
818 } else {
819 toolbar->throbber_size.x = 0;
820 toolbar->throbber_size.y = 0;
821 }
822
823 if (row_height > 0) {
826 toolbar->row_y1[TOOLBAR_ROW_TOP] = row_height +
828 } else {
831 }
832
833 /* Establish the full dimensions of the bar.
834 *
835 * \TODO -- This currently assumes an "all or nothing" approach to
836 * the editor bar, and will need reworking once we have to
837 * worry about tab bars.
838 */
839
840 if (toolbar->row_y1[TOOLBAR_ROW_TOP] > 0) {
843 } else {
844 toolbar->full_height = 0;
845 }
847 ((row_width > toolbar->editor_size.x) ?
848 row_width : toolbar->editor_size.x);
849}
850
851
852/**
853 * Reformat (reflow) the widgets into the toolbar, based on the toolbar size
854 * and the previously calculated widget dimensions.
855 *
856 * \param *toolbar The toolbar to reformat.
857 */
858
860{
861 int left_margin, right_margin;
862
863 left_margin = TOOLBAR_WIDGET_GUTTER;
864 right_margin = toolbar->clip_width - TOOLBAR_WIDGET_GUTTER;
865
866 /* Flow the toolbar editor row, which will be a fixed with and
867 * may alter the right margin.
868 */
869
870 if (toolbar->editor != NULL && toolbar->editing) {
871 if (right_margin < left_margin + toolbar->editor_size.x)
872 right_margin = left_margin + toolbar->editor_size.x;
873
875 left_margin,
877 left_margin + toolbar->editor_size.x,
879
880 if (toolbar->editor_div1 != -1)
881 xwimp_resize_icon(toolbar->toolbar_handle,
882 toolbar->editor_div1, -8,
884 toolbar->clip_width + 8,
886 }
887
888 /* Flow the top row. */
889
890 if (toolbar->throbber != NULL && toolbar->throbber_display) {
891 if (toolbar->throbber_right) {
892 right_margin -= (toolbar->throbber_size.x +
894 } else {
896 left_margin,
898 left_margin + toolbar->throbber_size.x,
900 left_margin += (toolbar->throbber_size.x +
902 }
903 }
904
905 if (toolbar->buttons != NULL &&
907 if (right_margin < left_margin + toolbar->buttons_size.x)
908 right_margin = left_margin + toolbar->buttons_size.x;
909
911 left_margin,
913 left_margin + toolbar->buttons_size.x,
915 left_margin += (toolbar->buttons_size.x +
917 }
918
919 if (toolbar->url != NULL && toolbar->url_display) {
920 if (right_margin < left_margin + toolbar->url_size.x)
921 right_margin = left_margin + toolbar->url_size.x;
922
924 left_margin,
926 right_margin,
928
929 left_margin = right_margin + TOOLBAR_WIDGET_GUTTER;
930 }
931
932 if (toolbar->throbber != NULL && toolbar->throbber_display &&
934 left_margin = right_margin + TOOLBAR_WIDGET_GUTTER;
936 left_margin,
938 left_margin + toolbar->throbber_size.x,
940 }
941
942}
943
944
945/* This is an exported interface documented in toolbar.h */
946
948{
949 struct toolbar *bar;
950
951 if (toolbar == NULL)
952 return;
953
954 NSLOG(netsurf, INFO, "Destroying toolbar 0x%x", (unsigned int)toolbar);
955
956 /* Destroy the widgets. */
957
958 if (toolbar->buttons != NULL)
960
961 if (toolbar->editor != NULL)
963
964 if (toolbar->url != NULL)
966
967 if (toolbar->throbber != NULL)
969
970 /* Delete the toolbar window. */
971
972 if (toolbar->toolbar_handle != NULL) {
973 xwimp_delete_window(toolbar->toolbar_handle);
975 }
976
977 /* Remove the bar from the list and free the memory.
978 */
979
980 if (ro_toolbar_bars == toolbar) {
982 } else {
983 for (bar = ro_toolbar_bars; bar != NULL && bar->next != toolbar;
984 bar = bar->next);
985
986 if (bar->next == toolbar)
987 bar->next = toolbar->next;
988 }
989
990 free(toolbar);
991
992}
993
994
995/**
996 * Handle redraw request events for a toolbar workarea.
997 *
998 * \param *redraw The redraw block for the event.
999 */
1000
1001void ro_toolbar_redraw(wimp_draw *redraw)
1002{
1003 struct toolbar *toolbar;
1004 osbool more;
1005 os_error *error;
1006
1007 toolbar = (struct toolbar *)ro_gui_wimp_event_get_user_data(redraw->w);
1008
1009 assert(toolbar != NULL);
1010
1011 error = xwimp_redraw_window(redraw, &more);
1012 if (error) {
1013 NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
1014 error->errnum, error->errmess);
1015 ro_warn_user("WimpError", error->errmess);
1016 return;
1017 }
1018 while (more) {
1019 ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
1020 ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
1021
1022 if (toolbar->buttons != NULL && toolbar->buttons_display)
1024
1025 if (toolbar->editor != NULL && toolbar->editing)
1027
1028 if (toolbar->url != NULL && toolbar->url_display)
1030
1031 error = xwimp_get_rectangle(redraw, &more);
1032 if (error) {
1033 NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
1034 error->errnum, error->errmess);
1035 ro_warn_user("WimpError", error->errmess);
1036 return;
1037 }
1038 }
1039}
1040
1041
1042/**
1043 * Process clicks on a toolbar, passing details on to clients where necessary.
1044 *
1045 * \param *pointer The wimp mouse click event.
1046 * \return True if the event was handled; else false.
1047 */
1048
1049bool ro_toolbar_click(wimp_pointer *pointer)
1050{
1051 struct toolbar *toolbar;
1052 union toolbar_action action;
1053 wimp_window_state state;
1054 os_error *error;
1055
1056 toolbar = (struct toolbar *)
1058
1059 if (toolbar == NULL)
1060 return false;
1061
1062 assert(pointer->w == toolbar->toolbar_handle);
1063
1064 state.w = toolbar->toolbar_handle;
1065 error = xwimp_get_window_state(&state);
1066 if (error) {
1067 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
1068 error->errnum, error->errmess);
1069 ro_warn_user("WimpError", error->errmess);
1070 return false;
1071 }
1072
1073 /* If the click wasn't in the URL Bar's text field, then it will
1074 * need to close any URL Complete window that is open.
1075 *
1076 * \TODO -- This should really move into the URL Bar module, as
1077 * URL Complete is really an extension to that.
1078 */
1079
1080 if (toolbar->url != NULL && toolbar->url_display &&
1082 pointer))
1084
1085 /* Pass the click around the toolbar widgets. */
1086
1087 if (toolbar->buttons != NULL &&
1090 &state, &action.button)) {
1091 if (action.button != TOOLBAR_BUTTON_NONE &&
1092 !toolbar->editing &&
1093 toolbar->callbacks != NULL &&
1094 toolbar->callbacks->user_action != NULL)
1096 TOOLBAR_ACTION_BUTTON, action);
1097 return true;
1098 }
1099
1100 if (toolbar->url != NULL && toolbar->url_display &&
1102 &state, &action.url)) {
1103 if (action.url != TOOLBAR_URL_NONE &&
1104 !toolbar->editing &&
1105 toolbar->callbacks != NULL &&
1106 toolbar->callbacks->user_action != NULL)
1108 TOOLBAR_ACTION_URL, action);
1109 return true;
1110 }
1111
1112 if (toolbar->editor != NULL && toolbar->editing &&
1114 &state, &action.button)) {
1115 return true;
1116 }
1117
1118 if (pointer->buttons != wimp_DRAG_SELECT &&
1119 pointer->buttons != wimp_DRAG_ADJUST) {
1120 /* Nothing else has handled this click, so try passing it to
1121 * the URL Complete module.
1122 *
1123 * \TODO -- This should really move into the URL Bar module, as
1124 * URL Complete is really an extension to that.
1125 */
1126 if (toolbar->url != NULL && toolbar->url_display &&
1128 toolbar->url, pointer)) {
1130 return true;
1131 }
1132 }
1133
1134 return false;
1135}
1136
1137
1138/**
1139 * Process keypresses in a toolbar, passing details on to clients where
1140 * necessary.
1141 *
1142 * \param *key The wimp key press event.
1143 * \return True if the event was handled; else false.
1144 */
1145
1146bool ro_toolbar_keypress(wimp_key *key)
1147{
1148 struct toolbar *toolbar;
1149
1150 toolbar = (struct toolbar *) ro_gui_wimp_event_get_user_data(key->w);
1151
1152 if (toolbar == NULL)
1153 return false;
1154
1155 /* Pass the keypress on to the client and stop if they handle it. */
1156
1157 if (toolbar->callbacks->key_press != NULL &&
1159 return true;
1160
1161 /* If the caret is in the URL bar, ask the URL Complete module if it
1162 * wants to handle the keypress.
1163 *
1164 * \TODO -- This should really move into the URL Bar module, as
1165 * URL Complete is really an extension to that.
1166 */
1167
1168 if (toolbar->url != NULL && toolbar->url_display &&
1170 toolbar->url, key) &&
1172 return true;
1173
1174 return false;
1175}
1176
1177
1178/**
1179 * Prepare the toolbar menu for (re-)opening
1180 *
1181 * \param w The window owning the menu.
1182 * \param i The icon owning the menu.
1183 * \param *menu The menu about to be opened.
1184 * \param *pointer Pointer to the relevant wimp event block, or
1185 * NULL for an Adjust click.
1186 * \return true if the event was handled; else false.
1187 */
1188
1189bool ro_toolbar_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
1190 wimp_pointer *pointer)
1191{
1192 struct toolbar *toolbar;
1193
1195
1196 if (toolbar == NULL)
1197 return false;
1198
1199 /* Pass the event on to potentially interested widgets. */
1200
1202 i, menu, pointer))
1203 return true;
1204
1205 /* Try to process the event as a toolbar menu. */
1206
1207 if (menu != toolbar_menu)
1208 return false;
1209
1210 /* Shade menu entries according to the state of the window and object
1211 * under the pointer.
1212 */
1213
1214 /* Toolbar (Sub)Menu */
1215
1220
1223 toolbar->buttons == NULL);
1226 toolbar->buttons != NULL);
1227
1230 toolbar->url == NULL);
1233 toolbar->url != NULL);
1234
1237 toolbar->throbber == NULL);
1240 toolbar->throbber != NULL);
1241
1242 return true;
1243}
1244
1245
1246/**
1247 * Handle submenu warnings for the toolbar menu
1248 *
1249 * \param w The window owning the menu.
1250 * \param i The icon owning the menu.
1251 * \param *menu The menu to which the warning applies.
1252 * \param *selection The wimp menu selection data.
1253 * \param action The selected menu action.
1254 */
1255
1256void ro_toolbar_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
1257 wimp_selection *selection, menu_action action)
1258{
1259 /* Do nothing */
1260}
1261
1262
1263/**
1264 * Handle selections from the toolbar menu
1265 *
1266 * \param w The window owning the menu.
1267 * \param i The icon owning the menu.
1268 * \param *menu The menu from which the selection was made.
1269 * \param *selection The wimp menu selection data.
1270 * \param action The selected menu action.
1271 * \return true if action accepted; else false.
1272 */
1273
1274bool ro_toolbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
1275 wimp_selection *selection, menu_action action)
1276{
1277 struct toolbar *toolbar;
1278
1280
1281 if (toolbar == NULL)
1282 return false;
1283
1284 /* Pass the event on to potentially interested widgets. */
1285
1287 i, menu, selection, action))
1288 return true;
1289
1290 /* Try to process the event as a toolbar menu. */
1291
1292 if (menu != toolbar_menu)
1293 return false;
1294
1295 switch (action) {
1296 case TOOLBAR_BUTTONS:
1299 break;
1305 break;
1306 case TOOLBAR_THROBBER:
1309 break;
1310 case TOOLBAR_EDIT:
1312 break;
1313 default:
1314 return false;
1315 }
1316
1317 return true;
1318}
1319
1320
1321/**
1322 * Translate the contents of a message_HELP_REQUEST into a suffix for a
1323 * NetSurf message token. The help system will then add this to whatever
1324 * prefix the current toolbar has registered with WimpEvent.
1325 *
1326 * \param w The window handle under the mouse.
1327 * \param i The icon handle under the mouse.
1328 * \param *pos The mouse position.
1329 * \param buttons The mouse button state.
1330 * \return The required help token suffix.
1331 */
1332
1333const char *ro_toolbar_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos,
1334 wimp_mouse_state buttons)
1335{
1336 struct toolbar *toolbar;
1337 wimp_window_state state;
1338 os_error *error;
1339 const char *suffix;
1340
1342
1343 if (toolbar == NULL || toolbar->toolbar_handle != w)
1344 return NULL;
1345
1346 state.w = toolbar->toolbar_handle;
1347 error = xwimp_get_window_state(&state);
1348 if (error) {
1349 NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
1350 error->errnum, error->errmess);
1351 ro_warn_user("WimpError", error->errmess);
1352 return NULL;
1353 }
1354
1355 /* Pass the help request around the toolbar widgets. */
1356
1357 if (toolbar->throbber != NULL && toolbar->throbber_display &&
1359 pos, &state, buttons, &suffix))
1360 return suffix;
1361
1362 if (toolbar->url != NULL && toolbar->url_display &&
1364 pos, &state, buttons, &suffix))
1365 return suffix;
1366
1367 if (toolbar->buttons != NULL && toolbar->buttons_display &&
1369 pos, &state, buttons, &suffix))
1370 return suffix;
1371
1372 return "";
1373}
1374
1375
1376/* This is an exported interface documented in toolbar.h */
1377
1379{
1380 if (toolbar != NULL)
1382}
1383
1384
1385/* This is an exported interface documented in toolbar.h */
1386
1388{
1389 struct toolbar *bar;
1390
1391 bar = ro_toolbar_bars;
1392 while (bar != NULL) {
1394
1395 bar = bar->next;
1396 }
1397}
1398
1399
1400/**
1401 * Update the state of a toolbar's buttons.
1402 *
1403 * \param toolbar the toolbar to update
1404 */
1405
1407{
1408 assert(toolbar != NULL);
1409
1410 if (toolbar->callbacks != NULL &&
1413}
1414
1415/* This is an exported interface documented in toolbar.h */
1416
1418{
1419 assert(toolbar != NULL);
1420
1421 ro_toolbar_process(toolbar, -1, true);
1422 if (toolbar->callbacks != NULL &&
1423 toolbar->callbacks->change_size != NULL)
1425
1426 if (toolbar->toolbar_handle != NULL)
1427 xwimp_force_redraw(toolbar->toolbar_handle, 0, 0,
1430}
1431
1432
1433/* This is an exported interface documented in toolbar.h */
1434
1436{
1437 struct toolbar *bar, *next;
1438 bool ok;
1439
1440 bar = ro_toolbar_bars;
1441 while (bar != NULL) {
1442 /* Take the next bar address now, as *bar may become invalid
1443 * during the update process (if an update fails and
1444 * ro_toolbar_destroy() is called) and we don't want to lose
1445 * the link to the rest of the chain.
1446 */
1447
1448 next = bar->next;
1449
1450 /* Only process the bar if the theme is set to the default.
1451 * Otherwise, it's up to the owner to do whatever they need
1452 * to do for themselves.
1453 */
1454
1455 if (bar->theme == NULL) {
1456 ok = ro_toolbar_rebuild(bar);
1457
1458 if (!ok)
1459 ro_toolbar_destroy(bar);
1460 } else {
1461 ok = true;
1462 }
1463
1464 if (bar->callbacks != NULL &&
1465 bar->callbacks->theme_update != NULL)
1466 bar->callbacks->theme_update(bar->client_data, ok);
1467
1468 bar = next;
1469 }
1470}
1471
1472
1473/* This is an exported interface documented in toolbar.h */
1474
1476{
1477 struct toolbar *toolbar;
1478
1480 while (toolbar != NULL && toolbar->parent_handle != w)
1481 toolbar = toolbar->next;
1482
1483 return toolbar;
1484}
1485
1486
1487/* This is an exported interface documented in toolbar.h */
1488
1490{
1491 struct toolbar *toolbar;
1492
1494 while (toolbar != NULL && toolbar->toolbar_handle != w)
1495 toolbar = toolbar->next;
1496
1497 return toolbar;
1498}
1499
1500
1501/* This is an exported interface documented in toolbar.h */
1502
1504{
1505 return (toolbar != NULL) ? toolbar->parent_handle : 0;
1506}
1507
1508
1509/* This is an exported interface documented in toolbar.h */
1510
1512{
1513 return (toolbar != NULL) ? toolbar->toolbar_handle : 0;
1514}
1515
1516
1517/* This is an exported interface documented in toolbar.h */
1518
1520{
1521 return (toolbar == NULL) ? 0 : toolbar->current_height;
1522}
1523
1524
1525/* This is an exported interface documented in toolbar.h */
1526
1528{
1529 return (toolbar == NULL) ? 0 : toolbar->full_height;
1530}
1531
1532
1533/* This is an exported interface documented in toolbar.h */
1534
1536{
1537 if (toolbar != NULL && toolbar->throbber != NULL)
1539}
1540
1541
1542/* This is an exported interface documented in toolbar.h */
1544{
1545 if (toolbar != NULL && toolbar->throbber != NULL)
1547}
1548
1549
1550/* This is an exported interface documented in toolbar.h */
1552{
1553 if (toolbar == NULL || toolbar->url == NULL)
1554 return;
1555
1557}
1558
1559
1560/* This is an exported interface documented in toolbar.h */
1562{
1563 if (toolbar != NULL && toolbar->throbber != NULL)
1565}
1566
1567
1568/* This is an exported interface documented in toolbar.h */
1569
1571{
1572 if (toolbar == NULL || toolbar->buttons == NULL)
1573 return false;
1574
1576 return false;
1577
1579
1580 return ro_toolbar_process(toolbar, -1, true);
1581}
1582
1583
1584/* This is an exported interface documented in toolbar.h */
1585
1587 button_bar_action action, bool shaded)
1588{
1589 if (toolbar == NULL || toolbar->buttons == NULL)
1590 return;
1591
1593}
1594
1595
1596/* This is an exported interface documented in toolbar.h */
1597
1599{
1600 if (toolbar == NULL || toolbar->url == NULL || !toolbar->url_display)
1601 return false;
1602
1604}
1605
1606
1607/* This is an exported interface documented in toolbar.h */
1608
1609void ro_toolbar_set_url(struct toolbar *toolbar, const char *url,
1610 bool is_utf8, bool set_caret)
1611{
1612 if (toolbar != NULL && toolbar->url != NULL)
1613 ro_gui_url_bar_set_url(toolbar->url, url, is_utf8, set_caret);
1614}
1615
1616
1617/* This is an exported interface documented in toolbar.h */
1618
1620{
1621 if (toolbar == NULL || toolbar->url == NULL)
1622 return NULL;
1623
1625}
1626
1627
1628/* This is an exported interface documented in toolbar.h */
1629
1631{
1632 struct toolbar *bar;
1633
1634 bar = ro_toolbar_bars;
1635 while (bar != NULL) {
1637
1638 bar = bar->next;
1639 }
1640}
1641
1642
1643/* This is an exported interface documented in toolbar.h */
1644
1646{
1647 if (toolbar == NULL || toolbar->url == NULL)
1648 return;
1649
1651}
1652
1653
1654/* This is an exported interface documented in toolbar.h */
1655
1657{
1658 if (toolbar == NULL || toolbar->url == NULL)
1659 return false;
1660
1661 if (extent == NULL)
1662 return true;
1663
1664 return ro_gui_url_bar_get_url_extent(toolbar->url, extent);
1665}
1666
1667
1668/* This is an exported interface documented in toolbar.h */
1670 struct hlcache_handle *h)
1671{
1672 if (toolbar == NULL || toolbar->url == NULL)
1673 return;
1674
1676}
1677
1678
1679/* This is an exported interface documented in toolbar.h */
1681 struct gui_window *g)
1682{
1683 if (toolbar == NULL || toolbar->url == NULL)
1684 return;
1685
1687}
1688
1689
1690/* This is an exported interface documented in toolbar.h */
1691
1693{
1694 if (toolbar == NULL || toolbar->url == NULL)
1695 return;
1696
1698}
1699
1700
1701/* This is an exported interface documented in toolbar.h */
1702
1704{
1705 if (toolbar == NULL || toolbar->buttons == NULL)
1706 return;
1707
1708 toolbar->buttons_display = display;
1712}
1713
1714
1715/* This is an exported interface documented in toolbar.h */
1716
1717void ro_toolbar_set_display_url(struct toolbar *toolbar, bool display)
1718{
1719 if (toolbar == NULL || toolbar->url == NULL)
1720 return;
1721
1722 toolbar->url_display = display;
1723 ro_gui_url_bar_hide(toolbar->url, !display);
1726}
1727
1728
1729/* This is an exported interface documented in toolbar.h */
1730
1732{
1733 if (toolbar == NULL || toolbar->throbber == NULL)
1734 return;
1735
1736 toolbar->throbber_display = display;
1740}
1741
1742
1743/* This is an exported interface documented in toolbar.h */
1744
1746{
1747 return (toolbar == NULL || toolbar->buttons == NULL) ?
1748 false : toolbar->buttons_display;
1749}
1750
1751
1752/* This is an exported interface documented in toolbar.h */
1753
1755{
1756 return (toolbar == NULL || toolbar->url == NULL) ?
1757 false : toolbar->url_display;
1758}
1759
1760
1761/* This is an exported interface documented in toolbar.h */
1762
1764{
1765 return (toolbar == NULL || toolbar->throbber == NULL) ?
1766 false : toolbar->throbber_display;
1767}
1768
1769
1770/* This is an exported interface documented in toolbar.h */
1771
1773{
1774 return (toolbar == NULL || !toolbar->editing) ? false : true;
1775}
1776
1777
1778/* This is an exported interface documented in toolbar.h */
1779
1781{
1782 if (toolbar == NULL || toolbar->editor == NULL)
1783 return false;
1784
1786
1790
1793 return false;
1794 }
1795
1797
1798 /* If there's a callback registered and an edit has finished,
1799 * tell out client what the new button state is.
1800 */
1801
1802 if (!toolbar->editing && toolbar->buttons != NULL &&
1803 toolbar->callbacks != NULL &&
1804 toolbar->callbacks->save_buttons != NULL) {
1805 char *new_buttons;
1808 new_buttons);
1809 }
1810
1811 return true;
1812}
1813
menu_action
Definition: scaffolding.h:77
@ TOOLBAR_ADDRESS_BAR
Definition: scaffolding.h:171
@ TOOLBAR_BUTTONS
Definition: scaffolding.h:170
@ TOOLBAR_EDIT
Definition: scaffolding.h:173
@ TOOLBAR_THROBBER
Definition: scaffolding.h:172
void ro_gui_button_bar_destroy(struct button_bar *button_bar)
Destroy a button bar widget.
Definition: button_bar.c:395
bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i, os_coord *mouse, wimp_window_state *state, wimp_mouse_state buttons, const char **suffix)
Translate mouse data into an interactive help message for a button bar.
Definition: button_bar.c:826
bool ro_gui_button_bar_arrange_buttons(struct button_bar *button_bar, char order[])
Arrange buttons on a button bar, using an order string to specify the required button and separator l...
Definition: button_bar.c:303
bool ro_gui_button_bar_rebuild(struct button_bar *button_bar, struct theme_descriptor *theme, theme_style style, wimp_w window, bool edit)
Place a button bar into a toolbar window and initialise any theme-specific settings.
Definition: button_bar.c:245
struct button_bar * ro_gui_button_bar_create(struct theme_descriptor *theme, const struct button_bar_buttons buttons[])
Create a new button bar widget.
Definition: button_bar.c:130
char * ro_gui_button_bar_get_config(struct button_bar *button_bar)
Return a config string reflecting the configured order of buttons and spacers.
Definition: button_bar.c:1067
bool ro_gui_button_bar_set_extent(struct button_bar *button_bar, int x0, int y0, int x1, int y1)
Set or update the dimensions to be used by the button bar, in RO units.
Definition: button_bar.c:437
bool ro_gui_button_bar_shade_button(struct button_bar *button_bar, button_bar_action action, bool shaded)
Shade or unshade a button in a bar corresponding to the given action.
Definition: button_bar.c:640
bool ro_gui_button_bar_link_editor(struct button_bar *target, struct button_bar *source, void(*refresh)(void *), void *client_data)
Link two button bars together.
Definition: button_bar.c:220
bool ro_gui_button_bar_get_dims(struct button_bar *button_bar, int *width, int *height)
Return the MINIMUM dimensions required by the button bar, in RO units, allowing for the current theme...
Definition: button_bar.c:416
void ro_gui_button_bar_redraw(struct button_bar *button_bar, wimp_draw *redraw)
Handle redraw event rectangles in a button bar.
Definition: button_bar.c:672
bool ro_gui_button_bar_hide(struct button_bar *button_bar, bool hide)
Show or hide a button bar.
Definition: button_bar.c:627
bool ro_gui_button_bar_click(struct button_bar *button_bar, wimp_pointer *pointer, wimp_window_state *state, button_bar_action *action)
Handle mouse clicks in a button bar.
Definition: button_bar.c:723
Button bars (interface).
button_bar_action
Definition: button_bar.h:32
@ TOOLBAR_BUTTON_NONE
Definition: button_bar.h:33
wimp_w parent
Definition: dialog.c:88
RISc OS global history interface.
Hotlist (interface).
Window themes(interface).
@ THEME_ELEMENT_BACKGROUND
Definition: theme.h:44
theme_style
Theme styles, collecting groups of attributes for different locations.
Definition: theme.h:31
Browser window handling (interface).
#define NO_ACTION
Definition: idna.c:695
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
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_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
Interface to riscos cookie viewing using riscos core window.
bool ro_gui_throbber_stop(struct throbber *throbber)
Stop the amimation of a throbber.
Definition: throbber.c:403
bool ro_gui_throbber_set_extent(struct throbber *throbber, int x0, int y0, int x1, int y1)
Set or update the dimensions to be used by the throbber in RO units.
Definition: throbber.c:186
void ro_gui_throbber_destroy(struct throbber *throbber)
Destroy a throbber widget.
Definition: throbber.c:154
bool ro_gui_throbber_hide(struct throbber *throbber, bool hide)
Show or hide a throbber.
Definition: throbber.c:315
bool ro_gui_throbber_animate(struct throbber *throbber)
Start or update the amimation of a throbber.
Definition: throbber.c:363
bool ro_gui_throbber_get_dims(struct throbber *throbber, int *width, int *height)
Return the MINIMUM dimensions required by the throbber, in RO units, allowing for the current theme.
Definition: throbber.c:165
bool ro_gui_throbber_rebuild(struct throbber *throbber, struct theme_descriptor *theme, theme_style style, wimp_w window, bool shaded)
Place a throbber into a toolbar window and initialise any theme-specific settings.
Definition: throbber.c:124
struct throbber * ro_gui_throbber_create(struct theme_descriptor *theme)
Create a new throbber widget.
Definition: throbber.c:77
bool ro_gui_throbber_help_suffix(struct throbber *throbber, wimp_i i, os_coord *mouse, wimp_window_state *state, wimp_mouse_state buttons, const char **suffix)
Translate mouse data into an interactive help message for the throbber.
Definition: throbber.c:328
Throbber (interface).
int width
Definition: gui.c:160
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
Definition: gui.c:2077
int height
Definition: gui.c:161
int ro_plot_origin_x
Definition: plotters.c:40
int ro_plot_origin_y
Definition: plotters.c:41
File/object/selection saving (Interface).
osspriteop_area * ro_gui_theme_get_sprites(struct theme_descriptor *descriptor)
Returns a sprite area for use with the given theme.
Definition: theme.c:221
int ro_gui_theme_get_style_element(struct theme_descriptor *descriptor, theme_style style, theme_element element)
Returns an interger element from the specified theme, or the current theme if the descriptor is NULL.
Definition: theme.c:251
bool ro_gui_theme_get_throbber_data(struct theme_descriptor *descriptor, int *frames, int *width, int *height, bool *right, bool *redraw)
Returns details of the throbber as defined in a theme.
Definition: theme.c:325
static char ro_toolbar_null_string[]
Definition: toolbar.c:171
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
static bool ro_toolbar_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
Prepare the toolbar menu for (re-)opening.
Definition: toolbar.c:1189
void ro_toolbar_theme_update(void)
Force the update of all toolbars to reflect the application of a new theme.
Definition: toolbar.c:1435
wimp_w ro_toolbar_get_window(struct toolbar *toolbar)
Return the RO window handle of a toolbar.
Definition: toolbar.c:1511
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
#define TOOLBAR_ROW_EDIT
Definition: toolbar.c:71
#define TOOLBAR_WIDGET_GUTTER
Definition: toolbar.c:63
void ro_toolbar_destroy(struct toolbar *toolbar)
Destroy a toolbar after use.
Definition: toolbar.c:947
void ro_toolbar_update_all_buttons(void)
Force the update of all toolbars buttons to reflect the current state.
Definition: toolbar.c:1387
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_get_url_field_extent(struct toolbar *toolbar, os_box *extent)
Return the current work area coordinates of the URL and favicon field's bounding box.
Definition: toolbar.c:1656
bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent)
Attach or re-attach a toolbar to its parent window.
Definition: toolbar.c:524
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
static void ro_toolbar_update_buttons(struct toolbar *toolbar)
Update the state of a toolbar's buttons.
Definition: toolbar.c:1406
static void ro_toolbar_update_current_widgets(struct toolbar *toolbar)
Update the widgets currently on view in a toolbar.
Definition: toolbar.c:695
#define TOOLBAR_ROW_TOP
Definition: toolbar.c:69
void ro_toolbar_refresh(struct toolbar *toolbar)
Refresh a toolbar after it has been updated.
Definition: toolbar.c:1417
#define TOOLBAR_MAX_ROWS
Definition: toolbar.c:72
static char ro_toolbar_line_validation[]
Definition: toolbar.c:172
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
static void ro_toolbar_redraw(wimp_draw *redraw)
Handle redraw request events for a toolbar workarea.
Definition: toolbar.c:1001
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
static struct toolbar * ro_toolbar_bars
The list of defined toolbars.
Definition: toolbar.c:135
void ro_toolbar_set_display_buttons(struct toolbar *toolbar, bool display)
Set the display button bar state for a toolbar.
Definition: toolbar.c:1703
bool ro_toolbar_get_editing(struct toolbar *toolbar)
Return true or false depending on whether the given toolbar is currently being edited.
Definition: toolbar.c:1772
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
static void ro_toolbar_reformat_widgets(struct toolbar *toolbar)
Reformat (reflow) the widgets into the toolbar, based on the toolbar size and the previously calculat...
Definition: toolbar.c:859
void ro_toolbar_init(void)
Initialise the RISC OS toolbar widget.
Definition: toolbar.c:199
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
static const char * ro_toolbar_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos, wimp_mouse_state buttons)
Translate the contents of a message_HELP_REQUEST into a suffix for a NetSurf message token.
Definition: toolbar.c:1333
#define TOOLBAR_DEFAULT_WIDTH
Definition: toolbar.c:64
static void ro_toolbar_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handle submenu warnings for the toolbar menu.
Definition: toolbar.c:1256
void ro_toolbar_update_client_data(struct toolbar *toolbar, void *client_data)
Change the client data associated with a toolbar's callbacks.
Definition: toolbar.c:1378
static bool ro_toolbar_keypress(wimp_key *key)
Process keypresses in a toolbar, passing details on to clients where necessary.
Definition: toolbar.c:1146
bool ro_toolbar_set_button_order(struct toolbar *toolbar, char order[])
Change the arrangement of buttons and spacers on a button bar within a toolbar.
Definition: toolbar.c:1570
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
#define TOOLBAR_ROW_DIV1
Definition: toolbar.c:70
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_update_all_hotlists(void)
Update the state of the URL Bar hotlist icons in all open toolbars.
Definition: toolbar.c:1630
static void ro_toolbar_refresh_widget_dimensions(struct toolbar *toolbar)
Get the minimum dimenstions required by the toolbar widgets after these have changed.
Definition: toolbar.c:724
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
static bool ro_toolbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handle selections from the toolbar menu.
Definition: toolbar.c:1274
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_menu * toolbar_menu
The Toolber Menu.
Definition: toolbar.c:138
static wimp_window ro_toolbar_window
Definition: toolbar.c:144
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
static bool ro_toolbar_click(wimp_pointer *pointer)
Process clicks on a toolbar, passing details on to clients where necessary.
Definition: toolbar.c:1049
Window toolbars (interface).
@ 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
Definition: toolbar.h:33
@ TOOLBAR_FLAGS_DISPLAY
Definition: toolbar.h:35
static BList * callbacks
List of all callbacks.
Definition: schedule.cpp:44
Interface to utility string handling.
first entry in window list
Definition: gui.c:297
High-level cache handle.
Definition: hlcache.c:66
Definition: menus.h:159
bool(* key_press)(void *, wimp_key *)
Call to handle keypresses.
Definition: toolbar.h:75
void(* save_buttons)(void *, char *)
Call on change to button order.
Definition: toolbar.h:78
void(* theme_update)(void *, bool)
Call on theme update.
Definition: toolbar.h:63
void(* update_buttons)(void *)
Call to update button states.
Definition: toolbar.h:69
void(* user_action)(void *, toolbar_action_type, union toolbar_action)
Call to handle user actions.
Definition: toolbar.h:72
void(* change_size)(void *)
Call on bar size change.
Definition: toolbar.h:66
int row_y0[TOOLBAR_MAX_ROWS]
Row locations and sizes.
Definition: toolbar.c:92
int clip_height
Definition: toolbar.c:85
int current_width
Definition: toolbar.c:83
struct theme_descriptor * theme
Bar details.
Definition: toolbar.c:79
struct button_bar * buttons
Details for the button bar.
Definition: toolbar.c:96
theme_style style
Definition: toolbar.c:80
bool url_display
Definition: toolbar.c:102
const struct toolbar_callbacks * callbacks
Client callback data.
Definition: toolbar.c:112
bool throbber_display
Definition: toolbar.c:107
bool editing
Definition: toolbar.c:120
toolbar_flags flags
Definition: toolbar.c:81
int row_y1[TOOLBAR_MAX_ROWS]
Definition: toolbar.c:93
void * client_data
Definition: toolbar.c:113
struct url_bar * url
Details for the URL bar.
Definition: toolbar.c:101
wimp_w toolbar_handle
Toolbar and parent window handles.
Definition: toolbar.c:88
wimp_w parent_handle
Definition: toolbar.c:89
int full_width
Definition: toolbar.c:84
wimp_i editor_div1
Details for the toolbar editor.
Definition: toolbar.c:116
struct toolbar * next
The next bar in the toolbar list.
Definition: toolbar.c:127
os_coord throbber_size
Definition: toolbar.c:109
int clip_width
Definition: toolbar.c:85
const char * help_prefix
Interactive help data.
Definition: toolbar.c:124
os_coord buttons_size
Definition: toolbar.c:98
int full_height
Definition: toolbar.c:84
os_coord url_size
Definition: toolbar.c:103
int current_height
Definition: toolbar.c:83
bool buttons_display
Definition: toolbar.c:97
bool throbber_right
Definition: toolbar.c:108
struct throbber * throbber
Details for the throbber.
Definition: toolbar.c:106
os_coord editor_size
Definition: toolbar.c:118
struct button_bar * editor
Definition: toolbar.c:117
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
bool ro_gui_url_bar_test_for_text_field_click(struct url_bar *url_bar, wimp_pointer *pointer)
Test a pointer click to see if it was in the URL bar's text field.
Definition: url_bar.c:1344
bool ro_gui_url_bar_page_info_change(struct url_bar *url_bar)
Update the page info icon.
Definition: url_bar.c:1455
bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent)
Return the current work area coordinates of the URL and favicon field's bounding box.
Definition: url_bar.c:1309
bool ro_gui_url_bar_take_caret(struct url_bar *url_bar)
Give a URL bar input focus.
Definition: url_bar.c:1134
bool ro_gui_url_bar_set_extent(struct url_bar *url_bar, int x0, int y0, int x1, int y1)
Set or update the dimensions to be used by the URL bar, in RO units.
Definition: url_bar.c:677
const char * ro_gui_url_bar_get_url(struct url_bar *url_bar)
Return a pointer to the URL contained in a URL bar.
Definition: url_bar.c:1280
void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
Handle redraw event rectangles in a URL bar.
Definition: url_bar.c:744
bool ro_gui_url_bar_hide(struct url_bar *url_bar, bool hide)
Show or hide a URL bar.
Definition: url_bar.c:732
bool ro_gui_url_bar_menu_prepare(struct url_bar *url_bar, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
Process offered menu prepare events from the parent window.
Definition: url_bar.c:1013
void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, bool is_utf8, bool set_caret)
Set the content of a URL Bar field.
Definition: url_bar.c:1160
bool ro_gui_url_bar_get_dims(struct url_bar *url_bar, int *width, int *height)
Return the MINIMUM dimensions required by the URL bar, in RO units, allowing for the current theme.
Definition: url_bar.c:653
bool ro_gui_url_bar_set_site_favicon(struct url_bar *url_bar, struct hlcache_handle *h)
Set the favicon to a site supplied favicon image, or remove the image and return to using filetype-ba...
Definition: url_bar.c:1394
bool ro_gui_url_bar_test_for_text_field_keypress(struct url_bar *url_bar, wimp_key *key)
Test a keypress to see if it was in the URL bar's text field.
Definition: url_bar.c:1360
void ro_gui_url_bar_update_hotlist(struct url_bar *url_bar)
Update the state of a URL Bar's hotlist icon to reflect any changes to the URL or the contents of the...
Definition: url_bar.c:1261
struct url_bar * ro_gui_url_bar_create(struct theme_descriptor *theme)
Create a new url bar widget.
Definition: url_bar.c:516
bool ro_gui_url_bar_rebuild(struct url_bar *url_bar, struct theme_descriptor *theme, theme_style style, wimp_w window, bool display, bool shaded)
Place a URL bar into a toolbar window and initialise any theme-specific settings.
Definition: url_bar.c:593
bool ro_gui_url_bar_set_content_favicon(struct url_bar *url_bar, struct gui_window *g)
Set the favicon to a RISC OS filetype sprite based on the type of the content within the supplied win...
Definition: url_bar.c:1508
bool ro_gui_url_bar_update_urlsuggest(struct url_bar *url_bar)
Update the state of the URL suggestion pop-up menu icon on a URL bar.
Definition: url_bar.c:1559
bool ro_gui_url_bar_help_suffix(struct url_bar *url_bar, wimp_i i, os_coord *mouse, wimp_window_state *state, wimp_mouse_state buttons, const char **suffix)
Translate mouse data into an interactive help message for the URL bar.
Definition: url_bar.c:1081
bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Process offered menu select events from the parent window.
Definition: url_bar.c:1034
bool ro_gui_url_bar_click(struct url_bar *url_bar, wimp_pointer *pointer, wimp_window_state *state, url_bar_action *action)
Handle mouse clicks in a URL bar.
Definition: url_bar.c:936
void ro_gui_url_bar_destroy(struct url_bar *url_bar)
Destroy a url bar widget.
Definition: url_bar.c:634
URL bars (interface).
@ TOOLBAR_URL_NONE
Definition: url_bar.h:34
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
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).
Option reading and saving interface.
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_set_help_prefix(wimp_w w, const char *help_prefix)
Set the associated help prefix for a given window.
Definition: wimp_event.c:390
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_transfer(wimp_w from, wimp_w to)
Transfer event data from one window to another.
Definition: wimp_event.c:267
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_help_suffix(wimp_w w, const char *(*get_help_suffix)(wimp_w w, wimp_i i, os_coord *pos, wimp_mouse_state buttons))
Register a handler to decode help suffixes for a given window.
Definition: wimp_event.c:424
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).
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_WIMP_OPEN(pstate)
Definition: wimputils.h:39