[project @ 2004-05-14 19:59:09 by rjw]
Interactive help tokens now fall back to their base key when not available. Help menu is now fully implemented. F1 opens the help page. svn path=/import/netsurf/; revision=864
This commit is contained in:
parent
2dd600802c
commit
48ace0dd89
12
riscos/gui.c
12
riscos/gui.c
|
@ -1263,15 +1263,19 @@ void ro_gui_screen_size(int *width, int *height)
|
|||
}
|
||||
|
||||
|
||||
void ro_gui_open_help_page(void)
|
||||
/**
|
||||
* Opens a language sensitive help page
|
||||
*
|
||||
* \param page the page to open
|
||||
*/
|
||||
void ro_gui_open_help_page(char *page)
|
||||
{
|
||||
char url[80];
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/docs_%s",
|
||||
option_language);
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/%s_%s",
|
||||
page, option_language);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send the source of a content to a text editor.
|
||||
*/
|
||||
|
|
|
@ -102,7 +102,7 @@ struct gui_window
|
|||
|
||||
/* in gui.c */
|
||||
void ro_gui_copy_selection(gui_window* g);
|
||||
void ro_gui_open_help_page(void);
|
||||
void ro_gui_open_help_page(char *page);
|
||||
void ro_gui_screen_size(int *width, int *height);
|
||||
void ro_gui_view_source(struct content *content);
|
||||
void ro_gui_drag_box_start(wimp_pointer *pointer);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "oslib/help.h"
|
||||
#include "oslib/taskmanager.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/help.h"
|
||||
|
@ -40,6 +41,8 @@
|
|||
|
||||
The prefixes are followed by either the icon number (eg 'HelpToolbar7'), or a series
|
||||
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.
|
||||
*/
|
||||
|
||||
static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token);
|
||||
|
@ -165,13 +168,32 @@ void ro_gui_interactive_help_request(wimp_message *message) {
|
|||
*/
|
||||
static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token) {
|
||||
char *translated_token;
|
||||
char *base_token;
|
||||
help_full_message_reply *reply;
|
||||
|
||||
/* Check if the message exists
|
||||
*/
|
||||
translated_token = (char *)messages_get(token);
|
||||
if (translated_token == token) return;
|
||||
|
||||
if (translated_token == token) {
|
||||
|
||||
/* Find the key from the token.
|
||||
*/
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the base key exists
|
||||
*/
|
||||
translated_token = (char *)messages_get(token);
|
||||
if (translated_token == token) return;
|
||||
}
|
||||
|
||||
/* Copy our message string
|
||||
*/
|
||||
reply = (help_full_message_reply *)message;
|
||||
|
@ -185,3 +207,32 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token
|
|||
reply->your_ref = reply->my_ref;
|
||||
wimp_send_message(wimp_USER_MESSAGE, (wimp_message *)reply, reply->sender);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if interactive help is running
|
||||
*
|
||||
* \return the task handle of !Help, or 0 if not available
|
||||
*/
|
||||
int ro_gui_interactive_help_available() {
|
||||
taskmanager_task task;
|
||||
int context = 0;
|
||||
char *end;
|
||||
|
||||
/* Attempt to find 'Help'
|
||||
*/
|
||||
do {
|
||||
if (xtaskmanager_enumerate_tasks(context, &task, sizeof(taskmanager_task),
|
||||
&context, &end)) return 0;
|
||||
|
||||
/* We can't just use strcmp due to string termination issues.
|
||||
*/
|
||||
if (strncmp(task.name, "Help", 4) == 0) {
|
||||
if (task.name[4] < 32) return (int)task.task;
|
||||
}
|
||||
} while (context >= 0);
|
||||
|
||||
/* Return failure
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
#include "oslib/wimp.h"
|
||||
|
||||
void ro_gui_interactive_help_request(wimp_message *message);
|
||||
int ro_gui_interactive_help_available(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "netsurf/desktop/gui.h"
|
||||
#include "netsurf/riscos/constdata.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/help.h"
|
||||
#include "netsurf/riscos/theme.h"
|
||||
#include "netsurf/riscos/options.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
|
@ -41,6 +43,7 @@
|
|||
static void translate_menu(wimp_menu *menu);
|
||||
static void ro_gui_menu_prepare_images(void);
|
||||
static void ro_gui_menu_prepare_toolbars(void);
|
||||
static void ro_gui_menu_prepare_help(int forced);
|
||||
static void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning);
|
||||
static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
|
||||
static struct box *ro_gui_menu_find_object_box(void);
|
||||
|
@ -225,10 +228,10 @@ static wimp_MENU(4) utilities_menu = {
|
|||
static wimp_MENU(4) help_menu = {
|
||||
{ "Help" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HelpContent" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "HelpGuide" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "HelpInfo" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "HelpInter" } }
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HelpContent" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HelpGuide" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HelpInfo" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HelpInter" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -238,13 +241,13 @@ static wimp_MENU(4) help_menu = {
|
|||
static wimp_MENU(5) menu = {
|
||||
{ "NetSurf" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ 0, (wimp_menu *)&page_menu, DEFAULT_FLAGS, { "Page" } },
|
||||
{ 0, (wimp_menu *)&object_menu, DEFAULT_FLAGS, { "Object" } },
|
||||
// { 0, (wimp_menu *)&selection_menu, DEFAULT_FLAGS, { "Selection" } },
|
||||
{ 0, (wimp_menu *)&navigate_menu, DEFAULT_FLAGS, { "Navigate" } },
|
||||
{ 0, (wimp_menu *)&view_menu, DEFAULT_FLAGS, { "View" } },
|
||||
// { 0, (wimp_menu *)&utilities_menu, DEFAULT_FLAGS, { "Utilities" } },
|
||||
{ wimp_MENU_LAST, (wimp_menu *)&help_menu, DEFAULT_FLAGS, { "Help" } }
|
||||
{ 0, (wimp_menu *)&page_menu, DEFAULT_FLAGS, { "Page" } },
|
||||
{ 0, (wimp_menu *)&object_menu, DEFAULT_FLAGS, { "Object" } },
|
||||
// { 0, (wimp_menu *)&selection_menu, DEFAULT_FLAGS, { "Selection" } },
|
||||
{ 0, (wimp_menu *)&navigate_menu, DEFAULT_FLAGS, { "Navigate" } },
|
||||
{ 0, (wimp_menu *)&view_menu, DEFAULT_FLAGS, { "View" } },
|
||||
// { 0, (wimp_menu *)&utilities_menu, DEFAULT_FLAGS, { "Utilities" } },
|
||||
{ wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu *)&help_menu, DEFAULT_FLAGS, { "Help" } }
|
||||
}
|
||||
};
|
||||
wimp_menu *browser_menu = (wimp_menu *) &menu;
|
||||
|
@ -395,7 +398,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
|
|||
pointer.pos.x, pointer.pos.y, 0);
|
||||
break;
|
||||
case 1: /* Help */
|
||||
ro_gui_open_help_page();
|
||||
ro_gui_open_help_page("docs");
|
||||
break;
|
||||
case 2: /* Choices */
|
||||
ro_gui_dialog_open(dialog_config);
|
||||
|
@ -537,13 +540,17 @@ void ro_gui_menu_selection(wimp_selection *selection)
|
|||
switch (selection->items[1]) {
|
||||
case -1: /* No sub-item */
|
||||
case 0: /* Contents */
|
||||
ro_gui_open_help_page();
|
||||
ro_gui_open_help_page("docs");
|
||||
break;
|
||||
case 1: /* User guide -> */
|
||||
ro_gui_open_help_page("guide");
|
||||
break;
|
||||
case 2: /* User information */
|
||||
ro_gui_open_help_page("info");
|
||||
break;
|
||||
case 3: /* Interactive help */
|
||||
xos_cli("Filer_Run Resources:$.Apps.!Help");
|
||||
ro_gui_menu_prepare_help(true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -678,6 +685,10 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case MENU_HELP: /* Help -> */
|
||||
ro_gui_menu_prepare_help(false);
|
||||
error = xwimp_create_sub_menu(browser_help_menu,
|
||||
warning->pos.x, warning->pos.y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -814,6 +825,18 @@ void ro_gui_menu_prepare_scale(void) {
|
|||
sprintf(scale_buffer, "%.0f", current_gui->scale * 100);
|
||||
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
|
||||
}
|
||||
/**
|
||||
* Update the Interactive Help status
|
||||
*
|
||||
* \parmam force force the status to be disabled
|
||||
*/
|
||||
void ro_gui_menu_prepare_help(int forced) {
|
||||
if (ro_gui_interactive_help_available() || (forced)) {
|
||||
browser_help_menu->entries[3].icon_flags |= wimp_ICON_SHADED;
|
||||
} else {
|
||||
browser_help_menu->entries[3].icon_flags &= ~wimp_ICON_SHADED;
|
||||
}
|
||||
}
|
||||
|
||||
void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
|
||||
{
|
||||
|
|
|
@ -813,6 +813,10 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
|
|||
}
|
||||
|
||||
switch (key) {
|
||||
case wimp_KEY_F1: /* Help. */
|
||||
ro_gui_open_help_page("docs");
|
||||
return true;
|
||||
|
||||
case wimp_KEY_F8: /* View source. */
|
||||
ro_gui_view_source(content);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue