summaryrefslogtreecommitdiff
path: root/frontends/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/riscos')
-rw-r--r--frontends/riscos/401login.c5
-rw-r--r--frontends/riscos/Makefile31
-rw-r--r--frontends/riscos/appdir/!Boot,feb90
-rw-r--r--frontends/riscos/appdir/!Sprites,ff9bin0 -> 1580 bytes
-rw-r--r--frontends/riscos/appdir/!Sprites22,ff9bin0 -> 11528 bytes
-rwxr-xr-xfrontends/riscos/appdir/5Sprites,ff9bin0 -> 30964 bytes
-rwxr-xr-xfrontends/riscos/appdir/5Sprites11,ff9bin0 -> 64228 bytes
-rwxr-xr-xfrontends/riscos/appdir/5Sprites22,ff9bin0 -> 40800 bytes
-rwxr-xr-xfrontends/riscos/appdir/ASprites,ff9bin0 -> 3664 bytes
-rwxr-xr-xfrontends/riscos/appdir/ASprites11,ff9bin0 -> 15892 bytes
-rwxr-xr-xfrontends/riscos/appdir/ASprites22,ff9bin0 -> 12668 bytes
-rw-r--r--frontends/riscos/appdir/ChkSprites,ffbbin0 -> 2029 bytes
-rwxr-xr-xfrontends/riscos/appdir/Docs/online,b60bin0 -> 165 bytes
-rw-r--r--frontends/riscos/appdir/FixFonts,ffb147
-rw-r--r--frontends/riscos/appdir/KickNS,ffbbin0 -> 1511 bytes
-rwxr-xr-xfrontends/riscos/appdir/OpenChoices,feb1
-rw-r--r--frontends/riscos/appdir/OpenHelp,ffbbin0 -> 925 bytes
-rwxr-xr-xfrontends/riscos/appdir/OpenScrap,feb1
l---------frontends/riscos/appdir/Resources/AdBlock,f791
-rw-r--r--frontends/riscos/appdir/Resources/Aletheia,ffdbin0 -> 15237 bytes
l---------frontends/riscos/appdir/Resources/CSS,f791
-rw-r--r--frontends/riscos/appdir/Resources/Fonts/NSSymbol/Encoding39
-rw-r--r--frontends/riscos/appdir/Resources/Fonts/NSSymbol/IntMetrics,ff6bin0 -> 344 bytes
-rw-r--r--frontends/riscos/appdir/Resources/Fonts/NSSymbol/Outlines,ff6bin0 -> 904 bytes
l---------frontends/riscos/appdir/Resources/Icons1
-rwxr-xr-xfrontends/riscos/appdir/Resources/Image,ff9bin0 -> 111972 bytes
-rw-r--r--frontends/riscos/appdir/Resources/LangNames52
l---------frontends/riscos/appdir/Resources/Quirks,f791
-rw-r--r--frontends/riscos/appdir/Resources/SearchEngines22
-rwxr-xr-xfrontends/riscos/appdir/Resources/Sprites,ff9bin0 -> 77336 bytes
l---------frontends/riscos/appdir/Resources/ca-bundle1
l---------frontends/riscos/appdir/Resources/de/Messages1
l---------frontends/riscos/appdir/Resources/de/welcome.html,faf1
-rw-r--r--frontends/riscos/appdir/Resources/en/!Help14
l---------frontends/riscos/appdir/Resources/en/Messages1
l---------frontends/riscos/appdir/Resources/en/credits.html,faf1
l---------frontends/riscos/appdir/Resources/en/licence.html,faf1
l---------frontends/riscos/appdir/Resources/en/maps.html,faf1
l---------frontends/riscos/appdir/Resources/en/welcome.html,faf1
l---------frontends/riscos/appdir/Resources/fr/Messages1
l---------frontends/riscos/appdir/Resources/internal.css,f791
l---------frontends/riscos/appdir/Resources/it/Messages1
l---------frontends/riscos/appdir/Resources/it/credits.html,faf1
l---------frontends/riscos/appdir/Resources/it/licence.html,faf1
l---------frontends/riscos/appdir/Resources/it/welcome.html,faf1
l---------frontends/riscos/appdir/Resources/ja/welcome.html,faf1
l---------frontends/riscos/appdir/Resources/netsurf.png,b601
-rw-r--r--frontends/riscos/appdir/Resources/nl/!Help15
l---------frontends/riscos/appdir/Resources/nl/Messages1
l---------frontends/riscos/appdir/Resources/nl/credits.html,faf1
l---------frontends/riscos/appdir/Resources/nl/licence.html,faf1
l---------frontends/riscos/appdir/Resources/nl/welcome.html,faf1
-rw-r--r--frontends/riscos/bitmap.c32
-rw-r--r--frontends/riscos/buffer.c36
-rw-r--r--frontends/riscos/configure.c32
-rw-r--r--frontends/riscos/configure/con_image.c5
-rw-r--r--frontends/riscos/configure/con_language.c6
-rw-r--r--frontends/riscos/configure/con_theme.c23
-rw-r--r--frontends/riscos/content-handlers/artworks.c48
-rw-r--r--frontends/riscos/content-handlers/draw.c10
-rw-r--r--frontends/riscos/content-handlers/sprite.c11
-rw-r--r--frontends/riscos/cookies.c6
-rw-r--r--frontends/riscos/corewindow.c190
-rw-r--r--frontends/riscos/corewindow.h4
-rw-r--r--frontends/riscos/dialog.c70
-rw-r--r--frontends/riscos/dialog.h1
-rw-r--r--frontends/riscos/download.c152
-rw-r--r--frontends/riscos/filetype.c37
-rw-r--r--frontends/riscos/font.c77
-rw-r--r--frontends/riscos/global_history.c6
-rw-r--r--frontends/riscos/gui.c154
-rw-r--r--frontends/riscos/gui.h34
-rw-r--r--frontends/riscos/gui/button_bar.c30
-rw-r--r--frontends/riscos/gui/progress_bar.c33
-rw-r--r--frontends/riscos/gui/status_bar.c83
-rw-r--r--frontends/riscos/gui/throbber.c11
-rw-r--r--frontends/riscos/gui/url_bar.c48
-rw-r--r--frontends/riscos/help.c22
-rw-r--r--frontends/riscos/history.c336
-rw-r--r--frontends/riscos/hotlist.c11
-rw-r--r--frontends/riscos/iconbar.c6
-rw-r--r--frontends/riscos/image.c20
-rw-r--r--frontends/riscos/local_history.c442
-rw-r--r--frontends/riscos/local_history.h46
-rw-r--r--frontends/riscos/menus.c31
-rw-r--r--frontends/riscos/message.c8
-rw-r--r--frontends/riscos/mouse.c5
-rw-r--r--frontends/riscos/plotters.c824
-rw-r--r--frontends/riscos/print.c316
-rw-r--r--frontends/riscos/query.c21
-rw-r--r--frontends/riscos/save.c117
-rw-r--r--frontends/riscos/save_draw.c638
-rw-r--r--frontends/riscos/save_draw.h7
-rw-r--r--frontends/riscos/schedule.c2
-rw-r--r--frontends/riscos/sslcert.c36
-rw-r--r--frontends/riscos/textarea.c127
-rw-r--r--frontends/riscos/textselection.c41
-rw-r--r--frontends/riscos/theme.c55
-rw-r--r--frontends/riscos/theme_install.c5
-rw-r--r--frontends/riscos/toolbar.c48
-rw-r--r--frontends/riscos/ucstables.c7
-rw-r--r--frontends/riscos/uri.c6
-rw-r--r--frontends/riscos/url_complete.c67
-rw-r--r--frontends/riscos/url_protocol.c19
-rw-r--r--frontends/riscos/wimp.c135
-rw-r--r--frontends/riscos/wimp_event.c76
-rw-r--r--frontends/riscos/window.c5961
-rw-r--r--frontends/riscos/window.h207
108 files changed, 6535 insertions, 4687 deletions
diff --git a/frontends/riscos/401login.c b/frontends/riscos/401login.c
index a23c01c90..4b2deb16b 100644
--- a/frontends/riscos/401login.c
+++ b/frontends/riscos/401login.c
@@ -191,7 +191,8 @@ void ro_gui_401login_close(wimp_w w)
error = xwimp_delete_window(w);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
ro_gui_wimp_event_finalise(w);
@@ -212,7 +213,7 @@ bool ro_gui_401login_apply(wimp_w w)
auth = malloc(strlen(session->uname) + strlen(session->pwd) + 2);
if (!auth) {
- LOG("calloc failed");
+ NSLOG(netsurf, INFO, "calloc failed");
ro_warn_user("NoMemory", 0);
return false;
}
diff --git a/frontends/riscos/Makefile b/frontends/riscos/Makefile
index 87790acc0..f531b6b5b 100644
--- a/frontends/riscos/Makefile
+++ b/frontends/riscos/Makefile
@@ -16,7 +16,7 @@ $(eval $(call feature_enabled,DRAW_EXPORT,-DWITH_DRAW_EXPORT,-lpencil,Drawfile e
TPD_RISCOS = $(foreach TPL,$(notdir $(TPL_RISCOS)), \
- !NetSurf/Resources/$(TPL)/Templates$(TPLEXT))
+ $(FRONTEND_SOURCE_DIR)/appdir/Resources/$(TPL)/Templates$(TPLEXT))
RESOURCES = $(TPD_RISCOS)
@@ -47,13 +47,14 @@ endif
# S_RISCOS are sources purely for the RISC OS build
S_FRONTEND := 401login.c assert.c bitmap.c buffer.c configure.c gui.c \
- dialog.c download.c filetype.c font.c help.c history.c image.c \
+ dialog.c download.c filetype.c font.c help.c image.c \
iconbar.c menus.c message.c mouse.c palettes.c plotters.c \
print.c query.c save.c save_draw.c save_pdf.c schedule.c \
search.c searchweb.c textarea.c textselection.c theme.c \
theme_install.c toolbar.c url_suggest.c wimp.c wimp_event.c \
ucstables.c uri.c url_complete.c url_protocol.c window.c \
- corewindow.c cookies.c sslcert.c global_history.c hotlist.c \
+ corewindow.c cookies.c sslcert.c hotlist.c \
+ local_history.c global_history.c \
$(addprefix content-handlers/,artworks.c awrender.s draw.c \
sprite.c) \
$(addprefix gui/,button_bar.c progress_bar.c status_bar.c \
@@ -67,16 +68,16 @@ S_FRONTEND := 401login.c assert.c bitmap.c buffer.c configure.c gui.c \
# are not yet available
SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_FRONTEND)
-EXETARGET := !NetSurf/!RunImage$(EXEEXT)
+EXETARGET := $(FRONTEND_SOURCE_DIR)/appdir/!RunImage$(EXEEXT)
# The filter and target for split messages
MESSAGES_FILTER=ro
-!NetSurf/!Run$(RUNEXT): $(FRONTEND_SOURCE_DIR)/scripts/Run $(EXETARGET)
+$(FRONTEND_SOURCE_DIR)/appdir/!Run$(RUNEXT): $(FRONTEND_SOURCE_DIR)/scripts/Run $(EXETARGET)
$(VQ)echo " MAKERUN: $@"
$(Q)$(MAKERUN) $(EXETARGET) $< $@
-!NetSurf/!Help$(RUNEXT): $(FRONTEND_SOURCE_DIR)/scripts/Help
+$(FRONTEND_SOURCE_DIR)/appdir/!Help$(RUNEXT): $(FRONTEND_SOURCE_DIR)/scripts/Help
$(VQ)echo " CP: $@"
$(Q)cp $< $@
@@ -85,16 +86,16 @@ $(DEPROOT)/squeeze.d: $(EXETARGET)
$(Q)$(SQUEEZE) -f -v $(EXETARGET)
$(Q)$(TOUCH) $@
-POSTEXES += !NetSurf/!Run$(RUNEXT) !NetSurf/!Help$(RUNEXT) $(DEPROOT)/squeeze.d
+POSTEXES += $(FRONTEND_SOURCE_DIR)/appdir/!Run$(RUNEXT) $(FRONTEND_SOURCE_DIR)/appdir/!Help$(RUNEXT) $(DEPROOT)/squeeze.d
clean-run:
- $(VQ)echo " CLEAN: !NetSurf/!Run$(RUNEXT)"
- $(Q) $(RM) !NetSurf/!Run$(RUNEXT)
+ $(VQ)echo " CLEAN: !Run$(RUNEXT)"
+ $(Q) $(RM) $(FRONTEND_SOURCE_DIR)/appdir/!Run$(RUNEXT)
clean-help:
- $(VQ)echo " CLEAN: !NetSurf/!Help$(RUNEXT)"
- $(Q) $(RM) !NetSurf/!Help$(RUNEXT)
+ $(VQ)echo " CLEAN: !Help$(RUNEXT)"
+ $(Q) $(RM) $(FRONTEND_SOURCE_DIR)/appdir/!Help$(RUNEXT)
CLEANS += clean-run clean-help
@@ -108,12 +109,12 @@ TPL_RISCOS := $(addprefix $(FRONTEND_SOURCE_DIR)/templates/,$(TPL_RISCOS))
# Template target creation macro
define compile_template
-!NetSurf/Resources/$(1)/Templates$$(TPLEXT): $(2)
+$(FRONTEND_SOURCE_DIR)/appdir/Resources/$(1)/Templates$$(TPLEXT): $(2)
$$(VQ)echo "TEMPLATE: $(2)"
- $$(Q)$$(MKDIR) -p !NetSurf/Resources/$(1)
+ $$(Q)$$(MKDIR) -p $(FRONTEND_SOURCE_DIR)/appdir/Resources/$(1)
$$(Q)$$(CC) -x c -E -P $$(CFLAGS) $(2) | $$(CCRES) - $$@
-CLEAN_TEMPLATES += !NetSurf/Resources/$(1)/Templates$$(TPLEXT)
+CLEAN_TEMPLATES += $(FRONTEND_SOURCE_DIR)/appdir/Resources/$(1)/Templates$$(TPLEXT)
endef
@@ -141,7 +142,7 @@ package-riscos: netsurf.zip
netsurf.zip: $(EXETARGET)
$(eval $@_TMPDIR := $(shell mktemp -d))
$(Q) $(RM) $@
- $(Q) rsync --archive --verbose $(CURDIR)/!NetSurf $($@_TMPDIR)
+ $(Q) cp -rLvp $(FRONTEND_SOURCE_DIR)/appdir $($@_TMPDIR)/!NetSurf
$(Q) $(CURDIR)/utils/git-date.sh $(FRONTEND_SOURCE_DIR)/distribution
$(Q) rsync --archive --verbose $(FRONTEND_SOURCE_DIR)/distribution/!Boot $($@_TMPDIR)
$(Q) rsync --archive --verbose $(FRONTEND_SOURCE_DIR)/distribution/!System $($@_TMPDIR)
diff --git a/frontends/riscos/appdir/!Boot,feb b/frontends/riscos/appdir/!Boot,feb
new file mode 100644
index 000000000..ca7a3feec
--- /dev/null
+++ b/frontends/riscos/appdir/!Boot,feb
@@ -0,0 +1,90 @@
+| Boot file for NetSurf. ( $Revision$ )
+|
+| This file sets up various system variables which NetSurf may use.
+| Additionally, it places the NetSurf application sprites into the Wimp
+| sprite pool.
+|
+| This file may be executed in two ways:
+| 1. When NetSurf is first seen by the OS.
+| 2. When NetSurf is run by the user (called from the !Run file).
+| In the first instance, NetSurf-specific variables are set and non
+| NetSurf-specific variables which are unset are initialised.
+| In the second instance, all variables are set, irrespective of their
+| previous state. This is achieved by use of the NetSurf$ForceVars
+| variable, which is set by the !Run file prior to calling this file.
+
+| Set up NetSurf$Dir
+If (("<NetSurf$Dir>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Dir <Obey$Dir>
+
+| Filetype -> Type name mappings
+|
+| These get set whether they were previously set or not
+Set File$Type_132 ICO
+Set File$Type_695 GIF
+Set File$Type_69C BMP
+Set File$Type_AAD SVG
+Set File$Type_ADF PDF
+Set File$Type_B28 URL
+Set File$Type_B60 PNG
+Set File$Type_C85 JPEG
+Set File$Type_F78 JNG
+Set File$Type_F79 CSS
+Set File$Type_F81 JSScript
+Set File$Type_F83 MNG
+Set File$Type_F91 URI
+Set File$Type_FAF HTML
+
+| Application system variables
+|
+| See http://www.iyonix.com/32bit/help.shtml for more details.
+If (("<NetSurf$Help>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Help <NetSurf$Dir>.Docs.docs_en
+If (("<NetSurf$Web>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Web "http://www.netsurf-browser.org/"
+If (("<NetSurf$Title>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Title "NetSurf"
+If (("<NetSurf$Publisher>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Publisher "The NetSurf Developers"
+If (("<NetSurf$Description>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set NetSurf$Description "Web browser"
+
+| NetSurf Sprites
+Set NetSurf$Sprites "!Sprites"
+/<NetSurf$Dir>.ChkSprites
+IconSprites <NetSurf$Dir>.<NetSurf$Sprites>
+Unset NetSurf$Sprites
+
+| Acorn URI protocol
+|
+| Format: Alias$Open_URI_<scheme> <command to run>
+|
+| These are basically a last resort. The URI module will initially broadcast
+| Message_URI_MProcess. If this isn't claimed, then it'll check if an
+| appropriate Alias$Open_URI_<scheme> variable is set. If such a variable
+| exists, then it will attempt to launch the task named by the variable.
+| If the launch is successful, the Message_URI_MProcess is rebroadcast.
+| The -nowin is required to ensure only one window is opened (this only has
+| an effect if the user has configured auto window opening at startup).
+If (("<Alias$Open_URI_http>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$Open_URI_http /<NetSurf$Dir>.!Run -nowin
+If (("<Alias$Open_URI_https>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$Open_URI_https /<NetSurf$Dir>.!Run -nowin
+If (("<Alias$Open_URI_file>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$Open_URI_file /<NetSurf$Dir>.!Run -nowin
+
+| ANT URL protocol
+|
+| Format: Alias$URLOpen_<scheme> <command to run>
+|
+| These handle the "load" stage of the protocol. The appropriate variable's
+| existence is checked then, if it is present, the URL to be opened is
+| appended to the string "URLOpen_<scheme> " and this is then fed to
+| Wimp_StartTask.
+If (("<Alias$URLOpen_http>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$URLOpen_http /<NetSurf$Dir>.!Run -url %%*0
+If (("<Alias$URLOpen_https>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$URLOpen_https /<NetSurf$Dir>.!Run -url %%*0
+If (("<Alias$URLOpen_file>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$URLOpen_file /<NetSurf$Dir>.!Run -url %%*0
+
+| Claim HTML and URL files
+|
+| Format: Alias$@RunType_<hex> <command to run>
+|
+| Again, a fallback. The filer initially tries a DataOpen message. If that
+| bounces, it looks at these variables.
+If (("<Alias$@RunType_FAF>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$@RunType_FAF /<NetSurf$Dir>.!Run -html %%*0
+If (("<Alias$@RunType_B28>" = "") OR ("<NetSurf$ForceVars>" = "1")) Then Set Alias$@RunType_B28 /<NetSurf$Dir>.!Run -urlf %%*0
+
+| We don't claim the URI filetype as the spec tells us not to:
+| "Applications must not set an Alias$@RunType variable for the URI filetype"
+| Obviously this means that Browse/Phoenix and the Oreganos are incorrect.
diff --git a/frontends/riscos/appdir/!Sprites,ff9 b/frontends/riscos/appdir/!Sprites,ff9
new file mode 100644
index 000000000..2c7d6f648
--- /dev/null
+++ b/frontends/riscos/appdir/!Sprites,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/!Sprites22,ff9 b/frontends/riscos/appdir/!Sprites22,ff9
new file mode 100644
index 000000000..8bc3aa616
--- /dev/null
+++ b/frontends/riscos/appdir/!Sprites22,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/5Sprites,ff9 b/frontends/riscos/appdir/5Sprites,ff9
new file mode 100755
index 000000000..b0cf1c95f
--- /dev/null
+++ b/frontends/riscos/appdir/5Sprites,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/5Sprites11,ff9 b/frontends/riscos/appdir/5Sprites11,ff9
new file mode 100755
index 000000000..c039ea180
--- /dev/null
+++ b/frontends/riscos/appdir/5Sprites11,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/5Sprites22,ff9 b/frontends/riscos/appdir/5Sprites22,ff9
new file mode 100755
index 000000000..766471428
--- /dev/null
+++ b/frontends/riscos/appdir/5Sprites22,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/ASprites,ff9 b/frontends/riscos/appdir/ASprites,ff9
new file mode 100755
index 000000000..5cab2a16b
--- /dev/null
+++ b/frontends/riscos/appdir/ASprites,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/ASprites11,ff9 b/frontends/riscos/appdir/ASprites11,ff9
new file mode 100755
index 000000000..5f94dfbd9
--- /dev/null
+++ b/frontends/riscos/appdir/ASprites11,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/ASprites22,ff9 b/frontends/riscos/appdir/ASprites22,ff9
new file mode 100755
index 000000000..cc932844e
--- /dev/null
+++ b/frontends/riscos/appdir/ASprites22,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/ChkSprites,ffb b/frontends/riscos/appdir/ChkSprites,ffb
new file mode 100644
index 000000000..4e38dfba5
--- /dev/null
+++ b/frontends/riscos/appdir/ChkSprites,ffb
Binary files differ
diff --git a/frontends/riscos/appdir/Docs/online,b60 b/frontends/riscos/appdir/Docs/online,b60
new file mode 100755
index 000000000..1ef39f0c9
--- /dev/null
+++ b/frontends/riscos/appdir/Docs/online,b60
Binary files differ
diff --git a/frontends/riscos/appdir/FixFonts,ffb b/frontends/riscos/appdir/FixFonts,ffb
new file mode 100644
index 000000000..c6b73d0b0
--- /dev/null
+++ b/frontends/riscos/appdir/FixFonts,ffb
@@ -0,0 +1,147 @@
+REM Attempt to fix broken font installations which have non-Base0 copies of the
+REM ROM fonts in !Fonts on disc.
+
+ON ERROR ON ERROR OFF: PRINT REPORT$ + " (at line " + STR$ERL + ")": END
+
+DIM f$(11)
+f$() = "Corpus.Bold","Corpus.Bold.Oblique","Corpus.Medium","Corpus.Medium.Oblique","Homerton.Bold","Homerton.Bold.Oblique","Homerton.Medium","Homerton.Medium.Oblique","Trinity.Bold","Trinity.Bold.Italic","Trinity.Medium","Trinity.Medium.Italic"
+
+PRINT "FONT INSTALLATION FIX"
+PRINT
+
+PRINT "Checking ROM fonts"
+PRINT
+ok% = TRUE
+FOR f% = 0 TO 11
+ PROCcheck_rom_font(f$(f%))
+NEXT
+PRINT
+IF NOT ok% THEN
+ PRINT "One or more of the standard ROM fonts are missing!"
+ PRINT "Please contact the developers stating your RISC OS version."
+ END
+ENDIF
+
+
+PRINT "Searching for obsolete copies in Boot:Resources.!Fonts"
+PRINT
+ok% = TRUE
+FOR f% = 0 TO 11
+ PROCcheck_disc_font(f$(f%))
+NEXT
+PRINT
+IF ok% THEN
+ PRINT "No problems were found."
+ END
+ENDIF
+
+PRINT "One or more obsolete fonts were found in !Fonts."
+PRINT
+PRINT "Press Y to move these fonts to a new directory"
+PRINT "called 'ObsolFonts' and remove them from the"
+PRINT "font list ('Messages1'),"
+PRINT "or any other key to exit without changes."
+key$ = GET$
+IF INSTR("Yy", key$) = 0 THEN
+ PRINT
+ PRINT "Exiting without changes."
+ END
+ENDIF
+PRINT
+
+PRINT "Creating 'ObsolFonts' directory - ";
+SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts"
+PRINT "done"
+PRINT
+PRINT "Closing open files - ";
+SYS"OS_FSControl", 22
+PRINT "done"
+PRINT
+PRINT "Removing fonts from font list - ";
+file% = OPENIN "<Boot$Dir>.Resources.!Fonts.Messages1"
+IF file% THEN
+ new% = OPENOUT "<Boot$Dir>.Resources.!Fonts.Messages_"
+ IF new% = 0 THEN
+ PRINT "Failed to open new font list"
+ END
+ ENDIF
+ WHILE NOT EOF#file%
+ line$ = GET$#file%
+ ok% = TRUE
+ FOR f% = 0 TO 11
+ IF INSTR(line$, "Font_" + f$(f%) + ":") <> 0 THEN ok% = FALSE
+ NEXT
+ IF ok% THEN
+ BPUT#new%, line$
+ ENDIF
+ ENDWHILE
+ CLOSE#file%
+ CLOSE#new%
+ SYS"OS_File", 18, "<Boot$Dir>.Resources.!Fonts.Messages_", &fff
+ SYS"XOS_FSControl", 27, "<Boot$Dir>.^.ObsolFonts.Messages1"
+ SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages1", "<Boot$Dir>.^.ObsolFonts.Messages1"
+ SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages_", "<Boot$Dir>.Resources.!Fonts.Messages1"
+ENDIF
+PRINT "done"
+PRINT
+PRINT "Moving away obsolete fonts"
+PRINT
+FOR f% = 0 TO 11
+ PROCfix_font(f$(f%))
+NEXT
+PRINT
+PRINT "Finished"
+PRINT "Please restart your machine for the changes to take effect."
+
+END
+
+
+
+DEF PROCcheck_rom_font(f$)
+PRINT " "; f$;
+SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".Outlines0" TO t1%
+SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".IntMetric0" TO t2%
+IF t1% = 1 AND t2% = 1 THEN
+ PRINT " - ok"
+ELSE
+ PRINT " - MISSING"
+ ok% = FALSE
+ENDIF
+ENDPROC
+
+
+
+DEF PROCcheck_disc_font(f$)
+SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
+IF t% <> 0 THEN
+ PRINT " "; f$
+ ok% = FALSE
+ENDIF
+ENDPROC
+
+
+
+DEF PROCfix_font(f$)
+SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
+IF t% = 0 THEN ENDPROC
+
+PRINT " "; f$; " - ";
+i% = 0
+REPEAT
+ i% = INSTR(f$, ".", i% + 1)
+ IF i% <> 0 THEN
+ SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + LEFT$(f$, i% - 1)
+ ENDIF
+UNTIL i% = 0
+SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + f$
+
+SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines", "<Boot$Dir>.^.ObsolFonts." + f$ + ".Outlines"
+
+SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics" TO t%
+IF t% <> 0 THEN
+ SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics", "<Boot$Dir>.^.ObsolFonts." + f$ + ".IntMetrics"
+ENDIF
+
+PRINT "done"
+ENDPROC
+
diff --git a/frontends/riscos/appdir/KickNS,ffb b/frontends/riscos/appdir/KickNS,ffb
new file mode 100644
index 000000000..bc209ad02
--- /dev/null
+++ b/frontends/riscos/appdir/KickNS,ffb
Binary files differ
diff --git a/frontends/riscos/appdir/OpenChoices,feb b/frontends/riscos/appdir/OpenChoices,feb
new file mode 100755
index 000000000..06ed7be01
--- /dev/null
+++ b/frontends/riscos/appdir/OpenChoices,feb
@@ -0,0 +1 @@
+*Filer_OpenDir Choices:WWW.NetSurf
diff --git a/frontends/riscos/appdir/OpenHelp,ffb b/frontends/riscos/appdir/OpenHelp,ffb
new file mode 100644
index 000000000..8928652da
--- /dev/null
+++ b/frontends/riscos/appdir/OpenHelp,ffb
Binary files differ
diff --git a/frontends/riscos/appdir/OpenScrap,feb b/frontends/riscos/appdir/OpenScrap,feb
new file mode 100755
index 000000000..e45854bcd
--- /dev/null
+++ b/frontends/riscos/appdir/OpenScrap,feb
@@ -0,0 +1 @@
+*Filer_OpenDir <Wimp$ScrapDir>.WWW.NetSurf
diff --git a/frontends/riscos/appdir/Resources/AdBlock,f79 b/frontends/riscos/appdir/Resources/AdBlock,f79
new file mode 120000
index 000000000..8f57c43fd
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/AdBlock,f79
@@ -0,0 +1 @@
+../../../../resources/adblock.css \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/Aletheia,ffd b/frontends/riscos/appdir/Resources/Aletheia,ffd
new file mode 100644
index 000000000..9af7ea129
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Aletheia,ffd
Binary files differ
diff --git a/frontends/riscos/appdir/Resources/CSS,f79 b/frontends/riscos/appdir/Resources/CSS,f79
new file mode 120000
index 000000000..3238d9188
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/CSS,f79
@@ -0,0 +1 @@
+../../../../resources/default.css \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Encoding b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Encoding
new file mode 100644
index 000000000..c92dad17a
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Encoding
@@ -0,0 +1,39 @@
+% Encoding vector for NSSymbol
+
+% Codes 0-31
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+
+% Codes 32-33
+/H18543
+/circle
diff --git a/frontends/riscos/appdir/Resources/Fonts/NSSymbol/IntMetrics,ff6 b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/IntMetrics,ff6
new file mode 100644
index 000000000..4dcbc625d
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/IntMetrics,ff6
Binary files differ
diff --git a/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Outlines,ff6 b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Outlines,ff6
new file mode 100644
index 000000000..d2e624132
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Fonts/NSSymbol/Outlines,ff6
Binary files differ
diff --git a/frontends/riscos/appdir/Resources/Icons b/frontends/riscos/appdir/Resources/Icons
new file mode 120000
index 000000000..6820377bb
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Icons
@@ -0,0 +1 @@
+../../../../resources/icons \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/Image,ff9 b/frontends/riscos/appdir/Resources/Image,ff9
new file mode 100755
index 000000000..a61ddefd2
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Image,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/Resources/LangNames b/frontends/riscos/appdir/Resources/LangNames
new file mode 100644
index 000000000..de7c76c65
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/LangNames
@@ -0,0 +1,52 @@
+# Language names file for NetSurf
+#
+# IMPORTANT! - If you add/remove a language from this file, the
+# languages menu definition in menus.c _must_ be updated correspondingly.
+#
+lang_af:Afrikaans
+lang_bm:Bamanankan
+lang_ca:Català
+lang_cs:Cestina
+lang_cy:Cymraeg
+lang_da:Dansk
+lang_de:Deutsch
+lang_en:English
+lang_es:Español
+lang_et:Eesti
+lang_eu:euskera
+lang_ff:Fulfulde
+lang_fi:suomi
+lang_fr:français
+lang_ga:Gaeilge
+lang_gl:Galego
+lang_ha:Hausa
+lang_hr:Hrvatski
+lang_hu:Magyar
+lang_id:Bahasa indonesia
+lang_is:íslenska
+lang_it:italiano
+lang_lt:Lietuviskai
+lang_lv:Latviesu
+lang_ms:Bahasa melayu
+lang_mt:Malti
+lang_nl:Nederlands
+lang_no:Norsk
+lang_pl:Polski
+lang_pt:português
+lang_rn:Kirundi
+lang_ro:Româna
+lang_rw:Kinyarwanda
+lang_sk:Slovencina
+lang_sl:Slovenscina
+lang_so:Somali
+lang_sq:shqip
+lang_sr:Srpski
+lang_sv:svenska
+lang_sw:Kiswahili
+lang_tr:Türkçe
+lang_uz:o'zbek
+lang_vi:Tiêng Viêêt
+lang_wo:Wolof
+lang_xs:isiXhosa
+lang_yo:Yorùbá
+lang_zu:isiZulu
diff --git a/frontends/riscos/appdir/Resources/Quirks,f79 b/frontends/riscos/appdir/Resources/Quirks,f79
new file mode 120000
index 000000000..995fafc61
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Quirks,f79
@@ -0,0 +1 @@
+../../../../resources/quirks.css \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/SearchEngines b/frontends/riscos/appdir/Resources/SearchEngines
new file mode 100644
index 000000000..e7fd7cb65
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/SearchEngines
@@ -0,0 +1,22 @@
+Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|
+Yahoo|search.yahoo.com|http://search.yahoo.com/search?p=%s|http://www.yahoo.com/favicon.ico|
+Bing|www.bing.com|http://www.bing.com/search?q=%s|http://www.bing.com/favicon.ico|
+Business.com|www.business.com|http://www.business.com/search/rslt_default.asp?query=%s|http://www.business.com/favicon.ico|
+Omgili|www.omgili.com|http://www.omgili.com/AAAAA/%s.html|http://www.omgili.com/favicon.ico|
+BBC News|search.bbc.co.uk|http://search.bbc.co.uk/search?q=%s&tab=ns|http://news.bbc.co.uk/favicon.ico|
+Ubuntu Packages|packages.ubuntu.com|http://packages.ubuntu.com/search?keywords=%s|http://packages.ubuntu.com/favicon.ico|
+Creative Commons|creativecommons.org|http://creativecommons.org/?s=%s|http://creativecommons.org/favicon.ico|
+Ask.com|www.ask.com|http://www.ask.com/web?q=%s|http://www.ask.com/favicon.ico|
+Answers.com|www.answers.com|http://www.answers.com/%s|http://www.answers.com/favicon.ico|
+Dictionary.com|dictionary.reference.com|http://dictionary.reference.com/browse/%s?jss=0|http://dictionary.reference.com/favicon.ico|
+Youtube|www.youtube.com|http://www.youtube.com/results?search_query=%s|http://www.youtube.com/favicon.ico|
+AeroMp3|www.aeromp3.com|http://www.aeromp3.com/search?q=%s|http://www.aeromp3.com/favicon.ico|
+AOL|search.aol.com|http://search.aol.com/aol/search?query=%s|http://www.aol.com/favicon.ico|
+Baidu|www.baidu.com|http://www.baidu.com/s?wd=%s|http://www.baidu.com/favicon.ico|
+Amazon|www.amazon.com|http://www.amazon.com/s/ref=nb_ss_gw?field-keywords=%s|http://www.amazon.com/favicon.ico|
+Ebay|shop.ebay.com|http://shop.ebay.com/items/%s|http://www.ebay.com/favicon.ico|
+IMDB|www.imdb.com|http://www.imdb.com/find?q=%s|http://www.imdb.com/favicon.ico|
+ESPN|search.espn.go.com|http://search.espn.go.com/%s/|http://www.espn.go.com/favicon.ico|
+Wikipedia|en.wikipedia.org|http://en.wikipedia.org/w/index.php?title=Special%%3ASearch&search=%s|http://en.wikipedia.org/favicon.ico|
+DuckDuckGo|www.duckduckgo.com|http://www.duckduckgo.com/?q=%s|http://www.duckduckgo.com/favicon.ico|
+Seeks|www.seeks-project.info|https://www.seeks-project.info/search.php/search?q=%s|http://www.seeks-project.info/search.php/public/images/seek_icon_32x32_transparent.png|
diff --git a/frontends/riscos/appdir/Resources/Sprites,ff9 b/frontends/riscos/appdir/Resources/Sprites,ff9
new file mode 100755
index 000000000..bdbd6e877
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/Sprites,ff9
Binary files differ
diff --git a/frontends/riscos/appdir/Resources/ca-bundle b/frontends/riscos/appdir/Resources/ca-bundle
new file mode 120000
index 000000000..2d99c7508
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/ca-bundle
@@ -0,0 +1 @@
+../../../../resources/ca-bundle \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/de/Messages b/frontends/riscos/appdir/Resources/de/Messages
new file mode 120000
index 000000000..aa4060685
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/de/Messages
@@ -0,0 +1 @@
+../../../../../resources/de/Messages \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/de/welcome.html,faf b/frontends/riscos/appdir/Resources/de/welcome.html,faf
new file mode 120000
index 000000000..d3cfb115d
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/de/welcome.html,faf
@@ -0,0 +1 @@
+../../../../../resources/de/welcome.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/en/!Help b/frontends/riscos/appdir/Resources/en/!Help
new file mode 100644
index 000000000..977f069d8
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/!Help
@@ -0,0 +1,14 @@
+NetSurf - Open Source web browser - http://www.netsurf-browser.org/
+
+To view the full documentation, start NetSurf and choose "Help..." from the
+icon bar menu.
+
+This is a development build of NetSurf. In case of problems, please check
+for a newer development build at http://www.netsurf-browser.org/
+
+Please report any unexpected behaviour on the NetSurf bug tracker.
+This may be found at http://bugs.netsurf-browser.org/
+
+
+Alternatively, the developers are often available on Freenode in the
+channel #netsurf.
diff --git a/frontends/riscos/appdir/Resources/en/Messages b/frontends/riscos/appdir/Resources/en/Messages
new file mode 120000
index 000000000..56c2ae237
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/Messages
@@ -0,0 +1 @@
+../../../../../resources/en/Messages \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/en/credits.html,faf b/frontends/riscos/appdir/Resources/en/credits.html,faf
new file mode 120000
index 000000000..7999c6c56
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/credits.html,faf
@@ -0,0 +1 @@
+../../../../../resources/en/credits.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/en/licence.html,faf b/frontends/riscos/appdir/Resources/en/licence.html,faf
new file mode 120000
index 000000000..70371ada8
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/licence.html,faf
@@ -0,0 +1 @@
+../../../../../resources/en/licence.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/en/maps.html,faf b/frontends/riscos/appdir/Resources/en/maps.html,faf
new file mode 120000
index 000000000..4ae4f6c42
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/maps.html,faf
@@ -0,0 +1 @@
+../../../../../resources/en/maps.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/en/welcome.html,faf b/frontends/riscos/appdir/Resources/en/welcome.html,faf
new file mode 120000
index 000000000..71020bfe8
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/en/welcome.html,faf
@@ -0,0 +1 @@
+../../../../../resources/en/welcome.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/fr/Messages b/frontends/riscos/appdir/Resources/fr/Messages
new file mode 120000
index 000000000..4c321aefd
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/fr/Messages
@@ -0,0 +1 @@
+../../../../../resources/fr/Messages \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/internal.css,f79 b/frontends/riscos/appdir/Resources/internal.css,f79
new file mode 120000
index 000000000..c807a4d3d
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/internal.css,f79
@@ -0,0 +1 @@
+../../../../resources/internal.css \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/it/Messages b/frontends/riscos/appdir/Resources/it/Messages
new file mode 120000
index 000000000..7dc2ae2b1
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/it/Messages
@@ -0,0 +1 @@
+../../../../../resources/it/Messages \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/it/credits.html,faf b/frontends/riscos/appdir/Resources/it/credits.html,faf
new file mode 120000
index 000000000..e0bd9a23f
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/it/credits.html,faf
@@ -0,0 +1 @@
+../../../../../resources/it/credits.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/it/licence.html,faf b/frontends/riscos/appdir/Resources/it/licence.html,faf
new file mode 120000
index 000000000..7e8c83571
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/it/licence.html,faf
@@ -0,0 +1 @@
+../../../../../resources/it/licence.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/it/welcome.html,faf b/frontends/riscos/appdir/Resources/it/welcome.html,faf
new file mode 120000
index 000000000..6e24135ff
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/it/welcome.html,faf
@@ -0,0 +1 @@
+../../../../../resources/it/welcome.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/ja/welcome.html,faf b/frontends/riscos/appdir/Resources/ja/welcome.html,faf
new file mode 120000
index 000000000..1dfdbd7ea
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/ja/welcome.html,faf
@@ -0,0 +1 @@
+../../../../../resources/ja/welcome.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/netsurf.png,b60 b/frontends/riscos/appdir/Resources/netsurf.png,b60
new file mode 120000
index 000000000..e7fa4cb87
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/netsurf.png,b60
@@ -0,0 +1 @@
+../../../../resources/netsurf.png \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/nl/!Help b/frontends/riscos/appdir/Resources/nl/!Help
new file mode 100644
index 000000000..4eca563bc
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/nl/!Help
@@ -0,0 +1,15 @@
+NetSurf - Webbrowser (met open broncode) - http://www.netsurf-browser.org/
+
+Om alle documentatie te kunnen raadplegen: start NetSurf en kies "Help..."
+vanuit het symbolenbalkmenu.
+
+Dit is een ontwikkelversie van NetSurf. Bij problemen: kijk eerst of er een
+nieuwere versie is op http://www.netsurf-browser.org/
+
+Gelieve ook elk onverwacht gedrag van NetSurf, in het Engels te melden via
+onze 'bug tracker' op http://bugs.netsurf-browser.org/
+
+
+Een alternatief is Freenode op het kanaal #netsurf waar de ontwikkelaars
+vaak bereikbaar zijn.
+
diff --git a/frontends/riscos/appdir/Resources/nl/Messages b/frontends/riscos/appdir/Resources/nl/Messages
new file mode 120000
index 000000000..20acc40f2
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/nl/Messages
@@ -0,0 +1 @@
+../../../../../resources/nl/Messages \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/nl/credits.html,faf b/frontends/riscos/appdir/Resources/nl/credits.html,faf
new file mode 120000
index 000000000..2380aa33c
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/nl/credits.html,faf
@@ -0,0 +1 @@
+../../../../../resources/nl/credits.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/nl/licence.html,faf b/frontends/riscos/appdir/Resources/nl/licence.html,faf
new file mode 120000
index 000000000..46804ce86
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/nl/licence.html,faf
@@ -0,0 +1 @@
+../../../../../resources/nl/licence.html \ No newline at end of file
diff --git a/frontends/riscos/appdir/Resources/nl/welcome.html,faf b/frontends/riscos/appdir/Resources/nl/welcome.html,faf
new file mode 120000
index 000000000..6de5c4a73
--- /dev/null
+++ b/frontends/riscos/appdir/Resources/nl/welcome.html,faf
@@ -0,0 +1 @@
+../../../../../resources/nl/welcome.html \ No newline at end of file
diff --git a/frontends/riscos/bitmap.c b/frontends/riscos/bitmap.c
index 1a3524633..d554d54b4 100644
--- a/frontends/riscos/bitmap.c
+++ b/frontends/riscos/bitmap.c
@@ -287,7 +287,10 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
(bitmap->sprite_area), path);
if (error) {
- LOG("xosspriteop_save_sprite_file: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_save_sprite_file: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -347,7 +350,8 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
error = xosfind_openoutw(0, path, NULL, &fw);
if (error) {
- LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s",
+ error->errnum, error->errmess);
free(chunk_buf);
ro_warn_user("SaveError", error->errmess);
return false;
@@ -361,7 +365,8 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
if (!error)
error = xosgbpb_writew(fw, (byte*)p, image_size, NULL);
if (error) {
- LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosgbpb_writew: 0x%x: %s",
+ error->errnum, error->errmess);
free(chunk_buf);
xosfind_closew(fw);
ro_warn_user("SaveError", error->errmess);
@@ -406,7 +411,10 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
}
error = xosgbpb_writew(fw, (byte*)chunk_buf, dp-chunk_buf, NULL);
if (error) {
- LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosgbpb_writew: 0x%x: %s",
+ error->errnum,
+ error->errmess);
free(chunk_buf);
xosfind_closew(fw);
ro_warn_user("SaveError", error->errmess);
@@ -416,13 +424,15 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
error = xosfind_closew(fw);
if (error) {
- LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
error = xosfile_set_type(path, osfile_TYPE_SPRITE);
if (error) {
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
@@ -509,7 +519,8 @@ void riscos_bitmap_overlay_sprite(struct bitmap *bitmap,
(osspriteop_id)s,
&w, &h, NULL, NULL);
if (error) {
- LOG("xosspriteop_read_sprite_info: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosspriteop_read_sprite_info: 0x%x:%s",
+ error->errnum, error->errmess);
return;
}
sp_offset = ((s->width + 1) * 4) - w;
@@ -591,7 +602,7 @@ static osspriteop_area *thumbnail_create_8bpp(struct bitmap *bitmap)
sprite_area = (osspriteop_area *)malloc(area_size);
if (!sprite_area) {
- LOG("no memory for malloc()");
+ NSLOG(netsurf, INFO, "no memory for malloc()");
return NULL;
}
sprite_area->size = area_size;
@@ -759,7 +770,8 @@ static void thumbnail_test(void)
area_size = sizeof(osspriteop_area) +
sizeof(osspriteop_header) + sizeof(int);
if ((sprite_area = (osspriteop_area *)malloc(area_size)) == NULL) {
- LOG("Insufficient memory to perform sprite test.");
+ NSLOG(netsurf, INFO,
+ "Insufficient memory to perform sprite test.");
return;
}
sprite_area->size = area_size + 1;
@@ -791,7 +803,7 @@ nserror riscos_bitmap_render(struct bitmap *bitmap,
assert(content);
assert(bitmap);
- LOG("content %p in bitmap %p", content, bitmap);
+ NSLOG(netsurf, INFO, "content %p in bitmap %p", content, bitmap);
/* check if we have access to 32bpp sprites natively */
if (thumbnail_32bpp_available == -1) {
diff --git a/frontends/riscos/buffer.c b/frontends/riscos/buffer.c
index 7176c1c1c..c63a270db 100644
--- a/frontends/riscos/buffer.c
+++ b/frontends/riscos/buffer.c
@@ -107,7 +107,12 @@ void ro_gui_buffer_open(wimp_draw *redraw)
*/
if ((clipping.x1 < clipping.x0) ||
(clipping.y1 < clipping.y0)) {
- LOG("Invalid clipping rectangle (%i, %i) to (%i,%i)", clipping.x0, clipping.y0, clipping.x1, clipping.y1);
+ NSLOG(netsurf, INFO,
+ "Invalid clipping rectangle (%i, %i) to (%i,%i)",
+ clipping.x0,
+ clipping.y0,
+ clipping.x1,
+ clipping.y1);
return;
}
@@ -138,7 +143,7 @@ void ro_gui_buffer_open(wimp_draw *redraw)
(word_width * sprite_size.y * 4) + palette_size;
buffer = (osspriteop_area *)malloc(total_size);
if (!buffer) {
- LOG("Failed to allocate memory");
+ NSLOG(netsurf, INFO, "Failed to allocate memory");
ro_gui_buffer_free();
return;
}
@@ -149,7 +154,8 @@ void ro_gui_buffer_open(wimp_draw *redraw)
mode = tinct_SPRITE_MODE;
#else
if ((error = xwimpreadsysinfo_wimp_mode(&mode)) != NULL) {
- LOG("Error reading mode '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Error reading mode '%s'",
+ error->errmess);
ro_gui_buffer_free();
return;
}
@@ -177,7 +183,9 @@ void ro_gui_buffer_open(wimp_draw *redraw)
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), (int *)&vals);
if (error) {
- LOG("Error reading mode properties '%s'", error->errmess);
+ NSLOG(netsurf, INFO,
+ "Error reading mode properties '%s'",
+ error->errmess);
ro_gui_buffer_free();
return;
}
@@ -233,7 +241,9 @@ void ro_gui_buffer_open(wimp_draw *redraw)
}
break;
default:
- LOG("Unhandled 16bpp format from flags %d", vals.flags);
+ NSLOG(netsurf, INFO,
+ "Unhandled 16bpp format from flags %d",
+ vals.flags);
ro_gui_buffer_free();
return;
}
@@ -261,13 +271,16 @@ void ro_gui_buffer_open(wimp_draw *redraw)
}
break;
default:
- LOG("Unhandled 32bpp data format from flags %d", vals.flags);
+ NSLOG(netsurf, INFO,
+ "Unhandled 32bpp data format from flags %d",
+ vals.flags);
ro_gui_buffer_free();
return;
}
break;
default:
- LOG("Unhandled NCOLOUR value %d", vals.ncolour);
+ NSLOG(netsurf, INFO, "Unhandled NCOLOUR value %d",
+ vals.ncolour);
ro_gui_buffer_free();
return;
}
@@ -305,7 +318,7 @@ void ro_gui_buffer_open(wimp_draw *redraw)
buffer, buffer_name, palette,
clipping.x0, clipping.y0,
clipping.x1, clipping.y1)) != NULL) {
- LOG("Grab error '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Grab error '%s'", error->errmess);
ro_gui_buffer_free();
return;
}
@@ -314,7 +327,7 @@ void ro_gui_buffer_open(wimp_draw *redraw)
*/
if ((error = xosspriteop_read_save_area_size(osspriteop_PTR,
buffer, (osspriteop_id)(buffer + 1), &size)) != NULL) {
- LOG("Save area error '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Save area error '%s'", error->errmess);
ro_gui_buffer_free();
return;
}
@@ -329,7 +342,7 @@ void ro_gui_buffer_open(wimp_draw *redraw)
if ((error = xosspriteop_switch_output_to_sprite(osspriteop_PTR,
buffer, (osspriteop_id)(buffer + 1), save_area,
&context0, &context1, &context2, &context3)) != NULL) {
- LOG("Switching error '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Switching error '%s'", error->errmess);
free(save_area);
ro_gui_buffer_free();
return;
@@ -345,7 +358,8 @@ void ro_gui_buffer_open(wimp_draw *redraw)
*/
if ((error = xos_set_ecf_origin(-ro_plot_origin_x,
-ro_plot_origin_y)) != NULL) {
- LOG("Invalid ECF origin: '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Invalid ECF origin: '%s'",
+ error->errmess);
}
}
diff --git a/frontends/riscos/configure.c b/frontends/riscos/configure.c
index 9d28616ec..f4dced55b 100644
--- a/frontends/riscos/configure.c
+++ b/frontends/riscos/configure.c
@@ -212,7 +212,10 @@ void ro_gui_configure_open_window(wimp_open *open)
y + configure_icon_height -
CONFIGURE_ICON_PADDING_V);
if (error) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_resize_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
}
x += configure_icon_width;
l++;
@@ -225,7 +228,8 @@ void ro_gui_configure_open_window(wimp_open *open)
error = xwimp_force_redraw(configure_window,
0, -16384, 16384, 0);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -248,7 +252,8 @@ void ro_gui_configure_open_window(wimp_open *open)
extent.y0 = -max_height;
error = xwimp_set_extent(open->w, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -259,7 +264,8 @@ void ro_gui_configure_open_window(wimp_open *open)
/* open the window */
error = xwimp_open_window(open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -276,7 +282,7 @@ void ro_gui_configure_register(const char *window,
/* create our tool */
tool = calloc(sizeof(struct configure_tool), 1);
if (!tool) {
- LOG("Insufficient memory for calloc()");
+ NSLOG(netsurf, INFO, "Insufficient memory for calloc()");
die("Insufficient memory");
return; /* For the benefit of scan-build */
}
@@ -284,7 +290,7 @@ void ro_gui_configure_register(const char *window,
tool->translated[0] = '\0';
tool->validation = malloc(strlen(window) + 2);
if (!tool->validation) {
- LOG("Insufficient memory for malloc()");
+ NSLOG(netsurf, INFO, "Insufficient memory for malloc()");
die("Insufficient memory");
}
sprintf(tool->validation, "S%s", window);
@@ -311,7 +317,8 @@ void ro_gui_configure_register(const char *window,
CONFIGURE_TOOL_TRANSLATED_SIZE;
error = xwimp_create_icon(&new_icon, &tool->i);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
die(error->errmess);
}
@@ -360,7 +367,8 @@ bool ro_gui_configure_translate(void)
error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0,
&alphabet);
if (error) {
- LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s",
+ error->errnum, error->errmess);
/* assume Latin1 */
alphabet = territory_ALPHABET_LATIN1;
}
@@ -381,7 +389,10 @@ bool ro_gui_configure_translate(void)
error = xwimptextop_string_width(tool->translated,
strlen(tool->translated), &icon_width);
if (error) {
- LOG("xwimptextop_string_width: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimptextop_string_width: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return false;
}
icon_width += CONFIGURE_ICON_PADDING_H;
@@ -395,7 +406,8 @@ bool ro_gui_configure_translate(void)
configure_icon_width,
0);
if (error) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
diff --git a/frontends/riscos/configure/con_image.c b/frontends/riscos/configure/con_image.c
index 49dd4f76d..c7fc7f314 100644
--- a/frontends/riscos/configure/con_image.c
+++ b/frontends/riscos/configure/con_image.c
@@ -150,8 +150,9 @@ void ro_gui_options_image_redraw(wimp_draw *redraw)
icon_state.i = IMAGE_CURRENT_DISPLAY;
error = xwimp_get_icon_state(&icon_state);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
return;
}
diff --git a/frontends/riscos/configure/con_language.c b/frontends/riscos/configure/con_language.c
index 2030c65c0..77e4f6cb4 100644
--- a/frontends/riscos/configure/con_language.c
+++ b/frontends/riscos/configure/con_language.c
@@ -98,7 +98,8 @@ bool ro_gui_options_language_ok(wimp_w w)
if (temp) {
nsoption_set_charp(language, temp);
} else {
- LOG("No memory to duplicate language code");
+ NSLOG(netsurf, INFO,
+ "No memory to duplicate language code");
ro_warn_user("NoMemory", 0);
}
}
@@ -113,7 +114,8 @@ bool ro_gui_options_language_ok(wimp_w w)
if (temp) {
nsoption_set_charp(accept_language,temp);
} else {
- LOG("No memory to duplicate language code");
+ NSLOG(netsurf, INFO,
+ "No memory to duplicate language code");
ro_warn_user("NoMemory", 0);
}
}
diff --git a/frontends/riscos/configure/con_theme.c b/frontends/riscos/configure/con_theme.c
index fb0d3dfb0..28195dea9 100644
--- a/frontends/riscos/configure/con_theme.c
+++ b/frontends/riscos/configure/con_theme.c
@@ -104,20 +104,23 @@ bool ro_gui_options_theme_initialise(wimp_w w)
return false;
error = xwimp_create_window(&theme_pane_definition, &theme_pane);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
icon_state.w = w;
icon_state.i = THEME_PANE_AREA;
error = xwimp_get_icon_state(&icon_state);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
state.w = theme_pane;
@@ -126,7 +129,8 @@ bool ro_gui_options_theme_initialise(wimp_w w)
state.visible.x0 += icon_state.icon.extent.x0 + 16;
state.visible.y0 = state.visible.y1 + icon_state.icon.extent.y0 + 16;
state.visible.y1 += icon_state.icon.extent.y1 - 28;
- LOG("Y0 = %i, y1 = %i", icon_state.icon.extent.y0, icon_state.icon.extent.y1);
+ NSLOG(netsurf, INFO, "Y0 = %i, y1 = %i", icon_state.icon.extent.y0,
+ icon_state.icon.extent.y1);
error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), w,
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
<< wimp_CHILD_XORIGIN_SHIFT |
@@ -141,7 +145,8 @@ bool ro_gui_options_theme_initialise(wimp_w w)
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
<< wimp_CHILD_TS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -176,7 +181,8 @@ void ro_gui_options_theme_finalise(wimp_w w)
ro_gui_wimp_event_finalise(theme_pane);
error = xwimp_delete_window(theme_pane);
if (error) {
- LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
theme_pane = 0;
@@ -269,7 +275,7 @@ void ro_gui_options_theme_load(void)
ro_toolbar_rebuild(toolbar);
toolbar_display = calloc(sizeof(struct toolbar_display), 1);
if (!toolbar_display) {
- LOG("No memory for calloc()");
+ NSLOG(netsurf, INFO, "No memory for calloc()");
ro_warn_user("NoMemory", 0);
return;
}
@@ -291,7 +297,8 @@ void ro_gui_options_theme_load(void)
state.w = theme_pane;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
diff --git a/frontends/riscos/content-handlers/artworks.c b/frontends/riscos/content-handlers/artworks.c
index f70b10ac7..8ec4edcae 100644
--- a/frontends/riscos/content-handlers/artworks.c
+++ b/frontends/riscos/content-handlers/artworks.c
@@ -183,18 +183,19 @@ bool artworks_convert(struct content *c)
xos_read_var_val_size("Alias$LoadArtWorksModules", 0, os_VARTYPE_STRING,
&used, NULL, NULL);
if (used >= 0) {
- LOG("Alias$LoadArtWorksModules not defined");
+ NSLOG(netsurf, INFO, "Alias$LoadArtWorksModules not defined");
msg_data.error = messages_get("AWNotSeen");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
/* load the modules, or do nothing if they're already loaded */
error = xos_cli("LoadArtWorksModules");
if (error) {
- LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s", error->errnum,
+ error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -202,9 +203,10 @@ bool artworks_convert(struct content *c)
error = (os_error*)_swix(AWRender_FileInitAddress, _OUT(0) | _OUT(1),
&init_routine, &init_workspace);
if (error) {
- LOG("AWRender_FileInitAddress: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "AWRender_FileInitAddress: 0x%x: %s",
+ error->errnum, error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -212,9 +214,10 @@ bool artworks_convert(struct content *c)
&aw->render_routine,
&aw->render_workspace);
if (error) {
- LOG("AWRender_RenderAddress: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "AWRender_RenderAddress: 0x%x: %s",
+ error->errnum, error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -224,9 +227,10 @@ bool artworks_convert(struct content *c)
error = awrender_init(&source_data, &source_size,
init_routine, init_workspace);
if (error) {
- LOG("awrender_init: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "awrender_init: 0x%x : %s",
+ error->errnum, error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -239,13 +243,15 @@ bool artworks_convert(struct content *c)
&aw->y1);
if (error) {
- LOG("AWRender_DocBounds: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "AWRender_DocBounds: 0x%x: %s",
+ error->errnum, error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
- LOG("bounding box: %d,%d,%d,%d", aw->x0, aw->y0, aw->x1, aw->y1);
+ NSLOG(netsurf, INFO, "bounding box: %d,%d,%d,%d", aw->x0, aw->y0,
+ aw->x1, aw->y1);
/* create the resizable workspace required by the
ArtWorksRenderer rendering routine */
@@ -253,9 +259,10 @@ bool artworks_convert(struct content *c)
aw->size = INITIAL_BLOCK_SIZE;
aw->block = malloc(INITIAL_BLOCK_SIZE);
if (!aw->block) {
- LOG("failed to create block for ArtworksRenderer");
+ NSLOG(netsurf, INFO,
+ "failed to create block for ArtworksRenderer");
msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -317,7 +324,7 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
int clip_x1 = clip->x1;
int clip_y1 = clip->y1;
- if (ctx->plot->flush && !ctx->plot->flush())
+ if (ctx->plot->flush && (ctx->plot->flush(ctx) != NSERROR_OK))
return false;
/* pick up render addresses again in case they've changed
@@ -368,13 +375,15 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
if (error) {
- LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_read_vdu_variables: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
error = xwimp_read_palette((os_palette*)&vals[3]);
if (error) {
- LOG("xwimp_read_palette: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_read_palette: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -393,7 +402,8 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
aw->render_workspace);
if (error) {
- LOG("awrender_render: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "awrender_render: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
diff --git a/frontends/riscos/content-handlers/draw.c b/frontends/riscos/content-handlers/draw.c
index 9dff75736..bb66f9dbb 100644
--- a/frontends/riscos/content-handlers/draw.c
+++ b/frontends/riscos/content-handlers/draw.c
@@ -126,9 +126,10 @@ bool draw_convert(struct content *c)
error = xdrawfile_bbox(0, (drawfile_diagram *) data,
(int) source_size, 0, &bbox);
if (error) {
- LOG("xdrawfile_bbox: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xdrawfile_bbox: 0x%x: %s",
+ error->errnum, error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -184,7 +185,7 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data,
const void *src_data;
os_error *error;
- if (ctx->plot->flush && !ctx->plot->flush())
+ if (ctx->plot->flush && (ctx->plot->flush(ctx) != NSERROR_OK))
return false;
if (!c->width || !c->height)
@@ -208,7 +209,8 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data,
error = xdrawfile_render(0, (drawfile_diagram *) src_data,
(int) source_size, &matrix, 0, 0);
if (error) {
- LOG("xdrawfile_render: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xdrawfile_render: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
diff --git a/frontends/riscos/content-handlers/sprite.c b/frontends/riscos/content-handlers/sprite.c
index ed06110ec..3556aa555 100644
--- a/frontends/riscos/content-handlers/sprite.c
+++ b/frontends/riscos/content-handlers/sprite.c
@@ -126,7 +126,7 @@ bool sprite_convert(struct content *c)
/* check for bad data */
if ((int)source_size + 4 != area->used) {
msg_data.error = messages_get("BadSprite");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -135,9 +135,12 @@ bool sprite_convert(struct content *c)
(osspriteop_id) ((char *) area + area->first),
&w, &h, NULL, NULL);
if (error) {
- LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_read_sprite_info: 0x%x: %s",
+ error->errnum,
+ error->errmess);
msg_data.error = error->errmess;
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
return false;
}
@@ -180,7 +183,7 @@ bool sprite_redraw(struct content *c, struct content_redraw_data *data,
{
sprite_content *sprite = (sprite_content *) c;
- if (ctx->plot->flush && !ctx->plot->flush())
+ if (ctx->plot->flush && (ctx->plot->flush(ctx) != NSERROR_OK))
return false;
return image_redraw(sprite->data,
diff --git a/frontends/riscos/cookies.c b/frontends/riscos/cookies.c
index 38963ab3a..125d04356 100644
--- a/frontends/riscos/cookies.c
+++ b/frontends/riscos/cookies.c
@@ -377,7 +377,7 @@ static nserror ro_cookie_init(void)
return NSERROR_OK;
}
- ncwin = malloc(sizeof(struct ro_cookie_window));
+ ncwin = calloc(1, sizeof(*ncwin));
if (ncwin == NULL) {
return NSERROR_NOMEM;
}
@@ -445,12 +445,12 @@ nserror ro_gui_cookies_present(void)
res = ro_cookie_init();
if (res == NSERROR_OK) {
- LOG("Presenting");
+ NSLOG(netsurf, INFO, "Presenting");
ro_gui_dialog_open_top(cookie_window->core.wh,
cookie_window->core.toolbar,
600, 800);
} else {
- LOG("Failed presenting code %d", res);
+ NSLOG(netsurf, INFO, "Failed presenting code %d", res);
}
return res;
diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c
index 3219be985..84177aa90 100644
--- a/frontends/riscos/corewindow.c
+++ b/frontends/riscos/corewindow.c
@@ -42,6 +42,7 @@
#include "riscos/wimp_event.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/toolbar.h"
#include "riscos/mouse.h"
#include "riscos/corewindow.h"
@@ -62,22 +63,22 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open)
int extent_height;
os_box extent;
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
/* extent of content in not smaller than window so start there */
extent_width = open->visible.x1 - open->visible.x0;
extent_height = open->visible.y0 - open->visible.y1;
- LOG("extent w:%d h:%d content w:%d h:%d origin h:%d",
- extent_width, extent_height,
- ro_cw->content_width, ro_cw->content_height, ro_cw->origin_y);
+ NSLOG(netsurf, INFO,
+ "extent w:%d h:%d content w:%d h:%d origin h:%d", extent_width,
+ extent_height, ro_cw->content_width, ro_cw->content_height,
+ ro_cw->origin_y);
if (ro_cw->content_width > extent_width) {
extent_width = ro_cw->content_width;
}
if (extent_height > (ro_cw->origin_y + ro_cw->content_height)) {
extent_height = ro_cw->origin_y + ro_cw->content_height;
}
- LOG("extent w:%d h:%d",
- extent_width, extent_height);
+ NSLOG(netsurf, INFO, "extent w:%d h:%d", extent_width, extent_height);
extent.x0 = 0;
extent.y0 = extent_height;
extent.x1 = extent_width;
@@ -85,15 +86,15 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open)
error = xwimp_set_extent(ro_cw->wh, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
error = xwimp_open_window(open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -129,8 +130,8 @@ static void ro_cw_redraw(wimp_draw *redraw)
error = xwimp_get_rectangle(redraw, &more);
}
if (error != NULL) {
- LOG("xwimp_redraw_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -144,7 +145,7 @@ static void ro_cw_scroll(wimp_scroll *scroll)
wimp_open open;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(scroll->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
page_x = scroll->visible.x1 - scroll->visible.x0 - 32;
page_y = scroll->visible.y1 - scroll->visible.y0 - 32;
@@ -201,8 +202,8 @@ static void ro_cw_scroll(wimp_scroll *scroll)
error = xwimp_open_window(&open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -230,38 +231,38 @@ static void ro_cw_mouse_at(wimp_pointer *pointer, void *data)
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w);
if (ro_cw == NULL) {
- LOG("no corewindow conext for window: 0x%x",
- (unsigned int)pointer->w);
+ NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x",
+ (unsigned int)pointer->w);
return;
}
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
- /* no futher processing required if no drag in progress */
- if (ro_cw->drag_status == CORE_WINDOW_DRAG_NONE) {
- return;
- }
-
- /* Not a Menu click and a drag is in progress. */
+ /* Not a Menu click. */
state.w = pointer->w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
- /* Convert the returned mouse coordinates into NetSurf's internal
- * units.
+ /* Convert the returned mouse coordinates into
+ * NetSurf's internal units.
*/
xpos = ((pointer->pos.x - state.visible.x0) + state.xscroll) / 2;
ypos = ((state.visible.y1 - pointer->pos.y) -
state.yscroll + ro_cw->origin_y) / 2;
- /* Start to process the mouse click. */
- mouse = ro_gui_mouse_drag_state(pointer->buttons,
- wimp_BUTTON_DOUBLE_CLICK_DRAG);
+ /* if no drag in progress report hover */
+ if (ro_cw->drag_status == CORE_WINDOW_DRAG_NONE) {
+ mouse = BROWSER_MOUSE_HOVER;
+ } else {
+ /* Start to process the mouse click. */
+ mouse = ro_gui_mouse_drag_state(pointer->buttons,
+ wimp_BUTTON_DOUBLE_CLICK_DRAG);
- ro_cw->mouse(ro_cw, mouse, xpos, ypos);
+ ro_cw->mouse(ro_cw, mouse, xpos, ypos);
+ }
if (!(mouse & BROWSER_MOUSE_DRAG_ON)) {
ro_cw->mouse(ro_cw, BROWSER_MOUSE_HOVER, xpos, ypos);
@@ -284,14 +285,15 @@ static void ro_cw_drag_end(wimp_dragged *drag, void *data)
error = xwimp_drag_box((wimp_drag *) -1);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_auto_scroll(0, NULL, NULL);
if (error) {
- LOG("xwimp_auto_scroll: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -344,12 +346,13 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
break;
}
- LOG("Drag start...");
+ NSLOG(netsurf, INFO, "Drag start...");
error = xwimp_drag_box_with_flags(&drag,
wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
} else {
auto_scroll.w = ro_cw->wh;
@@ -363,7 +366,8 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL,
&auto_scroll, NULL);
if (error) {
- LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -373,16 +377,40 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
/**
+ * Handle Pointer Leaving Window events.
+ *
+ * These events are delivered as the termination callback handler from
+ * ro_mouse's mouse tracking.
+ *
+ * \param leaving The Wimp_PointerLeavingWindow block.
+ * \param data NULL data pointer.
+ */
+static void ro_cw_pointer_leaving(wimp_leaving *leaving, void *data)
+{
+ struct ro_corewindow *ro_cw;
+
+ ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(leaving->w);
+ if (ro_cw == NULL) {
+ NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x",
+ (unsigned int)leaving->w);
+ return;
+ }
+
+ ro_cw->mouse(ro_cw, BROWSER_MOUSE_LEAVE, 0, 0);
+}
+
+
+/**
* Wimp callback on pointer entering window.
*
* The wimp has issued an event to the window because the pointer has
* entered it.
*
- * \param open The open event to be processed
+ * \param entering The entering event to be processed
*/
static void ro_cw_pointer_entering(wimp_entering *entering)
{
- ro_mouse_track_start(NULL, ro_cw_mouse_at, NULL);
+ ro_mouse_track_start(ro_cw_pointer_leaving, ro_cw_mouse_at, NULL);
}
@@ -414,14 +442,14 @@ static bool ro_cw_mouse_click(wimp_pointer *pointer)
struct ro_corewindow *ro_cw;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -492,7 +520,7 @@ static bool ro_cw_keypress(wimp_key *key)
nserror res;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(key->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
c = (uint32_t) key->c;
@@ -615,8 +643,8 @@ static void cw_tb_size(void *ctx)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -624,8 +652,8 @@ static void cw_tb_size(void *ctx)
0, state.visible.y0 - state.visible.y1,
state.visible.x1 - state.visible.x0, 0);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
@@ -664,6 +692,8 @@ static void cw_tb_update(void *ctx)
* Respond to user actions (click) in a corewindow.
*
* \param ctx Context as passed to toolbar creation.
+ * \param action_type type of action on toolbar
+ * \param action data for action.
*/
static void
cw_tb_click(void *ctx,
@@ -698,7 +728,9 @@ static void cw_tb_save(void *ctx, char *config)
-/** core window toolbar callbacks */
+/**
+ * riscos core window toolbar callbacks
+ */
static const struct toolbar_callbacks corewindow_toolbar_callbacks = {
.theme_update = cw_tb_theme,
.change_size = cw_tb_size,
@@ -707,24 +739,52 @@ static const struct toolbar_callbacks corewindow_toolbar_callbacks = {
.save_buttons = cw_tb_save,
};
+
/**
- * callback from core to request a redraw.
+ * callback from core to request an invalidation of a window area.
+ *
+ * The specified area of the window should now be considered
+ * out of date. If the area is NULL the entire window must be
+ * invalidated.
+ *
+ * \param[in] cw The core window to invalidate.
+ * \param[in] r area to redraw or NULL for the entire window area.
+ * \return NSERROR_OK on success or appropriate error code.
*/
-static void
-ro_cw_redraw_request(struct core_window *cw, const struct rect *r)
+static nserror
+ro_cw_invalidate(struct core_window *cw, const struct rect *r)
{
struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
os_error *error;
+ wimp_window_info info;
+
+ if (r == NULL) {
+ info.w = ro_cw->wh;
+ error = xwimp_get_window_info_header_only(&info);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_info_header_only: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+ } else {
+ /* convert the passed rectangle into RO window dimensions */
+ info.extent.x0 = 2 * r->x0;
+ info.extent.y0 = (-2 * (r->y0 + (r->y1 - r->y0))) + ro_cw->origin_y;
+ info.extent.x1 = 2 * (r->x0 + (r->x1 - r->x0));
+ info.extent.y1 = (-2 * r->y0) + ro_cw->origin_y;
+ }
error = xwimp_force_redraw(ro_cw->wh,
- (2 * r->x0),
- (-2 * (r->y0 + (r->y1 - r->y0))) + ro_cw->origin_y,
- (2 * (r->x0 + (r->x1 - r->x0))),
- (-2 * r->y0) + ro_cw->origin_y);
+ info.extent.x0, info.extent.y0,
+ info.extent.x1, info.extent.y1);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
+ return NSERROR_OK;
}
@@ -739,8 +799,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
wimp_window_state state;
os_error *error;
- LOG("content resize from w:%d h:%d to w:%d h:%d",
- ro_cw->content_width, ro_cw->content_height, width, height);
+ NSLOG(netsurf, INFO, "content resize from w:%d h:%d to w:%d h:%d",
+ ro_cw->content_width, ro_cw->content_height, width, height);
ro_cw->content_width = width * 2;
ro_cw->content_height = -(2 * height);
@@ -748,8 +808,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -793,8 +853,8 @@ ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -815,7 +875,7 @@ ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
struct core_window_callback_table ro_cw_cb_table = {
- .redraw_request = ro_cw_redraw_request,
+ .invalidate = ro_cw_invalidate,
.update_size = ro_cw_update_size,
.scroll_visible = ro_cw_scroll_visible,
.get_window_dimensions = ro_cw_get_window_dimensions,
diff --git a/frontends/riscos/corewindow.h b/frontends/riscos/corewindow.h
index b340bde35..7d808c298 100644
--- a/frontends/riscos/corewindow.h
+++ b/frontends/riscos/corewindow.h
@@ -123,6 +123,10 @@ struct ro_corewindow {
* As a pre-requisite the draw, key and mouse callbacks must be defined
*
* \param ro_cw A riscos core window structure to initialise
+ * \param tb_buttons toolbar button bar context
+ * \param tb_order The order of toolbar buttons
+ * \param tb_style The style of toolbar buttons
+ * \param tb_help Thh toolbar help text
* \return NSERROR_OK on successful initialisation otherwise error code.
*/
nserror ro_corewindow_init(struct ro_corewindow *ro_cw, const struct button_bar_buttons *tb_buttons, char *tb_order, theme_style tb_style, const char *tb_help);
diff --git a/frontends/riscos/dialog.c b/frontends/riscos/dialog.c
index 18df1bfe4..a50d1289b 100644
--- a/frontends/riscos/dialog.c
+++ b/frontends/riscos/dialog.c
@@ -44,8 +44,10 @@
#include "riscos/configure.h"
#include "riscos/cookies.h"
#include "riscos/dialog.h"
+#include "riscos/local_history.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/hotlist.h"
#include "riscos/menus.h"
#include "riscos/save.h"
@@ -176,7 +178,7 @@ void ro_gui_dialog_init(void)
ro_gui_dialog_zoom_apply);
ro_gui_wimp_event_set_help_prefix(dialog_zoom, "HelpScaleView");
- /* Treeview initialisation has moved to the end, to allow any
+ /* core window based initialisation done last to allow any
* associated dialogues to be set up first.
*/
@@ -186,6 +188,9 @@ void ro_gui_dialog_init(void)
/* hotlist window */
ro_gui_hotlist_initialise();
+ /* local history window */
+ ro_gui_local_history_initialise();
+
/* global history window */
ro_gui_global_history_initialise();
@@ -215,7 +220,8 @@ wimp_w ro_gui_dialog_create(const char *template_name)
window->sprite_area = gui_sprites;
error = xwimp_create_window(window, &w);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
}
@@ -254,12 +260,13 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name)
error = xwimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS,
name, 0, &window_size, &data_size, &context);
if (error) {
- LOG("xwimp_load_template: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_load_template: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
}
if (!context) {
- LOG("template '%s' missing", template_name);
+ NSLOG(netsurf, INFO, "template '%s' missing", template_name);
xwimp_close_template();
die("Template");
}
@@ -276,7 +283,8 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name)
error = xwimp_load_template(window, data, data + data_size,
wimp_NO_FONTS, name, 0, 0, 0, 0);
if (error) {
- LOG("xwimp_load_template: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_load_template: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
}
@@ -304,7 +312,8 @@ void ro_gui_dialog_open(wimp_w w)
state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -351,7 +360,8 @@ void ro_gui_dialog_close(wimp_w close)
*/
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
} else if (caret.w == close) {
/* Check if we are a persistent window */
@@ -362,7 +372,10 @@ void ro_gui_dialog_close(wimp_w close)
32, -1);
/* parent may have been closed first */
if ((error) && (error->errnum != 0x287)) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -370,7 +383,8 @@ void ro_gui_dialog_close(wimp_w close)
error = xwimp_close_window(close);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -455,7 +469,8 @@ void ro_gui_dialog_open_at_pointer(wimp_w w)
/* get the pointer position */
error = xwimp_get_pointer_info(&ptr);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -478,7 +493,8 @@ void ro_gui_dialog_open_xy(wimp_w w, int x, int y)
state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -493,7 +509,8 @@ void ro_gui_dialog_open_xy(wimp_w w, int x, int y)
* on screen */
error = xwimp_close_window(w);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -510,7 +527,8 @@ void ro_gui_dialog_open_xy(wimp_w w, int x, int y)
* /param parent the parent window (NULL for centre of screen)
* /param child the child window
*/
-void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
+static void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child)
+{
os_error *error;
wimp_window_state state;
int mid_x, mid_y;
@@ -521,7 +539,10 @@ void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
state.w = parent;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -538,14 +559,15 @@ void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
state.w = child;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
/* move to the centre of the parent at the top of the stack */
dimension = state.visible.x1 - state.visible.x0;
- scroll_width = ro_get_vscroll_width(history_window);
+ scroll_width = ro_get_vscroll_width(parent);
state.visible.x0 = mid_x - (dimension + scroll_width) / 2;
state.visible.x1 = state.visible.x0 + dimension;
dimension = state.visible.y1 - state.visible.y0;
@@ -567,10 +589,11 @@ void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer) {
- if (pointer)
+ if (pointer) {
ro_gui_dialog_open_at_pointer(w);
- else
+ } else {
ro_gui_dialog_open_centre_parent(parent, w);
+ }
/* todo: use wimp_event definitions rather than special cases */
if ((w == dialog_pageinfo) || (w == dialog_objinfo))
@@ -600,7 +623,7 @@ void ro_gui_dialog_add_persistent(wimp_w parent, wimp_w w) {
return;
}
}
- LOG("Unable to map persistent dialog to parent.");
+ NSLOG(netsurf, INFO, "Unable to map persistent dialog to parent.");
return;
}
@@ -629,7 +652,9 @@ void ro_gui_dialog_close_persistent(wimp_w parent) {
w = persistent_dialog[i].dialog;
ro_gui_dialog_close(w);
if (ro_gui_wimp_event_close_window(w))
- LOG("Persistent dialog close event: 0x%x", (unsigned)w);
+ NSLOG(netsurf, INFO,
+ "Persistent dialog close event: 0x%x",
+ (unsigned)w);
persistent_dialog[i].parent = NULL;
persistent_dialog[i].dialog = NULL;
}
@@ -706,7 +731,7 @@ static bool ro_gui_dialog_open_url_init(void)
if ((definition->icons[ICON_OPENURL_URL].flags & wimp_ICON_INDIRECTED)
== 0) {
- LOG("open_url URL icon not indirected");
+ NSLOG(netsurf, INFO, "open_url URL icon not indirected");
xwimp_close_template();
die("Template");
}
@@ -724,7 +749,8 @@ static bool ro_gui_dialog_open_url_init(void)
error = xwimp_create_window(definition, &dialog_openurl);
if (error != NULL) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
}
diff --git a/frontends/riscos/dialog.h b/frontends/riscos/dialog.h
index 463048436..2ec86c339 100644
--- a/frontends/riscos/dialog.h
+++ b/frontends/riscos/dialog.h
@@ -33,7 +33,6 @@ bool ro_gui_dialog_open_top(wimp_w w, struct toolbar *toolbar,
int width, int height);
void ro_gui_dialog_open_at_pointer(wimp_w w);
void ro_gui_dialog_open_xy(wimp_w, int x, int y);
-void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w w);
void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer);
void ro_gui_dialog_add_persistent(wimp_w parent, wimp_w w);
diff --git a/frontends/riscos/download.c b/frontends/riscos/download.c
index 561409ed1..bdc705426 100644
--- a/frontends/riscos/download.c
+++ b/frontends/riscos/download.c
@@ -261,7 +261,10 @@ static nserror download_ro_filetype(download_context *ctx, bits *ftype_out)
mime_type = download_context_get_mime_type(ctx);
error = xmimemaptranslate_mime_type_to_filetype(mime_type, &ftype);
if (error) {
- LOG("xmimemaptranslate_mime_type_to_filetype: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xmimemaptranslate_mime_type_to_filetype: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
ftype = 0xffd;
}
@@ -339,7 +342,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR,
temp_name, 0, &dw->file);
if (error) {
- LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
free(dw);
return 0;
@@ -372,7 +376,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
filename = strdup(temp_name);
if (filename == NULL) {
- LOG("Failed to establish download filename.");
+ NSLOG(netsurf, INFO, "Failed to establish download filename.");
ro_warn_user("SaveError", error->errmess);
free(dw);
return 0;
@@ -404,7 +408,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
if (err != NSERROR_OK) {
/* badenc should never happen */
assert(err !=NSERROR_BAD_ENCODING);
- LOG("utf8_to_local_encoding failed");
+ NSLOG(netsurf, INFO, "utf8_to_local_encoding failed");
ro_warn_user("NoMemory", 0);
free(dw);
return 0;
@@ -430,7 +434,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
/* create and open the download window */
error = xwimp_create_window(download_template, &dw->window);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
free(dw);
return 0;
@@ -485,7 +490,8 @@ static void gui_download_window_error(struct gui_download_window *dw,
wimp_COLOUR_RED << wimp_ICON_FG_COLOUR_SHIFT,
wimp_ICON_FG_COLOUR);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -493,7 +499,8 @@ static void gui_download_window_error(struct gui_download_window *dw,
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_PATH,
wimp_ICON_SHADED, 0);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -501,7 +508,8 @@ static void gui_download_window_error(struct gui_download_window *dw,
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON,
wimp_ICON_SHADED, wimp_ICON_SHADED);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -528,11 +536,13 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
error = xosgbpb_writew(dw->file, (const byte *) data, size,
&unwritten);
if (error) {
- LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosgbpb_writew: 0x%x: %s",
+ error->errnum, error->errmess);
msg = error->errmess;
} else if (unwritten) {
- LOG("xosgbpb_writew: unwritten %i", unwritten);
+ NSLOG(netsurf, INFO, "xosgbpb_writew: unwritten %i",
+ unwritten);
msg = messages_get("Unwritten");
}
else {
@@ -555,20 +565,29 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON,
wimp_ICON_SHADED, 0);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_DESTINATION,
wimp_ICON_DELETED, wimp_ICON_DELETED);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_set_icon_state(dw->window,
ICON_DOWNLOAD_PATH, wimp_ICON_DELETED, 0);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -717,13 +736,15 @@ void ro_gui_download_update_status(struct gui_download_window *dw)
download_progress_x0 + width,
download_progress_y1);
if (error) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_STATUS, 0, 0);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -759,13 +780,17 @@ void ro_gui_download_window_hide_caret(struct gui_download_window *dw)
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
else if (caret.w == dw->window) {
error = xwimp_set_caret_position(dw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_caret_position: 0x%x : %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -791,7 +816,8 @@ static void gui_download_window_done(struct gui_download_window *dw)
error = xosfind_closew(dw->file);
if (error) {
- LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
dw->file = 0;
@@ -800,7 +826,8 @@ static void gui_download_window_done(struct gui_download_window *dw)
error = xosfile_set_type(dw->path,
dw->file_type);
if (error) {
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
@@ -856,7 +883,8 @@ bool ro_gui_download_click(wimp_pointer *pointer)
*dot = 0;
error = xos_cli(command);
if (error) {
- LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
}
}
@@ -929,7 +957,8 @@ static void ro_gui_download_drag_end(wimp_dragged *drag, void *data)
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -959,7 +988,10 @@ static void ro_gui_download_drag_end(wimp_dragged *drag, void *data)
error = xwimp_send_message_to_window(wimp_USER_MESSAGE, &message,
pointer.w, pointer.i, 0);
if (error) {
- LOG("xwimp_send_message_to_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_send_message_to_window: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -1011,7 +1043,10 @@ char *ro_gui_download_canonicalise(const char *path)
error = xosfscontrol_canonicalise_path(path, NULL, NULL, NULL, 0, &spare);
if (error) {
- LOG("xosfscontrol_canonicalise_path: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfscontrol_canonicalise_path: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return NULL;
}
@@ -1020,7 +1055,10 @@ char *ro_gui_download_canonicalise(const char *path)
error = xosfscontrol_canonicalise_path(path, buf, NULL, NULL,
1 - spare, NULL);
if (error) {
- LOG("xosfscontrol_canonicalise_path: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfscontrol_canonicalise_path: 0x%x: %s",
+ error->errnum,
+ error->errmess);
free(buf);
return NULL;
@@ -1065,13 +1103,17 @@ bool ro_gui_download_check_space(struct gui_download_window *dw,
error = xosfscontrol_free_space64(dir, &free_lo, &free_hi,
&max_file, NULL, NULL);
if (error) {
- LOG("xosfscontrol_free_space64: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfscontrol_free_space64: 0x%x: %s",
+ error->errnum, error->errmess);
free_hi = 0;
error = xosfscontrol_free_space(dir, (int*)&free_lo,
&max_file, NULL);
if (error) {
- LOG("xosfscontrol_free_space: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfscontrol_free_space: 0x%x: %s",
+ error->errnum,
+ error->errmess);
/* close our eyes and hope */
free(dir);
return true;
@@ -1108,7 +1150,10 @@ bool ro_gui_download_check_space(struct gui_download_window *dw,
error = xosargs_read_allocation(dw->file,
&allocation);
if (error) {
- LOG("xosargs_read_allocation: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosargs_read_allocation: 0x%x : %s",
+ error->errnum,
+ error->errmess);
}
else {
space += allocation;
@@ -1147,7 +1192,8 @@ os_error *ro_gui_download_move(struct gui_download_window *dw,
error = xosfind_closew(dw->file);
dw->file = 0;
if (error) {
- LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s",
+ error->errnum, error->errmess);
return error;
}
}
@@ -1165,11 +1211,13 @@ os_error *ro_gui_download_move(struct gui_download_window *dw,
osfscontrol_COPY_LOOK,
0, 0, 0, 0, 0);
if (error) {
- LOG("xosfscontrol_copy: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfscontrol_copy: 0x%x: %s",
+ error->errnum, error->errmess);
return error;
}
} else if (error) {
- LOG("xosfscontrol_rename: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfscontrol_rename: 0x%x: %s",
+ error->errnum, error->errmess);
return error;
}
@@ -1179,20 +1227,23 @@ os_error *ro_gui_download_move(struct gui_download_window *dw,
fileswitch_ATTR_OWNER_READ |
fileswitch_ATTR_OWNER_WRITE);
if (error) {
- LOG("xosfile_write: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_write: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
error = xosfind_openupw(osfind_NO_PATH | osfind_ERROR_IF_DIR,
dest_file, 0, &dw->file);
if (error) {
- LOG("xosfind_openupw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openupw: 0x%x: %s",
+ error->errnum, error->errmess);
return error;
}
error = xosargs_set_ptrw(dw->file, dw->received);
if (error) {
- LOG("xosargs_set_ptrw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosargs_set_ptrw: 0x%x: %s",
+ error->errnum, error->errmess);
return error;
}
@@ -1201,7 +1252,8 @@ os_error *ro_gui_download_move(struct gui_download_window *dw,
error = xosfile_set_type(dest_file,
dw->file_type);
if (error) {
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
}
@@ -1273,7 +1325,8 @@ bool ro_gui_download_save(struct gui_download_window *dw,
error = xosfile_read_stamped(file_name, &obj_type,
NULL, NULL, NULL, NULL, NULL);
if (error) {
- LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s",
+ error->errnum, error->errmess);
return false;
}
@@ -1309,12 +1362,16 @@ bool ro_gui_download_save(struct gui_download_window *dw,
error = xosfind_openupw(osfind_NO_PATH | osfind_ERROR_IF_DIR,
temp_name, 0, &dw->file);
if (error) {
- LOG("xosfind_openupw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openupw: 0x%x: %s",
+ error->errnum, error->errmess);
} else {
error = xosargs_set_ptrw(dw->file, dw->received);
if (error) {
- LOG("xosargs_set_ptrw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosargs_set_ptrw: 0x%x: %s",
+ error->errnum,
+ error->errmess);
}
}
@@ -1336,7 +1393,8 @@ bool ro_gui_download_save(struct gui_download_window *dw,
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON,
wimp_ICON_SHADED, wimp_ICON_SHADED);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -1349,13 +1407,15 @@ bool ro_gui_download_save(struct gui_download_window *dw,
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_PATH,
wimp_ICON_DELETED, wimp_ICON_DELETED);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_set_icon_state(dw->window,
ICON_DOWNLOAD_DESTINATION, wimp_ICON_DELETED, 0);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -1401,7 +1461,8 @@ void ro_gui_download_send_dataload(struct gui_download_window *dw)
* for the rather depressing details.
*/
if (error && error->errnum != error_WIMP_BAD_HANDLE) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -1482,7 +1543,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
/* delete window */
error = xwimp_delete_window(dw->window);
if (error) {
- LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
ro_gui_wimp_event_finalise(dw->window);
@@ -1491,7 +1553,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
if (dw->file) {
error = xosfind_closew(dw->file);
if (error) {
- LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
}
@@ -1502,7 +1565,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
error = xosfile_delete(temp_name, 0, 0, 0, 0, 0);
if (error) {
- LOG("xosfile_delete: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_delete: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
}
diff --git a/frontends/riscos/filetype.c b/frontends/riscos/filetype.c
index 75ff41414..73651cd63 100644
--- a/frontends/riscos/filetype.c
+++ b/frontends/riscos/filetype.c
@@ -72,7 +72,7 @@ const char *fetch_filetype(const char *unix_path)
int objtype;
if (!path) {
- LOG("Insufficient memory for calloc");
+ NSLOG(netsurf, INFO, "Insufficient memory for calloc");
ro_warn_user("NoMemory", 0);
return "application/riscos";
}
@@ -80,7 +80,7 @@ const char *fetch_filetype(const char *unix_path)
/* convert path to RISC OS format and read file type */
r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX, path, len, 0);
if (r == 0) {
- LOG("__riscosify failed");
+ NSLOG(netsurf, INFO, "__riscosify failed");
free(path);
return "application/riscos";
}
@@ -88,7 +88,9 @@ const char *fetch_filetype(const char *unix_path)
error = xosfile_read_stamped_no_path(path, &objtype, 0, 0, 0, 0,
&file_type);
if (error) {
- LOG("xosfile_read_stamped_no_path failed: %s", error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_read_stamped_no_path failed: %s",
+ error->errmess);
free(path);
return "application/riscos";
}
@@ -108,7 +110,10 @@ const char *fetch_filetype(const char *unix_path)
slash+1, &temp);
if (error)
/* ignore error and leave file_type alone */
- LOG("xmimemaptranslate_extension_to_filetype: ""0x%x %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xmimemaptranslate_extension_to_filetype: ""0x%x %s",
+ error->errnum,
+ error->errmess);
else
file_type = temp;
}
@@ -126,7 +131,7 @@ const char *fetch_filetype(const char *unix_path)
/* not in internal table, so ask MimeMap */
error = xmimemaptranslate_filetype_to_mime_type(file_type, type_buf);
if (error) {
- LOG("0x%x %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "0x%x %s", error->errnum, error->errmess);
free(path);
return "application/riscos";
}
@@ -139,7 +144,7 @@ const char *fetch_filetype(const char *unix_path)
free(path);
- LOG("mime type '%s'", type_buf);
+ NSLOG(netsurf, INFO, "mime type '%s'", type_buf);
return (const char *)type_buf;
}
@@ -155,14 +160,15 @@ char *fetch_mimetype(const char *ro_path)
struct type_entry *t;
if (!mime) {
- LOG("Insufficient memory for calloc");
+ NSLOG(netsurf, INFO, "Insufficient memory for calloc");
ro_warn_user("NoMemory", 0);
return 0;
}
e = xosfile_read_no_path(ro_path, &objtype, &load, 0, 0, 0);
if (e) {
- LOG("xosfile_read_no_path: 0x%x: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "xosfile_read_no_path: 0x%x: %s",
+ e->errnum, e->errmess);
free(mime);
return 0;
}
@@ -188,7 +194,7 @@ char *fetch_mimetype(const char *ro_path)
if (e)
/* if we get an error here, simply ignore it and
* leave filetype unchanged */
- LOG("0x%x %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "0x%x %s", e->errnum, e->errmess);
else
filetype = load;
}
@@ -205,7 +211,10 @@ char *fetch_mimetype(const char *ro_path)
/* not in internal table, so ask MimeMap */
e = xmimemaptranslate_filetype_to_mime_type(filetype, mime);
if (e) {
- LOG("xmimemaptranslate_filetype_to_mime_type: 0x%x: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO,
+ "xmimemaptranslate_filetype_to_mime_type: 0x%x: %s",
+ e->errnum,
+ e->errmess);
free(mime);
return 0;
}
@@ -322,7 +331,7 @@ bits ro_filetype_from_unix_path(const char *unix_path)
bits file_type;
if (!path) {
- LOG("Insufficient memory for calloc");
+ NSLOG(netsurf, INFO, "Insufficient memory for calloc");
ro_warn_user("NoMemory", 0);
return osfile_TYPE_DATA;
}
@@ -330,7 +339,7 @@ bits ro_filetype_from_unix_path(const char *unix_path)
/* convert path to RISC OS format and read file type */
r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX, path, len, 0);
if (r == 0) {
- LOG("__riscosify failed");
+ NSLOG(netsurf, INFO, "__riscosify failed");
free(path);
return osfile_TYPE_DATA;
}
@@ -338,7 +347,9 @@ bits ro_filetype_from_unix_path(const char *unix_path)
error = xosfile_read_stamped_no_path(path, 0, 0, 0, 0, 0,
&file_type);
if (error) {
- LOG("xosfile_read_stamped_no_path failed: %s", error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_read_stamped_no_path failed: %s",
+ error->errmess);
free(path);
return osfile_TYPE_DATA;
}
diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c
index 560afc785..2ff309043 100644
--- a/frontends/riscos/font.c
+++ b/frontends/riscos/font.c
@@ -65,7 +65,8 @@ static void nsfont_check_fonts(void)
"<NetSurf$Dir>.FixFonts", 0);
die("FontBadInst");
} else {
- LOG("xfont_find_font: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xfont_find_font: 0x%x: %s",
+ error->errnum, error->errmess);
snprintf(s, sizeof s, messages_get("FontError"),
error->errmess);
die(s);
@@ -74,7 +75,8 @@ static void nsfont_check_fonts(void)
error = xfont_lose_font(font);
if (error) {
- LOG("xfont_lose_font: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xfont_lose_font: 0x%x: %s",
+ error->errnum, error->errmess);
snprintf(s, sizeof s, messages_get("FontError"),
error->errmess);
die(s);
@@ -118,17 +120,20 @@ void nsfont_init(void)
nsfont_check_fonts();
- LOG("Initialise RUfl");
+ NSLOG(netsurf, INFO, "Initialise RUfl");
code = rufl_init();
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_init: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_init: 0x%x", code);
die("The Unicode font library could not be initialized. "
"Please report this to the developers.");
}
- LOG("RUfl initialised");
+ NSLOG(netsurf, INFO, "RUfl initialised");
if (rufl_family_list_entries == 0)
die("No fonts could be found. At least one font must be "
@@ -162,9 +167,10 @@ const char *nsfont_fallback_font(void)
const char *fallback = "Homerton";
if (!nsfont_exists(fallback)) {
- LOG("Homerton not found, dumping RUfl family list");
+ NSLOG(netsurf, INFO,
+ "Homerton not found, dumping RUfl family list");
for (unsigned int i = 0; i < rufl_family_list_entries; i++) {
- LOG("'%s'", rufl_family_list[i]);
+ NSLOG(netsurf, INFO, "'%s'", rufl_family_list[i]);
}
fallback = rufl_family_list[0];
}
@@ -230,9 +236,12 @@ ro_font_width(const plot_font_style_t *fstyle,
width);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_width: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_width: 0x%x", code);
/* ro_warn_user("MiscError", "font error"); */
*width = 0;
return NSERROR_INVALID;
@@ -276,9 +285,12 @@ ro_font_position(const plot_font_style_t *fstyle,
x * 2, char_offset, actual_x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_x_to_offset: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_x_to_offset: rufl_FONT_MANAGER_ERROR: ""0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_x_to_offset: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x", code);
/* ro_warn_user("MiscError", "font error"); */
*char_offset = 0;
*actual_x = 0;
@@ -335,10 +347,12 @@ ro_font_split(const plot_font_style_t *fstyle,
x * 2, char_offset, actual_x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR) {
- LOG("rufl_split: rufl_FONT_MANAGER_ERROR: ""0x%x: %s",
- rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_split: rufl_FONT_MANAGER_ERROR: ""0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
} else {
- LOG("rufl_split: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_split: 0x%x", code);
}
/* ro_warn_user("MiscError", "font error"); */
*char_offset = 0;
@@ -370,10 +384,12 @@ ro_font_split(const plot_font_style_t *fstyle,
actual_x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR) {
- LOG("rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
- rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
} else {
- LOG("rufl_width: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_width: 0x%x", code);
}
/* ro_warn_user("MiscError", "font error"); */
*char_offset = 0;
@@ -416,9 +432,12 @@ bool nsfont_paint(const plot_font_style_t *fstyle, const char *string,
string, length, x, y, flags);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR) {
- LOG("rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
} else {
- LOG("rufl_paint: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_paint: 0x%x", code);
}
}
@@ -450,7 +469,7 @@ void nsfont_read_style(const plot_font_style_t *fstyle,
rufl_WEIGHT_900
};
- *font_size = (fstyle->size * 16) / FONT_SIZE_SCALE;
+ *font_size = (fstyle->size * 16) / PLOT_STYLE_SCALE;
if (1600 < *font_size)
*font_size = 1600;
@@ -513,7 +532,8 @@ ro_gui_wimp_desktop_font(char *family,
error = xwimpreadsysinfo_font(&font_handle, NULL);
if (error) {
- LOG("xwimpreadsysinfo_font: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimpreadsysinfo_font: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
goto failsafe;
}
@@ -525,20 +545,22 @@ ro_gui_wimp_desktop_font(char *family,
error = xfont_read_identifier(font_handle, NULL, &used);
if (error) {
- LOG("xfont_read_identifier: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xfont_read_identifier: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
goto failsafe;
}
if (family_size < (size_t) used + 1) {
- LOG("desktop font name too long");
+ NSLOG(netsurf, INFO, "desktop font name too long");
goto failsafe;
}
error = xfont_read_defn(font_handle, (byte *) family,
&ptx, &pty, NULL, NULL, NULL, NULL);
if (error) {
- LOG("xfont_read_defn: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xfont_read_defn: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
goto failsafe;
}
@@ -550,7 +572,7 @@ ro_gui_wimp_desktop_font(char *family,
}
}
- LOG("desktop font \"%s\"", family);
+ NSLOG(netsurf, INFO, "desktop font \"%s\"", family);
if (strcasestr(family, ".Medium"))
style = rufl_WEIGHT_500;
@@ -566,7 +588,8 @@ ro_gui_wimp_desktop_font(char *family,
*psize = max(ptx, pty);
*pstyle = style;
- LOG("family \"%s\", size %i, style %i", family, *psize, style);
+ NSLOG(netsurf, INFO, "family \"%s\", size %i, style %i", family,
+ *psize, style);
return;
diff --git a/frontends/riscos/global_history.c b/frontends/riscos/global_history.c
index 94e1d4a03..7dfc58317 100644
--- a/frontends/riscos/global_history.c
+++ b/frontends/riscos/global_history.c
@@ -405,7 +405,7 @@ static nserror ro_global_history_init(void)
return NSERROR_OK;
}
- ncwin = malloc(sizeof(struct ro_global_history_window));
+ ncwin = calloc(1, sizeof(*ncwin));
if (ncwin == NULL) {
return NSERROR_NOMEM;
}
@@ -474,12 +474,12 @@ nserror ro_gui_global_history_present(void)
res = ro_global_history_init();
if (res == NSERROR_OK) {
- LOG("Presenting");
+ NSLOG(netsurf, INFO, "Presenting");
ro_gui_dialog_open_top(global_history_window->core.wh,
global_history_window->core.toolbar,
600, 800);
} else {
- LOG("Failed presenting code %d", res);
+ NSLOG(netsurf, INFO, "Failed presenting code %d", res);
}
return res;
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 27b81d92e..be1bc8d9a 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -74,6 +74,7 @@
#include "riscos/window.h"
#include "riscos/iconbar.h"
#include "riscos/sslcert.h"
+#include "riscos/local_history.h"
#include "riscos/global_history.h"
#include "riscos/cookies.h"
#include "riscos/wimp_event.h"
@@ -194,6 +195,7 @@ static struct
static nsurl *gui_get_resource_url(const char *path)
{
static const char base_url[] = "file:///NetSurf:/Resources/";
+ const char *lang;
size_t path_len, length;
char *raw;
nsurl *url = NULL;
@@ -219,8 +221,12 @@ static nsurl *gui_get_resource_url(const char *path)
path_len = strlen(path);
+ lang = ro_gui_default_language();
+
/* Find max URL length */
- length = SLEN(base_url) + SLEN("xx/") + path_len + 1;
+ length = SLEN(base_url) +
+ strlen(lang) + 1 + /* <lang> + / */
+ path_len + 1; /* + NUL */
raw = malloc(length);
if (raw != NULL) {
@@ -229,13 +235,11 @@ static nsurl *gui_get_resource_url(const char *path)
ptr += SLEN(base_url);
/* Add language directory to URL, for translated files */
- /* TODO: handle non-en langauages
- * handle non-html translated files */
+ /* TODO: handle non-html translated files */
if (path_len > SLEN(".html") &&
strncmp(path + path_len - SLEN(".html"),
".html", SLEN(".html")) == 0) {
- memcpy(ptr, "en/", SLEN("en/"));
- ptr += SLEN("en/");
+ ptr += sprintf(ptr, "%s/", lang);
}
/* Add filename to URL */
@@ -273,8 +277,10 @@ set_colour_from_wimp(struct nsoption_s *opts,
error = xwimp_read_true_palette((os_palette *) &palette);
if (error != NULL) {
- LOG("xwimp_read_palette: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_read_palette: 0x%x: %s",
+ error->errnum,
+ error->errmess);
} else {
/* entries are in B0G0R0LL */
def_colour = palette.entries[wimp] >> 8;
@@ -306,7 +312,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
if (nsoption_charp(ca_bundle) == NULL ||
nsoption_charp(cookie_file) == NULL ||
nsoption_charp(cookie_jar) == NULL) {
- LOG("Failed initialising default options");
+ NSLOG(netsurf, INFO, "Failed initialising default options");
return NSERROR_BAD_PARAMETER;
}
@@ -429,7 +435,7 @@ static void ro_gui_signal(int sig)
if (used) {
int curr_slot;
xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
- LOG("saving WimpSlot, size 0x%x", curr_slot);
+ NSLOG(netsurf, INFO, "saving WimpSlot, size 0x%x", curr_slot);
xosfile_save("$.NetSurf_Slot", 0x8000, 0,
(byte *) 0x8000,
(byte *) 0x8000 + curr_slot);
@@ -439,7 +445,11 @@ static void ro_gui_signal(int sig)
byte *base_address;
xosdynamicarea_read(__dynamic_num, &size,
&base_address, 0, 0, 0, 0, 0);
- LOG("saving DA %i, base %p, size 0x%x", __dynamic_num, base_address, size);
+ NSLOG(netsurf, INFO,
+ "saving DA %i, base %p, size 0x%x",
+ __dynamic_num,
+ base_address,
+ size);
xosfile_save("$.NetSurf_DA",
(bits) base_address, 0,
base_address,
@@ -451,7 +461,7 @@ static void ro_gui_signal(int sig)
* defines a coredump directory. */
const _kernel_oserror *err = __unixlib_write_coredump (NULL);
if (err != NULL)
- LOG("Coredump failed: %s", err->errmess);
+ NSLOG(netsurf, INFO, "Coredump failed: %s", err->errmess);
#endif
xhourglass_colours(old_sand, old_glass, 0, 0);
@@ -535,7 +545,8 @@ static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
*uri_title = NULL;
fp = fopen(file_name, "rb");
if (!fp) {
- LOG("fopen(\"%s\", \"rb\"): %i: %s", file_name, errno, strerror(errno));
+ NSLOG(netsurf, INFO, "fopen(\"%s\", \"rb\"): %i: %s",
+ file_name, errno, strerror(errno));
ro_warn_user("LoadError", strerror(errno));
return 0;
}
@@ -596,14 +607,16 @@ static char *ro_gui_url_file_parse(const char *file_name)
fp = fopen(file_name, "r");
if (!fp) {
- LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno));
+ NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s",
+ file_name, errno, strerror(errno));
ro_warn_user("LoadError", strerror(errno));
return 0;
}
if (!fgets(line, sizeof line, fp)) {
if (ferror(fp)) {
- LOG("fgets: %i: %s", errno, strerror(errno));
+ NSLOG(netsurf, INFO, "fgets: %i: %s", errno,
+ strerror(errno));
ro_warn_user("LoadError", strerror(errno));
} else
ro_warn_user("LoadError", messages_get("EmptyError"));
@@ -640,7 +653,8 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
fp = fopen(file_name, "r");
if (!fp) {
- LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno));
+ NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s",
+ file_name, errno, strerror(errno));
ro_warn_user("LoadError", strerror(errno));
return 0;
}
@@ -659,7 +673,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
}
}
if (ferror(fp)) {
- LOG("fgets: %i: %s", errno, strerror(errno));
+ NSLOG(netsurf, INFO, "fgets: %i: %s", errno, strerror(errno));
ro_warn_user("LoadError", strerror(errno));
fclose(fp);
return 0;
@@ -731,7 +745,8 @@ static void ro_msg_dataopen(wimp_message *message)
message->your_ref = message->my_ref;
oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
if (oserror) {
- LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ oserror->errnum, oserror->errmess);
ro_warn_user("WimpError", oserror->errmess);
return;
}
@@ -854,7 +869,8 @@ static void ro_msg_dataload(wimp_message *message)
oserror = xwimp_send_message(wimp_USER_MESSAGE, message,
message->sender);
if (oserror) {
- LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ oserror->errnum, oserror->errmess);
ro_warn_user("WimpError", oserror->errmess);
return;
}
@@ -924,7 +940,10 @@ static void ro_msg_datasave(wimp_message *message)
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_send_message: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -976,7 +995,8 @@ static void ro_msg_prequit(wimp_message *message)
error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
message, message->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1002,7 +1022,8 @@ static void ro_msg_save_desktop(wimp_message *message)
}
if (error) {
- LOG("xosgbpb_writew/xos_bputw: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosgbpb_writew/xos_bputw: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
/* we must cancel the save by acknowledging the message */
@@ -1010,7 +1031,8 @@ static void ro_msg_save_desktop(wimp_message *message)
error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
message, message->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1061,7 +1083,8 @@ static void ro_gui_get_screen_properties(void)
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
if (error) {
- LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_read_vdu_variables: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
return;
}
@@ -1078,9 +1101,9 @@ static void ro_gui_check_resolvers(void)
char *resolvers;
resolvers = getenv("Inet$Resolvers");
if (resolvers && resolvers[0]) {
- LOG("Inet$Resolvers '%s'", resolvers);
+ NSLOG(netsurf, INFO, "Inet$Resolvers '%s'", resolvers);
} else {
- LOG("Inet$Resolvers not set or empty");
+ NSLOG(netsurf, INFO, "Inet$Resolvers not set or empty");
ro_warn_user("Resolvers", 0);
}
}
@@ -1179,17 +1202,24 @@ static nserror gui_init(int argc, char** argv)
/* Initialise save complete functionality */
save_complete_init();
+ /* Initialise the font subsystem */
+ nsfont_init();
+
/* Load in visited URLs, Cookies, and hostlist */
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_bool(external_hotlists) ?
+ NULL :
+ nsoption_charp(hotlist_save));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
PTR_WIMP_MESSAGE_LIST(&task_messages), 0,
&task_handle);
if (error) {
- LOG("xwimp_initialise: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_initialise: 0x%x: %s",
+ error->errnum, error->errmess);
die(error->errmess);
}
/* Register message handlers */
@@ -1212,9 +1242,6 @@ static nserror gui_init(int argc, char** argv)
ro_message_register_route(message_WINDOW_INFO,
ro_msg_window_info);
- /* Initialise the font subsystem */
- nsfont_init();
-
/* Initialise global information */
ro_gui_get_screen_properties();
ro_gui_wimp_get_desktop_font();
@@ -1230,7 +1257,8 @@ static nserror gui_init(int argc, char** argv)
die("Failed to locate Templates resource.");
error = xwimp_open_template(path);
if (error) {
- LOG("xwimp_open_template failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_template failed: 0x%x: %s",
+ error->errnum, error->errmess);
die(error->errmess);
}
@@ -1249,9 +1277,6 @@ static nserror gui_init(int argc, char** argv)
/* Initialise query windows */
ro_gui_query_init();
- /* Initialise the history subsystem */
- ro_gui_history_init();
-
/* Initialise toolbars */
ro_toolbar_init();
@@ -1274,7 +1299,7 @@ static nserror gui_init(int argc, char** argv)
/* parse command-line arguments */
if (argc == 2) {
- LOG("parameters: '%s'", argv[1]);
+ NSLOG(netsurf, INFO, "parameters: '%s'", argv[1]);
/* this is needed for launching URI files */
if (strcasecmp(argv[1], "-nowin") == 0) {
return NSERROR_OK;
@@ -1282,7 +1307,8 @@ static nserror gui_init(int argc, char** argv)
ret = nsurl_create(NETSURF_HOMEPAGE, &url);
}
else if (argc == 3) {
- LOG("parameters: '%s' '%s'", argv[1], argv[2]);
+ NSLOG(netsurf, INFO, "parameters: '%s' '%s'", argv[1],
+ argv[2]);
open_window = true;
/* HTML files */
@@ -1293,7 +1319,7 @@ static nserror gui_init(int argc, char** argv)
else if (strcasecmp(argv[1], "-urlf") == 0) {
char *urlf = ro_gui_url_file_parse(argv[2]);
if (!urlf) {
- LOG("allocation failed");
+ NSLOG(netsurf, INFO, "allocation failed");
die("Insufficient memory for URL");
}
ret = nsurl_create(urlf, &url);
@@ -1305,7 +1331,8 @@ static nserror gui_init(int argc, char** argv)
}
/* Unknown => exit here. */
else {
- LOG("Unknown parameters: '%s' '%s'", argv[1], argv[2]);
+ NSLOG(netsurf, INFO, "Unknown parameters: '%s' '%s'",
+ argv[1], argv[2]);
return NSERROR_BAD_PARAMETER;
}
}
@@ -1353,7 +1380,8 @@ const char *ro_gui_default_language(void)
/* choose a language from the configured country number */
error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
if (error) {
- LOG("xosbyte_read failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosbyte_read failed: 0x%x: %s",
+ error->errnum, error->errmess);
country = 1;
}
switch (country) {
@@ -1404,7 +1432,10 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
/* calculate the canonical risc os path */
error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare);
if (error) {
- LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfscontrol_canonicalise_path failed: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("PathToURL", error->errmess);
return NSERROR_NOT_FOUND;
}
@@ -1417,7 +1448,10 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
error = xosfscontrol_canonicalise_path(path, canonical_path, 0, 0, 1 - spare, 0);
if (error) {
- LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfscontrol_canonicalise_path failed: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("PathToURL", error->errmess);
free(canonical_path);
return NSERROR_NOT_FOUND;
@@ -1427,7 +1461,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
if (unix_path == NULL) {
- LOG("__unixify failed: %s", canonical_path);
+ NSLOG(netsurf, INFO, "__unixify failed: %s", canonical_path);
free(canonical_path);
return NSERROR_BAD_PARAMETER;
}
@@ -1445,7 +1479,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
urllen = strlen(escaped_path) + FILE_SCHEME_PREFIX_LEN + 1;
url = malloc(urllen);
if (url == NULL) {
- LOG("Unable to allocate url");
+ NSLOG(netsurf, INFO, "Unable to allocate url");
free(escaped_path);
return NSERROR_NOMEM;
}
@@ -1557,6 +1591,7 @@ static void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
ro_gui_window_quit();
+ ro_gui_local_history_finalise();
ro_gui_global_history_finalise();
ro_gui_hotlist_finalise();
ro_gui_cookies_finalise();
@@ -1594,7 +1629,8 @@ static void ro_gui_keypress_cb(void *pw)
if (ro_gui_wimp_event_keypress(key) == false) {
os_error *error = xwimp_process_key(key->c);
if (error) {
- LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1631,7 +1667,8 @@ static void ro_gui_keypress(wimp_key *key)
} else if (ro_gui_wimp_event_keypress(key) == false) {
os_error *error = xwimp_process_key(key->c);
if (error) {
- LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1903,7 +1940,8 @@ void ro_gui_open_window_request(wimp_open *open)
error = xwimp_open_window(open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1924,7 +1962,8 @@ static void ro_gui_view_source_bounce(wimp_message *message)
sprintf(command, "@RunType_FFF %s", filename);
error = xwimp_start_task(command, 0);
if (error) {
- LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1987,7 +2026,7 @@ void ro_gui_view_source(struct hlcache_handle *c)
r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX,
message.file_name, 212, 0);
if (r == 0) {
- LOG("__riscosify failed");
+ NSLOG(netsurf, INFO, "__riscosify failed");
return;
}
message.file_name[211] = '\0';
@@ -1997,7 +2036,10 @@ void ro_gui_view_source(struct hlcache_handle *c)
(byte *) source_data,
(byte *) source_data + source_size);
if (error) {
- LOG("xosfile_save_stamped failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_save_stamped failed: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
return;
}
@@ -2067,7 +2109,7 @@ static void ro_gui_choose_language(void)
*/
nserror ro_warn_user(const char *warning, const char *detail)
{
- LOG("%s %s", warning, detail);
+ NSLOG(netsurf, INFO, "%s %s", warning, detail);
if (dialog_warning) {
char warn_buffer[300];
@@ -2111,7 +2153,7 @@ void die(const char * const error)
{
os_error warn_error;
- LOG("%s", error);
+ NSLOG(netsurf, INFO, "%s", error);
warn_error.errnum = 1; /* \todo: reasonable ? */
strncpy(warn_error.errmess, messages_get(error),
@@ -2348,7 +2390,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
/* open file for dump */
FILE *stream = fopen("<Wimp$ScrapDir>.WWW.NetSurf.dump", "w");
if (!stream) {
- LOG("fopen: errno %i", errno);
+ NSLOG(netsurf, INFO, "fopen: errno %i", errno);
ro_warn_user("SaveError", strerror(errno));
return;
}
@@ -2361,7 +2403,8 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
error = xwimp_start_task("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
0);
if (error) {
- LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -2401,7 +2444,7 @@ static char *get_cachepath(void)
cachedir = getenv("Cache$Dir");
if ((cachedir == NULL) || (cachedir[0] == 0)) {
- LOG("cachedir was null");
+ NSLOG(netsurf, INFO, "cachedir was null");
return NULL;
}
ret = netsurf_mkpath(&cachepath, NULL, 2, cachedir, "NetSurf");
@@ -2517,5 +2560,8 @@ int main(int argc, char** argv)
netsurf_exit();
nsoption_finalise(nsoptions, nsoptions_default);
+ /* finalise logging */
+ nslog_finalise();
+
return 0;
}
diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h
index 1f5070012..49a8ba417 100644
--- a/frontends/riscos/gui.h
+++ b/frontends/riscos/gui.h
@@ -59,7 +59,6 @@ extern wimp_w dialog_info, dialog_saveas, dialog_zoom, dialog_pageinfo,
extern wimp_w current_menu_window;
extern bool current_menu_open;
extern wimp_menu *recent_search_menu; /* search.c */
-extern wimp_w history_window;
extern bool gui_redraw_debug;
extern osspriteop_area *gui_sprites;
extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
@@ -140,39 +139,6 @@ void ro_gui_401login_init(void);
void gui_401login_open(struct nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
-/* in window.c */
-void ro_gui_window_set_scale(struct gui_window *g, float scale);
-bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
-void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data);
-void ro_gui_window_iconise(struct gui_window *g,
- wimp_full_message_window_info *wi);
-bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
-void ro_gui_window_redraw_all(void);
-void ro_gui_window_update_boxes(void);
-void ro_gui_window_quit(void);
-/* void ro_gui_window_close_all(void); */
-#define ro_gui_window_close_all ro_gui_window_quit /* no need for a separate fn */
-void ro_gui_throb(void);
-void ro_gui_window_default_options(struct gui_window *gui);
-struct gui_window *ro_gui_window_lookup(wimp_w window);
-struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
-bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
- os_coord *pos);
-bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
- os_coord *pos);
-enum browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons,
- wimp_icon_flags type);
-enum browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
- wimp_icon_flags type);
-bool ro_gui_shift_pressed(void);
-bool ro_gui_ctrl_pressed(void);
-bool ro_gui_alt_pressed(void);
-void gui_window_set_pointer(struct gui_window *g, enum gui_pointer_shape shape);
-
-/* in history.c */
-void ro_gui_history_init(void);
-void ro_gui_history_open(struct gui_window *g, bool pointer);
-
/* in schedule.c */
extern bool sched_active;
extern os_t sched_time;
diff --git a/frontends/riscos/gui/button_bar.c b/frontends/riscos/gui/button_bar.c
index 6ecd7cffa..34ae39ae5 100644
--- a/frontends/riscos/gui/button_bar.c
+++ b/frontends/riscos/gui/button_bar.c
@@ -138,7 +138,7 @@ struct button_bar *ro_gui_button_bar_create(struct theme_descriptor *theme,
button_bar = malloc(sizeof(struct button_bar));
if (button_bar == NULL) {
- LOG("No memory for malloc()");
+ NSLOG(netsurf, INFO, "No memory for malloc()");
return NULL;
}
@@ -538,7 +538,10 @@ bool ro_gui_button_bar_icon_update(struct button_bar *button_bar)
error = xwimp_create_icon(&icon, &button->icon);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_create_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
button->icon = -1;
return false;
@@ -548,7 +551,10 @@ bool ro_gui_button_bar_icon_update(struct button_bar *button_bar)
error = xwimp_delete_icon(button_bar->window,
button->icon);
if (error != NULL) {
- LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_delete_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -598,7 +604,10 @@ bool ro_gui_button_bar_icon_resize(struct button_bar *button_bar)
button->y_pos +
button->y_size);
if (error != NULL) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_resize_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
button->icon = -1;
return false;
@@ -769,7 +778,10 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar,
button_bar->sprites,
sprite, &box, NULL);
if (error)
- LOG("xdragasprite_start: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xdragasprite_start: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_mouse_drag_start(ro_gui_button_bar_drag_end,
NULL, NULL, NULL);
@@ -870,7 +882,8 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data)
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -880,7 +893,8 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data)
state.w = drag_start->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1068,7 +1082,7 @@ char *ro_gui_button_bar_get_config(struct button_bar *button_bar)
config = malloc(size);
if (config == NULL) {
- LOG("No memory for malloc()");
+ NSLOG(netsurf, INFO, "No memory for malloc()");
ro_warn_user("NoMemory", 0);
return NULL;
}
diff --git a/frontends/riscos/gui/progress_bar.c b/frontends/riscos/gui/progress_bar.c
index c26b46c84..06d89dbf4 100644
--- a/frontends/riscos/gui/progress_bar.c
+++ b/frontends/riscos/gui/progress_bar.c
@@ -30,9 +30,9 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
-#include "netsurf/plotters.h"
#include "utils/log.h"
#include "utils/utils.h"
+#include "netsurf/plotters.h"
#include "riscos/gui.h"
#include "riscos/tinct.h"
@@ -137,7 +137,8 @@ struct progress_bar *ro_gui_progress_bar_create(void)
error = xwimp_create_window((wimp_window *)&progress_bar_definition,
&pb->w);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
free(pb);
return NULL;
}
@@ -165,7 +166,8 @@ void ro_gui_progress_bar_destroy(struct progress_bar *pb)
ro_gui_wimp_event_finalise(pb->w);
error = xwimp_delete_window(pb->w);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
free(pb);
@@ -327,7 +329,8 @@ void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height)
redraw.box.x0 = cur.x1;
error = xwimp_update_window(&redraw, &more);
if (error) {
- LOG("Error getting update window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "Error getting update window: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
if (more)
@@ -351,7 +354,8 @@ void ro_gui_progress_bar_redraw(wimp_draw *redraw)
error = xwimp_redraw_window(redraw, &more);
if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
if (more)
@@ -385,7 +389,8 @@ void ro_gui_progress_bar_animate(void *p)
redraw.box = pb->visible;
error = xwimp_update_window(&redraw, &more);
if (error != NULL) {
- LOG("Error getting update window: '%s'", error->errmess);
+ NSLOG(netsurf, INFO, "Error getting update window: '%s'",
+ error->errmess);
return;
}
if (more)
@@ -482,6 +487,11 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
osbool more = true;
struct rect clip;
int progress_ymid;
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
/* initialise the plotters */
ro_plot_origin_x = 0;
@@ -513,22 +523,23 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
redraw->box.y0 + pb->visible.y0) >> 1;
if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) {
if (progress_icon) {
- ro_plotters.clip(&clip);
+ ctx.plot->clip(&ctx, &clip);
_swix(Tinct_Plot, _IN(2) | _IN(3) | _IN(4) | _IN(7),
progress_icon,
redraw->box.x0 - pb->offset,
progress_ymid - progress_height,
tinct_FILL_HORIZONTALLY);
} else {
- ro_plotters.rectangle(clip.x0, clip.y0,
- clip.x1, clip.y1,
- plot_style_fill_red);
+ ctx.plot->rectangle(&ctx,
+ plot_style_fill_red,
+ &clip);
}
}
}
error = xwimp_get_rectangle(redraw, &more);
if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
diff --git a/frontends/riscos/gui/status_bar.c b/frontends/riscos/gui/status_bar.c
index 9d1bada91..dd1aab639 100644
--- a/frontends/riscos/gui/status_bar.c
+++ b/frontends/riscos/gui/status_bar.c
@@ -28,9 +28,10 @@
#include "oslib/os.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
-#include "netsurf/plotters.h"
+
#include "utils/log.h"
#include "utils/utils.h"
+#include "netsurf/plotters.h"
#include "riscos/gui.h"
#include "riscos/wimp.h"
@@ -130,7 +131,8 @@ struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width)
error = xwimp_create_window((wimp_window *)&status_bar_definition,
&sb->w);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
free(sb);
return NULL;
}
@@ -164,7 +166,8 @@ void ro_gui_status_bar_destroy(struct status_bar *sb)
ro_gui_wimp_event_finalise(sb->w);
error = xwimp_delete_window(sb->w);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
ro_gui_progress_bar_destroy(sb->pb);
@@ -221,7 +224,8 @@ void ro_gui_status_bar_set_visible(struct status_bar *sb, bool visible)
} else {
os_error *error = xwimp_close_window(sb->w);
if (error) {
- LOG("xwimp_close_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
}
}
@@ -274,14 +278,15 @@ void ro_gui_status_bar_set_progress_range(struct status_bar *sb,
old_range = ro_gui_progress_bar_get_range(sb->pb);
ro_gui_progress_bar_set_range(sb->pb, range);
- LOG("Ranges are %i vs %i", old_range, range);
+ NSLOG(netsurf, INFO, "Ranges are %i vs %i", old_range, range);
if ((old_range == 0) && (range != 0)) {
ro_gui_status_position_progress_bar(sb);
} else if ((old_range != 0) && (range == 0)) {
os_error *error = xwimp_close_window(
ro_gui_progress_bar_get_window(sb->pb));
if (error) {
- LOG("xwimp_close_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
}
}
@@ -353,7 +358,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb)
state.w = sb->parent;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
window_width = state.visible.x1 - state.visible.x0;
@@ -376,7 +382,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb)
extent.y1 = status_height - 4;
error = xwimp_set_extent(sb->w, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -404,7 +411,10 @@ void ro_gui_status_bar_resize(struct status_bar *sb)
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
<< wimp_CHILD_TS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
ro_gui_status_position_progress_bar(sb);
@@ -412,7 +422,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb)
status_width - WIDGET_WIDTH, 0,
status_width, status_height - 4);
if (error) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -436,6 +447,12 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw)
os_error *error;
osbool more;
rufl_code code;
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
+ struct rect rect;
sb = (struct status_bar *)ro_gui_wimp_event_get_user_data(redraw->w);
assert(sb);
@@ -447,7 +464,8 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw)
/* redraw the window */
error = xwimp_redraw_window(redraw, &more);
if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
while (more) {
@@ -456,7 +474,10 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw)
error = xcolourtrans_set_font_colours(font_CURRENT,
0xeeeeee00, 0x00000000, 14, 0, 0, 0);
if (error) {
- LOG("xcolourtrans_set_font_colours: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_font_colours: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
code = rufl_paint(ro_gui_desktop_font_family,
@@ -467,22 +488,30 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw)
rufl_BLEND_FONT);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_paint: 0x%x", code);
+ NSLOG(netsurf, INFO,
+ "rufl_paint: 0x%x", code);
}
}
+ rect.x0 = (redraw->box.x0 + sb->width - WIDGET_WIDTH - 2) >> 1;
+ rect.y0 = -redraw->box.y0 >> 1;
+ rect.x1 = (redraw->box.x0 + sb->width - WIDGET_WIDTH) >> 1;
+ rect.y1 = -redraw->box.y1 >> 1;
+
/* separate the widget from the text with a line */
- ro_plotters.rectangle((redraw->box.x0 + sb->width - WIDGET_WIDTH - 2) >> 1,
- -redraw->box.y0 >> 1,
- (redraw->box.x0 + sb->width - WIDGET_WIDTH) >> 1,
- -redraw->box.y1 >> 1,
- plot_style_fill_black);
+ ctx.plot->rectangle(&ctx,
+ plot_style_fill_black,
+ &rect);
error = xwimp_get_rectangle(redraw, &more);
if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
@@ -521,7 +550,10 @@ bool ro_gui_status_bar_click(wimp_pointer *pointer)
drag.initial.y1 = pointer->pos.y;
error = xwimp_drag_box(&drag);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_drag_box: 0x%x: %s",
+ error->errnum,
+ error->errmess);
}
break;
}
@@ -546,7 +578,8 @@ void ro_gui_status_bar_open(wimp_open *open)
state.w = sb->parent;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
window_width = state.visible.x1 - state.visible.x0;
@@ -585,7 +618,8 @@ void ro_gui_status_position_progress_bar(struct status_bar *sb)
state.w = sb->w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -615,7 +649,8 @@ void ro_gui_status_position_progress_bar(struct status_bar *sb)
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
<< wimp_CHILD_TS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
/* update the progress bar display on non-standard width */
diff --git a/frontends/riscos/gui/throbber.c b/frontends/riscos/gui/throbber.c
index a326f806c..f3b79a68e 100644
--- a/frontends/riscos/gui/throbber.c
+++ b/frontends/riscos/gui/throbber.c
@@ -81,7 +81,7 @@ struct throbber *ro_gui_throbber_create(struct theme_descriptor *theme)
throbber = malloc(sizeof(struct throbber));
if (throbber == NULL) {
- LOG("No memory for malloc()");
+ NSLOG(netsurf, INFO, "No memory for malloc()");
return NULL;
}
@@ -248,7 +248,8 @@ bool ro_gui_throbber_icon_update(struct throbber *throbber)
error = xwimp_create_icon(&icon, &throbber->icon);
if (error != NULL) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
throbber->icon = -1;
return false;
@@ -259,7 +260,8 @@ bool ro_gui_throbber_icon_update(struct throbber *throbber)
} else if (throbber->hidden && throbber->icon != -1) {
error = xwimp_delete_icon(throbber->window, throbber->icon);
if (error != NULL) {
- LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -295,7 +297,8 @@ bool ro_gui_throbber_icon_resize(struct throbber *throbber)
throbber->extent.x0, throbber->extent.y0,
throbber->extent.x1, throbber->extent.y1);
if (error != NULL) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
throbber->icon = -1;
return false;
diff --git a/frontends/riscos/gui/url_bar.c b/frontends/riscos/gui/url_bar.c
index a5ec3f8c6..ee5c689df 100644
--- a/frontends/riscos/gui/url_bar.c
+++ b/frontends/riscos/gui/url_bar.c
@@ -140,7 +140,7 @@ struct url_bar *ro_gui_url_bar_create(struct theme_descriptor *theme)
url_bar = malloc(sizeof(struct url_bar));
if (url_bar == NULL) {
- LOG("No memory for malloc()");
+ NSLOG(netsurf, INFO, "No memory for malloc()");
return NULL;
}
@@ -240,7 +240,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
url_bar->container_icon,
x0, y0, x1, y1);
if (error != NULL) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
url_bar->container_icon = -1;
return false;
@@ -260,7 +261,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
url_bar->suggest_icon,
x0, y0, x1, y1);
if (error != NULL) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
url_bar->suggest_icon = -1;
return false;
@@ -281,7 +283,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
url_bar->text_icon,
x0, y0, x1, y1);
if (error != NULL) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
url_bar->text_icon = -1;
return false;
@@ -362,7 +365,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
wimp_ICON_BUTTON_TYPE_SHIFT);
error = xwimp_create_icon(&icon, &url_bar->container_icon);
if (error != NULL) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
url_bar->container_icon = -1;
return false;
@@ -373,7 +377,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
error = xwimp_delete_icon(url_bar->window,
url_bar->container_icon);
if (error != NULL) {
- LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -399,7 +404,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
wimp_ICON_BUTTON_TYPE_SHIFT);
error = xwimp_create_icon(&icon, &url_bar->text_icon);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
url_bar->text_icon = -1;
return false;
@@ -410,7 +416,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
error = xwimp_delete_icon(url_bar->window,
url_bar->text_icon);
if (error != NULL) {
- LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -430,7 +437,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
wimp_ICON_BUTTON_TYPE_SHIFT);
error = xwimp_create_icon(&icon, &url_bar->suggest_icon);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -450,7 +458,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
error = xwimp_delete_icon(url_bar->window,
url_bar->suggest_icon);
if (error != NULL) {
- LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -940,7 +949,8 @@ bool ro_gui_url_bar_take_caret(struct url_bar *url_bar)
error = xwimp_set_caret_position(url_bar->window, url_bar->text_icon,
-1, -1, -1, 0);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
@@ -977,7 +987,7 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
if (err != NSERROR_OK) {
/* A bad encoding should never happen, so assert this */
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
/* Paranoia */
local_text = NULL;
}
@@ -993,7 +1003,8 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
if (strlen(local_url) >= url_bar->text_size) {
url_bar->text_buffer[0] = '\0';
ro_warn_user("LongURL", NULL);
- LOG("Long URL (%zu chars): %s", strlen(url), url);
+ NSLOG(netsurf, INFO, "Long URL (%zu chars): %s", strlen(url),
+ url);
} else {
strncpy(url_bar->text_buffer, local_url,
url_bar->text_size - 1);
@@ -1021,7 +1032,8 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1034,7 +1046,10 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
error = xwimp_set_caret_position(url_bar->window,
url_bar->text_icon, 0, 0, -1, strlen(set_url));
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1123,7 +1138,8 @@ bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent)
state.i = url_bar->container_icon;
error = xwimp_get_icon_state(&state);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
diff --git a/frontends/riscos/help.c b/frontends/riscos/help.c
index b6871c5eb..952b3f2d1 100644
--- a/frontends/riscos/help.c
+++ b/frontends/riscos/help.c
@@ -166,7 +166,8 @@ void ro_gui_interactive_help_request(wimp_message *message)
error = xwimp_get_menu_state(wimp_GIVEN_WINDOW_AND_ICON,
&menu_tree, window, icon);
if (error) {
- LOG("xwimp_get_menu_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_menu_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -269,7 +270,8 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message,
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message *)reply,
reply->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -297,7 +299,10 @@ bool ro_gui_interactive_help_available(void)
error = xtaskmanager_enumerate_tasks(context, &task,
sizeof(taskmanager_task), &context, 0);
if (error) {
- LOG("xtaskmanager_enumerate_tasks: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xtaskmanager_enumerate_tasks: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
}
@@ -334,7 +339,8 @@ void ro_gui_interactive_help_start(void)
if ((help_start) && (help_start[0])) {
error = xwimp_start_task("<Help$Start>", &task);
if (error) {
- LOG("xwimp_start_tast: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_start_tast: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -344,7 +350,8 @@ void ro_gui_interactive_help_start(void)
if (!task) {
error = xwimp_start_task("Resources:$.Apps.!Help", &task);
if (error) {
- LOG("xwimp_start_tast: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_start_tast: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -354,7 +361,10 @@ void ro_gui_interactive_help_start(void)
if (task) {
error = xos_read_monotonic_time(&help_time);
if (error) {
- LOG("xwimp_read_monotonic_time: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_read_monotonic_time: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
diff --git a/frontends/riscos/history.c b/frontends/riscos/history.c
deleted file mode 100644
index de3af085d..000000000
--- a/frontends/riscos/history.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright 2006 James Bursa <bursa@users.sourceforge.net>
- * Copyright 2005 Richard Wilson <info@tinct.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Browser history window (RISC OS implementation).
- *
- * There is only one history window, not one per browser window.
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include "oslib/wimp.h"
-
-#include "utils/nsoption.h"
-#include "utils/log.h"
-#include "desktop/browser_history.h"
-#include "netsurf/plotters.h"
-
-#include "riscos/dialog.h"
-#include "riscos/gui.h"
-#include "riscos/mouse.h"
-#include "riscos/wimp.h"
-#include "riscos/wimp_event.h"
-#include "riscos/wimputils.h"
-
-static struct browser_window *history_bw;
-/* Last position of mouse in window. */
-static int mouse_x = 0;
-/* Last position of mouse in window. */
-static int mouse_y = 0;
-wimp_w history_window;
-
-static void ro_gui_history_redraw(wimp_draw *redraw);
-static bool ro_gui_history_click(wimp_pointer *pointer);
-static void ro_gui_history_pointer_entering(wimp_entering *entering);
-static void ro_gui_history_track_end(wimp_leaving *leaving, void *data);
-static void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data);
-
-
-/**
- * Create history window.
- */
-
-void ro_gui_history_init(void)
-{
- history_window = ro_gui_dialog_create("history");
- ro_gui_wimp_event_register_redraw_window(history_window,
- ro_gui_history_redraw);
- ro_gui_wimp_event_register_mouse_click(history_window,
- ro_gui_history_click);
- ro_gui_wimp_event_register_pointer_entering_window(history_window,
- ro_gui_history_pointer_entering);
- ro_gui_wimp_event_set_help_prefix(history_window, "HelpHistory");
-}
-
-
-/**
- * Open history window.
- *
- * \param g The riscos window to open history for.
- * \param at_pointer open the window at the pointer.
- */
-
-void ro_gui_history_open(struct gui_window *g, bool at_pointer)
-{
- struct browser_window *bw;
- int width, height;
- os_box box = {0, 0, 0, 0};
- wimp_window_state state;
- os_error *error;
-
- assert(g != NULL);
- assert(g->bw != NULL);
- bw = g->bw;
- history_bw = bw;
-
- browser_window_history_size(bw, &width, &height);
- width *= 2;
- height *= 2;
-
- /* set extent */
- box.x1 = width;
- box.y0 = -height;
- error = xwimp_set_extent(history_window, &box);
- if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- /* open full size */
- state.w = history_window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- state.visible.x0 = 0;
- state.visible.y0 = 0;
- state.visible.x1 = width;
- state.visible.y1 = height;
- state.next = wimp_HIDDEN;
- error = xwimp_open_window(PTR_WIMP_OPEN(&state));
- if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- ro_gui_dialog_open_persistent(g->window, history_window, at_pointer);
-}
-
-
-/**
- * Redraw history window.
- */
-
-void ro_gui_history_redraw(wimp_draw *redraw)
-{
- osbool more;
- os_error *error;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &ro_plotters
- };
-
- error = xwimp_redraw_window(redraw, &more);
- if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- while (more) {
- ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
- browser_window_history_redraw(history_bw, &ctx);
- error = xwimp_get_rectangle(redraw, &more);
- if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- }
-}
-
-
-/**
- * Handle Pointer Entering Window events the history window.
- *
- * \param *entering The Wimp_PointerEnteringWindow block.
- */
-
-void ro_gui_history_pointer_entering(wimp_entering *entering)
-{
- ro_mouse_track_start(ro_gui_history_track_end,
- ro_gui_history_mouse_at, NULL);
-}
-
-
-/**
- * Handle Pointer Leaving Window events the history window. These arrive as the
- * termination callback handler from ro_mouse's mouse tracking.
- *
- * \param *leaving The Wimp_PointerLeavingWindow block.
- * \param *data NULL data pointer.
- */
-
-void ro_gui_history_track_end(wimp_leaving *leaving, void *data)
-{
- ro_gui_dialog_close(dialog_tooltip);
-}
-
-
-/**
- * Handle mouse movements over the history window.
- */
-
-void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data)
-{
- int x, y;
- int width;
- const char *url;
- wimp_window_state state;
- wimp_icon_state ic;
- os_box box = {0, 0, 0, 0};
- os_error *error;
-
- LOG("Mouse at...");
-
- /* If the mouse hasn't moved, or if we don't want tooltips, exit */
- if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) ||
- !nsoption_bool(history_tooltip))
- return;
-
- /* Update mouse position */
- mouse_x = pointer->pos.x;
- mouse_y = pointer->pos.y;
-
- /* Find history tree entry under mouse */
- state.w = history_window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
- y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
- url = browser_window_history_position_url(history_bw, x, y);
- if (!url) {
- /* not over a tree entry => close tooltip window. */
- error = xwimp_close_window(dialog_tooltip);
- if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- return;
- }
-
- /* get width of string */
- error = xwimptextop_string_width(url,
- strlen(url) > 256 ? 256 : strlen(url),
- &width);
- if (error) {
- LOG("xwimptextop_string_width: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- ro_gui_set_icon_string(dialog_tooltip, 0, url, true);
-
- /* resize icon appropriately */
- ic.w = dialog_tooltip;
- ic.i = 0;
- error = xwimp_get_icon_state(&ic);
- if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- error = xwimp_resize_icon(dialog_tooltip, 0,
- ic.icon.extent.x0, ic.icon.extent.y0,
- width + 16, ic.icon.extent.y1);
- if (error) {
- LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- state.w = dialog_tooltip;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- /* update window extent */
- box.x1 = width + 16;
- box.y0 = -36;
- error = xwimp_set_extent(dialog_tooltip, &box);
- if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- /* set visible area */
- state.visible.x0 = pointer->pos.x + 24;
- state.visible.y0 = pointer->pos.y - 22 - 36;
- state.visible.x1 = pointer->pos.x + 24 + width + 16;
- state.visible.y1 = pointer->pos.y - 22;
- state.next = wimp_TOP;
- /* open window */
- error = xwimp_open_window(PTR_WIMP_OPEN(&state));
- if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-}
-
-
-/**
- * Handle mouse clicks in the history window.
- *
- * \return true if the event was handled, false to pass it on
- */
-
-bool ro_gui_history_click(wimp_pointer *pointer)
-{
- int x, y;
- wimp_window_state state;
- os_error *error;
-
- if (pointer->buttons != wimp_CLICK_SELECT &&
- pointer->buttons != wimp_CLICK_ADJUST)
- /* return if not select or adjust click */
- return true;
-
- state.w = history_window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return true;
- }
-
- x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
- y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
- browser_window_history_click(history_bw, x, y,
- pointer->buttons == wimp_CLICK_ADJUST);
-
- return true;
-}
diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c
index ea85bc3b5..b0ed1e2f4 100644
--- a/frontends/riscos/hotlist.c
+++ b/frontends/riscos/hotlist.c
@@ -466,7 +466,7 @@ static nserror ro_hotlist_init(void)
return NSERROR_OK;
}
- ncwin = malloc(sizeof(struct ro_hotlist_window));
+ ncwin = calloc(1, sizeof(*ncwin));
if (ncwin == NULL) {
return NSERROR_NOMEM;
}
@@ -548,19 +548,20 @@ nserror ro_gui_hotlist_present(void)
return NSERROR_OK;
}
- LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s", error->errnum,
+ error->errmess);
ro_warn_user("Failed to launch external hotlist: %s",
error->errmess);
}
res = ro_hotlist_init();
if (res == NSERROR_OK) {
- LOG("Presenting");
+ NSLOG(netsurf, INFO, "Presenting");
ro_gui_dialog_open_top(hotlist_window->core.wh,
hotlist_window->core.toolbar,
600, 800);
} else {
- LOG("Failed presenting code %d", res);
+ NSLOG(netsurf, INFO, "Failed presenting code %d", res);
}
return res;
@@ -583,7 +584,7 @@ nserror ro_gui_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_save));
+ res = hotlist_fini();
if (res == NSERROR_OK) {
res = ro_corewindow_fini(&hotlist_window->core);
diff --git a/frontends/riscos/iconbar.c b/frontends/riscos/iconbar.c
index 3430ed2f0..23f97258b 100644
--- a/frontends/riscos/iconbar.c
+++ b/frontends/riscos/iconbar.c
@@ -95,7 +95,8 @@ void ro_gui_iconbar_initialise(void)
{ "!netsurf" } } };
error = xwimp_create_icon(&icon, 0);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
die(error->errmess);
}
@@ -238,7 +239,8 @@ bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
return true;
case APPLICATION_QUIT:
if (ro_gui_prequit()) {
- LOG("QUIT in response to user request");
+ NSLOG(netsurf, INFO,
+ "QUIT in response to user request");
riscos_done = true;
}
return true;
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index acbe62d98..30cb30096 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -142,7 +142,8 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
}
if (error) {
- LOG("xtinct_plotscaled%s: 0x%x: %s", (alpha ? "alpha" : ""), error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xtinct_plotscaled%s: 0x%x: %s",
+ (alpha ? "alpha" : ""), error->errnum, error->errmess);
return false;
}
@@ -176,13 +177,16 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
if (error) {
- LOG("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_generate_table_for_sprite: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return false;
}
table = calloc(size, sizeof(char));
if (!table) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
ro_warn_user("NoMemory", 0);
return false;
}
@@ -193,7 +197,10 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
if (error) {
- LOG("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_generate_table_for_sprite: 0x%x: %s",
+ error->errnum,
+ error->errmess);
free(table);
return false;
}
@@ -208,7 +215,10 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
x, (int)(y - req_height),
8, &f, table);
if (error) {
- LOG("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_put_sprite_scaled: 0x%x: %s",
+ error->errnum,
+ error->errmess);
free(table);
return false;
}
diff --git a/frontends/riscos/local_history.c b/frontends/riscos/local_history.c
new file mode 100644
index 000000000..bbe6a1d12
--- /dev/null
+++ b/frontends/riscos/local_history.c
@@ -0,0 +1,442 @@
+/*
+ * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Implementation of RISC OS local history.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <oslib/wimp.h>
+
+#include "utils/nsoption.h"
+#include "utils/messages.h"
+#include "utils/log.h"
+#include "utils/nsurl.h"
+#include "netsurf/window.h"
+#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
+#include "desktop/local_history.h"
+
+#include "riscos/dialog.h"
+#include "riscos/gui.h"
+#include "riscos/menus.h"
+#include "riscos/save.h"
+#include "riscos/toolbar.h"
+#include "riscos/wimp.h"
+#include "riscos/wimp_event.h"
+#include "riscos/wimputils.h"
+#include "riscos/corewindow.h"
+#include "riscos/local_history.h"
+
+struct ro_local_history_window {
+ struct ro_corewindow core;
+
+ /** local history window context */
+ struct local_history_session *session;
+
+ /** tooltip previous x */
+ int x;
+ /** tooltip previous y */
+ int y;
+};
+
+/** local_history window is a singleton */
+static struct ro_local_history_window *local_history_window = NULL;
+
+/** riscos template for local_history window */
+static wimp_window *dialog_local_history_template;
+
+
+/**
+ * callback to draw on drawable area of ro local history window
+ *
+ * \param ro_cw The riscos core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param originx The risc os plotter x origin.
+ * \param originy The risc os plotter y origin.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ro_local_history_draw(struct ro_corewindow *ro_cw,
+ int originx,
+ int originy,
+ struct rect *r)
+{
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
+ struct ro_local_history_window *lhw;
+
+ lhw = (struct ro_local_history_window *)ro_cw;
+
+ ro_plot_origin_x = originx;
+ ro_plot_origin_y = originy;
+ no_font_blending = true;
+ local_history_redraw(lhw->session, 0, 0, r, &ctx);
+ no_font_blending = false;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * callback for keypress on ro coookie window
+ *
+ * \param ro_cw The ro core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
+ */
+static nserror
+ro_local_history_key(struct ro_corewindow *ro_cw, uint32_t nskey)
+{
+ struct ro_local_history_window *lhw;
+
+ lhw = (struct ro_local_history_window *)ro_cw;
+
+ if (local_history_keypress(lhw->session, nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+
+/**
+ * handle hover mouse movement for tooltips
+ */
+static nserror
+ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y)
+{
+ int width;
+ nsurl *url;
+ wimp_window_state state;
+ wimp_icon_state ic;
+ os_box box = {0, 0, 0, 0};
+ os_error *error;
+ wimp_pointer pointer;
+ nserror res;
+
+ /* check if tooltip are required */
+ if (!nsoption_bool(history_tooltip)) {
+ return NSERROR_OK;
+ }
+
+ /* ensure pointer has moved */
+ if ((lhw->x == x) && (lhw->y == y)) {
+ return NSERROR_OK;
+ }
+
+ lhw->x = x;
+ lhw->y = y;
+
+ res = local_history_get_url(lhw->session, x, y, &url);
+ if (res != NSERROR_OK) {
+ /* not over a tree entry => close tooltip window. */
+ error = xwimp_close_window(dialog_tooltip);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+ return NSERROR_OK;
+ }
+
+ /* get width of string */
+ error = xwimptextop_string_width(nsurl_access(url),
+ nsurl_length(url) > 256 ? 256 : nsurl_length(url),
+ &width);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ nsurl_unref(url);
+ return NSERROR_NOMEM;
+ }
+
+ ro_gui_set_icon_string(dialog_tooltip, 0, nsurl_access(url), true);
+ nsurl_unref(url);
+
+ /* resize icon appropriately */
+ ic.w = dialog_tooltip;
+ ic.i = 0;
+ error = xwimp_get_icon_state(&ic);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+ error = xwimp_resize_icon(dialog_tooltip, 0,
+ ic.icon.extent.x0, ic.icon.extent.y0,
+ width + 16, ic.icon.extent.y1);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ state.w = dialog_tooltip;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ /* update window extent */
+ box.x1 = width + 16;
+ box.y0 = -36;
+ error = xwimp_set_extent(dialog_tooltip, &box);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ /* set visible area */
+ state.visible.x0 = pointer.pos.x + 24;
+ state.visible.y0 = pointer.pos.y - 22 - 36;
+ state.visible.x1 = pointer.pos.x + 24 + width + 16;
+ state.visible.y1 = pointer.pos.y - 22;
+ state.next = wimp_TOP;
+ /* open window */
+ error = xwimp_open_window(PTR_WIMP_OPEN(&state));
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+ return NSERROR_OK;
+}
+
+
+/**
+ * callback for mouse event on ro local_history window
+ *
+ * \param ro_cw The ro core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+static nserror
+ro_local_history_mouse(struct ro_corewindow *ro_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct ro_local_history_window *lhw;
+
+ lhw = (struct ro_local_history_window *)ro_cw;
+
+ switch (mouse_state) {
+
+ case BROWSER_MOUSE_HOVER:
+ ro_local_history_tooltip(lhw, x, y);
+ break;
+
+ case BROWSER_MOUSE_LEAVE:
+ ro_gui_dialog_close(dialog_tooltip);
+ break;
+
+ default:
+ local_history_mouse_action(lhw->session, mouse_state, x, y);
+ break;
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Creates the window for the local_history tree.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+static nserror
+ro_local_history_init(struct browser_window *bw,
+ struct ro_local_history_window **win_out)
+{
+ struct ro_local_history_window *ncwin;
+ nserror res;
+
+ /* memoise window so it can be represented when necessary
+ * instead of recreating every time.
+ */
+ if ((*win_out) != NULL) {
+ res = local_history_set((*win_out)->session, bw);
+ return res;
+ }
+
+ ncwin = calloc(1, sizeof(*ncwin));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ /* create window from template */
+ ncwin->core.wh = wimp_create_window(dialog_local_history_template);
+
+ /* initialise callbacks */
+ ncwin->core.draw = ro_local_history_draw;
+ ncwin->core.key = ro_local_history_key;
+ ncwin->core.mouse = ro_local_history_mouse;
+
+ /* initialise core window */
+ res = ro_corewindow_init(&ncwin->core,
+ NULL,
+ NULL,
+ 0,
+ NULL);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = local_history_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ bw,
+ &ncwin->session);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ *win_out = ncwin;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * open RISC OS local history window at the correct size
+ */
+static nserror
+ro_local_history_open(struct ro_local_history_window *lhw, wimp_w parent)
+{
+ nserror res;
+ int width, height;
+ os_box box = {0, 0, 0, 0};
+ wimp_window_state state;
+ os_error *error;
+
+ res = local_history_get_size(lhw->session, &width, &height);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ width *= 2;
+ height *= 2;
+
+ /* set extent */
+ box.x1 = width;
+ box.y0 = -height;
+ error = xwimp_set_extent(lhw->core.wh, &box);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ /* open full size */
+ state.w = lhw->core.wh;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+ state.visible.x0 = 0;
+ state.visible.y0 = 0;
+ state.visible.x1 = width;
+ state.visible.y1 = height;
+ state.next = wimp_HIDDEN;
+ error = xwimp_open_window(PTR_WIMP_OPEN(&state));
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ ro_gui_dialog_open_persistent(parent, lhw->core.wh, true);
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in riscos/local_history.h */
+nserror ro_gui_local_history_present(wimp_w parent, struct browser_window *bw)
+{
+ nserror res;
+
+ res = ro_local_history_init(bw, &local_history_window);
+ if (res == NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Presenting");
+ res = ro_local_history_open(local_history_window, parent);
+ } else {
+ NSLOG(netsurf, INFO, "Failed presenting error code %d", res);
+ }
+
+ return res;
+}
+
+
+/* exported interface documented in riscos/local_history.h */
+void ro_gui_local_history_initialise(void)
+{
+ dialog_local_history_template = ro_gui_dialog_load_template("history");
+}
+
+
+/* exported interface documented in riscos/local_history.h */
+nserror ro_gui_local_history_finalise(void)
+{
+ nserror res;
+
+ if (local_history_window == NULL) {
+ return NSERROR_OK;
+ }
+
+ res = local_history_fini(local_history_window->session);
+ if (res == NSERROR_OK) {
+ res = ro_corewindow_fini(&local_history_window->core);
+
+ free(local_history_window);
+ local_history_window = NULL;
+ }
+
+ return res;
+}
diff --git a/frontends/riscos/local_history.h b/frontends/riscos/local_history.h
new file mode 100644
index 000000000..d5b22b404
--- /dev/null
+++ b/frontends/riscos/local_history.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * RISC OS local history interface.
+ */
+
+#ifndef RISCOS_LOCALHISTORY_H
+#define RISCOS_LOCALHISTORY_H
+
+/**
+ * initialise the local history window template ready for subsequent use.
+ */
+void ro_gui_local_history_initialise(void);
+
+/**
+ * make the local history window visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_local_history_present(wimp_w parent, struct browser_window *bw);
+
+/**
+ * Free any resources allocated for the local history window.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_local_history_finalise(void);
+
+#endif
diff --git a/frontends/riscos/menus.c b/frontends/riscos/menus.c
index d46afa28e..a6e978a6c 100644
--- a/frontends/riscos/menus.c
+++ b/frontends/riscos/menus.c
@@ -232,7 +232,8 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
current_menu_open = true;
error = xwimp_create_menu(menu, x - 64, y);
if (error) {
- LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
ro_gui_menu_closed();
}
@@ -258,14 +259,16 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i)
icon_state.i = i;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
return;
}
error = xwimp_get_icon_state(&icon_state);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
return;
}
@@ -291,7 +294,8 @@ void ro_gui_menu_destroy(void)
error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
if (error) {
- LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
}
@@ -354,7 +358,8 @@ void ro_gui_menu_selection(wimp_selection *selection)
/* re-open the menu for Adjust clicks */
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
ro_gui_menu_closed();
return;
@@ -420,7 +425,8 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
error = xwimp_create_sub_menu(menu_entry->sub_menu,
warning->pos.x, warning->pos.y);
if (error) {
- LOG("xwimp_create_sub_menu: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_sub_menu: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
}
}
@@ -485,7 +491,8 @@ void ro_gui_menu_refresh(wimp_menu *menu)
os_error *error;
error = xwimp_create_menu(current_menu, 0, 0);
if (error) {
- LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
}
}
@@ -851,7 +858,8 @@ int ro_gui_menu_get_checksum(void)
error = xwimp_get_menu_state((wimp_menu_state_flags)0,
&menu_tree, 0, 0);
if (error) {
- LOG("xwimp_get_menu_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_menu_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MenuError", error->errmess);
return 0;
}
@@ -894,7 +902,8 @@ bool ro_gui_menu_translate(struct menu_definition *menu)
/* read current alphabet */
error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &alphabet);
if (error) {
- LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s",
+ error->errnum, error->errmess);
/* assume Latin1 */
alphabet = territory_ALPHABET_LATIN1;
}
@@ -909,7 +918,7 @@ bool ro_gui_menu_translate(struct menu_definition *menu)
0, &translated);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
return false;
}
@@ -926,7 +935,7 @@ bool ro_gui_menu_translate(struct menu_definition *menu)
0, &translated);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
return false;
}
diff --git a/frontends/riscos/message.c b/frontends/riscos/message.c
index 1c54ea0b7..7a0216185 100644
--- a/frontends/riscos/message.c
+++ b/frontends/riscos/message.c
@@ -64,7 +64,8 @@ bool ro_message_send_message(wimp_event_no event, wimp_message *message,
/* send a message */
error = xwimp_send_message(event, message, task);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -101,7 +102,10 @@ bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *messag
/* send a message */
error = xwimp_send_message_to_window(event, message, to_w, to_i, to_t);
if (error) {
- LOG("xwimp_send_message_to_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_send_message_to_window: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
diff --git a/frontends/riscos/mouse.c b/frontends/riscos/mouse.c
index a0cc0e7ce..89184cff3 100644
--- a/frontends/riscos/mouse.c
+++ b/frontends/riscos/mouse.c
@@ -81,7 +81,8 @@ void ro_mouse_poll(void)
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -194,7 +195,7 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
ro_mouse_ignore_leaving_event == false)
ro_mouse_poll_end_callback(NULL, ro_mouse_poll_data);
- LOG("Unexpected mouse track termination.");
+ NSLOG(netsurf, INFO, "Unexpected mouse track termination.");
ro_mouse_ignore_leaving_event = false;
ro_mouse_poll_end_callback = NULL;
diff --git a/frontends/riscos/plotters.c b/frontends/riscos/plotters.c
index 06e732d99..2b306827d 100644
--- a/frontends/riscos/plotters.c
+++ b/frontends/riscos/plotters.c
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Target independent plotting (RISC OS screen implementation).
+/**
+ * \file
+ * RISC OS screen plotter implementation.
*/
#include <stdbool.h>
@@ -35,38 +36,6 @@
#include "riscos/font.h"
#include "riscos/oslib_pre7.h"
-static bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_plot_draw_path(const draw_path * const path, int width,
- colour c, bool dotted, bool dashed);
-static bool ro_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
-static bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6]);
-static bool ro_plot_clip(const struct rect *clip);
-static bool ro_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle);
-static bool ro_plot_disc(int x, int y, int radius, const plot_style_t *style);
-static bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style);
-static bool ro_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags);
-
-
-struct plotter_table plot;
-
-const struct plotter_table ro_plotters = {
- .rectangle = ro_plot_rectangle,
- .line = ro_plot_line,
- .polygon = ro_plot_polygon,
- .clip = ro_plot_clip,
- .text = ro_plot_text,
- .disc = ro_plot_disc,
- .arc = ro_plot_arc,
- .bitmap = ro_plot_bitmap,
- .path = ro_plot_path,
- .option_knockout = true,
-};
int ro_plot_origin_x = 0;
int ro_plot_origin_y = 0;
@@ -74,143 +43,404 @@ int ro_plot_origin_y = 0;
/** One version of the A9home OS is incapable of drawing patterned lines */
bool ro_plot_patterned_lines = true;
+/**
+ * plot a path on RISC OS
+ */
+static nserror
+ro_plot_draw_path(const draw_path * const path,
+ int width,
+ colour c,
+ bool dotted,
+ bool dashed)
+{
+ static const draw_line_style line_style = {
+ draw_JOIN_MITRED,
+ draw_CAP_BUTT,
+ draw_CAP_BUTT,
+ 0, 0x7fffffff,
+ 0, 0, 0, 0
+ };
+ draw_dash_pattern dash = { 0, 1, { 512 } };
+ const draw_dash_pattern *dash_pattern = 0;
+ os_error *error;
+
+ if (width < 1)
+ width = 1;
+
+ if (ro_plot_patterned_lines) {
+ if (dotted) {
+ dash.elements[0] = 512 * width;
+ dash_pattern = &dash;
+ } else if (dashed) {
+ dash.elements[0] = 1536 * width;
+ dash_pattern = &dash;
+ }
+ }
+
+ error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ error = xdraw_stroke(path, 0, 0, 0, width * 2 * 256,
+ &line_style, dash_pattern);
+ if (error) {
+ NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * \brief Sets a clip rectangle for subsequent plot operations.
+ *
+ * \param ctx The current redraw context.
+ * \param clip The rectangle to limit all subsequent plot
+ * operations within.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
+{
+ os_error *error;
+ char buf[12];
+
+ int clip_x0 = ro_plot_origin_x + clip->x0 * 2;
+ int clip_y0 = ro_plot_origin_y - clip->y0 * 2 - 1;
+ int clip_x1 = ro_plot_origin_x + clip->x1 * 2 - 1;
+ int clip_y1 = ro_plot_origin_y - clip->y1 * 2;
+
+ if (clip_x1 < clip_x0 || clip_y0 < clip_y1) {
+ NSLOG(netsurf, INFO, "bad clip rectangle %i %i %i %i",
+ clip_x0, clip_y0, clip_x1, clip_y1);
+ return NSERROR_BAD_SIZE;
+ }
+
+ buf[0] = os_VDU_SET_GRAPHICS_WINDOW;
+ buf[1] = clip_x0;
+ buf[2] = clip_x0 >> 8;
+ buf[3] = clip_y1;
+ buf[4] = clip_y1 >> 8;
+ buf[5] = clip_x1;
+ buf[6] = clip_x1 >> 8;
+ buf[7] = clip_y0;
+ buf[8] = clip_y0 >> 8;
+
+ error = xos_writen(buf, 9);
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_writen: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+ return NSERROR_OK;
+}
-bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
+
+/**
+ * Plots an arc
+ *
+ * plot an arc segment around (x,y), anticlockwise from angle1
+ * to angle2. Angles are measured anticlockwise from
+ * horizontal, in degrees.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the arc plot.
+ * \param x The x coordinate of the arc.
+ * \param y The y coordinate of the arc.
+ * \param radius The radius of the arc.
+ * \param angle1 The start angle of the arc.
+ * \param angle2 The finish angle of the arc.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_arc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius, int angle1, int angle2)
{
+ os_error *error;
+ int sx, sy, ex, ey;
+ double t;
+
+ x = ro_plot_origin_x + x * 2;
+ y = ro_plot_origin_y - y * 2;
+ radius <<= 1;
+
+ error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
+ os_ACTION_OVERWRITE, 0, 0);
+
+ if (error) {
+ NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ t = ((double)angle1 * M_PI) / 180.0;
+ sx = (x + (int)(radius * cos(t)));
+ sy = (y + (int)(radius * sin(t)));
+
+ t = ((double)angle2 * M_PI) / 180.0;
+ ex = (x + (int)(radius * cos(t)));
+ ey = (y + (int)(radius * sin(t)));
+
+ error = xos_plot(os_MOVE_TO, x, y); /* move to centre */
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ error = xos_plot(os_MOVE_TO, sx, sy); /* move to start */
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ error = xos_plot(os_PLOT_ARC | os_PLOT_TO, ex, ey); /* arc to end */
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Plots a circle
+ *
+ * Plot a circle centered on (x,y), which is optionally filled.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the circle plot.
+ * \param x The x coordinate of the circle.
+ * \param y The y coordinate of the circle.
+ * \param radius The radius of the circle.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_disc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius)
+{
+ os_error *error;
if (style->fill_type != PLOT_OP_TYPE_NONE) {
- os_error *error;
- error = xcolourtrans_set_gcol(style->fill_colour << 8,
- colourtrans_USE_ECFS_GCOL,
- os_ACTION_OVERWRITE, 0, 0);
+ error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
+ os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
}
-
error = xos_plot(os_MOVE_TO,
- ro_plot_origin_x + x0 * 2,
- ro_plot_origin_y - y0 * 2 - 1);
+ ro_plot_origin_x + x * 2,
+ ro_plot_origin_y - y * 2);
if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
-
- error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- ro_plot_origin_x + x1 * 2 - 1,
- ro_plot_origin_y - y1 * 2);
+ error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius * 2, 0);
if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- bool dotted = false;
- bool dashed = false;
-
- const int path[] = { draw_MOVE_TO,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + (x1) * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + (x1) * 2) * 256,
- (ro_plot_origin_y - (y1) * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - (y1) * 2 - 1) * 256,
- draw_CLOSE_LINE,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_END_PATH };
-
- if (style->stroke_type == PLOT_OP_TYPE_DOT)
- dotted = true;
- if (style->stroke_type == PLOT_OP_TYPE_DASH)
- dashed = true;
+ error = xcolourtrans_set_gcol(style->stroke_colour << 8, 0,
+ os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+ error = xos_plot(os_MOVE_TO,
+ ro_plot_origin_x + x * 2,
+ ro_plot_origin_y - y * 2);
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
+ error = xos_plot(os_PLOT_CIRCLE_OUTLINE | os_PLOT_BY,
+ radius * 2, 0);
- ro_plot_draw_path((const draw_path *)path,
- style->stroke_width,
- style->stroke_colour,
- dotted, dashed);
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
}
-
- return true;
+ return NSERROR_OK;
}
-bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
+/**
+ * Plots a line
+ *
+ * plot a line from (x0,y0) to (x1,y1). Coordinates are at
+ * centre of line width/thickness.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the line plot.
+ * \param line A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_line(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *line)
{
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- const int path[] = { draw_MOVE_TO,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + x1 * 2) * 256,
- (ro_plot_origin_y - y1 * 2 - 1) * 256,
- draw_END_PATH };
- bool dotted = false;
+ const int path[] = {
+ draw_MOVE_TO,
+ (ro_plot_origin_x + line->x0 * 2) * 256,
+ (ro_plot_origin_y - line->y0 * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + line->x1 * 2) * 256,
+ (ro_plot_origin_y - line->y1 * 2 - 1) * 256,
+ draw_END_PATH };
+ bool dotted = false;
bool dashed = false;
- if (style->stroke_type == PLOT_OP_TYPE_DOT)
+ if (style->stroke_type == PLOT_OP_TYPE_DOT)
dotted = true;
- if (style->stroke_type == PLOT_OP_TYPE_DASH)
+ if (style->stroke_type == PLOT_OP_TYPE_DASH)
dashed = true;
- return ro_plot_draw_path((const draw_path *)path,
- style->stroke_width,
- style->stroke_colour,
- dotted, dashed);
+ return ro_plot_draw_path((const draw_path *)path,
+ plot_style_fixed_to_int(style->stroke_width),
+ style->stroke_colour,
+ dotted, dashed);
}
- return true;
+ return NSERROR_OK;
}
-bool ro_plot_draw_path(const draw_path * const path, int width,
- colour c, bool dotted, bool dashed)
+/**
+ * Plots a rectangle.
+ *
+ * The rectangle can be filled an outline or both controlled
+ * by the plot style The line can be solid, dotted or
+ * dashed. Top left corner at (x0,y0) and rectangle has given
+ * width and height.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the rectangle plot.
+ * \param rect A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_rectangle(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *rect)
{
- static const draw_line_style line_style = { draw_JOIN_MITRED,
- draw_CAP_BUTT, draw_CAP_BUTT, 0, 0x7fffffff,
- 0, 0, 0, 0 };
- draw_dash_pattern dash = { 0, 1, { 512 } };
- const draw_dash_pattern *dash_pattern = 0;
- os_error *error;
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ os_error *error;
+ error = xcolourtrans_set_gcol(style->fill_colour << 8,
+ colourtrans_USE_ECFS_GCOL,
+ os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
- if (width < 1)
- width = 1;
+ error = xos_plot(os_MOVE_TO,
+ ro_plot_origin_x + rect->x0 * 2,
+ ro_plot_origin_y - rect->y0 * 2 - 1);
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
- if (ro_plot_patterned_lines) {
- if (dotted) {
- dash.elements[0] = 512 * width;
- dash_pattern = &dash;
- } else if (dashed) {
- dash.elements[0] = 1536 * width;
- dash_pattern = &dash;
+ error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
+ ro_plot_origin_x + rect->x1 * 2 - 1,
+ ro_plot_origin_y - rect->y1 * 2);
+ if (error) {
+ NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
}
- error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0);
- if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ bool dotted = false;
+ bool dashed = false;
- error = xdraw_stroke(path, 0, 0, 0, width * 2 * 256,
- &line_style, dash_pattern);
- if (error) {
- LOG("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ const int path[] = {
+ draw_MOVE_TO,
+ (ro_plot_origin_x + rect->x0 * 2) * 256,
+ (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + (rect->x1) * 2) * 256,
+ (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + (rect->x1) * 2) * 256,
+ (ro_plot_origin_y - (rect->y1) * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + rect->x0 * 2) * 256,
+ (ro_plot_origin_y - (rect->y1) * 2 - 1) * 256,
+ draw_CLOSE_LINE,
+ (ro_plot_origin_x + rect->x0 * 2) * 256,
+ (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
+ draw_END_PATH
+ };
+
+ if (style->stroke_type == PLOT_OP_TYPE_DOT)
+ dotted = true;
+
+ if (style->stroke_type == PLOT_OP_TYPE_DASH)
+ dashed = true;
+
+ ro_plot_draw_path((const draw_path *)path,
+ plot_style_fixed_to_int(style->stroke_width),
+ style->stroke_colour,
+ dotted,
+ dashed);
}
- return true;
+ return NSERROR_OK;
}
-bool ro_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
+/**
+ * Plot a polygon
+ *
+ * Plots a filled polygon with straight lines between
+ * points. The lines around the edge of the ploygon are not
+ * plotted. The polygon is filled with the non-zero winding
+ * rule.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the polygon plot.
+ * \param p verticies of polygon
+ * \param n number of verticies.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_polygon(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
{
int path[n * 3 + 2];
unsigned int i;
@@ -225,43 +455,68 @@ bool ro_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
path[n * 3] = draw_END_PATH;
path[n * 3 + 1] = 0;
- error = xcolourtrans_set_gcol(style->fill_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0);
+ error = xcolourtrans_set_gcol(style->fill_colour << 8,
+ 0, os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
error = xdraw_fill((draw_path *) path, 0, 0, 0);
if (error) {
- LOG("xdraw_fill: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO, "xdraw_fill: 0x%x: %s", error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
}
- return true;
+ return NSERROR_OK;
}
-bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6])
+/**
+ * Plots a path.
+ *
+ * Path plot consisting of cubic Bezier curves. Line and fill colour is
+ * controlled by the plot style.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the path plot.
+ * \param p elements of path
+ * \param n nunber of elements on path
+ * \param transform A transform to apply to the path.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_path(const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ const float transform[6])
{
- static const draw_line_style line_style = { draw_JOIN_MITRED,
- draw_CAP_BUTT, draw_CAP_BUTT, 0, 0x7fffffff,
- 0, 0, 0, 0 };
+ static const draw_line_style line_style = {
+ draw_JOIN_MITRED,
+ draw_CAP_BUTT,
+ draw_CAP_BUTT,
+ 0, 0x7fffffff,
+ 0, 0, 0, 0
+ };
int *path = 0;
unsigned int i;
os_trfm trfm;
os_error *error;
- if (n == 0)
- return true;
+ if (n == 0) {
+ return NSERROR_OK;
+ }
if (p[0] != PLOTTER_PATH_MOVE) {
- LOG("path doesn't start with a move");
+ NSLOG(netsurf, INFO, "path doesn't start with a move");
goto error;
}
path = malloc(sizeof *path * (n + 10));
if (!path) {
- LOG("out of memory");
+ NSLOG(netsurf, INFO, "out of memory");
goto error;
}
@@ -289,7 +544,7 @@ bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
path[i + 6] = -p[i + 6] * 2 * 256;
i += 7;
} else {
- LOG("bad path command %f", p[i]);
+ NSLOG(netsurf, INFO, "bad path command %f", p[i]);
goto error;
}
}
@@ -303,222 +558,167 @@ bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
trfm.entries[2][0] = (ro_plot_origin_x + transform[4] * 2) * 256;
trfm.entries[2][1] = (ro_plot_origin_y - transform[5] * 2) * 256;
- if (fill != NS_TRANSPARENT) {
- error = xcolourtrans_set_gcol(fill << 8, 0,
+ if (pstyle->fill_colour != NS_TRANSPARENT) {
+ error = xcolourtrans_set_gcol(pstyle->fill_colour << 8, 0,
os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
goto error;
}
error = xdraw_fill((draw_path *) path, 0, &trfm, 0);
if (error) {
- LOG("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s",
+ error->errnum, error->errmess);
goto error;
}
}
- if (c != NS_TRANSPARENT) {
- error = xcolourtrans_set_gcol(c << 8, 0,
+ if (pstyle->stroke_colour != NS_TRANSPARENT) {
+ error = xcolourtrans_set_gcol(pstyle->stroke_colour << 8, 0,
os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
goto error;
}
error = xdraw_stroke((draw_path *) path, 0, &trfm, 0,
- width * 2 * 256, &line_style, 0);
+ plot_style_fixed_to_int(
+ pstyle->stroke_width) * 2 * 256,
+ &line_style, 0);
if (error) {
- LOG("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s",
+ error->errnum, error->errmess);
goto error;
}
}
free(path);
- return true;
+ return NSERROR_OK;
error:
free(path);
- return false;
+ return NSERROR_INVALID;
}
-
-
-bool ro_plot_clip(const struct rect *clip)
+/**
+ * Plot a bitmap
+ *
+ * Tiled plot of a bitmap image. (x,y) gives the top left
+ * coordinate of an explicitly placed tile. From this tile the
+ * image can repeat in all four directions -- up, down, left
+ * and right -- to the extents given by the current clip
+ * rectangle.
+ *
+ * The bitmap_flags say whether to tile in the x and y
+ * directions. If not tiling in x or y directions, the single
+ * image is plotted. The width and height give the dimensions
+ * the image is to be scaled to.
+ *
+ * \param ctx The current redraw context.
+ * \param bitmap The bitmap to plot
+ * \param x The x coordinate to plot the bitmap
+ * \param y The y coordiante to plot the bitmap
+ * \param width The width of area to plot the bitmap into
+ * \param height The height of area to plot the bitmap into
+ * \param bg the background colour to alpha blend into
+ * \param flags the flags controlling the type of plot operation
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_bitmap(const struct redraw_context *ctx,
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
{
- os_error *error;
- char buf[12];
-
- int clip_x0 = ro_plot_origin_x + clip->x0 * 2;
- int clip_y0 = ro_plot_origin_y - clip->y0 * 2 - 1;
- int clip_x1 = ro_plot_origin_x + clip->x1 * 2 - 1;
- int clip_y1 = ro_plot_origin_y - clip->y1 * 2;
+ const uint8_t *buffer;
- if (clip_x1 < clip_x0 || clip_y0 < clip_y1) {
- LOG("bad clip rectangle %i %i %i %i", clip_x0, clip_y0, clip_x1, clip_y1);
- return false;
+ buffer = riscos_bitmap_get_buffer(bitmap);
+ if (!buffer) {
+ NSLOG(netsurf, INFO, "bitmap_get_buffer failed");
+ return NSERROR_INVALID;
}
- buf[0] = os_VDU_SET_GRAPHICS_WINDOW;
- buf[1] = clip_x0;
- buf[2] = clip_x0 >> 8;
- buf[3] = clip_y1;
- buf[4] = clip_y1 >> 8;
- buf[5] = clip_x1;
- buf[6] = clip_x1 >> 8;
- buf[7] = clip_y0;
- buf[8] = clip_y0 >> 8;
-
- error = xos_writen(buf, 9);
- if (error) {
- LOG("xos_writen: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ if (!image_redraw(bitmap->sprite_area,
+ ro_plot_origin_x + x * 2,
+ ro_plot_origin_y - y * 2,
+ width, height,
+ bitmap->width,
+ bitmap->height,
+ bg,
+ flags & BITMAPF_REPEAT_X, flags & BITMAPF_REPEAT_Y,
+ flags & BITMAPF_REPEAT_X || flags & BITMAPF_REPEAT_Y,
+ riscos_bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
+ IMAGE_PLOT_TINCT_ALPHA)) {
+ return NSERROR_INVALID;
}
-
- return true;
+ return NSERROR_OK;
}
-bool ro_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle)
+/**
+ * Text plotting.
+ *
+ * \param ctx The current redraw context.
+ * \param fstyle plot style for this text
+ * \param x x coordinate
+ * \param y y coordinate
+ * \param text UTF-8 string to plot
+ * \param length length of string, in bytes
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_plot_text(const struct redraw_context *ctx,
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
{
os_error *error;
error = xcolourtrans_set_font_colours(font_CURRENT,
- fstyle->background << 8, fstyle->foreground << 8,
+ fstyle->background << 8, fstyle->foreground << 8,
14, 0, 0, 0);
if (error) {
- LOG("xcolourtrans_set_font_colours: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_font_colours: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
}
- return nsfont_paint(fstyle, text, length,
+ if (!nsfont_paint(fstyle, text, length,
ro_plot_origin_x + x * 2,
- ro_plot_origin_y - y * 2);
-}
-
-
-bool ro_plot_disc(int x, int y, int radius, const plot_style_t *style)
-{
- os_error *error;
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
- error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
- os_ACTION_OVERWRITE, 0, 0);
- if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- error = xos_plot(os_MOVE_TO,
- ro_plot_origin_x + x * 2,
- ro_plot_origin_y - y * 2);
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius * 2, 0);
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- }
-
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
-
- error = xcolourtrans_set_gcol(style->stroke_colour << 8, 0,
- os_ACTION_OVERWRITE, 0, 0);
- if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- error = xos_plot(os_MOVE_TO,
- ro_plot_origin_x + x * 2,
- ro_plot_origin_y - y * 2);
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- error = xos_plot(os_PLOT_CIRCLE_OUTLINE | os_PLOT_BY,
- radius * 2, 0);
-
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
- }
- return true;
-}
-
-bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
-{
- os_error *error;
- int sx, sy, ex, ey;
- double t;
-
- x = ro_plot_origin_x + x * 2;
- y = ro_plot_origin_y - y * 2;
- radius <<= 1;
-
- error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
- os_ACTION_OVERWRITE, 0, 0);
-
- if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
- return false;
+ ro_plot_origin_y - y * 2)) {
+ return NSERROR_INVALID;
}
-
- t = ((double)angle1 * M_PI) / 180.0;
- sx = (x + (int)(radius * cos(t)));
- sy = (y + (int)(radius * sin(t)));
-
- t = ((double)angle2 * M_PI) / 180.0;
- ex = (x + (int)(radius * cos(t)));
- ey = (y + (int)(radius * sin(t)));
-
- error = xos_plot(os_MOVE_TO, x, y); /* move to centre */
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
-
- error = xos_plot(os_MOVE_TO, sx, sy); /* move to start */
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
-
- error = xos_plot(os_PLOT_ARC | os_PLOT_TO, ex, ey); /* arc to end */
- if (error) {
- LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess);
- return false;
- }
-
- return true;
+ return NSERROR_OK;
}
-
-bool ro_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags)
-{
- const uint8_t *buffer;
-
- buffer = riscos_bitmap_get_buffer(bitmap);
- if (!buffer) {
- LOG("bitmap_get_buffer failed");
- return false;
- }
-
- return image_redraw(bitmap->sprite_area,
- ro_plot_origin_x + x * 2,
- ro_plot_origin_y - y * 2,
- width, height,
- bitmap->width,
- bitmap->height,
- bg,
- flags & BITMAPF_REPEAT_X, flags & BITMAPF_REPEAT_Y,
- flags & BITMAPF_REPEAT_X || flags & BITMAPF_REPEAT_Y,
- riscos_bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
- IMAGE_PLOT_TINCT_ALPHA);
-}
+/**
+ * RISC OS plotter operation table
+ */
+const struct plotter_table ro_plotters = {
+ .rectangle = ro_plot_rectangle,
+ .line = ro_plot_line,
+ .polygon = ro_plot_polygon,
+ .clip = ro_plot_clip,
+ .text = ro_plot_text,
+ .disc = ro_plot_disc,
+ .arc = ro_plot_arc,
+ .bitmap = ro_plot_bitmap,
+ .path = ro_plot_path,
+ .option_knockout = true,
+};
diff --git a/frontends/riscos/print.c b/frontends/riscos/print.c
index 465627eea..b390c693d 100644
--- a/frontends/riscos/print.c
+++ b/frontends/riscos/print.c
@@ -41,6 +41,7 @@
#include "content/content.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/dialog.h"
#include "riscos/menus.h"
#include "riscos/print.h"
@@ -95,7 +96,6 @@ static unsigned int print_fonts_count;
/** Error in print_fonts_plot_text() or print_fonts_callback(). */
static const char *print_fonts_error;
-void gui_window_redraw_window(struct gui_window *g);
static bool ro_gui_print_click(wimp_pointer *pointer);
static bool ro_gui_print_apply(wimp_w w);
@@ -104,39 +104,12 @@ static void print_send_printsave(struct hlcache_handle *h);
static bool print_send_printtypeknown(wimp_message *m);
static bool print_document(struct gui_window *g, const char *filename);
static const char *print_declare_fonts(struct hlcache_handle *h);
-static bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool print_fonts_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
-static bool print_fonts_plot_clip(const struct rect *clip);
-static bool print_fonts_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle);
-static bool print_fonts_plot_disc(int x, int y, int radius, const plot_style_t *style);
-static bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style);
-static bool print_fonts_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags);
-static bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6]);
static void print_fonts_callback(void *context,
const char *font_name, unsigned int font_size,
const char *s8, unsigned short *s16, unsigned int n,
int x, int y);
-/** Plotter for print_declare_fonts(). All the functions do nothing except for
- * print_fonts_plot_text, which records the fonts used. */
-static const struct plotter_table print_fonts_plotters = {
- .rectangle = print_fonts_plot_rectangle,
- .line = print_fonts_plot_line,
- .polygon = print_fonts_plot_polygon,
- .clip = print_fonts_plot_clip,
- .text = print_fonts_plot_text,
- .disc = print_fonts_plot_disc,
- .arc = print_fonts_plot_arc,
- .bitmap = print_fonts_plot_bitmap,
- .path = print_fonts_plot_path,
- .option_knockout = false,
-};
/**
@@ -196,7 +169,8 @@ void ro_gui_print_prepare(struct gui_window *g)
/* Read Printer Driver name */
error = xpdriver_info(0, 0, 0, 0, &desc, 0, 0, 0);
if (error) {
- LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s",
+ error->errnum, error->errmess);
printers_exists = false;
}
@@ -333,7 +307,8 @@ void print_send_printsave(struct hlcache_handle *h)
e = xwimp_send_message(wimp_USER_MESSAGE_RECORDED,
(wimp_message *)&m, 0);
if (e) {
- LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ e->errnum, e->errmess);
ro_warn_user("WimpError", e->errmess);
ro_print_cleanup();
}
@@ -357,7 +332,8 @@ bool print_send_printtypeknown(wimp_message *m)
m->action = message_PRINT_TYPE_KNOWN;
e = xwimp_send_message(wimp_USER_MESSAGE, m, m->sender);
if (e) {
- LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ e->errnum, e->errmess);
ro_warn_user("WimpError", e->errmess);
return false;
}
@@ -463,7 +439,8 @@ bool ro_print_ack(wimp_message *m)
/* read printer driver type */
error = xpdriver_info(&info_type, 0, 0, 0, 0, 0, 0, 0);
if (error) {
- LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
ro_print_cleanup();
return true;
@@ -488,7 +465,8 @@ bool ro_print_ack(wimp_message *m)
error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, m, m->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
/* and delete temporary file */
xosfile_delete(m->data.data_xfer.file_name,
@@ -560,7 +538,8 @@ bool print_document(struct gui_window *g, const char *filename)
/* read printer driver features */
error = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0);
if (error) {
- LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
return false;
}
@@ -568,7 +547,8 @@ bool print_document(struct gui_window *g, const char *filename)
/* read page size */
error = xpdriver_page_size(0, 0, &left, &bottom, &right, &top);
if (error) {
- LOG("xpdriver_page_size: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_page_size: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
return false;
}
@@ -591,7 +571,8 @@ bool print_document(struct gui_window *g, const char *filename)
error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR |
osfind_ERROR_IF_ABSENT, filename, 0, &fhandle);
if (error) {
- LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
return false;
}
@@ -599,7 +580,8 @@ bool print_document(struct gui_window *g, const char *filename)
/* select print job */
error = xpdriver_select_jobw(fhandle, "NetSurf", &old_job);
if (error) {
- LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_select_jobw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
xosfind_closew(fhandle);
return false;
@@ -659,18 +641,23 @@ bool print_document(struct gui_window *g, const char *filename)
/* give page rectangle */
error = xpdriver_give_rectangle(0, &b, &t, &p, os_COLOUR_WHITE);
if (error) {
- LOG("xpdriver_give_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xpdriver_give_rectangle: 0x%x: %s",
+ error->errnum,
+ error->errmess);
error_message = error->errmess;
goto error;
}
- LOG("given rectangle: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1);
+ NSLOG(netsurf, INFO, "given rectangle: [(%d, %d), (%d, %d)]",
+ b.x0, b.y0, b.x1, b.y1);
/* and redraw the document */
error = xpdriver_draw_page(print_num_copies, &b, 0, 0,
&more, 0);
if (error) {
- LOG("xpdriver_draw_page: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_draw_page: 0x%x: %s",
+ error->errnum, error->errmess);
error_message = error->errmess;
goto error;
}
@@ -684,7 +671,9 @@ bool print_document(struct gui_window *g, const char *filename)
.plot = &ro_plotters
};
- LOG("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1);
+ NSLOG(netsurf, INFO,
+ "redrawing area: [(%d, %d), (%d, %d)]", b.x0,
+ b.y0, b.x1, b.y1);
clip.x0 = (b.x0 - ro_plot_origin_x) / 2;
clip.y0 = (ro_plot_origin_y - b.y1) / 2;
clip.x1 = (b.x1 - ro_plot_origin_x) / 2;
@@ -706,7 +695,10 @@ bool print_document(struct gui_window *g, const char *filename)
error = xpdriver_get_rectangle(&b, &more, 0);
if (error) {
- LOG("xpdriver_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xpdriver_get_rectangle: 0x%x: %s",
+ error->errnum,
+ error->errmess);
error_message = error->errmess;
goto error;
}
@@ -728,14 +720,16 @@ bool print_document(struct gui_window *g, const char *filename)
error = (os_error *) _swix(PDriver_EndJob, _IN(0), (int) fhandle);
if (error) {
- LOG("xpdriver_end_jobw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_end_jobw: 0x%x: %s",
+ error->errnum, error->errmess);
error_message = error->errmess;
goto error;
}
error = xosfind_closew(fhandle);
if (error) {
- LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("PrintError", error->errmess);
return false;
}
@@ -743,7 +737,10 @@ bool print_document(struct gui_window *g, const char *filename)
if (old_job) {
error = xpdriver_select_jobw(old_job, 0, 0);
if (error) {
- LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xpdriver_select_jobw: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("PrintError", error->errmess);
/* the printing succeeded anyway */
return true;
@@ -756,7 +753,7 @@ bool print_document(struct gui_window *g, const char *filename)
if (content_get_type(h) == CONTENT_HTML)
content_reformat(h, false, saved_width, saved_height);
- gui_window_redraw_window(g);
+ ro_gui_window_invalidate_area(g, NULL);
return true;
@@ -780,6 +777,145 @@ error:
}
+
+
+static nserror
+print_fonts_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_arc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius, int angle1, int angle2)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_disc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_line(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *line)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_rectangle(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *rect)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_polygon(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_path(const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ const float transform[6])
+{
+ return NSERROR_OK;
+}
+
+static nserror
+print_fonts_plot_bitmap(const struct redraw_context *ctx,
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
+{
+ return NSERROR_OK;
+}
+
+/**
+ * text plotting during RO print font listing.
+ *
+ * \param ctx The current redraw context.
+ * \param fstyle plot style for this text
+ * \param x x coordinate
+ * \param y y coordinate
+ * \param text UTF-8 string to plot
+ * \param length length of string, in bytes
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+print_fonts_plot_text(const struct redraw_context *ctx,
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
+{
+ const char *font_family;
+ unsigned int font_size;
+ rufl_style font_style;
+ rufl_code code;
+
+ nsfont_read_style(fstyle, &font_family, &font_size, &font_style);
+
+ code = rufl_paint_callback(font_family, font_style, font_size,
+ text, length, 0, 0, print_fonts_callback, 0);
+ if (code != rufl_OK) {
+ if (code == rufl_FONT_MANAGER_ERROR) {
+ NSLOG(netsurf, INFO,
+ "rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
+ print_fonts_error = rufl_fm_error->errmess;
+ } else {
+ NSLOG(netsurf, INFO, "rufl_paint_callback: 0x%x",
+ code);
+ }
+ return NSERROR_INVALID;
+ }
+ if (print_fonts_error)
+ return NSERROR_INVALID;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Plotter table for print_declare_fonts().
+ *
+ * All the functions do nothing except for print_fonts_plot_text,
+ * which records the fonts used.
+*/
+static const struct plotter_table print_fonts_plotters = {
+ .rectangle = print_fonts_plot_rectangle,
+ .line = print_fonts_plot_line,
+ .polygon = print_fonts_plot_polygon,
+ .clip = print_fonts_plot_clip,
+ .text = print_fonts_plot_text,
+ .disc = print_fonts_plot_disc,
+ .arc = print_fonts_plot_arc,
+ .bitmap = print_fonts_plot_bitmap,
+ .path = print_fonts_plot_path,
+ .option_knockout = false,
+};
+
+
/**
* Declare fonts to the printer driver.
*
@@ -824,18 +960,22 @@ const char *print_declare_fonts(struct hlcache_handle *h)
}
for (i = 0; i != print_fonts_count; ++i) {
- LOG("%u %s", i, print_fonts_list[i]);
+ NSLOG(netsurf, INFO, "%u %s", i, print_fonts_list[i]);
error = xpdriver_declare_font(0, print_fonts_list[i],
pdriver_KERNED);
if (error) {
- LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xpdriver_declare_font: 0x%x: %s",
+ error->errnum,
+ error->errmess);
error_message = error->errmess;
goto end;
}
}
error = xpdriver_declare_font(0, 0, 0);
if (error) {
- LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xpdriver_declare_font: 0x%x: %s",
+ error->errnum, error->errmess);
error_message = error->errmess;
goto end;
}
@@ -850,84 +990,6 @@ end:
}
-bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
-{
- return true;
-}
-
-
-bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
-{
- return true;
-}
-
-bool print_fonts_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
-{
- return true;
-}
-
-
-bool print_fonts_plot_clip(const struct rect *clip)
-{
- return true;
-}
-
-bool print_fonts_plot_disc(int x, int y, int radius, const plot_style_t *style)
-{
- return true;
-}
-
-bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style)
-{
- return true;
-}
-
-bool print_fonts_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg, bitmap_flags_t flags)
-{
- return true;
-}
-
-bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6])
-{
- return true;
-}
-
-
-/**
- * Plotter for text plotting during font listing.
- */
-
-bool print_fonts_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle)
-{
- const char *font_family;
- unsigned int font_size;
- rufl_style font_style;
- rufl_code code;
-
- nsfont_read_style(fstyle, &font_family, &font_size, &font_style);
-
- code = rufl_paint_callback(font_family, font_style, font_size,
- text, length, 0, 0, print_fonts_callback, 0);
- if (code != rufl_OK) {
- if (code == rufl_FONT_MANAGER_ERROR) {
- LOG("rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
- print_fonts_error = rufl_fm_error->errmess;
- } else {
- LOG("rufl_paint_callback: 0x%x", code);
- }
- return false;
- }
- if (print_fonts_error)
- return false;
-
- return true;
-}
-
-
/**
* Callback for print_fonts_plot_text().
*
diff --git a/frontends/riscos/query.c b/frontends/riscos/query.c
index 1d7cf5120..49aea6321 100644
--- a/frontends/riscos/query.c
+++ b/frontends/riscos/query.c
@@ -175,7 +175,7 @@ query_id query_user_xy(const char *query, const char *detail,
err = utf8_to_local_encoding(yes, 0, &local_text);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_local_encoding_failed");
+ NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed");
local_text = NULL;
}
@@ -191,7 +191,8 @@ query_id query_user_xy(const char *query, const char *detail,
error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
if (error) {
- LOG("xwimptextop_string_width: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s",
+ error->errnum, error->errmess);
width = len * 16;
}
if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
@@ -204,7 +205,7 @@ query_id query_user_xy(const char *query, const char *detail,
err = utf8_to_local_encoding(no, 0, &local_text);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_local_encoding_failed");
+ NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed");
local_text = NULL;
}
@@ -222,7 +223,8 @@ query_id query_user_xy(const char *query, const char *detail,
icn->extent.x1 = tx - 16;
error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
if (error) {
- LOG("xwimptextop_string_width: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s",
+ error->errnum, error->errmess);
width = len * 16;
}
width += 28;
@@ -263,7 +265,8 @@ query_id query_user_xy(const char *query, const char *detail,
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -307,7 +310,10 @@ void ro_gui_query_window_bring_to_front(query_id id)
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_caret_position: 0x%x : %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -327,7 +333,8 @@ void ro_gui_query_close(wimp_w w)
ro_gui_dialog_close(w);
error = xwimp_delete_window(qw->window);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
ro_gui_wimp_event_finalise(w);
diff --git a/frontends/riscos/save.c b/frontends/riscos/save.c
index 37474b85c..76ce6d3e5 100644
--- a/frontends/riscos/save.c
+++ b/frontends/riscos/save.c
@@ -56,6 +56,7 @@
#include "riscos/bitmap.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/menus.h"
#include "riscos/message.h"
#include "riscos/mouse.h"
@@ -165,7 +166,8 @@ wimp_w ro_gui_saveas_create(const char *template_name)
error = xosmodule_alloc(area_size, (void **) &area);
if (error) {
- LOG("xosmodule_alloc: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosmodule_alloc: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
} else {
@@ -175,7 +177,10 @@ wimp_w ro_gui_saveas_create(const char *template_name)
error = xosspriteop_clear_sprites(osspriteop_USER_AREA, saveas_area);
if (error) {
- LOG("xosspriteop_clear_sprites: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_clear_sprites: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
xosmodule_free(saveas_area);
@@ -191,7 +196,8 @@ wimp_w ro_gui_saveas_create(const char *template_name)
/* create window */
error = xwimp_create_window(window, &w);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
xwimp_close_template();
die(error->errmess);
}
@@ -211,7 +217,8 @@ void ro_gui_saveas_quit(void)
if (saveas_area) {
os_error *error = xosmodule_free(saveas_area);
if (error) {
- LOG("xosmodule_free: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosmodule_free: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
}
saveas_area = NULL;
@@ -238,14 +245,14 @@ ro_gui_save_create_thumbnail(struct hlcache_handle *h, const char *name)
bitmap = riscos_bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
if (!bitmap) {
- LOG("Thumbnail initialisation failed.");
+ NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
return false;
}
riscos_bitmap_render(bitmap, h);
area = riscos_bitmap_convert_8bpp(bitmap);
riscos_bitmap_destroy(bitmap);
if (!area) {
- LOG("Thumbnail conversion failed.");
+ NSLOG(netsurf, INFO, "Thumbnail conversion failed.");
return false;
}
@@ -390,7 +397,10 @@ ro_gui_save_set_state(struct hlcache_handle *h, gui_save_type save_type,
}
if (error) {
- LOG("ro_gui_wimp_get_sprite: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "ro_gui_wimp_get_sprite: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
} else {
/* the sprite area should always be large enough for
@@ -500,7 +510,8 @@ static void ro_gui_save_drag_end(wimp_dragged *drag, void *data)
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -626,7 +637,8 @@ static void ro_gui_save_done(void)
error = xwimp_send_message(wimp_USER_MESSAGE, message,
message->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
}
}
@@ -666,7 +678,10 @@ static void ro_gui_save_done(void)
ro_gui_dialog_close(dialog_saveas);
error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
if (error) {
- LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_create_menu: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MenuError", error->errmess);
}
}
@@ -769,8 +784,8 @@ static void ro_gui_save_set_file_type(const char *path, lwc_string *mime_type)
error = xosfile_set_type(path, rotype);
if (error != NULL) {
- LOG("xosfile_set_type: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -797,7 +812,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path)
/* Create dir */
error = xosfile_create_dir(path, 0);
if (error) {
- LOG("xosfile_create_dir: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_create_dir: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -806,7 +822,7 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path)
snprintf(buf, sizeof buf, "%s.!Run", path);
fp = fopen(buf, "w");
if (!fp) {
- LOG("fopen(): errno = %i", errno);
+ NSLOG(netsurf, INFO, "fopen(): errno = %i", errno);
ro_warn_user("SaveError", strerror(errno));
return false;
}
@@ -815,7 +831,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path)
fclose(fp);
error = xosfile_set_type(buf, 0xfeb);
if (error) {
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -824,7 +841,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path)
snprintf(buf, sizeof buf, "%s.!RunImage", path);
fp = fopen(buf, "w");
if (!fp) {
- LOG("Creating !RunImage failed: errno = %i", errno);
+ NSLOG(netsurf, INFO, "Creating !RunImage failed: errno = %i",
+ errno);
} else {
fclose(fp);
}
@@ -850,7 +868,10 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path)
error = xosspriteop_save_sprite_file(osspriteop_NAME, saveas_area, buf);
if (error) {
- LOG("xosspriteop_save_sprite_file: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_save_sprite_file: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -896,7 +917,10 @@ static bool ro_gui_save_object_native(struct hlcache_handle *h, char *path)
(byte *) source_data,
(byte *) source_data + source_size);
if (error != NULL) {
- LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_save_stamped: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -946,7 +970,8 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite)
error = xosfile_read_stamped(path, &obj_type,
NULL, NULL, NULL, NULL, NULL);
if (error) {
- LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -1002,7 +1027,10 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite)
(byte *) source_data,
(byte *) source_data + source_size);
if (error) {
- LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_save_stamped: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -1028,14 +1056,20 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_set_type: 0x%x: %s",
+ error->errnum,
+ error->errmess);
break;
case GUI_SAVE_HISTORY_EXPORT_HTML:
if (global_history_export(path, NULL) != NSERROR_OK)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
- LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_set_type: 0x%x: %s",
+ error->errnum,
+ error->errmess);
break;
case GUI_SAVE_TEXT_SELECTION:
@@ -1055,7 +1089,10 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite)
return ro_gui_save_clipboard(path);
default:
- LOG("Unexpected content type: %d, path %s", gui_save_current_type, path);
+ NSLOG(netsurf, INFO,
+ "Unexpected content type: %d, path %s",
+ gui_save_current_type,
+ path);
return false;
}
return true;
@@ -1120,7 +1157,8 @@ void gui_drag_save_object(struct gui_window *g,
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1157,7 +1195,8 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1209,8 +1248,8 @@ void ro_gui_drag_save_link(gui_save_type save_type, const nsurl *url,
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1251,7 +1290,10 @@ void ro_gui_drag_icon(int x, int y, const char *sprite)
saveas_area, (osspriteop_id)sprite, NULL);
if (error) {
if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
- LOG("xosspriteop_select_sprite: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_select_sprite: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
}
}
@@ -1271,7 +1313,8 @@ void ro_gui_drag_icon(int x, int y, const char *sprite)
return;
}
- LOG("xdragasprite_start: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xdragasprite_start: 0x%x: %s",
+ error->errnum, error->errmess);
}
drag.type = wimp_DRAG_USER_FIXED;
@@ -1284,7 +1327,8 @@ void ro_gui_drag_icon(int x, int y, const char *sprite)
error = xwimp_drag_box(&drag);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("DragError", error->errmess);
} else {
dragbox_active = true;
@@ -1322,14 +1366,20 @@ void ro_gui_drag_box_cancel(void)
if (using_dragasprite) {
error = xdragasprite_stop();
if (error) {
- LOG("xdragasprite_stop: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xdragasprite_stop: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
else {
error = xwimp_drag_box(NULL);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_drag_box: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -1383,7 +1433,8 @@ void ro_gui_save_datasave_ack(wimp_message *message)
default:
if (!gui_save_content) {
- LOG("unexpected DataSaveAck: gui_save_content not set");
+ NSLOG(netsurf, INFO,
+ "unexpected DataSaveAck: gui_save_content not set");
return;
}
break;
diff --git a/frontends/riscos/save_draw.c b/frontends/riscos/save_draw.c
index 7e6c9462e..1e67d2d8d 100644
--- a/frontends/riscos/save_draw.c
+++ b/frontends/riscos/save_draw.c
@@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Export a content as a DrawFile (implementation).
*/
@@ -39,38 +40,6 @@
#include "riscos/save_draw.h"
#include "riscos/font.h"
-static bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_save_draw_polygon(const int *p, unsigned int n, const plot_style_t *style);
-static bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
- float width, colour c, const float transform[6]);
-static bool ro_save_draw_clip(const struct rect *clip);
-static bool ro_save_draw_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle);
-static bool ro_save_draw_disc(int x, int y, int radius, const plot_style_t *style);
-static bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style);
-static bool ro_save_draw_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg, bitmap_flags_t flags);
-static bool ro_save_draw_group_start(const char *name);
-static bool ro_save_draw_group_end(void);
-static bool ro_save_draw_error(pencil_code code);
-
-
-static const struct plotter_table ro_save_draw_plotters = {
- .rectangle = ro_save_draw_rectangle,
- .line = ro_save_draw_line,
- .polygon = ro_save_draw_polygon,
- .clip = ro_save_draw_clip,
- .text = ro_save_draw_text,
- .disc = ro_save_draw_disc,
- .arc = ro_save_draw_arc,
- .bitmap = ro_save_draw_bitmap,
- .group_start = ro_save_draw_group_start,
- .group_end = ro_save_draw_group_end,
- .path = ro_save_draw_path,
- .option_knockout = false,
-};
static struct pencil_diagram *ro_save_draw_diagram;
static int ro_save_draw_width;
@@ -78,157 +47,229 @@ static int ro_save_draw_height;
/**
- * Export a content as a DrawFile.
+ * Report an error from pencil.
*
- * \param h content to export
- * \param path path to save DrawFile as
- * \return true on success, false on error and error reported
+ * \param code error code
+ * \return false
*/
-
-bool save_as_draw(struct hlcache_handle *h, const char *path)
+static nserror ro_save_draw_error(pencil_code code)
{
- pencil_code code;
- char *drawfile_buffer;
- struct rect clip;
- struct content_redraw_data data;
- size_t drawfile_size;
- os_error *error;
- struct redraw_context ctx = {
- .interactive = false,
- .background_images = true,
- .plot = &ro_save_draw_plotters
- };
+ NSLOG(netsurf, INFO, "code %i", code);
- ro_save_draw_diagram = pencil_create();
- if (!ro_save_draw_diagram) {
+ switch (code) {
+ case pencil_OK:
+ assert(0);
+ break;
+
+ case pencil_OUT_OF_MEMORY:
ro_warn_user("NoMemory", 0);
- return false;
+ break;
+
+ case pencil_FONT_MANAGER_ERROR:
+ ro_warn_user("SaveError", rufl_fm_error->errmess);
+ break;
+
+ case pencil_FONT_NOT_FOUND:
+ case pencil_IO_ERROR:
+ case pencil_IO_EOF:
+ ro_warn_user("SaveError", "generating the DrawFile failed");
+ break;
}
- ro_save_draw_width = content_get_width(h);
- ro_save_draw_height = content_get_height(h);
+ return NSERROR_INVALID;
+}
- clip.x0 = clip.y0 = INT_MIN;
- clip.x1 = clip.y1 = INT_MAX;
+/**
+ * \brief Sets a clip rectangle for subsequent plot operations.
+ *
+ * \param ctx The current redraw context.
+ * \param clip The rectangle to limit all subsequent plot
+ * operations within.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_clip(const struct redraw_context *ctx, const struct rect *clip)
+{
+ return NSERROR_OK;
+}
- data.x = 0;
- data.y = -ro_save_draw_height;
- data.width = ro_save_draw_width;
- data.height = ro_save_draw_height;
- data.background_colour = 0xFFFFFF;
- data.scale = 1;
- data.repeat_x = false;
- data.repeat_y = false;
- if (!content_redraw(h, &data, &clip, &ctx)) {
- pencil_free(ro_save_draw_diagram);
- return false;
- }
+/**
+ * Plots an arc
+ *
+ * plot an arc segment around (x,y), anticlockwise from angle1
+ * to angle2. Angles are measured anticlockwise from
+ * horizontal, in degrees.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the arc plot.
+ * \param x The x coordinate of the arc.
+ * \param y The y coordinate of the arc.
+ * \param radius The radius of the arc.
+ * \param angle1 The start angle of the arc.
+ * \param angle2 The finish angle of the arc.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_arc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius, int angle1, int angle2)
+{
+ return NSERROR_OK;
+}
- /*pencil_dump(ro_save_draw_diagram);*/
- code = pencil_save_drawfile(ro_save_draw_diagram, "NetSurf",
- &drawfile_buffer, &drawfile_size);
- if (code != pencil_OK) {
- ro_warn_user("SaveError", 0);
- pencil_free(ro_save_draw_diagram);
- return false;
- }
- assert(drawfile_buffer);
+/**
+ * Plots a circle
+ *
+ * Plot a circle centered on (x,y), which is optionally filled.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the circle plot.
+ * \param x The x coordinate of the circle.
+ * \param y The y coordinate of the circle.
+ * \param radius The radius of the circle.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_disc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius)
+{
+ return NSERROR_OK;
+}
- error = xosfile_save_stamped(path, osfile_TYPE_DRAW,
- (byte *) drawfile_buffer,
- (byte *) drawfile_buffer + drawfile_size);
- if (error) {
- LOG("xosfile_save_stamped failed: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("SaveError", error->errmess);
- pencil_free(ro_save_draw_diagram);
- return false;
- }
- pencil_free(ro_save_draw_diagram);
+/**
+ * Plots a line
+ *
+ * plot a line from (x0,y0) to (x1,y1). Coordinates are at
+ * centre of line width/thickness.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the line plot.
+ * \param line A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_line(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *line)
+{
+ pencil_code code;
+ const int path[] = {
+ draw_MOVE_TO, line->x0 * 2, -line->y0 * 2 - 1,
+ draw_LINE_TO, line->x1 * 2, -line->y1 * 2 - 1,
+ draw_END_PATH
+ };
- return true;
+ code = pencil_path(ro_save_draw_diagram,
+ path,
+ sizeof path / sizeof path[0],
+ pencil_TRANSPARENT,
+ style->stroke_colour << 8,
+ plot_style_fixed_to_int(style->stroke_width),
+ pencil_JOIN_MITRED,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0, 0, false,
+ pencil_SOLID);
+ if (code != pencil_OK)
+ return ro_save_draw_error(code);
+
+ return NSERROR_OK;
}
-bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
+
+/**
+ * Plots a rectangle.
+ *
+ * The rectangle can be filled an outline or both controlled
+ * by the plot style The line can be solid, dotted or
+ * dashed. Top left corner at (x0,y0) and rectangle has given
+ * width and height.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the rectangle plot.
+ * \param rect A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_rectangle(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *rect)
{
pencil_code code;
- const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
- draw_LINE_TO, x0 * 2, -y1 * 2 - 1,
- draw_CLOSE_LINE,
- draw_END_PATH };
+ const int path[] = {
+ draw_MOVE_TO, rect->x0 * 2, -rect->y0 * 2 - 1,
+ draw_LINE_TO, rect->x1 * 2, -rect->y0 * 2 - 1,
+ draw_LINE_TO, rect->x1 * 2, -rect->y1 * 2 - 1,
+ draw_LINE_TO, rect->x0 * 2, -rect->y1 * 2 - 1,
+ draw_CLOSE_LINE,
+ draw_END_PATH
+ };
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
- code = pencil_path(ro_save_draw_diagram,
+ code = pencil_path(ro_save_draw_diagram,
path,
sizeof path / sizeof path[0],
- style->fill_colour << 8,
- pencil_TRANSPARENT,
- 0,
+ style->fill_colour << 8,
+ pencil_TRANSPARENT,
+ 0,
pencil_JOIN_MITRED,
- pencil_CAP_BUTT,
- pencil_CAP_BUTT,
- 0,
- 0,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0,
+ 0,
false,
pencil_SOLID);
if (code != pencil_OK)
return ro_save_draw_error(code);
}
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- code = pencil_path(ro_save_draw_diagram,
+ code = pencil_path(ro_save_draw_diagram,
path,
sizeof path / sizeof path[0],
- pencil_TRANSPARENT,
- style->stroke_colour << 8,
- style->stroke_width,
+ pencil_TRANSPARENT,
+ style->stroke_colour << 8,
+ plot_style_fixed_to_int(style->stroke_width),
pencil_JOIN_MITRED,
- pencil_CAP_BUTT,
- pencil_CAP_BUTT,
- 0,
- 0,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0,
+ 0,
false,
pencil_SOLID);
if (code != pencil_OK)
return ro_save_draw_error(code);
}
- return true;
-}
-
-
-bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
-{
- pencil_code code;
- const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
- draw_END_PATH };
-
- code = pencil_path(ro_save_draw_diagram,
- path,
- sizeof path / sizeof path[0],
- pencil_TRANSPARENT,
- style->stroke_colour << 8,
- style->stroke_width,
- pencil_JOIN_MITRED,
- pencil_CAP_BUTT,
- pencil_CAP_BUTT,
- 0, 0, false,
- pencil_SOLID);
- if (code != pencil_OK)
- return ro_save_draw_error(code);
-
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_polygon(const int *p, unsigned int n, const plot_style_t *style)
+/**
+ * Plot a polygon
+ *
+ * Plots a filled polygon with straight lines between
+ * points. The lines around the edge of the ploygon are not
+ * plotted. The polygon is filled with the non-zero winding
+ * rule.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the polygon plot.
+ * \param p verticies of polygon
+ * \param n number of verticies.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_polygon(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
{
pencil_code code;
int path[n * 3 + 1];
@@ -242,44 +283,64 @@ bool ro_save_draw_polygon(const int *p, unsigned int n, const plot_style_t *styl
path[0] = draw_MOVE_TO;
path[n * 3] = draw_END_PATH;
- code = pencil_path(ro_save_draw_diagram,
+ code = pencil_path(ro_save_draw_diagram,
path, n * 3 + 1,
- style->fill_colour << 8,
- pencil_TRANSPARENT,
- 0,
+ style->fill_colour << 8,
+ pencil_TRANSPARENT,
+ 0,
pencil_JOIN_MITRED,
- pencil_CAP_BUTT,
- pencil_CAP_BUTT,
- 0,
- 0,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0,
+ 0,
false,
pencil_SOLID);
if (code != pencil_OK)
return ro_save_draw_error(code);
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
- float width, colour c, const float transform[6])
+/**
+ * Plots a path.
+ *
+ * Path plot consisting of cubic Bezier curves. Line and fill colour is
+ * controlled by the plot style.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the path plot.
+ * \param p elements of path
+ * \param n nunber of elements on path
+ * \param transform A transform to apply to the path.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_path(const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ const float transform[6])
{
+ pencil_code code;
+ int *path;
+ unsigned int i;
+ bool empty_path = true;
+
if (n == 0)
- return true;
+ return NSERROR_OK;
if (p[0] != PLOTTER_PATH_MOVE) {
- LOG("path doesn't start with a move");
- return false;
+ NSLOG(netsurf, INFO, "path doesn't start with a move");
+ return NSERROR_INVALID;
}
- int *path = malloc(sizeof *path * (n + 10));
+ path = malloc(sizeof *path * (n + 10));
if (!path) {
- LOG("out of memory");
- return false;
+ NSLOG(netsurf, INFO, "out of memory");
+ return NSERROR_INVALID;
}
- unsigned int i;
- bool empty_path = true;
for (i = 0; i < n; ) {
if (p[i] == PLOTTER_PATH_MOVE) {
path[i] = draw_MOVE_TO;
@@ -326,42 +387,114 @@ bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
i += 7;
empty_path = false;
} else {
- LOG("bad path command %f", p[i]);
+ NSLOG(netsurf, INFO, "bad path command %f", p[i]);
free(path);
- return false;
+ return NSERROR_INVALID;
}
}
path[i] = draw_END_PATH;
if (empty_path) {
free(path);
- return true;
+ return NSERROR_OK;
}
- pencil_code code = pencil_path(ro_save_draw_diagram, path, i + 1,
- fill == NS_TRANSPARENT ? pencil_TRANSPARENT : fill << 8,
- c == NS_TRANSPARENT ? pencil_TRANSPARENT : c << 8,
- width, pencil_JOIN_MITRED,
- pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
- pencil_SOLID);
+ code = pencil_path(ro_save_draw_diagram,
+ path, i + 1,
+ pstyle->fill_colour == NS_TRANSPARENT ?
+ pencil_TRANSPARENT :
+ pstyle->fill_colour << 8,
+ pstyle->stroke_colour == NS_TRANSPARENT ?
+ pencil_TRANSPARENT :
+ pstyle->stroke_colour << 8,
+ plot_style_fixed_to_int(pstyle->stroke_width),
+ pencil_JOIN_MITRED,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0,
+ 0,
+ false,
+ pencil_SOLID);
free(path);
if (code != pencil_OK)
return ro_save_draw_error(code);
- return true;
+ return NSERROR_OK;
}
+/**
+ * Plot a bitmap
+ *
+ * Tiled plot of a bitmap image. (x,y) gives the top left
+ * coordinate of an explicitly placed tile. From this tile the
+ * image can repeat in all four directions -- up, down, left
+ * and right -- to the extents given by the current clip
+ * rectangle.
+ *
+ * The bitmap_flags say whether to tile in the x and y
+ * directions. If not tiling in x or y directions, the single
+ * image is plotted. The width and height give the dimensions
+ * the image is to be scaled to.
+ *
+ * \param ctx The current redraw context.
+ * \param bitmap The bitmap to plot
+ * \param x The x coordinate to plot the bitmap
+ * \param y The y coordiante to plot the bitmap
+ * \param width The width of area to plot the bitmap into
+ * \param height The height of area to plot the bitmap into
+ * \param bg the background colour to alpha blend into
+ * \param flags the flags controlling the type of plot operation
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_bitmap(const struct redraw_context *ctx,
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
+{
+ pencil_code code;
+ const uint8_t *buffer;
+
+ buffer = riscos_bitmap_get_buffer(bitmap);
+ if (!buffer) {
+ ro_warn_user("NoMemory", 0);
+ return NSERROR_INVALID;
+ }
+ code = pencil_sprite(ro_save_draw_diagram,
+ x * 2, (-y - height) * 2,
+ width * 2, height * 2,
+ ((char *) bitmap->sprite_area) +
+ bitmap->sprite_area->first);
+ if (code != pencil_OK)
+ return ro_save_draw_error(code);
-bool ro_save_draw_clip(const struct rect *clip)
-{
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle)
+/**
+ * Text plotting.
+ *
+ * \param ctx The current redraw context.
+ * \param fstyle plot style for this text
+ * \param x x coordinate
+ * \param y y coordinate
+ * \param text UTF-8 string to plot
+ * \param length length of string, in bytes
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_text(const struct redraw_context *ctx,
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
{
pencil_code code;
const char *font_family;
@@ -371,102 +504,135 @@ bool ro_save_draw_text(int x, int y, const char *text, size_t length,
nsfont_read_style(fstyle, &font_family, &font_size, &font_style);
code = pencil_text(ro_save_draw_diagram, x * 2, -y * 2, font_family,
- font_style, font_size, text, length,
+ font_style, font_size, text, length,
fstyle->foreground << 8);
if (code != pencil_OK)
return ro_save_draw_error(code);
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_disc(int x, int y, int radius, const plot_style_t *style)
-{
- return true;
-}
-
-bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style)
-{
- return true;
-}
-
-bool ro_save_draw_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg, bitmap_flags_t flags)
+/**
+ * Start of a group of objects.
+ *
+ * \param ctx The current redraw context.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_group_start(const struct redraw_context *ctx, const char *name)
{
pencil_code code;
- const uint8_t *buffer;
- buffer = riscos_bitmap_get_buffer(bitmap);
- if (!buffer) {
- ro_warn_user("NoMemory", 0);
- return false;
- }
-
- code = pencil_sprite(ro_save_draw_diagram, x * 2, (-y - height) * 2,
- width * 2, height * 2,
- ((char *) bitmap->sprite_area) +
- bitmap->sprite_area->first);
+ code = pencil_group_start(ro_save_draw_diagram, name);
if (code != pencil_OK)
return ro_save_draw_error(code);
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_group_start(const char *name)
+/**
+ * End of the most recently started group.
+ *
+ * \param ctx The current redraw context.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+ro_save_draw_group_end(const struct redraw_context *ctx)
{
pencil_code code;
- code = pencil_group_start(ro_save_draw_diagram, name);
+ code = pencil_group_end(ro_save_draw_diagram);
if (code != pencil_OK)
return ro_save_draw_error(code);
- return true;
+ return NSERROR_OK;
}
-bool ro_save_draw_group_end(void)
+static const struct plotter_table ro_save_draw_plotters = {
+ .rectangle = ro_save_draw_rectangle,
+ .line = ro_save_draw_line,
+ .polygon = ro_save_draw_polygon,
+ .clip = ro_save_draw_clip,
+ .text = ro_save_draw_text,
+ .disc = ro_save_draw_disc,
+ .arc = ro_save_draw_arc,
+ .bitmap = ro_save_draw_bitmap,
+ .group_start = ro_save_draw_group_start,
+ .group_end = ro_save_draw_group_end,
+ .path = ro_save_draw_path,
+ .option_knockout = false,
+};
+
+
+/* exported interface documented in save_draw.h */
+bool save_as_draw(struct hlcache_handle *h, const char *path)
{
pencil_code code;
+ char *drawfile_buffer;
+ struct rect clip;
+ struct content_redraw_data data;
+ size_t drawfile_size;
+ os_error *error;
+ struct redraw_context ctx = {
+ .interactive = false,
+ .background_images = true,
+ .plot = &ro_save_draw_plotters
+ };
- code = pencil_group_end(ro_save_draw_diagram);
- if (code != pencil_OK)
- return ro_save_draw_error(code);
+ ro_save_draw_diagram = pencil_create();
+ if (!ro_save_draw_diagram) {
+ ro_warn_user("NoMemory", 0);
+ return false;
+ }
- return true;
-}
+ ro_save_draw_width = content_get_width(h);
+ ro_save_draw_height = content_get_height(h);
+ clip.x0 = clip.y0 = INT_MIN;
+ clip.x1 = clip.y1 = INT_MAX;
-/**
- * Report an error from pencil.
- *
- * \param code error code
- * \return false
- */
+ data.x = 0;
+ data.y = -ro_save_draw_height;
+ data.width = ro_save_draw_width;
+ data.height = ro_save_draw_height;
+ data.background_colour = 0xFFFFFF;
+ data.scale = 1;
+ data.repeat_x = false;
+ data.repeat_y = false;
-bool ro_save_draw_error(pencil_code code)
-{
- LOG("code %i", code);
+ if (!content_redraw(h, &data, &clip, &ctx)) {
+ pencil_free(ro_save_draw_diagram);
+ return false;
+ }
- switch (code) {
- case pencil_OK:
- assert(0);
- break;
- case pencil_OUT_OF_MEMORY:
- ro_warn_user("NoMemory", 0);
- break;
- case pencil_FONT_MANAGER_ERROR:
- ro_warn_user("SaveError", rufl_fm_error->errmess);
- break;
- case pencil_FONT_NOT_FOUND:
- case pencil_IO_ERROR:
- case pencil_IO_EOF:
- ro_warn_user("SaveError", "generating the DrawFile failed");
- break;
+ /*pencil_dump(ro_save_draw_diagram);*/
+
+ code = pencil_save_drawfile(ro_save_draw_diagram, "NetSurf",
+ &drawfile_buffer, &drawfile_size);
+ if (code != pencil_OK) {
+ ro_warn_user("SaveError", 0);
+ pencil_free(ro_save_draw_diagram);
+ return false;
}
+ assert(drawfile_buffer);
- return false;
+ error = xosfile_save_stamped(path, osfile_TYPE_DRAW,
+ (byte *) drawfile_buffer,
+ (byte *) drawfile_buffer + drawfile_size);
+ if (error) {
+ NSLOG(netsurf, INFO, "xosfile_save_stamped failed: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("SaveError", error->errmess);
+ pencil_free(ro_save_draw_diagram);
+ return false;
+ }
+
+ pencil_free(ro_save_draw_diagram);
+
+ return true;
}
#endif
diff --git a/frontends/riscos/save_draw.h b/frontends/riscos/save_draw.h
index 7ae447790..99662e371 100644
--- a/frontends/riscos/save_draw.h
+++ b/frontends/riscos/save_draw.h
@@ -24,6 +24,13 @@
#include <stdbool.h>
struct hlcache_handle;
+/**
+ * Export a content as a DrawFile.
+ *
+ * \param h content to export
+ * \param path path to save DrawFile as
+ * \return true on success, false on error and error reported
+ */
bool save_as_draw(struct hlcache_handle *h, const char *path);
#endif
diff --git a/frontends/riscos/schedule.c b/frontends/riscos/schedule.c
index 54308b7a9..cb44d906d 100644
--- a/frontends/riscos/schedule.c
+++ b/frontends/riscos/schedule.c
@@ -108,7 +108,7 @@ nserror riscos_schedule(int t, void (*callback)(void *p), void *p)
entry = malloc(sizeof *entry);
if (!entry) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
return NSERROR_NOMEM;
}
diff --git a/frontends/riscos/sslcert.c b/frontends/riscos/sslcert.c
index 85b84456e..4d81268f4 100644
--- a/frontends/riscos/sslcert.c
+++ b/frontends/riscos/sslcert.c
@@ -82,14 +82,14 @@ static void ro_gui_cert_release_window(struct ro_cert_window *certw)
error = xwimp_delete_window(certw->wh);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
error = xwimp_delete_window(certw->core.wh);
if (error) {
- LOG("xwimp_delete_window: 0x%x:%s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess);
}
free(certw);
@@ -165,16 +165,16 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane)
winfo.w = pane;
error = xwimp_get_window_info_header_only(&winfo);
if (error) {
- LOG("xwimp_get_window_info: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s",
+ error->errnum, error->errmess);
return NSERROR_INIT_FAILED;
}
wstate.w = parent;
error = xwimp_get_window_state(&wstate);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return NSERROR_INIT_FAILED;
}
@@ -182,8 +182,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane)
istate.i = ICON_SSL_PANE;
error = xwimp_get_icon_state(&istate);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
return NSERROR_INIT_FAILED;
}
@@ -211,8 +211,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane)
if (set_extent) {
error = xwimp_set_extent(pane, &(winfo.extent));
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return NSERROR_INIT_FAILED;
}
}
@@ -225,8 +225,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane)
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_LS_EDGE_SHIFT |
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_RS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum, error->errmess);
return NSERROR_INIT_FAILED;
}
@@ -336,8 +336,8 @@ gui_cert_verify(nsurl *url,
/* Create the SSL window */
error = xwimp_create_window(dialog_cert_template, &ncwin->wh);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
free(ncwin);
return NSERROR_INIT_FAILED;
}
@@ -345,8 +345,8 @@ gui_cert_verify(nsurl *url,
/* create ssl viewer pane window */
error = xwimp_create_window(cert_tree_template, &ncwin->core.wh);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
free(ncwin);
return NSERROR_INIT_FAILED;
}
diff --git a/frontends/riscos/textarea.c b/frontends/riscos/textarea.c
index d9872927c..6f41c640b 100644
--- a/frontends/riscos/textarea.c
+++ b/frontends/riscos/textarea.c
@@ -138,7 +138,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags,
ret = malloc(sizeof(struct text_area));
if (!ret) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
return 0;
}
@@ -148,7 +148,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags,
ret->flags = flags;
ret->text = malloc(64);
if (!ret->text) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
free(ret);
return 0;
}
@@ -160,7 +160,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags,
// ret->selection_end = (unsigned int)-1;
ret->font_family = strdup(font_family ? font_family : "Corpus");
if (!ret->font_family) {
- LOG("strdup failed");
+ NSLOG(netsurf, INFO, "strdup failed");
free(ret->text);
free(ret);
return 0;
@@ -181,7 +181,8 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags,
text_area_definition.title_fg = wimp_COLOUR_BLACK;
error = xwimp_create_window(&text_area_definition, &ret->window);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
free(ret->font_family);
free(ret->text);
free(ret);
@@ -228,7 +229,8 @@ bool ro_textarea_update(uintptr_t self)
state.w = ta->parent;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -236,7 +238,8 @@ bool ro_textarea_update(uintptr_t self)
istate.i = ta->icon;
error = xwimp_get_icon_state(&istate);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -267,7 +270,8 @@ bool ro_textarea_update(uintptr_t self)
error = xwimp_set_extent(ta->window, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -282,7 +286,8 @@ bool ro_textarea_update(uintptr_t self)
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
<< wimp_CHILD_RS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -307,7 +312,8 @@ void ro_textarea_destroy(uintptr_t self)
error = xwimp_delete_window(ta->window);
if (error) {
- LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
ro_gui_wimp_event_finalise(ta->window);
@@ -331,14 +337,14 @@ bool ro_textarea_set_text(uintptr_t self, const char *text)
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return true;
}
if (len >= ta->text_alloc) {
char *temp = realloc(ta->text, len + 64);
if (!temp) {
- LOG("realloc failed");
+ NSLOG(netsurf, INFO, "realloc failed");
return false;
}
ta->text = temp;
@@ -368,7 +374,7 @@ int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len)
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return -1;
}
@@ -378,7 +384,7 @@ int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len)
}
if (len < ta->text_len) {
- LOG("buffer too small");
+ NSLOG(netsurf, INFO, "buffer too small");
return -1;
}
@@ -403,7 +409,7 @@ void ro_textarea_insert_text(uintptr_t self, unsigned int index,
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return;
}
@@ -420,7 +426,7 @@ void ro_textarea_insert_text(uintptr_t self, unsigned int index,
if (b_len + ta->text_len >= ta->text_alloc) {
char *temp = realloc(ta->text, b_len + ta->text_len + 64);
if (!temp) {
- LOG("realloc failed");
+ NSLOG(netsurf, INFO, "realloc failed");
return;
}
@@ -457,7 +463,7 @@ void ro_textarea_replace_text(uintptr_t self, unsigned int start,
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return;
}
@@ -491,7 +497,7 @@ void ro_textarea_replace_text(uintptr_t self, unsigned int start,
char *temp = realloc(ta->text,
b_len + ta->text_len - (b_end - b_start) + 64);
if (!temp) {
- LOG("realloc failed");
+ NSLOG(netsurf, INFO, "realloc failed");
return;
}
@@ -532,7 +538,7 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret)
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return;
}
@@ -574,9 +580,10 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret)
b_off - ta->lines[ta->caret_pos.line].b_start, &x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_width: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO, "rufl_width: 0x%x: %s",
+ rufl_fm_error->errnum, rufl_fm_error->errmess);
else
- LOG("rufl_width: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_width: 0x%x", code);
return;
}
@@ -585,7 +592,8 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret)
ta->line_height / 4 + ta->line_spacing,
os_line_height.y, -1);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
@@ -609,7 +617,7 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y)
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return;
}
@@ -623,7 +631,8 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y)
state.w = ta->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -644,9 +653,10 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y)
x, &b_off, &x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_x_to_offset: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x: %s",
+ rufl_fm_error->errnum, rufl_fm_error->errmess);
else
- LOG("rufl_x_to_offset: 0x%x", code);
+ NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x", code);
return;
}
@@ -670,7 +680,7 @@ unsigned int ro_textarea_get_caret(uintptr_t self)
ta = (struct text_area *)self;
if (!ta || ta->magic != MAGIC) {
- LOG("magic doesn't match");
+ NSLOG(netsurf, INFO, "magic doesn't match");
return -1;
}
@@ -711,7 +721,7 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
ta->lines =
malloc(LINE_CHUNK_SIZE * sizeof(struct line_info));
if (!ta->lines) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
return;
}
}
@@ -734,9 +744,13 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
&b_off, &x);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_x_to_offset: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_x_to_offset: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_x_to_offset: 0x%x", code);
+ NSLOG(netsurf, INFO,
+ "rufl_x_to_offset: 0x%x", code);
return;
}
@@ -745,7 +759,7 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
(line_count + LINE_CHUNK_SIZE) *
sizeof(struct line_info));
if (!temp) {
- LOG("realloc failed");
+ NSLOG(netsurf, INFO, "realloc failed");
return;
}
@@ -809,7 +823,8 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
error = xwimp_set_extent(ta->window, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -826,7 +841,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
error = xwimp_get_window_state_and_nesting(&state,
&parent, &linkage);
if (error) {
- LOG("xwimp_get_window_state_and_nesting: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state_and_nesting: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
@@ -839,7 +857,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
state.w = ta->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
@@ -853,7 +874,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line)
error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state),
parent, linkage);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
@@ -1009,7 +1033,10 @@ bool ro_textarea_key_press(wimp_key *key)
(wimp_message*)&keypress, ta->parent,
ta->icon, 0);
if (error) {
- LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_send_message: 0x%x:%s",
+ error->errnum,
+ error->errmess);
}
break;
}
@@ -1060,7 +1087,8 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update)
else
error = xwimp_redraw_window(redraw, &more);
if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -1076,13 +1104,17 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update)
colourtrans_SET_BG_GCOL | colourtrans_USE_ECFS_GCOL,
os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
error = xos_clg();
if (error) {
- LOG("xos_clg: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_clg: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -1113,7 +1145,10 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update)
0xD9D9D900 : 0xFFFFFF00,
0x00000000, 14, 0, 0, 0);
if (error) {
- LOG("xcolourtrans_set_font_colours: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_font_colours: 0x%x: %s",
+ error->errnum,
+ error->errmess);
return;
}
@@ -1128,15 +1163,20 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update)
rufl_BLEND_FONT);
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
- LOG("rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
+ NSLOG(netsurf, INFO,
+ "rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
else
- LOG("rufl_paint: 0x%x", code);
+ NSLOG(netsurf, INFO,
+ "rufl_paint: 0x%x", code);
}
}
error = xwimp_get_rectangle(redraw, &more);
if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
@@ -1153,7 +1193,8 @@ void ro_textarea_open(wimp_open *open)
error = xwimp_open_window(open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
diff --git a/frontends/riscos/textselection.c b/frontends/riscos/textselection.c
index bce35750f..e5be27791 100644
--- a/frontends/riscos/textselection.c
+++ b/frontends/riscos/textselection.c
@@ -36,6 +36,7 @@
#include "netsurf/browser_window.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/menus.h"
#include "riscos/message.h"
#include "riscos/mouse.h"
@@ -91,12 +92,13 @@ void gui_start_selection(struct gui_window *g)
wimp_drag drag;
os_error *error;
- LOG("starting text_selection drag");
+ NSLOG(netsurf, INFO, "starting text_selection drag");
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -110,7 +112,8 @@ void gui_start_selection(struct gui_window *g)
error = xwimp_send_message(wimp_USER_MESSAGE,
(wimp_message*)&msg, wimp_BROADCAST);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
owns_caret_and_selection = true;
@@ -126,7 +129,8 @@ void gui_start_selection(struct gui_window *g)
wimp_AUTO_SCROLL_ENABLE_HORIZONTAL,
&scroll, 0);
if (error)
- LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
ro_mouse_drag_start(ro_gui_selection_drag_end, ro_gui_window_mouse_at,
NULL, g);
@@ -140,7 +144,8 @@ void gui_start_selection(struct gui_window *g)
error = xwimp_drag_box(&drag);
if (error) {
- LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
last_start_window = g;
@@ -165,17 +170,20 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
scroll.w = g->window;
error = xwimp_auto_scroll(0, &scroll, 0);
if (error)
- LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
error = xwimp_drag_box((wimp_drag*)-1);
if (error) {
- LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -216,7 +224,7 @@ static void gui_set_clipboard(const char *buffer, size_t length,
wimp_full_message_claim_entity msg;
os_error *error;
- LOG("claiming clipboard");
+ NSLOG(netsurf, INFO, "claiming clipboard");
msg.size = sizeof(msg);
msg.your_ref = 0;
@@ -226,13 +234,14 @@ static void gui_set_clipboard(const char *buffer, size_t length,
error = xwimp_send_message(wimp_USER_MESSAGE,
(wimp_message*)&msg, wimp_BROADCAST);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
owns_clipboard = true;
}
- LOG("clipboard now holds %zd bytes", clip_length);
+ NSLOG(netsurf, INFO, "clipboard now holds %zd bytes", clip_length);
}
@@ -440,7 +449,7 @@ void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim)
/* ignore our own broadcasts! */
if (claim->sender != task_handle) {
- LOG("%x", claim->flags);
+ NSLOG(netsurf, INFO, "%x", claim->flags);
if (claim->flags & wimp_CLAIM_CARET_OR_SELECTION) {
owns_caret_and_selection = false;
@@ -473,7 +482,7 @@ void ro_gui_selection_data_request(wimp_full_message_data_request *req)
// bits ftype = req->file_types[i];
// if (ftype == ~0U) break; /* list terminator */
//
-// LOG("type %x", ftype);
+// NSLOG(netsurf, INFO, "type %x", ftype);
// i++;
// }
@@ -523,7 +532,8 @@ bool ro_gui_save_clipboard(const char *path)
free(local_cb);
if (error) {
- LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_save_stamped: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("SaveError", error->errmess);
return false;
}
@@ -605,7 +615,8 @@ void ro_gui_selection_send_dragging(wimp_pointer *pointer)
{
wimp_full_message_dragging dragmsg;
- LOG("sending DRAGGING to %p, %d", pointer->w, pointer->i);
+ NSLOG(netsurf, INFO, "sending DRAGGING to %p, %d", pointer->w,
+ pointer->i);
dragmsg.size = offsetof(wimp_full_message_dragging, file_types) + 8;
dragmsg.your_ref = 0;
diff --git a/frontends/riscos/theme.c b/frontends/riscos/theme.c
index b0b4ab879..341b7f7cd 100644
--- a/frontends/riscos/theme.c
+++ b/frontends/riscos/theme.c
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Window themes (implementation).
+/**
+ * \file
+ * Window themes implementation.
*/
#include <alloca.h>
@@ -180,8 +181,10 @@ static void ro_gui_theme_get_available_in_dir(const char *directory)
(osgbpb_info_list *) &info, 1, context,
sizeof(info), 0, &read_count, &context);
if (error) {
- LOG("xosgbpb_dir_entries_info: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosgbpb_dir_entries_info: 0x%x: %s",
+ error->errnum,
+ error->errmess);
if (error->errnum == 0xd6) /* no such dir */
return;
ro_warn_user("MiscError", error->errmess);
@@ -364,7 +367,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname)
/* create a full filename */
filename = malloc(strlen(folder) + strlen(leafname) + 2);
if (!filename) {
- LOG("No memory for malloc");
+ NSLOG(netsurf, INFO, "No memory for malloc");
ro_warn_user("NoMemory", 0);
return false;
}
@@ -374,7 +377,8 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname)
error = xosfind_openinw(osfind_NO_PATH, filename, 0,
&file_handle);
if (error) {
- LOG("xosfind_openinw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfind_openinw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("FileError", error->errmess);
free(filename);
return false;
@@ -389,7 +393,8 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname)
0, &output_left);
xosfind_closew(file_handle);
if (error) {
- LOG("xosbgpb_read_atw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosbgpb_read_atw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("FileError", error->errmess);
free(filename);
return false;
@@ -403,7 +408,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname)
current = (struct theme_descriptor *)calloc(1,
sizeof(struct theme_descriptor));
if (!current) {
- LOG("calloc failed");
+ NSLOG(netsurf, INFO, "calloc failed");
ro_warn_user("NoMemory", 0);
free(filename);
return false;
@@ -521,7 +526,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
descriptor->theme = (struct theme *)calloc(1,
sizeof(struct theme));
if (!descriptor->theme) {
- LOG("calloc() failed");
+ NSLOG(netsurf, INFO, "calloc() failed");
ro_warn_user("NoMemory", 0);
continue;
}
@@ -531,7 +536,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
error = xosfile_read_stamped_no_path(descriptor->filename,
&obj_type, 0, 0, &file_size, 0, 0);
if (error) {
- LOG("xosfile_read_stamped_no_path: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_read_stamped_no_path: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("FileError", error->errmess);
continue;
}
@@ -539,7 +547,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
continue;
raw_data = malloc(file_size);
if (!raw_data) {
- LOG("malloc() failed");
+ NSLOG(netsurf, INFO, "malloc() failed");
ro_warn_user("NoMemory", 0);
continue;
}
@@ -547,7 +555,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
(byte *)raw_data, 0, 0, 0, 0, 0);
if (error) {
free(raw_data);
- LOG("xosfile_load_stamped_no_path: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_load_stamped_no_path: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("FileError", error->errmess);
continue;
}
@@ -556,7 +567,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
error = xsquash_decompress_return_sizes(-1, &workspace_size, 0);
if (error) {
free(raw_data);
- LOG("xsquash_decompress_return_sizes: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xsquash_decompress_return_sizes: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
continue;
}
@@ -566,7 +580,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
if ((!decompressed) || (!workspace)) {
free(decompressed);
free(raw_data);
- LOG("malloc() failed");
+ NSLOG(netsurf, INFO, "malloc() failed");
ro_warn_user("NoMemory", 0);
continue;
}
@@ -581,7 +595,8 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
free(raw_data);
if (error) {
free(decompressed);
- LOG("xsquash_decompress: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xsquash_decompress: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
continue;
}
@@ -599,7 +614,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
descriptor->theme->sprite_area,
sprite_name, 16, i, 0);
if (error) {
- LOG("xosspriteop_return_name: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_return_name: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
continue;
}
@@ -614,7 +632,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list)
&dimensions.x, &dimensions.y,
(osbool *) 0, &mode);
if (error) {
- LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_read_sprite_info: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
continue;
}
diff --git a/frontends/riscos/theme_install.c b/frontends/riscos/theme_install.c
index 43ecb4687..fbca9e4fa 100644
--- a/frontends/riscos/theme_install.c
+++ b/frontends/riscos/theme_install.c
@@ -182,7 +182,7 @@ bool ro_gui_theme_install_apply(wimp_w w)
/* convert spaces to hard spaces */
theme_file = strdup(theme_install_descriptor.name);
if (!theme_file) {
- LOG("malloc failed");
+ NSLOG(netsurf, INFO, "malloc failed");
ro_warn_user("NoMemory", 0);
return false;
}
@@ -203,7 +203,8 @@ bool ro_gui_theme_install_apply(wimp_w w)
(byte *) source_data,
(byte *) source_data + source_size);
if (error) {
- LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xosfile_save_stamped: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("ThemeInstallErr", 0);
free(theme_file);
return false;
diff --git a/frontends/riscos/toolbar.c b/frontends/riscos/toolbar.c
index 2b5cb3415..758c90cc2 100644
--- a/frontends/riscos/toolbar.c
+++ b/frontends/riscos/toolbar.c
@@ -227,7 +227,7 @@ struct toolbar *ro_toolbar_create(struct theme_descriptor *descriptor,
toolbar = calloc(sizeof(struct toolbar), 1);
if (toolbar == NULL) {
- LOG("No memory for malloc()");
+ NSLOG(netsurf, INFO, "No memory for malloc()");
ro_warn_user("NoMemory", 0);
return NULL;
}
@@ -366,7 +366,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar)
old_window = toolbar->toolbar_handle;
error = xwimp_delete_window(toolbar->toolbar_handle);
if (error)
- LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess);
toolbar->toolbar_handle = NULL;
}
@@ -375,7 +376,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar)
error = xwimp_create_window(&ro_toolbar_window,
&toolbar->toolbar_handle);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -493,7 +495,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar)
icon.icon.data.indirected_text.size = 1;
error = xwimp_create_icon(&icon, &toolbar->editor_div1);
if (error) {
- LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
toolbar->editor_div1 = -1;
}
@@ -558,7 +561,10 @@ bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent)
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
<< wimp_CHILD_TS_EDGE_SHIFT);
if (error) {
- LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_open_window_nested: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -568,7 +574,8 @@ bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent)
error = xwimp_close_window(toolbar->toolbar_handle);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -601,7 +608,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat)
outline.w = toolbar->parent_handle;
error = xwimp_get_window_outline(&outline);
if (error) {
- LOG("xwimp_get_window_outline: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_outline: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -621,7 +631,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat)
state.w = toolbar->parent_handle;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -647,7 +660,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat)
error = xwimp_set_extent(toolbar->toolbar_handle,
&extent);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -935,7 +951,7 @@ void ro_toolbar_destroy(struct toolbar *toolbar)
if (toolbar == NULL)
return;
- LOG("Destroying toolbar 0x%x", (unsigned int)toolbar);
+ NSLOG(netsurf, INFO, "Destroying toolbar 0x%x", (unsigned int)toolbar);
/* Destroy the widgets. */
@@ -994,7 +1010,8 @@ void ro_toolbar_redraw(wimp_draw *redraw)
error = xwimp_redraw_window(redraw, &more);
if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1013,7 +1030,8 @@ void ro_toolbar_redraw(wimp_draw *redraw)
error = xwimp_get_rectangle(redraw, &more);
if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1046,7 +1064,8 @@ bool ro_toolbar_click(wimp_pointer *pointer)
state.w = toolbar->toolbar_handle;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -1325,7 +1344,8 @@ const char *ro_toolbar_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos,
state.w = toolbar->toolbar_handle;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return NULL;
}
diff --git a/frontends/riscos/ucstables.c b/frontends/riscos/ucstables.c
index 8e538ef95..3e31c992e 100644
--- a/frontends/riscos/ucstables.c
+++ b/frontends/riscos/ucstables.c
@@ -623,7 +623,8 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
off - prev_off, &temp, NULL);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_from_enc failed");
+ NSLOG(netsurf, INFO,
+ "utf8_from_enc failed");
free(*result);
return NSERROR_NOMEM;
}
@@ -665,7 +666,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
&temp, NULL);
if (err != NSERROR_OK) {
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_from_enc failed");
+ NSLOG(netsurf, INFO, "utf8_from_enc failed");
free(*result);
return NSERROR_NOMEM;
}
@@ -680,7 +681,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
/* and copy into more reasonably-sized buffer */
temp = realloc((*result), cur_off + 1);
if (!temp) {
- LOG("realloc failed");
+ NSLOG(netsurf, INFO, "realloc failed");
free(*result);
return NSERROR_NOMEM;
}
diff --git a/frontends/riscos/uri.c b/frontends/riscos/uri.c
index a2f126b31..d79cfe56d 100644
--- a/frontends/riscos/uri.c
+++ b/frontends/riscos/uri.c
@@ -120,7 +120,8 @@ void ro_uri_bounce(wimp_message *msg)
/* Get required buffer size */
e = xuri_request_uri(0, NULL, 0, message->handle, &size);
if (e) {
- LOG("xuri_request_uri: %d: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "xuri_request_uri: %d: %s", e->errnum,
+ e->errmess);
return;
}
@@ -131,7 +132,8 @@ void ro_uri_bounce(wimp_message *msg)
/* Get URI */
e = xuri_request_uri(0, uri_buf, size, message->handle, 0);
if (e) {
- LOG("xuri_request_uri: %d: %s", e->errnum, e->errmess);
+ NSLOG(netsurf, INFO, "xuri_request_uri: %d: %s", e->errnum,
+ e->errmess);
free(uri_buf);
return;
}
diff --git a/frontends/riscos/url_complete.c b/frontends/riscos/url_complete.c
index 3ca9be4c0..82c2d2c67 100644
--- a/frontends/riscos/url_complete.c
+++ b/frontends/riscos/url_complete.c
@@ -36,6 +36,7 @@
#include "riscos/global_history.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/mouse.h"
#include "riscos/toolbar.h"
#include "riscos/url_complete.h"
@@ -170,7 +171,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
-(url_complete_matches_selection + 1) * 44,
65536, -url_complete_matches_selection * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -209,7 +211,10 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
state.w = parent;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -227,7 +232,10 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
error = xwimp_force_redraw(dialog_url_complete,
0, -(i + 1) * 44, 65536, -i * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_force_redraw: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError",
error->errmess);
}
@@ -280,7 +288,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
0, -(old_selection + 1) * 44,
65536, -old_selection * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -288,7 +297,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
0, -(url_complete_matches_selection + 1) * 44,
65536, -url_complete_matches_selection * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -319,7 +329,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
state.w = dialog_url_complete;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return true;
}
@@ -334,7 +345,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
error = xwimp_open_window(PTR_WIMP_OPEN(&state));
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return true;
}
@@ -410,7 +422,8 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
state.w = dialog_url_complete;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -422,13 +435,14 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
toolbar_state.w = ro_toolbar_get_window(toolbar);
error = xwimp_get_window_state(&toolbar_state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
if (!ro_toolbar_get_url_field_extent(toolbar, &url_extent)) {
- LOG("Failed to read URL field extent.");
+ NSLOG(netsurf, INFO, "Failed to read URL field extent.");
return;
}
@@ -437,7 +451,8 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
extent.x1 = 65536;
error = xwimp_set_extent(dialog_url_complete, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -459,14 +474,16 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
if (state.visible.x1 - state.visible.x0 < 0) {
error = xwimp_close_window(dialog_url_complete);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
} else {
error = xwimp_open_window_nested_with_flags(&state,
(wimp_w)-1, 0);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -506,7 +523,8 @@ bool ro_gui_url_complete_close(void)
error = xwimp_close_window(dialog_url_complete);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -546,7 +564,7 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
/* no matches? no redraw */
if (!url_complete_matches) {
- LOG("Attempt to redraw with no matches made");
+ NSLOG(netsurf, INFO, "Attempt to redraw with no matches made");
/* Fill is never used, so make it something obvious */
ro_gui_user_redraw(redraw, false, os_COLOUR_BLACK);
return;
@@ -581,7 +599,10 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
error = xwimp_plot_icon(&url_complete_icon);
if (error) {
- LOG("xwimp_plot_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_plot_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -603,7 +624,10 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
url_complete_sprite.extent.y0 = -(line + 1) * 44;
error = xwimp_plot_icon(&url_complete_sprite);
if (error) {
- LOG("xwimp_plot_icon: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_plot_icon: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -657,7 +681,8 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
state.w = dialog_url_complete;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -684,14 +709,16 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
0, -(old_selection + 1) * 44,
65536, -old_selection * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_force_redraw(dialog_url_complete,
0, -(url_complete_matches_selection + 1) * 44,
65536, -url_complete_matches_selection * 44);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
diff --git a/frontends/riscos/url_protocol.c b/frontends/riscos/url_protocol.c
index 9a7ae062c..184aaeab0 100644
--- a/frontends/riscos/url_protocol.c
+++ b/frontends/riscos/url_protocol.c
@@ -75,17 +75,19 @@ void ro_url_message_received(wimp_message *message)
} else {
if (!url_message->indirect.url.offset) {
- LOG("no URL in message");
+ NSLOG(netsurf, INFO, "no URL in message");
return;
}
if (28 < message->size &&
url_message->indirect.body_file.offset) {
- LOG("POST for URL message not implemented");
+ NSLOG(netsurf, INFO,
+ "POST for URL message not implemented");
return;
}
if (url_message->indirect.url.offset < 28 ||
236 <= url_message->indirect.url.offset) {
- LOG("external pointers in URL message unimplemented");
+ NSLOG(netsurf, INFO,
+ "external pointers in URL message unimplemented");
/* these messages have never been seen in the wild,
* and there is the problem of invalid addresses which
* would cause an abort */
@@ -122,7 +124,8 @@ void ro_url_message_received(wimp_message *message)
error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, message,
message->sender);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -165,7 +168,8 @@ void ro_url_broadcast(const char *url)
error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED,
(wimp_message *) &message, 0);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -184,7 +188,7 @@ void ro_url_load(const char *url)
colon = strchr(url, ':');
if (!colon) {
- LOG("invalid url '%s'", url);
+ NSLOG(netsurf, INFO, "invalid url '%s'", url);
return;
}
@@ -204,7 +208,8 @@ void ro_url_load(const char *url)
error = xwimp_start_task(command, 0);
if (error) {
- LOG("xwimp_start_task: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_start_task: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
diff --git a/frontends/riscos/wimp.c b/frontends/riscos/wimp.c
index abf099a55..d851ab59e 100644
--- a/frontends/riscos/wimp.c
+++ b/frontends/riscos/wimp.c
@@ -103,7 +103,10 @@ void ro_gui_wimp_cache_furniture_sizes(wimp_w w)
furniture_sizes.border_widths.x1 = 40;
error = xwimpextend_get_furniture_sizes(&furniture_sizes);
if (error) {
- LOG("xwimpextend_get_furniture_sizes: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimpextend_get_furniture_sizes: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -123,13 +126,15 @@ bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig)
error = xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, xeig, 0);
if (error) {
- LOG("xos_read_mode_variable: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
return false;
}
error = xos_read_mode_variable(mode, os_MODEVAR_YEIG_FACTOR, yeig, 0);
if (error) {
- LOG("xos_read_mode_variable: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("MiscError", error->errmess);
return false;
}
@@ -196,14 +201,16 @@ void ro_gui_force_redraw_icon(wimp_w w, wimp_i i)
ic.i = i;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
error = xwimp_force_redraw(w, ic.icon.extent.x0, ic.icon.extent.y0,
ic.icon.extent.x1, ic.icon.extent.y1);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -235,7 +242,8 @@ const char *ro_gui_get_icon_string(wimp_w w, wimp_i i)
ic.i = i;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return NULL;
}
@@ -277,7 +285,7 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
if (err != NSERROR_OK) {
/* A bad encoding should never happen, so assert this */
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
/* Paranoia */
local_text = NULL;
}
@@ -292,7 +300,8 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
ic.i = i;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
goto exit;
}
@@ -325,7 +334,10 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
(button_type == wimp_BUTTON_WRITE_CLICK_DRAG)) {
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
goto exit;
}
@@ -336,7 +348,10 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
error = xwimp_set_caret_position(w, i, caret.pos.x,
caret.pos.y, -1, caret.index);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -433,7 +448,8 @@ void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state)
error = xwimp_set_icon_state(w, i,
(state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED);
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -452,7 +468,8 @@ bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i)
ic.i = i;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -478,7 +495,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
error = xwimp_set_icon_state(w, i,
(state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
if (!state)
@@ -487,7 +505,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
/* ensure the caret is not in a shaded icon */
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -499,7 +518,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
/* lose the caret */
error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -540,7 +560,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state)
error = xwimp_set_icon_state(w, i,
(state ? wimp_ICON_DELETED : 0), wimp_ICON_DELETED);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
if (!state)
@@ -549,7 +570,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state)
/* ensure the caret is not in a shaded icon */
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -561,7 +583,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state)
/* lose the caret */
error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -597,7 +620,8 @@ void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type)
error = xwimp_set_icon_state(w, i, wimp_ICON_BUTTON_TYPE,
(type << wimp_ICON_BUTTON_TYPE_SHIFT));
if (error) {
- LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -622,7 +646,8 @@ void ro_gui_set_icon_sprite(wimp_w w, wimp_i i, osspriteop_area *area,
ic.i = i;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -659,7 +684,8 @@ void ro_gui_set_window_title(wimp_w w, const char *text)
window.w = w;
error = xwimp_get_window_info_header_only((wimp_window_info *)&window);
if (error) {
- LOG("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -670,7 +696,7 @@ void ro_gui_set_window_title(wimp_w w, const char *text)
/* A bad encoding should never happen,
* so assert this */
assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
return;
}
@@ -686,7 +712,8 @@ void ro_gui_set_window_title(wimp_w w, const char *text)
*/
error = xwimp_force_redraw_title(w);
if (error) {
- LOG("xwimp_force_redraw_title: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw_title: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -713,7 +740,8 @@ bool ro_gui_set_caret_first(wimp_w w)
win_state.w = w;
error = xwimp_get_window_state(&win_state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -724,7 +752,8 @@ bool ro_gui_set_caret_first(wimp_w w)
window.w = w;
error = xwimp_get_window_info_header_only((wimp_window_info *)&window);
if (error) {
- LOG("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -735,7 +764,10 @@ bool ro_gui_set_caret_first(wimp_w w)
state.i = icon;
error = xwimp_get_icon_state(&state);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -752,7 +784,10 @@ bool ro_gui_set_caret_first(wimp_w w)
error = xwimp_set_caret_position(w, icon, 0, 0, -1,
strlen(state.icon.data.indirected_text.text));
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
return true;
@@ -778,7 +813,10 @@ osspriteop_area *ro_gui_load_sprite_file(const char *pathname)
error = xosfile_read_stamped_no_path(pathname,
&obj_type, 0, 0, &len, 0, 0);
if (error) {
- LOG("xosfile_read_stamped_no_path: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosfile_read_stamped_no_path: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
return 0;
}
@@ -801,7 +839,10 @@ osspriteop_area *ro_gui_load_sprite_file(const char *pathname)
error = xosspriteop_load_sprite_file(osspriteop_USER_AREA,
area, pathname);
if (error) {
- LOG("xosspriteop_load_sprite_file: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_load_sprite_file: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
free(area);
return 0;
@@ -831,7 +872,10 @@ bool ro_gui_wimp_sprite_exists(const char *sprite)
error = xwimpspriteop_select_sprite(sprite, 0);
if (error) {
if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
- LOG("xwimpspriteop_select_sprite: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimpspriteop_select_sprite: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
}
return false;
@@ -904,7 +948,10 @@ bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite,
if (height != NULL)
*height = dimensions.y;
} else if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
- LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xosspriteop_read_sprite_info: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
return false;
}
@@ -929,7 +976,8 @@ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill,
error = xwimp_redraw_window(redraw, &more);
if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -939,14 +987,18 @@ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill,
colourtrans_SET_BG_GCOL,
os_ACTION_OVERWRITE, 0, 0);
if (error) {
- LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("MiscError", error->errmess);
}
os_clg();
}
error = xwimp_get_rectangle(redraw, &more);
if (error) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -973,7 +1025,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask,
state.w = w;
error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -986,7 +1039,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask,
state.next = wimp_HIDDEN;
error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -994,7 +1048,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask,
if (!open) {
error = xwimp_close_window(w);
if (error) {
- LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -1016,7 +1071,8 @@ bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask)
state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -1116,7 +1172,8 @@ void ro_gui_scroll(wimp_scroll *scroll)
error = xwimp_open_window((wimp_open *) scroll);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
diff --git a/frontends/riscos/wimp_event.c b/frontends/riscos/wimp_event.c
index 015e87baf..cdca470da 100644
--- a/frontends/riscos/wimp_event.c
+++ b/frontends/riscos/wimp_event.c
@@ -156,7 +156,9 @@ bool ro_gui_wimp_event_memorise(wimp_w w)
ro_gui_get_icon_string(window->w, event->i));
if (!event->previous_value.textual) {
error = true;
- LOG("Unable to store state for icon %i", event->i);
+ NSLOG(netsurf, INFO,
+ "Unable to store state for icon %i",
+ event->i);
}
break;
case EVENT_CHECKBOX:
@@ -267,7 +269,10 @@ bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to)
struct event_window *window;
int h;
- LOG("Transferring all events from window 0x%x to window 0x%x", (unsigned int)from, (unsigned int)to);
+ NSLOG(netsurf, INFO,
+ "Transferring all events from window 0x%x to window 0x%x",
+ (unsigned int)from,
+ (unsigned int)to);
window = ro_gui_wimp_event_remove_window(from);
if (window == NULL || window->w != from)
@@ -293,7 +298,8 @@ void ro_gui_wimp_event_finalise(wimp_w w)
struct event_window *window;
struct icon_event *event;
- LOG("Removing all events for window 0x%x", (unsigned int)w);
+ NSLOG(netsurf, INFO, "Removing all events for window 0x%x",
+ (unsigned int)w);
window = ro_gui_wimp_event_remove_window(w);
if (!window)
return;
@@ -330,7 +336,8 @@ void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
struct event_window *window;
struct icon_event *event, *parent, *child;
- LOG("Removing all events for window 0x%x, icon %d", (unsigned int)w, (int)i);
+ NSLOG(netsurf, INFO, "Removing all events for window 0x%x, icon %d",
+ (unsigned int)w, (int)i);
window = ro_gui_wimp_event_get_window(w);
if (!window)
return;
@@ -344,7 +351,8 @@ void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
child = event->next;
if (event->i == i) {
- LOG("Removing event 0x%x", (unsigned int)event);
+ NSLOG(netsurf, INFO, "Removing event 0x%x",
+ (unsigned int)event);
if (parent == NULL)
window->first = child;
@@ -576,7 +584,8 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
ic.i = event->data.menu_gright.field;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -586,7 +595,8 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
return prepared;
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -594,7 +604,10 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
error = xwimp_set_caret_position(window->w, event->data.menu_gright.field,
-1, -1, -1, strlen(menu_entry->data.indirected_text.text));
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -666,7 +679,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
for (search = window->first; search; search = search->next)
if (search->i == event->data.linked_icon) break;
if (!search) {
- LOG("Incorrect reference.");
+ NSLOG(netsurf, INFO, "Incorrect reference.");
return false;
}
stepping = search->data.numeric_field.stepping;
@@ -703,13 +716,19 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
open.w = pointer->w;
error = xwimp_get_window_state(&open);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -718,7 +737,10 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
ro_gui_menu_destroy();
error = xwimp_open_window(PTR_WIMP_OPEN(&open));
if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_open_window: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -728,7 +750,10 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
caret.pos.x, caret.pos.y,
-1, caret.index);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -796,7 +821,8 @@ void ro_gui_wimp_event_prepare_gright_menu(wimp_w w, struct icon_event *event)
ic.i = event->data.menu_gright.field;
error = xwimp_get_icon_state(&ic);
if (error) {
- LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
@@ -903,7 +929,8 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
*/
error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &t_alphabet);
if (error) {
- LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s",
+ error->errnum, error->errmess);
/* prevent any corruption of ucstable */
t_alphabet = alphabet;
}
@@ -917,7 +944,10 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
error = xserviceinternational_get_ucs_conversion_table(
alphabet, &unclaimed, &ostable);
if (error != NULL) {
- LOG("failed reading UCS conversion table: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "failed reading UCS conversion table: 0x%x: %s",
+ error->errnum,
+ error->errmess);
/* Try using our own table instead */
ucstable = ucstable_from_alphabet(alphabet);
} else if (unclaimed) {
@@ -974,7 +1004,9 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
/* If this ever happens,
* RISC OS' UTF8 keyboard
* drivers are broken */
- LOG("unexpected UTF8 start"" byte %x (ignoring)", c);
+ NSLOG(netsurf, INFO,
+ "unexpected UTF8 start"" byte %x (ignoring)",
+ c);
return true;
}
/* Anything else is ASCII, so just
@@ -985,7 +1017,9 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
/* If this ever happens,
* RISC OS' UTF8 keyboard
* drivers are broken */
- LOG("unexpected keycode: ""%x (ignoring)", c);
+ NSLOG(netsurf, INFO,
+ "unexpected keycode: ""%x (ignoring)",
+ c);
return true;
}
@@ -1074,7 +1108,8 @@ bool ro_gui_wimp_event_close_window(wimp_w w)
{
struct event_window *window;
- LOG("Close event received for window 0x%x", (unsigned int)w);
+ NSLOG(netsurf, INFO, "Close event received for window 0x%x",
+ (unsigned int)w);
if (w == ro_gui_wimp_event_submenu)
ro_gui_wimp_event_submenu = 0;
window = ro_gui_wimp_event_find_window(w);
@@ -1615,7 +1650,8 @@ struct event_window *ro_gui_wimp_event_get_window(wimp_w w)
if (window)
return window;
- LOG("Creating structure for window 0x%x", (unsigned int)w);
+ NSLOG(netsurf, INFO, "Creating structure for window 0x%x",
+ (unsigned int)w);
window = calloc(1, sizeof(struct event_window));
if (!window)
return NULL;
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index b1ea58ae1..e41f6096f 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -35,6 +35,7 @@
#include <stdint.h>
#include <time.h>
#include <string.h>
+#include <limits.h>
#include <oslib/colourtrans.h>
#include <oslib/osbyte.h>
#include <oslib/osfile.h>
@@ -63,12 +64,12 @@
#include "netsurf/keypress.h"
#include "desktop/browser_history.h"
#include "desktop/cookie_manager.h"
-#include "desktop/scrollbar.h"
#include "riscos/bitmap.h"
#include "riscos/buffer.h"
#include "riscos/cookies.h"
#include "riscos/dialog.h"
+#include "riscos/local_history.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
#include "riscos/gui/status_bar.h"
@@ -90,72 +91,6 @@
#include "riscos/ucstables.h"
#include "riscos/filetype.h"
-void gui_window_redraw_window(struct gui_window *g);
-
-static void gui_window_set_extent(struct gui_window *g, int width, int height);
-
-static void ro_gui_window_redraw(wimp_draw *redraw);
-static void ro_gui_window_scroll(wimp_scroll *scroll);
-static void ro_gui_window_pointer_entering(wimp_entering *entering);
-static void ro_gui_window_track_end(wimp_leaving *leaving, void *data);
-static void ro_gui_window_open(wimp_open *open);
-static void ro_gui_window_close(wimp_w w);
-static bool ro_gui_window_click(wimp_pointer *mouse);
-static bool ro_gui_window_keypress(wimp_key *key);
-static bool ro_gui_window_toolbar_keypress(void *data, wimp_key *key);
-static bool ro_gui_window_handle_local_keypress(struct gui_window *g,
- wimp_key *key, bool is_toolbar);
-static bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_pointer *pointer);
-static void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action);
-static bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action);
-static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu);
-
-static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data);
-
-static void ro_gui_window_scroll_action(struct gui_window *g,
- int scroll_x, int scroll_y);
-
-static void ro_gui_window_toolbar_click(void *data,
- toolbar_action_type action_type, union toolbar_action action);
-
-static bool ro_gui_window_content_export_types(struct hlcache_handle *h,
- bool *export_draw, bool *export_sprite);
-static void ro_gui_window_prepare_pageinfo(struct gui_window *g);
-static void ro_gui_window_prepare_objectinfo(struct hlcache_handle *object,
- nsurl *target_url);
-
-static void ro_gui_window_launch_url(struct gui_window *g, const char *url);
-static void ro_gui_window_action_home(struct gui_window *g);
-static void ro_gui_window_action_new_window(struct gui_window *g);
-static void ro_gui_window_action_local_history(struct gui_window *g);
-static void ro_gui_window_action_save(struct gui_window *g,
- gui_save_type save_type);
-static void ro_gui_window_action_search(struct gui_window *g);
-static void ro_gui_window_action_zoom(struct gui_window *g);
-static void ro_gui_window_action_add_bookmark(struct gui_window *g);
-static void ro_gui_window_action_remove_bookmark(struct gui_window *g);
-static void ro_gui_window_action_print(struct gui_window *g);
-static void ro_gui_window_action_page_info(struct gui_window *g);
-
-static void ro_gui_window_remove_update_boxes(struct gui_window *g);
-static void ro_gui_window_update_toolbar_buttons(struct gui_window *g);
-static void ro_gui_window_update_toolbar(void *data);
-static void ro_gui_window_save_toolbar_buttons(void *data, char *config);
-static void ro_gui_window_update_theme(void *data, bool ok);
-
-static bool ro_gui_window_import_text(struct gui_window *g,
- const char *filename);
-static void ro_gui_window_clone_options(
- struct gui_window *new_gui,
- struct gui_window *old_gui);
-
-static bool ro_gui_window_prepare_form_select_menu(struct gui_window *bw,
- struct form_control *control);
-static void ro_gui_window_process_form_select_menu(struct gui_window *g,
- wimp_selection *selection);
#ifndef wimp_KEY_END
#define wimp_KEY_END wimp_KEY_COPY
@@ -168,6 +103,11 @@ static void ro_gui_window_process_form_select_menu(struct gui_window *g,
#define SCROLL_VISIBLE_PADDING 32
+#define SCROLL_TOP INT_MIN
+#define SCROLL_PAGE_UP (INT_MIN + 1)
+#define SCROLL_PAGE_DOWN (INT_MAX - 1)
+#define SCROLL_BOTTOM INT_MAX
+
/** Remembers which iconised sprite numbers are in use */
static bool iconise_used[64];
static int iconise_next = 0;
@@ -206,7 +146,8 @@ struct ro_gui_pointer_entry {
int yactive;
};
-/** Map from gui_pointer_shape to pointer sprite data. Must be ordered as
+/**
+ * Map from gui_pointer_shape to pointer sprite data. Must be ordered as
* enum gui_pointer_shape. */
struct ro_gui_pointer_entry ro_gui_pointer_table[] = {
{ true, "ptr_default", 0, 0 },
@@ -243,1609 +184,1046 @@ struct update_box {
struct update_box *pending_updates;
#define MARGIN 4
-static const struct toolbar_callbacks ro_gui_window_toolbar_callbacks = {
- ro_gui_window_update_theme,
- ro_gui_window_update_toolbar,
- (void (*)(void *)) ro_gui_window_update_toolbar_buttons,
- ro_gui_window_toolbar_click,
- ro_gui_window_toolbar_keypress,
- ro_gui_window_save_toolbar_buttons
-};
-
-
-/**
- * Initialise the browser window module and its menus.
- */
-
-void ro_gui_window_initialise(void)
-{
- /* Build the browser window menu. */
-
- static const struct ns_menu browser_definition = {
- "NetSurf", {
- { "Page", BROWSER_PAGE, 0 },
- { "Page.PageInfo",BROWSER_PAGE_INFO, &dialog_pageinfo },
- { "Page.Save", BROWSER_SAVE, &dialog_saveas },
- { "Page.SaveComp", BROWSER_SAVE_COMPLETE, &dialog_saveas },
- { "Page.Export", NO_ACTION, 0 },
-#ifdef WITH_DRAW_EXPORT
- { "Page.Export.Draw", BROWSER_EXPORT_DRAW, &dialog_saveas },
-#endif
-#ifdef WITH_PDF_EXPORT
- { "Page.Export.PDF", BROWSER_EXPORT_PDF, &dialog_saveas },
-#endif
- { "Page.Export.Text", BROWSER_EXPORT_TEXT, &dialog_saveas },
- { "Page.SaveURL", NO_ACTION, 0 },
- { "Page.SaveURL.URI", BROWSER_SAVE_URL_URI, &dialog_saveas },
- { "Page.SaveURL.URL", BROWSER_SAVE_URL_URL, &dialog_saveas },
- { "Page.SaveURL.LinkText", BROWSER_SAVE_URL_TEXT, &dialog_saveas },
- { "_Page.Print", BROWSER_PRINT, &dialog_print },
- { "Page.NewWindow", BROWSER_NEW_WINDOW, 0 },
- { "Page.FindText", BROWSER_FIND_TEXT, &dialog_search },
- { "Page.ViewSrc", BROWSER_VIEW_SOURCE, 0 },
- { "Object", BROWSER_OBJECT, 0 },
- { "Object.Object", BROWSER_OBJECT_OBJECT, 0 },
- { "Object.Object.ObjInfo", BROWSER_OBJECT_INFO, &dialog_objinfo },
- { "Object.Object.ObjSave", BROWSER_OBJECT_SAVE, &dialog_saveas },
- { "Object.Object.Export", BROWSER_OBJECT_EXPORT, 0 },
- { "Object.Object.Export.Sprite", BROWSER_OBJECT_EXPORT_SPRITE, &dialog_saveas },
-#ifdef WITH_DRAW_EXPORT
- { "Object.Object.Export.ObjDraw", BROWSER_OBJECT_EXPORT_DRAW, &dialog_saveas },
-#endif
- { "Object.Object.SaveURL", NO_ACTION, 0 },
- { "Object.Object.SaveURL.URI", BROWSER_OBJECT_SAVE_URL_URI, &dialog_saveas },
- { "Object.Object.SaveURL.URL", BROWSER_OBJECT_SAVE_URL_URL, &dialog_saveas },
- { "Object.Object.SaveURL.LinkText", BROWSER_OBJECT_SAVE_URL_TEXT, &dialog_saveas },
- { "Object.Object.ObjPrint", BROWSER_OBJECT_PRINT, 0 },
- { "Object.Object.ObjReload", BROWSER_OBJECT_RELOAD, 0 },
- { "Object.Link", BROWSER_OBJECT_LINK, 0 },
- { "Object.Link.LinkSave", BROWSER_LINK_SAVE, 0 },
- { "Object.Link.LinkSave.URI", BROWSER_LINK_SAVE_URI, &dialog_saveas },
- { "Object.Link.LinkSave.URL", BROWSER_LINK_SAVE_URL, &dialog_saveas },
- { "Object.Link.LinkSave.LinkText", BROWSER_LINK_SAVE_TEXT, &dialog_saveas },
- { "_Object.Link.LinkDload", BROWSER_LINK_DOWNLOAD, 0 },
- { "Object.Link.LinkNew", BROWSER_LINK_NEW_WINDOW, 0 },
- { "Selection", BROWSER_SELECTION, 0 },
- { "_Selection.SelSave", BROWSER_SELECTION_SAVE, &dialog_saveas },
- { "Selection.Copy", BROWSER_SELECTION_COPY, 0 },
- { "Selection.Cut", BROWSER_SELECTION_CUT, 0 },
- { "_Selection.Paste", BROWSER_SELECTION_PASTE, 0 },
- { "Selection.Clear", BROWSER_SELECTION_CLEAR, 0 },
- { "Selection.SelectAll", BROWSER_SELECTION_ALL, 0 },
- { "Navigate", NO_ACTION, 0 },
- { "Navigate.Home", BROWSER_NAVIGATE_HOME, 0 },
- { "Navigate.Back", BROWSER_NAVIGATE_BACK, 0 },
- { "Navigate.Forward", BROWSER_NAVIGATE_FORWARD, 0 },
- { "_Navigate.UpLevel", BROWSER_NAVIGATE_UP, 0 },
- { "Navigate.Reload", BROWSER_NAVIGATE_RELOAD_ALL, 0 },
- { "Navigate.Stop", BROWSER_NAVIGATE_STOP, 0 },
- { "View", NO_ACTION, 0 },
- { "View.ScaleView", BROWSER_SCALE_VIEW, &dialog_zoom },
- { "View.Images", NO_ACTION, 0 },
- { "View.Images.ForeImg", BROWSER_IMAGES_FOREGROUND, 0 },
- { "View.Images.BackImg", BROWSER_IMAGES_BACKGROUND, 0 },
- { "View.Toolbars", NO_ACTION, 0 },
- { "View.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
- { "View.Toolbars.ToolAddress", TOOLBAR_ADDRESS_BAR, 0 },
- { "_View.Toolbars.ToolThrob", TOOLBAR_THROBBER, 0 },
- { "View.Toolbars.EditToolbar", TOOLBAR_EDIT, 0 },
- { "_View.Render", NO_ACTION, 0 },
- { "View.Render.RenderAnims", BROWSER_BUFFER_ANIMS, 0 },
- { "View.Render.RenderAll", BROWSER_BUFFER_ALL, 0 },
- { "_View.OptDefault", BROWSER_SAVE_VIEW, 0 },
- { "View.Window", NO_ACTION, 0 },
- { "View.Window.WindowSave", BROWSER_WINDOW_DEFAULT, 0 },
- { "View.Window.WindowStagr", BROWSER_WINDOW_STAGGER, 0 },
- { "_View.Window.WindowSize", BROWSER_WINDOW_COPY, 0 },
- { "View.Window.WindowReset", BROWSER_WINDOW_RESET, 0 },
- { "Utilities", NO_ACTION, 0 },
- { "Utilities.Hotlist", HOTLIST_SHOW, 0 },
- { "Utilities.Hotlist.HotlistAdd", HOTLIST_ADD_URL, 0 },
- { "Utilities.Hotlist.HotlistShow", HOTLIST_SHOW, 0 },
- { "Utilities.History", HISTORY_SHOW_GLOBAL, 0 },
- { "Utilities.History.HistLocal", HISTORY_SHOW_LOCAL, 0 },
- { "Utilities.History.HistGlobal", HISTORY_SHOW_GLOBAL, 0 },
- { "Utilities.Cookies", COOKIES_SHOW, 0 },
- { "Utilities.Cookies.ShowCookies", COOKIES_SHOW, 0 },
- { "Utilities.Cookies.DeleteCookies", COOKIES_DELETE, 0 },
- { "Help", HELP_OPEN_CONTENTS, 0 },
- { "Help.HelpContent", HELP_OPEN_CONTENTS, 0 },
- { "Help.HelpGuide", HELP_OPEN_GUIDE, 0 },
- { "_Help.HelpInfo", HELP_OPEN_INFORMATION, 0 },
- { "Help.HelpCredits", HELP_OPEN_CREDITS, 0 },
- { "_Help.HelpLicence", HELP_OPEN_LICENCE, 0 },
- { "Help.HelpInter", HELP_LAUNCH_INTERACTIVE, 0 },
- {NULL, 0, 0}
- }
- };
- ro_gui_browser_window_menu =
- ro_gui_menu_define_menu(&browser_definition);
-
-}
-
-
-/*
- * Interface With Core
- */
/**
* Place the caret in a browser window.
*
- * \param g window with caret
- * \param x coordinates of caret
- * \param y coordinates of caret
- * \param height height of caret
- * \param clip clip rectangle, or NULL if none
+ * \param g window with caret
+ * \param x coordinates of caret
+ * \param y coordinates of caret
+ * \param height height of caret
+ * \param clip clip rectangle, or NULL if none
*/
-
-static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
- const struct rect *clip)
+static void
+gui_window_place_caret(struct gui_window *g,
+ int x,
+ int y,
+ int height,
+ const struct rect *clip)
{
os_error *error;
error = xwimp_set_caret_position(g->window, -1,
x * 2, -(y + height) * 2, height * 2, -1);
if (error) {
- LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
+
/**
- * Create and open a new browser window.
+ * Updates a windows extent.
*
- * \param bw bw to create gui_window for
- * \param existing an existing gui_window, may be NULL
- * \param flags flags for gui window creation
- * \return gui window, or NULL on error
+ * \param g the gui_window to update
+ * \param width the minimum width, or -1 to use window width
+ * \param height the minimum height, or -1 to use window height
*/
-
-static struct gui_window *gui_window_create(struct browser_window *bw,
- struct gui_window *existing,
- gui_window_create_flags flags)
+static void gui_window_set_extent(struct gui_window *g, int width, int height)
{
- int screen_width, screen_height;
- static int window_count = 2;
- wimp_window window;
+ int screen_width;
+ int toolbar_height = 0;
wimp_window_state state;
os_error *error;
- bool open_centred = true;
- struct gui_window *g;
- g = malloc(sizeof *g);
- if (!g) {
- ro_warn_user("NoMemory", 0);
- return 0;
+ if (g->toolbar) {
+ toolbar_height = ro_toolbar_full_height(g->toolbar);
}
- g->bw = bw;
- g->toolbar = 0;
- g->status_bar = 0;
- g->old_width = 0;
- g->old_height = 0;
- g->update_extent = true;
- g->active = false;
- strcpy(g->title, "NetSurf");
- g->iconise_icon = -1;
- g->scale = browser_window_get_scale(bw);
- /* Set the window position */
- if (existing != NULL &&
- flags & GW_CREATE_CLONE &&
- nsoption_bool(window_size_clone)) {
- state.w = existing->window;
+ /* get the current state */
+ if ((height == -1) || (width == -1)) {
+ state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
+ return;
}
- window.visible.x0 = state.visible.x0;
- window.visible.x1 = state.visible.x1;
- window.visible.y0 = state.visible.y0 - 48;
- window.visible.y1 = state.visible.y1 - 48;
- open_centred = false;
- } else {
- int win_width, win_height;
- ro_gui_screen_size(&screen_width, &screen_height);
-
- /* Check if we have a preferred position */
- if ((nsoption_int(window_screen_width) != 0) &&
- (nsoption_int(window_screen_height) != 0)) {
- win_width = (nsoption_int(window_width) *
- screen_width) /
- nsoption_int(window_screen_width);
- win_height = (nsoption_int(window_height) *
- screen_height) /
- nsoption_int(window_screen_height);
- window.visible.x0 = (nsoption_int(window_x) *
- screen_width) /
- nsoption_int(window_screen_width);
- window.visible.y0 = (nsoption_int(window_y) *
- screen_height) /
- nsoption_int(window_screen_height);
- if (nsoption_bool(window_stagger)) {
- window.visible.y0 += 96 -
- (48 * (window_count % 5));
- }
- open_centred = false;
- if (win_width < 100)
- win_width = 100;
- if (win_height < 100)
- win_height = 100;
- } else {
-
- /* Base how we define the window height/width
- on the compile time options set */
- win_width = screen_width * 3 / 4;
- if (1600 < win_width)
- win_width = 1600;
- win_height = win_width * 3 / 4;
-
- window.visible.x0 = (screen_width - win_width) / 2;
- window.visible.y0 = ((screen_height - win_height) / 2) +
- 96 - (48 * (window_count % 5));
+ if (width == -1)
+ width = state.visible.x1 - state.visible.x0;
+ if (height == -1) {
+ height = state.visible.y1 - state.visible.y0;
+ height -= toolbar_height;
}
- window.visible.x1 = window.visible.x0 + win_width;
- window.visible.y1 = window.visible.y0 + win_height;
}
- /* General flags for a non-movable, non-resizable, no-title bar window */
- window.xscroll = 0;
- window.yscroll = 0;
- window.next = wimp_TOP;
- window.flags = wimp_WINDOW_MOVEABLE |
- wimp_WINDOW_NEW_FORMAT |
- wimp_WINDOW_VSCROLL |
- wimp_WINDOW_HSCROLL |
- wimp_WINDOW_IGNORE_XEXTENT |
- wimp_WINDOW_IGNORE_YEXTENT |
- wimp_WINDOW_SCROLL_REPEAT;
- window.title_fg = wimp_COLOUR_BLACK;
- window.title_bg = wimp_COLOUR_LIGHT_GREY;
- window.work_fg = wimp_COLOUR_LIGHT_GREY;
- window.work_bg = wimp_COLOUR_TRANSPARENT;
- window.scroll_outer = wimp_COLOUR_DARK_GREY;
- window.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
- window.highlight_bg = wimp_COLOUR_CREAM;
- window.extra_flags = wimp_WINDOW_USE_EXTENDED_SCROLL_REQUEST |
- wimp_WINDOW_GIVE_SHADED_ICON_INFO;
- window.extent.x0 = 0;
- window.extent.y0 = -(window.visible.y1 - window.visible.y0);
- window.extent.x1 = window.visible.x1 - window.visible.x0;
- window.extent.y1 = 0;
- window.title_flags = wimp_ICON_TEXT |
- wimp_ICON_INDIRECTED |
- wimp_ICON_HCENTRED;
- window.work_flags = wimp_BUTTON_DOUBLE_CLICK_DRAG <<
- wimp_ICON_BUTTON_TYPE_SHIFT;
- window.sprite_area = wimpspriteop_AREA;
- window.xmin = 1;
- window.ymin = 1;
- window.title_data.indirected_text.text = g->title;
- window.title_data.indirected_text.validation = (char *) -1;
- window.title_data.indirected_text.size = 255;
- window.icon_count = 0;
-
- /* Add in flags */
- window.flags |= wimp_WINDOW_SIZE_ICON |
- wimp_WINDOW_BACK_ICON |
- wimp_WINDOW_CLOSE_ICON |
- wimp_WINDOW_TITLE_ICON |
- wimp_WINDOW_TOGGLE_ICON;
-
- if (open_centred) {
- int scroll_width = ro_get_vscroll_width(NULL);
- window.visible.x0 -= scroll_width;
+ /* the top-level framed window is a total pain. to get it to maximise
+ * to the top of the screen we need to fake it having a suitably large
+ * extent */
+ if (browser_window_is_frameset(g->bw)) {
+ ro_gui_screen_size(&screen_width, &height);
+ if (g->toolbar)
+ height -= ro_toolbar_full_height(g->toolbar);
+ height -= ro_get_hscroll_height(g->window);
+ height -= ro_get_title_height(g->window);
}
-
- error = xwimp_create_window(&window, &g->window);
+ if (browser_window_has_content(g->bw)) {
+ int w, h;
+ browser_window_get_extents(g->bw, true, &w, &h);
+ width = max(width, w * 2);
+ height = max(height, h * 2);
+ }
+ os_box extent = { 0, -height, width, toolbar_height };
+ error = xwimp_set_extent(g->window, &extent);
if (error) {
- LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
- free(g);
- return 0;
+ return;
}
+}
- /* Link into window list */
- g->prev = 0;
- g->next = window_list;
- if (window_list)
- window_list->prev = g;
- window_list = g;
- window_count++;
- /* Add in a toolbar and status bar */
- g->status_bar = ro_gui_status_bar_create(g->window,
- nsoption_int(toolbar_status_size));
- g->toolbar = ro_toolbar_create(NULL, g->window,
- THEME_STYLE_BROWSER_TOOLBAR, TOOLBAR_FLAGS_NONE,
- &ro_gui_window_toolbar_callbacks, g,
- "HelpToolbar");
- if (g->toolbar != NULL) {
- ro_toolbar_add_buttons(g->toolbar,
- brower_toolbar_buttons,
- nsoption_charp(toolbar_browser));
- ro_toolbar_add_url(g->toolbar);
- ro_toolbar_add_throbber(g->toolbar);
- ro_toolbar_rebuild(g->toolbar);
- }
+/**
+ * Open a window
+ *
+ * opens a window using the given wimp_open, handling toolbars and resizing.
+ *
+ * \param open the window open event information
+ */
+static void ro_gui_window_open(wimp_open *open)
+{
+ struct gui_window *g;
+ int width = open->visible.x1 - open->visible.x0;
+ int height = open->visible.y1 - open->visible.y0;
+ browser_scrolling h_scroll;
+ browser_scrolling v_scroll;
+ int toolbar_height = 0;
+ float new_scale = 0;
+ wimp_window_state state;
+ os_error *error;
+ wimp_w parent;
+ bits linkage;
+ bool have_content;
- /* Register event handlers. Do this quickly, as some of the things
- * that follow will indirectly look up our user data: this MUST
- * be set first!
- */
- ro_gui_wimp_event_set_user_data(g->window, g);
- ro_gui_wimp_event_register_open_window(g->window, ro_gui_window_open);
- ro_gui_wimp_event_register_close_window(g->window, ro_gui_window_close);
- ro_gui_wimp_event_register_redraw_window(g->window, ro_gui_window_redraw);
- ro_gui_wimp_event_register_scroll_window(g->window, ro_gui_window_scroll);
- ro_gui_wimp_event_register_pointer_entering_window(g->window, ro_gui_window_pointer_entering);
- ro_gui_wimp_event_register_keypress(g->window, ro_gui_window_keypress);
- ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_window_click);
- ro_gui_wimp_event_register_menu(g->window, ro_gui_browser_window_menu,
- true, false);
- ro_gui_wimp_event_register_menu_prepare(g->window,
- ro_gui_window_menu_prepare);
- ro_gui_wimp_event_register_menu_selection(g->window,
- ro_gui_window_menu_select);
- ro_gui_wimp_event_register_menu_warning(g->window,
- ro_gui_window_menu_warning);
- ro_gui_wimp_event_register_menu_close(g->window,
- ro_gui_window_menu_close);
+ g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
- /* Set the window options */
- ro_gui_window_clone_options(g, existing);
- ro_gui_window_update_toolbar_buttons(g);
+ if (open->next == wimp_TOP && g->iconise_icon >= 0) {
+ /* window is no longer iconised, release its sprite number */
+ iconise_used[g->iconise_icon] = false;
+ g->iconise_icon = -1;
+ }
- /* Open the window at the top of the stack */
+ have_content = browser_window_has_content(g->bw);
+
+ /* get the current flags/nesting state */
state.w = g->window;
- error = xwimp_get_window_state(&state);
+ error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
- return g;
+ return;
}
- state.next = wimp_TOP;
-
- ro_gui_window_open(PTR_WIMP_OPEN(&state));
+ /* account for toolbar height, if present */
+ if (g->toolbar)
+ toolbar_height = ro_toolbar_full_height(g->toolbar);
+ height -= toolbar_height;
- /* Claim the caret */
- if (ro_toolbar_take_caret(g->toolbar))
- ro_gui_url_complete_start(g->toolbar);
- else
- gui_window_place_caret(g, -100, -100, 0, NULL);
+ /* work with the state from now on so we can modify flags */
+ state.visible = open->visible;
+ state.xscroll = open->xscroll;
+ state.yscroll = open->yscroll;
+ state.next = open->next;
- return g;
-}
+ browser_window_get_scrollbar_type(g->bw, &h_scroll, &v_scroll);
+ /* handle 'auto' scroll bars' and non-fitting scrollbar removal */
+ if ((h_scroll != BW_SCROLLING_NO) && (v_scroll != BW_SCROLLING_NO)) {
+ int size;
-/**
- * Close a browser window and free any related resources.
- *
- * \param g gui_window to destroy
- */
+ /* windows lose scrollbars when containing a frameset */
+ bool no_hscroll = false;
+ bool no_vscroll = browser_window_is_frameset(g->bw);
-static void gui_window_destroy(struct gui_window *g)
-{
- os_error *error;
- wimp_w w;
+ /* hscroll */
+ size = ro_get_hscroll_height(NULL);
+ size -= 2; /* 1px border on both sides */
+ if (!no_hscroll) {
+ if (!(state.flags & wimp_WINDOW_HSCROLL)) {
+ height -= size;
+ state.visible.y0 += size;
+ if (have_content) {
+ browser_window_schedule_reformat(g->bw);
+ }
+ }
+ state.flags |= wimp_WINDOW_HSCROLL;
+ } else {
+ if (state.flags & wimp_WINDOW_HSCROLL) {
+ height += size;
+ state.visible.y0 -= size;
+ if (have_content) {
+ browser_window_schedule_reformat(g->bw);
+ }
+ }
+ state.flags &= ~wimp_WINDOW_HSCROLL;
+ }
- assert(g);
+ /* vscroll */
+ size = ro_get_vscroll_width(NULL);
+ size -= 2; /* 1px border on both sides */
+ if (!no_vscroll) {
+ if (!(state.flags & wimp_WINDOW_VSCROLL)) {
+ width -= size;
+ state.visible.x1 -= size;
+ if (have_content) {
+ browser_window_schedule_reformat(g->bw);
+ }
+ }
+ state.flags |= wimp_WINDOW_VSCROLL;
+ } else {
+ if (state.flags & wimp_WINDOW_VSCROLL) {
+ width += size;
+ state.visible.x1 += size;
+ if (have_content) {
+ browser_window_schedule_reformat(g->bw);
+ }
+ }
+ state.flags &= ~wimp_WINDOW_VSCROLL;
+ }
+ }
- /* stop any tracking */
- ro_mouse_kill(g);
+ /* reformat or change extent if necessary */
+ if (have_content &&
+ (g->old_width != width || g->old_height != height)) {
+ /* Ctrl-resize of a top-level window scales the content size */
+ if ((g->old_width > 0) && (g->old_width != width) &&
+ (ro_gui_ctrl_pressed()))
+ new_scale = (g->scale * width) / g->old_width;
+ browser_window_schedule_reformat(g->bw);
+ }
+ if (g->update_extent || g->old_width != width ||
+ g->old_height != height) {
+ g->old_width = width;
+ g->old_height = height;
+ g->update_extent = false;
+ gui_window_set_extent(g, width, height);
+ }
- /* remove from list */
- if (g->prev)
- g->prev->next = g->next;
- else
- window_list = g->next;
- if (g->next)
- g->next->prev = g->prev;
+ /* first resize stops any flickering by making the URL window on top */
+ ro_gui_url_complete_resize(g->toolbar, PTR_WIMP_OPEN(&state));
- /* destroy toolbar */
- if (g->toolbar)
- ro_toolbar_destroy(g->toolbar);
- if (g->status_bar)
- ro_gui_status_bar_destroy(g->status_bar);
+ /* Windows containing framesets can only be scrolled via the core, which
+ * is implementing frame scrollbars itself. The x and y offsets are
+ * therefore fixed.
+ */
- w = g->window;
- ro_gui_url_complete_close();
- ro_gui_dialog_close_persistent(w);
- if (current_menu_window == w)
- ro_gui_menu_destroy();
- ro_gui_window_remove_update_boxes(g);
+ if (browser_window_is_frameset(g->bw)) {
+ state.xscroll = 0;
+ state.yscroll = toolbar_height;
+ }
- /* delete window */
- error = xwimp_delete_window(w);
+ error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
if (error) {
- LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
+ return;
}
- ro_gui_wimp_event_finalise(w);
-
- free(g);
-}
-
-/**
- * Set the title of a browser window.
- *
- * \param g gui_window to update
- * \param title new window title, copied
- */
-
-static void gui_window_set_title(struct gui_window *g, const char *title)
-{
- assert(g);
- assert(title);
-
- if (g->scale != 1.0) {
- int scale_disp = g->scale * 100;
-
- if (ABS((float)scale_disp - g->scale * 100) >= 0.05)
- snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
- title, g->scale * 100);
- else
- snprintf(g->title, sizeof g->title, "%s (%i%%)",
- title, scale_disp);
- } else {
- strncpy(g->title, title, sizeof g->title);
+ /* update the toolbar */
+ if (g->status_bar)
+ ro_gui_status_bar_resize(g->status_bar);
+ if (g->toolbar) {
+ ro_toolbar_process(g->toolbar, -1, false);
+ /* second resize updates to the new URL bar width */
+ ro_gui_url_complete_resize(g->toolbar, open);
}
- ro_gui_set_window_title(g->window, g->title);
+ /* set the new scale from a ctrl-resize. this must be done at the end as
+ * it may cause a frameset recalculation based on the new window size.
+ */
+ if (new_scale > 0) {
+ ro_gui_window_set_scale(g, new_scale);
+ }
}
/**
- * Force a redraw of the entire contents of a browser window.
+ * Update the extent of the inside of a browser window to that of the
+ * current content.
*
- * \param g gui_window to redraw
+ * \param g gui_window to update the extent of
*/
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
- wimp_window_info info;
os_error *error;
+ wimp_window_info info;
assert(g);
+
info.w = g->window;
error = xwimp_get_window_info_header_only(&info);
if (error) {
- LOG("xwimp_get_window_info_header_only: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_info_header_only: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
- error = xwimp_force_redraw(g->window, info.extent.x0, info.extent.y0,
- info.extent.x1, info.extent.y1);
- if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+
+ /* scroll on toolbar height change */
+ if (g->toolbar) {
+ int scroll = ro_toolbar_height(g->toolbar) - info.extent.y1;
+ info.yscroll += scroll;
}
+
+ /* Handle change of extents */
+ g->update_extent = true;
+ ro_gui_window_open(PTR_WIMP_OPEN(&info));
}
/**
- * Redraw an area of a window.
+ * Update a window and its toolbar
*
- * \param g The window to update
- * \param rect The area of the window to update.
+ * makes a window and toolbar reflect a new theme: used as a callback
+ * by the toolbar module when a theme change affects a toolbar.
+ *
+ * \param data void pointer to the window's gui_window struct
+ * \param ok true if the bar still exists; else false.
*/
-
-static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void ro_gui_window_update_theme(void *data, bool ok)
{
- bool use_buffer;
- int x0, y0, x1, y1;
- struct update_box *cur;
-
- x0 = floorf(rect->x0 * 2 * g->scale);
- y0 = -ceilf(rect->y1 * 2 * g->scale);
- x1 = ceilf(rect->x1 * 2 * g->scale) + 1;
- y1 = -floorf(rect->y0 * 2 * g->scale) + 1;
- use_buffer =
- (g->option.buffer_everything || g->option.buffer_animations);
-
- /* try to optimise buffered redraws */
- if (use_buffer) {
- for (cur = pending_updates; cur != NULL; cur = cur->next) {
- if ((cur->g != g) || (!cur->use_buffer))
- continue;
- if ((((cur->x0 - x1) < MARGIN) || ((cur->x1 - x0) < MARGIN)) &&
- (((cur->y0 - y1) < MARGIN) || ((cur->y1 - y0) < MARGIN))) {
- cur->x0 = min(cur->x0, x0);
- cur->y0 = min(cur->y0, y0);
- cur->x1 = max(cur->x1, x1);
- cur->y1 = max(cur->y1, y1);
- return;
- }
+ struct gui_window *g = (struct gui_window *) data;
+ if (g != NULL && g->toolbar != NULL) {
+ if (ok) {
+ gui_window_update_extent(g);
+ } else {
+ g->toolbar = NULL;
}
}
- cur = malloc(sizeof(struct update_box));
- if (!cur) {
- LOG("No memory for malloc.");
- ro_warn_user("NoMemory", 0);
- return;
- }
- cur->x0 = x0;
- cur->y0 = y0;
- cur->x1 = x1;
- cur->y1 = y1;
- cur->next = pending_updates;
- pending_updates = cur;
- cur->g = g;
- cur->use_buffer = use_buffer;
}
/**
- * Get the scroll position of a browser window.
+ * Update a window to reflect a change in toolbar size: used as a callback by
+ * the toolbar module when a toolbar height changes.
*
- * \param g gui_window
- * \param sx receives x ordinate of point at top-left of window
- * \param sy receives y ordinate of point at top-left of window
- * \return true iff successful
+ * \param data void pointer the window's gui_window struct
*/
-
-static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static void ro_gui_window_update_toolbar(void *data)
{
- wimp_window_state state;
- os_error *error;
- int toolbar_height = 0;
-
- assert(g);
+ struct gui_window *g = (struct gui_window *) data;
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
+ if (g != NULL) {
+ gui_window_update_extent(g);
}
-
- if (g->toolbar)
- toolbar_height = ro_toolbar_full_height(g->toolbar);
- *sx = state.xscroll / (2 * g->scale);
- *sy = -(state.yscroll - toolbar_height) / (2 * g->scale);
- return true;
}
/**
- * Set the scroll position of a browser window.
+ * Update the toolbar buttons for a given browser window to reflect the
+ * current state of its contents.
*
- * \param g gui_window to scroll
- * \param sx point to place at top-left of window
- * \param sy point to place at top-left of window
+ * Note that the parameters to this function are arranged so that it can be
+ * supplied to the toolbar module as an button state update callback.
+ *
+ * \param g The browser window to update.
*/
-
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void ro_gui_window_update_toolbar_buttons(struct gui_window *g)
{
- wimp_window_state state;
- os_error *error;
-
- assert(g);
+ struct browser_window *bw;
+ struct toolbar *toolbar;
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (g == NULL || g->toolbar == NULL)
return;
- }
- state.xscroll = sx * 2 * g->scale;
- state.yscroll = -sy * 2 * g->scale;
- if (g->toolbar)
- state.yscroll += ro_toolbar_full_height(g->toolbar);
- ro_gui_window_open(PTR_WIMP_OPEN(&state));
-}
+ bw = g->bw;
+ toolbar = g->toolbar;
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_RELOAD,
+ !browser_window_reload_available(bw));
-/**
- * Scrolls the specified area of a browser window into view.
- *
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
- */
-static void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
-{
- wimp_window_state state;
- os_error *error;
- int cx0, cy0, width, height;
- int padding_available;
- int toolbar_height = 0;
- int correction;
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_STOP,
+ !browser_window_stop_available(bw));
- assert(g);
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_BACK,
+ !browser_window_back_available(bw));
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_FORWARD,
+ !browser_window_forward_available(bw));
- if (g->toolbar)
- toolbar_height = ro_toolbar_full_height(g->toolbar);
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_UP,
+ !browser_window_up_available(bw));
- x0 = x0 * 2 * g->scale;
- y0 = y0 * 2 * g->scale;
- x1 = x1 * 2 * g->scale;
- y1 = y1 * 2 * g->scale;
-
- cx0 = state.xscroll;
- cy0 = -state.yscroll + toolbar_height;
- width = state.visible.x1 - state.visible.x0;
- height = state.visible.y1 - state.visible.y0 - toolbar_height;
-
- /* make sure we're visible */
- correction = (x1 - cx0 - width);
- if (correction > 0)
- cx0 += correction;
- correction = (y1 - cy0 - height);
- if (correction > 0)
- cy0 += correction;
- if (x0 < cx0)
- cx0 = x0;
- if (y0 < cy0)
- cy0 = y0;
-
- /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
- padding_available = (width - x1 + x0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cx0 + width - x1);
- if (correction < padding_available)
- cx0 += padding_available;
- correction = (x0 - cx0);
- if (correction < padding_available)
- cx0 -= padding_available;
- }
- padding_available = (height - y1 + y0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cy0 + height - y1);
- if (correction < padding_available)
- cy0 += padding_available;
- correction = (y0 - cy0);
- if (correction < padding_available)
- cy0 -= padding_available;
- }
-
- state.xscroll = cx0;
- state.yscroll = -cy0 + toolbar_height;
- ro_gui_window_open(PTR_WIMP_OPEN(&state));
-}
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SEARCH,
+ !browser_window_can_search(bw));
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SCALE,
+ !browser_window_has_content(bw));
-/**
- * Find the current dimensions of a browser window's content area.
- *
- * \param g gui_window to measure
- * \param width receives width of window
- * \param height receives height of window
- * \param scaled whether to return scaled values
- */
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_PRINT,
+ !browser_window_has_content(bw));
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
-{
- /* use the cached window sizes */
- *width = g->old_width / 2;
- *height = g->old_height / 2;
- if (scaled) {
- *width /= g->scale;
- *height /= g->scale;
- }
+ ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SAVE_SOURCE,
+ !browser_window_has_content(bw));
+
+ ro_toolbar_update_urlsuggest(toolbar);
}
/**
- * Update the extent of the inside of a browser window to that of the
- * current content.
+ * Add a hotlist entry for a browser window.
*
- * \param g gui_window to update the extent of
+ * \param g The browser window to act on.
*/
-
-static void gui_window_update_extent(struct gui_window *g)
+static void ro_gui_window_action_add_bookmark(struct gui_window *g)
{
- os_error *error;
- wimp_window_info info;
-
- assert(g);
+ nsurl *url;
- info.w = g->window;
- error = xwimp_get_window_info_header_only(&info);
- if (error) {
- LOG("xwimp_get_window_info_header_only: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
+ browser_window_has_content(g->bw) == false)
return;
- }
- /* scroll on toolbar height change */
- if (g->toolbar) {
- int scroll = ro_toolbar_height(g->toolbar) - info.extent.y1;
- info.yscroll += scroll;
- }
+ url = browser_window_access_url(g->bw);
- /* Handle change of extents */
- g->update_extent = true;
- ro_gui_window_open(PTR_WIMP_OPEN(&info));
+ ro_gui_hotlist_add_page(url);
+ ro_toolbar_update_hotlist(g->toolbar);
}
/**
- * Set the status bar of a browser window.
+ * Remove a hotlist entry for a browser window.
*
- * \param g gui_window to update
- * \param text new status text
+ * \param g The browser window to act on.
*/
-
-static void riscos_window_set_status(struct gui_window *g, const char *text)
+static void ro_gui_window_action_remove_bookmark(struct gui_window *g)
{
- if (g->status_bar)
- ro_gui_status_bar_set_text(g->status_bar, text);
+ nsurl *url;
+
+ if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
+ browser_window_has_content(g->bw) == false)
+ return;
+
+ url = browser_window_access_url(g->bw);
+
+ ro_gui_hotlist_remove_page(url);
}
/**
- * Change mouse pointer shape
+ * Open a local history pane for a browser window.
+ *
+ * \param gw The browser window to act on.
*/
-
-void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+static void ro_gui_window_action_local_history(struct gui_window *gw)
{
- static gui_pointer_shape curr_pointer = GUI_POINTER_DEFAULT;
- struct ro_gui_pointer_entry *entry;
- os_error *error;
+ nserror res;
- if (shape == curr_pointer)
+ if ((gw == NULL) || (gw->bw == NULL)) {
return;
+ }
- assert(shape < sizeof ro_gui_pointer_table /
- sizeof ro_gui_pointer_table[0]);
-
- entry = &ro_gui_pointer_table[shape];
+ res = ro_gui_local_history_present(gw->window, gw->bw);
- if (entry->wimp_area) {
- /* pointer in the Wimp's sprite area */
- error = xwimpspriteop_set_pointer_shape(entry->sprite_name,
- 1, entry->xactive, entry->yactive, 0, 0);
- if (error) {
- LOG("xwimpspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- }
- } else {
- /* pointer in our own sprite area */
- error = xosspriteop_set_pointer_shape(osspriteop_USER_AREA,
- gui_sprites,
- (osspriteop_id) entry->sprite_name,
- 1, entry->xactive, entry->yactive, 0, 0);
- if (error) {
- LOG("xosspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- }
+ if (res != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(res), 0);
}
-
- curr_pointer = shape;
}
-/* exported function documented in riscos/window.h */
-nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
+/**
+ * Perform a Navigate Home action on a browser window.
+ *
+ * \param g The browser window to act on.
+ */
+static void ro_gui_window_action_home(struct gui_window *g)
{
- size_t idn_url_l;
- char *idn_url_s = NULL;
-
- if (g->toolbar) {
- if (nsoption_bool(display_decoded_idn) == true) {
- if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) != NSERROR_OK)
- idn_url_s = NULL;
- }
-
- ro_toolbar_set_url(g->toolbar, idn_url_s ? idn_url_s : nsurl_access(url), true, false);
+ static const char *addr = NETSURF_HOMEPAGE;
+ nsurl *url;
+ nserror error;
- if (idn_url_s)
- free(idn_url_s);
+ if (g == NULL || g->bw == NULL)
+ return;
- ro_gui_url_complete_start(g->toolbar);
+ if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
}
- return NSERROR_OK;
+ error = nsurl_create(addr, &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_navigate(g->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(error), 0);
+ }
}
/**
- * Update the interface to reflect start of page loading.
+ * Open a text search dialogue for a browser window.
*
- * \param g window with start of load
+ * \param g The browser window to act on.
*/
-
-static void gui_window_start_throbber(struct gui_window *g)
+static void ro_gui_window_action_search(struct gui_window *g)
{
- ro_gui_window_update_toolbar_buttons(g);
- ro_gui_menu_refresh(ro_gui_browser_window_menu);
- if (g->toolbar != NULL)
- ro_toolbar_start_throbbing(g->toolbar);
- g->active = true;
-}
+ if (g == NULL || g->bw == NULL || !browser_window_can_search(g->bw))
+ return;
+ ro_gui_search_prepare(g->bw);
+ ro_gui_dialog_open_persistent(g->window, dialog_search, true);
+}
/**
- * Update the interface to reflect page loading stopped.
+ * Open a zoom dialogue for a browser window.
*
- * \param g window with start of load
+ * \param g The browser window to act on.
*/
-
-static void gui_window_stop_throbber(struct gui_window *g)
+static void ro_gui_window_action_zoom(struct gui_window *g)
{
- ro_gui_window_update_toolbar_buttons(g);
- ro_gui_menu_refresh(ro_gui_browser_window_menu);
- if (g->toolbar != NULL)
- ro_toolbar_stop_throbbing(g->toolbar);
- g->active = false;
-}
-
-/**
- * set favicon
- */
-
-static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
-{
- if (g == NULL || g->toolbar == NULL)
+ if (g == NULL)
return;
- ro_toolbar_set_site_favicon(g->toolbar, icon);
+ ro_gui_dialog_prepare_zoom(g);
+ ro_gui_dialog_open_persistent(g->window, dialog_zoom, true);
}
-
/**
- * Remove the caret, if present.
+ * Open a save dialogue for a browser window contents.
*
- * \param g window with caret
+ * \param g The browser window to act on.
+ * \param save_type The type of save to open.
*/
-
-static void gui_window_remove_caret(struct gui_window *g)
+static void
+ro_gui_window_action_save(struct gui_window *g, gui_save_type save_type)
{
- wimp_caret caret;
- os_error *error;
+ struct hlcache_handle *h;
- error = xwimp_get_caret_position(&caret);
- if (error) {
- LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (g == NULL || g->bw == NULL || !browser_window_has_content(g->bw))
return;
- }
- if (caret.w != g->window)
- /* we don't have the caret: do nothing */
+ h = browser_window_get_content(g->bw);
+ if (h == NULL)
return;
- /* hide caret, but keep input focus */
- gui_window_place_caret(g, -100, -100, 0, NULL);
+ ro_gui_save_prepare(save_type, h, NULL, NULL, NULL);
+ ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
}
/**
- * Called when the gui_window has new content.
+ * Open a print dialogue for a browser window.
*
- * \param g the gui_window that has new content
+ * \param g The browser window to act on.
*/
-
-static void gui_window_new_content(struct gui_window *g)
+static void ro_gui_window_action_print(struct gui_window *g)
{
- ro_gui_menu_refresh(ro_gui_browser_window_menu);
- ro_gui_window_update_toolbar_buttons(g);
- ro_gui_dialog_close_persistent(g->window);
- ro_toolbar_set_content_favicon(g->toolbar, g);
+ if (g != NULL) {
+ ro_gui_print_prepare(g);
+ ro_gui_dialog_open_persistent(g->window, dialog_print, true);
+ }
}
/**
- * Starts drag scrolling of a browser window
+ * Prepare the page info window for use.
*
- * \param g the window to scroll
+ * \param g The GUI window block to use.
*/
-
-static bool gui_window_scroll_start(struct gui_window *g)
+static void ro_gui_window_prepare_pageinfo(struct gui_window *g)
{
- wimp_window_info_base info;
- wimp_pointer pointer;
- os_error *error;
- wimp_drag drag;
- int height;
- int width;
-
- error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
+ struct hlcache_handle *h = browser_window_get_content(g->bw);
+ char icon_buf[20] = "file_xxx";
+ char enc_buf[40];
+ const char *icon = icon_buf;
+ const char *title, *url;
+ lwc_string *mime;
+ const char *enc = "-";
- info.w = g->window;
- error = xwimp_get_window_info_header_only((wimp_window_info*)&info);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x : %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
+ assert(h);
- width = info.extent.x1 - info.extent.x0;
- height = info.extent.y1 - info.extent.y0;
+ title = content_get_title(h);
+ if (title == NULL)
+ title = "-";
+ url = nsurl_access(hlcache_handle_get_url(h));
+ if (url == NULL)
+ url = "-";
+ mime = content_get_mime_type(h);
- drag.type = wimp_DRAG_USER_POINT;
- drag.bbox.x1 = pointer.pos.x + info.xscroll;
- drag.bbox.y0 = pointer.pos.y + info.yscroll;
- drag.bbox.x0 = drag.bbox.x1 - (width - (info.visible.x1 - info.visible.x0));
- drag.bbox.y1 = drag.bbox.y0 + (height - (info.visible.y1 - info.visible.y0));
+ sprintf(icon_buf, "file_%x", ro_content_filetype(h));
+ if (!ro_gui_wimp_sprite_exists(icon_buf))
+ sprintf(icon_buf, "file_xxx");
- if (g->toolbar) {
- int tbar_height = ro_toolbar_full_height(g->toolbar);
- drag.bbox.y0 -= tbar_height;
- drag.bbox.y1 -= tbar_height;
+ if (content_get_type(h) == CONTENT_HTML) {
+ if (content_get_encoding(h, CONTENT_ENCODING_NORMAL)) {
+ snprintf(enc_buf, sizeof enc_buf, "%s (%s)",
+ content_get_encoding(h, CONTENT_ENCODING_NORMAL),
+ content_get_encoding(h, CONTENT_ENCODING_SOURCE));
+ enc = enc_buf;
+ } else {
+ enc = messages_get("EncodingUnk");
+ }
}
- error = xwimp_drag_box(&drag);
- if (error) {
- LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
+ ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_ICON,
+ icon, true);
+ ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TITLE,
+ title, true);
+ ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_URL,
+ url, true);
+ ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_ENC,
+ enc, true);
+ ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TYPE,
+ lwc_string_data(mime), true);
- ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
- NULL, g);
- return true;
+ lwc_string_unref(mime);
}
/**
- * Platform-dependent part of starting drag operation.
+ * Open a page info box for a browser window.
*
- * \param g gui window containing the drag
- * \param type type of drag the core is performing
- * \param rect rectangle to constrain pointer to (relative to drag start coord)
- * \return true iff succesful
+ * \param g The browser window to act on.
*/
-
-static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
+static void ro_gui_window_action_page_info(struct gui_window *g)
{
- wimp_pointer pointer;
- wimp_drag drag;
-
- if (rect != NULL) {
- /* We have a box to constrain the pointer to, for the drag
- * duration */
- os_error *error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
-
- drag.type = wimp_DRAG_USER_POINT;
- drag.bbox.x0 = pointer.pos.x +
- (int)(rect->x0 * 2 * g->scale);
- drag.bbox.y0 = pointer.pos.y +
- (int)(rect->y0 * 2 * g->scale);
- drag.bbox.x1 = pointer.pos.x +
- (int)(rect->x1 * 2 * g->scale);
- drag.bbox.y1 = pointer.pos.y +
- (int)(rect->y1 * 2 * g->scale);
-
- error = xwimp_drag_box(&drag);
- if (error) {
- LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
- }
-
- switch (type) {
- case GDRAGGING_SCROLLBAR:
- /* Dragging a core scrollbar */
- ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
- NULL, g);
- break;
-
- default:
- /* Not handled here yet */
- break;
- }
+ if (g == NULL || g->bw == NULL ||
+ browser_window_has_content(g->bw) == false)
+ return;
- return true;
+ ro_gui_window_prepare_pageinfo(g);
+ ro_gui_dialog_open_persistent(g->window, dialog_pageinfo, false);
}
/**
- * Save the specified content as a link.
+ * Process Mouse_Click events in a toolbar's button bar.
*
- * \param g The window containing the content
- * \param url The url of the link
- * \param title The title of the link
- */
-static nserror
-gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
-{
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
- return NSERROR_OK;
-}
-
-
-/**
- * Updates a windows extent.
+ * This does not handle other clicks in a toolbar: these are handled
+ * by the toolbar module itself.
*
- * \param g the gui_window to update
- * \param width the minimum width, or -1 to use window width
- * \param height the minimum height, or -1 to use window height
+ * \param data The GUI window associated with the click.
+ * \param action_type The action type to be handled.
+ * \param action The action to process.
*/
-
-void gui_window_set_extent(struct gui_window *g, int width, int height)
+static void
+ro_gui_window_toolbar_click(void *data,
+ toolbar_action_type action_type,
+ union toolbar_action action)
{
- int screen_width;
- int toolbar_height = 0;
- wimp_window_state state;
- os_error *error;
-
- if (g->toolbar)
- toolbar_height = ro_toolbar_full_height(g->toolbar);
-
- /* get the current state */
- if ((height == -1) || (width == -1)) {
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
- if (width == -1)
- width = state.visible.x1 - state.visible.x0;
- if (height == -1) {
- height = state.visible.y1 - state.visible.y0;
- height -= toolbar_height;
- }
- }
+ struct gui_window *g = data;
+ nserror err;
- /* the top-level framed window is a total pain. to get it to maximise
- * to the top of the screen we need to fake it having a suitably large
- * extent */
- if (browser_window_is_frameset(g->bw)) {
- ro_gui_screen_size(&screen_width, &height);
- if (g->toolbar)
- height -= ro_toolbar_full_height(g->toolbar);
- height -= ro_get_hscroll_height(g->window);
- height -= ro_get_title_height(g->window);
- }
- if (browser_window_has_content(g->bw)) {
- int w, h;
- browser_window_get_extents(g->bw, true, &w, &h);
- width = max(width, w * 2);
- height = max(height, h * 2);
- }
- os_box extent = { 0, -height, width, toolbar_height };
- error = xwimp_set_extent(g->window, &extent);
- if (error) {
- LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (g == NULL)
return;
- }
-}
-/**
- * Display a menu of options for a form select control.
- *
- * \param g gui window containing form control
- * \param control form control of type GADGET_SELECT
- */
-
-static void gui_window_create_form_select_menu(struct gui_window *g,
- struct form_control *control)
-{
- os_error *error;
- wimp_pointer pointer;
-
- /* The first time the menu is opened, control bypasses the normal
- * Menu Prepare event and so we prepare here. On any re-opens,
- * ro_gui_window_prepare_form_select_menu() is called from the
- * normal wimp event.
- */
-
- if (!ro_gui_window_prepare_form_select_menu(g, control))
- return;
-
- error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- ro_gui_menu_destroy();
- return;
- }
+ if (action_type == TOOLBAR_ACTION_URL) {
+ switch (action.url) {
+ case TOOLBAR_URL_DRAG_URL:
+ {
+ gui_save_type save_type;
+ nserror err;
+ nsurl *url;
- gui_form_select_control = control;
- ro_gui_menu_create(gui_form_select_menu,
- pointer.pos.x, pointer.pos.y, g->window);
-}
+ if (!browser_window_has_content(g->bw))
+ break;
+ if (ro_gui_shift_pressed())
+ save_type = GUI_SAVE_LINK_URL;
+ else
+ save_type = GUI_SAVE_LINK_TEXT;
-/*
- * RISC OS Wimp Event Handlers
- */
+ err = browser_window_get_url(g->bw, true, &url);
+ if (err != NSERROR_OK) {
+ /* Fall back to access (won't get fragment). */
+ url = nsurl_ref(
+ browser_window_access_url(g->bw));
+ }
+ ro_gui_drag_save_link(save_type, url,
+ browser_window_get_title(g->bw), g);
-/**
- * Handle a Redraw_Window_Request for a browser window.
- */
+ nsurl_unref(url);
+ }
+ break;
-void ro_gui_window_redraw(wimp_draw *redraw)
-{
- osbool more;
- struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
- os_error *error;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &ro_plotters
- };
+ case TOOLBAR_URL_SELECT_HOTLIST:
+ ro_gui_window_action_add_bookmark(g);
+ break;
- /* We can't render locked contents. If the browser window is not
- * ready for redraw, do nothing. Else, in the case of buffered
- * rendering we'll show random data. */
- if (!browser_window_redraw_ready(g->bw))
- return;
+ case TOOLBAR_URL_ADJUST_HOTLIST:
+ ro_gui_window_action_remove_bookmark(g);
+ break;
- ro_gui_current_redraw_gui = g;
+ default:
+ break;
+ }
- error = xwimp_redraw_window(redraw, &more);
- if (error) {
- LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
return;
}
- while (more) {
- struct rect clip;
- /* OS's redraw request coordinates are in screen coordinates,
- * with an origin at the bottom left of the screen.
- * Find the coordinate of the top left of the document in terms
- * of OS screen coordinates.
- * NOTE: OS units are 2 per px. */
- ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
- /* Convert OS redraw rectangle request coordinates into NetSurf
- * coordinates. NetSurf coordinates have origin at top left of
- * document and units are in px. */
- clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2; /* left */
- clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2; /* top */
- clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2; /* right */
- clip.y1 = (ro_plot_origin_y - redraw->clip.y0) / 2; /* bottom */
+ /* By now, the only valid action left is a button click. If it isn't
+ * one of those, give up.
+ */
- if (ro_gui_current_redraw_gui->option.buffer_everything)
- ro_gui_buffer_open(redraw);
+ if (action_type != TOOLBAR_ACTION_BUTTON)
+ return;
- browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
+ switch (action.button) {
+ case TOOLBAR_BUTTON_BACK:
+ if (g->bw != NULL)
+ browser_window_history_back(g->bw, false);
+ break;
- if (ro_gui_current_redraw_gui->option.buffer_everything)
- ro_gui_buffer_close();
+ case TOOLBAR_BUTTON_BACK_NEW:
+ if (g->bw != NULL)
+ browser_window_history_back(g->bw, true);
+ break;
- /* Check to see if there are more rectangles to draw and
- * get next one */
- error = xwimp_get_rectangle(redraw, &more);
- /* RISC OS 3.7 returns an error here if enough buffer was
- claimed to cause a new dynamic area to be created. It
- doesn't actually stop anything working, so we mask it out
- for now until a better fix is found. This appears to be a
- bug in RISC OS. */
- if (error && !(ro_gui_current_redraw_gui->
- option.buffer_everything &&
- error->errnum == error_WIMP_GET_RECT)) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- ro_gui_current_redraw_gui = NULL;
- return;
- }
- }
- ro_gui_current_redraw_gui = NULL;
-}
+ case TOOLBAR_BUTTON_FORWARD:
+ if (g->bw != NULL)
+ browser_window_history_forward(g->bw, false);
+ break;
+ case TOOLBAR_BUTTON_FORWARD_NEW:
+ if (g->bw != NULL)
+ browser_window_history_forward(g->bw, true);
+ break;
-/**
- * Set a gui_window's scale
- */
-void ro_gui_window_set_scale(struct gui_window *g, float scale)
-{
- g->scale = scale;
- browser_window_set_scale(g->bw, scale, true);
-}
+ case TOOLBAR_BUTTON_STOP:
+ if (g->bw != NULL)
+ browser_window_stop(g->bw);
+ break;
+ case TOOLBAR_BUTTON_RELOAD:
+ if (g->bw != NULL)
+ browser_window_reload(g->bw, false);
+ break;
-/**
- * Open a window using the given wimp_open, handling toolbars and resizing.
- */
+ case TOOLBAR_BUTTON_RELOAD_ALL:
+ if (g->bw != NULL)
+ browser_window_reload(g->bw, true);
+ break;
-void ro_gui_window_open(wimp_open *open)
-{
- struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
- int width = open->visible.x1 - open->visible.x0;
- int height = open->visible.y1 - open->visible.y0;
- browser_scrolling h_scroll;
- browser_scrolling v_scroll;
- int toolbar_height = 0;
- float new_scale = 0;
- wimp_window_state state;
- os_error *error;
- wimp_w parent;
- bits linkage;
- bool have_content;
+ case TOOLBAR_BUTTON_HISTORY_LOCAL:
+ ro_gui_window_action_local_history(g);
+ break;
- if (open->next == wimp_TOP && g->iconise_icon >= 0) {
- /* window is no longer iconised, release its sprite number */
- iconise_used[g->iconise_icon] = false;
- g->iconise_icon = -1;
- }
+ case TOOLBAR_BUTTON_HISTORY_GLOBAL:
+ ro_gui_global_history_present();
+ break;
- have_content = browser_window_has_content(g->bw);
+ case TOOLBAR_BUTTON_HOME:
+ ro_gui_window_action_home(g);
+ break;
- /* get the current flags/nesting state */
- state.w = g->window;
- error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
+ case TOOLBAR_BUTTON_SEARCH:
+ ro_gui_window_action_search(g);
+ break;
- /* account for toolbar height, if present */
- if (g->toolbar)
- toolbar_height = ro_toolbar_full_height(g->toolbar);
- height -= toolbar_height;
+ case TOOLBAR_BUTTON_SCALE:
+ ro_gui_window_action_zoom(g);
+ break;
- /* work with the state from now on so we can modify flags */
- state.visible = open->visible;
- state.xscroll = open->xscroll;
- state.yscroll = open->yscroll;
- state.next = open->next;
+ case TOOLBAR_BUTTON_BOOKMARK_OPEN:
+ ro_gui_hotlist_present();
+ break;
- browser_window_get_scrollbar_type(g->bw, &h_scroll, &v_scroll);
+ case TOOLBAR_BUTTON_BOOKMARK_ADD:
+ ro_gui_window_action_add_bookmark(g);
+ break;
- /* handle 'auto' scroll bars' and non-fitting scrollbar removal */
- if ((h_scroll != BW_SCROLLING_NO) && (v_scroll != BW_SCROLLING_NO)) {
- int size;
+ case TOOLBAR_BUTTON_SAVE_SOURCE:
+ ro_gui_window_action_save(g, GUI_SAVE_SOURCE);
+ break;
- /* windows lose scrollbars when containing a frameset */
- bool no_hscroll = false;
- bool no_vscroll = browser_window_is_frameset(g->bw);
+ case TOOLBAR_BUTTON_SAVE_COMPLETE:
+ ro_gui_window_action_save(g, GUI_SAVE_COMPLETE);
+ break;
- /* hscroll */
- size = ro_get_hscroll_height(NULL);
- size -= 2; /* 1px border on both sides */
- if (!no_hscroll) {
- if (!(state.flags & wimp_WINDOW_HSCROLL)) {
- height -= size;
- state.visible.y0 += size;
- if (have_content) {
- browser_window_schedule_reformat(g->bw);
- }
- }
- state.flags |= wimp_WINDOW_HSCROLL;
- } else {
- if (state.flags & wimp_WINDOW_HSCROLL) {
- height += size;
- state.visible.y0 -= size;
- if (have_content) {
- browser_window_schedule_reformat(g->bw);
- }
- }
- state.flags &= ~wimp_WINDOW_HSCROLL;
+ case TOOLBAR_BUTTON_PRINT:
+ ro_gui_window_action_print(g);
+ break;
+
+ case TOOLBAR_BUTTON_UP:
+ err = browser_window_navigate_up(g->bw, false);
+ if (err != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(err), NULL);
}
+ break;
- /* vscroll */
- size = ro_get_vscroll_width(NULL);
- size -= 2; /* 1px border on both sides */
- if (!no_vscroll) {
- if (!(state.flags & wimp_WINDOW_VSCROLL)) {
- width -= size;
- state.visible.x1 -= size;
- if (have_content) {
- browser_window_schedule_reformat(g->bw);
- }
- }
- state.flags |= wimp_WINDOW_VSCROLL;
- } else {
- if (state.flags & wimp_WINDOW_VSCROLL) {
- width += size;
- state.visible.x1 += size;
- if (have_content) {
- browser_window_schedule_reformat(g->bw);
- }
- }
- state.flags &= ~wimp_WINDOW_VSCROLL;
+ case TOOLBAR_BUTTON_UP_NEW:
+ err = browser_window_navigate_up(g->bw, true);
+ if (err != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(err), NULL);
}
- }
+ break;
- /* reformat or change extent if necessary */
- if (have_content &&
- (g->old_width != width || g->old_height != height)) {
- /* Ctrl-resize of a top-level window scales the content size */
- if ((g->old_width > 0) && (g->old_width != width) &&
- (ro_gui_ctrl_pressed()))
- new_scale = (g->scale * width) / g->old_width;
- browser_window_schedule_reformat(g->bw);
- }
- if (g->update_extent || g->old_width != width ||
- g->old_height != height) {
- g->old_width = width;
- g->old_height = height;
- g->update_extent = false;
- gui_window_set_extent(g, width, height);
+ default:
+ break;
}
- /* first resize stops any flickering by making the URL window on top */
- ro_gui_url_complete_resize(g->toolbar, PTR_WIMP_OPEN(&state));
+ ro_gui_window_update_toolbar_buttons(g);
+}
- /* Windows containing framesets can only be scrolled via the core, which
- * is implementing frame scrollbars itself. The x and y offsets are
- * therefore fixed.
- */
- if (browser_window_is_frameset(g->bw)) {
- state.xscroll = 0;
- state.yscroll = toolbar_height;
- }
+/**
+ * Launch a new url in the given window.
+ *
+ * \param g gui_window to update
+ * \param url1 url to be launched
+ */
+static void ro_gui_window_launch_url(struct gui_window *g, const char *url1)
+{
+ nserror error;
+ nsurl *url;
- error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
- if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (url1 == NULL)
return;
- }
- /* update the toolbar */
- if (g->status_bar)
- ro_gui_status_bar_resize(g->status_bar);
- if (g->toolbar) {
- ro_toolbar_process(g->toolbar, -1, false);
- /* second resize updates to the new URL bar width */
- ro_gui_url_complete_resize(g->toolbar, open);
- }
+ ro_gui_url_complete_close();
- /* set the new scale from a ctrl-resize. this must be done at the end as
- * it may cause a frameset recalculation based on the new window size.
- */
- if (new_scale > 0) {
- ro_gui_window_set_scale(g, new_scale);
+ error = nsurl_create(url1, &url);
+ if (error != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(error), 0);
+ } else {
+ ro_gui_window_set_url(g, url);
+
+ browser_window_navigate(g->bw, url,
+ NULL, BW_NAVIGATE_HISTORY,
+ NULL, NULL, NULL);
+ nsurl_unref(url);
}
}
/**
- * Handle wimp closing event
+ * Open a new browser window.
+ *
+ * \param g The browser window to act on.
*/
-
-void ro_gui_window_close(wimp_w w)
+static void ro_gui_window_action_new_window(struct gui_window *g)
{
- struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(w);
- wimp_pointer pointer;
- os_error *error;
- char *temp_name;
- char *filename = NULL;
- struct nsurl *url;
- bool destroy;
+ nserror error;
- error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
+ if (g == NULL || g->bw == NULL)
return;
- }
- if (pointer.buttons & wimp_CLICK_ADJUST) {
- destroy = !ro_gui_shift_pressed();
+ error = browser_window_create(BW_CREATE_CLONE,
+ browser_window_access_url(g->bw),
+ NULL, g->bw, NULL);
- url = browser_window_get_url(g->bw);
- if (url != NULL) {
- netsurf_nsurl_to_path(url, &filename);
- }
- if (filename != NULL) {
- temp_name = malloc(strlen(filename) + 32);
- if (temp_name) {
- char *r;
- sprintf(temp_name, "Filer_OpenDir %s",
- filename);
- r = temp_name + strlen(temp_name);
- while (r > temp_name) {
- if (*r == '.') {
- *r = '\0';
- break;
- }
- r--;
- }
- error = xos_cli(temp_name);
- if (error) {
- LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("MiscError", error->errmess);
- return;
- }
- free(temp_name);
- }
- free(filename);
- } else {
- /* this is pointless if we are about to close the
- * window */
- if (!destroy && url != NULL)
- browser_window_navigate_up(g->bw, false);
- }
+ if (error != NSERROR_OK) {
+ ro_warn_user(messages_get_errorcode(error), 0);
}
- else
- destroy = true;
-
- if (destroy)
- browser_window_destroy(g->bw);
}
/**
- * Handle Mouse_Click events in a browser window. This should never see
- * Menu clicks, as these will be routed to the menu handlers.
+ * Scroll a browser window.
+ *
+ * the scroll is either via the core or directly using the normal
+ * Wimp_OpenWindow interface.
+ *
+ * Scroll steps are supplied in terms of the (extended) Scroll Event direction
+ * values returned by Wimp_Poll. Special values of 0x7fffffff and 0x80000000
+ * are added to mean "Home" and "End".
*
- * \param *pointer details of mouse click
- * \return true if click handled, false otherwise
+ * \param g The GUI Window to be scrolled.
+ * \param scroll_x The X scroll step to be applied.
+ * \param scroll_y The Y scroll step to be applied.
*/
-
-bool ro_gui_window_click(wimp_pointer *pointer)
+static void
+ro_gui_window_scroll_action(struct gui_window *g,
+ wimp_scroll_direction scroll_x,
+ wimp_scroll_direction scroll_y)
{
- struct gui_window *g;
- os_coord pos;
+ int visible_x, visible_y;
+ int step_x = 0, step_y = 0;
+ int toolbar_y;
+ wimp_window_state state;
+ wimp_pointer pointer;
+ os_error *error;
+ os_coord pos;
+ bool handled = false;
+ struct toolbar *toolbar;
- /* We should never see Menu clicks. */
+ if (g == NULL)
+ return;
- if (pointer->buttons == wimp_CLICK_MENU)
- return false;
+ /* Get the current window, toolbar and pointer details. */
- g = (struct gui_window *) ro_gui_wimp_event_get_user_data(pointer->w);
+ state.w = g->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
- /* try to close url-completion */
- ro_gui_url_complete_close();
+ toolbar = ro_toolbar_parent_window_lookup(g->window);
+ assert(g == NULL || g->toolbar == NULL || g->toolbar == toolbar);
- /* set input focus */
- if (pointer->buttons & (wimp_SINGLE_SELECT | wimp_SINGLE_ADJUST))
- gui_window_place_caret(g, -100, -100, 0, NULL);
+ toolbar_y = (toolbar == NULL) ? 0 : ro_toolbar_full_height(toolbar);
- if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
- browser_window_mouse_click(g->bw,
- ro_gui_mouse_click_state(pointer->buttons,
- wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x, pos.y);
+ visible_x = state.visible.x1 - state.visible.x0 - 32;
+ visible_y = state.visible.y1 - state.visible.y0 - 32 - toolbar_y;
- return true;
-}
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return;
+ }
+ /* Turn the scroll requirement from Scroll Event codes into coordinates
+ * that the core can understand.
+ */
-/**
- * Process Key_Pressed events in a browser window.
- *
- * \param *key The wimp keypress block for the event.
- * \return true if the event was handled, else false.
- */
+ switch (scroll_x) {
+ case wimp_SCROLL_PAGE_LEFT:
+ step_x = SCROLL_PAGE_DOWN;
+ break;
+ case wimp_SCROLL_AUTO_LEFT:
+ case wimp_SCROLL_COLUMN_LEFT:
+ step_x = -16;
+ break;
+ case wimp_SCROLL_AUTO_RIGHT:
+ case wimp_SCROLL_COLUMN_RIGHT:
+ step_x = 16;
+ break;
+ case wimp_SCROLL_PAGE_RIGHT:
+ step_x = SCROLL_PAGE_UP;
+ break;
+ case 0x80000000:
+ step_x = SCROLL_BOTTOM;
+ break;
+ case 0x7fffffff:
+ step_x = SCROLL_TOP;
+ break;
+ default:
+ step_x = (visible_x * (scroll_x>>2)) >> 2;
+ break;
+ }
-bool ro_gui_window_keypress(wimp_key *key)
-{
- struct gui_window *g;
- uint32_t c = (uint32_t) key->c;
+ switch (scroll_y) {
+ case wimp_SCROLL_PAGE_UP:
+ step_y = SCROLL_PAGE_UP;
+ break;
+ case wimp_SCROLL_AUTO_UP:
+ case wimp_SCROLL_LINE_UP:
+ step_y = -16;
+ break;
+ case wimp_SCROLL_AUTO_DOWN:
+ case wimp_SCROLL_LINE_DOWN:
+ step_y = 16;
+ break;
+ case wimp_SCROLL_PAGE_DOWN:
+ step_y = SCROLL_PAGE_DOWN;
+ break;
+ case 0x80000000:
+ step_y = SCROLL_BOTTOM;
+ break;
+ case 0x7fffffff:
+ step_y = SCROLL_TOP;
+ break;
+ default:
+ step_y = -((visible_y * (scroll_y>>2)) >> 2);
+ break;
+ }
- g = (struct gui_window *) ro_gui_wimp_event_get_user_data(key->w);
- if (g == NULL)
- return false;
+ /* If no scrolling is required, there's no point trying to do any. */
- /* First send the key to the browser window, eg. form fields. */
+ if (step_x == 0 && step_y == 0)
+ return;
- if ((unsigned)c < 0x20 || (0x7f <= c && c <= 0x9f) ||
- (c & IS_WIMP_KEY)) {
- /* Munge control keys into unused control chars */
- /* We can't map onto 1->26 (reserved for ctrl+<qwerty>
- That leaves 27->31 and 128->159 */
- switch (c & ~IS_WIMP_KEY) {
- case wimp_KEY_TAB: c = 9; break;
- case wimp_KEY_SHIFT | wimp_KEY_TAB: c = 11; break;
+ /* If the pointer is over the window being scrolled, then try to get
+ * the core to do the scrolling on the object under the pointer.
+ */
- /* cursor movement keys */
- case wimp_KEY_HOME:
- case wimp_KEY_CONTROL | wimp_KEY_LEFT:
- c = NS_KEY_LINE_START;
+ if (pointer.w == g->window &&
+ ro_gui_window_to_window_pos(g,
+ pointer.pos.x, pointer.pos.y, &pos))
+ handled = browser_window_scroll_at_point(g->bw, pos.x, pos.y,
+ step_x, step_y);
+
+ /* If the core didn't do the scrolling, handle it via the Wimp.
+ * Windows which contain frames can only be scrolled by the core,
+ * because it implements frame scroll bars.
+ */
+
+ if (!handled && (browser_window_is_frameset(g->bw) == false)) {
+ switch (step_x) {
+ case SCROLL_TOP:
+ state.xscroll -= 0x10000000;
break;
- case wimp_KEY_END:
- if (os_version >= RISCOS5)
- c = NS_KEY_LINE_END;
- else
- c = NS_KEY_DELETE_RIGHT;
+ case SCROLL_BOTTOM:
+ state.xscroll += 0x10000000;
break;
- case wimp_KEY_CONTROL | wimp_KEY_RIGHT: c = NS_KEY_LINE_END; break;
- case wimp_KEY_CONTROL | wimp_KEY_UP: c = NS_KEY_TEXT_START; break;
- case wimp_KEY_CONTROL | wimp_KEY_DOWN: c = NS_KEY_TEXT_END; break;
- case wimp_KEY_SHIFT | wimp_KEY_LEFT: c = NS_KEY_WORD_LEFT ; break;
- case wimp_KEY_SHIFT | wimp_KEY_RIGHT: c = NS_KEY_WORD_RIGHT; break;
- case wimp_KEY_SHIFT | wimp_KEY_UP: c = NS_KEY_PAGE_UP; break;
- case wimp_KEY_SHIFT | wimp_KEY_DOWN: c = NS_KEY_PAGE_DOWN; break;
- case wimp_KEY_LEFT: c = NS_KEY_LEFT; break;
- case wimp_KEY_RIGHT: c = NS_KEY_RIGHT; break;
- case wimp_KEY_UP: c = NS_KEY_UP; break;
- case wimp_KEY_DOWN: c = NS_KEY_DOWN; break;
-
- /* editing */
- case wimp_KEY_CONTROL | wimp_KEY_END:
- c = NS_KEY_DELETE_LINE_END;
+ case SCROLL_PAGE_UP:
+ state.xscroll += visible_x;
break;
- case wimp_KEY_DELETE:
- if (ro_gui_ctrl_pressed())
- c = NS_KEY_DELETE_LINE_START;
- else if (os_version < RISCOS5)
- c = NS_KEY_DELETE_LEFT;
+ case SCROLL_PAGE_DOWN:
+ state.xscroll -= visible_x;
break;
+ default:
+ state.xscroll += 2 * step_x;
+ break;
+ }
- case wimp_KEY_F8:
- c = NS_KEY_UNDO;
+ switch (step_y) {
+ case SCROLL_TOP:
+ state.yscroll += 0x10000000;
break;
- case wimp_KEY_F9:
- c = NS_KEY_REDO;
+ case SCROLL_BOTTOM:
+ state.yscroll -= 0x10000000;
+ break;
+ case SCROLL_PAGE_UP:
+ state.yscroll += visible_y;
+ break;
+ case SCROLL_PAGE_DOWN:
+ state.yscroll -= visible_y;
break;
-
default:
+ state.yscroll -= 2 * step_y;
break;
}
- }
- if (!(c & IS_WIMP_KEY)) {
- if (browser_window_key_press(g->bw, c))
- return true;
+ error = xwimp_open_window((wimp_open *) &state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ }
}
-
- return ro_gui_window_handle_local_keypress(g, key, false);
}
/**
- * Callback handler for keypresses within browser window toolbars.
+ * Handle keypresses within the RISC OS GUI
*
- * \param *data Client data, pointing to the GUI Window.
- * \param *key The keypress data.
- * \return true if the keypress was handled; else false.
- */
-
-bool ro_gui_window_toolbar_keypress(void *data, wimp_key *key)
-{
- struct gui_window *g = (struct gui_window *) data;
-
- if (g != NULL)
- return ro_gui_window_handle_local_keypress(g, key, true);
-
- return false;
-}
-
-
-/**
- * Handle keypresses within the RISC OS GUI: this is to be called after the
- * core has been given a chance to act, or on keypresses in the toolbar where
- * the core doesn't get involved.
+ * this is to be called after the core has been given a chance to act,
+ * or on keypresses in the toolbar where the core doesn't get
+ * involved.
*
- * \param *g The gui window to which the keypress applies.
- * \param *key The keypress data.
- * \param is_toolbar true if the keypress is from a toolbar;
- * else false.
- * \return true if the keypress was claimed; else false.
+ * \param *g The gui window to which the keypress applies.
+ * \param *key The keypress data.
+ * \param is_toolbar true if the keypress is from a toolbar else false.
+ * \return true if the keypress was claimed; else false.
*/
-
-bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key,
- bool is_toolbar)
+static bool
+ro_gui_window_handle_local_keypress(struct gui_window *g,
+ wimp_key *key,
+ bool is_toolbar)
{
struct browser_window_features cont;
os_error *ro_error;
@@ -1862,7 +1240,8 @@ bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key,
ro_error = xwimp_get_pointer_info(&pointer);
if (ro_error) {
- LOG("xwimp_get_pointer_info: 0x%x: %s\n", ro_error->errnum, ro_error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s\n",
+ ro_error->errnum, ro_error->errmess);
ro_warn_user("WimpError", ro_error->errmess);
return false;
}
@@ -1983,7 +1362,7 @@ bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key,
/* Toggle display of box outlines. */
browser_window_debug(g->bw, CONTENT_DEBUG_REDRAW);
- gui_window_redraw_window(g);
+ ro_gui_window_invalidate_area(g, NULL);
return true;
case wimp_KEY_RETURN:
@@ -2108,18 +1487,648 @@ bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key,
/**
- * Prepare the browser window menu for (re-)opening
+ * Callback handler for keypresses within browser window toolbars.
+ *
+ * \param data Client data, pointing to the GUI Window.
+ * \param key The keypress data.
+ * \return true if the keypress was handled; else false.
+ */
+static bool ro_gui_window_toolbar_keypress(void *data, wimp_key *key)
+{
+ struct gui_window *g = (struct gui_window *) data;
+
+ if (g != NULL) {
+ return ro_gui_window_handle_local_keypress(g, key, true);
+ }
+
+ return false;
+}
+
+
+/**
+ * Save a new toolbar button configuration
+ *
+ * used as a callback by the toolbar module when a buttonbar edit has
+ * finished.
+ *
+ * \param data void pointer to the window's gui_window struct
+ * \param config pointer to a malloc()'d button config string.
+ */
+static void ro_gui_window_save_toolbar_buttons(void *data, char *config)
+{
+ nsoption_set_charp(toolbar_browser, config);
+ ro_gui_save_options();
+}
+
+
+/**
+ * toolbar callbacks for a browser window.
+ */
+static const struct toolbar_callbacks ro_gui_window_toolbar_callbacks = {
+ ro_gui_window_update_theme,
+ ro_gui_window_update_toolbar,
+ (void (*)(void *)) ro_gui_window_update_toolbar_buttons,
+ ro_gui_window_toolbar_click,
+ ro_gui_window_toolbar_keypress,
+ ro_gui_window_save_toolbar_buttons
+};
+
+
+/**
+ * Handle wimp closing event
+ *
+ * \param w The window handle the event occoured on
+ */
+static void ro_gui_window_close(wimp_w w)
+{
+ struct gui_window *g;
+ wimp_pointer pointer;
+ os_error *error;
+ char *temp_name;
+ char *filename = NULL;
+ struct nsurl *url;
+ bool destroy;
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ g = (struct gui_window *)ro_gui_wimp_event_get_user_data(w);
+
+ if (pointer.buttons & wimp_CLICK_ADJUST) {
+ destroy = !ro_gui_shift_pressed();
+
+ url = browser_window_access_url(g->bw);
+ if (url != NULL) {
+ netsurf_nsurl_to_path(url, &filename);
+ }
+ if (filename != NULL) {
+ temp_name = malloc(strlen(filename) + 32);
+ if (temp_name) {
+ char *r;
+ sprintf(temp_name, "Filer_OpenDir %s",
+ filename);
+ r = temp_name + strlen(temp_name);
+ while (r > temp_name) {
+ if (*r == '.') {
+ *r = '\0';
+ break;
+ }
+ r--;
+ }
+ error = xos_cli(temp_name);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xos_cli: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("MiscError", error->errmess);
+ return;
+ }
+ free(temp_name);
+ }
+ free(filename);
+ } else {
+ /* this is pointless if we are about to close the
+ * window */
+ if (!destroy && url != NULL)
+ browser_window_navigate_up(g->bw, false);
+ }
+ } else {
+ destroy = true;
+ }
+
+ if (destroy) {
+ browser_window_destroy(g->bw);
+ }
+}
+
+
+/**
+ * Handle a Redraw_Window_Request for a browser window.
+ *
+ * \param redraw The redraw event
+ */
+static void ro_gui_window_redraw(wimp_draw *redraw)
+{
+ osbool more;
+ struct gui_window *g;
+ os_error *error;
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
+
+ g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
+
+ /* We cannot render locked contents. If the browser window is not
+ * ready for redraw, do nothing. Else, in the case of buffered
+ * rendering we'll show random data. */
+ if (!browser_window_redraw_ready(g->bw)) {
+ return;
+ }
+
+ ro_gui_current_redraw_gui = g;
+
+ error = xwimp_redraw_window(redraw, &more);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return;
+ }
+ while (more) {
+ struct rect clip;
+
+ /* OS's redraw request coordinates are in screen coordinates,
+ * with an origin at the bottom left of the screen.
+ * Find the coordinate of the top left of the document in terms
+ * of OS screen coordinates.
+ * NOTE: OS units are 2 per px. */
+ ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
+ ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
+
+ /* Convert OS redraw rectangle request coordinates into NetSurf
+ * coordinates. NetSurf coordinates have origin at top left of
+ * document and units are in px. */
+ clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2; /* left */
+ clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2; /* top */
+ clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2; /* right */
+ clip.y1 = (ro_plot_origin_y - redraw->clip.y0) / 2; /* bottom */
+
+ if (ro_gui_current_redraw_gui->option.buffer_everything)
+ ro_gui_buffer_open(redraw);
+
+ browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
+
+ if (ro_gui_current_redraw_gui->option.buffer_everything)
+ ro_gui_buffer_close();
+
+ /* Check to see if there are more rectangles to draw and
+ * get next one */
+ error = xwimp_get_rectangle(redraw, &more);
+ /* RISC OS 3.7 returns an error here if enough buffer was
+ claimed to cause a new dynamic area to be created. It
+ doesn't actually stop anything working, so we mask it out
+ for now until a better fix is found. This appears to be a
+ bug in RISC OS. */
+ if (error && !(ro_gui_current_redraw_gui->
+ option.buffer_everything &&
+ error->errnum == error_WIMP_GET_RECT)) {
+ NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ ro_gui_current_redraw_gui = NULL;
+ return;
+ }
+ }
+ ro_gui_current_redraw_gui = NULL;
+}
+
+
+/**
+ * Process Scroll_Request events in a browser window.
+ *
+ * \param scroll The wimp scroll event data block.
+ */
+static void ro_gui_window_scroll(wimp_scroll *scroll)
+{
+ struct gui_window *g = ro_gui_window_lookup(scroll->w);
+
+ if (g && browser_window_has_content(g->bw) && ro_gui_shift_pressed()) {
+ /* extended scroll request with shift held down; change zoom */
+ float scale, inc;
+
+ if (scroll->ymin & 3)
+ inc = 0.02; /* RO5 sends the msg 5 times;
+ * don't ask me why
+ *
+ * @todo this is liable to break if
+ * HID is configured optimally for
+ * frame scrolling. *5 appears to be
+ * an artifact of non-HID mode scrolling.
+ */
+ else
+ inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
+
+ if (scroll->ymin > 0) {
+ scale = g->scale + inc;
+ if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
+ scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
+ } else {
+ scale = g->scale - inc;
+ if (scale < scale_snap_to[0])
+ scale = scale_snap_to[0];
+ }
+ if (g->scale != scale)
+ ro_gui_window_set_scale(g, scale);
+ } else if (g != NULL) {
+ ro_gui_window_scroll_action(g, scroll->xmin, scroll->ymin);
+ }
+}
+
+
+/**
+ * Process Pointer Leaving Window events in a browser window.
+ *
+ * These arrive via the termination callback handler from ro_mouse's
+ * mouse tracking.
+ *
+ * \param leaving The wimp pointer leaving event data block.
+ * \param data The GUI window that the pointer is leaving.
+ */
+static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
+{
+ struct gui_window *g = (struct gui_window *)data;
+
+ if (g != NULL) {
+ gui_window_set_pointer(g, GUI_POINTER_DEFAULT);
+ }
+}
+
+
+/**
+ * Process Pointer Entering Window events in a browser window.
+ *
+ * \param entering The wimp pointer entering event data block.
+ */
+static void ro_gui_window_pointer_entering(wimp_entering *entering)
+{
+ struct gui_window *g = ro_gui_window_lookup(entering->w);
+
+ if (g != NULL) {
+ ro_mouse_track_start(ro_gui_window_track_end,
+ ro_gui_window_mouse_at,
+ g);
+ }
+}
+
+
+/**
+ * Process Key_Pressed events in a browser window.
+ *
+ * \param key The wimp keypress block for the event.
+ * \return true if the event was handled, else false.
+ */
+static bool ro_gui_window_keypress(wimp_key *key)
+{
+ struct gui_window *g;
+ uint32_t c = (uint32_t) key->c;
+
+ g = (struct gui_window *) ro_gui_wimp_event_get_user_data(key->w);
+ if (g == NULL) {
+ return false;
+ }
+
+ /* First send the key to the browser window, eg. form fields. */
+
+ if ((unsigned)c < 0x20 ||
+ (0x7f <= c && c <= 0x9f) ||
+ (c & IS_WIMP_KEY)) {
+ /* Munge control keys into unused control chars */
+ /* We can't map onto 1->26 (reserved for ctrl+<qwerty>
+ That leaves 27->31 and 128->159 */
+ switch (c & ~IS_WIMP_KEY) {
+ case wimp_KEY_TAB:
+ c = 9;
+ break;
+
+ case wimp_KEY_SHIFT | wimp_KEY_TAB:
+ c = 11;
+ break;
+
+ /* cursor movement keys */
+ case wimp_KEY_HOME:
+ case wimp_KEY_CONTROL | wimp_KEY_LEFT:
+ c = NS_KEY_LINE_START;
+ break;
+
+ case wimp_KEY_END:
+ if (os_version >= RISCOS5) {
+ c = NS_KEY_LINE_END;
+ } else {
+ c = NS_KEY_DELETE_RIGHT;
+ }
+ break;
+
+ case wimp_KEY_CONTROL | wimp_KEY_RIGHT:
+ c = NS_KEY_LINE_END;
+ break;
+
+ case wimp_KEY_CONTROL | wimp_KEY_UP:
+ c = NS_KEY_TEXT_START;
+ break;
+
+ case wimp_KEY_CONTROL | wimp_KEY_DOWN:
+ c = NS_KEY_TEXT_END;
+ break;
+
+ case wimp_KEY_SHIFT | wimp_KEY_LEFT:
+ c = NS_KEY_WORD_LEFT ;
+ break;
+
+ case wimp_KEY_SHIFT | wimp_KEY_RIGHT:
+ c = NS_KEY_WORD_RIGHT;
+ break;
+
+ case wimp_KEY_SHIFT | wimp_KEY_UP:
+ c = NS_KEY_PAGE_UP;
+ break;
+
+ case wimp_KEY_SHIFT | wimp_KEY_DOWN:
+ c = NS_KEY_PAGE_DOWN;
+ break;
+
+ case wimp_KEY_LEFT:
+ c = NS_KEY_LEFT;
+ break;
+
+ case wimp_KEY_RIGHT:
+ c = NS_KEY_RIGHT;
+ break;
+
+ case wimp_KEY_UP:
+ c = NS_KEY_UP;
+ break;
+
+ case wimp_KEY_DOWN:
+ c = NS_KEY_DOWN;
+ break;
+
+ /* editing */
+ case wimp_KEY_CONTROL | wimp_KEY_END:
+ c = NS_KEY_DELETE_LINE_END;
+ break;
+
+ case wimp_KEY_DELETE:
+ if (ro_gui_ctrl_pressed()) {
+ c = NS_KEY_DELETE_LINE_START;
+ } else if (os_version < RISCOS5) {
+ c = NS_KEY_DELETE_LEFT;
+ }
+ break;
+
+ case wimp_KEY_F8:
+ c = NS_KEY_UNDO;
+ break;
+
+ case wimp_KEY_F9:
+ c = NS_KEY_REDO;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (!(c & IS_WIMP_KEY)) {
+ if (browser_window_key_press(g->bw, c)) {
+ return true;
+ }
+ }
+
+ return ro_gui_window_handle_local_keypress(g, key, false);
+}
+
+
+/**
+ * Handle Mouse_Click events in a browser window.
+ *
+ * This should never see Menu clicks, as these will be routed to the
+ * menu handlers.
+ *
+ * \param pointer details of mouse click
+ * \return true if click handled, false otherwise
+ */
+static bool ro_gui_window_click(wimp_pointer *pointer)
+{
+ struct gui_window *g;
+ os_coord pos;
+
+ /* We should never see Menu clicks. */
+
+ if (pointer->buttons == wimp_CLICK_MENU) {
+ return false;
+ }
+
+ g = (struct gui_window *) ro_gui_wimp_event_get_user_data(pointer->w);
+
+ /* try to close url-completion */
+ ro_gui_url_complete_close();
+
+ /* set input focus */
+ if (pointer->buttons & (wimp_SINGLE_SELECT | wimp_SINGLE_ADJUST))
+ gui_window_place_caret(g, -100, -100, 0, NULL);
+
+ if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos)) {
+ browser_window_mouse_click(g->bw,
+ ro_gui_mouse_click_state(pointer->buttons,
+ wimp_BUTTON_DOUBLE_CLICK_DRAG),
+ pos.x, pos.y);
+ }
+
+ return true;
+}
+
+
+/**
+ * Prepare or reprepare a form select menu
+ *
+ * setting up the menu handle globals in the process.
+ *
+ * \param g The RISC OS gui window the menu is in.
+ * \param control The form control needing a menu.
+ * \return true if the menu is OK to be opened; else false.
+ */
+static bool
+ro_gui_window_prepare_form_select_menu(struct gui_window *g,
+ struct form_control *control)
+{
+ unsigned int item, entries;
+ char *text_convert, *temp;
+ struct form_option *option;
+ bool reopen = true;
+ nserror err;
+
+ assert(control);
+
+ /* enumerate the entries */
+ entries = 0;
+ option = form_select_get_option(control, entries);
+ while (option != NULL) {
+ entries++;
+ option = form_select_get_option(control, entries);
+ }
+
+ if (entries == 0) {
+ /* no menu to display */
+ ro_gui_menu_destroy();
+ return false;
+ }
+
+ /* free riscos menu if there already is one */
+ if ((gui_form_select_menu) && (control != gui_form_select_control)) {
+ for (item = 0; ; item++) {
+ free(gui_form_select_menu->entries[item].data.
+ indirected_text.text);
+ if (gui_form_select_menu->entries[item].menu_flags &
+ wimp_MENU_LAST)
+ break;
+ }
+ free(gui_form_select_menu->title_data.indirected_text.text);
+ free(gui_form_select_menu);
+ gui_form_select_menu = 0;
+ }
+
+ /* allocate new riscos menu */
+ if (!gui_form_select_menu) {
+ reopen = false;
+ gui_form_select_menu = malloc(wimp_SIZEOF_MENU(entries));
+ if (!gui_form_select_menu) {
+ ro_warn_user("NoMemory", 0);
+ ro_gui_menu_destroy();
+ return false;
+ }
+ err = utf8_to_local_encoding(messages_get("SelectMenu"), 0,
+ &text_convert);
+ if (err != NSERROR_OK) {
+ /* badenc should never happen */
+ assert(err != NSERROR_BAD_ENCODING);
+ NSLOG(netsurf, INFO, "utf8_to_local_encoding failed");
+ ro_warn_user("NoMemory", 0);
+ ro_gui_menu_destroy();
+ return false;
+ }
+ gui_form_select_menu->title_data.indirected_text.text =
+ text_convert;
+ ro_gui_menu_init_structure(gui_form_select_menu, entries);
+ }
+
+ /* initialise menu entries from form control */
+ for (item = 0; item < entries; item++) {
+ option = form_select_get_option(control, item);
+ gui_form_select_menu->entries[item].menu_flags = 0;
+ if (option->selected)
+ gui_form_select_menu->entries[item].menu_flags =
+ wimp_MENU_TICKED;
+ if (!reopen) {
+
+ /* convert spaces to hard spaces to stop things
+ * like 'Go Home' being treated as if 'Home' is a
+ * keyboard shortcut and right aligned in the menu.
+ */
+
+ temp = cnv_space2nbsp(option->text);
+ if (!temp) {
+ NSLOG(netsurf, INFO, "cnv_space2nbsp failed");
+ ro_warn_user("NoMemory", 0);
+ ro_gui_menu_destroy();
+ return false;
+ }
+
+ err = utf8_to_local_encoding(temp,
+ 0, &text_convert);
+ if (err != NSERROR_OK) {
+ /* A bad encoding should never happen,
+ * so assert this */
+ assert(err != NSERROR_BAD_ENCODING);
+ NSLOG(netsurf, INFO, "utf8_to_enc failed");
+ ro_warn_user("NoMemory", 0);
+ ro_gui_menu_destroy();
+ return false;
+ }
+
+ free(temp);
+
+ gui_form_select_menu->entries[item].data.indirected_text.text =
+ text_convert;
+ gui_form_select_menu->entries[item].data.indirected_text.size =
+ strlen(gui_form_select_menu->entries[item].
+ data.indirected_text.text) + 1;
+ }
+ }
+
+ gui_form_select_menu->entries[0].menu_flags |=
+ wimp_MENU_TITLE_INDIRECTED;
+ gui_form_select_menu->entries[item - 1].menu_flags |= wimp_MENU_LAST;
+
+ return true;
+}
+
+
+/**
+ * Return boolean flags to show what RISC OS types we can sensibly convert
+ * the given object into.
+ *
+ * \todo This should probably be somewhere else but in window.c, and
+ * should probably even be done in content_().
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu about to be opened.
- * \param *pointer Pointer to the relevant wimp event block, or
- * NULL for an Adjust click.
- * \return true if the event was handled; else false.
+ * \param h The object to test.
+ * \param export_draw true on exit if a drawfile would be possible.
+ * \param export_sprite true on exit if a sprite would be possible.
+ * \return true if valid data is returned; else false.
*/
+static bool
+ro_gui_window_content_export_types(struct hlcache_handle *h,
+ bool *export_draw,
+ bool *export_sprite)
+{
+ bool found_type = false;
-bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_pointer *pointer)
+ if (export_draw != NULL) {
+ *export_draw = false;
+ }
+ if (export_sprite != NULL) {
+ *export_sprite = false;
+ }
+
+ if (h != NULL && content_get_type(h) == CONTENT_IMAGE) {
+ switch (ro_content_native_type(h)) {
+ case osfile_TYPE_SPRITE:
+ /* bitmap types (Sprite export possible) */
+ found_type = true;
+ if (export_sprite != NULL) {
+ *export_sprite = true;
+ }
+ break;
+
+ case osfile_TYPE_DRAW:
+ /* vector types (Draw export possible) */
+ found_type = true;
+ if (export_draw != NULL) {
+ *export_draw = true;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return found_type;
+}
+
+
+/**
+ * Prepare the browser window menu for (re-)opening
+ *
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu about to be opened.
+ * \param pointer Pointer to the relevant wimp event block, or
+ * NULL for an Adjust click.
+ * \return true if the event was handled; else false.
+ */
+static bool
+ro_gui_window_menu_prepare(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_pointer *pointer)
{
struct gui_window *g;
struct browser_window *bw;
@@ -2144,13 +2153,13 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
gui_form_select_control);
}
- if (menu != ro_gui_browser_window_menu)
+ if (menu != ro_gui_browser_window_menu) {
return false;
+ }
/* If this is a new opening for the browser window menu (ie. not for a
* toolbar menu), get details of the object under the pointer.
*/
-
if (pointer != NULL && g->window == w) {
ro_gui_url_complete_close();
@@ -2261,13 +2270,14 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_menu_set_entry_shaded(menu, BROWSER_OBJECT_SAVE_URL_TEXT,
current_menu_object == NULL);
- if (current_menu_object != NULL)
+ if (current_menu_object != NULL) {
ro_gui_window_content_export_types(current_menu_object,
&export_draw, &export_sprite);
- else
+ } else {
ro_gui_window_content_export_types(
browser_window_get_content(bw),
&export_draw, &export_sprite);
+ }
ro_gui_menu_set_entry_shaded(menu, BROWSER_OBJECT_EXPORT,
(!have_content && current_menu_object == NULL)
@@ -2325,14 +2335,15 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
/* View Submenu */
ro_gui_menu_set_entry_ticked(menu, BROWSER_IMAGES_FOREGROUND,
- g != NULL && nsoption_bool(foreground_images));
+ g != NULL && nsoption_bool(foreground_images));
ro_gui_menu_set_entry_ticked(menu, BROWSER_IMAGES_BACKGROUND,
- g != NULL && nsoption_bool(background_images));
+ g != NULL && nsoption_bool(background_images));
ro_gui_menu_set_entry_shaded(menu, BROWSER_BUFFER_ANIMS,
g == NULL || g->option.buffer_everything);
- ro_gui_menu_set_entry_ticked(menu, BROWSER_BUFFER_ANIMS, g != NULL &&
+ ro_gui_menu_set_entry_ticked(menu, BROWSER_BUFFER_ANIMS,
+ g != NULL &&
(g->option.buffer_animations ||
g->option.buffer_everything));
@@ -2343,16 +2354,16 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_menu_set_entry_shaded(menu, BROWSER_SCALE_VIEW, !have_content);
ro_gui_menu_set_entry_shaded(menu, BROWSER_WINDOW_STAGGER,
- nsoption_int(window_screen_width) == 0);
+ nsoption_int(window_screen_width) == 0);
ro_gui_menu_set_entry_ticked(menu, BROWSER_WINDOW_STAGGER,
- ((nsoption_int(window_screen_width) == 0) ||
- nsoption_bool(window_stagger)));
+ ((nsoption_int(window_screen_width) == 0) ||
+ nsoption_bool(window_stagger)));
ro_gui_menu_set_entry_ticked(menu, BROWSER_WINDOW_COPY,
- nsoption_bool(window_size_clone));
+ nsoption_bool(window_size_clone));
ro_gui_menu_set_entry_shaded(menu, BROWSER_WINDOW_RESET,
- nsoption_int(window_screen_width) == 0);
+ nsoption_int(window_screen_width) == 0);
/* Utilities Submenu */
@@ -2376,199 +2387,72 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
/**
- * Handle submenu warnings for a browser window menu
+ * Process selections from a form select menu, passing them back to the core.
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu to which the warning applies.
- * \param *selection The wimp menu selection data.
- * \param action The selected menu action.
+ * \param g The browser window affected by the menu.
+ * \param selection The menu selection.
*/
-
-void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action)
+static void
+ro_gui_window_process_form_select_menu(struct gui_window *g,
+ wimp_selection *selection)
{
- struct gui_window *g;
- struct hlcache_handle *h;
- bool export;
-
- if (menu != ro_gui_browser_window_menu)
- return;
-
- g = (struct gui_window *) ro_gui_wimp_event_get_user_data(w);
- h = browser_window_get_content(g->bw);
-
- switch (action) {
- case BROWSER_PAGE_INFO:
- if (h != NULL)
- ro_gui_window_prepare_pageinfo(g);
- break;
-
- case BROWSER_FIND_TEXT:
- if (h != NULL && (content_get_type(h) == CONTENT_HTML ||
- content_get_type(h) == CONTENT_TEXTPLAIN))
- ro_gui_search_prepare(g->bw);
- break;
-
- case BROWSER_SCALE_VIEW:
- if (h != NULL)
- ro_gui_dialog_prepare_zoom(g);
- break;
-
- case BROWSER_PRINT:
- if (h != NULL)
- ro_gui_print_prepare(g);
- break;
-
- case BROWSER_OBJECT_INFO:
- if (current_menu_object != NULL)
- ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
- break;
-
- case BROWSER_OBJECT_SAVE:
- if (current_menu_object != NULL)
- ro_gui_save_prepare(GUI_SAVE_OBJECT_ORIG,
- current_menu_object, NULL, NULL, NULL);
- break;
-
- case BROWSER_SELECTION_SAVE:
- if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY)
- ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION, NULL,
- browser_window_get_selection(g->bw),
- NULL, NULL);
- break;
-
- case BROWSER_SAVE_URL_URI:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- hlcache_handle_get_url(h),
- content_get_title(h));
- break;
-
- case BROWSER_SAVE_URL_URL:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- hlcache_handle_get_url(h),
- content_get_title(h));
- break;
-
- case BROWSER_SAVE_URL_TEXT:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- hlcache_handle_get_url(h),
- content_get_title(h));
- break;
-
- case BROWSER_OBJECT_SAVE_URL_URI:
- if (current_menu_object != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- hlcache_handle_get_url(
- current_menu_object),
- content_get_title(current_menu_object));
- break;
-
- case BROWSER_OBJECT_SAVE_URL_URL:
- if (current_menu_object != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- hlcache_handle_get_url(
- current_menu_object),
- content_get_title(current_menu_object));
- break;
-
- case BROWSER_OBJECT_SAVE_URL_TEXT:
- if (current_menu_object != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- hlcache_handle_get_url(
- current_menu_object),
- content_get_title(current_menu_object));
- break;
-
- case BROWSER_SAVE:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_SOURCE, h, NULL, NULL, NULL);
- break;
-
- case BROWSER_SAVE_COMPLETE:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_COMPLETE, h, NULL, NULL, NULL);
- break;
-
- case BROWSER_EXPORT_DRAW:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_DRAW, h, NULL, NULL, NULL);
- break;
-
- case BROWSER_EXPORT_PDF:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_PDF, h, NULL, NULL, NULL);
- break;
-
- case BROWSER_EXPORT_TEXT:
- if (h != NULL)
- ro_gui_save_prepare(GUI_SAVE_TEXT, h, NULL, NULL, NULL);
- break;
-
- case BROWSER_LINK_SAVE_URI:
- if (current_menu_url != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- current_menu_url, NULL);
- break;
-
- case BROWSER_LINK_SAVE_URL:
- if (current_menu_url != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- current_menu_url, NULL);
- break;
+ assert(g != NULL);
- case BROWSER_LINK_SAVE_TEXT:
- if (current_menu_url != NULL)
- ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- current_menu_url, NULL);
- break;
+ if (selection->items[0] >= 0) {
+ form_select_process_selection(gui_form_select_control,
+ selection->items[0]);
+ }
+}
- case BROWSER_OBJECT_EXPORT_SPRITE:
- if (current_menu_object != NULL) {
- ro_gui_window_content_export_types(current_menu_object,
- NULL, &export);
- if (export)
- ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- current_menu_object,
- NULL, NULL, NULL);
- } else if (h != NULL) {
- ro_gui_window_content_export_types(h, NULL, &export);
+/**
+ * Prepare the object info window for use
+ *
+ * \param object the object for which information is to be displayed
+ * \param target_url corresponding url, if any
+ */
+static void
+ro_gui_window_prepare_objectinfo(struct hlcache_handle *object,
+ nsurl *target_url)
+{
+ char icon_buf[20] = "file_xxx";
+ const char *url;
+ lwc_string *mime;
+ const char *target = "-";
- if (export)
- ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- h, NULL, NULL, NULL);
- }
- break;
+ sprintf(icon_buf, "file_%.3x",ro_content_filetype(object));
+ if (!ro_gui_wimp_sprite_exists(icon_buf)) {
+ sprintf(icon_buf, "file_xxx");
+ }
- case BROWSER_OBJECT_EXPORT_DRAW:
- if (current_menu_object != NULL) {
- ro_gui_window_content_export_types(current_menu_object,
- &export, NULL);
+ url = nsurl_access(hlcache_handle_get_url(object));
+ if (url == NULL) {
+ url = "-";
+ }
+ mime = content_get_mime_type(object);
- if (export)
- ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- current_menu_object,
- NULL, NULL, NULL);
- } else if (h != NULL) {
- ro_gui_window_content_export_types(h, &export, NULL);
+ if (target_url != NULL) {
+ target = nsurl_access(target_url);
+ }
- if (export)
- ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- h, NULL, NULL, NULL);
- }
- break;
+ ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_ICON,
+ icon_buf, true);
+ ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_URL,
+ url, true);
+ ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TARGET,
+ target, true);
+ ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TYPE,
+ lwc_string_data(mime), true);
- default:
- break;
- }
+ lwc_string_unref(mime);
}
+/**
+ * callback to handle window paste operation
+ *
+ * \param pw context containing browser window
+ */
static void ro_gui_window_paste_cb(void *pw)
{
struct browser_window *bw = pw;
@@ -2580,22 +2464,25 @@ static void ro_gui_window_paste_cb(void *pw)
/**
* Handle selections from a browser window menu
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu from which the selection was made.
- * \param *selection The wimp menu selection data.
- * \param action The selected menu action.
- * \return true if action accepted; else false.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu from which the selection was made.
+ * \param selection The wimp menu selection data.
+ * \param action The selected menu action.
+ * \return true if action accepted; else false.
*/
-
-bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action)
+static bool
+ro_gui_window_menu_select(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_selection *selection,
+ menu_action action)
{
- struct gui_window *g;
- struct browser_window *bw;
- struct hlcache_handle *h;
- struct toolbar *toolbar;
- wimp_window_state state;
+ struct gui_window *g;
+ struct browser_window *bw;
+ struct hlcache_handle *h;
+ struct toolbar *toolbar;
+ wimp_window_state state;
nsurl *url;
nserror error = NSERROR_OK;
@@ -2607,7 +2494,6 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
/* If this is a form menu from the core, handle it now and then exit.
* Otherwise, carry on to the main browser window menu.
*/
-
if (menu == gui_form_select_menu && w == g->window) {
ro_gui_window_process_form_select_menu(g, selection);
@@ -2625,10 +2511,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
+ url,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
break;
@@ -2637,10 +2523,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = nsurl_create("http://www.netsurf-browser.org/documentation/guide", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
+ url,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
break;
@@ -2649,10 +2535,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = nsurl_create("http://www.netsurf-browser.org/documentation/info", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
+ url,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
break;
@@ -2661,10 +2547,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = nsurl_create("about:credits", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
+ url,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
break;
@@ -2673,10 +2559,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = nsurl_create("about:licence", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
+ url,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
break;
@@ -2686,7 +2572,8 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_interactive_help_start();
nsoption_set_bool(interactive_help, true);
} else {
- nsoption_set_bool(interactive_help, !nsoption_bool(interactive_help));
+ nsoption_set_bool(interactive_help,
+ !nsoption_bool(interactive_help));
}
break;
@@ -2738,9 +2625,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_INFO:
if (current_menu_object != NULL) {
ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
+ current_menu_url);
ro_gui_dialog_open_persistent(g->window,
- dialog_objinfo, false);
+ dialog_objinfo,
+ false);
}
break;
case BROWSER_OBJECT_RELOAD:
@@ -2753,50 +2641,62 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
/* link actions */
case BROWSER_LINK_SAVE_URI:
if (current_menu_url != NULL) {
- ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- current_menu_url, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ ro_gui_save_prepare(GUI_SAVE_LINK_URI,
+ NULL,
+ NULL,
+ current_menu_url,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
case BROWSER_LINK_SAVE_URL:
if (current_menu_url != NULL) {
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- current_menu_url, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL,
+ NULL,
+ NULL,
+ current_menu_url,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
case BROWSER_LINK_SAVE_TEXT:
if (current_menu_url != NULL) {
- ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- current_menu_url, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ ro_gui_save_prepare(GUI_SAVE_LINK_TEXT,
+ NULL,
+ NULL,
+ current_menu_url,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
case BROWSER_LINK_DOWNLOAD:
if (current_menu_url != NULL) {
- error = browser_window_navigate(bw,
- current_menu_url,
- browser_window_get_url(bw),
- BW_NAVIGATE_DOWNLOAD,
- NULL,
- NULL,
- NULL);
+ error = browser_window_navigate(
+ bw,
+ current_menu_url,
+ browser_window_access_url(bw),
+ BW_NAVIGATE_DOWNLOAD,
+ NULL,
+ NULL,
+ NULL);
}
break;
case BROWSER_LINK_NEW_WINDOW:
if (current_menu_url != NULL) {
error = browser_window_create(
- BW_CREATE_HISTORY |
- BW_CREATE_CLONE,
- current_menu_url,
- browser_window_get_url(bw),
- bw,
- NULL);
+ BW_CREATE_HISTORY | BW_CREATE_CLONE,
+ current_menu_url,
+ browser_window_access_url(bw),
+ bw,
+ NULL);
}
break;
@@ -2805,24 +2705,36 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_SAVE:
if (current_menu_object != NULL) {
ro_gui_save_prepare(GUI_SAVE_OBJECT_ORIG,
- current_menu_object, NULL, NULL, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ current_menu_object,
+ NULL,
+ NULL,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
case BROWSER_OBJECT_EXPORT_SPRITE:
if (current_menu_object != NULL) {
ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- current_menu_object, NULL, NULL, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ current_menu_object,
+ NULL,
+ NULL,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
case BROWSER_OBJECT_EXPORT_DRAW:
if (current_menu_object != NULL) {
ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
- current_menu_object, NULL, NULL, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ current_menu_object,
+ NULL,
+ NULL,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
@@ -2854,10 +2766,13 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
/* selection actions */
case BROWSER_SELECTION_SAVE:
if (h != NULL) {
- ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION, NULL,
+ ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION,
+ NULL,
browser_window_get_selection(bw),
- NULL, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas,
+ NULL,
+ NULL);
+ ro_gui_dialog_open_persistent(g->window,
+ dialog_saveas,
false);
}
break;
@@ -2944,7 +2859,10 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
state.w = w;
oserror = xwimp_get_window_state(&state);
if (oserror) {
- LOG("xwimp_get_window_state: 0x%x: %s", oserror->errnum, oserror->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ oserror->errnum,
+ oserror->errmess);
ro_warn_user("WimpError", oserror->errmess);
}
nsoption_set_int(window_x, state.visible.x0);
@@ -2976,19 +2894,19 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case TOOLBAR_BUTTONS:
assert(toolbar);
ro_toolbar_set_display_buttons(toolbar,
- !ro_toolbar_get_display_buttons(toolbar));
+ !ro_toolbar_get_display_buttons(toolbar));
break;
case TOOLBAR_ADDRESS_BAR:
assert(toolbar);
ro_toolbar_set_display_url(toolbar,
- !ro_toolbar_get_display_url(toolbar));
+ !ro_toolbar_get_display_url(toolbar));
if (ro_toolbar_get_display_url(toolbar))
ro_toolbar_take_caret(toolbar);
break;
case TOOLBAR_THROBBER:
assert(toolbar);
ro_toolbar_set_display_throbber(toolbar,
- !ro_toolbar_get_display_throbber(toolbar));
+ !ro_toolbar_get_display_throbber(toolbar));
break;
case TOOLBAR_EDIT:
assert(toolbar);
@@ -3008,467 +2926,881 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
/**
- * Handle the closure of a browser window menu
+ * Handle submenu warnings for a browser window menu
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu that is being closed.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu to which the warning applies.
+ * \param selection The wimp menu selection data.
+ * \param action The selected menu action.
*/
-
-void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
+static void
+ro_gui_window_menu_warning(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_selection *selection,
+ menu_action action)
{
- if (menu == ro_gui_browser_window_menu) {
- current_menu_object = NULL;
- current_menu_url = NULL;
- } else if (menu == gui_form_select_menu) {
- gui_form_select_control = NULL;
+ struct gui_window *g;
+ struct hlcache_handle *h;
+ bool export;
+
+ if (menu != ro_gui_browser_window_menu) {
+ return;
}
-}
+ g = (struct gui_window *) ro_gui_wimp_event_get_user_data(w);
+ h = browser_window_get_content(g->bw);
-/**
- * Process Scroll_Request events in a browser window.
- *
- * \param *scroll The wimp scroll event data block.
- */
+ switch (action) {
+ case BROWSER_PAGE_INFO:
+ if (h != NULL) {
+ ro_gui_window_prepare_pageinfo(g);
+ }
+ break;
-void ro_gui_window_scroll(wimp_scroll *scroll)
-{
- struct gui_window *g = ro_gui_window_lookup(scroll->w);
+ case BROWSER_FIND_TEXT:
+ if (h != NULL &&
+ (content_get_type(h) == CONTENT_HTML ||
+ content_get_type(h) == CONTENT_TEXTPLAIN)) {
+ ro_gui_search_prepare(g->bw);
+ }
+ break;
- if (g && browser_window_has_content(g->bw) && ro_gui_shift_pressed()) {
- /* extended scroll request with shift held down; change zoom */
- float scale, inc;
+ case BROWSER_SCALE_VIEW:
+ if (h != NULL) {
+ ro_gui_dialog_prepare_zoom(g);
+ }
+ break;
- if (scroll->ymin & 3)
- inc = 0.02; /* RO5 sends the msg 5 times;
- * don't ask me why
- *
- * @todo this is liable to break if
- * HID is configured optimally for
- * frame scrolling. *5 appears to be
- * an artifact of non-HID mode scrolling.
- */
- else
- inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
+ case BROWSER_PRINT:
+ if (h != NULL) {
+ ro_gui_print_prepare(g);
+ }
+ break;
- if (scroll->ymin > 0) {
- scale = g->scale + inc;
- if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
- scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
- } else {
- scale = g->scale - inc;
- if (scale < scale_snap_to[0])
- scale = scale_snap_to[0];
+ case BROWSER_OBJECT_INFO:
+ if (current_menu_object != NULL) {
+ ro_gui_window_prepare_objectinfo(current_menu_object,
+ current_menu_url);
}
- if (g->scale != scale)
- ro_gui_window_set_scale(g, scale);
- } else if (g != NULL) {
- ro_gui_window_scroll_action(g, scroll->xmin, scroll->ymin);
+ break;
+
+ case BROWSER_OBJECT_SAVE:
+ if (current_menu_object != NULL) {
+ ro_gui_save_prepare(GUI_SAVE_OBJECT_ORIG,
+ current_menu_object,
+ NULL,
+ NULL,
+ NULL);
+ }
+ break;
+
+ case BROWSER_SELECTION_SAVE:
+ if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY)
+ ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION, NULL,
+ browser_window_get_selection(g->bw),
+ NULL, NULL);
+ break;
+
+ case BROWSER_SAVE_URL_URI:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
+ hlcache_handle_get_url(h),
+ content_get_title(h));
+ break;
+
+ case BROWSER_SAVE_URL_URL:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
+ hlcache_handle_get_url(h),
+ content_get_title(h));
+ break;
+
+ case BROWSER_SAVE_URL_TEXT:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
+ hlcache_handle_get_url(h),
+ content_get_title(h));
+ break;
+
+ case BROWSER_OBJECT_SAVE_URL_URI:
+ if (current_menu_object != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
+ hlcache_handle_get_url(
+ current_menu_object),
+ content_get_title(current_menu_object));
+ break;
+
+ case BROWSER_OBJECT_SAVE_URL_URL:
+ if (current_menu_object != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
+ hlcache_handle_get_url(
+ current_menu_object),
+ content_get_title(current_menu_object));
+ break;
+
+ case BROWSER_OBJECT_SAVE_URL_TEXT:
+ if (current_menu_object != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
+ hlcache_handle_get_url(
+ current_menu_object),
+ content_get_title(current_menu_object));
+ break;
+
+ case BROWSER_SAVE:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_SOURCE, h, NULL, NULL, NULL);
+ break;
+
+ case BROWSER_SAVE_COMPLETE:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_COMPLETE, h, NULL, NULL, NULL);
+ break;
+
+ case BROWSER_EXPORT_DRAW:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_DRAW, h, NULL, NULL, NULL);
+ break;
+
+ case BROWSER_EXPORT_PDF:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_PDF, h, NULL, NULL, NULL);
+ break;
+
+ case BROWSER_EXPORT_TEXT:
+ if (h != NULL)
+ ro_gui_save_prepare(GUI_SAVE_TEXT, h, NULL, NULL, NULL);
+ break;
+
+ case BROWSER_LINK_SAVE_URI:
+ if (current_menu_url != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
+ current_menu_url, NULL);
+ break;
+
+ case BROWSER_LINK_SAVE_URL:
+ if (current_menu_url != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
+ current_menu_url, NULL);
+ break;
+
+ case BROWSER_LINK_SAVE_TEXT:
+ if (current_menu_url != NULL)
+ ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
+ current_menu_url, NULL);
+ break;
+
+ case BROWSER_OBJECT_EXPORT_SPRITE:
+ if (current_menu_object != NULL) {
+ ro_gui_window_content_export_types(current_menu_object,
+ NULL, &export);
+
+ if (export)
+ ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
+ current_menu_object,
+ NULL, NULL, NULL);
+ } else if (h != NULL) {
+ ro_gui_window_content_export_types(h, NULL, &export);
+
+ if (export)
+ ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
+ h, NULL, NULL, NULL);
+ }
+ break;
+
+ case BROWSER_OBJECT_EXPORT_DRAW:
+ if (current_menu_object != NULL) {
+ ro_gui_window_content_export_types(current_menu_object,
+ &export, NULL);
+
+ if (export)
+ ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
+ current_menu_object,
+ NULL, NULL, NULL);
+ } else if (h != NULL) {
+ ro_gui_window_content_export_types(h, &export, NULL);
+
+ if (export)
+ ro_gui_save_prepare(GUI_SAVE_OBJECT_NATIVE,
+ h, NULL, NULL, NULL);
+ }
+ break;
+
+ default:
+ break;
}
}
+
/**
- * Process Pointer Entering Window events in a browser window.
+ * Handle the closure of a browser window menu
*
- * \param *entering The wimp pointer entering event data block.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu that is being closed.
*/
-
-static void ro_gui_window_pointer_entering(wimp_entering *entering)
+static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
{
- struct gui_window *g = ro_gui_window_lookup(entering->w);
-
- if (g != NULL)
- ro_mouse_track_start(ro_gui_window_track_end,
- ro_gui_window_mouse_at, g);
+ if (menu == ro_gui_browser_window_menu) {
+ current_menu_object = NULL;
+ current_menu_url = NULL;
+ } else if (menu == gui_form_select_menu) {
+ gui_form_select_control = NULL;
+ }
}
+
/**
- * Process Pointer Leaving Window events in a browser window. These arrive via
- * the termination callback handler from ro_mouse's mouse tracking.
+ * Clones a browser window's options.
*
- * \param *leaving The wimp pointer leaving event data block.
- * \param *data The GUI window that the pointer is leaving.
+ * \param new_gui the new gui window
+ * \param old_gui the gui window to clone from, or NULL for default
*/
-
-static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
+static void
+ro_gui_window_clone_options(struct gui_window *new_gui,
+ struct gui_window *old_gui)
{
- struct gui_window *g = (struct gui_window *) data;
+ assert(new_gui);
- if (g != NULL)
- gui_window_set_pointer(g, GUI_POINTER_DEFAULT);
+ /* Clone the basic options
+ */
+ if (!old_gui) {
+ new_gui->option.buffer_animations = nsoption_bool(buffer_animations);
+ new_gui->option.buffer_everything = nsoption_bool(buffer_everything);
+ } else {
+ new_gui->option = old_gui->option;
+ }
+
+ /* Set up the toolbar
+ */
+ if (new_gui->toolbar) {
+ ro_toolbar_set_display_buttons(new_gui->toolbar,
+ nsoption_bool(toolbar_show_buttons));
+ ro_toolbar_set_display_url(new_gui->toolbar,
+ nsoption_bool(toolbar_show_address));
+ ro_toolbar_set_display_throbber(new_gui->toolbar,
+ nsoption_bool(toolbar_show_throbber));
+ if ((old_gui) && (old_gui->toolbar)) {
+ ro_toolbar_set_display_buttons(new_gui->toolbar,
+ ro_toolbar_get_display_buttons(
+ old_gui->toolbar));
+ ro_toolbar_set_display_url(new_gui->toolbar,
+ ro_toolbar_get_display_url(
+ old_gui->toolbar));
+ ro_toolbar_set_display_throbber(new_gui->toolbar,
+ ro_toolbar_get_display_throbber(
+ old_gui->toolbar));
+ ro_toolbar_process(new_gui->toolbar, -1, true);
+ }
+ }
}
/**
- * Scroll a browser window, either via the core or directly using the
- * normal Wimp_OpenWindow interface.
- *
- * Scroll steps are supplied in terms of the (extended) Scroll Event direction
- * values returned by Wimp_Poll. Special values of 0x7fffffff and 0x80000000
- * are added to mean "Home" and "End".
+ * Create and open a new browser window.
*
- * \param *g The GUI Window to be scrolled.
- * \param scroll_x The X scroll step to be applied.
- * \param scroll_y The Y scroll step to be applied.
+ * \param bw bw to create gui_window for
+ * \param existing an existing gui_window, may be NULL
+ * \param flags flags for gui window creation
+ * \return gui window, or NULL on error
*/
-
-void ro_gui_window_scroll_action(struct gui_window *g,
- wimp_scroll_direction scroll_x, wimp_scroll_direction scroll_y)
+static struct gui_window *gui_window_create(struct browser_window *bw,
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
- int visible_x, visible_y;
- int step_x = 0, step_y = 0;
- int toolbar_y;
- wimp_window_state state;
- wimp_pointer pointer;
- os_error *error;
- os_coord pos;
- bool handled = false;
- struct toolbar *toolbar;
+ int screen_width, screen_height;
+ static int window_count = 2;
+ wimp_window window;
+ wimp_window_state state;
+ os_error *error;
+ bool open_centred = true;
+ struct gui_window *g;
- if (g == NULL)
- return;
+ g = malloc(sizeof *g);
+ if (!g) {
+ ro_warn_user("NoMemory", 0);
+ return 0;
+ }
+ g->bw = bw;
+ g->toolbar = 0;
+ g->status_bar = 0;
+ g->old_width = 0;
+ g->old_height = 0;
+ g->update_extent = true;
+ g->active = false;
+ strcpy(g->title, "NetSurf");
+ g->iconise_icon = -1;
+ g->scale = browser_window_get_scale(bw);
- /* Get the current window, toolbar and pointer details. */
+ /* Set the window position */
+ if (existing != NULL &&
+ flags & GW_CREATE_CLONE &&
+ nsoption_bool(window_size_clone)) {
+ state.w = existing->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_state: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
+ window.visible.x0 = state.visible.x0;
+ window.visible.x1 = state.visible.x1;
+ window.visible.y0 = state.visible.y0 - 48;
+ window.visible.y1 = state.visible.y1 - 48;
+ open_centred = false;
+ } else {
+ int win_width, win_height;
+ ro_gui_screen_size(&screen_width, &screen_height);
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- return;
+ /* Check if we have a preferred position */
+ if ((nsoption_int(window_screen_width) != 0) &&
+ (nsoption_int(window_screen_height) != 0)) {
+ win_width = (nsoption_int(window_width) *
+ screen_width) /
+ nsoption_int(window_screen_width);
+ win_height = (nsoption_int(window_height) *
+ screen_height) /
+ nsoption_int(window_screen_height);
+ window.visible.x0 = (nsoption_int(window_x) *
+ screen_width) /
+ nsoption_int(window_screen_width);
+ window.visible.y0 = (nsoption_int(window_y) *
+ screen_height) /
+ nsoption_int(window_screen_height);
+ if (nsoption_bool(window_stagger)) {
+ window.visible.y0 += 96 -
+ (48 * (window_count % 5));
+ }
+ open_centred = false;
+ if (win_width < 100)
+ win_width = 100;
+ if (win_height < 100)
+ win_height = 100;
+ } else {
+
+ /* Base how we define the window height/width
+ on the compile time options set */
+ win_width = screen_width * 3 / 4;
+ if (1600 < win_width)
+ win_width = 1600;
+ win_height = win_width * 3 / 4;
+
+ window.visible.x0 = (screen_width - win_width) / 2;
+ window.visible.y0 = ((screen_height - win_height) / 2) +
+ 96 - (48 * (window_count % 5));
+ }
+ window.visible.x1 = window.visible.x0 + win_width;
+ window.visible.y1 = window.visible.y0 + win_height;
}
- toolbar = ro_toolbar_parent_window_lookup(g->window);
- assert(g == NULL || g->toolbar == NULL || g->toolbar == toolbar);
+ /* General flags for a non-movable, non-resizable, no-title bar window */
+ window.xscroll = 0;
+ window.yscroll = 0;
+ window.next = wimp_TOP;
+ window.flags = wimp_WINDOW_MOVEABLE |
+ wimp_WINDOW_NEW_FORMAT |
+ wimp_WINDOW_VSCROLL |
+ wimp_WINDOW_HSCROLL |
+ wimp_WINDOW_IGNORE_XEXTENT |
+ wimp_WINDOW_IGNORE_YEXTENT |
+ wimp_WINDOW_SCROLL_REPEAT;
+ window.title_fg = wimp_COLOUR_BLACK;
+ window.title_bg = wimp_COLOUR_LIGHT_GREY;
+ window.work_fg = wimp_COLOUR_LIGHT_GREY;
+ window.work_bg = wimp_COLOUR_TRANSPARENT;
+ window.scroll_outer = wimp_COLOUR_DARK_GREY;
+ window.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
+ window.highlight_bg = wimp_COLOUR_CREAM;
+ window.extra_flags = wimp_WINDOW_USE_EXTENDED_SCROLL_REQUEST |
+ wimp_WINDOW_GIVE_SHADED_ICON_INFO;
+ window.extent.x0 = 0;
+ window.extent.y0 = -(window.visible.y1 - window.visible.y0);
+ window.extent.x1 = window.visible.x1 - window.visible.x0;
+ window.extent.y1 = 0;
+ window.title_flags = wimp_ICON_TEXT |
+ wimp_ICON_INDIRECTED |
+ wimp_ICON_HCENTRED;
+ window.work_flags = wimp_BUTTON_DOUBLE_CLICK_DRAG <<
+ wimp_ICON_BUTTON_TYPE_SHIFT;
+ window.sprite_area = wimpspriteop_AREA;
+ window.xmin = 1;
+ window.ymin = 1;
+ window.title_data.indirected_text.text = g->title;
+ window.title_data.indirected_text.validation = (char *) -1;
+ window.title_data.indirected_text.size = 255;
+ window.icon_count = 0;
- toolbar_y = (toolbar == NULL) ? 0 : ro_toolbar_full_height(toolbar);
+ /* Add in flags */
+ window.flags |= wimp_WINDOW_SIZE_ICON |
+ wimp_WINDOW_BACK_ICON |
+ wimp_WINDOW_CLOSE_ICON |
+ wimp_WINDOW_TITLE_ICON |
+ wimp_WINDOW_TOGGLE_ICON;
- visible_x = state.visible.x1 - state.visible.x0 - 32;
- visible_y = state.visible.y1 - state.visible.y0 - 32 - toolbar_y;
+ if (open_centred) {
+ int scroll_width = ro_get_vscroll_width(NULL);
+ window.visible.x0 -= scroll_width;
+ }
- error = xwimp_get_pointer_info(&pointer);
+ error = xwimp_create_window(&window, &g->window);
if (error) {
- LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
- return;
+ free(g);
+ return 0;
}
- /* Turn the scroll requirement from Scroll Event codes into coordinates
- * that the core can understand.
- */
+ /* Link into window list */
+ g->prev = 0;
+ g->next = window_list;
+ if (window_list)
+ window_list->prev = g;
+ window_list = g;
+ window_count++;
- switch (scroll_x) {
- case wimp_SCROLL_PAGE_LEFT:
- step_x = SCROLL_PAGE_DOWN;
- break;
- case wimp_SCROLL_AUTO_LEFT:
- case wimp_SCROLL_COLUMN_LEFT:
- step_x = -16;
- break;
- case wimp_SCROLL_AUTO_RIGHT:
- case wimp_SCROLL_COLUMN_RIGHT:
- step_x = 16;
- break;
- case wimp_SCROLL_PAGE_RIGHT:
- step_x = SCROLL_PAGE_UP;
- break;
- case 0x80000000:
- step_x = SCROLL_BOTTOM;
- break;
- case 0x7fffffff:
- step_x = SCROLL_TOP;
- break;
- default:
- step_x = (visible_x * (scroll_x>>2)) >> 2;
- break;
+ /* Add in a toolbar and status bar */
+ g->status_bar = ro_gui_status_bar_create(g->window,
+ nsoption_int(toolbar_status_size));
+ g->toolbar = ro_toolbar_create(NULL, g->window,
+ THEME_STYLE_BROWSER_TOOLBAR, TOOLBAR_FLAGS_NONE,
+ &ro_gui_window_toolbar_callbacks, g,
+ "HelpToolbar");
+ if (g->toolbar != NULL) {
+ ro_toolbar_add_buttons(g->toolbar,
+ brower_toolbar_buttons,
+ nsoption_charp(toolbar_browser));
+ ro_toolbar_add_url(g->toolbar);
+ ro_toolbar_add_throbber(g->toolbar);
+ ro_toolbar_rebuild(g->toolbar);
}
- switch (scroll_y) {
- case wimp_SCROLL_PAGE_UP:
- step_y = SCROLL_PAGE_UP;
- break;
- case wimp_SCROLL_AUTO_UP:
- case wimp_SCROLL_LINE_UP:
- step_y = -16;
- break;
- case wimp_SCROLL_AUTO_DOWN:
- case wimp_SCROLL_LINE_DOWN:
- step_y = 16;
- break;
- case wimp_SCROLL_PAGE_DOWN:
- step_y = SCROLL_PAGE_DOWN;
- break;
- case 0x80000000:
- step_y = SCROLL_BOTTOM;
- break;
- case 0x7fffffff:
- step_y = SCROLL_TOP;
- break;
- default:
- step_y = -((visible_y * (scroll_y>>2)) >> 2);
- break;
- }
+ /* Register event handlers. Do this quickly, as some of the things
+ * that follow will indirectly look up our user data: this MUST
+ * be set first!
+ */
+ ro_gui_wimp_event_set_user_data(g->window, g);
+ ro_gui_wimp_event_register_open_window(g->window,
+ ro_gui_window_open);
+ ro_gui_wimp_event_register_close_window(g->window,
+ ro_gui_window_close);
+ ro_gui_wimp_event_register_redraw_window(g->window,
+ ro_gui_window_redraw);
+ ro_gui_wimp_event_register_scroll_window(g->window,
+ ro_gui_window_scroll);
+ ro_gui_wimp_event_register_pointer_entering_window(g->window,
+ ro_gui_window_pointer_entering);
+ ro_gui_wimp_event_register_keypress(g->window,
+ ro_gui_window_keypress);
+ ro_gui_wimp_event_register_mouse_click(g->window,
+ ro_gui_window_click);
+ ro_gui_wimp_event_register_menu(g->window,
+ ro_gui_browser_window_menu,
+ true, false);
+ ro_gui_wimp_event_register_menu_prepare(g->window,
+ ro_gui_window_menu_prepare);
+ ro_gui_wimp_event_register_menu_selection(g->window,
+ ro_gui_window_menu_select);
+ ro_gui_wimp_event_register_menu_warning(g->window,
+ ro_gui_window_menu_warning);
+ ro_gui_wimp_event_register_menu_close(g->window,
+ ro_gui_window_menu_close);
- /* If no scrolling is required, there's no point trying to do any. */
+ /* Set the window options */
+ ro_gui_window_clone_options(g, existing);
+ ro_gui_window_update_toolbar_buttons(g);
- if (step_x == 0 && step_y == 0)
- return;
+ /* Open the window at the top of the stack */
+ state.w = g->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return g;
+ }
- /* If the pointer is over the window being scrolled, then try to get
- * the core to do the scrolling on the object under the pointer.
- */
+ state.next = wimp_TOP;
- if (pointer.w == g->window &&
- ro_gui_window_to_window_pos(g,
- pointer.pos.x, pointer.pos.y, &pos))
- handled = browser_window_scroll_at_point(g->bw, pos.x, pos.y,
- step_x, step_y);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
- /* If the core didn't do the scrolling, handle it via the Wimp.
- * Windows which contain frames can only be scrolled by the core,
- * because it implements frame scroll bars.
- */
+ /* Claim the caret */
+ if (ro_toolbar_take_caret(g->toolbar)) {
+ ro_gui_url_complete_start(g->toolbar);
+ } else {
+ gui_window_place_caret(g, -100, -100, 0, NULL);
+ }
- if (!handled && (browser_window_is_frameset(g->bw) == false)) {
- switch (step_x) {
- case SCROLL_TOP:
- state.xscroll -= 0x10000000;
- break;
- case SCROLL_BOTTOM:
- state.xscroll += 0x10000000;
- break;
- case SCROLL_PAGE_UP:
- state.xscroll += visible_x;
- break;
- case SCROLL_PAGE_DOWN:
- state.xscroll -= visible_x;
- break;
- default:
- state.xscroll += 2 * step_x;
- break;
- }
+ return g;
+}
- switch (step_y) {
- case SCROLL_TOP:
- state.yscroll += 0x10000000;
- break;
- case SCROLL_BOTTOM:
- state.yscroll -= 0x10000000;
- break;
- case SCROLL_PAGE_UP:
- state.yscroll += visible_y;
- break;
- case SCROLL_PAGE_DOWN:
- state.yscroll -= visible_y;
- break;
- default:
- state.yscroll -= 2 * step_y;
- break;
- }
- error = xwimp_open_window((wimp_open *) &state);
- if (error) {
- LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
+/**
+ * Remove all pending update boxes for a window
+ *
+ * \param g gui_window
+ */
+static void ro_gui_window_remove_update_boxes(struct gui_window *g)
+{
+ struct update_box *cur;
+
+ for (cur = pending_updates; cur != NULL; cur = cur->next) {
+ if (cur->g == g) {
+ cur->g = NULL;
}
}
}
/**
- * Handle Message_DataLoad (file dragged in) for a window.
- *
- * \param g window
- * \param message Message_DataLoad block
- * \return true if the load was processed
+ * Close a browser window and free any related resources.
*
- * If the file was dragged into a form file input, it is used as the value.
+ * \param g gui_window to destroy
*/
-
-bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
+static void gui_window_destroy(struct gui_window *g)
{
os_error *error;
- os_coord pos;
+ wimp_w w;
- /* Ignore directories etc. */
- if (0x1000 <= message->data.data_xfer.file_type)
- return false;
+ assert(g);
- if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
- message->data.data_xfer.pos.y, &pos))
- return false;
+ /* stop any tracking */
+ ro_mouse_kill(g);
- if (browser_window_drop_file_at_point(g->bw, pos.x, pos.y,
- message->data.data_xfer.file_name) == false)
- return false;
+ /* remove from list */
+ if (g->prev)
+ g->prev->next = g->next;
+ else
+ window_list = g->next;
+ if (g->next)
+ g->next->prev = g->prev;
- /* send DataLoadAck */
- message->action = message_DATA_LOAD_ACK;
- message->your_ref = message->my_ref;
- error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
+ /* destroy toolbar */
+ if (g->toolbar)
+ ro_toolbar_destroy(g->toolbar);
+ if (g->status_bar)
+ ro_gui_status_bar_destroy(g->status_bar);
+
+ w = g->window;
+ ro_gui_url_complete_close();
+ ro_gui_dialog_close_persistent(w);
+ if (current_menu_window == w)
+ ro_gui_menu_destroy();
+ ro_gui_window_remove_update_boxes(g);
+
+ /* delete window */
+ error = xwimp_delete_window(w);
if (error) {
- LOG("xwimp_send_message: 0x%x: %s\n", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
+ ro_gui_wimp_event_finalise(w);
- return true;
+ free(g);
}
/**
- * Handle pointer movements in a browser window.
+ * Set the title of a browser window.
*
- * \param *pointer new mouse position
- * \param *data browser window that the pointer is in
+ * \param g gui_window to update
+ * \param title new window title, copied
*/
-
-void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
+static void gui_window_set_title(struct gui_window *g, const char *title)
{
- os_coord pos;
- struct gui_window *g = (struct gui_window *) data;
+ assert(g);
+ assert(title);
- if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
- browser_window_mouse_track(g->bw,
- ro_gui_mouse_drag_state(pointer->buttons,
- wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x, pos.y);
+ if (g->scale != 1.0) {
+ int scale_disp = g->scale * 100;
+
+ if (ABS((float)scale_disp - g->scale * 100) >= 0.05)
+ snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
+ title, g->scale * 100);
+ else
+ snprintf(g->title, sizeof g->title, "%s (%i%%)",
+ title, scale_disp);
+ } else {
+ strncpy(g->title, title, sizeof g->title);
+ }
+
+ ro_gui_set_window_title(g->window, g->title);
}
/**
- * Window is being iconised. Create a suitable thumbnail sprite
- * (which, sadly, must be in the Wimp sprite pool), and return
- * the sprite name and truncated title to the iconiser
+ * Get the scroll position of a browser window.
*
- * \param g the gui window being iconised
- * \param wi the WindowInfo message from the iconiser
+ * \param g gui_window
+ * \param sx receives x ordinate of point at top-left of window
+ * \param sy receives y ordinate of point at top-left of window
+ * \return true iff successful
*/
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+{
+ wimp_window_state state;
+ os_error *error;
+ int toolbar_height = 0;
+
+ assert(g);
+
+ state.w = g->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
+ }
+
+ if (g->toolbar)
+ toolbar_height = ro_toolbar_full_height(g->toolbar);
+ *sx = state.xscroll / (2 * g->scale);
+ *sy = -(state.yscroll - toolbar_height) / (2 * g->scale);
+ return true;
+}
+
-void ro_gui_window_iconise(struct gui_window *g,
- wimp_full_message_window_info *wi)
+/**
+ * Set the scroll position of a riscos browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
+ *
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
- /* sadly there is no 'legal' way to get the sprite into
- * the Wimp sprite pool other than via a filing system */
- const char *temp_fname = "Pipe:$._tmpfile";
- struct browser_window *bw = g->bw;
- osspriteop_header *overlay = NULL;
- osspriteop_header *sprite_header;
- struct bitmap *bitmap;
- osspriteop_area *area;
- int width = 34, height = 34;
- struct hlcache_handle *h;
+ wimp_window_state state;
os_error *error;
- int len, id;
+ int toolbar_height = 0;
- assert(bw);
+ assert(g);
- h = browser_window_get_content(bw);
- if (!h) return;
+ state.w = g->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_BAD_PARAMETER;
+ }
- /* if an overlay sprite is defined, locate it and gets its dimensions
- * so that we can produce a thumbnail with the same dimensions */
- if (!ro_gui_wimp_get_sprite("ic_netsfxx", &overlay)) {
- error = xosspriteop_read_sprite_info(osspriteop_PTR,
- (osspriteop_area *)0x100,
- (osspriteop_id)overlay, &width, &height, NULL,
- NULL);
- if (error) {
- LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("MiscError", error->errmess);
- overlay = NULL;
+ if (g->toolbar) {
+ toolbar_height = ro_toolbar_full_height(g->toolbar);
+ }
+
+ if ((rect->x0 == rect->x1) && (rect->y0 == rect->y1)) {
+ /* scroll to top */
+ state.xscroll = rect->x0 * 2 * g->scale;
+ state.yscroll = (-rect->y0 * 2 * g->scale) + toolbar_height;
+ } else {
+ /* scroll area into view with padding */
+ int x0, y0, x1, y1;
+ int cx0, cy0, width, height;
+ int padding_available;
+ int correction;
+
+ x0 = rect->x0 * 2 * g->scale;
+ y0 = rect->y0 * 2 * g->scale;
+ x1 = rect->x1 * 2 * g->scale;
+ y1 = rect->y1 * 2 * g->scale;
+
+ cx0 = state.xscroll;
+ cy0 = -state.yscroll + toolbar_height;
+ width = state.visible.x1 - state.visible.x0;
+ height = state.visible.y1 - state.visible.y0 - toolbar_height;
+
+ /* make sure we're visible */
+ correction = (x1 - cx0 - width);
+ if (correction > 0) {
+ cx0 += correction;
}
- else if (sprite_bpp(overlay) != 8) {
- LOG("overlay sprite is not 8bpp");
- overlay = NULL;
+ correction = (y1 - cy0 - height);
+ if (correction > 0) {
+ cy0 += correction;
+ }
+ if (x0 < cx0) {
+ cx0 = x0;
+ }
+ if (y0 < cy0) {
+ cy0 = y0;
}
- }
- /* create the thumbnail sprite */
- bitmap = riscos_bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE |
- BITMAP_CLEAR_MEMORY);
- if (!bitmap) {
- LOG("Thumbnail initialisation failed.");
- return;
+ /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
+ padding_available = (width - x1 + x0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cx0 + width - x1);
+ if (correction < padding_available) {
+ cx0 += padding_available;
+ }
+ correction = (x0 - cx0);
+ if (correction < padding_available) {
+ cx0 -= padding_available;
+ }
+ }
+ padding_available = (height - y1 + y0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cy0 + height - y1);
+ if (correction < padding_available) {
+ cy0 += padding_available;
+ }
+ correction = (y0 - cy0);
+ if (correction < padding_available) {
+ cy0 -= padding_available;
+ }
+ }
+
+ state.xscroll = cx0;
+ state.yscroll = -cy0 + toolbar_height;
}
- riscos_bitmap_render(bitmap, h);
- if (overlay) {
- riscos_bitmap_overlay_sprite(bitmap, overlay);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Find the current dimensions of a browser window's content area.
+ *
+ * \param gw gui window to measure
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
+ int *width, int *height,
+ bool scaled)
+{
+ /* use the cached window sizes */
+ *width = gw->old_width / 2;
+ *height = gw->old_height / 2;
+
+ if (scaled) {
+ *width /= gw->scale;
+ *height /= gw->scale;
}
- area = riscos_bitmap_convert_8bpp(bitmap);
- riscos_bitmap_destroy(bitmap);
- if (!area) {
- LOG("Thumbnail conversion failed.");
- return;
+ return NSERROR_OK;
+}
+
+
+/**
+ * Set the status bar of a browser window.
+ *
+ * \param g gui_window to update
+ * \param text new status text
+ */
+static void riscos_window_set_status(struct gui_window *g, const char *text)
+{
+ if (g->status_bar) {
+ ro_gui_status_bar_set_text(g->status_bar, text);
}
+}
- /* choose a suitable sprite name */
- id = 0;
- while (iconise_used[id])
- if ((unsigned)++id >= NOF_ELEMENTS(iconise_used)) {
- id = iconise_next;
- if ((unsigned)++iconise_next >=
- NOF_ELEMENTS(iconise_used))
- iconise_next = 0;
- break;
- }
- sprite_header = (osspriteop_header *)(area + 1);
- len = sprintf(sprite_header->name, "ic_netsf%.2d", id);
+/**
+ * Update the interface to reflect start of page loading.
+ *
+ * \param g window with start of load
+ */
+static void gui_window_start_throbber(struct gui_window *g)
+{
+ ro_gui_window_update_toolbar_buttons(g);
+ ro_gui_menu_refresh(ro_gui_browser_window_menu);
+ if (g->toolbar != NULL)
+ ro_toolbar_start_throbbing(g->toolbar);
+ g->active = true;
+}
- error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
- area, temp_fname);
- if (error) {
- LOG("xosspriteop_save_sprite_file: 0x%x:%s", error->errnum, error->errmess);
- ro_warn_user("MiscError", error->errmess);
- free(area);
- return;
- }
- error = xwimpspriteop_merge_sprite_file(temp_fname);
- if (error) {
- LOG("xwimpspriteop_merge_sprite_file: 0x%x:%s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- remove(temp_fname);
- free(area);
+
+/**
+ * Update the interface to reflect page loading stopped.
+ *
+ * \param g window with start of load
+ */
+static void gui_window_stop_throbber(struct gui_window *g)
+{
+ ro_gui_window_update_toolbar_buttons(g);
+ ro_gui_menu_refresh(ro_gui_browser_window_menu);
+ if (g->toolbar != NULL)
+ ro_toolbar_stop_throbbing(g->toolbar);
+ g->active = false;
+}
+
+/**
+ * set favicon
+ */
+static void
+gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
+{
+ if (g == NULL || g->toolbar == NULL)
return;
- }
- memcpy(wi->sprite_name, sprite_header->name + 3, len - 2); /* inc NUL */
- strncpy(wi->title, g->title, sizeof(wi->title));
- wi->title[sizeof(wi->title) - 1] = '\0';
+ ro_toolbar_set_site_favicon(g->toolbar, icon);
+}
- if (wimptextop_string_width(wi->title, 0) > 182) {
- /* work around bug in Pinboard where it will fail to display
- * the icon if the text is very wide */
- if (strlen(wi->title) > 10)
- wi->title[10] = '\0'; /* pinboard does this anyway */
- while (wimptextop_string_width(wi->title, 0) > 182)
- wi->title[strlen(wi->title) - 1] = '\0';
- }
- wi->size = sizeof(wimp_full_message_window_info);
- wi->your_ref = wi->my_ref;
- error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)wi,
- wi->sender);
+
+/**
+ * Remove the caret, if present.
+ *
+ * \param g window with caret
+ */
+static void gui_window_remove_caret(struct gui_window *g)
+{
+ wimp_caret caret;
+ os_error *error;
+
+ error = xwimp_get_caret_position(&caret);
if (error) {
- LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
+ return;
}
- else {
- g->iconise_icon = id;
- iconise_used[id] = true;
+
+ if (caret.w == g->window) {
+ /* we have the caret: hide caret, but keep input focus */
+ gui_window_place_caret(g, -100, -100, 0, NULL);
}
+}
- free(area);
+
+/**
+ * Called when the gui_window has new content.
+ *
+ * \param g the gui_window that has new content
+ */
+static void gui_window_new_content(struct gui_window *g)
+{
+ ro_gui_menu_refresh(ro_gui_browser_window_menu);
+ ro_gui_window_update_toolbar_buttons(g);
+ ro_gui_dialog_close_persistent(g->window);
+ ro_toolbar_set_content_favicon(g->toolbar, g);
}
/**
* Completes scrolling of a browser window
*
- * \param *drag The DragEnd event data block.
- * \param *data gui window block pointer.
+ * \param drag The DragEnd event data block.
+ * \param data gui window block pointer.
*/
-
static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
{
wimp_pointer pointer;
@@ -3481,20 +3813,25 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
error = xwimp_drag_box((wimp_drag*)-1);
if (error) {
- LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_get_pointer_info(&pointer);
if (error) {
- LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return;
}
error = xwimpspriteop_set_pointer_shape("ptr_default", 0x31, 0, 0, 0, 0);
if (error) {
- LOG("xwimpspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimpspriteop_set_pointer_shape: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -3504,630 +3841,736 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
/**
- * Process Mouse_Click events in a toolbar's button bar. This does not handle
- * other clicks in a toolbar: these are handled by the toolbar module itself.
+ * Starts drag scrolling of a browser window
*
- * \param *data The GUI window associated with the click.
- * \param action_type The action type to be handled.
- * \param action The action to process.
+ * \param g the window to scroll
*/
-
-void ro_gui_window_toolbar_click(void *data,
- toolbar_action_type action_type, union toolbar_action action)
+static bool gui_window_scroll_start(struct gui_window *g)
{
- struct gui_window *g = data;
- nserror err;
-
- if (g == NULL)
- return;
-
-
- if (action_type == TOOLBAR_ACTION_URL) {
- switch (action.url) {
- case TOOLBAR_URL_DRAG_URL:
- {
- gui_save_type save_type;
-
- if (!browser_window_has_content(g->bw))
- break;
-
- if (ro_gui_shift_pressed())
- save_type = GUI_SAVE_LINK_URL;
- else
- save_type = GUI_SAVE_LINK_TEXT;
-
- ro_gui_drag_save_link(save_type,
- browser_window_get_url(g->bw),
- browser_window_get_title(g->bw), g);
- }
- break;
-
- case TOOLBAR_URL_SELECT_HOTLIST:
- ro_gui_window_action_add_bookmark(g);
- break;
-
- case TOOLBAR_URL_ADJUST_HOTLIST:
- ro_gui_window_action_remove_bookmark(g);
- break;
-
- default:
- break;
- }
+ wimp_window_info_base info;
+ wimp_pointer pointer;
+ os_error *error;
+ wimp_drag drag;
+ int height;
+ int width;
- return;
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
}
+ info.w = g->window;
+ error = xwimp_get_window_info_header_only((wimp_window_info*)&info);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x : %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
+ }
- /* By now, the only valid action left is a button click. If it isn't
- * one of those, give up.
- */
-
- if (action_type != TOOLBAR_ACTION_BUTTON)
- return;
-
- switch (action.button) {
- case TOOLBAR_BUTTON_BACK:
- if (g->bw != NULL)
- browser_window_history_back(g->bw, false);
- break;
-
- case TOOLBAR_BUTTON_BACK_NEW:
- if (g->bw != NULL)
- browser_window_history_back(g->bw, true);
- break;
-
- case TOOLBAR_BUTTON_FORWARD:
- if (g->bw != NULL)
- browser_window_history_forward(g->bw, false);
- break;
-
- case TOOLBAR_BUTTON_FORWARD_NEW:
- if (g->bw != NULL)
- browser_window_history_forward(g->bw, true);
- break;
-
- case TOOLBAR_BUTTON_STOP:
- if (g->bw != NULL)
- browser_window_stop(g->bw);
- break;
-
- case TOOLBAR_BUTTON_RELOAD:
- if (g->bw != NULL)
- browser_window_reload(g->bw, false);
- break;
-
- case TOOLBAR_BUTTON_RELOAD_ALL:
- if (g->bw != NULL)
- browser_window_reload(g->bw, true);
- break;
-
- case TOOLBAR_BUTTON_HISTORY_LOCAL:
- ro_gui_window_action_local_history(g);
- break;
-
- case TOOLBAR_BUTTON_HISTORY_GLOBAL:
- ro_gui_global_history_present();
- break;
+ width = info.extent.x1 - info.extent.x0;
+ height = info.extent.y1 - info.extent.y0;
- case TOOLBAR_BUTTON_HOME:
- ro_gui_window_action_home(g);
- break;
+ drag.type = wimp_DRAG_USER_POINT;
+ drag.bbox.x1 = pointer.pos.x + info.xscroll;
+ drag.bbox.y0 = pointer.pos.y + info.yscroll;
+ drag.bbox.x0 = drag.bbox.x1 - (width - (info.visible.x1 - info.visible.x0));
+ drag.bbox.y1 = drag.bbox.y0 + (height - (info.visible.y1 - info.visible.y0));
- case TOOLBAR_BUTTON_SEARCH:
- ro_gui_window_action_search(g);
- break;
+ if (g->toolbar) {
+ int tbar_height = ro_toolbar_full_height(g->toolbar);
+ drag.bbox.y0 -= tbar_height;
+ drag.bbox.y1 -= tbar_height;
+ }
- case TOOLBAR_BUTTON_SCALE:
- ro_gui_window_action_zoom(g);
- break;
+ error = xwimp_drag_box(&drag);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
+ }
- case TOOLBAR_BUTTON_BOOKMARK_OPEN:
- ro_gui_hotlist_present();
- break;
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
+ return true;
+}
- case TOOLBAR_BUTTON_BOOKMARK_ADD:
- ro_gui_window_action_add_bookmark(g);
- break;
- case TOOLBAR_BUTTON_SAVE_SOURCE:
- ro_gui_window_action_save(g, GUI_SAVE_SOURCE);
- break;
+/**
+ * Platform-dependent part of starting drag operation.
+ *
+ * \param g gui window containing the drag
+ * \param type type of drag the core is performing
+ * \param rect rectangle to constrain pointer to (relative to drag start coord)
+ * \return true iff succesful
+ */
+static bool
+gui_window_drag_start(struct gui_window *g,
+ gui_drag_type type,
+ const struct rect *rect)
+{
+ wimp_pointer pointer;
+ wimp_drag drag;
- case TOOLBAR_BUTTON_SAVE_COMPLETE:
- ro_gui_window_action_save(g, GUI_SAVE_COMPLETE);
- break;
+ if (rect != NULL) {
+ /* We have a box to constrain the pointer to, for the drag
+ * duration */
+ os_error *error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_get_pointer_info 0x%x : %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
+ }
- case TOOLBAR_BUTTON_PRINT:
- ro_gui_window_action_print(g);
- break;
+ drag.type = wimp_DRAG_USER_POINT;
+ drag.bbox.x0 = pointer.pos.x +
+ (int)(rect->x0 * 2 * g->scale);
+ drag.bbox.y0 = pointer.pos.y +
+ (int)(rect->y0 * 2 * g->scale);
+ drag.bbox.x1 = pointer.pos.x +
+ (int)(rect->x1 * 2 * g->scale);
+ drag.bbox.y1 = pointer.pos.y +
+ (int)(rect->y1 * 2 * g->scale);
- case TOOLBAR_BUTTON_UP:
- err = browser_window_navigate_up(g->bw, false);
- if (err != NSERROR_OK) {
- ro_warn_user(messages_get_errorcode(err), NULL);
+ error = xwimp_drag_box(&drag);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return false;
}
- break;
+ }
- case TOOLBAR_BUTTON_UP_NEW:
- err = browser_window_navigate_up(g->bw, true);
- if (err != NSERROR_OK) {
- ro_warn_user(messages_get_errorcode(err), NULL);
- }
+ switch (type) {
+ case GDRAGGING_SCROLLBAR:
+ /* Dragging a core scrollbar */
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
break;
default:
+ /* Not handled here yet */
break;
}
- ro_gui_window_update_toolbar_buttons(g);
+ return true;
}
/**
- * Handle Message_DataLoad (file dragged in) for a toolbar
- *
- * @todo This belongs in the toolbar module, and should be moved there
- * once the module is able to usefully handle its own events.
+ * Save the specified content as a link.
*
- * \param g window
- * \param message Message_DataLoad block
- * \return true if the load was processed
+ * \param g The window containing the content
+ * \param url The url of the link
+ * \param title The title of the link
*/
-
-bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
+static nserror
+gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
{
- if (message->data.data_xfer.file_type == osfile_TYPE_TEXT &&
- ro_gui_window_import_text(g,
- message->data.data_xfer.file_name)) {
- os_error *error;
-
- /* send DataLoadAck */
- message->action = message_DATA_LOAD_ACK;
- message->your_ref = message->my_ref;
- error = xwimp_send_message(wimp_USER_MESSAGE, message,
- message->sender);
- if (error) {
- LOG("xwimp_send_message: 0x%x: %s\n", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- }
- return true;
- }
- return false;
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
+ ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
+ return NSERROR_OK;
}
-/*
- * Helper code for the Wimp Event Handlers.
- */
-
/**
- * Check if a particular menu handle is a browser window menu
+ * Display a menu of options for a form select control.
*
- * \param *menu The menu in question.
- * \return true if this menu is a browser window menu
+ * \param g gui window containing form control
+ * \param control form control of type GADGET_SELECT
*/
-
-bool ro_gui_window_check_menu(wimp_menu *menu)
+static void
+gui_window_create_form_select_menu(struct gui_window *g,
+ struct form_control *control)
{
- return (ro_gui_browser_window_menu == menu) ? true : false;
-}
-
-
-/**
- * Return boolean flags to show what RISC OS types we can sensibly convert
- * the given object into.
- *
- * \todo This should probably be somewhere else but in window.c, and
- * should probably even be done in content_().
- *
- * \param h The object to test.
- * \param export_draw true on exit if a drawfile would be possible.
- * \param export_sprite true on exit if a sprite would be possible.
- * \return true if valid data is returned; else false.
- */
+ os_error *error;
+ wimp_pointer pointer;
-bool ro_gui_window_content_export_types(struct hlcache_handle *h,
- bool *export_draw, bool *export_sprite)
-{
- bool found_type = false;
+ /* The first time the menu is opened, control bypasses the normal
+ * Menu Prepare event and so we prepare here. On any re-opens,
+ * ro_gui_window_prepare_form_select_menu() is called from the
+ * normal wimp event.
+ */
- if (export_draw != NULL)
- *export_draw = false;
- if (export_sprite != NULL)
- *export_sprite = false;
+ if (!ro_gui_window_prepare_form_select_menu(g, control))
+ return;
- if (h != NULL && content_get_type(h) == CONTENT_IMAGE) {
- switch (ro_content_native_type(h)) {
- case osfile_TYPE_SPRITE:
- /* bitmap types (Sprite export possible) */
- found_type = true;
- if (export_sprite != NULL)
- *export_sprite = true;
- break;
- case osfile_TYPE_DRAW:
- /* vector types (Draw export possible) */
- found_type = true;
- if (export_draw != NULL)
- *export_draw = true;
- break;
- default:
- break;
- }
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ ro_gui_menu_destroy();
+ return;
}
- return found_type;
+ gui_form_select_control = control;
+ ro_gui_menu_create(gui_form_select_menu,
+ pointer.pos.x, pointer.pos.y, g->window);
}
/**
- * Prepare the page info window for use.
+ * Import text file into window
*
- * \param *g The GUI window block to use.
+ * \param g gui window containing textarea
+ * \param filename pathname of file to be imported
+ * \return true iff successful
*/
-
-void ro_gui_window_prepare_pageinfo(struct gui_window *g)
+static bool
+ro_gui_window_import_text(struct gui_window *g, const char *filename)
{
- struct hlcache_handle *h = browser_window_get_content(g->bw);
- char icon_buf[20] = "file_xxx";
- char enc_buf[40];
- const char *icon = icon_buf;
- const char *title, *url;
- lwc_string *mime;
- const char *enc = "-";
-
- assert(h);
-
- title = content_get_title(h);
- if (title == NULL)
- title = "-";
- url = nsurl_access(hlcache_handle_get_url(h));
- if (url == NULL)
- url = "-";
- mime = content_get_mime_type(h);
-
- sprintf(icon_buf, "file_%x", ro_content_filetype(h));
- if (!ro_gui_wimp_sprite_exists(icon_buf))
- sprintf(icon_buf, "file_xxx");
+ fileswitch_object_type obj_type;
+ os_error *error;
+ char *buf, *utf8_buf, *sp;
+ int size;
+ nserror ret;
+ const char *ep;
+ char *p;
- if (content_get_type(h) == CONTENT_HTML) {
- if (content_get_encoding(h, CONTENT_ENCODING_NORMAL)) {
- snprintf(enc_buf, sizeof enc_buf, "%s (%s)",
- content_get_encoding(h, CONTENT_ENCODING_NORMAL),
- content_get_encoding(h, CONTENT_ENCODING_SOURCE));
- enc = enc_buf;
- } else {
- enc = messages_get("EncodingUnk");
- }
+ error = xosfile_read_stamped(filename, &obj_type, NULL, NULL,
+ &size, NULL, NULL);
+ if (error) {
+ NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s",
+ error->errnum, error->errmess);
+ ro_warn_user("FileError", error->errmess);
+ return true; /* was for us, but it didn't work! */
}
- ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_ICON,
- icon, true);
- ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TITLE,
- title, true);
- ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_URL,
- url, true);
- ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_ENC,
- enc, true);
- ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TYPE,
- lwc_string_data(mime), true);
-
- lwc_string_unref(mime);
-}
-
+ /* Allocate one byte more than needed to ensure that the buffer is
+ * always terminated, regardless of file contents.
+ */
-/**
- * Prepare the object info window for use
- *
- * \param *object the object for which information is to be displayed
- * \param *target_url corresponding url, if any
- */
+ buf = calloc(size + 1, sizeof(char));
+ if (!buf) {
+ ro_warn_user("NoMemory", NULL);
+ return true;
+ }
-void ro_gui_window_prepare_objectinfo(struct hlcache_handle *object, nsurl *target_url)
-{
- char icon_buf[20] = "file_xxx";
- const char *url;
- lwc_string *mime;
- const char *target = "-";
+ error = xosfile_load_stamped(filename, (byte*)buf,
+ NULL, NULL, NULL, NULL, NULL);
- sprintf(icon_buf, "file_%.3x",ro_content_filetype(object));
- if (!ro_gui_wimp_sprite_exists(icon_buf)) {
- sprintf(icon_buf, "file_xxx");
+ if (error) {
+ NSLOG(netsurf, INFO, "xosfile_load_stamped: 0x%x:%s",
+ error->errnum, error->errmess);
+ ro_warn_user("LoadError", error->errmess);
+ free(buf);
+ return true;
}
- url = nsurl_access(hlcache_handle_get_url(object));
- if (url == NULL) {
- url = "-";
+ ret = utf8_from_local_encoding(buf, size, &utf8_buf);
+ if (ret != NSERROR_OK) {
+ /* bad encoding shouldn't happen */
+ assert(ret != NSERROR_BAD_ENCODING);
+ NSLOG(netsurf, INFO, "utf8_from_local_encoding failed");
+ free(buf);
+ ro_warn_user("NoMemory", NULL);
+ return true;
}
- mime = content_get_mime_type(object);
+ size = strlen(utf8_buf);
- if (target_url != NULL) {
- target = nsurl_access(target_url);
- }
+ ep = utf8_buf + size;
+ p = utf8_buf;
- ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_ICON,
- icon_buf, true);
- ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_URL,
- url, true);
- ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TARGET,
- target, true);
- ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TYPE,
- lwc_string_data(mime), true);
+ /* skip leading whitespace */
+ while (isspace(*p)) p++;
- lwc_string_unref(mime);
-}
+ sp = p;
+ while (*p && *p != '\r' && *p != '\n')
+ p += utf8_next(p, ep - p, 0);
+ *p = '\0';
+ if (p > sp)
+ ro_gui_window_launch_url(g, sp);
+
+ free(buf);
+ free(utf8_buf);
+ return true;
+}
-/*
- * User Actions in the browser window
- */
/**
- * Launch a new url in the given window.
- *
- * \param g gui_window to update
- * \param url1 url to be launched
+ * RISC OS browser window operation table
*/
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .invalidate = ro_gui_window_invalidate_area,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
-void ro_gui_window_launch_url(struct gui_window *g, const char *url1)
-{
- nserror error;
- nsurl *url;
+ .set_title = gui_window_set_title,
+ .set_url = ro_gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = riscos_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .save_link = gui_window_save_link,
+ .drag_start = gui_window_drag_start,
+ .scroll_start = gui_window_scroll_start,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+ .create_form_select_menu = gui_window_create_form_select_menu,
- if (url1 == NULL)
- return;
+ /* from save */
+ .drag_save_object = gui_drag_save_object,
+ .drag_save_selection =gui_drag_save_selection,
- ro_gui_url_complete_close();
+ /* from textselection */
+ .start_selection = gui_start_selection,
+};
- error = nsurl_create(url1, &url);
- if (error != NSERROR_OK) {
- ro_warn_user(messages_get_errorcode(error), 0);
- } else {
- ro_gui_window_set_url(g, url);
+struct gui_window_table *riscos_window_table = &window_table;
- browser_window_navigate(g->bw, url,
- NULL, BW_NAVIGATE_HISTORY,
- NULL, NULL, NULL);
- nsurl_unref(url);
- }
-}
+/* exported interface documented in riscos/window.h */
+void ro_gui_window_initialise(void)
+{
+ /* Build the browser window menu. */
-/**
- * Perform a Navigate Home action on a browser window.
- *
- * \param *g The browser window to act on.
- */
+ static const struct ns_menu browser_definition = {
+ "NetSurf", {
+ { "Page", BROWSER_PAGE, 0 },
+ { "Page.PageInfo",BROWSER_PAGE_INFO, &dialog_pageinfo },
+ { "Page.Save", BROWSER_SAVE, &dialog_saveas },
+ { "Page.SaveComp", BROWSER_SAVE_COMPLETE, &dialog_saveas },
+ { "Page.Export", NO_ACTION, 0 },
+#ifdef WITH_DRAW_EXPORT
+ { "Page.Export.Draw", BROWSER_EXPORT_DRAW, &dialog_saveas },
+#endif
+#ifdef WITH_PDF_EXPORT
+ { "Page.Export.PDF", BROWSER_EXPORT_PDF, &dialog_saveas },
+#endif
+ { "Page.Export.Text", BROWSER_EXPORT_TEXT, &dialog_saveas },
+ { "Page.SaveURL", NO_ACTION, 0 },
+ { "Page.SaveURL.URI", BROWSER_SAVE_URL_URI, &dialog_saveas },
+ { "Page.SaveURL.URL", BROWSER_SAVE_URL_URL, &dialog_saveas },
+ { "Page.SaveURL.LinkText", BROWSER_SAVE_URL_TEXT, &dialog_saveas },
+ { "_Page.Print", BROWSER_PRINT, &dialog_print },
+ { "Page.NewWindow", BROWSER_NEW_WINDOW, 0 },
+ { "Page.FindText", BROWSER_FIND_TEXT, &dialog_search },
+ { "Page.ViewSrc", BROWSER_VIEW_SOURCE, 0 },
+ { "Object", BROWSER_OBJECT, 0 },
+ { "Object.Object", BROWSER_OBJECT_OBJECT, 0 },
+ { "Object.Object.ObjInfo", BROWSER_OBJECT_INFO, &dialog_objinfo },
+ { "Object.Object.ObjSave", BROWSER_OBJECT_SAVE, &dialog_saveas },
+ { "Object.Object.Export", BROWSER_OBJECT_EXPORT, 0 },
+ { "Object.Object.Export.Sprite", BROWSER_OBJECT_EXPORT_SPRITE, &dialog_saveas },
+#ifdef WITH_DRAW_EXPORT
+ { "Object.Object.Export.ObjDraw", BROWSER_OBJECT_EXPORT_DRAW, &dialog_saveas },
+#endif
+ { "Object.Object.SaveURL", NO_ACTION, 0 },
+ { "Object.Object.SaveURL.URI", BROWSER_OBJECT_SAVE_URL_URI, &dialog_saveas },
+ { "Object.Object.SaveURL.URL", BROWSER_OBJECT_SAVE_URL_URL, &dialog_saveas },
+ { "Object.Object.SaveURL.LinkText", BROWSER_OBJECT_SAVE_URL_TEXT, &dialog_saveas },
+ { "Object.Object.ObjPrint", BROWSER_OBJECT_PRINT, 0 },
+ { "Object.Object.ObjReload", BROWSER_OBJECT_RELOAD, 0 },
+ { "Object.Link", BROWSER_OBJECT_LINK, 0 },
+ { "Object.Link.LinkSave", BROWSER_LINK_SAVE, 0 },
+ { "Object.Link.LinkSave.URI", BROWSER_LINK_SAVE_URI, &dialog_saveas },
+ { "Object.Link.LinkSave.URL", BROWSER_LINK_SAVE_URL, &dialog_saveas },
+ { "Object.Link.LinkSave.LinkText", BROWSER_LINK_SAVE_TEXT, &dialog_saveas },
+ { "_Object.Link.LinkDload", BROWSER_LINK_DOWNLOAD, 0 },
+ { "Object.Link.LinkNew", BROWSER_LINK_NEW_WINDOW, 0 },
+ { "Selection", BROWSER_SELECTION, 0 },
+ { "_Selection.SelSave", BROWSER_SELECTION_SAVE, &dialog_saveas },
+ { "Selection.Copy", BROWSER_SELECTION_COPY, 0 },
+ { "Selection.Cut", BROWSER_SELECTION_CUT, 0 },
+ { "_Selection.Paste", BROWSER_SELECTION_PASTE, 0 },
+ { "Selection.Clear", BROWSER_SELECTION_CLEAR, 0 },
+ { "Selection.SelectAll", BROWSER_SELECTION_ALL, 0 },
+ { "Navigate", NO_ACTION, 0 },
+ { "Navigate.Home", BROWSER_NAVIGATE_HOME, 0 },
+ { "Navigate.Back", BROWSER_NAVIGATE_BACK, 0 },
+ { "Navigate.Forward", BROWSER_NAVIGATE_FORWARD, 0 },
+ { "_Navigate.UpLevel", BROWSER_NAVIGATE_UP, 0 },
+ { "Navigate.Reload", BROWSER_NAVIGATE_RELOAD_ALL, 0 },
+ { "Navigate.Stop", BROWSER_NAVIGATE_STOP, 0 },
+ { "View", NO_ACTION, 0 },
+ { "View.ScaleView", BROWSER_SCALE_VIEW, &dialog_zoom },
+ { "View.Images", NO_ACTION, 0 },
+ { "View.Images.ForeImg", BROWSER_IMAGES_FOREGROUND, 0 },
+ { "View.Images.BackImg", BROWSER_IMAGES_BACKGROUND, 0 },
+ { "View.Toolbars", NO_ACTION, 0 },
+ { "View.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
+ { "View.Toolbars.ToolAddress", TOOLBAR_ADDRESS_BAR, 0 },
+ { "_View.Toolbars.ToolThrob", TOOLBAR_THROBBER, 0 },
+ { "View.Toolbars.EditToolbar", TOOLBAR_EDIT, 0 },
+ { "_View.Render", NO_ACTION, 0 },
+ { "View.Render.RenderAnims", BROWSER_BUFFER_ANIMS, 0 },
+ { "View.Render.RenderAll", BROWSER_BUFFER_ALL, 0 },
+ { "_View.OptDefault", BROWSER_SAVE_VIEW, 0 },
+ { "View.Window", NO_ACTION, 0 },
+ { "View.Window.WindowSave", BROWSER_WINDOW_DEFAULT, 0 },
+ { "View.Window.WindowStagr", BROWSER_WINDOW_STAGGER, 0 },
+ { "_View.Window.WindowSize", BROWSER_WINDOW_COPY, 0 },
+ { "View.Window.WindowReset", BROWSER_WINDOW_RESET, 0 },
+ { "Utilities", NO_ACTION, 0 },
+ { "Utilities.Hotlist", HOTLIST_SHOW, 0 },
+ { "Utilities.Hotlist.HotlistAdd", HOTLIST_ADD_URL, 0 },
+ { "Utilities.Hotlist.HotlistShow", HOTLIST_SHOW, 0 },
+ { "Utilities.History", HISTORY_SHOW_GLOBAL, 0 },
+ { "Utilities.History.HistLocal", HISTORY_SHOW_LOCAL, 0 },
+ { "Utilities.History.HistGlobal", HISTORY_SHOW_GLOBAL, 0 },
+ { "Utilities.Cookies", COOKIES_SHOW, 0 },
+ { "Utilities.Cookies.ShowCookies", COOKIES_SHOW, 0 },
+ { "Utilities.Cookies.DeleteCookies", COOKIES_DELETE, 0 },
+ { "Help", HELP_OPEN_CONTENTS, 0 },
+ { "Help.HelpContent", HELP_OPEN_CONTENTS, 0 },
+ { "Help.HelpGuide", HELP_OPEN_GUIDE, 0 },
+ { "_Help.HelpInfo", HELP_OPEN_INFORMATION, 0 },
+ { "Help.HelpCredits", HELP_OPEN_CREDITS, 0 },
+ { "_Help.HelpLicence", HELP_OPEN_LICENCE, 0 },
+ { "Help.HelpInter", HELP_LAUNCH_INTERACTIVE, 0 },
+ {NULL, 0, 0}
+ }
+ };
+ ro_gui_browser_window_menu =
+ ro_gui_menu_define_menu(&browser_definition);
+
+}
-void ro_gui_window_action_home(struct gui_window *g)
+
+/* exported interface documented in riscos/window.h */
+nserror
+ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect)
{
- static const char *addr = NETSURF_HOMEPAGE;
- nsurl *url;
- nserror error;
+ bool use_buffer;
+ int x0, y0, x1, y1;
+ struct update_box *cur;
+ wimp_window_info info;
+ os_error *error;
- if (g == NULL || g->bw == NULL)
- return;
+ assert(g);
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
+ if (rect == NULL) {
+ info.w = g->window;
+ error = xwimp_get_window_info_header_only(&info);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_info_header_only: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ error = xwimp_force_redraw(g->window,
+ info.extent.x0, info.extent.y0,
+ info.extent.x1, info.extent.y1);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_INVALID;
+ }
+ return NSERROR_OK;
}
- error = nsurl_create(addr, &url);
- if (error == NSERROR_OK) {
- error = browser_window_navigate(g->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
+ x0 = floorf(rect->x0 * 2 * g->scale);
+ y0 = -ceilf(rect->y1 * 2 * g->scale);
+ x1 = ceilf(rect->x1 * 2 * g->scale) + 1;
+ y1 = -floorf(rect->y0 * 2 * g->scale) + 1;
+ use_buffer =
+ (g->option.buffer_everything || g->option.buffer_animations);
+
+ /* try to optimise buffered redraws */
+ if (use_buffer) {
+ for (cur = pending_updates; cur != NULL; cur = cur->next) {
+ if ((cur->g != g) || (!cur->use_buffer)) {
+ continue;
+ }
+ if ((((cur->x0 - x1) < MARGIN) ||
+ ((cur->x1 - x0) < MARGIN)) &&
+ (((cur->y0 - y1) < MARGIN) ||
+ ((cur->y1 - y0) < MARGIN))) {
+ cur->x0 = min(cur->x0, x0);
+ cur->y0 = min(cur->y0, y0);
+ cur->x1 = max(cur->x1, x1);
+ cur->y1 = max(cur->y1, y1);
+ return NSERROR_OK;
+ }
+ }
}
- if (error != NSERROR_OK) {
- ro_warn_user(messages_get_errorcode(error), 0);
+ cur = malloc(sizeof(struct update_box));
+ if (!cur) {
+ NSLOG(netsurf, INFO, "No memory for malloc.");
+ return NSERROR_NOMEM;
}
-}
+ cur->x0 = x0;
+ cur->y0 = y0;
+ cur->x1 = x1;
+ cur->y1 = y1;
+ cur->next = pending_updates;
+ pending_updates = cur;
+ cur->g = g;
+ cur->use_buffer = use_buffer;
+
+ return NSERROR_OK;
+}
-/**
- * Open a new browser window.
- *
- * \param *g The browser window to act on.
- */
-void ro_gui_window_action_new_window(struct gui_window *g)
+/* exported function documented in riscos/window.h */
+nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
{
- nserror error;
+ size_t idn_url_l;
+ char *idn_url_s = NULL;
- if (g == NULL || g->bw == NULL)
- return;
+ if (g->toolbar) {
+ if (nsoption_bool(display_decoded_idn) == true) {
+ if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) != NSERROR_OK)
+ idn_url_s = NULL;
+ }
- error = browser_window_create(BW_CREATE_CLONE,
- browser_window_get_url(g->bw),
- NULL, g->bw, NULL);
+ ro_toolbar_set_url(g->toolbar, idn_url_s ? idn_url_s : nsurl_access(url), true, false);
- if (error != NSERROR_OK) {
- ro_warn_user(messages_get_errorcode(error), 0);
+ if (idn_url_s)
+ free(idn_url_s);
+
+ ro_gui_url_complete_start(g->toolbar);
}
-}
+ return NSERROR_OK;
+}
-/**
- * Open a local history pane for a browser window.
- *
- * \param *g The browser window to act on.
- */
-void ro_gui_window_action_local_history(struct gui_window *g)
+/* exported interface documented in riscos/window.h */
+void ro_gui_window_set_scale(struct gui_window *g, float scale)
{
- if (g != NULL && g->bw != NULL)
- ro_gui_history_open(g, true);
+ g->scale = scale;
+ browser_window_set_scale(g->bw, scale, true);
}
-/**
- * Open a save dialogue for a browser window contents.
- *
- * \param *g The browser window to act on.
- * \param save_type The type of save to open.
- */
-
-void ro_gui_window_action_save(struct gui_window *g, gui_save_type save_type)
+/* exported interface documented in riscos/window.h */
+bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
{
- struct hlcache_handle *h;
-
- if (g == NULL || g->bw == NULL || !browser_window_has_content(g->bw))
- return;
-
- h = browser_window_get_content(g->bw);
- if (h == NULL)
- return;
+ os_error *error;
+ os_coord pos;
- ro_gui_save_prepare(save_type, h, NULL, NULL, NULL);
- ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
-}
+ /* Ignore directories etc. */
+ if (0x1000 <= message->data.data_xfer.file_type)
+ return false;
+ if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
+ message->data.data_xfer.pos.y, &pos))
+ return false;
-/**
- * Open a text search dialogue for a browser window.
- *
- * \param *g The browser window to act on.
- */
+ if (browser_window_drop_file_at_point(g->bw, pos.x, pos.y,
+ message->data.data_xfer.file_name) == false)
+ return false;
-void ro_gui_window_action_search(struct gui_window *g)
-{
- if (g == NULL || g->bw == NULL || !browser_window_can_search(g->bw))
- return;
+ /* send DataLoadAck */
+ message->action = message_DATA_LOAD_ACK;
+ message->your_ref = message->my_ref;
+ error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s\n",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
- ro_gui_search_prepare(g->bw);
- ro_gui_dialog_open_persistent(g->window, dialog_search, true);
+ return true;
}
-/**
- * Open a zoom dialogue for a browser window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_zoom(struct gui_window *g)
+/* exported interface documented in riscos/window.h */
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
{
- if (g == NULL)
- return;
+ os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
- ro_gui_dialog_prepare_zoom(g);
- ro_gui_dialog_open_persistent(g->window, dialog_zoom, true);
+ if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
+ browser_window_mouse_track(g->bw,
+ ro_gui_mouse_drag_state(pointer->buttons,
+ wimp_BUTTON_DOUBLE_CLICK_DRAG),
+ pos.x, pos.y);
}
-/**
- * Add a hotlist entry for a browser window.
- *
- * \param *g The browser window to act on.
- */
-
-static void ro_gui_window_action_add_bookmark(struct gui_window *g)
+/* exported interface documented in riscos/window.h */
+void
+ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
{
- nsurl *url;
+ /* sadly there is no 'legal' way to get the sprite into
+ * the Wimp sprite pool other than via a filing system */
+ const char *temp_fname = "Pipe:$._tmpfile";
+ struct browser_window *bw = g->bw;
+ osspriteop_header *overlay = NULL;
+ osspriteop_header *sprite_header;
+ struct bitmap *bitmap;
+ osspriteop_area *area;
+ int width = 34, height = 34;
+ struct hlcache_handle *h;
+ os_error *error;
+ int len, id;
- if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
- browser_window_has_content(g->bw) == false)
- return;
+ assert(bw);
- url = browser_window_get_url(g->bw);
+ h = browser_window_get_content(bw);
+ if (!h) return;
- ro_gui_hotlist_add_page(url);
- ro_toolbar_update_hotlist(g->toolbar);
-}
+ /* if an overlay sprite is defined, locate it and gets its dimensions
+ * so that we can produce a thumbnail with the same dimensions */
+ if (!ro_gui_wimp_get_sprite("ic_netsfxx", &overlay)) {
+ error = xosspriteop_read_sprite_info(osspriteop_PTR,
+ (osspriteop_area *)0x100,
+ (osspriteop_id)overlay, &width, &height, NULL,
+ NULL);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xosspriteop_read_sprite_info: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("MiscError", error->errmess);
+ overlay = NULL;
+ } else if (sprite_bpp(overlay) != 8) {
+ NSLOG(netsurf, INFO, "overlay sprite is not 8bpp");
+ overlay = NULL;
+ }
+ }
+ /* create the thumbnail sprite */
+ bitmap = riscos_bitmap_create(width, height,
+ BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
+ if (!bitmap) {
+ NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
+ return;
+ }
+ riscos_bitmap_render(bitmap, h);
+ if (overlay) {
+ riscos_bitmap_overlay_sprite(bitmap, overlay);
+ }
+ area = riscos_bitmap_convert_8bpp(bitmap);
+ riscos_bitmap_destroy(bitmap);
+ if (!area) {
+ NSLOG(netsurf, INFO, "Thumbnail conversion failed.");
+ return;
+ }
-/**
- * Remove a hotlist entry for a browser window.
- *
- * \param *g The browser window to act on.
- */
+ /* choose a suitable sprite name */
+ id = 0;
+ while (iconise_used[id])
+ if ((unsigned)++id >= NOF_ELEMENTS(iconise_used)) {
+ id = iconise_next;
+ if ((unsigned)++iconise_next >=
+ NOF_ELEMENTS(iconise_used))
+ iconise_next = 0;
+ break;
+ }
-static void ro_gui_window_action_remove_bookmark(struct gui_window *g)
-{
- nsurl *url;
+ sprite_header = (osspriteop_header *)(area + 1);
+ len = sprintf(sprite_header->name, "ic_netsf%.2d", id);
- if (g == NULL || g->bw == NULL || g->toolbar == NULL ||
- browser_window_has_content(g->bw) == false)
+ error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
+ area, temp_fname);
+ if (error) {
+ NSLOG(netsurf, INFO, "xosspriteop_save_sprite_file: 0x%x:%s",
+ error->errnum, error->errmess);
+ ro_warn_user("MiscError", error->errmess);
+ free(area);
return;
+ }
- url = browser_window_get_url(g->bw);
-
- ro_gui_hotlist_remove_page(url);
-}
+ error = xwimpspriteop_merge_sprite_file(temp_fname);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimpspriteop_merge_sprite_file: 0x%x:%s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ remove(temp_fname);
+ free(area);
+ return;
+ }
+ memcpy(wi->sprite_name, sprite_header->name + 3, len - 2); /* inc NUL */
+ strncpy(wi->title, g->title, sizeof(wi->title));
+ wi->title[sizeof(wi->title) - 1] = '\0';
-/**
- * Open a print dialogue for a browser window.
- *
- * \param *g The browser window to act on.
- */
+ if (wimptextop_string_width(wi->title, 0) > 182) {
+ /* work around bug in Pinboard where it will fail to display
+ * the icon if the text is very wide */
+ if (strlen(wi->title) > 10)
+ wi->title[10] = '\0'; /* pinboard does this anyway */
+ while (wimptextop_string_width(wi->title, 0) > 182)
+ wi->title[strlen(wi->title) - 1] = '\0';
+ }
-void ro_gui_window_action_print(struct gui_window *g)
-{
- if (g == NULL)
- return;
+ wi->size = sizeof(wimp_full_message_window_info);
+ wi->your_ref = wi->my_ref;
+ error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)wi,
+ wi->sender);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
+ else {
+ g->iconise_icon = id;
+ iconise_used[id] = true;
+ }
- ro_gui_print_prepare(g);
- ro_gui_dialog_open_persistent(g->window, dialog_print, true);
+ free(area);
}
-/**
- * Open a page info box for a browser window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_page_info(struct gui_window *g)
+/* exported interface documented in riscos/window.h */
+bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
{
- if (g == NULL || g->bw == NULL ||
- browser_window_has_content(g->bw) == false)
- return;
+ if (message->data.data_xfer.file_type == osfile_TYPE_TEXT &&
+ ro_gui_window_import_text(g,
+ message->data.data_xfer.file_name)) {
+ os_error *error;
- ro_gui_window_prepare_pageinfo(g);
- ro_gui_dialog_open_persistent(g->window, dialog_pageinfo, false);
+ /* send DataLoadAck */
+ message->action = message_DATA_LOAD_ACK;
+ message->your_ref = message->my_ref;
+ error = xwimp_send_message(wimp_USER_MESSAGE, message,
+ message->sender);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_send_message: 0x%x: %s\n",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
+ return true;
+ }
+ return false;
}
-/*
- * Window and Toolbar Redraw and Update
- */
-
-/**
- * Redraws the content for all windows.
- */
-
-void ro_gui_window_redraw_all(void)
+/* exported interface documented in riscos/window.h */
+bool ro_gui_window_check_menu(wimp_menu *menu)
{
- struct gui_window *g;
- for (g = window_list; g; g = g->next)
- gui_window_redraw_window(g);
+ return (ro_gui_browser_window_menu == menu) ? true : false;
}
-/**
- * Remove all pending update boxes for a window
- *
- * \param g gui_window
- */
-void ro_gui_window_remove_update_boxes(struct gui_window *g)
+/* exported interface documented in riscos/window.h */
+void ro_gui_window_redraw_all(void)
{
- struct update_box *cur;
-
- for (cur = pending_updates; cur != NULL; cur = cur->next) {
- if (cur->g == g)
- cur->g = NULL;
+ struct gui_window *g;
+ for (g = window_list; g; g = g->next) {
+ ro_gui_window_invalidate_area(g, NULL);
}
}
-/**
- * Redraw any pending update boxes.
- */
+/* exported interface documented in riscos/window.h */
void ro_gui_window_update_boxes(void)
{
osbool more;
@@ -4158,7 +4601,8 @@ void ro_gui_window_update_boxes(void)
error = xwimp_update_window(&update, &more);
if (error) {
- LOG("xwimp_update_window: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_update_window: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
continue;
}
@@ -4191,7 +4635,10 @@ void ro_gui_window_update_boxes(void)
* found. This appears to be a bug in RISC OS. */
if (error && !(use_buffer &&
error->errnum == error_WIMP_GET_RECT)) {
- LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO,
+ "xwimp_get_rectangle: 0x%x: %s",
+ error->errnum,
+ error->errmess);
ro_warn_user("WimpError", error->errmess);
ro_gui_current_redraw_gui = NULL;
continue;
@@ -4210,22 +4657,7 @@ void ro_gui_window_update_boxes(void)
}
-/**
- * callback from core to reformat a window.
- */
-static void riscos_window_reformat(struct gui_window *gw)
-{
- if (gw != NULL) {
- browser_window_reformat(gw->bw, false,
- gw->old_width / 2,
- gw->old_height / 2);
- }
-}
-
-/**
- * Destroy all browser windows.
- */
-
+/* exported interface documented in riscos/window.h */
void ro_gui_window_quit(void)
{
while (window_list) {
@@ -4237,13 +4669,10 @@ void ro_gui_window_quit(void)
}
-/**
- * Animate the "throbbers" of all browser windows.
- */
-
+/* exported interface documented in riscos/window.h */
void ro_gui_throb(void)
{
- struct gui_window *g;
+ struct gui_window *g;
for (g = window_list; g; g = g->next) {
if (!g->active)
@@ -4254,245 +4683,7 @@ void ro_gui_throb(void)
}
-/**
- * Update the toolbar buttons for a given browser window to reflect the
- * current state of its contents.
- *
- * Note that the parameters to this function are arranged so that it can be
- * supplied to the toolbar module as an button state update callback.
- *
- * \param *g The browser window to update.
- */
-
-void ro_gui_window_update_toolbar_buttons(struct gui_window *g)
-{
- struct browser_window *bw;
- struct toolbar *toolbar;
-
- if (g == NULL || g->toolbar == NULL)
- return;
-
- bw = g->bw;
- toolbar = g->toolbar;
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_RELOAD,
- !browser_window_reload_available(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_STOP,
- !browser_window_stop_available(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_BACK,
- !browser_window_back_available(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_FORWARD,
- !browser_window_forward_available(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_UP,
- !browser_window_up_available(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SEARCH,
- !browser_window_can_search(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SCALE,
- !browser_window_has_content(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_PRINT,
- !browser_window_has_content(bw));
-
- ro_toolbar_set_button_shaded_state(toolbar, TOOLBAR_BUTTON_SAVE_SOURCE,
- !browser_window_has_content(bw));
-
- ro_toolbar_update_urlsuggest(toolbar);
-}
-
-
-/**
- * Update a window to reflect a change in toolbar size: used as a callback by
- * the toolbar module when a toolbar height changes.
- *
- * \param *data void pointer the window's gui_window struct
- */
-
-void ro_gui_window_update_toolbar(void *data)
-{
- struct gui_window *g = (struct gui_window *) data;
-
- if (g != NULL)
- gui_window_update_extent(g);
-}
-
-
-/**
- * Save a new toolbar button configuration: used as a callback by the toolbar
- * module when a buttonbar edit has finished.
- *
- * \param *data void pointer to the window's gui_window struct
- * \param *config pointer to a malloc()'d button config string.
- */
-
-void ro_gui_window_save_toolbar_buttons(void *data, char *config)
-{
- nsoption_set_charp(toolbar_browser, config);
- ro_gui_save_options();
-}
-
-
-/**
- * Update a window and its toolbar to reflect a new theme: used as a callback
- * by the toolbar module when a theme change affects a toolbar.
- *
- * \param *data void pointer to the window's gui_window struct
- * \param ok true if the bar still exists; else false.
- */
-
-void ro_gui_window_update_theme(void *data, bool ok)
-{
- struct gui_window *g = (struct gui_window *) data;
-
- if (g != NULL && g->toolbar != NULL) {
- if (ok) {
- gui_window_update_extent(g);
- } else {
- g->toolbar = NULL;
- }
- }
-}
-
-
-/*
- * General Window Support
- */
-
-/**
- * Import text file into window
- *
- * \param g gui window containing textarea
- * \param filename pathname of file to be imported
- * \return true iff successful
- */
-
-bool ro_gui_window_import_text(struct gui_window *g, const char *filename)
-{
- fileswitch_object_type obj_type;
- os_error *error;
- char *buf, *utf8_buf, *sp;
- int size;
- nserror ret;
- const char *ep;
- char *p;
-
- error = xosfile_read_stamped(filename, &obj_type, NULL, NULL,
- &size, NULL, NULL);
- if (error) {
- LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess);
- ro_warn_user("FileError", error->errmess);
- return true; /* was for us, but it didn't work! */
- }
-
- /* Allocate one byte more than needed to ensure that the buffer is
- * always terminated, regardless of file contents.
- */
-
- buf = calloc(size + 1, sizeof(char));
- if (!buf) {
- ro_warn_user("NoMemory", NULL);
- return true;
- }
-
- error = xosfile_load_stamped(filename, (byte*)buf,
- NULL, NULL, NULL, NULL, NULL);
-
- if (error) {
- LOG("xosfile_load_stamped: 0x%x:%s", error->errnum, error->errmess);
- ro_warn_user("LoadError", error->errmess);
- free(buf);
- return true;
- }
-
- ret = utf8_from_local_encoding(buf, size, &utf8_buf);
- if (ret != NSERROR_OK) {
- /* bad encoding shouldn't happen */
- assert(ret != NSERROR_BAD_ENCODING);
- LOG("utf8_from_local_encoding failed");
- free(buf);
- ro_warn_user("NoMemory", NULL);
- return true;
- }
- size = strlen(utf8_buf);
-
- ep = utf8_buf + size;
- p = utf8_buf;
-
- /* skip leading whitespace */
- while (isspace(*p)) p++;
-
- sp = p;
- while (*p && *p != '\r' && *p != '\n')
- p += utf8_next(p, ep - p, 0);
- *p = '\0';
-
- if (p > sp)
- ro_gui_window_launch_url(g, sp);
-
- free(buf);
- free(utf8_buf);
- return true;
-}
-
-
-/**
- * Clones a browser window's options.
- *
- * \param new_gui the new gui window
- * \param old_gui the gui window to clone from, or NULL for default
- */
-
-void ro_gui_window_clone_options(
- struct gui_window *new_gui,
- struct gui_window *old_gui)
-{
- assert(new_gui);
-
- /* Clone the basic options
- */
- if (!old_gui) {
- new_gui->option.buffer_animations = nsoption_bool(buffer_animations);
- new_gui->option.buffer_everything = nsoption_bool(buffer_everything);
- } else {
- new_gui->option = old_gui->option;
- }
-
- /* Set up the toolbar
- */
- if (new_gui->toolbar) {
- ro_toolbar_set_display_buttons(new_gui->toolbar,
- nsoption_bool(toolbar_show_buttons));
- ro_toolbar_set_display_url(new_gui->toolbar,
- nsoption_bool(toolbar_show_address));
- ro_toolbar_set_display_throbber(new_gui->toolbar,
- nsoption_bool(toolbar_show_throbber));
- if ((old_gui) && (old_gui->toolbar)) {
- ro_toolbar_set_display_buttons(new_gui->toolbar,
- ro_toolbar_get_display_buttons(
- old_gui->toolbar));
- ro_toolbar_set_display_url(new_gui->toolbar,
- ro_toolbar_get_display_url(
- old_gui->toolbar));
- ro_toolbar_set_display_throbber(new_gui->toolbar,
- ro_toolbar_get_display_throbber(
- old_gui->toolbar));
- ro_toolbar_process(new_gui->toolbar, -1, true);
- }
- }
-}
-
-
-/**
- * Makes a browser window's options the default.
- *
- * \param gui The riscos gui window to set default options in.
- */
-
+/* exported interface documented in riscos/window.h */
void ro_gui_window_default_options(struct gui_window *gui)
{
if (gui == NULL)
@@ -4520,179 +4711,20 @@ void ro_gui_window_default_options(struct gui_window *gui)
}
-/*
- * Custom Menu Support
- */
-
-/**
- * Prepare or reprepare a form select menu, setting up the menu handle
- * globals in the process.
- *
- * \param g The RISC OS gui window the menu is in.
- * \param control The form control needing a menu.
- * \return true if the menu is OK to be opened; else false.
- */
-
-bool ro_gui_window_prepare_form_select_menu(struct gui_window *g,
- struct form_control *control)
-{
- unsigned int item, entries;
- char *text_convert, *temp;
- struct form_option *option;
- bool reopen = true;
- nserror err;
-
- assert(control);
-
- /* enumerate the entries */
- entries = 0;
- option = form_select_get_option(control, entries);
- while (option != NULL) {
- entries++;
- option = form_select_get_option(control, entries);
- }
-
- if (entries == 0) {
- /* no menu to display */
- ro_gui_menu_destroy();
- return false;
- }
-
- /* free riscos menu if there already is one */
- if ((gui_form_select_menu) && (control != gui_form_select_control)) {
- for (item = 0; ; item++) {
- free(gui_form_select_menu->entries[item].data.
- indirected_text.text);
- if (gui_form_select_menu->entries[item].menu_flags &
- wimp_MENU_LAST)
- break;
- }
- free(gui_form_select_menu->title_data.indirected_text.text);
- free(gui_form_select_menu);
- gui_form_select_menu = 0;
- }
-
- /* allocate new riscos menu */
- if (!gui_form_select_menu) {
- reopen = false;
- gui_form_select_menu = malloc(wimp_SIZEOF_MENU(entries));
- if (!gui_form_select_menu) {
- ro_warn_user("NoMemory", 0);
- ro_gui_menu_destroy();
- return false;
- }
- err = utf8_to_local_encoding(messages_get("SelectMenu"), 0,
- &text_convert);
- if (err != NSERROR_OK) {
- /* badenc should never happen */
- assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_local_encoding failed");
- ro_warn_user("NoMemory", 0);
- ro_gui_menu_destroy();
- return false;
- }
- gui_form_select_menu->title_data.indirected_text.text =
- text_convert;
- ro_gui_menu_init_structure(gui_form_select_menu, entries);
- }
-
- /* initialise menu entries from form control */
- for (item = 0; item < entries; item++) {
- option = form_select_get_option(control, item);
- gui_form_select_menu->entries[item].menu_flags = 0;
- if (option->selected)
- gui_form_select_menu->entries[item].menu_flags =
- wimp_MENU_TICKED;
- if (!reopen) {
-
- /* convert spaces to hard spaces to stop things
- * like 'Go Home' being treated as if 'Home' is a
- * keyboard shortcut and right aligned in the menu.
- */
-
- temp = cnv_space2nbsp(option->text);
- if (!temp) {
- LOG("cnv_space2nbsp failed");
- ro_warn_user("NoMemory", 0);
- ro_gui_menu_destroy();
- return false;
- }
-
- err = utf8_to_local_encoding(temp,
- 0, &text_convert);
- if (err != NSERROR_OK) {
- /* A bad encoding should never happen,
- * so assert this */
- assert(err != NSERROR_BAD_ENCODING);
- LOG("utf8_to_enc failed");
- ro_warn_user("NoMemory", 0);
- ro_gui_menu_destroy();
- return false;
- }
-
- free(temp);
-
- gui_form_select_menu->entries[item].data.indirected_text.text =
- text_convert;
- gui_form_select_menu->entries[item].data.indirected_text.size =
- strlen(gui_form_select_menu->entries[item].
- data.indirected_text.text) + 1;
- }
- }
-
- gui_form_select_menu->entries[0].menu_flags |=
- wimp_MENU_TITLE_INDIRECTED;
- gui_form_select_menu->entries[item - 1].menu_flags |= wimp_MENU_LAST;
-
- return true;
-}
-
-/**
- * Process selections from a form select menu, passing them back to the core.
- *
- * \param *g The browser window affected by the menu.
- * \param *selection The menu selection.
- */
-
-void ro_gui_window_process_form_select_menu(struct gui_window *g,
- wimp_selection *selection)
-{
- assert(g != NULL);
-
- if (selection->items[0] >= 0)
- form_select_process_selection(gui_form_select_control,
- selection->items[0]);
-}
-
-
-/*
- * Window and Toolbar Lookup
- */
-
-/**
- * Convert a RISC OS window handle to a gui_window.
- *
- * \param window RISC OS window handle.
- * \return A pointer to a riscos gui window if found or NULL.
- */
-
+/* exported interface documented in riscos/window.h */
struct gui_window *ro_gui_window_lookup(wimp_w window)
{
struct gui_window *g;
- for (g = window_list; g; g = g->next)
- if (g->window == window)
+ for (g = window_list; g; g = g->next) {
+ if (g->window == window) {
return g;
+ }
+ }
return NULL;
}
-/**
- * Convert a toolbar RISC OS window handle to a gui_window.
- *
- * \param window RISC OS window handle of a toolbar
- * \return pointer to a structure if found, NULL otherwise
- */
-
+/* exported interface documented in riscos/window.h */
struct gui_window *ro_gui_toolbar_lookup(wimp_w window)
{
struct gui_window *g = NULL;
@@ -4710,22 +4742,9 @@ struct gui_window *ro_gui_toolbar_lookup(wimp_w window)
}
-/*
- * Core to RISC OS Conversions
- */
-
-/**
- * Convert x,y screen co-ordinates into window co-ordinates.
- *
- * \param g gui window
- * \param x x ordinate
- * \param y y ordinate
- * \param pos receives position in window co-ordinatates
- * \return true iff conversion successful
- */
-
-bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
- os_coord *pos)
+/* exported interface documented in riscos/window.h */
+bool
+ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
{
wimp_window_state state;
os_error *error;
@@ -4735,7 +4754,8 @@ bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -4745,18 +4765,11 @@ bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
}
-/**
- * Convert x,y window co-ordinates into screen co-ordinates.
- *
- * \param g gui window
- * \param x x ordinate
- * \param y y ordinate
- * \param pos receives position in screen co-ordinatates
- * \return true iff conversion successful
- */
-
-bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
- os_coord *pos)
+/* exported interface documented in riscos/window.h */
+bool ro_gui_window_to_screen_pos(struct gui_window *g,
+ int x,
+ int y,
+ os_coord *pos)
{
wimp_window_state state;
os_error *error;
@@ -4766,7 +4779,8 @@ bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x:%s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
return false;
}
@@ -4776,24 +4790,9 @@ bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
}
-/*
- * Miscellaneous Functions
- *
- * \TODO -- These items might well belong elsewhere.
- */
-
-/**
- * Returns the state of the mouse buttons and modifiers keys for a
- * mouse action, suitable for passing to the OS-independent
- * browser window/ treeview/ etc code.
- *
- * \param buttons Wimp button state.
- * \param type Wimp work-area/icon type for decoding.
- * \return NetSurf core button state.
- */
-
-browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons,
- wimp_icon_flags type)
+/* exported interface documented in riscos/window.h */
+enum browser_mouse_state
+ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type)
{
browser_mouse_state state = 0; /* Blank state with nothing set */
static struct {
@@ -4908,18 +4907,9 @@ browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons,
}
-/**
- * Returns the state of the mouse buttons and modifiers keys whilst
- * dragging, for passing to the OS-independent browser window/ treeview/
- * etc code
- *
- * \param buttons Wimp button state.
- * \param type Wimp work-area/icon type for decoding.
- * \return NetSurf core button state.
- */
-
-browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
- wimp_icon_flags type)
+/* exported interface documented in riscos/window.h */
+browser_mouse_state
+ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type)
{
browser_mouse_state state = 0; /* Blank state with nothing set */
@@ -4947,10 +4937,7 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
}
-/**
- * Returns true iff one or more Shift keys is held down
- */
-
+/* exported interface documented in riscos/window.h */
bool ro_gui_shift_pressed(void)
{
int shift = 0;
@@ -4959,10 +4946,7 @@ bool ro_gui_shift_pressed(void)
}
-/**
- * Returns true iff one or more Ctrl keys is held down
- */
-
+/* exported interface documented in riscos/window.h */
bool ro_gui_ctrl_pressed(void)
{
int ctrl = 0;
@@ -4971,10 +4955,7 @@ bool ro_gui_ctrl_pressed(void)
}
-/**
- * Returns true iff one or more Alt keys is held down
- */
-
+/* exported interface documented in riscos/window.h */
bool ro_gui_alt_pressed(void)
{
int alt = 0;
@@ -4982,39 +4963,47 @@ bool ro_gui_alt_pressed(void)
return (alt == 0xff);
}
-static struct gui_window_table window_table = {
- .create = gui_window_create,
- .destroy = gui_window_destroy,
- .redraw = gui_window_redraw_window,
- .update = gui_window_update_box,
- .get_scroll = gui_window_get_scroll,
- .set_scroll = gui_window_set_scroll,
- .get_dimensions = gui_window_get_dimensions,
- .update_extent = gui_window_update_extent,
- .reformat = riscos_window_reformat,
- .set_title = gui_window_set_title,
- .set_url = ro_gui_window_set_url,
- .set_icon = gui_window_set_icon,
- .set_status = riscos_window_set_status,
- .set_pointer = gui_window_set_pointer,
- .place_caret = gui_window_place_caret,
- .remove_caret = gui_window_remove_caret,
- .save_link = gui_window_save_link,
- .drag_start = gui_window_drag_start,
- .scroll_visible = gui_window_scroll_visible,
- .scroll_start = gui_window_scroll_start,
- .new_content = gui_window_new_content,
- .start_throbber = gui_window_start_throbber,
- .stop_throbber = gui_window_stop_throbber,
- .create_form_select_menu = gui_window_create_form_select_menu,
+/* exported interface documented in riscos/window.h */
+void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+{
+ static gui_pointer_shape curr_pointer = GUI_POINTER_DEFAULT;
+ struct ro_gui_pointer_entry *entry;
+ os_error *error;
- /* from save */
- .drag_save_object = gui_drag_save_object,
- .drag_save_selection =gui_drag_save_selection,
+ if (shape == curr_pointer)
+ return;
- /* from textselection */
- .start_selection = gui_start_selection,
-};
+ assert(shape < sizeof ro_gui_pointer_table /
+ sizeof ro_gui_pointer_table[0]);
-struct gui_window_table *riscos_window_table = &window_table;
+ entry = &ro_gui_pointer_table[shape];
+
+ if (entry->wimp_area) {
+ /* pointer in the Wimp's sprite area */
+ error = xwimpspriteop_set_pointer_shape(entry->sprite_name,
+ 1, entry->xactive, entry->yactive, 0, 0);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimpspriteop_set_pointer_shape: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
+ } else {
+ /* pointer in our own sprite area */
+ error = xosspriteop_set_pointer_shape(osspriteop_USER_AREA,
+ gui_sprites,
+ (osspriteop_id) entry->sprite_name,
+ 1, entry->xactive, entry->yactive, 0, 0);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xosspriteop_set_pointer_shape: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ }
+ }
+
+ curr_pointer = shape;
+}
diff --git a/frontends/riscos/window.h b/frontends/riscos/window.h
index 2e6f6e9aa..0a5bd43c2 100644
--- a/frontends/riscos/window.h
+++ b/frontends/riscos/window.h
@@ -30,10 +30,21 @@ struct nsurl;
extern struct gui_window_table *riscos_window_table;
+/**
+ * Initialise the browser window module and its menus.
+ */
void ro_gui_window_initialise(void);
+
+/**
+ * Check if a particular menu handle is a browser window menu
+ *
+ * \param menu The menu in question.
+ * \return true if this menu is a browser window menu
+ */
bool ro_gui_window_check_menu(wimp_menu *menu);
+
/**
* Set the contents of a window's address bar.
*
@@ -42,5 +53,201 @@ bool ro_gui_window_check_menu(wimp_menu *menu);
*/
nserror ro_gui_window_set_url(struct gui_window *g, struct nsurl *url);
+
+/**
+ * Cause an area of a window to be invalidated
+ *
+ * The specified area of the window should now be considered out of
+ * date. If the entire window is invalidated this simply calls
+ * wimp_force_redraw() otherwise the area is added to a queue of
+ * pending updates which will be processed from a wimp poll allowing
+ * multiple invalidation requests to be agregated.
+ *
+ * \param g The window to update
+ * \param rect The area of the window to update or NULL to redraw entire contents.
+ */
+nserror ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect);
+
+
+/**
+ * Set a gui_window's scale
+ */
+void ro_gui_window_set_scale(struct gui_window *g, float scale);
+
+
+/**
+ * Handle Message_DataLoad (file dragged in) for a window.
+ *
+ * If the file was dragged into a form file input, it is used as the value.
+ *
+ * \param g window
+ * \param message Message_DataLoad block
+ * \return true if the load was processed
+ */
+bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
+
+
+/**
+ * Handle pointer movements in a browser window.
+ *
+ * \param pointer new mouse position
+ * \param data browser window that the pointer is in
+ */
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data);
+
+
+/**
+ * Window is being iconised.
+ *
+ * Create a suitable thumbnail sprite (which, sadly, must be in the
+ * Wimp sprite pool), and return the sprite name and truncated title
+ * to the iconiser
+ *
+ * \param g the gui window being iconised
+ * \param wi the WindowInfo message from the iconiser
+ */
+void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi);
+
+
+/**
+ * Handle Message_DataLoad (file dragged in) for a toolbar
+ *
+ * @todo This belongs in the toolbar module, and should be moved there
+ * once the module is able to usefully handle its own events.
+ *
+ * \param g window
+ * \param message Message_DataLoad block
+ * \return true if the load was processed
+ */
+bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
+
+
+/**
+ * Redraws the content for all windows.
+ */
+void ro_gui_window_redraw_all(void);
+
+
+/**
+ * Redraw any pending update boxes.
+ */
+void ro_gui_window_update_boxes(void);
+
+
+/**
+ * Destroy all browser windows.
+ */
+void ro_gui_window_quit(void);
+
+
+/**
+ * Close all browser windows
+ *
+ * no need for a separate fn same operation as quit
+*/
+#define ro_gui_window_close_all ro_gui_window_quit
+
+
+/**
+ * Animate the "throbbers" of all browser windows.
+ */
+void ro_gui_throb(void);
+
+/**
+ * Makes a browser window's options the default.
+ *
+ * \param gui The riscos gui window to set default options in.
+ */
+void ro_gui_window_default_options(struct gui_window *gui);
+
+
+/**
+ * Convert a RISC OS window handle to a gui_window.
+ *
+ * \param window RISC OS window handle.
+ * \return A pointer to a riscos gui window if found or NULL.
+ */
+struct gui_window *ro_gui_window_lookup(wimp_w window);
+
+
+/**
+ * Convert a toolbar RISC OS window handle to a gui_window.
+ *
+ * \param window RISC OS window handle of a toolbar
+ * \return pointer to a structure if found, NULL otherwise
+ */
+struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
+
+
+/**
+ * Convert x,y screen co-ordinates into window co-ordinates.
+ *
+ * \param g gui window
+ * \param x x ordinate
+ * \param y y ordinate
+ * \param pos receives position in window co-ordinatates
+ * \return true iff conversion successful
+ */
+bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos);
+
+
+/**
+ * Convert x,y window co-ordinates into screen co-ordinates.
+ *
+ * \param g gui window
+ * \param x x ordinate
+ * \param y y ordinate
+ * \param pos receives position in screen co-ordinatates
+ * \return true iff conversion successful
+ */
+bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);
+
+/**
+ * Returns the state of the mouse buttons and modifiers keys for a
+ * mouse action, suitable for passing to the OS-independent
+ * browser window/ treeview/ etc code.
+ *
+ * \param buttons Wimp button state.
+ * \param type Wimp work-area/icon type for decoding.
+ * \return NetSurf core button state.
+ */
+enum browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type);
+
+
+/**
+ * Returns the state of the mouse buttons and modifiers keys whilst
+ * dragging, for passing to the OS-independent browser window/ treeview/
+ * etc code
+ *
+ * \param buttons Wimp button state.
+ * \param type Wimp work-area/icon type for decoding.
+ * \return NetSurf core button state.
+ */
+enum browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type);
+
+
+/**
+ * Returns true iff one or more Shift keys is held down
+ */
+bool ro_gui_shift_pressed(void);
+
+
+/**
+ * Returns true iff one or more Ctrl keys is held down
+ */
+bool ro_gui_ctrl_pressed(void);
+
+
+/**
+ * Returns true iff one or more Alt keys is held down
+ */
+bool ro_gui_alt_pressed(void);
+
+
+/**
+ * Change mouse pointer shape
+ */
+void gui_window_set_pointer(struct gui_window *g, enum gui_pointer_shape shape);
+
#endif