netsurf: branch chris/menuclass updated. release/3.6-206-gd871be3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d871be3ea00ef74ab28b9...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d871be3ea00ef74ab28b936...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d871be3ea00ef74ab28b93652...
The branch, chris/menuclass has been updated
via d871be3ea00ef74ab28b936526768bbf121e3eb0 (commit)
via d843f78c202900409b0cd0c16397f6dae77bbe2b (commit)
from 9e814fd0f0f03584debb43b6d8acf144bd8675a2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d871be3ea00ef74ab28...
commit d871be3ea00ef74ab28b936526768bbf121e3eb0
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Update documentaton
diff --git a/frontends/amiga/dist/NetSurf.guide b/frontends/amiga/dist/NetSurf.guide
index 754cdbe..512a264 100755
--- a/frontends/amiga/dist/NetSurf.guide
+++ b/frontends/amiga/dist/NetSurf.guide
@@ -285,11 +285,11 @@ Items from the hotlist can be added to the Hotlist menu as follows:
Select Hotlist => Show hotlist...
-Items in the "Hotlist menu" folder node, up to a maximum (currently) of 40 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
+Items in the "Hotlist menu" folder node, up to a maximum (currently) of 200 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
Items in folders within the Menu folder node will be converted to subitems in the menu.
-Folders more than one level down in the heirarchy will become menu items with no action. Items deeper will not be included in the menu at all (until we switch to using menuclass).
+When using a version of AmigaOS older than OS4.1FE, folders more than one level down in the heirarchy will become menu items with no action. Items deeper will not be included in the menu at all.
Folders with no items in them will show up disabled in the menu. If they are named "--" they will be displayed as separator bars.
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 91acce7..2d2ec4e 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -262,7 +262,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
TAG_DONE);
}
- LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
+ //LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
continue;
} else if (md[j]->menutype > level) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d843f78c202900409b0...
commit d843f78c202900409b0cd0c16397f6dae77bbe2b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
disable dynamic hotlist menu update
menuclass doesn't appear to be working as advertised
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index b2a489e..bee7a8d 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3327,7 +3327,7 @@ void ami_gui_hotlist_update_all(void)
if(IsMinListEmpty(window_list)) return;
- ami_gui_menu_refresh_hotlist();
+ //ami_gui_menu_refresh_hotlist(); /**\todo disabled as menuclass isn't updating correctly */
node = (struct nsObject *)GetHead((struct List *)window_list);
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/dist/NetSurf.guide | 4 ++--
frontends/amiga/gui.c | 2 +-
frontends/amiga/menu.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frontends/amiga/dist/NetSurf.guide b/frontends/amiga/dist/NetSurf.guide
index 754cdbe..512a264 100755
--- a/frontends/amiga/dist/NetSurf.guide
+++ b/frontends/amiga/dist/NetSurf.guide
@@ -285,11 +285,11 @@ Items from the hotlist can be added to the Hotlist menu as follows:
Select Hotlist => Show hotlist...
-Items in the "Hotlist menu" folder node, up to a maximum (currently) of 40 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
+Items in the "Hotlist menu" folder node, up to a maximum (currently) of 200 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
Items in folders within the Menu folder node will be converted to subitems in the menu.
-Folders more than one level down in the heirarchy will become menu items with no action. Items deeper will not be included in the menu at all (until we switch to using menuclass).
+When using a version of AmigaOS older than OS4.1FE, folders more than one level down in the heirarchy will become menu items with no action. Items deeper will not be included in the menu at all.
Folders with no items in them will show up disabled in the menu. If they are named "--" they will be displayed as separator bars.
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index b2a489e..bee7a8d 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3327,7 +3327,7 @@ void ami_gui_hotlist_update_all(void)
if(IsMinListEmpty(window_list)) return;
- ami_gui_menu_refresh_hotlist();
+ //ami_gui_menu_refresh_hotlist(); /**\todo disabled as menuclass isn't updating correctly */
node = (struct nsObject *)GetHead((struct List *)window_list);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 91acce7..2d2ec4e 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -262,7 +262,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
TAG_DONE);
}
- LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
+ //LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
continue;
} else if (md[j]->menutype > level) {
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/menuclass updated. release/3.6-204-g9e814fd
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9e814fd0f0f03584debb4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9e814fd0f0f03584debb43b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9e814fd0f0f03584debb43b6d...
The branch, chris/menuclass has been updated
via 9e814fd0f0f03584debb43b6d8acf144bd8675a2 (commit)
via b78d6f458e5d5cb9c78d7430aacf10abd227eb32 (commit)
from b8640956d48af03f2f7f6c07e66958fa825a4972 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9e814fd0f0f03584deb...
commit 9e814fd0f0f03584debb43b6d8acf144bd8675a2
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
minor menu fixes
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index c6ca886..b2a489e 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3335,8 +3335,7 @@ void ami_gui_hotlist_update_all(void)
nnode=(struct nsObject *)GetSucc((struct Node *)node);
gwin = node->objstruct;
- if(node->Type == AMINS_WINDOW)
- {
+ if(node->Type == AMINS_WINDOW) {
ami_gui_hotlist_toolbar_update(gwin);
}
} while((node = nnode));
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index c453c64..6b9b207 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -1084,6 +1084,7 @@ static void ami_free_menulabs(struct ami_menu_data **md)
md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
+ md[i] = NULL;
}
}
@@ -1093,6 +1094,8 @@ void ami_gui_menu_free(struct gui_window_2 *gwin)
#ifdef __amigaos4__
gui_menu_count--;
+ SetAttrs(gwin->objects[OID_MAIN], WINDOW_MenuStrip, NULL, TAG_DONE);
+
if(gui_menu_count == 0) {
ami_free_menulabs(gui_menu_data);
// if we detach our menu from the window we need to do this manually
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index cfbbd8d..91acce7 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -100,6 +100,7 @@ void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
+ md[i] = NULL;
}
static void ami_menu_free_labs(struct ami_menu_data **md, int max)
@@ -115,8 +116,6 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags)
{
- char menu_icon[1024];
-
md[num] = calloc(1, sizeof(struct ami_menu_data));
md[num]->menutype = type;
md[num]->flags = flags;
@@ -127,11 +126,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
md[num]->menulab = NM_BARLABEL;
icon = NULL;
} else { /* horrid non-generic stuff */
- if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
- utf8_from_local_encoding(label,
- (strlen(label) < NSA_MAX_HOTLIST_MENU_LEN) ? strlen(label) : NSA_MAX_HOTLIST_MENU_LEN,
- (char **)&md[num]->menulab);
- } else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
+ if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
md[num]->menulab = strdup(label);
} else {
md[num]->menulab = ami_utf8_easy(messages_get(label));
@@ -144,6 +139,8 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
if(hookdata) md[num]->menu_hook.h_Data = hookdata;
#ifdef __amigaos4__
+ char menu_icon[1024];
+
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
if(icon) {
if(ami_locate_resource(menu_icon, icon) == true) {
@@ -265,6 +262,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
TAG_DONE);
}
+ LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
continue;
} else if (md[j]->menutype > level) {
@@ -452,7 +450,7 @@ void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_ite
/* remove all children */
while((obj = (Object *)IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) {
IDoMethod(menu_item_obj, OM_REMMEMBER, obj);
- /* do we need to disposeobject? */
+ DisposeObject(obj);
}
/* free associated data */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b78d6f458e5d5cb9c78...
commit b78d6f458e5d5cb9c78d7430aacf10abd227eb32
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Attempt hotlist menu refresh
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index d660e93..c6ca886 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3327,6 +3327,8 @@ void ami_gui_hotlist_update_all(void)
if(IsMinListEmpty(window_list)) return;
+ ami_gui_menu_refresh_hotlist();
+
node = (struct nsObject *)GetHead((struct List *)window_list);
do {
@@ -3336,7 +3338,6 @@ void ami_gui_hotlist_update_all(void)
if(node->Type == AMINS_WINDOW)
{
ami_gui_hotlist_toolbar_update(gwin);
- //ami_gui_menu_refresh_hotlist(gwin);
}
} while((node = nnode));
}
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 77f6839..07ff922 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -134,7 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 6b33194..c453c64 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -80,8 +80,11 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
+#ifdef __amigaos4__
static struct Menu *restrict gui_menu = NULL;
static int gui_menu_count = 0;
+struct ami_menu_data *gui_menu_data[AMI_MENU_AREXX_MAX + 1];
+#endif
static bool ami_menu_check_toggled = false;
static bool menu_quit = false;
@@ -900,6 +903,12 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
static nserror ami_menu_scan(struct ami_menu_data **md)
{
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
+ ami_menu_item_hotlist_add, NULL, 0);
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
+ ami_menu_item_hotlist_show, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
@@ -1002,11 +1011,7 @@ static void ami_init_menulabs(struct ami_menu_data **md)
ami_menu_item_browser_redraw, NULL, 0);
ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ /* see ami_menu_scan for the rest of this menu */
ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
@@ -1027,21 +1032,25 @@ static void ami_init_menulabs(struct ami_menu_data **md)
struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
if(gui_menu != NULL) {
gwin->imenu = gui_menu;
gui_menu_count++;
return gwin->imenu;
}
- }
+ ami_init_menulabs(gui_menu_data);
+ ami_menu_scan(gui_menu_data);
+ ami_menu_arexx_scan(gui_menu_data);
+ gwin->imenu = ami_menu_layout(gui_menu_data, AMI_MENU_AREXX_MAX);
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
-
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
gui_menu = gwin->imenu;
gui_menu_count++;
+#endif
+ } else {
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(gwin->menu_data);
+ ami_menu_arexx_scan(gwin->menu_data);
+ gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
}
return gwin->imenu;
@@ -1081,14 +1090,16 @@ static void ami_free_menulabs(struct ami_menu_data **md)
void ami_gui_menu_free(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
gui_menu_count--;
if(gui_menu_count == 0) {
- ami_free_menulabs(gwin->menu_data);
+ ami_free_menulabs(gui_menu_data);
// if we detach our menu from the window we need to do this manually
DisposeObject((Object *)gui_menu);
gui_menu = NULL;
}
+#endif
} else {
ami_free_menulabs(gwin->menu_data);
FreeMenus(gwin->imenu);
@@ -1100,3 +1111,10 @@ bool ami_gui_menu_quit_selected(void)
return menu_quit;
}
+void ami_gui_menu_refresh_hotlist(void)
+{
+#ifdef __amigaos4__
+ ami_menu_refresh(gui_menu, gui_menu_data, M_HOTLIST, AMI_MENU_HOTLIST_MAX, ami_menu_scan);
+#endif
+}
+
diff --git a/frontends/amiga/gui_menu.h b/frontends/amiga/gui_menu.h
index a9de69a..16fc720 100644
--- a/frontends/amiga/gui_menu.h
+++ b/frontends/amiga/gui_menu.h
@@ -142,6 +142,10 @@ void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
*/
void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+/**
+ * Refresh the Hotlist menu
+ */
+void ami_gui_menu_refresh_hotlist(void);
/**
* Gets if NetSurf has been quit from the menu
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 04c6eb0..cfbbd8d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -80,7 +80,7 @@ bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
}
/* menu creation code */
-static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
{
if(md[i] == NULL) return;
if(md[i]->menulab &&
@@ -435,3 +435,38 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
}
}
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md))
+{
+#ifdef __amigaos4__
+ Object *restrict obj;
+ Object *restrict menu_item_obj;
+ int i;
+
+ if(menu == NULL) return;
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* find the address of the menu */
+ menu_item_obj = (Object *)IDoMethod((Object *)menu, MM_FINDID, 0, menu_item);
+
+ /* remove all children */
+ while((obj = (Object *)IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) {
+ IDoMethod(menu_item_obj, OM_REMMEMBER, obj);
+ /* do we need to disposeobject? */
+ }
+
+ /* free associated data */
+ for(i = (menu_item + 1); i <= max; i++) {
+ if(md[i] == NULL) continue;
+ ami_menu_free_lab_item(md, i);
+ }
+
+ /* get current data */
+ cb(md);
+
+ /* re-add items to menu */
+ ami_menu_layout_mc_recursive(menu_item_obj, md, NM_ITEM, (menu_item + 1), max);
+ }
+#endif
+}
+
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index f8a3f17..358faa4 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -45,6 +45,11 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
void *restrict func, void *restrict hookdata, UWORD flags);
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i);
+
+/* refresh a menu's children */
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md));
/**
* Get the selected state of a menu item
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/gui.c | 6 +++---
frontends/amiga/gui.h | 2 +-
frontends/amiga/gui_menu.c | 47 ++++++++++++++++++++++++++++++------------
frontends/amiga/gui_menu.h | 4 ++++
frontends/amiga/menu.c | 49 ++++++++++++++++++++++++++++++++++++--------
frontends/amiga/menu.h | 5 +++++
6 files changed, 88 insertions(+), 25 deletions(-)
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index d660e93..b2a489e 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3327,16 +3327,16 @@ void ami_gui_hotlist_update_all(void)
if(IsMinListEmpty(window_list)) return;
+ ami_gui_menu_refresh_hotlist();
+
node = (struct nsObject *)GetHead((struct List *)window_list);
do {
nnode=(struct nsObject *)GetSucc((struct Node *)node);
gwin = node->objstruct;
- if(node->Type == AMINS_WINDOW)
- {
+ if(node->Type == AMINS_WINDOW) {
ami_gui_hotlist_toolbar_update(gwin);
- //ami_gui_menu_refresh_hotlist(gwin);
}
} while((node = nnode));
}
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 77f6839..07ff922 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -134,7 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 6b33194..6b9b207 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -80,8 +80,11 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
+#ifdef __amigaos4__
static struct Menu *restrict gui_menu = NULL;
static int gui_menu_count = 0;
+struct ami_menu_data *gui_menu_data[AMI_MENU_AREXX_MAX + 1];
+#endif
static bool ami_menu_check_toggled = false;
static bool menu_quit = false;
@@ -900,6 +903,12 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
static nserror ami_menu_scan(struct ami_menu_data **md)
{
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
+ ami_menu_item_hotlist_add, NULL, 0);
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
+ ami_menu_item_hotlist_show, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
@@ -1002,11 +1011,7 @@ static void ami_init_menulabs(struct ami_menu_data **md)
ami_menu_item_browser_redraw, NULL, 0);
ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ /* see ami_menu_scan for the rest of this menu */
ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
@@ -1027,21 +1032,25 @@ static void ami_init_menulabs(struct ami_menu_data **md)
struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
if(gui_menu != NULL) {
gwin->imenu = gui_menu;
gui_menu_count++;
return gwin->imenu;
}
- }
-
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
+ ami_init_menulabs(gui_menu_data);
+ ami_menu_scan(gui_menu_data);
+ ami_menu_arexx_scan(gui_menu_data);
+ gwin->imenu = ami_menu_layout(gui_menu_data, AMI_MENU_AREXX_MAX);
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
gui_menu = gwin->imenu;
gui_menu_count++;
+#endif
+ } else {
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(gwin->menu_data);
+ ami_menu_arexx_scan(gwin->menu_data);
+ gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
}
return gwin->imenu;
@@ -1075,20 +1084,25 @@ static void ami_free_menulabs(struct ami_menu_data **md)
md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
+ md[i] = NULL;
}
}
void ami_gui_menu_free(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
gui_menu_count--;
+ SetAttrs(gwin->objects[OID_MAIN], WINDOW_MenuStrip, NULL, TAG_DONE);
+
if(gui_menu_count == 0) {
- ami_free_menulabs(gwin->menu_data);
+ ami_free_menulabs(gui_menu_data);
// if we detach our menu from the window we need to do this manually
DisposeObject((Object *)gui_menu);
gui_menu = NULL;
}
+#endif
} else {
ami_free_menulabs(gwin->menu_data);
FreeMenus(gwin->imenu);
@@ -1100,3 +1114,10 @@ bool ami_gui_menu_quit_selected(void)
return menu_quit;
}
+void ami_gui_menu_refresh_hotlist(void)
+{
+#ifdef __amigaos4__
+ ami_menu_refresh(gui_menu, gui_menu_data, M_HOTLIST, AMI_MENU_HOTLIST_MAX, ami_menu_scan);
+#endif
+}
+
diff --git a/frontends/amiga/gui_menu.h b/frontends/amiga/gui_menu.h
index a9de69a..16fc720 100644
--- a/frontends/amiga/gui_menu.h
+++ b/frontends/amiga/gui_menu.h
@@ -142,6 +142,10 @@ void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
*/
void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+/**
+ * Refresh the Hotlist menu
+ */
+void ami_gui_menu_refresh_hotlist(void);
/**
* Gets if NetSurf has been quit from the menu
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 04c6eb0..91acce7 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -80,7 +80,7 @@ bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
}
/* menu creation code */
-static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
{
if(md[i] == NULL) return;
if(md[i]->menulab &&
@@ -100,6 +100,7 @@ static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
+ md[i] = NULL;
}
static void ami_menu_free_labs(struct ami_menu_data **md, int max)
@@ -115,8 +116,6 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags)
{
- char menu_icon[1024];
-
md[num] = calloc(1, sizeof(struct ami_menu_data));
md[num]->menutype = type;
md[num]->flags = flags;
@@ -127,11 +126,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
md[num]->menulab = NM_BARLABEL;
icon = NULL;
} else { /* horrid non-generic stuff */
- if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
- utf8_from_local_encoding(label,
- (strlen(label) < NSA_MAX_HOTLIST_MENU_LEN) ? strlen(label) : NSA_MAX_HOTLIST_MENU_LEN,
- (char **)&md[num]->menulab);
- } else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
+ if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
md[num]->menulab = strdup(label);
} else {
md[num]->menulab = ami_utf8_easy(messages_get(label));
@@ -144,6 +139,8 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
if(hookdata) md[num]->menu_hook.h_Data = hookdata;
#ifdef __amigaos4__
+ char menu_icon[1024];
+
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
if(icon) {
if(ami_locate_resource(menu_icon, icon) == true) {
@@ -265,6 +262,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
TAG_DONE);
}
+ LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
continue;
} else if (md[j]->menutype > level) {
@@ -435,3 +433,38 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
}
}
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md))
+{
+#ifdef __amigaos4__
+ Object *restrict obj;
+ Object *restrict menu_item_obj;
+ int i;
+
+ if(menu == NULL) return;
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* find the address of the menu */
+ menu_item_obj = (Object *)IDoMethod((Object *)menu, MM_FINDID, 0, menu_item);
+
+ /* remove all children */
+ while((obj = (Object *)IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) {
+ IDoMethod(menu_item_obj, OM_REMMEMBER, obj);
+ DisposeObject(obj);
+ }
+
+ /* free associated data */
+ for(i = (menu_item + 1); i <= max; i++) {
+ if(md[i] == NULL) continue;
+ ami_menu_free_lab_item(md, i);
+ }
+
+ /* get current data */
+ cb(md);
+
+ /* re-add items to menu */
+ ami_menu_layout_mc_recursive(menu_item_obj, md, NM_ITEM, (menu_item + 1), max);
+ }
+#endif
+}
+
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index f8a3f17..358faa4 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -45,6 +45,11 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
void *restrict func, void *restrict hookdata, UWORD flags);
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i);
+
+/* refresh a menu's children */
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md));
/**
* Get the selected state of a menu item
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/menuclass updated. release/3.6-202-gb864095
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b8640956d48af03f2f7f6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b8640956d48af03f2f7f6c0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b8640956d48af03f2f7f6c07e...
The branch, chris/menuclass has been updated
via b8640956d48af03f2f7f6c07e66958fa825a4972 (commit)
via 8e7603e6a263eb765df4886a321537f209d88245 (commit)
via 606cc0c2196f5934a7c48e89ab05da7d5e05081f (commit)
via 52f98c9fb2b3dc04412ad25b7c24fa8cf357e78d (commit)
from 24fed9d51ccf3e786e59983ae84b4f13e68b0ea4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b8640956d48af03f2f7...
commit b8640956d48af03f2f7f6c07e66958fa825a4972
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Ignore the other check toggle stuff with menuclass
The one thing we are toggling is actioned immediately when potentially changing the state in the prefs window
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 3f053a5..6b33194 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -671,7 +671,7 @@ void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item,
void ami_gui_menu_update_checked(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- //needs re-writing for MenuClass
+ /* Irrelevant when using MenuClass */
return;
}
@@ -780,11 +780,21 @@ void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c
void ami_gui_menu_set_check_toggled(void)
{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* Irrelevant when using MenuClass */
+ return;
+ }
+
ami_menu_check_toggled = true;
}
bool ami_gui_menu_get_check_toggled(void)
{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* Irrelevant when using MenuClass */
+ return false;
+ }
+
bool check_toggled = ami_menu_check_toggled;
ami_menu_check_toggled = false;
return check_toggled;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8e7603e6a263eb765df...
commit 8e7603e6a263eb765df4886a321537f209d88245
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Update JS menu check state when prefs option is toggled
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 791182b..3f053a5 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -598,12 +598,20 @@ static void ami_gui_menu_set_checked_mc(struct Menu *menu, int item, bool check)
check_state = 0;
}
+ if(menu == NULL) {
+ menu = gui_menu;
+ }
+
IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_CHECKED, check_state);
}
#endif
static void ami_gui_menu_set_checked_gt(struct Menu *menu, int item, bool check)
{
+ if(menu == NULL) {
+ return;
+ }
+
if(check == true) {
if((ItemAddress(menu, ami_gui_menu_number(item))->Flags & CHECKED) == 0)
ItemAddress(menu, ami_gui_menu_number(item))->Flags ^= CHECKED;
diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c
index b349e43..78dea58 100755
--- a/frontends/amiga/gui_options.c
+++ b/frontends/amiga/gui_options.c
@@ -1727,7 +1727,9 @@ static void ami_gui_opts_use(bool save)
} else {
nsoption_set_bool(enable_javascript, false);
}
-
+
+ ami_gui_menu_set_checked(NULL, M_JS, nsoption_bool(enable_javascript));
+
GetAttr(GA_Selected,gow->objects[GID_OPTS_DONOTTRACK],(ULONG *)&data);
if (data) {
nsoption_set_bool(do_not_track, true);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 6e33d5e..04c6eb0 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -39,7 +39,7 @@
#include <reaction/reaction_macros.h>
#include "utils/log.h"
-#include "utils/utils.h"
+#include "utils/messages.h"
#include "amiga/gui.h"
#include "amiga/libs.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=606cc0c2196f5934a7c...
commit 606cc0c2196f5934a7c48e89ab05da7d5e05081f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Split up menu.c into generic and gui_window-specific files
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile
index 985a085..f57b4ef 100644
--- a/frontends/amiga/Makefile
+++ b/frontends/amiga/Makefile
@@ -46,7 +46,7 @@ S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \
stringview/stringview.c stringview/urlhistory.c rtg.c \
agclass/amigaguide_class.c os3support.c font_diskfont.c \
selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \
- nsoption.c corewindow.c
+ nsoption.c corewindow.c gui_menu.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 0fc9841..27b8015 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -44,7 +44,7 @@
#include "amiga/gui.h"
#include "amiga/iff_cset.h"
#include "amiga/iff_dr2d.h"
-#include "amiga/menu.h"
+#include "amiga/gui_menu.h"
#include "amiga/utf8.h"
#define ID_UTF8 MAKE_ID('U','T','F','8')
@@ -89,11 +89,11 @@ void gui_start_selection(struct gui_window *g)
if(!g->shared->win) return;
if(nsoption_bool(kiosk_mode) == true) return;
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
}
static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 17933d5..877805c 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -43,6 +43,7 @@
#include "amiga/cookies.h"
#include "amiga/corewindow.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/utf8.h"
enum {
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 8b389a0..d660e93 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1209,9 +1209,9 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
if(nsoption_bool(kiosk_mode) == false) {
if(gwin->tabs <= 1) {
tabclose=TRUE;
- ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
+ ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
} else {
- ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
+ ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
}
}
@@ -1637,7 +1637,7 @@ static void ami_gui_menu_update_all(void)
if(node->Type == AMINS_WINDOW)
{
- ami_menu_update_checked(gwin);
+ ami_gui_menu_update_checked(gwin);
}
} while((node = nnode));
}
@@ -1964,11 +1964,11 @@ static BOOL ami_handle_msg(void)
}
} while((node = nnode));
- if(ami_menu_quit_selected() == true) {
+ if(ami_gui_menu_quit_selected() == true) {
ami_quit_netsurf();
}
- if(ami_menu_get_check_toggled() == true) {
+ if(ami_gui_menu_get_check_toggled() == true) {
ami_gui_menu_update_all();
}
@@ -2903,7 +2903,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
ami_plot_release_pens(gwin->shared_pens);
ami_update_buttons(gwin);
- ami_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
+ ami_gui_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
if(redraw)
{
@@ -3336,7 +3336,7 @@ void ami_gui_hotlist_update_all(void)
if(node->Type == AMINS_WINDOW)
{
ami_gui_hotlist_toolbar_update(gwin);
- ami_menu_refresh(gwin);
+ //ami_gui_menu_refresh_hotlist(gwin);
}
} while((node = nnode));
}
@@ -3985,7 +3985,7 @@ gui_window_create(struct browser_window *bw,
iconifygadget = TRUE;
LOG("Creating menu");
- struct Menu *menu = ami_menu_create(g->shared);
+ struct Menu *menu = ami_gui_menu_create(g->shared);
NewList(&g->shared->tab_list);
g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
@@ -4603,7 +4603,7 @@ static void gui_window_destroy(struct gui_window *g)
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
- ami_menu_free(g->shared);
+ ami_gui_menu_free(g->shared);
free(g->shared->wintitle);
ami_utf8_free(g->shared->status);
@@ -5257,7 +5257,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
g->c_h = height;
if((nsoption_bool(kiosk_mode) == false))
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
}
static void gui_window_remove_caret(struct gui_window *g)
@@ -5266,7 +5266,7 @@ static void gui_window_remove_caret(struct gui_window *g)
if(g->c_h == 0) return;
if((nsoption_bool(kiosk_mode) == false))
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
@@ -5290,7 +5290,7 @@ static void gui_window_new_content(struct gui_window *g)
g->shared->oldv = 0;
g->favicon = NULL;
ami_plot_release_pens(g->shared->shared_pens);
- ami_menu_update_disabled(g, c);
+ ami_gui_menu_update_disabled(g, c);
ami_gui_update_hotlist_button(g->shared);
ami_gui_scroller_update(g->shared);
}
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index a176df1..77f6839 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -28,7 +28,7 @@
#include "netsurf/window.h"
#include "netsurf/mouse.h"
-#include "amiga/menu.h"
+#include "amiga/gui_menu.h"
#include "amiga/object.h"
#include "amiga/os3support.h"
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
new file mode 100644
index 0000000..791182b
--- /dev/null
+++ b/frontends/amiga/gui_menu.c
@@ -0,0 +1,1084 @@
+/*
+ * Copyright 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * 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/>.
+ */
+
+#include "amiga/os3support.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <proto/dos.h>
+#include <proto/asl.h>
+#include <proto/exec.h>
+#include <proto/gadtools.h>
+#include <proto/intuition.h>
+#include <proto/utility.h>
+#ifdef __amigaos4__
+#include <dos/anchorpath.h>
+#include <dos/obsolete.h> /* Needed for ExAll() */
+#endif
+
+#include <libraries/gadtools.h>
+#ifdef __amigaos4__
+#include <intuition/menuclass.h>
+#endif
+
+#include <classes/window.h>
+#include <proto/label.h>
+#include <images/label.h>
+#include <proto/bitmap.h>
+#include <images/bitmap.h>
+
+#include <reaction/reaction_macros.h>
+
+#include "utils/nsoption.h"
+#include "utils/messages.h"
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/nsurl.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/content.h"
+#include "netsurf/keypress.h"
+#include "desktop/hotlist.h"
+#include "desktop/version.h"
+
+#include "amiga/arexx.h"
+#include "amiga/bitmap.h"
+#include "amiga/clipboard.h"
+#include "amiga/cookies.h"
+#include "amiga/file.h"
+#include "amiga/filetype.h"
+#include "amiga/gui.h"
+#include "amiga/gui_menu.h"
+#include "amiga/gui_options.h"
+#include "amiga/history.h"
+#include "amiga/history_local.h"
+#include "amiga/hotlist.h"
+#include "amiga/libs.h"
+#include "amiga/menu.h"
+#include "amiga/misc.h"
+#include "amiga/nsoption.h"
+#include "amiga/print.h"
+#include "amiga/search.h"
+#include "amiga/theme.h"
+#include "amiga/utf8.h"
+#include "amiga/schedule.h"
+
+static struct Menu *restrict gui_menu = NULL;
+static int gui_menu_count = 0;
+
+static bool ami_menu_check_toggled = false;
+static bool menu_quit = false;
+
+const char * const netsurf_version;
+const char * const verdate;
+
+static nserror ami_menu_scan(struct ami_menu_data **md);
+void ami_menu_arexx_scan(struct ami_menu_data **md);
+
+/*
+ * The below functions are called automatically by window.class when menu items are selected.
+ */
+
+HOOKF(void, ami_menu_item_project_newwin, APTR, window, struct IntuiMessage *)
+{
+ nsurl *url;
+ nserror error;
+
+ error = nsurl_create(nsoption_charp(homepage_url), &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ amiga_warn_user(messages_get_errorcode(error), 0);
+ }
+}
+
+HOOKF(void, ami_menu_item_project_newtab, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+ ami_gui_new_blank_tab(gwin);
+}
+
+HOOKF(void, ami_menu_item_project_open, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_file_open(gwin);
+}
+
+HOOKF(void, ami_menu_item_project_save, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ ULONG type = (ULONG)hook->h_Data;
+
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_file_save_req(type, gwin, browser_window_get_content(gwin->gw->bw));
+}
+
+HOOKF(void, ami_menu_item_project_closetab, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_destroy(gwin->gw->bw);
+}
+
+HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ gwin->closed = true;
+}
+
+HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
+ ami_print_ui(browser_window_get_content(gwin->gw->bw));
+ ami_reset_pointer(gwin);
+}
+
+HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ char *temp, *temp2;
+ int sel;
+ nsurl *url = NULL;
+ nserror error = NSERROR_OK;
+
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
+
+ temp = ASPrintf("%s|%s|%s", messages_get("OK"),
+ messages_get("HelpCredits"),
+ messages_get("HelpLicence"));
+
+ temp2 = ami_utf8_easy(temp);
+ FreeVec(temp);
+#ifdef __amigaos4__
+ sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
+ TDR_TitleString, messages_get("NetSurf"),
+ TDR_Window, gwin->win,
+ TDR_GadgetString, temp2,
+ TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
+ TDR_Arg1,netsurf_version,
+ TDR_Arg2,verdate,
+ TAG_DONE);
+#else
+ struct EasyStruct about_req = {
+ sizeof(struct EasyStruct),
+ 0,
+ "NetSurf",
+ "NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
+ temp2,
+ };
+
+ sel = EasyRequest(gwin->win, &about_req, NULL, netsurf_version, verdate);
+#endif
+ free(temp2);
+
+ if(sel == 2) {
+ error = nsurl_create("about:credits", &url);
+ } else if(sel == 0) {
+ error = nsurl_create("about:licence", &url);
+ }
+
+ if(url) {
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ amiga_warn_user(messages_get_errorcode(error), 0);
+ }
+ }
+
+ ami_reset_pointer(gwin);
+}
+
+HOOKF(void, ami_menu_item_project_quit, APTR, window, struct IntuiMessage *)
+{
+ menu_quit = true;
+}
+
+HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_CUT_SELECTION);
+}
+
+HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *)
+{
+ struct bitmap *bm;
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ if(browser_window_can_select(gwin->gw->bw)) {
+ browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION);
+ browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
+ }
+ else if((bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw)))) {
+ /** @todo It should be checked that the lifetime of
+ * the objects containing the values returned (and the
+ * constness cast away) is safe.
+ */
+ ami_bitmap_set_url(bm, browser_window_get_url(gwin->gw->bw));
+ ami_bitmap_set_title(bm, browser_window_get_title(gwin->gw->bw));
+ ami_easy_clipboard_bitmap(bm);
+ }
+#ifdef WITH_NS_SVG
+ else if(ami_mime_compare(browser_window_get_content(gwin->gw->bw), "svg") == true) {
+ ami_easy_clipboard_svg(browser_window_get_content(gwin->gw->bw));
+ }
+#endif
+}
+
+HOOKF(void, ami_menu_item_edit_paste, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_PASTE);
+}
+
+HOOKF(void, ami_menu_item_edit_selectall, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_SELECT_ALL);
+ gui_start_selection(gwin->gw);
+}
+
+HOOKF(void, ami_menu_item_edit_clearsel, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_menu_item_edit_undo, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_UNDO);
+}
+
+HOOKF(void, ami_menu_item_edit_redo, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ browser_window_key_press(gwin->gw->bw, NS_KEY_REDO);
+}
+
+HOOKF(void, ami_menu_item_browser_find, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_search_open(gwin->gw);
+}
+
+HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_history_open(gwin->gw);
+}
+
+HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessage *)
+{
+ ami_history_global_present();
+}
+
+HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
+{
+ ami_cookies_present();
+}
+
+HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
+{
+ struct Menu *menustrip;
+ bool checked = false;
+
+ GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
+ checked = ami_menu_get_selected(menustrip, msg);
+
+ nsoption_set_bool(foreground_images, checked);
+ ami_gui_menu_set_check_toggled();
+}
+
+HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
+{
+ struct Menu *menustrip;
+ bool checked = false;
+
+ GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
+ checked = ami_menu_get_selected(menustrip, msg);
+
+ nsoption_set_bool(background_images, checked);
+ ami_gui_menu_set_check_toggled();
+}
+
+HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
+{
+ struct Menu *menustrip;
+ bool checked = false;
+
+ GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
+ checked = ami_menu_get_selected(menustrip, msg);
+
+ nsoption_set_bool(enable_javascript, checked);
+ ami_gui_menu_set_check_toggled();
+}
+
+HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1);
+}
+
+HOOKF(void, ami_menu_item_browser_scale_normal, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_gui_set_scale(gwin->gw, 1.0);
+}
+
+HOOKF(void, ami_menu_item_browser_scale_increase, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1);
+}
+
+HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ ami_schedule_redraw(gwin, true);
+ gwin->new_content = true;
+}
+
+HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *)
+{
+ struct browser_window *bw;
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ bw = gwin->gw->bw;
+
+ if (bw == NULL || browser_window_has_content(bw) == false)
+ return;
+
+ hotlist_add_url(browser_window_get_url(bw));
+ ami_gui_update_hotlist_button(gwin);
+}
+
+HOOKF(void, ami_menu_item_hotlist_show, APTR, window, struct IntuiMessage *)
+{
+ ami_hotlist_present();
+}
+
+HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *)
+{
+ nsurl *url = hook->h_Data;
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ if(url == NULL) return;
+
+ browser_window_navigate(gwin->gw->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+}
+
+HOOKF(void, ami_menu_item_settings_edit, APTR, window, struct IntuiMessage *)
+{
+ ami_gui_opts_open();
+}
+
+HOOKF(void, ami_menu_item_settings_snapshot, APTR, window, struct IntuiMessage *)
+{
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ nsoption_set_int(window_x, gwin->win->LeftEdge);
+ nsoption_set_int(window_y, gwin->win->TopEdge);
+ nsoption_set_int(window_width, gwin->win->Width);
+ nsoption_set_int(window_height, gwin->win->Height);
+}
+
+HOOKF(void, ami_menu_item_settings_save, APTR, window, struct IntuiMessage *)
+{
+ ami_nsoption_write();
+}
+
+HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *)
+{
+ char *temp;
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ if(AslRequestTags(filereq,
+ ASLFR_Window, gwin->win,
+ ASLFR_SleepWindow, TRUE,
+ ASLFR_TitleText, messages_get("NetSurf"),
+ ASLFR_Screen, scrn,
+ ASLFR_DoSaveMode, FALSE,
+ ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
+ ASLFR_InitialPattern, "#?.nsrx",
+ TAG_DONE)) {
+ if((temp = malloc(1024))) {
+ strlcpy(temp, filereq->fr_Drawer, 1024);
+ AddPart(temp, filereq->fr_File, 1024);
+ ami_arexx_execute(temp);
+ free(temp);
+ }
+ }
+}
+
+HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
+{
+ char *script = hook->h_Data;
+ char *temp;
+ struct gui_window_2 *gwin;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+
+ if(script) {
+ if((temp = malloc(1024))) {
+ BPTR lock;
+ if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
+ DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
+ AddPart(temp, script, 1024);
+ ami_arexx_execute(temp);
+ free(temp);
+ UnLock(lock);
+ }
+ }
+ }
+}
+
+/* normal GUI-specific menu functions */
+
+ULONG ami_gui_menu_number(int item)
+{
+ /* horrible, horrible, horrible */
+ ULONG menu_num;
+
+ switch(item) {
+ case M_SAVETXT:
+ menu_num = FULLMENUNUM(0,4,1);
+ break;
+
+ case M_SAVECOMP:
+ menu_num = FULLMENUNUM(0,4,2);
+ break;
+
+ case M_SAVEIFF:
+ menu_num = FULLMENUNUM(0,4,3);
+ break;
+#ifdef WITH_PDF_EXPORT
+ case M_SAVEPDF:
+ menu_num = FULLMENUNUM(0,4,4);
+ break;
+#endif
+ case M_CLOSETAB:
+ menu_num = FULLMENUNUM(0,8,0);
+ break;
+
+ case M_CUT:
+ menu_num = FULLMENUNUM(1,0,0);
+ break;
+
+ case M_COPY:
+ menu_num = FULLMENUNUM(1,1,0);
+ break;
+
+ case M_PASTE:
+ menu_num = FULLMENUNUM(1,2,0);
+ break;
+
+ case M_SELALL:
+ menu_num = FULLMENUNUM(1,4,0);
+ break;
+
+ case M_CLEAR:
+ menu_num = FULLMENUNUM(1,5,0);
+ break;
+
+ case M_UNDO:
+ menu_num = FULLMENUNUM(1,8,0);
+ break;
+
+ case M_REDO:
+ menu_num = FULLMENUNUM(1,9,0);
+ break;
+
+ case M_FIND:
+ menu_num = FULLMENUNUM(2,0,0);
+ break;
+
+ case M_IMGFORE:
+ menu_num = FULLMENUNUM(2,8,0);
+ break;
+
+ case M_IMGBACK:
+ menu_num = FULLMENUNUM(2,8,1);
+ break;
+
+ case M_JS:
+ menu_num = FULLMENUNUM(2,9,0);
+ break;
+
+ default:
+ LOG("WARNING: Unrecognised menu item %d", item);
+ menu_num = 0;
+ break;
+ }
+
+ return menu_num;
+}
+
+#ifdef __amigaos4__
+static void ami_gui_menu_set_checked_mc(struct Menu *menu, int item, bool check)
+{
+ ULONG check_state = MS_CHECKED;
+
+ if(check == false) {
+ check_state = 0;
+ }
+
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_CHECKED, check_state);
+}
+#endif
+
+static void ami_gui_menu_set_checked_gt(struct Menu *menu, int item, bool check)
+{
+ if(check == true) {
+ if((ItemAddress(menu, ami_gui_menu_number(item))->Flags & CHECKED) == 0)
+ ItemAddress(menu, ami_gui_menu_number(item))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menu, ami_gui_menu_number(item))->Flags & CHECKED)
+ ItemAddress(menu, ami_gui_menu_number(item))->Flags ^= CHECKED;
+ }
+}
+
+void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ return ami_gui_menu_set_checked_mc(menu, item, check);
+#endif
+ } else {
+ return ami_gui_menu_set_checked_gt(menu, item, check);
+ }
+}
+
+#ifdef __amigaos4__
+static void ami_gui_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG disable_state = MS_DISABLED;
+
+ if(disable == false) {
+ disable_state = 0;
+ }
+
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+}
+#endif
+
+static void ami_gui_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG menu_num = ami_gui_menu_number(item);
+
+ if(disable == false) {
+ OnMenu(win, menu_num);
+ } else {
+ OffMenu(win, menu_num);
+ }
+}
+
+void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ return ami_gui_menu_set_disabled_mc(win, menu, item, disable);
+#endif
+ } else {
+ return ami_gui_menu_set_disabled_gt(win, menu, item, disable);
+ }
+}
+
+
+void ami_gui_menu_update_checked(struct gui_window_2 *gwin)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ //needs re-writing for MenuClass
+ return;
+ }
+
+ struct Menu *menustrip;
+
+ GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
+ if(!menustrip) return;
+ if(nsoption_bool(enable_javascript) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags ^= CHECKED;
+ }
+ if(nsoption_bool(foreground_images) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags ^= CHECKED;
+ }
+
+ if(nsoption_bool(background_images) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags ^= CHECKED;
+ }
+
+ ResetMenuStrip(gwin->win, menustrip);
+}
+
+void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
+{
+ struct Window *win = g->shared->win;
+
+ if(nsoption_bool(kiosk_mode) == true) return;
+
+ if(content_get_type(c) <= CONTENT_CSS)
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
+#ifdef WITH_PDF_EXPORT
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
+#endif
+#if 0
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
+ OnMenu(win,AMI_MENU_COPY);
+ OnMenu(win,AMI_MENU_CLEAR);
+ } else {
+ OffMenu(win,AMI_MENU_COPY);
+ OffMenu(win,AMI_MENU_CLEAR);
+ }
+
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
+ OnMenu(win,AMI_MENU_CUT);
+ else
+ OffMenu(win,AMI_MENU_CUT);
+
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE)
+ OnMenu(win,AMI_MENU_PASTE);
+ else
+ OffMenu(win,AMI_MENU_PASTE);
+#else
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
+#endif
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
+ }
+ else
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
+
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
+#ifdef WITH_PDF_EXPORT
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
+#endif
+
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
+
+#ifdef WITH_NS_SVG
+ if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
+#else
+ if(content_get_bitmap(c))
+#endif
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
+ }
+ else
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
+ }
+ }
+}
+
+void ami_gui_menu_set_check_toggled(void)
+{
+ ami_menu_check_toggled = true;
+}
+
+bool ami_gui_menu_get_check_toggled(void)
+{
+ bool check_toggled = ami_menu_check_toggled;
+ ami_menu_check_toggled = false;
+ return check_toggled;
+}
+
+void ami_menu_arexx_scan(struct ami_menu_data **md)
+{
+ /**\todo Rewrite this to not use ExAll() **/
+ int item = AMI_MENU_AREXX;
+ BPTR lock = 0;
+ UBYTE *buffer;
+ struct ExAllControl *ctrl;
+ char matchpatt[16];
+ LONG cont;
+ struct ExAllData *ead;
+ char *menu_lab;
+
+ if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
+ if((buffer = malloc(1024))) {
+ if((ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))) {
+ ctrl->eac_LastKey = 0;
+
+ if(ParsePatternNoCase("#?.nsrx",(char *)&matchpatt,16) != -1) {
+ ctrl->eac_MatchString = (char *)&matchpatt;
+ }
+
+ do {
+ cont = ExAll(lock,(struct ExAllData *)buffer,1024,ED_COMMENT,ctrl);
+ if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES)) break;
+ if(!ctrl->eac_Entries) continue;
+
+ for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
+ if(item >= AMI_MENU_AREXX_MAX) continue;
+ if(EAD_IS_FILE(ead)) {
+ if(ead->ed_Comment[0] != '\0')
+ menu_lab = ead->ed_Comment;
+ else
+ menu_lab = ead->ed_Name;
+
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, NULL, NSA_SPACE,
+ ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
+
+ item++;
+ }
+ }
+ } while(cont);
+ FreeDosObject(DOS_EXALLCONTROL,ctrl);
+ }
+ free(buffer);
+ }
+ UnLock(lock);
+ }
+
+ ami_menu_alloc_item(md, item, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
+}
+
+static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
+{
+ UBYTE type;
+ STRPTR icon;
+ UWORD flags = 0;
+ struct ami_menu_data **md = (struct ami_menu_data **)userdata;
+
+ if(item >= AMI_MENU_HOTLIST_MAX) return false;
+
+ switch(level) {
+ case 1:
+ type = NM_ITEM;
+ break;
+ case 2:
+ type = NM_SUB;
+ break;
+ default:
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ type = NM_SUB + (level - 2);
+ } else {
+ /* entries not at level 1 or 2 are not able to be added */
+ return false;
+ }
+ break;
+ }
+
+ if(is_folder == true) {
+ icon = ASPrintf("icons/directory.png");
+ } else {
+ icon = ami_gui_get_cache_favicon_name(url, true);
+ if (icon == NULL) icon = ASPrintf("icons/content.png");
+ }
+
+ if(!LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ if((is_folder == true) && (type == NM_SUB)) {
+ flags = NM_ITEMDISABLED;
+ }
+ }
+
+ ami_menu_alloc_item(md, item, type, title,
+ NULL, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
+
+ if(icon) FreeVec(icon);
+
+ return true;
+}
+
+static nserror ami_menu_scan(struct ami_menu_data **md)
+{
+ return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
+}
+
+static void ami_init_menulabs(struct ami_menu_data **md)
+{
+ UWORD js_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(enable_javascript) == true)
+ js_flags |= CHECKED;
+
+ UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(foreground_images) == true)
+ imgfore_flags |= CHECKED;
+
+ UWORD imgback_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(background_images) == true)
+ imgback_flags |= CHECKED;
+
+ ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
+ ami_menu_item_project_newwin, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
+ ami_menu_item_project_newtab, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
+ ami_menu_item_project_open, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
+ ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
+#ifdef WITH_PDF_EXPORT
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
+#endif
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
+ ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
+ ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
+ ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
+ ami_menu_item_project_closetab, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
+ ami_menu_item_project_closewin, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
+ ami_menu_item_project_about, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
+ ami_menu_item_project_quit, NULL, 0);
+
+ ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
+ ami_menu_item_edit_cut, NULL, 0);
+ ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
+ ami_menu_item_edit_copy, NULL, 0);
+ ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
+ ami_menu_item_edit_paste, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
+ ami_menu_item_edit_selectall, NULL, 0);
+ ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
+ ami_menu_item_edit_clearsel, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
+ ami_menu_item_edit_undo, NULL, 0);
+ ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
+ ami_menu_item_edit_redo, NULL, 0);
+
+ ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
+ ami_menu_item_browser_find, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
+ ami_menu_item_browser_localhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
+ ami_menu_item_browser_globalhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
+ ami_menu_item_browser_cookies, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
+ ami_menu_item_browser_scale_decrease, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
+ ami_menu_item_browser_scale_normal, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
+ ami_menu_item_browser_scale_increase, NULL, 0);
+ ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
+ ami_menu_item_browser_foreimg, NULL, imgfore_flags);
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
+ ami_menu_item_browser_backimg, NULL, imgback_flags);
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
+ ami_menu_item_browser_enablejs, NULL, js_flags);
+ ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
+ ami_menu_item_browser_redraw, NULL, 0);
+
+ ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
+ ami_menu_item_hotlist_add, NULL, 0);
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
+ ami_menu_item_hotlist_show, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+
+ ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
+ ami_menu_item_settings_edit, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
+ ami_menu_item_settings_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
+ ami_menu_item_settings_save, NULL, 0);
+
+ ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
+ ami_menu_item_arexx_execute, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
+}
+
+struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ if(gui_menu != NULL) {
+ gwin->imenu = gui_menu;
+ gui_menu_count++;
+ return gwin->imenu;
+ }
+ }
+
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(gwin->menu_data);
+ ami_menu_arexx_scan(gwin->menu_data);
+ gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu = gwin->imenu;
+ gui_menu_count++;
+ }
+
+ return gwin->imenu;
+}
+
+static void ami_free_menulabs(struct ami_menu_data **md)
+{
+ int i;
+
+ for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
+ if(md[i] == NULL) continue;
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
+ }
+
+ ami_utf8_free(md[i]->menulab);
+
+ if(i >= AMI_MENU_AREXX) {
+ if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
+ md[i]->menu_hook.h_Data = NULL;
+ }
+ }
+
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
+
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = NULL;
+ md[i]->menutype = 0;
+ free(md[i]);
+ }
+}
+
+void ami_gui_menu_free(struct gui_window_2 *gwin)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu_count--;
+
+ if(gui_menu_count == 0) {
+ ami_free_menulabs(gwin->menu_data);
+ // if we detach our menu from the window we need to do this manually
+ DisposeObject((Object *)gui_menu);
+ gui_menu = NULL;
+ }
+ } else {
+ ami_free_menulabs(gwin->menu_data);
+ FreeMenus(gwin->imenu);
+ }
+}
+
+bool ami_gui_menu_quit_selected(void)
+{
+ return menu_quit;
+}
+
diff --git a/frontends/amiga/gui_menu.h b/frontends/amiga/gui_menu.h
new file mode 100644
index 0000000..a9de69a
--- /dev/null
+++ b/frontends/amiga/gui_menu.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2008-2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * 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/>.
+ */
+
+#ifndef AMIGA_GUI_MENU_H
+#define AMIGA_GUI_MENU_H
+
+/** Maximum number of hotlist items (somewhat arbitrary value) */
+#define AMI_HOTLIST_ITEMS 200
+
+/** Maximum number of ARexx menu items (somewhat arbitrary value) */
+#define AMI_MENU_AREXX_ITEMS 20
+
+/** enum menu structure, has to be here as we need it below. */
+enum {
+ /* Project menu */
+ M_PROJECT = 0,
+ M_NEWWIN,
+ M_NEWTAB,
+ M_BAR_P1,
+ M_OPEN,
+ M_SAVEAS,
+ M_SAVESRC,
+ M_SAVETXT,
+ M_SAVECOMP,
+ M_SAVEIFF,
+#ifdef WITH_PDF_EXPORT
+ M_SAVEPDF,
+#endif
+ M_BAR_P2,
+ M_PRINT,
+ M_BAR_P3,
+ M_CLOSETAB,
+ M_CLOSEWIN,
+ M_BAR_P4,
+ M_ABOUT,
+ M_BAR_P5,
+ M_QUIT,
+ /* Edit menu */
+ M_EDIT,
+ M_CUT,
+ M_COPY,
+ M_PASTE,
+ M_BAR_E1,
+ M_SELALL,
+ M_CLEAR,
+ M_BAR_E2,
+ M_UNDO,
+ M_REDO,
+ /* Browser menu */
+ M_BROWSER,
+ M_FIND,
+ M_BAR_B1,
+ M_HISTLOCL,
+ M_HISTGLBL,
+ M_BAR_B2,
+ M_COOKIES,
+ M_BAR_B3,
+ M_SCALE,
+ M_SCALEDEC,
+ M_SCALENRM,
+ M_SCALEINC,
+ M_IMAGES,
+ M_IMGFORE,
+ M_IMGBACK,
+ M_JS,
+ M_BAR_B4,
+ M_REDRAW,
+ /* Hotlist menu */
+ M_HOTLIST,
+ M_HLADD,
+ M_HLSHOW,
+ M_BAR_H1, // 47
+ AMI_MENU_HOTLIST, /* Where the hotlist entries start */
+ AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS,
+ /* Settings menu */
+ M_PREFS,
+ M_PREDIT,
+ M_BAR_S1,
+ M_SNAPSHOT,
+ M_PRSAVE,
+ /* ARexx menu */
+ M_AREXX,
+ M_AREXXEX,
+ M_BAR_A1,
+ AMI_MENU_AREXX,
+ AMI_MENU_AREXX_MAX = AMI_MENU_AREXX + AMI_MENU_AREXX_ITEMS
+};
+
+/* We can get away with AMI_MENU_MAX falling short as it is
+ * only used for freeing the UTF-8 converted menu labels */
+#define AMI_MENU_MAX AMI_MENU_AREXX
+
+struct gui_window;
+struct gui_window_2;
+struct hlcache_handle;
+
+ULONG ami_gui_menu_number(int item);
+struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin);
+void ami_gui_menu_free(struct gui_window_2 *gwin);
+
+void ami_gui_menu_update_checked(struct gui_window_2 *gwin);
+void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
+
+/**
+ * Sets that an item linked to a toggle menu item has been changed.
+ */
+void ami_gui_menu_set_check_toggled(void);
+
+/**
+ * Gets if the menu needs updating because an item linked
+ * to a toggle menu item has been changed.
+ * NB: This also *clears* the state
+ *
+ * \return true if the menus need refreshing
+ */
+bool ami_gui_menu_get_check_toggled(void);
+
+/**
+ * Set checked state of a menu item
+ * almost generic, but not quite
+ */
+void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
+
+/**
+ * Set disabled state of a menu item
+ * almost generic, but not quite
+ */
+void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+
+
+/**
+ * Gets if NetSurf has been quit from the menu
+ *
+ * \return true if NetSurf has been quit
+ */
+bool ami_gui_menu_quit_selected(void);
+#endif
+
diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c
index 698735b..b349e43 100755
--- a/frontends/amiga/gui_options.c
+++ b/frontends/amiga/gui_options.c
@@ -70,6 +70,7 @@
#include "amiga/font.h"
#include "amiga/font_bullet.h"
#include "amiga/gui.h"
+#include "amiga/gui_menu.h"
#include "amiga/gui_options.h"
#include "amiga/help.h"
#include "amiga/libs.h"
@@ -2066,7 +2067,7 @@ static void ami_gui_opts_use(bool save)
ami_font_savescanner(); /* just in case it has changed and been used only */
}
- ami_menu_set_check_toggled();
+ ami_gui_menu_set_check_toggled();
ami_update_pointer(gow->win, GUI_POINTER_DEFAULT);
}
diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c
index a1c6bf6..12c306a 100644
--- a/frontends/amiga/history.c
+++ b/frontends/amiga/history.c
@@ -49,6 +49,7 @@
#include "amiga/file.h"
#include "amiga/history.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index 6d6f7ce..008e45a 100644
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -49,6 +49,7 @@
#include "amiga/file.h"
#include "amiga/hotlist.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 8a3ca8d..6e33d5e 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -21,16 +21,9 @@
#include <string.h>
#include <stdlib.h>
-#include <proto/dos.h>
-#include <proto/asl.h>
-#include <proto/exec.h>
#include <proto/gadtools.h>
+#include <proto/graphics.h>
#include <proto/intuition.h>
-#include <proto/utility.h>
-#ifdef __amigaos4__
-#include <dos/anchorpath.h>
-#include <dos/obsolete.h> /* Needed for ExAll() */
-#endif
#include <libraries/gadtools.h>
#ifdef __amigaos4__
@@ -45,41 +38,13 @@
#include <reaction/reaction_macros.h>
-#include "utils/nsoption.h"
-#include "utils/messages.h"
#include "utils/log.h"
#include "utils/utils.h"
-#include "utils/nsurl.h"
-#include "netsurf/browser_window.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
-#include "netsurf/content.h"
-#include "netsurf/keypress.h"
-#include "desktop/hotlist.h"
-#include "desktop/version.h"
-#include "amiga/arexx.h"
-#include "amiga/bitmap.h"
-#include "amiga/clipboard.h"
-#include "amiga/cookies.h"
-#include "amiga/file.h"
-#include "amiga/filetype.h"
#include "amiga/gui.h"
-#include "amiga/gui_options.h"
-#include "amiga/history.h"
-#include "amiga/history_local.h"
-#include "amiga/hotlist.h"
#include "amiga/libs.h"
#include "amiga/menu.h"
-#include "amiga/misc.h"
-#include "amiga/nsoption.h"
-#include "amiga/print.h"
-#include "amiga/search.h"
-#include "amiga/theme.h"
#include "amiga/utf8.h"
-#include "amiga/schedule.h"
-
-#define NSA_MAX_HOTLIST_MENU_LEN 100
enum {
NSA_GLYPH_SUBMENU,
@@ -89,32 +54,13 @@ enum {
NSA_GLYPH_MAX
};
-struct ami_menu_data {
- char *restrict menulab;
- Object *restrict menuobj;
- char *restrict menukey;
- char *restrict menuicon;
- struct Hook menu_hook;
- UBYTE menutype;
- UWORD flags;
-};
-
-static struct Menu *restrict gui_menu = NULL;
-static int gui_menu_count = 0;
+#define NSA_MAX_HOTLIST_MENU_LEN 100
-static bool menu_quit = false;
-static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
static int menu_glyph_width[NSA_GLYPH_MAX];
static bool menu_glyphs_loaded = false;
-const char * const netsurf_version;
-const char * const verdate;
-
-static nserror ami_menu_scan(struct ami_menu_data **md);
-void ami_menu_arexx_scan(struct ami_menu_data **md);
-
-static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
+bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
{
bool checked = false;
@@ -133,495 +79,35 @@ static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
return checked;
}
-void ami_menu_set_check_toggled(void)
-{
- ami_menu_check_toggled = true;
-}
-
-bool ami_menu_get_check_toggled(void)
-{
- bool check_toggled = ami_menu_check_toggled;
- ami_menu_check_toggled = false;
- return check_toggled;
-}
-
-bool ami_menu_quit_selected(void)
-{
- return menu_quit;
-}
-
-/*
- * The below functions are called automatically by window.class when menu items are selected.
- */
-
-HOOKF(void, ami_menu_item_project_newwin, APTR, window, struct IntuiMessage *)
-{
- nsurl *url;
- nserror error;
-
- error = nsurl_create(nsoption_charp(homepage_url), &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(error), 0);
- }
-}
-
-HOOKF(void, ami_menu_item_project_newtab, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- ami_gui_new_blank_tab(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_open, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_file_open(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_save, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- ULONG type = (ULONG)hook->h_Data;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_file_save_req(type, gwin, browser_window_get_content(gwin->gw->bw));
-}
-
-HOOKF(void, ami_menu_item_project_closetab, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_destroy(gwin->gw->bw);
-}
-
-HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- gwin->closed = true;
-}
-
-HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
- ami_print_ui(browser_window_get_content(gwin->gw->bw));
- ami_reset_pointer(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- char *temp, *temp2;
- int sel;
- nsurl *url = NULL;
- nserror error = NSERROR_OK;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
-
- temp = ASPrintf("%s|%s|%s", messages_get("OK"),
- messages_get("HelpCredits"),
- messages_get("HelpLicence"));
-
- temp2 = ami_utf8_easy(temp);
- FreeVec(temp);
-#ifdef __amigaos4__
- sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
- TDR_TitleString, messages_get("NetSurf"),
- TDR_Window, gwin->win,
- TDR_GadgetString, temp2,
- TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
- TDR_Arg1,netsurf_version,
- TDR_Arg2,verdate,
- TAG_DONE);
-#else
- struct EasyStruct about_req = {
- sizeof(struct EasyStruct),
- 0,
- "NetSurf",
- "NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
- temp2,
- };
-
- sel = EasyRequest(gwin->win, &about_req, NULL, netsurf_version, verdate);
-#endif
- free(temp2);
-
- if(sel == 2) {
- error = nsurl_create("about:credits", &url);
- } else if(sel == 0) {
- error = nsurl_create("about:licence", &url);
- }
-
- if(url) {
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(error), 0);
+/* menu creation code */
+static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
+{
+ if(md[i] == NULL) return;
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
- }
- ami_reset_pointer(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_quit, APTR, window, struct IntuiMessage *)
-{
- menu_quit = true;
-}
-
-HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_CUT_SELECTION);
-}
-
-HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *)
-{
- struct bitmap *bm;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(browser_window_can_select(gwin->gw->bw)) {
- browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION);
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
- }
- else if((bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw)))) {
- /** @todo It should be checked that the lifetime of
- * the objects containing the values returned (and the
- * constness cast away) is safe.
- */
- ami_bitmap_set_url(bm, browser_window_get_url(gwin->gw->bw));
- ami_bitmap_set_title(bm, browser_window_get_title(gwin->gw->bw));
- ami_easy_clipboard_bitmap(bm);
- }
-#ifdef WITH_NS_SVG
- else if(ami_mime_compare(browser_window_get_content(gwin->gw->bw), "svg") == true) {
- ami_easy_clipboard_svg(browser_window_get_content(gwin->gw->bw));
+ ami_utf8_free(md[i]->menulab);
}
-#endif
-}
-
-HOOKF(void, ami_menu_item_edit_paste, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_PASTE);
-}
-HOOKF(void, ami_menu_item_edit_selectall, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_SELECT_ALL);
- gui_start_selection(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_edit_clearsel, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = NULL;
+ md[i]->menutype = 0;
+ free(md[i]);
}
-HOOKF(void, ami_menu_item_edit_undo, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_UNDO);
-}
-
-HOOKF(void, ami_menu_item_edit_redo, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_REDO);
-}
-
-HOOKF(void, ami_menu_item_browser_find, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_search_open(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_history_open(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessage *)
-{
- ami_history_global_present();
-}
-
-HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
-{
- ami_cookies_present();
-}
-
-HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(foreground_images, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(background_images, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(enable_javascript, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1);
-}
-
-HOOKF(void, ami_menu_item_browser_scale_normal, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, 1.0);
-}
-
-HOOKF(void, ami_menu_item_browser_scale_increase, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1);
-}
-
-HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_schedule_redraw(gwin, true);
- gwin->new_content = true;
-}
-
-HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *)
-{
- struct browser_window *bw;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- bw = gwin->gw->bw;
-
- if (bw == NULL || browser_window_has_content(bw) == false)
- return;
-
- hotlist_add_url(browser_window_get_url(bw));
- ami_gui_update_hotlist_button(gwin);
-}
-
-HOOKF(void, ami_menu_item_hotlist_show, APTR, window, struct IntuiMessage *)
-{
- ami_hotlist_present();
-}
-
-HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *)
-{
- nsurl *url = hook->h_Data;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(url == NULL) return;
-
- browser_window_navigate(gwin->gw->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
-}
-
-HOOKF(void, ami_menu_item_settings_edit, APTR, window, struct IntuiMessage *)
-{
- ami_gui_opts_open();
-}
-
-HOOKF(void, ami_menu_item_settings_snapshot, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- nsoption_set_int(window_x, gwin->win->LeftEdge);
- nsoption_set_int(window_y, gwin->win->TopEdge);
- nsoption_set_int(window_width, gwin->win->Width);
- nsoption_set_int(window_height, gwin->win->Height);
-}
-
-HOOKF(void, ami_menu_item_settings_save, APTR, window, struct IntuiMessage *)
-{
- ami_nsoption_write();
-}
-
-HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *)
-{
- char *temp;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(AslRequestTags(filereq,
- ASLFR_Window, gwin->win,
- ASLFR_SleepWindow, TRUE,
- ASLFR_TitleText, messages_get("NetSurf"),
- ASLFR_Screen, scrn,
- ASLFR_DoSaveMode, FALSE,
- ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
- ASLFR_InitialPattern, "#?.nsrx",
- TAG_DONE)) {
- if((temp = malloc(1024))) {
- strlcpy(temp, filereq->fr_Drawer, 1024);
- AddPart(temp, filereq->fr_File, 1024);
- ami_arexx_execute(temp);
- free(temp);
- }
- }
-}
-
-HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
-{
- char *script = hook->h_Data;
- char *temp;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(script) {
- if((temp = malloc(1024))) {
- BPTR lock;
- if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
- DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
- AddPart(temp, script, 1024);
- ami_arexx_execute(temp);
- free(temp);
- UnLock(lock);
- }
- }
- }
-}
-
-
-/* menu creation code */
static void ami_menu_free_labs(struct ami_menu_data **md, int max)
{
int i;
for(i = 0; i <= max; i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
-
- ami_utf8_free(md[i]->menulab);
- }
-
- if(md[i]->menukey != NULL) free(md[i]->menukey);
-
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
- }
-}
-
-static void ami_free_menulabs(struct ami_menu_data **md)
-{
- int i;
-
- for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
-
- ami_utf8_free(md[i]->menulab);
-
- if(i >= AMI_MENU_AREXX) {
- if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
- md[i]->menu_hook.h_Data = NULL;
- }
- }
-
- if(md[i]->menukey != NULL) free(md[i]->menukey);
-
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
+ ami_menu_free_lab_item(md, i);
}
}
@@ -671,154 +157,6 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
#endif
}
-static void ami_init_menulabs(struct ami_menu_data **md)
-{
- UWORD js_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- js_flags |= CHECKED;
-
- UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- imgfore_flags |= CHECKED;
-
- UWORD imgback_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- imgback_flags |= CHECKED;
-
- ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
- ami_menu_item_project_newwin, NULL, 0);
- ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL, 0);
- ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
- ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
- ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
-#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
-#endif
- ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
- ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
- ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
- ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
- ami_menu_item_project_about, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
- ami_menu_item_project_quit, NULL, 0);
-
- ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL, 0);
- ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL, 0);
- ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
- ami_menu_item_edit_selectall, NULL, 0);
- ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL, 0);
- ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL, 0);
-
- ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
- ami_menu_item_browser_find, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL, 0);
- ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL, 0);
- ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL, 0);
- ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
- ami_menu_item_browser_foreimg, NULL, imgfore_flags);
- ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
- ami_menu_item_browser_backimg, NULL, imgback_flags);
- ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
- ami_menu_item_browser_enablejs, NULL, js_flags);
- ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL, 0);
-
- ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
-
- ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL, 0);
- ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
- ami_menu_item_settings_save, NULL, 0);
-
- ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
-}
-
-/* Menu refresh for hotlist */
-void ami_menu_refresh(struct gui_window_2 *gwin)
-{
- return; /**\todo fix this after migrating to menuclass */
-
- struct Menu *menu;
-
- LOG("Clearing MenuStrip");
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, NULL,
- TAG_DONE);
-
- LOG("Freeing menu");
- ami_menu_free(gwin);
-
- LOG("Freeing menu labels");
- ami_free_menulabs(gwin->menu_data);
-
- LOG("Creating new menu");
- menu = ami_menu_create(gwin);
-
- LOG("Attaching MenuStrip %p to %p", menu, gwin->objects[OID_MAIN]);
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, menu,
- TAG_DONE);
-}
-
static void ami_menu_load_glyphs(struct DrawInfo *dri)
{
#ifdef __amigaos4__
@@ -1087,23 +425,6 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
}
}
-void ami_menu_free(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- gui_menu_count--;
-
- if(gui_menu_count == 0) {
- ami_free_menulabs(gwin->menu_data);
- // if we detach our menu from the window we need to do this manually
- DisposeObject((Object *)gui_menu);
- gui_menu = NULL;
- }
- } else {
- ami_free_menulabs(gwin->menu_data);
- FreeMenus(gwin->imenu);
- }
-}
-
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
{
ami_menu_free_labs(md, max);
@@ -1114,353 +435,3 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
}
}
-struct Menu *ami_menu_create(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- if(gui_menu != NULL) {
- gwin->imenu = gui_menu;
- gui_menu_count++;
- return gwin->imenu;
- }
- }
-
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
-
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- gui_menu = gwin->imenu;
- gui_menu_count++;
- }
-
- return gwin->imenu;
-}
-
-void ami_menu_arexx_scan(struct ami_menu_data **md)
-{
- /**\todo Rewrite this to not use ExAll() **/
- int item = AMI_MENU_AREXX;
- BPTR lock = 0;
- UBYTE *buffer;
- struct ExAllControl *ctrl;
- char matchpatt[16];
- LONG cont;
- struct ExAllData *ead;
- char *menu_lab;
-
- if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
- if((buffer = malloc(1024))) {
- if((ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))) {
- ctrl->eac_LastKey = 0;
-
- if(ParsePatternNoCase("#?.nsrx",(char *)&matchpatt,16) != -1) {
- ctrl->eac_MatchString = (char *)&matchpatt;
- }
-
- do {
- cont = ExAll(lock,(struct ExAllData *)buffer,1024,ED_COMMENT,ctrl);
- if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES)) break;
- if(!ctrl->eac_Entries) continue;
-
- for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
- if(item >= AMI_MENU_AREXX_MAX) continue;
- if(EAD_IS_FILE(ead)) {
- if(ead->ed_Comment[0] != '\0')
- menu_lab = ead->ed_Comment;
- else
- menu_lab = ead->ed_Name;
-
- ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, NULL, NSA_SPACE,
- ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
-
- item++;
- }
- }
- } while(cont);
- FreeDosObject(DOS_EXALLCONTROL,ctrl);
- }
- free(buffer);
- }
- UnLock(lock);
- }
-
- ami_menu_alloc_item(md, item, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
-}
-
-static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
-{
- UBYTE type;
- STRPTR icon;
- UWORD flags = 0;
- struct ami_menu_data **md = (struct ami_menu_data **)userdata;
-
- if(item >= AMI_MENU_HOTLIST_MAX) return false;
-
- switch(level) {
- case 1:
- type = NM_ITEM;
- break;
- case 2:
- type = NM_SUB;
- break;
- default:
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- type = NM_SUB + (level - 2);
- } else {
- /* entries not at level 1 or 2 are not able to be added */
- return false;
- }
- break;
- }
-
- if(is_folder == true) {
- icon = ASPrintf("icons/directory.png");
- } else {
- icon = ami_gui_get_cache_favicon_name(url, true);
- if (icon == NULL) icon = ASPrintf("icons/content.png");
- }
-
- if(!LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- if((is_folder == true) && (type == NM_SUB)) {
- flags = NM_ITEMDISABLED;
- }
- }
-
- ami_menu_alloc_item(md, item, type, title,
- NULL, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
-
- if(icon) FreeVec(icon);
-
- return true;
-}
-
-static nserror ami_menu_scan(struct ami_menu_data **md)
-{
- return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
-}
-
-#ifdef __amigaos4__
-static void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG disable_state = MS_DISABLED;
-
- if(disable == false) {
- disable_state = 0;
- }
-
- IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
-}
-#endif
-
-static ULONG ami_menu_number(int item)
-{
- /* horrible, horrible, horrible */
- ULONG menu_num;
-
- switch(item) {
- case M_SAVETXT:
- menu_num = FULLMENUNUM(0,4,1);
- break;
-
- case M_SAVECOMP:
- menu_num = FULLMENUNUM(0,4,2);
- break;
-
- case M_SAVEIFF:
- menu_num = FULLMENUNUM(0,4,3);
- break;
-#ifdef WITH_PDF_EXPORT
- case M_SAVEPDF:
- menu_num = FULLMENUNUM(0,4,4);
- break;
-#endif
- case M_CLOSETAB:
- menu_num = FULLMENUNUM(0,8,0);
- break;
-
- case M_CUT:
- menu_num = FULLMENUNUM(1,0,0);
- break;
-
- case M_COPY:
- menu_num = FULLMENUNUM(1,1,0);
- break;
-
- case M_PASTE:
- menu_num = FULLMENUNUM(1,2,0);
- break;
-
- case M_SELALL:
- menu_num = FULLMENUNUM(1,4,0);
- break;
-
- case M_CLEAR:
- menu_num = FULLMENUNUM(1,5,0);
- break;
-
- case M_UNDO:
- menu_num = FULLMENUNUM(1,8,0);
- break;
-
- case M_REDO:
- menu_num = FULLMENUNUM(1,9,0);
- break;
-
- case M_FIND:
- menu_num = FULLMENUNUM(2,0,0);
- break;
-
- case M_IMGFORE:
- menu_num = FULLMENUNUM(2,8,0);
- break;
-
- case M_IMGBACK:
- menu_num = FULLMENUNUM(2,8,1);
- break;
-
- case M_JS:
- menu_num = FULLMENUNUM(2,9,0);
- break;
-
- default:
- LOG("WARNING: Unrecognised menu item %d", item);
- menu_num = 0;
- break;
- }
-
- return menu_num;
-}
-
-static void ami_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG menu_num = ami_menu_number(item);
-
- if(disable == false) {
- OnMenu(win, menu_num);
- } else {
- OffMenu(win, menu_num);
- }
-}
-
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
-#ifdef __amigaos4__
- return ami_menu_set_disabled_mc(win, menu, item, disable);
-#endif
- } else {
- return ami_menu_set_disabled_gt(win, menu, item, disable);
- }
-}
-
-void ami_menu_update_checked(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- //needs re-writing for MenuClass
- return;
- }
-
- struct Menu *menustrip;
-
- GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
- if(!menustrip) return;
- if(nsoption_bool(enable_javascript) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- }
- if(nsoption_bool(foreground_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- }
-
- if(nsoption_bool(background_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
- }
-
- ResetMenuStrip(gwin->win, menustrip);
-}
-
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
-{
- struct Window *win = g->shared->win;
-
- if(nsoption_bool(kiosk_mode) == true) return;
-
- if(content_get_type(c) <= CONTENT_CSS)
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
-#endif
-#if 0
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_CLEAR);
- } else {
- OffMenu(win,AMI_MENU_COPY);
- OffMenu(win,AMI_MENU_CLEAR);
- }
-
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- OnMenu(win,AMI_MENU_CUT);
- else
- OffMenu(win,AMI_MENU_CUT);
-
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE)
- OnMenu(win,AMI_MENU_PASTE);
- else
- OffMenu(win,AMI_MENU_PASTE);
-#else
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
-#endif
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
-
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
-#endif
-
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
-
-#ifdef WITH_NS_SVG
- if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
-#else
- if(content_get_bitmap(c))
-#endif
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
- }
- }
-}
-
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 1bb13c4..f8a3f17 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -23,101 +23,19 @@
#include <intuition/intuition.h>
#include <libraries/gadtools.h>
-struct hlcache_handle;
-struct ami_menu_data;
+struct ami_menu_data {
+ char *restrict menulab;
+ Object *restrict menuobj;
+ char *restrict menukey;
+ char *restrict menuicon;
+ struct Hook menu_hook;
+ UBYTE menutype;
+ UWORD flags;
+};
/** empty space */
#define NSA_SPACE "blankspace.png"
-/** Maximum number of hotlist items (somewhat arbitrary value) */
-#define AMI_HOTLIST_ITEMS 60
-
-/** Maximum number of ARexx menu items (somewhat arbitrary value) */
-#define AMI_MENU_AREXX_ITEMS 20
-
-/** enum menu structure, has to be here as we need it below. */
-enum {
- /* Project menu */
- M_PROJECT = 0,
- M_NEWWIN,
- M_NEWTAB,
- M_BAR_P1,
- M_OPEN,
- M_SAVEAS,
- M_SAVESRC,
- M_SAVETXT,
- M_SAVECOMP,
- M_SAVEIFF,
-#ifdef WITH_PDF_EXPORT
- M_SAVEPDF,
-#endif
- M_BAR_P2,
- M_PRINT,
- M_BAR_P3,
- M_CLOSETAB,
- M_CLOSEWIN,
- M_BAR_P4,
- M_ABOUT,
- M_BAR_P5,
- M_QUIT,
- /* Edit menu */
- M_EDIT,
- M_CUT,
- M_COPY,
- M_PASTE,
- M_BAR_E1,
- M_SELALL,
- M_CLEAR,
- M_BAR_E2,
- M_UNDO,
- M_REDO,
- /* Browser menu */
- M_BROWSER,
- M_FIND,
- M_BAR_B1,
- M_HISTLOCL,
- M_HISTGLBL,
- M_BAR_B2,
- M_COOKIES,
- M_BAR_B3,
- M_SCALE,
- M_SCALEDEC,
- M_SCALENRM,
- M_SCALEINC,
- M_IMAGES,
- M_IMGFORE,
- M_IMGBACK,
- M_JS,
- M_BAR_B4,
- M_REDRAW,
- /* Hotlist menu */
- M_HOTLIST,
- M_HLADD,
- M_HLSHOW,
- M_BAR_H1, // 47
- AMI_MENU_HOTLIST, /* Where the hotlist entries start */
- AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS,
- /* Settings menu */
- M_PREFS,
- M_PREDIT,
- M_BAR_S1,
- M_SNAPSHOT,
- M_PRSAVE,
- /* ARexx menu */
- M_AREXX,
- M_AREXXEX,
- M_BAR_A1,
- AMI_MENU_AREXX,
- AMI_MENU_AREXX_MAX = AMI_MENU_AREXX + AMI_MENU_AREXX_ITEMS
-};
-
-/* We can get away with AMI_MENU_MAX falling short as it is
- * only used for freeing the UTF-8 converted menu labels */
-#define AMI_MENU_MAX AMI_MENU_AREXX
-
-struct gui_window;
-struct gui_window_2;
-
/* cleanup */
void ami_menu_free_glyphs(void);
@@ -128,37 +46,9 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
-/* specific to browser windows */
-struct Menu *ami_menu_create(struct gui_window_2 *gwin);
-void ami_menu_refresh(struct gui_window_2 *gwin);
-void ami_menu_update_checked(struct gui_window_2 *gwin);
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
-void ami_menu_free(struct gui_window_2 *gwin);
-
-/**
- * Set disabled state of a menu item
- */
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
-
-/**
- * Sets that an item linked to a toggle menu item has been changed.
- */
-void ami_menu_set_check_toggled(void);
-
/**
- * Gets if the menu needs updating because an item linked
- * to a toggle menu item has been changed.
- * NB: This also *clears* the state
- *
- * \return true if the menus need refreshing
- */
-bool ami_menu_get_check_toggled(void);
-
-/**
- * Gets if NetSurf has been quit from the menu
- *
- * \return true if NetSurf has been quit
+ * Get the selected state of a menu item
*/
-bool ami_menu_quit_selected(void);
+bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg);
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=52f98c9fb2b3dc04412...
commit 52f98c9fb2b3dc04412ad25b7c24fa8cf357e78d
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Share menuclass object with all browser windows
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index cb0f2fa..8b389a0 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4603,7 +4603,6 @@ static void gui_window_destroy(struct gui_window *g)
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
- ami_free_menulabs(g->shared->menu_data);
ami_menu_free(g->shared);
free(g->shared->wintitle);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index cfb3429..8a3ca8d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -99,6 +99,9 @@ struct ami_menu_data {
UWORD flags;
};
+static struct Menu *restrict gui_menu = NULL;
+static int gui_menu_count = 0;
+
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
@@ -591,7 +594,7 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
}
}
-void ami_free_menulabs(struct ami_menu_data **md)
+static void ami_free_menulabs(struct ami_menu_data **md)
{
int i;
@@ -1087,8 +1090,16 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
void ami_menu_free(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- DisposeObject((Object *)gwin->imenu); // if we detach our menu from the window we need to do this manually
+ gui_menu_count--;
+
+ if(gui_menu_count == 0) {
+ ami_free_menulabs(gwin->menu_data);
+ // if we detach our menu from the window we need to do this manually
+ DisposeObject((Object *)gui_menu);
+ gui_menu = NULL;
+ }
} else {
+ ami_free_menulabs(gwin->menu_data);
FreeMenus(gwin->imenu);
}
}
@@ -1105,11 +1116,24 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ if(gui_menu != NULL) {
+ gwin->imenu = gui_menu;
+ gui_menu_count++;
+ return gwin->imenu;
+ }
+ }
+
ami_init_menulabs(gwin->menu_data);
ami_menu_scan(gwin->menu_data);
ami_menu_arexx_scan(gwin->menu_data);
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu = gwin->imenu;
+ gui_menu_count++;
+ }
+
return gwin->imenu;
}
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 35a0ac7..1bb13c4 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -129,7 +129,6 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
/* specific to browser windows */
-void ami_free_menulabs(struct ami_menu_data **md);
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
void ami_menu_update_checked(struct gui_window_2 *gwin);
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/Makefile | 2 +-
frontends/amiga/clipboard.c | 8 +-
frontends/amiga/cookies.c | 1 +
frontends/amiga/gui.c | 25 +-
frontends/amiga/gui.h | 2 +-
frontends/amiga/{menu.c => gui_menu.c} | 1150 +++++++++++---------------------
frontends/amiga/{menu.h => gui_menu.h} | 64 +-
frontends/amiga/gui_options.c | 7 +-
frontends/amiga/history.c | 1 +
frontends/amiga/hotlist.c | 1 +
frontends/amiga/menu.c | 1047 +----------------------------
frontends/amiga/menu.h | 135 +---
12 files changed, 490 insertions(+), 1953 deletions(-)
copy frontends/amiga/{menu.c => gui_menu.c} (66%)
copy frontends/amiga/{menu.h => gui_menu.h} (66%)
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile
index 985a085..f57b4ef 100644
--- a/frontends/amiga/Makefile
+++ b/frontends/amiga/Makefile
@@ -46,7 +46,7 @@ S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \
stringview/stringview.c stringview/urlhistory.c rtg.c \
agclass/amigaguide_class.c os3support.c font_diskfont.c \
selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \
- nsoption.c corewindow.c
+ nsoption.c corewindow.c gui_menu.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 0fc9841..27b8015 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -44,7 +44,7 @@
#include "amiga/gui.h"
#include "amiga/iff_cset.h"
#include "amiga/iff_dr2d.h"
-#include "amiga/menu.h"
+#include "amiga/gui_menu.h"
#include "amiga/utf8.h"
#define ID_UTF8 MAKE_ID('U','T','F','8')
@@ -89,11 +89,11 @@ void gui_start_selection(struct gui_window *g)
if(!g->shared->win) return;
if(nsoption_bool(kiosk_mode) == true) return;
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
}
static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 17933d5..877805c 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -43,6 +43,7 @@
#include "amiga/cookies.h"
#include "amiga/corewindow.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/utf8.h"
enum {
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index cb0f2fa..d660e93 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1209,9 +1209,9 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
if(nsoption_bool(kiosk_mode) == false) {
if(gwin->tabs <= 1) {
tabclose=TRUE;
- ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
+ ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
} else {
- ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
+ ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
}
}
@@ -1637,7 +1637,7 @@ static void ami_gui_menu_update_all(void)
if(node->Type == AMINS_WINDOW)
{
- ami_menu_update_checked(gwin);
+ ami_gui_menu_update_checked(gwin);
}
} while((node = nnode));
}
@@ -1964,11 +1964,11 @@ static BOOL ami_handle_msg(void)
}
} while((node = nnode));
- if(ami_menu_quit_selected() == true) {
+ if(ami_gui_menu_quit_selected() == true) {
ami_quit_netsurf();
}
- if(ami_menu_get_check_toggled() == true) {
+ if(ami_gui_menu_get_check_toggled() == true) {
ami_gui_menu_update_all();
}
@@ -2903,7 +2903,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
ami_plot_release_pens(gwin->shared_pens);
ami_update_buttons(gwin);
- ami_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
+ ami_gui_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
if(redraw)
{
@@ -3336,7 +3336,7 @@ void ami_gui_hotlist_update_all(void)
if(node->Type == AMINS_WINDOW)
{
ami_gui_hotlist_toolbar_update(gwin);
- ami_menu_refresh(gwin);
+ //ami_gui_menu_refresh_hotlist(gwin);
}
} while((node = nnode));
}
@@ -3985,7 +3985,7 @@ gui_window_create(struct browser_window *bw,
iconifygadget = TRUE;
LOG("Creating menu");
- struct Menu *menu = ami_menu_create(g->shared);
+ struct Menu *menu = ami_gui_menu_create(g->shared);
NewList(&g->shared->tab_list);
g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
@@ -4603,8 +4603,7 @@ static void gui_window_destroy(struct gui_window *g)
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
- ami_free_menulabs(g->shared->menu_data);
- ami_menu_free(g->shared);
+ ami_gui_menu_free(g->shared);
free(g->shared->wintitle);
ami_utf8_free(g->shared->status);
@@ -5258,7 +5257,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
g->c_h = height;
if((nsoption_bool(kiosk_mode) == false))
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
}
static void gui_window_remove_caret(struct gui_window *g)
@@ -5267,7 +5266,7 @@ static void gui_window_remove_caret(struct gui_window *g)
if(g->c_h == 0) return;
if((nsoption_bool(kiosk_mode) == false))
- ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
+ ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
@@ -5291,7 +5290,7 @@ static void gui_window_new_content(struct gui_window *g)
g->shared->oldv = 0;
g->favicon = NULL;
ami_plot_release_pens(g->shared->shared_pens);
- ami_menu_update_disabled(g, c);
+ ami_gui_menu_update_disabled(g, c);
ami_gui_update_hotlist_button(g->shared);
ami_gui_scroller_update(g->shared);
}
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index a176df1..77f6839 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -28,7 +28,7 @@
#include "netsurf/window.h"
#include "netsurf/mouse.h"
-#include "amiga/menu.h"
+#include "amiga/gui_menu.h"
#include "amiga/object.h"
#include "amiga/os3support.h"
diff --git a/frontends/amiga/menu.c b/frontends/amiga/gui_menu.c
similarity index 66%
copy from frontends/amiga/menu.c
copy to frontends/amiga/gui_menu.c
index cfb3429..6b33194 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-9, 2013, 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -65,6 +65,7 @@
#include "amiga/file.h"
#include "amiga/filetype.h"
#include "amiga/gui.h"
+#include "amiga/gui_menu.h"
#include "amiga/gui_options.h"
#include "amiga/history.h"
#include "amiga/history_local.h"
@@ -79,31 +80,11 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
-#define NSA_MAX_HOTLIST_MENU_LEN 100
-
-enum {
- NSA_GLYPH_SUBMENU,
- NSA_GLYPH_AMIGAKEY,
- NSA_GLYPH_CHECKMARK,
- NSA_GLYPH_MX,
- NSA_GLYPH_MAX
-};
-
-struct ami_menu_data {
- char *restrict menulab;
- Object *restrict menuobj;
- char *restrict menukey;
- char *restrict menuicon;
- struct Hook menu_hook;
- UBYTE menutype;
- UWORD flags;
-};
+static struct Menu *restrict gui_menu = NULL;
+static int gui_menu_count = 0;
-static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
-static Object *restrict menu_glyph[NSA_GLYPH_MAX];
-static int menu_glyph_width[NSA_GLYPH_MAX];
-static bool menu_glyphs_loaded = false;
+static bool menu_quit = false;
const char * const netsurf_version;
const char * const verdate;
@@ -111,42 +92,6 @@ const char * const verdate;
static nserror ami_menu_scan(struct ami_menu_data **md);
void ami_menu_arexx_scan(struct ami_menu_data **md);
-static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
-{
- bool checked = false;
-
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
-#ifdef __amigaos4__
- ULONG state;
- struct ExtIntuiMessage *emsg = (struct ExtIntuiMessage *)msg;
-
- state = IDoMethod((Object *)menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
- if(state & MS_CHECKED) checked = true;
-#endif
- } else {
- if(ItemAddress(menu, msg->Code)->Flags & CHECKED) checked = true;
- }
-
- return checked;
-}
-
-void ami_menu_set_check_toggled(void)
-{
- ami_menu_check_toggled = true;
-}
-
-bool ami_menu_get_check_toggled(void)
-{
- bool check_toggled = ami_menu_check_toggled;
- ami_menu_check_toggled = false;
- return check_toggled;
-}
-
-bool ami_menu_quit_selected(void)
-{
- return menu_quit;
-}
-
/*
* The below functions are called automatically by window.class when menu items are selected.
*/
@@ -400,7 +345,7 @@ HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(foreground_images, checked);
- ami_menu_set_check_toggled();
+ ami_gui_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
@@ -412,7 +357,7 @@ HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(background_images, checked);
- ami_menu_set_check_toggled();
+ ami_gui_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
@@ -424,7 +369,7 @@ HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(enable_javascript, checked);
- ami_menu_set_check_toggled();
+ ami_gui_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *)
@@ -563,554 +508,296 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
}
}
+/* normal GUI-specific menu functions */
-/* menu creation code */
-static void ami_menu_free_labs(struct ami_menu_data **md, int max)
+ULONG ami_gui_menu_number(int item)
{
- int i;
+ /* horrible, horrible, horrible */
+ ULONG menu_num;
- for(i = 0; i <= max; i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
+ switch(item) {
+ case M_SAVETXT:
+ menu_num = FULLMENUNUM(0,4,1);
+ break;
- ami_utf8_free(md[i]->menulab);
- }
+ case M_SAVECOMP:
+ menu_num = FULLMENUNUM(0,4,2);
+ break;
- if(md[i]->menukey != NULL) free(md[i]->menukey);
+ case M_SAVEIFF:
+ menu_num = FULLMENUNUM(0,4,3);
+ break;
+#ifdef WITH_PDF_EXPORT
+ case M_SAVEPDF:
+ menu_num = FULLMENUNUM(0,4,4);
+ break;
+#endif
+ case M_CLOSETAB:
+ menu_num = FULLMENUNUM(0,8,0);
+ break;
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
+ case M_CUT:
+ menu_num = FULLMENUNUM(1,0,0);
+ break;
+
+ case M_COPY:
+ menu_num = FULLMENUNUM(1,1,0);
+ break;
+
+ case M_PASTE:
+ menu_num = FULLMENUNUM(1,2,0);
+ break;
+
+ case M_SELALL:
+ menu_num = FULLMENUNUM(1,4,0);
+ break;
+
+ case M_CLEAR:
+ menu_num = FULLMENUNUM(1,5,0);
+ break;
+
+ case M_UNDO:
+ menu_num = FULLMENUNUM(1,8,0);
+ break;
+
+ case M_REDO:
+ menu_num = FULLMENUNUM(1,9,0);
+ break;
+
+ case M_FIND:
+ menu_num = FULLMENUNUM(2,0,0);
+ break;
+
+ case M_IMGFORE:
+ menu_num = FULLMENUNUM(2,8,0);
+ break;
+
+ case M_IMGBACK:
+ menu_num = FULLMENUNUM(2,8,1);
+ break;
+
+ case M_JS:
+ menu_num = FULLMENUNUM(2,9,0);
+ break;
+
+ default:
+ LOG("WARNING: Unrecognised menu item %d", item);
+ menu_num = 0;
+ break;
}
+
+ return menu_num;
}
-void ami_free_menulabs(struct ami_menu_data **md)
+#ifdef __amigaos4__
+static void ami_gui_menu_set_checked_mc(struct Menu *menu, int item, bool check)
{
- int i;
+ ULONG check_state = MS_CHECKED;
- for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
+ if(check == false) {
+ check_state = 0;
+ }
- ami_utf8_free(md[i]->menulab);
+ if(menu == NULL) {
+ menu = gui_menu;
+ }
- if(i >= AMI_MENU_AREXX) {
- if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
- md[i]->menu_hook.h_Data = NULL;
- }
- }
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_CHECKED, check_state);
+}
+#endif
- if(md[i]->menukey != NULL) free(md[i]->menukey);
+static void ami_gui_menu_set_checked_gt(struct Menu *menu, int item, bool check)
+{
+ if(menu == NULL) {
+ return;
+ }
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
+ if(check == true) {
+ if((ItemAddress(menu, ami_gui_menu_number(item))->Flags & CHECKED) == 0)
+ ItemAddress(menu, ami_gui_menu_number(item))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menu, ami_gui_menu_number(item))->Flags & CHECKED)
+ ItemAddress(menu, ami_gui_menu_number(item))->Flags ^= CHECKED;
}
}
-void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, const char *restrict key, const char *restrict icon,
- void *restrict func, void *restrict hookdata, UWORD flags)
+void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check)
{
- char menu_icon[1024];
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ return ami_gui_menu_set_checked_mc(menu, item, check);
+#endif
+ } else {
+ return ami_gui_menu_set_checked_gt(menu, item, check);
+ }
+}
- md[num] = calloc(1, sizeof(struct ami_menu_data));
- md[num]->menutype = type;
- md[num]->flags = flags;
-
- if(type == NM_END) return;
-
- if((label == NM_BARLABEL) || (strcmp(label, "--") == 0)) {
- md[num]->menulab = NM_BARLABEL;
- icon = NULL;
- } else { /* horrid non-generic stuff */
- if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
- utf8_from_local_encoding(label,
- (strlen(label) < NSA_MAX_HOTLIST_MENU_LEN) ? strlen(label) : NSA_MAX_HOTLIST_MENU_LEN,
- (char **)&md[num]->menulab);
- } else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
- md[num]->menulab = strdup(label);
- } else {
- md[num]->menulab = ami_utf8_easy(messages_get(label));
- }
+#ifdef __amigaos4__
+static void ami_gui_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG disable_state = MS_DISABLED;
+
+ if(disable == false) {
+ disable_state = 0;
}
- md[num]->menuicon = NULL;
- if(key) md[num]->menukey = strdup(key);
- if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
- if(hookdata) md[num]->menu_hook.h_Data = hookdata;
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+}
+#endif
+
+static void ami_gui_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG menu_num = ami_gui_menu_number(item);
+
+ if(disable == false) {
+ OnMenu(win, menu_num);
+ } else {
+ OffMenu(win, menu_num);
+ }
+}
+void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
#ifdef __amigaos4__
- if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
- if(icon) {
- if(ami_locate_resource(menu_icon, icon) == true) {
- md[num]->menuicon = (char *)strdup(menu_icon);
- } else {
- /* If the requested icon can't be found, put blank space in instead */
- md[num]->menuicon = (char *)strdup(NSA_SPACE);
- }
- }
+ return ami_gui_menu_set_disabled_mc(win, menu, item, disable);
+#endif
+ } else {
+ return ami_gui_menu_set_disabled_gt(win, menu, item, disable);
}
-#endif
}
-static void ami_init_menulabs(struct ami_menu_data **md)
+
+void ami_gui_menu_update_checked(struct gui_window_2 *gwin)
{
- UWORD js_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- js_flags |= CHECKED;
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* Irrelevant when using MenuClass */
+ return;
+ }
- UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- imgfore_flags |= CHECKED;
+ struct Menu *menustrip;
- UWORD imgback_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- imgback_flags |= CHECKED;
+ GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
+ if(!menustrip) return;
+ if(nsoption_bool(enable_javascript) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags ^= CHECKED;
+ }
+ if(nsoption_bool(foreground_images) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags ^= CHECKED;
+ }
- ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
- ami_menu_item_project_newwin, NULL, 0);
- ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL, 0);
- ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
- ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
- ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
+ if(nsoption_bool(background_images) == true) {
+ if((ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags ^= CHECKED;
+ } else {
+ if(ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags ^= CHECKED;
+ }
+
+ ResetMenuStrip(gwin->win, menustrip);
+}
+
+void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
+{
+ struct Window *win = g->shared->win;
+
+ if(nsoption_bool(kiosk_mode) == true) return;
+
+ if(content_get_type(c) <= CONTENT_CSS)
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
#endif
- ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
- ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
- ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
- ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
- ami_menu_item_project_about, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
- ami_menu_item_project_quit, NULL, 0);
-
- ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL, 0);
- ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL, 0);
- ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
- ami_menu_item_edit_selectall, NULL, 0);
- ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL, 0);
- ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL, 0);
-
- ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
- ami_menu_item_browser_find, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL, 0);
- ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL, 0);
- ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL, 0);
- ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
- ami_menu_item_browser_foreimg, NULL, imgfore_flags);
- ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
- ami_menu_item_browser_backimg, NULL, imgback_flags);
- ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
- ami_menu_item_browser_enablejs, NULL, js_flags);
- ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL, 0);
-
- ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
-
- ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL, 0);
- ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
- ami_menu_item_settings_save, NULL, 0);
-
- ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
-}
-
-/* Menu refresh for hotlist */
-void ami_menu_refresh(struct gui_window_2 *gwin)
-{
- return; /**\todo fix this after migrating to menuclass */
-
- struct Menu *menu;
-
- LOG("Clearing MenuStrip");
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, NULL,
- TAG_DONE);
-
- LOG("Freeing menu");
- ami_menu_free(gwin);
-
- LOG("Freeing menu labels");
- ami_free_menulabs(gwin->menu_data);
-
- LOG("Creating new menu");
- menu = ami_menu_create(gwin);
-
- LOG("Attaching MenuStrip %p to %p", menu, gwin->objects[OID_MAIN]);
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, menu,
- TAG_DONE);
-}
-
-static void ami_menu_load_glyphs(struct DrawInfo *dri)
-{
-#ifdef __amigaos4__
- if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
- for(int i = 0; i < NSA_GLYPH_MAX; i++)
- menu_glyph[i] = NULL;
-
- menu_glyph[NSA_GLYPH_SUBMENU] = NewObject(NULL, "sysiclass",
- SYSIA_Which, MENUSUB,
- SYSIA_DrawInfo, dri,
- TAG_DONE);
- menu_glyph[NSA_GLYPH_AMIGAKEY] = NewObject(NULL, "sysiclass",
- SYSIA_Which, AMIGAKEY,
- SYSIA_DrawInfo, dri,
- TAG_DONE);
- GetAttr(IA_Width, menu_glyph[NSA_GLYPH_SUBMENU],
- (ULONG *)&menu_glyph_width[NSA_GLYPH_SUBMENU]);
- GetAttr(IA_Width, menu_glyph[NSA_GLYPH_AMIGAKEY],
- (ULONG *)&menu_glyph_width[NSA_GLYPH_AMIGAKEY]);
-
- menu_glyphs_loaded = true;
- }
-#endif
-}
-
-void ami_menu_free_glyphs(void)
-{
-#ifdef __amigaos4__
- if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
- int i;
- if(menu_glyphs_loaded == false) return;
-
- for(i = 0; i < NSA_GLYPH_MAX; i++) {
- if(menu_glyph[i]) DisposeObject(menu_glyph[i]);
- menu_glyph[i] = NULL;
- };
-
- menu_glyphs_loaded = false;
- }
-#endif
-}
-
-static int ami_menu_calc_item_width(struct ami_menu_data **md, int j, struct RastPort *rp)
-{
- int space_width = TextLength(rp, " ", 1);
- int item_size;
-
- item_size = TextLength(rp, md[j]->menulab, strlen(md[j]->menulab));
- item_size += space_width;
-
- if(md[j]->menukey) {
- item_size += TextLength(rp, md[j]->menukey, 1);
- item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
- /**TODO: take account of the size of other imagery too
- */
- } else {
- /* assume worst case - it doesn't really matter if we make menus wider */
- item_size += TextLength(rp, "M", 1);
- item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
- }
-
- if(md[j]->menuicon) {
- item_size += 16;
- }
-
- return item_size;
-}
-
-#ifdef __amigaos4__
-static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_data **md, int level, int i, int max)
-{
- int j;
- Object *menu_item = menu_parent;
-
- for(j = i; j < max; j++) {
- /* skip empty entries */
- if(md[j] == NULL) continue;
- if(md[j]->menutype == NM_IGNORE) continue;
-
- if(md[j]->menutype == level) {
- if(md[j]->menulab == NM_BARLABEL)
- md[j]->menulab = ML_SEPARATOR;
-
- if(level == NM_TITLE) {
- menu_item = NewObject(NULL, "menuclass",
- MA_Type, T_MENU,
- MA_Label, md[j]->menulab,
- TAG_DONE);
- } else {
- menu_item = NewObject(NULL, "menuclass",
- MA_Type, T_ITEM,
- MA_ID, j,
- MA_Label, md[j]->menulab,
- MA_Image,
- BitMapObj,
- IA_Scalable, TRUE,
- BITMAP_Screen, scrn,
- BITMAP_SourceFile, md[j]->menuicon,
- BITMAP_Masking, TRUE,
- BitMapEnd,
- MA_Key, md[j]->menukey,
- MA_UserData, &md[j]->menu_hook, /* NB: Intentionally UserData */
- MA_Disabled, (md[j]->flags & NM_ITEMDISABLED),
- MA_Selected, (md[j]->flags & CHECKED),
- MA_Toggle, (md[j]->flags & MENUTOGGLE),
- TAG_DONE);
- }
-
- IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
- continue;
- } else if (md[j]->menutype > level) {
- j = ami_menu_layout_mc_recursive(menu_item, md, md[j]->menutype, j, max);
+#if 0
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
+ OnMenu(win,AMI_MENU_COPY);
+ OnMenu(win,AMI_MENU_CLEAR);
} else {
- break;
+ OffMenu(win,AMI_MENU_COPY);
+ OffMenu(win,AMI_MENU_CLEAR);
}
- }
- return (j - 1);
-}
-
-static struct Menu *ami_menu_layout_mc(struct ami_menu_data **md, int max)
-{
- Object *menu_root = NewObject(NULL, "menuclass",
- MA_Type, T_ROOT,
- MA_EmbeddedKey, FALSE,
- TAG_DONE);
-
- ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, 0, max);
- return (struct Menu *)menu_root;
-}
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
+ OnMenu(win,AMI_MENU_CUT);
+ else
+ OffMenu(win,AMI_MENU_CUT);
+
+ if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE)
+ OnMenu(win,AMI_MENU_PASTE);
+ else
+ OffMenu(win,AMI_MENU_PASTE);
+#else
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
#endif
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
+ }
+ else
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
-static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max)
-{
- int i, j;
- int txtlen = 0;
- int left_posn = 0;
- struct NewMenu *nm;
- struct Menu *imenu = NULL;
- struct VisualInfo *vi;
- struct RastPort *rp = &scrn->RastPort;
- struct DrawInfo *dri = GetScreenDrawInfo(scrn);
- int space_width = TextLength(rp, " ", 1);
-
- if(menu_glyphs_loaded == false)
- ami_menu_load_glyphs(dri);
-
- nm = calloc(1, sizeof(struct NewMenu) * (max + 1));
- if(nm == NULL) return NULL;
-
- for(i = 0; i < max; i++) {
- if(md[i] == NULL) {
- nm[i].nm_Type = NM_IGNORE;
- continue;
- }
-
- if(md[i]->menutype == NM_TITLE) {
- j = i + 1;
- txtlen = 0;
- do {
- if(md[j]->menulab != NM_BARLABEL) {
- if(md[j]->menutype == NM_ITEM) {
- int item_size = ami_menu_calc_item_width(md, j, rp);
- if(item_size > txtlen) {
- txtlen = item_size;
- }
- }
- }
- j++;
- } while((j <= max) && (md[j] != NULL) && (md[j]->menutype != NM_TITLE) && (md[j]->menutype != 0));
- }
-#ifdef __amigaos4__
- if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
- /* GadTools 53.7+ only. For now we will only create the menu
- using label.image if there's a bitmap associated with the item. */
- if((md[i]->menuicon != NULL) && (md[i]->menulab != NM_BARLABEL)) {
- int icon_width = 0;
- Object *restrict submenuarrow = NULL;
- Object *restrict icon = BitMapObj,
- IA_Scalable, TRUE,
- BITMAP_Screen, scrn,
- BITMAP_SourceFile, md[i]->menuicon,
- BITMAP_Masking, TRUE,
- BitMapEnd;
-
- /* \todo make this scale the bitmap to these dimensions */
- SetAttrs(icon,
- BITMAP_Width, 16,
- BITMAP_Height, 16,
- TAG_DONE);
-
- GetAttr(IA_Width, icon, (ULONG *)&icon_width);
-
- if(md[i]->menutype != NM_SUB) {
- left_posn = txtlen;
- }
-
- left_posn = left_posn -
- TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
- icon_width - space_width;
-
- if((md[i]->menutype == NM_ITEM) && md[i+1] && (md[i+1]->menutype == NM_SUB)) {
- left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
+#ifdef WITH_PDF_EXPORT
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
+#endif
- submenuarrow = NewObject(NULL, "sysiclass",
- SYSIA_Which, MENUSUB,
- SYSIA_DrawInfo, dri,
- IA_Left, left_posn,
- TAG_DONE);
- }
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
- md[i]->menuobj = LabelObj,
- LABEL_MenuMode, TRUE,
- LABEL_DrawInfo, dri,
- LABEL_DisposeImage, TRUE,
- LABEL_Image, icon,
- LABEL_Text, " ",
- LABEL_Text, md[i]->menulab,
- LABEL_DisposeImage, TRUE,
- LABEL_Image, submenuarrow,
- LabelEnd;
-
- if(md[i]->menuobj) md[i]->menutype |= MENU_IMAGE;
- }
- }
+#ifdef WITH_NS_SVG
+ if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
+#else
+ if(content_get_bitmap(c))
#endif
- nm[i].nm_Type = md[i]->menutype;
-
- if(md[i]->menuobj)
- nm[i].nm_Label = (void *)md[i]->menuobj;
- else
- nm[i].nm_Label = md[i]->menulab;
-
- if((md[i]->menukey) && (strlen(md[i]->menukey) > 1)) {
- nm[i].nm_CommKey = md[i]->menukey;
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
}
- nm[i].nm_Flags = md[i]->flags;
- if(md[i]->menu_hook.h_Entry) nm[i].nm_UserData = &md[i]->menu_hook;
-
- if(md[i]->menuicon) {
- free(md[i]->menuicon);
- md[i]->menuicon = NULL;
+ else
+ {
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
+ ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
}
}
-
- FreeScreenDrawInfo(scrn, dri);
-
- vi = GetVisualInfo(scrn, TAG_DONE);
- imenu = CreateMenus(nm, TAG_DONE);
- LayoutMenus(imenu, vi,
- GTMN_NewLookMenus, TRUE, TAG_DONE);
- free(nm);
- FreeVisualInfo(vi); /* Not using GadTools after layout so shouldn't need this */
-
- return imenu;
}
-struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
+void ami_gui_menu_set_check_toggled(void)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
-#ifdef __amigaos4__
- return ami_menu_layout_mc(md, max);
-#endif
- } else {
- return ami_menu_layout_gt(md, max);
+ /* Irrelevant when using MenuClass */
+ return;
}
-}
-void ami_menu_free(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- DisposeObject((Object *)gwin->imenu); // if we detach our menu from the window we need to do this manually
- } else {
- FreeMenus(gwin->imenu);
- }
+ ami_menu_check_toggled = true;
}
-void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
+bool ami_gui_menu_get_check_toggled(void)
{
- ami_menu_free_labs(md, max);
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- DisposeObject((Object *)imenu); // if we detach our menu from the window we need to do this manually
- } else {
- FreeMenus(imenu);
+ /* Irrelevant when using MenuClass */
+ return false;
}
-}
-
-struct Menu *ami_menu_create(struct gui_window_2 *gwin)
-{
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
- return gwin->imenu;
+ bool check_toggled = ami_menu_check_toggled;
+ ami_menu_check_toggled = false;
+ return check_toggled;
}
void ami_menu_arexx_scan(struct ami_menu_data **md)
@@ -1216,227 +903,200 @@ static nserror ami_menu_scan(struct ami_menu_data **md)
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
-#ifdef __amigaos4__
-static void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG disable_state = MS_DISABLED;
-
- if(disable == false) {
- disable_state = 0;
- }
-
- IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
-}
-#endif
-
-static ULONG ami_menu_number(int item)
+static void ami_init_menulabs(struct ami_menu_data **md)
{
- /* horrible, horrible, horrible */
- ULONG menu_num;
+ UWORD js_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(enable_javascript) == true)
+ js_flags |= CHECKED;
- switch(item) {
- case M_SAVETXT:
- menu_num = FULLMENUNUM(0,4,1);
- break;
+ UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(foreground_images) == true)
+ imgfore_flags |= CHECKED;
- case M_SAVECOMP:
- menu_num = FULLMENUNUM(0,4,2);
- break;
+ UWORD imgback_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(background_images) == true)
+ imgback_flags |= CHECKED;
- case M_SAVEIFF:
- menu_num = FULLMENUNUM(0,4,3);
- break;
+ ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
+ ami_menu_item_project_newwin, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
+ ami_menu_item_project_newtab, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
+ ami_menu_item_project_open, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
+ ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- case M_SAVEPDF:
- menu_num = FULLMENUNUM(0,4,4);
- break;
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- case M_CLOSETAB:
- menu_num = FULLMENUNUM(0,8,0);
- break;
-
- case M_CUT:
- menu_num = FULLMENUNUM(1,0,0);
- break;
-
- case M_COPY:
- menu_num = FULLMENUNUM(1,1,0);
- break;
-
- case M_PASTE:
- menu_num = FULLMENUNUM(1,2,0);
- break;
-
- case M_SELALL:
- menu_num = FULLMENUNUM(1,4,0);
- break;
-
- case M_CLEAR:
- menu_num = FULLMENUNUM(1,5,0);
- break;
-
- case M_UNDO:
- menu_num = FULLMENUNUM(1,8,0);
- break;
-
- case M_REDO:
- menu_num = FULLMENUNUM(1,9,0);
- break;
-
- case M_FIND:
- menu_num = FULLMENUNUM(2,0,0);
- break;
-
- case M_IMGFORE:
- menu_num = FULLMENUNUM(2,8,0);
- break;
-
- case M_IMGBACK:
- menu_num = FULLMENUNUM(2,8,1);
- break;
-
- case M_JS:
- menu_num = FULLMENUNUM(2,9,0);
- break;
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
+ ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
+ ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
+ ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
+ ami_menu_item_project_closetab, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
+ ami_menu_item_project_closewin, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
+ ami_menu_item_project_about, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
+ ami_menu_item_project_quit, NULL, 0);
- default:
- LOG("WARNING: Unrecognised menu item %d", item);
- menu_num = 0;
- break;
- }
+ ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
+ ami_menu_item_edit_cut, NULL, 0);
+ ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
+ ami_menu_item_edit_copy, NULL, 0);
+ ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
+ ami_menu_item_edit_paste, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
+ ami_menu_item_edit_selectall, NULL, 0);
+ ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
+ ami_menu_item_edit_clearsel, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
+ ami_menu_item_edit_undo, NULL, 0);
+ ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
+ ami_menu_item_edit_redo, NULL, 0);
- return menu_num;
-}
+ ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
+ ami_menu_item_browser_find, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
+ ami_menu_item_browser_localhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
+ ami_menu_item_browser_globalhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
+ ami_menu_item_browser_cookies, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
+ ami_menu_item_browser_scale_decrease, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
+ ami_menu_item_browser_scale_normal, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
+ ami_menu_item_browser_scale_increase, NULL, 0);
+ ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
+ ami_menu_item_browser_foreimg, NULL, imgfore_flags);
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
+ ami_menu_item_browser_backimg, NULL, imgback_flags);
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
+ ami_menu_item_browser_enablejs, NULL, js_flags);
+ ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
+ ami_menu_item_browser_redraw, NULL, 0);
-static void ami_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG menu_num = ami_menu_number(item);
+ ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
+ ami_menu_item_hotlist_add, NULL, 0);
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
+ ami_menu_item_hotlist_show, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- if(disable == false) {
- OnMenu(win, menu_num);
- } else {
- OffMenu(win, menu_num);
- }
-}
+ ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
+ ami_menu_item_settings_edit, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
+ ami_menu_item_settings_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
+ ami_menu_item_settings_save, NULL, 0);
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
-#ifdef __amigaos4__
- return ami_menu_set_disabled_mc(win, menu, item, disable);
-#endif
- } else {
- return ami_menu_set_disabled_gt(win, menu, item, disable);
- }
+ ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
+ ami_menu_item_arexx_execute, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
-void ami_menu_update_checked(struct gui_window_2 *gwin)
+struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- //needs re-writing for MenuClass
- return;
+ if(gui_menu != NULL) {
+ gwin->imenu = gui_menu;
+ gui_menu_count++;
+ return gwin->imenu;
+ }
}
- struct Menu *menustrip;
-
- GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
- if(!menustrip) return;
- if(nsoption_bool(enable_javascript) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- }
- if(nsoption_bool(foreground_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- }
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(gwin->menu_data);
+ ami_menu_arexx_scan(gwin->menu_data);
+ gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
- if(nsoption_bool(background_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu = gwin->imenu;
+ gui_menu_count++;
}
- ResetMenuStrip(gwin->win, menustrip);
+ return gwin->imenu;
}
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
+static void ami_free_menulabs(struct ami_menu_data **md)
{
- struct Window *win = g->shared->win;
+ int i;
- if(nsoption_bool(kiosk_mode) == true) return;
+ for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
+ if(md[i] == NULL) continue;
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
+ }
- if(content_get_type(c) <= CONTENT_CSS)
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
-#endif
-#if 0
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_CLEAR);
- } else {
- OffMenu(win,AMI_MENU_COPY);
- OffMenu(win,AMI_MENU_CLEAR);
+ ami_utf8_free(md[i]->menulab);
+
+ if(i >= AMI_MENU_AREXX) {
+ if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
+ md[i]->menu_hook.h_Data = NULL;
+ }
}
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- OnMenu(win,AMI_MENU_CUT);
- else
- OffMenu(win,AMI_MENU_CUT);
-
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE)
- OnMenu(win,AMI_MENU_PASTE);
- else
- OffMenu(win,AMI_MENU_PASTE);
-#else
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
-#endif
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
-#endif
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = NULL;
+ md[i]->menutype = 0;
+ free(md[i]);
+ }
+}
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
+void ami_gui_menu_free(struct gui_window_2 *gwin)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu_count--;
-#ifdef WITH_NS_SVG
- if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
-#else
- if(content_get_bitmap(c))
-#endif
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
+ if(gui_menu_count == 0) {
+ ami_free_menulabs(gwin->menu_data);
+ // if we detach our menu from the window we need to do this manually
+ DisposeObject((Object *)gui_menu);
+ gui_menu = NULL;
}
+ } else {
+ ami_free_menulabs(gwin->menu_data);
+ FreeMenus(gwin->imenu);
}
}
+bool ami_gui_menu_quit_selected(void)
+{
+ return menu_quit;
+}
+
diff --git a/frontends/amiga/menu.h b/frontends/amiga/gui_menu.h
similarity index 66%
copy from frontends/amiga/menu.h
copy to frontends/amiga/gui_menu.h
index 35a0ac7..a9de69a 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/gui_menu.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,21 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef AMIGA_MENU_H
-#define AMIGA_MENU_H
-
-#include <exec/types.h>
-#include <intuition/intuition.h>
-#include <libraries/gadtools.h>
-
-struct hlcache_handle;
-struct ami_menu_data;
-
-/** empty space */
-#define NSA_SPACE "blankspace.png"
+#ifndef AMIGA_GUI_MENU_H
+#define AMIGA_GUI_MENU_H
/** Maximum number of hotlist items (somewhat arbitrary value) */
-#define AMI_HOTLIST_ITEMS 60
+#define AMI_HOTLIST_ITEMS 200
/** Maximum number of ARexx menu items (somewhat arbitrary value) */
#define AMI_MENU_AREXX_ITEMS 20
@@ -117,34 +107,19 @@ enum {
struct gui_window;
struct gui_window_2;
+struct hlcache_handle;
-/* cleanup */
-void ami_menu_free_glyphs(void);
-
-/* generic menu alloc/free/layout */
-void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, const char *restrict key, const char *restrict icon,
- void *restrict func, void *restrict hookdata, UWORD flags);
-struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
-void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
-
-/* specific to browser windows */
-void ami_free_menulabs(struct ami_menu_data **md);
-struct Menu *ami_menu_create(struct gui_window_2 *gwin);
-void ami_menu_refresh(struct gui_window_2 *gwin);
-void ami_menu_update_checked(struct gui_window_2 *gwin);
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
-void ami_menu_free(struct gui_window_2 *gwin);
+ULONG ami_gui_menu_number(int item);
+struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin);
+void ami_gui_menu_free(struct gui_window_2 *gwin);
-/**
- * Set disabled state of a menu item
- */
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+void ami_gui_menu_update_checked(struct gui_window_2 *gwin);
+void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
/**
* Sets that an item linked to a toggle menu item has been changed.
*/
-void ami_menu_set_check_toggled(void);
+void ami_gui_menu_set_check_toggled(void);
/**
* Gets if the menu needs updating because an item linked
@@ -153,13 +128,26 @@ void ami_menu_set_check_toggled(void);
*
* \return true if the menus need refreshing
*/
-bool ami_menu_get_check_toggled(void);
+bool ami_gui_menu_get_check_toggled(void);
+
+/**
+ * Set checked state of a menu item
+ * almost generic, but not quite
+ */
+void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
+
+/**
+ * Set disabled state of a menu item
+ * almost generic, but not quite
+ */
+void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+
/**
* Gets if NetSurf has been quit from the menu
*
* \return true if NetSurf has been quit
*/
-bool ami_menu_quit_selected(void);
+bool ami_gui_menu_quit_selected(void);
#endif
diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c
index 698735b..78dea58 100755
--- a/frontends/amiga/gui_options.c
+++ b/frontends/amiga/gui_options.c
@@ -70,6 +70,7 @@
#include "amiga/font.h"
#include "amiga/font_bullet.h"
#include "amiga/gui.h"
+#include "amiga/gui_menu.h"
#include "amiga/gui_options.h"
#include "amiga/help.h"
#include "amiga/libs.h"
@@ -1726,7 +1727,9 @@ static void ami_gui_opts_use(bool save)
} else {
nsoption_set_bool(enable_javascript, false);
}
-
+
+ ami_gui_menu_set_checked(NULL, M_JS, nsoption_bool(enable_javascript));
+
GetAttr(GA_Selected,gow->objects[GID_OPTS_DONOTTRACK],(ULONG *)&data);
if (data) {
nsoption_set_bool(do_not_track, true);
@@ -2066,7 +2069,7 @@ static void ami_gui_opts_use(bool save)
ami_font_savescanner(); /* just in case it has changed and been used only */
}
- ami_menu_set_check_toggled();
+ ami_gui_menu_set_check_toggled();
ami_update_pointer(gow->win, GUI_POINTER_DEFAULT);
}
diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c
index a1c6bf6..12c306a 100644
--- a/frontends/amiga/history.c
+++ b/frontends/amiga/history.c
@@ -49,6 +49,7 @@
#include "amiga/file.h"
#include "amiga/history.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index 6d6f7ce..008e45a 100644
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -49,6 +49,7 @@
#include "amiga/file.h"
#include "amiga/hotlist.h"
#include "amiga/libs.h"
+#include "amiga/menu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index cfb3429..04c6eb0 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -21,16 +21,9 @@
#include <string.h>
#include <stdlib.h>
-#include <proto/dos.h>
-#include <proto/asl.h>
-#include <proto/exec.h>
#include <proto/gadtools.h>
+#include <proto/graphics.h>
#include <proto/intuition.h>
-#include <proto/utility.h>
-#ifdef __amigaos4__
-#include <dos/anchorpath.h>
-#include <dos/obsolete.h> /* Needed for ExAll() */
-#endif
#include <libraries/gadtools.h>
#ifdef __amigaos4__
@@ -45,41 +38,13 @@
#include <reaction/reaction_macros.h>
-#include "utils/nsoption.h"
-#include "utils/messages.h"
#include "utils/log.h"
-#include "utils/utils.h"
-#include "utils/nsurl.h"
-#include "netsurf/browser_window.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
-#include "netsurf/content.h"
-#include "netsurf/keypress.h"
-#include "desktop/hotlist.h"
-#include "desktop/version.h"
+#include "utils/messages.h"
-#include "amiga/arexx.h"
-#include "amiga/bitmap.h"
-#include "amiga/clipboard.h"
-#include "amiga/cookies.h"
-#include "amiga/file.h"
-#include "amiga/filetype.h"
#include "amiga/gui.h"
-#include "amiga/gui_options.h"
-#include "amiga/history.h"
-#include "amiga/history_local.h"
-#include "amiga/hotlist.h"
#include "amiga/libs.h"
#include "amiga/menu.h"
-#include "amiga/misc.h"
-#include "amiga/nsoption.h"
-#include "amiga/print.h"
-#include "amiga/search.h"
-#include "amiga/theme.h"
#include "amiga/utf8.h"
-#include "amiga/schedule.h"
-
-#define NSA_MAX_HOTLIST_MENU_LEN 100
enum {
NSA_GLYPH_SUBMENU,
@@ -89,29 +54,13 @@ enum {
NSA_GLYPH_MAX
};
-struct ami_menu_data {
- char *restrict menulab;
- Object *restrict menuobj;
- char *restrict menukey;
- char *restrict menuicon;
- struct Hook menu_hook;
- UBYTE menutype;
- UWORD flags;
-};
+#define NSA_MAX_HOTLIST_MENU_LEN 100
-static bool menu_quit = false;
-static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
static int menu_glyph_width[NSA_GLYPH_MAX];
static bool menu_glyphs_loaded = false;
-const char * const netsurf_version;
-const char * const verdate;
-
-static nserror ami_menu_scan(struct ami_menu_data **md);
-void ami_menu_arexx_scan(struct ami_menu_data **md);
-
-static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
+bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
{
bool checked = false;
@@ -130,495 +79,35 @@ static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
return checked;
}
-void ami_menu_set_check_toggled(void)
-{
- ami_menu_check_toggled = true;
-}
-
-bool ami_menu_get_check_toggled(void)
-{
- bool check_toggled = ami_menu_check_toggled;
- ami_menu_check_toggled = false;
- return check_toggled;
-}
-
-bool ami_menu_quit_selected(void)
-{
- return menu_quit;
-}
-
-/*
- * The below functions are called automatically by window.class when menu items are selected.
- */
-
-HOOKF(void, ami_menu_item_project_newwin, APTR, window, struct IntuiMessage *)
-{
- nsurl *url;
- nserror error;
-
- error = nsurl_create(nsoption_charp(homepage_url), &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(error), 0);
- }
-}
-
-HOOKF(void, ami_menu_item_project_newtab, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- ami_gui_new_blank_tab(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_open, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_file_open(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_save, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- ULONG type = (ULONG)hook->h_Data;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_file_save_req(type, gwin, browser_window_get_content(gwin->gw->bw));
-}
-
-HOOKF(void, ami_menu_item_project_closetab, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_destroy(gwin->gw->bw);
-}
-
-HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- gwin->closed = true;
-}
-
-HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
- ami_print_ui(browser_window_get_content(gwin->gw->bw));
- ami_reset_pointer(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- char *temp, *temp2;
- int sel;
- nsurl *url = NULL;
- nserror error = NSERROR_OK;
-
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
-
- temp = ASPrintf("%s|%s|%s", messages_get("OK"),
- messages_get("HelpCredits"),
- messages_get("HelpLicence"));
-
- temp2 = ami_utf8_easy(temp);
- FreeVec(temp);
-#ifdef __amigaos4__
- sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
- TDR_TitleString, messages_get("NetSurf"),
- TDR_Window, gwin->win,
- TDR_GadgetString, temp2,
- TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
- TDR_Arg1,netsurf_version,
- TDR_Arg2,verdate,
- TAG_DONE);
-#else
- struct EasyStruct about_req = {
- sizeof(struct EasyStruct),
- 0,
- "NetSurf",
- "NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
- temp2,
- };
-
- sel = EasyRequest(gwin->win, &about_req, NULL, netsurf_version, verdate);
-#endif
- free(temp2);
-
- if(sel == 2) {
- error = nsurl_create("about:credits", &url);
- } else if(sel == 0) {
- error = nsurl_create("about:licence", &url);
- }
-
- if(url) {
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(error), 0);
+/* menu creation code */
+static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
+{
+ if(md[i] == NULL) return;
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
- }
- ami_reset_pointer(gwin);
-}
-
-HOOKF(void, ami_menu_item_project_quit, APTR, window, struct IntuiMessage *)
-{
- menu_quit = true;
-}
-
-HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_CUT_SELECTION);
-}
-
-HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *)
-{
- struct bitmap *bm;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(browser_window_can_select(gwin->gw->bw)) {
- browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION);
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
+ ami_utf8_free(md[i]->menulab);
}
- else if((bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw)))) {
- /** @todo It should be checked that the lifetime of
- * the objects containing the values returned (and the
- * constness cast away) is safe.
- */
- ami_bitmap_set_url(bm, browser_window_get_url(gwin->gw->bw));
- ami_bitmap_set_title(bm, browser_window_get_title(gwin->gw->bw));
- ami_easy_clipboard_bitmap(bm);
- }
-#ifdef WITH_NS_SVG
- else if(ami_mime_compare(browser_window_get_content(gwin->gw->bw), "svg") == true) {
- ami_easy_clipboard_svg(browser_window_get_content(gwin->gw->bw));
- }
-#endif
-}
-HOOKF(void, ami_menu_item_edit_paste, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
- browser_window_key_press(gwin->gw->bw, NS_KEY_PASTE);
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = NULL;
+ md[i]->menutype = 0;
+ free(md[i]);
}
-HOOKF(void, ami_menu_item_edit_selectall, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_SELECT_ALL);
- gui_start_selection(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_edit_clearsel, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
-}
-
-HOOKF(void, ami_menu_item_edit_undo, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_UNDO);
-}
-
-HOOKF(void, ami_menu_item_edit_redo, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- browser_window_key_press(gwin->gw->bw, NS_KEY_REDO);
-}
-
-HOOKF(void, ami_menu_item_browser_find, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_search_open(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_history_open(gwin->gw);
-}
-
-HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessage *)
-{
- ami_history_global_present();
-}
-
-HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
-{
- ami_cookies_present();
-}
-
-HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(foreground_images, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(background_images, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
-{
- struct Menu *menustrip;
- bool checked = false;
-
- GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- checked = ami_menu_get_selected(menustrip, msg);
-
- nsoption_set_bool(enable_javascript, checked);
- ami_menu_set_check_toggled();
-}
-
-HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1);
-}
-
-HOOKF(void, ami_menu_item_browser_scale_normal, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, 1.0);
-}
-
-HOOKF(void, ami_menu_item_browser_scale_increase, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1);
-}
-
-HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- ami_schedule_redraw(gwin, true);
- gwin->new_content = true;
-}
-
-HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *)
-{
- struct browser_window *bw;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- bw = gwin->gw->bw;
-
- if (bw == NULL || browser_window_has_content(bw) == false)
- return;
-
- hotlist_add_url(browser_window_get_url(bw));
- ami_gui_update_hotlist_button(gwin);
-}
-
-HOOKF(void, ami_menu_item_hotlist_show, APTR, window, struct IntuiMessage *)
-{
- ami_hotlist_present();
-}
-
-HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *)
-{
- nsurl *url = hook->h_Data;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(url == NULL) return;
-
- browser_window_navigate(gwin->gw->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
-}
-
-HOOKF(void, ami_menu_item_settings_edit, APTR, window, struct IntuiMessage *)
-{
- ami_gui_opts_open();
-}
-
-HOOKF(void, ami_menu_item_settings_snapshot, APTR, window, struct IntuiMessage *)
-{
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- nsoption_set_int(window_x, gwin->win->LeftEdge);
- nsoption_set_int(window_y, gwin->win->TopEdge);
- nsoption_set_int(window_width, gwin->win->Width);
- nsoption_set_int(window_height, gwin->win->Height);
-}
-
-HOOKF(void, ami_menu_item_settings_save, APTR, window, struct IntuiMessage *)
-{
- ami_nsoption_write();
-}
-
-HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *)
-{
- char *temp;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(AslRequestTags(filereq,
- ASLFR_Window, gwin->win,
- ASLFR_SleepWindow, TRUE,
- ASLFR_TitleText, messages_get("NetSurf"),
- ASLFR_Screen, scrn,
- ASLFR_DoSaveMode, FALSE,
- ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
- ASLFR_InitialPattern, "#?.nsrx",
- TAG_DONE)) {
- if((temp = malloc(1024))) {
- strlcpy(temp, filereq->fr_Drawer, 1024);
- AddPart(temp, filereq->fr_File, 1024);
- ami_arexx_execute(temp);
- free(temp);
- }
- }
-}
-
-HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
-{
- char *script = hook->h_Data;
- char *temp;
- struct gui_window_2 *gwin;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- if(script) {
- if((temp = malloc(1024))) {
- BPTR lock;
- if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
- DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
- AddPart(temp, script, 1024);
- ami_arexx_execute(temp);
- free(temp);
- UnLock(lock);
- }
- }
- }
-}
-
-
-/* menu creation code */
static void ami_menu_free_labs(struct ami_menu_data **md, int max)
{
int i;
for(i = 0; i <= max; i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
-
- ami_utf8_free(md[i]->menulab);
- }
-
- if(md[i]->menukey != NULL) free(md[i]->menukey);
-
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
- }
-}
-
-void ami_free_menulabs(struct ami_menu_data **md)
-{
- int i;
-
- for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
- if(md[i] == NULL) continue;
- if(md[i]->menulab &&
- (md[i]->menulab != NM_BARLABEL) &&
- (md[i]->menulab != ML_SEPARATOR)) {
- if(md[i]->menutype & MENU_IMAGE) {
- if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
- }
-
- ami_utf8_free(md[i]->menulab);
-
- if(i >= AMI_MENU_AREXX) {
- if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
- md[i]->menu_hook.h_Data = NULL;
- }
- }
-
- if(md[i]->menukey != NULL) free(md[i]->menukey);
-
- md[i]->menulab = NULL;
- md[i]->menuobj = NULL;
- md[i]->menukey = NULL;
- md[i]->menutype = 0;
- free(md[i]);
+ ami_menu_free_lab_item(md, i);
}
}
@@ -668,154 +157,6 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
#endif
}
-static void ami_init_menulabs(struct ami_menu_data **md)
-{
- UWORD js_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- js_flags |= CHECKED;
-
- UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- imgfore_flags |= CHECKED;
-
- UWORD imgback_flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- imgback_flags |= CHECKED;
-
- ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
- ami_menu_item_project_newwin, NULL, 0);
- ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL, 0);
- ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
- ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
- ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
-#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
-#endif
- ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
- ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
- ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
- ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
- ami_menu_item_project_about, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
- ami_menu_item_project_quit, NULL, 0);
-
- ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL, 0);
- ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL, 0);
- ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
- ami_menu_item_edit_selectall, NULL, 0);
- ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL, 0);
- ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL, 0);
-
- ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
- ami_menu_item_browser_find, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL, 0);
- ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL, 0);
- ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL, 0);
- ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
- ami_menu_item_browser_foreimg, NULL, imgfore_flags);
- ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
- ami_menu_item_browser_backimg, NULL, imgback_flags);
- ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
- ami_menu_item_browser_enablejs, NULL, js_flags);
- ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL, 0);
-
- ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
-
- ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL, 0);
- ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
- ami_menu_item_settings_save, NULL, 0);
-
- ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
-}
-
-/* Menu refresh for hotlist */
-void ami_menu_refresh(struct gui_window_2 *gwin)
-{
- return; /**\todo fix this after migrating to menuclass */
-
- struct Menu *menu;
-
- LOG("Clearing MenuStrip");
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, NULL,
- TAG_DONE);
-
- LOG("Freeing menu");
- ami_menu_free(gwin);
-
- LOG("Freeing menu labels");
- ami_free_menulabs(gwin->menu_data);
-
- LOG("Creating new menu");
- menu = ami_menu_create(gwin);
-
- LOG("Attaching MenuStrip %p to %p", menu, gwin->objects[OID_MAIN]);
- SetAttrs(gwin->objects[OID_MAIN],
- WINDOW_MenuStrip, menu,
- TAG_DONE);
-}
-
static void ami_menu_load_glyphs(struct DrawInfo *dri)
{
#ifdef __amigaos4__
@@ -1084,15 +425,6 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
}
}
-void ami_menu_free(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- DisposeObject((Object *)gwin->imenu); // if we detach our menu from the window we need to do this manually
- } else {
- FreeMenus(gwin->imenu);
- }
-}
-
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
{
ami_menu_free_labs(md, max);
@@ -1103,340 +435,3 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
}
}
-struct Menu *ami_menu_create(struct gui_window_2 *gwin)
-{
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
-
- return gwin->imenu;
-}
-
-void ami_menu_arexx_scan(struct ami_menu_data **md)
-{
- /**\todo Rewrite this to not use ExAll() **/
- int item = AMI_MENU_AREXX;
- BPTR lock = 0;
- UBYTE *buffer;
- struct ExAllControl *ctrl;
- char matchpatt[16];
- LONG cont;
- struct ExAllData *ead;
- char *menu_lab;
-
- if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
- if((buffer = malloc(1024))) {
- if((ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))) {
- ctrl->eac_LastKey = 0;
-
- if(ParsePatternNoCase("#?.nsrx",(char *)&matchpatt,16) != -1) {
- ctrl->eac_MatchString = (char *)&matchpatt;
- }
-
- do {
- cont = ExAll(lock,(struct ExAllData *)buffer,1024,ED_COMMENT,ctrl);
- if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES)) break;
- if(!ctrl->eac_Entries) continue;
-
- for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
- if(item >= AMI_MENU_AREXX_MAX) continue;
- if(EAD_IS_FILE(ead)) {
- if(ead->ed_Comment[0] != '\0')
- menu_lab = ead->ed_Comment;
- else
- menu_lab = ead->ed_Name;
-
- ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, NULL, NSA_SPACE,
- ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
-
- item++;
- }
- }
- } while(cont);
- FreeDosObject(DOS_EXALLCONTROL,ctrl);
- }
- free(buffer);
- }
- UnLock(lock);
- }
-
- ami_menu_alloc_item(md, item, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
-}
-
-static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
-{
- UBYTE type;
- STRPTR icon;
- UWORD flags = 0;
- struct ami_menu_data **md = (struct ami_menu_data **)userdata;
-
- if(item >= AMI_MENU_HOTLIST_MAX) return false;
-
- switch(level) {
- case 1:
- type = NM_ITEM;
- break;
- case 2:
- type = NM_SUB;
- break;
- default:
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- type = NM_SUB + (level - 2);
- } else {
- /* entries not at level 1 or 2 are not able to be added */
- return false;
- }
- break;
- }
-
- if(is_folder == true) {
- icon = ASPrintf("icons/directory.png");
- } else {
- icon = ami_gui_get_cache_favicon_name(url, true);
- if (icon == NULL) icon = ASPrintf("icons/content.png");
- }
-
- if(!LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- if((is_folder == true) && (type == NM_SUB)) {
- flags = NM_ITEMDISABLED;
- }
- }
-
- ami_menu_alloc_item(md, item, type, title,
- NULL, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
-
- if(icon) FreeVec(icon);
-
- return true;
-}
-
-static nserror ami_menu_scan(struct ami_menu_data **md)
-{
- return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
-}
-
-#ifdef __amigaos4__
-static void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG disable_state = MS_DISABLED;
-
- if(disable == false) {
- disable_state = 0;
- }
-
- IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
-}
-#endif
-
-static ULONG ami_menu_number(int item)
-{
- /* horrible, horrible, horrible */
- ULONG menu_num;
-
- switch(item) {
- case M_SAVETXT:
- menu_num = FULLMENUNUM(0,4,1);
- break;
-
- case M_SAVECOMP:
- menu_num = FULLMENUNUM(0,4,2);
- break;
-
- case M_SAVEIFF:
- menu_num = FULLMENUNUM(0,4,3);
- break;
-#ifdef WITH_PDF_EXPORT
- case M_SAVEPDF:
- menu_num = FULLMENUNUM(0,4,4);
- break;
-#endif
- case M_CLOSETAB:
- menu_num = FULLMENUNUM(0,8,0);
- break;
-
- case M_CUT:
- menu_num = FULLMENUNUM(1,0,0);
- break;
-
- case M_COPY:
- menu_num = FULLMENUNUM(1,1,0);
- break;
-
- case M_PASTE:
- menu_num = FULLMENUNUM(1,2,0);
- break;
-
- case M_SELALL:
- menu_num = FULLMENUNUM(1,4,0);
- break;
-
- case M_CLEAR:
- menu_num = FULLMENUNUM(1,5,0);
- break;
-
- case M_UNDO:
- menu_num = FULLMENUNUM(1,8,0);
- break;
-
- case M_REDO:
- menu_num = FULLMENUNUM(1,9,0);
- break;
-
- case M_FIND:
- menu_num = FULLMENUNUM(2,0,0);
- break;
-
- case M_IMGFORE:
- menu_num = FULLMENUNUM(2,8,0);
- break;
-
- case M_IMGBACK:
- menu_num = FULLMENUNUM(2,8,1);
- break;
-
- case M_JS:
- menu_num = FULLMENUNUM(2,9,0);
- break;
-
- default:
- LOG("WARNING: Unrecognised menu item %d", item);
- menu_num = 0;
- break;
- }
-
- return menu_num;
-}
-
-static void ami_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- ULONG menu_num = ami_menu_number(item);
-
- if(disable == false) {
- OnMenu(win, menu_num);
- } else {
- OffMenu(win, menu_num);
- }
-}
-
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
-#ifdef __amigaos4__
- return ami_menu_set_disabled_mc(win, menu, item, disable);
-#endif
- } else {
- return ami_menu_set_disabled_gt(win, menu, item, disable);
- }
-}
-
-void ami_menu_update_checked(struct gui_window_2 *gwin)
-{
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- //needs re-writing for MenuClass
- return;
- }
-
- struct Menu *menustrip;
-
- GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
- if(!menustrip) return;
- if(nsoption_bool(enable_javascript) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
- }
- if(nsoption_bool(foreground_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
- }
-
- if(nsoption_bool(background_images) == true) {
- if((ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
- } else {
- if(ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED)
- ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
- }
-
- ResetMenuStrip(gwin->win, menustrip);
-}
-
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
-{
- struct Window *win = g->shared->win;
-
- if(nsoption_bool(kiosk_mode) == true) return;
-
- if(content_get_type(c) <= CONTENT_CSS)
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
-#endif
-#if 0
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_CLEAR);
- } else {
- OffMenu(win,AMI_MENU_COPY);
- OffMenu(win,AMI_MENU_CLEAR);
- }
-
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- OnMenu(win,AMI_MENU_CUT);
- else
- OffMenu(win,AMI_MENU_CUT);
-
- if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE)
- OnMenu(win,AMI_MENU_PASTE);
- else
- OffMenu(win,AMI_MENU_PASTE);
-#else
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
-#endif
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
-
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
-#ifdef WITH_PDF_EXPORT
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
-#endif
-
- ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
-
-#ifdef WITH_NS_SVG
- if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
-#else
- if(content_get_bitmap(c))
-#endif
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
- }
- else
- {
- ami_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
- ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
- }
- }
-}
-
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 35a0ac7..f8a3f17 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -23,101 +23,19 @@
#include <intuition/intuition.h>
#include <libraries/gadtools.h>
-struct hlcache_handle;
-struct ami_menu_data;
+struct ami_menu_data {
+ char *restrict menulab;
+ Object *restrict menuobj;
+ char *restrict menukey;
+ char *restrict menuicon;
+ struct Hook menu_hook;
+ UBYTE menutype;
+ UWORD flags;
+};
/** empty space */
#define NSA_SPACE "blankspace.png"
-/** Maximum number of hotlist items (somewhat arbitrary value) */
-#define AMI_HOTLIST_ITEMS 60
-
-/** Maximum number of ARexx menu items (somewhat arbitrary value) */
-#define AMI_MENU_AREXX_ITEMS 20
-
-/** enum menu structure, has to be here as we need it below. */
-enum {
- /* Project menu */
- M_PROJECT = 0,
- M_NEWWIN,
- M_NEWTAB,
- M_BAR_P1,
- M_OPEN,
- M_SAVEAS,
- M_SAVESRC,
- M_SAVETXT,
- M_SAVECOMP,
- M_SAVEIFF,
-#ifdef WITH_PDF_EXPORT
- M_SAVEPDF,
-#endif
- M_BAR_P2,
- M_PRINT,
- M_BAR_P3,
- M_CLOSETAB,
- M_CLOSEWIN,
- M_BAR_P4,
- M_ABOUT,
- M_BAR_P5,
- M_QUIT,
- /* Edit menu */
- M_EDIT,
- M_CUT,
- M_COPY,
- M_PASTE,
- M_BAR_E1,
- M_SELALL,
- M_CLEAR,
- M_BAR_E2,
- M_UNDO,
- M_REDO,
- /* Browser menu */
- M_BROWSER,
- M_FIND,
- M_BAR_B1,
- M_HISTLOCL,
- M_HISTGLBL,
- M_BAR_B2,
- M_COOKIES,
- M_BAR_B3,
- M_SCALE,
- M_SCALEDEC,
- M_SCALENRM,
- M_SCALEINC,
- M_IMAGES,
- M_IMGFORE,
- M_IMGBACK,
- M_JS,
- M_BAR_B4,
- M_REDRAW,
- /* Hotlist menu */
- M_HOTLIST,
- M_HLADD,
- M_HLSHOW,
- M_BAR_H1, // 47
- AMI_MENU_HOTLIST, /* Where the hotlist entries start */
- AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS,
- /* Settings menu */
- M_PREFS,
- M_PREDIT,
- M_BAR_S1,
- M_SNAPSHOT,
- M_PRSAVE,
- /* ARexx menu */
- M_AREXX,
- M_AREXXEX,
- M_BAR_A1,
- AMI_MENU_AREXX,
- AMI_MENU_AREXX_MAX = AMI_MENU_AREXX + AMI_MENU_AREXX_ITEMS
-};
-
-/* We can get away with AMI_MENU_MAX falling short as it is
- * only used for freeing the UTF-8 converted menu labels */
-#define AMI_MENU_MAX AMI_MENU_AREXX
-
-struct gui_window;
-struct gui_window_2;
-
/* cleanup */
void ami_menu_free_glyphs(void);
@@ -128,38 +46,9 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
-/* specific to browser windows */
-void ami_free_menulabs(struct ami_menu_data **md);
-struct Menu *ami_menu_create(struct gui_window_2 *gwin);
-void ami_menu_refresh(struct gui_window_2 *gwin);
-void ami_menu_update_checked(struct gui_window_2 *gwin);
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
-void ami_menu_free(struct gui_window_2 *gwin);
-
-/**
- * Set disabled state of a menu item
- */
-void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
-
-/**
- * Sets that an item linked to a toggle menu item has been changed.
- */
-void ami_menu_set_check_toggled(void);
-
/**
- * Gets if the menu needs updating because an item linked
- * to a toggle menu item has been changed.
- * NB: This also *clears* the state
- *
- * \return true if the menus need refreshing
- */
-bool ami_menu_get_check_toggled(void);
-
-/**
- * Gets if NetSurf has been quit from the menu
- *
- * \return true if NetSurf has been quit
+ * Get the selected state of a menu item
*/
-bool ami_menu_quit_selected(void);
+bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg);
#endif
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/menuclass updated. release/3.6-198-g24fed9d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/24fed9d51ccf3e786e599...
...commit http://git.netsurf-browser.org/netsurf.git/commit/24fed9d51ccf3e786e59983...
...tree http://git.netsurf-browser.org/netsurf.git/tree/24fed9d51ccf3e786e59983ae...
The branch, chris/menuclass has been updated
via 24fed9d51ccf3e786e59983ae84b4f13e68b0ea4 (commit)
via b6f7ea536cececaa07fb2c46c129675d91167177 (commit)
from e4d6d9a972736bbea70eb0af62a430e77cc05ee5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=24fed9d51ccf3e786e5...
commit 24fed9d51ccf3e786e59983ae84b4f13e68b0ea4
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Remove excess logging and fix user-added hotlist separator bars
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 253ab3c..cfb3429 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -636,6 +636,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
if((label == NM_BARLABEL) || (strcmp(label, "--") == 0)) {
md[num]->menulab = NM_BARLABEL;
+ icon = NULL;
} else { /* horrid non-generic stuff */
if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
utf8_from_local_encoding(label,
@@ -890,7 +891,6 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
Object *menu_item = menu_parent;
for(j = i; j < max; j++) {
- LOG("%d/%d", j, max);
/* skip empty entries */
if(md[j] == NULL) continue;
if(md[j]->menutype == NM_IGNORE) continue;
@@ -924,14 +924,11 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat
TAG_DONE);
}
- LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
continue;
} else if (md[j]->menutype > level) {
-LOG("rec");
j = ami_menu_layout_mc_recursive(menu_item, md, md[j]->menutype, j, max);
} else {
-LOG("brk");
break;
}
}
@@ -942,7 +939,7 @@ static struct Menu *ami_menu_layout_mc(struct ami_menu_data **md, int max)
{
Object *menu_root = NewObject(NULL, "menuclass",
MA_Type, T_ROOT,
- MA_FreeImage, FALSE,
+ MA_EmbeddedKey, FALSE,
TAG_DONE);
ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, 0, max);
@@ -1109,7 +1106,7 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data); //\todo this needs to be MenuClass created
+ ami_menu_scan(gwin->menu_data);
ami_menu_arexx_scan(gwin->menu_data);
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b6f7ea536cececaa07f...
commit b6f7ea536cececaa07fb2c46c129675d91167177
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix MenuClass menu creation
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 74c89cb..17933d5 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -239,38 +239,38 @@ HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage
static void ami_cookies_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_cookies_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", NULL, NULL,
ami_cookies_menu_item_project_expand_domains, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES, NM_SUB, "Cookies", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES, NM_SUB, "Cookies", NULL, NULL,
ami_cookies_menu_item_project_expand_cookies, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_cookies_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", NULL, NULL,
ami_cookies_menu_item_project_collapse_domains, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES, NM_SUB, "Cookies", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES, NM_SUB, "Cookies", NULL, NULL,
ami_cookies_menu_item_project_collapse_cookies, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_cookies_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_cookies_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_cookies_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_cookies_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_cookies_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c
index b2a3cc0..a1c6bf6 100644
--- a/frontends/amiga/history.c
+++ b/frontends/amiga/history.c
@@ -308,41 +308,41 @@ HOOKF(void, ami_history_global_menu_item_edit_delete, APTR, window, struct Intui
static void ami_history_global_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_HISTORY_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPORT, NM_ITEM, "TreeExport", "S", "TBImages:list_save",
ami_history_global_menu_item_project_export, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_history_global_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_history_global_menu_item_project_expand_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_LINKS, NM_SUB, "Links", NULL, NULL,
ami_history_global_menu_item_project_expand_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_history_global_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_history_global_menu_item_project_collapse_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_LINKS, NM_SUB, "Links", NULL, NULL,
ami_history_global_menu_item_project_collapse_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_history_global_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_history_global_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_history_global_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_history_global_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_history_global_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index 8aa181b..6d6f7ce 100644
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -404,49 +404,49 @@ HOOKF(void, ami_hotlist_menu_item_edit_delete, APTR, window, struct IntuiMessage
static void ami_hotlist_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", "S", "TBImages:list_save",
ami_hotlist_menu_item_project_export, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_hotlist_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_hotlist_menu_item_project_expand_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", NULL, NULL,
ami_hotlist_menu_item_project_expand_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_hotlist_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_hotlist_menu_item_project_collapse_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", NULL, NULL,
ami_hotlist_menu_item_project_collapse_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_hotlist_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_hotlist_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", 'N', "TBImages:list_drawer",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", "N", "TBImages:list_drawer",
ami_hotlist_menu_item_edit_newfolder, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", 0, "TBImages:list_favouriteadd",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", NULL, "TBImages:list_favouriteadd",
ami_hotlist_menu_item_edit_newlink, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", 'E', "TBImages:list_edit",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", "E", "TBImages:list_edit",
ami_hotlist_menu_item_edit_edit, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_hotlist_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_hotlist_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_hotlist_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 175fe15..253ab3c 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -92,7 +92,7 @@ enum {
struct ami_menu_data {
char *restrict menulab;
Object *restrict menuobj;
- char menukey;
+ char *restrict menukey;
char *restrict menuicon;
struct Hook menu_hook;
UBYTE menutype;
@@ -120,7 +120,7 @@ static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
ULONG state;
struct ExtIntuiMessage *emsg = (struct ExtIntuiMessage *)msg;
- state = IDoMethod(menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
+ state = IDoMethod((Object *)menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
if(state & MS_CHECKED) checked = true;
#endif
} else {
@@ -571,7 +571,9 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
for(i = 0; i <= max; i++) {
if(md[i] == NULL) continue;
- if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
if(md[i]->menutype & MENU_IMAGE) {
if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
@@ -579,9 +581,11 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
ami_utf8_free(md[i]->menulab);
}
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
+
md[i]->menulab = NULL;
md[i]->menuobj = NULL;
- md[i]->menukey = 0;
+ md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
}
@@ -593,7 +597,9 @@ void ami_free_menulabs(struct ami_menu_data **md)
for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
if(md[i] == NULL) continue;
- if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
if(md[i]->menutype & MENU_IMAGE) {
if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
@@ -606,16 +612,18 @@ void ami_free_menulabs(struct ami_menu_data **md)
}
}
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
+
md[i]->menulab = NULL;
md[i]->menuobj = NULL;
- md[i]->menukey = 0;
+ md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
}
}
void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, char key, const char *restrict icon,
+ const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags)
{
char menu_icon[1024];
@@ -641,7 +649,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
}
md[num]->menuicon = NULL;
- if(key) md[num]->menukey = key;
+ if(key) md[num]->menukey = strdup(key);
if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
if(hookdata) md[num]->menu_hook.h_Data = hookdata;
@@ -673,111 +681,111 @@ static void ami_init_menulabs(struct ami_menu_data **md)
if(nsoption_bool(background_images) == true)
imgback_flags |= CHECKED;
- ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
+ ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
ami_menu_item_project_newwin, NULL, 0);
- ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
+ ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
ami_menu_item_project_newtab, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
+ ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
ami_menu_item_project_open, NULL, 0);
- ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, "TBImages:list_saveas", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
+ ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
- ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
- ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
- ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", 'P', "TBImages:list_print",
+ ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
- ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', "TBImages:list_remove",
+ ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
ami_menu_item_project_closetab, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
ami_menu_item_project_closewin, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", '?', "TBImages:list_info",
+ ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
ami_menu_item_project_about, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", 'Q', "TBImages:list_warning",
+ ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
ami_menu_item_project_quit, NULL, 0);
- ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", 'X', "TBImages:list_cut",
+ ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
ami_menu_item_edit_cut, NULL, 0);
- ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", 'C', "TBImages:list_copy",
+ ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
ami_menu_item_edit_copy, NULL, 0);
- ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", 'V', "TBImages:list_paste",
+ ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
ami_menu_item_edit_paste, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_menu_item_edit_selectall, NULL, 0);
- ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_menu_item_edit_clearsel, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", 'Z', "TBImages:list_undo",
+ ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
ami_menu_item_edit_undo, NULL, 0);
- ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", 'Y', "TBImages:list_redo",
+ ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
ami_menu_item_edit_redo, NULL, 0);
- ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", 'F', "TBImages:list_search",
+ ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
ami_menu_item_browser_find, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, "TBImages:list_history",
+ ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
ami_menu_item_browser_localhistory, NULL, 0);
- ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "TBImages:list_history",
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
ami_menu_item_browser_globalhistory, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, "TBImages:list_internet",
+ ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
ami_menu_item_browser_cookies, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", 0, "TBImages:list_preview", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", '-', "TBImages:list_zoom_out",
+ ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
ami_menu_item_browser_scale_decrease, NULL, 0);
- ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", '=', "TBImages:list_zoom_100",
+ ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
ami_menu_item_browser_scale_normal, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", '+', "TBImages:list_zoom_in",
+ ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
ami_menu_item_browser_scale_increase, NULL, 0);
- ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", 0, "TBImages:list_image", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
+ ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
ami_menu_item_browser_foreimg, NULL, imgfore_flags);
- ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
ami_menu_item_browser_backimg, NULL, imgback_flags);
- ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", 0, NULL,
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
ami_menu_item_browser_enablejs, NULL, js_flags);
- ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", 0, "TBImages:list_wand",
+ ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
ami_menu_item_browser_redraw, NULL, 0);
- ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", 'B', "TBImages:list_favouriteadd",
+ ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', "TBImages:list_favourite",
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", 0, "TBImages:list_prefs",
+ ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
ami_menu_item_settings_edit, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
ami_menu_item_settings_snapshot, NULL, 0);
- ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "TBImages:list_use",
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
ami_menu_item_settings_save, NULL, 0);
- ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', "TBImages:list_arexx",
+ ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
ami_menu_item_arexx_execute, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
/* Menu refresh for hotlist */
@@ -858,7 +866,7 @@ static int ami_menu_calc_item_width(struct ami_menu_data **md, int j, struct Ras
item_size += space_width;
if(md[j]->menukey) {
- item_size += TextLength(rp, &md[j]->menukey, 1);
+ item_size += TextLength(rp, md[j]->menukey, 1);
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
/**TODO: take account of the size of other imagery too
*/
@@ -876,53 +884,68 @@ static int ami_menu_calc_item_width(struct ami_menu_data **md, int j, struct Ras
}
#ifdef __amigaos4__
-static void ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_data **md, int level, int *i, int max)
+static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_data **md, int level, int i, int max)
{
+ int j;
Object *menu_item = menu_parent;
- ULONG item_type = T_ITEM;
-
- if(level == NM_TITLE) {
- item_type = T_MENU;
- }
- while(*i <= max) {
+ for(j = i; j < max; j++) {
+ LOG("%d/%d", j, max);
/* skip empty entries */
- if(md[*i] == NULL) continue;
- if(md[*i]->menutype == NM_IGNORE) continue;
-
- if(md[*i]->menutype == level) {
- menu_item = NewObject(NULL, "menuclass",
- MA_Type, item_type,
- MA_ID, *i,
- MA_Label, md[*i]->menulab,
- MA_Image, md[*i]->menuicon,
- MA_Key, &md[*i]->menukey,
- MA_UserData, &md[*i]->menu_hook, /* NB: Intentionally UserData */
- MA_Disabled, (md[*i]->flags & NM_ITEMDISABLED),
- MA_Selected, (md[*i]->flags & CHECKED),
- MA_Toggle, (md[*i]->flags & MENUTOGGLE),
- TAG_DONE);
+ if(md[j] == NULL) continue;
+ if(md[j]->menutype == NM_IGNORE) continue;
+
+ if(md[j]->menutype == level) {
+ if(md[j]->menulab == NM_BARLABEL)
+ md[j]->menulab = ML_SEPARATOR;
+
+ if(level == NM_TITLE) {
+ menu_item = NewObject(NULL, "menuclass",
+ MA_Type, T_MENU,
+ MA_Label, md[j]->menulab,
+ TAG_DONE);
+ } else {
+ menu_item = NewObject(NULL, "menuclass",
+ MA_Type, T_ITEM,
+ MA_ID, j,
+ MA_Label, md[j]->menulab,
+ MA_Image,
+ BitMapObj,
+ IA_Scalable, TRUE,
+ BITMAP_Screen, scrn,
+ BITMAP_SourceFile, md[j]->menuicon,
+ BITMAP_Masking, TRUE,
+ BitMapEnd,
+ MA_Key, md[j]->menukey,
+ MA_UserData, &md[j]->menu_hook, /* NB: Intentionally UserData */
+ MA_Disabled, (md[j]->flags & NM_ITEMDISABLED),
+ MA_Selected, (md[j]->flags & CHECKED),
+ MA_Toggle, (md[j]->flags & MENUTOGGLE),
+ TAG_DONE);
+ }
+
+ LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent);
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
- } else if (md[*i]->menutype > level) {
- ami_menu_layout_mc_recursive(menu_item, md, md[*i]->menutype, i, max);
+ continue;
+ } else if (md[j]->menutype > level) {
+LOG("rec");
+ j = ami_menu_layout_mc_recursive(menu_item, md, md[j]->menutype, j, max);
} else {
+LOG("brk");
break;
}
- *i++;
}
- return;
+ return (j - 1);
}
static struct Menu *ami_menu_layout_mc(struct ami_menu_data **md, int max)
{
- int i = 0;
-
Object *menu_root = NewObject(NULL, "menuclass",
MA_Type, T_ROOT,
MA_FreeImage, FALSE,
TAG_DONE);
- ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, &i, max);
+ ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, 0, max);
return (struct Menu *)menu_root;
}
@@ -1029,7 +1052,9 @@ static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max)
else
nm[i].nm_Label = md[i]->menulab;
- if(md[i]->menukey) nm[i].nm_CommKey = &md[i]->menukey;
+ if((md[i]->menukey) && (strlen(md[i]->menukey) > 1)) {
+ nm[i].nm_CommKey = md[i]->menukey;
+ }
nm[i].nm_Flags = md[i]->flags;
if(md[i]->menu_hook.h_Entry) nm[i].nm_UserData = &md[i]->menu_hook;
@@ -1125,7 +1150,7 @@ void ami_menu_arexx_scan(struct ami_menu_data **md)
else
menu_lab = ead->ed_Name;
- ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, NULL, NSA_SPACE,
ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
item++;
@@ -1139,7 +1164,7 @@ void ami_menu_arexx_scan(struct ami_menu_data **md)
UnLock(lock);
}
- ami_menu_alloc_item(md, item, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, item, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
@@ -1182,7 +1207,7 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
}
ami_menu_alloc_item(md, item, type, title,
- 0, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
+ NULL, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
if(icon) FreeVec(icon);
@@ -1195,7 +1220,7 @@ static nserror ami_menu_scan(struct ami_menu_data **md)
}
#ifdef __amigaos4__
-void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+static void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
{
ULONG disable_state = MS_DISABLED;
@@ -1203,7 +1228,7 @@ void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, b
disable_state = 0;
}
- IDoMethod(menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
}
#endif
@@ -1224,7 +1249,7 @@ static ULONG ami_menu_number(int item)
case M_SAVEIFF:
menu_num = FULLMENUNUM(0,4,3);
break;
-#ifdef WITH_PDF_EXPORT:
+#ifdef WITH_PDF_EXPORT
case M_SAVEPDF:
menu_num = FULLMENUNUM(0,4,4);
break;
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 43f7e1e..35a0ac7 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -123,7 +123,7 @@ void ami_menu_free_glyphs(void);
/* generic menu alloc/free/layout */
void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, char key, const char *restrict icon,
+ const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags);
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/cookies.c | 38 ++++----
frontends/amiga/history.c | 42 ++++----
frontends/amiga/hotlist.c | 50 +++++-----
frontends/amiga/menu.c | 238 +++++++++++++++++++++++++--------------------
frontends/amiga/menu.h | 2 +-
5 files changed, 196 insertions(+), 174 deletions(-)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 74c89cb..17933d5 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -239,38 +239,38 @@ HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage
static void ami_cookies_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_cookies_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", NULL, NULL,
ami_cookies_menu_item_project_expand_domains, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES, NM_SUB, "Cookies", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES, NM_SUB, "Cookies", NULL, NULL,
ami_cookies_menu_item_project_expand_cookies, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_cookies_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", NULL, NULL,
ami_cookies_menu_item_project_collapse_domains, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES, NM_SUB, "Cookies", 0, NULL,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES, NM_SUB, "Cookies", NULL, NULL,
ami_cookies_menu_item_project_collapse_cookies, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_cookies_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_cookies_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_cookies_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_cookies_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_cookies_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c
index b2a3cc0..a1c6bf6 100644
--- a/frontends/amiga/history.c
+++ b/frontends/amiga/history.c
@@ -308,41 +308,41 @@ HOOKF(void, ami_history_global_menu_item_edit_delete, APTR, window, struct Intui
static void ami_history_global_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_HISTORY_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPORT, NM_ITEM, "TreeExport", "S", "TBImages:list_save",
ami_history_global_menu_item_project_export, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_history_global_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_history_global_menu_item_project_expand_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_LINKS, NM_SUB, "Links", NULL, NULL,
ami_history_global_menu_item_project_expand_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_history_global_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_history_global_menu_item_project_collapse_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_LINKS, NM_SUB, "Links", NULL, NULL,
ami_history_global_menu_item_project_collapse_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_history_global_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_history_global_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_history_global_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HISTORY_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_history_global_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_history_global_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_HISTORY_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HISTORY_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index 8aa181b..6d6f7ce 100644
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -404,49 +404,49 @@ HOOKF(void, ami_hotlist_menu_item_edit_delete, APTR, window, struct IntuiMessage
static void ami_hotlist_menulabs(struct ami_menu_data **md)
{
- ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", "S", "TBImages:list_save",
ami_hotlist_menu_item_project_export, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", NULL, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", "+", NULL,
ami_hotlist_menu_item_project_expand_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_hotlist_menu_item_project_expand_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", NULL, NULL,
ami_hotlist_menu_item_project_expand_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", NULL, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", "-", NULL,
ami_hotlist_menu_item_project_collapse_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", NULL, NULL,
ami_hotlist_menu_item_project_collapse_folders, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", NULL, NULL,
ami_hotlist_menu_item_project_collapse_links, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", NULL, "TBImages:list_hold",
ami_hotlist_menu_item_project_snapshot, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", "K", "TBImages:list_cancel",
ami_hotlist_menu_item_project_close, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", 'N', "TBImages:list_drawer",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", "N", "TBImages:list_drawer",
ami_hotlist_menu_item_edit_newfolder, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", 0, "TBImages:list_favouriteadd",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", NULL, "TBImages:list_favouriteadd",
ami_hotlist_menu_item_edit_newlink, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", 'E', "TBImages:list_edit",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", "E", "TBImages:list_edit",
ami_hotlist_menu_item_edit_edit, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_hotlist_menu_item_edit_select_all, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_hotlist_menu_item_edit_clear, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", "Del", "TBImages:list_delete",
ami_hotlist_menu_item_edit_delete, NULL, 0);
- ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static struct Menu *
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 175fe15..cfb3429 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -92,7 +92,7 @@ enum {
struct ami_menu_data {
char *restrict menulab;
Object *restrict menuobj;
- char menukey;
+ char *restrict menukey;
char *restrict menuicon;
struct Hook menu_hook;
UBYTE menutype;
@@ -120,7 +120,7 @@ static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
ULONG state;
struct ExtIntuiMessage *emsg = (struct ExtIntuiMessage *)msg;
- state = IDoMethod(menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
+ state = IDoMethod((Object *)menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
if(state & MS_CHECKED) checked = true;
#endif
} else {
@@ -571,7 +571,9 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
for(i = 0; i <= max; i++) {
if(md[i] == NULL) continue;
- if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
if(md[i]->menutype & MENU_IMAGE) {
if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
@@ -579,9 +581,11 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
ami_utf8_free(md[i]->menulab);
}
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
+
md[i]->menulab = NULL;
md[i]->menuobj = NULL;
- md[i]->menukey = 0;
+ md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
}
@@ -593,7 +597,9 @@ void ami_free_menulabs(struct ami_menu_data **md)
for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
if(md[i] == NULL) continue;
- if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menulab &&
+ (md[i]->menulab != NM_BARLABEL) &&
+ (md[i]->menulab != ML_SEPARATOR)) {
if(md[i]->menutype & MENU_IMAGE) {
if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
@@ -606,16 +612,18 @@ void ami_free_menulabs(struct ami_menu_data **md)
}
}
+ if(md[i]->menukey != NULL) free(md[i]->menukey);
+
md[i]->menulab = NULL;
md[i]->menuobj = NULL;
- md[i]->menukey = 0;
+ md[i]->menukey = NULL;
md[i]->menutype = 0;
free(md[i]);
}
}
void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, char key, const char *restrict icon,
+ const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags)
{
char menu_icon[1024];
@@ -628,6 +636,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
if((label == NM_BARLABEL) || (strcmp(label, "--") == 0)) {
md[num]->menulab = NM_BARLABEL;
+ icon = NULL;
} else { /* horrid non-generic stuff */
if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
utf8_from_local_encoding(label,
@@ -641,7 +650,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
}
md[num]->menuicon = NULL;
- if(key) md[num]->menukey = key;
+ if(key) md[num]->menukey = strdup(key);
if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
if(hookdata) md[num]->menu_hook.h_Data = hookdata;
@@ -673,111 +682,111 @@ static void ami_init_menulabs(struct ami_menu_data **md)
if(nsoption_bool(background_images) == true)
imgback_flags |= CHECKED;
- ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
+ ami_menu_alloc_item(md, M_PROJECT, NM_TITLE, "Project", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_NEWWIN, NM_ITEM, "NewWindowNS", "N", "TBImages:list_app",
ami_menu_item_project_newwin, NULL, 0);
- ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
+ ami_menu_alloc_item(md, M_NEWTAB, NM_ITEM, "NewTab", "T", "TBImages:list_tab",
ami_menu_item_project_newtab, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
+ ami_menu_alloc_item(md, M_BAR_P1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_OPEN, NM_ITEM, "OpenFile", "O", "TBImages:list_folder_misc",
ami_menu_item_project_open, NULL, 0);
- ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, "TBImages:list_saveas", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
+ ami_menu_alloc_item(md, M_SAVEAS, NM_ITEM, "SaveAsNS", NULL, "TBImages:list_saveas", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SAVESRC, NM_SUB, "Source", "S", NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
- ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT, 0);
- ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVECOMP, NM_SUB, "SaveCompNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", NULL, NULL,
ami_menu_item_project_save, (void *)AMINS_SAVE_IFF, 0);
- ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", 'P', "TBImages:list_print",
+ ami_menu_alloc_item(md, M_BAR_P2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PRINT, NM_ITEM, "PrintNS", "P", "TBImages:list_print",
ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
- ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', "TBImages:list_remove",
+ ami_menu_alloc_item(md, M_BAR_P3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSETAB, NM_ITEM, "CloseTab", "K", "TBImages:list_remove",
ami_menu_item_project_closetab, NULL, 0);
- ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", NULL, "TBImages:list_cancel",
ami_menu_item_project_closewin, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", '?', "TBImages:list_info",
+ ami_menu_alloc_item(md, M_BAR_P4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_ABOUT, NM_ITEM, "About", "?", "TBImages:list_info",
ami_menu_item_project_about, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", 'Q', "TBImages:list_warning",
+ ami_menu_alloc_item(md, M_BAR_P5, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_QUIT, NM_ITEM, "Quit", "Q", "TBImages:list_warning",
ami_menu_item_project_quit, NULL, 0);
- ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", 'X', "TBImages:list_cut",
+ ami_menu_alloc_item(md, M_EDIT, NM_TITLE, "Edit", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_CUT, NM_ITEM, "CutNS", "X", "TBImages:list_cut",
ami_menu_item_edit_cut, NULL, 0);
- ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", 'C', "TBImages:list_copy",
+ ami_menu_alloc_item(md, M_COPY, NM_ITEM, "CopyNS", "C", "TBImages:list_copy",
ami_menu_item_edit_copy, NULL, 0);
- ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", 'V', "TBImages:list_paste",
+ ami_menu_alloc_item(md, M_PASTE, NM_ITEM, "PasteNS", "V", "TBImages:list_paste",
ami_menu_item_edit_paste, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_menu_alloc_item(md, M_BAR_E1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SELALL, NM_ITEM, "SelectAllNS", "A", NSA_SPACE,
ami_menu_item_edit_selectall, NULL, 0);
- ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_menu_alloc_item(md, M_CLEAR, NM_ITEM, "ClearNS", NULL, NSA_SPACE,
ami_menu_item_edit_clearsel, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", 'Z', "TBImages:list_undo",
+ ami_menu_alloc_item(md, M_BAR_E2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_UNDO, NM_ITEM, "Undo", "Z", "TBImages:list_undo",
ami_menu_item_edit_undo, NULL, 0);
- ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", 'Y', "TBImages:list_redo",
+ ami_menu_alloc_item(md, M_REDO, NM_ITEM, "Redo", "Y", "TBImages:list_redo",
ami_menu_item_edit_redo, NULL, 0);
- ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", 'F', "TBImages:list_search",
+ ami_menu_alloc_item(md, M_BROWSER, NM_TITLE, "Browser", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_FIND, NM_ITEM, "FindTextNS", "F", "TBImages:list_search",
ami_menu_item_browser_find, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, "TBImages:list_history",
+ ami_menu_alloc_item(md, M_BAR_B1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTLOCL, NM_ITEM, "HistLocalNS", NULL, "TBImages:list_history",
ami_menu_item_browser_localhistory, NULL, 0);
- ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "TBImages:list_history",
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", NULL, "TBImages:list_history",
ami_menu_item_browser_globalhistory, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, "TBImages:list_internet",
+ ami_menu_alloc_item(md, M_BAR_B2, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_COOKIES, NM_ITEM, "ShowCookiesNS",NULL, "TBImages:list_internet",
ami_menu_item_browser_cookies, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", 0, "TBImages:list_preview", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", '-', "TBImages:list_zoom_out",
+ ami_menu_alloc_item(md, M_BAR_B3, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALE, NM_ITEM, "ScaleNS", NULL, "TBImages:list_preview", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SCALEDEC, NM_SUB, "ScaleDec", "-", "TBImages:list_zoom_out",
ami_menu_item_browser_scale_decrease, NULL, 0);
- ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", '=', "TBImages:list_zoom_100",
+ ami_menu_alloc_item(md, M_SCALENRM, NM_SUB, "ScaleNorm", "=", "TBImages:list_zoom_100",
ami_menu_item_browser_scale_normal, NULL, 0);
- ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", '+', "TBImages:list_zoom_in",
+ ami_menu_alloc_item(md, M_SCALEINC, NM_SUB, "ScaleInc", "+", "TBImages:list_zoom_in",
ami_menu_item_browser_scale_increase, NULL, 0);
- ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", 0, "TBImages:list_image", NULL, NULL, 0);
- ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
+ ami_menu_alloc_item(md, M_IMAGES, NM_ITEM, "Images", NULL, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", NULL, NULL,
ami_menu_item_browser_foreimg, NULL, imgfore_flags);
- ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", NULL, NULL,
ami_menu_item_browser_backimg, NULL, imgback_flags);
- ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", 0, NULL,
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL,
ami_menu_item_browser_enablejs, NULL, js_flags);
- ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", 0, "TBImages:list_wand",
+ ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand",
ami_menu_item_browser_redraw, NULL, 0);
- ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", 'B', "TBImages:list_favouriteadd",
+ ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', "TBImages:list_favourite",
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", 0, "TBImages:list_prefs",
+ ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
ami_menu_item_settings_edit, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, "TBImages:list_hold",
+ ami_menu_alloc_item(md, M_BAR_S1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",NULL, "TBImages:list_hold",
ami_menu_item_settings_snapshot, NULL, 0);
- ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "TBImages:list_use",
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", NULL, "TBImages:list_use",
ami_menu_item_settings_save, NULL, 0);
- ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', "TBImages:list_arexx",
+ ami_menu_alloc_item(md, M_AREXX, NM_TITLE, "ARexx", NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_AREXXEX, NM_ITEM, "ARexxExecute", "E", "TBImages:list_arexx",
ami_menu_item_arexx_execute, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_A1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_MENU_AREXX_MAX, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
/* Menu refresh for hotlist */
@@ -858,7 +867,7 @@ static int ami_menu_calc_item_width(struct ami_menu_data **md, int j, struct Ras
item_size += space_width;
if(md[j]->menukey) {
- item_size += TextLength(rp, &md[j]->menukey, 1);
+ item_size += TextLength(rp, md[j]->menukey, 1);
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
/**TODO: take account of the size of other imagery too
*/
@@ -876,53 +885,64 @@ static int ami_menu_calc_item_width(struct ami_menu_data **md, int j, struct Ras
}
#ifdef __amigaos4__
-static void ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_data **md, int level, int *i, int max)
+static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_data **md, int level, int i, int max)
{
+ int j;
Object *menu_item = menu_parent;
- ULONG item_type = T_ITEM;
-
- if(level == NM_TITLE) {
- item_type = T_MENU;
- }
- while(*i <= max) {
+ for(j = i; j < max; j++) {
/* skip empty entries */
- if(md[*i] == NULL) continue;
- if(md[*i]->menutype == NM_IGNORE) continue;
-
- if(md[*i]->menutype == level) {
- menu_item = NewObject(NULL, "menuclass",
- MA_Type, item_type,
- MA_ID, *i,
- MA_Label, md[*i]->menulab,
- MA_Image, md[*i]->menuicon,
- MA_Key, &md[*i]->menukey,
- MA_UserData, &md[*i]->menu_hook, /* NB: Intentionally UserData */
- MA_Disabled, (md[*i]->flags & NM_ITEMDISABLED),
- MA_Selected, (md[*i]->flags & CHECKED),
- MA_Toggle, (md[*i]->flags & MENUTOGGLE),
- TAG_DONE);
+ if(md[j] == NULL) continue;
+ if(md[j]->menutype == NM_IGNORE) continue;
+
+ if(md[j]->menutype == level) {
+ if(md[j]->menulab == NM_BARLABEL)
+ md[j]->menulab = ML_SEPARATOR;
+
+ if(level == NM_TITLE) {
+ menu_item = NewObject(NULL, "menuclass",
+ MA_Type, T_MENU,
+ MA_Label, md[j]->menulab,
+ TAG_DONE);
+ } else {
+ menu_item = NewObject(NULL, "menuclass",
+ MA_Type, T_ITEM,
+ MA_ID, j,
+ MA_Label, md[j]->menulab,
+ MA_Image,
+ BitMapObj,
+ IA_Scalable, TRUE,
+ BITMAP_Screen, scrn,
+ BITMAP_SourceFile, md[j]->menuicon,
+ BITMAP_Masking, TRUE,
+ BitMapEnd,
+ MA_Key, md[j]->menukey,
+ MA_UserData, &md[j]->menu_hook, /* NB: Intentionally UserData */
+ MA_Disabled, (md[j]->flags & NM_ITEMDISABLED),
+ MA_Selected, (md[j]->flags & CHECKED),
+ MA_Toggle, (md[j]->flags & MENUTOGGLE),
+ TAG_DONE);
+ }
+
IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
- } else if (md[*i]->menutype > level) {
- ami_menu_layout_mc_recursive(menu_item, md, md[*i]->menutype, i, max);
+ continue;
+ } else if (md[j]->menutype > level) {
+ j = ami_menu_layout_mc_recursive(menu_item, md, md[j]->menutype, j, max);
} else {
break;
}
- *i++;
}
- return;
+ return (j - 1);
}
static struct Menu *ami_menu_layout_mc(struct ami_menu_data **md, int max)
{
- int i = 0;
-
Object *menu_root = NewObject(NULL, "menuclass",
MA_Type, T_ROOT,
- MA_FreeImage, FALSE,
+ MA_EmbeddedKey, FALSE,
TAG_DONE);
- ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, &i, max);
+ ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, 0, max);
return (struct Menu *)menu_root;
}
@@ -1029,7 +1049,9 @@ static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max)
else
nm[i].nm_Label = md[i]->menulab;
- if(md[i]->menukey) nm[i].nm_CommKey = &md[i]->menukey;
+ if((md[i]->menukey) && (strlen(md[i]->menukey) > 1)) {
+ nm[i].nm_CommKey = md[i]->menukey;
+ }
nm[i].nm_Flags = md[i]->flags;
if(md[i]->menu_hook.h_Entry) nm[i].nm_UserData = &md[i]->menu_hook;
@@ -1084,7 +1106,7 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data); //\todo this needs to be MenuClass created
+ ami_menu_scan(gwin->menu_data);
ami_menu_arexx_scan(gwin->menu_data);
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
@@ -1125,7 +1147,7 @@ void ami_menu_arexx_scan(struct ami_menu_data **md)
else
menu_lab = ead->ed_Name;
- ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, NULL, NSA_SPACE,
ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
item++;
@@ -1139,7 +1161,7 @@ void ami_menu_arexx_scan(struct ami_menu_data **md)
UnLock(lock);
}
- ami_menu_alloc_item(md, item, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, item, NM_END, NULL, NULL, NULL, NULL, NULL, 0);
}
static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
@@ -1182,7 +1204,7 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
}
ami_menu_alloc_item(md, item, type, title,
- 0, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
+ NULL, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
if(icon) FreeVec(icon);
@@ -1195,7 +1217,7 @@ static nserror ami_menu_scan(struct ami_menu_data **md)
}
#ifdef __amigaos4__
-void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+static void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
{
ULONG disable_state = MS_DISABLED;
@@ -1203,7 +1225,7 @@ void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, b
disable_state = 0;
}
- IDoMethod(menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+ IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
}
#endif
@@ -1224,7 +1246,7 @@ static ULONG ami_menu_number(int item)
case M_SAVEIFF:
menu_num = FULLMENUNUM(0,4,3);
break;
-#ifdef WITH_PDF_EXPORT:
+#ifdef WITH_PDF_EXPORT
case M_SAVEPDF:
menu_num = FULLMENUNUM(0,4,4);
break;
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 43f7e1e..35a0ac7 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -123,7 +123,7 @@ void ami_menu_free_glyphs(void);
/* generic menu alloc/free/layout */
void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
- const char *restrict label, char key, const char *restrict icon,
+ const char *restrict label, const char *restrict key, const char *restrict icon,
void *restrict func, void *restrict hookdata, UWORD flags);
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/menuclass updated. release/3.6-196-ge4d6d9a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e4d6d9a972736bbea70eb...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e4d6d9a972736bbea70eb0a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e4d6d9a972736bbea70eb0af6...
The branch, chris/menuclass has been updated
via e4d6d9a972736bbea70eb0af62a430e77cc05ee5 (commit)
via 313aaabdde2e6f0bb1f0dfe571b77261cc697a95 (commit)
via 9f10babe645fe67b02fae90f852d5e4cdfcbb70e (commit)
via 7dab7cb43d4091648ceb40684ff70aff7091c648 (commit)
via 8ffc2e753b04a9e794e7a6302d57d590b311e41f (commit)
via 74e73a3b8b5ab3effd8e3d94c10463907d4c4ea9 (commit)
via 9e037376276aaa042b529499f1978766b9535f7b (commit)
from 0d9023148d2a34bd908aac38e44d449359b03438 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e4d6d9a972736bbea70...
commit e4d6d9a972736bbea70eb0af62a430e77cc05ee5
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Get selected state with MenuClass compatible abstraction
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 3d2f293..175fe15 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -111,6 +111,25 @@ const char * const verdate;
static nserror ami_menu_scan(struct ami_menu_data **md);
void ami_menu_arexx_scan(struct ami_menu_data **md);
+static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
+{
+ bool checked = false;
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ ULONG state;
+ struct ExtIntuiMessage *emsg = (struct ExtIntuiMessage *)msg;
+
+ state = IDoMethod(menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
+ if(state & MS_CHECKED) checked = true;
+#endif
+ } else {
+ if(ItemAddress(menu, msg->Code)->Flags & CHECKED) checked = true;
+ }
+
+ return checked;
+}
+
void ami_menu_set_check_toggled(void)
{
ami_menu_check_toggled = true;
@@ -378,8 +397,8 @@ HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
-
+ checked = ami_menu_get_selected(menustrip, msg);
+
nsoption_set_bool(foreground_images, checked);
ami_menu_set_check_toggled();
}
@@ -390,7 +409,7 @@ HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
+ checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(background_images, checked);
ami_menu_set_check_toggled();
@@ -402,7 +421,7 @@ HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
+ checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(enable_javascript, checked);
ami_menu_set_check_toggled();
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=313aaabdde2e6f0bb1f...
commit 313aaabdde2e6f0bb1f0dfe571b77261cc697a95
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Replace OnMenu/OffMenu with MenuClass compatible abstraction
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 9489110..0fc9841 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -89,11 +89,11 @@ void gui_start_selection(struct gui_window *g)
if(!g->shared->win) return;
if(nsoption_bool(kiosk_mode) == true) return;
- OnMenu(g->shared->win, AMI_MENU_CLEAR);
- OnMenu(g->shared->win, AMI_MENU_COPY);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- OnMenu(g->shared->win, AMI_MENU_CUT);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
}
static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 6627e87..cb0f2fa 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1206,16 +1206,12 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
if(!browser_window_reload_available(gwin->gw->bw))
reload=TRUE;
- if(nsoption_bool(kiosk_mode) == false)
- {
- if(gwin->tabs <= 1)
- {
+ if(nsoption_bool(kiosk_mode) == false) {
+ if(gwin->tabs <= 1) {
tabclose=TRUE;
- OffMenu(gwin->win,AMI_MENU_CLOSETAB);
- }
- else
- {
- OnMenu(gwin->win,AMI_MENU_CLOSETAB);
+ ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
+ } else {
+ ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
}
}
@@ -5262,7 +5258,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
g->c_h = height;
if((nsoption_bool(kiosk_mode) == false))
- OnMenu(g->shared->win, AMI_MENU_PASTE);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
}
static void gui_window_remove_caret(struct gui_window *g)
@@ -5271,7 +5267,7 @@ static void gui_window_remove_caret(struct gui_window *g)
if(g->c_h == 0) return;
if((nsoption_bool(kiosk_mode) == false))
- OffMenu(g->shared->win, AMI_MENU_PASTE);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 3595f96..3d2f293 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -1175,6 +1175,120 @@ static nserror ami_menu_scan(struct ami_menu_data **md)
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
+#ifdef __amigaos4__
+void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG disable_state = MS_DISABLED;
+
+ if(disable == false) {
+ disable_state = 0;
+ }
+
+ IDoMethod(menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+}
+#endif
+
+static ULONG ami_menu_number(int item)
+{
+ /* horrible, horrible, horrible */
+ ULONG menu_num;
+
+ switch(item) {
+ case M_SAVETXT:
+ menu_num = FULLMENUNUM(0,4,1);
+ break;
+
+ case M_SAVECOMP:
+ menu_num = FULLMENUNUM(0,4,2);
+ break;
+
+ case M_SAVEIFF:
+ menu_num = FULLMENUNUM(0,4,3);
+ break;
+#ifdef WITH_PDF_EXPORT:
+ case M_SAVEPDF:
+ menu_num = FULLMENUNUM(0,4,4);
+ break;
+#endif
+ case M_CLOSETAB:
+ menu_num = FULLMENUNUM(0,8,0);
+ break;
+
+ case M_CUT:
+ menu_num = FULLMENUNUM(1,0,0);
+ break;
+
+ case M_COPY:
+ menu_num = FULLMENUNUM(1,1,0);
+ break;
+
+ case M_PASTE:
+ menu_num = FULLMENUNUM(1,2,0);
+ break;
+
+ case M_SELALL:
+ menu_num = FULLMENUNUM(1,4,0);
+ break;
+
+ case M_CLEAR:
+ menu_num = FULLMENUNUM(1,5,0);
+ break;
+
+ case M_UNDO:
+ menu_num = FULLMENUNUM(1,8,0);
+ break;
+
+ case M_REDO:
+ menu_num = FULLMENUNUM(1,9,0);
+ break;
+
+ case M_FIND:
+ menu_num = FULLMENUNUM(2,0,0);
+ break;
+
+ case M_IMGFORE:
+ menu_num = FULLMENUNUM(2,8,0);
+ break;
+
+ case M_IMGBACK:
+ menu_num = FULLMENUNUM(2,8,1);
+ break;
+
+ case M_JS:
+ menu_num = FULLMENUNUM(2,9,0);
+ break;
+
+ default:
+ LOG("WARNING: Unrecognised menu item %d", item);
+ menu_num = 0;
+ break;
+ }
+
+ return menu_num;
+}
+
+static void ami_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG menu_num = ami_menu_number(item);
+
+ if(disable == false) {
+ OnMenu(win, menu_num);
+ } else {
+ OffMenu(win, menu_num);
+ }
+}
+
+void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ return ami_menu_set_disabled_mc(win, menu, item, disable);
+#endif
+ } else {
+ return ami_menu_set_disabled_gt(win, menu, item, disable);
+ }
+}
+
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
@@ -1187,26 +1301,26 @@ void ami_menu_update_checked(struct gui_window_2 *gwin)
GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
if(!menustrip) return;
if(nsoption_bool(enable_javascript) == true) {
- if((ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
}
if(nsoption_bool(foreground_images) == true) {
- if((ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
}
if(nsoption_bool(background_images) == true) {
- if((ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
}
ResetMenuStrip(gwin->win, menustrip);
@@ -1220,10 +1334,10 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
if(content_get_type(c) <= CONTENT_CSS)
{
- OnMenu(win,AMI_MENU_SAVEAS_TEXT);
- OnMenu(win,AMI_MENU_SAVEAS_COMPLETE);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
#ifdef WITH_PDF_EXPORT
- OnMenu(win,AMI_MENU_SAVEAS_PDF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
#endif
#if 0
if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
@@ -1244,28 +1358,29 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
else
OffMenu(win,AMI_MENU_PASTE);
#else
- OnMenu(win,AMI_MENU_CUT);
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_PASTE);
- OnMenu(win,AMI_MENU_CLEAR);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
#endif
- OnMenu(win,AMI_MENU_SELECTALL);
- OnMenu(win,AMI_MENU_FIND);
- OffMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
}
else
{
- OffMenu(win,AMI_MENU_CUT);
- OffMenu(win,AMI_MENU_PASTE);
- OffMenu(win,AMI_MENU_CLEAR);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
- OffMenu(win,AMI_MENU_SAVEAS_TEXT);
- OffMenu(win,AMI_MENU_SAVEAS_COMPLETE);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
#ifdef WITH_PDF_EXPORT
- OffMenu(win,AMI_MENU_SAVEAS_PDF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
#endif
- OffMenu(win,AMI_MENU_SELECTALL);
- OffMenu(win,AMI_MENU_FIND);
+
+ ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
#ifdef WITH_NS_SVG
if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
@@ -1273,13 +1388,13 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
if(content_get_bitmap(c))
#endif
{
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
}
else
{
- OffMenu(win,AMI_MENU_COPY);
- OffMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
}
}
}
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index ad0e96d..43f7e1e 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -115,24 +115,6 @@ enum {
* only used for freeing the UTF-8 converted menu labels */
#define AMI_MENU_MAX AMI_MENU_AREXX
-/* The Intuition menu numbers of some menus we might need to modify */
-#define AMI_MENU_SAVEAS_TEXT FULLMENUNUM(0,4,1)
-#define AMI_MENU_SAVEAS_COMPLETE FULLMENUNUM(0,4,2)
-#define AMI_MENU_SAVEAS_IFF FULLMENUNUM(0,4,3)
-#define AMI_MENU_SAVEAS_PDF FULLMENUNUM(0,4,4)
-#define AMI_MENU_CLOSETAB FULLMENUNUM(0,8,0)
-#define AMI_MENU_CUT FULLMENUNUM(1,0,0)
-#define AMI_MENU_COPY FULLMENUNUM(1,1,0)
-#define AMI_MENU_PASTE FULLMENUNUM(1,2,0)
-#define AMI_MENU_SELECTALL FULLMENUNUM(1,4,0)
-#define AMI_MENU_CLEAR FULLMENUNUM(1,5,0)
-#define AMI_MENU_UNDO FULLMENUNUM(1,8,0)
-#define AMI_MENU_REDO FULLMENUNUM(1,9,0)
-#define AMI_MENU_FIND FULLMENUNUM(2,0,0)
-#define AMI_MENU_FOREIMG FULLMENUNUM(2,8,0)
-#define AMI_MENU_BACKIMG FULLMENUNUM(2,8,1)
-#define AMI_MENU_JS FULLMENUNUM(2,9,0)
-
struct gui_window;
struct gui_window_2;
@@ -155,6 +137,11 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
void ami_menu_free(struct gui_window_2 *gwin);
/**
+ * Set disabled state of a menu item
+ */
+void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+
+/**
* Sets that an item linked to a toggle menu item has been changed.
*/
void ami_menu_set_check_toggled(void);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9f10babe645fe67b02f...
commit 9f10babe645fe67b02fae90f852d5e4cdfcbb70e
Merge: 0d90231 7dab7cb
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into chris/menuclass
-----------------------------------------------------------------------
Summary of changes:
Docs/core-window-interface | 2 +-
content/handlers/css/select.c | 1 +
desktop/browser_history.c | 126 +++++++++---
desktop/browser_private.h | 3 +-
desktop/font_haru.h | 1 -
desktop/knockout.c | 2 +-
desktop/options.h | 2 +-
desktop/plot_style.c | 15 +-
desktop/scrollbar.c | 6 +-
desktop/system_colour.h | 2 +-
desktop/textarea.h | 3 +-
frontends/amiga/clipboard.c | 6 +-
frontends/amiga/corewindow.c | 2 +-
frontends/amiga/gui.c | 18 +-
frontends/amiga/menu.c | 212 ++++++++++++++++----
frontends/amiga/menu.h | 23 +--
frontends/atari/plot/font_freetype.c | 2 +-
frontends/atari/plot/font_internal.c | 2 +-
frontends/atari/plot/fontplot.c | 2 +-
frontends/atari/settings.c | 2 +-
frontends/atari/toolbar.c | 1 -
frontends/beos/font.h | 2 +-
frontends/cocoa/font.h | 2 +-
frontends/cocoa/plotter.h | 2 +-
frontends/cocoa/plotter.m | 1 -
frontends/framebuffer/convert_image.c | 2 +-
frontends/framebuffer/fbtk.h | 2 +-
frontends/framebuffer/fbtk/user.c | 1 -
frontends/framebuffer/font_freetype.c | 1 +
frontends/framebuffer/font_internal.c | 1 +
frontends/gtk/corewindow.c | 2 +-
frontends/gtk/layout_pango.c | 1 +
frontends/monkey/layout.c | 2 +-
frontends/riscos/configure/con_fonts.c | 2 +-
frontends/riscos/font.c | 1 +
frontends/riscos/font.h | 5 +-
frontends/riscos/image.h | 2 +-
frontends/riscos/templates/de | 2 +-
frontends/riscos/templates/en | 2 +-
frontends/riscos/templates/fr | 2 +-
frontends/riscos/templates/nl | 2 +-
frontends/windows/corewindow.c | 1 -
frontends/windows/font.c | 1 +
frontends/windows/font.h | 4 +-
include/netsurf/clipboard.h | 2 +-
include/netsurf/content.h | 2 +-
{desktop => include/netsurf}/plot_style.h | 166 +++++++--------
include/netsurf/plotters.h | 2 +-
.../windows/file.h => include/netsurf/types.h | 20 +-
render/box_construct.c | 5 +-
render/font.c | 1 +
render/font.h | 4 +-
render/form.c | 9 +-
render/html.h | 5 +-
utils/nsoption.c | 2 +-
55 files changed, 436 insertions(+), 258 deletions(-)
rename {desktop => include/netsurf}/plot_style.h (88%)
copy frontends/windows/file.h => include/netsurf/types.h (71%)
diff --git a/Docs/core-window-interface b/Docs/core-window-interface
index 0267f37..3dfbcaf 100644
--- a/Docs/core-window-interface
+++ b/Docs/core-window-interface
@@ -259,7 +259,7 @@ frontends/example/corewindow.c
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
/* extremely likely there will be additional headers required in a real frontend */
#include "example/corewindow.h"
diff --git a/content/handlers/css/select.c b/content/handlers/css/select.c
index aaede77..daa3b40 100644
--- a/content/handlers/css/select.c
+++ b/content/handlers/css/select.c
@@ -24,6 +24,7 @@
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
+#include "netsurf/plot_style.h"
#include "netsurf/url_db.h"
#include "desktop/system_colour.h"
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 5cd98cd..d21c5bc 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -37,6 +37,7 @@
#include "content/urldb.h"
#include "netsurf/bitmap.h"
+#include "desktop/system_colour.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
@@ -235,6 +236,45 @@ static void browser_window_history__layout(struct history *history)
history->height += BOTTOM_MARGIN / 2;
}
+/** plot style for drawing lines between nodes */
+static plot_style_t pstyle_line = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 2,
+};
+
+/** plot style for drawing background */
+static plot_style_t pstyle_bg = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+};
+
+/** plot style for drawing rectangle round unselected nodes */
+static plot_style_t pstyle_rect = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+};
+
+/** plot style for drawing rectangle round selected nodes */
+static plot_style_t pstyle_rect_sel = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 3,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 400,
+ .flags = FONTF_NONE,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node_sel = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 900,
+ .flags = FONTF_NONE,
+};
+
/**
* Recursively redraw a history_entry.
*
@@ -260,19 +300,25 @@ browser_window_history__redraw_entry(struct history *history,
size_t char_offset;
int actual_x;
struct history_entry *child;
- colour c = entry == history->current ?
- HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
int tailsize = 5;
int xoffset = x - x0;
int yoffset = y - y0;
- plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 3 : 1,
- };
- plot_font_style_t fstyle = *plot_style_font;
+
+ plot_style_t *pstyle;
+ plot_font_style_t *pfstyle;
+
nserror res;
+ /* setup plot styles */
+ if (entry == history->current) {
+ pstyle = &pstyle_rect_sel;
+ pfstyle = &pfstyle_node_sel;
+ } else {
+ pstyle = &pstyle_rect;
+ pfstyle = &pfstyle_node;
+ }
+
+ /* setup clip area */
if (clip) {
struct rect rect;
rect.x0 = x0 + xoffset;
@@ -289,14 +335,16 @@ browser_window_history__redraw_entry(struct history *history,
plot->bitmap(entry->x + xoffset,
entry->y + yoffset,
WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0);
+ entry->bitmap,
+ 0xffffff,
+ 0);
}
if (!plot->rectangle(entry->x - 1 + xoffset,
- entry->y - 1 + yoffset,
- entry->x + xoffset + WIDTH,
- entry->y + yoffset + HEIGHT,
- &pstyle_history_rect)) {
+ entry->y - 1 + yoffset,
+ entry->x + xoffset + WIDTH,
+ entry->y + yoffset + HEIGHT,
+ pstyle)) {
return false;
}
@@ -307,36 +355,42 @@ browser_window_history__redraw_entry(struct history *history,
return false;
}
- fstyle.background = HISTORY_COLOUR_BACKGROUND;
- fstyle.foreground = c;
- fstyle.weight = entry == history->current ? 900 : 400;
- if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
- entry->page.title, char_offset, &fstyle))
+ if (!plot->text(entry->x + xoffset,
+ entry->y + HEIGHT + 12 + yoffset,
+ entry->page.title,
+ char_offset,
+ pfstyle)) {
return false;
+ }
+ /* for each child node draw a line and recurse redraw into it */
for (child = entry->forward; child; child = child->next) {
if (!plot->line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
- entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y +
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y +
HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ &pstyle_line)) {
return false;
+ }
if (!browser_window_history__redraw_entry(history, child,
- x0, y0, x1, y1, x, y, clip, ctx))
+ x0, y0, x1, y1, x, y, clip, ctx)) {
return false;
+ }
}
return true;
@@ -415,6 +469,17 @@ nserror browser_window_history_create(struct browser_window *bw)
{
struct history *history;
+ pstyle_bg.fill_colour = ns_system_colour_char("Window");
+ pfstyle_node.background = pstyle_bg.fill_colour;
+ pfstyle_node_sel.background = pstyle_bg.fill_colour;
+
+ pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
+ pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
+ pfstyle_node.foreground = pstyle_line.stroke_colour;
+
+ pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
+ pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+
bw->history = NULL;
history = calloc(1, sizeof *history);
@@ -426,6 +491,7 @@ nserror browser_window_history_create(struct browser_window *bw)
history->height = BOTTOM_MARGIN / 2;
bw->history = history;
+
return NSERROR_OK;
}
@@ -709,6 +775,7 @@ bool browser_window_history_redraw(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
0, 0, 0, 0, 0, 0, false, ctx);
}
@@ -726,6 +793,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
x0, y0, x1, y1, x, y, true, ctx);
}
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 64c698b..072a894 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -26,9 +26,10 @@
#include <libwapcaplet/libwapcaplet.h>
+#include "netsurf/types.h"
#include "netsurf/browser_window.h"
+
#include "desktop/frame_types.h"
-#include "desktop/plot_style.h"
struct box;
struct hlcache_handle;
diff --git a/desktop/font_haru.h b/desktop/font_haru.h
index 479f7de..988b9ba 100644
--- a/desktop/font_haru.h
+++ b/desktop/font_haru.h
@@ -26,7 +26,6 @@
#include <hpdf.h>
-#include "desktop/plot_style.h"
#include "desktop/font.h"
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
diff --git a/desktop/knockout.c b/desktop/knockout.c
index b930ef6..bcfc272 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -71,10 +71,10 @@
#include "utils/errors.h"
#include "netsurf/bitmap.h"
#include "content/content.h"
+#include "netsurf/plotters.h"
#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
-#include "netsurf/plotters.h"
/* Define to enable knockout debug */
#undef KNOCKOUT_DEBUG
diff --git a/desktop/options.h b/desktop/options.h
index 437d104..d91898c 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -30,7 +30,7 @@
#ifndef _NETSURF_DESKTOP_OPTIONS_H_
#define _NETSURF_DESKTOP_OPTIONS_H_
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/* defines for system colour table */
#define NSOPTION_SYS_COLOUR_START NSOPTION_sys_colour_ActiveBorder
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index f9ba4bc..1f0ac39 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * \file desktop/plot_style.c
+/**
+ * \file
* \brief Plotter global styles.
*
* These plot styles are globaly available and used in many places.
*/
-#include "netsurf/plotters.h"
+#include "netsurf/plot_style.h"
static plot_style_t plot_style_fill_white_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
@@ -152,15 +152,6 @@ static plot_style_t plot_style_stroke_lightwbasec_static = {
};
plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
-/* history styles */
-
-/** stroke style for history core. */
-static plot_style_t plot_style_stroke_history_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = HISTORY_COLOUR_LINES,
- .stroke_width = 2,
-};
-plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static;
/* Generic font style */
static const plot_font_style_t plot_style_font_static = {
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index b9e963a..9a4d70f 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -29,14 +29,12 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
-
#include "netsurf/browser_window.h"
-#include "desktop/system_colour.h"
#include "netsurf/mouse.h"
-#include "desktop/scrollbar.h"
#include "netsurf/plotters.h"
-#include "desktop/plot_style.h"
+#include "desktop/system_colour.h"
+#include "desktop/scrollbar.h"
struct scrollbar {
bool horizontal; /* Horizontal scrollbar if true, else vertical
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index b5d4baa..8e82818 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -26,7 +26,7 @@
#include <libcss/libcss.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/** css callback to obtain named system colours. */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 74652f3..19162ff 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -28,8 +28,7 @@
#include <stdbool.h>
#include "utils/utils.h"
-
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/mouse.h"
struct textarea;
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 9489110..0fc9841 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -89,11 +89,11 @@ void gui_start_selection(struct gui_window *g)
if(!g->shared->win) return;
if(nsoption_bool(kiosk_mode) == true) return;
- OnMenu(g->shared->win, AMI_MENU_CLEAR);
- OnMenu(g->shared->win, AMI_MENU_COPY);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
- OnMenu(g->shared->win, AMI_MENU_CUT);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
}
static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index d2bfbf9..0ed16d1 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -44,7 +44,7 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include <proto/exec.h>
#include <proto/intuition.h>
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 6627e87..cb0f2fa 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1206,16 +1206,12 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
if(!browser_window_reload_available(gwin->gw->bw))
reload=TRUE;
- if(nsoption_bool(kiosk_mode) == false)
- {
- if(gwin->tabs <= 1)
- {
+ if(nsoption_bool(kiosk_mode) == false) {
+ if(gwin->tabs <= 1) {
tabclose=TRUE;
- OffMenu(gwin->win,AMI_MENU_CLOSETAB);
- }
- else
- {
- OnMenu(gwin->win,AMI_MENU_CLOSETAB);
+ ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
+ } else {
+ ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
}
}
@@ -5262,7 +5258,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
g->c_h = height;
if((nsoption_bool(kiosk_mode) == false))
- OnMenu(g->shared->win, AMI_MENU_PASTE);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
}
static void gui_window_remove_caret(struct gui_window *g)
@@ -5271,7 +5267,7 @@ static void gui_window_remove_caret(struct gui_window *g)
if(g->c_h == 0) return;
if((nsoption_bool(kiosk_mode) == false))
- OffMenu(g->shared->win, AMI_MENU_PASTE);
+ ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 97debb6..175fe15 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -111,6 +111,25 @@ const char * const verdate;
static nserror ami_menu_scan(struct ami_menu_data **md);
void ami_menu_arexx_scan(struct ami_menu_data **md);
+static bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
+{
+ bool checked = false;
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ ULONG state;
+ struct ExtIntuiMessage *emsg = (struct ExtIntuiMessage *)msg;
+
+ state = IDoMethod(menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
+ if(state & MS_CHECKED) checked = true;
+#endif
+ } else {
+ if(ItemAddress(menu, msg->Code)->Flags & CHECKED) checked = true;
+ }
+
+ return checked;
+}
+
void ami_menu_set_check_toggled(void)
{
ami_menu_check_toggled = true;
@@ -378,8 +397,8 @@ HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
-
+ checked = ami_menu_get_selected(menustrip, msg);
+
nsoption_set_bool(foreground_images, checked);
ami_menu_set_check_toggled();
}
@@ -390,7 +409,7 @@ HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
+ checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(background_images, checked);
ami_menu_set_check_toggled();
@@ -402,7 +421,7 @@ HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
bool checked = false;
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
- if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
+ checked = ami_menu_get_selected(menustrip, msg);
nsoption_set_bool(enable_javascript, checked);
ami_menu_set_check_toggled();
@@ -978,7 +997,7 @@ static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max)
TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && md[i+1] && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
@@ -1175,6 +1194,120 @@ static nserror ami_menu_scan(struct ami_menu_data **md)
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
+#ifdef __amigaos4__
+void ami_menu_set_disabled_mc(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG disable_state = MS_DISABLED;
+
+ if(disable == false) {
+ disable_state = 0;
+ }
+
+ IDoMethod(menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
+}
+#endif
+
+static ULONG ami_menu_number(int item)
+{
+ /* horrible, horrible, horrible */
+ ULONG menu_num;
+
+ switch(item) {
+ case M_SAVETXT:
+ menu_num = FULLMENUNUM(0,4,1);
+ break;
+
+ case M_SAVECOMP:
+ menu_num = FULLMENUNUM(0,4,2);
+ break;
+
+ case M_SAVEIFF:
+ menu_num = FULLMENUNUM(0,4,3);
+ break;
+#ifdef WITH_PDF_EXPORT:
+ case M_SAVEPDF:
+ menu_num = FULLMENUNUM(0,4,4);
+ break;
+#endif
+ case M_CLOSETAB:
+ menu_num = FULLMENUNUM(0,8,0);
+ break;
+
+ case M_CUT:
+ menu_num = FULLMENUNUM(1,0,0);
+ break;
+
+ case M_COPY:
+ menu_num = FULLMENUNUM(1,1,0);
+ break;
+
+ case M_PASTE:
+ menu_num = FULLMENUNUM(1,2,0);
+ break;
+
+ case M_SELALL:
+ menu_num = FULLMENUNUM(1,4,0);
+ break;
+
+ case M_CLEAR:
+ menu_num = FULLMENUNUM(1,5,0);
+ break;
+
+ case M_UNDO:
+ menu_num = FULLMENUNUM(1,8,0);
+ break;
+
+ case M_REDO:
+ menu_num = FULLMENUNUM(1,9,0);
+ break;
+
+ case M_FIND:
+ menu_num = FULLMENUNUM(2,0,0);
+ break;
+
+ case M_IMGFORE:
+ menu_num = FULLMENUNUM(2,8,0);
+ break;
+
+ case M_IMGBACK:
+ menu_num = FULLMENUNUM(2,8,1);
+ break;
+
+ case M_JS:
+ menu_num = FULLMENUNUM(2,9,0);
+ break;
+
+ default:
+ LOG("WARNING: Unrecognised menu item %d", item);
+ menu_num = 0;
+ break;
+ }
+
+ return menu_num;
+}
+
+static void ami_menu_set_disabled_gt(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ ULONG menu_num = ami_menu_number(item);
+
+ if(disable == false) {
+ OnMenu(win, menu_num);
+ } else {
+ OffMenu(win, menu_num);
+ }
+}
+
+void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
+{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
+ return ami_menu_set_disabled_mc(win, menu, item, disable);
+#endif
+ } else {
+ return ami_menu_set_disabled_gt(win, menu, item, disable);
+ }
+}
+
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
@@ -1187,26 +1320,26 @@ void ami_menu_update_checked(struct gui_window_2 *gwin)
GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
if(!menustrip) return;
if(nsoption_bool(enable_javascript) == true) {
- if((ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_JS))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_JS))->Flags ^= CHECKED;
}
if(nsoption_bool(foreground_images) == true) {
- if((ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_IMGFORE))->Flags ^= CHECKED;
}
if(nsoption_bool(background_images) == true) {
- if((ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED) == 0)
- ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
+ if((ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED) == 0)
+ ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
} else {
- if(ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED)
- ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
+ if(ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags & CHECKED)
+ ItemAddress(menustrip, ami_menu_number(M_IMGBACK))->Flags ^= CHECKED;
}
ResetMenuStrip(gwin->win, menustrip);
@@ -1220,10 +1353,10 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
if(content_get_type(c) <= CONTENT_CSS)
{
- OnMenu(win,AMI_MENU_SAVEAS_TEXT);
- OnMenu(win,AMI_MENU_SAVEAS_COMPLETE);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false);
#ifdef WITH_PDF_EXPORT
- OnMenu(win,AMI_MENU_SAVEAS_PDF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false);
#endif
#if 0
if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) {
@@ -1244,28 +1377,29 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
else
OffMenu(win,AMI_MENU_PASTE);
#else
- OnMenu(win,AMI_MENU_CUT);
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_PASTE);
- OnMenu(win,AMI_MENU_CLEAR);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CUT, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false);
#endif
- OnMenu(win,AMI_MENU_SELECTALL);
- OnMenu(win,AMI_MENU_FIND);
- OffMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_FIND, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
}
else
{
- OffMenu(win,AMI_MENU_CUT);
- OffMenu(win,AMI_MENU_PASTE);
- OffMenu(win,AMI_MENU_CLEAR);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CUT, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_PASTE, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true);
- OffMenu(win,AMI_MENU_SAVEAS_TEXT);
- OffMenu(win,AMI_MENU_SAVEAS_COMPLETE);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true);
#ifdef WITH_PDF_EXPORT
- OffMenu(win,AMI_MENU_SAVEAS_PDF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true);
#endif
- OffMenu(win,AMI_MENU_SELECTALL);
- OffMenu(win,AMI_MENU_FIND);
+
+ ami_menu_set_disabled(win, g->shared->imenu, M_SELALL, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_FIND, true);
#ifdef WITH_NS_SVG
if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
@@ -1273,13 +1407,13 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
if(content_get_bitmap(c))
#endif
{
- OnMenu(win,AMI_MENU_COPY);
- OnMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, false);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false);
}
else
{
- OffMenu(win,AMI_MENU_COPY);
- OffMenu(win,AMI_MENU_SAVEAS_IFF);
+ ami_menu_set_disabled(win, g->shared->imenu, M_COPY, true);
+ ami_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true);
}
}
}
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index ad0e96d..43f7e1e 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -115,24 +115,6 @@ enum {
* only used for freeing the UTF-8 converted menu labels */
#define AMI_MENU_MAX AMI_MENU_AREXX
-/* The Intuition menu numbers of some menus we might need to modify */
-#define AMI_MENU_SAVEAS_TEXT FULLMENUNUM(0,4,1)
-#define AMI_MENU_SAVEAS_COMPLETE FULLMENUNUM(0,4,2)
-#define AMI_MENU_SAVEAS_IFF FULLMENUNUM(0,4,3)
-#define AMI_MENU_SAVEAS_PDF FULLMENUNUM(0,4,4)
-#define AMI_MENU_CLOSETAB FULLMENUNUM(0,8,0)
-#define AMI_MENU_CUT FULLMENUNUM(1,0,0)
-#define AMI_MENU_COPY FULLMENUNUM(1,1,0)
-#define AMI_MENU_PASTE FULLMENUNUM(1,2,0)
-#define AMI_MENU_SELECTALL FULLMENUNUM(1,4,0)
-#define AMI_MENU_CLEAR FULLMENUNUM(1,5,0)
-#define AMI_MENU_UNDO FULLMENUNUM(1,8,0)
-#define AMI_MENU_REDO FULLMENUNUM(1,9,0)
-#define AMI_MENU_FIND FULLMENUNUM(2,0,0)
-#define AMI_MENU_FOREIMG FULLMENUNUM(2,8,0)
-#define AMI_MENU_BACKIMG FULLMENUNUM(2,8,1)
-#define AMI_MENU_JS FULLMENUNUM(2,9,0)
-
struct gui_window;
struct gui_window_2;
@@ -155,6 +137,11 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
void ami_menu_free(struct gui_window_2 *gwin);
/**
+ * Set disabled state of a menu item
+ */
+void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+
+/**
* Sets that an item linked to a toggle menu item has been changed.
*/
void ami_menu_set_check_toggled(void);
diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c
index 6028207..8b535e3 100644
--- a/frontends/atari/plot/font_freetype.c
+++ b/frontends/atari/plot/font_freetype.c
@@ -25,7 +25,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c
index b96f4c7..6a811e3 100644
--- a/frontends/atari/plot/font_internal.c
+++ b/frontends/atari/plot/font_internal.c
@@ -25,7 +25,7 @@
#include "utils/utf8.h"
#include "utils/log.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/fontplot.c b/frontends/atari/plot/fontplot.c
index d0a1fe1..2e02b50 100644
--- a/frontends/atari/plot/fontplot.c
+++ b/frontends/atari/plot/fontplot.c
@@ -22,7 +22,7 @@
#include <mt_gem.h>
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/bitmap.h"
#include "atari/plot/fontplot.h"
diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c
index b6df127..5759a89 100644
--- a/frontends/atari/settings.c
+++ b/frontends/atari/settings.c
@@ -32,7 +32,7 @@
#include "utils/dirent.h"
#include "utils/nsoption.h"
#include "utils/log.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/res/netsurf.rsh"
diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c
index 66bd44b..9ed8784 100644
--- a/frontends/atari/toolbar.c
+++ b/frontends/atari/toolbar.c
@@ -35,7 +35,6 @@
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
-#include "desktop/plot_style.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "desktop/textarea.h"
diff --git a/frontends/beos/font.h b/frontends/beos/font.h
index 63909ef..285ba9c 100644
--- a/frontends/beos/font.h
+++ b/frontends/beos/font.h
@@ -24,7 +24,7 @@
#ifndef NS_BEOS_FONT_H
#define NS_BEOS_FONT_H
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
bool nsfont_paint(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/frontends/cocoa/font.h b/frontends/cocoa/font.h
index cabd2b9..ed04797 100644
--- a/frontends/cocoa/font.h
+++ b/frontends/cocoa/font.h
@@ -19,7 +19,7 @@
#ifndef COCOA_FONT_H
#define COCOA_FONT_H
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t length, const struct plot_font_style *style );
diff --git a/frontends/cocoa/plotter.h b/frontends/cocoa/plotter.h
index 88f9fca..ce48653 100644
--- a/frontends/cocoa/plotter.h
+++ b/frontends/cocoa/plotter.h
@@ -20,7 +20,7 @@
#define COCOA_PLOTTER_H
#import <Cocoa/Cocoa.h>
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
extern const struct plotter_table cocoa_plotters;
diff --git a/frontends/cocoa/plotter.m b/frontends/cocoa/plotter.m
index 20b6884..dea3245 100644
--- a/frontends/cocoa/plotter.m
+++ b/frontends/cocoa/plotter.m
@@ -22,7 +22,6 @@
#import "utils/utils.h"
#import "netsurf/browser_window.h"
#import "netsurf/plotters.h"
-#import "desktop/plot_style.h"
#import "cocoa/font.h"
#import "cocoa/coordinates.h"
diff --git a/frontends/framebuffer/convert_image.c b/frontends/framebuffer/convert_image.c
index 2608328..de772fc 100644
--- a/frontends/framebuffer/convert_image.c
+++ b/frontends/framebuffer/convert_image.c
@@ -262,7 +262,7 @@ main(int argc, char **argv)
fprintf(f, "#include <stdint.h>\n\n");
fprintf(f, "#include <stdbool.h>\n\n");
fprintf(f, "#include <libnsfb.h>\n\n");
- fprintf(f, "#include \"desktop/plot_style.h\"\n");
+ fprintf(f, "#include \"netsurf/plot_style.h\"\n");
fprintf(f, "#include \"framebuffer/gui.h\"\n");
fprintf(f, "#include \"framebuffer/fbtk.h\"\n\n");
diff --git a/frontends/framebuffer/fbtk.h b/frontends/framebuffer/fbtk.h
index fe4f5a5..3cc326c 100644
--- a/frontends/framebuffer/fbtk.h
+++ b/frontends/framebuffer/fbtk.h
@@ -19,7 +19,7 @@
#ifndef NETSURF_FB_FBTK_H
#define NETSURF_FB_FBTK_H
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#ifdef FBTK_LOGGING
#define FBTK_LOG(x) LOG(x)
diff --git a/frontends/framebuffer/fbtk/user.c b/frontends/framebuffer/fbtk/user.c
index 2b9cc87..de547ab 100644
--- a/frontends/framebuffer/fbtk/user.c
+++ b/frontends/framebuffer/fbtk/user.c
@@ -22,7 +22,6 @@
#include <stdbool.h>
#include <libnsfb.h>
-#include "desktop/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c
index 3239820..ccc60ea 100644
--- a/frontends/framebuffer/font_freetype.c
+++ b/frontends/framebuffer/font_freetype.c
@@ -30,6 +30,7 @@
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/browser_window.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c
index 3fd3ac6..3b8a1c4 100644
--- a/frontends/framebuffer/font_internal.c
+++ b/frontends/framebuffer/font_internal.c
@@ -26,6 +26,7 @@
#include "utils/utf8.h"
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c
index 9f66ef1..8af1958 100644
--- a/frontends/gtk/corewindow.c
+++ b/frontends/gtk/corewindow.c
@@ -42,9 +42,9 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/utf8.h"
+#include "netsurf/types.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "gtk/compat.h"
#include "gtk/gui.h" /* just for gtk_gui_gdkkey_to_nskey */
diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c
index a0196df..7c71909 100644
--- a/frontends/gtk/layout_pango.c
+++ b/frontends/gtk/layout_pango.c
@@ -31,6 +31,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "gtk/layout_pango.h"
#include "gtk/plotters.h"
diff --git a/frontends/monkey/layout.c b/frontends/monkey/layout.c
index 00ed9df..4bcc51b 100644
--- a/frontends/monkey/layout.c
+++ b/frontends/monkey/layout.c
@@ -24,7 +24,7 @@
#include <stddef.h>
#include "utils/utf8.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/layout.h"
#include "monkey/layout.h"
diff --git a/frontends/riscos/configure/con_fonts.c b/frontends/riscos/configure/con_fonts.c
index 2803128..ecbf396 100644
--- a/frontends/riscos/configure/con_fonts.c
+++ b/frontends/riscos/configure/con_fonts.c
@@ -21,7 +21,7 @@
#include "utils/nsoption.h"
#include "utils/messages.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c
index a7a394e..560afc7 100644
--- a/frontends/riscos/font.c
+++ b/frontends/riscos/font.c
@@ -35,6 +35,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.h b/frontends/riscos/font.h
index 0319a7e..a29bad8 100644
--- a/frontends/riscos/font.h
+++ b/frontends/riscos/font.h
@@ -25,6 +25,7 @@
#include <rufl.h>
+struct plot_font_style;
struct gui_layout_table *riscos_layout_table;
/** desktop font, size and style being used */
@@ -35,9 +36,9 @@ extern rufl_style ro_gui_desktop_font_style;
void nsfont_init(void);
bool nsfont_exists(const char *font_family);
const char *nsfont_fallback_font(void);
-bool nsfont_paint(const plot_font_style_t *fstyle, const char *string,
+bool nsfont_paint(const struct plot_font_style *fstyle, const char *string,
size_t length, int x, int y);
-void nsfont_read_style(const plot_font_style_t *fstyle,
+void nsfont_read_style(const struct plot_font_style *fstyle,
const char **font_family, unsigned int *font_size,
rufl_style *font_style);
void ro_gui_wimp_get_desktop_font(void);
diff --git a/frontends/riscos/image.h b/frontends/riscos/image.h
index a11388c..2ed3e18 100644
--- a/frontends/riscos/image.h
+++ b/frontends/riscos/image.h
@@ -20,7 +20,7 @@
#define _NETSURF_RISCOS_IMAGE_H_
#include <stdbool.h>
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#include "oslib/osspriteop.h"
struct osspriteop_area;
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index 0fb4a9d..a4ec1f4 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -2542,7 +2542,7 @@ wimp_window {
xscroll:0
yscroll:0
next:wimp_TOP
- window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_NO_BOUNDS
title_fg:wimp_COLOUR_BLACK
title_bg:wimp_COLOUR_LIGHT_GREY
work_fg:wimp_COLOUR_BLACK
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index 7746b86..25be55f 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -2750,7 +2750,7 @@ wimp_window {
xscroll:0
yscroll:0
next:wimp_TOP
- window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_NO_BOUNDS
title_fg:wimp_COLOUR_BLACK
title_bg:wimp_COLOUR_LIGHT_GREY
work_fg:wimp_COLOUR_BLACK
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index 6779264..fafe0ce 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -2554,7 +2554,7 @@ wimp_window {
xscroll:0
yscroll:0
next:wimp_TOP
- window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_NO_BOUNDS
title_fg:wimp_COLOUR_BLACK
title_bg:wimp_COLOUR_LIGHT_GREY
work_fg:wimp_COLOUR_BLACK
diff --git a/frontends/riscos/templates/nl b/frontends/riscos/templates/nl
index 704206f..5ed9cac 100644
--- a/frontends/riscos/templates/nl
+++ b/frontends/riscos/templates/nl
@@ -2796,7 +2796,7 @@ wimp_window {
xscroll:0
yscroll:0
next:wimp_TOP
- window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT | wimp_WINDOW_BOUNDED_ONCE | wimp_WINDOW_BACK_ICON | wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_TOGGLE_ICON | wimp_WINDOW_VSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_HSCROLL | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_NO_BOUNDS
title_fg:wimp_COLOUR_BLACK
title_bg:wimp_COLOUR_LIGHT_GREY
work_fg:wimp_COLOUR_BLACK
diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c
index 8d853fb..ff89d92 100644
--- a/frontends/windows/corewindow.c
+++ b/frontends/windows/corewindow.c
@@ -43,7 +43,6 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "windows/windbg.h"
#include "windows/corewindow.h"
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index 1e99a78..791b8cd 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -32,6 +32,7 @@
#include "utils/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/utf8.h"
+#include "netsurf/plot_style.h"
#include "windows/font.h"
diff --git a/frontends/windows/font.h b/frontends/windows/font.h
index 0e86755..a1077e0 100644
--- a/frontends/windows/font.h
+++ b/frontends/windows/font.h
@@ -25,6 +25,8 @@
#ifndef NETSURF_WINDOWS_FONT_H
#define NETSURF_WINDOWS_FONT_H
+struct plot_font_style;
+
extern HWND font_hwnd;
struct font_desc {
@@ -47,7 +49,7 @@ extern nserror utf8_to_font_encoding(const struct font_desc* font,
* \param style The font style.
* \return The win32 font handle
*/
-HFONT get_font(const plot_font_style_t *style);
+HFONT get_font(const struct plot_font_style *style);
#endif /* NETSURF_WINDOWS_FONT_H */
diff --git a/include/netsurf/clipboard.h b/include/netsurf/clipboard.h
index d90ebc4..ab8d10a 100644
--- a/include/netsurf/clipboard.h
+++ b/include/netsurf/clipboard.h
@@ -28,7 +28,7 @@
#include <stddef.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
diff --git a/include/netsurf/content.h b/include/netsurf/content.h
index 35b8b33..5eee59a 100644
--- a/include/netsurf/content.h
+++ b/include/netsurf/content.h
@@ -28,7 +28,7 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "desktop/plot_style.h" /* color typedef */
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
struct bitmap;
diff --git a/desktop/plot_style.h b/include/netsurf/plot_style.h
similarity index 88%
rename from desktop/plot_style.h
rename to include/netsurf/plot_style.h
index 347c6e8..30db366 100644
--- a/desktop/plot_style.h
+++ b/include/netsurf/plot_style.h
@@ -16,19 +16,88 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Plotter styles.
+/**
+ * \file
+ * plotter style interfaces, generic styles and style colour helpers.
*/
-#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
-#define _NETSURF_DESKTOP_PLOT_STYLE_H_
+#ifndef NETSURF_PLOT_STYLE_H
+#define NETSURF_PLOT_STYLE_H
#include <stdint.h>
+#include "netsurf/types.h"
-/* html widget colours */
+/** light grey widget base colour */
#define WIDGET_BASEC 0xd9d9d9
+
+/** black blob colour */
#define WIDGET_BLOBC 0x000000
+/** Transparent colour value. */
+#define NS_TRANSPARENT 0x01000000
+
+/** Scaling factor for font sizes */
+#define FONT_SIZE_SCALE 1024
+
+/**
+ * Type of plot operation
+ */
+typedef enum {
+ PLOT_OP_TYPE_NONE = 0, /**< No operation */
+ PLOT_OP_TYPE_SOLID, /**< Solid colour */
+ PLOT_OP_TYPE_DOT, /**< Dotted plot */
+ PLOT_OP_TYPE_DASH, /**< Dashed plot */
+} plot_operation_type_t;
+
+
+/**
+ * Plot style for stroke/fill plotters
+ */
+typedef struct plot_style_s {
+ plot_operation_type_t stroke_type; /**< Stroke plot type */
+ int stroke_width; /**< Width of stroke, in pixels */
+ colour stroke_colour; /**< Colour of stroke */
+ plot_operation_type_t fill_type; /**< Fill plot type */
+ colour fill_colour; /**< Colour of fill */
+} plot_style_t;
+
+
+/**
+ * Generic font family type
+ */
+typedef enum {
+ PLOT_FONT_FAMILY_SANS_SERIF = 0,
+ PLOT_FONT_FAMILY_SERIF,
+ PLOT_FONT_FAMILY_MONOSPACE,
+ PLOT_FONT_FAMILY_CURSIVE,
+ PLOT_FONT_FAMILY_FANTASY,
+ PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
+} plot_font_generic_family_t;
+
+
+/**
+ * Font plot flags
+ */
+typedef enum {
+ FONTF_NONE = 0,
+ FONTF_ITALIC = 1,
+ FONTF_OBLIQUE = 2,
+ FONTF_SMALLCAPS = 4,
+} plot_font_flags_t;
+
+/**
+ * Font style for plotting
+ */
+typedef struct plot_font_style {
+ plot_font_generic_family_t family; /**< Generic family to plot with */
+ int size; /**< Font size, in points * FONT_SIZE_SCALE */
+ int weight; /**< Font weight: value in range [100,900] as per CSS */
+ plot_font_flags_t flags; /**< Font flags */
+ colour background; /**< Background colour to blend to, if appropriate */
+ colour foreground; /**< Colour of text */
+} plot_font_style_t;
+
+
/* Darken a colour by taking three quarters of each channel's intensity */
#define darken_colour(c1) \
((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
@@ -90,85 +159,19 @@
#define blue_from_colour(c) \
((c >> 16) & 0xff)
-/**
- * Colour type: XBGR
- */
-typedef uint32_t colour;
-
-/**
- * Magical transparent value
- */
-#define NS_TRANSPARENT 0x01000000
-
-/**
- * Type of plot operation
- */
-typedef enum {
- PLOT_OP_TYPE_NONE = 0, /**< No operation */
- PLOT_OP_TYPE_SOLID, /**< Solid colour */
- PLOT_OP_TYPE_DOT, /**< Dotted plot */
- PLOT_OP_TYPE_DASH, /**< Dashed plot */
-} plot_operation_type_t;
-
-/**
- * Plot style for stroke/fill plotters
- */
-typedef struct plot_style_s {
- plot_operation_type_t stroke_type; /**< Stroke plot type */
- int stroke_width; /**< Width of stroke, in pixels */
- colour stroke_colour; /**< Colour of stroke */
- plot_operation_type_t fill_type; /**< Fill plot type */
- colour fill_colour; /**< Colour of fill */
-} plot_style_t;
-
-/**
- * Generic font family type
- */
-typedef enum {
- PLOT_FONT_FAMILY_SANS_SERIF = 0,
- PLOT_FONT_FAMILY_SERIF,
- PLOT_FONT_FAMILY_MONOSPACE,
- PLOT_FONT_FAMILY_CURSIVE,
- PLOT_FONT_FAMILY_FANTASY,
- PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
-} plot_font_generic_family_t;
-
-/**
- * Font plot flags
- */
-typedef unsigned long plot_font_flags_t;
-#define FONTF_NONE 0
-#define FONTF_ITALIC 1
-#define FONTF_OBLIQUE 2
-#define FONTF_SMALLCAPS 4
-
-/**
- * Scaling factor for font sizes
- */
-#define FONT_SIZE_SCALE 1024
-
-/**
- * Font style for plotting
- */
-typedef struct plot_font_style {
- plot_font_generic_family_t family; /**< Generic family to plot with */
- int size; /**< Font size, in points * FONT_SIZE_SCALE */
- int weight; /**< Font weight: value in range [100,900] as per CSS */
- plot_font_flags_t flags; /**< Font flags */
- colour background; /**< Background colour to blend to, if appropriate */
- colour foreground; /**< Colour of text */
-} plot_font_style_t;
/* global fill styles */
extern plot_style_t *plot_style_fill_white;
extern plot_style_t *plot_style_fill_red;
extern plot_style_t *plot_style_fill_black;
+
/* Box model debug outline styles for content, padding and margin edges */
extern plot_style_t const * const plot_style_content_edge;
extern plot_style_t const * const plot_style_padding_edge;
extern plot_style_t const * const plot_style_margin_edge;
+
/* Broken object replacement styles */
extern plot_style_t const * const plot_style_broken_object;
extern plot_font_style_t const * const plot_fstyle_broken_object;
@@ -176,7 +179,6 @@ extern plot_font_style_t const * const plot_fstyle_broken_object;
/* other styles */
extern plot_style_t *plot_style_caret;
-extern plot_style_t *plot_style_stroke_history;
extern plot_style_t *plot_style_fill_wbasec;
extern plot_style_t *plot_style_fill_darkwbasec;
extern plot_style_t *plot_style_fill_lightwbasec;
@@ -185,23 +187,9 @@ extern plot_style_t *plot_style_stroke_wblobc;
extern plot_style_t *plot_style_stroke_darkwbasec;
extern plot_style_t *plot_style_stroke_lightwbasec;
+
/* Default font style */
extern plot_font_style_t const * const plot_style_font;
-#ifndef HISTORY_COLOUR_SELECTED
-#define HISTORY_COLOUR_SELECTED 0xFF0000
-#endif
-
-#ifndef HISTORY_COLOUR_FOREGROUND
-#define HISTORY_COLOUR_FOREGROUND 0x333333
-#endif
-
-#ifndef HISTORY_COLOUR_BACKGROUND
-#define HISTORY_COLOUR_BACKGROUND 0xFFFFFF
-#endif
-
-#ifndef HISTORY_COLOUR_LINES
-#define HISTORY_COLOUR_LINES HISTORY_COLOUR_FOREGROUND
-#endif
#endif
diff --git a/include/netsurf/plotters.h b/include/netsurf/plotters.h
index b13c9b2..88cbbe5 100644
--- a/include/netsurf/plotters.h
+++ b/include/netsurf/plotters.h
@@ -27,7 +27,7 @@
#include <stdbool.h>
#include <stdio.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
struct bitmap;
struct rect;
diff --git a/frontends/windows/file.h b/include/netsurf/types.h
similarity index 71%
copy from frontends/windows/file.h
copy to include/netsurf/types.h
index 5262dde..27f2e8f 100644
--- a/frontends/windows/file.h
+++ b/include/netsurf/types.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ * Copyright 2017 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,12 +18,20 @@
/**
* \file
- * Windows file operation table interface.
+ *
+ * NetSurf types.
+ *
+ * These are convenience types used throughout the browser.
*/
-#ifndef _NETSURF_WINDOWS_FILE_H_
-#define _NETSURF_WINDOWS_FILE_H_
+#ifndef NETSURF_TYPES_H
+#define NETSURF_TYPES_H
+
+#include <stdint.h>
-struct gui_file_table *win32_file_table;
+/**
+ * Colour type: XBGR
+ */
+typedef uint32_t colour;
-#endif
+#endif
diff --git a/render/box_construct.c b/render/box_construct.c
index 4b54a30..d7de68c 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -41,11 +41,12 @@
#include "utils/utils.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "netsurf/css.h"
+#include "netsurf/misc.h"
+#include "netsurf/plot_style.h"
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
-#include "netsurf/css.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/font.c b/render/font.c
index 8128269..94ef877 100644
--- a/render/font.c
+++ b/render/font.c
@@ -23,6 +23,7 @@
*/
#include "utils/nsoption.h"
+#include "netsurf/plot_style.h"
#include "css/utils.h"
#include "render/font.h"
diff --git a/render/font.h b/render/font.h
index e4353df..fba368a 100644
--- a/render/font.h
+++ b/render/font.h
@@ -27,6 +27,8 @@
#ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_
+struct plot_font_style;
+
/**
* Populate a font style using data from a computed CSS style
*
@@ -34,6 +36,6 @@
* \param fstyle Font style to populate
*/
void font_plot_style_from_css(const css_computed_style *css,
- plot_font_style_t *fstyle);
+ struct plot_font_style *fstyle);
#endif
diff --git a/render/form.c b/render/form.c
index 52e54e4..093b11f 100644
--- a/render/form.c
+++ b/render/form.c
@@ -40,17 +40,16 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/ascii.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/misc.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "css/utils.h"
-#include "netsurf/browser_window.h"
-#include "netsurf/mouse.h"
#include "desktop/knockout.h"
-#include "desktop/plot_style.h"
-#include "netsurf/plotters.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/html.h b/render/html.h
index 871eb33..b8429fd 100644
--- a/render/html.h
+++ b/render/html.h
@@ -30,10 +30,10 @@
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "desktop/frame_types.h"
struct fetch_multipart_data;
@@ -52,6 +52,7 @@ struct scrollbar_msg_data;
struct search_context;
struct selection;
struct nsurl;
+struct plot_font_style;
/**
* Container for stylesheets used by an HTML document
@@ -158,7 +159,7 @@ void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
bool text_redraw(const char *utf8_text, size_t utf8_len,
size_t offset, int space,
- const plot_font_style_t *fstyle,
+ const struct plot_font_style *fstyle,
int x, int y,
const struct rect *clip,
int height,
diff --git a/utils/nsoption.c b/utils/nsoption.c
index 9ac4778..8f05a91 100644
--- a/utils/nsoption.c
+++ b/utils/nsoption.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <strings.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/utils.h"
--
NetSurf Browser
6 years, 8 months
netsurf: branch master updated. release/3.6-191-g7dab7cb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7dab7cb43d4091648ceb4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7dab7cb43d4091648ceb406...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7dab7cb43d4091648ceb40684...
The branch, master has been updated
via 7dab7cb43d4091648ceb40684ff70aff7091c648 (commit)
from 8ffc2e753b04a9e794e7a6302d57d590b311e41f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7dab7cb43d4091648ce...
commit 7dab7cb43d4091648ceb40684ff70aff7091c648
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move plot style header to netsurf include directory
move plotter style header and adjust all callers to use only what they
actually require.
diff --git a/Docs/core-window-interface b/Docs/core-window-interface
index 0267f37..3dfbcaf 100644
--- a/Docs/core-window-interface
+++ b/Docs/core-window-interface
@@ -259,7 +259,7 @@ frontends/example/corewindow.c
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
/* extremely likely there will be additional headers required in a real frontend */
#include "example/corewindow.h"
diff --git a/content/handlers/css/select.c b/content/handlers/css/select.c
index aaede77..daa3b40 100644
--- a/content/handlers/css/select.c
+++ b/content/handlers/css/select.c
@@ -24,6 +24,7 @@
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
+#include "netsurf/plot_style.h"
#include "netsurf/url_db.h"
#include "desktop/system_colour.h"
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 64c698b..072a894 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -26,9 +26,10 @@
#include <libwapcaplet/libwapcaplet.h>
+#include "netsurf/types.h"
#include "netsurf/browser_window.h"
+
#include "desktop/frame_types.h"
-#include "desktop/plot_style.h"
struct box;
struct hlcache_handle;
diff --git a/desktop/font_haru.h b/desktop/font_haru.h
index 479f7de..988b9ba 100644
--- a/desktop/font_haru.h
+++ b/desktop/font_haru.h
@@ -26,7 +26,6 @@
#include <hpdf.h>
-#include "desktop/plot_style.h"
#include "desktop/font.h"
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
diff --git a/desktop/knockout.c b/desktop/knockout.c
index b930ef6..bcfc272 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -71,10 +71,10 @@
#include "utils/errors.h"
#include "netsurf/bitmap.h"
#include "content/content.h"
+#include "netsurf/plotters.h"
#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
-#include "netsurf/plotters.h"
/* Define to enable knockout debug */
#undef KNOCKOUT_DEBUG
diff --git a/desktop/options.h b/desktop/options.h
index 437d104..d91898c 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -30,7 +30,7 @@
#ifndef _NETSURF_DESKTOP_OPTIONS_H_
#define _NETSURF_DESKTOP_OPTIONS_H_
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/* defines for system colour table */
#define NSOPTION_SYS_COLOUR_START NSOPTION_sys_colour_ActiveBorder
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index 1e6a911..1f0ac39 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * \file desktop/plot_style.c
+/**
+ * \file
* \brief Plotter global styles.
*
* These plot styles are globaly available and used in many places.
*/
-#include "netsurf/plotters.h"
+#include "netsurf/plot_style.h"
static plot_style_t plot_style_fill_white_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
deleted file mode 100644
index 15327f3..0000000
--- a/desktop/plot_style.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2004 James Bursa <bursa(a)users.sourceforge.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
- * Plotter styles.
- */
-
-#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
-#define _NETSURF_DESKTOP_PLOT_STYLE_H_
-
-#include <stdint.h>
-#include "netsurf/types.h"
-
-/* html widget colours */
-/** light grey widget base colour */
-#define WIDGET_BASEC 0xd9d9d9
-
-/** black blob colour */
-#define WIDGET_BLOBC 0x000000
-
-/**
- * Transparent value
- */
-#define NS_TRANSPARENT 0x01000000
-
-/* Darken a colour by taking three quarters of each channel's intensity */
-#define darken_colour(c1) \
- ((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
- (((3 * (c1 & 0x00ff00)) >> 2) & 0x00ff00))
-
-/* Darken a colour by taking nine sixteenths of each channel's intensity */
-#define double_darken_colour(c1) \
- ((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \
- (((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00))
-
-/* Lighten a colour by taking 12/16ths of each channel's intensity
- * and adding a full 4/16ths intensity */
-#define lighten_colour(c1) \
- (((((3 * (c1 & 0xff00ff)) >> 2) + 0x400040) & 0xff00ff) | \
- ((((3 * (c1 & 0x00ff00)) >> 2) + 0x004000) & 0x00ff00))
-
-/* Lighten a colour by taking 9/16ths of each channel's intensity
- * and adding a full 7/16ths intensity */
-#define double_lighten_colour(c1) \
- (((((9 * (c1 & 0xff00ff)) >> 4) + 0x700070) & 0xff00ff) | \
- ((((9 * (c1 & 0x00ff00)) >> 4) + 0x007000) & 0x00ff00))
-
-/* Blend two colours by taking half the intensity of each channel in the first
- * colour and adding them to half the intensity of each channel in the second
- * colour */
-#define blend_colour(c0, c1) \
- (((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \
- ((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00))
-
-/* Choose either black or white, depending on which is furthest from the
- * percieved lightness of the supplied colour, c0. */
-#define colour_to_bw_furthest(c0) \
- ((((((c0 & 0x0000ff) * 77) >> 8) + \
- (((c0 & 0x00ff00) * 151) >> 16) + \
- (((c0 & 0xff0000) * 28) >> 24)) > \
- (0xff / 2)) ? 0x000000 : 0xffffff)
-
-/* Mix two colours according to the proportion given by p, where 0 <= p <= 255
- * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */
-#define mix_colour(c0, c1, p) \
- ((((((c1 & 0xff00ff) * (255 - p)) + \
- ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
- (((((c1 & 0x00ff00) * (255 - p)) + \
- ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
-
-/* get a bitmap pixel (image/bitmap.h) into a plot colour */
-#define pixel_to_colour(b) \
- b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
-
-/* Get the red channel from a colour */
-#define red_from_colour(c) \
- ((c ) & 0xff)
-
-/* Get the green channel from a colour */
-#define green_from_colour(c) \
- ((c >> 8) & 0xff)
-
-/* Get the blue channel from a colour */
-#define blue_from_colour(c) \
- ((c >> 16) & 0xff)
-
-
-/**
- * Type of plot operation
- */
-typedef enum {
- PLOT_OP_TYPE_NONE = 0, /**< No operation */
- PLOT_OP_TYPE_SOLID, /**< Solid colour */
- PLOT_OP_TYPE_DOT, /**< Dotted plot */
- PLOT_OP_TYPE_DASH, /**< Dashed plot */
-} plot_operation_type_t;
-
-
-/**
- * Plot style for stroke/fill plotters
- */
-typedef struct plot_style_s {
- plot_operation_type_t stroke_type; /**< Stroke plot type */
- int stroke_width; /**< Width of stroke, in pixels */
- colour stroke_colour; /**< Colour of stroke */
- plot_operation_type_t fill_type; /**< Fill plot type */
- colour fill_colour; /**< Colour of fill */
-} plot_style_t;
-
-
-/**
- * Generic font family type
- */
-typedef enum {
- PLOT_FONT_FAMILY_SANS_SERIF = 0,
- PLOT_FONT_FAMILY_SERIF,
- PLOT_FONT_FAMILY_MONOSPACE,
- PLOT_FONT_FAMILY_CURSIVE,
- PLOT_FONT_FAMILY_FANTASY,
- PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
-} plot_font_generic_family_t;
-
-
-/**
- * Font plot flags
- */
-typedef unsigned long plot_font_flags_t;
-#define FONTF_NONE 0
-#define FONTF_ITALIC 1
-#define FONTF_OBLIQUE 2
-#define FONTF_SMALLCAPS 4
-
-
-/**
- * Scaling factor for font sizes
- */
-#define FONT_SIZE_SCALE 1024
-
-
-/**
- * Font style for plotting
- */
-typedef struct plot_font_style {
- plot_font_generic_family_t family; /**< Generic family to plot with */
- int size; /**< Font size, in points * FONT_SIZE_SCALE */
- int weight; /**< Font weight: value in range [100,900] as per CSS */
- plot_font_flags_t flags; /**< Font flags */
- colour background; /**< Background colour to blend to, if appropriate */
- colour foreground; /**< Colour of text */
-} plot_font_style_t;
-
-
-/* global fill styles */
-extern plot_style_t *plot_style_fill_white;
-extern plot_style_t *plot_style_fill_red;
-extern plot_style_t *plot_style_fill_black;
-
-
-/* Box model debug outline styles for content, padding and margin edges */
-extern plot_style_t const * const plot_style_content_edge;
-extern plot_style_t const * const plot_style_padding_edge;
-extern plot_style_t const * const plot_style_margin_edge;
-
-
-/* Broken object replacement styles */
-extern plot_style_t const * const plot_style_broken_object;
-extern plot_font_style_t const * const plot_fstyle_broken_object;
-
-
-/* other styles */
-extern plot_style_t *plot_style_caret;
-extern plot_style_t *plot_style_fill_wbasec;
-extern plot_style_t *plot_style_fill_darkwbasec;
-extern plot_style_t *plot_style_fill_lightwbasec;
-extern plot_style_t *plot_style_fill_wblobc;
-extern plot_style_t *plot_style_stroke_wblobc;
-extern plot_style_t *plot_style_stroke_darkwbasec;
-extern plot_style_t *plot_style_stroke_lightwbasec;
-
-
-/* Default font style */
-extern plot_font_style_t const * const plot_style_font;
-
-
-#endif
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index b9e963a..9a4d70f 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -29,14 +29,12 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
-
#include "netsurf/browser_window.h"
-#include "desktop/system_colour.h"
#include "netsurf/mouse.h"
-#include "desktop/scrollbar.h"
#include "netsurf/plotters.h"
-#include "desktop/plot_style.h"
+#include "desktop/system_colour.h"
+#include "desktop/scrollbar.h"
struct scrollbar {
bool horizontal; /* Horizontal scrollbar if true, else vertical
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index b5d4baa..8e82818 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -26,7 +26,7 @@
#include <libcss/libcss.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/** css callback to obtain named system colours. */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 74652f3..19162ff 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -28,8 +28,7 @@
#include <stdbool.h>
#include "utils/utils.h"
-
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/mouse.h"
struct textarea;
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index d2bfbf9..0ed16d1 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -44,7 +44,7 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include <proto/exec.h>
#include <proto/intuition.h>
diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c
index 6028207..8b535e3 100644
--- a/frontends/atari/plot/font_freetype.c
+++ b/frontends/atari/plot/font_freetype.c
@@ -25,7 +25,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c
index b96f4c7..6a811e3 100644
--- a/frontends/atari/plot/font_internal.c
+++ b/frontends/atari/plot/font_internal.c
@@ -25,7 +25,7 @@
#include "utils/utf8.h"
#include "utils/log.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/fontplot.c b/frontends/atari/plot/fontplot.c
index d0a1fe1..2e02b50 100644
--- a/frontends/atari/plot/fontplot.c
+++ b/frontends/atari/plot/fontplot.c
@@ -22,7 +22,7 @@
#include <mt_gem.h>
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/bitmap.h"
#include "atari/plot/fontplot.h"
diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c
index b6df127..5759a89 100644
--- a/frontends/atari/settings.c
+++ b/frontends/atari/settings.c
@@ -32,7 +32,7 @@
#include "utils/dirent.h"
#include "utils/nsoption.h"
#include "utils/log.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/res/netsurf.rsh"
diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c
index 66bd44b..9ed8784 100644
--- a/frontends/atari/toolbar.c
+++ b/frontends/atari/toolbar.c
@@ -35,7 +35,6 @@
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
-#include "desktop/plot_style.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "desktop/textarea.h"
diff --git a/frontends/beos/font.h b/frontends/beos/font.h
index 63909ef..285ba9c 100644
--- a/frontends/beos/font.h
+++ b/frontends/beos/font.h
@@ -24,7 +24,7 @@
#ifndef NS_BEOS_FONT_H
#define NS_BEOS_FONT_H
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
bool nsfont_paint(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/frontends/cocoa/font.h b/frontends/cocoa/font.h
index cabd2b9..ed04797 100644
--- a/frontends/cocoa/font.h
+++ b/frontends/cocoa/font.h
@@ -19,7 +19,7 @@
#ifndef COCOA_FONT_H
#define COCOA_FONT_H
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t length, const struct plot_font_style *style );
diff --git a/frontends/cocoa/plotter.h b/frontends/cocoa/plotter.h
index 88f9fca..ce48653 100644
--- a/frontends/cocoa/plotter.h
+++ b/frontends/cocoa/plotter.h
@@ -20,7 +20,7 @@
#define COCOA_PLOTTER_H
#import <Cocoa/Cocoa.h>
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
extern const struct plotter_table cocoa_plotters;
diff --git a/frontends/cocoa/plotter.m b/frontends/cocoa/plotter.m
index 20b6884..dea3245 100644
--- a/frontends/cocoa/plotter.m
+++ b/frontends/cocoa/plotter.m
@@ -22,7 +22,6 @@
#import "utils/utils.h"
#import "netsurf/browser_window.h"
#import "netsurf/plotters.h"
-#import "desktop/plot_style.h"
#import "cocoa/font.h"
#import "cocoa/coordinates.h"
diff --git a/frontends/framebuffer/convert_image.c b/frontends/framebuffer/convert_image.c
index 2608328..de772fc 100644
--- a/frontends/framebuffer/convert_image.c
+++ b/frontends/framebuffer/convert_image.c
@@ -262,7 +262,7 @@ main(int argc, char **argv)
fprintf(f, "#include <stdint.h>\n\n");
fprintf(f, "#include <stdbool.h>\n\n");
fprintf(f, "#include <libnsfb.h>\n\n");
- fprintf(f, "#include \"desktop/plot_style.h\"\n");
+ fprintf(f, "#include \"netsurf/plot_style.h\"\n");
fprintf(f, "#include \"framebuffer/gui.h\"\n");
fprintf(f, "#include \"framebuffer/fbtk.h\"\n\n");
diff --git a/frontends/framebuffer/fbtk.h b/frontends/framebuffer/fbtk.h
index fe4f5a5..3cc326c 100644
--- a/frontends/framebuffer/fbtk.h
+++ b/frontends/framebuffer/fbtk.h
@@ -19,7 +19,7 @@
#ifndef NETSURF_FB_FBTK_H
#define NETSURF_FB_FBTK_H
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#ifdef FBTK_LOGGING
#define FBTK_LOG(x) LOG(x)
diff --git a/frontends/framebuffer/fbtk/user.c b/frontends/framebuffer/fbtk/user.c
index 2b9cc87..de547ab 100644
--- a/frontends/framebuffer/fbtk/user.c
+++ b/frontends/framebuffer/fbtk/user.c
@@ -22,7 +22,6 @@
#include <stdbool.h>
#include <libnsfb.h>
-#include "desktop/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c
index 3239820..ccc60ea 100644
--- a/frontends/framebuffer/font_freetype.c
+++ b/frontends/framebuffer/font_freetype.c
@@ -30,6 +30,7 @@
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/browser_window.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c
index 3fd3ac6..3b8a1c4 100644
--- a/frontends/framebuffer/font_internal.c
+++ b/frontends/framebuffer/font_internal.c
@@ -26,6 +26,7 @@
#include "utils/utf8.h"
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c
index 9f66ef1..8af1958 100644
--- a/frontends/gtk/corewindow.c
+++ b/frontends/gtk/corewindow.c
@@ -42,9 +42,9 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/utf8.h"
+#include "netsurf/types.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "gtk/compat.h"
#include "gtk/gui.h" /* just for gtk_gui_gdkkey_to_nskey */
diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c
index a0196df..7c71909 100644
--- a/frontends/gtk/layout_pango.c
+++ b/frontends/gtk/layout_pango.c
@@ -31,6 +31,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "gtk/layout_pango.h"
#include "gtk/plotters.h"
diff --git a/frontends/monkey/layout.c b/frontends/monkey/layout.c
index 00ed9df..4bcc51b 100644
--- a/frontends/monkey/layout.c
+++ b/frontends/monkey/layout.c
@@ -24,7 +24,7 @@
#include <stddef.h>
#include "utils/utf8.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/layout.h"
#include "monkey/layout.h"
diff --git a/frontends/riscos/configure/con_fonts.c b/frontends/riscos/configure/con_fonts.c
index 2803128..ecbf396 100644
--- a/frontends/riscos/configure/con_fonts.c
+++ b/frontends/riscos/configure/con_fonts.c
@@ -21,7 +21,7 @@
#include "utils/nsoption.h"
#include "utils/messages.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c
index a7a394e..560afc7 100644
--- a/frontends/riscos/font.c
+++ b/frontends/riscos/font.c
@@ -35,6 +35,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.h b/frontends/riscos/font.h
index 0319a7e..a29bad8 100644
--- a/frontends/riscos/font.h
+++ b/frontends/riscos/font.h
@@ -25,6 +25,7 @@
#include <rufl.h>
+struct plot_font_style;
struct gui_layout_table *riscos_layout_table;
/** desktop font, size and style being used */
@@ -35,9 +36,9 @@ extern rufl_style ro_gui_desktop_font_style;
void nsfont_init(void);
bool nsfont_exists(const char *font_family);
const char *nsfont_fallback_font(void);
-bool nsfont_paint(const plot_font_style_t *fstyle, const char *string,
+bool nsfont_paint(const struct plot_font_style *fstyle, const char *string,
size_t length, int x, int y);
-void nsfont_read_style(const plot_font_style_t *fstyle,
+void nsfont_read_style(const struct plot_font_style *fstyle,
const char **font_family, unsigned int *font_size,
rufl_style *font_style);
void ro_gui_wimp_get_desktop_font(void);
diff --git a/frontends/riscos/image.h b/frontends/riscos/image.h
index a11388c..2ed3e18 100644
--- a/frontends/riscos/image.h
+++ b/frontends/riscos/image.h
@@ -20,7 +20,7 @@
#define _NETSURF_RISCOS_IMAGE_H_
#include <stdbool.h>
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#include "oslib/osspriteop.h"
struct osspriteop_area;
diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c
index 8d853fb..ff89d92 100644
--- a/frontends/windows/corewindow.c
+++ b/frontends/windows/corewindow.c
@@ -43,7 +43,6 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "windows/windbg.h"
#include "windows/corewindow.h"
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index 1e99a78..791b8cd 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -32,6 +32,7 @@
#include "utils/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/utf8.h"
+#include "netsurf/plot_style.h"
#include "windows/font.h"
diff --git a/frontends/windows/font.h b/frontends/windows/font.h
index 0e86755..a1077e0 100644
--- a/frontends/windows/font.h
+++ b/frontends/windows/font.h
@@ -25,6 +25,8 @@
#ifndef NETSURF_WINDOWS_FONT_H
#define NETSURF_WINDOWS_FONT_H
+struct plot_font_style;
+
extern HWND font_hwnd;
struct font_desc {
@@ -47,7 +49,7 @@ extern nserror utf8_to_font_encoding(const struct font_desc* font,
* \param style The font style.
* \return The win32 font handle
*/
-HFONT get_font(const plot_font_style_t *style);
+HFONT get_font(const struct plot_font_style *style);
#endif /* NETSURF_WINDOWS_FONT_H */
diff --git a/include/netsurf/clipboard.h b/include/netsurf/clipboard.h
index d90ebc4..ab8d10a 100644
--- a/include/netsurf/clipboard.h
+++ b/include/netsurf/clipboard.h
@@ -28,7 +28,7 @@
#include <stddef.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
diff --git a/include/netsurf/content.h b/include/netsurf/content.h
index 35b8b33..5eee59a 100644
--- a/include/netsurf/content.h
+++ b/include/netsurf/content.h
@@ -28,7 +28,7 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "desktop/plot_style.h" /* color typedef */
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
struct bitmap;
diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h
new file mode 100644
index 0000000..30db366
--- /dev/null
+++ b/include/netsurf/plot_style.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2004 James Bursa <bursa(a)users.sourceforge.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
+ * plotter style interfaces, generic styles and style colour helpers.
+ */
+
+#ifndef NETSURF_PLOT_STYLE_H
+#define NETSURF_PLOT_STYLE_H
+
+#include <stdint.h>
+#include "netsurf/types.h"
+
+/** light grey widget base colour */
+#define WIDGET_BASEC 0xd9d9d9
+
+/** black blob colour */
+#define WIDGET_BLOBC 0x000000
+
+/** Transparent colour value. */
+#define NS_TRANSPARENT 0x01000000
+
+/** Scaling factor for font sizes */
+#define FONT_SIZE_SCALE 1024
+
+/**
+ * Type of plot operation
+ */
+typedef enum {
+ PLOT_OP_TYPE_NONE = 0, /**< No operation */
+ PLOT_OP_TYPE_SOLID, /**< Solid colour */
+ PLOT_OP_TYPE_DOT, /**< Dotted plot */
+ PLOT_OP_TYPE_DASH, /**< Dashed plot */
+} plot_operation_type_t;
+
+
+/**
+ * Plot style for stroke/fill plotters
+ */
+typedef struct plot_style_s {
+ plot_operation_type_t stroke_type; /**< Stroke plot type */
+ int stroke_width; /**< Width of stroke, in pixels */
+ colour stroke_colour; /**< Colour of stroke */
+ plot_operation_type_t fill_type; /**< Fill plot type */
+ colour fill_colour; /**< Colour of fill */
+} plot_style_t;
+
+
+/**
+ * Generic font family type
+ */
+typedef enum {
+ PLOT_FONT_FAMILY_SANS_SERIF = 0,
+ PLOT_FONT_FAMILY_SERIF,
+ PLOT_FONT_FAMILY_MONOSPACE,
+ PLOT_FONT_FAMILY_CURSIVE,
+ PLOT_FONT_FAMILY_FANTASY,
+ PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
+} plot_font_generic_family_t;
+
+
+/**
+ * Font plot flags
+ */
+typedef enum {
+ FONTF_NONE = 0,
+ FONTF_ITALIC = 1,
+ FONTF_OBLIQUE = 2,
+ FONTF_SMALLCAPS = 4,
+} plot_font_flags_t;
+
+/**
+ * Font style for plotting
+ */
+typedef struct plot_font_style {
+ plot_font_generic_family_t family; /**< Generic family to plot with */
+ int size; /**< Font size, in points * FONT_SIZE_SCALE */
+ int weight; /**< Font weight: value in range [100,900] as per CSS */
+ plot_font_flags_t flags; /**< Font flags */
+ colour background; /**< Background colour to blend to, if appropriate */
+ colour foreground; /**< Colour of text */
+} plot_font_style_t;
+
+
+/* Darken a colour by taking three quarters of each channel's intensity */
+#define darken_colour(c1) \
+ ((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
+ (((3 * (c1 & 0x00ff00)) >> 2) & 0x00ff00))
+
+/* Darken a colour by taking nine sixteenths of each channel's intensity */
+#define double_darken_colour(c1) \
+ ((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \
+ (((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00))
+
+/* Lighten a colour by taking 12/16ths of each channel's intensity
+ * and adding a full 4/16ths intensity */
+#define lighten_colour(c1) \
+ (((((3 * (c1 & 0xff00ff)) >> 2) + 0x400040) & 0xff00ff) | \
+ ((((3 * (c1 & 0x00ff00)) >> 2) + 0x004000) & 0x00ff00))
+
+/* Lighten a colour by taking 9/16ths of each channel's intensity
+ * and adding a full 7/16ths intensity */
+#define double_lighten_colour(c1) \
+ (((((9 * (c1 & 0xff00ff)) >> 4) + 0x700070) & 0xff00ff) | \
+ ((((9 * (c1 & 0x00ff00)) >> 4) + 0x007000) & 0x00ff00))
+
+/* Blend two colours by taking half the intensity of each channel in the first
+ * colour and adding them to half the intensity of each channel in the second
+ * colour */
+#define blend_colour(c0, c1) \
+ (((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \
+ ((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00))
+
+/* Choose either black or white, depending on which is furthest from the
+ * percieved lightness of the supplied colour, c0. */
+#define colour_to_bw_furthest(c0) \
+ ((((((c0 & 0x0000ff) * 77) >> 8) + \
+ (((c0 & 0x00ff00) * 151) >> 16) + \
+ (((c0 & 0xff0000) * 28) >> 24)) > \
+ (0xff / 2)) ? 0x000000 : 0xffffff)
+
+/* Mix two colours according to the proportion given by p, where 0 <= p <= 255
+ * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */
+#define mix_colour(c0, c1, p) \
+ ((((((c1 & 0xff00ff) * (255 - p)) + \
+ ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
+ (((((c1 & 0x00ff00) * (255 - p)) + \
+ ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
+
+/* get a bitmap pixel (image/bitmap.h) into a plot colour */
+#define pixel_to_colour(b) \
+ b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
+
+/* Get the red channel from a colour */
+#define red_from_colour(c) \
+ ((c ) & 0xff)
+
+/* Get the green channel from a colour */
+#define green_from_colour(c) \
+ ((c >> 8) & 0xff)
+
+/* Get the blue channel from a colour */
+#define blue_from_colour(c) \
+ ((c >> 16) & 0xff)
+
+
+/* global fill styles */
+extern plot_style_t *plot_style_fill_white;
+extern plot_style_t *plot_style_fill_red;
+extern plot_style_t *plot_style_fill_black;
+
+
+/* Box model debug outline styles for content, padding and margin edges */
+extern plot_style_t const * const plot_style_content_edge;
+extern plot_style_t const * const plot_style_padding_edge;
+extern plot_style_t const * const plot_style_margin_edge;
+
+
+/* Broken object replacement styles */
+extern plot_style_t const * const plot_style_broken_object;
+extern plot_font_style_t const * const plot_fstyle_broken_object;
+
+
+/* other styles */
+extern plot_style_t *plot_style_caret;
+extern plot_style_t *plot_style_fill_wbasec;
+extern plot_style_t *plot_style_fill_darkwbasec;
+extern plot_style_t *plot_style_fill_lightwbasec;
+extern plot_style_t *plot_style_fill_wblobc;
+extern plot_style_t *plot_style_stroke_wblobc;
+extern plot_style_t *plot_style_stroke_darkwbasec;
+extern plot_style_t *plot_style_stroke_lightwbasec;
+
+
+/* Default font style */
+extern plot_font_style_t const * const plot_style_font;
+
+
+#endif
diff --git a/include/netsurf/plotters.h b/include/netsurf/plotters.h
index b13c9b2..88cbbe5 100644
--- a/include/netsurf/plotters.h
+++ b/include/netsurf/plotters.h
@@ -27,7 +27,7 @@
#include <stdbool.h>
#include <stdio.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
struct bitmap;
struct rect;
diff --git a/include/netsurf/types.h b/include/netsurf/types.h
index a68013b..27f2e8f 100644
--- a/include/netsurf/types.h
+++ b/include/netsurf/types.h
@@ -27,6 +27,8 @@
#ifndef NETSURF_TYPES_H
#define NETSURF_TYPES_H
+#include <stdint.h>
+
/**
* Colour type: XBGR
*/
diff --git a/render/box_construct.c b/render/box_construct.c
index 4b54a30..d7de68c 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -41,11 +41,12 @@
#include "utils/utils.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "netsurf/css.h"
+#include "netsurf/misc.h"
+#include "netsurf/plot_style.h"
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
-#include "netsurf/css.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/font.c b/render/font.c
index 8128269..94ef877 100644
--- a/render/font.c
+++ b/render/font.c
@@ -23,6 +23,7 @@
*/
#include "utils/nsoption.h"
+#include "netsurf/plot_style.h"
#include "css/utils.h"
#include "render/font.h"
diff --git a/render/font.h b/render/font.h
index e4353df..fba368a 100644
--- a/render/font.h
+++ b/render/font.h
@@ -27,6 +27,8 @@
#ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_
+struct plot_font_style;
+
/**
* Populate a font style using data from a computed CSS style
*
@@ -34,6 +36,6 @@
* \param fstyle Font style to populate
*/
void font_plot_style_from_css(const css_computed_style *css,
- plot_font_style_t *fstyle);
+ struct plot_font_style *fstyle);
#endif
diff --git a/render/form.c b/render/form.c
index 52e54e4..093b11f 100644
--- a/render/form.c
+++ b/render/form.c
@@ -40,17 +40,16 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/ascii.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/misc.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "css/utils.h"
-#include "netsurf/browser_window.h"
-#include "netsurf/mouse.h"
#include "desktop/knockout.h"
-#include "desktop/plot_style.h"
-#include "netsurf/plotters.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/html.h b/render/html.h
index 871eb33..b8429fd 100644
--- a/render/html.h
+++ b/render/html.h
@@ -30,10 +30,10 @@
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "desktop/frame_types.h"
struct fetch_multipart_data;
@@ -52,6 +52,7 @@ struct scrollbar_msg_data;
struct search_context;
struct selection;
struct nsurl;
+struct plot_font_style;
/**
* Container for stylesheets used by an HTML document
@@ -158,7 +159,7 @@ void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
bool text_redraw(const char *utf8_text, size_t utf8_len,
size_t offset, int space,
- const plot_font_style_t *fstyle,
+ const struct plot_font_style *fstyle,
int x, int y,
const struct rect *clip,
int height,
diff --git a/utils/nsoption.c b/utils/nsoption.c
index 9ac4778..8f05a91 100644
--- a/utils/nsoption.c
+++ b/utils/nsoption.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <strings.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/utils.h"
-----------------------------------------------------------------------
Summary of changes:
Docs/core-window-interface | 2 +-
content/handlers/css/select.c | 1 +
desktop/browser_private.h | 3 +-
desktop/font_haru.h | 1 -
desktop/knockout.c | 2 +-
desktop/options.h | 2 +-
desktop/plot_style.c | 6 +-
desktop/scrollbar.c | 6 +-
desktop/system_colour.h | 2 +-
desktop/textarea.h | 3 +-
frontends/amiga/corewindow.c | 2 +-
frontends/atari/plot/font_freetype.c | 2 +-
frontends/atari/plot/font_internal.c | 2 +-
frontends/atari/plot/fontplot.c | 2 +-
frontends/atari/settings.c | 2 +-
frontends/atari/toolbar.c | 1 -
frontends/beos/font.h | 2 +-
frontends/cocoa/font.h | 2 +-
frontends/cocoa/plotter.h | 2 +-
frontends/cocoa/plotter.m | 1 -
frontends/framebuffer/convert_image.c | 2 +-
frontends/framebuffer/fbtk.h | 2 +-
frontends/framebuffer/fbtk/user.c | 1 -
frontends/framebuffer/font_freetype.c | 1 +
frontends/framebuffer/font_internal.c | 1 +
frontends/gtk/corewindow.c | 2 +-
frontends/gtk/layout_pango.c | 1 +
frontends/monkey/layout.c | 2 +-
frontends/riscos/configure/con_fonts.c | 2 +-
frontends/riscos/font.c | 1 +
frontends/riscos/font.h | 5 +-
frontends/riscos/image.h | 2 +-
frontends/windows/corewindow.c | 1 -
frontends/windows/font.c | 1 +
frontends/windows/font.h | 4 +-
include/netsurf/clipboard.h | 2 +-
include/netsurf/content.h | 2 +-
{desktop => include/netsurf}/plot_style.h | 139 ++++++++++++++---------------
include/netsurf/plotters.h | 2 +-
include/netsurf/types.h | 2 +
render/box_construct.c | 5 +-
render/font.c | 1 +
render/font.h | 4 +-
render/form.c | 9 +-
render/html.h | 5 +-
utils/nsoption.c | 2 +-
46 files changed, 125 insertions(+), 122 deletions(-)
rename {desktop => include/netsurf}/plot_style.h (94%)
diff --git a/Docs/core-window-interface b/Docs/core-window-interface
index 0267f37..3dfbcaf 100644
--- a/Docs/core-window-interface
+++ b/Docs/core-window-interface
@@ -259,7 +259,7 @@ frontends/example/corewindow.c
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
/* extremely likely there will be additional headers required in a real frontend */
#include "example/corewindow.h"
diff --git a/content/handlers/css/select.c b/content/handlers/css/select.c
index aaede77..daa3b40 100644
--- a/content/handlers/css/select.c
+++ b/content/handlers/css/select.c
@@ -24,6 +24,7 @@
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
+#include "netsurf/plot_style.h"
#include "netsurf/url_db.h"
#include "desktop/system_colour.h"
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 64c698b..072a894 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -26,9 +26,10 @@
#include <libwapcaplet/libwapcaplet.h>
+#include "netsurf/types.h"
#include "netsurf/browser_window.h"
+
#include "desktop/frame_types.h"
-#include "desktop/plot_style.h"
struct box;
struct hlcache_handle;
diff --git a/desktop/font_haru.h b/desktop/font_haru.h
index 479f7de..988b9ba 100644
--- a/desktop/font_haru.h
+++ b/desktop/font_haru.h
@@ -26,7 +26,6 @@
#include <hpdf.h>
-#include "desktop/plot_style.h"
#include "desktop/font.h"
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
diff --git a/desktop/knockout.c b/desktop/knockout.c
index b930ef6..bcfc272 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -71,10 +71,10 @@
#include "utils/errors.h"
#include "netsurf/bitmap.h"
#include "content/content.h"
+#include "netsurf/plotters.h"
#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
-#include "netsurf/plotters.h"
/* Define to enable knockout debug */
#undef KNOCKOUT_DEBUG
diff --git a/desktop/options.h b/desktop/options.h
index 437d104..d91898c 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -30,7 +30,7 @@
#ifndef _NETSURF_DESKTOP_OPTIONS_H_
#define _NETSURF_DESKTOP_OPTIONS_H_
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/* defines for system colour table */
#define NSOPTION_SYS_COLOUR_START NSOPTION_sys_colour_ActiveBorder
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index 1e6a911..1f0ac39 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * \file desktop/plot_style.c
+/**
+ * \file
* \brief Plotter global styles.
*
* These plot styles are globaly available and used in many places.
*/
-#include "netsurf/plotters.h"
+#include "netsurf/plot_style.h"
static plot_style_t plot_style_fill_white_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index b9e963a..9a4d70f 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -29,14 +29,12 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
-
#include "netsurf/browser_window.h"
-#include "desktop/system_colour.h"
#include "netsurf/mouse.h"
-#include "desktop/scrollbar.h"
#include "netsurf/plotters.h"
-#include "desktop/plot_style.h"
+#include "desktop/system_colour.h"
+#include "desktop/scrollbar.h"
struct scrollbar {
bool horizontal; /* Horizontal scrollbar if true, else vertical
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index b5d4baa..8e82818 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -26,7 +26,7 @@
#include <libcss/libcss.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
/** css callback to obtain named system colours. */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 74652f3..19162ff 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -28,8 +28,7 @@
#include <stdbool.h>
#include "utils/utils.h"
-
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/mouse.h"
struct textarea;
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index d2bfbf9..0ed16d1 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -44,7 +44,7 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include <proto/exec.h>
#include <proto/intuition.h>
diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c
index 6028207..8b535e3 100644
--- a/frontends/atari/plot/font_freetype.c
+++ b/frontends/atari/plot/font_freetype.c
@@ -25,7 +25,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c
index b96f4c7..6a811e3 100644
--- a/frontends/atari/plot/font_internal.c
+++ b/frontends/atari/plot/font_internal.c
@@ -25,7 +25,7 @@
#include "utils/utf8.h"
#include "utils/log.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/fontplot.c b/frontends/atari/plot/fontplot.c
index d0a1fe1..2e02b50 100644
--- a/frontends/atari/plot/fontplot.c
+++ b/frontends/atari/plot/fontplot.c
@@ -22,7 +22,7 @@
#include <mt_gem.h>
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/bitmap.h"
#include "atari/plot/fontplot.h"
diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c
index b6df127..5759a89 100644
--- a/frontends/atari/settings.c
+++ b/frontends/atari/settings.c
@@ -32,7 +32,7 @@
#include "utils/dirent.h"
#include "utils/nsoption.h"
#include "utils/log.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "atari/gui.h"
#include "atari/res/netsurf.rsh"
diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c
index 66bd44b..9ed8784 100644
--- a/frontends/atari/toolbar.c
+++ b/frontends/atari/toolbar.c
@@ -35,7 +35,6 @@
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
-#include "desktop/plot_style.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "desktop/textarea.h"
diff --git a/frontends/beos/font.h b/frontends/beos/font.h
index 63909ef..285ba9c 100644
--- a/frontends/beos/font.h
+++ b/frontends/beos/font.h
@@ -24,7 +24,7 @@
#ifndef NS_BEOS_FONT_H
#define NS_BEOS_FONT_H
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
bool nsfont_paint(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/frontends/cocoa/font.h b/frontends/cocoa/font.h
index cabd2b9..ed04797 100644
--- a/frontends/cocoa/font.h
+++ b/frontends/cocoa/font.h
@@ -19,7 +19,7 @@
#ifndef COCOA_FONT_H
#define COCOA_FONT_H
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t length, const struct plot_font_style *style );
diff --git a/frontends/cocoa/plotter.h b/frontends/cocoa/plotter.h
index 88f9fca..ce48653 100644
--- a/frontends/cocoa/plotter.h
+++ b/frontends/cocoa/plotter.h
@@ -20,7 +20,7 @@
#define COCOA_PLOTTER_H
#import <Cocoa/Cocoa.h>
-#import "desktop/plot_style.h"
+#import "netsurf/plot_style.h"
extern const struct plotter_table cocoa_plotters;
diff --git a/frontends/cocoa/plotter.m b/frontends/cocoa/plotter.m
index 20b6884..dea3245 100644
--- a/frontends/cocoa/plotter.m
+++ b/frontends/cocoa/plotter.m
@@ -22,7 +22,6 @@
#import "utils/utils.h"
#import "netsurf/browser_window.h"
#import "netsurf/plotters.h"
-#import "desktop/plot_style.h"
#import "cocoa/font.h"
#import "cocoa/coordinates.h"
diff --git a/frontends/framebuffer/convert_image.c b/frontends/framebuffer/convert_image.c
index 2608328..de772fc 100644
--- a/frontends/framebuffer/convert_image.c
+++ b/frontends/framebuffer/convert_image.c
@@ -262,7 +262,7 @@ main(int argc, char **argv)
fprintf(f, "#include <stdint.h>\n\n");
fprintf(f, "#include <stdbool.h>\n\n");
fprintf(f, "#include <libnsfb.h>\n\n");
- fprintf(f, "#include \"desktop/plot_style.h\"\n");
+ fprintf(f, "#include \"netsurf/plot_style.h\"\n");
fprintf(f, "#include \"framebuffer/gui.h\"\n");
fprintf(f, "#include \"framebuffer/fbtk.h\"\n\n");
diff --git a/frontends/framebuffer/fbtk.h b/frontends/framebuffer/fbtk.h
index fe4f5a5..3cc326c 100644
--- a/frontends/framebuffer/fbtk.h
+++ b/frontends/framebuffer/fbtk.h
@@ -19,7 +19,7 @@
#ifndef NETSURF_FB_FBTK_H
#define NETSURF_FB_FBTK_H
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#ifdef FBTK_LOGGING
#define FBTK_LOG(x) LOG(x)
diff --git a/frontends/framebuffer/fbtk/user.c b/frontends/framebuffer/fbtk/user.c
index 2b9cc87..de547ab 100644
--- a/frontends/framebuffer/fbtk/user.c
+++ b/frontends/framebuffer/fbtk/user.c
@@ -22,7 +22,6 @@
#include <stdbool.h>
#include <libnsfb.h>
-#include "desktop/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c
index 3239820..ccc60ea 100644
--- a/frontends/framebuffer/font_freetype.c
+++ b/frontends/framebuffer/font_freetype.c
@@ -30,6 +30,7 @@
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/browser_window.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c
index 3fd3ac6..3b8a1c4 100644
--- a/frontends/framebuffer/font_internal.c
+++ b/frontends/framebuffer/font_internal.c
@@ -26,6 +26,7 @@
#include "utils/utf8.h"
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c
index 9f66ef1..8af1958 100644
--- a/frontends/gtk/corewindow.c
+++ b/frontends/gtk/corewindow.c
@@ -42,9 +42,9 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/utf8.h"
+#include "netsurf/types.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "gtk/compat.h"
#include "gtk/gui.h" /* just for gtk_gui_gdkkey_to_nskey */
diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c
index a0196df..7c71909 100644
--- a/frontends/gtk/layout_pango.c
+++ b/frontends/gtk/layout_pango.c
@@ -31,6 +31,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "gtk/layout_pango.h"
#include "gtk/plotters.h"
diff --git a/frontends/monkey/layout.c b/frontends/monkey/layout.c
index 00ed9df..4bcc51b 100644
--- a/frontends/monkey/layout.c
+++ b/frontends/monkey/layout.c
@@ -24,7 +24,7 @@
#include <stddef.h>
#include "utils/utf8.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "netsurf/layout.h"
#include "monkey/layout.h"
diff --git a/frontends/riscos/configure/con_fonts.c b/frontends/riscos/configure/con_fonts.c
index 2803128..ecbf396 100644
--- a/frontends/riscos/configure/con_fonts.c
+++ b/frontends/riscos/configure/con_fonts.c
@@ -21,7 +21,7 @@
#include "utils/nsoption.h"
#include "utils/messages.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c
index a7a394e..560afc7 100644
--- a/frontends/riscos/font.c
+++ b/frontends/riscos/font.c
@@ -35,6 +35,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "netsurf/layout.h"
+#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/frontends/riscos/font.h b/frontends/riscos/font.h
index 0319a7e..a29bad8 100644
--- a/frontends/riscos/font.h
+++ b/frontends/riscos/font.h
@@ -25,6 +25,7 @@
#include <rufl.h>
+struct plot_font_style;
struct gui_layout_table *riscos_layout_table;
/** desktop font, size and style being used */
@@ -35,9 +36,9 @@ extern rufl_style ro_gui_desktop_font_style;
void nsfont_init(void);
bool nsfont_exists(const char *font_family);
const char *nsfont_fallback_font(void);
-bool nsfont_paint(const plot_font_style_t *fstyle, const char *string,
+bool nsfont_paint(const struct plot_font_style *fstyle, const char *string,
size_t length, int x, int y);
-void nsfont_read_style(const plot_font_style_t *fstyle,
+void nsfont_read_style(const struct plot_font_style *fstyle,
const char **font_family, unsigned int *font_size,
rufl_style *font_style);
void ro_gui_wimp_get_desktop_font(void);
diff --git a/frontends/riscos/image.h b/frontends/riscos/image.h
index a11388c..2ed3e18 100644
--- a/frontends/riscos/image.h
+++ b/frontends/riscos/image.h
@@ -20,7 +20,7 @@
#define _NETSURF_RISCOS_IMAGE_H_
#include <stdbool.h>
-#include "desktop/plot_style.h"
+#include "netsurf/types.h"
#include "oslib/osspriteop.h"
struct osspriteop_area;
diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c
index 8d853fb..ff89d92 100644
--- a/frontends/windows/corewindow.c
+++ b/frontends/windows/corewindow.c
@@ -43,7 +43,6 @@
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "windows/windbg.h"
#include "windows/corewindow.h"
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index 1e99a78..791b8cd 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -32,6 +32,7 @@
#include "utils/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/utf8.h"
+#include "netsurf/plot_style.h"
#include "windows/font.h"
diff --git a/frontends/windows/font.h b/frontends/windows/font.h
index 0e86755..a1077e0 100644
--- a/frontends/windows/font.h
+++ b/frontends/windows/font.h
@@ -25,6 +25,8 @@
#ifndef NETSURF_WINDOWS_FONT_H
#define NETSURF_WINDOWS_FONT_H
+struct plot_font_style;
+
extern HWND font_hwnd;
struct font_desc {
@@ -47,7 +49,7 @@ extern nserror utf8_to_font_encoding(const struct font_desc* font,
* \param style The font style.
* \return The win32 font handle
*/
-HFONT get_font(const plot_font_style_t *style);
+HFONT get_font(const struct plot_font_style *style);
#endif /* NETSURF_WINDOWS_FONT_H */
diff --git a/include/netsurf/clipboard.h b/include/netsurf/clipboard.h
index d90ebc4..ab8d10a 100644
--- a/include/netsurf/clipboard.h
+++ b/include/netsurf/clipboard.h
@@ -28,7 +28,7 @@
#include <stddef.h>
#include "utils/errors.h"
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
diff --git a/include/netsurf/content.h b/include/netsurf/content.h
index 35b8b33..5eee59a 100644
--- a/include/netsurf/content.h
+++ b/include/netsurf/content.h
@@ -28,7 +28,7 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "desktop/plot_style.h" /* color typedef */
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
struct bitmap;
diff --git a/desktop/plot_style.h b/include/netsurf/plot_style.h
similarity index 94%
rename from desktop/plot_style.h
rename to include/netsurf/plot_style.h
index 15327f3..30db366 100644
--- a/desktop/plot_style.h
+++ b/include/netsurf/plot_style.h
@@ -16,27 +16,87 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Plotter styles.
+/**
+ * \file
+ * plotter style interfaces, generic styles and style colour helpers.
*/
-#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
-#define _NETSURF_DESKTOP_PLOT_STYLE_H_
+#ifndef NETSURF_PLOT_STYLE_H
+#define NETSURF_PLOT_STYLE_H
#include <stdint.h>
#include "netsurf/types.h"
-/* html widget colours */
/** light grey widget base colour */
#define WIDGET_BASEC 0xd9d9d9
/** black blob colour */
#define WIDGET_BLOBC 0x000000
+/** Transparent colour value. */
+#define NS_TRANSPARENT 0x01000000
+
+/** Scaling factor for font sizes */
+#define FONT_SIZE_SCALE 1024
+
/**
- * Transparent value
+ * Type of plot operation
*/
-#define NS_TRANSPARENT 0x01000000
+typedef enum {
+ PLOT_OP_TYPE_NONE = 0, /**< No operation */
+ PLOT_OP_TYPE_SOLID, /**< Solid colour */
+ PLOT_OP_TYPE_DOT, /**< Dotted plot */
+ PLOT_OP_TYPE_DASH, /**< Dashed plot */
+} plot_operation_type_t;
+
+
+/**
+ * Plot style for stroke/fill plotters
+ */
+typedef struct plot_style_s {
+ plot_operation_type_t stroke_type; /**< Stroke plot type */
+ int stroke_width; /**< Width of stroke, in pixels */
+ colour stroke_colour; /**< Colour of stroke */
+ plot_operation_type_t fill_type; /**< Fill plot type */
+ colour fill_colour; /**< Colour of fill */
+} plot_style_t;
+
+
+/**
+ * Generic font family type
+ */
+typedef enum {
+ PLOT_FONT_FAMILY_SANS_SERIF = 0,
+ PLOT_FONT_FAMILY_SERIF,
+ PLOT_FONT_FAMILY_MONOSPACE,
+ PLOT_FONT_FAMILY_CURSIVE,
+ PLOT_FONT_FAMILY_FANTASY,
+ PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
+} plot_font_generic_family_t;
+
+
+/**
+ * Font plot flags
+ */
+typedef enum {
+ FONTF_NONE = 0,
+ FONTF_ITALIC = 1,
+ FONTF_OBLIQUE = 2,
+ FONTF_SMALLCAPS = 4,
+} plot_font_flags_t;
+
+/**
+ * Font style for plotting
+ */
+typedef struct plot_font_style {
+ plot_font_generic_family_t family; /**< Generic family to plot with */
+ int size; /**< Font size, in points * FONT_SIZE_SCALE */
+ int weight; /**< Font weight: value in range [100,900] as per CSS */
+ plot_font_flags_t flags; /**< Font flags */
+ colour background; /**< Background colour to blend to, if appropriate */
+ colour foreground; /**< Colour of text */
+} plot_font_style_t;
+
/* Darken a colour by taking three quarters of each channel's intensity */
#define darken_colour(c1) \
@@ -100,71 +160,6 @@
((c >> 16) & 0xff)
-/**
- * Type of plot operation
- */
-typedef enum {
- PLOT_OP_TYPE_NONE = 0, /**< No operation */
- PLOT_OP_TYPE_SOLID, /**< Solid colour */
- PLOT_OP_TYPE_DOT, /**< Dotted plot */
- PLOT_OP_TYPE_DASH, /**< Dashed plot */
-} plot_operation_type_t;
-
-
-/**
- * Plot style for stroke/fill plotters
- */
-typedef struct plot_style_s {
- plot_operation_type_t stroke_type; /**< Stroke plot type */
- int stroke_width; /**< Width of stroke, in pixels */
- colour stroke_colour; /**< Colour of stroke */
- plot_operation_type_t fill_type; /**< Fill plot type */
- colour fill_colour; /**< Colour of fill */
-} plot_style_t;
-
-
-/**
- * Generic font family type
- */
-typedef enum {
- PLOT_FONT_FAMILY_SANS_SERIF = 0,
- PLOT_FONT_FAMILY_SERIF,
- PLOT_FONT_FAMILY_MONOSPACE,
- PLOT_FONT_FAMILY_CURSIVE,
- PLOT_FONT_FAMILY_FANTASY,
- PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
-} plot_font_generic_family_t;
-
-
-/**
- * Font plot flags
- */
-typedef unsigned long plot_font_flags_t;
-#define FONTF_NONE 0
-#define FONTF_ITALIC 1
-#define FONTF_OBLIQUE 2
-#define FONTF_SMALLCAPS 4
-
-
-/**
- * Scaling factor for font sizes
- */
-#define FONT_SIZE_SCALE 1024
-
-
-/**
- * Font style for plotting
- */
-typedef struct plot_font_style {
- plot_font_generic_family_t family; /**< Generic family to plot with */
- int size; /**< Font size, in points * FONT_SIZE_SCALE */
- int weight; /**< Font weight: value in range [100,900] as per CSS */
- plot_font_flags_t flags; /**< Font flags */
- colour background; /**< Background colour to blend to, if appropriate */
- colour foreground; /**< Colour of text */
-} plot_font_style_t;
-
-
/* global fill styles */
extern plot_style_t *plot_style_fill_white;
extern plot_style_t *plot_style_fill_red;
diff --git a/include/netsurf/plotters.h b/include/netsurf/plotters.h
index b13c9b2..88cbbe5 100644
--- a/include/netsurf/plotters.h
+++ b/include/netsurf/plotters.h
@@ -27,7 +27,7 @@
#include <stdbool.h>
#include <stdio.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
struct bitmap;
struct rect;
diff --git a/include/netsurf/types.h b/include/netsurf/types.h
index a68013b..27f2e8f 100644
--- a/include/netsurf/types.h
+++ b/include/netsurf/types.h
@@ -27,6 +27,8 @@
#ifndef NETSURF_TYPES_H
#define NETSURF_TYPES_H
+#include <stdint.h>
+
/**
* Colour type: XBGR
*/
diff --git a/render/box_construct.c b/render/box_construct.c
index 4b54a30..d7de68c 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -41,11 +41,12 @@
#include "utils/utils.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "netsurf/css.h"
+#include "netsurf/misc.h"
+#include "netsurf/plot_style.h"
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
-#include "netsurf/css.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/font.c b/render/font.c
index 8128269..94ef877 100644
--- a/render/font.c
+++ b/render/font.c
@@ -23,6 +23,7 @@
*/
#include "utils/nsoption.h"
+#include "netsurf/plot_style.h"
#include "css/utils.h"
#include "render/font.h"
diff --git a/render/font.h b/render/font.h
index e4353df..fba368a 100644
--- a/render/font.h
+++ b/render/font.h
@@ -27,6 +27,8 @@
#ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_
+struct plot_font_style;
+
/**
* Populate a font style using data from a computed CSS style
*
@@ -34,6 +36,6 @@
* \param fstyle Font style to populate
*/
void font_plot_style_from_css(const css_computed_style *css,
- plot_font_style_t *fstyle);
+ struct plot_font_style *fstyle);
#endif
diff --git a/render/form.c b/render/form.c
index 52e54e4..093b11f 100644
--- a/render/form.c
+++ b/render/form.c
@@ -40,17 +40,16 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/ascii.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/misc.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "css/utils.h"
-#include "netsurf/browser_window.h"
-#include "netsurf/mouse.h"
#include "desktop/knockout.h"
-#include "desktop/plot_style.h"
-#include "netsurf/plotters.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
-#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
diff --git a/render/html.h b/render/html.h
index 871eb33..b8429fd 100644
--- a/render/html.h
+++ b/render/html.h
@@ -30,10 +30,10 @@
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
+#include "netsurf/types.h"
#include "netsurf/content_type.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
-#include "desktop/plot_style.h"
#include "desktop/frame_types.h"
struct fetch_multipart_data;
@@ -52,6 +52,7 @@ struct scrollbar_msg_data;
struct search_context;
struct selection;
struct nsurl;
+struct plot_font_style;
/**
* Container for stylesheets used by an HTML document
@@ -158,7 +159,7 @@ void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
bool text_redraw(const char *utf8_text, size_t utf8_len,
size_t offset, int space,
- const plot_font_style_t *fstyle,
+ const struct plot_font_style *fstyle,
int x, int y,
const struct rect *clip,
int height,
diff --git a/utils/nsoption.c b/utils/nsoption.c
index 9ac4778..8f05a91 100644
--- a/utils/nsoption.c
+++ b/utils/nsoption.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <strings.h>
-#include "desktop/plot_style.h"
+#include "netsurf/plot_style.h"
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/utils.h"
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/menuclass updated. release/3.6-189-g0d90231
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0d9023148d2a34bd908aa...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0d9023148d2a34bd908aac3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0d9023148d2a34bd908aac38e...
The branch, chris/menuclass has been updated
via 0d9023148d2a34bd908aac38e44d449359b03438 (commit)
from 439deddba14f509fa0be90beff07481643178b69 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0d9023148d2a34bd908...
commit 0d9023148d2a34bd908aac38e44d449359b03438
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Our hook function needs to be in UserData, not PickHook, for window.class reasons.
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index fc42dc9..97debb6 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -878,7 +878,7 @@ static void ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_da
MA_Label, md[*i]->menulab,
MA_Image, md[*i]->menuicon,
MA_Key, &md[*i]->menukey,
- MA_PickHook, &md[*i]->menu_hook,
+ MA_UserData, &md[*i]->menu_hook, /* NB: Intentionally UserData */
MA_Disabled, (md[*i]->flags & NM_ITEMDISABLED),
MA_Selected, (md[*i]->flags & CHECKED),
MA_Toggle, (md[*i]->flags & MENUTOGGLE),
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/menu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index fc42dc9..97debb6 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -878,7 +878,7 @@ static void ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_da
MA_Label, md[*i]->menulab,
MA_Image, md[*i]->menuicon,
MA_Key, &md[*i]->menukey,
- MA_PickHook, &md[*i]->menu_hook,
+ MA_UserData, &md[*i]->menu_hook, /* NB: Intentionally UserData */
MA_Disabled, (md[*i]->flags & NM_ITEMDISABLED),
MA_Selected, (md[*i]->flags & CHECKED),
MA_Toggle, (md[*i]->flags & MENUTOGGLE),
--
NetSurf Browser
6 years, 8 months
netsurf: branch master updated. release/3.6-190-g8ffc2e7
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8ffc2e753b04a9e794e7a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8ffc2e753b04a9e794e7a63...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8ffc2e753b04a9e794e7a6302...
The branch, master has been updated
via 8ffc2e753b04a9e794e7a6302d57d590b311e41f (commit)
from 74e73a3b8b5ab3effd8e3d94c10463907d4c4ea9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8ffc2e753b04a9e794e...
commit 8ffc2e753b04a9e794e7a6302d57d590b311e41f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Avoid accessing NULL pointer
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 88a875e..c354fef 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -923,7 +923,7 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && md[i+1] && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/menu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 88a875e..c354fef 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -923,7 +923,7 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && md[i+1] && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
--
NetSurf Browser
6 years, 8 months
netsurf: branch master updated. release/3.6-189-g74e73a3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/74e73a3b8b5ab3effd8e3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/74e73a3b8b5ab3effd8e3d9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/74e73a3b8b5ab3effd8e3d94c...
The branch, master has been updated
via 74e73a3b8b5ab3effd8e3d94c10463907d4c4ea9 (commit)
from 9e037376276aaa042b529499f1978766b9535f7b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=74e73a3b8b5ab3effd8...
commit 74e73a3b8b5ab3effd8e3d94c10463907d4c4ea9
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make local history use system colours
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 5cd98cd..d21c5bc 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -37,6 +37,7 @@
#include "content/urldb.h"
#include "netsurf/bitmap.h"
+#include "desktop/system_colour.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
@@ -235,6 +236,45 @@ static void browser_window_history__layout(struct history *history)
history->height += BOTTOM_MARGIN / 2;
}
+/** plot style for drawing lines between nodes */
+static plot_style_t pstyle_line = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 2,
+};
+
+/** plot style for drawing background */
+static plot_style_t pstyle_bg = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+};
+
+/** plot style for drawing rectangle round unselected nodes */
+static plot_style_t pstyle_rect = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+};
+
+/** plot style for drawing rectangle round selected nodes */
+static plot_style_t pstyle_rect_sel = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 3,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 400,
+ .flags = FONTF_NONE,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node_sel = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 900,
+ .flags = FONTF_NONE,
+};
+
/**
* Recursively redraw a history_entry.
*
@@ -260,19 +300,25 @@ browser_window_history__redraw_entry(struct history *history,
size_t char_offset;
int actual_x;
struct history_entry *child;
- colour c = entry == history->current ?
- HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
int tailsize = 5;
int xoffset = x - x0;
int yoffset = y - y0;
- plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 3 : 1,
- };
- plot_font_style_t fstyle = *plot_style_font;
+
+ plot_style_t *pstyle;
+ plot_font_style_t *pfstyle;
+
nserror res;
+ /* setup plot styles */
+ if (entry == history->current) {
+ pstyle = &pstyle_rect_sel;
+ pfstyle = &pfstyle_node_sel;
+ } else {
+ pstyle = &pstyle_rect;
+ pfstyle = &pfstyle_node;
+ }
+
+ /* setup clip area */
if (clip) {
struct rect rect;
rect.x0 = x0 + xoffset;
@@ -289,14 +335,16 @@ browser_window_history__redraw_entry(struct history *history,
plot->bitmap(entry->x + xoffset,
entry->y + yoffset,
WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0);
+ entry->bitmap,
+ 0xffffff,
+ 0);
}
if (!plot->rectangle(entry->x - 1 + xoffset,
- entry->y - 1 + yoffset,
- entry->x + xoffset + WIDTH,
- entry->y + yoffset + HEIGHT,
- &pstyle_history_rect)) {
+ entry->y - 1 + yoffset,
+ entry->x + xoffset + WIDTH,
+ entry->y + yoffset + HEIGHT,
+ pstyle)) {
return false;
}
@@ -307,36 +355,42 @@ browser_window_history__redraw_entry(struct history *history,
return false;
}
- fstyle.background = HISTORY_COLOUR_BACKGROUND;
- fstyle.foreground = c;
- fstyle.weight = entry == history->current ? 900 : 400;
- if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
- entry->page.title, char_offset, &fstyle))
+ if (!plot->text(entry->x + xoffset,
+ entry->y + HEIGHT + 12 + yoffset,
+ entry->page.title,
+ char_offset,
+ pfstyle)) {
return false;
+ }
+ /* for each child node draw a line and recurse redraw into it */
for (child = entry->forward; child; child = child->next) {
if (!plot->line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
- entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y +
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y +
HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ &pstyle_line)) {
return false;
+ }
if (!browser_window_history__redraw_entry(history, child,
- x0, y0, x1, y1, x, y, clip, ctx))
+ x0, y0, x1, y1, x, y, clip, ctx)) {
return false;
+ }
}
return true;
@@ -415,6 +469,17 @@ nserror browser_window_history_create(struct browser_window *bw)
{
struct history *history;
+ pstyle_bg.fill_colour = ns_system_colour_char("Window");
+ pfstyle_node.background = pstyle_bg.fill_colour;
+ pfstyle_node_sel.background = pstyle_bg.fill_colour;
+
+ pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
+ pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
+ pfstyle_node.foreground = pstyle_line.stroke_colour;
+
+ pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
+ pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+
bw->history = NULL;
history = calloc(1, sizeof *history);
@@ -426,6 +491,7 @@ nserror browser_window_history_create(struct browser_window *bw)
history->height = BOTTOM_MARGIN / 2;
bw->history = history;
+
return NSERROR_OK;
}
@@ -709,6 +775,7 @@ bool browser_window_history_redraw(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
0, 0, 0, 0, 0, 0, false, ctx);
}
@@ -726,6 +793,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
x0, y0, x1, y1, x, y, true, ctx);
}
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index f9ba4bc..1e6a911 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -152,15 +152,6 @@ static plot_style_t plot_style_stroke_lightwbasec_static = {
};
plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
-/* history styles */
-
-/** stroke style for history core. */
-static plot_style_t plot_style_stroke_history_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = HISTORY_COLOUR_LINES,
- .stroke_width = 2,
-};
-plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static;
/* Generic font style */
static const plot_font_style_t plot_style_font_static = {
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index 347c6e8..15327f3 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -24,11 +24,20 @@
#define _NETSURF_DESKTOP_PLOT_STYLE_H_
#include <stdint.h>
+#include "netsurf/types.h"
/* html widget colours */
+/** light grey widget base colour */
#define WIDGET_BASEC 0xd9d9d9
+
+/** black blob colour */
#define WIDGET_BLOBC 0x000000
+/**
+ * Transparent value
+ */
+#define NS_TRANSPARENT 0x01000000
+
/* Darken a colour by taking three quarters of each channel's intensity */
#define darken_colour(c1) \
((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
@@ -90,15 +99,6 @@
#define blue_from_colour(c) \
((c >> 16) & 0xff)
-/**
- * Colour type: XBGR
- */
-typedef uint32_t colour;
-
-/**
- * Magical transparent value
- */
-#define NS_TRANSPARENT 0x01000000
/**
* Type of plot operation
@@ -110,6 +110,7 @@ typedef enum {
PLOT_OP_TYPE_DASH, /**< Dashed plot */
} plot_operation_type_t;
+
/**
* Plot style for stroke/fill plotters
*/
@@ -121,6 +122,7 @@ typedef struct plot_style_s {
colour fill_colour; /**< Colour of fill */
} plot_style_t;
+
/**
* Generic font family type
*/
@@ -133,6 +135,7 @@ typedef enum {
PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
} plot_font_generic_family_t;
+
/**
* Font plot flags
*/
@@ -142,11 +145,13 @@ typedef unsigned long plot_font_flags_t;
#define FONTF_OBLIQUE 2
#define FONTF_SMALLCAPS 4
+
/**
* Scaling factor for font sizes
*/
#define FONT_SIZE_SCALE 1024
+
/**
* Font style for plotting
*/
@@ -159,16 +164,19 @@ typedef struct plot_font_style {
colour foreground; /**< Colour of text */
} plot_font_style_t;
+
/* global fill styles */
extern plot_style_t *plot_style_fill_white;
extern plot_style_t *plot_style_fill_red;
extern plot_style_t *plot_style_fill_black;
+
/* Box model debug outline styles for content, padding and margin edges */
extern plot_style_t const * const plot_style_content_edge;
extern plot_style_t const * const plot_style_padding_edge;
extern plot_style_t const * const plot_style_margin_edge;
+
/* Broken object replacement styles */
extern plot_style_t const * const plot_style_broken_object;
extern plot_font_style_t const * const plot_fstyle_broken_object;
@@ -176,7 +184,6 @@ extern plot_font_style_t const * const plot_fstyle_broken_object;
/* other styles */
extern plot_style_t *plot_style_caret;
-extern plot_style_t *plot_style_stroke_history;
extern plot_style_t *plot_style_fill_wbasec;
extern plot_style_t *plot_style_fill_darkwbasec;
extern plot_style_t *plot_style_fill_lightwbasec;
@@ -185,23 +192,9 @@ extern plot_style_t *plot_style_stroke_wblobc;
extern plot_style_t *plot_style_stroke_darkwbasec;
extern plot_style_t *plot_style_stroke_lightwbasec;
+
/* Default font style */
extern plot_font_style_t const * const plot_style_font;
-#ifndef HISTORY_COLOUR_SELECTED
-#define HISTORY_COLOUR_SELECTED 0xFF0000
-#endif
-
-#ifndef HISTORY_COLOUR_FOREGROUND
-#define HISTORY_COLOUR_FOREGROUND 0x333333
-#endif
-
-#ifndef HISTORY_COLOUR_BACKGROUND
-#define HISTORY_COLOUR_BACKGROUND 0xFFFFFF
-#endif
-
-#ifndef HISTORY_COLOUR_LINES
-#define HISTORY_COLOUR_LINES HISTORY_COLOUR_FOREGROUND
-#endif
#endif
diff --git a/include/netsurf/types.h b/include/netsurf/types.h
new file mode 100644
index 0000000..a68013b
--- /dev/null
+++ b/include/netsurf/types.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Vincent Sanders <vince(a)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
+ *
+ * NetSurf types.
+ *
+ * These are convenience types used throughout the browser.
+ */
+
+#ifndef NETSURF_TYPES_H
+#define NETSURF_TYPES_H
+
+/**
+ * Colour type: XBGR
+ */
+typedef uint32_t colour;
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_history.c | 126 +++++++++++++++-----
desktop/plot_style.c | 9 --
desktop/plot_style.h | 43 +++----
.../windows/file.h => include/netsurf/types.h | 18 ++-
4 files changed, 127 insertions(+), 69 deletions(-)
copy frontends/windows/file.h => include/netsurf/types.h (72%)
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 5cd98cd..d21c5bc 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -37,6 +37,7 @@
#include "content/urldb.h"
#include "netsurf/bitmap.h"
+#include "desktop/system_colour.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
@@ -235,6 +236,45 @@ static void browser_window_history__layout(struct history *history)
history->height += BOTTOM_MARGIN / 2;
}
+/** plot style for drawing lines between nodes */
+static plot_style_t pstyle_line = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 2,
+};
+
+/** plot style for drawing background */
+static plot_style_t pstyle_bg = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+};
+
+/** plot style for drawing rectangle round unselected nodes */
+static plot_style_t pstyle_rect = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+};
+
+/** plot style for drawing rectangle round selected nodes */
+static plot_style_t pstyle_rect_sel = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 3,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 400,
+ .flags = FONTF_NONE,
+};
+
+/** plot style for font on unselected nodes */
+static plot_font_style_t pfstyle_node_sel = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 8 * FONT_SIZE_SCALE,
+ .weight = 900,
+ .flags = FONTF_NONE,
+};
+
/**
* Recursively redraw a history_entry.
*
@@ -260,19 +300,25 @@ browser_window_history__redraw_entry(struct history *history,
size_t char_offset;
int actual_x;
struct history_entry *child;
- colour c = entry == history->current ?
- HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
int tailsize = 5;
int xoffset = x - x0;
int yoffset = y - y0;
- plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 3 : 1,
- };
- plot_font_style_t fstyle = *plot_style_font;
+
+ plot_style_t *pstyle;
+ plot_font_style_t *pfstyle;
+
nserror res;
+ /* setup plot styles */
+ if (entry == history->current) {
+ pstyle = &pstyle_rect_sel;
+ pfstyle = &pfstyle_node_sel;
+ } else {
+ pstyle = &pstyle_rect;
+ pfstyle = &pfstyle_node;
+ }
+
+ /* setup clip area */
if (clip) {
struct rect rect;
rect.x0 = x0 + xoffset;
@@ -289,14 +335,16 @@ browser_window_history__redraw_entry(struct history *history,
plot->bitmap(entry->x + xoffset,
entry->y + yoffset,
WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0);
+ entry->bitmap,
+ 0xffffff,
+ 0);
}
if (!plot->rectangle(entry->x - 1 + xoffset,
- entry->y - 1 + yoffset,
- entry->x + xoffset + WIDTH,
- entry->y + yoffset + HEIGHT,
- &pstyle_history_rect)) {
+ entry->y - 1 + yoffset,
+ entry->x + xoffset + WIDTH,
+ entry->y + yoffset + HEIGHT,
+ pstyle)) {
return false;
}
@@ -307,36 +355,42 @@ browser_window_history__redraw_entry(struct history *history,
return false;
}
- fstyle.background = HISTORY_COLOUR_BACKGROUND;
- fstyle.foreground = c;
- fstyle.weight = entry == history->current ? 900 : 400;
- if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
- entry->page.title, char_offset, &fstyle))
+ if (!plot->text(entry->x + xoffset,
+ entry->y + HEIGHT + 12 + yoffset,
+ entry->page.title,
+ char_offset,
+ pfstyle)) {
return false;
+ }
+ /* for each child node draw a line and recurse redraw into it */
for (child = entry->forward; child; child = child->next) {
if (!plot->line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
- entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ &pstyle_line)) {
return false;
+ }
if (!plot->line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y +
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y +
HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
+ &pstyle_line)) {
return false;
+ }
if (!browser_window_history__redraw_entry(history, child,
- x0, y0, x1, y1, x, y, clip, ctx))
+ x0, y0, x1, y1, x, y, clip, ctx)) {
return false;
+ }
}
return true;
@@ -415,6 +469,17 @@ nserror browser_window_history_create(struct browser_window *bw)
{
struct history *history;
+ pstyle_bg.fill_colour = ns_system_colour_char("Window");
+ pfstyle_node.background = pstyle_bg.fill_colour;
+ pfstyle_node_sel.background = pstyle_bg.fill_colour;
+
+ pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
+ pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
+ pfstyle_node.foreground = pstyle_line.stroke_colour;
+
+ pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
+ pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+
bw->history = NULL;
history = calloc(1, sizeof *history);
@@ -426,6 +491,7 @@ nserror browser_window_history_create(struct browser_window *bw)
history->height = BOTTOM_MARGIN / 2;
bw->history = history;
+
return NSERROR_OK;
}
@@ -709,6 +775,7 @@ bool browser_window_history_redraw(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
0, 0, 0, 0, 0, 0, false, ctx);
}
@@ -726,6 +793,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw,
if (!history->start)
return true;
+
return browser_window_history__redraw_entry(history, history->start,
x0, y0, x1, y1, x, y, true, ctx);
}
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index f9ba4bc..1e6a911 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -152,15 +152,6 @@ static plot_style_t plot_style_stroke_lightwbasec_static = {
};
plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
-/* history styles */
-
-/** stroke style for history core. */
-static plot_style_t plot_style_stroke_history_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = HISTORY_COLOUR_LINES,
- .stroke_width = 2,
-};
-plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static;
/* Generic font style */
static const plot_font_style_t plot_style_font_static = {
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index 347c6e8..15327f3 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -24,11 +24,20 @@
#define _NETSURF_DESKTOP_PLOT_STYLE_H_
#include <stdint.h>
+#include "netsurf/types.h"
/* html widget colours */
+/** light grey widget base colour */
#define WIDGET_BASEC 0xd9d9d9
+
+/** black blob colour */
#define WIDGET_BLOBC 0x000000
+/**
+ * Transparent value
+ */
+#define NS_TRANSPARENT 0x01000000
+
/* Darken a colour by taking three quarters of each channel's intensity */
#define darken_colour(c1) \
((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
@@ -90,15 +99,6 @@
#define blue_from_colour(c) \
((c >> 16) & 0xff)
-/**
- * Colour type: XBGR
- */
-typedef uint32_t colour;
-
-/**
- * Magical transparent value
- */
-#define NS_TRANSPARENT 0x01000000
/**
* Type of plot operation
@@ -110,6 +110,7 @@ typedef enum {
PLOT_OP_TYPE_DASH, /**< Dashed plot */
} plot_operation_type_t;
+
/**
* Plot style for stroke/fill plotters
*/
@@ -121,6 +122,7 @@ typedef struct plot_style_s {
colour fill_colour; /**< Colour of fill */
} plot_style_t;
+
/**
* Generic font family type
*/
@@ -133,6 +135,7 @@ typedef enum {
PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
} plot_font_generic_family_t;
+
/**
* Font plot flags
*/
@@ -142,11 +145,13 @@ typedef unsigned long plot_font_flags_t;
#define FONTF_OBLIQUE 2
#define FONTF_SMALLCAPS 4
+
/**
* Scaling factor for font sizes
*/
#define FONT_SIZE_SCALE 1024
+
/**
* Font style for plotting
*/
@@ -159,16 +164,19 @@ typedef struct plot_font_style {
colour foreground; /**< Colour of text */
} plot_font_style_t;
+
/* global fill styles */
extern plot_style_t *plot_style_fill_white;
extern plot_style_t *plot_style_fill_red;
extern plot_style_t *plot_style_fill_black;
+
/* Box model debug outline styles for content, padding and margin edges */
extern plot_style_t const * const plot_style_content_edge;
extern plot_style_t const * const plot_style_padding_edge;
extern plot_style_t const * const plot_style_margin_edge;
+
/* Broken object replacement styles */
extern plot_style_t const * const plot_style_broken_object;
extern plot_font_style_t const * const plot_fstyle_broken_object;
@@ -176,7 +184,6 @@ extern plot_font_style_t const * const plot_fstyle_broken_object;
/* other styles */
extern plot_style_t *plot_style_caret;
-extern plot_style_t *plot_style_stroke_history;
extern plot_style_t *plot_style_fill_wbasec;
extern plot_style_t *plot_style_fill_darkwbasec;
extern plot_style_t *plot_style_fill_lightwbasec;
@@ -185,23 +192,9 @@ extern plot_style_t *plot_style_stroke_wblobc;
extern plot_style_t *plot_style_stroke_darkwbasec;
extern plot_style_t *plot_style_stroke_lightwbasec;
+
/* Default font style */
extern plot_font_style_t const * const plot_style_font;
-#ifndef HISTORY_COLOUR_SELECTED
-#define HISTORY_COLOUR_SELECTED 0xFF0000
-#endif
-
-#ifndef HISTORY_COLOUR_FOREGROUND
-#define HISTORY_COLOUR_FOREGROUND 0x333333
-#endif
-
-#ifndef HISTORY_COLOUR_BACKGROUND
-#define HISTORY_COLOUR_BACKGROUND 0xFFFFFF
-#endif
-
-#ifndef HISTORY_COLOUR_LINES
-#define HISTORY_COLOUR_LINES HISTORY_COLOUR_FOREGROUND
-#endif
#endif
diff --git a/frontends/windows/file.h b/include/netsurf/types.h
similarity index 72%
copy from frontends/windows/file.h
copy to include/netsurf/types.h
index 5262dde..a68013b 100644
--- a/frontends/windows/file.h
+++ b/include/netsurf/types.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ * Copyright 2017 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,12 +18,18 @@
/**
* \file
- * Windows file operation table interface.
+ *
+ * NetSurf types.
+ *
+ * These are convenience types used throughout the browser.
*/
-#ifndef _NETSURF_WINDOWS_FILE_H_
-#define _NETSURF_WINDOWS_FILE_H_
+#ifndef NETSURF_TYPES_H
+#define NETSURF_TYPES_H
-struct gui_file_table *win32_file_table;
+/**
+ * Colour type: XBGR
+ */
+typedef uint32_t colour;
-#endif
+#endif
--
NetSurf Browser
6 years, 8 months