netsurf: branch master updated. release/3.6-169-g047b37d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/047b37d5f8c3810f8942f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/047b37d5f8c3810f8942f57...
...tree http://git.netsurf-browser.org/netsurf.git/tree/047b37d5f8c3810f8942f5744...
The branch, master has been updated
via 047b37d5f8c3810f8942f5744bb92640fbd4879f (commit)
via 5687f6c27d40ec596b4d64c705d16a97bdb3c893 (commit)
via e98a05bb087fb5c2c2ee8d94b3011ae8b3aa5c7a (commit)
via 6e957396a9bdc78a7d9823aaf76764bbb30c184a (commit)
via d6f6326ce9b6e60fcf9865e726b718ccfbbbea65 (commit)
via 26b98ac51b2f5a7c3d35050fcf79f521bfdb05f8 (commit)
via 57a2bb85992844b644433142e687940b3870ce40 (commit)
via 2e11f7f3cbd7d563cb525a26ce79d76502ba7686 (commit)
via 5eb7ee97ed641e152c488dab6c33c37d0635e48b (commit)
from 695783e33b9c100b1ce28ef71a59a00f52cc374f (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=047b37d5f8c3810f894...
commit 047b37d5f8c3810f8942f5744bb92640fbd4879f
Merge: 695783e 5687f6c
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Merge branch 'chris/amiga-corewindow'
Amiga cookie and SSL cert windows now migrated to corewindow
-----------------------------------------------------------------------
Summary of changes:
desktop/cookie_manager.c | 1 +
frontends/amiga/cookies.c | 373 ++++++++++++++++++++++++++++++++++++++++--
frontends/amiga/cookies.h | 11 +-
frontends/amiga/corewindow.c | 59 ++++---
frontends/amiga/corewindow.h | 4 +
frontends/amiga/gui.c | 13 +-
frontends/amiga/menu.c | 11 +-
frontends/amiga/menu.h | 22 ++-
frontends/amiga/sslcert.c | 2 +-
9 files changed, 440 insertions(+), 56 deletions(-)
mode change 100755 => 100644 frontends/amiga/cookies.c
mode change 100755 => 100644 frontends/amiga/cookies.h
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 6134fa5..5429f68 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -843,6 +843,7 @@ nserror cookie_manager_fini(void)
/* Destroy the cookie manager treeview */
err = treeview_destroy(cm_ctx.tree);
+ cm_ctx.tree = NULL;
/* Free cookie manager treeview entry fields */
for (i = 0; i < COOKIE_M_N_FIELDS; i++)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
old mode 100755
new mode 100644
index 15f6dce..18ca425
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -16,26 +16,375 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <proto/exec.h>
+/**
+ * \file
+ * Implementation of Amiga cookie viewer using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/space.h>
+
+#include <reaction/reaction_macros.h>
#include "desktop/cookie_manager.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
#include "amiga/cookies.h"
-#include "amiga/tree.h"
+#include "amiga/corewindow.h"
+#include "amiga/libs.h"
+#include "amiga/utf8.h"
+
+enum {
+ /* Project menu */
+ AMI_COOKIE_M_PROJECT = 0,
+ AMI_COOKIE_M_EXPAND,
+ AMI_COOKIE_M_EXPAND_ALL,
+ AMI_COOKIE_M_EXPAND_DOMAINS,
+ AMI_COOKIE_M_EXPAND_COOKIES,
+ AMI_COOKIE_M_COLLAPSE,
+ AMI_COOKIE_M_COLLAPSE_ALL,
+ AMI_COOKIE_M_COLLAPSE_DOMAINS,
+ AMI_COOKIE_M_COLLAPSE_COOKIES,
+ AMI_COOKIE_M_BAR_P1,
+ AMI_COOKIE_M_SNAPSHOT,
+ AMI_COOKIE_M_BAR_P2,
+ AMI_COOKIE_M_CLOSE,
+ /* Edit menu */
+ AMI_COOKIE_M_EDIT,
+ AMI_COOKIE_M_SELECTALL,
+ AMI_COOKIE_M_CLEAR,
+ AMI_COOKIE_M_BAR_E1,
+ AMI_COOKIE_M_DELETE,
+ AMI_COOKIE_M_LAST
+};
+
+/**
+ * Amiga cookie viewer window context
+ */
+struct ami_cookie_window {
+ /** Amiga core window context */
+ struct ami_corewindow core;
+
+ struct ami_menu_data *menu_data[AMI_COOKIE_M_LAST + 1];
+ struct Menu *imenu; /* Intuition menu */
+};
+
+static struct ami_cookie_window *cookie_window = NULL;
+
+
+static void
+ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
+{
+ SetAttrs(cookie_win->core.objects[GID_CW_WIN],
+ WINDOW_MenuStrip, NULL,
+ TAG_DONE);
+
+ ami_menu_free_menu(cookie_win->menu_data, AMI_COOKIE_M_LAST, cookie_win->imenu);
+}
+
+/**
+ * destroy a previously created cookie view
+ */
+static void
+ami_cookies_destroy(struct ami_corewindow *ami_cw)
+{
+ nserror res;
+
+ if(cookie_window == NULL)
+ return;
+
+ res = cookie_manager_fini();
+ if (res == NSERROR_OK) {
+ ami_cookies_menu_free(cookie_window);
+ res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us, frees cookie_win */
+ cookie_window = NULL;
+ }
+}
+
+
+/**
+ * callback for mouse action for cookie viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_mouse(struct ami_corewindow *ami_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ cookie_manager_mouse_action(mouse_state, x, y);
+
+ return NSERROR_OK;
+}
+
+/**
+ * callback for keypress for cookies viewer on core window
+ *
+ * \param example_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_key(struct ami_corewindow *ami_cw, uint32_t nskey)
+{
+ if (cookie_manager_keypress(nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback on draw event for cookies viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx The drawing context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+ cookie_manager_redraw(x, y, r, ctx);
-struct treeview_window *cookies_window;
+ return NSERROR_OK;
+}
+
+/**
+ * menu stuff
+ */
+
+ /* menu hook functions */
+
+HOOKF(void, ami_cookies_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_expand_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(true);
+}
-void ami_cookies_initialise(void)
+HOOKF(void, ami_cookies_menu_item_project_expand_cookies, APTR, window, struct IntuiMessage *)
{
- cookies_window = ami_tree_create(TREE_COOKIES, NULL);
+ cookie_manager_expand(false);
+}
- if(!cookies_window) return;
+HOOKF(void, ami_cookies_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_collapse_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
}
-void ami_cookies_free()
+HOOKF(void, ami_cookies_menu_item_project_collapse_cookies, APTR, window, struct IntuiMessage *)
{
- ami_tree_destroy(cookies_window);
- cookies_window = NULL;
+ cookie_manager_contract(false);
}
+
+HOOKF(void, ami_cookies_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ nsoption_set_int(cookies_window_ypos, ami_cw->win->TopEdge);
+ nsoption_set_int(cookies_window_xpos, ami_cw->win->LeftEdge);
+ nsoption_set_int(cookies_window_xsize, ami_cw->win->Width);
+ nsoption_set_int(cookies_window_ysize, ami_cw->win->Height);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_close, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ ami_cw->close_window = true;
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_SELECT_ALL);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_DELETE_LEFT);
+}
+
+
+/* menu setup */
+
+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_cookies_menu_item_project_expand_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, 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_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_cookies_menu_item_project_collapse_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, 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_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_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", 0, "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_cookies_menu_item_edit_select_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, 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_cookies_menu_item_edit_delete, NULL, 0);
+
+ ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+}
+
+static struct Menu *
+ami_cookies_menu_create(struct ami_cookie_window *cookie_win)
+{
+ ami_cookies_menulabs(cookie_win->menu_data);
+ cookie_win->imenu = ami_menu_layout(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+ if(cookie_win->imenu == NULL) return NULL;
+
+ return cookie_win->imenu;
+}
+
+
+static nserror
+ami_cookies_create_window(struct ami_cookie_window *cookie_win)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)&cookie_win->core;
+
+ ami_cw->objects[GID_CW_WIN] = WindowObj,
+ WA_ScreenTitle, ami_gui_get_screen_title(),
+ WA_Title, ami_cw->wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
+ WA_SizeBRight, TRUE,
+ WA_Top, nsoption_int(cookies_window_ypos),
+ WA_Left, nsoption_int(cookies_window_xpos),
+ WA_Width, nsoption_int(cookies_window_xsize),
+ WA_Height, nsoption_int(cookies_window_ysize),
+ WA_PubScreen, scrn,
+ WA_ReportMouse, TRUE,
+ WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort, sport,
+ WINDOW_HorizProp, 1,
+ WINDOW_VertProp, 1,
+ WINDOW_UserData, cookie_win,
+ WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
+ WINDOW_MenuUserData, WGUD_HOOK,
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ EndGroup,
+ EndWindow;
+
+ if(ami_cw->objects[GID_CW_WIN] == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in amiga/cookies.h */
+nserror ami_cookies_present(void)
+{
+ struct ami_cookie_window *ncwin;
+ nserror res;
+
+ if(cookie_window != NULL) {
+ //windowtofront()
+ return NSERROR_OK;
+ }
+
+ ncwin = calloc(1, sizeof(struct ami_cookie_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Cookies"));
+
+ res = ami_cookies_create_window(ncwin);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ ami_utf8_free(ncwin->core.wintitle);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise Amiga core window */
+ ncwin->core.draw = ami_cookies_draw;
+ ncwin->core.key = ami_cookies_key;
+ ncwin->core.mouse = ami_cookies_mouse;
+ ncwin->core.close = ami_cookies_destroy;
+ ncwin->core.event = NULL;
+
+ res = ami_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ res = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ cookie_window = ncwin;
+
+ return NSERROR_OK;
+}
+
diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h
old mode 100755
new mode 100644
index 157091d..6858e4c
--- a/frontends/amiga/cookies.h
+++ b/frontends/amiga/cookies.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -18,11 +18,8 @@
#ifndef AMIGA_COOKIES_H
#define AMIGA_COOKIES_H
-#include "amiga/desktop-tree.h"
-#include "amiga/tree.h"
-void ami_cookies_initialise(void);
-void ami_cookies_free(void);
-
-extern struct treeview_window *cookies_window;
+/** Open the cookie viewer */
+nserror ami_cookies_present(void);
#endif
+
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 38b980a..1bfc537 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -34,6 +34,7 @@
#include "amiga/os3support.h"
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -103,6 +104,17 @@ ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *re
*y = *y + ys;
}
+/**
+ * check if mouse has moved since position was stored
+ * @return true if it has, false otherwise
+ */
+static bool
+ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y)
+{
+ if(abs(x - ami_cw->mouse_x_click) > 5) return true;
+ if(abs(y - ami_cw->mouse_y_click) > 5) return true;
+ return false;
+}
/* get current mouse position in the draw area, adjusted for scroll.
* @return true if the mouse was in the draw area and co-ordinates updated
@@ -391,18 +403,14 @@ ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
}
}
-#if 0
- /* in-window scrollbars aren't getting hidden until the window is resized
- * this code should fix it, but it isn't working */
if(ami_cw->in_border_scroll == false) {
FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
ami_cw->win, NULL, TRUE);
-
- /* probably need to redraw here */
- ami_cw_redraw(ami_cw, NULL);
}
-#endif
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
}
static void
@@ -464,6 +472,11 @@ ami_cw_event(void *w)
int x = 0, y = 0;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
+ if(ami_cw->close_window == true) {
+ ami_cw_close(ami_cw);
+ return TRUE;
+ }
+
switch(result & WMHI_CLASSMASK) {
case WMHI_MOUSEMOVE:
if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
@@ -494,12 +507,16 @@ ami_cw_event(void *w)
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
if(ami_cw->lastclick.tv_sec) {
- if(DoubleClick(ami_cw->lastclick.tv_sec,
+ if((ami_cw_mouse_moved(ami_cw, x, y) == false) &&
+ (DoubleClick(ami_cw->lastclick.tv_sec,
ami_cw->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec))
+ curtime.tv_sec, curtime.tv_usec)))
ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
+ ami_cw->mouse_x_click = x;
+ ami_cw->mouse_y_click = y;
+
if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
ami_cw->lastclick.tv_sec = 0;
ami_cw->lastclick.tv_usec = 0;
@@ -616,28 +633,22 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
if(width == -1) {
ami_cw_toggle_scrollbar(ami_cw, false, false);
- return;
+ } else {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)width,
+ SCROLLER_Visible, win_w,
+ TAG_DONE);
}
if(height == -1) {
ami_cw_toggle_scrollbar(ami_cw, true, false);
- return;
- }
-
- if(ami_cw->objects[GID_CW_VSCROLL]) {
+ } else {
ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)height,
+ SCROLLER_Total, height,
SCROLLER_Visible, win_h,
- TAG_DONE);
- }
-
- if(ami_cw->objects[GID_CW_HSCROLL]) {
- ami_cw_toggle_scrollbar(ami_cw, false, true);
- RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)width,
- SCROLLER_Visible, win_w,
- TAG_DONE);
+ TAG_DONE);
}
}
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 8d93882..17af249 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -54,8 +54,12 @@ struct ami_corewindow {
struct Hook idcmp_hook;
struct timeval lastclick;
+ int mouse_x_click;
+ int mouse_y_click;
int mouse_state;
+ bool close_window; // set to true to close the window during event loop
+
APTR deferred_rects_pool;
struct MinList *deferred_rects;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 74cd5a3..9fce681 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -536,6 +536,17 @@ STRPTR ami_gui_get_screen_title(void)
static void ami_set_screen_defaults(struct Screen *screen)
{
+ /* various window size/position defaults */
+ int width = screen->Width / 2;
+ int height = screen->Height / 2;
+ int top = (screen->Height / 2) - (height / 2);
+ int left = (screen->Width / 2) - (width / 2);
+
+ nsoption_default_set_int(cookies_window_ypos, top);
+ nsoption_default_set_int(cookies_window_xpos, left);
+ nsoption_default_set_int(cookies_window_xsize, width);
+ nsoption_default_set_int(cookies_window_ysize, height);
+
nsoption_default_set_int(window_x, 0);
nsoption_default_set_int(window_y, screen->BarHeight + 1);
nsoption_default_set_int(window_width, screen->Width);
@@ -1003,7 +1014,6 @@ static void gui_init2(int argc, char** argv)
/**/
ami_hotlist_initialise(nsoption_charp(hotlist_file));
- ami_cookies_initialise();
ami_global_history_initialise();
search_web_select_provider(nsoption_int(search_provider));
@@ -3028,7 +3038,6 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
ami_hotlist_free(nsoption_charp(hotlist_file));
- ami_cookies_free();
ami_global_history_free();
#ifdef __amigaos4__
if(IApplication && ami_appid)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 97b00f9..d88139d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -77,7 +77,6 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
-#define NSA_SPACE "blankspace.png"
#define NSA_MAX_HOTLIST_MENU_LEN 100
enum {
@@ -368,7 +367,7 @@ HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessa
HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
{
- ami_tree_open(cookies_window,AMI_TREE_COOKIES);
+ ami_cookies_present();
}
HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
@@ -545,7 +544,7 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
-void ami_menu_free_labs(struct ami_menu_data **md, int max)
+static void ami_menu_free_labs(struct ami_menu_data **md, int max)
{
int i;
@@ -984,6 +983,12 @@ void ami_menu_free(struct gui_window_2 *gwin)
FreeMenus(gwin->imenu);
}
+void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
+{
+ ami_menu_free_labs(md, max);
+ FreeMenus(imenu);
+}
+
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 1f6f245..ad0e96d 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -26,6 +26,9 @@
struct hlcache_handle;
struct ami_menu_data;
+/** empty space */
+#define NSA_SPACE "blankspace.png"
+
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -133,18 +136,23 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
-void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
-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);
+/* cleanup */
void ami_menu_free_glyphs(void);
-void ami_menu_free(struct gui_window_2 *gwin);
+
+/* 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,
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);
/**
* Sets that an item linked to a toggle menu item has been changed.
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index d56a1fe..28f3a4d 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -313,7 +313,7 @@ nserror ami_cert_verify(struct nsurl *url,
return res;
}
- /* initialise example core window */
+ /* initialise Amiga core window */
ncwin->core.draw = ami_crtvrfy_draw;
ncwin->core.key = ami_crtvrfy_key;
ncwin->core.mouse = ami_crtvrfy_mouse;
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/amiga-corewindow updated. release/3.6-168-g5687f6c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5687f6c27d40ec596b4d6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5687f6c27d40ec596b4d64c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5687f6c27d40ec596b4d64c70...
The branch, chris/amiga-corewindow has been updated
via 5687f6c27d40ec596b4d64c705d16a97bdb3c893 (commit)
via e98a05bb087fb5c2c2ee8d94b3011ae8b3aa5c7a (commit)
from 6e957396a9bdc78a7d9823aaf76764bbb30c184a (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=5687f6c27d40ec596b4...
commit 5687f6c27d40ec596b4d64c705d16a97bdb3c893
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
clear tree pointer on free
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 6134fa5..5429f68 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -843,6 +843,7 @@ nserror cookie_manager_fini(void)
/* Destroy the cookie manager treeview */
err = treeview_destroy(cm_ctx.tree);
+ cm_ctx.tree = NULL;
/* Free cookie manager treeview entry fields */
for (i = 0; i < COOKIE_M_N_FIELDS; i++)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e98a05bb087fb5c2c2e...
commit e98a05bb087fb5c2c2ee8d94b3011ae8b3aa5c7a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Complete cookie manager corewindow interface
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 1300236..18ca425 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <stdbool.h>
-#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <classes/window.h>
@@ -49,8 +48,25 @@
enum {
/* Project menu */
AMI_COOKIE_M_PROJECT = 0,
- AMI_COOKIE_M_TEST,
- AMI_COOKIE_M_LAST
+ AMI_COOKIE_M_EXPAND,
+ AMI_COOKIE_M_EXPAND_ALL,
+ AMI_COOKIE_M_EXPAND_DOMAINS,
+ AMI_COOKIE_M_EXPAND_COOKIES,
+ AMI_COOKIE_M_COLLAPSE,
+ AMI_COOKIE_M_COLLAPSE_ALL,
+ AMI_COOKIE_M_COLLAPSE_DOMAINS,
+ AMI_COOKIE_M_COLLAPSE_COOKIES,
+ AMI_COOKIE_M_BAR_P1,
+ AMI_COOKIE_M_SNAPSHOT,
+ AMI_COOKIE_M_BAR_P2,
+ AMI_COOKIE_M_CLOSE,
+ /* Edit menu */
+ AMI_COOKIE_M_EDIT,
+ AMI_COOKIE_M_SELECTALL,
+ AMI_COOKIE_M_CLEAR,
+ AMI_COOKIE_M_BAR_E1,
+ AMI_COOKIE_M_DELETE,
+ AMI_COOKIE_M_LAST
};
/**
@@ -74,8 +90,7 @@ ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
WINDOW_MenuStrip, NULL,
TAG_DONE);
- ami_menu_free_labs(cookie_win->menu_data, AMI_COOKIE_M_LAST);
- FreeMenus(cookie_win->imenu);
+ ami_menu_free_menu(cookie_win->menu_data, AMI_COOKIE_M_LAST, cookie_win->imenu);
}
/**
@@ -155,19 +170,106 @@ ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, st
/* menu hook functions */
-HOOKF(void, ami_cookies_menu_item_project_test, APTR, window, struct IntuiMessage *)
+HOOKF(void, ami_cookies_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
{
-
+ cookie_manager_expand(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_expand_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(true);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_expand_cookies, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
}
+HOOKF(void, ami_cookies_menu_item_project_collapse_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_collapse_cookies, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ nsoption_set_int(cookies_window_ypos, ami_cw->win->TopEdge);
+ nsoption_set_int(cookies_window_xpos, ami_cw->win->LeftEdge);
+ nsoption_set_int(cookies_window_xsize, ami_cw->win->Width);
+ nsoption_set_int(cookies_window_ysize, ami_cw->win->Height);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_close, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ ami_cw->close_window = true;
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_SELECT_ALL);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_DELETE_LEFT);
+}
+
+
/* menu setup */
static void ami_cookies_menulabs(struct ami_menu_data **md)
{
- /* not real menu items */
- ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_TEST, NM_ITEM, "TEST", 'N', "TBImages:list_app",
- ami_cookies_menu_item_project_test, NULL, 0);
+ 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_cookies_menu_item_project_expand_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, 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_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_cookies_menu_item_project_collapse_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, 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_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_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", 0, "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_cookies_menu_item_edit_select_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, 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_cookies_menu_item_edit_delete, NULL, 0);
+
ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
}
@@ -212,6 +314,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win)
WINDOW_VertProp, 1,
WINDOW_UserData, cookie_win,
WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
+ WINDOW_MenuUserData, WGUD_HOOK,
WINDOW_IconifyGadget, FALSE,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 0d0c9d6..1bfc537 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -472,6 +472,11 @@ ami_cw_event(void *w)
int x = 0, y = 0;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
+ if(ami_cw->close_window == true) {
+ ami_cw_close(ami_cw);
+ return TRUE;
+ }
+
switch(result & WMHI_CLASSMASK) {
case WMHI_MOUSEMOVE:
if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 2fa4a23..17af249 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -58,6 +58,8 @@ struct ami_corewindow {
int mouse_y_click;
int mouse_state;
+ bool close_window; // set to true to close the window during event loop
+
APTR deferred_rects_pool;
struct MinList *deferred_rects;
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 1b69b3e..d88139d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -77,7 +77,6 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
-#define NSA_SPACE "blankspace.png"
#define NSA_MAX_HOTLIST_MENU_LEN 100
enum {
@@ -545,7 +544,7 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
-void ami_menu_free_labs(struct ami_menu_data **md, int max)
+static void ami_menu_free_labs(struct ami_menu_data **md, int max)
{
int i;
@@ -984,6 +983,12 @@ void ami_menu_free(struct gui_window_2 *gwin)
FreeMenus(gwin->imenu);
}
+void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
+{
+ ami_menu_free_labs(md, max);
+ FreeMenus(imenu);
+}
+
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 1f6f245..ad0e96d 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -26,6 +26,9 @@
struct hlcache_handle;
struct ami_menu_data;
+/** empty space */
+#define NSA_SPACE "blankspace.png"
+
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -133,18 +136,23 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
-void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
-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);
+/* cleanup */
void ami_menu_free_glyphs(void);
-void ami_menu_free(struct gui_window_2 *gwin);
+
+/* 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,
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);
/**
* Sets that an item linked to a toggle menu item has been changed.
-----------------------------------------------------------------------
Summary of changes:
desktop/cookie_manager.c | 1 +
frontends/amiga/cookies.c | 125 ++++++++++++++++++++++++++++++++++++++----
frontends/amiga/corewindow.c | 5 ++
frontends/amiga/corewindow.h | 2 +
frontends/amiga/menu.c | 9 ++-
frontends/amiga/menu.h | 22 +++++---
6 files changed, 144 insertions(+), 20 deletions(-)
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 6134fa5..5429f68 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -843,6 +843,7 @@ nserror cookie_manager_fini(void)
/* Destroy the cookie manager treeview */
err = treeview_destroy(cm_ctx.tree);
+ cm_ctx.tree = NULL;
/* Free cookie manager treeview entry fields */
for (i = 0; i < COOKIE_M_N_FIELDS; i++)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 1300236..18ca425 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <stdbool.h>
-#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <classes/window.h>
@@ -49,8 +48,25 @@
enum {
/* Project menu */
AMI_COOKIE_M_PROJECT = 0,
- AMI_COOKIE_M_TEST,
- AMI_COOKIE_M_LAST
+ AMI_COOKIE_M_EXPAND,
+ AMI_COOKIE_M_EXPAND_ALL,
+ AMI_COOKIE_M_EXPAND_DOMAINS,
+ AMI_COOKIE_M_EXPAND_COOKIES,
+ AMI_COOKIE_M_COLLAPSE,
+ AMI_COOKIE_M_COLLAPSE_ALL,
+ AMI_COOKIE_M_COLLAPSE_DOMAINS,
+ AMI_COOKIE_M_COLLAPSE_COOKIES,
+ AMI_COOKIE_M_BAR_P1,
+ AMI_COOKIE_M_SNAPSHOT,
+ AMI_COOKIE_M_BAR_P2,
+ AMI_COOKIE_M_CLOSE,
+ /* Edit menu */
+ AMI_COOKIE_M_EDIT,
+ AMI_COOKIE_M_SELECTALL,
+ AMI_COOKIE_M_CLEAR,
+ AMI_COOKIE_M_BAR_E1,
+ AMI_COOKIE_M_DELETE,
+ AMI_COOKIE_M_LAST
};
/**
@@ -74,8 +90,7 @@ ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
WINDOW_MenuStrip, NULL,
TAG_DONE);
- ami_menu_free_labs(cookie_win->menu_data, AMI_COOKIE_M_LAST);
- FreeMenus(cookie_win->imenu);
+ ami_menu_free_menu(cookie_win->menu_data, AMI_COOKIE_M_LAST, cookie_win->imenu);
}
/**
@@ -155,19 +170,106 @@ ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, st
/* menu hook functions */
-HOOKF(void, ami_cookies_menu_item_project_test, APTR, window, struct IntuiMessage *)
+HOOKF(void, ami_cookies_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
{
-
+ cookie_manager_expand(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_expand_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(true);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_expand_cookies, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_expand(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
}
+HOOKF(void, ami_cookies_menu_item_project_collapse_domains, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(true);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_collapse_cookies, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_contract(false);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ nsoption_set_int(cookies_window_ypos, ami_cw->win->TopEdge);
+ nsoption_set_int(cookies_window_xpos, ami_cw->win->LeftEdge);
+ nsoption_set_int(cookies_window_xsize, ami_cw->win->Width);
+ nsoption_set_int(cookies_window_ysize, ami_cw->win->Height);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_close, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ ami_cw->close_window = true;
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_SELECT_ALL);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
+{
+ cookie_manager_keypress(NS_KEY_DELETE_LEFT);
+}
+
+
/* menu setup */
static void ami_cookies_menulabs(struct ami_menu_data **md)
{
- /* not real menu items */
- ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, AMI_COOKIE_M_TEST, NM_ITEM, "TEST", 'N', "TBImages:list_app",
- ami_cookies_menu_item_project_test, NULL, 0);
+ 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_cookies_menu_item_project_expand_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, 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_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_cookies_menu_item_project_collapse_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, 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_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_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", 0, "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_cookies_menu_item_edit_select_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, 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_cookies_menu_item_edit_delete, NULL, 0);
+
ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
}
@@ -212,6 +314,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win)
WINDOW_VertProp, 1,
WINDOW_UserData, cookie_win,
WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
+ WINDOW_MenuUserData, WGUD_HOOK,
WINDOW_IconifyGadget, FALSE,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 0d0c9d6..1bfc537 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -472,6 +472,11 @@ ami_cw_event(void *w)
int x = 0, y = 0;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
+ if(ami_cw->close_window == true) {
+ ami_cw_close(ami_cw);
+ return TRUE;
+ }
+
switch(result & WMHI_CLASSMASK) {
case WMHI_MOUSEMOVE:
if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 2fa4a23..17af249 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -58,6 +58,8 @@ struct ami_corewindow {
int mouse_y_click;
int mouse_state;
+ bool close_window; // set to true to close the window during event loop
+
APTR deferred_rects_pool;
struct MinList *deferred_rects;
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 1b69b3e..d88139d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -77,7 +77,6 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
-#define NSA_SPACE "blankspace.png"
#define NSA_MAX_HOTLIST_MENU_LEN 100
enum {
@@ -545,7 +544,7 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
-void ami_menu_free_labs(struct ami_menu_data **md, int max)
+static void ami_menu_free_labs(struct ami_menu_data **md, int max)
{
int i;
@@ -984,6 +983,12 @@ void ami_menu_free(struct gui_window_2 *gwin)
FreeMenus(gwin->imenu);
}
+void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
+{
+ ami_menu_free_labs(md, max);
+ FreeMenus(imenu);
+}
+
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 1f6f245..ad0e96d 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -26,6 +26,9 @@
struct hlcache_handle;
struct ami_menu_data;
+/** empty space */
+#define NSA_SPACE "blankspace.png"
+
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -133,18 +136,23 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
-void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
-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);
+/* cleanup */
void ami_menu_free_glyphs(void);
-void ami_menu_free(struct gui_window_2 *gwin);
+
+/* 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,
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);
/**
* Sets that an item linked to a toggle menu item has been changed.
--
NetSurf Browser
6 years, 8 months
toolchains: branch master updated. bd64939acb3dcd982ccb1c15fb98e1123ecc5752
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/toolchains.git/shortlog/bd64939acb3dcd982c...
...commit http://git.netsurf-browser.org/toolchains.git/commit/bd64939acb3dcd982ccb...
...tree http://git.netsurf-browser.org/toolchains.git/tree/bd64939acb3dcd982ccb1c...
The branch, master has been updated
via bd64939acb3dcd982ccb1c15fb98e1123ecc5752 (commit)
via 26f54c957537528b6c45f0dbc7c8dd2765aafec3 (commit)
from 554158c91114fe78ca70ed50255df7cc491240b7 (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/toolchains.git/commit/?id=bd64939acb3dcd98...
commit bd64939acb3dcd982ccb1c15fb98e1123ecc5752
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Update libpng from 1.6.25 to 1.6.27.
diff --git a/sdk/Makefile b/sdk/Makefile
index 47ea5f6..35e6463 100644
--- a/sdk/Makefile
+++ b/sdk/Makefile
@@ -27,7 +27,7 @@ VERSION_ZLIB := 1.2.10
VERSION_LIBICONV := 1.14
VERSION_LIBTRE := 0.8.0
VERSION_OPENSSL := 1.0.1u
-VERSION_LIBPNG := 1.6.25
+VERSION_LIBPNG := 1.6.27
VERSION_LIBJPEG := 8d
VERSION_LIBJPEG_TURBO := 1.5.1
VERSION_LIBCARES := 1.12.0
commitdiff http://git.netsurf-browser.org/toolchains.git/commit/?id=26f54c957537528b...
commit 26f54c957537528b6c45f0dbc7c8dd2765aafec3
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Update zlib to 1.2.10.
diff --git a/sdk/Makefile b/sdk/Makefile
index 76facb8..47ea5f6 100644
--- a/sdk/Makefile
+++ b/sdk/Makefile
@@ -23,7 +23,7 @@ ifeq ($(GCCSDK_INSTALL_CROSSBIN),)
endif
# Upstream package versions
-VERSION_ZLIB := 1.2.8
+VERSION_ZLIB := 1.2.10
VERSION_LIBICONV := 1.14
VERSION_LIBTRE := 0.8.0
VERSION_OPENSSL := 1.0.1u
-----------------------------------------------------------------------
Summary of changes:
sdk/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sdk/Makefile b/sdk/Makefile
index 76facb8..35e6463 100644
--- a/sdk/Makefile
+++ b/sdk/Makefile
@@ -23,11 +23,11 @@ ifeq ($(GCCSDK_INSTALL_CROSSBIN),)
endif
# Upstream package versions
-VERSION_ZLIB := 1.2.8
+VERSION_ZLIB := 1.2.10
VERSION_LIBICONV := 1.14
VERSION_LIBTRE := 0.8.0
VERSION_OPENSSL := 1.0.1u
-VERSION_LIBPNG := 1.6.25
+VERSION_LIBPNG := 1.6.27
VERSION_LIBJPEG := 8d
VERSION_LIBJPEG_TURBO := 1.5.1
VERSION_LIBCARES := 1.12.0
--
Cross-compilation toolchains and environments
6 years, 8 months
netsurf: branch chris/amiga-corewindow updated. release/3.6-166-g6e95739
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6e957396a9bdc78a7d982...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6e957396a9bdc78a7d9823a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6e957396a9bdc78a7d9823aaf...
The branch, chris/amiga-corewindow has been updated
via 6e957396a9bdc78a7d9823aaf76764bbb30c184a (commit)
via d6f6326ce9b6e60fcf9865e726b718ccfbbbea65 (commit)
via 26b98ac51b2f5a7c3d35050fcf79f521bfdb05f8 (commit)
via 57a2bb85992844b644433142e687940b3870ce40 (commit)
via 695783e33b9c100b1ce28ef71a59a00f52cc374f (commit)
via 2e11f7f3cbd7d563cb525a26ce79d76502ba7686 (commit)
from 5eb7ee97ed641e152c488dab6c33c37d0635e48b (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=6e957396a9bdc78a7d9...
commit 6e957396a9bdc78a7d9823aaf76764bbb30c184a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
fix some ui corruption on scrollbar hide
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index d3d55ec..0d0c9d6 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -403,18 +403,14 @@ ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
}
}
-#if 0
- /* in-window scrollbars aren't getting hidden until the window is resized
- * this code should fix it, but it isn't working */
if(ami_cw->in_border_scroll == false) {
FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
ami_cw->win, NULL, TRUE);
-
- /* probably need to redraw here */
- ami_cw_redraw(ami_cw, NULL);
}
-#endif
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
}
static void
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d6f6326ce9b6e60fcf9...
commit d6f6326ce9b6e60fcf9865e726b718ccfbbbea65
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
it's not a double-click if the mouse has moved
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 59fc3e1..d3d55ec 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -34,6 +34,7 @@
#include "amiga/os3support.h"
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -103,6 +104,17 @@ ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *re
*y = *y + ys;
}
+/**
+ * check if mouse has moved since position was stored
+ * @return true if it has, false otherwise
+ */
+static bool
+ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y)
+{
+ if(abs(x - ami_cw->mouse_x_click) > 5) return true;
+ if(abs(y - ami_cw->mouse_y_click) > 5) return true;
+ return false;
+}
/* get current mouse position in the draw area, adjusted for scroll.
* @return true if the mouse was in the draw area and co-ordinates updated
@@ -494,12 +506,16 @@ ami_cw_event(void *w)
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
if(ami_cw->lastclick.tv_sec) {
- if(DoubleClick(ami_cw->lastclick.tv_sec,
+ if((ami_cw_mouse_moved(ami_cw, x, y) == false) &&
+ (DoubleClick(ami_cw->lastclick.tv_sec,
ami_cw->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec))
+ curtime.tv_sec, curtime.tv_usec)))
ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
+ ami_cw->mouse_x_click = x;
+ ami_cw->mouse_y_click = y;
+
if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
ami_cw->lastclick.tv_sec = 0;
ami_cw->lastclick.tv_usec = 0;
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 8d93882..2fa4a23 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -54,6 +54,8 @@ struct ami_corewindow {
struct Hook idcmp_hook;
struct timeval lastclick;
+ int mouse_x_click;
+ int mouse_y_click;
int mouse_state;
APTR deferred_rects_pool;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=26b98ac51b2f5a7c3d3...
commit 26b98ac51b2f5a7c3d35050fcf79f521bfdb05f8
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
template for menu addition in cookie manager
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 29e41de..1300236 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdbool.h>
+#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <classes/window.h>
@@ -40,10 +41,17 @@
#include "utils/messages.h"
#include "utils/nsoption.h"
+#include "amiga/cookies.h"
#include "amiga/corewindow.h"
#include "amiga/libs.h"
#include "amiga/utf8.h"
+enum {
+ /* Project menu */
+ AMI_COOKIE_M_PROJECT = 0,
+ AMI_COOKIE_M_TEST,
+ AMI_COOKIE_M_LAST
+};
/**
* Amiga cookie viewer window context
@@ -51,27 +59,42 @@
struct ami_cookie_window {
/** Amiga core window context */
struct ami_corewindow core;
+
+ struct ami_menu_data *menu_data[AMI_COOKIE_M_LAST + 1];
+ struct Menu *imenu; /* Intuition menu */
};
static struct ami_cookie_window *cookie_window = NULL;
+
+static void
+ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
+{
+ SetAttrs(cookie_win->core.objects[GID_CW_WIN],
+ WINDOW_MenuStrip, NULL,
+ TAG_DONE);
+
+ ami_menu_free_labs(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+ FreeMenus(cookie_win->imenu);
+}
+
/**
* destroy a previously created cookie view
*/
-static nserror
-ami_cookies_destroy(void)
+static void
+ami_cookies_destroy(struct ami_corewindow *ami_cw)
{
nserror res;
if(cookie_window == NULL)
- return NSERROR_OK;
+ return;
res = cookie_manager_fini();
if (res == NSERROR_OK) {
- res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us */
+ ami_cookies_menu_free(cookie_window);
+ res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us, frees cookie_win */
cookie_window = NULL;
}
- return res;
}
@@ -126,6 +149,39 @@ ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, st
return NSERROR_OK;
}
+/**
+ * menu stuff
+ */
+
+ /* menu hook functions */
+
+HOOKF(void, ami_cookies_menu_item_project_test, APTR, window, struct IntuiMessage *)
+{
+
+}
+
+/* menu setup */
+
+static void ami_cookies_menulabs(struct ami_menu_data **md)
+{
+ /* not real menu items */
+ ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_TEST, NM_ITEM, "TEST", 'N', "TBImages:list_app",
+ ami_cookies_menu_item_project_test, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+}
+
+static struct Menu *
+ami_cookies_menu_create(struct ami_cookie_window *cookie_win)
+{
+ ami_cookies_menulabs(cookie_win->menu_data);
+ cookie_win->imenu = ami_menu_layout(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+ if(cookie_win->imenu == NULL) return NULL;
+
+ return cookie_win->imenu;
+}
+
+
static nserror
ami_cookies_create_window(struct ami_cookie_window *cookie_win)
{
@@ -155,7 +211,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win)
WINDOW_HorizProp, 1,
WINDOW_VertProp, 1,
WINDOW_UserData, cookie_win,
- /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
WINDOW_IconifyGadget, FALSE,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=57a2bb85992844b6444...
commit 57a2bb85992844b644433142e687940b3870ce40
Merge: 2e11f7f 695783e
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/amiga-corewindow
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2e11f7f3cbd7d563cb5...
commit 2e11f7f3cbd7d563cb525a26ce79d76502ba7686
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
less cranky scrollbars
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index e5d289a..59fc3e1 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -616,28 +616,22 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
if(width == -1) {
ami_cw_toggle_scrollbar(ami_cw, false, false);
- return;
+ } else {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)width,
+ SCROLLER_Visible, win_w,
+ TAG_DONE);
}
if(height == -1) {
ami_cw_toggle_scrollbar(ami_cw, true, false);
- return;
- }
-
- if(ami_cw->objects[GID_CW_VSCROLL]) {
+ } else {
ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
SCROLLER_Total, height,
SCROLLER_Visible, win_h,
- TAG_DONE);
- }
-
- if(ami_cw->objects[GID_CW_HSCROLL]) {
- ami_cw_toggle_scrollbar(ami_cw, false, true);
- RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)width,
- SCROLLER_Visible, win_w,
- TAG_DONE);
+ TAG_DONE);
}
}
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/cookies.c | 68 ++++++-
frontends/amiga/corewindow.c | 52 ++---
frontends/amiga/corewindow.h | 2 +
frontends/amiga/gui.c | 2 +-
frontends/amiga/gui.h | 11 +-
frontends/amiga/menu.c | 463 ++++++++++++++++++++++--------------------
frontends/amiga/menu.h | 8 +-
7 files changed, 351 insertions(+), 255 deletions(-)
mode change 100755 => 100644 frontends/amiga/menu.h
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 29e41de..1300236 100644
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdbool.h>
+#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <classes/window.h>
@@ -40,10 +41,17 @@
#include "utils/messages.h"
#include "utils/nsoption.h"
+#include "amiga/cookies.h"
#include "amiga/corewindow.h"
#include "amiga/libs.h"
#include "amiga/utf8.h"
+enum {
+ /* Project menu */
+ AMI_COOKIE_M_PROJECT = 0,
+ AMI_COOKIE_M_TEST,
+ AMI_COOKIE_M_LAST
+};
/**
* Amiga cookie viewer window context
@@ -51,27 +59,42 @@
struct ami_cookie_window {
/** Amiga core window context */
struct ami_corewindow core;
+
+ struct ami_menu_data *menu_data[AMI_COOKIE_M_LAST + 1];
+ struct Menu *imenu; /* Intuition menu */
};
static struct ami_cookie_window *cookie_window = NULL;
+
+static void
+ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
+{
+ SetAttrs(cookie_win->core.objects[GID_CW_WIN],
+ WINDOW_MenuStrip, NULL,
+ TAG_DONE);
+
+ ami_menu_free_labs(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+ FreeMenus(cookie_win->imenu);
+}
+
/**
* destroy a previously created cookie view
*/
-static nserror
-ami_cookies_destroy(void)
+static void
+ami_cookies_destroy(struct ami_corewindow *ami_cw)
{
nserror res;
if(cookie_window == NULL)
- return NSERROR_OK;
+ return;
res = cookie_manager_fini();
if (res == NSERROR_OK) {
- res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us */
+ ami_cookies_menu_free(cookie_window);
+ res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us, frees cookie_win */
cookie_window = NULL;
}
- return res;
}
@@ -126,6 +149,39 @@ ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, st
return NSERROR_OK;
}
+/**
+ * menu stuff
+ */
+
+ /* menu hook functions */
+
+HOOKF(void, ami_cookies_menu_item_project_test, APTR, window, struct IntuiMessage *)
+{
+
+}
+
+/* menu setup */
+
+static void ami_cookies_menulabs(struct ami_menu_data **md)
+{
+ /* not real menu items */
+ ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_TEST, NM_ITEM, "TEST", 'N', "TBImages:list_app",
+ ami_cookies_menu_item_project_test, NULL, 0);
+ ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+}
+
+static struct Menu *
+ami_cookies_menu_create(struct ami_cookie_window *cookie_win)
+{
+ ami_cookies_menulabs(cookie_win->menu_data);
+ cookie_win->imenu = ami_menu_layout(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+ if(cookie_win->imenu == NULL) return NULL;
+
+ return cookie_win->imenu;
+}
+
+
static nserror
ami_cookies_create_window(struct ami_cookie_window *cookie_win)
{
@@ -155,7 +211,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win)
WINDOW_HorizProp, 1,
WINDOW_VertProp, 1,
WINDOW_UserData, cookie_win,
- /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
WINDOW_IconifyGadget, FALSE,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index e5d289a..0d0c9d6 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -34,6 +34,7 @@
#include "amiga/os3support.h"
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -103,6 +104,17 @@ ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *re
*y = *y + ys;
}
+/**
+ * check if mouse has moved since position was stored
+ * @return true if it has, false otherwise
+ */
+static bool
+ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y)
+{
+ if(abs(x - ami_cw->mouse_x_click) > 5) return true;
+ if(abs(y - ami_cw->mouse_y_click) > 5) return true;
+ return false;
+}
/* get current mouse position in the draw area, adjusted for scroll.
* @return true if the mouse was in the draw area and co-ordinates updated
@@ -391,18 +403,14 @@ ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
}
}
-#if 0
- /* in-window scrollbars aren't getting hidden until the window is resized
- * this code should fix it, but it isn't working */
if(ami_cw->in_border_scroll == false) {
FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
ami_cw->win, NULL, TRUE);
-
- /* probably need to redraw here */
- ami_cw_redraw(ami_cw, NULL);
}
-#endif
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
}
static void
@@ -494,12 +502,16 @@ ami_cw_event(void *w)
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
if(ami_cw->lastclick.tv_sec) {
- if(DoubleClick(ami_cw->lastclick.tv_sec,
+ if((ami_cw_mouse_moved(ami_cw, x, y) == false) &&
+ (DoubleClick(ami_cw->lastclick.tv_sec,
ami_cw->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec))
+ curtime.tv_sec, curtime.tv_usec)))
ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
+ ami_cw->mouse_x_click = x;
+ ami_cw->mouse_y_click = y;
+
if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
ami_cw->lastclick.tv_sec = 0;
ami_cw->lastclick.tv_usec = 0;
@@ -616,28 +628,22 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
if(width == -1) {
ami_cw_toggle_scrollbar(ami_cw, false, false);
- return;
+ } else {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)width,
+ SCROLLER_Visible, win_w,
+ TAG_DONE);
}
if(height == -1) {
ami_cw_toggle_scrollbar(ami_cw, true, false);
- return;
- }
-
- if(ami_cw->objects[GID_CW_VSCROLL]) {
+ } else {
ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
SCROLLER_Total, height,
SCROLLER_Visible, win_h,
- TAG_DONE);
- }
-
- if(ami_cw->objects[GID_CW_HSCROLL]) {
- ami_cw_toggle_scrollbar(ami_cw, false, true);
- RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)width,
- SCROLLER_Visible, win_w,
- TAG_DONE);
+ TAG_DONE);
}
}
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 8d93882..2fa4a23 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -54,6 +54,8 @@ struct ami_corewindow {
struct Hook idcmp_hook;
struct timeval lastclick;
+ int mouse_x_click;
+ int mouse_y_click;
int mouse_state;
APTR deferred_rects_pool;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 3af51a0..9fce681 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4599,7 +4599,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);
+ ami_free_menulabs(g->shared->menu_data);
ami_menu_free(g->shared);
free(g->shared->wintitle);
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 4c3e586..a176df1 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -110,6 +110,8 @@ struct ami_generic_window {
const struct ami_win_event_table *tbl;
};
+struct ami_menu_data;
+
struct gui_window_2 {
struct ami_generic_window w;
struct Window *win;
@@ -132,13 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- char *restrict menulab[AMI_MENU_AREXX_MAX + 1];
- Object *restrict menuobj[AMI_MENU_AREXX_MAX + 1];
- char menukey[AMI_MENU_AREXX_MAX + 1];
- char *restrict menuicon[AMI_MENU_AREXX_MAX + 1];
- struct Hook menu_hook[AMI_MENU_AREXX_MAX + 1];
- UBYTE *menutype;
- struct NewMenu *menu;
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
@@ -163,7 +159,6 @@ struct gui_window_2 {
struct MinList *shared_pens;
gui_pointer_shape mouse_pointer;
struct Menu *imenu; /* Intuition menu */
- struct VisualInfo *vi; /* For GadTools menu */
bool closed; /* Window has been closed (via menu) */
};
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index cd72269..1b69b3e 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-9,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-9, 2013, 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -88,6 +88,16 @@ enum {
NSA_GLYPH_MAX
};
+struct ami_menu_data {
+ char *restrict menulab;
+ Object *restrict menuobj;
+ char menukey;
+ char *restrict menuicon;
+ struct Hook menu_hook;
+ UBYTE menutype;
+ UWORD flags;
+};
+
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
@@ -97,8 +107,8 @@ static bool menu_glyphs_loaded = false;
const char * const netsurf_version;
const char * const verdate;
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
-void ami_menu_arexx_scan(struct gui_window_2 *gwin);
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md);
+void ami_menu_arexx_scan(struct ami_menu_data **md);
void ami_menu_set_check_toggled(void)
{
@@ -535,194 +545,219 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
+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)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
+ }
+
+ ami_utf8_free(md[i]->menulab);
+ }
-void ami_free_menulabs(struct gui_window_2 *gwin)
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ 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(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL)) {
- if(gwin->menutype[i] & MENU_IMAGE) {
- if(gwin->menuobj[i]) DisposeObject(gwin->menuobj[i]);
+ if(md[i] == NULL) continue;
+ if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
- ami_utf8_free(gwin->menulab[i]);
+ ami_utf8_free(md[i]->menulab);
if(i >= AMI_MENU_AREXX) {
- if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data);
- gwin->menu_hook[i].h_Data = NULL;
+ if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
+ md[i]->menu_hook.h_Data = NULL;
}
}
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menukey[i] = 0;
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ md[i]->menutype = 0;
+ free(md[i]);
}
-
- free(gwin->menutype);
- gwin->menutype = NULL;
}
-static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
const char *restrict label, char key, const char *restrict icon,
- void *restrict func, void *restrict hookdata)
+ void *restrict func, void *restrict hookdata, UWORD flags)
{
char menu_icon[1024];
- gwin->menutype[num] = type;
+ 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)) {
- gwin->menulab[num] = NM_BARLABEL;
- } else {
+ md[num]->menulab = NM_BARLABEL;
+ } 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 **)&gwin->menulab[num]);
+ (char **)&md[num]->menulab);
} else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
- gwin->menulab[num] = strdup(label);
+ md[num]->menulab = strdup(label);
} else {
- gwin->menulab[num] = ami_utf8_easy(messages_get(label));
+ md[num]->menulab = ami_utf8_easy(messages_get(label));
}
}
- gwin->menuicon[num] = NULL;
- if(key) gwin->menukey[num] = key;
- if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func;
- if(hookdata) gwin->menu_hook[num].h_Data = hookdata;
+ md[num]->menuicon = NULL;
+ if(key) md[num]->menukey = key;
+ if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
+ if(hookdata) md[num]->menu_hook.h_Data = hookdata;
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
if(icon) {
if(ami_locate_resource(menu_icon, icon) == true) {
- gwin->menuicon[num] = (char *)strdup(menu_icon);
+ md[num]->menuicon = (char *)strdup(menu_icon);
} else {
/* If the requested icon can't be found, put blank space in instead */
- gwin->menuicon[num] = (char *)strdup(NSA_SPACE);
+ md[num]->menuicon = (char *)strdup(NSA_SPACE);
}
}
}
#endif
}
-static void ami_init_menulabs(struct gui_window_2 *gwin)
+static void ami_init_menulabs(struct ami_menu_data **md)
{
- int i;
-
- gwin->menutype = calloc(1, sizeof(UBYTE) * (AMI_MENU_AREXX_MAX + 1));
+ UWORD js_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(enable_javascript) == true)
+ js_flags |= CHECKED;
- for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
- {
- gwin->menutype[i] = NM_IGNORE;
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menuicon[i] = NULL;
- }
+ UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(foreground_images) == true)
+ imgfore_flags |= CHECKED;
- ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
- ami_menu_item_project_newwin, NULL);
- ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL);
- ami_menu_alloc_item(gwin, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, "TBImages:list_saveas", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE);
- ami_menu_alloc_item(gwin, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT);
- ami_menu_alloc_item(gwin, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE);
+ UWORD imgback_flags = CHECKIT | MENUTOGGLE;
+ 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_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, 0, 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_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", 0, 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_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(gwin, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF);
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- ami_menu_alloc_item(gwin, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF);
- ami_menu_alloc_item(gwin, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PRINT, NM_ITEM, "PrintNS", 'P', "TBImages:list_print",
- ami_menu_item_project_print, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL);
- ami_menu_alloc_item(gwin, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_ABOUT, NM_ITEM, "About", '?', "TBImages:list_info",
- ami_menu_item_project_about, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_QUIT, NM_ITEM, "Quit", 'Q', "TBImages:list_warning",
- ami_menu_item_project_quit, NULL);
-
- ami_menu_alloc_item(gwin, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CUT, NM_ITEM, "CutNS", 'X', "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL);
- ami_menu_alloc_item(gwin, M_COPY, NM_ITEM, "CopyNS", 'C', "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL);
- ami_menu_alloc_item(gwin, M_PASTE, NM_ITEM, "PasteNS", 'V', "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
- ami_menu_item_edit_selectall, NULL);
- ami_menu_alloc_item(gwin, M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_UNDO, NM_ITEM, "Undo", 'Z', "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL);
- ami_menu_alloc_item(gwin, M_REDO, NM_ITEM, "Redo", 'Y', "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL);
-
- ami_menu_alloc_item(gwin, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_FIND, NM_ITEM, "FindTextNS", 'F', "TBImages:list_search",
- ami_menu_item_browser_find, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL);
- ami_menu_alloc_item(gwin, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALE, NM_ITEM, "ScaleNS", 0, "TBImages:list_preview", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL);
- ami_menu_alloc_item(gwin, M_SCALENRM, NM_SUB, "ScaleNorm", '=', "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL);
- ami_menu_alloc_item(gwin, M_SCALEINC, NM_SUB, "ScaleInc", '+', "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL);
- ami_menu_alloc_item(gwin, M_IMAGES, NM_ITEM, "Images", 0, "TBImages:list_image", NULL, NULL);
- ami_menu_alloc_item(gwin, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
- ami_menu_item_browser_foreimg, NULL);
- ami_menu_alloc_item(gwin, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
- ami_menu_item_browser_backimg, NULL);
- ami_menu_alloc_item(gwin, M_JS, NM_ITEM, "EnableJS", 0, NULL,
- ami_menu_item_browser_enablejs, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_REDRAW, NM_ITEM, "Redraw", 0, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL);
-
- ami_menu_alloc_item(gwin, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HLADD, NM_ITEM, "HotlistAdd", 'B', "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL);
- ami_menu_alloc_item(gwin, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL);
- ami_menu_alloc_item(gwin, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
-
- ami_menu_alloc_item(gwin, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PREDIT, NM_ITEM, "SettingsEdit", 0, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL);
- ami_menu_alloc_item(gwin, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL);
- ami_menu_alloc_item(gwin, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "TBImages:list_use",
- ami_menu_item_settings_save, NULL);
-
- ami_menu_alloc_item(gwin, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL);
- ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", 0, 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_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_item_project_closetab, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "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_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_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_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, 0, 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_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_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", 0, 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_item_browser_localhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "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_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_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", 0, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
+ ami_menu_item_browser_foreimg, NULL, imgfore_flags);
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
+ ami_menu_item_browser_backimg, NULL, imgback_flags);
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", 0, 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_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_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, 0, 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_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_item_settings_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "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_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);
}
/* Menu refresh for hotlist */
@@ -741,7 +776,7 @@ void ami_menu_refresh(struct gui_window_2 *gwin)
ami_menu_free(gwin);
LOG("Freeing menu labels");
- ami_free_menulabs(gwin);
+ ami_free_menulabs(gwin->menu_data);
LOG("Creating new menu");
menu = ami_menu_create(gwin);
@@ -794,16 +829,16 @@ void ami_menu_free_glyphs(void)
#endif
}
-static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp)
+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, gwin->menulab[j], strlen(gwin->menulab[j]));
+ item_size = TextLength(rp, md[j]->menulab, strlen(md[j]->menulab));
item_size += space_width;
- if(gwin->menukey[j]) {
- item_size += TextLength(rp, &gwin->menukey[j], 1);
+ 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
*/
@@ -813,7 +848,7 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
}
- if(gwin->menuicon[j]) {
+ if(md[j]->menuicon) {
item_size += 16;
}
@@ -821,11 +856,14 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
}
-static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
+struct Menu *ami_menu_layout(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);
@@ -833,34 +871,41 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(menu_glyphs_loaded == false)
ami_menu_load_glyphs(dri);
- for(i=0; i < AMI_MENU_AREXX_MAX; i++)
- {
- if(gwin->menutype[i] == NM_TITLE) {
+ 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(gwin->menulab[j] != NM_BARLABEL) {
- if(gwin->menutype[j] == NM_ITEM) {
- int item_size = ami_menu_calc_item_width(gwin, j, rp);
+ 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((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
+ } 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((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
+ 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, gwin->menuicon[i],
+ BITMAP_SourceFile, md[i]->menuicon,
BITMAP_Masking, TRUE,
BitMapEnd;
@@ -872,15 +917,15 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
GetAttr(IA_Width, icon, (ULONG *)&icon_width);
- if(gwin->menutype[i] != NM_SUB) {
+ if(md[i]->menutype != NM_SUB) {
left_posn = txtlen;
}
left_posn = left_posn -
- TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
+ TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
@@ -890,81 +935,66 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
TAG_DONE);
}
- gwin->menuobj[i] = LabelObj,
+ md[i]->menuobj = LabelObj,
LABEL_MenuMode, TRUE,
LABEL_DrawInfo, dri,
LABEL_DisposeImage, TRUE,
LABEL_Image, icon,
LABEL_Text, " ",
- LABEL_Text, gwin->menulab[i],
+ LABEL_Text, md[i]->menulab,
LABEL_DisposeImage, TRUE,
LABEL_Image, submenuarrow,
LabelEnd;
- if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
+ if(md[i]->menuobj) md[i]->menutype |= MENU_IMAGE;
}
}
#endif
- gwin->menu[i].nm_Type = gwin->menutype[i];
+ nm[i].nm_Type = md[i]->menutype;
- if(gwin->menuobj[i])
- gwin->menu[i].nm_Label = (void *)gwin->menuobj[i];
+ if(md[i]->menuobj)
+ nm[i].nm_Label = (void *)md[i]->menuobj;
else
- gwin->menu[i].nm_Label = gwin->menulab[i];
+ nm[i].nm_Label = md[i]->menulab;
- if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
- gwin->menu[i].nm_Flags = 0;
- if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
+ if(md[i]->menukey) 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;
- if(gwin->menuicon[i]) {
- free(gwin->menuicon[i]);
- gwin->menuicon[i] = NULL;
+ if(md[i]->menuicon) {
+ free(md[i]->menuicon);
+ md[i]->menuicon = NULL;
}
}
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 gwin;
+ return imenu;
}
void ami_menu_free(struct gui_window_2 *gwin)
{
FreeMenus(gwin->imenu);
- FreeVisualInfo(gwin->vi);
}
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
- gwin->menu = calloc(1, sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1));
- ami_init_menulabs(gwin);
- ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
- ami_menu_arexx_scan(gwin);
- gwin = ami_menu_layout(gwin);
-
- gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- gwin->menu[M_JS].nm_Flags |= CHECKED;
-
- gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED;
-
- gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- gwin->menu[M_IMGFORE].nm_Flags |= CHECKED;
- gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
-
- gwin->vi = GetVisualInfo(scrn, TAG_DONE);
- gwin->imenu = CreateMenus(gwin->menu, TAG_DONE);
- LayoutMenus(gwin->imenu, gwin->vi,
- GTMN_NewLookMenus, TRUE, TAG_DONE);
- free(gwin->menu); /**\todo this should be local to this function */
- gwin->menu = NULL;
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin->menu_data); //\todo this needs to be MenuClass created
+ 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 gui_window_2 *gwin)
+void ami_menu_arexx_scan(struct ami_menu_data **md)
{
/**\todo Rewrite this to not use ExAll() **/
int item = AMI_MENU_AREXX;
@@ -993,14 +1023,13 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
if(item >= AMI_MENU_AREXX_MAX) continue;
if(EAD_IS_FILE(ead)) {
- gwin->menu[item].nm_Type = NM_ITEM;
if(ead->ed_Comment[0] != '\0')
menu_lab = ead->ed_Comment;
else
menu_lab = ead->ed_Name;
- ami_menu_alloc_item(gwin, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
- ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name));
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
+ ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
item++;
}
@@ -1013,15 +1042,15 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
UnLock(lock);
}
- gwin->menu[item].nm_Type = NM_END;
- gwin->menu[item].nm_Label = NULL;
+ ami_menu_alloc_item(md, item, NM_END, NULL, 0, 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;
- struct gui_window_2 *gw = (struct gui_window_2 *)userdata;
+ UWORD flags = 0;
+ struct ami_menu_data **md = (struct ami_menu_data **)userdata;
if(item >= AMI_MENU_HOTLIST_MAX) return false;
@@ -1046,19 +1075,21 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
if (icon == NULL) icon = ASPrintf("icons/content.png");
}
- ami_menu_alloc_item(gw, item, type, title,
- 0, icon, ami_menu_item_hotlist_entries, (void *)url);
- if((is_folder == true) && (type == NM_SUB))
- gw->menu[item].nm_Flags = NM_ITEMDISABLED;
+ if((is_folder == true) && (type == NM_SUB)) {
+ flags = NM_ITEMDISABLED;
+ }
+
+ ami_menu_alloc_item(md, item, type, title,
+ 0, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
if(icon) FreeVec(icon);
return true;
}
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md)
{
- return ami_hotlist_scan((void *)gwin, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
+ return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
void ami_menu_update_checked(struct gui_window_2 *gwin)
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
old mode 100755
new mode 100644
index ac74f38..1f6f245
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -24,6 +24,7 @@
#include <libraries/gadtools.h>
struct hlcache_handle;
+struct ami_menu_data;
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -132,13 +133,18 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct gui_window_2 *gwin);
+void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
+void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
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_glyphs(void);
void ami_menu_free(struct gui_window_2 *gwin);
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
+ const char *restrict label, char 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);
/**
* Sets that an item linked to a toggle menu item has been changed.
--
NetSurf Browser
6 years, 8 months
netsurf: branch master updated. release/3.6-160-g695783e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/695783e33b9c100b1ce28...
...commit http://git.netsurf-browser.org/netsurf.git/commit/695783e33b9c100b1ce28ef...
...tree http://git.netsurf-browser.org/netsurf.git/tree/695783e33b9c100b1ce28ef71...
The branch, master has been updated
via 695783e33b9c100b1ce28ef71a59a00f52cc374f (commit)
from 3b1ef784fd53095213fa8b89806982567359dca4 (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=695783e33b9c100b1ce...
commit 695783e33b9c100b1ce28ef71a59a00f52cc374f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
re-structure menu code to make it useable elsewhere in the frontend
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index f94090b..74cd5a3 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4590,7 +4590,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);
+ ami_free_menulabs(g->shared->menu_data);
ami_menu_free(g->shared);
free(g->shared->wintitle);
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 4c3e586..a176df1 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -110,6 +110,8 @@ struct ami_generic_window {
const struct ami_win_event_table *tbl;
};
+struct ami_menu_data;
+
struct gui_window_2 {
struct ami_generic_window w;
struct Window *win;
@@ -132,13 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- char *restrict menulab[AMI_MENU_AREXX_MAX + 1];
- Object *restrict menuobj[AMI_MENU_AREXX_MAX + 1];
- char menukey[AMI_MENU_AREXX_MAX + 1];
- char *restrict menuicon[AMI_MENU_AREXX_MAX + 1];
- struct Hook menu_hook[AMI_MENU_AREXX_MAX + 1];
- UBYTE *menutype;
- struct NewMenu *menu;
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
@@ -163,7 +159,6 @@ struct gui_window_2 {
struct MinList *shared_pens;
gui_pointer_shape mouse_pointer;
struct Menu *imenu; /* Intuition menu */
- struct VisualInfo *vi; /* For GadTools menu */
bool closed; /* Window has been closed (via menu) */
};
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index dc5514b..97b00f9 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-9,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-9, 2013, 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -88,6 +88,16 @@ enum {
NSA_GLYPH_MAX
};
+struct ami_menu_data {
+ char *restrict menulab;
+ Object *restrict menuobj;
+ char menukey;
+ char *restrict menuicon;
+ struct Hook menu_hook;
+ UBYTE menutype;
+ UWORD flags;
+};
+
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
@@ -97,8 +107,8 @@ static bool menu_glyphs_loaded = false;
const char * const netsurf_version;
const char * const verdate;
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
-void ami_menu_arexx_scan(struct gui_window_2 *gwin);
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md);
+void ami_menu_arexx_scan(struct ami_menu_data **md);
void ami_menu_set_check_toggled(void)
{
@@ -535,194 +545,219 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
+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)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
+ }
+
+ ami_utf8_free(md[i]->menulab);
+ }
-void ami_free_menulabs(struct gui_window_2 *gwin)
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ 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(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL)) {
- if(gwin->menutype[i] & MENU_IMAGE) {
- if(gwin->menuobj[i]) DisposeObject(gwin->menuobj[i]);
+ if(md[i] == NULL) continue;
+ if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
- ami_utf8_free(gwin->menulab[i]);
+ ami_utf8_free(md[i]->menulab);
if(i >= AMI_MENU_AREXX) {
- if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data);
- gwin->menu_hook[i].h_Data = NULL;
+ if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
+ md[i]->menu_hook.h_Data = NULL;
}
}
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menukey[i] = 0;
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ md[i]->menutype = 0;
+ free(md[i]);
}
-
- free(gwin->menutype);
- gwin->menutype = NULL;
}
-static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
const char *restrict label, char key, const char *restrict icon,
- void *restrict func, void *restrict hookdata)
+ void *restrict func, void *restrict hookdata, UWORD flags)
{
char menu_icon[1024];
- gwin->menutype[num] = type;
+ 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)) {
- gwin->menulab[num] = NM_BARLABEL;
- } else {
+ md[num]->menulab = NM_BARLABEL;
+ } 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 **)&gwin->menulab[num]);
+ (char **)&md[num]->menulab);
} else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
- gwin->menulab[num] = strdup(label);
+ md[num]->menulab = strdup(label);
} else {
- gwin->menulab[num] = ami_utf8_easy(messages_get(label));
+ md[num]->menulab = ami_utf8_easy(messages_get(label));
}
}
- gwin->menuicon[num] = NULL;
- if(key) gwin->menukey[num] = key;
- if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func;
- if(hookdata) gwin->menu_hook[num].h_Data = hookdata;
+ md[num]->menuicon = NULL;
+ if(key) md[num]->menukey = key;
+ if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
+ if(hookdata) md[num]->menu_hook.h_Data = hookdata;
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
if(icon) {
if(ami_locate_resource(menu_icon, icon) == true) {
- gwin->menuicon[num] = (char *)strdup(menu_icon);
+ md[num]->menuicon = (char *)strdup(menu_icon);
} else {
/* If the requested icon can't be found, put blank space in instead */
- gwin->menuicon[num] = (char *)strdup(NSA_SPACE);
+ md[num]->menuicon = (char *)strdup(NSA_SPACE);
}
}
}
#endif
}
-static void ami_init_menulabs(struct gui_window_2 *gwin)
+static void ami_init_menulabs(struct ami_menu_data **md)
{
- int i;
-
- gwin->menutype = calloc(1, sizeof(UBYTE) * (AMI_MENU_AREXX_MAX + 1));
+ UWORD js_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(enable_javascript) == true)
+ js_flags |= CHECKED;
- for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
- {
- gwin->menutype[i] = NM_IGNORE;
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menuicon[i] = NULL;
- }
+ UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(foreground_images) == true)
+ imgfore_flags |= CHECKED;
- ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
- ami_menu_item_project_newwin, NULL);
- ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL);
- ami_menu_alloc_item(gwin, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, "TBImages:list_saveas", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE);
- ami_menu_alloc_item(gwin, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT);
- ami_menu_alloc_item(gwin, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE);
+ UWORD imgback_flags = CHECKIT | MENUTOGGLE;
+ 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_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, 0, 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_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", 0, 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_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(gwin, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF);
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- ami_menu_alloc_item(gwin, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF);
- ami_menu_alloc_item(gwin, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PRINT, NM_ITEM, "PrintNS", 'P', "TBImages:list_print",
- ami_menu_item_project_print, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL);
- ami_menu_alloc_item(gwin, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_ABOUT, NM_ITEM, "About", '?', "TBImages:list_info",
- ami_menu_item_project_about, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_QUIT, NM_ITEM, "Quit", 'Q', "TBImages:list_warning",
- ami_menu_item_project_quit, NULL);
-
- ami_menu_alloc_item(gwin, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CUT, NM_ITEM, "CutNS", 'X', "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL);
- ami_menu_alloc_item(gwin, M_COPY, NM_ITEM, "CopyNS", 'C', "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL);
- ami_menu_alloc_item(gwin, M_PASTE, NM_ITEM, "PasteNS", 'V', "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
- ami_menu_item_edit_selectall, NULL);
- ami_menu_alloc_item(gwin, M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_UNDO, NM_ITEM, "Undo", 'Z', "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL);
- ami_menu_alloc_item(gwin, M_REDO, NM_ITEM, "Redo", 'Y', "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL);
-
- ami_menu_alloc_item(gwin, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_FIND, NM_ITEM, "FindTextNS", 'F', "TBImages:list_search",
- ami_menu_item_browser_find, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL);
- ami_menu_alloc_item(gwin, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALE, NM_ITEM, "ScaleNS", 0, "TBImages:list_preview", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL);
- ami_menu_alloc_item(gwin, M_SCALENRM, NM_SUB, "ScaleNorm", '=', "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL);
- ami_menu_alloc_item(gwin, M_SCALEINC, NM_SUB, "ScaleInc", '+', "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL);
- ami_menu_alloc_item(gwin, M_IMAGES, NM_ITEM, "Images", 0, "TBImages:list_image", NULL, NULL);
- ami_menu_alloc_item(gwin, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
- ami_menu_item_browser_foreimg, NULL);
- ami_menu_alloc_item(gwin, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
- ami_menu_item_browser_backimg, NULL);
- ami_menu_alloc_item(gwin, M_JS, NM_ITEM, "EnableJS", 0, NULL,
- ami_menu_item_browser_enablejs, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_REDRAW, NM_ITEM, "Redraw", 0, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL);
-
- ami_menu_alloc_item(gwin, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HLADD, NM_ITEM, "HotlistAdd", 'B', "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL);
- ami_menu_alloc_item(gwin, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL);
- ami_menu_alloc_item(gwin, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
-
- ami_menu_alloc_item(gwin, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PREDIT, NM_ITEM, "SettingsEdit", 0, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL);
- ami_menu_alloc_item(gwin, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL);
- ami_menu_alloc_item(gwin, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "TBImages:list_use",
- ami_menu_item_settings_save, NULL);
-
- ami_menu_alloc_item(gwin, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL);
- ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", 0, 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_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_item_project_closetab, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "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_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_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_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, 0, 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_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_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", 0, 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_item_browser_localhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "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_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_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", 0, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
+ ami_menu_item_browser_foreimg, NULL, imgfore_flags);
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
+ ami_menu_item_browser_backimg, NULL, imgback_flags);
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", 0, 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_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_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, 0, 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_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_item_settings_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "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_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);
}
/* Menu refresh for hotlist */
@@ -741,7 +776,7 @@ void ami_menu_refresh(struct gui_window_2 *gwin)
ami_menu_free(gwin);
LOG("Freeing menu labels");
- ami_free_menulabs(gwin);
+ ami_free_menulabs(gwin->menu_data);
LOG("Creating new menu");
menu = ami_menu_create(gwin);
@@ -794,16 +829,16 @@ void ami_menu_free_glyphs(void)
#endif
}
-static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp)
+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, gwin->menulab[j], strlen(gwin->menulab[j]));
+ item_size = TextLength(rp, md[j]->menulab, strlen(md[j]->menulab));
item_size += space_width;
- if(gwin->menukey[j]) {
- item_size += TextLength(rp, &gwin->menukey[j], 1);
+ 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
*/
@@ -813,7 +848,7 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
}
- if(gwin->menuicon[j]) {
+ if(md[j]->menuicon) {
item_size += 16;
}
@@ -821,11 +856,14 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
}
-static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
+struct Menu *ami_menu_layout(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);
@@ -833,34 +871,41 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(menu_glyphs_loaded == false)
ami_menu_load_glyphs(dri);
- for(i=0; i < AMI_MENU_AREXX_MAX; i++)
- {
- if(gwin->menutype[i] == NM_TITLE) {
+ 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(gwin->menulab[j] != NM_BARLABEL) {
- if(gwin->menutype[j] == NM_ITEM) {
- int item_size = ami_menu_calc_item_width(gwin, j, rp);
+ 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((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
+ } 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((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
+ 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, gwin->menuicon[i],
+ BITMAP_SourceFile, md[i]->menuicon,
BITMAP_Masking, TRUE,
BitMapEnd;
@@ -872,15 +917,15 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
GetAttr(IA_Width, icon, (ULONG *)&icon_width);
- if(gwin->menutype[i] != NM_SUB) {
+ if(md[i]->menutype != NM_SUB) {
left_posn = txtlen;
}
left_posn = left_posn -
- TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
+ TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
@@ -890,81 +935,66 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
TAG_DONE);
}
- gwin->menuobj[i] = LabelObj,
+ md[i]->menuobj = LabelObj,
LABEL_MenuMode, TRUE,
LABEL_DrawInfo, dri,
LABEL_DisposeImage, TRUE,
LABEL_Image, icon,
LABEL_Text, " ",
- LABEL_Text, gwin->menulab[i],
+ LABEL_Text, md[i]->menulab,
LABEL_DisposeImage, TRUE,
LABEL_Image, submenuarrow,
LabelEnd;
- if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
+ if(md[i]->menuobj) md[i]->menutype |= MENU_IMAGE;
}
}
#endif
- gwin->menu[i].nm_Type = gwin->menutype[i];
+ nm[i].nm_Type = md[i]->menutype;
- if(gwin->menuobj[i])
- gwin->menu[i].nm_Label = (void *)gwin->menuobj[i];
+ if(md[i]->menuobj)
+ nm[i].nm_Label = (void *)md[i]->menuobj;
else
- gwin->menu[i].nm_Label = gwin->menulab[i];
+ nm[i].nm_Label = md[i]->menulab;
- if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
- gwin->menu[i].nm_Flags = 0;
- if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
+ if(md[i]->menukey) 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;
- if(gwin->menuicon[i]) {
- free(gwin->menuicon[i]);
- gwin->menuicon[i] = NULL;
+ if(md[i]->menuicon) {
+ free(md[i]->menuicon);
+ md[i]->menuicon = NULL;
}
}
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 gwin;
+ return imenu;
}
void ami_menu_free(struct gui_window_2 *gwin)
{
FreeMenus(gwin->imenu);
- FreeVisualInfo(gwin->vi);
}
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
- gwin->menu = calloc(1, sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1));
- ami_init_menulabs(gwin);
- ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
- ami_menu_arexx_scan(gwin);
- gwin = ami_menu_layout(gwin);
-
- gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- gwin->menu[M_JS].nm_Flags |= CHECKED;
-
- gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED;
-
- gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- gwin->menu[M_IMGFORE].nm_Flags |= CHECKED;
- gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
-
- gwin->vi = GetVisualInfo(scrn, TAG_DONE);
- gwin->imenu = CreateMenus(gwin->menu, TAG_DONE);
- LayoutMenus(gwin->imenu, gwin->vi,
- GTMN_NewLookMenus, TRUE, TAG_DONE);
- free(gwin->menu); /**\todo this should be local to this function */
- gwin->menu = NULL;
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin->menu_data); //\todo this needs to be MenuClass created
+ 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 gui_window_2 *gwin)
+void ami_menu_arexx_scan(struct ami_menu_data **md)
{
/**\todo Rewrite this to not use ExAll() **/
int item = AMI_MENU_AREXX;
@@ -993,14 +1023,13 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
if(item >= AMI_MENU_AREXX_MAX) continue;
if(EAD_IS_FILE(ead)) {
- gwin->menu[item].nm_Type = NM_ITEM;
if(ead->ed_Comment[0] != '\0')
menu_lab = ead->ed_Comment;
else
menu_lab = ead->ed_Name;
- ami_menu_alloc_item(gwin, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
- ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name));
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
+ ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
item++;
}
@@ -1013,15 +1042,15 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
UnLock(lock);
}
- gwin->menu[item].nm_Type = NM_END;
- gwin->menu[item].nm_Label = NULL;
+ ami_menu_alloc_item(md, item, NM_END, NULL, 0, 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;
- struct gui_window_2 *gw = (struct gui_window_2 *)userdata;
+ UWORD flags = 0;
+ struct ami_menu_data **md = (struct ami_menu_data **)userdata;
if(item >= AMI_MENU_HOTLIST_MAX) return false;
@@ -1046,19 +1075,21 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
if (icon == NULL) icon = ASPrintf("icons/content.png");
}
- ami_menu_alloc_item(gw, item, type, title,
- 0, icon, ami_menu_item_hotlist_entries, (void *)url);
- if((is_folder == true) && (type == NM_SUB))
- gw->menu[item].nm_Flags = NM_ITEMDISABLED;
+ if((is_folder == true) && (type == NM_SUB)) {
+ flags = NM_ITEMDISABLED;
+ }
+
+ ami_menu_alloc_item(md, item, type, title,
+ 0, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
if(icon) FreeVec(icon);
return true;
}
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md)
{
- return ami_hotlist_scan((void *)gwin, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
+ return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
void ami_menu_update_checked(struct gui_window_2 *gwin)
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
old mode 100755
new mode 100644
index ac74f38..1f6f245
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -24,6 +24,7 @@
#include <libraries/gadtools.h>
struct hlcache_handle;
+struct ami_menu_data;
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -132,13 +133,18 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct gui_window_2 *gwin);
+void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
+void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
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_glyphs(void);
void ami_menu_free(struct gui_window_2 *gwin);
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
+ const char *restrict label, char 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);
/**
* Sets that an item linked to a toggle menu item has been changed.
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/gui.c | 2 +-
frontends/amiga/gui.h | 11 +-
frontends/amiga/menu.c | 463 ++++++++++++++++++++++++++----------------------
frontends/amiga/menu.h | 8 +-
4 files changed, 258 insertions(+), 226 deletions(-)
mode change 100755 => 100644 frontends/amiga/menu.h
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index f94090b..74cd5a3 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4590,7 +4590,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);
+ ami_free_menulabs(g->shared->menu_data);
ami_menu_free(g->shared);
free(g->shared->wintitle);
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 4c3e586..a176df1 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -110,6 +110,8 @@ struct ami_generic_window {
const struct ami_win_event_table *tbl;
};
+struct ami_menu_data;
+
struct gui_window_2 {
struct ami_generic_window w;
struct Window *win;
@@ -132,13 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- char *restrict menulab[AMI_MENU_AREXX_MAX + 1];
- Object *restrict menuobj[AMI_MENU_AREXX_MAX + 1];
- char menukey[AMI_MENU_AREXX_MAX + 1];
- char *restrict menuicon[AMI_MENU_AREXX_MAX + 1];
- struct Hook menu_hook[AMI_MENU_AREXX_MAX + 1];
- UBYTE *menutype;
- struct NewMenu *menu;
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
@@ -163,7 +159,6 @@ struct gui_window_2 {
struct MinList *shared_pens;
gui_pointer_shape mouse_pointer;
struct Menu *imenu; /* Intuition menu */
- struct VisualInfo *vi; /* For GadTools menu */
bool closed; /* Window has been closed (via menu) */
};
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index dc5514b..97b00f9 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-9,2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-9, 2013, 2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -88,6 +88,16 @@ enum {
NSA_GLYPH_MAX
};
+struct ami_menu_data {
+ char *restrict menulab;
+ Object *restrict menuobj;
+ char menukey;
+ char *restrict menuicon;
+ struct Hook menu_hook;
+ UBYTE menutype;
+ UWORD flags;
+};
+
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
@@ -97,8 +107,8 @@ static bool menu_glyphs_loaded = false;
const char * const netsurf_version;
const char * const verdate;
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
-void ami_menu_arexx_scan(struct gui_window_2 *gwin);
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md);
+void ami_menu_arexx_scan(struct ami_menu_data **md);
void ami_menu_set_check_toggled(void)
{
@@ -535,194 +545,219 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
/* menu creation code */
+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)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
+ }
+
+ ami_utf8_free(md[i]->menulab);
+ }
-void ami_free_menulabs(struct gui_window_2 *gwin)
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ 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(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL)) {
- if(gwin->menutype[i] & MENU_IMAGE) {
- if(gwin->menuobj[i]) DisposeObject(gwin->menuobj[i]);
+ if(md[i] == NULL) continue;
+ if(md[i]->menulab && (md[i]->menulab != NM_BARLABEL)) {
+ if(md[i]->menutype & MENU_IMAGE) {
+ if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
}
- ami_utf8_free(gwin->menulab[i]);
+ ami_utf8_free(md[i]->menulab);
if(i >= AMI_MENU_AREXX) {
- if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data);
- gwin->menu_hook[i].h_Data = NULL;
+ if(md[i]->menu_hook.h_Data) free(md[i]->menu_hook.h_Data);
+ md[i]->menu_hook.h_Data = NULL;
}
}
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menukey[i] = 0;
+ md[i]->menulab = NULL;
+ md[i]->menuobj = NULL;
+ md[i]->menukey = 0;
+ md[i]->menutype = 0;
+ free(md[i]);
}
-
- free(gwin->menutype);
- gwin->menutype = NULL;
}
-static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
const char *restrict label, char key, const char *restrict icon,
- void *restrict func, void *restrict hookdata)
+ void *restrict func, void *restrict hookdata, UWORD flags)
{
char menu_icon[1024];
- gwin->menutype[num] = type;
+ 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)) {
- gwin->menulab[num] = NM_BARLABEL;
- } else {
+ md[num]->menulab = NM_BARLABEL;
+ } 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 **)&gwin->menulab[num]);
+ (char **)&md[num]->menulab);
} else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
- gwin->menulab[num] = strdup(label);
+ md[num]->menulab = strdup(label);
} else {
- gwin->menulab[num] = ami_utf8_easy(messages_get(label));
+ md[num]->menulab = ami_utf8_easy(messages_get(label));
}
}
- gwin->menuicon[num] = NULL;
- if(key) gwin->menukey[num] = key;
- if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func;
- if(hookdata) gwin->menu_hook[num].h_Data = hookdata;
+ md[num]->menuicon = NULL;
+ if(key) md[num]->menukey = key;
+ if(func) md[num]->menu_hook.h_Entry = (HOOKFUNC)func;
+ if(hookdata) md[num]->menu_hook.h_Data = hookdata;
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) {
if(icon) {
if(ami_locate_resource(menu_icon, icon) == true) {
- gwin->menuicon[num] = (char *)strdup(menu_icon);
+ md[num]->menuicon = (char *)strdup(menu_icon);
} else {
/* If the requested icon can't be found, put blank space in instead */
- gwin->menuicon[num] = (char *)strdup(NSA_SPACE);
+ md[num]->menuicon = (char *)strdup(NSA_SPACE);
}
}
}
#endif
}
-static void ami_init_menulabs(struct gui_window_2 *gwin)
+static void ami_init_menulabs(struct ami_menu_data **md)
{
- int i;
-
- gwin->menutype = calloc(1, sizeof(UBYTE) * (AMI_MENU_AREXX_MAX + 1));
+ UWORD js_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(enable_javascript) == true)
+ js_flags |= CHECKED;
- for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
- {
- gwin->menutype[i] = NM_IGNORE;
- gwin->menulab[i] = NULL;
- gwin->menuobj[i] = NULL;
- gwin->menuicon[i] = NULL;
- }
+ UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
+ if(nsoption_bool(foreground_images) == true)
+ imgfore_flags |= CHECKED;
- ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
- ami_menu_item_project_newwin, NULL);
- ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
- ami_menu_item_project_newtab, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
- ami_menu_item_project_open, NULL);
- ami_menu_alloc_item(gwin, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, "TBImages:list_saveas", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE);
- ami_menu_alloc_item(gwin, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT);
- ami_menu_alloc_item(gwin, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE);
+ UWORD imgback_flags = CHECKIT | MENUTOGGLE;
+ 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_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, 0, 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_item_project_save, (void *)AMINS_SAVE_SOURCE, 0);
+ ami_menu_alloc_item(md, M_SAVETXT, NM_SUB, "TextNS", 0, 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_item_project_save, (void *)AMINS_SAVE_COMPLETE, 0);
#ifdef WITH_PDF_EXPORT
- ami_menu_alloc_item(gwin, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_PDF);
+ ami_menu_alloc_item(md, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
+ ami_menu_item_project_save, (void *)AMINS_SAVE_PDF, 0);
#endif
- ami_menu_alloc_item(gwin, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
- ami_menu_item_project_save, (void *)AMINS_SAVE_IFF);
- ami_menu_alloc_item(gwin, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PRINT, NM_ITEM, "PrintNS", 'P', "TBImages:list_print",
- ami_menu_item_project_print, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', "TBImages:list_remove",
- ami_menu_item_project_closetab, NULL);
- ami_menu_alloc_item(gwin, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
- ami_menu_item_project_closewin, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_ABOUT, NM_ITEM, "About", '?', "TBImages:list_info",
- ami_menu_item_project_about, NULL);
- ami_menu_alloc_item(gwin, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_QUIT, NM_ITEM, "Quit", 'Q', "TBImages:list_warning",
- ami_menu_item_project_quit, NULL);
-
- ami_menu_alloc_item(gwin, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_CUT, NM_ITEM, "CutNS", 'X', "TBImages:list_cut",
- ami_menu_item_edit_cut, NULL);
- ami_menu_alloc_item(gwin, M_COPY, NM_ITEM, "CopyNS", 'C', "TBImages:list_copy",
- ami_menu_item_edit_copy, NULL);
- ami_menu_alloc_item(gwin, M_PASTE, NM_ITEM, "PasteNS", 'V', "TBImages:list_paste",
- ami_menu_item_edit_paste, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
- ami_menu_item_edit_selectall, NULL);
- ami_menu_alloc_item(gwin, M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
- ami_menu_item_edit_clearsel, NULL);
- ami_menu_alloc_item(gwin, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_UNDO, NM_ITEM, "Undo", 'Z', "TBImages:list_undo",
- ami_menu_item_edit_undo, NULL);
- ami_menu_alloc_item(gwin, M_REDO, NM_ITEM, "Redo", 'Y', "TBImages:list_redo",
- ami_menu_item_edit_redo, NULL);
-
- ami_menu_alloc_item(gwin, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_FIND, NM_ITEM, "FindTextNS", 'F', "TBImages:list_search",
- ami_menu_item_browser_find, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_localhistory, NULL);
- ami_menu_alloc_item(gwin, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "TBImages:list_history",
- ami_menu_item_browser_globalhistory, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, "TBImages:list_internet",
- ami_menu_item_browser_cookies, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALE, NM_ITEM, "ScaleNS", 0, "TBImages:list_preview", NULL, NULL);
- ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', "TBImages:list_zoom_out",
- ami_menu_item_browser_scale_decrease, NULL);
- ami_menu_alloc_item(gwin, M_SCALENRM, NM_SUB, "ScaleNorm", '=', "TBImages:list_zoom_100",
- ami_menu_item_browser_scale_normal, NULL);
- ami_menu_alloc_item(gwin, M_SCALEINC, NM_SUB, "ScaleInc", '+', "TBImages:list_zoom_in",
- ami_menu_item_browser_scale_increase, NULL);
- ami_menu_alloc_item(gwin, M_IMAGES, NM_ITEM, "Images", 0, "TBImages:list_image", NULL, NULL);
- ami_menu_alloc_item(gwin, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
- ami_menu_item_browser_foreimg, NULL);
- ami_menu_alloc_item(gwin, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
- ami_menu_item_browser_backimg, NULL);
- ami_menu_alloc_item(gwin, M_JS, NM_ITEM, "EnableJS", 0, NULL,
- ami_menu_item_browser_enablejs, NULL);
- ami_menu_alloc_item(gwin, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_REDRAW, NM_ITEM, "Redraw", 0, "TBImages:list_wand",
- ami_menu_item_browser_redraw, NULL);
-
- ami_menu_alloc_item(gwin, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_HLADD, NM_ITEM, "HotlistAdd", 'B', "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL);
- ami_menu_alloc_item(gwin, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL);
- ami_menu_alloc_item(gwin, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
-
- ami_menu_alloc_item(gwin, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_PREDIT, NM_ITEM, "SettingsEdit", 0, "TBImages:list_prefs",
- ami_menu_item_settings_edit, NULL);
- ami_menu_alloc_item(gwin, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, "TBImages:list_hold",
- ami_menu_item_settings_snapshot, NULL);
- ami_menu_alloc_item(gwin, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "TBImages:list_use",
- ami_menu_item_settings_save, NULL);
-
- ami_menu_alloc_item(gwin, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL);
- ami_menu_alloc_item(gwin, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', "TBImages:list_arexx",
- ami_menu_item_arexx_execute, NULL);
- ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
- gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
+ ami_menu_alloc_item(md, M_SAVEIFF, NM_SUB, "IFF", 0, 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_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_item_project_closetab, NULL, 0);
+ ami_menu_alloc_item(md, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, "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_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_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_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, 0, 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_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_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", 0, 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_item_browser_localhistory, NULL, 0);
+ ami_menu_alloc_item(md, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, "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_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_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", 0, "TBImages:list_image", NULL, NULL, 0);
+ ami_menu_alloc_item(md, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
+ ami_menu_item_browser_foreimg, NULL, imgfore_flags);
+ ami_menu_alloc_item(md, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
+ ami_menu_item_browser_backimg, NULL, imgback_flags);
+ ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", 0, 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_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_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, 0, 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_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_item_settings_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, M_PRSAVE, NM_ITEM, "SettingsSave", 0, "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_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);
}
/* Menu refresh for hotlist */
@@ -741,7 +776,7 @@ void ami_menu_refresh(struct gui_window_2 *gwin)
ami_menu_free(gwin);
LOG("Freeing menu labels");
- ami_free_menulabs(gwin);
+ ami_free_menulabs(gwin->menu_data);
LOG("Creating new menu");
menu = ami_menu_create(gwin);
@@ -794,16 +829,16 @@ void ami_menu_free_glyphs(void)
#endif
}
-static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp)
+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, gwin->menulab[j], strlen(gwin->menulab[j]));
+ item_size = TextLength(rp, md[j]->menulab, strlen(md[j]->menulab));
item_size += space_width;
- if(gwin->menukey[j]) {
- item_size += TextLength(rp, &gwin->menukey[j], 1);
+ 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
*/
@@ -813,7 +848,7 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
}
- if(gwin->menuicon[j]) {
+ if(md[j]->menuicon) {
item_size += 16;
}
@@ -821,11 +856,14 @@ static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct Ras
}
-static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
+struct Menu *ami_menu_layout(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);
@@ -833,34 +871,41 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(menu_glyphs_loaded == false)
ami_menu_load_glyphs(dri);
- for(i=0; i < AMI_MENU_AREXX_MAX; i++)
- {
- if(gwin->menutype[i] == NM_TITLE) {
+ 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(gwin->menulab[j] != NM_BARLABEL) {
- if(gwin->menutype[j] == NM_ITEM) {
- int item_size = ami_menu_calc_item_width(gwin, j, rp);
+ 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((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
+ } 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((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
+ 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, gwin->menuicon[i],
+ BITMAP_SourceFile, md[i]->menuicon,
BITMAP_Masking, TRUE,
BitMapEnd;
@@ -872,15 +917,15 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
GetAttr(IA_Width, icon, (ULONG *)&icon_width);
- if(gwin->menutype[i] != NM_SUB) {
+ if(md[i]->menutype != NM_SUB) {
left_posn = txtlen;
}
left_posn = left_posn -
- TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
+ TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
icon_width - space_width;
- if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
+ if((md[i]->menutype == NM_ITEM) && (md[i+1]->menutype == NM_SUB)) {
left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
submenuarrow = NewObject(NULL, "sysiclass",
@@ -890,81 +935,66 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
TAG_DONE);
}
- gwin->menuobj[i] = LabelObj,
+ md[i]->menuobj = LabelObj,
LABEL_MenuMode, TRUE,
LABEL_DrawInfo, dri,
LABEL_DisposeImage, TRUE,
LABEL_Image, icon,
LABEL_Text, " ",
- LABEL_Text, gwin->menulab[i],
+ LABEL_Text, md[i]->menulab,
LABEL_DisposeImage, TRUE,
LABEL_Image, submenuarrow,
LabelEnd;
- if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
+ if(md[i]->menuobj) md[i]->menutype |= MENU_IMAGE;
}
}
#endif
- gwin->menu[i].nm_Type = gwin->menutype[i];
+ nm[i].nm_Type = md[i]->menutype;
- if(gwin->menuobj[i])
- gwin->menu[i].nm_Label = (void *)gwin->menuobj[i];
+ if(md[i]->menuobj)
+ nm[i].nm_Label = (void *)md[i]->menuobj;
else
- gwin->menu[i].nm_Label = gwin->menulab[i];
+ nm[i].nm_Label = md[i]->menulab;
- if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
- gwin->menu[i].nm_Flags = 0;
- if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
+ if(md[i]->menukey) 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;
- if(gwin->menuicon[i]) {
- free(gwin->menuicon[i]);
- gwin->menuicon[i] = NULL;
+ if(md[i]->menuicon) {
+ free(md[i]->menuicon);
+ md[i]->menuicon = NULL;
}
}
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 gwin;
+ return imenu;
}
void ami_menu_free(struct gui_window_2 *gwin)
{
FreeMenus(gwin->imenu);
- FreeVisualInfo(gwin->vi);
}
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
- gwin->menu = calloc(1, sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1));
- ami_init_menulabs(gwin);
- ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
- ami_menu_arexx_scan(gwin);
- gwin = ami_menu_layout(gwin);
-
- gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(enable_javascript) == true)
- gwin->menu[M_JS].nm_Flags |= CHECKED;
-
- gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED;
-
- gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(foreground_images) == true)
- gwin->menu[M_IMGFORE].nm_Flags |= CHECKED;
- gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE;
- if(nsoption_bool(background_images) == true)
- gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
-
- gwin->vi = GetVisualInfo(scrn, TAG_DONE);
- gwin->imenu = CreateMenus(gwin->menu, TAG_DONE);
- LayoutMenus(gwin->imenu, gwin->vi,
- GTMN_NewLookMenus, TRUE, TAG_DONE);
- free(gwin->menu); /**\todo this should be local to this function */
- gwin->menu = NULL;
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin->menu_data); //\todo this needs to be MenuClass created
+ 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 gui_window_2 *gwin)
+void ami_menu_arexx_scan(struct ami_menu_data **md)
{
/**\todo Rewrite this to not use ExAll() **/
int item = AMI_MENU_AREXX;
@@ -993,14 +1023,13 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) {
if(item >= AMI_MENU_AREXX_MAX) continue;
if(EAD_IS_FILE(ead)) {
- gwin->menu[item].nm_Type = NM_ITEM;
if(ead->ed_Comment[0] != '\0')
menu_lab = ead->ed_Comment;
else
menu_lab = ead->ed_Name;
- ami_menu_alloc_item(gwin, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
- ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name));
+ ami_menu_alloc_item(md, item, NM_ITEM, menu_lab, 0, NSA_SPACE,
+ ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name), 0);
item++;
}
@@ -1013,15 +1042,15 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
UnLock(lock);
}
- gwin->menu[item].nm_Type = NM_END;
- gwin->menu[item].nm_Label = NULL;
+ ami_menu_alloc_item(md, item, NM_END, NULL, 0, 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;
- struct gui_window_2 *gw = (struct gui_window_2 *)userdata;
+ UWORD flags = 0;
+ struct ami_menu_data **md = (struct ami_menu_data **)userdata;
if(item >= AMI_MENU_HOTLIST_MAX) return false;
@@ -1046,19 +1075,21 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
if (icon == NULL) icon = ASPrintf("icons/content.png");
}
- ami_menu_alloc_item(gw, item, type, title,
- 0, icon, ami_menu_item_hotlist_entries, (void *)url);
- if((is_folder == true) && (type == NM_SUB))
- gw->menu[item].nm_Flags = NM_ITEMDISABLED;
+ if((is_folder == true) && (type == NM_SUB)) {
+ flags = NM_ITEMDISABLED;
+ }
+
+ ami_menu_alloc_item(md, item, type, title,
+ 0, icon, ami_menu_item_hotlist_entries, (void *)url, flags);
if(icon) FreeVec(icon);
return true;
}
-static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md)
{
- return ami_hotlist_scan((void *)gwin, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
+ return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
void ami_menu_update_checked(struct gui_window_2 *gwin)
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
old mode 100755
new mode 100644
index ac74f38..1f6f245
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -24,6 +24,7 @@
#include <libraries/gadtools.h>
struct hlcache_handle;
+struct ami_menu_data;
/** Maximum number of hotlist items (somewhat arbitrary value) */
#define AMI_HOTLIST_ITEMS 60
@@ -132,13 +133,18 @@ enum {
struct gui_window;
struct gui_window_2;
-void ami_free_menulabs(struct gui_window_2 *gwin);
+void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
+void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
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_glyphs(void);
void ami_menu_free(struct gui_window_2 *gwin);
+void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
+ const char *restrict label, char 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);
/**
* Sets that an item linked to a toggle menu item has been changed.
--
NetSurf Browser
6 years, 8 months
netsurf: branch chris/amiga-corewindow updated. release/3.6-160-g5eb7ee9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5eb7ee97ed641e152c488...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5eb7ee97ed641e152c488da...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5eb7ee97ed641e152c488dab6...
The branch, chris/amiga-corewindow has been updated
via 5eb7ee97ed641e152c488dab6c33c37d0635e48b (commit)
via 3b1ef784fd53095213fa8b89806982567359dca4 (commit)
via eb63c1cc50847b88e598cdf0f775814a43a2799e (commit)
via a5222b579b8202f130e0afceb570b6e700385efe (commit)
via e3b2f792c0250d219dc56976f8305a05b6b04e36 (commit)
via 24b7fdf4382dcef274092b4735093fc390815455 (commit)
from 2bd8eb8c0b468799109191e63e939ea7bd69f8a1 (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=5eb7ee97ed641e152c4...
commit 5eb7ee97ed641e152c488dab6c33c37d0635e48b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Basic conversion of cookie manager to core window
slightly broken; blank window until resized; scroll bar wrong; no menu
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
old mode 100755
new mode 100644
index 15f6dce..29e41de
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -16,26 +16,216 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <proto/exec.h>
+/**
+ * \file
+ * Implementation of Amiga cookie viewer using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/space.h>
+
+#include <reaction/reaction_macros.h>
#include "desktop/cookie_manager.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
+
+#include "amiga/corewindow.h"
+#include "amiga/libs.h"
+#include "amiga/utf8.h"
+
+
+/**
+ * Amiga cookie viewer window context
+ */
+struct ami_cookie_window {
+ /** Amiga core window context */
+ struct ami_corewindow core;
+};
+
+static struct ami_cookie_window *cookie_window = NULL;
+
+/**
+ * destroy a previously created cookie view
+ */
+static nserror
+ami_cookies_destroy(void)
+{
+ nserror res;
+
+ if(cookie_window == NULL)
+ return NSERROR_OK;
+
+ res = cookie_manager_fini();
+ if (res == NSERROR_OK) {
+ res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us */
+ cookie_window = NULL;
+ }
+ return res;
+}
+
+
+/**
+ * callback for mouse action for cookie viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_mouse(struct ami_corewindow *ami_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ cookie_manager_mouse_action(mouse_state, x, y);
+
+ return NSERROR_OK;
+}
-#include "amiga/cookies.h"
-#include "amiga/tree.h"
+/**
+ * callback for keypress for cookies viewer on core window
+ *
+ * \param example_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_key(struct ami_corewindow *ami_cw, uint32_t nskey)
+{
+ if (cookie_manager_keypress(nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
-struct treeview_window *cookies_window;
+/**
+ * callback on draw event for cookies viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx The drawing context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+ cookie_manager_redraw(x, y, r, ctx);
-void ami_cookies_initialise(void)
+ return NSERROR_OK;
+}
+
+static nserror
+ami_cookies_create_window(struct ami_cookie_window *cookie_win)
{
- cookies_window = ami_tree_create(TREE_COOKIES, NULL);
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)&cookie_win->core;
+
+ ami_cw->objects[GID_CW_WIN] = WindowObj,
+ WA_ScreenTitle, ami_gui_get_screen_title(),
+ WA_Title, ami_cw->wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
+ WA_SizeBRight, TRUE,
+ WA_Top, nsoption_int(cookies_window_ypos),
+ WA_Left, nsoption_int(cookies_window_xpos),
+ WA_Width, nsoption_int(cookies_window_xsize),
+ WA_Height, nsoption_int(cookies_window_ysize),
+ WA_PubScreen, scrn,
+ WA_ReportMouse, TRUE,
+ WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort, sport,
+ WINDOW_HorizProp, 1,
+ WINDOW_VertProp, 1,
+ WINDOW_UserData, cookie_win,
+ /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ EndGroup,
+ EndWindow;
- if(!cookies_window) return;
+ if(ami_cw->objects[GID_CW_WIN] == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ return NSERROR_OK;
}
-void ami_cookies_free()
+/* exported interface documented in amiga/cookies.h */
+nserror ami_cookies_present(void)
{
- ami_tree_destroy(cookies_window);
- cookies_window = NULL;
+ struct ami_cookie_window *ncwin;
+ nserror res;
+
+ if(cookie_window != NULL) {
+ //windowtofront()
+ return NSERROR_OK;
+ }
+
+ ncwin = calloc(1, sizeof(struct ami_cookie_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Cookies"));
+
+ res = ami_cookies_create_window(ncwin);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ ami_utf8_free(ncwin->core.wintitle);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise Amiga core window */
+ ncwin->core.draw = ami_cookies_draw;
+ ncwin->core.key = ami_cookies_key;
+ ncwin->core.mouse = ami_cookies_mouse;
+ ncwin->core.close = ami_cookies_destroy;
+ ncwin->core.event = NULL;
+
+ res = ami_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ res = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ cookie_window = ncwin;
+
+ return NSERROR_OK;
}
+
diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h
old mode 100755
new mode 100644
index 157091d..6858e4c
--- a/frontends/amiga/cookies.h
+++ b/frontends/amiga/cookies.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -18,11 +18,8 @@
#ifndef AMIGA_COOKIES_H
#define AMIGA_COOKIES_H
-#include "amiga/desktop-tree.h"
-#include "amiga/tree.h"
-void ami_cookies_initialise(void);
-void ami_cookies_free(void);
-
-extern struct treeview_window *cookies_window;
+/** Open the cookie viewer */
+nserror ami_cookies_present(void);
#endif
+
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 38b980a..e5d289a 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -627,7 +627,7 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
if(ami_cw->objects[GID_CW_VSCROLL]) {
ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)height,
+ SCROLLER_Total, height,
SCROLLER_Visible, win_h,
TAG_DONE);
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index f94090b..3af51a0 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -536,6 +536,17 @@ STRPTR ami_gui_get_screen_title(void)
static void ami_set_screen_defaults(struct Screen *screen)
{
+ /* various window size/position defaults */
+ int width = screen->Width / 2;
+ int height = screen->Height / 2;
+ int top = (screen->Height / 2) - (height / 2);
+ int left = (screen->Width / 2) - (width / 2);
+
+ nsoption_default_set_int(cookies_window_ypos, top);
+ nsoption_default_set_int(cookies_window_xpos, left);
+ nsoption_default_set_int(cookies_window_xsize, width);
+ nsoption_default_set_int(cookies_window_ysize, height);
+
nsoption_default_set_int(window_x, 0);
nsoption_default_set_int(window_y, screen->BarHeight + 1);
nsoption_default_set_int(window_width, screen->Width);
@@ -1003,7 +1014,6 @@ static void gui_init2(int argc, char** argv)
/**/
ami_hotlist_initialise(nsoption_charp(hotlist_file));
- ami_cookies_initialise();
ami_global_history_initialise();
search_web_select_provider(nsoption_int(search_provider));
@@ -3028,7 +3038,6 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
ami_hotlist_free(nsoption_charp(hotlist_file));
- ami_cookies_free();
ami_global_history_free();
#ifdef __amigaos4__
if(IApplication && ami_appid)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index dc5514b..cd72269 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -358,7 +358,7 @@ HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessa
HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
{
- ami_tree_open(cookies_window,AMI_TREE_COOKIES);
+ ami_cookies_present();
}
HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index d56a1fe..28f3a4d 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -313,7 +313,7 @@ nserror ami_cert_verify(struct nsurl *url,
return res;
}
- /* initialise example core window */
+ /* initialise Amiga core window */
ncwin->core.draw = ami_crtvrfy_draw;
ncwin->core.key = ami_crtvrfy_key;
ncwin->core.mouse = ami_crtvrfy_mouse;
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/cookies.c | 216 +++++++++++++++++++++++++++++--
frontends/amiga/cookies.h | 11 +-
frontends/amiga/corewindow.c | 2 +-
frontends/amiga/gui.c | 13 +-
frontends/amiga/menu.c | 2 +-
frontends/amiga/sslcert.c | 2 +-
frontends/framebuffer/Makefile.defaults | 2 +-
frontends/framebuffer/font_freetype.c | 9 +-
frontends/framebuffer/font_internal.c | 8 +-
frontends/windows/font.c | 24 ++--
10 files changed, 244 insertions(+), 45 deletions(-)
mode change 100755 => 100644 frontends/amiga/cookies.c
mode change 100755 => 100644 frontends/amiga/cookies.h
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
old mode 100755
new mode 100644
index 15f6dce..29e41de
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -16,26 +16,216 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <proto/exec.h>
+/**
+ * \file
+ * Implementation of Amiga cookie viewer using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/space.h>
+
+#include <reaction/reaction_macros.h>
#include "desktop/cookie_manager.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
+
+#include "amiga/corewindow.h"
+#include "amiga/libs.h"
+#include "amiga/utf8.h"
+
+
+/**
+ * Amiga cookie viewer window context
+ */
+struct ami_cookie_window {
+ /** Amiga core window context */
+ struct ami_corewindow core;
+};
+
+static struct ami_cookie_window *cookie_window = NULL;
+
+/**
+ * destroy a previously created cookie view
+ */
+static nserror
+ami_cookies_destroy(void)
+{
+ nserror res;
+
+ if(cookie_window == NULL)
+ return NSERROR_OK;
+
+ res = cookie_manager_fini();
+ if (res == NSERROR_OK) {
+ res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us */
+ cookie_window = NULL;
+ }
+ return res;
+}
+
+
+/**
+ * callback for mouse action for cookie viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_mouse(struct ami_corewindow *ami_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ cookie_manager_mouse_action(mouse_state, x, y);
+
+ return NSERROR_OK;
+}
-#include "amiga/cookies.h"
-#include "amiga/tree.h"
+/**
+ * callback for keypress for cookies viewer on core window
+ *
+ * \param example_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_key(struct ami_corewindow *ami_cw, uint32_t nskey)
+{
+ if (cookie_manager_keypress(nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
-struct treeview_window *cookies_window;
+/**
+ * callback on draw event for cookies viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx The drawing context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+ cookie_manager_redraw(x, y, r, ctx);
-void ami_cookies_initialise(void)
+ return NSERROR_OK;
+}
+
+static nserror
+ami_cookies_create_window(struct ami_cookie_window *cookie_win)
{
- cookies_window = ami_tree_create(TREE_COOKIES, NULL);
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)&cookie_win->core;
+
+ ami_cw->objects[GID_CW_WIN] = WindowObj,
+ WA_ScreenTitle, ami_gui_get_screen_title(),
+ WA_Title, ami_cw->wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
+ WA_SizeBRight, TRUE,
+ WA_Top, nsoption_int(cookies_window_ypos),
+ WA_Left, nsoption_int(cookies_window_xpos),
+ WA_Width, nsoption_int(cookies_window_xsize),
+ WA_Height, nsoption_int(cookies_window_ysize),
+ WA_PubScreen, scrn,
+ WA_ReportMouse, TRUE,
+ WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort, sport,
+ WINDOW_HorizProp, 1,
+ WINDOW_VertProp, 1,
+ WINDOW_UserData, cookie_win,
+ /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ EndGroup,
+ EndWindow;
- if(!cookies_window) return;
+ if(ami_cw->objects[GID_CW_WIN] == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ return NSERROR_OK;
}
-void ami_cookies_free()
+/* exported interface documented in amiga/cookies.h */
+nserror ami_cookies_present(void)
{
- ami_tree_destroy(cookies_window);
- cookies_window = NULL;
+ struct ami_cookie_window *ncwin;
+ nserror res;
+
+ if(cookie_window != NULL) {
+ //windowtofront()
+ return NSERROR_OK;
+ }
+
+ ncwin = calloc(1, sizeof(struct ami_cookie_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Cookies"));
+
+ res = ami_cookies_create_window(ncwin);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ ami_utf8_free(ncwin->core.wintitle);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise Amiga core window */
+ ncwin->core.draw = ami_cookies_draw;
+ ncwin->core.key = ami_cookies_key;
+ ncwin->core.mouse = ami_cookies_mouse;
+ ncwin->core.close = ami_cookies_destroy;
+ ncwin->core.event = NULL;
+
+ res = ami_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ res = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ cookie_window = ncwin;
+
+ return NSERROR_OK;
}
+
diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h
old mode 100755
new mode 100644
index 157091d..6858e4c
--- a/frontends/amiga/cookies.h
+++ b/frontends/amiga/cookies.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 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/
*
@@ -18,11 +18,8 @@
#ifndef AMIGA_COOKIES_H
#define AMIGA_COOKIES_H
-#include "amiga/desktop-tree.h"
-#include "amiga/tree.h"
-void ami_cookies_initialise(void);
-void ami_cookies_free(void);
-
-extern struct treeview_window *cookies_window;
+/** Open the cookie viewer */
+nserror ami_cookies_present(void);
#endif
+
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 38b980a..e5d289a 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -627,7 +627,7 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
if(ami_cw->objects[GID_CW_VSCROLL]) {
ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- SCROLLER_Total, (ULONG)height,
+ SCROLLER_Total, height,
SCROLLER_Visible, win_h,
TAG_DONE);
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index f94090b..3af51a0 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -536,6 +536,17 @@ STRPTR ami_gui_get_screen_title(void)
static void ami_set_screen_defaults(struct Screen *screen)
{
+ /* various window size/position defaults */
+ int width = screen->Width / 2;
+ int height = screen->Height / 2;
+ int top = (screen->Height / 2) - (height / 2);
+ int left = (screen->Width / 2) - (width / 2);
+
+ nsoption_default_set_int(cookies_window_ypos, top);
+ nsoption_default_set_int(cookies_window_xpos, left);
+ nsoption_default_set_int(cookies_window_xsize, width);
+ nsoption_default_set_int(cookies_window_ysize, height);
+
nsoption_default_set_int(window_x, 0);
nsoption_default_set_int(window_y, screen->BarHeight + 1);
nsoption_default_set_int(window_width, screen->Width);
@@ -1003,7 +1014,6 @@ static void gui_init2(int argc, char** argv)
/**/
ami_hotlist_initialise(nsoption_charp(hotlist_file));
- ami_cookies_initialise();
ami_global_history_initialise();
search_web_select_provider(nsoption_int(search_provider));
@@ -3028,7 +3038,6 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
ami_hotlist_free(nsoption_charp(hotlist_file));
- ami_cookies_free();
ami_global_history_free();
#ifdef __amigaos4__
if(IApplication && ami_appid)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index dc5514b..cd72269 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -358,7 +358,7 @@ HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessa
HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
{
- ami_tree_open(cookies_window,AMI_TREE_COOKIES);
+ ami_cookies_present();
}
HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index d56a1fe..28f3a4d 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -313,7 +313,7 @@ nserror ami_cert_verify(struct nsurl *url,
return res;
}
- /* initialise example core window */
+ /* initialise Amiga core window */
ncwin->core.draw = ami_crtvrfy_draw;
ncwin->core.key = ami_crtvrfy_key;
ncwin->core.mouse = ami_crtvrfy_mouse;
diff --git a/frontends/framebuffer/Makefile.defaults b/frontends/framebuffer/Makefile.defaults
index 92d837e..cc712e9 100644
--- a/frontends/framebuffer/Makefile.defaults
+++ b/frontends/framebuffer/Makefile.defaults
@@ -47,5 +47,5 @@ NETSURF_FRAMEBUFFER_RESOURCES := $(PREFIX)/share/netsurf/
NETSURF_FB_RESPATH := $${HOME}/.netsurf/:$${NETSURFRES}:$(NETSURF_FRAMEBUFFER_RESOURCES):./frontends/framebuffer/res
# freetype compiled in font serch path
-NETSURF_FB_FONTPATH := /usr/share/fonts/truetype/ttf-dejavu:/usr/share/fonts/truetype/msttcorefonts
+NETSURF_FB_FONTPATH := /usr/share/fonts/truetype/dejavu:/usr/share/fonts/truetype/msttcorefonts
diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c
index 9235ad4..3239820 100644
--- a/frontends/framebuffer/font_freetype.c
+++ b/frontends/framebuffer/font_freetype.c
@@ -444,8 +444,7 @@ fb_font_width(const plot_font_style_t *fstyle,
*width += glyph->advance.x >> 16;
}
-
- return true;
+ return NSERROR_OK;
}
@@ -481,7 +480,7 @@ fb_font_position(const plot_font_style_t *fstyle,
*actual_x = prev_x;
*char_offset = nxtchr;
- return true;
+ return NSERROR_OK;
}
@@ -537,7 +536,7 @@ fb_font_split(const plot_font_style_t *fstyle,
* found a space; return previous space */
*actual_x = last_space_x;
*char_offset = last_space_idx;
- return true;
+ return NSERROR_OK;
}
nxtchr = utf8_next(string, length, nxtchr);
@@ -545,7 +544,7 @@ fb_font_split(const plot_font_style_t *fstyle,
*char_offset = nxtchr;
- return true;
+ return NSERROR_OK;
}
static struct gui_layout_table layout_table = {
diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c
index 9164a29..3fd3ac6 100644
--- a/frontends/framebuffer/font_internal.c
+++ b/frontends/framebuffer/font_internal.c
@@ -364,7 +364,7 @@ fb_font_width(const plot_font_style_t *fstyle,
}
*width *= fb_get_font_size(fstyle);
- return true;
+ return NSERROR_OK;
}
@@ -397,7 +397,7 @@ fb_font_position(const plot_font_style_t *fstyle,
*actual_x = x_pos;
*char_offset = nxtchr;
- return true;
+ return NSERROR_OK;
}
@@ -455,7 +455,7 @@ fb_font_split(const plot_font_style_t *fstyle,
* found a space; return previous space */
*actual_x = last_space_x;
*char_offset = last_space_idx;
- return true;
+ return NSERROR_OK;
}
nxtchr = utf8_next(string, length, nxtchr);
@@ -463,7 +463,7 @@ fb_font_split(const plot_font_style_t *fstyle,
*char_offset = nxtchr;
- return true;
+ return NSERROR_OK;
}
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index 551a0eb..1e99a78 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -138,7 +138,7 @@ HFONT get_font(const plot_font_style_t *style)
* \param[in] string UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[out] width updated to width of string[0..length)
- * \return true on success and width updated else false
+ * \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
win32_font_width(const plot_font_style_t *style,
@@ -150,7 +150,7 @@ win32_font_width(const plot_font_style_t *style,
HFONT font;
HFONT fontbak;
SIZE s;
- bool ret = true;
+ nserror ret = NSERROR_OK;
if (length == 0) {
*width = 0;
@@ -163,7 +163,7 @@ win32_font_width(const plot_font_style_t *style,
if (GetTextExtentPoint32A(hdc, string, length, &s) != 0) {
*width = s.cx;
} else {
- ret = false;
+ ret = NSERROR_UNKNOWN;
}
font = SelectObject(hdc, fontbak);
DeleteObject(font);
@@ -183,7 +183,7 @@ win32_font_width(const plot_font_style_t *style,
* \param x x coordinate to search for
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
+ * \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
win32_font_position(const plot_font_style_t *style,
@@ -198,7 +198,7 @@ win32_font_position(const plot_font_style_t *style,
HFONT fontbak;
SIZE s;
int offset;
- bool ret = true;
+ nserror ret = NSERROR_OK;
if ((length == 0) || (x < 1)) {
*char_offset = 0;
@@ -213,7 +213,7 @@ win32_font_position(const plot_font_style_t *style,
*char_offset = (size_t)offset;
*actual_x = s.cx;
} else {
- ret = false;
+ ret = NSERROR_UNKNOWN;
}
font = SelectObject(hdc, fontbak);
DeleteObject(font);
@@ -234,7 +234,7 @@ win32_font_position(const plot_font_style_t *style,
* \param x width available
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
+ * \return NSERROR_OK on success otherwise apropriate error code
*
* On exit, [char_offset == 0 ||
* string[char_offset] == ' ' ||
@@ -249,13 +249,14 @@ win32_font_split(const plot_font_style_t *style,
int *actual_x)
{
int c_off;
- bool ret = false;
+ nserror ret = NSERROR_UNKNOWN;
if (win32_font_position(style, string, length, x, char_offset, actual_x)) {
c_off = *char_offset;
if (*char_offset == length) {
- ret = true;
+ ret = NSERROR_OK;
} else {
+ bool success;
while ((string[*char_offset] != ' ') &&
(*char_offset > 0)) {
(*char_offset)--;
@@ -269,7 +270,10 @@ win32_font_split(const plot_font_style_t *style,
}
}
- ret = win32_font_width(style, string, *char_offset, actual_x);
+ success = win32_font_width(style, string, *char_offset, actual_x);
+ if (success) {
+ ret = NSERROR_OK;
+ }
}
}
--
NetSurf Browser
6 years, 9 months
netsurf: branch master updated. release/3.6-159-g3b1ef78
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3b1ef784fd53095213fa8...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3b1ef784fd53095213fa8b8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3b1ef784fd53095213fa8b898...
The branch, master has been updated
via 3b1ef784fd53095213fa8b89806982567359dca4 (commit)
via 2bd8eb8c0b468799109191e63e939ea7bd69f8a1 (commit)
via 64bb74bdafa216d4163d6b717271a9f45ac0d287 (commit)
via 48e95ad2b3ede2b6170b635074bf0ee1010dfb39 (commit)
via 0fafa9576e8963928c13c81524e64b624b794c98 (commit)
via 4892497a19083cf328711f28376d16133a684353 (commit)
via 4b7abde7b0449a3a3fe03b43533b8d0697f55e0d (commit)
via 98f94c4bf39db60b0b686bccc84175e15214b348 (commit)
via e7c9b863b3d2dd8579cb2c9f80f4a20933d04315 (commit)
via a9cc0792a43d108e5ff61055354422a6c7218a74 (commit)
via dab118b6f7e9a22ed01413a2ce2fd60e4c4df97b (commit)
via 3227ed655609e731f3d216706c524028f566f114 (commit)
via eb1f39fe7d80893b1f7c804eb48ec61e89f17d78 (commit)
via 31c08f39be64f739cac727ab5a13fc513d1a61aa (commit)
via c40e8197c270b1600fa7b32056a2019cd83e6f3f (commit)
via 8196f5b60241a6389ca3b76446de131a3dd2e891 (commit)
from eb63c1cc50847b88e598cdf0f775814a43a2799e (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=3b1ef784fd53095213f...
commit 3b1ef784fd53095213fa8b89806982567359dca4
Merge: eb63c1c 2bd8eb8
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Partially implement Amiga core window
Migrate SSL cert window to use core window
Core window implementation has some features missing but is good enough for SSL cert
I will improve it as I migrate the other windows.
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/Makefile | 2 +-
frontends/amiga/corewindow.c | 798 ++++++++++++++++++++++++++++++++++++++++++
frontends/amiga/corewindow.h | 155 ++++++++
frontends/amiga/gui.c | 33 +-
frontends/amiga/gui.h | 14 +-
frontends/amiga/object.h | 1 +
frontends/amiga/sslcert.c | 350 ++++++++++++++++--
frontends/amiga/sslcert.h | 22 +-
frontends/amiga/tree.c | 2 +-
9 files changed, 1335 insertions(+), 42 deletions(-)
create mode 100644 frontends/amiga/corewindow.c
create mode 100644 frontends/amiga/corewindow.h
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile
index f3c178e..8115f2f 100644
--- a/frontends/amiga/Makefile
+++ b/frontends/amiga/Makefile
@@ -46,7 +46,7 @@ S_FRONTEND := gui.c tree.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 desktop-tree.c
+ nsoption.c desktop-tree.c corewindow.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
new file mode 100644
index 0000000..38b980a
--- /dev/null
+++ b/frontends/amiga/corewindow.c
@@ -0,0 +1,798 @@
+/*
+ * 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/>.
+ */
+
+/**
+ * \file
+ * Amiga core window interface.
+ *
+ * Provides interface for core renderers to the Amiga Intuition drawable area.
+ *
+ * This module is an object that must be encapsulated. Client users
+ * should embed a struct ami_corewindow at the beginning of their
+ * context for this display surface, fill in relevant data and then
+ * call ami_corewindow_init()
+ *
+ * The Amiga core window structure requires the callback for draw, key and
+ * mouse operations.
+ */
+
+#include "amiga/os3support.h"
+
+#include <assert.h>
+#include <string.h>
+#include <math.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "netsurf/keypress.h"
+#include "netsurf/mouse.h"
+#include "desktop/plot_style.h"
+
+#include <proto/exec.h>
+#include <proto/intuition.h>
+#include <proto/layout.h>
+#include <proto/utility.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/scroller.h>
+#include <gadgets/space.h>
+#include <intuition/icclass.h>
+#include <reaction/reaction_macros.h>
+
+#include "amiga/corewindow.h"
+#include "amiga/memory.h"
+#include "amiga/misc.h"
+#include "amiga/object.h"
+#include "amiga/schedule.h"
+#include "amiga/utf8.h"
+
+static void
+ami_cw_scroller_top(struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y)
+{
+ ULONG xs = 0;
+ ULONG ys = 0;
+
+ if(ami_cw->scroll_x_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ }
+
+ if(ami_cw->scroll_y_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ }
+
+ *x = xs;
+ *y = ys;
+}
+
+
+/**
+ * Convert co-ordinates relative to space.gadget
+ * into document co-ordinates
+ *
+ * @param ami_cw core window
+ * @param x co-ordinate, will be updated to new x co-ordinate
+ * @param y co-ordinate, will be updated to new y co-ordinate
+ */
+static void
+ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
+{
+ ULONG xs = 0;
+ ULONG ys = 0;
+
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
+
+ *x = *x + xs;
+ *y = *y + ys;
+}
+
+
+/* get current mouse position in the draw area, adjusted for scroll.
+ * @return true if the mouse was in the draw area and co-ordinates updated
+ */
+static bool
+ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
+{
+ int16 xm, ym;
+ ULONG xs, ys;
+ struct IBox *bbox;
+
+ xm = ami_cw->win->MouseX;
+ ym = ami_cw->win->MouseY;
+
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return false;
+ }
+
+ xm -= bbox->Left;
+ ym -= bbox->Top;
+
+ ami_gui_free_space_box(bbox);
+
+ if((xm < 0) || (ym < 0) || (xm > bbox->Width) || (ym > bbox->Height))
+ return false;
+
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
+
+ xm += xs;
+ ym += ys;
+ *x = xm;
+ *y = ym;
+
+ return true;
+}
+
+/* handle keypress */
+static void
+ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
+{
+ ami_cw->key(ami_cw, nskey);
+
+ switch(nskey) {
+ case NS_KEY_COPY_SELECTION:
+ /* if we've copied a selection we need to clear it - style guide rules */
+ ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
+ break;
+
+ /* we may need to deal with scroll-related keys here */
+ }
+}
+
+
+/**
+ * Redraw functions
+ *
+ * This is slightly over-engineered as it was taken from the main browser/old tree redraws
+ * and supports deferred drawing of rectangles and tiling
+ */
+
+/**
+ * Redraw an area of a core window
+ *
+ * \param g a struct ami_corewindow
+ * \param r rect (in document co-ordinates)
+ */
+
+static void
+ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
+{
+ struct IBox *bbox;
+ ULONG pos_x, pos_y;
+ struct rect draw_rect;
+ int tile_size_x = ami_cw->gg.width;
+ int tile_size_y = ami_cw->gg.height;
+ int tile_x, tile_y, tile_w, tile_h;
+ int x = r->x0;
+ int y = r->y0;
+ int width = r->x1 - r->x0;
+ int height = r->y1 - r->y0;
+
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &amiplot
+ };
+
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ ami_cw_scroller_top(ami_cw, &pos_x, &pos_y);
+
+ glob = &ami_cw->gg;
+
+ if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x);
+ if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y);
+
+ if(x < pos_x) {
+ width -= pos_x - x;
+ x = pos_x;
+ }
+
+ if(y < pos_y) {
+ height -= pos_y - y;
+ y = pos_y;
+ }
+
+ for(tile_y = y; tile_y < (y + height); tile_y += tile_size_y) {
+ tile_h = tile_size_y;
+ if(((y + height) - tile_y) < tile_size_y)
+ tile_h = (y + height) - tile_y;
+
+ for(tile_x = x; tile_x < (x + width); tile_x += tile_size_x) {
+ tile_w = tile_size_x;
+ if(((x + width) - tile_x) < tile_size_x)
+ tile_w = (x + width) - tile_x;
+
+ draw_rect.x0 = tile_x; // was -
+ draw_rect.y0 = tile_y; // was -
+ draw_rect.x1 = tile_x + tile_w;
+ draw_rect.y1 = tile_y + tile_h;
+
+ ami_cw->draw(ami_cw, -tile_x, -tile_y, &draw_rect, &ctx);
+
+#ifdef __amigaos4__
+ BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
+ BLITA_Source, ami_cw->gg.bm,
+ BLITA_SrcX, 0,
+ BLITA_SrcY, 0,
+ BLITA_DestType, BLITT_RASTPORT,
+ BLITA_Dest, ami_cw->win->RPort,
+ BLITA_DestX, bbox->Left + tile_x - pos_x,
+ BLITA_DestY, bbox->Top + tile_y - pos_y,
+ BLITA_Width, tile_w,
+ BLITA_Height, tile_h,
+ TAG_DONE);
+#else
+ BltBitMapRastPort(ami_cw->gg.bm, 0, 0,
+ ami_cw->win->RPort, bbox->Left + tile_x - pos_x, bbox->Top + tile_y - pos_y,
+ tile_w, tile_h, 0xC0);
+#endif
+ }
+ }
+
+ ami_gui_free_space_box(bbox);
+ ami_clearclipreg(glob);
+ ami_gui_set_default_gg();
+}
+
+
+/**
+ * Draw the deferred rectangles
+ *
+ * @param draw set to false to just delete the queue
+ */
+static void ami_cw_redraw_queue(struct ami_corewindow *ami_cw, bool draw)
+{
+ struct nsObject *node;
+ struct nsObject *nnode;
+ struct rect *rect;
+
+ if(IsMinListEmpty(ami_cw->deferred_rects)) return;
+
+ if(draw == false) {
+ LOG("Ignoring deferred box redraw queue");
+ } // else should probably show busy pointer
+
+ node = (struct nsObject *)GetHead((struct List *)ami_cw->deferred_rects);
+
+ do {
+ if(draw == true) {
+ rect = (struct rect *)node->objstruct;
+ ami_cw_redraw_rect(ami_cw, rect);
+ }
+ nnode = (struct nsObject *)GetSucc((struct Node *)node);
+ ami_memory_itempool_free(ami_cw->deferred_rects_pool, node->objstruct, sizeof(struct rect));
+ DelObjectNoFree(node);
+ } while((node = nnode));
+}
+
+static void
+ami_cw_redraw_cb(void *p)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)p;
+
+ ami_cw_redraw_queue(ami_cw, true);
+}
+
+/**
+ * Queue a redraw of a rectangle
+ *
+ * @param ami_cw the core window to redraw
+ * @param r the rectangle (in doc coords) to redraw, or NULL for full window
+ */
+
+static void
+ami_cw_redraw(struct ami_corewindow *ami_cw, const struct rect *restrict r)
+{
+ struct nsObject *nsobj;
+ struct rect *restrict deferred_rect;
+ struct rect new_rect;
+
+ if(r == NULL) {
+ struct IBox *bbox;
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ new_rect.x0 = 0;
+ new_rect.y0 = 0;
+ ami_cw_coord_amiga_to_ns(ami_cw, &new_rect.x0, &new_rect.y0);
+ new_rect.x1 = new_rect.x0 + bbox->Width;
+ new_rect.y1 = new_rect.y0 + bbox->Height;
+
+ ami_gui_free_space_box(bbox);
+
+ r = &new_rect;
+ }
+
+ if(ami_gui_window_update_box_deferred_check(ami_cw->deferred_rects, r,
+ ami_cw->deferred_rects_pool)) {
+ deferred_rect = ami_memory_itempool_alloc(ami_cw->deferred_rects_pool, sizeof(struct rect));
+ CopyMem(r, deferred_rect, sizeof(struct rect));
+ nsobj = AddObject(ami_cw->deferred_rects, AMINS_RECT);
+ nsobj->objstruct = deferred_rect;
+ } else {
+ LOG("Ignoring duplicate or subset of queued box redraw");
+ }
+ ami_schedule(1, ami_cw_redraw_cb, ami_cw);
+}
+
+static void
+ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
+{
+ Object *scroller;
+ Object *layout;
+ ULONG tag;
+
+ if(vert == true) {
+ if(visible == ami_cw->scroll_y_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_VSCROLL];
+ layout = ami_cw->objects[GID_CW_VSCROLLLAYOUT];
+ tag = WINDOW_VertProp;
+ ami_cw->scroll_y_visible = visible;
+ }
+ } else {
+ if(visible == ami_cw->scroll_x_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_HSCROLL];
+ layout = ami_cw->objects[GID_CW_HSCROLLLAYOUT];
+ tag = WINDOW_HorizProp;
+ ami_cw->scroll_x_visible = visible;
+ }
+ }
+
+ if(visible == true) {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, 1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_ADDCHILD, ami_cw->win, scroller, NULL);
+#else
+ SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
+#endif
+ }
+ } else {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, -1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_REMOVECHILD, ami_cw->win, scroller);
+#else
+ SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
+#endif
+ }
+ }
+
+#if 0
+ /* in-window scrollbars aren't getting hidden until the window is resized
+ * this code should fix it, but it isn't working */
+ if(ami_cw->in_border_scroll == false) {
+ FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
+ RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
+ ami_cw->win, NULL, TRUE);
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
+ }
+#endif
+}
+
+static void
+ami_cw_close(void *w)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)w;
+
+ ami_cw->close(ami_cw);
+}
+
+HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw = hook->h_Data;
+ struct IntuiWheelData *wheel;
+ ULONG gid = GetTagData( GA_ID, 0, msg->IAddress );
+
+ switch(msg->Class)
+ {
+ case IDCMP_IDCMPUPDATE:
+ switch(gid)
+ {
+ case GID_CW_HSCROLL:
+ case GID_CW_VSCROLL:
+ ami_cw_redraw(ami_cw, NULL);
+ break;
+ }
+ break;
+#ifdef __amigaos4__
+ case IDCMP_EXTENDEDMOUSE:
+ if(msg->Code == IMSGCODE_INTUIWHEELDATA)
+ {
+ wheel = (struct IntuiWheelData *)msg->IAddress;
+
+ //ami_tree_scroll(twin, (wheel->WheelX * 20), (wheel->WheelY * 20));
+ }
+ break;
+#endif
+ }
+}
+
+
+/**
+ * Main event loop for our core window
+ *
+ * \return TRUE if window destroyed
+ */
+static BOOL
+ami_cw_event(void *w)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)w;
+
+ ULONG result;
+ ULONG storage;
+ uint16 code;
+ struct InputEvent *ie;
+ int nskey;
+ int key_state = 0;
+ struct timeval curtime;
+ int x = 0, y = 0;
+
+ while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
+ switch(result & WMHI_CLASSMASK) {
+ case WMHI_MOUSEMOVE:
+ if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
+ key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ }
+ break;
+
+ case WMHI_MOUSEBUTTONS:
+ if(ami_cw_mouse_pos(ami_cw, &x, &y) == false)
+ break;
+
+ key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
+
+ switch(code) {
+ case SELECTDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
+ break;
+
+ case MIDDLEDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
+ break;
+
+ case SELECTUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
+
+ if(ami_cw->lastclick.tv_sec) {
+ if(DoubleClick(ami_cw->lastclick.tv_sec,
+ ami_cw->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec))
+ ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
+ }
+
+ if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
+ } else {
+ ami_cw->lastclick.tv_sec = curtime.tv_sec;
+ ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ }
+ }
+
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+
+ case MIDDLEUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+ }
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ break;
+
+ case WMHI_RAWKEY:
+ storage = result & WMHI_GADGETMASK;
+
+ GetAttr(WINDOW_InputEvent, ami_cw->objects[GID_CW_WIN], (ULONG *)&ie);
+ nskey = ami_key_to_nskey(storage, ie);
+
+ ami_cw_key(ami_cw, nskey);
+ break;
+
+ case WMHI_NEWSIZE:
+ ami_cw_redraw(ami_cw, NULL);
+ break;
+
+ case WMHI_CLOSEWINDOW:
+ ami_cw_close(ami_cw);
+ return TRUE;
+ break;
+
+ case WMHI_GADGETUP:
+ switch(result & WMHI_GADGETMASK) {
+ case GID_CW_HSCROLL:
+ case GID_CW_VSCROLL:
+ ami_cw_redraw(ami_cw, NULL);
+ break;
+
+ default:
+ /* pass the event to the window owner */
+ if(ami_cw->event != NULL)
+ if(ami_cw->event(ami_cw, result) == TRUE) {
+ return TRUE;
+ }
+ break;
+ }
+
+ default:
+ /* pass the event to the window owner */
+ if(ami_cw->event != NULL)
+ if(ami_cw->event(ami_cw, result) == TRUE) {
+ return TRUE;
+ }
+ break;
+ }
+ };
+
+ return FALSE;
+}
+
+static const struct ami_win_event_table ami_cw_table = {
+ ami_cw_event,
+ ami_cw_close,
+};
+
+/**
+ * callback from core to request a redraw
+ */
+static void
+ami_cw_redraw_request(struct core_window *cw, const struct rect *r)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+
+ ami_cw_redraw(ami_cw, r);
+}
+
+
+static void
+ami_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+ struct IBox *bbox;
+
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ *width = bbox->Width;
+ *height = bbox->Height;
+
+ ami_gui_free_space_box(bbox);
+}
+
+
+static void
+ami_cw_update_size(struct core_window *cw, int width, int height)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+ int win_w, win_h;
+
+ ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+
+ if(width == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, false, false);
+ return;
+ }
+
+ if(height == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, true, false);
+ return;
+ }
+
+ if(ami_cw->objects[GID_CW_VSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, true, true);
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)height,
+ SCROLLER_Visible, win_h,
+ TAG_DONE);
+ }
+
+ if(ami_cw->objects[GID_CW_HSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)width,
+ SCROLLER_Visible, win_w,
+ TAG_DONE);
+ }
+}
+
+
+static void
+ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+
+ int scrollsetx;
+ int scrollsety;
+ int win_w = 0, win_h = 0;
+ ULONG win_x0, win_y0;
+ int win_x1, win_y1;
+
+ ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+
+ ami_cw_scroller_top(ami_cw, &win_x0, &win_y0);
+
+ win_x1 = win_x0 + win_w;
+ win_y1 = win_y0 + win_h;
+
+ if(r->y1 > win_y1) scrollsety = r->y1 - win_h;
+ if(r->y0 < win_y0) scrollsety = r->y0;
+ if(r->x1 > win_x1) scrollsetx = r->x1 - win_w;
+ if(r->x0 < win_x0) scrollsetx = r->x0;
+
+ if(ami_cw->scroll_y_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsety,
+ TAG_DONE);
+ }
+
+ if(ami_cw->scroll_x_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsetx,
+ TAG_DONE);
+ }
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
+}
+
+
+static void
+ami_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+ ami_cw->drag_status = ds;
+}
+
+
+struct core_window_callback_table ami_cw_cb_table = {
+ .redraw_request = ami_cw_redraw_request,
+ .update_size = ami_cw_update_size,
+ .scroll_visible = ami_cw_scroll_visible,
+ .get_window_dimensions = ami_cw_get_window_dimensions,
+ .drag_status = ami_cw_drag_status
+};
+
+/* exported function documented example/corewindow.h */
+nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
+{
+ /* setup the core window callback table */
+ ami_cw->cb_table = &ami_cw_cb_table;
+
+ /* clear some vars */
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
+ ami_cw->scroll_x_visible = true;
+ ami_cw->scroll_y_visible = true;
+ ami_cw->in_border_scroll = false;
+
+ /* allocate drawing area etc */
+ ami_init_layers(&ami_cw->gg, 0, 0, false);
+ ami_cw->gg.shared_pens = ami_AllocMinList();
+
+ ami_cw->deferred_rects = NewObjList();
+ ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
+
+ /* add the core window to our window list so we process events */
+ ami_gui_win_list_add(ami_cw, AMINS_COREWINDOW, &ami_cw_table);
+
+ /* set up the IDCMP hook for event processing (extended mouse, scrollbars) */
+ ami_cw->idcmp_hook.h_Entry = (void *)ami_cw_idcmp_hook;
+ ami_cw->idcmp_hook.h_Data = ami_cw;
+
+ /* open the window */
+ ami_cw->win = (struct Window *)RA_OpenWindow(ami_cw->objects[GID_CW_WIN]);
+
+ /* attach the scrollbars for event processing _if they are in the window border_ */
+ if(ami_cw->objects[GID_CW_HSCROLL] == NULL) {
+ GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_HSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
+ }
+
+ if(ami_cw->objects[GID_CW_VSCROLL] == NULL) {
+ GetAttr(WINDOW_VertObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_VSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_VSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
+ }
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in example/corewindow.h */
+nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
+{
+ /* remove any pending redraws */
+ ami_schedule(-1, ami_cw_redraw_cb, ami_cw);
+ FreeObjList(ami_cw->deferred_rects);
+ ami_memory_itempool_delete(ami_cw->deferred_rects_pool);
+
+ /* destroy the window */
+ ami_cw->win = NULL;
+ DisposeObject(ami_cw->objects[GID_CW_WIN]);
+
+#if 0
+ /* ensure our scrollbars are destroyed */
+ /* it appears these are disposed anyway,
+ * even if the gadgets are no longer attached to the window */
+ if(ami_cw->in_border_scroll == false) {
+ if(ami_cw->scroll_x_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_HSCROLL]);
+ }
+ if(ami_cw->scroll_y_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_VSCROLL]);
+ }
+ }
+#endif
+
+ /* release off-screen bitmap stuff */
+ ami_plot_release_pens(ami_cw->gg.shared_pens);
+ ami_free_layers(&ami_cw->gg);
+
+ /* free the window title */
+ ami_utf8_free(ami_cw->wintitle);
+
+ /* remove the core window from our window list */
+ ami_gui_win_list_remove(ami_cw);
+
+ return NSERROR_OK;
+}
+
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
new file mode 100644
index 0000000..8d93882
--- /dev/null
+++ b/frontends/amiga/corewindow.h
@@ -0,0 +1,155 @@
+/*
+ * 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/>.
+ */
+
+#ifndef AMIGA_COREWINDOW_H
+#define AMIGA_COREWINDOW_H
+
+#include "netsurf/core_window.h"
+
+#include "amiga/gui.h" /* need to know the size of ami_generic_window :( */
+#include "amiga/plotters.h"
+
+/**
+ * BOOPSI objects
+ */
+
+enum {
+ GID_CW_WIN = 0, /* window object */
+ GID_CW_MAIN, /* root layout object */
+ GID_CW_DRAW, /* drawing area (space.gadget) */
+ GID_CW_HSCROLL, /* horizontal scroller */
+ GID_CW_VSCROLL, /* vertical scroller */
+ GID_CW_HSCROLLLAYOUT, /* horizontal scroller container*/
+ GID_CW_VSCROLLLAYOUT, /* vertical scroller container */
+ GID_CW_LAST
+};
+
+/**
+ * Amiga core window state
+ */
+struct ami_corewindow {
+ /*
+ * Any variables common to any frontend window would go here.
+ * e.g. drawing area handles, toolkit pointers or other state
+ */
+ struct ami_generic_window w;
+ struct Window *win;
+ Object *objects[GID_CW_LAST];
+
+ struct Hook idcmp_hook;
+ struct timeval lastclick;
+
+ int mouse_state;
+
+ APTR deferred_rects_pool;
+ struct MinList *deferred_rects;
+
+ /** keep track of the scrollbar type we're using */
+ bool in_border_scroll;
+ bool scroll_x_visible;
+ bool scroll_y_visible;
+
+ /** window title, must be allocated wth ami_utf8 function */
+ char *wintitle;
+
+ /** stuff for our off-screen render bitmap */
+ struct gui_globals gg;
+ struct MinList *shared_pens;
+
+ /** drag status set by core */
+ core_window_drag_status drag_status;
+
+ /** table of callbacks for core window operations */
+ struct core_window_callback_table *cb_table;
+
+ /**
+ * callback to draw on drawable area of Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param x Plot origin (X)
+ * \param r Plot origin (Y)
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx Redraw context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+ nserror (*draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r,
+ struct redraw_context *ctx);
+
+ /**
+ * callback for keypress on Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
+ */
+ nserror (*key)(struct ami_corewindow *ami_cw, uint32_t nskey);
+
+ /**
+ * callback for mouse event on Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+ nserror (*mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y);
+
+ /**
+ * callback for unknown events on Amiga core window
+ * eg. buttons in the ssl cert window
+ * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP)
+ * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT)
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param result event as returned by RA_HandleInput()
+ * \return TRUE if window closed during event processing
+ */
+ BOOL (*event)(struct ami_corewindow *ami_cw, ULONG result);
+
+ /**
+ * callback to close an Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ */
+ void (*close)(struct ami_corewindow *ami_cw);
+
+};
+
+/**
+ * initialise elements of Amiga core window.
+ *
+ * As a pre-requisite the draw, key and mouse callbacks must be defined
+ *
+ * \param example_cw An Amiga core window structure to initialise
+ * \return NSERROR_OK on successful initialisation otherwise error code.
+ */
+nserror ami_corewindow_init(struct ami_corewindow *ami_cw);
+
+/**
+ * finalise elements of Amiga core window.
+ *
+ * \param ami_cw An Amiga core window structure to finialise
+ * \return NSERROR_OK on successful finalisation otherwise error code.
+ */
+nserror ami_corewindow_fini(struct ami_corewindow *ami_cw);
+
+#endif
+
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index ba0a786..f94090b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1376,27 +1376,34 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
return nskey;
}
-static void ami_update_quals(struct gui_window_2 *gwin)
+int ami_gui_get_quals(Object *win_obj)
{
uint32 quals = 0;
+ int key_state = 0;
#ifdef __amigaos4__
- GetAttr(WINDOW_Qualifier,gwin->objects[OID_MAIN],(uint32 *)&quals);
+ GetAttr(WINDOW_Qualifier, win_obj, (uint32 *)&quals);
#else
#warning qualifier needs fixing for OS3
#endif
- gwin->key_state = 0;
if(quals & NSA_QUAL_SHIFT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_1;
+ key_state |= BROWSER_MOUSE_MOD_1;
}
if(quals & IEQUALIFIER_CONTROL) {
- gwin->key_state |= BROWSER_MOUSE_MOD_2;
+ key_state |= BROWSER_MOUSE_MOD_2;
}
if(quals & NSA_QUAL_ALT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_3;
+ key_state |= BROWSER_MOUSE_MOD_3;
}
+
+ return key_state;
+}
+
+static void ami_update_quals(struct gui_window_2 *gwin)
+{
+ gwin->key_state = ami_gui_get_quals(gwin->objects[OID_MAIN]);
}
/* exported interface documented in amiga/gui.h */
@@ -1682,7 +1689,7 @@ static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HSCROLL]);
#else
- SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL]);
+ SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL], TAG_DONE);
#endif
gwin->objects[GID_HSCROLL] = NULL;
@@ -1727,7 +1734,7 @@ static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_VSCROLL]);
#else
- SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL]);
+ SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL], TAG_DONE);
#endif
gwin->objects[GID_VSCROLL] = NULL;
@@ -3259,8 +3266,10 @@ static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HOTLISTSEPBAR]);
#else
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST]);
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR]);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST], TAG_DONE);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR], TAG_DONE);
#endif
FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
@@ -4734,7 +4743,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
if(draw == true) ami_reset_pointer(g->shared);
}
-static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
+bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
const struct rect *restrict new_rect, APTR mempool)
{
struct nsObject *node;
@@ -5603,7 +5612,7 @@ static struct gui_misc_table amiga_misc_table = {
.quit = gui_quit,
.launch_url = gui_launch_url,
- .cert_verify = gui_cert_verify,
+ .cert_verify = ami_cert_verify,
.login = gui_401login_open,
};
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index eb39e9e..4c3e586 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2016 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/
*
@@ -282,5 +282,17 @@ nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_tab
* Remove a window from the NetSurf window list
*/
void ami_gui_win_list_remove(void *win);
+
+/**
+ * Get which qualifier keys are being pressed
+ */
+int ami_gui_get_quals(Object *win_obj);
+
+/**
+ * Check rect is not already queued for redraw
+ */
+bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
+ const struct rect *restrict new_rect, APTR mempool);
+
#endif
diff --git a/frontends/amiga/object.h b/frontends/amiga/object.h
index be96504..70bb550 100755
--- a/frontends/amiga/object.h
+++ b/frontends/amiga/object.h
@@ -33,6 +33,7 @@ enum
AMINS_HISTORYWINDOW,
AMINS_GUIOPTSWINDOW,
AMINS_PRINTWINDOW,
+ AMINS_COREWINDOW,
AMINS_FONT,
AMINS_MIME,
AMINS_RECT
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index 83798f2..d56a1fe 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 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/
*
@@ -16,39 +16,347 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <proto/exec.h>
+/**
+ * \file
+ * Implementation of Amiga certificate viewing using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/button.h>
+#include <gadgets/layout.h>
+#include <gadgets/scroller.h>
+#include <gadgets/space.h>
+#include <images/label.h>
+
+#include <reaction/reaction_macros.h>
-#include "utils/nsurl.h"
-#include "content/llcache.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "utils/log.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
#include "desktop/sslcert_viewer.h"
+#include "utils/messages.h"
-#include "amiga/tree.h"
+#include "amiga/corewindow.h"
+#include "amiga/libs.h"
#include "amiga/sslcert.h"
+#include "amiga/utf8.h"
+
+
+/**
+ * Amiga certificate viewing window context
+ */
+enum {
+ GID_SSLCERT_ACCEPT = GID_CW_LAST,
+ GID_SSLCERT_REJECT,
+ GID_SSLCERT_LAST
+};
+
+#define GID_SSLCERT_SIZE GID_SSLCERT_LAST - GID_CW_LAST
+
+struct ami_crtvrfy_window {
+ /** Amiga core window context */
+ struct ami_corewindow core;
+
+ /** Amiga GUI stuff */
+ Object *sslcert_objects[GID_SSLCERT_LAST]; // technically wasting a few bytes here
+
+ char *sslerr;
+ char *sslaccept;
+ char *sslreject;
+
+ /** SSL certificate viewer context data */
+ struct sslcert_session_data *ssl_data;
+};
+
+/**
+ * destroy a previously created certificate view
+ */
+static nserror
+ami_crtvrfy_destroy(struct ami_crtvrfy_window *crtvrfy_win)
+{
+ nserror res;
+
+ res = sslcert_viewer_fini(crtvrfy_win->ssl_data);
+ if (res == NSERROR_OK) {
+ ami_utf8_free(crtvrfy_win->sslerr);
+ ami_utf8_free(crtvrfy_win->sslaccept);
+ ami_utf8_free(crtvrfy_win->sslreject);
+ res = ami_corewindow_fini(&crtvrfy_win->core); /* closes the window for us */
+ }
+ return res;
+}
-nserror gui_cert_verify(nsurl *url,
- const struct ssl_cert_info *certs, unsigned long num,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
+static void
+ami_crtvrfy_accept(struct ami_corewindow *ami_cw)
{
- struct sslcert_session_data *data;
- struct treeview_window *ssl_window;
+ struct ami_crtvrfy_window *crtvrfy_win;
+ /* technically degenerate container of */
+ crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
- sslcert_viewer_create_session_data(num, url, cb, cbpw,
- certs, &data);
- ssl_current_session = data;
+ sslcert_viewer_accept(crtvrfy_win->ssl_data);
- ssl_window = ami_tree_create(TREE_SSLCERT, data);
- if (!ssl_window) {
- return NSERROR_INIT_FAILED;
+ ami_crtvrfy_destroy(crtvrfy_win);
+}
+
+static void
+ami_crtvrfy_reject(struct ami_corewindow *ami_cw)
+{
+ struct ami_crtvrfy_window *crtvrfy_win;
+ /* technically degenerate container of */
+ crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
+
+ sslcert_viewer_reject(crtvrfy_win->ssl_data);
+
+ ami_crtvrfy_destroy(crtvrfy_win);
+}
+
+/**
+ * callback for unknown events on Amiga core window
+ * eg. buttons in the ssl cert window
+ * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP)
+ * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT)
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param result event as returned by RA_HandleInput()
+ * \return TRUE if window closed during event processing
+ */
+static BOOL
+ami_crtvrfy_event(struct ami_corewindow *ami_cw, ULONG result)
+{
+ if((result & WMHI_CLASSMASK) == WMHI_GADGETUP) {
+ switch(result & WMHI_GADGETMASK) {
+ case GID_SSLCERT_ACCEPT:
+ ami_crtvrfy_accept(ami_cw);
+ return TRUE;
+ break;
+
+ case GID_SSLCERT_REJECT:
+ ami_crtvrfy_reject(ami_cw);
+ return TRUE;
+ break;
+ }
}
+ return FALSE;
+}
- ami_tree_open(ssl_window, AMI_TREE_SSLCERT);
+/**
+ * callback for mouse action for certificate verify on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_crtvrfy_mouse(struct ami_corewindow *ami_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct ami_crtvrfy_window *crtvrfy_win;
+ /* technically degenerate container of */
+ crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
+
+ sslcert_viewer_mouse_action(crtvrfy_win->ssl_data, mouse_state, x, y);
return NSERROR_OK;
}
-void ami_ssl_free(struct treeview_window *twin)
+/**
+ * callback for keypress for certificate verify on core window
+ *
+ * \param example_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_crtvrfy_key(struct ami_corewindow *ami_cw, uint32_t nskey)
{
- ami_tree_destroy(twin);
+ struct ami_crtvrfy_window *crtvrfy_win;
+
+ /* technically degenerate container of */
+ crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
+
+ if (sslcert_viewer_keypress(crtvrfy_win->ssl_data, nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback on draw event for certificate verify on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx The drawing context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_crtvrfy_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+ struct ami_crtvrfy_window *crtvrfy_win;
+
+ /* technically degenerate container of */
+ crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
+
+ sslcert_viewer_redraw(crtvrfy_win->ssl_data, x, y, r, ctx);
+
+ return NSERROR_OK;
+}
+
+static nserror
+ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)&crtvrfy_win->core;
+
+ ami_cw->objects[GID_CW_WIN] = WindowObj,
+ WA_ScreenTitle, ami_gui_get_screen_title(),
+ WA_Title, ami_cw->wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, FALSE,
+ WA_SizeGadget, TRUE,
+ WA_SizeBBottom, TRUE,
+ WA_Height, scrn->Height / 2,
+ WA_PubScreen, scrn,
+ WA_ReportMouse, TRUE,
+ WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort, sport,
+ WINDOW_UserData, crtvrfy_win,
+ /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
+ LAYOUT_AddImage, LabelObj,
+ LABEL_Text, crtvrfy_win->sslerr,
+ LabelEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLLLAYOUT] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLLLAYOUT] = LayoutHObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_VSCROLL,
+ GA_RelVerify, TRUE,
+ ScrollerEnd,
+ LayoutEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_HSCROLL,
+ GA_RelVerify, TRUE,
+ SCROLLER_Orientation, SORIENT_HORIZ,
+ ScrollerEnd,
+ LayoutEnd,
+ LAYOUT_AddChild, LayoutHObj,
+ LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_ACCEPT] = ButtonObj,
+ GA_ID, GID_SSLCERT_ACCEPT,
+ GA_Text, crtvrfy_win->sslaccept,
+ GA_RelVerify, TRUE,
+ ButtonEnd,
+ LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_REJECT] = ButtonObj,
+ GA_ID, GID_SSLCERT_REJECT,
+ GA_Text, crtvrfy_win->sslreject,
+ GA_RelVerify, TRUE,
+ ButtonEnd,
+ EndGroup,
+ CHILD_WeightedHeight, 0,
+ EndGroup,
+ EndWindow;
+
+ if(ami_cw->objects[GID_CW_WIN] == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ return NSERROR_OK;
}
+
+/* exported interface documented in amiga/ssl_cert.h */
+nserror ami_cert_verify(struct nsurl *url,
+ const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
+{
+ struct ami_crtvrfy_window *ncwin;
+ nserror res;
+
+ ncwin = calloc(1, sizeof(struct ami_crtvrfy_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("SSLCerts"));
+ ncwin->sslerr = ami_utf8_easy((char *)messages_get("SSLError"));
+ ncwin->sslaccept = ami_utf8_easy((char *)messages_get("SSL_Certificate_Accept"));
+ ncwin->sslreject = ami_utf8_easy((char *)messages_get("SSL_Certificate_Reject"));
+
+ res = ami_crtvrfy_create_window(ncwin);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ ami_utf8_free(ncwin->core.wintitle);
+ ami_utf8_free(ncwin->sslerr);
+ ami_utf8_free(ncwin->sslaccept);
+ ami_utf8_free(ncwin->sslreject);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise example core window */
+ ncwin->core.draw = ami_crtvrfy_draw;
+ ncwin->core.key = ami_crtvrfy_key;
+ ncwin->core.mouse = ami_crtvrfy_mouse;
+ ncwin->core.close = ami_crtvrfy_reject;
+ ncwin->core.event = ami_crtvrfy_event;
+
+ res = ami_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ ami_utf8_free(ncwin->sslerr);
+ ami_utf8_free(ncwin->sslaccept);
+ ami_utf8_free(ncwin->sslreject);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise certificate viewing interface */
+ res = sslcert_viewer_create_session_data(num, url, cb, cbpw, certs,
+ &ncwin->ssl_data);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ ami_utf8_free(ncwin->sslerr);
+ ami_utf8_free(ncwin->sslaccept);
+ ami_utf8_free(ncwin->sslreject);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ res = sslcert_viewer_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ ncwin->ssl_data);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ ami_utf8_free(ncwin->sslerr);
+ ami_utf8_free(ncwin->sslaccept);
+ ami_utf8_free(ncwin->sslreject);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ return NSERROR_OK;
+}
+
diff --git a/frontends/amiga/sslcert.h b/frontends/amiga/sslcert.h
index 86ce9c4..392989f 100644
--- a/frontends/amiga/sslcert.h
+++ b/frontends/amiga/sslcert.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 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/
*
@@ -18,11 +18,21 @@
#ifndef AMIGA_SSLCERT_H
#define AMIGA_SSLCERT_H
+struct nsurl;
+struct ssl_cert_info;
-nserror gui_cert_verify(nsurl *url,
+/**
+ * Prompt the user to verify a certificate with issues.
+ *
+ * \param url The URL being verified.
+ * \param certs The certificate to be verified
+ * \param num The number of certificates to be verified.
+ * \param cb Callback upon user decision.
+ * \param cbpw Context pointer passed to cb
+ * \return NSERROR_OK or error code if prompt creation failed.
+ */
+nserror ami_cert_verify(struct nsurl *url,
const struct ssl_cert_info *certs, unsigned long num,
- nserror (*cb)(bool proceed, void *pw), void *cbpw);
-
-void ami_ssl_free(struct treeview_window *twin);
-
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
#endif
+
diff --git a/frontends/amiga/tree.c b/frontends/amiga/tree.c
index f1c5327..b9747c0 100644
--- a/frontends/amiga/tree.c
+++ b/frontends/amiga/tree.c
@@ -916,7 +916,7 @@ void ami_tree_close(void *w)
ami_utf8_free(twin->sslerr);
ami_utf8_free(twin->sslaccept);
ami_utf8_free(twin->sslreject);
- ami_ssl_free(twin);
+ //ami_ssl_free(twin);
}
if(twin->type == AMI_TREE_HOTLIST)
--
NetSurf Browser
6 years, 9 months
netsurf: branch chris/amiga-corewindow updated. release/3.6-154-g2bd8eb8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2bd8eb8c0b46879910919...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2bd8eb8c0b468799109191e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2bd8eb8c0b468799109191e63...
The branch, chris/amiga-corewindow has been updated
via 2bd8eb8c0b468799109191e63e939ea7bd69f8a1 (commit)
from 64bb74bdafa216d4163d6b717271a9f45ac0d287 (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=2bd8eb8c0b468799109...
commit 2bd8eb8c0b468799109191e63e939ea7bd69f8a1
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix sslcert redraw
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 052ddd6..38b980a 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -223,12 +223,12 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
if(((x + width) - tile_x) < tile_size_x)
tile_w = (x + width) - tile_x;
- draw_rect.x0 = - tile_x;
- draw_rect.y0 = - tile_y;
+ draw_rect.x0 = tile_x; // was -
+ draw_rect.y0 = tile_y; // was -
draw_rect.x1 = tile_x + tile_w;
draw_rect.y1 = tile_y + tile_h;
- ami_cw->draw(ami_cw, &draw_rect, &ctx);
+ ami_cw->draw(ami_cw, -tile_x, -tile_y, &draw_rect, &ctx);
#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index ba754d6..8d93882 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -81,10 +81,14 @@ struct ami_corewindow {
* callback to draw on drawable area of Amiga core window
*
* \param ami_cw The Amiga core window structure.
+ * \param x Plot origin (X)
+ * \param r Plot origin (Y)
* \param r The rectangle of the window that needs updating.
+ * \param ctx Redraw context
* \return NSERROR_OK on success otherwise apropriate error code
*/
- nserror (*draw)(struct ami_corewindow *ami_cw, struct rect *r, struct redraw_context *ctx);
+ nserror (*draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r,
+ struct redraw_context *ctx);
/**
* callback for keypress on Amiga core window
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index 4685cae..d56a1fe 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -197,14 +197,14 @@ ami_crtvrfy_key(struct ami_corewindow *ami_cw, uint32_t nskey)
* \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
-ami_crtvrfy_draw(struct ami_corewindow *ami_cw, struct rect *r, struct redraw_context *ctx)
+ami_crtvrfy_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
{
struct ami_crtvrfy_window *crtvrfy_win;
/* technically degenerate container of */
crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
- sslcert_viewer_redraw(crtvrfy_win->ssl_data, 0, 0, r, ctx);
+ sslcert_viewer_redraw(crtvrfy_win->ssl_data, x, y, r, ctx);
return NSERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/corewindow.c | 6 +++---
frontends/amiga/corewindow.h | 6 +++++-
frontends/amiga/sslcert.c | 4 ++--
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 052ddd6..38b980a 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -223,12 +223,12 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
if(((x + width) - tile_x) < tile_size_x)
tile_w = (x + width) - tile_x;
- draw_rect.x0 = - tile_x;
- draw_rect.y0 = - tile_y;
+ draw_rect.x0 = tile_x; // was -
+ draw_rect.y0 = tile_y; // was -
draw_rect.x1 = tile_x + tile_w;
draw_rect.y1 = tile_y + tile_h;
- ami_cw->draw(ami_cw, &draw_rect, &ctx);
+ ami_cw->draw(ami_cw, -tile_x, -tile_y, &draw_rect, &ctx);
#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index ba754d6..8d93882 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -81,10 +81,14 @@ struct ami_corewindow {
* callback to draw on drawable area of Amiga core window
*
* \param ami_cw The Amiga core window structure.
+ * \param x Plot origin (X)
+ * \param r Plot origin (Y)
* \param r The rectangle of the window that needs updating.
+ * \param ctx Redraw context
* \return NSERROR_OK on success otherwise apropriate error code
*/
- nserror (*draw)(struct ami_corewindow *ami_cw, struct rect *r, struct redraw_context *ctx);
+ nserror (*draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r,
+ struct redraw_context *ctx);
/**
* callback for keypress on Amiga core window
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index 4685cae..d56a1fe 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -197,14 +197,14 @@ ami_crtvrfy_key(struct ami_corewindow *ami_cw, uint32_t nskey)
* \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
-ami_crtvrfy_draw(struct ami_corewindow *ami_cw, struct rect *r, struct redraw_context *ctx)
+ami_crtvrfy_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
{
struct ami_crtvrfy_window *crtvrfy_win;
/* technically degenerate container of */
crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw;
- sslcert_viewer_redraw(crtvrfy_win->ssl_data, 0, 0, r, ctx);
+ sslcert_viewer_redraw(crtvrfy_win->ssl_data, x, y, r, ctx);
return NSERROR_OK;
}
--
NetSurf Browser
6 years, 9 months
netsurf: branch chris/amiga-corewindow updated. release/3.6-153-g64bb74b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/64bb74bdafa216d4163d6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/64bb74bdafa216d4163d6b7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/64bb74bdafa216d4163d6b717...
The branch, chris/amiga-corewindow has been updated
via 64bb74bdafa216d4163d6b717271a9f45ac0d287 (commit)
via 48e95ad2b3ede2b6170b635074bf0ee1010dfb39 (commit)
from 0fafa9576e8963928c13c81524e64b624b794c98 (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=64bb74bdafa216d4163...
commit 64bb74bdafa216d4163d6b717271a9f45ac0d287
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
fix mouse click processing
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index df2bc1d..052ddd6 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -140,60 +140,6 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y
return true;
}
-static void
-ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
-{
- Object *scroller;
- Object *layout;
- ULONG tag;
-
- if(vert == true) {
- if(visible == ami_cw->scroll_y_visible) {
- return;
- } else {
- scroller = ami_cw->objects[GID_CW_VSCROLL];
- layout = ami_cw->objects[GID_CW_VSCROLLLAYOUT];
- tag = WINDOW_VertProp;
- ami_cw->scroll_y_visible = visible;
- }
- } else {
- if(visible == ami_cw->scroll_x_visible) {
- return;
- } else {
- scroller = ami_cw->objects[GID_CW_HSCROLL];
- layout = ami_cw->objects[GID_CW_HSCROLLLAYOUT];
- tag = WINDOW_HorizProp;
- ami_cw->scroll_x_visible = visible;
- }
- }
-
- if(visible == true) {
- if(ami_cw->in_border_scroll == true) {
- SetAttrs(ami_cw->objects[GID_CW_WIN],
- tag, 1,
- TAG_DONE);
- } else {
-#ifdef __amigaos4__
- IDoMethod(layout, LM_ADDCHILD, ami_cw->win, scroller, NULL);
-#else
- SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
-#endif
- }
- } else {
- if(ami_cw->in_border_scroll == true) {
- SetAttrs(ami_cw->objects[GID_CW_WIN],
- tag, -1,
- TAG_DONE);
- } else {
-#ifdef __amigaos4__
- IDoMethod(layout, LM_REMOVECHILD, ami_cw->win, scroller);
-#else
- SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
-#endif
- }
- }
-}
-
/* handle keypress */
static void
ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
@@ -392,6 +338,72 @@ ami_cw_redraw(struct ami_corewindow *ami_cw, const struct rect *restrict r)
ami_schedule(1, ami_cw_redraw_cb, ami_cw);
}
+static void
+ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
+{
+ Object *scroller;
+ Object *layout;
+ ULONG tag;
+
+ if(vert == true) {
+ if(visible == ami_cw->scroll_y_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_VSCROLL];
+ layout = ami_cw->objects[GID_CW_VSCROLLLAYOUT];
+ tag = WINDOW_VertProp;
+ ami_cw->scroll_y_visible = visible;
+ }
+ } else {
+ if(visible == ami_cw->scroll_x_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_HSCROLL];
+ layout = ami_cw->objects[GID_CW_HSCROLLLAYOUT];
+ tag = WINDOW_HorizProp;
+ ami_cw->scroll_x_visible = visible;
+ }
+ }
+
+ if(visible == true) {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, 1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_ADDCHILD, ami_cw->win, scroller, NULL);
+#else
+ SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
+#endif
+ }
+ } else {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, -1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_REMOVECHILD, ami_cw->win, scroller);
+#else
+ SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
+#endif
+ }
+ }
+
+#if 0
+ /* in-window scrollbars aren't getting hidden until the window is resized
+ * this code should fix it, but it isn't working */
+ if(ami_cw->in_border_scroll == false) {
+ FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
+ RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
+ ami_cw->win, NULL, TRUE);
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
+ }
+#endif
+}
static void
ami_cw_close(void *w)
@@ -466,48 +478,49 @@ ami_cw_event(void *w)
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
- case SELECTDOWN:
- ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
- break;
+ switch(code) {
+ case SELECTDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
+ break;
- case MIDDLEDOWN:
- ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
- break;
+ case MIDDLEDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
+ break;
- case SELECTUP:
- if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
- CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+ case SELECTUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
- ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
- if(ami_cw->lastclick.tv_sec) {
- if(DoubleClick(ami_cw->lastclick.tv_sec,
- ami_cw->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec))
- ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
- }
+ if(ami_cw->lastclick.tv_sec) {
+ if(DoubleClick(ami_cw->lastclick.tv_sec,
+ ami_cw->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec))
+ ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
+ }
- if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
- ami_cw->lastclick.tv_sec = 0;
- ami_cw->lastclick.tv_usec = 0;
- } else {
- ami_cw->lastclick.tv_sec = curtime.tv_sec;
- ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
+ } else {
+ ami_cw->lastclick.tv_sec = curtime.tv_sec;
+ ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ }
}
- }
-
- ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
- ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
- break;
- case MIDDLEUP:
- if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
- ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
- ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
- ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
- break;
+ case MIDDLEUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+ }
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
break;
@@ -626,17 +639,6 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
SCROLLER_Visible, win_w,
TAG_DONE);
}
-
-#if 0
- /* in-window scrollbars aren't getting hidden until the window is resized
- * this code should fix it, but it isn't working */
- FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
- RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
- ami_cw->win, NULL, TRUE);
-
- /* probably need to redraw here */
- ami_cw_redraw(ami_cw, NULL);
-#endif
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=48e95ad2b3ede2b6170...
commit 48e95ad2b3ede2b6170b635074bf0ee1010dfb39
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
show/hide scrollbars as required
move the sslcert scrollbars into the window as per the style guide
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 024e768..df2bc1d 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -47,9 +47,11 @@
#include <proto/exec.h>
#include <proto/intuition.h>
+#include <proto/layout.h>
#include <proto/utility.h>
#include <classes/window.h>
+#include <gadgets/layout.h>
#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <intuition/icclass.h>
@@ -62,6 +64,25 @@
#include "amiga/schedule.h"
#include "amiga/utf8.h"
+static void
+ami_cw_scroller_top(struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y)
+{
+ ULONG xs = 0;
+ ULONG ys = 0;
+
+ if(ami_cw->scroll_x_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ }
+
+ if(ami_cw->scroll_y_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ }
+
+ *x = xs;
+ *y = ys;
+}
+
+
/**
* Convert co-ordinates relative to space.gadget
* into document co-ordinates
@@ -73,10 +94,10 @@
static void
ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
{
- ULONG xs, ys;
+ ULONG xs = 0;
+ ULONG ys = 0;
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
*x = *x + xs;
*y = *y + ys;
@@ -109,8 +130,7 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y
if((xm < 0) || (ym < 0) || (xm > bbox->Width) || (ym > bbox->Height))
return false;
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
xm += xs;
ym += ys;
@@ -120,6 +140,60 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y
return true;
}
+static void
+ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
+{
+ Object *scroller;
+ Object *layout;
+ ULONG tag;
+
+ if(vert == true) {
+ if(visible == ami_cw->scroll_y_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_VSCROLL];
+ layout = ami_cw->objects[GID_CW_VSCROLLLAYOUT];
+ tag = WINDOW_VertProp;
+ ami_cw->scroll_y_visible = visible;
+ }
+ } else {
+ if(visible == ami_cw->scroll_x_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_HSCROLL];
+ layout = ami_cw->objects[GID_CW_HSCROLLLAYOUT];
+ tag = WINDOW_HorizProp;
+ ami_cw->scroll_x_visible = visible;
+ }
+ }
+
+ if(visible == true) {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, 1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_ADDCHILD, ami_cw->win, scroller, NULL);
+#else
+ SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
+#endif
+ }
+ } else {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, -1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_REMOVECHILD, ami_cw->win, scroller);
+#else
+ SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
+#endif
+ }
+ }
+}
+
/* handle keypress */
static void
ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
@@ -176,8 +250,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
return;
}
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&pos_x);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&pos_y);
+ ami_cw_scroller_top(ami_cw, &pos_x, &pos_y);
glob = &ami_cw->gg;
@@ -376,7 +449,7 @@ ami_cw_event(void *w)
int nskey;
int key_state = 0;
struct timeval curtime;
- int x, y;
+ int x = 0, y = 0;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
switch(result & WMHI_CLASSMASK) {
@@ -524,12 +597,22 @@ static void
ami_cw_update_size(struct core_window *cw, int width, int height)
{
struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
-
- /* I'm assuming this is telling me the new page size, not wanting the window physically resized */
int win_w, win_h;
+
ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+ if(width == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, false, false);
+ return;
+ }
+
+ if(height == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, true, false);
+ return;
+ }
+
if(ami_cw->objects[GID_CW_VSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
SCROLLER_Total, (ULONG)height,
SCROLLER_Visible, win_h,
@@ -537,11 +620,23 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
}
if(ami_cw->objects[GID_CW_HSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
SCROLLER_Total, (ULONG)width,
SCROLLER_Visible, win_w,
TAG_DONE);
}
+
+#if 0
+ /* in-window scrollbars aren't getting hidden until the window is resized
+ * this code should fix it, but it isn't working */
+ FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
+ RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
+ ami_cw->win, NULL, TRUE);
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
+#endif
}
@@ -553,13 +648,12 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
int scrollsetx;
int scrollsety;
int win_w = 0, win_h = 0;
- int win_x0, win_x1;
- int win_y0, win_y1;
+ ULONG win_x0, win_y0;
+ int win_x1, win_y1;
ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&win_y0);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&win_x0);
+ ami_cw_scroller_top(ami_cw, &win_x0, &win_y0);
win_x1 = win_x0 + win_w;
win_y1 = win_y0 + win_h;
@@ -569,13 +663,17 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
if(r->x1 > win_x1) scrollsetx = r->x1 - win_w;
if(r->x0 < win_x0) scrollsetx = r->x0;
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- SCROLLER_Top, scrollsety,
- TAG_DONE);
+ if(ami_cw->scroll_y_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsety,
+ TAG_DONE);
+ }
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- SCROLLER_Top, scrollsetx,
- TAG_DONE);
+ if(ami_cw->scroll_x_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsetx,
+ TAG_DONE);
+ }
/* probably need to redraw here */
ami_cw_redraw(ami_cw, NULL);
@@ -608,6 +706,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
ami_cw->lastclick.tv_sec = 0;
ami_cw->lastclick.tv_usec = 0;
+ ami_cw->scroll_x_visible = true;
+ ami_cw->scroll_y_visible = true;
+ ami_cw->in_border_scroll = false;
/* allocate drawing area etc */
ami_init_layers(&ami_cw->gg, 0, 0, false);
@@ -635,6 +736,8 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
GA_ID, GID_CW_HSCROLL,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
}
if(ami_cw->objects[GID_CW_VSCROLL] == NULL) {
@@ -645,6 +748,8 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
GA_ID, GID_CW_VSCROLL,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
}
return NSERROR_OK;
@@ -662,6 +767,20 @@ nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
ami_cw->win = NULL;
DisposeObject(ami_cw->objects[GID_CW_WIN]);
+#if 0
+ /* ensure our scrollbars are destroyed */
+ /* it appears these are disposed anyway,
+ * even if the gadgets are no longer attached to the window */
+ if(ami_cw->in_border_scroll == false) {
+ if(ami_cw->scroll_x_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_HSCROLL]);
+ }
+ if(ami_cw->scroll_y_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_VSCROLL]);
+ }
+ }
+#endif
+
/* release off-screen bitmap stuff */
ami_plot_release_pens(ami_cw->gg.shared_pens);
ami_free_layers(&ami_cw->gg);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 42c0f03..ba754d6 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -34,6 +34,8 @@ enum {
GID_CW_DRAW, /* drawing area (space.gadget) */
GID_CW_HSCROLL, /* horizontal scroller */
GID_CW_VSCROLL, /* vertical scroller */
+ GID_CW_HSCROLLLAYOUT, /* horizontal scroller container*/
+ GID_CW_VSCROLLLAYOUT, /* vertical scroller container */
GID_CW_LAST
};
@@ -57,6 +59,11 @@ struct ami_corewindow {
APTR deferred_rects_pool;
struct MinList *deferred_rects;
+ /** keep track of the scrollbar type we're using */
+ bool in_border_scroll;
+ bool scroll_x_visible;
+ bool scroll_y_visible;
+
/** window title, must be allocated wth ami_utf8 function */
char *wintitle;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 1508135..f94090b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1689,7 +1689,7 @@ static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HSCROLL]);
#else
- SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL]);
+ SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL], TAG_DONE);
#endif
gwin->objects[GID_HSCROLL] = NULL;
@@ -1734,7 +1734,7 @@ static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_VSCROLL]);
#else
- SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL]);
+ SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL], TAG_DONE);
#endif
gwin->objects[GID_VSCROLL] = NULL;
@@ -3266,8 +3266,10 @@ static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HOTLISTSEPBAR]);
#else
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST]);
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR]);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST], TAG_DONE);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR], TAG_DONE);
#endif
FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index b3d57ef..4685cae 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -29,6 +29,7 @@
#include <classes/window.h>
#include <gadgets/button.h>
#include <gadgets/layout.h>
+#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <images/label.h>
@@ -221,15 +222,13 @@ ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win)
WA_DragBar, TRUE,
WA_CloseGadget, FALSE,
WA_SizeGadget, TRUE,
- WA_SizeBRight, TRUE,
+ WA_SizeBBottom, TRUE,
WA_Height, scrn->Height / 2,
WA_PubScreen, scrn,
WA_ReportMouse, TRUE,
WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
- WINDOW_HorizProp, 1,
- WINDOW_VertProp, 1,
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
WINDOW_SharedPort, sport,
@@ -241,12 +240,25 @@ ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win)
LAYOUT_AddImage, LabelObj,
LABEL_Text, crtvrfy_win->sslerr,
LabelEnd,
- LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
- GA_ID, GID_CW_DRAW,
- SPACE_Transparent, TRUE,
- SPACE_BevelStyle, BVS_DISPLAY,
- GA_RelVerify, TRUE,
- SpaceEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLLLAYOUT] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLLLAYOUT] = LayoutHObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_VSCROLL,
+ GA_RelVerify, TRUE,
+ ScrollerEnd,
+ LayoutEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_HSCROLL,
+ GA_RelVerify, TRUE,
+ SCROLLER_Orientation, SORIENT_HORIZ,
+ ScrollerEnd,
+ LayoutEnd,
LAYOUT_AddChild, LayoutHObj,
LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_ACCEPT] = ButtonObj,
GA_ID, GID_SSLCERT_ACCEPT,
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/corewindow.c | 227 ++++++++++++++++++++++++++++++++----------
frontends/amiga/corewindow.h | 7 ++
frontends/amiga/gui.c | 10 +-
frontends/amiga/sslcert.c | 30 ++++--
4 files changed, 208 insertions(+), 66 deletions(-)
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 024e768..052ddd6 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -47,9 +47,11 @@
#include <proto/exec.h>
#include <proto/intuition.h>
+#include <proto/layout.h>
#include <proto/utility.h>
#include <classes/window.h>
+#include <gadgets/layout.h>
#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <intuition/icclass.h>
@@ -62,6 +64,25 @@
#include "amiga/schedule.h"
#include "amiga/utf8.h"
+static void
+ami_cw_scroller_top(struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y)
+{
+ ULONG xs = 0;
+ ULONG ys = 0;
+
+ if(ami_cw->scroll_x_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ }
+
+ if(ami_cw->scroll_y_visible == true) {
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ }
+
+ *x = xs;
+ *y = ys;
+}
+
+
/**
* Convert co-ordinates relative to space.gadget
* into document co-ordinates
@@ -73,10 +94,10 @@
static void
ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
{
- ULONG xs, ys;
+ ULONG xs = 0;
+ ULONG ys = 0;
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
*x = *x + xs;
*y = *y + ys;
@@ -109,8 +130,7 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y
if((xm < 0) || (ym < 0) || (xm > bbox->Width) || (ym > bbox->Height))
return false;
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ ami_cw_scroller_top(ami_cw, &xs, &ys);
xm += xs;
ym += ys;
@@ -176,8 +196,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
return;
}
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&pos_x);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&pos_y);
+ ami_cw_scroller_top(ami_cw, &pos_x, &pos_y);
glob = &ami_cw->gg;
@@ -319,6 +338,72 @@ ami_cw_redraw(struct ami_corewindow *ami_cw, const struct rect *restrict r)
ami_schedule(1, ami_cw_redraw_cb, ami_cw);
}
+static void
+ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
+{
+ Object *scroller;
+ Object *layout;
+ ULONG tag;
+
+ if(vert == true) {
+ if(visible == ami_cw->scroll_y_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_VSCROLL];
+ layout = ami_cw->objects[GID_CW_VSCROLLLAYOUT];
+ tag = WINDOW_VertProp;
+ ami_cw->scroll_y_visible = visible;
+ }
+ } else {
+ if(visible == ami_cw->scroll_x_visible) {
+ return;
+ } else {
+ scroller = ami_cw->objects[GID_CW_HSCROLL];
+ layout = ami_cw->objects[GID_CW_HSCROLLLAYOUT];
+ tag = WINDOW_HorizProp;
+ ami_cw->scroll_x_visible = visible;
+ }
+ }
+
+ if(visible == true) {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, 1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_ADDCHILD, ami_cw->win, scroller, NULL);
+#else
+ SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
+#endif
+ }
+ } else {
+ if(ami_cw->in_border_scroll == true) {
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ tag, -1,
+ TAG_DONE);
+ } else {
+#ifdef __amigaos4__
+ IDoMethod(layout, LM_REMOVECHILD, ami_cw->win, scroller);
+#else
+ SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
+#endif
+ }
+ }
+
+#if 0
+ /* in-window scrollbars aren't getting hidden until the window is resized
+ * this code should fix it, but it isn't working */
+ if(ami_cw->in_border_scroll == false) {
+ FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
+ RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
+ ami_cw->win, NULL, TRUE);
+
+ /* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
+ }
+#endif
+}
static void
ami_cw_close(void *w)
@@ -376,7 +461,7 @@ ami_cw_event(void *w)
int nskey;
int key_state = 0;
struct timeval curtime;
- int x, y;
+ int x = 0, y = 0;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
switch(result & WMHI_CLASSMASK) {
@@ -393,48 +478,49 @@ ami_cw_event(void *w)
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
- case SELECTDOWN:
- ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
- break;
+ switch(code) {
+ case SELECTDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
+ break;
- case MIDDLEDOWN:
- ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
- break;
+ case MIDDLEDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
+ break;
- case SELECTUP:
- if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
- CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+ case SELECTUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
- ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
- if(ami_cw->lastclick.tv_sec) {
- if(DoubleClick(ami_cw->lastclick.tv_sec,
- ami_cw->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec))
- ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
- }
+ if(ami_cw->lastclick.tv_sec) {
+ if(DoubleClick(ami_cw->lastclick.tv_sec,
+ ami_cw->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec))
+ ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
+ }
- if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
- ami_cw->lastclick.tv_sec = 0;
- ami_cw->lastclick.tv_usec = 0;
- } else {
- ami_cw->lastclick.tv_sec = curtime.tv_sec;
- ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
+ } else {
+ ami_cw->lastclick.tv_sec = curtime.tv_sec;
+ ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ }
}
- }
-
- ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
- ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
- break;
- case MIDDLEUP:
- if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
- ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
- ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
- ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
- break;
+ case MIDDLEUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+ }
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
break;
@@ -524,12 +610,22 @@ static void
ami_cw_update_size(struct core_window *cw, int width, int height)
{
struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
-
- /* I'm assuming this is telling me the new page size, not wanting the window physically resized */
int win_w, win_h;
+
ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+ if(width == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, false, false);
+ return;
+ }
+
+ if(height == -1) {
+ ami_cw_toggle_scrollbar(ami_cw, true, false);
+ return;
+ }
+
if(ami_cw->objects[GID_CW_VSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, true, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
SCROLLER_Total, (ULONG)height,
SCROLLER_Visible, win_h,
@@ -537,6 +633,7 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
}
if(ami_cw->objects[GID_CW_HSCROLL]) {
+ ami_cw_toggle_scrollbar(ami_cw, false, true);
RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
SCROLLER_Total, (ULONG)width,
SCROLLER_Visible, win_w,
@@ -553,13 +650,12 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
int scrollsetx;
int scrollsety;
int win_w = 0, win_h = 0;
- int win_x0, win_x1;
- int win_y0, win_y1;
+ ULONG win_x0, win_y0;
+ int win_x1, win_y1;
ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&win_y0);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&win_x0);
+ ami_cw_scroller_top(ami_cw, &win_x0, &win_y0);
win_x1 = win_x0 + win_w;
win_y1 = win_y0 + win_h;
@@ -569,13 +665,17 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
if(r->x1 > win_x1) scrollsetx = r->x1 - win_w;
if(r->x0 < win_x0) scrollsetx = r->x0;
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- SCROLLER_Top, scrollsety,
- TAG_DONE);
+ if(ami_cw->scroll_y_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsety,
+ TAG_DONE);
+ }
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- SCROLLER_Top, scrollsetx,
- TAG_DONE);
+ if(ami_cw->scroll_x_visible == true) {
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsetx,
+ TAG_DONE);
+ }
/* probably need to redraw here */
ami_cw_redraw(ami_cw, NULL);
@@ -608,6 +708,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
ami_cw->lastclick.tv_sec = 0;
ami_cw->lastclick.tv_usec = 0;
+ ami_cw->scroll_x_visible = true;
+ ami_cw->scroll_y_visible = true;
+ ami_cw->in_border_scroll = false;
/* allocate drawing area etc */
ami_init_layers(&ami_cw->gg, 0, 0, false);
@@ -635,6 +738,8 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
GA_ID, GID_CW_HSCROLL,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
}
if(ami_cw->objects[GID_CW_VSCROLL] == NULL) {
@@ -645,6 +750,8 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
GA_ID, GID_CW_VSCROLL,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE);
+
+ ami_cw->in_border_scroll = true;
}
return NSERROR_OK;
@@ -662,6 +769,20 @@ nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
ami_cw->win = NULL;
DisposeObject(ami_cw->objects[GID_CW_WIN]);
+#if 0
+ /* ensure our scrollbars are destroyed */
+ /* it appears these are disposed anyway,
+ * even if the gadgets are no longer attached to the window */
+ if(ami_cw->in_border_scroll == false) {
+ if(ami_cw->scroll_x_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_HSCROLL]);
+ }
+ if(ami_cw->scroll_y_visible == false) {
+ DisposeObject(ami_cw->objects[GID_CW_VSCROLL]);
+ }
+ }
+#endif
+
/* release off-screen bitmap stuff */
ami_plot_release_pens(ami_cw->gg.shared_pens);
ami_free_layers(&ami_cw->gg);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 42c0f03..ba754d6 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -34,6 +34,8 @@ enum {
GID_CW_DRAW, /* drawing area (space.gadget) */
GID_CW_HSCROLL, /* horizontal scroller */
GID_CW_VSCROLL, /* vertical scroller */
+ GID_CW_HSCROLLLAYOUT, /* horizontal scroller container*/
+ GID_CW_VSCROLLLAYOUT, /* vertical scroller container */
GID_CW_LAST
};
@@ -57,6 +59,11 @@ struct ami_corewindow {
APTR deferred_rects_pool;
struct MinList *deferred_rects;
+ /** keep track of the scrollbar type we're using */
+ bool in_border_scroll;
+ bool scroll_x_visible;
+ bool scroll_y_visible;
+
/** window title, must be allocated wth ami_utf8 function */
char *wintitle;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 1508135..f94090b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1689,7 +1689,7 @@ static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HSCROLL]);
#else
- SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL]);
+ SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL], TAG_DONE);
#endif
gwin->objects[GID_HSCROLL] = NULL;
@@ -1734,7 +1734,7 @@ static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_VSCROLL]);
#else
- SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL]);
+ SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL], TAG_DONE);
#endif
gwin->objects[GID_VSCROLL] = NULL;
@@ -3266,8 +3266,10 @@ static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HOTLISTSEPBAR]);
#else
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST]);
- SetAttrs(gwin->objects[GID_HOTLISTLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR]);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST], TAG_DONE);
+ SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
+ LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR], TAG_DONE);
#endif
FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index b3d57ef..4685cae 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -29,6 +29,7 @@
#include <classes/window.h>
#include <gadgets/button.h>
#include <gadgets/layout.h>
+#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <images/label.h>
@@ -221,15 +222,13 @@ ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win)
WA_DragBar, TRUE,
WA_CloseGadget, FALSE,
WA_SizeGadget, TRUE,
- WA_SizeBRight, TRUE,
+ WA_SizeBBottom, TRUE,
WA_Height, scrn->Height / 2,
WA_PubScreen, scrn,
WA_ReportMouse, TRUE,
WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
- WINDOW_HorizProp, 1,
- WINDOW_VertProp, 1,
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
WINDOW_SharedPort, sport,
@@ -241,12 +240,25 @@ ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win)
LAYOUT_AddImage, LabelObj,
LABEL_Text, crtvrfy_win->sslerr,
LabelEnd,
- LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
- GA_ID, GID_CW_DRAW,
- SPACE_Transparent, TRUE,
- SPACE_BevelStyle, BVS_DISPLAY,
- GA_RelVerify, TRUE,
- SpaceEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLLLAYOUT] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLLLAYOUT] = LayoutHObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_VSCROLL,
+ GA_RelVerify, TRUE,
+ ScrollerEnd,
+ LayoutEnd,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLL] = ScrollerObj,
+ GA_ID, GID_CW_HSCROLL,
+ GA_RelVerify, TRUE,
+ SCROLLER_Orientation, SORIENT_HORIZ,
+ ScrollerEnd,
+ LayoutEnd,
LAYOUT_AddChild, LayoutHObj,
LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_ACCEPT] = ButtonObj,
GA_ID, GID_SSLCERT_ACCEPT,
--
NetSurf Browser
6 years, 9 months
packaging/debian: branch master updated. release/3.6-3-3-g6ff2458
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/packaging/debian.git/shortlog/6ff2458205a2...
...commit http://git.netsurf-browser.org/packaging/debian.git/commit/6ff2458205a240...
...tree http://git.netsurf-browser.org/packaging/debian.git/tree/6ff2458205a24008...
The branch, master has been updated
via 6ff2458205a2400808535a4e1a337b06e0d4012b (commit)
from 3d81cf04656d904755fc09ef12b3a9b5cd453baf (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/packaging/debian.git/commit/?id=6ff2458205...
commit 6ff2458205a2400808535a4e1a337b06e0d4012b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix typo in recommends
diff --git a/control b/control
index 7852c1f..b2d81de 100644
--- a/control
+++ b/control
@@ -38,7 +38,7 @@ Package: netsurf-fb
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, netsurf-common (=${source:Version})
Provides: www-browser
-Recommends: mime-support fonts-dejavu
+Recommends: mime-support, fonts-dejavu
Description: small web browser with CSS support for framebuffers
NetSurf is a multi-platform lightweight web browser. It aims to provide
comprehensive rendering of HTML 5 with CSS 2 in a small resource footprint
-----------------------------------------------------------------------
Summary of changes:
control | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/control b/control
index 7852c1f..b2d81de 100644
--- a/control
+++ b/control
@@ -38,7 +38,7 @@ Package: netsurf-fb
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, netsurf-common (=${source:Version})
Provides: www-browser
-Recommends: mime-support fonts-dejavu
+Recommends: mime-support, fonts-dejavu
Description: small web browser with CSS support for framebuffers
NetSurf is a multi-platform lightweight web browser. It aims to provide
comprehensive rendering of HTML 5 with CSS 2 in a small resource footprint
--
Debian Packaging for NetSurf
6 years, 9 months