32#include "oslib/osbyte.h"
33#include "oslib/osgbpb.h"
34#include "oslib/territory.h"
35#include "oslib/wimp.h"
77 wimp_menu_entry *parent_entry,
78 int first,
int last,
const char *prefix,
int prefix_length);
89#define DEFAULT_FLAGS (wimp_ICON_TEXT | wimp_ICON_FILLED | \
90 (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | \
91 (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
110#define IS_MENU(menu) !((int)(menu) & 1)
119 static const struct ns_menu images_definition = {
131 static const struct ns_menu proxy_type_definition = {
146 static const struct ns_menu lang_definition = {
233 error = xwimp_create_menu(
menu, x - 64, y);
235 NSLOG(netsurf, INFO,
"xwimp_create_menu: 0x%x: %s",
236 error->errnum, error->errmess);
253 wimp_window_state state;
254 wimp_icon_state icon_state;
260 error = xwimp_get_window_state(&state);
262 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
263 error->errnum, error->errmess);
268 error = xwimp_get_icon_state(&icon_state);
270 NSLOG(netsurf, INFO,
"xwimp_get_icon_state: 0x%x: %s",
271 error->errnum, error->errmess);
277 state.visible.x0 + icon_state.icon.extent.x1 + 64,
278 state.visible.y1 + icon_state.icon.extent.y1 -
295 error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
297 NSLOG(netsurf, INFO,
"xwimp_create_menu: 0x%x: %s",
298 error->errnum, error->errmess);
329 wimp_menu_entry *menu_entry;
331 wimp_pointer pointer;
345 for (i = 1;
selection->items[i] != -1; i++)
346 menu_entry = &menu_entry->sub_menu->
359 error = xwimp_get_pointer_info(&pointer);
361 NSLOG(netsurf, INFO,
"xwimp_get_pointer_info: 0x%x: %s",
362 error->errnum, error->errmess);
368 if (pointer.buttons != wimp_CLICK_ADJUST) {
385 wimp_menu_entry *menu_entry;
392 if (warning->selection.items[0] == -1)
394 menu_entry = &
current_menu->entries[warning->selection.items[0]];
395 for (i = 1; warning->selection.items[i] != -1; i++)
396 menu_entry = &menu_entry->sub_menu->
397 entries[warning->selection.items[i]];
408 if (
IS_MENU(menu_entry->sub_menu)) {
412 menu_entry->sub_menu);
418 menu_entry->sub_menu,
419 wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_BACK_ICON,
425 error = xwimp_create_sub_menu(menu_entry->sub_menu,
426 warning->pos.x, warning->pos.y);
428 NSLOG(netsurf, INFO,
"xwimp_create_sub_menu: 0x%x: %s",
429 error->errnum, error->errmess);
494 NSLOG(netsurf, INFO,
"xwimp_create_menu: 0x%x: %s",
495 error->errnum, error->errmess);
517 die(
"No memory to create menu definition.");
526 for (entry = 0;
menu->entries[entry].text; entry++)
535 die(
"No memory to translate menu.");
537 return definition->
menu;
557 wimp_menu_entry *parent_entry,
int first,
int last,
558 const char *prefix,
int prefix_length)
562 int matches[last - first + 1];
563 const char *
text, *menu_text;
568 for (entry = first; entry < last; entry++) {
574 while (!isalnum(*match))
578 if ((prefix) && (strncmp(match, prefix, prefix_length)))
586 if (depth == cur_depth)
587 matches[entries++] = entry;
589 matches[entries] = last;
597 new_menu = (wimp_menu *)malloc(wimp_SIZEOF_MENU(entries));
599 die(
"No memory to create menu.");
603 parent_entry->sub_menu = new_menu;
608 definition->
menu = new_menu;
612 new_menu->title_data.indirected_text.text = NULL;
618 for (entry = 0; entry < entries; entry++) {
620 int id = matches[entry];
625 new_menu->entries[entry].menu_flags = 0;
626 while (!isalnum(*
text)) {
628 new_menu->entries[entry].menu_flags |=
634 menu_text = strrchr(
text,
'.');
643 new_menu->entries[entry].sub_menu =
647 new_menu->entries[entry].data.indirected_text.text = NULL;
652 if (!definition_entry)
653 die(
"Unable to create menu definition entry");
655 definition_entry->
menu_entry = &new_menu->entries[entry];
658 definition->
entries = definition_entry;
661 if (new_menu->entries[entry].sub_menu == wimp_NO_SUB_MENU) {
663 depth + 1, &new_menu->
entries[entry],
664 matches[entry], matches[entry + 1],
669 if (new_menu->entries[entry].sub_menu != wimp_NO_SUB_MENU)
670 new_menu->entries[entry].menu_flags |=
671 wimp_MENU_GIVE_WARNING;
673 new_menu->entries[0].menu_flags |= wimp_MENU_TITLE_INDIRECTED;
674 new_menu->entries[entries - 1].menu_flags |= wimp_MENU_LAST;
686 menu->title_fg = wimp_COLOUR_BLACK;
687 menu->title_bg = wimp_COLOUR_LIGHT_GREY;
688 menu->work_fg = wimp_COLOUR_BLACK;
689 menu->work_bg = wimp_COLOUR_WHITE;
691 menu->height = wimp_MENU_ITEM_HEIGHT;
692 menu->gap = wimp_MENU_ITEM_GAP;
694 for (i = 0; i < entries; i++) {
695 menu->entries[i].menu_flags = 0;
696 menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
697 menu->entries[i].icon_flags =
699 menu->entries[i].data.indirected_text.validation =
702 menu->entries[0].menu_flags |= wimp_MENU_TITLE_INDIRECTED;
703 menu->entries[i - 1].menu_flags |= wimp_MENU_LAST;
721 definition = definition->
next)
736 const char *translated)
744 for (entry = definition->
entries; entry; entry = entry->
next)
745 if (!strcmp(entry->
menu_entry->data.indirected_text.text, translated))
767 for (entry = definition->
entries; entry; entry = entry->
next)
768 if (entry->
action == action)
789 for (entry = definition->
entries; entry; entry = entry->
next) {
814 for (entry = definition->
entries; entry; entry = entry->
next)
815 if (entry->
action == action) {
817 entry->
menu_entry->icon_flags |= wimp_ICON_SHADED;
819 entry->
menu_entry->icon_flags &= ~wimp_ICON_SHADED;
838 entry->
menu_entry->menu_flags |= wimp_MENU_TICKED;
840 entry->
menu_entry->menu_flags &= ~wimp_MENU_TICKED;
850 wimp_selection menu_tree;
851 int i = 0, j, checksum = 0;
858 error = xwimp_get_menu_state((wimp_menu_state_flags)0,
861 NSLOG(netsurf, INFO,
"xwimp_get_menu_state: 0x%x: %s",
862 error->errnum, error->errmess);
871 if (menu->entries[j].icon_flags & wimp_ICON_SHADED)
872 checksum ^= (1 << (i + j * 2));
873 if (menu->entries[j].menu_flags & wimp_MENU_TICKED)
874 checksum ^= (2 << (i + j * 2));
875 }
while (!(menu->entries[j++].menu_flags & wimp_MENU_LAST));
877 j = menu_tree.items[i++];
879 menu = menu->entries[j].sub_menu;
880 if ((!menu) || (menu == wimp_NO_SUB_MENU) || (!
IS_MENU(menu)))
903 error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &alphabet);
905 NSLOG(netsurf, INFO,
"failed reading alphabet: 0x%x: %s",
906 error->errnum, error->errmess);
908 alphabet = territory_ALPHABET_LATIN1;
916 free(menu->
menu->title_data.indirected_text.text);
921 NSLOG(netsurf, INFO,
"utf8_to_enc failed");
926 menu->
menu->title_data.indirected_text.text = translated;
929 for (entry = menu->
entries; entry; entry = entry->
next) {
930 wimp_menu *submenu = entry->
menu_entry->sub_menu;
933 free(entry->
menu_entry->data.indirected_text.text);
938 NSLOG(netsurf, INFO,
"utf8_to_enc failed");
943 entry->
menu_entry->data.indirected_text.text = translated;
944 entry->
menu_entry->data.indirected_text.validation =
946 entry->
menu_entry->data.indirected_text.size =
951 if (submenu != wimp_NO_SUB_MENU &&
IS_MENU(submenu)) {
952 submenu->title_data.indirected_text.text =
void die(const char *error)
Cause an abnormal program termination.
Cookie Manager (interface).
nserror
Enumeration of error codes.
@ NSERROR_BAD_ENCODING
The character set is unknown.
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
RISc OS global history interface.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
Interface to riscos cookie viewing using riscos core window.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
Interactive help (interface).
File/object/selection saving (Interface).
Interface to utility string handling.
Tinct SWI numbers and flags for version 0.11.
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
URL Suggestion Menu (interface).
bool ro_gui_url_suggest_init(void)
Option reading and saving interface.
char from[32]
Encoding name to convert from.
char to[32]
Encoding name to convert to.
UTF-8 manipulation functions (interface).
void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, wimp_window_flags xor_mask)
Sets whether a piece of window furniture is present for a window.
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu)
Trigger a window's Prepare Menu event.
void ro_gui_wimp_event_register_submenu(wimp_w w)
Register a submenu as being opened.
void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu)
Handle menus being closed.
bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handles a menu selection event.
Automated RISC OS WIMP event handling (interface).
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.