summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2004-07-21 20:02:13 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2004-07-21 20:02:13 +0000
commitd89753a11ba1125efb23079eae3372f8812ff442 (patch)
tree28556a5509def83540ee9763aa763b70dc789cab /riscos
parent0383834501d86df607f632d856bf757ac6dac172 (diff)
downloadnetsurf-d89753a11ba1125efb23079eae3372f8812ff442.tar.gz
netsurf-d89753a11ba1125efb23079eae3372f8812ff442.tar.bz2
[project @ 2004-07-21 20:02:13 by rjw]
Less compiler warnings. Fixed create_folder window title indirection from being too small. Support for help keys for greyed out menu items/icons. svn path=/import/netsurf/; revision=1135
Diffstat (limited to 'riscos')
-rw-r--r--riscos/help.c63
-rw-r--r--riscos/menus.c18
-rw-r--r--riscos/toolbar.c2
-rw-r--r--riscos/wimp.c17
-rw-r--r--riscos/wimp.h6
5 files changed, 82 insertions, 24 deletions
diff --git a/riscos/help.c b/riscos/help.c
index 2aa4bf7a6..d247f51b4 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -19,6 +19,7 @@
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
#include "netsurf/riscos/toolbar.h"
+#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/log.h"
@@ -50,6 +51,10 @@
of numbers representing the menu structure (eg 'HelpBrowserMenu3-1-2').
If '<key><identifier>' is not available, then simply '<key>' is then used. For example
if 'HelpToolbar7' is not available then 'HelpToolbar' is then tried.
+
+ If an item is greyed out then a suffix of 'g' is added (eg 'HelpToolbar7g'). For this to
+ work, windows must have bit 4 of the window flag byte set and the user must be running
+ RISC OS 5.03 or greater.
For items marked with an asterisk [*] a call must be made to determine the required
help text as the window does not contain any icons. An example of this is the hotlist
@@ -73,6 +78,8 @@ void ro_gui_interactive_help_request(wimp_message *message) {
wimp_i icon;
struct gui_window *g;
unsigned int index;
+ bool greyed = false;
+ wimp_menu *test_menu;
/* Ensure we have a help request
*/
@@ -130,6 +137,14 @@ void ro_gui_interactive_help_request(wimp_message *message) {
/* If we've managed to find something so far then we broadcast it
*/
if (message_token[0] != 0x00) {
+ /* Check to see if we are greyed out
+ */
+ if ((icon >= 0) && (ro_gui_get_icon_shaded_state(window, icon))) {
+ strcat(message_token, "g");
+ }
+
+ /* Broadcast out message
+ */
ro_gui_interactive_help_broadcast(message, &message_token[0]);
return;
}
@@ -162,7 +177,15 @@ void ro_gui_interactive_help_request(wimp_message *message) {
/* Decode the menu
*/
index = 0;
+ test_menu = current_menu;
while (menu_tree.items[index] != -1) {
+ /* Check if we're greyed out
+ */
+ greyed |= test_menu->entries[menu_tree.items[index]].icon_flags & wimp_ICON_SHADED;
+ test_menu = test_menu->entries[menu_tree.items[index]].sub_menu;
+
+ /* Continue adding the entries
+ */
if (index == 0) {
sprintf(menu_buffer, "%i", menu_tree.items[index]);
} else {
@@ -171,6 +194,7 @@ void ro_gui_interactive_help_request(wimp_message *message) {
strcat(message_token, menu_buffer);
index++;
}
+ if (greyed) strcat(message_token, "g");
/* Finally, broadcast the menu help
*/
@@ -185,31 +209,36 @@ void ro_gui_interactive_help_request(wimp_message *message) {
* \param token the token to look up
*/
static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token) {
- char *translated_token;
+ const char *translated_token;
help_full_message_reply *reply;
+ char *base_token;
/* Check if the message exists
*/
- translated_token = (char *)messages_get(token);
+ translated_token = messages_get(token);
if (translated_token == token) {
- char *base_token;
-
- /* Find the key from the token.
+ /* We must never provide default help for a 'g' suffix.
*/
- base_token = translated_token;
- while (base_token[0] != 0x00) {
- if ((base_token[0] == '-') ||
- ((base_token[0] >= '0') && (base_token[0] <= '9'))) {
- base_token[0] = 0x00;
- } else {
- ++base_token;
+ if (token[strlen(token) - 1] == 'g') {
+ token[0] = '\0';
+ } else {
+ /* Find the key from the token.
+ */
+ base_token = token;
+ while (base_token[0] != 0x00) {
+ if ((base_token[0] == '-') ||
+ ((base_token[0] >= '0') && (base_token[0] <= '9'))) {
+ base_token[0] = 0x00;
+ } else {
+ ++base_token;
+ }
}
- }
- /* Check if the base key exists
- */
- translated_token = (char *)messages_get(token);
- if (translated_token == token) return;
+ /* Check if the base key exists and use an empty string if not
+ */
+ translated_token = messages_get(token);
+ if (translated_token == token) token[0] = '\0';
+ }
}
/* Copy our message string
diff --git a/riscos/menus.c b/riscos/menus.c
index 0ac547a65..535fe22a3 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -333,13 +333,12 @@ static wimp_MENU(3) hotlist_collapse = {
};
-static wimp_MENU(4) hotlist_save = {
+static wimp_MENU(3) hotlist_save = {
{ "SaveSelect" }, 7,2,7,0, 200, 44, 0,
{
{ wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "URI" } },
{ wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "URL" } },
- { wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "HTML" } },
- { wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "LinkText" } }
+ { wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "HTML" } },
}
};
@@ -1133,6 +1132,19 @@ void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning)
warning->pos.x, warning->pos.y);
break;
case 0: /* Save-> */
+ switch (warning->selection.items[2]) {
+ case -1: /* No sub-menu */
+ ro_gui_menu_prepare_hotlist();
+ error = xwimp_create_sub_menu(hotlist_save_menu,
+ warning->pos.x, warning->pos.y);
+ break;
+ case 1: /* URI */
+ break;
+ case 2: /* URL */
+ break;
+ case 3: /* HTML */
+ break;
+ }
break;
case 1: /* Edit-> */
hotlist_insert = true;
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index ba922e453..3b2edddc6 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -62,7 +62,7 @@ static wimp_window empty_window = {
wimp_COLOUR_DARK_GREY,
wimp_COLOUR_MID_LIGHT_GREY,
wimp_COLOUR_CREAM,
- wimp_WINDOW_NEVER3D,
+ wimp_WINDOW_NEVER3D | 0x16u /* RISC OS 5.03+ - greyed icons detected for interactive help */,
{0, 0, 16384, 16384},
0,
0,
diff --git a/riscos/wimp.c b/riscos/wimp.c
index 03d78a2ff..fcb5bcd9f 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -223,7 +223,7 @@ void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) {
* \param w window handle
* \param i icon handle
*/
-int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) {
+bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) {
wimp_icon_state ic;
ic.w = w;
ic.i = i;
@@ -243,6 +243,21 @@ int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) {
/**
+ * Gets the shaded state of an icon.
+ *
+ * \param w window handle
+ * \param i icon handle
+ */
+bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i) {
+ wimp_icon_state ic;
+ ic.w = w;
+ ic.i = i;
+ xwimp_get_icon_state(&ic);
+ return (ic.icon.flags & wimp_ICON_SHADED) != 0;
+}
+
+
+/**
* Set a window title (does *not* redraw the title)
*
* \param w window handle
diff --git a/riscos/wimp.h b/riscos/wimp.h
index 6ba7ecf76..daa386e15 100644
--- a/riscos/wimp.h
+++ b/riscos/wimp.h
@@ -14,9 +14,10 @@
#define _NETSURF_RISCOS_WIMP_H_
#include <assert.h>
-#include <string.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "oslib/os.h"
#include "oslib/wimp.h"
@@ -37,8 +38,9 @@ char *ro_gui_get_icon_string(wimp_w w, wimp_i i);
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text);
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value);
#define ro_gui_set_icon_selected_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED)
-int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
+bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
#define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED)
+bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i);
void ro_gui_set_window_title(wimp_w w, const char *title);
void ro_gui_set_caret_first(wimp_w w);
void ro_gui_open_window_centre(wimp_w parent, wimp_w child);