NetSurf
url_bar.c
Go to the documentation of this file.
1/*
2 * Copyright 2004, 2005 Richard Wilson <info@tinct.net>
3 * Copyright 2011-2014 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/**
21 * \file
22 * RISC OS URL bar implementation.
23 *
24 * The treeview resources are retrieved from resource url necessitating
25 * the use of the hlcache content interface.
26 */
27
28#include <stddef.h>
29#include "oslib/wimp.h"
30
31#include "utils/log.h"
32#include "utils/messages.h"
34#include "netsurf/plotters.h"
35#include "netsurf/content.h"
36#include "content/hlcache.h"
37
38#include "riscos/gui.h"
39#include "riscos/hotlist.h"
40#include "riscos/url_suggest.h"
41#include "riscos/wimp.h"
42#include "riscos/wimp_event.h"
43#include "riscos/wimputils.h"
44#include "riscos/window.h"
45#include "riscos/ucstables.h"
46#include "riscos/filetype.h"
47#include "riscos/gui/url_bar.h"
48
49#define URLBAR_HEIGHT 52
50#define URLBAR_FAVICON_SIZE 16
51#define URLBAR_HOTLIST_SIZE 17
52#define URLBAR_PGINFO_WIDTH ((26) * 2)
53#define URLBAR_FAVICON_WIDTH ((5 + URLBAR_FAVICON_SIZE + 5) * 2)
54#define URLBAR_HOTLIST_WIDTH ((5 + URLBAR_HOTLIST_SIZE + 5) * 2)
55#define URLBAR_MIN_WIDTH 52
56#define URLBAR_GRIGHT_GUTTER 8
57
58#define URLBAR_PGINFO_NAME_LENGTH 12
59#define URLBAR_FAVICON_NAME_LENGTH 12
60
61struct url_bar {
62 /** The applied theme (or NULL to use the default) */
64
65 /** The widget dimensions. */
67
68 /** The window and icon details. */
69 wimp_w window;
70 os_box extent;
71 osspriteop_area *sprites;
72
74
75 bool hidden;
76 bool display;
77 bool shaded;
78
79 struct {
81 os_box extent;
83
84 struct {
86 int type;
88 os_box extent;
89 os_coord offset;
90 int width;
91 int height;
93
94 struct {
95 wimp_i icon;
96 char *buffer;
97 size_t size;
100
101 struct {
102 wimp_i icon;
103 int x;
104 int y;
106
107 struct {
108 bool set;
109 os_box extent;
110 os_coord offset;
112};
113
114static char text_validation[] = "Pptr_write;KN";
115static char suggest_icon[] = "gright";
116static char suggest_validation[] = "R5;Sgright,pgright";
117static char null_text_string[] = "";
118
119/** Treeview content resource data */
121 const char *url;
124 bool ready;
125};
126
132
133/** Treeview content resources */
135 { "resource:icons/hotlist-add.png", NULL, 0, false },
136 { "resource:icons/hotlist-rmv.png", NULL, 0, false }
137};
138
139
140/**
141 * Position the icons in the URL bar to take account of the currently
142 * configured extent.
143 *
144 * \param *url_bar The URL bar to update.
145 * \param full true to resize everything;
146 * false to move only the right-hand end of the bar.
147 * \return true if successful; else false.
148 */
149static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
150{
151 int x0, y0, x1, y1;
152 int centre;
153 os_error *error;
154 os_coord eig = {1, 1};
155 wimp_caret caret;
156
157 if ((url_bar == NULL) ||
158 (url_bar->window == NULL)) {
159 return false;
160 }
161
162 /* calculate 1px in OS units */
163 ro_convert_pixels_to_os_units(&eig, (os_mode) -1);
164
165 /* The vertical centre line of the widget's extent. */
166 centre = url_bar->extent.y0 +
167 (url_bar->extent.y1 - url_bar->extent.y0) / 2;
168
169 /* Position the container icon. */
170 if (url_bar->container_icon != -1) {
171 x0 = url_bar->extent.x0;
172 x1 = url_bar->extent.x1 -
174
175 y0 = centre - (URLBAR_HEIGHT / 2);
176 y1 = y0 + URLBAR_HEIGHT;
177
178 error = xwimp_resize_icon(url_bar->window,
180 x0, y0, x1, y1);
181 if (error != NULL) {
182 NSLOG(netsurf, INFO,
183 "xwimp_resize_icon: 0x%x: %s",
184 error->errnum, error->errmess);
185 ro_warn_user("WimpError", error->errmess);
187 return false;
188 }
189 }
190
191 /* Position the URL Suggest icon. */
192 if (url_bar->suggest.icon != -1) {
193 x0 = url_bar->extent.x1 - url_bar->suggest.x;
194 x1 = url_bar->extent.x1;
195
196 y0 = centre - (url_bar->suggest.y / 2);
197 y1 = y0 + url_bar->suggest.y;
198
199 error = xwimp_resize_icon(url_bar->window,
201 x0, y0, x1, y1);
202 if (error != NULL) {
203 NSLOG(netsurf, INFO,
204 "xwimp_resize_icon: 0x%x: %s",
205 error->errnum, error->errmess);
206 ro_warn_user("WimpError", error->errmess);
207 url_bar->suggest.icon = -1;
208 return false;
209 }
210 }
211
212 /* Position the Text icon. */
213 if (url_bar->text.icon != -1) {
215 x1 = url_bar->extent.x1 - eig.x - URLBAR_HOTLIST_WIDTH -
217
218 y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
219 y1 = y0 + URLBAR_HEIGHT - 2 * eig.y;
220
221 error = xwimp_resize_icon(url_bar->window,
223 x0, y0, x1, y1);
224 if (error != NULL) {
225 NSLOG(netsurf, INFO,
226 "xwimp_resize_icon: 0x%x: %s",
227 error->errnum, error->errmess);
228 ro_warn_user("WimpError", error->errmess);
229 url_bar->text.icon = -1;
230 return false;
231 }
232
233 if (xwimp_get_caret_position(&caret) == NULL) {
234 if ((caret.w == url_bar->window) &&
235 (caret.i == url_bar->text.icon)) {
236 xwimp_set_caret_position(url_bar->window,
238 caret.pos.x,
239 caret.pos.y,
240 -1,
241 caret.index);
242 }
243 }
244 }
245
246 /* Position the page info icon. */
247 url_bar->pginfo.extent.x0 = url_bar->extent.x0 + eig.x;
249 url_bar->pginfo.extent.y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
251 - 2 * eig.y;
252
253 /* Position the Favicon icon. */
256 url_bar->favicon.extent.y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
258 - 2 * eig.y;
259
260 /* Position the Hotlist icon. */
261 url_bar->hotlist.extent.x0 = url_bar->extent.x1 - eig.x -
266 url_bar->hotlist.extent.y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
268 - 2 * eig.y;
269
271 url_bar->hotlist.extent.x0) -
272 (URLBAR_HOTLIST_SIZE * 2)) / 2;
274 url_bar->hotlist.extent.y0) -
275 (URLBAR_HOTLIST_SIZE * 2)) / 2 - 1;
276
277 return true;
278}
279
280
281/**
282 * Create or delete a URL bar's icons if required to bring it into sync with
283 * the current hidden setting.
284 *
285 * \param *url_bar The URL bar to update.
286 * \return true if successful; else false.
287 */
289{
290 wimp_icon_create icon;
291 os_error *error;
292 bool resize;
293
294 if ((url_bar == NULL) ||
295 (url_bar->window == NULL)) {
296 return false;
297 }
298
299 icon.w = url_bar->window;
300 icon.icon.extent.x0 = 0;
301 icon.icon.extent.y0 = 0;
302 icon.icon.extent.x1 = 0;
303 icon.icon.extent.y1 = 0;
304
305 resize = false;
306
307 /* Create or delete the container icon. */
308
309 if (!url_bar->hidden && url_bar->container_icon == -1) {
310 icon.icon.flags = wimp_ICON_BORDER |
311 (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
312 (wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT);
313 error = xwimp_create_icon(&icon, &url_bar->container_icon);
314 if (error != NULL) {
315 NSLOG(netsurf, INFO,
316 "xwimp_create_icon: 0x%x: %s",
317 error->errnum, error->errmess);
318 ro_warn_user("WimpError", error->errmess);
320 return false;
321 }
322
323 resize = true;
324 } else if ((url_bar->hidden) &&
325 (url_bar->container_icon != -1)) {
326 error = xwimp_delete_icon(url_bar->window,
328 if (error != NULL) {
329 NSLOG(netsurf, INFO,
330 "xwimp_delete_icon: 0x%x: %s",
331 error->errnum, error->errmess);
332 ro_warn_user("WimpError", error->errmess);
333 return false;
334 }
335
337 }
338
339 /* Create or delete the text icon. */
340 if (!url_bar->hidden &&
341 url_bar->text.icon == -1) {
342 icon.icon.data.indirected_text.text = url_bar->text.buffer;
343 icon.icon.data.indirected_text.validation = text_validation;
344 icon.icon.data.indirected_text.size = url_bar->text.size;
345 icon.icon.flags = wimp_ICON_TEXT |
346 wimp_ICON_INDIRECTED |
347 wimp_ICON_VCENTRED |
348 wimp_ICON_FILLED |
349 (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT);
350
351 if (url_bar->display) {
352 icon.icon.flags |= (wimp_BUTTON_NEVER <<
353 wimp_ICON_BUTTON_TYPE_SHIFT);
354 } else if (!ns_wimp_has_text_selection()) {
355 icon.icon.flags |= (wimp_BUTTON_WRITE_CLICK_DRAG <<
356 wimp_ICON_BUTTON_TYPE_SHIFT);
357 } else {
358 icon.icon.flags |= (wimp_BUTTON_WRITABLE <<
359 wimp_ICON_BUTTON_TYPE_SHIFT);
360 }
361 error = xwimp_create_icon(&icon, &url_bar->text.icon);
362 if (error) {
363 NSLOG(netsurf, INFO,
364 "xwimp_create_icon: 0x%x: %s",
365 error->errnum, error->errmess);
366 ro_warn_user("WimpError", error->errmess);
367 url_bar->text.icon = -1;
368 return false;
369 }
370
371 resize = true;
372
373 } else if (url_bar->hidden &&
374 url_bar->text.icon != -1) {
375 error = xwimp_delete_icon(url_bar->window,
376 url_bar->text.icon);
377 if (error != NULL) {
378 NSLOG(netsurf, INFO,
379 "xwimp_delete_icon: 0x%x: %s",
380 error->errnum, error->errmess);
381 ro_warn_user("WimpError", error->errmess);
382 return false;
383 }
384
385 url_bar->text.icon = -1;
386 }
387
388 /* Create or delete the suggest icon. */
389 if (!url_bar->hidden &&
390 url_bar->suggest.icon == -1) {
391 icon.icon.data.indirected_text.text = null_text_string;
392 icon.icon.data.indirected_text.size = 1;
393 icon.icon.data.indirected_text.validation = suggest_validation;
394 icon.icon.flags = wimp_ICON_TEXT |
395 wimp_ICON_SPRITE |
396 wimp_ICON_INDIRECTED |
397 wimp_ICON_HCENTRED |
398 wimp_ICON_VCENTRED |
399 (wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
400
401 error = xwimp_create_icon(&icon, &url_bar->suggest.icon);
402 if (error) {
403 NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
404 error->errnum, error->errmess);
405 ro_warn_user("WimpError", error->errmess);
406 return false;
407 }
408
409 if (!url_bar->display)
411 wimp_ICON_WINDOW,
414
416 return false;
417 }
418
419 resize = true;
420
421 } else if (url_bar->hidden &&
422 url_bar->suggest.icon != -1) {
425 error = xwimp_delete_icon(url_bar->window,
427 if (error != NULL) {
428 NSLOG(netsurf, INFO,
429 "xwimp_delete_icon: 0x%x: %s",
430 error->errnum, error->errmess);
431 ro_warn_user("WimpError", error->errmess);
432 return false;
433 }
434
435 url_bar->suggest.icon = -1;
436 }
437
438 /* If any icons were created, resize the bar. */
439 if (resize && !ro_gui_url_bar_icon_resize(url_bar, true)) {
440 return false;
441 }
442
443 /* If there are any icons, apply shading as necessary. */
444 if (url_bar->container_icon != -1) {
447 url_bar->shaded);
448 }
449
450 if (url_bar->text.icon != -1) {
453 url_bar->shaded);
454 }
455
456 if (url_bar->suggest.icon != -1) {
459 url_bar->shaded);
460 }
461
462 return true;
463}
464
465
466/**
467 * Set the state of a URL Bar's hotlist icon.
468 *
469 * \param *url_bar The URL Bar to update.
470 * \param set TRUE to set the hotlist icon; FALSE to clear it.
471 */
472static void ro_gui_url_bar_set_hotlist(struct url_bar *url_bar, bool set)
473{
474 if (url_bar == NULL ||
475 set == url_bar->hotlist.set) {
476 return;
477 }
478
479 url_bar->hotlist.set = set;
480
481 if (!url_bar->hidden) {
482 xwimp_force_redraw(url_bar->window,
487 }
488}
489
490
491/**
492 * Callback for hlcache.
493 */
494static nserror
496 const hlcache_event *event, void *pw)
497{
498 struct url_bar_resource *r = pw;
499
500 switch (event->type) {
502 case CONTENT_MSG_DONE:
503 r->ready = true;
504 r->height = content_get_height(handle);
505 break;
506
507 default:
508 break;
509 }
510
511 return NSERROR_OK;
512}
513
514
515/* This is an exported interface documented in url_bar.h */
517{
518 struct url_bar *url_bar;
519
520 /* Allocate memory. */
521
522 url_bar = malloc(sizeof(struct url_bar));
523 if (url_bar == NULL) {
524 NSLOG(netsurf, INFO, "No memory for malloc()");
525 return NULL;
526 }
527
528 /* Set up default parameters. */
529
532
533 url_bar->display = false;
534 url_bar->shaded = false;
535
539
540 url_bar->extent.x0 = 0;
541 url_bar->extent.y0 = 0;
542 url_bar->extent.x1 = 0;
543 url_bar->extent.y1 = 0;
544
545 url_bar->window = NULL;
547 url_bar->text.icon = -1;
548 url_bar->suggest.icon = -1;
549
550 url_bar->pginfo.extent.x0 = 0;
551 url_bar->pginfo.extent.y0 = 0;
552 url_bar->pginfo.extent.x1 = 0;
553 url_bar->pginfo.extent.y1 = 0;
554 strncpy(url_bar->pginfo.sprite,
555 "pgiinternal",
557
558 url_bar->favicon.extent.x0 = 0;
559 url_bar->favicon.extent.y0 = 0;
560 url_bar->favicon.extent.x1 = 0;
561 url_bar->favicon.extent.y1 = 0;
562 url_bar->favicon.width = 0;
564 url_bar->favicon.content = NULL;
565 url_bar->favicon.type = 0;
566 strncpy(url_bar->favicon.sprite,
567 "Ssmall_xxx",
569
570 url_bar->hotlist.set = false;
571 url_bar->hotlist.extent.x0 = 0;
572 url_bar->hotlist.extent.y0 = 0;
573 url_bar->hotlist.extent.x1 = 0;
574 url_bar->hotlist.extent.y1 = 0;
575
577 url_bar->text.buffer = malloc(url_bar->text.size);
578 if (url_bar->text.buffer == NULL) {
579 free(url_bar);
580 return NULL;
581 }
582 url_bar->text.buffer[0] = 0;
583 url_bar->text.buffer_utf8 = NULL;
584
585 url_bar->hidden = false;
586
587 return url_bar;
588}
589
590
591/* This is an exported interface documented in url_bar.h */
592bool
594 struct theme_descriptor *theme,
595 theme_style style,
596 wimp_w window,
597 bool display,
598 bool shaded)
599{
600 if (url_bar == NULL) {
601 return false;
602 }
603
606
609
611 url_bar->text.icon = -1;
612 url_bar->suggest.icon = -1;
613
614 ro_gui_wimp_get_sprite_dimensions((osspriteop_area *) -1,
616 &url_bar->suggest.x,
617 &url_bar->suggest.y);
618
625
628
630}
631
632
633/* This is an exported interface documented in url_bar.h */
635{
636 if (url_bar == NULL) {
637 return;
638 }
639
640 if (url_bar->text.buffer_utf8 != NULL) {
641 free(url_bar->text.buffer_utf8);
642 }
643
644 if (url_bar->text.buffer != NULL) {
645 free(url_bar->text.buffer);
646 }
647
648 free(url_bar);
649}
650
651
652/* This is an exported interface documented in url_bar.h */
654{
655 if (url_bar == NULL) {
656 return false;
657 }
658
659 if (url_bar->x_min != -1 &&
660 url_bar->y_min != -1) {
661 if (width != NULL) {
662 *width = url_bar->x_min;
663 }
664 if (height != NULL) {
665 *height = url_bar->y_min;
666 }
667
668 return true;
669 }
670
671 return false;
672}
673
674
675/* This is an exported interface documented in url_bar.h */
676bool
678 int x0, int y0, int x1, int y1)
679{
680 bool stretch;
681
682 if (url_bar == NULL) {
683 return false;
684 }
685
686 if ((x1 - x0) < url_bar->x_min ||
687 (y1 - y0) < url_bar->y_min) {
688 return false;
689 }
690
691 if (url_bar->extent.x0 == x0 &&
692 url_bar->extent.y0 == y0 &&
693 url_bar->extent.x1 == x1 &&
694 url_bar->extent.y1 == y1) {
695 return true;
696 }
697
698 /* If it's only the length that changes, less needs to be updated. */
699 stretch = (url_bar->extent.x0 == x0 &&
700 url_bar->extent.y0 == y0 &&
701 url_bar->extent.y1 == y1) ? true : false;
702
703 /* Redraw the relevant bits of the toolbar. */
704 if (url_bar->window != NULL &&
705 !url_bar->hidden) {
706 if (stretch) {
707 xwimp_force_redraw(url_bar->window,
709 (x1 > url_bar->extent.x1) ?
710 x1 : url_bar->extent.x1, y1);
711 } else {
712 xwimp_force_redraw(url_bar->window,
713 url_bar->extent.x0,
714 url_bar->extent.y0,
715 url_bar->extent.x1,
716 url_bar->extent.y1);
717 xwimp_force_redraw(url_bar->window, x0, y0, x1, y1);
718 }
719 }
720
721 /* Reposition the URL bar icons. */
722 url_bar->extent.x0 = x0;
723 url_bar->extent.y0 = y0;
724 url_bar->extent.x1 = x1;
725 url_bar->extent.y1 = y1;
726
727 return ro_gui_url_bar_icon_resize(url_bar, !stretch);
728}
729
730
731/* This is an exported interface documented in url_bar.h */
732bool ro_gui_url_bar_hide(struct url_bar *url_bar, bool hide)
733{
734 if (url_bar == NULL || url_bar->hidden == hide)
735 return (url_bar == NULL) ? false : true;
736
737 url_bar->hidden = hide;
738
740}
741
742
743/* This is an exported interface documented in url_bar.h */
744void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
745{
746 wimp_icon icon;
747 struct rect clip;
748 bool draw_pginfo = true;
749 bool draw_favicon = true;
750 bool draw_hotlist = true;
751
752 /* Test for a valid URL bar */
753 if (url_bar == NULL || url_bar->hidden)
754 return;
755
756 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
757 (url_bar->pginfo.extent.x1) ||
758 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
759 (url_bar->pginfo.extent.y1) ||
760 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
761 (url_bar->pginfo.extent.x0) ||
762 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
763 (url_bar->pginfo.extent.y0)) {
764 /* page info not in redraw area */
765 draw_pginfo = false;
766 }
767
768 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
769 (url_bar->favicon.extent.x1) ||
770 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
771 (url_bar->favicon.extent.y1) ||
772 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
773 (url_bar->favicon.extent.x0) ||
774 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
775 (url_bar->favicon.extent.y0)) {
776 /* Favicon not in redraw area */
777 draw_favicon = false;
778 }
779
780 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
781 (url_bar->hotlist.extent.x1) ||
782 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
783 (url_bar->hotlist.extent.y1) ||
784 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
785 (url_bar->hotlist.extent.x0) ||
786 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
787 (url_bar->hotlist.extent.y0)) {
788 /* Hotlist icon not in redraw area */
789 draw_hotlist = false;
790 }
791
792 if (draw_pginfo) {
793 icon.flags = wimp_ICON_SPRITE |
794 wimp_ICON_INDIRECTED |
795 wimp_ICON_FILLED |
796 wimp_ICON_HCENTRED |
797 wimp_ICON_VCENTRED |
798 (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
799 icon.data.indirected_sprite.id = (osspriteop_id)url_bar->pginfo.sprite;
800 icon.data.indirected_sprite.area = url_bar->sprites;
801 icon.data.indirected_sprite.size = 12;
802
803 icon.extent.x0 = url_bar->pginfo.extent.x0;
804 icon.extent.x1 = url_bar->pginfo.extent.x1;
805 icon.extent.y0 = url_bar->pginfo.extent.y0;
806 icon.extent.y1 = url_bar->pginfo.extent.y1;
807
808 xwimp_plot_icon(&icon);
809 }
810
811 if (draw_favicon) {
812 if (url_bar->favicon.content == NULL) {
813 icon.data.indirected_text.text = null_text_string;
814 icon.data.indirected_text.validation =
816 icon.data.indirected_text.size = 1;
817 icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
818 wimp_ICON_INDIRECTED |
819 wimp_ICON_FILLED |
820 wimp_ICON_HCENTRED |
821 wimp_ICON_VCENTRED;
822 icon.extent.x0 = url_bar->favicon.extent.x0;
823 icon.extent.x1 = url_bar->favicon.extent.x1;
824 icon.extent.y0 = url_bar->favicon.extent.y0;
825 icon.extent.y1 = url_bar->favicon.extent.y1;
826
827 xwimp_plot_icon(&icon);
828 } else {
829 struct content_redraw_data data;
830 struct redraw_context ctx = {
831 .interactive = true,
832 .background_images = true,
833 .plot = &ro_plotters
834 };
835
836 xwimp_set_colour(wimp_COLOUR_WHITE);
837 xos_plot(os_MOVE_TO,
838 (redraw->box.x0 - redraw->xscroll) +
840 (redraw->box.y1 - redraw->yscroll) +
842 xos_plot(os_PLOT_TO | os_PLOT_RECTANGLE,
843 (redraw->box.x0 - redraw->xscroll) +
845 (redraw->box.y1 - redraw->yscroll) +
847
848 clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
849 clip.y0 = (ro_plot_origin_y - redraw->clip.y0) / 2;
850 clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
851 clip.y1 = (ro_plot_origin_y - redraw->clip.y1) / 2;
852
853 data.x = (url_bar->favicon.extent.x0 +
854 url_bar->favicon.offset.x) / 2;
855 data.y = (url_bar->favicon.offset.y -
856 url_bar->favicon.extent.y1) / 2;
857 data.width = url_bar->favicon.width;
859 data.background_colour = 0xFFFFFF;
860 data.scale = 1;
861 data.repeat_x = false;
862 data.repeat_y = false;
863
865 &data, &clip, &ctx);
866 }
867 }
868
869 if (draw_hotlist) {
870 struct content_redraw_data data;
871 struct redraw_context ctx = {
872 .interactive = true,
873 .background_images = true,
874 .plot = &ro_plotters
875 };
876 struct url_bar_resource *hotlist_icon = url_bar->hotlist.set ?
879
880 xwimp_set_colour(wimp_COLOUR_WHITE);
881 xos_plot(os_MOVE_TO,
882 (redraw->box.x0 - redraw->xscroll) +
884 (redraw->box.y1 - redraw->yscroll) +
886 xos_plot(os_PLOT_TO | os_PLOT_RECTANGLE,
887 (redraw->box.x0 - redraw->xscroll) +
889 (redraw->box.y1 - redraw->yscroll) +
891
892 if (hotlist_icon->ready == false) {
893 return;
894 }
895
896 clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
897 clip.y0 = (ro_plot_origin_y - redraw->clip.y0) / 2;
898 clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
899 clip.y1 = (ro_plot_origin_y - redraw->clip.y1) / 2;
900
901 data.x = (url_bar->hotlist.extent.x0 +
902 url_bar->hotlist.offset.x) / 2;
903 data.y = (url_bar->hotlist.offset.y -
904 url_bar->hotlist.extent.y1) / 2;
907 data.background_colour = 0xFFFFFF;
908 data.scale = 1;
909 data.repeat_x = false;
910 data.repeat_y = false;
911
912 content_redraw(hotlist_icon->c, &data, &clip, &ctx);
913 }
914}
915
916/**
917 * check if os point is inside an os box
918 *
919 * \param pos The coordinate of the point
920 * \param box The box to check against
921 * \return true if point is inside the box else false
922 */
923static inline bool is_point_in_box(os_coord *pos, os_box *box)
924{
925 if (pos->x < box->x0 ||
926 pos->x > box->x1 ||
927 pos->y < box->y0 ||
928 pos->y > box->y1) {
929 return false;
930 }
931 return true;
932}
933
934/* This is an exported interface documented in url_bar.h */
935bool
937 wimp_pointer *pointer,
938 wimp_window_state *state,
939 url_bar_action *action)
940{
941 os_coord pos;
942
943 if (url_bar == NULL || url_bar->hidden ||
945 return false;
946 }
947
948 /* Check that the click was within our part of the window. */
949 pos.x = pointer->pos.x - state->visible.x0 + state->xscroll;
950 pos.y = pointer->pos.y - state->visible.y1 + state->yscroll;
951
952 if (!is_point_in_box(&pos, &url_bar->extent)) {
953 return false;
954 }
955
956 /* If we have a Select or Adjust click, check if it originated on the
957 * hotlist icon; if it did, return an event.
958 */
959 if (pointer->buttons == wimp_SINGLE_SELECT ||
960 pointer->buttons == wimp_SINGLE_ADJUST) {
961 if (is_point_in_box(&pos, &url_bar->hotlist.extent)) {
962 if (pointer->buttons == wimp_SINGLE_SELECT &&
963 action != NULL) {
965 } else if (pointer->buttons == wimp_SINGLE_ADJUST &&
966 action != NULL) {
968 }
969 return true;
970 }
971
972 if (is_point_in_box(&pos, &url_bar->pginfo.extent)) {
973 if (pointer->buttons == wimp_SINGLE_SELECT &&
974 action != NULL) {
976 } else if (pointer->buttons == wimp_SINGLE_ADJUST &&
977 action != NULL) {
979 }
980 return true;
981 }
982
983 }
984
985 /* If we find a Select or Adjust drag, check if it originated on the
986 * URL bar or over the favicon. If either, then return an event.
987 */
988 if (pointer->buttons == wimp_DRAG_SELECT ||
989 pointer->buttons == wimp_DRAG_ADJUST) {
991 if (pointer->i == url_bar->text.icon) {
992 if (action != NULL) {
993 *action = TOOLBAR_URL_DRAG_URL;
994 }
995 return true;
996 }
997 }
998
999 if (is_point_in_box(&pos, &url_bar->favicon.extent)) {
1000 if (action != NULL) {
1001 *action = TOOLBAR_URL_DRAG_FAVICON;
1002 }
1003 return true;
1004 }
1005 }
1006
1007 return false;
1008}
1009
1010
1011/* This is an exported interface documented in url_bar.h */
1012bool
1014 wimp_i i,
1015 wimp_menu *menu,
1016 wimp_pointer *pointer)
1017{
1018 if (url_bar == NULL ||
1019 url_bar->suggest.icon != i ||
1020 menu != ro_gui_url_suggest_menu) {
1021 return false;
1022 }
1023
1024 if (pointer != NULL) {
1026 }
1027
1028 return true;
1029}
1030
1031
1032/* This is an exported interface documented in url_bar.h */
1033bool
1035 wimp_i i,
1036 wimp_menu *menu,
1037 wimp_selection *selection,
1038 menu_action action)
1039{
1040 const char *urltxt;
1041 struct gui_window *g;
1042
1043 if (url_bar == NULL ||
1044 url_bar->suggest.icon != i ||
1045 menu != ro_gui_url_suggest_menu) {
1046 return false;
1047 }
1048
1051
1052 if (urltxt != NULL &&
1053 g != NULL &&
1054 g->bw != NULL) {
1055 nsurl *url;
1056 nserror error;
1057
1058 error = nsurl_create(urltxt, &url);
1059 if (error != NSERROR_OK) {
1061 } else {
1063
1065 url,
1066 NULL,
1068 NULL,
1069 NULL,
1070 NULL);
1072 }
1073 }
1074
1075 return true;
1076}
1077
1078
1079/* This is an exported interface documented in url_bar.h */
1080bool
1082 wimp_i i,
1083 os_coord *mouse,
1084 wimp_window_state *state,
1085 wimp_mouse_state buttons,
1086 const char **suffix)
1087{
1088 os_coord pos;
1089
1090 if (url_bar == NULL || url_bar->hidden) {
1091 return false;
1092 }
1093
1094 /* Check that the click was within our part of the window. */
1095
1096 pos.x = mouse->x - state->visible.x0 + state->xscroll;
1097 pos.y = mouse->y - state->visible.y1 + state->yscroll;
1098
1099 if (pos.x < url_bar->extent.x0 ||
1100 pos.x > url_bar->extent.x1 ||
1101 pos.y < url_bar->extent.y0 ||
1102 pos.y > url_bar->extent.y1) {
1103 return false;
1104 }
1105
1106 /* Return hard-coded icon numbers that match the ones that were
1107 * always allocated to the URL bar in a previous implementation.
1108 * If Messages can be updated, this could be changed.
1109 */
1110
1111 if (i == url_bar->text.icon) {
1112 *suffix = "14";
1113 } else if (i == url_bar->suggest.icon) {
1114 *suffix = "15";
1115 } else if (pos.x >= url_bar->hotlist.extent.x0 &&
1116 pos.x <= url_bar->hotlist.extent.x1 &&
1117 pos.y >= url_bar->hotlist.extent.y0 &&
1118 pos.y <= url_bar->hotlist.extent.y1) {
1119 *suffix = "Hot";
1120 } else if (pos.x >= url_bar->favicon.extent.x0 &&
1121 pos.x <= url_bar->favicon.extent.x1 &&
1122 pos.y >= url_bar->favicon.extent.y0 &&
1123 pos.y <= url_bar->favicon.extent.y1) {
1124 *suffix = "Fav";
1125 } else {
1126 *suffix = "";
1127 }
1128
1129 return true;
1130}
1131
1132
1133/* This is an exported interface documented in url_bar.h */
1135{
1136 os_error *error;
1137
1138 if (url_bar == NULL || url_bar->hidden) {
1139 return false;
1140 }
1141
1142 error = xwimp_set_caret_position(url_bar->window,
1143 url_bar->text.icon,
1144 -1, -1, -1, 0);
1145 if (error) {
1146 NSLOG(netsurf, INFO,
1147 "xwimp_set_caret_position: 0x%x: %s",
1148 error->errnum, error->errmess);
1149 ro_warn_user("WimpError", error->errmess);
1150
1151 return false;
1152 }
1153
1154 return true;
1155}
1156
1157
1158/* This is an exported interface documented in url_bar.h */
1159void
1161 const char *url,
1162 bool is_utf8,
1163 bool set_caret)
1164{
1165 wimp_caret caret;
1166 os_error *error;
1167 char *local_text = NULL;
1168 const char *local_url;
1169 nsurl *n;
1170
1171 if (url_bar == NULL ||
1172 url_bar->text.buffer == NULL ||
1173 url == NULL) {
1174 return;
1175 }
1176
1177 /* Before we do anything with the URL, get it into local encoding so
1178 * that behaviour is consistent with the rest of the URL Bar module
1179 * (which will act on the icon's text buffer, which is always in local
1180 * encoding).
1181 */
1182
1183 if (is_utf8) {
1184 nserror err;
1185
1186 err = utf8_to_local_encoding(url, 0, &local_text);
1187 if (err != NSERROR_OK) {
1188 /* A bad encoding should never happen, so assert this */
1189 assert(err != NSERROR_BAD_ENCODING);
1190 NSLOG(netsurf, INFO, "utf8_to_enc failed");
1191 /* Paranoia */
1192 local_text = NULL;
1193 }
1194 local_url = (local_text != NULL) ? local_text : url;
1195 } else {
1196 local_url = url;
1197 }
1198
1199 /* Copy the text into the icon buffer. If the text is too long, truncate
1200 * for URL bar and log the full URL.
1201 */
1202 if (strlen(local_url) >= url_bar->text.size) {
1203 NSLOG(netsurf, WARNING,
1204 "URL too long to show in URL bar (%zu chars): %s",
1205 strlen(url), url);
1206 }
1207
1208 strncpy(url_bar->text.buffer, local_url, url_bar->text.size - 1);
1209 url_bar->text.buffer[url_bar->text.size - 1] = '\0';
1210
1211 if (local_text != NULL) {
1212 free(local_text);
1213 }
1214
1215 /* Set the hotlist flag. */
1216 if (nsurl_create(url, &n) == NSERROR_OK) {
1218 nsurl_unref(n);
1219 }
1220
1221 /* If there's no icon, then there's nothing else to do... */
1222 if (url_bar->text.icon == -1) {
1223 return;
1224 }
1225
1226 /* ...if there is, redraw the icon and fix the caret's position. */
1228
1229 error = xwimp_get_caret_position(&caret);
1230 if (error) {
1231 NSLOG(netsurf, INFO,
1232 "xwimp_get_caret_position: 0x%x: %s",
1233 error->errnum, error->errmess);
1234 ro_warn_user("WimpError", error->errmess);
1235 return;
1236 }
1237
1238 if (set_caret ||
1239 (caret.w == url_bar->window &&
1240 caret.i == url_bar->text.icon)) {
1241 const char *set_url;
1243 url_bar->text.icon);
1244
1245 error = xwimp_set_caret_position(url_bar->window,
1246 url_bar->text.icon,
1247 0, 0, -1,
1248 strlen(set_url));
1249 if (error) {
1250 NSLOG(netsurf, INFO,
1251 "xwimp_set_caret_position: 0x%x: %s",
1252 error->errnum,
1253 error->errmess);
1254 ro_warn_user("WimpError", error->errmess);
1255 }
1256 }
1257}
1258
1259
1260/* This is an exported interface documented in url_bar.h */
1262{
1263 const char *url;
1264 nsurl *n;
1265
1266 if (url_bar == NULL) {
1267 return;
1268 }
1269
1270 url = (const char *) url_bar->text.buffer;
1271 if (url != NULL &&
1272 nsurl_create(url, &n) == NSERROR_OK) {
1274 nsurl_unref(n);
1275 }
1276}
1277
1278
1279/* This is an exported interface documented in url_bar.h */
1281{
1282 nserror res;
1283
1284 if ((url_bar == NULL) ||
1285 (url_bar->text.buffer == NULL)) {
1286 return NULL;
1287 }
1288
1289 if (url_bar->text.buffer_utf8 != NULL) {
1290 free(url_bar->text.buffer_utf8);
1291 url_bar->text.buffer_utf8 = NULL;
1292 }
1293
1294 if (url_bar->text.buffer[0] == '\0') {
1295 return (const char *) url_bar->text.buffer;
1296 }
1297
1300 if (res == NSERROR_OK) {
1301 return (const char *)url_bar->text.buffer_utf8;
1302 }
1303
1304 return (const char *) url_bar->text.buffer;
1305}
1306
1307
1308/* This is an exported interface documented in url_bar.h */
1309bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent)
1310{
1311 wimp_icon_state state;
1312 os_error *error;
1313
1314 if (url_bar == NULL || url_bar->hidden) {
1315 return false;
1316 }
1317
1318 if (extent == NULL) {
1319 return true;
1320 }
1321
1322 state.w = url_bar->window;
1324 error = xwimp_get_icon_state(&state);
1325 if (error) {
1326 NSLOG(netsurf, INFO,
1327 "xwimp_get_icon_state: 0x%x: %s",
1328 error->errnum, error->errmess);
1329 ro_warn_user("WimpError", error->errmess);
1330 return false;
1331 }
1332
1333 extent->x0 = state.icon.extent.x0;
1334 extent->y0 = state.icon.extent.y0;
1335 extent->x1 = state.icon.extent.x1;
1336 extent->y1 = state.icon.extent.y1;
1337
1338 return true;
1339}
1340
1341
1342/* This is an exported interface documented in url_bar.h */
1343bool
1345 wimp_pointer *pointer)
1346{
1347 if (url_bar == NULL ||
1348 url_bar->hidden ||
1349 pointer == NULL) {
1350 return false;
1351 }
1352
1353 return (pointer->w == url_bar->window &&
1354 pointer->i == url_bar->text.icon) ? true : false;
1355}
1356
1357
1358/* This is an exported interface documented in url_bar.h */
1359bool
1361 wimp_key *key)
1362{
1363 const char *url;
1364 nsurl *n;
1365
1366 if (url_bar == NULL ||
1367 url_bar->hidden ||
1368 key == NULL) {
1369 return false;
1370 }
1371
1372 if (key->w != url_bar->window ||
1373 key->i != url_bar->text.icon) {
1374 return false;
1375 }
1376
1377 /* Update hotlist indicator */
1378
1379 url = (const char *) url_bar->text.buffer;
1380 if (url != NULL &&
1381 nsurl_create(url, &n) == NSERROR_OK) {
1383 nsurl_unref(n);
1384 } else if (url_bar->hotlist.set) {
1386 }
1387
1388 return true;
1389}
1390
1391
1392/* This is an exported interface documented in url_bar.h */
1393bool
1395 struct hlcache_handle *h)
1396{
1398
1399 if (url_bar == NULL) {
1400 return false;
1401 }
1402
1403 if (h != NULL) {
1405 }
1406
1407 // \TODO -- Maybe test for CONTENT_ICO ???
1408
1409 if (type == CONTENT_IMAGE) {
1410 url_bar->favicon.content = h;
1413
1416 }
1417
1420 }
1421
1423 url_bar->favicon.extent.x0) -
1424 (url_bar->favicon.width * 2)) / 2;
1426 url_bar->favicon.extent.y0) -
1427 (url_bar->favicon.height * 2)) / 2;
1428 } else {
1429 url_bar->favicon.content = NULL;
1430
1431 if (url_bar->favicon.type != 0) {
1432 snprintf(url_bar->favicon.sprite,
1434 "Ssmall_%.3x", url_bar->favicon.type);
1435 } else {
1436 snprintf(url_bar->favicon.sprite,
1438 "Ssmall_xxx");
1439 }
1440 }
1441
1442 if (!url_bar->hidden) {
1443 xwimp_force_redraw(url_bar->window,
1447 url_bar->favicon.extent.y1);
1448 }
1449
1450 return true;
1451}
1452
1453
1454/* This is an exported interface documented in url_bar.h */
1456{
1458 const char *icon_name;
1459 struct gui_window *g;
1460
1462
1464
1465 switch (pistate) {
1466 case PAGE_STATE_LOCAL:
1467 icon_name = "pgilocal";
1468 break;
1469
1471 icon_name = "pgiinsecure";
1472 break;
1473
1475 icon_name = "pgiwarning";
1476 break;
1477
1479 icon_name = "pgiwarning";
1480 break;
1481
1482 case PAGE_STATE_SECURE:
1483 icon_name = "pgisecure";
1484 break;
1485
1487 default:
1488 icon_name = "pgiinternal";
1489 break;
1490 }
1491
1492 strncpy(url_bar->pginfo.sprite, icon_name, URLBAR_PGINFO_NAME_LENGTH);
1493
1494 if (!url_bar->hidden) {
1495 xwimp_force_redraw(url_bar->window,
1496 url_bar->pginfo.extent.x0,
1497 url_bar->pginfo.extent.y0,
1498 url_bar->pginfo.extent.x1,
1499 url_bar->pginfo.extent.y1);
1500 }
1501
1502 return true;
1503}
1504
1505
1506/* This is an exported interface documented in url_bar.h */
1507bool
1509 struct gui_window *g)
1510{
1511 int type = 0;
1512 char sprite[URLBAR_FAVICON_NAME_LENGTH-1];
1513 struct hlcache_handle *h;
1514
1515 if (url_bar == NULL ||
1516 g == NULL) {
1517 return false;
1518 }
1519
1521 if (h != NULL) {
1523 }
1524
1525 if (type != 0) {
1526 snprintf(sprite, URLBAR_FAVICON_NAME_LENGTH,
1527 "small_%.3x", type);
1528
1529 if (!ro_gui_wimp_sprite_exists(sprite)) {
1530 type = 0;
1531 }
1532 }
1533
1535
1536 if (url_bar->favicon.content == NULL) {
1537 if (type == 0) {
1538 snprintf(url_bar->favicon.sprite,
1539 URLBAR_FAVICON_NAME_LENGTH, "Ssmall_xxx");
1540 } else {
1541 snprintf(url_bar->favicon.sprite,
1542 URLBAR_FAVICON_NAME_LENGTH, "S%s", sprite);
1543 }
1544
1545 if (!url_bar->hidden) {
1546 xwimp_force_redraw(url_bar->window,
1550 url_bar->favicon.extent.y1);
1551 }
1552 }
1553
1554 return true;
1555}
1556
1557
1558/* This is an exported interface documented in url_bar.h */
1560{
1561 if (url_bar == NULL ||
1562 url_bar->hidden) {
1563 return (url_bar == NULL) ? false : true;
1564 }
1565
1566 if (url_bar->window != NULL &&
1567 url_bar->suggest.icon != -1) {
1571 }
1572
1573 return true;
1574}
1575
1576
1577/* Exported interface, documented in url_bar.h */
1579{
1580 int i;
1581
1582 for (i = 0; i < URLBAR_RES_LAST; i++) {
1583 nsurl *url;
1584 if (nsurl_create(url_bar_res[i].url, &url) == NSERROR_OK) {
1586 0,
1587 NULL,
1588 NULL,
1590 &(url_bar_res[i]),
1591 NULL,
1593 &(url_bar_res[i].c));
1594 nsurl_unref(url);
1595 }
1596 }
1597
1598 return true;
1599}
1600
1601
1602/* Exported interface, documented in url_bar.h */
1604{
1605 int i;
1606
1607 for (i = 0; i < URLBAR_RES_LAST; i++) {
1609 }
1610}
menu_action
Definition: scaffolding.h:77
Browser window creation and manipulation interface.
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.
browser_window_page_info_state
Browser window page information states.
@ PAGE_STATE_INSECURE
Insecure page load.
@ PAGE_STATE_SECURE_ISSUES
Secure load, but has insecure elements.
@ PAGE_STATE_SECURE
Secure load.
@ PAGE_STATE_SECURE_OVERRIDE
Secure load, but had to override.
@ PAGE_STATE_LOCAL
Page loaded from file:/// etc.
@ PAGE_STATE_INTERNAL
Page loaded from internal handler.
browser_window_page_info_state browser_window_get_page_info_state(const struct browser_window *bw)
Request the current browser window page info state.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
content_type
The type of a content.
Definition: content_type.h:53
@ CONTENT_IMAGE
All images.
Definition: content_type.h:67
@ CONTENT_NONE
no type for content
Definition: content_type.h:55
@ CONTENT_MSG_DONE
content has finished processing
Definition: content_type.h:119
@ CONTENT_MSG_READY
may be displayed
Definition: content_type.h:116
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_BAD_ENCODING
The character set is unknown.
Definition: errors.h:45
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
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
bool ro_gui_hotlist_has_page(nsurl *url)
Report whether the hotlist contains a given URL.
Definition: hotlist.c:826
Hotlist (interface).
theme_style
Theme styles, collecting groups of attributes for different locations.
Definition: theme.h:31
Browser window handling (interface).
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
Definition: hlcache.c:740
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result)
Retrieve a high-level cache handle for an object.
Definition: hlcache.c:679
High-level resource cache interface.
Public content interface.
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
Definition: content.c:558
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
Definition: content.c:1175
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
Definition: content.c:1158
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Definition: content.c:1061
Target independent plotting interface.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
Localised message support (interface).
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.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
Definition: filetype.c:243
RISC OS filetpe 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
const struct plotter_table ro_plotters
RISC OS plotter operation table.
Definition: plotters.c:727
#define RO_GUI_MAX_URL_SIZE
Definition: gui.h:33
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
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
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
Node in box tree.
Definition: box.h:177
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
Definition: box.h:280
int y
Coordinate of top padding edge, relative as for x.
Definition: box.h:284
parameters to content redraw
Definition: content.h:40
int height
vertical dimension
Definition: content.h:48
bool repeat_y
whether content is tiled in y direction
Definition: content.h:59
bool repeat_x
whether content is tiled in x direction
Definition: content.h:58
int y
coordinate for top-left of redraw
Definition: content.h:42
int x
coordinate for top-left of redraw
Definition: content.h:41
colour background_colour
The background colour.
Definition: content.h:51
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Definition: content.h:47
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
Definition: content.h:56
first entry in window list
Definition: gui.c:298
int state
Definition: window.cpp:73
char * url
Definition: gui.h:154
struct gui_window::@32 mouse
struct s_caret caret
Definition: gui.h:157
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Definition: gui.c:316
High-level cache event.
Definition: hlcache.h:43
content_msg type
Event type.
Definition: hlcache.h:44
High-level cache handle.
Definition: hlcache.c:66
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
Definition: theme.h:64
Treeview content resource data.
Definition: url_bar.c:120
const char * url
Definition: url_bar.c:121
struct hlcache_handle * c
Definition: url_bar.c:122
os_coord offset
Definition: url_bar.c:89
struct hlcache_handle * content
Definition: url_bar.c:87
int width
Definition: url_bar.c:90
int type
Definition: url_bar.c:86
char sprite[URLBAR_PGINFO_NAME_LENGTH]
Definition: url_bar.c:80
os_box extent
Definition: url_bar.c:70
bool hidden
Definition: url_bar.c:75
bool shaded
Definition: url_bar.c:77
struct theme_descriptor * theme
The applied theme (or NULL to use the default)
Definition: url_bar.c:63
char * buffer_utf8
Definition: url_bar.c:98
int y_min
Definition: url_bar.c:66
bool set
Definition: url_bar.c:108
bool display
Definition: url_bar.c:76
wimp_w window
The window and icon details.
Definition: url_bar.c:69
int y
Definition: url_bar.c:104
struct url_bar::@51 pginfo
int x
Definition: url_bar.c:103
int x_min
The widget dimensions.
Definition: url_bar.c:66
char * buffer
Definition: url_bar.c:96
size_t size
Definition: url_bar.c:97
wimp_i container_icon
Definition: url_bar.c:73
struct url_bar::@52 favicon
wimp_i icon
Definition: url_bar.c:95
struct url_bar::@53 text
int height
Definition: url_bar.c:91
struct url_bar::@55 hotlist
osspriteop_area * sprites
Definition: url_bar.c:71
struct url_bar::@54 suggest
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
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
static struct url_bar_resource url_bar_res[URLBAR_RES_LAST]
Treeview content resources.
Definition: url_bar.c:134
void ro_gui_url_bar_fini(void)
Finalise the url bar module.
Definition: url_bar.c:1603
bool ro_gui_url_bar_page_info_change(struct url_bar *url_bar)
Update the page info icon.
Definition: url_bar.c:1455
static bool is_point_in_box(os_coord *pos, os_box *box)
check if os point is inside an os box
Definition: url_bar.c:923
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
static char text_validation[]
Definition: url_bar.c:114
static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
Position the icons in the URL bar to take account of the currently configured extent.
Definition: url_bar.c:149
static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
Create or delete a URL bar's icons if required to bring it into sync with the current hidden setting.
Definition: url_bar.c:288
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
#define URLBAR_HOTLIST_SIZE
Definition: url_bar.c:51
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
static char suggest_icon[]
Definition: url_bar.c:115
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
static void ro_gui_url_bar_set_hotlist(struct url_bar *url_bar, bool set)
Set the state of a URL Bar's hotlist icon.
Definition: url_bar.c:472
#define URLBAR_PGINFO_WIDTH
Definition: url_bar.c:52
static char null_text_string[]
Definition: url_bar.c:117
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
#define URLBAR_FAVICON_WIDTH
Definition: url_bar.c:53
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_init(void)
Initialise the url bar module.
Definition: url_bar.c:1578
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
#define URLBAR_FAVICON_SIZE
Definition: url_bar.c:50
#define URLBAR_PGINFO_NAME_LENGTH
Definition: url_bar.c:58
struct url_bar * ro_gui_url_bar_create(struct theme_descriptor *theme)
Create a new url bar widget.
Definition: url_bar.c:516
#define URLBAR_HEIGHT
Definition: url_bar.c:49
#define URLBAR_FAVICON_NAME_LENGTH
Definition: url_bar.c:59
static char suggest_validation[]
Definition: url_bar.c:116
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
url_bar_resource_id
Definition: url_bar.c:127
@ URLBAR_RES_HOTLIST_ADD
Definition: url_bar.c:128
@ URLBAR_RES_HOTLIST_REMOVE
Definition: url_bar.c:129
@ URLBAR_RES_LAST
Definition: url_bar.c:130
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
#define URLBAR_HOTLIST_WIDTH
Definition: url_bar.c:54
static nserror ro_gui_url_bar_res_cb(hlcache_handle *handle, const hlcache_event *event, void *pw)
Callback for hlcache.
Definition: url_bar.c:495
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
#define URLBAR_MIN_WIDTH
Definition: url_bar.c:55
#define URLBAR_GRIGHT_GUTTER
Definition: url_bar.c:56
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).
url_bar_action
Definition: url_bar.h:33
@ 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
const char * ro_gui_url_suggest_get_selection(wimp_selection *selection)
Process a selection from the URL Suggest menu.
Definition: url_suggest.c:230
bool ro_gui_url_suggest_prepare_menu(void)
Builds the URL suggestion menu.
Definition: url_suggest.c:94
bool ro_gui_url_suggest_get_menu_available(void)
Check if there is a URL suggestion menu available for use.
Definition: url_suggest.c:81
URL Suggestion Menu (interface).
wimp_menu * ro_gui_url_suggest_menu
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite, int *width, int *height)
Get the dimensions of a sprite.
Definition: wimp.c:925
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
Definition: wimp.c:487
bool ro_gui_wimp_sprite_exists(const char *sprite)
Check if a sprite is present in the Wimp sprite pool.
Definition: wimp.c:862
const char * ro_gui_get_icon_string(wimp_w w, wimp_i i)
Read the contents of a text or sprite icon.
Definition: wimp.c:235
void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode)
Converts the supplied os_coord from pixels to OS units.
Definition: wimp.c:167
#define ro_gui_redraw_icon(w, i)
Redraws an icon.
Definition: wimp.c:184
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu)
Register an icon menu to be automatically handled.
Definition: wimp_event.c:1331
void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
Free any resources associated with a specific icon in a window.
Definition: wimp_event.c:334
Automated RISC OS WIMP event handling (interface).
A collection of grubby utilities for working with OSLib's wimp API.
static bool ns_wimp_has_text_selection(void)
Check whether the OS supports text selection in writiable icons.
Definition: wimputils.h:73
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357