netsurf: branch mono/removing-windom-dependency updated. 9676253184e001d46a9ceb4e36c47484e169f272
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9676253184e001d46a9ce...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9676253184e001d46a9ceb4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9676253184e001d46a9ceb4e3...
The branch, mono/removing-windom-dependency has been updated
via 9676253184e001d46a9ceb4e36c47484e169f272 (commit)
from c415f9bf989f83c7ced6bb930e3421dab6f4093b (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/commitdiff/9676253184e001d46a9...
commit 9676253184e001d46a9ceb4e36c47484e169f272
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Imporved gemtk toolbar handling.
diff --git a/atari/Makefile.target b/atari/Makefile.target
index ad90807..9faa52d 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -7,7 +7,7 @@
# manually via env. variables, because the m68k-atari-mint
# toolchain is located in /usr/bin and the wildcard matching
# fails then. So this wildcard matches only works for
-# the netsurf environment!
+# the netsurf environment!
STRIP := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*strip)
STACK := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*stack)
@@ -73,15 +73,42 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
# S_ATARI are sources purely for the Atari FreeMiNT build
-S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
- download.c thumbnail.c login.c verify_ssl.c treeview.c hotlist.c history.c\
+S_ATARI := gui.c \
+ findfile.c \
+ filetype.c \
+ misc.c \
+ bitmap.c \
+ schedule.c \
+ download.c \
+ thumbnail.c \
+ login.c \
+ verify_ssl.c \
+ treeview.c \
+ hotlist.c \
+ history.c\
search.c font.c \
- plot/plot.c plot/fontplot.c plot/eddi.s \
- plot/font_freetype.c plot/font_internal.c \
- redrawslots.c encoding.c \
- browser_win.c toolbar.c statusbar.c browser.c \
- global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c
+ redrawslots.c \
+ encoding.c \
+ rootwin.c \
+ toolbar.c \
+ statusbar.c \
+ browser.c \
+ global_evnt.c \
+ osspec.c \
+ system_colour.c \
+ ctxmenu.c \
+ settings.c \
+ deskmenu.c \
+ plot/plot.c \
+ plot/fontplot.c \
+ plot/eddi.s \
+ plot/font_freetype.c \
+ plot/font_internal.c \
+ gemtk/utils.c \
+ gemtk/dragdrop.c \
+ gemtk/msgbox.c \
+ gemtk/guiwin.c
+
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/browser_win.c b/atari/browser_win.c
deleted file mode 100755
index f6daf37..0000000
--- a/atari/browser_win.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <windom.h>
-#include <assert.h>
-#include <math.h>
-#include <osbind.h>
-
-#include "utils/log.h"
-#include "desktop/gui.h"
-#include "desktop/history_core.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "css/css.h"
-#include "atari/gui.h"
-#include "atari/browser_win.h"
-#include "atari/browser.h"
-#include "atari/misc.h"
-#include "atari/plot/plot.h"
-#include "atari/global_evnt.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/browser.h"
-#include "atari/toolbar.h"
-#include "atari/statusbar.h"
-#include "atari/dragdrop.h"
-#include "atari/search.h"
-#include "atari/osspec.h"
-#include "atari/encoding.h"
-#include "atari/toolbar.h"
-
-extern void * h_gem_rsrc;
-extern struct gui_window *input_window;
-
-void __CDECL std_szd( WINDOW * win, short buff[8], void * );
-void __CDECL std_mvd( WINDOW * win, short buff[8], void * );
-
-
-/* -------------------------------------------------------------------------- */
-/* Static module methods follow here: */
-/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
-void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
-static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
-
-/* -------------------------------------------------------------------------- */
-/* Module public functions: */
-/* -------------------------------------------------------------------------- */
-
-
-int window_create( struct gui_window * gw,
- struct browser_window * bw,
- unsigned long inflags )
-{
- int err = 0;
- bool tb, sb;
- int flags;
-
- tb = (inflags & WIDGET_TOOLBAR );
- sb = (inflags & WIDGET_STATUSBAR );
-
- flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
- if( inflags & WIDGET_SCROLL ){
- flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
- }
- if( inflags & WIDGET_RESIZE ){
- flags |= ( SIZER );
- }
- if( inflags & WIDGET_STATUSBAR ){
- flags |= ( INFO );
- }
-
- gw->root = malloc( sizeof(struct s_gui_win_root) );
- if( gw->root == NULL )
- return( -1 );
- memset( gw->root, 0, sizeof(struct s_gui_win_root) );
- gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate( flags, 40, 40, app.w, app.h );
- if( gw->root->handle == NULL ) {
- free( gw->root->title );
- free( gw->root );
- return( -1 );
- }
-
- /* set scroll / content granularity ( 1 unit ) */
- gw->root->handle->w_u = 1;
- gw->root->handle->h_u = 1;
-
- /* Create Root component: */
- gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
- WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
-
- /* create toolbar component: */
- if( tb ) {
- gw->root->toolbar = tb_create( gw );
- assert( gw->root->toolbar );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
-
- } else {
- gw->root->toolbar = NULL;
- }
-
- /* create browser component: */
- gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
- mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
-
- /* create statusbar component: */
- if( sb ) {
- gw->root->statusbar = sb_create( gw );
-#ifdef WITH_COMOPONENT_STATUSBAR
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
-#endif
- } else {
- gw->root->statusbar = NULL;
- }
-
- WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
-
- /* Event Handlers: */
- EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
- /* capture resize/move events so we can handle that manually */
- EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
- EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
- EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
- EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
-
- if (inflags & WIN_TOP) {
- window_set_focus( gw, BROWSER, gw->browser);
- }
-
- return (err);
-}
-
-int window_destroy( struct gui_window * gw)
-{
- int err = 0;
-
- search_destroy( gw );
- if( input_window == gw )
- input_window = NULL;
-
- if( gw->root ) {
- if( gw->root->toolbar )
- tb_destroy( gw->root->toolbar );
-
- if( gw->root->statusbar )
- sb_destroy( gw->root->statusbar );
- }
-
- search_destroy( gw );
-
- if( gw->browser )
- browser_destroy( gw->browser );
-
- /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
- if( gw->root ) {
- /* TODO: check if no other browser is bound to this root window! */
- /* only needed for tabs */
- if( gw->root->title )
- free( gw->root->title );
- if( gw->root->cmproot )
- mt_CompDelete( &app, gw->root->cmproot );
- ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
- EvntWindom( MU_MESAG );
- gw->root->handle = NULL;
- free( gw->root );
- gw->root = NULL;
- }
- return( err );
-}
-
-
-
-void window_open( struct gui_window * gw, GRECT pos )
-{
- LGRECT br;
-
- WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
- WindClear( gw->root->handle );
- WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
-
- /* apply focus to the root frame: */
- long lfbuff[8] = { CM_GETFOCUS };
- mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
-
- /* recompute the nested component sizes and positions: */
- browser_update_rects( gw );
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_get_rect( gw, BR_CONTENT, &br );
- plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
- gw->browser->attached = true;
- if( gw->root->statusbar != NULL ){
- sb_attach(gw->root->statusbar, gw);
- }
- tb_adjust_size( gw );
- /*TBD: get already present content and set size? */
- input_window = gw;
- window_set_focus( gw, BROWSER, gw->browser );
-}
-
-
-
-/* update back forward buttons (see tb_update_buttons (bug) ) */
-void window_update_back_forward( struct gui_window * gw)
-{
- tb_update_buttons( gw, -1 );
-}
-
-void window_set_stauts(struct gui_window * gw , char * text )
-{
- if( gw->root == NULL )
- return;
-
- CMP_STATUSBAR sb = gw->root->statusbar;
-
- if( sb == NULL || gw->browser->attached == false )
- return;
-
- sb_set_text( sb, text );
-}
-
-/* set focus to an arbitary element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
-{
- if( gw->root->focus.type != type || gw->root->focus.element != element ) {
- LOG(("Set focus: %p (%d)\n", element, type));
- gw->root->focus.type = type;
- gw->root->focus.element = element;
- if( element != NULL ){
- switch( type ){
-
- case URL_WIDGET:
- textarea_keypress(((struct s_url_widget*)(element))->textarea,
- KEY_SELECT_ALL );
- break;
-
- default: break;
-
- }
- }
- }
-}
-
-/* check if the url widget has focus */
-bool window_url_widget_has_focus( struct gui_window * gw )
-{
- assert( gw );
- assert( gw->root );
- if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
- assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
- assert( GUIWIN_VISIBLE(gw) );
- return true;
- }
- return false;
-}
-
-/* check if an arbitary window widget / or frame has the focus */
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
-{
- if( gw == NULL )
- return( false );
- if( element == NULL ){
- assert( 1 != 0 );
- return( (gw->root->focus.type == t ) );
- }
- assert( gw->root != NULL );
- return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
-}
-
-void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
-{
- gw->icon = bmp;
- /* redraw window when it is iconyfied: */
- if (gw->icon != NULL) {
- short info, dummy;
- WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
- if (info == 1) {
- window_redraw_favicon(gw, NULL);
- }
- }
-}
-
-
-/**
- * Redraw the favicon
-*/
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
-{
- GRECT work;
-
- assert(gw->root);
-
- WINDOW * bw = gw->root->handle;
-
- WindClear(bw);
- WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
- if (clip == NULL) {
- clip = &work;
- }
-
- if (gw->icon == NULL) {
- OBJECT * tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree);
- tree->ob_x = work.g_x;
- tree->ob_y = work.g_y;
- tree->ob_width = work.g_w;
- tree->ob_height = work.g_h;
- objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
- } else {
- // TODO: consider the clipping rectangle
- struct rect work_clip = { 0,0,work.g_w,work.g_h };
- int xoff=0;
- if (work.g_w > work.g_h) {
- xoff = ((work.g_w-work.g_h)/2);
- work.g_w = work.g_h;
- }
- plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
- plot_clip(&work_clip);
- atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
- }
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* Event Handlers: */
-/* -------------------------------------------------------------------------- */
-
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
-{
- bool abs = false;
- LGRECT cwork;
- struct gui_window * gw = data;
- int value = BROWSER_SCROLL_SVAL;
-
- assert( gw != NULL );
-
- browser_get_rect( gw, BR_CONTENT, &cwork );
-
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
-
-
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
-
- default:
- break;
- }
- browser_scroll( gw, buff[4], value, abs );
-}
-
-
-static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
- char file[DD_NAMEMAX];
- char name[DD_NAMEMAX];
- char *buff=NULL;
- int dd_hdl;
- int dd_msg; /* pipe-handle */
- long size;
- char ext[32];
- short mx,my,bmstat,mkstat;
- graf_mkstate(&mx, &my, &bmstat, &mkstat);
-
- if( gw == NULL )
- return;
- if( (win->status & WS_ICONIFY))
- return;
-
- dd_hdl = ddopen( wbuff[7], DD_OK);
- if( dd_hdl<0)
- return; /* pipe not open */
- memset( ext, 0, 32);
- strcpy( ext, "ARGS");
- dd_msg = ddsexts( dd_hdl, ext);
- if( dd_msg<0)
- goto error;
- dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
- if( size+1 >= PATH_MAX )
- goto error;
- if( !strncmp( ext, "ARGS", 4) && dd_msg > 0)
- {
- ddreply(dd_hdl, DD_OK);
- buff = (char*)malloc(sizeof(char)*(size+1));
- if (buff != NULL)
- {
- if (Fread(dd_hdl, size, buff ) == size)
- buff[size] = 0;
- LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
- (char*)buff, (char*)&ext,
- size, mx, my
- ));
- {
- LGRECT bwrect;
- struct browser_window * bw = gw->browser->bw;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
- mx = mx - bwrect.g_x;
- my = my - bwrect.g_y;
- if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
- return;
-
- utf8_convert_ret ret;
- char *utf8_fn;
-
- ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
- free(buff);
- /* A bad encoding should never happen */
- LOG(("utf8_from_local_encoding failed"));
- assert(ret != UTF8_CONVERT_BADENC);
- /* no memory */
- return;
- }
- browser_window_drop_file_at_point( gw->browser->bw,
- mx+gw->browser->scroll.current.x,
- my+gw->browser->scroll.current.y,
- utf8_fn );
- free(utf8_fn);
- free(buff);
- }
- }
- }
-error:
- ddclose( dd_hdl);
-}
-
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
-{
- LOG(("%s\n", __FUNCTION__ ));
-}
-
-static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
-{
- struct gui_window * gw = (struct gui_window *) data ;
- if( gw != NULL ) {
- browser_window_destroy( gw->browser->bw );
- }
-}
-
-
-static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
-{
- input_window = (struct gui_window *) data;
- window_set_focus( input_window, BROWSER, input_window->browser );
- LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
- assert( input_window != NULL );
-}
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
-{
- int dx = buff[4];
- int dy = buff[5];
- struct gui_window * gw = data;
-
- if (!dx && !dy) return;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
-
- /* update the sliders _before_ we call redraw
- (which might depend on the slider possitions) */
- WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
-
- if( dy > 0 )
- browser_scroll( gw, WA_DNPAGE, abs(dy), false );
- else if ( dy < 0)
- browser_scroll( gw, WA_UPPAGE, abs(dy), false );
- if( dx > 0 )
- browser_scroll( gw, WA_RTPAGE, abs(dx), false );
- else if( dx < 0 )
- browser_scroll( gw, WA_LFPAGE, abs(dx), false );
-}
-
-static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
-
- input_window = gw;
- WindTop( gw->root->handle );
- window_set_focus( gw, BROWSER, gw->browser );
-}
-
-static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
- if( input_window == gw){
- input_window = NULL;
- }
-}
-
-
-static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
-{
- struct gui_window *gw = (struct gui_window*) data;
- GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
- window_redraw_favicon(gw, &clip);
-}
-
-/* perform the actual resize */
-static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
-{
- short x,y,w,h;
- struct gui_window * gw;
-
- wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
- gw = (struct gui_window *)data;
-
- assert( gw != NULL );
-
- if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
- /* report resize to component interface: */
- browser_update_rects( gw );
- tb_adjust_size( gw );
- if( gw->browser->bw->current_content != NULL ){
- /* Reformat will happen when next redraw message arrives: */
- gw->browser->reformat_pending = true;
- if( sys_XAAES() ){
- if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- gw->root->loc.g_x, gw->root->loc.g_y,
- gw->root->loc.g_w, gw->root->loc.g_h );
- }
- }
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
- (GRECT*)&gw->root->loc);
- }
- else {
- WindClear( gw->root->handle );
- }
- } else {
- if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_update_rects( gw );
- }
- }
-}
diff --git a/atari/browser_win.h b/atari/browser_win.h
deleted file mode 100755
index 28001ba..0000000
--- a/atari/browser_win.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NS_ATARI_BROWSER_WIN_H
-#define NS_ATARI_BROWSER_WIN_H
-
-#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
-#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
-
-#define WIDGET_STATUSBAR 0x1
-#define WIDGET_TOOLBAR 0x2
-#define WIDGET_SCROLL 0x4
-#define WIDGET_RESIZE 0x8
-
-#define WIN_TOP 0x100
-
-/* WinDom & Custom bindings for gui window */
-
-/* -------------------------------------------------------------------------- */
-/* Public module functions: */
-/* -------------------------------------------------------------------------- */
-
-/* Creates an normal Browser window with [toolbar], [statusbar] */
-int window_create( struct gui_window * gw,
- struct browser_window * bw, unsigned long flags );
-/* Destroys WinDom part of gui_window */
-int window_destroy( struct gui_window * gw );
-
-/* show the window */
-void window_open( struct gui_window * gw, GRECT pos);
-
-void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
-/* Update Shade / Unshade state of the fwd/back buttons*/
-void window_update_back_forward(struct gui_window * gw);
-/* set root browser component: */
-void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
-
-/* set focus element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
-/* adjust scroll settings */
-void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
-/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
-bool window_url_widget_has_focus( struct gui_window * gw );
-void window_set_url( struct gui_window * gw, const char * text);
-void window_set_stauts( struct gui_window * gw , char * text );
-void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
-
-
-/* -------------------------------------------------------------------------- */
-/* Public event handlers: */
-/* -------------------------------------------------------------------------- */
-
-#endif
diff --git a/atari/dragdrop.c b/atari/dragdrop.c
deleted file mode 100755
index bc7f565..0000000
--- a/atari/dragdrop.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
-* Routine pour Drag and drop sous MultiTos
-* source: D&D Atari, demo OEP (Alexander Lorenz)
-*
-* Struktur OEP (oep.apid): AES-ID der Applikation
-*
-* (Tab = 4)
-*/
-
-#ifdef __PUREC__
-#include <tos.h>
-#else
-#include <osbind.h>
-#include <mintbind.h>
-#include <signal.h>
-#endif
-
-#include <string.h>
-#include <stdio.h>
-
-#include "windom.h"
-#include "dragdrop.h"
-#include "cflib.h"
-
-#ifndef EACCDN
-#define EACCDN (-36)
-#endif
-
-#ifndef FA_HIDDEN
-#define FA_HIDDEN 0x02
-#endif
-
-static char pipename[] = "U:\\PIPE\\DRAGDROP.AA";
-static long pipesig;
-
-/*
-* Routinen f�r den Sender
-*/
-
-/*
-* Erzeugt Pipe f�r D&D
-*
-* Eingabeparameter:
-* pipe - Pointer auf 2 Byte Buffer f�r Pipeextension
-*
-* Ausgabeparameters:
-* keine
-*
-* Returnwert:
-* >0: Filehandle der Pipe
-* -1: Fehler beim Erzeugen der Pipe
-*/
-
-short ddcreate(short *pipe)
-{
- long fd = -1;
-
- pipename[17] = 'A';
- pipename[18] = 'A' - 1;
-
- do /* ouvre un pipe inoccup� */
- {
- pipename[18]++;
- if (pipename[18] > 'Z')
- {
- pipename[17]++;
- if (pipename[17] > 'Z')
- break;
- else
- pipename[18] = 'A';
- }
-
- /* FA_HIDDEN f�r Pipe notwendig! */
-
- fd = Fcreate(pipename, FA_HIDDEN);
-
- } while (fd == (long) EACCDN);
-
- if (fd < 0L)
- return(-1);
-
- *pipe = (pipename[17] << 8) | pipename[18];
-
-
- /* Signalhandler konfigurieren */
-
- ddgetsig(&pipesig);
-
-
- return((short) fd);
-}
-
-
-
-/*
-* Sendet AP_DRAGDROP an Empf�ngerapplikation
-*
-* Eingabeparameter:
-* apid - AES-ID der Emf�ngerapp.
-* fd - Filehandle der D&D-Pipe
-* winid - Handle des Zielfensters (0 f�r Desktopfenster)
-* mx/my - Maus X und Y Koord.
-* (-1/-1 f�r einen fake Drag&Drop)
-* kstate - Sondertastenstatus
-* pipename - Extension der D&D-Pipe
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Empf�ngerapp. gibt DD_NAK zur�ck
-* -2: Empf�ngerapp. antwortet nicht (Timeout)
-* -3: Fehler bei appl_write()
-*/
-
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipeid)
-{
- char c;
- short i, msg[8];
- long fd_mask;
-
-
- /* AES-Message define and post */
-
- msg[0] = AP_DRAGDROP;
- msg[1] = _AESapid;
- msg[2] = 0;
- msg[3] = winid;
- msg[4] = mx;
- msg[5] = my;
- msg[6] = kstate;
- msg[7] = pipeid;
-
- i = appl_write(apid, 16, msg);
-
- if (i == 0)
- {
- ddclose(fd);
- return(-3);
- }
-
-
- /* receiver reaction */
-
- fd_mask = (1L << fd);
- i = Fselect(DD_TIMEOUT, &fd_mask, 0L, 0L);
- if (!i || !fd_mask)
- {
- /* Timeout eingetreten */
-
- ddclose(fd);
- return(-2);
- }
-
-
- /* le recepteur refuse (lecture du pipe) */
-
- if (Fread(fd, 1L, &c) != 1L)
- {
- ddclose(fd);
- return(-1);
- }
-
- if (c != DD_OK)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Liest die 8 "bevorzugten" Extensionen der Empf�ngerapplikation
-*
-* Eingabeparameter:
-* fd - Filehandle der D&D-Pipe
-*
-* Ausgabeparameters:
-* exts - 32 Bytebuffer f�r die 8 bevorzugten Extensionen
-* der Zielapp.
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler beim Lesen aus der Pipe
-*/
-
-short ddrexts(short fd, char *exts)
-{
- if (Fread(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Testet, ob der Empf�nger einen Datentyp akzeptiert
-*
-* Eingabeparameter:
-* fd - Filehandle (von ddcreate())
-* ext - Zeiger auf Datentyp (4 Bytes zB. "ARGS")
-* text - Zeiger auf Datenbeschreibung (optional, zB. "DESKTOP args")
-* name - Zeiger auf Datendateiname (optional, zB. "SAMPLE.TXT")
-* size - Anzahl Bytes der zu sendenden Daten
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* DD_OK - Empf�nger akzeptiert Datentyp
-* DD_NAK - Empf�nger brach Drag&Drop ab
-* DD_EXT - Empf�nger lehnt Datentyp ab
-* DD_LEN - Empf�nger kann Datenmenge nicht verarbeiten
-* DD_TRASH - Drop erfolgte auf M�lleimer
-* DD_PRINTER - Drop erfolgte auf Drucker
-* DD_CLIPBOARD - Drop erfolgte auf Clipboard
-*/
-
-short ddstry(short fd, char *ext, char *text, char *name, long size)
-{
- char c;
- short hdrlen, i;
-
- /* 4 Bytes f�r "ext", 4 Bytes f�r "size",
- 2 Bytes f�r Stringendnullen */
-
- hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1);
-
-
- /* Header senden */
-
- if (Fwrite(fd, 2L, &hdrlen) != 2L)
- return(DD_NAK);
-
- i = (short) Fwrite(fd, 4L, ext);
- i += (short) Fwrite(fd, 4L, &size);
- i += (short) Fwrite(fd, strlen(text)+1, text);
- i += (short) Fwrite(fd, strlen(name)+1, name);
-
- if (i != hdrlen)
- return(DD_NAK);
-
-
- /* auf die Antwort warten */
-
- if (Fread(fd, 1L, &c) != 1L)
- return(DD_NAK);
-
- return(c);
-}
-
-
-
-/* Routinen f�r Sender und Empf�nger */
-
-/*
-* Pipe schlie�en (Drag&Drop beenden/abbrechen)
-*/
-
-void ddclose(short fd)
-{
- /* Signalhandler restaurieren */
-
- ddsetsig(pipesig);
-
-
- Fclose(fd);
-}
-
-
-/*
-* Signalhandler f�r D&D konfigurieren
-*
-* Eingabeparameter:
-* oldsig - Zeiger auf 4 Byte Puffer f�r alten Handlerwert
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* keine
-*/
-
-void ddgetsig(long *oldsig)
-{
- *oldsig = (long) Psignal(SIGPIPE, (void *) SIG_IGN);
-}
-
-
-/*
-* Signalhandler nach D&D restaurieren
-*
-* Eingabeparameter:
-* oldsig - Alter Handlerwert (von ddgetsig)
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* keine
-*/
-
-void ddsetsig(long oldsig)
-{
- if (oldsig != -32L)
- Psignal(SIGPIPE, (void *) oldsig);
-}
-
-
-
-/* Routinen f�r Empf�nger */
-
-/*
-* Drag&Drop Pipe �ffnen
-*
-* Eingabeparameter:
-* ddnam - Extension der Pipe (letztes short von AP_DRAGDROP)
-* ddmsg - DD_OK oder DD_NAK
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* >0 - Filehandle der Drag&Drop pipe
-* -1 - Drag&Drop abgebrochen
-*/
-
-short ddopen(short ddnam, char ddmsg)
-{
- long fd;
-
- pipename[17] = (ddnam & 0xff00) >> 8;
- pipename[18] = ddnam & 0x00ff;
-
- fd = Fopen(pipename, 2);
-
- if (fd < 0L)
- return(-1);
-
-
- /* Signalhandler konfigurieren */
-
- ddgetsig(&pipesig);
-
-
- if (Fwrite((short) fd, 1L, &ddmsg) != 1L)
- {
- ddclose((short) fd);
- return(-1);
- }
-
- return((short) fd);
-}
-
-
-
-/*
-* Schreibt die 8 "bevorzugten" Extensionen der Applikation
-*
-* Eingabeparameter:
-* fd - Filehandle der D&D-Pipe
-* exts - Liste aus acht 4 Byte Extensionen die verstanden
-* werden. Diese Liste sollte nach bevorzugten Datentypen
-* sortiert sein. Sollten weniger als DD_NUMEXTS
-* Extensionen unterst�tzt werden, mu� die Liste mit
-* Nullen (0) aufgef�llt werden!
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler beim Schreiben in die Pipe
-*/
-
-short ddsexts(short fd, char *exts)
-{
- if (Fwrite(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* N�chsten Header vom Sender holen
-*
-* Eingabeparameter:
-* fd - Filehandle der Pipe (von ddopen())
-*
-* Ausgabeparameters:
-* name - Zeiger auf Buffer f�r Datenbeschreibung (min. DD_NAMEMAX!)
-* file - Zeiger auf Buffer f�r Datendateiname (min. DD_NAMEMAX!)
-* whichext- Zeiger auf Buffer f�r Extension (4 Bytes)
-* size - Zeiger auf Buffer f�r Datengr��e (4 Bytes)
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Sender brach Drag&Drop ab
-*
-* On lit dans le pipe qui normalement est constitu� de:
-* 1 short: taille du header
-* 4 CHAR: type de donn�e (extension)
-* 1 long: taille des donn�es
-* STRING: description des donn�es
-* STRING: nom du fichiers
-* soit au minimun 11 octets (cas ou les string sont r�duites � \0)
-* les string sont limit� a 128 octets
-*/
-
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size)
-{
- char buf[DD_NAMEMAX * 2];
- short hdrlen, i, len;
-
- if (Fread(fd, 2L, &hdrlen) != 2L)
- return(-1);
-
-
- if (hdrlen < 9) /* il reste au minimum 11 - 2 = 9 octets a lire */
- {
- /* sollte eigentlich nie passieren */
-
- return(-1); /* erreur taille incorrecte */
- }
-
- if (Fread(fd, 4L, whichext) != 4L) /* lecture de l'extension */
- return(-1);
-
- if (Fread(fd, 4L, size) != 4L) /* lecture de la longueurs des donn�es */
- return(-1);
-
- hdrlen -= 8; /* on a lu 8 octets */
-
- if (hdrlen > DD_NAMEMAX*2)
- i = DD_NAMEMAX*2;
- else
- i = hdrlen;
-
- len = i;
-
- if (Fread(fd, (long) i, buf) != (long) i)
- return(-1);
-
- hdrlen -= i;
-
- strncpy(name, buf, DD_NAMEMAX);
-
- i = (short) strlen(name) + 1;
-
- if (len - i > 0)
- strncpy(file, buf + i, DD_NAMEMAX);
- else
- file[0] = '\0';
-
-
- /* weitere Bytes im Header in den M�ll */
-
- while (hdrlen > DD_NAMEMAX*2)
- {
- if (Fread(fd, DD_NAMEMAX*2, buf) != DD_NAMEMAX*2)
- return(-1);
-
- hdrlen -= DD_NAMEMAX*2;
- }
-
- if (hdrlen > 0)
- {
- if (Fread(fd, (long) hdrlen, buf) != (long) hdrlen)
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Sendet der Senderapplikation eine 1 Byte Antwort
-*
-* Eingabeparameter:
-* fd - Filehandle der Pipe (von ddopen())
-* ack - Byte das gesendet werden soll (zB. DD_OK)
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler (die Pipe wird automatisch geschlossen!)
-*/
-
-short ddreply(short fd, char ack)
-{
- if (Fwrite(fd, 1L, &ack) != 1L)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
diff --git a/atari/dragdrop.h b/atari/dragdrop.h
deleted file mode 100755
index dccd3e3..0000000
--- a/atari/dragdrop.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-* MultiTOS Drag&Drop Header file
-*/
-
-/*
-* Declarations
-*/
-
-short ddcreate(short *pipe);
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
-short ddrexts(short fd, char *exts);
-short ddstry(short fd, char *ext, char *text, char *name, long size);
-void ddclose(short fd);
-void ddgetsig(long *oldsig);
-void ddsetsig(long oldsig);
-short ddopen(short ddnam, char ddmsg);
-short ddsexts(short fd, char *exts);
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
-short ddreply(short fd, char ack);
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index fe59209..1ac8935 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -55,9 +55,10 @@ short msg_box_show(short type, const char * msg);
/*
Guiwin
*/
-#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
-#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
-#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
+#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
+#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 6d525c6..56a3064 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -68,18 +68,22 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_REDRAW:
+ if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
tb_area = tb_area_ro;
if(rc_intersect((GRECT*)&msg[4], &tb_area)){
wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
while (g.g_h > 0 || g.g_w > 0) {
gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
g.g_w, g.g_h);
wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
}
}
+ }
break;
default:
@@ -145,13 +149,21 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
dest = guiwin_find(info[0]);
if (dest) {
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
- if(dest->toolbar != NULL && dest->handler_func != NULL){
+
+ // toolbar handling:
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
+ dest->toolbar != NULL && dest->handler_func != NULL){
GRECT tb_area;
guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y, tb_area)) {
// send WM_TOOLBAR message
- short obj_idx = 0;
+ dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
+ dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
+ short obj_idx = objc_find(dest->toolbar,
+ dest->toolbar_idx, 8,
+ ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
short oldevents = ev_out->emo_events;
@@ -161,14 +173,6 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
retval = 1;
}
}
- /*
- if (dest->flags&GW_FLAG_PREPROC_WM) {
- preproc_wm(dest, ev_in, ev_out, msg);
- }
- if (dest->handler_func) {
- retval = dest->handler_func(dest, ev_in, ev_out, msg);
- }
- */
}
}
}
@@ -177,7 +181,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
{
- GUIWIN *win = malloc(sizeof(GUIWIN));
+ GUIWIN *win = calloc(sizeof(GUIWIN),1);
assert(win!=NULL);
DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
@@ -259,9 +263,8 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
dest->g_w -= tb_area.g_w;
} else {
dest->g_y += tb_area.g_h;
- dest->g_w -= tb_area.g_h;
+ dest->g_h -= tb_area.g_h;
}
- dbg_grect("guiwin_get_grect content", dest);
}
else if (mode == GUIWIN_AREA_TOOLBAR) {
if (win->toolbar != NULL) {
@@ -274,7 +277,6 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
dest->g_h = 0;
dest->g_w = 0;
}
- dbg_grect("guiwin_get_grect toolbar", dest);
}
}
diff --git a/atari/msgbox.c b/atari/msgbox.c
deleted file mode 100644
index a9de5d2..0000000
--- a/atari/msgbox.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gem.h>
-#include "atari/msgbox.h"
-
-#ifndef min
-# define min(x,y) ((x<y) ? x : y )
-#endif
-
-short msg_box_show(short type, char * msg)
-{
- #define MSG_BOX_STR_SIZE 256
- short retval=0, i=0, z=0, l=0;
- char c;
- int len_msg = strlen(msg);
-
- // TODO: localize strings
- const char *str_yes = "Yes";
- const char *str_no = "No";
- const char *str_ok = "OK";
- char msg_box_str[MSG_BOX_STR_SIZE];
- char *dst = msg_box_str;
-
- memset(msg_box_str, 0, MSG_BOX_STR_SIZE);
-
- strncat(msg_box_str, "[1]", MSG_BOX_STR_SIZE);
- strncat(msg_box_str, "[", MSG_BOX_STR_SIZE);
-
- dst = msg_box_str + strlen(msg_box_str);
-
- for (i=0; i<min(len_msg,40*5); i++) {
-
- c = msg[i];
-
- if(c==0)
- break;
-
- if (z==40) {
- if(l==4){
- break;
- }
- z = 0;
- l++;
- *dst = (char)'|';
- dst++;
- }
-
- if ((c=='\r' || c=='\n') && *dst != '|') {
- if(l==4){
- break;
- }
- z = 0;
- l++;
- *dst = '|';
- dst++;
- }
- else {
- z++;
- *dst = c;
- dst++;
- }
- }
- strncat(msg_box_str, "][", MSG_BOX_STR_SIZE);
-
- if(type == MSG_BOX_CONFIRM){
- strncat(msg_box_str, str_yes, MSG_BOX_STR_SIZE);
- strncat(msg_box_str, "|", MSG_BOX_STR_SIZE);
- strncat(msg_box_str, str_no, MSG_BOX_STR_SIZE);
- } else {
- strncat(msg_box_str, str_ok, MSG_BOX_STR_SIZE);
- }
- strncat(msg_box_str, "]", MSG_BOX_STR_SIZE);
-
- retval = form_alert(type, msg_box_str);
- if(type == MSG_BOX_CONFIRM){
- if(retval != 1){
- retval = 0;
- }
- }
- return(retval);
-
- #undef MSG_BOX_STR_SIZE
-}
diff --git a/atari/msgbox.h b/atari/msgbox.h
deleted file mode 100644
index 204a490..0000000
--- a/atari/msgbox.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef GUIMSG_H_INCLUDED
-#define GUIMSG_H_INCLUDED
-
-#define MSG_BOX_ALERT 1
-#define MSG_BOX_CONFIRM 2
-
-short msg_box_show(short type, char * msg);
-
-
-#endif // GUIMSG_H_INCLUDED
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index de49363..a8a8b80 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index 3c2353e..7b422ef 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -197,3 +197,14 @@
#define CHOICES_CB_BG_IMAGES 107 /* BUTTON in tree CHOICES */
#define CHOICES_ABORT 108 /* BUTTON in tree CHOICES */
#define CHOICES_OK 109 /* BUTTON in tree CHOICES */
+
+#define ALERT 14 /* form/dial */
+
+#define VSCROLLER 15 /* form/dial */
+#define VSCROLLER_AREA 1 /* BOX in tree VSCROLLER */
+#define VSCROLLER_SLIDER_AREA 2 /* BUTTON in tree VSCROLLER */
+#define VSCROLLER_SLIDER 3 /* BUTTON in tree VSCROLLER */
+#define VSCROLLER_BT_DOWN 7 /* IBOX in tree VSCROLLER */
+#define VSCROLLER_BT_DOWN_PIC 5 /* CICON in tree VSCROLLER */
+#define VSCROLLER_BT_UP 6 /* IBOX in tree VSCROLLER */
+#define VSCROLLER_BT_UP_PIC 4 /* CICON in tree VSCROLLER */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index 67af68f..6996aea 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -1,9 +1,9 @@
ResourceMaster v3.65
-#C 14@0@0@0@
+#C 16@0@0@0@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@603@
+#M 20010100@0@7728@606@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -187,4 +187,13 @@ ResourceMaster v3.65
#O 107@26@CB_BG_IMAGES@@
#O 108@26@ABORT@@
#O 109@26@OK@@
-#c 31683@
+#T 14@2@ALERT@@1@@
+#T 15@2@VSCROLLER@@8@@
+#O 1@20@AREA@@
+#O 2@26@SLIDER_AREA@@
+#O 3@26@SLIDER@@
+#O 7@25@BT_DOWN@@
+#O 5@33@BT_DOWN_PIC@@
+#O 6@25@BT_UP@@
+#O 4@33@BT_UP_PIC@@
+#c 9608@
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 16d3363..a05c66e 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -131,8 +131,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_TOOLBAR:
- printf("toolbar click at %d,%d!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, msg[4]);
break;
default:
@@ -599,31 +599,6 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
-//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-//
-// input_window = gw;
-// WindTop( gw->root->handle );
-// window_set_focus( gw, BROWSER, gw->browser );
-//}
-
-//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-// if( input_window == gw) {
-// input_window = NULL;
-// }
-//}
-
-
-//static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
-//{
-// struct gui_window *gw = (struct gui_window*) data;
-// GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
-// window_redraw_favicon(gw, &clip);
-//}
-
static void redraw(GUIWIN *win, short msg[8])
{
short handle;
@@ -638,23 +613,17 @@ static void redraw(GUIWIN *win, short msg[8])
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(gw, &clip);
} else {
- GRECT area;
+ GRECT content_area, tb_area;
short pxy[8];
- guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
- /*
- pxy[0] = area.g_x;
- pxy[1] = area.g_y;
- pxy[2] = pxy[0] + area.g_w;
- pxy[3] = pxy[1];
- pxy[4] = pxy[2];
- pxy[5] = pxy[1] + area.g_h;
- pxy[6] = pxy[0];
- pxy[7] = pxy[5];
- */
- //const plot_style_fill_white
- plot_rectangle(area.g_x, area.g_y, area.g_x+area.g_h,
- area.g_y + area.g_h,
- plot_style_fill_white);
+
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area);
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ struct rect clip = {0,0,content_area.g_w,content_area.g_h};
+ plot_set_dimensions(content_area.g_x, content_area.g_y,
+ content_area.g_w,content_area.g_h);
+ //plot_clip(&clip);
+ plot_rectangle(0, 0, content_area.g_w,
+ content_area.g_h, plot_style_broken_object);
//WindClear(gw->root->handle);
-----------------------------------------------------------------------
Summary of changes:
atari/Makefile.target | 45 +++-
atari/browser_win.c | 589 -------------------------------------------------
atari/browser_win.h | 70 ------
atari/dragdrop.c | 516 -------------------------------------------
atari/dragdrop.h | 19 --
atari/gemtk/gemtk.h | 7 +-
atari/gemtk/guiwin.c | 30 ++--
atari/msgbox.c | 84 -------
atari/msgbox.h | 10 -
atari/res/netsurf.rsc | Bin 34322 -> 35768 bytes
atari/res/netsurf.rsh | 11 +
atari/res/netsurf.rsm | 15 +-
atari/rootwin.c | 55 +----
13 files changed, 91 insertions(+), 1360 deletions(-)
delete mode 100755 atari/browser_win.c
delete mode 100755 atari/browser_win.h
delete mode 100755 atari/dragdrop.c
delete mode 100755 atari/dragdrop.h
delete mode 100644 atari/msgbox.c
delete mode 100644 atari/msgbox.h
diff --git a/atari/Makefile.target b/atari/Makefile.target
index ad90807..9faa52d 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -7,7 +7,7 @@
# manually via env. variables, because the m68k-atari-mint
# toolchain is located in /usr/bin and the wildcard matching
# fails then. So this wildcard matches only works for
-# the netsurf environment!
+# the netsurf environment!
STRIP := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*strip)
STACK := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*stack)
@@ -73,15 +73,42 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
# S_ATARI are sources purely for the Atari FreeMiNT build
-S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
- download.c thumbnail.c login.c verify_ssl.c treeview.c hotlist.c history.c\
+S_ATARI := gui.c \
+ findfile.c \
+ filetype.c \
+ misc.c \
+ bitmap.c \
+ schedule.c \
+ download.c \
+ thumbnail.c \
+ login.c \
+ verify_ssl.c \
+ treeview.c \
+ hotlist.c \
+ history.c\
search.c font.c \
- plot/plot.c plot/fontplot.c plot/eddi.s \
- plot/font_freetype.c plot/font_internal.c \
- redrawslots.c encoding.c \
- browser_win.c toolbar.c statusbar.c browser.c \
- global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c
+ redrawslots.c \
+ encoding.c \
+ rootwin.c \
+ toolbar.c \
+ statusbar.c \
+ browser.c \
+ global_evnt.c \
+ osspec.c \
+ system_colour.c \
+ ctxmenu.c \
+ settings.c \
+ deskmenu.c \
+ plot/plot.c \
+ plot/fontplot.c \
+ plot/eddi.s \
+ plot/font_freetype.c \
+ plot/font_internal.c \
+ gemtk/utils.c \
+ gemtk/dragdrop.c \
+ gemtk/msgbox.c \
+ gemtk/guiwin.c
+
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/browser_win.c b/atari/browser_win.c
deleted file mode 100755
index f6daf37..0000000
--- a/atari/browser_win.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <windom.h>
-#include <assert.h>
-#include <math.h>
-#include <osbind.h>
-
-#include "utils/log.h"
-#include "desktop/gui.h"
-#include "desktop/history_core.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "css/css.h"
-#include "atari/gui.h"
-#include "atari/browser_win.h"
-#include "atari/browser.h"
-#include "atari/misc.h"
-#include "atari/plot/plot.h"
-#include "atari/global_evnt.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/browser.h"
-#include "atari/toolbar.h"
-#include "atari/statusbar.h"
-#include "atari/dragdrop.h"
-#include "atari/search.h"
-#include "atari/osspec.h"
-#include "atari/encoding.h"
-#include "atari/toolbar.h"
-
-extern void * h_gem_rsrc;
-extern struct gui_window *input_window;
-
-void __CDECL std_szd( WINDOW * win, short buff[8], void * );
-void __CDECL std_mvd( WINDOW * win, short buff[8], void * );
-
-
-/* -------------------------------------------------------------------------- */
-/* Static module methods follow here: */
-/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
-void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
-static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
-static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
-
-/* -------------------------------------------------------------------------- */
-/* Module public functions: */
-/* -------------------------------------------------------------------------- */
-
-
-int window_create( struct gui_window * gw,
- struct browser_window * bw,
- unsigned long inflags )
-{
- int err = 0;
- bool tb, sb;
- int flags;
-
- tb = (inflags & WIDGET_TOOLBAR );
- sb = (inflags & WIDGET_STATUSBAR );
-
- flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
- if( inflags & WIDGET_SCROLL ){
- flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
- }
- if( inflags & WIDGET_RESIZE ){
- flags |= ( SIZER );
- }
- if( inflags & WIDGET_STATUSBAR ){
- flags |= ( INFO );
- }
-
- gw->root = malloc( sizeof(struct s_gui_win_root) );
- if( gw->root == NULL )
- return( -1 );
- memset( gw->root, 0, sizeof(struct s_gui_win_root) );
- gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate( flags, 40, 40, app.w, app.h );
- if( gw->root->handle == NULL ) {
- free( gw->root->title );
- free( gw->root );
- return( -1 );
- }
-
- /* set scroll / content granularity ( 1 unit ) */
- gw->root->handle->w_u = 1;
- gw->root->handle->h_u = 1;
-
- /* Create Root component: */
- gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
- WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
-
- /* create toolbar component: */
- if( tb ) {
- gw->root->toolbar = tb_create( gw );
- assert( gw->root->toolbar );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
-
- } else {
- gw->root->toolbar = NULL;
- }
-
- /* create browser component: */
- gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
- mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
-
- /* create statusbar component: */
- if( sb ) {
- gw->root->statusbar = sb_create( gw );
-#ifdef WITH_COMOPONENT_STATUSBAR
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
-#endif
- } else {
- gw->root->statusbar = NULL;
- }
-
- WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
-
- /* Event Handlers: */
- EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
- /* capture resize/move events so we can handle that manually */
- EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
- EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
- EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
- EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
-
- if (inflags & WIN_TOP) {
- window_set_focus( gw, BROWSER, gw->browser);
- }
-
- return (err);
-}
-
-int window_destroy( struct gui_window * gw)
-{
- int err = 0;
-
- search_destroy( gw );
- if( input_window == gw )
- input_window = NULL;
-
- if( gw->root ) {
- if( gw->root->toolbar )
- tb_destroy( gw->root->toolbar );
-
- if( gw->root->statusbar )
- sb_destroy( gw->root->statusbar );
- }
-
- search_destroy( gw );
-
- if( gw->browser )
- browser_destroy( gw->browser );
-
- /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
- if( gw->root ) {
- /* TODO: check if no other browser is bound to this root window! */
- /* only needed for tabs */
- if( gw->root->title )
- free( gw->root->title );
- if( gw->root->cmproot )
- mt_CompDelete( &app, gw->root->cmproot );
- ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
- EvntWindom( MU_MESAG );
- gw->root->handle = NULL;
- free( gw->root );
- gw->root = NULL;
- }
- return( err );
-}
-
-
-
-void window_open( struct gui_window * gw, GRECT pos )
-{
- LGRECT br;
-
- WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
- WindClear( gw->root->handle );
- WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
-
- /* apply focus to the root frame: */
- long lfbuff[8] = { CM_GETFOCUS };
- mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
-
- /* recompute the nested component sizes and positions: */
- browser_update_rects( gw );
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_get_rect( gw, BR_CONTENT, &br );
- plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
- gw->browser->attached = true;
- if( gw->root->statusbar != NULL ){
- sb_attach(gw->root->statusbar, gw);
- }
- tb_adjust_size( gw );
- /*TBD: get already present content and set size? */
- input_window = gw;
- window_set_focus( gw, BROWSER, gw->browser );
-}
-
-
-
-/* update back forward buttons (see tb_update_buttons (bug) ) */
-void window_update_back_forward( struct gui_window * gw)
-{
- tb_update_buttons( gw, -1 );
-}
-
-void window_set_stauts(struct gui_window * gw , char * text )
-{
- if( gw->root == NULL )
- return;
-
- CMP_STATUSBAR sb = gw->root->statusbar;
-
- if( sb == NULL || gw->browser->attached == false )
- return;
-
- sb_set_text( sb, text );
-}
-
-/* set focus to an arbitary element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
-{
- if( gw->root->focus.type != type || gw->root->focus.element != element ) {
- LOG(("Set focus: %p (%d)\n", element, type));
- gw->root->focus.type = type;
- gw->root->focus.element = element;
- if( element != NULL ){
- switch( type ){
-
- case URL_WIDGET:
- textarea_keypress(((struct s_url_widget*)(element))->textarea,
- KEY_SELECT_ALL );
- break;
-
- default: break;
-
- }
- }
- }
-}
-
-/* check if the url widget has focus */
-bool window_url_widget_has_focus( struct gui_window * gw )
-{
- assert( gw );
- assert( gw->root );
- if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
- assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
- assert( GUIWIN_VISIBLE(gw) );
- return true;
- }
- return false;
-}
-
-/* check if an arbitary window widget / or frame has the focus */
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
-{
- if( gw == NULL )
- return( false );
- if( element == NULL ){
- assert( 1 != 0 );
- return( (gw->root->focus.type == t ) );
- }
- assert( gw->root != NULL );
- return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
-}
-
-void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
-{
- gw->icon = bmp;
- /* redraw window when it is iconyfied: */
- if (gw->icon != NULL) {
- short info, dummy;
- WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
- if (info == 1) {
- window_redraw_favicon(gw, NULL);
- }
- }
-}
-
-
-/**
- * Redraw the favicon
-*/
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
-{
- GRECT work;
-
- assert(gw->root);
-
- WINDOW * bw = gw->root->handle;
-
- WindClear(bw);
- WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
- if (clip == NULL) {
- clip = &work;
- }
-
- if (gw->icon == NULL) {
- OBJECT * tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree);
- tree->ob_x = work.g_x;
- tree->ob_y = work.g_y;
- tree->ob_width = work.g_w;
- tree->ob_height = work.g_h;
- objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
- } else {
- // TODO: consider the clipping rectangle
- struct rect work_clip = { 0,0,work.g_w,work.g_h };
- int xoff=0;
- if (work.g_w > work.g_h) {
- xoff = ((work.g_w-work.g_h)/2);
- work.g_w = work.g_h;
- }
- plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
- plot_clip(&work_clip);
- atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
- }
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* Event Handlers: */
-/* -------------------------------------------------------------------------- */
-
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
-{
- bool abs = false;
- LGRECT cwork;
- struct gui_window * gw = data;
- int value = BROWSER_SCROLL_SVAL;
-
- assert( gw != NULL );
-
- browser_get_rect( gw, BR_CONTENT, &cwork );
-
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
-
-
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
-
- default:
- break;
- }
- browser_scroll( gw, buff[4], value, abs );
-}
-
-
-static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
- char file[DD_NAMEMAX];
- char name[DD_NAMEMAX];
- char *buff=NULL;
- int dd_hdl;
- int dd_msg; /* pipe-handle */
- long size;
- char ext[32];
- short mx,my,bmstat,mkstat;
- graf_mkstate(&mx, &my, &bmstat, &mkstat);
-
- if( gw == NULL )
- return;
- if( (win->status & WS_ICONIFY))
- return;
-
- dd_hdl = ddopen( wbuff[7], DD_OK);
- if( dd_hdl<0)
- return; /* pipe not open */
- memset( ext, 0, 32);
- strcpy( ext, "ARGS");
- dd_msg = ddsexts( dd_hdl, ext);
- if( dd_msg<0)
- goto error;
- dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
- if( size+1 >= PATH_MAX )
- goto error;
- if( !strncmp( ext, "ARGS", 4) && dd_msg > 0)
- {
- ddreply(dd_hdl, DD_OK);
- buff = (char*)malloc(sizeof(char)*(size+1));
- if (buff != NULL)
- {
- if (Fread(dd_hdl, size, buff ) == size)
- buff[size] = 0;
- LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
- (char*)buff, (char*)&ext,
- size, mx, my
- ));
- {
- LGRECT bwrect;
- struct browser_window * bw = gw->browser->bw;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
- mx = mx - bwrect.g_x;
- my = my - bwrect.g_y;
- if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
- return;
-
- utf8_convert_ret ret;
- char *utf8_fn;
-
- ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
- free(buff);
- /* A bad encoding should never happen */
- LOG(("utf8_from_local_encoding failed"));
- assert(ret != UTF8_CONVERT_BADENC);
- /* no memory */
- return;
- }
- browser_window_drop_file_at_point( gw->browser->bw,
- mx+gw->browser->scroll.current.x,
- my+gw->browser->scroll.current.y,
- utf8_fn );
- free(utf8_fn);
- free(buff);
- }
- }
- }
-error:
- ddclose( dd_hdl);
-}
-
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
-{
- LOG(("%s\n", __FUNCTION__ ));
-}
-
-static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
-{
- struct gui_window * gw = (struct gui_window *) data ;
- if( gw != NULL ) {
- browser_window_destroy( gw->browser->bw );
- }
-}
-
-
-static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
-{
- input_window = (struct gui_window *) data;
- window_set_focus( input_window, BROWSER, input_window->browser );
- LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
- assert( input_window != NULL );
-}
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
-{
- int dx = buff[4];
- int dy = buff[5];
- struct gui_window * gw = data;
-
- if (!dx && !dy) return;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
-
- /* update the sliders _before_ we call redraw
- (which might depend on the slider possitions) */
- WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
-
- if( dy > 0 )
- browser_scroll( gw, WA_DNPAGE, abs(dy), false );
- else if ( dy < 0)
- browser_scroll( gw, WA_UPPAGE, abs(dy), false );
- if( dx > 0 )
- browser_scroll( gw, WA_RTPAGE, abs(dx), false );
- else if( dx < 0 )
- browser_scroll( gw, WA_LFPAGE, abs(dx), false );
-}
-
-static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
-
- input_window = gw;
- WindTop( gw->root->handle );
- window_set_focus( gw, BROWSER, gw->browser );
-}
-
-static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
- if( input_window == gw){
- input_window = NULL;
- }
-}
-
-
-static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
-{
- struct gui_window *gw = (struct gui_window*) data;
- GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
- window_redraw_favicon(gw, &clip);
-}
-
-/* perform the actual resize */
-static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
-{
- short x,y,w,h;
- struct gui_window * gw;
-
- wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
- gw = (struct gui_window *)data;
-
- assert( gw != NULL );
-
- if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
- /* report resize to component interface: */
- browser_update_rects( gw );
- tb_adjust_size( gw );
- if( gw->browser->bw->current_content != NULL ){
- /* Reformat will happen when next redraw message arrives: */
- gw->browser->reformat_pending = true;
- if( sys_XAAES() ){
- if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- gw->root->loc.g_x, gw->root->loc.g_y,
- gw->root->loc.g_w, gw->root->loc.g_h );
- }
- }
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
- (GRECT*)&gw->root->loc);
- }
- else {
- WindClear( gw->root->handle );
- }
- } else {
- if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_update_rects( gw );
- }
- }
-}
diff --git a/atari/browser_win.h b/atari/browser_win.h
deleted file mode 100755
index 28001ba..0000000
--- a/atari/browser_win.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NS_ATARI_BROWSER_WIN_H
-#define NS_ATARI_BROWSER_WIN_H
-
-#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
-#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
-
-#define WIDGET_STATUSBAR 0x1
-#define WIDGET_TOOLBAR 0x2
-#define WIDGET_SCROLL 0x4
-#define WIDGET_RESIZE 0x8
-
-#define WIN_TOP 0x100
-
-/* WinDom & Custom bindings for gui window */
-
-/* -------------------------------------------------------------------------- */
-/* Public module functions: */
-/* -------------------------------------------------------------------------- */
-
-/* Creates an normal Browser window with [toolbar], [statusbar] */
-int window_create( struct gui_window * gw,
- struct browser_window * bw, unsigned long flags );
-/* Destroys WinDom part of gui_window */
-int window_destroy( struct gui_window * gw );
-
-/* show the window */
-void window_open( struct gui_window * gw, GRECT pos);
-
-void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
-/* Update Shade / Unshade state of the fwd/back buttons*/
-void window_update_back_forward(struct gui_window * gw);
-/* set root browser component: */
-void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
-
-/* set focus element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
-/* adjust scroll settings */
-void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
-/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
-bool window_url_widget_has_focus( struct gui_window * gw );
-void window_set_url( struct gui_window * gw, const char * text);
-void window_set_stauts( struct gui_window * gw , char * text );
-void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
-
-
-/* -------------------------------------------------------------------------- */
-/* Public event handlers: */
-/* -------------------------------------------------------------------------- */
-
-#endif
diff --git a/atari/dragdrop.c b/atari/dragdrop.c
deleted file mode 100755
index bc7f565..0000000
--- a/atari/dragdrop.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
-* Routine pour Drag and drop sous MultiTos
-* source: D&D Atari, demo OEP (Alexander Lorenz)
-*
-* Struktur OEP (oep.apid): AES-ID der Applikation
-*
-* (Tab = 4)
-*/
-
-#ifdef __PUREC__
-#include <tos.h>
-#else
-#include <osbind.h>
-#include <mintbind.h>
-#include <signal.h>
-#endif
-
-#include <string.h>
-#include <stdio.h>
-
-#include "windom.h"
-#include "dragdrop.h"
-#include "cflib.h"
-
-#ifndef EACCDN
-#define EACCDN (-36)
-#endif
-
-#ifndef FA_HIDDEN
-#define FA_HIDDEN 0x02
-#endif
-
-static char pipename[] = "U:\\PIPE\\DRAGDROP.AA";
-static long pipesig;
-
-/*
-* Routinen f�r den Sender
-*/
-
-/*
-* Erzeugt Pipe f�r D&D
-*
-* Eingabeparameter:
-* pipe - Pointer auf 2 Byte Buffer f�r Pipeextension
-*
-* Ausgabeparameters:
-* keine
-*
-* Returnwert:
-* >0: Filehandle der Pipe
-* -1: Fehler beim Erzeugen der Pipe
-*/
-
-short ddcreate(short *pipe)
-{
- long fd = -1;
-
- pipename[17] = 'A';
- pipename[18] = 'A' - 1;
-
- do /* ouvre un pipe inoccup� */
- {
- pipename[18]++;
- if (pipename[18] > 'Z')
- {
- pipename[17]++;
- if (pipename[17] > 'Z')
- break;
- else
- pipename[18] = 'A';
- }
-
- /* FA_HIDDEN f�r Pipe notwendig! */
-
- fd = Fcreate(pipename, FA_HIDDEN);
-
- } while (fd == (long) EACCDN);
-
- if (fd < 0L)
- return(-1);
-
- *pipe = (pipename[17] << 8) | pipename[18];
-
-
- /* Signalhandler konfigurieren */
-
- ddgetsig(&pipesig);
-
-
- return((short) fd);
-}
-
-
-
-/*
-* Sendet AP_DRAGDROP an Empf�ngerapplikation
-*
-* Eingabeparameter:
-* apid - AES-ID der Emf�ngerapp.
-* fd - Filehandle der D&D-Pipe
-* winid - Handle des Zielfensters (0 f�r Desktopfenster)
-* mx/my - Maus X und Y Koord.
-* (-1/-1 f�r einen fake Drag&Drop)
-* kstate - Sondertastenstatus
-* pipename - Extension der D&D-Pipe
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Empf�ngerapp. gibt DD_NAK zur�ck
-* -2: Empf�ngerapp. antwortet nicht (Timeout)
-* -3: Fehler bei appl_write()
-*/
-
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipeid)
-{
- char c;
- short i, msg[8];
- long fd_mask;
-
-
- /* AES-Message define and post */
-
- msg[0] = AP_DRAGDROP;
- msg[1] = _AESapid;
- msg[2] = 0;
- msg[3] = winid;
- msg[4] = mx;
- msg[5] = my;
- msg[6] = kstate;
- msg[7] = pipeid;
-
- i = appl_write(apid, 16, msg);
-
- if (i == 0)
- {
- ddclose(fd);
- return(-3);
- }
-
-
- /* receiver reaction */
-
- fd_mask = (1L << fd);
- i = Fselect(DD_TIMEOUT, &fd_mask, 0L, 0L);
- if (!i || !fd_mask)
- {
- /* Timeout eingetreten */
-
- ddclose(fd);
- return(-2);
- }
-
-
- /* le recepteur refuse (lecture du pipe) */
-
- if (Fread(fd, 1L, &c) != 1L)
- {
- ddclose(fd);
- return(-1);
- }
-
- if (c != DD_OK)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Liest die 8 "bevorzugten" Extensionen der Empf�ngerapplikation
-*
-* Eingabeparameter:
-* fd - Filehandle der D&D-Pipe
-*
-* Ausgabeparameters:
-* exts - 32 Bytebuffer f�r die 8 bevorzugten Extensionen
-* der Zielapp.
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler beim Lesen aus der Pipe
-*/
-
-short ddrexts(short fd, char *exts)
-{
- if (Fread(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Testet, ob der Empf�nger einen Datentyp akzeptiert
-*
-* Eingabeparameter:
-* fd - Filehandle (von ddcreate())
-* ext - Zeiger auf Datentyp (4 Bytes zB. "ARGS")
-* text - Zeiger auf Datenbeschreibung (optional, zB. "DESKTOP args")
-* name - Zeiger auf Datendateiname (optional, zB. "SAMPLE.TXT")
-* size - Anzahl Bytes der zu sendenden Daten
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* DD_OK - Empf�nger akzeptiert Datentyp
-* DD_NAK - Empf�nger brach Drag&Drop ab
-* DD_EXT - Empf�nger lehnt Datentyp ab
-* DD_LEN - Empf�nger kann Datenmenge nicht verarbeiten
-* DD_TRASH - Drop erfolgte auf M�lleimer
-* DD_PRINTER - Drop erfolgte auf Drucker
-* DD_CLIPBOARD - Drop erfolgte auf Clipboard
-*/
-
-short ddstry(short fd, char *ext, char *text, char *name, long size)
-{
- char c;
- short hdrlen, i;
-
- /* 4 Bytes f�r "ext", 4 Bytes f�r "size",
- 2 Bytes f�r Stringendnullen */
-
- hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1);
-
-
- /* Header senden */
-
- if (Fwrite(fd, 2L, &hdrlen) != 2L)
- return(DD_NAK);
-
- i = (short) Fwrite(fd, 4L, ext);
- i += (short) Fwrite(fd, 4L, &size);
- i += (short) Fwrite(fd, strlen(text)+1, text);
- i += (short) Fwrite(fd, strlen(name)+1, name);
-
- if (i != hdrlen)
- return(DD_NAK);
-
-
- /* auf die Antwort warten */
-
- if (Fread(fd, 1L, &c) != 1L)
- return(DD_NAK);
-
- return(c);
-}
-
-
-
-/* Routinen f�r Sender und Empf�nger */
-
-/*
-* Pipe schlie�en (Drag&Drop beenden/abbrechen)
-*/
-
-void ddclose(short fd)
-{
- /* Signalhandler restaurieren */
-
- ddsetsig(pipesig);
-
-
- Fclose(fd);
-}
-
-
-/*
-* Signalhandler f�r D&D konfigurieren
-*
-* Eingabeparameter:
-* oldsig - Zeiger auf 4 Byte Puffer f�r alten Handlerwert
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* keine
-*/
-
-void ddgetsig(long *oldsig)
-{
- *oldsig = (long) Psignal(SIGPIPE, (void *) SIG_IGN);
-}
-
-
-/*
-* Signalhandler nach D&D restaurieren
-*
-* Eingabeparameter:
-* oldsig - Alter Handlerwert (von ddgetsig)
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* keine
-*/
-
-void ddsetsig(long oldsig)
-{
- if (oldsig != -32L)
- Psignal(SIGPIPE, (void *) oldsig);
-}
-
-
-
-/* Routinen f�r Empf�nger */
-
-/*
-* Drag&Drop Pipe �ffnen
-*
-* Eingabeparameter:
-* ddnam - Extension der Pipe (letztes short von AP_DRAGDROP)
-* ddmsg - DD_OK oder DD_NAK
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwerte:
-* >0 - Filehandle der Drag&Drop pipe
-* -1 - Drag&Drop abgebrochen
-*/
-
-short ddopen(short ddnam, char ddmsg)
-{
- long fd;
-
- pipename[17] = (ddnam & 0xff00) >> 8;
- pipename[18] = ddnam & 0x00ff;
-
- fd = Fopen(pipename, 2);
-
- if (fd < 0L)
- return(-1);
-
-
- /* Signalhandler konfigurieren */
-
- ddgetsig(&pipesig);
-
-
- if (Fwrite((short) fd, 1L, &ddmsg) != 1L)
- {
- ddclose((short) fd);
- return(-1);
- }
-
- return((short) fd);
-}
-
-
-
-/*
-* Schreibt die 8 "bevorzugten" Extensionen der Applikation
-*
-* Eingabeparameter:
-* fd - Filehandle der D&D-Pipe
-* exts - Liste aus acht 4 Byte Extensionen die verstanden
-* werden. Diese Liste sollte nach bevorzugten Datentypen
-* sortiert sein. Sollten weniger als DD_NUMEXTS
-* Extensionen unterst�tzt werden, mu� die Liste mit
-* Nullen (0) aufgef�llt werden!
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler beim Schreiben in die Pipe
-*/
-
-short ddsexts(short fd, char *exts)
-{
- if (Fwrite(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* N�chsten Header vom Sender holen
-*
-* Eingabeparameter:
-* fd - Filehandle der Pipe (von ddopen())
-*
-* Ausgabeparameters:
-* name - Zeiger auf Buffer f�r Datenbeschreibung (min. DD_NAMEMAX!)
-* file - Zeiger auf Buffer f�r Datendateiname (min. DD_NAMEMAX!)
-* whichext- Zeiger auf Buffer f�r Extension (4 Bytes)
-* size - Zeiger auf Buffer f�r Datengr��e (4 Bytes)
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Sender brach Drag&Drop ab
-*
-* On lit dans le pipe qui normalement est constitu� de:
-* 1 short: taille du header
-* 4 CHAR: type de donn�e (extension)
-* 1 long: taille des donn�es
-* STRING: description des donn�es
-* STRING: nom du fichiers
-* soit au minimun 11 octets (cas ou les string sont r�duites � \0)
-* les string sont limit� a 128 octets
-*/
-
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size)
-{
- char buf[DD_NAMEMAX * 2];
- short hdrlen, i, len;
-
- if (Fread(fd, 2L, &hdrlen) != 2L)
- return(-1);
-
-
- if (hdrlen < 9) /* il reste au minimum 11 - 2 = 9 octets a lire */
- {
- /* sollte eigentlich nie passieren */
-
- return(-1); /* erreur taille incorrecte */
- }
-
- if (Fread(fd, 4L, whichext) != 4L) /* lecture de l'extension */
- return(-1);
-
- if (Fread(fd, 4L, size) != 4L) /* lecture de la longueurs des donn�es */
- return(-1);
-
- hdrlen -= 8; /* on a lu 8 octets */
-
- if (hdrlen > DD_NAMEMAX*2)
- i = DD_NAMEMAX*2;
- else
- i = hdrlen;
-
- len = i;
-
- if (Fread(fd, (long) i, buf) != (long) i)
- return(-1);
-
- hdrlen -= i;
-
- strncpy(name, buf, DD_NAMEMAX);
-
- i = (short) strlen(name) + 1;
-
- if (len - i > 0)
- strncpy(file, buf + i, DD_NAMEMAX);
- else
- file[0] = '\0';
-
-
- /* weitere Bytes im Header in den M�ll */
-
- while (hdrlen > DD_NAMEMAX*2)
- {
- if (Fread(fd, DD_NAMEMAX*2, buf) != DD_NAMEMAX*2)
- return(-1);
-
- hdrlen -= DD_NAMEMAX*2;
- }
-
- if (hdrlen > 0)
- {
- if (Fread(fd, (long) hdrlen, buf) != (long) hdrlen)
- return(-1);
- }
-
- return(1);
-}
-
-
-
-/*
-* Sendet der Senderapplikation eine 1 Byte Antwort
-*
-* Eingabeparameter:
-* fd - Filehandle der Pipe (von ddopen())
-* ack - Byte das gesendet werden soll (zB. DD_OK)
-*
-* Ausgabeparameter:
-* keine
-*
-* Returnwert:
-* >0: kein Fehler
-* -1: Fehler (die Pipe wird automatisch geschlossen!)
-*/
-
-short ddreply(short fd, char ack)
-{
- if (Fwrite(fd, 1L, &ack) != 1L)
- {
- ddclose(fd);
- return(-1);
- }
-
- return(1);
-}
-
-
diff --git a/atari/dragdrop.h b/atari/dragdrop.h
deleted file mode 100755
index dccd3e3..0000000
--- a/atari/dragdrop.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-* MultiTOS Drag&Drop Header file
-*/
-
-/*
-* Declarations
-*/
-
-short ddcreate(short *pipe);
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
-short ddrexts(short fd, char *exts);
-short ddstry(short fd, char *ext, char *text, char *name, long size);
-void ddclose(short fd);
-void ddgetsig(long *oldsig);
-void ddsetsig(long oldsig);
-short ddopen(short ddnam, char ddmsg);
-short ddsexts(short fd, char *exts);
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
-short ddreply(short fd, char ack);
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index fe59209..1ac8935 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -55,9 +55,10 @@ short msg_box_show(short type, const char * msg);
/*
Guiwin
*/
-#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
-#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
-#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
+#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
+#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 6d525c6..56a3064 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -68,18 +68,22 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_REDRAW:
+ if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
tb_area = tb_area_ro;
if(rc_intersect((GRECT*)&msg[4], &tb_area)){
wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
while (g.g_h > 0 || g.g_w > 0) {
gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
g.g_w, g.g_h);
wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
}
}
+ }
break;
default:
@@ -145,13 +149,21 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
dest = guiwin_find(info[0]);
if (dest) {
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
- if(dest->toolbar != NULL && dest->handler_func != NULL){
+
+ // toolbar handling:
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
+ dest->toolbar != NULL && dest->handler_func != NULL){
GRECT tb_area;
guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y, tb_area)) {
// send WM_TOOLBAR message
- short obj_idx = 0;
+ dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
+ dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
+ short obj_idx = objc_find(dest->toolbar,
+ dest->toolbar_idx, 8,
+ ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
short oldevents = ev_out->emo_events;
@@ -161,14 +173,6 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
retval = 1;
}
}
- /*
- if (dest->flags&GW_FLAG_PREPROC_WM) {
- preproc_wm(dest, ev_in, ev_out, msg);
- }
- if (dest->handler_func) {
- retval = dest->handler_func(dest, ev_in, ev_out, msg);
- }
- */
}
}
}
@@ -177,7 +181,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
{
- GUIWIN *win = malloc(sizeof(GUIWIN));
+ GUIWIN *win = calloc(sizeof(GUIWIN),1);
assert(win!=NULL);
DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
@@ -259,9 +263,8 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
dest->g_w -= tb_area.g_w;
} else {
dest->g_y += tb_area.g_h;
- dest->g_w -= tb_area.g_h;
+ dest->g_h -= tb_area.g_h;
}
- dbg_grect("guiwin_get_grect content", dest);
}
else if (mode == GUIWIN_AREA_TOOLBAR) {
if (win->toolbar != NULL) {
@@ -274,7 +277,6 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
dest->g_h = 0;
dest->g_w = 0;
}
- dbg_grect("guiwin_get_grect toolbar", dest);
}
}
diff --git a/atari/msgbox.c b/atari/msgbox.c
deleted file mode 100644
index a9de5d2..0000000
--- a/atari/msgbox.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gem.h>
-#include "atari/msgbox.h"
-
-#ifndef min
-# define min(x,y) ((x<y) ? x : y )
-#endif
-
-short msg_box_show(short type, char * msg)
-{
- #define MSG_BOX_STR_SIZE 256
- short retval=0, i=0, z=0, l=0;
- char c;
- int len_msg = strlen(msg);
-
- // TODO: localize strings
- const char *str_yes = "Yes";
- const char *str_no = "No";
- const char *str_ok = "OK";
- char msg_box_str[MSG_BOX_STR_SIZE];
- char *dst = msg_box_str;
-
- memset(msg_box_str, 0, MSG_BOX_STR_SIZE);
-
- strncat(msg_box_str, "[1]", MSG_BOX_STR_SIZE);
- strncat(msg_box_str, "[", MSG_BOX_STR_SIZE);
-
- dst = msg_box_str + strlen(msg_box_str);
-
- for (i=0; i<min(len_msg,40*5); i++) {
-
- c = msg[i];
-
- if(c==0)
- break;
-
- if (z==40) {
- if(l==4){
- break;
- }
- z = 0;
- l++;
- *dst = (char)'|';
- dst++;
- }
-
- if ((c=='\r' || c=='\n') && *dst != '|') {
- if(l==4){
- break;
- }
- z = 0;
- l++;
- *dst = '|';
- dst++;
- }
- else {
- z++;
- *dst = c;
- dst++;
- }
- }
- strncat(msg_box_str, "][", MSG_BOX_STR_SIZE);
-
- if(type == MSG_BOX_CONFIRM){
- strncat(msg_box_str, str_yes, MSG_BOX_STR_SIZE);
- strncat(msg_box_str, "|", MSG_BOX_STR_SIZE);
- strncat(msg_box_str, str_no, MSG_BOX_STR_SIZE);
- } else {
- strncat(msg_box_str, str_ok, MSG_BOX_STR_SIZE);
- }
- strncat(msg_box_str, "]", MSG_BOX_STR_SIZE);
-
- retval = form_alert(type, msg_box_str);
- if(type == MSG_BOX_CONFIRM){
- if(retval != 1){
- retval = 0;
- }
- }
- return(retval);
-
- #undef MSG_BOX_STR_SIZE
-}
diff --git a/atari/msgbox.h b/atari/msgbox.h
deleted file mode 100644
index 204a490..0000000
--- a/atari/msgbox.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef GUIMSG_H_INCLUDED
-#define GUIMSG_H_INCLUDED
-
-#define MSG_BOX_ALERT 1
-#define MSG_BOX_CONFIRM 2
-
-short msg_box_show(short type, char * msg);
-
-
-#endif // GUIMSG_H_INCLUDED
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index de49363..a8a8b80 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index 3c2353e..7b422ef 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -197,3 +197,14 @@
#define CHOICES_CB_BG_IMAGES 107 /* BUTTON in tree CHOICES */
#define CHOICES_ABORT 108 /* BUTTON in tree CHOICES */
#define CHOICES_OK 109 /* BUTTON in tree CHOICES */
+
+#define ALERT 14 /* form/dial */
+
+#define VSCROLLER 15 /* form/dial */
+#define VSCROLLER_AREA 1 /* BOX in tree VSCROLLER */
+#define VSCROLLER_SLIDER_AREA 2 /* BUTTON in tree VSCROLLER */
+#define VSCROLLER_SLIDER 3 /* BUTTON in tree VSCROLLER */
+#define VSCROLLER_BT_DOWN 7 /* IBOX in tree VSCROLLER */
+#define VSCROLLER_BT_DOWN_PIC 5 /* CICON in tree VSCROLLER */
+#define VSCROLLER_BT_UP 6 /* IBOX in tree VSCROLLER */
+#define VSCROLLER_BT_UP_PIC 4 /* CICON in tree VSCROLLER */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index 67af68f..6996aea 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -1,9 +1,9 @@
ResourceMaster v3.65
-#C 14@0@0@0@
+#C 16@0@0@0@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@603@
+#M 20010100@0@7728@606@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -187,4 +187,13 @@ ResourceMaster v3.65
#O 107@26@CB_BG_IMAGES@@
#O 108@26@ABORT@@
#O 109@26@OK@@
-#c 31683@
+#T 14@2@ALERT@@1@@
+#T 15@2@VSCROLLER@@8@@
+#O 1@20@AREA@@
+#O 2@26@SLIDER_AREA@@
+#O 3@26@SLIDER@@
+#O 7@25@BT_DOWN@@
+#O 5@33@BT_DOWN_PIC@@
+#O 6@25@BT_UP@@
+#O 4@33@BT_UP_PIC@@
+#c 9608@
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 16d3363..a05c66e 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -131,8 +131,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_TOOLBAR:
- printf("toolbar click at %d,%d!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, msg[4]);
break;
default:
@@ -599,31 +599,6 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
-//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-//
-// input_window = gw;
-// WindTop( gw->root->handle );
-// window_set_focus( gw, BROWSER, gw->browser );
-//}
-
-//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-// if( input_window == gw) {
-// input_window = NULL;
-// }
-//}
-
-
-//static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
-//{
-// struct gui_window *gw = (struct gui_window*) data;
-// GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
-// window_redraw_favicon(gw, &clip);
-//}
-
static void redraw(GUIWIN *win, short msg[8])
{
short handle;
@@ -638,23 +613,17 @@ static void redraw(GUIWIN *win, short msg[8])
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(gw, &clip);
} else {
- GRECT area;
+ GRECT content_area, tb_area;
short pxy[8];
- guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
- /*
- pxy[0] = area.g_x;
- pxy[1] = area.g_y;
- pxy[2] = pxy[0] + area.g_w;
- pxy[3] = pxy[1];
- pxy[4] = pxy[2];
- pxy[5] = pxy[1] + area.g_h;
- pxy[6] = pxy[0];
- pxy[7] = pxy[5];
- */
- //const plot_style_fill_white
- plot_rectangle(area.g_x, area.g_y, area.g_x+area.g_h,
- area.g_y + area.g_h,
- plot_style_fill_white);
+
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area);
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ struct rect clip = {0,0,content_area.g_w,content_area.g_h};
+ plot_set_dimensions(content_area.g_x, content_area.g_y,
+ content_area.g_w,content_area.g_h);
+ //plot_clip(&clip);
+ plot_rectangle(0, 0, content_area.g_w,
+ content_area.g_h, plot_style_broken_object);
//WindClear(gw->root->handle);
--
NetSurf Browser
10 years, 6 months
netsurf: branch mono/removing-windom-dependency updated. c415f9bf989f83c7ced6bb930e3421dab6f4093b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c415f9bf989f83c7ced6b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c415f9bf989f83c7ced6bb9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c415f9bf989f83c7ced6bb930...
The branch, mono/removing-windom-dependency has been updated
via c415f9bf989f83c7ced6bb930e3421dab6f4093b (commit)
from e042008f2b7295243d2e6c72f948febe3cad0516 (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/commitdiff/c415f9bf989f83c7ced...
commit c415f9bf989f83c7ced6bb930e3421dab6f4093b
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Start to remove windom, wip.
- Refactored menu event handling.
- Load plain GEM resources.
- Refactored Event handling
diff --git a/atari/browser.c b/atari/browser.c
index 034f89a..1b3661e 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -45,7 +45,7 @@
#include "utils/messages.h"
#include "atari/gui.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 1a1755b..6239f21 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -41,7 +41,7 @@
#include "atari/gui.h"
#include "atari/browser.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/clipboard.h"
#include "desktop/options.h"
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
new file mode 100644
index 0000000..d486803
--- /dev/null
+++ b/atari/deskmenu.c
@@ -0,0 +1,660 @@
+#include <stdlib.h>
+#include <windom.h>
+
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/gemtk/gemtk.h"
+#include "atari/deskmenu.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/toolbar.h"
+#include "atari/settings.h"
+#include "atari/search.h"
+#include "atari/misc.h"
+#include "atari/gui.h"
+#include "atari/findfile.h"
+#include "atari/browser.h"
+#include "atari/rootwin.h"
+
+typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
+
+static void register_menu_str(struct s_menu_item_evnt * mi);
+static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
+
+extern void *h_gem_rsrc;
+extern bool html_redraw_debug;
+extern struct gui_window * input_window;
+extern char options[PATH_MAX];
+extern const char * option_homepage_url;
+extern int option_window_width;
+extern int option_window_height;
+extern int option_window_x;
+extern int option_window_y;
+
+static OBJECT * h_gem_menu;
+
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
+#define NUM_MENU_TITLES 7
+
+
+static void __CDECL menu_about(short item, short title, void *data);
+static void __CDECL menu_new_win(short item, short title, void *data);
+static void __CDECL menu_open_url(short item, short title, void *data);
+static void __CDECL menu_open_file(short item, short title, void *data);
+static void __CDECL menu_close_win(short item, short title, void *data);
+static void __CDECL menu_save_page(short item, short title, void *data);
+static void __CDECL menu_quit(short item, short title, void *data);
+static void __CDECL menu_cut(short item, short title, void *data);
+static void __CDECL menu_copy(short item, short title, void *data);
+static void __CDECL menu_paste(short item, short title, void *data);
+static void __CDECL menu_find(short item, short title, void *data);
+static void __CDECL menu_choices(short item, short title, void *data);
+static void __CDECL menu_stop(short item, short title, void *data);
+static void __CDECL menu_reload(short item, short title, void *data);
+static void __CDECL menu_toolbars(short item, short title, void *data);
+static void __CDECL menu_savewin(short item, short title, void *data);
+static void __CDECL menu_debug_render(short item, short title, void *data);
+static void __CDECL menu_fg_images(short item, short title, void *data);
+static void __CDECL menu_bg_images(short item, short title, void *data);
+static void __CDECL menu_back(short item, short title, void *data);
+static void __CDECL menu_forward(short item, short title, void *data);
+static void __CDECL menu_home(short item, short title, void *data);
+static void __CDECL menu_lhistory(short item, short title, void *data);
+static void __CDECL menu_ghistory(short item, short title, void *data);
+static void __CDECL menu_add_bookmark(short item, short title, void *data);
+static void __CDECL menu_bookmarks(short item, short title, void *data);
+static void __CDECL menu_vlog(short item, short title, void *data);
+static void __CDECL menu_help_content(short item, short title, void *data);
+
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
+};
+
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ OBJECT *gem_menu = deskmenu_get_obj_tree();
+
+ assert(gem_menu != NULL);
+
+ char * str = ObjcString( gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+ while (i > 2) {
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+
+ deskmenu_dispatch_item(buff[3], buff[4]);
+}
+
+/*
+ Menu item event handlers:
+*/
+
+static void __CDECL menu_about(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ char buf[PATH_MAX];
+ strcpy((char*)&buf, "file://");
+ strncat((char*)&buf, (char*)"./doc/README.TXT",
+ PATH_MAX - (strlen("file://")+1) );
+ browser_window_create((char*)&buf, 0, 0, true, false);
+}
+
+static void __CDECL menu_new_win(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+}
+
+static void __CDECL menu_open_url(short item, short title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+ LOG(("%s", __FUNCTION__));
+
+ gw = input_window;
+ if( gw == NULL ) {
+ bw = browser_window_create("", 0, 0, true, false);
+ gw = bw->window;
+
+ }
+ /* Loose focus: */
+ window_set_focus( gw, WIDGET_NONE, NULL );
+
+ /* trigger on-focus event (select all text): */
+ window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+
+ /* delete selection: */
+ tb_url_input( gw, NK_DEL );
+}
+
+static void __CDECL menu_open_file(short item, short title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+
+ LOG(("%s", __FUNCTION__));
+
+ const char * filename = file_select( messages_get("OpenFile"), "" );
+ if( filename != NULL ){
+ char * url = local_file_to_url( filename );
+ if( url ){
+ bw = browser_window_create(url, NULL, NULL, true, false);
+ free( url );
+ }
+ }
+}
+
+static void __CDECL menu_close_win(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ static bool init = true;
+ bool is_folder=false;
+ const char * path;
+
+ if( !input_window )
+ return;
+
+ if( init ){
+ init = false;
+ save_complete_init();
+ }
+
+ do {
+ // TODO: localize string
+ path = file_select("Select folder", "");
+ if (path)
+ is_folder = is_dir(path);
+ } while( !is_folder && path != NULL );
+
+ if( path != NULL ){
+ save_complete( input_window->browser->bw->current_content, path, NULL );
+ }
+
+}
+
+static void __CDECL menu_quit(short item, short title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ netsurf_quit = true;
+}
+
+static void __CDECL menu_cut(short item, short title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ open_browser_search( input_window );
+}
+
+static void __CDECL menu_choices(short item, short title, void *data)
+{
+ static WINDOW * settings_dlg = NULL;
+ LOG(("%s", __FUNCTION__));
+ settings_dlg = open_settings();
+}
+
+static void __CDECL menu_stop(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_stop_click( input_window );
+
+}
+
+static void __CDECL menu_reload(short item, short title, void *data)
+{
+ if( input_window == NULL)
+ return;
+ tb_reload_click( input_window );
+ LOG(("%s", __FUNCTION__));
+}
+
+static void __CDECL menu_toolbars(short item, short title, void *data)
+{
+ static int state = 0;
+ LOG(("%s", __FUNCTION__));
+ if( input_window != null && input_window->root->toolbar != null ){
+ state = !state;
+ tb_hide( input_window, state );
+ }
+}
+
+static void __CDECL menu_savewin(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window && input_window->browser) {
+ GRECT rect;
+ wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ option_window_width = rect.g_w;
+ option_window_height = rect.g_h;
+ option_window_x = rect.g_x;
+ option_window_y = rect.g_y;
+ nsoption_set_int(window_width, rect.g_w);
+ nsoption_set_int(window_height, rect.g_h);
+ nsoption_set_int(window_x, rect.g_x);
+ nsoption_set_int(window_y, rect.g_y);
+ nsoption_write((const char*)&options);
+ }
+
+}
+
+static void __CDECL menu_debug_render(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
+ if ( input_window->browser != NULL
+ && input_window->browser->bw != NULL) {
+ LGRECT rect;
+ browser_get_rect( input_window, BR_CONTENT, &rect );
+ browser_window_reformat(input_window->browser->bw, false,
+ rect.g_w, rect.g_h );
+ MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0 );
+ }
+ }
+}
+
+static void __CDECL menu_fg_images(short item, short title, void *data)
+{
+ nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_bg_images(short item, short title, void *data)
+{
+ nsoption_set_bool(background_images, !nsoption_bool(background_images));
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_back_click( input_window );
+}
+
+static void __CDECL menu_forward(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_forward_click( input_window );
+}
+
+static void __CDECL menu_home(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_home_click( input_window );
+}
+
+static void __CDECL menu_lhistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ hotlist_open();
+}
+
+static void __CDECL menu_vlog(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ verbose_log = !verbose_log;
+ MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+}
+
+static void __CDECL menu_help_content(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+}
+
+/*
+ Public deskmenu interface:
+*/
+
+
+/**
+* Setup & display an desktop menu.
+*/
+
+void deskmenu_init(void)
+{
+ int i;
+
+ h_gem_menu = get_tree(MAINMENU);
+
+ // TODO: remove that call somehow...
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ /* Update menu string if not null: */
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
+ menu_evnt_tbl[i].menustr);
+ }
+ i++;
+ }
+ deskmenu_update();
+
+ /* Install menu: */
+ menu_bar(h_gem_menu, MENU_INSTALL);
+ /* Redraw menu: */
+ menu_bar(h_gem_menu, MENU_UPDATE);
+}
+
+/**
+* Uninstall the desktop menu
+*/
+void deskmenu_destroy(void)
+{
+ int i;
+
+ /* Remove menu from desktop: */
+ menu_bar(h_gem_menu, MENU_REMOVE);
+
+ /* Free modified menu titles: */
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
+ }
+}
+
+/**
+* Return the deskmenu AES OBJECT tree
+*/
+OBJECT * deskmenu_get_obj_tree(void)
+{
+ return(h_gem_menu);
+}
+
+/**
+* Handle an menu item event
+*/
+int deskmenu_dispatch_item(short title, short item)
+{
+ int i=0;
+ int retval = 0;
+ OBJECT * menu_root = deskmenu_get_obj_tree();
+
+ menu_tnormal(menu_root, item, 1);
+ menu_tnormal(menu_root, title, 1);
+ menu_bar(menu_root, 1);
+
+ // legacy code, is this sensible?:
+ /*
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ */
+
+
+ while (menu_evnt_tbl[i].rid != -1) {
+ if (menu_evnt_tbl[i].rid == item) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func(item, title, NULL);
+ }
+ break;
+ }
+ i++;
+ }
+
+ return(retval);
+}
+
+/**
+* Handle an keypress (check for accelerator)
+*/
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ char sascii;
+ bool done = 0;
+ int i = 0;
+
+ sascii = keybd2ascii(kcode, K_LSHIFT);
+
+ /* Iterate through the menu function table: */
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ if( kstate == menu_evnt_tbl[i].accel.mod
+ && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ return((done==true) ? 1 : 0);
+}
+
+/**
+* Refresh the desk menu, reflecting netsurf current state.
+*/
+void deskmenu_update(void)
+{
+ OBJECT * gem_menu = deskmenu_get_obj_tree();
+
+ menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
+
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
new file mode 100644
index 0000000..6ab00dc
--- /dev/null
+++ b/atari/deskmenu.h
@@ -0,0 +1,12 @@
+#ifndef DESKMENU_H_INCLUDED
+#define DESKMENU_H_INCLUDED
+
+void deskmenu_init(void);
+void deskmenu_destroy(void);
+int deskmenu_dispatch_item(short title, short item);
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
+OBJECT * deskmenu_get_obj_tree(void);
+void deskmenu_update( void );
+
+#endif // DESKMENU_H_INCLUDED
diff --git a/atari/findfile.c b/atari/findfile.c
index 93bf463..00502c9 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -28,6 +28,7 @@
#include "utils/log.h"
#include "utils/url.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/findfile.h"
#include "atari/gui.h"
#include "atari/misc.h"
diff --git a/atari/gemtk/dragdrop.c b/atari/gemtk/dragdrop.c
new file mode 100755
index 0000000..d9fd9c7
--- /dev/null
+++ b/atari/gemtk/dragdrop.c
@@ -0,0 +1,516 @@
+/*
+* Routine pour Drag and drop sous MultiTos
+* source: D&D Atari, demo OEP (Alexander Lorenz)
+*
+* Struktur OEP (oep.apid): AES-ID der Applikation
+*
+* (Tab = 4)
+*/
+
+#ifdef __PUREC__
+#include <tos.h>
+#else
+#include <osbind.h>
+#include <mintbind.h>
+#include <signal.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+
+//#include "windom.h"
+#include "gemtk.h"
+#include "cflib.h"
+
+#ifndef EACCDN
+#define EACCDN (-36)
+#endif
+
+#ifndef FA_HIDDEN
+#define FA_HIDDEN 0x02
+#endif
+
+static char pipename[] = "U:\\PIPE\\DRAGDROP.AA";
+static long pipesig;
+
+/*
+* Routinen f�r den Sender
+*/
+
+/*
+* Erzeugt Pipe f�r D&D
+*
+* Eingabeparameter:
+* pipe - Pointer auf 2 Byte Buffer f�r Pipeextension
+*
+* Ausgabeparameters:
+* keine
+*
+* Returnwert:
+* >0: Filehandle der Pipe
+* -1: Fehler beim Erzeugen der Pipe
+*/
+
+short ddcreate(short *pipe)
+{
+ long fd = -1;
+
+ pipename[17] = 'A';
+ pipename[18] = 'A' - 1;
+
+ do /* ouvre un pipe inoccup� */
+ {
+ pipename[18]++;
+ if (pipename[18] > 'Z')
+ {
+ pipename[17]++;
+ if (pipename[17] > 'Z')
+ break;
+ else
+ pipename[18] = 'A';
+ }
+
+ /* FA_HIDDEN f�r Pipe notwendig! */
+
+ fd = Fcreate(pipename, FA_HIDDEN);
+
+ } while (fd == (long) EACCDN);
+
+ if (fd < 0L)
+ return(-1);
+
+ *pipe = (pipename[17] << 8) | pipename[18];
+
+
+ /* Signalhandler konfigurieren */
+
+ ddgetsig(&pipesig);
+
+
+ return((short) fd);
+}
+
+
+
+/*
+* Sendet AP_DRAGDROP an Empf�ngerapplikation
+*
+* Eingabeparameter:
+* apid - AES-ID der Emf�ngerapp.
+* fd - Filehandle der D&D-Pipe
+* winid - Handle des Zielfensters (0 f�r Desktopfenster)
+* mx/my - Maus X und Y Koord.
+* (-1/-1 f�r einen fake Drag&Drop)
+* kstate - Sondertastenstatus
+* pipename - Extension der D&D-Pipe
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwert:
+* >0: kein Fehler
+* -1: Empf�ngerapp. gibt DD_NAK zur�ck
+* -2: Empf�ngerapp. antwortet nicht (Timeout)
+* -3: Fehler bei appl_write()
+*/
+
+short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipeid)
+{
+ char c;
+ short i, msg[8];
+ long fd_mask;
+
+
+ /* AES-Message define and post */
+
+ msg[0] = AP_DRAGDROP;
+ msg[1] = _AESapid;
+ msg[2] = 0;
+ msg[3] = winid;
+ msg[4] = mx;
+ msg[5] = my;
+ msg[6] = kstate;
+ msg[7] = pipeid;
+
+ i = appl_write(apid, 16, msg);
+
+ if (i == 0)
+ {
+ ddclose(fd);
+ return(-3);
+ }
+
+
+ /* receiver reaction */
+
+ fd_mask = (1L << fd);
+ i = Fselect(DD_TIMEOUT, &fd_mask, 0L, 0L);
+ if (!i || !fd_mask)
+ {
+ /* Timeout eingetreten */
+
+ ddclose(fd);
+ return(-2);
+ }
+
+
+ /* le recepteur refuse (lecture du pipe) */
+
+ if (Fread(fd, 1L, &c) != 1L)
+ {
+ ddclose(fd);
+ return(-1);
+ }
+
+ if (c != DD_OK)
+ {
+ ddclose(fd);
+ return(-1);
+ }
+
+ return(1);
+}
+
+
+
+/*
+* Liest die 8 "bevorzugten" Extensionen der Empf�ngerapplikation
+*
+* Eingabeparameter:
+* fd - Filehandle der D&D-Pipe
+*
+* Ausgabeparameters:
+* exts - 32 Bytebuffer f�r die 8 bevorzugten Extensionen
+* der Zielapp.
+*
+* Returnwert:
+* >0: kein Fehler
+* -1: Fehler beim Lesen aus der Pipe
+*/
+
+short ddrexts(short fd, char *exts)
+{
+ if (Fread(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
+ {
+ ddclose(fd);
+ return(-1);
+ }
+
+ return(1);
+}
+
+
+
+/*
+* Testet, ob der Empf�nger einen Datentyp akzeptiert
+*
+* Eingabeparameter:
+* fd - Filehandle (von ddcreate())
+* ext - Zeiger auf Datentyp (4 Bytes zB. "ARGS")
+* text - Zeiger auf Datenbeschreibung (optional, zB. "DESKTOP args")
+* name - Zeiger auf Datendateiname (optional, zB. "SAMPLE.TXT")
+* size - Anzahl Bytes der zu sendenden Daten
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwert:
+* DD_OK - Empf�nger akzeptiert Datentyp
+* DD_NAK - Empf�nger brach Drag&Drop ab
+* DD_EXT - Empf�nger lehnt Datentyp ab
+* DD_LEN - Empf�nger kann Datenmenge nicht verarbeiten
+* DD_TRASH - Drop erfolgte auf M�lleimer
+* DD_PRINTER - Drop erfolgte auf Drucker
+* DD_CLIPBOARD - Drop erfolgte auf Clipboard
+*/
+
+short ddstry(short fd, char *ext, char *text, char *name, long size)
+{
+ char c;
+ short hdrlen, i;
+
+ /* 4 Bytes f�r "ext", 4 Bytes f�r "size",
+ 2 Bytes f�r Stringendnullen */
+
+ hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1);
+
+
+ /* Header senden */
+
+ if (Fwrite(fd, 2L, &hdrlen) != 2L)
+ return(DD_NAK);
+
+ i = (short) Fwrite(fd, 4L, ext);
+ i += (short) Fwrite(fd, 4L, &size);
+ i += (short) Fwrite(fd, strlen(text)+1, text);
+ i += (short) Fwrite(fd, strlen(name)+1, name);
+
+ if (i != hdrlen)
+ return(DD_NAK);
+
+
+ /* auf die Antwort warten */
+
+ if (Fread(fd, 1L, &c) != 1L)
+ return(DD_NAK);
+
+ return(c);
+}
+
+
+
+/* Routinen f�r Sender und Empf�nger */
+
+/*
+* Pipe schlie�en (Drag&Drop beenden/abbrechen)
+*/
+
+void ddclose(short fd)
+{
+ /* Signalhandler restaurieren */
+
+ ddsetsig(pipesig);
+
+
+ Fclose(fd);
+}
+
+
+/*
+* Signalhandler f�r D&D konfigurieren
+*
+* Eingabeparameter:
+* oldsig - Zeiger auf 4 Byte Puffer f�r alten Handlerwert
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwerte:
+* keine
+*/
+
+void ddgetsig(long *oldsig)
+{
+ *oldsig = (long) Psignal(SIGPIPE, (void *) SIG_IGN);
+}
+
+
+/*
+* Signalhandler nach D&D restaurieren
+*
+* Eingabeparameter:
+* oldsig - Alter Handlerwert (von ddgetsig)
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwerte:
+* keine
+*/
+
+void ddsetsig(long oldsig)
+{
+ if (oldsig != -32L)
+ Psignal(SIGPIPE, (void *) oldsig);
+}
+
+
+
+/* Routinen f�r Empf�nger */
+
+/*
+* Drag&Drop Pipe �ffnen
+*
+* Eingabeparameter:
+* ddnam - Extension der Pipe (letztes short von AP_DRAGDROP)
+* ddmsg - DD_OK oder DD_NAK
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwerte:
+* >0 - Filehandle der Drag&Drop pipe
+* -1 - Drag&Drop abgebrochen
+*/
+
+short ddopen(short ddnam, char ddmsg)
+{
+ long fd;
+
+ pipename[17] = (ddnam & 0xff00) >> 8;
+ pipename[18] = ddnam & 0x00ff;
+
+ fd = Fopen(pipename, 2);
+
+ if (fd < 0L)
+ return(-1);
+
+
+ /* Signalhandler konfigurieren */
+
+ ddgetsig(&pipesig);
+
+
+ if (Fwrite((short) fd, 1L, &ddmsg) != 1L)
+ {
+ ddclose((short) fd);
+ return(-1);
+ }
+
+ return((short) fd);
+}
+
+
+
+/*
+* Schreibt die 8 "bevorzugten" Extensionen der Applikation
+*
+* Eingabeparameter:
+* fd - Filehandle der D&D-Pipe
+* exts - Liste aus acht 4 Byte Extensionen die verstanden
+* werden. Diese Liste sollte nach bevorzugten Datentypen
+* sortiert sein. Sollten weniger als DD_NUMEXTS
+* Extensionen unterst�tzt werden, mu� die Liste mit
+* Nullen (0) aufgef�llt werden!
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwert:
+* >0: kein Fehler
+* -1: Fehler beim Schreiben in die Pipe
+*/
+
+short ddsexts(short fd, char *exts)
+{
+ if (Fwrite(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
+ {
+ ddclose(fd);
+ return(-1);
+ }
+
+ return(1);
+}
+
+
+
+/*
+* N�chsten Header vom Sender holen
+*
+* Eingabeparameter:
+* fd - Filehandle der Pipe (von ddopen())
+*
+* Ausgabeparameters:
+* name - Zeiger auf Buffer f�r Datenbeschreibung (min. DD_NAMEMAX!)
+* file - Zeiger auf Buffer f�r Datendateiname (min. DD_NAMEMAX!)
+* whichext- Zeiger auf Buffer f�r Extension (4 Bytes)
+* size - Zeiger auf Buffer f�r Datengr��e (4 Bytes)
+*
+* Returnwert:
+* >0: kein Fehler
+* -1: Sender brach Drag&Drop ab
+*
+* On lit dans le pipe qui normalement est constitu� de:
+* 1 short: taille du header
+* 4 CHAR: type de donn�e (extension)
+* 1 long: taille des donn�es
+* STRING: description des donn�es
+* STRING: nom du fichiers
+* soit au minimun 11 octets (cas ou les string sont r�duites � \0)
+* les string sont limit� a 128 octets
+*/
+
+short ddrtry(short fd, char *name, char *file, char *whichext, long *size)
+{
+ char buf[DD_NAMEMAX * 2];
+ short hdrlen, i, len;
+
+ if (Fread(fd, 2L, &hdrlen) != 2L)
+ return(-1);
+
+
+ if (hdrlen < 9) /* il reste au minimum 11 - 2 = 9 octets a lire */
+ {
+ /* sollte eigentlich nie passieren */
+
+ return(-1); /* erreur taille incorrecte */
+ }
+
+ if (Fread(fd, 4L, whichext) != 4L) /* lecture de l'extension */
+ return(-1);
+
+ if (Fread(fd, 4L, size) != 4L) /* lecture de la longueurs des donn�es */
+ return(-1);
+
+ hdrlen -= 8; /* on a lu 8 octets */
+
+ if (hdrlen > DD_NAMEMAX*2)
+ i = DD_NAMEMAX*2;
+ else
+ i = hdrlen;
+
+ len = i;
+
+ if (Fread(fd, (long) i, buf) != (long) i)
+ return(-1);
+
+ hdrlen -= i;
+
+ strncpy(name, buf, DD_NAMEMAX);
+
+ i = (short) strlen(name) + 1;
+
+ if (len - i > 0)
+ strncpy(file, buf + i, DD_NAMEMAX);
+ else
+ file[0] = '\0';
+
+
+ /* weitere Bytes im Header in den M�ll */
+
+ while (hdrlen > DD_NAMEMAX*2)
+ {
+ if (Fread(fd, DD_NAMEMAX*2, buf) != DD_NAMEMAX*2)
+ return(-1);
+
+ hdrlen -= DD_NAMEMAX*2;
+ }
+
+ if (hdrlen > 0)
+ {
+ if (Fread(fd, (long) hdrlen, buf) != (long) hdrlen)
+ return(-1);
+ }
+
+ return(1);
+}
+
+
+
+/*
+* Sendet der Senderapplikation eine 1 Byte Antwort
+*
+* Eingabeparameter:
+* fd - Filehandle der Pipe (von ddopen())
+* ack - Byte das gesendet werden soll (zB. DD_OK)
+*
+* Ausgabeparameter:
+* keine
+*
+* Returnwert:
+* >0: kein Fehler
+* -1: Fehler (die Pipe wird automatisch geschlossen!)
+*/
+
+short ddreply(short fd, char ack)
+{
+ if (Fwrite(fd, 1L, &ack) != 1L)
+ {
+ ddclose(fd);
+ return(-1);
+ }
+
+ return(1);
+}
+
+
diff --git a/atari/gemtk/dragdrop.h b/atari/gemtk/dragdrop.h
new file mode 100755
index 0000000..3846613
--- /dev/null
+++ b/atari/gemtk/dragdrop.h
@@ -0,0 +1,4 @@
+#ifndef DD_H_INCLUDED
+#define DD_H_INCLUDED
+
+#endif
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
new file mode 100644
index 0000000..fe59209
--- /dev/null
+++ b/atari/gemtk/gemtk.h
@@ -0,0 +1,100 @@
+#ifndef GEMTK_H_INCLUDED
+#define GEMTK_H_INCLUDED
+
+#include <gem.h>
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+#include <stdint.h>
+
+/* System type detection added by [GS] */
+/* detect the system type, AES + kernel */
+#define SYS_TOS 0x0001
+#define SYS_MAGIC 0x0002
+#define SYS_MINT 0x0004
+#define SYS_GENEVA 0x0010
+#define SYS_NAES 0x0020
+#define SYS_XAAES 0x0040
+#define sys_type() (_systype_v ? _systype_v : _systype())
+#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
+#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
+#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
+
+#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
+
+extern unsigned short _systype_v;
+
+/*
+ Utils
+*/
+unsigned short _systype (void);
+OBJECT *get_tree( int idx );
+
+/*
+* MultiTOS Drag&Drop
+*/
+short ddcreate(short *pipe);
+short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
+short ddrexts(short fd, char *exts);
+short ddstry(short fd, char *ext, char *text, char *name, long size);
+void ddclose(short fd);
+void ddgetsig(long *oldsig);
+void ddsetsig(long oldsig);
+short ddopen(short ddnam, char ddmsg);
+short ddsexts(short fd, char *exts);
+short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
+short ddreply(short fd, char ack);
+
+/*
+ Message box
+*/
+#define MSG_BOX_ALERT 1
+#define MSG_BOX_CONFIRM 2
+
+short msg_box_show(short type, const char * msg);
+
+/*
+ Guiwin
+*/
+#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
+#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
+#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+
+#define GW_STATUS_ICONIFIED 0x01
+#define GW_STATUS_SHADED 0x02
+
+struct gui_window_s;
+typedef struct gui_window_s GUIWIN;
+
+typedef short (*guiwin_event_handler_f)(GUIWIN *gw,
+ EVMULT_OUT *ev_out, short msg[8]);
+enum guwin_area_e {
+ GUIWIN_AREA_WORK = 0,
+ GUIWIN_AREA_TOOLBAR,
+ GUIWIN_AREA_CONTENT
+};
+
+GUIWIN * guiwin_add(short handle, uint32_t flags,
+ guiwin_event_handler_f handler);
+GUIWIN *guiwin_find(short handle);
+short guiwin_remove(GUIWIN *win);
+GUIWIN *guiwin_validate_ptr(GUIWIN *win);
+//short guiwin_set_event_handler(guiwin_event_handler_f);
+short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out,
+ short msg[8]);
+void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest);
+short guiwin_get_handle(GUIWIN *win);
+uint32_t guiwin_get_state(GUIWIN *win);
+void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
+ uint32_t flags);
+
+/*
+* AES Scroller Object
+*/
+
+#ifndef POINT_WITHIN
+#define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \
+ && (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
+#endif
+
+
+#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
new file mode 100644
index 0000000..6d525c6
--- /dev/null
+++ b/atari/gemtk/guiwin.c
@@ -0,0 +1,301 @@
+//#include "global.h"
+
+#include <stdint.h>
+#include <assert.h>
+#include <cflib.h>
+
+#include <mt_gem.h>
+#include "gemtk.h"
+
+//#define DEBUG_PRINT(x) printf x
+#define DEBUG_PRINT(x)
+
+struct gui_window_s {
+ short handle;
+ guiwin_event_handler_f handler_func;
+ uint32_t flags;
+ uint32_t state;
+ OBJECT * toolbar;
+ short toolbar_idx;
+ struct gui_window_s *next, *prev;
+};
+
+static GUIWIN * winlist;
+
+static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
+{
+ GRECT g, tb_area, tb_area_ro;
+ short retval = 1;
+
+ switch(msg[0]) {
+
+ case WM_TOPPED:
+ wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
+ break;
+
+ case WM_MOVED:
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h);
+ break;
+
+ case WM_SIZED:
+ case WM_REPOSED:
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ break;
+
+ case WM_FULLED:
+ wind_get_grect(0, WF_WORKXYWH, &g);
+ wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ break;
+
+ case WM_ICONIFY:
+ wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state |= GW_STATUS_ICONIFIED;
+ break;
+
+ case WM_UNICONIFY:
+ wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state &= ~(GW_STATUS_ICONIFIED);
+ break;
+
+ case WM_SHADED:
+ gw->state |= GW_STATUS_SHADED;
+ break;
+
+ case WM_UNSHADED:
+ gw->state &= ~(GW_STATUS_SHADED);
+ break;
+
+ case WM_REDRAW:
+ guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
+ tb_area = tb_area_ro;
+ if(rc_intersect((GRECT*)&msg[4], &tb_area)){
+ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+ wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
+ }
+ }
+ break;
+
+ default:
+ retval = 0;
+ break;
+ }
+ return(retval);
+}
+
+short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
+{
+ GUIWIN *dest;
+ short retval = 0;
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0]));
+ switch (msg[0]) {
+ case WM_REDRAW:
+ case WM_CLOSED:
+ case WM_TOPPED:
+ case WM_ARROWED:
+ case WM_HSLID:
+ case WM_VSLID:
+ case WM_FULLED:
+ case WM_SIZED:
+ case WM_REPOSED:
+ case WM_MOVED:
+ case WM_NEWTOP:
+ case WM_UNTOPPED:
+ case WM_ONTOP:
+ case WM_BOTTOM:
+ case WM_ICONIFY:
+ case WM_UNICONIFY:
+ case WM_ALLICONIFY:
+ case WM_TOOLBAR:
+ case AP_DRAGDROP:
+ case AP_TERM:
+ case AP_TFAIL:
+ dest = guiwin_find(msg[3]);
+ if (dest) {
+ DEBUG_PRINT(("Found WM_ dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ if (dest->flags&GW_FLAG_PREPROC_WM) {
+ retval = preproc_wm(dest, ev_out, msg);
+ if(((retval == 0)||(dest->flags&GW_FLAG_RECV_PREPROC_WM))) {
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ }
+ else {
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ }
+
+ }
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0){
+ short info[4];
+
+ wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
+ if(info[0] != 0 && info[1] == gl_apid){
+ dest = guiwin_find(info[0]);
+ if (dest) {
+ DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ if(dest->toolbar != NULL && dest->handler_func != NULL){
+ GRECT tb_area;
+ guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, tb_area)) {
+ // send WM_TOOLBAR message
+ short obj_idx = 0;
+ short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
+ obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
+ short oldevents = ev_out->emo_events;
+ ev_out->emo_events = MU_MESAG;
+ dest->handler_func(dest, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ }
+ }
+ /*
+ if (dest->flags&GW_FLAG_PREPROC_WM) {
+ preproc_wm(dest, ev_in, ev_out, msg);
+ }
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_in, ev_out, msg);
+ }
+ */
+ }
+ }
+ }
+ return(retval);
+}
+
+GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
+{
+ GUIWIN *win = malloc(sizeof(GUIWIN));
+
+ assert(win!=NULL);
+ DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
+
+ win->handle = handle;
+ win->handler_func = cb;
+ win->flags = flags;
+ if (winlist == NULL) {
+ winlist = win;
+ win->next = NULL;
+ win->prev = NULL;
+ } else {
+ GUIWIN *tmp = winlist;
+ while( tmp->next != NULL ) {
+ tmp = tmp->next;
+ }
+ tmp->next = win;
+ win->prev = tmp;
+ win->next = NULL;
+ }
+ return(win);
+}
+
+GUIWIN *guiwin_find(short handle)
+{
+ GUIWIN *g;
+ DEBUG_PRINT(("guiwin_find: handle: %d\n", handle));
+ for( g = winlist; g != NULL; g=g->next ) {
+ DEBUG_PRINT(("guiwin search: %d\n", g->handle));
+ if(g->handle == handle) {
+ DEBUG_PRINT(("guiwin_find: %p\n", g));
+ return(g);
+ }
+ }
+ return(NULL);
+}
+
+GUIWIN *guiwin_validate_ptr(GUIWIN *win)
+{
+ GUIWIN *g;
+ for( g = winlist; g != NULL; g=g->next ) {
+ DEBUG_PRINT(("guiwin guiwin_validate_ptr check: %p\n", g));
+ if(g == win) {
+ DEBUG_PRINT(("guiwin_validate_ptr valid: %p\n", g));
+ return(g);
+ }
+ }
+ return(NULL);
+}
+
+short guiwin_remove(GUIWIN *win)
+{
+ win = guiwin_validate_ptr(win);
+ if (win == NULL)
+ return(-1);
+
+ /* unlink the window: */
+ if(win->prev != NULL ) {
+ win->prev->next = win->next;
+ } else {
+ winlist = win->next;
+ }
+ if (win->next != NULL) {
+ win->next->prev = win->prev;
+ }
+
+ free(win);
+ return(0);
+}
+
+void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
+{
+ wind_get_grect(win->handle, WF_WORKXYWH, dest);
+ if (mode == GUIWIN_AREA_CONTENT) {
+ GRECT tb_area;
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_x += tb_area.g_w;
+ dest->g_w -= tb_area.g_w;
+ } else {
+ dest->g_y += tb_area.g_h;
+ dest->g_w -= tb_area.g_h;
+ }
+ dbg_grect("guiwin_get_grect content", dest);
+ }
+ else if (mode == GUIWIN_AREA_TOOLBAR) {
+ if (win->toolbar != NULL) {
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
+ } else {
+ dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
+ }
+ } else {
+ dest->g_h = 0;
+ dest->g_w = 0;
+ }
+ dbg_grect("guiwin_get_grect toolbar", dest);
+ }
+}
+
+short guiwin_get_handle(GUIWIN *win)
+{
+ return(win->handle);
+}
+
+uint32_t guiwin_get_state(GUIWIN *win)
+{
+ return(win->state);
+}
+
+void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags)
+{
+ win->toolbar = toolbar;
+ win->toolbar_idx = idx;
+ if(flags & GW_FLAG_HAS_VTOOLBAR){
+ win->flags |= GW_FLAG_HAS_VTOOLBAR;
+ }
+}
+
+
+
diff --git a/atari/gemtk/guiwin.h b/atari/gemtk/guiwin.h
new file mode 100644
index 0000000..dba112c
--- /dev/null
+++ b/atari/gemtk/guiwin.h
@@ -0,0 +1,5 @@
+#ifndef OPKG_GUI_GUIWIN_H
+#define OPKG_GUI_GUIWIN_H
+
+
+#endif /* OPKG_GUIWIN_H */
diff --git a/atari/gemtk/msgbox.c b/atari/gemtk/msgbox.c
new file mode 100644
index 0000000..770e0af
--- /dev/null
+++ b/atari/gemtk/msgbox.c
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gem.h>
+#include "gemtk.h"
+
+#ifndef min
+# define min(x,y) ((x<y) ? x : y )
+#endif
+
+short msg_box_show(short type, const char * msg)
+{
+ #define MSG_BOX_STR_SIZE 256
+ short retval=0, i=0, z=0, l=0;
+ char c;
+ int len_msg = strlen(msg);
+
+ // TODO: localize strings
+ const char *str_yes = "Yes";
+ const char *str_no = "No";
+ const char *str_ok = "OK";
+ char msg_box_str[MSG_BOX_STR_SIZE];
+ char *dst = msg_box_str;
+
+ memset(msg_box_str, 0, MSG_BOX_STR_SIZE);
+
+ strncat(msg_box_str, "[1]", MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, "[", MSG_BOX_STR_SIZE);
+
+ dst = msg_box_str + strlen(msg_box_str);
+
+ for (i=0; i<min(len_msg,40*5); i++) {
+
+ c = msg[i];
+
+ if(c==0)
+ break;
+
+ if (z==40) {
+ if(l==4){
+ break;
+ }
+ z = 0;
+ l++;
+ *dst = (char)'|';
+ dst++;
+ }
+
+ if ((c=='\r' || c=='\n') && *dst != '|') {
+ if(l==4){
+ break;
+ }
+ z = 0;
+ l++;
+ *dst = '|';
+ dst++;
+ }
+ else {
+ z++;
+ *dst = c;
+ dst++;
+ }
+ }
+ strncat(msg_box_str, "][", MSG_BOX_STR_SIZE);
+
+ if(type == MSG_BOX_CONFIRM){
+ strncat(msg_box_str, str_yes, MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, "|", MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, str_no, MSG_BOX_STR_SIZE);
+ } else {
+ strncat(msg_box_str, str_ok, MSG_BOX_STR_SIZE);
+ }
+ strncat(msg_box_str, "]", MSG_BOX_STR_SIZE);
+
+ retval = form_alert(type, msg_box_str);
+ if(type == MSG_BOX_CONFIRM){
+ if(retval != 1){
+ retval = 0;
+ }
+ }
+ return(retval);
+
+ #undef MSG_BOX_STR_SIZE
+}
diff --git a/atari/gemtk/msgbox.h b/atari/gemtk/msgbox.h
new file mode 100644
index 0000000..7a46900
--- /dev/null
+++ b/atari/gemtk/msgbox.h
@@ -0,0 +1,5 @@
+#ifndef GUIMSG_H_INCLUDED
+#define GUIMSG_H_INCLUDED
+
+
+#endif // GUIMSG_H_INCLUDED
diff --git a/atari/gemtk/utils.c b/atari/gemtk/utils.c
new file mode 100644
index 0000000..4a24d82
--- /dev/null
+++ b/atari/gemtk/utils.c
@@ -0,0 +1,45 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include <gem.h>
+#include "gemtk.h"
+
+/* -------------------------------------------------------------------------- */
+/* GEM Utillity functions: */
+/* -------------------------------------------------------------------------- */
+
+unsigned short _systype_v;
+unsigned short _systype (void)
+{
+ int32_t * cptr = NULL;
+ _systype_v = SYS_TOS;
+
+ cptr = (int32_t *)Setexc(0x0168, -1L);
+ if (cptr == NULL ) {
+ return _systype_v; /* stone old TOS without any cookie support */
+ }
+ while (*cptr) {
+ if (*cptr == C_MgMc || *cptr == C_MgMx ) {
+ _systype_v = (_systype_v & ~0xF) | SYS_MAGIC;
+ } else if (*cptr == C_MiNT ) {
+ _systype_v = (_systype_v & ~0xF) | SYS_MINT;
+ } else if (*cptr == C_Gnva /* Gnva */ ) {
+ _systype_v |= SYS_GENEVA;
+ } else if (*cptr == C_nAES /* nAES */ ) {
+ _systype_v |= SYS_NAES;
+ }
+ cptr += 2;
+ }
+ if (_systype_v & SYS_MINT) { /* check for XaAES */
+ short out = 0, u;
+ if (wind_get (0, (((short)'X') <<8)|'A', &out, &u,&u,&u) && out) {
+ _systype_v |= SYS_XAAES;
+ }
+ }
+ return _systype_v;
+}
+
+OBJECT *get_tree( int idx) {
+ OBJECT *tree;
+ rsrc_gaddr(R_TREE, idx, &tree);
+ return tree;
+}
diff --git a/atari/gemtk/utils.h b/atari/gemtk/utils.h
new file mode 100644
index 0000000..7ebbcf2
--- /dev/null
+++ b/atari/gemtk/utils.h
@@ -0,0 +1,5 @@
+#ifndef UTILS_H_INCLUDED
+#define UTILS_H_INCLUDED
+
+
+#endif // UTILS_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 3b15af8..40b8859 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,379 +26,31 @@
#include <windom.h>
#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "atari/misc.h"
#include "atari/gui.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
-#include "atari/findfile.h"
-#include "atari/settings.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
-extern bool html_redraw_debug;
-
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-extern char options[PATH_MAX];
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
-}
-
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window ) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
+void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
{
int i = 0;
LOG((""));
@@ -406,7 +58,7 @@ void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
}
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
+static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -416,23 +68,23 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if( gw == NULL)
+ if (gw == NULL)
return;
- if( prev_x == evnt.mx && prev_y == evnt.my ){
+ if (prev_x == evnt.mx && prev_y == evnt.my) {
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ if (input_window->root->handle->handle == ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -442,7 +94,7 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
);
}
- if( gw->root->toolbar && within == false ) {
+ if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -466,7 +118,6 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -500,178 +151,23 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
- }
- }
- i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
-
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
}
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
-
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
}
void unbind_global_events( void )
{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
+
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1e13264..76e73fc 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,6 +18,8 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
+
+#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -32,31 +34,14 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
+struct s_evnt_data evnt_data;
/*
- Global & Menu event handlers
+ Global event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
-void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index c2158e0..4f7a97b 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1,1041 +1,1143 @@
-/*
- * Copyright 2010 <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- /*
- This File provides all the mandatory functions prefixed with gui_
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <time.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <windom.h>
-#include <hubbub/hubbub.h>
-
-#include "content/urldb.h"
-#include "content/fetch.h"
-#include "content/fetchers/resource.h"
-#include "css/utils.h"
-#include "desktop/gui.h"
-#include "desktop/history_core.h"
-#include "desktop/plotters.h"
-#include "desktop/netsurf.h"
-#include "desktop/401login.h"
-
-#include "desktop/options.h"
-#include "desktop/save_complete.h"
-#include "desktop/selection.h"
-#include "desktop/textinput.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "render/font.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
-#include "atari/gui.h"
-#include "atari/misc.h"
-#include "atari/findfile.h"
-#include "atari/schedule.h"
-#include "atari/browser_win.h"
-#include "atari/browser.h"
-#include "atari/statusbar.h"
-#include "atari/toolbar.h"
-#include "atari/verify_ssl.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/login.h"
-#include "atari/global_evnt.h"
-#include "atari/encoding.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/plot/plot.h"
-#include "atari/clipboard.h"
-#include "atari/osspec.h"
-#include "atari/search.h"
-#include "cflib.h"
-
-#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
-
-char *tmp_clipboard;
-struct gui_window *input_window = NULL;
-struct gui_window *window_list = NULL;
-void * h_gem_rsrc;
-OBJECT * h_gem_menu;
-OBJECT **rsc_trindex;
-short rsc_ntree;
-long next_poll;
-bool rendering = false;
-
-
-/* Comandline / Options: */
-int option_window_width;
-int option_window_height;
-int option_window_x;
-int option_window_y;
-
-/* Defaults to option_homepage_url, commandline options overwrites that value */
-const char * option_homepage_url;
-
-/* path to choices file: */
-char options[PATH_MAX];
-
-
-void gui_poll(bool active)
-{
- short winloc[4];
- // int timeout; /* timeout in milliseconds */
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
- short mx, my, dummy;
-
- evnt.timer = schedule_run();
-
- if( active || rendering ) {
- if( clock() >= next_poll ) {
- evnt.timer = 0;
- flags |= MU_TIMER;
- EvntWindom( flags );
- next_poll = clock() + (CLOCKS_PER_SEC>>3);
- }
- } else {
- if (input_window != NULL) {
- wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
- if (winloc[1] == _AESapid) {
- /* only check for mouse move when netsurf is on top: */
- // move that into m1 event handler
- graf_mkstate( &mx, &my, &dummy, &dummy );
- flags |= MU_M1;
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = evnt.m1_h = 1;
- evnt.m1_x = mx;
- evnt.m1_y = my;
- }
- }
- flags |= MU_TIMER;
- EvntWindom( flags );
- }
-
- struct gui_window * g;
- for( g = window_list; g != NULL; g=g->next ) {
- if( browser_redraw_required( g ) ){
- browser_redraw( g );
- }
- if( g->root->toolbar ){
- if(g->root->toolbar->url.redraw ){
- tb_url_redraw( g );
- }
- }
- }
- if( evnt.timer != 0 && !active ){
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
-}
-
-struct gui_window *
-gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
-{
- struct gui_window *gw=NULL;
- LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
- (int)new_tab
- ));
-
- gw = malloc( sizeof(struct gui_window) );
- if (gw == NULL)
- return NULL;
- memset( gw, 0, sizeof(struct gui_window) );
-
- LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
- if( gw->root->handle ) {
- GRECT pos = {
- option_window_x, option_window_y,
- option_window_width, option_window_height
- };
- window_open( gw , pos );
- /* Recalculate windows browser area now */
- browser_update_rects( gw );
- tb_update_buttons( gw, -1 );
- input_window = gw;
- /* TODO:... this line: placeholder to create a local history widget ... */
- }
-
- /* add the window to the window list: */
- if( window_list == NULL ) {
- window_list = gw;
- gw->next = NULL;
- gw->prev = NULL;
- } else {
- struct gui_window * tmp = window_list;
- while( tmp->next != NULL ) {
- tmp = tmp->next;
- }
- tmp->next = gw;
- gw->prev = tmp;
- gw->next = NULL;
- }
-
- return( gw );
-
-}
-
-void gui_window_destroy(struct gui_window *w)
+/*
+ * Copyright 2010 <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ This File provides all the mandatory functions prefixed with gui_
+*/
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <windom.h>
+#include <hubbub/hubbub.h>
+
+#include "content/urldb.h"
+#include "content/fetch.h"
+#include "content/fetchers/resource.h"
+#include "css/utils.h"
+#include "desktop/gui.h"
+#include "desktop/history_core.h"
+#include "desktop/plotters.h"
+#include "desktop/netsurf.h"
+#include "desktop/401login.h"
+
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+#include "desktop/selection.h"
+#include "desktop/textinput.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "render/font.h"
+#include "utils/schedule.h"
+#include "utils/url.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+#include "atari/gemtk/gemtk.h"
+#include "atari/gui.h"
+#include "atari/misc.h"
+#include "atari/findfile.h"
+#include "atari/schedule.h"
+#include "atari/rootwin.h"
+#include "atari/browser.h"
+#include "atari/statusbar.h"
+#include "atari/toolbar.h"
+#include "atari/verify_ssl.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/login.h"
+#include "atari/global_evnt.h"
+#include "atari/encoding.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/plot/plot.h"
+#include "atari/clipboard.h"
+#include "atari/osspec.h"
+#include "atari/search.h"
+#include "atari/deskmenu.h"
+#include "cflib.h"
+
+#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
+
+char *tmp_clipboard;
+struct gui_window *input_window = NULL;
+struct gui_window *window_list = NULL;
+void * h_gem_rsrc;
+long next_poll;
+bool rendering = false;
+
+
+/* Comandline / Options: */
+int option_window_width;
+int option_window_height;
+int option_window_x;
+int option_window_y;
+
+/* Defaults to option_homepage_url, commandline options overwrites that value */
+const char * option_homepage_url;
+
+/* path to choices file: */
+char options[PATH_MAX];
+
+EVMULT_IN aes_event_in = {
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+};
+EVMULT_OUT aes_event_out;
+short aes_msg_out[8];
+
+
+void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- if (w == NULL)
+ long kstate = 0;
+ long kcode = 0;
+ unsigned short nkc = 0;
+ unsigned short nks = 0;
+
+ int i=0;
+ bool done = false;
+ struct gui_window * gw = input_window;
+ struct gui_window * gw_tmp;
+ if( gw == NULL )
return;
-
- LOG(("%s\n", __FUNCTION__ ));
-
- input_window = NULL;
-
- window_destroy( w );
-
- /* unlink the window: */
- if(w->prev != NULL ) {
- w->prev->next = w->next;
- } else {
- window_list = w->next;
- }
- if( w->next != NULL ) {
- w->next->prev = w->prev;
- }
- free(w);
- w = NULL;
-
- w = window_list;
- while( w != NULL ) {
- if( w->root ) {
- input_window = w;
- break;
- }
- w = w->next;
- }
-}
-
-void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
- bool scaled)
-{
- if (w == NULL)
- return;
- LGRECT rect;
- browser_get_rect( w, BR_CONTENT, &rect );
- *width = rect.g_w;
- *height = rect.g_h;
-}
-
-void gui_window_set_title(struct gui_window *gw, const char *title)
-{
- int l;
- char * conv;
-
- if (gw == NULL)
- return;
- if( gw->root ){
- l = strlen(title);
- if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ){
- strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
- free( conv );
- } else {
- strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
- }
- gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
- WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
- }
-}
-
-/**
- * set the status bar message
- */
-void gui_window_set_status(struct gui_window *w, const char *text)
-{
- if (w == NULL || text == NULL )
- return;
- window_set_stauts( w , (char*)text );
-}
-
-void gui_window_redraw_window(struct gui_window *gw)
-{
- CMP_BROWSER b;
- LGRECT rect;
- if (gw == NULL)
- return;
- b = gw->browser;
- browser_get_rect( gw, BR_CONTENT, &rect );
- browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
-}
-
-void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
-{
- CMP_BROWSER b;
- if (gw == NULL)
- return;
- b = gw->browser;
- int x0 = rect->x0 - b->scroll.current.x;
- int y0 = rect->y0 - b->scroll.current.y;
- int w,h;
- w = rect->x1 - rect->x0;
- h = rect->y1 - rect->y0;
- browser_schedule_redraw_rect( gw, x0, y0, w, h );
-}
-
-bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
-{
- if (w == NULL)
- return false;
- *sx = w->browser->scroll.current.x;
- *sy = w->browser->scroll.current.y;
- return( true );
-}
-
-void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
-{
- if ((w == NULL) ||
- (w->browser->bw == NULL) ||
- (w->browser->bw->current_content == NULL))
- return;
- if( sx != 0 ) {
- if( sx < 0 ) {
- browser_scroll(w, WA_LFLINE, abs(sx), true );
- } else {
- browser_scroll(w, WA_RTLINE, abs(sx), true );
- }
- }
-
- if( sy != 0 ) {
- if( sy < 0) {
- browser_scroll(w, WA_UPLINE, abs(sy), true );
- } else {
- browser_scroll(w, WA_DNLINE, abs(sy), true );
- }
- }
- return;
-
-}
-
-void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
-{
- LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
- gui_window_set_scroll(w,x0,y0);
- browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
-}
-
-
-/* It seems this method is called when content size got adjusted,
- so that we can adjust scroll info. We also have to call it when tab
- change occurs.
-*/
-void gui_window_update_extent(struct gui_window *gw)
-{
- int oldx, oldy;
- oldx = gw->browser->scroll.current.x;
- oldy = gw->browser->scroll.current.y;
- if( gw->browser->bw->current_content != NULL ) {
- browser_set_content_size( gw,
- content_get_width(gw->browser->bw->current_content),
- content_get_height(gw->browser->bw->current_content)
- );
- }
-}
-
-
-void gui_clear_selection(struct gui_window *g)
-{
-
-}
-
-
-
-/**
- * set the pointer shape
- */
-void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
-{
- if (w == NULL)
- return;
- switch (shape) {
- case GUI_POINTER_POINT: /* link */
- gem_set_cursor(&gem_cursors.hand);
- break;
-
- case GUI_POINTER_MENU:
- gem_set_cursor(&gem_cursors.menu);
- break;
-
- case GUI_POINTER_CARET: /* input */
- gem_set_cursor(&gem_cursors.ibeam);
- break;
-
- case GUI_POINTER_CROSS:
- gem_set_cursor(&gem_cursors.cross);
- break;
-
- case GUI_POINTER_MOVE:
- gem_set_cursor(&gem_cursors.sizeall);
- break;
-
- case GUI_POINTER_RIGHT:
- case GUI_POINTER_LEFT:
- gem_set_cursor(&gem_cursors.sizewe);
- break;
-
- case GUI_POINTER_UP:
- case GUI_POINTER_DOWN:
- gem_set_cursor(&gem_cursors.sizens);
- break;
-
- case GUI_POINTER_RU:
- case GUI_POINTER_LD:
- gem_set_cursor(&gem_cursors.sizenesw);
- break;
-
- case GUI_POINTER_RD:
- case GUI_POINTER_LU:
- gem_set_cursor(&gem_cursors.sizenwse);
- break;
-
- case GUI_POINTER_WAIT:
- gem_set_cursor(&gem_cursors.wait);
- break;
-
- case GUI_POINTER_PROGRESS:
- gem_set_cursor(&gem_cursors.appstarting);
- break;
-
- case GUI_POINTER_NO_DROP:
- gem_set_cursor(&gem_cursors.nodrop);
- break;
-
- case GUI_POINTER_NOT_ALLOWED:
- gem_set_cursor(&gem_cursors.deny);
- break;
-
- case GUI_POINTER_HELP:
- gem_set_cursor(&gem_cursors.help);
- break;
-
- default:
- gem_set_cursor(&gem_cursors.arrow);
- break;
- }
-}
-
-void gui_window_hide_pointer(struct gui_window *w)
-{
- TODO();
-}
-
-
-void gui_window_set_url(struct gui_window *w, const char *url)
-{
- if (w == NULL)
- return;
- tb_url_set(w, (char*)url );
-}
-
-static void throbber_advance( void * data )
-{
- LGRECT work;
- struct gui_window * gw = (struct gui_window *)data;
- if( gw->root == NULL )
- return;
- if( gw->root->toolbar == NULL )
- return;
- if( gw->root->toolbar->throbber.running == false )
- return;
- mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- gw->root->toolbar->throbber.index++;
- if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
- gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
- schedule(100, throbber_advance, gw );
-}
-
-void gui_window_start_throbber(struct gui_window *w)
-{
- LGRECT work;
- if (w == NULL)
- return;
- if( w->root->toolbar->throbber.running == true )
- return;
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = true;
- w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- schedule(100, throbber_advance, w );
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-
- rendering = true;
-}
-
-void gui_window_stop_throbber(struct gui_window *w)
-{
- LGRECT work;
- if (w == NULL)
- return;
- if( w->root->toolbar->throbber.running == false )
- return;
-
- schedule_remove(throbber_advance, w);
-
- /* refresh toolbar buttons: */
- tb_update_buttons( w, -1 );
-
- /* redraw throbber: */
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = false;
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-
- rendering = false;
-}
-
-/* Place caret in window */
-void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
-{
- if (w == NULL)
- return;
- if( w->browser->caret.current.g_w > 0 )
- gui_window_remove_caret( w );
- w->browser->caret.requested.g_x = x;
- w->browser->caret.requested.g_y = y;
- w->browser->caret.requested.g_w = 1;
- w->browser->caret.requested.g_h = height;
- w->browser->caret.redraw = true;
- return;
-}
-
-
-/**
- * clear window caret
- */
-void
-gui_window_remove_caret(struct gui_window *w)
-{
- if (w == NULL)
- return;
-
- if( w->browser->caret.background.fd_addr != NULL ){
- browser_restore_caret_background( w, NULL );
- w->browser->caret.requested.g_w = 0;
- w->browser->caret.current.g_w = 0;
- }
- return;
-}
-
-void
-gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
-{
- struct bitmap *bmp_icon;
-
- bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
-
- window_set_icon(g, bmp_icon);
-}
-
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
- TODO();
-}
-
-void gui_window_new_content(struct gui_window *w)
-{
- w->browser->scroll.current.x = 0;
- w->browser->scroll.current.y = 0;
- w->browser->scroll.requested.x = 0;
- w->browser->scroll.requested.y = 0;
- w->browser->scroll.required = true;
- gui_window_redraw_window( w );
-}
-
-bool gui_window_scroll_start(struct gui_window *w)
-{
- TODO();
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- TODO();
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- LOG(("%s -> %s", title, url ));
- TODO();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_drag_save_selection(struct selection *s, struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_start_selection(struct gui_window *w)
-{
- gui_empty_clipboard();
-}
-
-void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
-{
- char * clip = scrap_txt_read( &app );
- if( clip == NULL )
- return;
- int clip_length = strlen( clip );
- if (clip_length > 0) {
- char *utf8;
- utf8_convert_ret ret;
- /* Clipboard is in local encoding so
- * convert to UTF8 */
- ret = utf8_from_local_encoding(clip,
- clip_length, &utf8);
- if (ret == UTF8_CONVERT_OK) {
- browser_window_paste_text(w->browser->bw, utf8,
- strlen(utf8), true);
- free(utf8);
- }
- free( clip );
- }
-}
-
-bool gui_empty_clipboard(void)
-{
- if( tmp_clipboard != NULL ){
- free( tmp_clipboard );
- tmp_clipboard = NULL;
- }
- return true;
-}
-
-bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space,
- const plot_font_style_t *fstyle)
-{
- LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
- char * oldptr = tmp_clipboard;
- size_t oldlen = 0;
- size_t newlen = 0;
- char * text = NULL;
- char * text2 = NULL;
- bool retval;
- int length = 0;
- if( length_utf8 > 0 && text_utf8 != NULL ) {
- utf8_to_local_encoding(text_utf8,length_utf8,&text);
- if( text == NULL ) {
- LOG(("Conversion failed (%s)", text_utf8));
- goto error;
- } else {
- text2 = text;
- }
- } else {
- if( space == false ) {
- goto success;
- }
- text = malloc(length + 2);
- if( text == NULL ) {
- goto error;
- }
- text2 = text;
- text[length+1] = 0;
- memset(text, ' ', length+1);
- }
- length = strlen(text);
- if( tmp_clipboard != NULL ) {
- oldlen = strlen( tmp_clipboard );
- }
- newlen = oldlen + length + 1;
- if( tmp_clipboard == NULL){
- tmp_clipboard = malloc(newlen);
- if( tmp_clipboard == NULL ) {
- goto error;
- }
- strncpy(tmp_clipboard, text, newlen);
- } else {
- tmp_clipboard = realloc( tmp_clipboard, newlen);
- if( tmp_clipboard == NULL ) {
- goto error;
- }
- strncpy(tmp_clipboard, oldptr, newlen);
- strncat(tmp_clipboard, text, newlen-oldlen);
- }
- goto success;
-
-error:
- retval = false;
- goto fin;
-
-success:
- retval = true;
-
-fin:
- if( text2 != NULL )
- free( text2 );
- return(retval);
-
-}
-
-bool gui_commit_clipboard(void)
-{
- int r = scrap_txt_write(&app, tmp_clipboard);
- return( (r>0)?true:false );
-}
-
-bool gui_copy_to_clipboard(struct selection *s)
-{
- bool ret = false;
- if( s->defined ) {
- gui_empty_clipboard();
- if(selection_copy_to_clipboard(s)){
- ret = gui_commit_clipboard();
- }
- }
- gui_empty_clipboard();
- return ret;
-}
-
-
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- TODO();
-}
-
-/**
- * Broadcast an URL that we can't handle.
- */
-void gui_launch_url(const char *url)
-{
- TODO();
- LOG(("launch file: %s\n", url));
-}
-
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- bool bres;
- char * out = NULL;
- bres = login_form_do( url, (char*)realm, &out );
- if( bres ) {
- LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out ));
- urldb_set_auth_details(url, realm, out );
- }
- if( out != NULL ){
- free( out );
- }
- if( cb != NULL )
- cb(bres, cbpw);
-}
-
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- LOG((""));
-
- bool bres;
- /*bres = verify_ssl_form_do(url, certs, num);
- if( bres )
- urldb_set_cert_permissions(url, true);
- */
- // TODO: localize string
- int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
- bres = (b==1)? true : false;
- LOG(("Trust: %d", bres ));
- urldb_set_cert_permissions(url, bres);
- cb(bres, cbpw);
-}
-
-void gui_quit(void)
-{
- LOG((""));
-
- struct gui_window * gw = window_list;
- struct gui_window * tmp = window_list;
-
- while( gw ) {
- tmp = gw->next;
- browser_window_destroy(gw->browser->bw);
- gw = tmp;
- }
-
- global_history_destroy();
- hotlist_destroy();
- toolbar_exit();
-
- urldb_save_cookies(nsoption_charp(cookie_file));
- urldb_save(nsoption_charp(url_file));
-
- RsrcXtype( 0, rsc_trindex, rsc_ntree);
- unbind_global_events();
- MenuBar( h_gem_menu , 0 );
- if( h_gem_rsrc != NULL ) {
- RsrcXfree(h_gem_rsrc );
- }
- LOG(("Shutting down plotter"));
- plot_finalise();
- if( tmp_clipboard != NULL ){
- free( tmp_clipboard );
- tmp_clipboard = NULL;
- }
- LOG(("done"));
-}
-
-
-
-
-static bool
-process_cmdline(int argc, char** argv)
-{
- int opt;
- bool set_default_dimensions = true;
-
- LOG(("argc %d, argv %p", argc, argv));
-
- if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) {
-
- option_window_width = nsoption_int(window_width);
- option_window_height = nsoption_int(window_height);
- option_window_x = nsoption_int(window_x);
- option_window_y = nsoption_int(window_y);
-
- if (option_window_width <= app.w && option_window_height < app.h) {
- set_default_dimensions = false;
- }
- }
-
- if (set_default_dimensions) {
- if( sys_type() == SYS_TOS ){
- /* on single tasking OS, start as fulled window: */
- option_window_width = app.w;
- option_window_height = app.h-20;
- option_window_x = app.w/2-(option_window_width/2);
- option_window_y = (app.h/2)-(option_window_height/2);
- } else {
- option_window_width = 600;
- option_window_height = 360;
- option_window_x = 10;
- option_window_y = 30;
- }
- }
-
- if (nsoption_charp(homepage_url) != NULL)
- option_homepage_url = nsoption_charp(homepage_url);
- else
- option_homepage_url = NETSURF_HOMEPAGE;
-
- while((opt = getopt(argc, argv, "w:h:")) != -1) {
- switch (opt) {
- case 'w':
- option_window_width = atoi(optarg);
- break;
-
- case 'h':
- option_window_height = atoi(optarg);
- break;
-
- default:
- fprintf(stderr,
- "Usage: %s [w,h,v] url\n",
- argv[0]);
- return false;
+ kstate = evnt.mkstate;
+ kcode = evnt.keybd;
+ nkc= gem_to_norm( (short)kstate, (short)kcode);
+ nks = (nkc & 0xFF00);
+ if( kstate & (K_LSHIFT|K_RSHIFT))
+ kstate |= K_LSHIFT|K_RSHIFT;
+ if( window_url_widget_has_focus( gw ) ) {
+ /* make sure we report for the root window and report...: */
+ done = tb_url_input( gw, nkc );
+ } else {
+ gw_tmp = window_list;
+ /* search for active browser component: */
+ while( gw_tmp != NULL && done == false ) {
+ /* todo: only handle when input_window == ontop */
+ if( window_widget_has_focus( (struct gui_window *)input_window,
+ BROWSER,(void*)gw_tmp->browser)) {
+ done = browser_input( gw_tmp, nkc );
+ break;
+ } else {
+ gw_tmp = gw_tmp->next;
+ }
}
- }
-
- if (optind < argc) {
- option_homepage_url = argv[optind];
- }
- return true;
-}
-
-static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
-{
- m->flags = flags;
- m->number = mode;
- if( flags & MFORM_EX_FLAG_USERFORM ) {
- m->number = mode;
- m->tree = (OBJECT*)form;
- }
-}
-
-nsurl *gui_get_resource_url(const char *path)
-{
- char buf[PATH_MAX];
- char *raw;
- nsurl *url = NULL;
-
- atari_find_resource((char*)&buf, path, path);
- raw = path_to_url((char*)&buf);
- if (raw != NULL) {
- nsurl_create(raw, &url);
- free(raw);
- }
-
- return url;
-}
-
-/* Documented in desktop/options.h */
-void gui_options_init_defaults(void)
-{
- /* Set defaults for absent option strings */
- nsoption_setnull_charp(cookie_file, strdup("cookies"));
-
- if (nsoption_charp(cookie_file) == NULL) {
- die("Failed initialising string options");
- }
-}
-
-static void gui_init(int argc, char** argv)
-{
- char buf[PATH_MAX];
- OBJECT * cursors;
-
- atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- h_gem_rsrc = RsrcXload( (char*) &buf );
-
- if( !h_gem_rsrc )
- die("Uable to open GEM Resource file!");
- rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
-
- RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
- RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
-
- create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
- create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
- create_cursor(0, THIN_CROSS, NULL, &gem_cursors.cross);
- create_cursor(0, BUSY_BEE, NULL, &gem_cursors.wait);
- create_cursor(0, ARROW, NULL, &gem_cursors.arrow);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
- RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
- cursors, &gem_cursors.appstarting);
- gem_set_cursor( &gem_cursors.appstarting );
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZEWE,
- cursors, &gem_cursors.sizewe);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZENS,
- cursors, &gem_cursors.sizens);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_NODROP,
- cursors, &gem_cursors.nodrop);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_DENY,
- cursors, &gem_cursors.deny);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_MENU,
- cursors, &gem_cursors.menu);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP,
- cursors, &gem_cursors.help);
-
- LOG(("Enabling core select menu"));
- nsoption_set_bool(core_select_menu, true);
-
- LOG(("Loading url.db from: %s", nsoption_charp(url_file) ));
- if( strlen(nsoption_charp(url_file)) ){
- urldb_load(nsoption_charp(url_file));
- }
-
- LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
- if( strlen(nsoption_charp(cookie_file)) ){
- urldb_load_cookies(nsoption_charp(cookie_file));
- }
-
- if (process_cmdline(argc,argv) != true)
- die("unable to process command line.\n");
-
- nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
-}
-
-static char *theapp = (char*)"NetSurf";
-static void gui_init2(int argc, char** argv)
-{
- MenuBar( h_gem_menu , 1 );
- bind_global_events();
- menu_register( -1, theapp);
- if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
- menu_register( _AESapid, (char*)" NetSurf ");
- }
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
- global_history_init();
- hotlist_init();
- toolbar_init();
-}
-
-/* #define WITH_DBG_LOGFILE 1 */
-/** Entry point from OS.
- *
- * /param argc The number of arguments in the string vector.
- * /param argv The argument string vector.
- * /return The return code to the OS
- */
-int main(int argc, char** argv)
-{
- char messages[PATH_MAX];
-
- setbuf(stderr, NULL);
- setbuf(stdout, NULL);
-#ifdef WITH_DBG_LOGFILE
- freopen("stdout.log", "a+", stdout);
- freopen("stderr.log", "a+", stderr);
-#endif
- ApplInit();
- graf_mouse(BUSY_BEE, NULL);
- init_os_info();
- atari_find_resource((char*)&messages, "messages", "res/messages");
- atari_find_resource((char*)&options, "Choices", "Choices");
- netsurf_init(&argc, &argv, options, messages);
- gui_init(argc, argv);
- gui_init2(argc, argv);
- browser_window_create(option_homepage_url, 0, 0, true, false);
- graf_mouse( ARROW , NULL);
- netsurf_main_loop();
- netsurf_exit();
- LOG(("ApplExit"));
- ApplExit();
-#ifdef WITH_DBG_LOGFILE
- fclose(stdout);
- fclose(stderr);
-#endif
-
- return 0;
-}
-
-
+ }
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+}
+
+void gui_poll(bool active)
+{
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
+ short mx, my, dummy;
+ unsigned short nkc = 0;
+
+ evnt.timer = schedule_run();
+
+ if(active || rendering) {
+ if (clock() >= next_poll) {
+ aes_event_in.emi_tlow = 0;
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ next_poll = clock() + (CLOCKS_PER_SEC>>4);
+ }
+ } else {
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ }
+
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ //global_dispatch_event(&aes_event_in, &aes_event_out, msg);
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ printf("key: %d, %d\n", aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta);
+ nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
+ }
+
+}
+
+void gui_poll_old(bool active)
+{
+ short winloc[4];
+ // int timeout; /* timeout in milliseconds */
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
+ short mx, my, dummy;
+
+ evnt.timer = schedule_run();
+
+ if( active || rendering ) {
+ if( clock() >= next_poll ) {
+ evnt.timer = 0;
+ flags |= MU_TIMER;
+ EvntWindom( flags );
+ next_poll = clock() + (CLOCKS_PER_SEC>>3);
+ }
+ } else {
+ if (input_window != NULL) {
+ wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
+ if (winloc[1] == _AESapid) {
+ /* only check for mouse move when netsurf is on top: */
+ // move that into m1 event handler
+ graf_mkstate( &mx, &my, &dummy, &dummy );
+ flags |= MU_M1;
+ evnt.m1_flag = MO_LEAVE;
+ evnt.m1_w = evnt.m1_h = 1;
+ evnt.m1_x = mx;
+ evnt.m1_y = my;
+ }
+ }
+ flags |= MU_TIMER;
+ EvntWindom( flags );
+ }
+
+ struct gui_window * g;
+ for( g = window_list; g != NULL; g=g->next ) {
+ if( browser_redraw_required( g ) ) {
+ browser_redraw( g );
+ }
+ if( g->root->toolbar ) {
+ if(g->root->toolbar->url.redraw ) {
+ tb_url_redraw( g );
+ }
+ }
+ }
+ if( evnt.timer != 0 && !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ global_history_redraw();
+ }
+}
+
+struct gui_window *
+gui_create_browser_window(struct browser_window *bw,
+ struct browser_window *clone,
+ bool new_tab) {
+ struct gui_window *gw=NULL;
+ LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
+ (int)new_tab
+ ));
+
+ gw = malloc( sizeof(struct gui_window) );
+ if (gw == NULL)
+ return NULL;
+ memset( gw, 0, sizeof(struct gui_window) );
+
+ LOG(("new window: %p, bw: %p\n", gw, bw));
+ window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
+ if( gw->root->handle ) {
+ GRECT pos = {
+ option_window_x, option_window_y,
+ option_window_width, option_window_height
+ };
+ window_open( gw , pos );
+ /* Recalculate windows browser area now */
+ browser_update_rects( gw );
+ tb_update_buttons( gw, -1 );
+ input_window = gw;
+ /* TODO:... this line: placeholder to create a local history widget ... */
+ }
+
+ /* add the window to the window list: */
+ if( window_list == NULL ) {
+ window_list = gw;
+ gw->next = NULL;
+ gw->prev = NULL;
+ } else {
+ struct gui_window * tmp = window_list;
+ while( tmp->next != NULL ) {
+ tmp = tmp->next;
+ }
+ tmp->next = gw;
+ gw->prev = tmp;
+ gw->next = NULL;
+ }
+
+ return( gw );
+
+}
+
+void gui_window_destroy(struct gui_window *w)
+{
+ if (w == NULL)
+ return;
+
+ LOG(("%s\n", __FUNCTION__ ));
+
+ input_window = NULL;
+
+ window_destroy(w);
+
+ /* unlink the window: */
+ if(w->prev != NULL ) {
+ w->prev->next = w->next;
+ } else {
+ window_list = w->next;
+ }
+ if( w->next != NULL ) {
+ w->next->prev = w->prev;
+ }
+ free(w);
+ w = NULL;
+
+ w = window_list;
+ while( w != NULL ) {
+ if( w->root ) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
+ }
+}
+
+void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
+ bool scaled)
+{
+ if (w == NULL)
+ return;
+ LGRECT rect;
+ browser_get_rect( w, BR_CONTENT, &rect );
+ *width = rect.g_w;
+ *height = rect.g_h;
+}
+
+void gui_window_set_title(struct gui_window *gw, const char *title)
+{
+ int l;
+ char * conv;
+
+ if (gw == NULL)
+ return;
+ if( gw->root ) {
+ l = strlen(title);
+ if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
+ strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
+ free( conv );
+ } else {
+ strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
+ }
+ gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
+ WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
+ }
+}
+
+/**
+ * set the status bar message
+ */
+void gui_window_set_status(struct gui_window *w, const char *text)
+{
+ if (w == NULL || text == NULL )
+ return;
+ window_set_stauts( w , (char*)text );
+}
+
+void gui_window_redraw_window(struct gui_window *gw)
+{
+ CMP_BROWSER b;
+ LGRECT rect;
+ if (gw == NULL)
+ return;
+ b = gw->browser;
+ browser_get_rect( gw, BR_CONTENT, &rect );
+ browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
+}
+
+void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
+{
+ CMP_BROWSER b;
+ if (gw == NULL)
+ return;
+ b = gw->browser;
+ int x0 = rect->x0 - b->scroll.current.x;
+ int y0 = rect->y0 - b->scroll.current.y;
+ int w,h;
+ w = rect->x1 - rect->x0;
+ h = rect->y1 - rect->y0;
+ browser_schedule_redraw_rect( gw, x0, y0, w, h );
+}
+
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
+{
+ if (w == NULL)
+ return false;
+ *sx = w->browser->scroll.current.x;
+ *sy = w->browser->scroll.current.y;
+ return( true );
+}
+
+void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+{
+ if ((w == NULL) ||
+ (w->browser->bw == NULL) ||
+ (w->browser->bw->current_content == NULL))
+ return;
+ if( sx != 0 ) {
+ if( sx < 0 ) {
+ browser_scroll(w, WA_LFLINE, abs(sx), true );
+ } else {
+ browser_scroll(w, WA_RTLINE, abs(sx), true );
+ }
+ }
+
+ if( sy != 0 ) {
+ if( sy < 0) {
+ browser_scroll(w, WA_UPLINE, abs(sy), true );
+ } else {
+ browser_scroll(w, WA_DNLINE, abs(sy), true );
+ }
+ }
+ return;
+
+}
+
+void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
+{
+ LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
+ gui_window_set_scroll(w,x0,y0);
+ browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
+}
+
+
+/* It seems this method is called when content size got adjusted,
+ so that we can adjust scroll info. We also have to call it when tab
+ change occurs.
+*/
+void gui_window_update_extent(struct gui_window *gw)
+{
+ int oldx, oldy;
+ oldx = gw->browser->scroll.current.x;
+ oldy = gw->browser->scroll.current.y;
+ if( gw->browser->bw->current_content != NULL ) {
+ browser_set_content_size( gw,
+ content_get_width(gw->browser->bw->current_content),
+ content_get_height(gw->browser->bw->current_content)
+ );
+ }
+}
+
+
+void gui_clear_selection(struct gui_window *g)
+{
+
+}
+
+
+
+/**
+ * set the pointer shape
+ */
+void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
+{
+ if (w == NULL)
+ return;
+ switch (shape) {
+ case GUI_POINTER_POINT: /* link */
+ gem_set_cursor(&gem_cursors.hand);
+ break;
+
+ case GUI_POINTER_MENU:
+ gem_set_cursor(&gem_cursors.menu);
+ break;
+
+ case GUI_POINTER_CARET: /* input */
+ gem_set_cursor(&gem_cursors.ibeam);
+ break;
+
+ case GUI_POINTER_CROSS:
+ gem_set_cursor(&gem_cursors.cross);
+ break;
+
+ case GUI_POINTER_MOVE:
+ gem_set_cursor(&gem_cursors.sizeall);
+ break;
+
+ case GUI_POINTER_RIGHT:
+ case GUI_POINTER_LEFT:
+ gem_set_cursor(&gem_cursors.sizewe);
+ break;
+
+ case GUI_POINTER_UP:
+ case GUI_POINTER_DOWN:
+ gem_set_cursor(&gem_cursors.sizens);
+ break;
+
+ case GUI_POINTER_RU:
+ case GUI_POINTER_LD:
+ gem_set_cursor(&gem_cursors.sizenesw);
+ break;
+
+ case GUI_POINTER_RD:
+ case GUI_POINTER_LU:
+ gem_set_cursor(&gem_cursors.sizenwse);
+ break;
+
+ case GUI_POINTER_WAIT:
+ gem_set_cursor(&gem_cursors.wait);
+ break;
+
+ case GUI_POINTER_PROGRESS:
+ gem_set_cursor(&gem_cursors.appstarting);
+ break;
+
+ case GUI_POINTER_NO_DROP:
+ gem_set_cursor(&gem_cursors.nodrop);
+ break;
+
+ case GUI_POINTER_NOT_ALLOWED:
+ gem_set_cursor(&gem_cursors.deny);
+ break;
+
+ case GUI_POINTER_HELP:
+ gem_set_cursor(&gem_cursors.help);
+ break;
+
+ default:
+ gem_set_cursor(&gem_cursors.arrow);
+ break;
+ }
+}
+
+void gui_window_hide_pointer(struct gui_window *w)
+{
+ TODO();
+}
+
+
+void gui_window_set_url(struct gui_window *w, const char *url)
+{
+ if (w == NULL)
+ return;
+ tb_url_set(w, (char*)url );
+}
+
+static void throbber_advance( void * data )
+{
+ LGRECT work;
+ struct gui_window * gw = (struct gui_window *)data;
+ if( gw->root == NULL )
+ return;
+ if( gw->root->toolbar == NULL )
+ return;
+ if( gw->root->toolbar->throbber.running == false )
+ return;
+ mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ gw->root->toolbar->throbber.index++;
+ if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
+ gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+ schedule(100, throbber_advance, gw );
+}
+
+void gui_window_start_throbber(struct gui_window *w)
+{
+ LGRECT work;
+ if (w == NULL)
+ return;
+ if( w->root->toolbar->throbber.running == true )
+ return;
+ mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ w->root->toolbar->throbber.running = true;
+ w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ schedule(100, throbber_advance, w );
+ ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+
+ rendering = true;
+}
+
+void gui_window_stop_throbber(struct gui_window *w)
+{
+ LGRECT work;
+ if (w == NULL)
+ return;
+ if( w->root->toolbar->throbber.running == false )
+ return;
+
+ schedule_remove(throbber_advance, w);
+
+ /* refresh toolbar buttons: */
+ tb_update_buttons( w, -1 );
+
+ /* redraw throbber: */
+ mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ w->root->toolbar->throbber.running = false;
+ ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+
+ rendering = false;
+}
+
+/* Place caret in window */
+void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
+{
+ if (w == NULL)
+ return;
+ if( w->browser->caret.current.g_w > 0 )
+ gui_window_remove_caret( w );
+ w->browser->caret.requested.g_x = x;
+ w->browser->caret.requested.g_y = y;
+ w->browser->caret.requested.g_w = 1;
+ w->browser->caret.requested.g_h = height;
+ w->browser->caret.redraw = true;
+ return;
+}
+
+
+/**
+ * clear window caret
+ */
+void
+gui_window_remove_caret(struct gui_window *w)
+{
+ if (w == NULL)
+ return;
+
+ if( w->browser->caret.background.fd_addr != NULL ) {
+ browser_restore_caret_background( w, NULL );
+ w->browser->caret.requested.g_w = 0;
+ w->browser->caret.current.g_w = 0;
+ }
+ return;
+}
+
+void
+gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+{
+ struct bitmap *bmp_icon;
+
+ bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
+
+ window_set_icon(g, bmp_icon);
+}
+
+void
+gui_window_set_search_ico(hlcache_handle *ico)
+{
+ TODO();
+}
+
+void gui_window_new_content(struct gui_window *w)
+{
+ w->browser->scroll.current.x = 0;
+ w->browser->scroll.current.y = 0;
+ w->browser->scroll.requested.x = 0;
+ w->browser->scroll.requested.y = 0;
+ w->browser->scroll.required = true;
+ gui_window_redraw_window( w );
+}
+
+bool gui_window_scroll_start(struct gui_window *w)
+{
+ TODO();
+ return true;
+}
+
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ const struct rect *rect)
+{
+ TODO();
+ return true;
+}
+
+void gui_window_save_link(struct gui_window *g, const char *url,
+ const char *title)
+{
+ LOG(("%s -> %s", title, url ));
+ TODO();
+}
+
+void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
+ struct gui_window *w)
+{
+ LOG((""));
+ TODO();
+}
+
+void gui_drag_save_selection(struct selection *s, struct gui_window *w)
+{
+ LOG((""));
+ TODO();
+}
+
+void gui_start_selection(struct gui_window *w)
+{
+ gui_empty_clipboard();
+}
+
+void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
+{
+ char * clip = scrap_txt_read( &app );
+ if( clip == NULL )
+ return;
+ int clip_length = strlen( clip );
+ if (clip_length > 0) {
+ char *utf8;
+ utf8_convert_ret ret;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ ret = utf8_from_local_encoding(clip,
+ clip_length, &utf8);
+ if (ret == UTF8_CONVERT_OK) {
+ browser_window_paste_text(w->browser->bw, utf8,
+ strlen(utf8), true);
+ free(utf8);
+ }
+ free( clip );
+ }
+}
+
+bool gui_empty_clipboard(void)
+{
+ if( tmp_clipboard != NULL ) {
+ free( tmp_clipboard );
+ tmp_clipboard = NULL;
+ }
+ return true;
+}
+
+bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space,
+ const plot_font_style_t *fstyle)
+{
+ LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
+ char * oldptr = tmp_clipboard;
+ size_t oldlen = 0;
+ size_t newlen = 0;
+ char * text = NULL;
+ char * text2 = NULL;
+ bool retval;
+ int length = 0;
+ if( length_utf8 > 0 && text_utf8 != NULL ) {
+ utf8_to_local_encoding(text_utf8,length_utf8,&text);
+ if( text == NULL ) {
+ LOG(("Conversion failed (%s)", text_utf8));
+ goto error;
+ } else {
+ text2 = text;
+ }
+ } else {
+ if( space == false ) {
+ goto success;
+ }
+ text = malloc(length + 2);
+ if( text == NULL ) {
+ goto error;
+ }
+ text2 = text;
+ text[length+1] = 0;
+ memset(text, ' ', length+1);
+ }
+ length = strlen(text);
+ if( tmp_clipboard != NULL ) {
+ oldlen = strlen( tmp_clipboard );
+ }
+ newlen = oldlen + length + 1;
+ if( tmp_clipboard == NULL) {
+ tmp_clipboard = malloc(newlen);
+ if( tmp_clipboard == NULL ) {
+ goto error;
+ }
+ strncpy(tmp_clipboard, text, newlen);
+ } else {
+ tmp_clipboard = realloc( tmp_clipboard, newlen);
+ if( tmp_clipboard == NULL ) {
+ goto error;
+ }
+ strncpy(tmp_clipboard, oldptr, newlen);
+ strncat(tmp_clipboard, text, newlen-oldlen);
+ }
+ goto success;
+
+error:
+ retval = false;
+ goto fin;
+
+success:
+ retval = true;
+
+fin:
+ if( text2 != NULL )
+ free( text2 );
+ return(retval);
+
+}
+
+bool gui_commit_clipboard(void)
+{
+ int r = scrap_txt_write(&app, tmp_clipboard);
+ return( (r>0)?true:false );
+}
+
+bool gui_copy_to_clipboard(struct selection *s)
+{
+ bool ret = false;
+ if( s->defined ) {
+ gui_empty_clipboard();
+ if(selection_copy_to_clipboard(s)) {
+ ret = gui_commit_clipboard();
+ }
+ }
+ gui_empty_clipboard();
+ return ret;
+}
+
+
+void gui_create_form_select_menu(struct browser_window *bw,
+ struct form_control *control)
+{
+ TODO();
+}
+
+/**
+ * Broadcast an URL that we can't handle.
+ */
+void gui_launch_url(const char *url)
+{
+ TODO();
+ LOG(("launch file: %s\n", url));
+}
+
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ bool bres;
+ char * out = NULL;
+ bres = login_form_do( url, (char*)realm, &out );
+ if( bres ) {
+ LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out ));
+ urldb_set_auth_details(url, realm, out );
+ }
+ if( out != NULL ) {
+ free( out );
+ }
+ if( cb != NULL )
+ cb(bres, cbpw);
+}
+
+void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ LOG((""));
+
+ bool bres;
+ /*bres = verify_ssl_form_do(url, certs, num);
+ if( bres )
+ urldb_set_cert_permissions(url, true);
+ */
+ // TODO: localize string
+ int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
+ bres = (b==1)? true : false;
+ LOG(("Trust: %d", bres ));
+ urldb_set_cert_permissions(url, bres);
+ cb(bres, cbpw);
+}
+
+void gui_quit(void)
+{
+ LOG((""));
+
+ struct gui_window * gw = window_list;
+ struct gui_window * tmp = window_list;
+
+ unbind_global_events();
+
+ while( gw ) {
+ tmp = gw->next;
+ browser_window_destroy(gw->browser->bw);
+ gw = tmp;
+ }
+
+ global_history_destroy();
+ hotlist_destroy();
+ toolbar_exit();
+
+ urldb_save_cookies(nsoption_charp(cookie_file));
+ urldb_save(nsoption_charp(url_file));
+
+ deskmenu_destroy();
+
+ rsrc_free();
+
+ LOG(("Shutting down plotter"));
+ plot_finalise();
+ if( tmp_clipboard != NULL ) {
+ free( tmp_clipboard );
+ tmp_clipboard = NULL;
+ }
+ LOG(("done"));
+}
+
+
+
+
+static bool
+process_cmdline(int argc, char** argv)
+{
+ int opt;
+ bool set_default_dimensions = true;
+
+ LOG(("argc %d, argv %p", argc, argv));
+
+ if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) {
+
+ option_window_width = nsoption_int(window_width);
+ option_window_height = nsoption_int(window_height);
+ option_window_x = nsoption_int(window_x);
+ option_window_y = nsoption_int(window_y);
+
+ if (option_window_width <= app.w && option_window_height < app.h) {
+ set_default_dimensions = false;
+ }
+ }
+
+ if (set_default_dimensions) {
+ if( sys_type() == SYS_TOS ) {
+ /* on single tasking OS, start as fulled window: */
+ option_window_width = app.w;
+ option_window_height = app.h-20;
+ option_window_x = app.w/2-(option_window_width/2);
+ option_window_y = (app.h/2)-(option_window_height/2);
+ } else {
+ option_window_width = 600;
+ option_window_height = 360;
+ option_window_x = 10;
+ option_window_y = 30;
+ }
+ }
+
+ if (nsoption_charp(homepage_url) != NULL)
+ option_homepage_url = nsoption_charp(homepage_url);
+ else
+ option_homepage_url = NETSURF_HOMEPAGE;
+
+ while((opt = getopt(argc, argv, "w:h:")) != -1) {
+ switch (opt) {
+ case 'w':
+ option_window_width = atoi(optarg);
+ break;
+
+ case 'h':
+ option_window_height = atoi(optarg);
+ break;
+
+ default:
+ fprintf(stderr,
+ "Usage: %s [w,h,v] url\n",
+ argv[0]);
+ return false;
+ }
+ }
+
+ if (optind < argc) {
+ option_homepage_url = argv[optind];
+ }
+ return true;
+}
+
+static inline void create_cursor(int flags, short mode, void * form,
+ MFORM_EX * m)
+{
+ m->flags = flags;
+ m->number = mode;
+ if( flags & MFORM_EX_FLAG_USERFORM ) {
+ m->number = mode;
+ m->tree = (OBJECT*)form;
+ }
+}
+
+nsurl *gui_get_resource_url(const char *path)
+{
+ char buf[PATH_MAX];
+ char *raw;
+ nsurl *url = NULL;
+
+ atari_find_resource((char*)&buf, path, path);
+ raw = path_to_url((char*)&buf);
+ if (raw != NULL) {
+ nsurl_create(raw, &url);
+ free(raw);
+ }
+
+ return url;
+}
+
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ nsoption_setnull_charp(cookie_file, strdup("cookies"));
+
+ if (nsoption_charp(cookie_file) == NULL) {
+ die("Failed initialising string options");
+ }
+}
+
+static void gui_init(int argc, char** argv)
+{
+ char buf[PATH_MAX];
+ OBJECT * cursors;
+
+ atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
+ LOG(("%s ", (char*)&buf));
+ if (rsrc_load(buf)==0) {
+ die("Uable to open GEM Resource file!");
+ }
+ //h_gem_rsrc = RsrcXload( (char*) &buf );
+
+ //if( !h_gem_rsrc )
+ // die("Uable to open GEM Resource file!");
+ //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+
+ //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+
+ create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
+ create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
+ create_cursor(0, THIN_CROSS, NULL, &gem_cursors.cross);
+ create_cursor(0, BUSY_BEE, NULL, &gem_cursors.wait);
+ create_cursor(0, ARROW, NULL, &gem_cursors.arrow);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
+ RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
+ cursors, &gem_cursors.appstarting);
+ gem_set_cursor( &gem_cursors.appstarting );
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZEWE,
+ cursors, &gem_cursors.sizewe);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZENS,
+ cursors, &gem_cursors.sizens);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_NODROP,
+ cursors, &gem_cursors.nodrop);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_DENY,
+ cursors, &gem_cursors.deny);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_MENU,
+ cursors, &gem_cursors.menu);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP,
+ cursors, &gem_cursors.help);
+
+ LOG(("Enabling core select menu"));
+ nsoption_set_bool(core_select_menu, true);
+
+ LOG(("Loading url.db from: %s", nsoption_charp(url_file) ));
+ if( strlen(nsoption_charp(url_file)) ) {
+ urldb_load(nsoption_charp(url_file));
+ }
+
+ LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
+ if( strlen(nsoption_charp(cookie_file)) ) {
+ urldb_load_cookies(nsoption_charp(cookie_file));
+ }
+
+ if (process_cmdline(argc,argv) != true)
+ die("unable to process command line.\n");
+
+ nkc_init();
+ plot_init(nsoption_charp(atari_font_driver));
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+}
+
+static char *theapp = (char*)"NetSurf";
+static void gui_init2(int argc, char** argv)
+{
+ deskmenu_init();
+ menu_register( -1, theapp);
+ if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
+ menu_register( _AESapid, (char*)" NetSurf ");
+ }
+ bind_global_events();
+ global_history_init();
+ hotlist_init();
+ toolbar_init();
+}
+
+/* #define WITH_DBG_LOGFILE 1 */
+/** Entry point from OS.
+ *
+ * /param argc The number of arguments in the string vector.
+ * /param argv The argument string vector.
+ * /return The return code to the OS
+ */
+int main(int argc, char** argv)
+{
+ char messages[PATH_MAX];
+
+ setbuf(stderr, NULL);
+ setbuf(stdout, NULL);
+#ifdef WITH_DBG_LOGFILE
+ freopen("stdout.log", "a+", stdout);
+ freopen("stderr.log", "a+", stderr);
+#endif
+ ApplInit();
+ graf_mouse(BUSY_BEE, NULL);
+ init_os_info();
+ atari_find_resource((char*)&messages, "messages", "res/messages");
+ atari_find_resource((char*)&options, "Choices", "Choices");
+ netsurf_init(&argc, &argv, options, messages);
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+ graf_mouse( ARROW , NULL);
+ netsurf_main_loop();
+ netsurf_exit();
+ LOG(("ApplExit"));
+ ApplExit();
+#ifdef WITH_DBG_LOGFILE
+ fclose(stdout);
+ fclose(stderr);
+#endif
+
+ return 0;
+}
+
+
diff --git a/atari/hotlist.c b/atari/hotlist.c
index bdd10d9..5d54d06 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -40,6 +40,7 @@
#include "atari/treeview.h"
#include "atari/hotlist.h"
#include "atari/findfile.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
struct atari_hotlist hl;
diff --git a/atari/misc.c b/atari/misc.c
index 8b745fd..575e964 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -42,7 +42,7 @@
#include "atari/browser.h"
#include "atari/misc.h"
#include "atari/encoding.h"
-#include "atari/msgbox.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
extern void * h_gem_rsrc;
@@ -111,10 +111,7 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-/*
- TBD: make use of this function or remove it...
-*/
-struct gui_window * find_gui_window( unsigned long handle, short mode ){
+struct gui_window * find_guiwin_by_aes_handle(short handle){
struct gui_window * gw;
gw = window_list;
@@ -122,29 +119,17 @@ struct gui_window * find_gui_window( unsigned long handle, short mode ){
if( handle == 0 ){
return( NULL );
}
- else if( mode == BY_WINDOM_HANDLE ){
- WINDOW * win = (WINDOW*) handle;
- while( gw != NULL) {
- if( gw->root->handle == win ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
- }
- else if( mode == BY_GEM_HANDLE ){
- short ghandle = (short)handle;
- while( gw != NULL) {
- if( gw->root->handle != NULL
- && gw->root->handle->handle == ghandle ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
+
+ while(gw != NULL) {
+ if( gw->root->handle != NULL
+ && gw->root->handle->handle == handle ) {
+ return(gw);
+ }
+ else
+ gw = gw->next;
}
- return( NULL );
+ return( NULL );
}
@@ -260,25 +245,6 @@ bool is_process_running(const char * name)
}
-/* -------------------------------------------------------------------------- */
-/* GEM Utillity functions: */
-/* -------------------------------------------------------------------------- */
-
-/* Return a string from resource file */
-char *get_rsc_string( int idx) {
- char *txt;
- RsrcGaddr( h_gem_rsrc, R_STRING, idx, &txt );
- return txt;
-}
-
-OBJECT *get_tree( int idx) {
- OBJECT *tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
- return tree;
-}
-
-
-
/**
* Callback for load_icon(). Should be removed once bitmaps get loaded directly
* from disc
diff --git a/atari/misc.h b/atari/misc.h
index 612113f..5359d72 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -42,11 +42,9 @@
typedef int (*scan_process_callback)(int pid, void *data);
-struct gui_window * find_gui_window( unsigned long, short mode );
+struct gui_window * find_guiwin_by_aes_handle(short handle);
struct gui_window * find_cmp_window( COMPONENT * c );
bool is_process_running(const char * name);
-OBJECT *get_tree( int idx );
-char *get_rsc_string( int idx );
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
void * pw );
diff --git a/atari/osspec.c b/atari/osspec.c
index d697f43..c2e2252 100644
--- a/atari/osspec.c
+++ b/atari/osspec.c
@@ -28,7 +28,8 @@
#include <windom.h>
#include "utils/log.h"
-#include "atari/osspec.h"
+#include "atari/osspec.h"
+#include "atari/gemtk/gemtk.h"
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -36,38 +37,6 @@
NS_ATARI_SYSINFO atari_sysinfo;
-unsigned short _systype_v;
-unsigned short _systype (void)
-{
- int32_t * cptr = NULL;
- _systype_v = SYS_TOS;
-
- cptr = (int32_t *)Setexc(0x0168, -1L);
- if (cptr == NULL ) {
- return _systype_v; /* stone old TOS without any cookie support */
- }
- while (*cptr) {
- if (*cptr == C_MgMc || *cptr == C_MgMx ) {
- _systype_v = (_systype_v & ~0xF) | SYS_MAGIC;
- } else if (*cptr == C_MiNT ) {
- _systype_v = (_systype_v & ~0xF) | SYS_MINT;
- } else if (*cptr == C_Gnva /* Gnva */ ) {
- _systype_v |= SYS_GENEVA;
- } else if (*cptr == C_nAES /* nAES */ ) {
- _systype_v |= SYS_NAES;
- }
- cptr += 2;
- }
- if (_systype_v & SYS_MINT) { /* check for XaAES */
- short out = 0, u;
- if (wind_get (0, (((short)'X') <<8)|'A', &out, &u,&u,&u) && out) {
- _systype_v |= SYS_XAAES;
- }
- }
- LOG(("Detected OS: %d\n", _systype_v ));
- return _systype_v;
-}
-
void init_os_info(void)
{
int16_t out[4];
diff --git a/atari/osspec.h b/atari/osspec.h
index 91cf2f0..29f87cc 100644
--- a/atari/osspec.h
+++ b/atari/osspec.h
@@ -17,27 +17,13 @@
*/
#ifndef NS_ATARI_OSSPEC_H
-#define NS_ATARI_OSSPEC_H
-
+#define NS_ATARI_OSSPEC_H
+
typedef struct {
long c;
long v;
} COOKIE;
-/* System type detection added by [GS] */
-#define SYS_TOS 0x0001
-#define SYS_MAGIC 0x0002
-#define SYS_MINT 0x0004
-#define SYS_GENEVA 0x0010
-#define SYS_NAES 0x0020
-#define SYS_XAAES 0x0040
-/* detect the system type, AES + kernel */
-#define sys_type() (_systype_v ? _systype_v : _systype())
-#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
-#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
-#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
-
-
typedef struct {
unsigned short gemdos_version;
unsigned short gdos_FSMC;
@@ -50,13 +36,9 @@ typedef struct {
} NS_ATARI_SYSINFO;
extern NS_ATARI_SYSINFO atari_sysinfo;
-extern unsigned short _systype_v;
-
-#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
void init_os_info(void);
-int tos_getcookie( long tag, long * value );
void fix_path(char * path);
-char * gemdos_realpath(const char * path, char * rpath);
-unsigned short _systype (void);
-#endif
\ No newline at end of file
+char * gemdos_realpath(const char * path, char * rpath);
+int tos_getcookie( long tag, long * value );
+#endif
diff --git a/atari/redrawslots.c b/atari/redrawslots.c
index 9fe7161..069e6cc 100644
--- a/atari/redrawslots.c
+++ b/atari/redrawslots.c
@@ -45,7 +45,7 @@ static inline bool rect_intersect( struct rect * box1, struct rect * box2 )
return true;
}
/*
- schedule a slots, coords are relative.
+ schedule redraw coords, coords are relative.
*/
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0, short x1, short y1)
{
diff --git a/atari/rootwin.c b/atari/rootwin.c
new file mode 100755
index 0000000..16d3363
--- /dev/null
+++ b/atari/rootwin.c
@@ -0,0 +1,816 @@
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <windom.h>
+#include <assert.h>
+#include <math.h>
+#include <osbind.h>
+
+#include "utils/log.h"
+#include "desktop/gui.h"
+#include "desktop/history_core.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/plotters.h"
+#include "desktop/textinput.h"
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "content/urldb.h"
+#include "css/css.h"
+#include "atari/gemtk/gemtk.h"
+#include "atari/gui.h"
+#include "atari/rootwin.h"
+#include "atari/browser.h"
+#include "atari/misc.h"
+#include "atari/plot/plot.h"
+#include "atari/global_evnt.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/browser.h"
+#include "atari/toolbar.h"
+#include "atari/statusbar.h"
+#include "atari/search.h"
+#include "atari/osspec.h"
+#include "atari/encoding.h"
+#include "atari/toolbar.h"
+#include "atari/gemtk/gemtk.h"
+
+extern struct gui_window *input_window;
+
+/* -------------------------------------------------------------------------- */
+/* Static module methods follow here: */
+/* -------------------------------------------------------------------------- */
+//static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
+//void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
+//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
+static void redraw(GUIWIN *win, short msg[8]);
+static void resized(GUIWIN *win);
+static void file_dropped(GUIWIN *win, short msg[8]);
+//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
+static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
+//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
+
+#define FIND_NS_GUI_WINDOW(w) \
+ find_guiwin_by_aes_handle(guiwin_get_handle(w));
+
+/* -------------------------------------------------------------------------- */
+/* Module public functions: */
+/* -------------------------------------------------------------------------- */
+
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+ struct gui_window * gw;
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ // handle message
+ printf("root win msg: %d\n", msg[0]);
+ switch (msg[0]) {
+
+ case WM_REDRAW:
+ redraw(win, msg);
+ break;
+
+ case WM_REPOSED:
+ case WM_SIZED:
+ case WM_MOVED:
+ case WM_FULLED:
+ resized(win);
+ break;
+
+ case WM_ICONIFY:
+ gw = FIND_NS_GUI_WINDOW(win);
+ if( input_window == gw) {
+ input_window = NULL;
+ }
+ break;
+
+ case WM_TOPPED:
+ case WM_NEWTOP:
+ case WM_UNICONIFY:
+ input_window = FIND_NS_GUI_WINDOW(win);
+ break;
+
+ case WM_CLOSED:
+ gw = FIND_NS_GUI_WINDOW(win);
+ if( gw != NULL ) {
+ browser_window_destroy( gw->browser->bw );
+ }
+ break;
+
+ case AP_DRAGDROP:
+ file_dropped(win, msg);
+ break;
+
+ case WM_TOOLBAR:
+ printf("toolbar click at %d,%d!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ printf("root win keybd\n");
+ // handle key
+ }
+ if( (ev_out->emo_events & MU_TIMER) != 0 ) {
+ // handle_timer();
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y));
+ printf("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ //handle_mbutton(gw, ev_out);
+ }
+
+ return(0);
+}
+
+
+int window_create( struct gui_window * gw,
+ struct browser_window * bw,
+ unsigned long inflags )
+{
+ int err = 0;
+ bool tb, sb;
+ int flags;
+
+ tb = (inflags & WIDGET_TOOLBAR);
+ sb = (inflags & WIDGET_STATUSBAR);
+
+ flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
+ if( inflags & WIDGET_SCROLL ) {
+ flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
+ }
+ if( inflags & WIDGET_RESIZE ) {
+ flags |= ( SIZER );
+ }
+ if( inflags & WIDGET_STATUSBAR ) {
+ flags |= ( INFO );
+ }
+
+ gw->root = malloc( sizeof(struct s_gui_win_root) );
+ if( gw->root == NULL )
+ return( -1 );
+ memset( gw->root, 0, sizeof(struct s_gui_win_root) );
+ gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
+ gw->root->handle = WindCreate(flags, 40, 40, app.w, app.h);
+ if( gw->root->handle == NULL ) {
+ free( gw->root->title );
+ free( gw->root );
+ return( -1 );
+ }
+
+ /* set scroll / content granularity ( 1 unit ) */
+ gw->root->handle->w_u = 1;
+ gw->root->handle->h_u = 1;
+
+ /* Create Root component: */
+ gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
+ WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
+
+ /* create toolbar component: */
+ if( tb ) {
+ gw->root->toolbar = tb_create( gw );
+ assert( gw->root->toolbar );
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
+
+ } else {
+ gw->root->toolbar = NULL;
+ }
+
+ /* create browser component: */
+ gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
+ mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
+
+ /* create statusbar component: */
+ if( sb ) {
+ gw->root->statusbar = sb_create( gw );
+#ifdef WITH_COMOPONENT_STATUSBAR
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
+#endif
+ } else {
+ gw->root->statusbar = NULL;
+ }
+
+ WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
+
+ /* Event Handlers: */
+// EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
+ /* capture resize/move events so we can handle that manually */
+// EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
+// EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
+// EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
+ EvntDataAdd(gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
+ EvntDataAdd(gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
+// EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
+// EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
+// EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
+ EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
+
+ if (inflags & WIN_TOP) {
+ window_set_focus( gw, BROWSER, gw->browser);
+ }
+
+ GUIWIN * guiwin = guiwin_add(gw->root->handle->handle,
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
+ guiwin_set_toolbar(guiwin, get_tree(TOOLBAR), 0, 0);
+ return (err);
+}
+
+int window_destroy(struct gui_window * gw)
+{
+ int err = 0;
+
+ search_destroy( gw );
+ if( input_window == gw )
+ input_window = NULL;
+
+ if( gw->root ) {
+ if( gw->root->toolbar )
+ tb_destroy( gw->root->toolbar );
+
+ if( gw->root->statusbar )
+ sb_destroy( gw->root->statusbar );
+ }
+
+ search_destroy( gw );
+
+ guiwin_remove(guiwin_find(gw->root->handle->handle));
+
+ if( gw->browser )
+ browser_destroy( gw->browser );
+
+ /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
+ if( gw->root ) {
+ /* TODO: check if no other browser is bound to this root window! */
+ /* only needed for tabs */
+ if( gw->root->title )
+ free( gw->root->title );
+ if( gw->root->cmproot )
+ mt_CompDelete( &app, gw->root->cmproot );
+ ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
+ EvntWindom( MU_MESAG );
+ gw->root->handle = NULL;
+ free(gw->root);
+ gw->root = NULL;
+ }
+ return(err);
+}
+
+
+
+void window_open( struct gui_window * gw, GRECT pos )
+{
+ LGRECT br;
+
+ WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
+ WindClear( gw->root->handle );
+ WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
+
+ /* apply focus to the root frame: */
+ long lfbuff[8] = { CM_GETFOCUS };
+ mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
+
+ /* recompute the nested component sizes and positions: */
+ browser_update_rects( gw );
+ mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+ browser_get_rect( gw, BR_CONTENT, &br );
+ plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
+ gw->browser->attached = true;
+ if( gw->root->statusbar != NULL ) {
+ sb_attach(gw->root->statusbar, gw);
+ }
+ tb_adjust_size( gw );
+ /*TBD: get already present content and set size? */
+ input_window = gw;
+ window_set_focus( gw, BROWSER, gw->browser );
+}
+
+
+
+/* update back forward buttons (see tb_update_buttons (bug) ) */
+void window_update_back_forward( struct gui_window * gw)
+{
+ tb_update_buttons( gw, -1 );
+}
+
+void window_set_stauts(struct gui_window * gw , char * text )
+{
+ if( gw->root == NULL )
+ return;
+
+ CMP_STATUSBAR sb = gw->root->statusbar;
+
+ if( sb == NULL || gw->browser->attached == false )
+ return;
+
+ sb_set_text( sb, text );
+}
+
+/* set focus to an arbitary element */
+void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
+{
+ if( gw->root->focus.type != type || gw->root->focus.element != element ) {
+ LOG(("Set focus: %p (%d)\n", element, type));
+ gw->root->focus.type = type;
+ gw->root->focus.element = element;
+ if( element != NULL ) {
+ switch( type ) {
+
+ case URL_WIDGET:
+ textarea_keypress(((struct s_url_widget*)(element))->textarea,
+ KEY_SELECT_ALL );
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ }
+}
+
+/* check if the url widget has focus */
+bool window_url_widget_has_focus( struct gui_window * gw )
+{
+ assert( gw );
+ assert( gw->root );
+ if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
+ assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
+ assert( GUIWIN_VISIBLE(gw) );
+ return true;
+ }
+ return false;
+}
+
+/* check if an arbitary window widget / or frame has the focus */
+bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
+{
+ if( gw == NULL )
+ return( false );
+ if( element == NULL ) {
+ assert( 1 != 0 );
+ return( (gw->root->focus.type == t ) );
+ }
+ assert( gw->root != NULL );
+ return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
+}
+
+void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
+{
+ gw->icon = bmp;
+ /* redraw window when it is iconyfied: */
+ if (gw->icon != NULL) {
+ short info, dummy;
+ WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
+ if (info == 1) {
+ window_redraw_favicon(gw, NULL);
+ }
+ }
+}
+
+
+/**
+ * Redraw the favicon
+*/
+void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
+{
+ GRECT work;
+
+ assert(gw->root);
+
+ WINDOW * bw = gw->root->handle;
+
+ WindClear(bw);
+ WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
+ if (clip == NULL) {
+ clip = &work;
+ }
+
+ if (gw->icon == NULL) {
+ OBJECT * tree = get_tree(ICONIFY);
+ tree->ob_x = work.g_x;
+ tree->ob_y = work.g_y;
+ tree->ob_width = work.g_w;
+ tree->ob_height = work.g_h;
+ objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
+ } else {
+ // TODO: consider the clipping rectangle
+ struct rect work_clip = { 0,0,work.g_w,work.g_h };
+ int xoff=0;
+ if (work.g_w > work.g_h) {
+ xoff = ((work.g_w-work.g_h)/2);
+ work.g_w = work.g_h;
+ }
+ plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
+ plot_clip(&work_clip);
+ atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
+ }
+}
+
+
+/* -------------------------------------------------------------------------- */
+/* Event Handlers: */
+/* -------------------------------------------------------------------------- */
+
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
+{
+ bool abs = false;
+ LGRECT cwork;
+ struct gui_window * gw = data;
+ int value = BROWSER_SCROLL_SVAL;
+
+ assert( gw != NULL );
+
+ browser_get_rect( gw, BR_CONTENT, &cwork );
+
+ switch( buff[4] ) {
+ case WA_UPPAGE:
+ case WA_DNPAGE:
+ value = cwork.g_h;
+ break;
+
+
+ case WA_LFPAGE:
+ case WA_RTPAGE:
+ value = cwork.g_w;
+ break;
+
+ default:
+ break;
+ }
+ browser_scroll( gw, buff[4], value, abs );
+}
+
+//
+//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+// char file[DD_NAMEMAX];
+// char name[DD_NAMEMAX];
+// char *buff=NULL;
+// int dd_hdl;
+// int dd_msg; /* pipe-handle */
+// long size;
+// char ext[32];
+// short mx,my,bmstat,mkstat;
+// graf_mkstate(&mx, &my, &bmstat, &mkstat);
+//
+// if( gw == NULL )
+// return;
+// if( (win->status & WS_ICONIFY))
+// return;
+//
+// dd_hdl = ddopen( wbuff[7], DD_OK);
+// if( dd_hdl<0)
+// return; /* pipe not open */
+// memset( ext, 0, 32);
+// strcpy( ext, "ARGS");
+// dd_msg = ddsexts( dd_hdl, ext);
+// if( dd_msg<0)
+// goto error;
+// dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
+// if( size+1 >= PATH_MAX )
+// goto error;
+// if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
+// ddreply(dd_hdl, DD_OK);
+// buff = (char*)malloc(sizeof(char)*(size+1));
+// if (buff != NULL) {
+// if (Fread(dd_hdl, size, buff ) == size)
+// buff[size] = 0;
+// LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
+// (char*)buff, (char*)&ext,
+// size, mx, my
+// ));
+// {
+// LGRECT bwrect;
+// struct browser_window * bw = gw->browser->bw;
+// browser_get_rect( gw, BR_CONTENT, &bwrect );
+// mx = mx - bwrect.g_x;
+// my = my - bwrect.g_y;
+// if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
+// return;
+//
+// utf8_convert_ret ret;
+// char *utf8_fn;
+//
+// ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
+// if (ret != UTF8_CONVERT_OK) {
+// free(buff);
+// /* A bad encoding should never happen */
+// LOG(("utf8_from_local_encoding failed"));
+// assert(ret != UTF8_CONVERT_BADENC);
+// /* no memory */
+// return;
+// }
+// browser_window_drop_file_at_point( gw->browser->bw,
+// mx+gw->browser->scroll.current.x,
+// my+gw->browser->scroll.current.y,
+// utf8_fn );
+// free(utf8_fn);
+// free(buff);
+// }
+// }
+// }
+//error:
+// ddclose( dd_hdl);
+//}
+
+static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+}
+
+//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
+//{
+// struct gui_window * gw = (struct gui_window *) data ;
+// if( gw != NULL ) {
+// browser_window_destroy( gw->browser->bw );
+// }
+//}
+
+
+//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
+//{
+// input_window = (struct gui_window *) data;
+// window_set_focus( input_window, BROWSER, input_window->browser );
+// LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
+// assert( input_window != NULL );
+//}
+
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
+{
+ int dx = buff[4];
+ int dy = buff[5];
+ struct gui_window * gw = data;
+
+ if (!dx && !dy) return;
+
+ if( input_window == NULL || input_window != gw ) {
+ return;
+ }
+
+ /* update the sliders _before_ we call redraw
+ (which might depend on the slider possitions) */
+ WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
+
+ if( dy > 0 )
+ browser_scroll( gw, WA_DNPAGE, abs(dy), false );
+ else if ( dy < 0)
+ browser_scroll( gw, WA_UPPAGE, abs(dy), false );
+ if( dx > 0 )
+ browser_scroll( gw, WA_RTPAGE, abs(dx), false );
+ else if( dx < 0 )
+ browser_scroll( gw, WA_LFPAGE, abs(dx), false );
+}
+
+//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+//
+// input_window = gw;
+// WindTop( gw->root->handle );
+// window_set_focus( gw, BROWSER, gw->browser );
+//}
+
+//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+// if( input_window == gw) {
+// input_window = NULL;
+// }
+//}
+
+
+//static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
+//{
+// struct gui_window *gw = (struct gui_window*) data;
+// GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
+// window_redraw_favicon(gw, &clip);
+//}
+
+static void redraw(GUIWIN *win, short msg[8])
+{
+ short handle;
+ struct gui_window *gw;
+
+ handle = guiwin_get_handle(win);
+ gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
+
+ assert(gw != NULL);
+
+ if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
+ GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
+ window_redraw_favicon(gw, &clip);
+ } else {
+ GRECT area;
+ short pxy[8];
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
+ /*
+ pxy[0] = area.g_x;
+ pxy[1] = area.g_y;
+ pxy[2] = pxy[0] + area.g_w;
+ pxy[3] = pxy[1];
+ pxy[4] = pxy[2];
+ pxy[5] = pxy[1] + area.g_h;
+ pxy[6] = pxy[0];
+ pxy[7] = pxy[5];
+ */
+ //const plot_style_fill_white
+ plot_rectangle(area.g_x, area.g_y, area.g_x+area.g_h,
+ area.g_y + area.g_h,
+ plot_style_fill_white);
+
+
+ //WindClear(gw->root->handle);
+ }
+}
+
+static void resized(GUIWIN *win)
+{
+ short x,y,w,h;
+ short handle;
+ struct gui_window *gw;
+
+ handle = guiwin_get_handle(win);
+ gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
+
+ assert( gw != NULL );
+
+ wind_get(handle, WF_CURRXYWH, &x, &y, &w, &h);
+
+ if (gw->root->loc.g_w != w || gw->root->loc.g_h != h) {
+ // resized
+ tb_adjust_size( gw );
+ if ( gw->browser->bw->current_content != NULL ) {
+ /* Reformat will happen when next redraw message arrives: */
+ gw->browser->reformat_pending = true;
+ /* but on xaaes an resize doesn't trigger an redraw, */
+ /* when the window is shrinked, deal with it: */
+ if( sys_XAAES() ) {
+ if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ) {
+ ApplWrite(_AESapid, WM_REDRAW, gw->root->handle->handle,
+ x, y, w, h);
+ }
+ }
+ }
+ }
+ if (gw->root->loc.g_x != x || gw->root->loc.g_y != y) {
+ // moved
+ }
+ gw->root->loc.g_x = x;
+ gw->root->loc.g_y = y;
+ gw->root->loc.g_w = w;
+ gw->root->loc.g_h = h;
+}
+
+static void __CDECL file_dropped(GUIWIN *win, short msg[8])
+{
+ char file[DD_NAMEMAX];
+ char name[DD_NAMEMAX];
+ char *buff=NULL;
+ int dd_hdl;
+ int dd_msg; /* pipe-handle */
+ long size;
+ char ext[32];
+ short mx,my,bmstat,mkstat;
+ struct gui_window *gw;
+
+ graf_mkstate(&mx, &my, &bmstat, &mkstat);
+
+ gw = FIND_NS_GUI_WINDOW(win);
+
+ if( gw == NULL )
+ return;
+
+ if(guiwin_get_state(win) & GW_STATUS_ICONIFIED)
+ return;
+
+ dd_hdl = ddopen( msg[7], DD_OK);
+ if( dd_hdl<0)
+ return; /* pipe not open */
+ memset( ext, 0, 32);
+ strcpy( ext, "ARGS");
+ dd_msg = ddsexts( dd_hdl, ext);
+ if( dd_msg<0)
+ goto error;
+ dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
+ if( size+1 >= PATH_MAX )
+ goto error;
+ if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
+ ddreply(dd_hdl, DD_OK);
+ buff = (char*)malloc(sizeof(char)*(size+1));
+ if (buff != NULL) {
+ if (Fread(dd_hdl, size, buff ) == size)
+ buff[size] = 0;
+ LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
+ (char*)buff, (char*)&ext,
+ size, mx, my
+ ));
+ {
+ LGRECT bwrect;
+ struct browser_window * bw = gw->browser->bw;
+ browser_get_rect( gw, BR_CONTENT, &bwrect );
+ mx = mx - bwrect.g_x;
+ my = my - bwrect.g_y;
+ if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
+ return;
+
+ utf8_convert_ret ret;
+ char *utf8_fn;
+
+ ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
+ if (ret != UTF8_CONVERT_OK) {
+ free(buff);
+ /* A bad encoding should never happen */
+ LOG(("utf8_from_local_encoding failed"));
+ assert(ret != UTF8_CONVERT_BADENC);
+ /* no memory */
+ return;
+ }
+ browser_window_drop_file_at_point( gw->browser->bw,
+ mx+gw->browser->scroll.current.x,
+ my+gw->browser->scroll.current.y,
+ utf8_fn );
+ free(utf8_fn);
+ free(buff);
+ }
+ }
+ }
+error:
+ ddclose( dd_hdl);
+}
+
+///* perform the actual resize */
+//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
+//{
+// short x,y,w,h;
+// struct gui_window * gw;
+//
+// wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
+// gw = (struct gui_window *)data;
+//
+// assert( gw != NULL );
+//
+// if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
+// /* report resize to component interface: */
+// browser_update_rects( gw );
+// tb_adjust_size( gw );
+// if( gw->browser->bw->current_content != NULL ){
+// /* Reformat will happen when next redraw message arrives: */
+// gw->browser->reformat_pending = true;
+// if( sys_XAAES() ){
+// if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
+// ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+// gw->root->loc.g_x, gw->root->loc.g_y,
+// gw->root->loc.g_w, gw->root->loc.g_h );
+// }
+// }
+// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
+// (GRECT*)&gw->root->loc);
+// }
+// else {
+// WindClear( gw->root->handle );
+// }
+// } else {
+// if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
+// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+// browser_update_rects( gw );
+// }
+// }
+//}
diff --git a/atari/rootwin.h b/atari/rootwin.h
new file mode 100755
index 0000000..28001ba
--- /dev/null
+++ b/atari/rootwin.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NS_ATARI_BROWSER_WIN_H
+#define NS_ATARI_BROWSER_WIN_H
+
+#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
+#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
+
+#define WIDGET_STATUSBAR 0x1
+#define WIDGET_TOOLBAR 0x2
+#define WIDGET_SCROLL 0x4
+#define WIDGET_RESIZE 0x8
+
+#define WIN_TOP 0x100
+
+/* WinDom & Custom bindings for gui window */
+
+/* -------------------------------------------------------------------------- */
+/* Public module functions: */
+/* -------------------------------------------------------------------------- */
+
+/* Creates an normal Browser window with [toolbar], [statusbar] */
+int window_create( struct gui_window * gw,
+ struct browser_window * bw, unsigned long flags );
+/* Destroys WinDom part of gui_window */
+int window_destroy( struct gui_window * gw );
+
+/* show the window */
+void window_open( struct gui_window * gw, GRECT pos);
+
+void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
+/* Update Shade / Unshade state of the fwd/back buttons*/
+void window_update_back_forward(struct gui_window * gw);
+/* set root browser component: */
+void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
+
+/* set focus element */
+void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
+/* adjust scroll settings */
+void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
+/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
+bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
+bool window_url_widget_has_focus( struct gui_window * gw );
+void window_set_url( struct gui_window * gw, const char * text);
+void window_set_stauts( struct gui_window * gw , char * text );
+void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
+void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
+
+
+/* -------------------------------------------------------------------------- */
+/* Public event handlers: */
+/* -------------------------------------------------------------------------- */
+
+#endif
diff --git a/atari/search.c b/atari/search.c
index b5e2fdd..4737125 100644
--- a/atari/search.c
+++ b/atari/search.c
@@ -34,7 +34,8 @@
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/browser.h"
-#include "atari/search.h"
+#include "atari/search.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
extern struct gui_window * input_window;
@@ -139,7 +140,7 @@ static void destroy_search_session( SEARCH_FORM_SESSION s )
}
}
-static int apply_form( WINDOW * win, struct s_search_form_state * s )
+static int apply_form(WINDOW * win, struct s_search_form_state * s)
{
OBJECT * obj = ObjcTree(OC_FORM, win );
if( obj == NULL ){
@@ -290,11 +291,12 @@ SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
NULL, title,
&pos, true, false);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_CASESENSE, evnt_cb_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_SHOWALL, evnt_cb_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_FWD, evnt_cb_click, NULL);
- EvntAdd( sfs->formwind, WM_CLOSED, evnt_close, EV_TOP);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click,
+ NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_CASESENSE, evnt_cb_click, NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_SHOWALL, evnt_cb_click, NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_FWD, evnt_cb_click, NULL);
+ EvntAdd(sfs->formwind, WM_CLOSED, evnt_close, EV_TOP);
apply_form(sfs->formwind, &sfs->state );
strncpy( ObjcString( tree, SEARCH_TB_SRCH, NULL ), "", SEARCH_MAX_SLEN);
diff --git a/atari/settings.c b/atari/settings.c
index 8143cdc..ff39903 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,11 +31,12 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-#include "atari/global_evnt.h"
-#include "atari/misc.h"
+#include "atari/deskmenu.h"
+#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
-#include "atari/findfile.h"
+#include "atari/findfile.h"
+#include "atari/gemtk/gemtk.h"
extern char options[PATH_MAX];
@@ -232,7 +233,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- main_menu_update();
+ deskmenu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 08a62c5..c8f8688 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -38,7 +38,7 @@
#include "atari/gui.h"
#include "atari/statusbar.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
@@ -227,7 +227,6 @@ void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw)
void sb_set_text(CMP_STATUSBAR sb, char * text )
{
- LGRECT work;
assert( sb != NULL );
strncpy(sb->text, text, STATUSBAR_MAX_SLEN);
sb->text[STATUSBAR_MAX_SLEN]=0;
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 3594d24..396cccb 100755
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -43,7 +43,7 @@
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/browser.h"
#include "atari/clipboard.h"
#include "atari/misc.h"
@@ -176,8 +176,8 @@ void toolbar_init( void )
} else {
RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- toolbar_buttons->ob_x = 0;
- toolbar_buttons->ob_y = 0;
+ //toolbar_buttons->ob_x = 0;
+ //toolbar_buttons->ob_y = 0;
RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
throbber_form->ob_x = 0;
@@ -279,8 +279,8 @@ static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
tree = &toolbar_buttons[bt->rsc_id];
if( tree == NULL )
return;
- tree->ob_x = work.g_x;
- tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
+ //tree->ob_x = work.g_x;
+ //tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
if( drawstate == button_off ) {
tree->ob_state |= OS_DISABLED;
} else {
diff --git a/atari/treeview.c b/atari/treeview.c
index 4a5cb0a..6e567f5 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -37,7 +37,19 @@
#include "atari/treeview.h"
#include "atari/plot/plot.h"
#include "atari/misc.h"
-#include "cflib.h"
+#include "cflib.h"
+
+/*
+#define TREEVIEW_RECT_WORKAREA 0
+#define TREEVIEW_RECT_TOOLBAR 1
+#define TREEVIEW_RECT_CONTENT 2
+*/
+
+enum treeview_area_e {
+ TREEVIEW_AREA_WORK = 0,
+ TREEVIEW_AREA_TOOLBAR,
+ TREEVIEW_AREA_CONTENT
+};
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
@@ -46,9 +58,11 @@ extern short last_drag_y;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static void atari_treeview_resized(struct tree *tree,int w,int h,void *pw);
+static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
static void atari_treeview_scroll_visible(int y, int h, void *pw);
-static void atari_treeview_get_dimensions(int *width, int *height,void *pw);
+static void atari_treeview_get_dimensions(int *width, int *height, void *pw);
+static void atari_treeview_get_grect(NSTREEVIEW tree,
+ enum treeview_area_e mode, GRECT *dest);
static const struct treeview_table atari_tree_callbacks = {
atari_treeview_request_redraw,
@@ -403,6 +417,24 @@ void atari_treeview_scroll_visible(int y, int height, void *pw)
{
/* we don't support dragging outside the treeview */
/* so we don't need to implement this? */
+}
+
+static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
+ GRECT *dest)
+{
+
+ wind_get_grect(tv->window->handle, WF_WORKXYWH, dest);
+ if (mode == TREEVIEW_AREA_CONTENT) {
+ GRECT tb_grect;
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_grect);
+ dest->g_y += tb_grect.g_h;
+ dest->g_h -= tb_grect.g_h;
+ }
+ else if (mode == TREEVIEW_AREA_TOOLBAR) {
+ // TODO: this requires something like:
+ // guiwin_get_toolbar();
+ dest->g_h = 16;
+ }
}
/**
@@ -418,8 +450,8 @@ void atari_treeview_get_dimensions(int *width, int *height,
{
if (pw != NULL && (width != NULL || height != NULL)) {
NSTREEVIEW tv = (NSTREEVIEW) pw;
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ GRECT work;
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
*width = work.g_w;
*height = work.g_h;
}
-----------------------------------------------------------------------
Summary of changes:
atari/browser.c | 2 +-
atari/ctxmenu.c | 2 +-
atari/{global_evnt.c => deskmenu.c} | 757 ++++++-------
atari/deskmenu.h | 12 +
atari/findfile.c | 1 +
atari/{ => gemtk}/dragdrop.c | 4 +-
atari/gemtk/dragdrop.h | 4 +
atari/gemtk/gemtk.h | 100 ++
atari/gemtk/guiwin.c | 301 +++++
atari/gemtk/guiwin.h | 5 +
atari/{ => gemtk}/msgbox.c | 4 +-
atari/gemtk/msgbox.h | 5 +
atari/gemtk/utils.c | 45 +
atari/gemtk/utils.h | 5 +
atari/global_evnt.c | 536 +---------
atari/global_evnt.h | 23 +-
atari/gui.c | 2178 ++++++++++++++++++-----------------
atari/hotlist.c | 1 +
atari/misc.c | 56 +-
atari/misc.h | 4 +-
atari/osspec.c | 35 +-
atari/osspec.h | 28 +-
atari/redrawslots.c | 2 +-
atari/rootwin.c | 816 +++++++++++++
atari/{browser_win.h => rootwin.h} | 0
atari/search.c | 16 +-
atari/settings.c | 9 +-
atari/statusbar.c | 3 +-
atari/toolbar.c | 10 +-
atari/treeview.c | 42 +-
30 files changed, 2908 insertions(+), 2098 deletions(-)
copy atari/{global_evnt.c => deskmenu.c} (52%)
mode change 100755 => 100644
create mode 100644 atari/deskmenu.h
copy atari/{ => gemtk}/dragdrop.c (99%)
create mode 100755 atari/gemtk/dragdrop.h
create mode 100644 atari/gemtk/gemtk.h
create mode 100644 atari/gemtk/guiwin.c
create mode 100644 atari/gemtk/guiwin.h
copy atari/{ => gemtk}/msgbox.c (95%)
create mode 100644 atari/gemtk/msgbox.h
create mode 100644 atari/gemtk/utils.c
create mode 100644 atari/gemtk/utils.h
create mode 100755 atari/rootwin.c
copy atari/{browser_win.h => rootwin.h} (100%)
diff --git a/atari/browser.c b/atari/browser.c
index 034f89a..1b3661e 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -45,7 +45,7 @@
#include "utils/messages.h"
#include "atari/gui.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 1a1755b..6239f21 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -41,7 +41,7 @@
#include "atari/gui.h"
#include "atari/browser.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/clipboard.h"
#include "desktop/options.h"
diff --git a/atari/global_evnt.c b/atari/deskmenu.c
old mode 100755
new mode 100644
similarity index 52%
copy from atari/global_evnt.c
copy to atari/deskmenu.c
index 3b15af8..d486803
--- a/atari/global_evnt.c
+++ b/atari/deskmenu.c
@@ -1,73 +1,60 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <windom.h>
-
-#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
-#include "utils/log.h"
+#include <stdlib.h>
+#include <windom.h>
+
+#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
-
-#include "atari/gui.h"
-#include "atari/browser_win.h"
-#include "atari/toolbar.h"
-#include "atari/browser.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/gemtk/gemtk.h"
+#include "atari/deskmenu.h"
#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
-#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
+#include "atari/history.h"
+#include "atari/toolbar.h"
+#include "atari/settings.h"
+#include "atari/search.h"
+#include "atari/misc.h"
+#include "atari/gui.h"
#include "atari/findfile.h"
-#include "atari/settings.h"
-#include "cflib.h"
-
-extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
-extern int mouse_click_time[3];
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
-extern bool html_redraw_debug;
+#include "atari/browser.h"
+#include "atari/rootwin.h"
+
+typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
+
+static void register_menu_str(struct s_menu_item_evnt * mi);
+static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
+
+extern void *h_gem_rsrc;
+extern bool html_redraw_debug;
+extern struct gui_window * input_window;
+extern char options[PATH_MAX];
extern const char * option_homepage_url;
extern int option_window_width;
extern int option_window_height;
extern int option_window_x;
extern int option_window_y;
-extern char options[PATH_MAX];
+
+static OBJECT * h_gem_menu;
+
/* Zero based resource tree ids: */
#define T_ABOUT 0
@@ -80,33 +67,184 @@ extern char options[PATH_MAX];
/* Count of the above defines: */
#define NUM_MENU_TITLES 7
-/* Global event handlers: */
-static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
+
+static void __CDECL menu_about(short item, short title, void *data);
+static void __CDECL menu_new_win(short item, short title, void *data);
+static void __CDECL menu_open_url(short item, short title, void *data);
+static void __CDECL menu_open_file(short item, short title, void *data);
+static void __CDECL menu_close_win(short item, short title, void *data);
+static void __CDECL menu_save_page(short item, short title, void *data);
+static void __CDECL menu_quit(short item, short title, void *data);
+static void __CDECL menu_cut(short item, short title, void *data);
+static void __CDECL menu_copy(short item, short title, void *data);
+static void __CDECL menu_paste(short item, short title, void *data);
+static void __CDECL menu_find(short item, short title, void *data);
+static void __CDECL menu_choices(short item, short title, void *data);
+static void __CDECL menu_stop(short item, short title, void *data);
+static void __CDECL menu_reload(short item, short title, void *data);
+static void __CDECL menu_toolbars(short item, short title, void *data);
+static void __CDECL menu_savewin(short item, short title, void *data);
+static void __CDECL menu_debug_render(short item, short title, void *data);
+static void __CDECL menu_fg_images(short item, short title, void *data);
+static void __CDECL menu_bg_images(short item, short title, void *data);
+static void __CDECL menu_back(short item, short title, void *data);
+static void __CDECL menu_forward(short item, short title, void *data);
+static void __CDECL menu_home(short item, short title, void *data);
+static void __CDECL menu_lhistory(short item, short title, void *data);
+static void __CDECL menu_ghistory(short item, short title, void *data);
+static void __CDECL menu_add_bookmark(short item, short title, void *data);
+static void __CDECL menu_bookmarks(short item, short title, void *data);
+static void __CDECL menu_vlog(short item, short title, void *data);
+static void __CDECL menu_help_content(short item, short title, void *data);
+
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
+};
+
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ OBJECT *gem_menu = deskmenu_get_obj_tree();
+
+ assert(gem_menu != NULL);
+
+ char * str = ObjcString( gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+ while (i > 2) {
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+
+ deskmenu_dispatch_item(buff[3], buff[4]);
+}
+
+/*
+ Menu item event handlers:
+*/
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_about(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
char buf[PATH_MAX];
strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ strncat((char*)&buf, (char*)"./doc/README.TXT",
+ PATH_MAX - (strlen("file://")+1) );
browser_window_create((char*)&buf, 0, 0, true, false);
}
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_new_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
browser_window_create(option_homepage_url, 0, 0, true, false);
}
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_url(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -128,7 +266,7 @@ static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
tb_url_input( gw, NK_DEL );
}
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_file(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -145,7 +283,7 @@ static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_close_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -153,7 +291,7 @@ static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
gui_window_destroy( input_window );
}
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_save_page(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
static bool init = true;
@@ -181,49 +319,49 @@ static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_quit(short item, short title, void *data)
{
short buff[8];
memset( &buff, 0, sizeof(short)*8 );
LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
+ netsurf_quit = true;
}
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_cut(short item, short title, void *data)
{
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
}
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_copy(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
}
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_paste(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_PASTE);
}
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_find(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
open_browser_search( input_window );
}
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_choices(short item, short title, void *data)
{
static WINDOW * settings_dlg = NULL;
LOG(("%s", __FUNCTION__));
settings_dlg = open_settings();
}
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -232,7 +370,7 @@ static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_reload(short item, short title, void *data)
{
if( input_window == NULL)
return;
@@ -240,7 +378,7 @@ static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
LOG(("%s", __FUNCTION__));
}
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_toolbars(short item, short title, void *data)
{
static int state = 0;
LOG(("%s", __FUNCTION__));
@@ -250,7 +388,7 @@ static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_savewin(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
@@ -269,12 +407,13 @@ static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_debug_render(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
html_redraw_debug = !html_redraw_debug;
if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ if ( input_window->browser != NULL
+ && input_window->browser->bw != NULL) {
LGRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
@@ -285,19 +424,21 @@ static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *da
}
}
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_fg_images(short item, short title, void *data)
{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
}
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_bg_images(short item, short title, void *data)
{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
}
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_back(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -305,7 +446,7 @@ static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
tb_back_click( input_window );
}
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_forward(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -313,7 +454,7 @@ static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
tb_forward_click( input_window );
}
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_home(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -321,191 +462,168 @@ static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
tb_home_click( input_window );
}
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_lhistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
}
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_ghistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
global_history_open();
}
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- if( input_window ) {
+ if (input_window) {
if( input_window->browser->bw->current_content != NULL ){
atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
NULL
);
}
}
}
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_bookmarks(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
hotlist_open();
}
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_vlog(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
verbose_log = !verbose_log;
MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
}
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_help_content(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
-{
- int i = 0;
- LOG((""));
- netsurf_quit = true;
}
-
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
-{
- struct gui_window * gw = input_window;
- static bool prev_url = false;
- static short prev_x=0;
- static short prev_y=0;
- bool within = false;
- LGRECT urlbox, bwbox, sbbox;
- int nx, ny;
-
- if( gw == NULL)
- return;
+/*
+ Public deskmenu interface:
+*/
- if( prev_x == evnt.mx && prev_y == evnt.my ){
- return;
+
+/**
+* Setup & display an desktop menu.
+*/
+
+void deskmenu_init(void)
+{
+ int i;
+
+ h_gem_menu = get_tree(MAINMENU);
+
+ // TODO: remove that call somehow...
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ /* Update menu string if not null: */
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
+ menu_evnt_tbl[i].menustr);
+ }
+ i++;
}
+ deskmenu_update();
- short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ /* Install menu: */
+ menu_bar(h_gem_menu, MENU_INSTALL);
+ /* Redraw menu: */
+ menu_bar(h_gem_menu, MENU_UPDATE);
+}
- // The window found at x,y is an gui_window
- // and it's the input window.
-
- browser_get_rect( gw, BR_CONTENT, &bwbox );
-
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
- within = true;
- browser_window_mouse_track(
- input_window->browser->bw,
- 0,
- evnt.mx - bwbox.g_x + gw->browser->scroll.current.x,
- evnt.my - bwbox.g_y + gw->browser->scroll.current.y
- );
- }
+/**
+* Uninstall the desktop menu
+*/
+void deskmenu_destroy(void)
+{
+ int i;
- if( gw->root->toolbar && within == false ) {
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
- (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
- gem_set_cursor( &gem_cursors.ibeam );
- prev_url = true;
- } else {
- if( prev_url ) {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
- }
- }
- }
- } else {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
+ /* Remove menu from desktop: */
+ menu_bar(h_gem_menu, MENU_REMOVE);
+
+ /* Free modified menu titles: */
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
}
+}
- prev_x = evnt.mx;
- prev_y = evnt.my;
-}
-
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
-{
- char sascii;
- long kstate = 0;
- long kcode = 0;
- unsigned short nkc = 0;
- unsigned short nks = 0;
-
- int i=0;
- bool done = false;
- struct gui_window * gw = input_window;
- struct gui_window * gw_tmp;
- if( gw == NULL )
- return;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
- nkc= gem_to_norm( (short)kstate, (short)kcode );
- nks = (nkc & 0xFF00);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
- /* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
- } else {
- gw_tmp = window_list;
- /* search for active browser component: */
- while( gw_tmp != NULL && done == false ) {
- /* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
- break;
- } else {
- gw_tmp = gw_tmp->next;
+/**
+* Return the deskmenu AES OBJECT tree
+*/
+OBJECT * deskmenu_get_obj_tree(void)
+{
+ return(h_gem_menu);
+}
+
+/**
+* Handle an menu item event
+*/
+int deskmenu_dispatch_item(short title, short item)
+{
+ int i=0;
+ int retval = 0;
+ OBJECT * menu_root = deskmenu_get_obj_tree();
+
+ menu_tnormal(menu_root, item, 1);
+ menu_tnormal(menu_root, title, 1);
+ menu_bar(menu_root, 1);
+
+ // legacy code, is this sensible?:
+ /*
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ */
+
+
+ while (menu_evnt_tbl[i].rid != -1) {
+ if (menu_evnt_tbl[i].rid == item) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func(item, title, NULL);
}
+ break;
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ i++;
+ }
+
+ return(retval);
+}
+
+/**
+* Handle an keypress (check for accelerator)
+*/
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ char sascii;
+ bool done = 0;
+ int i = 0;
+
+ sascii = keybd2ascii(kcode, K_LSHIFT);
+
+ /* Iterate through the menu function table: */
while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ if( kstate == menu_evnt_tbl[i].accel.mod
+ && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
@@ -513,165 +631,30 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
/* the accel code hides in the keycode: */
if( menu_evnt_tbl[i].accel.keycode != 0) {
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
+ kstate == menu_evnt_tbl[i].accel.mod) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
}
}
i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
+ }
+ return((done==true) ? 1 : 0);
+}
+/**
+* Refresh the desk menu, reflecting netsurf current state.
*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
+void deskmenu_update(void)
{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
+ OBJECT * gem_menu = deskmenu_get_obj_tree();
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-
-/* Bind global and menu events to event handler functions, create accelerators */
-void bind_global_events( void )
-{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
- memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
- EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
- EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+ menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
-}
-
-void unbind_global_events( void )
-{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
new file mode 100644
index 0000000..6ab00dc
--- /dev/null
+++ b/atari/deskmenu.h
@@ -0,0 +1,12 @@
+#ifndef DESKMENU_H_INCLUDED
+#define DESKMENU_H_INCLUDED
+
+void deskmenu_init(void);
+void deskmenu_destroy(void);
+int deskmenu_dispatch_item(short title, short item);
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
+OBJECT * deskmenu_get_obj_tree(void);
+void deskmenu_update( void );
+
+#endif // DESKMENU_H_INCLUDED
diff --git a/atari/findfile.c b/atari/findfile.c
index 93bf463..00502c9 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -28,6 +28,7 @@
#include "utils/log.h"
#include "utils/url.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/findfile.h"
#include "atari/gui.h"
#include "atari/misc.h"
diff --git a/atari/dragdrop.c b/atari/gemtk/dragdrop.c
similarity index 99%
copy from atari/dragdrop.c
copy to atari/gemtk/dragdrop.c
index bc7f565..d9fd9c7 100755
--- a/atari/dragdrop.c
+++ b/atari/gemtk/dragdrop.c
@@ -18,8 +18,8 @@
#include <string.h>
#include <stdio.h>
-#include "windom.h"
-#include "dragdrop.h"
+//#include "windom.h"
+#include "gemtk.h"
#include "cflib.h"
#ifndef EACCDN
diff --git a/atari/gemtk/dragdrop.h b/atari/gemtk/dragdrop.h
new file mode 100755
index 0000000..3846613
--- /dev/null
+++ b/atari/gemtk/dragdrop.h
@@ -0,0 +1,4 @@
+#ifndef DD_H_INCLUDED
+#define DD_H_INCLUDED
+
+#endif
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
new file mode 100644
index 0000000..fe59209
--- /dev/null
+++ b/atari/gemtk/gemtk.h
@@ -0,0 +1,100 @@
+#ifndef GEMTK_H_INCLUDED
+#define GEMTK_H_INCLUDED
+
+#include <gem.h>
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+#include <stdint.h>
+
+/* System type detection added by [GS] */
+/* detect the system type, AES + kernel */
+#define SYS_TOS 0x0001
+#define SYS_MAGIC 0x0002
+#define SYS_MINT 0x0004
+#define SYS_GENEVA 0x0010
+#define SYS_NAES 0x0020
+#define SYS_XAAES 0x0040
+#define sys_type() (_systype_v ? _systype_v : _systype())
+#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
+#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
+#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
+
+#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
+
+extern unsigned short _systype_v;
+
+/*
+ Utils
+*/
+unsigned short _systype (void);
+OBJECT *get_tree( int idx );
+
+/*
+* MultiTOS Drag&Drop
+*/
+short ddcreate(short *pipe);
+short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
+short ddrexts(short fd, char *exts);
+short ddstry(short fd, char *ext, char *text, char *name, long size);
+void ddclose(short fd);
+void ddgetsig(long *oldsig);
+void ddsetsig(long oldsig);
+short ddopen(short ddnam, char ddmsg);
+short ddsexts(short fd, char *exts);
+short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
+short ddreply(short fd, char ack);
+
+/*
+ Message box
+*/
+#define MSG_BOX_ALERT 1
+#define MSG_BOX_CONFIRM 2
+
+short msg_box_show(short type, const char * msg);
+
+/*
+ Guiwin
+*/
+#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events
+#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
+#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
+
+#define GW_STATUS_ICONIFIED 0x01
+#define GW_STATUS_SHADED 0x02
+
+struct gui_window_s;
+typedef struct gui_window_s GUIWIN;
+
+typedef short (*guiwin_event_handler_f)(GUIWIN *gw,
+ EVMULT_OUT *ev_out, short msg[8]);
+enum guwin_area_e {
+ GUIWIN_AREA_WORK = 0,
+ GUIWIN_AREA_TOOLBAR,
+ GUIWIN_AREA_CONTENT
+};
+
+GUIWIN * guiwin_add(short handle, uint32_t flags,
+ guiwin_event_handler_f handler);
+GUIWIN *guiwin_find(short handle);
+short guiwin_remove(GUIWIN *win);
+GUIWIN *guiwin_validate_ptr(GUIWIN *win);
+//short guiwin_set_event_handler(guiwin_event_handler_f);
+short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out,
+ short msg[8]);
+void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest);
+short guiwin_get_handle(GUIWIN *win);
+uint32_t guiwin_get_state(GUIWIN *win);
+void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
+ uint32_t flags);
+
+/*
+* AES Scroller Object
+*/
+
+#ifndef POINT_WITHIN
+#define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \
+ && (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
+#endif
+
+
+#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
new file mode 100644
index 0000000..6d525c6
--- /dev/null
+++ b/atari/gemtk/guiwin.c
@@ -0,0 +1,301 @@
+//#include "global.h"
+
+#include <stdint.h>
+#include <assert.h>
+#include <cflib.h>
+
+#include <mt_gem.h>
+#include "gemtk.h"
+
+//#define DEBUG_PRINT(x) printf x
+#define DEBUG_PRINT(x)
+
+struct gui_window_s {
+ short handle;
+ guiwin_event_handler_f handler_func;
+ uint32_t flags;
+ uint32_t state;
+ OBJECT * toolbar;
+ short toolbar_idx;
+ struct gui_window_s *next, *prev;
+};
+
+static GUIWIN * winlist;
+
+static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
+{
+ GRECT g, tb_area, tb_area_ro;
+ short retval = 1;
+
+ switch(msg[0]) {
+
+ case WM_TOPPED:
+ wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
+ break;
+
+ case WM_MOVED:
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h);
+ break;
+
+ case WM_SIZED:
+ case WM_REPOSED:
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ break;
+
+ case WM_FULLED:
+ wind_get_grect(0, WF_WORKXYWH, &g);
+ wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ break;
+
+ case WM_ICONIFY:
+ wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state |= GW_STATUS_ICONIFIED;
+ break;
+
+ case WM_UNICONIFY:
+ wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state &= ~(GW_STATUS_ICONIFIED);
+ break;
+
+ case WM_SHADED:
+ gw->state |= GW_STATUS_SHADED;
+ break;
+
+ case WM_UNSHADED:
+ gw->state &= ~(GW_STATUS_SHADED);
+ break;
+
+ case WM_REDRAW:
+ guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
+ tb_area = tb_area_ro;
+ if(rc_intersect((GRECT*)&msg[4], &tb_area)){
+ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+ wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
+ }
+ }
+ break;
+
+ default:
+ retval = 0;
+ break;
+ }
+ return(retval);
+}
+
+short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
+{
+ GUIWIN *dest;
+ short retval = 0;
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0]));
+ switch (msg[0]) {
+ case WM_REDRAW:
+ case WM_CLOSED:
+ case WM_TOPPED:
+ case WM_ARROWED:
+ case WM_HSLID:
+ case WM_VSLID:
+ case WM_FULLED:
+ case WM_SIZED:
+ case WM_REPOSED:
+ case WM_MOVED:
+ case WM_NEWTOP:
+ case WM_UNTOPPED:
+ case WM_ONTOP:
+ case WM_BOTTOM:
+ case WM_ICONIFY:
+ case WM_UNICONIFY:
+ case WM_ALLICONIFY:
+ case WM_TOOLBAR:
+ case AP_DRAGDROP:
+ case AP_TERM:
+ case AP_TFAIL:
+ dest = guiwin_find(msg[3]);
+ if (dest) {
+ DEBUG_PRINT(("Found WM_ dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ if (dest->flags&GW_FLAG_PREPROC_WM) {
+ retval = preproc_wm(dest, ev_out, msg);
+ if(((retval == 0)||(dest->flags&GW_FLAG_RECV_PREPROC_WM))) {
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ }
+ else {
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ }
+
+ }
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0){
+ short info[4];
+
+ wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
+ if(info[0] != 0 && info[1] == gl_apid){
+ dest = guiwin_find(info[0]);
+ if (dest) {
+ DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ if(dest->toolbar != NULL && dest->handler_func != NULL){
+ GRECT tb_area;
+ guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, tb_area)) {
+ // send WM_TOOLBAR message
+ short obj_idx = 0;
+ short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
+ obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
+ short oldevents = ev_out->emo_events;
+ ev_out->emo_events = MU_MESAG;
+ dest->handler_func(dest, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ }
+ }
+ /*
+ if (dest->flags&GW_FLAG_PREPROC_WM) {
+ preproc_wm(dest, ev_in, ev_out, msg);
+ }
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_in, ev_out, msg);
+ }
+ */
+ }
+ }
+ }
+ return(retval);
+}
+
+GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
+{
+ GUIWIN *win = malloc(sizeof(GUIWIN));
+
+ assert(win!=NULL);
+ DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
+
+ win->handle = handle;
+ win->handler_func = cb;
+ win->flags = flags;
+ if (winlist == NULL) {
+ winlist = win;
+ win->next = NULL;
+ win->prev = NULL;
+ } else {
+ GUIWIN *tmp = winlist;
+ while( tmp->next != NULL ) {
+ tmp = tmp->next;
+ }
+ tmp->next = win;
+ win->prev = tmp;
+ win->next = NULL;
+ }
+ return(win);
+}
+
+GUIWIN *guiwin_find(short handle)
+{
+ GUIWIN *g;
+ DEBUG_PRINT(("guiwin_find: handle: %d\n", handle));
+ for( g = winlist; g != NULL; g=g->next ) {
+ DEBUG_PRINT(("guiwin search: %d\n", g->handle));
+ if(g->handle == handle) {
+ DEBUG_PRINT(("guiwin_find: %p\n", g));
+ return(g);
+ }
+ }
+ return(NULL);
+}
+
+GUIWIN *guiwin_validate_ptr(GUIWIN *win)
+{
+ GUIWIN *g;
+ for( g = winlist; g != NULL; g=g->next ) {
+ DEBUG_PRINT(("guiwin guiwin_validate_ptr check: %p\n", g));
+ if(g == win) {
+ DEBUG_PRINT(("guiwin_validate_ptr valid: %p\n", g));
+ return(g);
+ }
+ }
+ return(NULL);
+}
+
+short guiwin_remove(GUIWIN *win)
+{
+ win = guiwin_validate_ptr(win);
+ if (win == NULL)
+ return(-1);
+
+ /* unlink the window: */
+ if(win->prev != NULL ) {
+ win->prev->next = win->next;
+ } else {
+ winlist = win->next;
+ }
+ if (win->next != NULL) {
+ win->next->prev = win->prev;
+ }
+
+ free(win);
+ return(0);
+}
+
+void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
+{
+ wind_get_grect(win->handle, WF_WORKXYWH, dest);
+ if (mode == GUIWIN_AREA_CONTENT) {
+ GRECT tb_area;
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_x += tb_area.g_w;
+ dest->g_w -= tb_area.g_w;
+ } else {
+ dest->g_y += tb_area.g_h;
+ dest->g_w -= tb_area.g_h;
+ }
+ dbg_grect("guiwin_get_grect content", dest);
+ }
+ else if (mode == GUIWIN_AREA_TOOLBAR) {
+ if (win->toolbar != NULL) {
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
+ } else {
+ dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
+ }
+ } else {
+ dest->g_h = 0;
+ dest->g_w = 0;
+ }
+ dbg_grect("guiwin_get_grect toolbar", dest);
+ }
+}
+
+short guiwin_get_handle(GUIWIN *win)
+{
+ return(win->handle);
+}
+
+uint32_t guiwin_get_state(GUIWIN *win)
+{
+ return(win->state);
+}
+
+void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags)
+{
+ win->toolbar = toolbar;
+ win->toolbar_idx = idx;
+ if(flags & GW_FLAG_HAS_VTOOLBAR){
+ win->flags |= GW_FLAG_HAS_VTOOLBAR;
+ }
+}
+
+
+
diff --git a/atari/gemtk/guiwin.h b/atari/gemtk/guiwin.h
new file mode 100644
index 0000000..dba112c
--- /dev/null
+++ b/atari/gemtk/guiwin.h
@@ -0,0 +1,5 @@
+#ifndef OPKG_GUI_GUIWIN_H
+#define OPKG_GUI_GUIWIN_H
+
+
+#endif /* OPKG_GUIWIN_H */
diff --git a/atari/msgbox.c b/atari/gemtk/msgbox.c
similarity index 95%
copy from atari/msgbox.c
copy to atari/gemtk/msgbox.c
index a9de5d2..770e0af 100644
--- a/atari/msgbox.c
+++ b/atari/gemtk/msgbox.c
@@ -2,13 +2,13 @@
#include <stdlib.h>
#include <string.h>
#include <gem.h>
-#include "atari/msgbox.h"
+#include "gemtk.h"
#ifndef min
# define min(x,y) ((x<y) ? x : y )
#endif
-short msg_box_show(short type, char * msg)
+short msg_box_show(short type, const char * msg)
{
#define MSG_BOX_STR_SIZE 256
short retval=0, i=0, z=0, l=0;
diff --git a/atari/gemtk/msgbox.h b/atari/gemtk/msgbox.h
new file mode 100644
index 0000000..7a46900
--- /dev/null
+++ b/atari/gemtk/msgbox.h
@@ -0,0 +1,5 @@
+#ifndef GUIMSG_H_INCLUDED
+#define GUIMSG_H_INCLUDED
+
+
+#endif // GUIMSG_H_INCLUDED
diff --git a/atari/gemtk/utils.c b/atari/gemtk/utils.c
new file mode 100644
index 0000000..4a24d82
--- /dev/null
+++ b/atari/gemtk/utils.c
@@ -0,0 +1,45 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include <gem.h>
+#include "gemtk.h"
+
+/* -------------------------------------------------------------------------- */
+/* GEM Utillity functions: */
+/* -------------------------------------------------------------------------- */
+
+unsigned short _systype_v;
+unsigned short _systype (void)
+{
+ int32_t * cptr = NULL;
+ _systype_v = SYS_TOS;
+
+ cptr = (int32_t *)Setexc(0x0168, -1L);
+ if (cptr == NULL ) {
+ return _systype_v; /* stone old TOS without any cookie support */
+ }
+ while (*cptr) {
+ if (*cptr == C_MgMc || *cptr == C_MgMx ) {
+ _systype_v = (_systype_v & ~0xF) | SYS_MAGIC;
+ } else if (*cptr == C_MiNT ) {
+ _systype_v = (_systype_v & ~0xF) | SYS_MINT;
+ } else if (*cptr == C_Gnva /* Gnva */ ) {
+ _systype_v |= SYS_GENEVA;
+ } else if (*cptr == C_nAES /* nAES */ ) {
+ _systype_v |= SYS_NAES;
+ }
+ cptr += 2;
+ }
+ if (_systype_v & SYS_MINT) { /* check for XaAES */
+ short out = 0, u;
+ if (wind_get (0, (((short)'X') <<8)|'A', &out, &u,&u,&u) && out) {
+ _systype_v |= SYS_XAAES;
+ }
+ }
+ return _systype_v;
+}
+
+OBJECT *get_tree( int idx) {
+ OBJECT *tree;
+ rsrc_gaddr(R_TREE, idx, &tree);
+ return tree;
+}
diff --git a/atari/gemtk/utils.h b/atari/gemtk/utils.h
new file mode 100644
index 0000000..7ebbcf2
--- /dev/null
+++ b/atari/gemtk/utils.h
@@ -0,0 +1,5 @@
+#ifndef UTILS_H_INCLUDED
+#define UTILS_H_INCLUDED
+
+
+#endif // UTILS_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 3b15af8..40b8859 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,379 +26,31 @@
#include <windom.h>
#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "atari/misc.h"
#include "atari/gui.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
-#include "atari/findfile.h"
-#include "atari/settings.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
-extern bool html_redraw_debug;
-
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-extern char options[PATH_MAX];
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
-}
-
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window ) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
+void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
{
int i = 0;
LOG((""));
@@ -406,7 +58,7 @@ void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
}
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
+static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -416,23 +68,23 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if( gw == NULL)
+ if (gw == NULL)
return;
- if( prev_x == evnt.mx && prev_y == evnt.my ){
+ if (prev_x == evnt.mx && prev_y == evnt.my) {
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ if (input_window->root->handle->handle == ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -442,7 +94,7 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
);
}
- if( gw->root->toolbar && within == false ) {
+ if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -466,7 +118,6 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -500,178 +151,23 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
- }
- }
- i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
-
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
}
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
-
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
}
void unbind_global_events( void )
{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
+
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1e13264..76e73fc 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,6 +18,8 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
+
+#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -32,31 +34,14 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
+struct s_evnt_data evnt_data;
/*
- Global & Menu event handlers
+ Global event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
-void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index c2158e0..4f7a97b 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1,1041 +1,1143 @@
-/*
- * Copyright 2010 <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- /*
- This File provides all the mandatory functions prefixed with gui_
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <time.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <windom.h>
-#include <hubbub/hubbub.h>
-
-#include "content/urldb.h"
-#include "content/fetch.h"
-#include "content/fetchers/resource.h"
-#include "css/utils.h"
-#include "desktop/gui.h"
-#include "desktop/history_core.h"
-#include "desktop/plotters.h"
-#include "desktop/netsurf.h"
-#include "desktop/401login.h"
-
-#include "desktop/options.h"
-#include "desktop/save_complete.h"
-#include "desktop/selection.h"
-#include "desktop/textinput.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "render/font.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
-#include "atari/gui.h"
-#include "atari/misc.h"
-#include "atari/findfile.h"
-#include "atari/schedule.h"
-#include "atari/browser_win.h"
-#include "atari/browser.h"
-#include "atari/statusbar.h"
-#include "atari/toolbar.h"
-#include "atari/verify_ssl.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/login.h"
-#include "atari/global_evnt.h"
-#include "atari/encoding.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/plot/plot.h"
-#include "atari/clipboard.h"
-#include "atari/osspec.h"
-#include "atari/search.h"
-#include "cflib.h"
-
-#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
-
-char *tmp_clipboard;
-struct gui_window *input_window = NULL;
-struct gui_window *window_list = NULL;
-void * h_gem_rsrc;
-OBJECT * h_gem_menu;
-OBJECT **rsc_trindex;
-short rsc_ntree;
-long next_poll;
-bool rendering = false;
-
-
-/* Comandline / Options: */
-int option_window_width;
-int option_window_height;
-int option_window_x;
-int option_window_y;
-
-/* Defaults to option_homepage_url, commandline options overwrites that value */
-const char * option_homepage_url;
-
-/* path to choices file: */
-char options[PATH_MAX];
-
-
-void gui_poll(bool active)
-{
- short winloc[4];
- // int timeout; /* timeout in milliseconds */
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
- short mx, my, dummy;
-
- evnt.timer = schedule_run();
-
- if( active || rendering ) {
- if( clock() >= next_poll ) {
- evnt.timer = 0;
- flags |= MU_TIMER;
- EvntWindom( flags );
- next_poll = clock() + (CLOCKS_PER_SEC>>3);
- }
- } else {
- if (input_window != NULL) {
- wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
- if (winloc[1] == _AESapid) {
- /* only check for mouse move when netsurf is on top: */
- // move that into m1 event handler
- graf_mkstate( &mx, &my, &dummy, &dummy );
- flags |= MU_M1;
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = evnt.m1_h = 1;
- evnt.m1_x = mx;
- evnt.m1_y = my;
- }
- }
- flags |= MU_TIMER;
- EvntWindom( flags );
- }
-
- struct gui_window * g;
- for( g = window_list; g != NULL; g=g->next ) {
- if( browser_redraw_required( g ) ){
- browser_redraw( g );
- }
- if( g->root->toolbar ){
- if(g->root->toolbar->url.redraw ){
- tb_url_redraw( g );
- }
- }
- }
- if( evnt.timer != 0 && !active ){
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
-}
-
-struct gui_window *
-gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
-{
- struct gui_window *gw=NULL;
- LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
- (int)new_tab
- ));
-
- gw = malloc( sizeof(struct gui_window) );
- if (gw == NULL)
- return NULL;
- memset( gw, 0, sizeof(struct gui_window) );
-
- LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
- if( gw->root->handle ) {
- GRECT pos = {
- option_window_x, option_window_y,
- option_window_width, option_window_height
- };
- window_open( gw , pos );
- /* Recalculate windows browser area now */
- browser_update_rects( gw );
- tb_update_buttons( gw, -1 );
- input_window = gw;
- /* TODO:... this line: placeholder to create a local history widget ... */
- }
-
- /* add the window to the window list: */
- if( window_list == NULL ) {
- window_list = gw;
- gw->next = NULL;
- gw->prev = NULL;
- } else {
- struct gui_window * tmp = window_list;
- while( tmp->next != NULL ) {
- tmp = tmp->next;
- }
- tmp->next = gw;
- gw->prev = tmp;
- gw->next = NULL;
- }
-
- return( gw );
-
-}
-
-void gui_window_destroy(struct gui_window *w)
+/*
+ * Copyright 2010 <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ This File provides all the mandatory functions prefixed with gui_
+*/
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <windom.h>
+#include <hubbub/hubbub.h>
+
+#include "content/urldb.h"
+#include "content/fetch.h"
+#include "content/fetchers/resource.h"
+#include "css/utils.h"
+#include "desktop/gui.h"
+#include "desktop/history_core.h"
+#include "desktop/plotters.h"
+#include "desktop/netsurf.h"
+#include "desktop/401login.h"
+
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+#include "desktop/selection.h"
+#include "desktop/textinput.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "render/font.h"
+#include "utils/schedule.h"
+#include "utils/url.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+#include "atari/gemtk/gemtk.h"
+#include "atari/gui.h"
+#include "atari/misc.h"
+#include "atari/findfile.h"
+#include "atari/schedule.h"
+#include "atari/rootwin.h"
+#include "atari/browser.h"
+#include "atari/statusbar.h"
+#include "atari/toolbar.h"
+#include "atari/verify_ssl.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/login.h"
+#include "atari/global_evnt.h"
+#include "atari/encoding.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/plot/plot.h"
+#include "atari/clipboard.h"
+#include "atari/osspec.h"
+#include "atari/search.h"
+#include "atari/deskmenu.h"
+#include "cflib.h"
+
+#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
+
+char *tmp_clipboard;
+struct gui_window *input_window = NULL;
+struct gui_window *window_list = NULL;
+void * h_gem_rsrc;
+long next_poll;
+bool rendering = false;
+
+
+/* Comandline / Options: */
+int option_window_width;
+int option_window_height;
+int option_window_x;
+int option_window_y;
+
+/* Defaults to option_homepage_url, commandline options overwrites that value */
+const char * option_homepage_url;
+
+/* path to choices file: */
+char options[PATH_MAX];
+
+EVMULT_IN aes_event_in = {
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+};
+EVMULT_OUT aes_event_out;
+short aes_msg_out[8];
+
+
+void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- if (w == NULL)
+ long kstate = 0;
+ long kcode = 0;
+ unsigned short nkc = 0;
+ unsigned short nks = 0;
+
+ int i=0;
+ bool done = false;
+ struct gui_window * gw = input_window;
+ struct gui_window * gw_tmp;
+ if( gw == NULL )
return;
-
- LOG(("%s\n", __FUNCTION__ ));
-
- input_window = NULL;
-
- window_destroy( w );
-
- /* unlink the window: */
- if(w->prev != NULL ) {
- w->prev->next = w->next;
- } else {
- window_list = w->next;
- }
- if( w->next != NULL ) {
- w->next->prev = w->prev;
- }
- free(w);
- w = NULL;
-
- w = window_list;
- while( w != NULL ) {
- if( w->root ) {
- input_window = w;
- break;
- }
- w = w->next;
- }
-}
-
-void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
- bool scaled)
-{
- if (w == NULL)
- return;
- LGRECT rect;
- browser_get_rect( w, BR_CONTENT, &rect );
- *width = rect.g_w;
- *height = rect.g_h;
-}
-
-void gui_window_set_title(struct gui_window *gw, const char *title)
-{
- int l;
- char * conv;
-
- if (gw == NULL)
- return;
- if( gw->root ){
- l = strlen(title);
- if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ){
- strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
- free( conv );
- } else {
- strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
- }
- gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
- WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
- }
-}
-
-/**
- * set the status bar message
- */
-void gui_window_set_status(struct gui_window *w, const char *text)
-{
- if (w == NULL || text == NULL )
- return;
- window_set_stauts( w , (char*)text );
-}
-
-void gui_window_redraw_window(struct gui_window *gw)
-{
- CMP_BROWSER b;
- LGRECT rect;
- if (gw == NULL)
- return;
- b = gw->browser;
- browser_get_rect( gw, BR_CONTENT, &rect );
- browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
-}
-
-void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
-{
- CMP_BROWSER b;
- if (gw == NULL)
- return;
- b = gw->browser;
- int x0 = rect->x0 - b->scroll.current.x;
- int y0 = rect->y0 - b->scroll.current.y;
- int w,h;
- w = rect->x1 - rect->x0;
- h = rect->y1 - rect->y0;
- browser_schedule_redraw_rect( gw, x0, y0, w, h );
-}
-
-bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
-{
- if (w == NULL)
- return false;
- *sx = w->browser->scroll.current.x;
- *sy = w->browser->scroll.current.y;
- return( true );
-}
-
-void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
-{
- if ((w == NULL) ||
- (w->browser->bw == NULL) ||
- (w->browser->bw->current_content == NULL))
- return;
- if( sx != 0 ) {
- if( sx < 0 ) {
- browser_scroll(w, WA_LFLINE, abs(sx), true );
- } else {
- browser_scroll(w, WA_RTLINE, abs(sx), true );
- }
- }
-
- if( sy != 0 ) {
- if( sy < 0) {
- browser_scroll(w, WA_UPLINE, abs(sy), true );
- } else {
- browser_scroll(w, WA_DNLINE, abs(sy), true );
- }
- }
- return;
-
-}
-
-void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
-{
- LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
- gui_window_set_scroll(w,x0,y0);
- browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
-}
-
-
-/* It seems this method is called when content size got adjusted,
- so that we can adjust scroll info. We also have to call it when tab
- change occurs.
-*/
-void gui_window_update_extent(struct gui_window *gw)
-{
- int oldx, oldy;
- oldx = gw->browser->scroll.current.x;
- oldy = gw->browser->scroll.current.y;
- if( gw->browser->bw->current_content != NULL ) {
- browser_set_content_size( gw,
- content_get_width(gw->browser->bw->current_content),
- content_get_height(gw->browser->bw->current_content)
- );
- }
-}
-
-
-void gui_clear_selection(struct gui_window *g)
-{
-
-}
-
-
-
-/**
- * set the pointer shape
- */
-void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
-{
- if (w == NULL)
- return;
- switch (shape) {
- case GUI_POINTER_POINT: /* link */
- gem_set_cursor(&gem_cursors.hand);
- break;
-
- case GUI_POINTER_MENU:
- gem_set_cursor(&gem_cursors.menu);
- break;
-
- case GUI_POINTER_CARET: /* input */
- gem_set_cursor(&gem_cursors.ibeam);
- break;
-
- case GUI_POINTER_CROSS:
- gem_set_cursor(&gem_cursors.cross);
- break;
-
- case GUI_POINTER_MOVE:
- gem_set_cursor(&gem_cursors.sizeall);
- break;
-
- case GUI_POINTER_RIGHT:
- case GUI_POINTER_LEFT:
- gem_set_cursor(&gem_cursors.sizewe);
- break;
-
- case GUI_POINTER_UP:
- case GUI_POINTER_DOWN:
- gem_set_cursor(&gem_cursors.sizens);
- break;
-
- case GUI_POINTER_RU:
- case GUI_POINTER_LD:
- gem_set_cursor(&gem_cursors.sizenesw);
- break;
-
- case GUI_POINTER_RD:
- case GUI_POINTER_LU:
- gem_set_cursor(&gem_cursors.sizenwse);
- break;
-
- case GUI_POINTER_WAIT:
- gem_set_cursor(&gem_cursors.wait);
- break;
-
- case GUI_POINTER_PROGRESS:
- gem_set_cursor(&gem_cursors.appstarting);
- break;
-
- case GUI_POINTER_NO_DROP:
- gem_set_cursor(&gem_cursors.nodrop);
- break;
-
- case GUI_POINTER_NOT_ALLOWED:
- gem_set_cursor(&gem_cursors.deny);
- break;
-
- case GUI_POINTER_HELP:
- gem_set_cursor(&gem_cursors.help);
- break;
-
- default:
- gem_set_cursor(&gem_cursors.arrow);
- break;
- }
-}
-
-void gui_window_hide_pointer(struct gui_window *w)
-{
- TODO();
-}
-
-
-void gui_window_set_url(struct gui_window *w, const char *url)
-{
- if (w == NULL)
- return;
- tb_url_set(w, (char*)url );
-}
-
-static void throbber_advance( void * data )
-{
- LGRECT work;
- struct gui_window * gw = (struct gui_window *)data;
- if( gw->root == NULL )
- return;
- if( gw->root->toolbar == NULL )
- return;
- if( gw->root->toolbar->throbber.running == false )
- return;
- mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- gw->root->toolbar->throbber.index++;
- if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
- gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
- schedule(100, throbber_advance, gw );
-}
-
-void gui_window_start_throbber(struct gui_window *w)
-{
- LGRECT work;
- if (w == NULL)
- return;
- if( w->root->toolbar->throbber.running == true )
- return;
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = true;
- w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- schedule(100, throbber_advance, w );
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-
- rendering = true;
-}
-
-void gui_window_stop_throbber(struct gui_window *w)
-{
- LGRECT work;
- if (w == NULL)
- return;
- if( w->root->toolbar->throbber.running == false )
- return;
-
- schedule_remove(throbber_advance, w);
-
- /* refresh toolbar buttons: */
- tb_update_buttons( w, -1 );
-
- /* redraw throbber: */
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = false;
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-
- rendering = false;
-}
-
-/* Place caret in window */
-void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
-{
- if (w == NULL)
- return;
- if( w->browser->caret.current.g_w > 0 )
- gui_window_remove_caret( w );
- w->browser->caret.requested.g_x = x;
- w->browser->caret.requested.g_y = y;
- w->browser->caret.requested.g_w = 1;
- w->browser->caret.requested.g_h = height;
- w->browser->caret.redraw = true;
- return;
-}
-
-
-/**
- * clear window caret
- */
-void
-gui_window_remove_caret(struct gui_window *w)
-{
- if (w == NULL)
- return;
-
- if( w->browser->caret.background.fd_addr != NULL ){
- browser_restore_caret_background( w, NULL );
- w->browser->caret.requested.g_w = 0;
- w->browser->caret.current.g_w = 0;
- }
- return;
-}
-
-void
-gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
-{
- struct bitmap *bmp_icon;
-
- bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
-
- window_set_icon(g, bmp_icon);
-}
-
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
- TODO();
-}
-
-void gui_window_new_content(struct gui_window *w)
-{
- w->browser->scroll.current.x = 0;
- w->browser->scroll.current.y = 0;
- w->browser->scroll.requested.x = 0;
- w->browser->scroll.requested.y = 0;
- w->browser->scroll.required = true;
- gui_window_redraw_window( w );
-}
-
-bool gui_window_scroll_start(struct gui_window *w)
-{
- TODO();
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- TODO();
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- LOG(("%s -> %s", title, url ));
- TODO();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_drag_save_selection(struct selection *s, struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_start_selection(struct gui_window *w)
-{
- gui_empty_clipboard();
-}
-
-void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
-{
- char * clip = scrap_txt_read( &app );
- if( clip == NULL )
- return;
- int clip_length = strlen( clip );
- if (clip_length > 0) {
- char *utf8;
- utf8_convert_ret ret;
- /* Clipboard is in local encoding so
- * convert to UTF8 */
- ret = utf8_from_local_encoding(clip,
- clip_length, &utf8);
- if (ret == UTF8_CONVERT_OK) {
- browser_window_paste_text(w->browser->bw, utf8,
- strlen(utf8), true);
- free(utf8);
- }
- free( clip );
- }
-}
-
-bool gui_empty_clipboard(void)
-{
- if( tmp_clipboard != NULL ){
- free( tmp_clipboard );
- tmp_clipboard = NULL;
- }
- return true;
-}
-
-bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space,
- const plot_font_style_t *fstyle)
-{
- LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
- char * oldptr = tmp_clipboard;
- size_t oldlen = 0;
- size_t newlen = 0;
- char * text = NULL;
- char * text2 = NULL;
- bool retval;
- int length = 0;
- if( length_utf8 > 0 && text_utf8 != NULL ) {
- utf8_to_local_encoding(text_utf8,length_utf8,&text);
- if( text == NULL ) {
- LOG(("Conversion failed (%s)", text_utf8));
- goto error;
- } else {
- text2 = text;
- }
- } else {
- if( space == false ) {
- goto success;
- }
- text = malloc(length + 2);
- if( text == NULL ) {
- goto error;
- }
- text2 = text;
- text[length+1] = 0;
- memset(text, ' ', length+1);
- }
- length = strlen(text);
- if( tmp_clipboard != NULL ) {
- oldlen = strlen( tmp_clipboard );
- }
- newlen = oldlen + length + 1;
- if( tmp_clipboard == NULL){
- tmp_clipboard = malloc(newlen);
- if( tmp_clipboard == NULL ) {
- goto error;
- }
- strncpy(tmp_clipboard, text, newlen);
- } else {
- tmp_clipboard = realloc( tmp_clipboard, newlen);
- if( tmp_clipboard == NULL ) {
- goto error;
- }
- strncpy(tmp_clipboard, oldptr, newlen);
- strncat(tmp_clipboard, text, newlen-oldlen);
- }
- goto success;
-
-error:
- retval = false;
- goto fin;
-
-success:
- retval = true;
-
-fin:
- if( text2 != NULL )
- free( text2 );
- return(retval);
-
-}
-
-bool gui_commit_clipboard(void)
-{
- int r = scrap_txt_write(&app, tmp_clipboard);
- return( (r>0)?true:false );
-}
-
-bool gui_copy_to_clipboard(struct selection *s)
-{
- bool ret = false;
- if( s->defined ) {
- gui_empty_clipboard();
- if(selection_copy_to_clipboard(s)){
- ret = gui_commit_clipboard();
- }
- }
- gui_empty_clipboard();
- return ret;
-}
-
-
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- TODO();
-}
-
-/**
- * Broadcast an URL that we can't handle.
- */
-void gui_launch_url(const char *url)
-{
- TODO();
- LOG(("launch file: %s\n", url));
-}
-
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- bool bres;
- char * out = NULL;
- bres = login_form_do( url, (char*)realm, &out );
- if( bres ) {
- LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out ));
- urldb_set_auth_details(url, realm, out );
- }
- if( out != NULL ){
- free( out );
- }
- if( cb != NULL )
- cb(bres, cbpw);
-}
-
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- LOG((""));
-
- bool bres;
- /*bres = verify_ssl_form_do(url, certs, num);
- if( bres )
- urldb_set_cert_permissions(url, true);
- */
- // TODO: localize string
- int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
- bres = (b==1)? true : false;
- LOG(("Trust: %d", bres ));
- urldb_set_cert_permissions(url, bres);
- cb(bres, cbpw);
-}
-
-void gui_quit(void)
-{
- LOG((""));
-
- struct gui_window * gw = window_list;
- struct gui_window * tmp = window_list;
-
- while( gw ) {
- tmp = gw->next;
- browser_window_destroy(gw->browser->bw);
- gw = tmp;
- }
-
- global_history_destroy();
- hotlist_destroy();
- toolbar_exit();
-
- urldb_save_cookies(nsoption_charp(cookie_file));
- urldb_save(nsoption_charp(url_file));
-
- RsrcXtype( 0, rsc_trindex, rsc_ntree);
- unbind_global_events();
- MenuBar( h_gem_menu , 0 );
- if( h_gem_rsrc != NULL ) {
- RsrcXfree(h_gem_rsrc );
- }
- LOG(("Shutting down plotter"));
- plot_finalise();
- if( tmp_clipboard != NULL ){
- free( tmp_clipboard );
- tmp_clipboard = NULL;
- }
- LOG(("done"));
-}
-
-
-
-
-static bool
-process_cmdline(int argc, char** argv)
-{
- int opt;
- bool set_default_dimensions = true;
-
- LOG(("argc %d, argv %p", argc, argv));
-
- if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) {
-
- option_window_width = nsoption_int(window_width);
- option_window_height = nsoption_int(window_height);
- option_window_x = nsoption_int(window_x);
- option_window_y = nsoption_int(window_y);
-
- if (option_window_width <= app.w && option_window_height < app.h) {
- set_default_dimensions = false;
- }
- }
-
- if (set_default_dimensions) {
- if( sys_type() == SYS_TOS ){
- /* on single tasking OS, start as fulled window: */
- option_window_width = app.w;
- option_window_height = app.h-20;
- option_window_x = app.w/2-(option_window_width/2);
- option_window_y = (app.h/2)-(option_window_height/2);
- } else {
- option_window_width = 600;
- option_window_height = 360;
- option_window_x = 10;
- option_window_y = 30;
- }
- }
-
- if (nsoption_charp(homepage_url) != NULL)
- option_homepage_url = nsoption_charp(homepage_url);
- else
- option_homepage_url = NETSURF_HOMEPAGE;
-
- while((opt = getopt(argc, argv, "w:h:")) != -1) {
- switch (opt) {
- case 'w':
- option_window_width = atoi(optarg);
- break;
-
- case 'h':
- option_window_height = atoi(optarg);
- break;
-
- default:
- fprintf(stderr,
- "Usage: %s [w,h,v] url\n",
- argv[0]);
- return false;
+ kstate = evnt.mkstate;
+ kcode = evnt.keybd;
+ nkc= gem_to_norm( (short)kstate, (short)kcode);
+ nks = (nkc & 0xFF00);
+ if( kstate & (K_LSHIFT|K_RSHIFT))
+ kstate |= K_LSHIFT|K_RSHIFT;
+ if( window_url_widget_has_focus( gw ) ) {
+ /* make sure we report for the root window and report...: */
+ done = tb_url_input( gw, nkc );
+ } else {
+ gw_tmp = window_list;
+ /* search for active browser component: */
+ while( gw_tmp != NULL && done == false ) {
+ /* todo: only handle when input_window == ontop */
+ if( window_widget_has_focus( (struct gui_window *)input_window,
+ BROWSER,(void*)gw_tmp->browser)) {
+ done = browser_input( gw_tmp, nkc );
+ break;
+ } else {
+ gw_tmp = gw_tmp->next;
+ }
}
- }
-
- if (optind < argc) {
- option_homepage_url = argv[optind];
- }
- return true;
-}
-
-static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
-{
- m->flags = flags;
- m->number = mode;
- if( flags & MFORM_EX_FLAG_USERFORM ) {
- m->number = mode;
- m->tree = (OBJECT*)form;
- }
-}
-
-nsurl *gui_get_resource_url(const char *path)
-{
- char buf[PATH_MAX];
- char *raw;
- nsurl *url = NULL;
-
- atari_find_resource((char*)&buf, path, path);
- raw = path_to_url((char*)&buf);
- if (raw != NULL) {
- nsurl_create(raw, &url);
- free(raw);
- }
-
- return url;
-}
-
-/* Documented in desktop/options.h */
-void gui_options_init_defaults(void)
-{
- /* Set defaults for absent option strings */
- nsoption_setnull_charp(cookie_file, strdup("cookies"));
-
- if (nsoption_charp(cookie_file) == NULL) {
- die("Failed initialising string options");
- }
-}
-
-static void gui_init(int argc, char** argv)
-{
- char buf[PATH_MAX];
- OBJECT * cursors;
-
- atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- h_gem_rsrc = RsrcXload( (char*) &buf );
-
- if( !h_gem_rsrc )
- die("Uable to open GEM Resource file!");
- rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
-
- RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
- RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
-
- create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
- create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
- create_cursor(0, THIN_CROSS, NULL, &gem_cursors.cross);
- create_cursor(0, BUSY_BEE, NULL, &gem_cursors.wait);
- create_cursor(0, ARROW, NULL, &gem_cursors.arrow);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
- create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
- RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
- cursors, &gem_cursors.appstarting);
- gem_set_cursor( &gem_cursors.appstarting );
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZEWE,
- cursors, &gem_cursors.sizewe);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZENS,
- cursors, &gem_cursors.sizens);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_NODROP,
- cursors, &gem_cursors.nodrop);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_DENY,
- cursors, &gem_cursors.deny);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_MENU,
- cursors, &gem_cursors.menu);
- create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP,
- cursors, &gem_cursors.help);
-
- LOG(("Enabling core select menu"));
- nsoption_set_bool(core_select_menu, true);
-
- LOG(("Loading url.db from: %s", nsoption_charp(url_file) ));
- if( strlen(nsoption_charp(url_file)) ){
- urldb_load(nsoption_charp(url_file));
- }
-
- LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
- if( strlen(nsoption_charp(cookie_file)) ){
- urldb_load_cookies(nsoption_charp(cookie_file));
- }
-
- if (process_cmdline(argc,argv) != true)
- die("unable to process command line.\n");
-
- nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
-}
-
-static char *theapp = (char*)"NetSurf";
-static void gui_init2(int argc, char** argv)
-{
- MenuBar( h_gem_menu , 1 );
- bind_global_events();
- menu_register( -1, theapp);
- if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
- menu_register( _AESapid, (char*)" NetSurf ");
- }
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
- global_history_init();
- hotlist_init();
- toolbar_init();
-}
-
-/* #define WITH_DBG_LOGFILE 1 */
-/** Entry point from OS.
- *
- * /param argc The number of arguments in the string vector.
- * /param argv The argument string vector.
- * /return The return code to the OS
- */
-int main(int argc, char** argv)
-{
- char messages[PATH_MAX];
-
- setbuf(stderr, NULL);
- setbuf(stdout, NULL);
-#ifdef WITH_DBG_LOGFILE
- freopen("stdout.log", "a+", stdout);
- freopen("stderr.log", "a+", stderr);
-#endif
- ApplInit();
- graf_mouse(BUSY_BEE, NULL);
- init_os_info();
- atari_find_resource((char*)&messages, "messages", "res/messages");
- atari_find_resource((char*)&options, "Choices", "Choices");
- netsurf_init(&argc, &argv, options, messages);
- gui_init(argc, argv);
- gui_init2(argc, argv);
- browser_window_create(option_homepage_url, 0, 0, true, false);
- graf_mouse( ARROW , NULL);
- netsurf_main_loop();
- netsurf_exit();
- LOG(("ApplExit"));
- ApplExit();
-#ifdef WITH_DBG_LOGFILE
- fclose(stdout);
- fclose(stderr);
-#endif
-
- return 0;
-}
-
-
+ }
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+}
+
+void gui_poll(bool active)
+{
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
+ short mx, my, dummy;
+ unsigned short nkc = 0;
+
+ evnt.timer = schedule_run();
+
+ if(active || rendering) {
+ if (clock() >= next_poll) {
+ aes_event_in.emi_tlow = 0;
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ next_poll = clock() + (CLOCKS_PER_SEC>>4);
+ }
+ } else {
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ }
+
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ //global_dispatch_event(&aes_event_in, &aes_event_out, msg);
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ printf("key: %d, %d\n", aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta);
+ nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
+ }
+
+}
+
+void gui_poll_old(bool active)
+{
+ short winloc[4];
+ // int timeout; /* timeout in milliseconds */
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
+ short mx, my, dummy;
+
+ evnt.timer = schedule_run();
+
+ if( active || rendering ) {
+ if( clock() >= next_poll ) {
+ evnt.timer = 0;
+ flags |= MU_TIMER;
+ EvntWindom( flags );
+ next_poll = clock() + (CLOCKS_PER_SEC>>3);
+ }
+ } else {
+ if (input_window != NULL) {
+ wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
+ if (winloc[1] == _AESapid) {
+ /* only check for mouse move when netsurf is on top: */
+ // move that into m1 event handler
+ graf_mkstate( &mx, &my, &dummy, &dummy );
+ flags |= MU_M1;
+ evnt.m1_flag = MO_LEAVE;
+ evnt.m1_w = evnt.m1_h = 1;
+ evnt.m1_x = mx;
+ evnt.m1_y = my;
+ }
+ }
+ flags |= MU_TIMER;
+ EvntWindom( flags );
+ }
+
+ struct gui_window * g;
+ for( g = window_list; g != NULL; g=g->next ) {
+ if( browser_redraw_required( g ) ) {
+ browser_redraw( g );
+ }
+ if( g->root->toolbar ) {
+ if(g->root->toolbar->url.redraw ) {
+ tb_url_redraw( g );
+ }
+ }
+ }
+ if( evnt.timer != 0 && !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ global_history_redraw();
+ }
+}
+
+struct gui_window *
+gui_create_browser_window(struct browser_window *bw,
+ struct browser_window *clone,
+ bool new_tab) {
+ struct gui_window *gw=NULL;
+ LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
+ (int)new_tab
+ ));
+
+ gw = malloc( sizeof(struct gui_window) );
+ if (gw == NULL)
+ return NULL;
+ memset( gw, 0, sizeof(struct gui_window) );
+
+ LOG(("new window: %p, bw: %p\n", gw, bw));
+ window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
+ if( gw->root->handle ) {
+ GRECT pos = {
+ option_window_x, option_window_y,
+ option_window_width, option_window_height
+ };
+ window_open( gw , pos );
+ /* Recalculate windows browser area now */
+ browser_update_rects( gw );
+ tb_update_buttons( gw, -1 );
+ input_window = gw;
+ /* TODO:... this line: placeholder to create a local history widget ... */
+ }
+
+ /* add the window to the window list: */
+ if( window_list == NULL ) {
+ window_list = gw;
+ gw->next = NULL;
+ gw->prev = NULL;
+ } else {
+ struct gui_window * tmp = window_list;
+ while( tmp->next != NULL ) {
+ tmp = tmp->next;
+ }
+ tmp->next = gw;
+ gw->prev = tmp;
+ gw->next = NULL;
+ }
+
+ return( gw );
+
+}
+
+void gui_window_destroy(struct gui_window *w)
+{
+ if (w == NULL)
+ return;
+
+ LOG(("%s\n", __FUNCTION__ ));
+
+ input_window = NULL;
+
+ window_destroy(w);
+
+ /* unlink the window: */
+ if(w->prev != NULL ) {
+ w->prev->next = w->next;
+ } else {
+ window_list = w->next;
+ }
+ if( w->next != NULL ) {
+ w->next->prev = w->prev;
+ }
+ free(w);
+ w = NULL;
+
+ w = window_list;
+ while( w != NULL ) {
+ if( w->root ) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
+ }
+}
+
+void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
+ bool scaled)
+{
+ if (w == NULL)
+ return;
+ LGRECT rect;
+ browser_get_rect( w, BR_CONTENT, &rect );
+ *width = rect.g_w;
+ *height = rect.g_h;
+}
+
+void gui_window_set_title(struct gui_window *gw, const char *title)
+{
+ int l;
+ char * conv;
+
+ if (gw == NULL)
+ return;
+ if( gw->root ) {
+ l = strlen(title);
+ if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
+ strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
+ free( conv );
+ } else {
+ strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
+ }
+ gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
+ WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
+ }
+}
+
+/**
+ * set the status bar message
+ */
+void gui_window_set_status(struct gui_window *w, const char *text)
+{
+ if (w == NULL || text == NULL )
+ return;
+ window_set_stauts( w , (char*)text );
+}
+
+void gui_window_redraw_window(struct gui_window *gw)
+{
+ CMP_BROWSER b;
+ LGRECT rect;
+ if (gw == NULL)
+ return;
+ b = gw->browser;
+ browser_get_rect( gw, BR_CONTENT, &rect );
+ browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
+}
+
+void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
+{
+ CMP_BROWSER b;
+ if (gw == NULL)
+ return;
+ b = gw->browser;
+ int x0 = rect->x0 - b->scroll.current.x;
+ int y0 = rect->y0 - b->scroll.current.y;
+ int w,h;
+ w = rect->x1 - rect->x0;
+ h = rect->y1 - rect->y0;
+ browser_schedule_redraw_rect( gw, x0, y0, w, h );
+}
+
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
+{
+ if (w == NULL)
+ return false;
+ *sx = w->browser->scroll.current.x;
+ *sy = w->browser->scroll.current.y;
+ return( true );
+}
+
+void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+{
+ if ((w == NULL) ||
+ (w->browser->bw == NULL) ||
+ (w->browser->bw->current_content == NULL))
+ return;
+ if( sx != 0 ) {
+ if( sx < 0 ) {
+ browser_scroll(w, WA_LFLINE, abs(sx), true );
+ } else {
+ browser_scroll(w, WA_RTLINE, abs(sx), true );
+ }
+ }
+
+ if( sy != 0 ) {
+ if( sy < 0) {
+ browser_scroll(w, WA_UPLINE, abs(sy), true );
+ } else {
+ browser_scroll(w, WA_DNLINE, abs(sy), true );
+ }
+ }
+ return;
+
+}
+
+void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
+{
+ LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
+ gui_window_set_scroll(w,x0,y0);
+ browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
+}
+
+
+/* It seems this method is called when content size got adjusted,
+ so that we can adjust scroll info. We also have to call it when tab
+ change occurs.
+*/
+void gui_window_update_extent(struct gui_window *gw)
+{
+ int oldx, oldy;
+ oldx = gw->browser->scroll.current.x;
+ oldy = gw->browser->scroll.current.y;
+ if( gw->browser->bw->current_content != NULL ) {
+ browser_set_content_size( gw,
+ content_get_width(gw->browser->bw->current_content),
+ content_get_height(gw->browser->bw->current_content)
+ );
+ }
+}
+
+
+void gui_clear_selection(struct gui_window *g)
+{
+
+}
+
+
+
+/**
+ * set the pointer shape
+ */
+void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
+{
+ if (w == NULL)
+ return;
+ switch (shape) {
+ case GUI_POINTER_POINT: /* link */
+ gem_set_cursor(&gem_cursors.hand);
+ break;
+
+ case GUI_POINTER_MENU:
+ gem_set_cursor(&gem_cursors.menu);
+ break;
+
+ case GUI_POINTER_CARET: /* input */
+ gem_set_cursor(&gem_cursors.ibeam);
+ break;
+
+ case GUI_POINTER_CROSS:
+ gem_set_cursor(&gem_cursors.cross);
+ break;
+
+ case GUI_POINTER_MOVE:
+ gem_set_cursor(&gem_cursors.sizeall);
+ break;
+
+ case GUI_POINTER_RIGHT:
+ case GUI_POINTER_LEFT:
+ gem_set_cursor(&gem_cursors.sizewe);
+ break;
+
+ case GUI_POINTER_UP:
+ case GUI_POINTER_DOWN:
+ gem_set_cursor(&gem_cursors.sizens);
+ break;
+
+ case GUI_POINTER_RU:
+ case GUI_POINTER_LD:
+ gem_set_cursor(&gem_cursors.sizenesw);
+ break;
+
+ case GUI_POINTER_RD:
+ case GUI_POINTER_LU:
+ gem_set_cursor(&gem_cursors.sizenwse);
+ break;
+
+ case GUI_POINTER_WAIT:
+ gem_set_cursor(&gem_cursors.wait);
+ break;
+
+ case GUI_POINTER_PROGRESS:
+ gem_set_cursor(&gem_cursors.appstarting);
+ break;
+
+ case GUI_POINTER_NO_DROP:
+ gem_set_cursor(&gem_cursors.nodrop);
+ break;
+
+ case GUI_POINTER_NOT_ALLOWED:
+ gem_set_cursor(&gem_cursors.deny);
+ break;
+
+ case GUI_POINTER_HELP:
+ gem_set_cursor(&gem_cursors.help);
+ break;
+
+ default:
+ gem_set_cursor(&gem_cursors.arrow);
+ break;
+ }
+}
+
+void gui_window_hide_pointer(struct gui_window *w)
+{
+ TODO();
+}
+
+
+void gui_window_set_url(struct gui_window *w, const char *url)
+{
+ if (w == NULL)
+ return;
+ tb_url_set(w, (char*)url );
+}
+
+static void throbber_advance( void * data )
+{
+ LGRECT work;
+ struct gui_window * gw = (struct gui_window *)data;
+ if( gw->root == NULL )
+ return;
+ if( gw->root->toolbar == NULL )
+ return;
+ if( gw->root->toolbar->throbber.running == false )
+ return;
+ mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ gw->root->toolbar->throbber.index++;
+ if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
+ gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+ schedule(100, throbber_advance, gw );
+}
+
+void gui_window_start_throbber(struct gui_window *w)
+{
+ LGRECT work;
+ if (w == NULL)
+ return;
+ if( w->root->toolbar->throbber.running == true )
+ return;
+ mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ w->root->toolbar->throbber.running = true;
+ w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ schedule(100, throbber_advance, w );
+ ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+
+ rendering = true;
+}
+
+void gui_window_stop_throbber(struct gui_window *w)
+{
+ LGRECT work;
+ if (w == NULL)
+ return;
+ if( w->root->toolbar->throbber.running == false )
+ return;
+
+ schedule_remove(throbber_advance, w);
+
+ /* refresh toolbar buttons: */
+ tb_update_buttons( w, -1 );
+
+ /* redraw throbber: */
+ mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+ WF_WORKXYWH, &work);
+ w->root->toolbar->throbber.running = false;
+ ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+
+ rendering = false;
+}
+
+/* Place caret in window */
+void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
+{
+ if (w == NULL)
+ return;
+ if( w->browser->caret.current.g_w > 0 )
+ gui_window_remove_caret( w );
+ w->browser->caret.requested.g_x = x;
+ w->browser->caret.requested.g_y = y;
+ w->browser->caret.requested.g_w = 1;
+ w->browser->caret.requested.g_h = height;
+ w->browser->caret.redraw = true;
+ return;
+}
+
+
+/**
+ * clear window caret
+ */
+void
+gui_window_remove_caret(struct gui_window *w)
+{
+ if (w == NULL)
+ return;
+
+ if( w->browser->caret.background.fd_addr != NULL ) {
+ browser_restore_caret_background( w, NULL );
+ w->browser->caret.requested.g_w = 0;
+ w->browser->caret.current.g_w = 0;
+ }
+ return;
+}
+
+void
+gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+{
+ struct bitmap *bmp_icon;
+
+ bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
+
+ window_set_icon(g, bmp_icon);
+}
+
+void
+gui_window_set_search_ico(hlcache_handle *ico)
+{
+ TODO();
+}
+
+void gui_window_new_content(struct gui_window *w)
+{
+ w->browser->scroll.current.x = 0;
+ w->browser->scroll.current.y = 0;
+ w->browser->scroll.requested.x = 0;
+ w->browser->scroll.requested.y = 0;
+ w->browser->scroll.required = true;
+ gui_window_redraw_window( w );
+}
+
+bool gui_window_scroll_start(struct gui_window *w)
+{
+ TODO();
+ return true;
+}
+
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ const struct rect *rect)
+{
+ TODO();
+ return true;
+}
+
+void gui_window_save_link(struct gui_window *g, const char *url,
+ const char *title)
+{
+ LOG(("%s -> %s", title, url ));
+ TODO();
+}
+
+void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
+ struct gui_window *w)
+{
+ LOG((""));
+ TODO();
+}
+
+void gui_drag_save_selection(struct selection *s, struct gui_window *w)
+{
+ LOG((""));
+ TODO();
+}
+
+void gui_start_selection(struct gui_window *w)
+{
+ gui_empty_clipboard();
+}
+
+void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
+{
+ char * clip = scrap_txt_read( &app );
+ if( clip == NULL )
+ return;
+ int clip_length = strlen( clip );
+ if (clip_length > 0) {
+ char *utf8;
+ utf8_convert_ret ret;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ ret = utf8_from_local_encoding(clip,
+ clip_length, &utf8);
+ if (ret == UTF8_CONVERT_OK) {
+ browser_window_paste_text(w->browser->bw, utf8,
+ strlen(utf8), true);
+ free(utf8);
+ }
+ free( clip );
+ }
+}
+
+bool gui_empty_clipboard(void)
+{
+ if( tmp_clipboard != NULL ) {
+ free( tmp_clipboard );
+ tmp_clipboard = NULL;
+ }
+ return true;
+}
+
+bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space,
+ const plot_font_style_t *fstyle)
+{
+ LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
+ char * oldptr = tmp_clipboard;
+ size_t oldlen = 0;
+ size_t newlen = 0;
+ char * text = NULL;
+ char * text2 = NULL;
+ bool retval;
+ int length = 0;
+ if( length_utf8 > 0 && text_utf8 != NULL ) {
+ utf8_to_local_encoding(text_utf8,length_utf8,&text);
+ if( text == NULL ) {
+ LOG(("Conversion failed (%s)", text_utf8));
+ goto error;
+ } else {
+ text2 = text;
+ }
+ } else {
+ if( space == false ) {
+ goto success;
+ }
+ text = malloc(length + 2);
+ if( text == NULL ) {
+ goto error;
+ }
+ text2 = text;
+ text[length+1] = 0;
+ memset(text, ' ', length+1);
+ }
+ length = strlen(text);
+ if( tmp_clipboard != NULL ) {
+ oldlen = strlen( tmp_clipboard );
+ }
+ newlen = oldlen + length + 1;
+ if( tmp_clipboard == NULL) {
+ tmp_clipboard = malloc(newlen);
+ if( tmp_clipboard == NULL ) {
+ goto error;
+ }
+ strncpy(tmp_clipboard, text, newlen);
+ } else {
+ tmp_clipboard = realloc( tmp_clipboard, newlen);
+ if( tmp_clipboard == NULL ) {
+ goto error;
+ }
+ strncpy(tmp_clipboard, oldptr, newlen);
+ strncat(tmp_clipboard, text, newlen-oldlen);
+ }
+ goto success;
+
+error:
+ retval = false;
+ goto fin;
+
+success:
+ retval = true;
+
+fin:
+ if( text2 != NULL )
+ free( text2 );
+ return(retval);
+
+}
+
+bool gui_commit_clipboard(void)
+{
+ int r = scrap_txt_write(&app, tmp_clipboard);
+ return( (r>0)?true:false );
+}
+
+bool gui_copy_to_clipboard(struct selection *s)
+{
+ bool ret = false;
+ if( s->defined ) {
+ gui_empty_clipboard();
+ if(selection_copy_to_clipboard(s)) {
+ ret = gui_commit_clipboard();
+ }
+ }
+ gui_empty_clipboard();
+ return ret;
+}
+
+
+void gui_create_form_select_menu(struct browser_window *bw,
+ struct form_control *control)
+{
+ TODO();
+}
+
+/**
+ * Broadcast an URL that we can't handle.
+ */
+void gui_launch_url(const char *url)
+{
+ TODO();
+ LOG(("launch file: %s\n", url));
+}
+
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ bool bres;
+ char * out = NULL;
+ bres = login_form_do( url, (char*)realm, &out );
+ if( bres ) {
+ LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out ));
+ urldb_set_auth_details(url, realm, out );
+ }
+ if( out != NULL ) {
+ free( out );
+ }
+ if( cb != NULL )
+ cb(bres, cbpw);
+}
+
+void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ LOG((""));
+
+ bool bres;
+ /*bres = verify_ssl_form_do(url, certs, num);
+ if( bres )
+ urldb_set_cert_permissions(url, true);
+ */
+ // TODO: localize string
+ int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
+ bres = (b==1)? true : false;
+ LOG(("Trust: %d", bres ));
+ urldb_set_cert_permissions(url, bres);
+ cb(bres, cbpw);
+}
+
+void gui_quit(void)
+{
+ LOG((""));
+
+ struct gui_window * gw = window_list;
+ struct gui_window * tmp = window_list;
+
+ unbind_global_events();
+
+ while( gw ) {
+ tmp = gw->next;
+ browser_window_destroy(gw->browser->bw);
+ gw = tmp;
+ }
+
+ global_history_destroy();
+ hotlist_destroy();
+ toolbar_exit();
+
+ urldb_save_cookies(nsoption_charp(cookie_file));
+ urldb_save(nsoption_charp(url_file));
+
+ deskmenu_destroy();
+
+ rsrc_free();
+
+ LOG(("Shutting down plotter"));
+ plot_finalise();
+ if( tmp_clipboard != NULL ) {
+ free( tmp_clipboard );
+ tmp_clipboard = NULL;
+ }
+ LOG(("done"));
+}
+
+
+
+
+static bool
+process_cmdline(int argc, char** argv)
+{
+ int opt;
+ bool set_default_dimensions = true;
+
+ LOG(("argc %d, argv %p", argc, argv));
+
+ if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) {
+
+ option_window_width = nsoption_int(window_width);
+ option_window_height = nsoption_int(window_height);
+ option_window_x = nsoption_int(window_x);
+ option_window_y = nsoption_int(window_y);
+
+ if (option_window_width <= app.w && option_window_height < app.h) {
+ set_default_dimensions = false;
+ }
+ }
+
+ if (set_default_dimensions) {
+ if( sys_type() == SYS_TOS ) {
+ /* on single tasking OS, start as fulled window: */
+ option_window_width = app.w;
+ option_window_height = app.h-20;
+ option_window_x = app.w/2-(option_window_width/2);
+ option_window_y = (app.h/2)-(option_window_height/2);
+ } else {
+ option_window_width = 600;
+ option_window_height = 360;
+ option_window_x = 10;
+ option_window_y = 30;
+ }
+ }
+
+ if (nsoption_charp(homepage_url) != NULL)
+ option_homepage_url = nsoption_charp(homepage_url);
+ else
+ option_homepage_url = NETSURF_HOMEPAGE;
+
+ while((opt = getopt(argc, argv, "w:h:")) != -1) {
+ switch (opt) {
+ case 'w':
+ option_window_width = atoi(optarg);
+ break;
+
+ case 'h':
+ option_window_height = atoi(optarg);
+ break;
+
+ default:
+ fprintf(stderr,
+ "Usage: %s [w,h,v] url\n",
+ argv[0]);
+ return false;
+ }
+ }
+
+ if (optind < argc) {
+ option_homepage_url = argv[optind];
+ }
+ return true;
+}
+
+static inline void create_cursor(int flags, short mode, void * form,
+ MFORM_EX * m)
+{
+ m->flags = flags;
+ m->number = mode;
+ if( flags & MFORM_EX_FLAG_USERFORM ) {
+ m->number = mode;
+ m->tree = (OBJECT*)form;
+ }
+}
+
+nsurl *gui_get_resource_url(const char *path)
+{
+ char buf[PATH_MAX];
+ char *raw;
+ nsurl *url = NULL;
+
+ atari_find_resource((char*)&buf, path, path);
+ raw = path_to_url((char*)&buf);
+ if (raw != NULL) {
+ nsurl_create(raw, &url);
+ free(raw);
+ }
+
+ return url;
+}
+
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ nsoption_setnull_charp(cookie_file, strdup("cookies"));
+
+ if (nsoption_charp(cookie_file) == NULL) {
+ die("Failed initialising string options");
+ }
+}
+
+static void gui_init(int argc, char** argv)
+{
+ char buf[PATH_MAX];
+ OBJECT * cursors;
+
+ atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
+ LOG(("%s ", (char*)&buf));
+ if (rsrc_load(buf)==0) {
+ die("Uable to open GEM Resource file!");
+ }
+ //h_gem_rsrc = RsrcXload( (char*) &buf );
+
+ //if( !h_gem_rsrc )
+ // die("Uable to open GEM Resource file!");
+ //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+
+ //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+
+ create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
+ create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
+ create_cursor(0, THIN_CROSS, NULL, &gem_cursors.cross);
+ create_cursor(0, BUSY_BEE, NULL, &gem_cursors.wait);
+ create_cursor(0, ARROW, NULL, &gem_cursors.arrow);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
+ create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
+ RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
+ cursors, &gem_cursors.appstarting);
+ gem_set_cursor( &gem_cursors.appstarting );
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZEWE,
+ cursors, &gem_cursors.sizewe);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZENS,
+ cursors, &gem_cursors.sizens);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_NODROP,
+ cursors, &gem_cursors.nodrop);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_DENY,
+ cursors, &gem_cursors.deny);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_MENU,
+ cursors, &gem_cursors.menu);
+ create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP,
+ cursors, &gem_cursors.help);
+
+ LOG(("Enabling core select menu"));
+ nsoption_set_bool(core_select_menu, true);
+
+ LOG(("Loading url.db from: %s", nsoption_charp(url_file) ));
+ if( strlen(nsoption_charp(url_file)) ) {
+ urldb_load(nsoption_charp(url_file));
+ }
+
+ LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
+ if( strlen(nsoption_charp(cookie_file)) ) {
+ urldb_load_cookies(nsoption_charp(cookie_file));
+ }
+
+ if (process_cmdline(argc,argv) != true)
+ die("unable to process command line.\n");
+
+ nkc_init();
+ plot_init(nsoption_charp(atari_font_driver));
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+}
+
+static char *theapp = (char*)"NetSurf";
+static void gui_init2(int argc, char** argv)
+{
+ deskmenu_init();
+ menu_register( -1, theapp);
+ if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
+ menu_register( _AESapid, (char*)" NetSurf ");
+ }
+ bind_global_events();
+ global_history_init();
+ hotlist_init();
+ toolbar_init();
+}
+
+/* #define WITH_DBG_LOGFILE 1 */
+/** Entry point from OS.
+ *
+ * /param argc The number of arguments in the string vector.
+ * /param argv The argument string vector.
+ * /return The return code to the OS
+ */
+int main(int argc, char** argv)
+{
+ char messages[PATH_MAX];
+
+ setbuf(stderr, NULL);
+ setbuf(stdout, NULL);
+#ifdef WITH_DBG_LOGFILE
+ freopen("stdout.log", "a+", stdout);
+ freopen("stderr.log", "a+", stderr);
+#endif
+ ApplInit();
+ graf_mouse(BUSY_BEE, NULL);
+ init_os_info();
+ atari_find_resource((char*)&messages, "messages", "res/messages");
+ atari_find_resource((char*)&options, "Choices", "Choices");
+ netsurf_init(&argc, &argv, options, messages);
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+ graf_mouse( ARROW , NULL);
+ netsurf_main_loop();
+ netsurf_exit();
+ LOG(("ApplExit"));
+ ApplExit();
+#ifdef WITH_DBG_LOGFILE
+ fclose(stdout);
+ fclose(stderr);
+#endif
+
+ return 0;
+}
+
+
diff --git a/atari/hotlist.c b/atari/hotlist.c
index bdd10d9..5d54d06 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -40,6 +40,7 @@
#include "atari/treeview.h"
#include "atari/hotlist.h"
#include "atari/findfile.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
struct atari_hotlist hl;
diff --git a/atari/misc.c b/atari/misc.c
index 8b745fd..575e964 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -42,7 +42,7 @@
#include "atari/browser.h"
#include "atari/misc.h"
#include "atari/encoding.h"
-#include "atari/msgbox.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
extern void * h_gem_rsrc;
@@ -111,10 +111,7 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-/*
- TBD: make use of this function or remove it...
-*/
-struct gui_window * find_gui_window( unsigned long handle, short mode ){
+struct gui_window * find_guiwin_by_aes_handle(short handle){
struct gui_window * gw;
gw = window_list;
@@ -122,29 +119,17 @@ struct gui_window * find_gui_window( unsigned long handle, short mode ){
if( handle == 0 ){
return( NULL );
}
- else if( mode == BY_WINDOM_HANDLE ){
- WINDOW * win = (WINDOW*) handle;
- while( gw != NULL) {
- if( gw->root->handle == win ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
- }
- else if( mode == BY_GEM_HANDLE ){
- short ghandle = (short)handle;
- while( gw != NULL) {
- if( gw->root->handle != NULL
- && gw->root->handle->handle == ghandle ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
+
+ while(gw != NULL) {
+ if( gw->root->handle != NULL
+ && gw->root->handle->handle == handle ) {
+ return(gw);
+ }
+ else
+ gw = gw->next;
}
- return( NULL );
+ return( NULL );
}
@@ -260,25 +245,6 @@ bool is_process_running(const char * name)
}
-/* -------------------------------------------------------------------------- */
-/* GEM Utillity functions: */
-/* -------------------------------------------------------------------------- */
-
-/* Return a string from resource file */
-char *get_rsc_string( int idx) {
- char *txt;
- RsrcGaddr( h_gem_rsrc, R_STRING, idx, &txt );
- return txt;
-}
-
-OBJECT *get_tree( int idx) {
- OBJECT *tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
- return tree;
-}
-
-
-
/**
* Callback for load_icon(). Should be removed once bitmaps get loaded directly
* from disc
diff --git a/atari/misc.h b/atari/misc.h
index 612113f..5359d72 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -42,11 +42,9 @@
typedef int (*scan_process_callback)(int pid, void *data);
-struct gui_window * find_gui_window( unsigned long, short mode );
+struct gui_window * find_guiwin_by_aes_handle(short handle);
struct gui_window * find_cmp_window( COMPONENT * c );
bool is_process_running(const char * name);
-OBJECT *get_tree( int idx );
-char *get_rsc_string( int idx );
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
void * pw );
diff --git a/atari/osspec.c b/atari/osspec.c
index d697f43..c2e2252 100644
--- a/atari/osspec.c
+++ b/atari/osspec.c
@@ -28,7 +28,8 @@
#include <windom.h>
#include "utils/log.h"
-#include "atari/osspec.h"
+#include "atari/osspec.h"
+#include "atari/gemtk/gemtk.h"
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -36,38 +37,6 @@
NS_ATARI_SYSINFO atari_sysinfo;
-unsigned short _systype_v;
-unsigned short _systype (void)
-{
- int32_t * cptr = NULL;
- _systype_v = SYS_TOS;
-
- cptr = (int32_t *)Setexc(0x0168, -1L);
- if (cptr == NULL ) {
- return _systype_v; /* stone old TOS without any cookie support */
- }
- while (*cptr) {
- if (*cptr == C_MgMc || *cptr == C_MgMx ) {
- _systype_v = (_systype_v & ~0xF) | SYS_MAGIC;
- } else if (*cptr == C_MiNT ) {
- _systype_v = (_systype_v & ~0xF) | SYS_MINT;
- } else if (*cptr == C_Gnva /* Gnva */ ) {
- _systype_v |= SYS_GENEVA;
- } else if (*cptr == C_nAES /* nAES */ ) {
- _systype_v |= SYS_NAES;
- }
- cptr += 2;
- }
- if (_systype_v & SYS_MINT) { /* check for XaAES */
- short out = 0, u;
- if (wind_get (0, (((short)'X') <<8)|'A', &out, &u,&u,&u) && out) {
- _systype_v |= SYS_XAAES;
- }
- }
- LOG(("Detected OS: %d\n", _systype_v ));
- return _systype_v;
-}
-
void init_os_info(void)
{
int16_t out[4];
diff --git a/atari/osspec.h b/atari/osspec.h
index 91cf2f0..29f87cc 100644
--- a/atari/osspec.h
+++ b/atari/osspec.h
@@ -17,27 +17,13 @@
*/
#ifndef NS_ATARI_OSSPEC_H
-#define NS_ATARI_OSSPEC_H
-
+#define NS_ATARI_OSSPEC_H
+
typedef struct {
long c;
long v;
} COOKIE;
-/* System type detection added by [GS] */
-#define SYS_TOS 0x0001
-#define SYS_MAGIC 0x0002
-#define SYS_MINT 0x0004
-#define SYS_GENEVA 0x0010
-#define SYS_NAES 0x0020
-#define SYS_XAAES 0x0040
-/* detect the system type, AES + kernel */
-#define sys_type() (_systype_v ? _systype_v : _systype())
-#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
-#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
-#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
-
-
typedef struct {
unsigned short gemdos_version;
unsigned short gdos_FSMC;
@@ -50,13 +36,9 @@ typedef struct {
} NS_ATARI_SYSINFO;
extern NS_ATARI_SYSINFO atari_sysinfo;
-extern unsigned short _systype_v;
-
-#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
void init_os_info(void);
-int tos_getcookie( long tag, long * value );
void fix_path(char * path);
-char * gemdos_realpath(const char * path, char * rpath);
-unsigned short _systype (void);
-#endif
\ No newline at end of file
+char * gemdos_realpath(const char * path, char * rpath);
+int tos_getcookie( long tag, long * value );
+#endif
diff --git a/atari/redrawslots.c b/atari/redrawslots.c
index 9fe7161..069e6cc 100644
--- a/atari/redrawslots.c
+++ b/atari/redrawslots.c
@@ -45,7 +45,7 @@ static inline bool rect_intersect( struct rect * box1, struct rect * box2 )
return true;
}
/*
- schedule a slots, coords are relative.
+ schedule redraw coords, coords are relative.
*/
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0, short x1, short y1)
{
diff --git a/atari/rootwin.c b/atari/rootwin.c
new file mode 100755
index 0000000..16d3363
--- /dev/null
+++ b/atari/rootwin.c
@@ -0,0 +1,816 @@
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <windom.h>
+#include <assert.h>
+#include <math.h>
+#include <osbind.h>
+
+#include "utils/log.h"
+#include "desktop/gui.h"
+#include "desktop/history_core.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/plotters.h"
+#include "desktop/textinput.h"
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "content/urldb.h"
+#include "css/css.h"
+#include "atari/gemtk/gemtk.h"
+#include "atari/gui.h"
+#include "atari/rootwin.h"
+#include "atari/browser.h"
+#include "atari/misc.h"
+#include "atari/plot/plot.h"
+#include "atari/global_evnt.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/browser.h"
+#include "atari/toolbar.h"
+#include "atari/statusbar.h"
+#include "atari/search.h"
+#include "atari/osspec.h"
+#include "atari/encoding.h"
+#include "atari/toolbar.h"
+#include "atari/gemtk/gemtk.h"
+
+extern struct gui_window *input_window;
+
+/* -------------------------------------------------------------------------- */
+/* Static module methods follow here: */
+/* -------------------------------------------------------------------------- */
+//static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
+//void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
+//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
+static void redraw(GUIWIN *win, short msg[8]);
+static void resized(GUIWIN *win);
+static void file_dropped(GUIWIN *win, short msg[8]);
+//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
+static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
+//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
+//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
+
+#define FIND_NS_GUI_WINDOW(w) \
+ find_guiwin_by_aes_handle(guiwin_get_handle(w));
+
+/* -------------------------------------------------------------------------- */
+/* Module public functions: */
+/* -------------------------------------------------------------------------- */
+
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+ struct gui_window * gw;
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ // handle message
+ printf("root win msg: %d\n", msg[0]);
+ switch (msg[0]) {
+
+ case WM_REDRAW:
+ redraw(win, msg);
+ break;
+
+ case WM_REPOSED:
+ case WM_SIZED:
+ case WM_MOVED:
+ case WM_FULLED:
+ resized(win);
+ break;
+
+ case WM_ICONIFY:
+ gw = FIND_NS_GUI_WINDOW(win);
+ if( input_window == gw) {
+ input_window = NULL;
+ }
+ break;
+
+ case WM_TOPPED:
+ case WM_NEWTOP:
+ case WM_UNICONIFY:
+ input_window = FIND_NS_GUI_WINDOW(win);
+ break;
+
+ case WM_CLOSED:
+ gw = FIND_NS_GUI_WINDOW(win);
+ if( gw != NULL ) {
+ browser_window_destroy( gw->browser->bw );
+ }
+ break;
+
+ case AP_DRAGDROP:
+ file_dropped(win, msg);
+ break;
+
+ case WM_TOOLBAR:
+ printf("toolbar click at %d,%d!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ printf("root win keybd\n");
+ // handle key
+ }
+ if( (ev_out->emo_events & MU_TIMER) != 0 ) {
+ // handle_timer();
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y));
+ printf("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ //handle_mbutton(gw, ev_out);
+ }
+
+ return(0);
+}
+
+
+int window_create( struct gui_window * gw,
+ struct browser_window * bw,
+ unsigned long inflags )
+{
+ int err = 0;
+ bool tb, sb;
+ int flags;
+
+ tb = (inflags & WIDGET_TOOLBAR);
+ sb = (inflags & WIDGET_STATUSBAR);
+
+ flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
+ if( inflags & WIDGET_SCROLL ) {
+ flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
+ }
+ if( inflags & WIDGET_RESIZE ) {
+ flags |= ( SIZER );
+ }
+ if( inflags & WIDGET_STATUSBAR ) {
+ flags |= ( INFO );
+ }
+
+ gw->root = malloc( sizeof(struct s_gui_win_root) );
+ if( gw->root == NULL )
+ return( -1 );
+ memset( gw->root, 0, sizeof(struct s_gui_win_root) );
+ gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
+ gw->root->handle = WindCreate(flags, 40, 40, app.w, app.h);
+ if( gw->root->handle == NULL ) {
+ free( gw->root->title );
+ free( gw->root );
+ return( -1 );
+ }
+
+ /* set scroll / content granularity ( 1 unit ) */
+ gw->root->handle->w_u = 1;
+ gw->root->handle->h_u = 1;
+
+ /* Create Root component: */
+ gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
+ WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
+
+ /* create toolbar component: */
+ if( tb ) {
+ gw->root->toolbar = tb_create( gw );
+ assert( gw->root->toolbar );
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
+
+ } else {
+ gw->root->toolbar = NULL;
+ }
+
+ /* create browser component: */
+ gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
+ mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
+
+ /* create statusbar component: */
+ if( sb ) {
+ gw->root->statusbar = sb_create( gw );
+#ifdef WITH_COMOPONENT_STATUSBAR
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
+#endif
+ } else {
+ gw->root->statusbar = NULL;
+ }
+
+ WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
+
+ /* Event Handlers: */
+// EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
+ /* capture resize/move events so we can handle that manually */
+// EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
+// EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
+// EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
+ EvntDataAdd(gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
+ EvntDataAdd(gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
+// EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
+// EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
+// EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
+// EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
+ EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
+
+ if (inflags & WIN_TOP) {
+ window_set_focus( gw, BROWSER, gw->browser);
+ }
+
+ GUIWIN * guiwin = guiwin_add(gw->root->handle->handle,
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
+ guiwin_set_toolbar(guiwin, get_tree(TOOLBAR), 0, 0);
+ return (err);
+}
+
+int window_destroy(struct gui_window * gw)
+{
+ int err = 0;
+
+ search_destroy( gw );
+ if( input_window == gw )
+ input_window = NULL;
+
+ if( gw->root ) {
+ if( gw->root->toolbar )
+ tb_destroy( gw->root->toolbar );
+
+ if( gw->root->statusbar )
+ sb_destroy( gw->root->statusbar );
+ }
+
+ search_destroy( gw );
+
+ guiwin_remove(guiwin_find(gw->root->handle->handle));
+
+ if( gw->browser )
+ browser_destroy( gw->browser );
+
+ /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
+ if( gw->root ) {
+ /* TODO: check if no other browser is bound to this root window! */
+ /* only needed for tabs */
+ if( gw->root->title )
+ free( gw->root->title );
+ if( gw->root->cmproot )
+ mt_CompDelete( &app, gw->root->cmproot );
+ ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
+ EvntWindom( MU_MESAG );
+ gw->root->handle = NULL;
+ free(gw->root);
+ gw->root = NULL;
+ }
+ return(err);
+}
+
+
+
+void window_open( struct gui_window * gw, GRECT pos )
+{
+ LGRECT br;
+
+ WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
+ WindClear( gw->root->handle );
+ WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
+
+ /* apply focus to the root frame: */
+ long lfbuff[8] = { CM_GETFOCUS };
+ mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
+
+ /* recompute the nested component sizes and positions: */
+ browser_update_rects( gw );
+ mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+ browser_get_rect( gw, BR_CONTENT, &br );
+ plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
+ gw->browser->attached = true;
+ if( gw->root->statusbar != NULL ) {
+ sb_attach(gw->root->statusbar, gw);
+ }
+ tb_adjust_size( gw );
+ /*TBD: get already present content and set size? */
+ input_window = gw;
+ window_set_focus( gw, BROWSER, gw->browser );
+}
+
+
+
+/* update back forward buttons (see tb_update_buttons (bug) ) */
+void window_update_back_forward( struct gui_window * gw)
+{
+ tb_update_buttons( gw, -1 );
+}
+
+void window_set_stauts(struct gui_window * gw , char * text )
+{
+ if( gw->root == NULL )
+ return;
+
+ CMP_STATUSBAR sb = gw->root->statusbar;
+
+ if( sb == NULL || gw->browser->attached == false )
+ return;
+
+ sb_set_text( sb, text );
+}
+
+/* set focus to an arbitary element */
+void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
+{
+ if( gw->root->focus.type != type || gw->root->focus.element != element ) {
+ LOG(("Set focus: %p (%d)\n", element, type));
+ gw->root->focus.type = type;
+ gw->root->focus.element = element;
+ if( element != NULL ) {
+ switch( type ) {
+
+ case URL_WIDGET:
+ textarea_keypress(((struct s_url_widget*)(element))->textarea,
+ KEY_SELECT_ALL );
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ }
+}
+
+/* check if the url widget has focus */
+bool window_url_widget_has_focus( struct gui_window * gw )
+{
+ assert( gw );
+ assert( gw->root );
+ if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
+ assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
+ assert( GUIWIN_VISIBLE(gw) );
+ return true;
+ }
+ return false;
+}
+
+/* check if an arbitary window widget / or frame has the focus */
+bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
+{
+ if( gw == NULL )
+ return( false );
+ if( element == NULL ) {
+ assert( 1 != 0 );
+ return( (gw->root->focus.type == t ) );
+ }
+ assert( gw->root != NULL );
+ return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
+}
+
+void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
+{
+ gw->icon = bmp;
+ /* redraw window when it is iconyfied: */
+ if (gw->icon != NULL) {
+ short info, dummy;
+ WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
+ if (info == 1) {
+ window_redraw_favicon(gw, NULL);
+ }
+ }
+}
+
+
+/**
+ * Redraw the favicon
+*/
+void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
+{
+ GRECT work;
+
+ assert(gw->root);
+
+ WINDOW * bw = gw->root->handle;
+
+ WindClear(bw);
+ WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
+ if (clip == NULL) {
+ clip = &work;
+ }
+
+ if (gw->icon == NULL) {
+ OBJECT * tree = get_tree(ICONIFY);
+ tree->ob_x = work.g_x;
+ tree->ob_y = work.g_y;
+ tree->ob_width = work.g_w;
+ tree->ob_height = work.g_h;
+ objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
+ } else {
+ // TODO: consider the clipping rectangle
+ struct rect work_clip = { 0,0,work.g_w,work.g_h };
+ int xoff=0;
+ if (work.g_w > work.g_h) {
+ xoff = ((work.g_w-work.g_h)/2);
+ work.g_w = work.g_h;
+ }
+ plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
+ plot_clip(&work_clip);
+ atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
+ }
+}
+
+
+/* -------------------------------------------------------------------------- */
+/* Event Handlers: */
+/* -------------------------------------------------------------------------- */
+
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
+{
+ bool abs = false;
+ LGRECT cwork;
+ struct gui_window * gw = data;
+ int value = BROWSER_SCROLL_SVAL;
+
+ assert( gw != NULL );
+
+ browser_get_rect( gw, BR_CONTENT, &cwork );
+
+ switch( buff[4] ) {
+ case WA_UPPAGE:
+ case WA_DNPAGE:
+ value = cwork.g_h;
+ break;
+
+
+ case WA_LFPAGE:
+ case WA_RTPAGE:
+ value = cwork.g_w;
+ break;
+
+ default:
+ break;
+ }
+ browser_scroll( gw, buff[4], value, abs );
+}
+
+//
+//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+// char file[DD_NAMEMAX];
+// char name[DD_NAMEMAX];
+// char *buff=NULL;
+// int dd_hdl;
+// int dd_msg; /* pipe-handle */
+// long size;
+// char ext[32];
+// short mx,my,bmstat,mkstat;
+// graf_mkstate(&mx, &my, &bmstat, &mkstat);
+//
+// if( gw == NULL )
+// return;
+// if( (win->status & WS_ICONIFY))
+// return;
+//
+// dd_hdl = ddopen( wbuff[7], DD_OK);
+// if( dd_hdl<0)
+// return; /* pipe not open */
+// memset( ext, 0, 32);
+// strcpy( ext, "ARGS");
+// dd_msg = ddsexts( dd_hdl, ext);
+// if( dd_msg<0)
+// goto error;
+// dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
+// if( size+1 >= PATH_MAX )
+// goto error;
+// if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
+// ddreply(dd_hdl, DD_OK);
+// buff = (char*)malloc(sizeof(char)*(size+1));
+// if (buff != NULL) {
+// if (Fread(dd_hdl, size, buff ) == size)
+// buff[size] = 0;
+// LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
+// (char*)buff, (char*)&ext,
+// size, mx, my
+// ));
+// {
+// LGRECT bwrect;
+// struct browser_window * bw = gw->browser->bw;
+// browser_get_rect( gw, BR_CONTENT, &bwrect );
+// mx = mx - bwrect.g_x;
+// my = my - bwrect.g_y;
+// if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
+// return;
+//
+// utf8_convert_ret ret;
+// char *utf8_fn;
+//
+// ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
+// if (ret != UTF8_CONVERT_OK) {
+// free(buff);
+// /* A bad encoding should never happen */
+// LOG(("utf8_from_local_encoding failed"));
+// assert(ret != UTF8_CONVERT_BADENC);
+// /* no memory */
+// return;
+// }
+// browser_window_drop_file_at_point( gw->browser->bw,
+// mx+gw->browser->scroll.current.x,
+// my+gw->browser->scroll.current.y,
+// utf8_fn );
+// free(utf8_fn);
+// free(buff);
+// }
+// }
+// }
+//error:
+// ddclose( dd_hdl);
+//}
+
+static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+}
+
+//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
+//{
+// struct gui_window * gw = (struct gui_window *) data ;
+// if( gw != NULL ) {
+// browser_window_destroy( gw->browser->bw );
+// }
+//}
+
+
+//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
+//{
+// input_window = (struct gui_window *) data;
+// window_set_focus( input_window, BROWSER, input_window->browser );
+// LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
+// assert( input_window != NULL );
+//}
+
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
+{
+ int dx = buff[4];
+ int dy = buff[5];
+ struct gui_window * gw = data;
+
+ if (!dx && !dy) return;
+
+ if( input_window == NULL || input_window != gw ) {
+ return;
+ }
+
+ /* update the sliders _before_ we call redraw
+ (which might depend on the slider possitions) */
+ WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
+
+ if( dy > 0 )
+ browser_scroll( gw, WA_DNPAGE, abs(dy), false );
+ else if ( dy < 0)
+ browser_scroll( gw, WA_UPPAGE, abs(dy), false );
+ if( dx > 0 )
+ browser_scroll( gw, WA_RTPAGE, abs(dx), false );
+ else if( dx < 0 )
+ browser_scroll( gw, WA_LFPAGE, abs(dx), false );
+}
+
+//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+//
+// input_window = gw;
+// WindTop( gw->root->handle );
+// window_set_focus( gw, BROWSER, gw->browser );
+//}
+
+//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data )
+//{
+// struct gui_window * gw = (struct gui_window *)data;
+// if( input_window == gw) {
+// input_window = NULL;
+// }
+//}
+
+
+//static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
+//{
+// struct gui_window *gw = (struct gui_window*) data;
+// GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
+// window_redraw_favicon(gw, &clip);
+//}
+
+static void redraw(GUIWIN *win, short msg[8])
+{
+ short handle;
+ struct gui_window *gw;
+
+ handle = guiwin_get_handle(win);
+ gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
+
+ assert(gw != NULL);
+
+ if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
+ GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
+ window_redraw_favicon(gw, &clip);
+ } else {
+ GRECT area;
+ short pxy[8];
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
+ /*
+ pxy[0] = area.g_x;
+ pxy[1] = area.g_y;
+ pxy[2] = pxy[0] + area.g_w;
+ pxy[3] = pxy[1];
+ pxy[4] = pxy[2];
+ pxy[5] = pxy[1] + area.g_h;
+ pxy[6] = pxy[0];
+ pxy[7] = pxy[5];
+ */
+ //const plot_style_fill_white
+ plot_rectangle(area.g_x, area.g_y, area.g_x+area.g_h,
+ area.g_y + area.g_h,
+ plot_style_fill_white);
+
+
+ //WindClear(gw->root->handle);
+ }
+}
+
+static void resized(GUIWIN *win)
+{
+ short x,y,w,h;
+ short handle;
+ struct gui_window *gw;
+
+ handle = guiwin_get_handle(win);
+ gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
+
+ assert( gw != NULL );
+
+ wind_get(handle, WF_CURRXYWH, &x, &y, &w, &h);
+
+ if (gw->root->loc.g_w != w || gw->root->loc.g_h != h) {
+ // resized
+ tb_adjust_size( gw );
+ if ( gw->browser->bw->current_content != NULL ) {
+ /* Reformat will happen when next redraw message arrives: */
+ gw->browser->reformat_pending = true;
+ /* but on xaaes an resize doesn't trigger an redraw, */
+ /* when the window is shrinked, deal with it: */
+ if( sys_XAAES() ) {
+ if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ) {
+ ApplWrite(_AESapid, WM_REDRAW, gw->root->handle->handle,
+ x, y, w, h);
+ }
+ }
+ }
+ }
+ if (gw->root->loc.g_x != x || gw->root->loc.g_y != y) {
+ // moved
+ }
+ gw->root->loc.g_x = x;
+ gw->root->loc.g_y = y;
+ gw->root->loc.g_w = w;
+ gw->root->loc.g_h = h;
+}
+
+static void __CDECL file_dropped(GUIWIN *win, short msg[8])
+{
+ char file[DD_NAMEMAX];
+ char name[DD_NAMEMAX];
+ char *buff=NULL;
+ int dd_hdl;
+ int dd_msg; /* pipe-handle */
+ long size;
+ char ext[32];
+ short mx,my,bmstat,mkstat;
+ struct gui_window *gw;
+
+ graf_mkstate(&mx, &my, &bmstat, &mkstat);
+
+ gw = FIND_NS_GUI_WINDOW(win);
+
+ if( gw == NULL )
+ return;
+
+ if(guiwin_get_state(win) & GW_STATUS_ICONIFIED)
+ return;
+
+ dd_hdl = ddopen( msg[7], DD_OK);
+ if( dd_hdl<0)
+ return; /* pipe not open */
+ memset( ext, 0, 32);
+ strcpy( ext, "ARGS");
+ dd_msg = ddsexts( dd_hdl, ext);
+ if( dd_msg<0)
+ goto error;
+ dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
+ if( size+1 >= PATH_MAX )
+ goto error;
+ if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
+ ddreply(dd_hdl, DD_OK);
+ buff = (char*)malloc(sizeof(char)*(size+1));
+ if (buff != NULL) {
+ if (Fread(dd_hdl, size, buff ) == size)
+ buff[size] = 0;
+ LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
+ (char*)buff, (char*)&ext,
+ size, mx, my
+ ));
+ {
+ LGRECT bwrect;
+ struct browser_window * bw = gw->browser->bw;
+ browser_get_rect( gw, BR_CONTENT, &bwrect );
+ mx = mx - bwrect.g_x;
+ my = my - bwrect.g_y;
+ if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
+ return;
+
+ utf8_convert_ret ret;
+ char *utf8_fn;
+
+ ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
+ if (ret != UTF8_CONVERT_OK) {
+ free(buff);
+ /* A bad encoding should never happen */
+ LOG(("utf8_from_local_encoding failed"));
+ assert(ret != UTF8_CONVERT_BADENC);
+ /* no memory */
+ return;
+ }
+ browser_window_drop_file_at_point( gw->browser->bw,
+ mx+gw->browser->scroll.current.x,
+ my+gw->browser->scroll.current.y,
+ utf8_fn );
+ free(utf8_fn);
+ free(buff);
+ }
+ }
+ }
+error:
+ ddclose( dd_hdl);
+}
+
+///* perform the actual resize */
+//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
+//{
+// short x,y,w,h;
+// struct gui_window * gw;
+//
+// wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
+// gw = (struct gui_window *)data;
+//
+// assert( gw != NULL );
+//
+// if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
+// /* report resize to component interface: */
+// browser_update_rects( gw );
+// tb_adjust_size( gw );
+// if( gw->browser->bw->current_content != NULL ){
+// /* Reformat will happen when next redraw message arrives: */
+// gw->browser->reformat_pending = true;
+// if( sys_XAAES() ){
+// if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
+// ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+// gw->root->loc.g_x, gw->root->loc.g_y,
+// gw->root->loc.g_w, gw->root->loc.g_h );
+// }
+// }
+// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
+// (GRECT*)&gw->root->loc);
+// }
+// else {
+// WindClear( gw->root->handle );
+// }
+// } else {
+// if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
+// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+// browser_update_rects( gw );
+// }
+// }
+//}
diff --git a/atari/browser_win.h b/atari/rootwin.h
similarity index 100%
copy from atari/browser_win.h
copy to atari/rootwin.h
diff --git a/atari/search.c b/atari/search.c
index b5e2fdd..4737125 100644
--- a/atari/search.c
+++ b/atari/search.c
@@ -34,7 +34,8 @@
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/browser.h"
-#include "atari/search.h"
+#include "atari/search.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
extern struct gui_window * input_window;
@@ -139,7 +140,7 @@ static void destroy_search_session( SEARCH_FORM_SESSION s )
}
}
-static int apply_form( WINDOW * win, struct s_search_form_state * s )
+static int apply_form(WINDOW * win, struct s_search_form_state * s)
{
OBJECT * obj = ObjcTree(OC_FORM, win );
if( obj == NULL ){
@@ -290,11 +291,12 @@ SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
NULL, title,
&pos, true, false);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_CASESENSE, evnt_cb_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_SHOWALL, evnt_cb_click, NULL);
- ObjcAttachFormFunc( sfs->formwind, SEARCH_CB_FWD, evnt_cb_click, NULL);
- EvntAdd( sfs->formwind, WM_CLOSED, evnt_close, EV_TOP);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click,
+ NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_CASESENSE, evnt_cb_click, NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_SHOWALL, evnt_cb_click, NULL);
+ ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_FWD, evnt_cb_click, NULL);
+ EvntAdd(sfs->formwind, WM_CLOSED, evnt_close, EV_TOP);
apply_form(sfs->formwind, &sfs->state );
strncpy( ObjcString( tree, SEARCH_TB_SRCH, NULL ), "", SEARCH_MAX_SLEN);
diff --git a/atari/settings.c b/atari/settings.c
index 8143cdc..ff39903 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,11 +31,12 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-#include "atari/global_evnt.h"
-#include "atari/misc.h"
+#include "atari/deskmenu.h"
+#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
-#include "atari/findfile.h"
+#include "atari/findfile.h"
+#include "atari/gemtk/gemtk.h"
extern char options[PATH_MAX];
@@ -232,7 +233,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- main_menu_update();
+ deskmenu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 08a62c5..c8f8688 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -38,7 +38,7 @@
#include "atari/gui.h"
#include "atari/statusbar.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
@@ -227,7 +227,6 @@ void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw)
void sb_set_text(CMP_STATUSBAR sb, char * text )
{
- LGRECT work;
assert( sb != NULL );
strncpy(sb->text, text, STATUSBAR_MAX_SLEN);
sb->text[STATUSBAR_MAX_SLEN]=0;
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 3594d24..396cccb 100755
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -43,7 +43,7 @@
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/browser.h"
#include "atari/clipboard.h"
#include "atari/misc.h"
@@ -176,8 +176,8 @@ void toolbar_init( void )
} else {
RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- toolbar_buttons->ob_x = 0;
- toolbar_buttons->ob_y = 0;
+ //toolbar_buttons->ob_x = 0;
+ //toolbar_buttons->ob_y = 0;
RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
throbber_form->ob_x = 0;
@@ -279,8 +279,8 @@ static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
tree = &toolbar_buttons[bt->rsc_id];
if( tree == NULL )
return;
- tree->ob_x = work.g_x;
- tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
+ //tree->ob_x = work.g_x;
+ //tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
if( drawstate == button_off ) {
tree->ob_state |= OS_DISABLED;
} else {
diff --git a/atari/treeview.c b/atari/treeview.c
index 4a5cb0a..6e567f5 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -37,7 +37,19 @@
#include "atari/treeview.h"
#include "atari/plot/plot.h"
#include "atari/misc.h"
-#include "cflib.h"
+#include "cflib.h"
+
+/*
+#define TREEVIEW_RECT_WORKAREA 0
+#define TREEVIEW_RECT_TOOLBAR 1
+#define TREEVIEW_RECT_CONTENT 2
+*/
+
+enum treeview_area_e {
+ TREEVIEW_AREA_WORK = 0,
+ TREEVIEW_AREA_TOOLBAR,
+ TREEVIEW_AREA_CONTENT
+};
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
@@ -46,9 +58,11 @@ extern short last_drag_y;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static void atari_treeview_resized(struct tree *tree,int w,int h,void *pw);
+static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
static void atari_treeview_scroll_visible(int y, int h, void *pw);
-static void atari_treeview_get_dimensions(int *width, int *height,void *pw);
+static void atari_treeview_get_dimensions(int *width, int *height, void *pw);
+static void atari_treeview_get_grect(NSTREEVIEW tree,
+ enum treeview_area_e mode, GRECT *dest);
static const struct treeview_table atari_tree_callbacks = {
atari_treeview_request_redraw,
@@ -403,6 +417,24 @@ void atari_treeview_scroll_visible(int y, int height, void *pw)
{
/* we don't support dragging outside the treeview */
/* so we don't need to implement this? */
+}
+
+static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
+ GRECT *dest)
+{
+
+ wind_get_grect(tv->window->handle, WF_WORKXYWH, dest);
+ if (mode == TREEVIEW_AREA_CONTENT) {
+ GRECT tb_grect;
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_grect);
+ dest->g_y += tb_grect.g_h;
+ dest->g_h -= tb_grect.g_h;
+ }
+ else if (mode == TREEVIEW_AREA_TOOLBAR) {
+ // TODO: this requires something like:
+ // guiwin_get_toolbar();
+ dest->g_h = 16;
+ }
}
/**
@@ -418,8 +450,8 @@ void atari_treeview_get_dimensions(int *width, int *height,
{
if (pw != NULL && (width != NULL || height != NULL)) {
NSTREEVIEW tv = (NSTREEVIEW) pw;
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ GRECT work;
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
*width = work.g_w;
*height = work.g_h;
}
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. e042008f2b7295243d2e6c72f948febe3cad0516
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e042008f2b7295243d2e6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e042008f2b7295243d2e6c7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e042008f2b7295243d2e6c72f...
The branch, master has been updated
via e042008f2b7295243d2e6c72f948febe3cad0516 (commit)
via 47c0ce6f14417da5c169e3a79a4396c7d2d5eea5 (commit)
from 6797e1f8ef51e7e22020797b68f07e0c295091ff (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/commitdiff/e042008f2b7295243d2...
commit e042008f2b7295243d2e6c72f948febe3cad0516
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Revert "Refactored menu event handling and got rid of several windom calls."
This reverts commit d1a5c738e62a9f0cb85658b435eefa8749006edc.
this change belongs into a new branch
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
deleted file mode 100644
index 38e3539..0000000
--- a/atari/deskmenu.c
+++ /dev/null
@@ -1,660 +0,0 @@
-#include <stdlib.h>
-#include <windom.h>
-
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/options.h"
-#include "desktop/save_complete.h"
-
-#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/toolbar.h"
-#include "atari/settings.h"
-#include "atari/search.h"
-#include "atari/misc.h"
-#include "atari/gui.h"
-#include "atari/findfile.h"
-#include "atari/browser.h"
-#include "atari/browser_win.h"
-
-typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
-
-static void register_menu_str(struct s_menu_item_evnt * mi);
-static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
-
-extern void *h_gem_rsrc;
-extern bool html_redraw_debug;
-extern struct gui_window * input_window;
-extern char options[PATH_MAX];
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-
-static OBJECT * h_gem_menu;
-
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
-
-
-static void __CDECL menu_about(short item, short title, void *data);
-static void __CDECL menu_new_win(short item, short title, void *data);
-static void __CDECL menu_open_url(short item, short title, void *data);
-static void __CDECL menu_open_file(short item, short title, void *data);
-static void __CDECL menu_close_win(short item, short title, void *data);
-static void __CDECL menu_save_page(short item, short title, void *data);
-static void __CDECL menu_quit(short item, short title, void *data);
-static void __CDECL menu_cut(short item, short title, void *data);
-static void __CDECL menu_copy(short item, short title, void *data);
-static void __CDECL menu_paste(short item, short title, void *data);
-static void __CDECL menu_find(short item, short title, void *data);
-static void __CDECL menu_choices(short item, short title, void *data);
-static void __CDECL menu_stop(short item, short title, void *data);
-static void __CDECL menu_reload(short item, short title, void *data);
-static void __CDECL menu_toolbars(short item, short title, void *data);
-static void __CDECL menu_savewin(short item, short title, void *data);
-static void __CDECL menu_debug_render(short item, short title, void *data);
-static void __CDECL menu_fg_images(short item, short title, void *data);
-static void __CDECL menu_bg_images(short item, short title, void *data);
-static void __CDECL menu_back(short item, short title, void *data);
-static void __CDECL menu_forward(short item, short title, void *data);
-static void __CDECL menu_home(short item, short title, void *data);
-static void __CDECL menu_lhistory(short item, short title, void *data);
-static void __CDECL menu_ghistory(short item, short title, void *data);
-static void __CDECL menu_add_bookmark(short item, short title, void *data);
-static void __CDECL menu_bookmarks(short item, short title, void *data);
-static void __CDECL menu_vlog(short item, short title, void *data);
-static void __CDECL menu_help_content(short item, short title, void *data);
-
-struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {-1, -1, NULL,{0,0,0}, NULL }
-};
-
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- OBJECT *gem_menu = deskmenu_get_obj_tree();
-
- assert(gem_menu != NULL);
-
- char * str = ObjcString( gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
- while (i > 2) {
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-static void __CDECL evnt_menu(WINDOW * win, short buff[8])
-{
- int title = buff[3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
-
- deskmenu_dispatch_item(buff[3], buff[4]);
-}
-
-/*
- Menu item event handlers:
-*/
-
-static void __CDECL menu_about(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT",
- PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(short item, short title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- netsurf_quit = true;
-}
-
-static void __CDECL menu_cut(short item, short title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(short item, short title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(short item, short title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(short item, short title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL
- && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(short item, short title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(short item, short title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-/*
- Public deskmenu interface:
-*/
-
-
-/**
-* Setup & display an desktop menu.
-*/
-
-void deskmenu_init(void)
-{
- int i;
-
- h_gem_menu = get_tree(MAINMENU);
-
- // TODO: remove that call somehow...
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- /* Update menu string if not null: */
- if( menu_evnt_tbl[i].menustr != NULL ){
- menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
- menu_evnt_tbl[i].menustr);
- }
- i++;
- }
- deskmenu_update();
-
- menu_bar(h_gem_menu, 100);
- menu_bar(h_gem_menu, 1);
-
- // TODO: remove windom dependency.
- EvntAttach(NULL, MN_SELECTED, evnt_menu);
-}
-
-/**
-* Uninstall the desktop menu
-*/
-void deskmenu_destroy(void)
-{
- int i;
-
- /* Remove menu from desktop: */
- menu_bar(h_gem_menu, 0);
-
- /* Free modified menu titles: */
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
-/**
-* Return the deskmenu AES OBJECT tree
-*/
-OBJECT * deskmenu_get_obj_tree(void)
-{
- return(h_gem_menu);
-}
-
-/**
-* Handle an menu item event
-*/
-int deskmenu_dispatch_item(short title, short item)
-{
- int i=0;
- int retval = 0;
- OBJECT * menu_root = deskmenu_get_obj_tree();
-
- menu_tnormal(menu_root, item, 1);
- menu_tnormal(menu_root, title, 1);
- menu_bar(menu_root, 1);
-
- // legacy code, is this sensible?:
- /*
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- */
-
-
- while (menu_evnt_tbl[i].rid != -1) {
- if (menu_evnt_tbl[i].rid == item) {
- if (menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func(item, title, NULL);
- }
- break;
- }
- i++;
- }
-
- return(retval);
-}
-
-/**
-* Handle an keypress (check for accelerator)
-*/
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
-{
- char sascii;
- bool done = 0;
- int i = 0;
-
- sascii = keybd2ascii(kcode, K_LSHIFT);
-
- /* Iterate through the menu function table: */
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod
- && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- }
- }
- i++;
- }
- return((done==true) ? 1 : 0);
-}
-
-/**
-* Refresh the desk menu, reflecting netsurf current state.
-*/
-void deskmenu_update(void)
-{
- OBJECT * gem_menu = deskmenu_get_obj_tree();
-
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
deleted file mode 100644
index 6ab00dc..0000000
--- a/atari/deskmenu.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef DESKMENU_H_INCLUDED
-#define DESKMENU_H_INCLUDED
-
-void deskmenu_init(void);
-void deskmenu_destroy(void);
-int deskmenu_dispatch_item(short title, short item);
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc);
-OBJECT * deskmenu_get_obj_tree(void);
-void deskmenu_update( void );
-
-#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index e3a93a0..3b15af8 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,31 +26,379 @@
#include <windom.h>
#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/textinput.h"
+#include "desktop/hotlist.h"
+#include "desktop/save_complete.h"
+#include "desktop/options.h"
#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
-#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/misc.h"
#include "atari/global_evnt.h"
+#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
+#include "atari/findfile.h"
+#include "atari/settings.h"
#include "cflib.h"
extern struct gui_window *input_window;
+extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
+extern bool html_redraw_debug;
+
+extern const char * option_homepage_url;
+extern int option_window_width;
+extern int option_window_height;
+extern int option_window_x;
+extern int option_window_y;
+extern char options[PATH_MAX];
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
+#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
+static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
+
+
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ char buf[PATH_MAX];
+ strcpy((char*)&buf, "file://");
+ strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ browser_window_create((char*)&buf, 0, 0, true, false);
+}
+
+static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+}
+
+static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+ LOG(("%s", __FUNCTION__));
+
+ gw = input_window;
+ if( gw == NULL ) {
+ bw = browser_window_create("", 0, 0, true, false);
+ gw = bw->window;
+
+ }
+ /* Loose focus: */
+ window_set_focus( gw, WIDGET_NONE, NULL );
+
+ /* trigger on-focus event (select all text): */
+ window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+
+ /* delete selection: */
+ tb_url_input( gw, NK_DEL );
+}
+
+static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+
+ LOG(("%s", __FUNCTION__));
+
+ const char * filename = file_select( messages_get("OpenFile"), "" );
+ if( filename != NULL ){
+ char * url = local_file_to_url( filename );
+ if( url ){
+ bw = browser_window_create(url, NULL, NULL, true, false);
+ free( url );
+ }
+ }
+}
+
+static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ static bool init = true;
+ bool is_folder=false;
+ const char * path;
+
+ if( !input_window )
+ return;
+
+ if( init ){
+ init = false;
+ save_complete_init();
+ }
+
+ do {
+ // TODO: localize string
+ path = file_select("Select folder", "");
+ if (path)
+ is_folder = is_dir(path);
+ } while( !is_folder && path != NULL );
+
+ if( path != NULL ){
+ save_complete( input_window->browser->bw->current_content, path, NULL );
+ }
+
+}
+
+static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ global_evnt_apterm( NULL, buff );
+}
+
+static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ open_browser_search( input_window );
+}
+
+static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+{
+ static WINDOW * settings_dlg = NULL;
+ LOG(("%s", __FUNCTION__));
+ settings_dlg = open_settings();
+}
+
+static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_stop_click( input_window );
+
+}
+
+static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window == NULL)
+ return;
+ tb_reload_click( input_window );
+ LOG(("%s", __FUNCTION__));
+}
+
+static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+{
+ static int state = 0;
+ LOG(("%s", __FUNCTION__));
+ if( input_window != null && input_window->root->toolbar != null ){
+ state = !state;
+ tb_hide( input_window, state );
+ }
+}
+
+static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window && input_window->browser) {
+ GRECT rect;
+ wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ option_window_width = rect.g_w;
+ option_window_height = rect.g_h;
+ option_window_x = rect.g_x;
+ option_window_y = rect.g_y;
+ nsoption_set_int(window_width, rect.g_w);
+ nsoption_set_int(window_height, rect.g_h);
+ nsoption_set_int(window_x, rect.g_x);
+ nsoption_set_int(window_y, rect.g_y);
+ nsoption_write((const char*)&options);
+ }
+
+}
+
+static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
+ if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ LGRECT rect;
+ browser_get_rect( input_window, BR_CONTENT, &rect );
+ browser_window_reformat(input_window->browser->bw, false,
+ rect.g_w, rect.g_h );
+ MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0 );
+ }
+ }
+}
+
+static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(background_images, !nsoption_bool(background_images));
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_back_click( input_window );
+}
+
+static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_forward_click( input_window );
+}
+
+static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_home_click( input_window );
+}
+
+static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window ) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ hotlist_open();
+}
+
+static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ verbose_log = !verbose_log;
+ MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+}
+
+static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+}
+
+static struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {T_HELP, -1, NULL,{0,0,0}, NULL }
+};
+
+void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
{
int i = 0;
LOG((""));
@@ -58,7 +406,7 @@ void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
}
-static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
+static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -68,23 +416,23 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if (gw == NULL)
+ if( gw == NULL)
return;
- if (prev_x == evnt.mx && prev_y == evnt.my) {
+ if( prev_x == evnt.mx && prev_y == evnt.my ){
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if (input_window->root->handle->handle == ghandle) {
+ if( input_window->root->handle->handle == ghandle ){
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
+ if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -94,7 +442,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
);
}
- if (gw->root->toolbar && within == false) {
+ if( gw->root->toolbar && within == false ) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -118,6 +466,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
+ char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -151,23 +500,178 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+ }
+ sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod &&
+ menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func( NULL,
+ menu_evnt_tbl[i].rid,
+ MAINMENU, buff
+ );
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
+ }
}
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ char * str = ObjcString( h_gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+
+
+ while( i>2 ){
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+
+void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
+{
+ int title = buff[ 3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+ MenuTnormal( NULL, title, 1);
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ while( menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].rid == buff[4] ) {
+ menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
+ break;
+ }
+ i++;
+ }
+}
+
+void main_menu_update( void )
+{
+ MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
+ int i, len;
+ int maxlen[NUM_MENU_TITLES]={0};
+ char * m, *u, *t;
+ char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
+ }
+ i++;
+ }
+ main_menu_update();
}
void unbind_global_events( void )
{
-
+ int i;
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
+ }
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 76e73fc..1e13264 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,8 +18,6 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
-
-#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -34,14 +32,31 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
+struct s_evnt_data evnt_data;
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
/*
- Global event handlers
+ Global & Menu event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
+void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index fdcb752..c2158e0 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,8 +73,7 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -83,8 +82,9 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-//OBJECT **rsc_trindex;
-//short rsc_ntree;
+OBJECT * h_gem_menu;
+OBJECT **rsc_trindex;
+short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,8 +789,6 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
-
- unbind_global_events();
while( gw ) {
tmp = gw->next;
@@ -804,8 +802,10 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- deskmenu_destroy();
+
+ RsrcXtype( 0, rsc_trindex, rsc_ntree);
+ unbind_global_events();
+ MenuBar( h_gem_menu , 0 );
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,8 +885,7 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form,
- MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -929,18 +928,16 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- if (rsrc_load(buf)==0) {
- die("Uable to open GEM Resource file!");
- }
- //h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ h_gem_rsrc = RsrcXload( (char*) &buf );
- //if( !h_gem_rsrc )
- // die("Uable to open GEM Resource file!");
- //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ if( !h_gem_rsrc )
+ die("Uable to open GEM Resource file!");
+ rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
+ RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -984,19 +981,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ plot_init(nsoption_charp(atari_font_driver));
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- deskmenu_init();
+ MenuBar( h_gem_menu , 1 );
+ bind_global_events();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- bind_global_events();
+ }
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index e5b0dc1..8b745fd 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,8 +273,7 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- rsrc_gaddr(R_TREE, idx, &tree);
- //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 25e0c0f..8143cdc 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,8 +31,7 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-//#include "atari/global_evnt.h"
-#include "atari/deskmenu.h"
+#include "atari/global_evnt.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -233,7 +232,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- deskmenu_update();
+ main_menu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/47c0ce6f14417da5c16...
commit 47c0ce6f14417da5c169e3a79a4396c7d2d5eea5
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Revert "Added missing Makefile changes for recent deskmenu commit."
This reverts commit c5fb16d56df03580d99fae44d9fea44868f33cc5.
This change belongs into a new branch
diff --git a/atari/Makefile.target b/atari/Makefile.target
index f7e1a63..ad90807 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c deskmenu.c
+ ctxmenu.c settings.c msgbox.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
-----------------------------------------------------------------------
Summary of changes:
atari/Makefile.target | 2 +-
atari/deskmenu.c | 660 -------------------------------------------------
atari/deskmenu.h | 12 -
atari/global_evnt.c | 534 ++++++++++++++++++++++++++++++++++++++--
atari/global_evnt.h | 23 ++-
atari/gui.c | 47 ++--
atari/misc.c | 3 +-
atari/settings.c | 5 +-
8 files changed, 564 insertions(+), 722 deletions(-)
delete mode 100644 atari/deskmenu.c
delete mode 100644 atari/deskmenu.h
diff --git a/atari/Makefile.target b/atari/Makefile.target
index f7e1a63..ad90807 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c deskmenu.c
+ ctxmenu.c settings.c msgbox.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
deleted file mode 100644
index 38e3539..0000000
--- a/atari/deskmenu.c
+++ /dev/null
@@ -1,660 +0,0 @@
-#include <stdlib.h>
-#include <windom.h>
-
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/options.h"
-#include "desktop/save_complete.h"
-
-#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/toolbar.h"
-#include "atari/settings.h"
-#include "atari/search.h"
-#include "atari/misc.h"
-#include "atari/gui.h"
-#include "atari/findfile.h"
-#include "atari/browser.h"
-#include "atari/browser_win.h"
-
-typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
-
-static void register_menu_str(struct s_menu_item_evnt * mi);
-static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
-
-extern void *h_gem_rsrc;
-extern bool html_redraw_debug;
-extern struct gui_window * input_window;
-extern char options[PATH_MAX];
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-
-static OBJECT * h_gem_menu;
-
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
-
-
-static void __CDECL menu_about(short item, short title, void *data);
-static void __CDECL menu_new_win(short item, short title, void *data);
-static void __CDECL menu_open_url(short item, short title, void *data);
-static void __CDECL menu_open_file(short item, short title, void *data);
-static void __CDECL menu_close_win(short item, short title, void *data);
-static void __CDECL menu_save_page(short item, short title, void *data);
-static void __CDECL menu_quit(short item, short title, void *data);
-static void __CDECL menu_cut(short item, short title, void *data);
-static void __CDECL menu_copy(short item, short title, void *data);
-static void __CDECL menu_paste(short item, short title, void *data);
-static void __CDECL menu_find(short item, short title, void *data);
-static void __CDECL menu_choices(short item, short title, void *data);
-static void __CDECL menu_stop(short item, short title, void *data);
-static void __CDECL menu_reload(short item, short title, void *data);
-static void __CDECL menu_toolbars(short item, short title, void *data);
-static void __CDECL menu_savewin(short item, short title, void *data);
-static void __CDECL menu_debug_render(short item, short title, void *data);
-static void __CDECL menu_fg_images(short item, short title, void *data);
-static void __CDECL menu_bg_images(short item, short title, void *data);
-static void __CDECL menu_back(short item, short title, void *data);
-static void __CDECL menu_forward(short item, short title, void *data);
-static void __CDECL menu_home(short item, short title, void *data);
-static void __CDECL menu_lhistory(short item, short title, void *data);
-static void __CDECL menu_ghistory(short item, short title, void *data);
-static void __CDECL menu_add_bookmark(short item, short title, void *data);
-static void __CDECL menu_bookmarks(short item, short title, void *data);
-static void __CDECL menu_vlog(short item, short title, void *data);
-static void __CDECL menu_help_content(short item, short title, void *data);
-
-struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {-1, -1, NULL,{0,0,0}, NULL }
-};
-
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- OBJECT *gem_menu = deskmenu_get_obj_tree();
-
- assert(gem_menu != NULL);
-
- char * str = ObjcString( gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
- while (i > 2) {
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-static void __CDECL evnt_menu(WINDOW * win, short buff[8])
-{
- int title = buff[3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
-
- deskmenu_dispatch_item(buff[3], buff[4]);
-}
-
-/*
- Menu item event handlers:
-*/
-
-static void __CDECL menu_about(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT",
- PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(short item, short title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- netsurf_quit = true;
-}
-
-static void __CDECL menu_cut(short item, short title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(short item, short title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(short item, short title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(short item, short title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL
- && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(short item, short title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(short item, short title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-/*
- Public deskmenu interface:
-*/
-
-
-/**
-* Setup & display an desktop menu.
-*/
-
-void deskmenu_init(void)
-{
- int i;
-
- h_gem_menu = get_tree(MAINMENU);
-
- // TODO: remove that call somehow...
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- /* Update menu string if not null: */
- if( menu_evnt_tbl[i].menustr != NULL ){
- menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
- menu_evnt_tbl[i].menustr);
- }
- i++;
- }
- deskmenu_update();
-
- menu_bar(h_gem_menu, 100);
- menu_bar(h_gem_menu, 1);
-
- // TODO: remove windom dependency.
- EvntAttach(NULL, MN_SELECTED, evnt_menu);
-}
-
-/**
-* Uninstall the desktop menu
-*/
-void deskmenu_destroy(void)
-{
- int i;
-
- /* Remove menu from desktop: */
- menu_bar(h_gem_menu, 0);
-
- /* Free modified menu titles: */
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
-/**
-* Return the deskmenu AES OBJECT tree
-*/
-OBJECT * deskmenu_get_obj_tree(void)
-{
- return(h_gem_menu);
-}
-
-/**
-* Handle an menu item event
-*/
-int deskmenu_dispatch_item(short title, short item)
-{
- int i=0;
- int retval = 0;
- OBJECT * menu_root = deskmenu_get_obj_tree();
-
- menu_tnormal(menu_root, item, 1);
- menu_tnormal(menu_root, title, 1);
- menu_bar(menu_root, 1);
-
- // legacy code, is this sensible?:
- /*
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- */
-
-
- while (menu_evnt_tbl[i].rid != -1) {
- if (menu_evnt_tbl[i].rid == item) {
- if (menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func(item, title, NULL);
- }
- break;
- }
- i++;
- }
-
- return(retval);
-}
-
-/**
-* Handle an keypress (check for accelerator)
-*/
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
-{
- char sascii;
- bool done = 0;
- int i = 0;
-
- sascii = keybd2ascii(kcode, K_LSHIFT);
-
- /* Iterate through the menu function table: */
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod
- && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- }
- }
- i++;
- }
- return((done==true) ? 1 : 0);
-}
-
-/**
-* Refresh the desk menu, reflecting netsurf current state.
-*/
-void deskmenu_update(void)
-{
- OBJECT * gem_menu = deskmenu_get_obj_tree();
-
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
deleted file mode 100644
index 6ab00dc..0000000
--- a/atari/deskmenu.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef DESKMENU_H_INCLUDED
-#define DESKMENU_H_INCLUDED
-
-void deskmenu_init(void);
-void deskmenu_destroy(void);
-int deskmenu_dispatch_item(short title, short item);
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc);
-OBJECT * deskmenu_get_obj_tree(void);
-void deskmenu_update( void );
-
-#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index e3a93a0..3b15af8 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,31 +26,379 @@
#include <windom.h>
#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/textinput.h"
+#include "desktop/hotlist.h"
+#include "desktop/save_complete.h"
+#include "desktop/options.h"
#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
-#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/misc.h"
#include "atari/global_evnt.h"
+#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
+#include "atari/findfile.h"
+#include "atari/settings.h"
#include "cflib.h"
extern struct gui_window *input_window;
+extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
+extern bool html_redraw_debug;
+
+extern const char * option_homepage_url;
+extern int option_window_width;
+extern int option_window_height;
+extern int option_window_x;
+extern int option_window_y;
+extern char options[PATH_MAX];
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
+#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
+static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
+
+
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ char buf[PATH_MAX];
+ strcpy((char*)&buf, "file://");
+ strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ browser_window_create((char*)&buf, 0, 0, true, false);
+}
+
+static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+}
+
+static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+ LOG(("%s", __FUNCTION__));
+
+ gw = input_window;
+ if( gw == NULL ) {
+ bw = browser_window_create("", 0, 0, true, false);
+ gw = bw->window;
+
+ }
+ /* Loose focus: */
+ window_set_focus( gw, WIDGET_NONE, NULL );
+
+ /* trigger on-focus event (select all text): */
+ window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+
+ /* delete selection: */
+ tb_url_input( gw, NK_DEL );
+}
+
+static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+
+ LOG(("%s", __FUNCTION__));
+
+ const char * filename = file_select( messages_get("OpenFile"), "" );
+ if( filename != NULL ){
+ char * url = local_file_to_url( filename );
+ if( url ){
+ bw = browser_window_create(url, NULL, NULL, true, false);
+ free( url );
+ }
+ }
+}
+
+static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ static bool init = true;
+ bool is_folder=false;
+ const char * path;
+
+ if( !input_window )
+ return;
+
+ if( init ){
+ init = false;
+ save_complete_init();
+ }
+
+ do {
+ // TODO: localize string
+ path = file_select("Select folder", "");
+ if (path)
+ is_folder = is_dir(path);
+ } while( !is_folder && path != NULL );
+
+ if( path != NULL ){
+ save_complete( input_window->browser->bw->current_content, path, NULL );
+ }
+
+}
+
+static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ global_evnt_apterm( NULL, buff );
+}
+
+static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ open_browser_search( input_window );
+}
+
+static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+{
+ static WINDOW * settings_dlg = NULL;
+ LOG(("%s", __FUNCTION__));
+ settings_dlg = open_settings();
+}
+
+static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_stop_click( input_window );
+
+}
+
+static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window == NULL)
+ return;
+ tb_reload_click( input_window );
+ LOG(("%s", __FUNCTION__));
+}
+
+static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+{
+ static int state = 0;
+ LOG(("%s", __FUNCTION__));
+ if( input_window != null && input_window->root->toolbar != null ){
+ state = !state;
+ tb_hide( input_window, state );
+ }
+}
+
+static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window && input_window->browser) {
+ GRECT rect;
+ wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ option_window_width = rect.g_w;
+ option_window_height = rect.g_h;
+ option_window_x = rect.g_x;
+ option_window_y = rect.g_y;
+ nsoption_set_int(window_width, rect.g_w);
+ nsoption_set_int(window_height, rect.g_h);
+ nsoption_set_int(window_x, rect.g_x);
+ nsoption_set_int(window_y, rect.g_y);
+ nsoption_write((const char*)&options);
+ }
+
+}
+
+static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
+ if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ LGRECT rect;
+ browser_get_rect( input_window, BR_CONTENT, &rect );
+ browser_window_reformat(input_window->browser->bw, false,
+ rect.g_w, rect.g_h );
+ MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0 );
+ }
+ }
+}
+
+static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(background_images, !nsoption_bool(background_images));
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_back_click( input_window );
+}
+
+static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_forward_click( input_window );
+}
+
+static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_home_click( input_window );
+}
+
+static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window ) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ hotlist_open();
+}
+
+static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ verbose_log = !verbose_log;
+ MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+}
+
+static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+}
+
+static struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {T_HELP, -1, NULL,{0,0,0}, NULL }
+};
+
+void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
{
int i = 0;
LOG((""));
@@ -58,7 +406,7 @@ void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
}
-static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
+static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -68,23 +416,23 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if (gw == NULL)
+ if( gw == NULL)
return;
- if (prev_x == evnt.mx && prev_y == evnt.my) {
+ if( prev_x == evnt.mx && prev_y == evnt.my ){
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if (input_window->root->handle->handle == ghandle) {
+ if( input_window->root->handle->handle == ghandle ){
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
+ if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -94,7 +442,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
);
}
- if (gw->root->toolbar && within == false) {
+ if( gw->root->toolbar && within == false ) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -118,6 +466,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
+ char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -151,23 +500,178 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+ }
+ sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod &&
+ menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func( NULL,
+ menu_evnt_tbl[i].rid,
+ MAINMENU, buff
+ );
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
+ }
}
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ char * str = ObjcString( h_gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+
+
+ while( i>2 ){
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+
+void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
+{
+ int title = buff[ 3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+ MenuTnormal( NULL, title, 1);
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ while( menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].rid == buff[4] ) {
+ menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
+ break;
+ }
+ i++;
+ }
+}
+
+void main_menu_update( void )
+{
+ MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
+ int i, len;
+ int maxlen[NUM_MENU_TITLES]={0};
+ char * m, *u, *t;
+ char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
+ }
+ i++;
+ }
+ main_menu_update();
}
void unbind_global_events( void )
{
-
+ int i;
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
+ }
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 76e73fc..1e13264 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,8 +18,6 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
-
-#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -34,14 +32,31 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
+struct s_evnt_data evnt_data;
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
/*
- Global event handlers
+ Global & Menu event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
+void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index fdcb752..c2158e0 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,8 +73,7 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -83,8 +82,9 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-//OBJECT **rsc_trindex;
-//short rsc_ntree;
+OBJECT * h_gem_menu;
+OBJECT **rsc_trindex;
+short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,8 +789,6 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
-
- unbind_global_events();
while( gw ) {
tmp = gw->next;
@@ -804,8 +802,10 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- deskmenu_destroy();
+
+ RsrcXtype( 0, rsc_trindex, rsc_ntree);
+ unbind_global_events();
+ MenuBar( h_gem_menu , 0 );
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,8 +885,7 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form,
- MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -929,18 +928,16 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- if (rsrc_load(buf)==0) {
- die("Uable to open GEM Resource file!");
- }
- //h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ h_gem_rsrc = RsrcXload( (char*) &buf );
- //if( !h_gem_rsrc )
- // die("Uable to open GEM Resource file!");
- //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ if( !h_gem_rsrc )
+ die("Uable to open GEM Resource file!");
+ rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
+ RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -984,19 +981,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ plot_init(nsoption_charp(atari_font_driver));
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- deskmenu_init();
+ MenuBar( h_gem_menu , 1 );
+ bind_global_events();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- bind_global_events();
+ }
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index e5b0dc1..8b745fd 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,8 +273,7 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- rsrc_gaddr(R_TREE, idx, &tree);
- //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 25e0c0f..8143cdc 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,8 +31,7 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-//#include "atari/global_evnt.h"
-#include "atari/deskmenu.h"
+#include "atari/global_evnt.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -233,7 +232,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- deskmenu_update();
+ main_menu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. 6797e1f8ef51e7e22020797b68f07e0c295091ff
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6797e1f8ef51e7e220207...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6797e1f8ef51e7e22020797...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6797e1f8ef51e7e22020797b6...
The branch, master has been updated
via 6797e1f8ef51e7e22020797b68f07e0c295091ff (commit)
via 4769698d13ca82c535896d7b168ee956709b12a8 (commit)
via 8810bc01635996fc6afa33a84ffb004aca6095e3 (commit)
via ba867955a2fc4be2e17cade11dbd0a1be86ad26e (commit)
via fa9046fc97cb73329652c86d3c77376d32935333 (commit)
via 99d3633e0348fcff3f99d87696b57a70cbdcaf4d (commit)
via bec871152864b1cfb42484505a6622f7f524a405 (commit)
via b1ca83ad8c68f18194d47c06bdcb410064ca8c25 (commit)
from 6589c7cc196863d0d0694d6bd14c39386b27ae81 (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/commitdiff/6797e1f8ef51e7e2202...
commit 6797e1f8ef51e7e22020797b68f07e0c295091ff
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add nodeValue implementation
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index 8020e7a..89d0d84 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -13,7 +13,6 @@ getter nodeType %{
return JS_FALSE;
}
jsret = node_type;
-
%}
@@ -27,9 +26,27 @@ getter nodeName %{
}
if (name != NULL) {
- jsret = JS_NewStringCopyN(cx, dom_string_data(name), dom_string_length(name));
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(name),
+ dom_string_length(name));
dom_string_unref(name);
+ }
+%}
+
+getter nodeValue %{
+ dom_exception exc;
+ dom_string *value;
+
+ exc = dom_node_get_node_value(private->node, &value);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+ if (value != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(value),
+ dom_string_length(value));
+ dom_string_unref(value);
}
%}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/4769698d13ca82c5358...
commit 4769698d13ca82c535896d7b168ee956709b12a8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add enumeration test on the document node
diff --git a/test/js/dom-document-enumerate.html b/test/js/dom-document-enumerate.html
new file mode 100644
index 0000000..18146ab
--- /dev/null
+++ b/test/js/dom-document-enumerate.html
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>document interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Document interface enumeration</h1>
+
+<script>
+function output(x,y) {
+ document.body.appendChild(document.createTextNode(x));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+ document.body.appendChild(document.createTextNode(y.length));
+ }
+ document.body.appendChild(document.createTextNode(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+for(var key in document) {
+ output(key, document[key]);
+}
+</script>
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index c59b541..7500870 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -36,6 +36,7 @@
<ul>
<li><a href="dom-node-enumerate.html">Node element interface</a></li>
<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+<li><a href="dom-document-enumerate.html">Document interface</a></li>
</ul>
<h3>Document element specific</h3>
<ul>
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/8810bc01635996fc6af...
commit 8810bc01635996fc6afa33a84ffb004aca6095e3
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add nodeName implementation
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index e11e071..8020e7a 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -16,6 +16,23 @@ getter nodeType %{
%}
+
+getter nodeName %{
+ dom_exception exc;
+ dom_string *name;
+
+ exc = dom_node_get_node_name(private->node, &name);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (name != NULL) {
+ jsret = JS_NewStringCopyN(cx, dom_string_data(name), dom_string_length(name));
+ dom_string_unref(name);
+
+ }
+%}
+
getter textContent %{
dom_exception exc;
dom_string *content;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ba867955a2fc4be2e17...
commit ba867955a2fc4be2e17cade11dbd0a1be86ad26e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add nodeType
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index 3a35525..e11e071 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -4,6 +4,17 @@ webidlfile "dom.idl";
/* interface Node members */
+getter nodeType %{
+ dom_exception exc;
+ dom_node_type node_type;
+
+ exc = dom_node_get_node_type(private->node, &node_type);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+ jsret = node_type;
+
+%}
getter textContent %{
dom_exception exc;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fa9046fc97cb7332965...
commit fa9046fc97cb73329652c86d3c77376d32935333
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement childElementCount
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 0730ad4..71bb31b 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -187,3 +187,30 @@ getter nextElementSibling %{
}
}
%}
+
+getter childElementCount %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ jsret += 1;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
diff --git a/test/js/dom-element-childElementCount.html b/test/js/dom-element-childElementCount.html
new file mode 100644
index 0000000..ec4b7f8
--- /dev/null
+++ b/test/js/dom-element-childElementCount.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM childElementCount reference</title>
+</head>
+<body>
+<h1>DOM childElementCount reference</h1>
+<p><b>head.childElementCount:</b> <script>document.write(document.head.childElementCount);</script></p>
+<p><b>body.childElementCount:</b> <script>document.write(document.body.childElementCount);</script></p>
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index 5341a74..c59b541 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -27,6 +27,7 @@
<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
<li><a href="dom-element-next_prev_ElementSibling.html">previousElementSibling nextElementSibling</a></li>
+<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/99d3633e0348fcff3f9...
commit 99d3633e0348fcff3f99d87696b57a70cbdcaf4d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement previousElementSibling and nextElementSibling
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 898f781..0730ad4 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -123,7 +123,67 @@ getter lastElementChild %{
%}
getter previousElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_previous_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
getter nextElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_next_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
diff --git a/test/js/dom-element-next_prev_ElementSibling.html b/test/js/dom-element-next_prev_ElementSibling.html
new file mode 100644
index 0000000..85263cc
--- /dev/null
+++ b/test/js/dom-element-next_prev_ElementSibling.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>DOM previousElementSibling and nextElementSibling reference</title>
+<!-- comment node should be skipped -->
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>DOM previousElementSibling and nextElementSibling reference</h1>
+<!-- comment node should be skipped -->
+<p><b>head.lastElementChild.previousElementSibling:</b> <script>document.write(document.head.lastElementChild.previousElementSibling.textContent);</script></p>
+<!-- comment node should be skipped -->
+<p><b>body.firstElementChild.nextElementSibling:</b> <script>document.write(document.body.firstElementChild.nextElementSibling.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index 70e4088..5341a74 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -26,6 +26,7 @@
<ul>
<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
+<li><a href="dom-element-next_prev_ElementSibling.html">previousElementSibling nextElementSibling</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/bec871152864b1cfb42...
commit bec871152864b1cfb42484505a6622f7f524a405
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement lastElementChild
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 3b533eb..898f781 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -89,6 +89,37 @@ getter firstElementChild %{
%}
getter lastElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_last_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+
+ }
%}
getter previousElementSibling %{
diff --git a/test/js/doc-dom1.html b/test/js/doc-dom1.html
deleted file mode 100644
index 2d7762d..0000000
--- a/test/js/doc-dom1.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-<head>
-<title>DOM firstElementChild reference</title>
-<link rel="stylesheet" type="text/css" href="tst.css">
-</head>
-<body>
-<h1>DOM firstElementChild reference</h1>
-<p><b>head.firstElementChild:</b> <script>document.write(document.head.firstElementChild.textContent);</script></p>
-<p><b>body.firstElementChild:</b> <script>document.write(document.body.firstElementChild.textContent);</script></p>
-</body>
-</html>
diff --git a/test/js/dom-element-firstElementChild.html b/test/js/dom-element-firstElementChild.html
new file mode 100644
index 0000000..2d7762d
--- /dev/null
+++ b/test/js/dom-element-firstElementChild.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<title>DOM firstElementChild reference</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>DOM firstElementChild reference</h1>
+<p><b>head.firstElementChild:</b> <script>document.write(document.head.firstElementChild.textContent);</script></p>
+<p><b>body.firstElementChild:</b> <script>document.write(document.body.firstElementChild.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/dom-element-lastElementChild.html b/test/js/dom-element-lastElementChild.html
new file mode 100644
index 0000000..e4e9f11
--- /dev/null
+++ b/test/js/dom-element-lastElementChild.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM lastElementChild reference</title>
+</head>
+<body>
+<h1>DOM lastElementChild reference</h1>
+<p><b>head.lastElementChild:</b> <script>document.write(document.head.lastElementChild.textContent);</script></p>
+<p><b>body.lastElementChild:</b> <script>document.write(document.body.lastElementChild.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index f02c4df..70e4088 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -24,7 +24,8 @@
<h2>DOM tests</h2>
<h3>Reference method tests</h3>
<ul>
-<li><a href="doc-dom1.html">firstElementChild</a></li>
+<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
+<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/b1ca83ad8c68f18194d...
commit b1ca83ad8c68f18194d47c06bdcb410064ca8c25
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement firstElementChild
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 18e343f..3b533eb 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -20,7 +20,7 @@ hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -35,16 +35,57 @@ binding htmlelement {
interface HTMLElement; /* Web IDL interface to generate */
private "dom_element *" node;
- private "struct html_content *" htmlc;
+ private "struct html_content *" htmlc;
}
api finalise %{
- if (private != NULL) {
- dom_node_unref(private->node);
- }
+ if (private != NULL) {
+ dom_node_unref(private->node);
+ }
%}
+/* interface Element in dom idl */
+
+/*
+ * DOM 3 has these as the element traversal extension
+ *
+ * http://dev.w3.org/2006/webapi/ElementTraversal/publish/ElementTraversal.html
+ */
+
getter firstElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+
+ }
+
+
%}
getter lastElementChild %{
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/dom.bnd | 45 +++++
javascript/jsapi/htmlelement.bnd | 173 +++++++++++++++++++-
...-enumerate.html => dom-document-enumerate.html} | 13 +-
test/js/dom-element-childElementCount.html | 11 ++
...om1.html => dom-element-firstElementChild.html} | 0
test/js/dom-element-lastElementChild.html | 11 ++
test/js/dom-element-next_prev_ElementSibling.html | 14 ++
test/js/index.html | 6 +-
8 files changed, 259 insertions(+), 14 deletions(-)
copy test/js/{dom-node-enumerate.html => dom-document-enumerate.html} (68%)
create mode 100644 test/js/dom-element-childElementCount.html
rename test/js/{doc-dom1.html => dom-element-firstElementChild.html} (100%)
create mode 100644 test/js/dom-element-lastElementChild.html
create mode 100644 test/js/dom-element-next_prev_ElementSibling.html
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index 3a35525..89d0d84 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -4,6 +4,51 @@ webidlfile "dom.idl";
/* interface Node members */
+getter nodeType %{
+ dom_exception exc;
+ dom_node_type node_type;
+
+ exc = dom_node_get_node_type(private->node, &node_type);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+ jsret = node_type;
+%}
+
+
+getter nodeName %{
+ dom_exception exc;
+ dom_string *name;
+
+ exc = dom_node_get_node_name(private->node, &name);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (name != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(name),
+ dom_string_length(name));
+ dom_string_unref(name);
+ }
+%}
+
+getter nodeValue %{
+ dom_exception exc;
+ dom_string *value;
+
+ exc = dom_node_get_node_value(private->node, &value);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (value != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(value),
+ dom_string_length(value));
+ dom_string_unref(value);
+ }
+%}
getter textContent %{
dom_exception exc;
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 18e343f..71bb31b 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -20,7 +20,7 @@ hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -35,23 +35,182 @@ binding htmlelement {
interface HTMLElement; /* Web IDL interface to generate */
private "dom_element *" node;
- private "struct html_content *" htmlc;
+ private "struct html_content *" htmlc;
}
api finalise %{
- if (private != NULL) {
- dom_node_unref(private->node);
- }
+ if (private != NULL) {
+ dom_node_unref(private->node);
+ }
%}
+/* interface Element in dom idl */
+
+/*
+ * DOM 3 has these as the element traversal extension
+ *
+ * http://dev.w3.org/2006/webapi/ElementTraversal/publish/ElementTraversal.html
+ */
+
getter firstElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+
+ }
+
+
%}
getter lastElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_last_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+
+ }
%}
getter previousElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_previous_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
getter nextElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_next_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
+
+getter childElementCount %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ jsret += 1;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-document-enumerate.html
similarity index 68%
copy from test/js/dom-node-enumerate.html
copy to test/js/dom-document-enumerate.html
index 573e27b..18146ab 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-document-enumerate.html
@@ -1,24 +1,25 @@
<html>
<head>
-<title>Node interface enumeration</title>
+<title>document interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Node interface enumeration</h1>
+<h1>Document interface enumeration</h1>
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
document.body.appendChild(document.createTextNode("("));
if (y != undefined) {
-document.body.appendChild(document.createTextNode(y.length));
-}
+ document.body.appendChild(document.createTextNode(y.length));
+ }
document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
-for(var key in Node){
-output(key, Node[key]);
+
+for(var key in document) {
+ output(key, document[key]);
}
</script>
</body>
diff --git a/test/js/dom-element-childElementCount.html b/test/js/dom-element-childElementCount.html
new file mode 100644
index 0000000..ec4b7f8
--- /dev/null
+++ b/test/js/dom-element-childElementCount.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM childElementCount reference</title>
+</head>
+<body>
+<h1>DOM childElementCount reference</h1>
+<p><b>head.childElementCount:</b> <script>document.write(document.head.childElementCount);</script></p>
+<p><b>body.childElementCount:</b> <script>document.write(document.body.childElementCount);</script></p>
+</body>
+</html>
diff --git a/test/js/doc-dom1.html b/test/js/dom-element-firstElementChild.html
similarity index 100%
rename from test/js/doc-dom1.html
rename to test/js/dom-element-firstElementChild.html
diff --git a/test/js/dom-element-lastElementChild.html b/test/js/dom-element-lastElementChild.html
new file mode 100644
index 0000000..e4e9f11
--- /dev/null
+++ b/test/js/dom-element-lastElementChild.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM lastElementChild reference</title>
+</head>
+<body>
+<h1>DOM lastElementChild reference</h1>
+<p><b>head.lastElementChild:</b> <script>document.write(document.head.lastElementChild.textContent);</script></p>
+<p><b>body.lastElementChild:</b> <script>document.write(document.body.lastElementChild.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/dom-element-next_prev_ElementSibling.html b/test/js/dom-element-next_prev_ElementSibling.html
new file mode 100644
index 0000000..85263cc
--- /dev/null
+++ b/test/js/dom-element-next_prev_ElementSibling.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>DOM previousElementSibling and nextElementSibling reference</title>
+<!-- comment node should be skipped -->
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>DOM previousElementSibling and nextElementSibling reference</h1>
+<!-- comment node should be skipped -->
+<p><b>head.lastElementChild.previousElementSibling:</b> <script>document.write(document.head.lastElementChild.previousElementSibling.textContent);</script></p>
+<!-- comment node should be skipped -->
+<p><b>body.firstElementChild.nextElementSibling:</b> <script>document.write(document.body.firstElementChild.nextElementSibling.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index f02c4df..7500870 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -24,7 +24,10 @@
<h2>DOM tests</h2>
<h3>Reference method tests</h3>
<ul>
-<li><a href="doc-dom1.html">firstElementChild</a></li>
+<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
+<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
+<li><a href="dom-element-next_prev_ElementSibling.html">previousElementSibling nextElementSibling</a></li>
+<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
@@ -33,6 +36,7 @@
<ul>
<li><a href="dom-node-enumerate.html">Node element interface</a></li>
<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+<li><a href="dom-document-enumerate.html">Document interface</a></li>
</ul>
<h3>Document element specific</h3>
<ul>
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. a044206384cb02aaaaab65f813878ddcd44b1dd1
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/a044206384cb02aaa...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/a044206384cb02aaaaa...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/a044206384cb02aaaaab6...
The branch, master has been updated
via a044206384cb02aaaaab65f813878ddcd44b1dd1 (commit)
from 3d3e27d666c7c35ab95f450c68766a9ba996a485 (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/nsgenjsbind.git/commitdiff/a044206384cb02a...
commit a044206384cb02aaaaab65f813878ddcd44b1dd1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add short property handling
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index e87620e..d96228a 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -192,7 +192,10 @@ static int output_return(struct binding *binding,
break;
case WEBIDL_TYPE_SHORT:
- WARN(WARNING_UNIMPLEMENTED, "Unhandled type WEBIDL_TYPE_SHORT");
+ /* int16_t */
+ fprintf(binding->outfile,
+ "\tJS_SET_RVAL(cx, vp, INT_TO_JSVAL(%s));\n",
+ ident);
break;
case WEBIDL_TYPE_LONGLONG:
@@ -296,7 +299,21 @@ static int output_return_declaration(struct binding *binding,
break;
case WEBIDL_TYPE_SHORT:
- WARN(WARNING_UNIMPLEMENTED, "Unhandled type WEBIDL_TYPE_SHORT");
+ /* int16_t */
+ type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+ if ((type_mod != NULL) &&
+ (webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
+ fprintf(binding->outfile,
+ "\tuint16_t %s = 0;\n",
+ ident);
+ } else {
+ fprintf(binding->outfile,
+ "\tint16_t %s = 0;\n",
+ ident);
+ }
+
break;
case WEBIDL_TYPE_LONGLONG:
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index e87620e..d96228a 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -192,7 +192,10 @@ static int output_return(struct binding *binding,
break;
case WEBIDL_TYPE_SHORT:
- WARN(WARNING_UNIMPLEMENTED, "Unhandled type WEBIDL_TYPE_SHORT");
+ /* int16_t */
+ fprintf(binding->outfile,
+ "\tJS_SET_RVAL(cx, vp, INT_TO_JSVAL(%s));\n",
+ ident);
break;
case WEBIDL_TYPE_LONGLONG:
@@ -296,7 +299,21 @@ static int output_return_declaration(struct binding *binding,
break;
case WEBIDL_TYPE_SHORT:
- WARN(WARNING_UNIMPLEMENTED, "Unhandled type WEBIDL_TYPE_SHORT");
+ /* int16_t */
+ type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+ if ((type_mod != NULL) &&
+ (webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
+ fprintf(binding->outfile,
+ "\tuint16_t %s = 0;\n",
+ ident);
+ } else {
+ fprintf(binding->outfile,
+ "\tint16_t %s = 0;\n",
+ ident);
+ }
+
break;
case WEBIDL_TYPE_LONGLONG:
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch chris/frame-scroll updated. 9a1a1209be4461eb3b7ff40eed23aa35ab0c54e2
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9a1a1209be4461eb3b7ff...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9a1a1209be4461eb3b7ff40...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9a1a1209be4461eb3b7ff40ee...
The branch, chris/frame-scroll has been updated
via 9a1a1209be4461eb3b7ff40eed23aa35ab0c54e2 (commit)
via 61241b731c4d92ed2dc77beb262645cea1593fdb (commit)
via bb260da36e2408421c548f93cbfd28fc0052f50f (commit)
via 64226af7488440725041e2ab1034cc735f16bb21 (commit)
via e310dac092797fa34008fea203a07291f5838ba1 (commit)
via 6589c7cc196863d0d0694d6bd14c39386b27ae81 (commit)
via 82cae102843de3f9d638648556592cf9d09c9638 (commit)
via e36b8f657997ffca3d1cc1fe1a7130854d247262 (commit)
via c5fb16d56df03580d99fae44d9fea44868f33cc5 (commit)
via d1a5c738e62a9f0cb85658b435eefa8749006edc (commit)
from 78e460e4bdfdfb1daed9a9549381f3e742ba4786 (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/commitdiff/9a1a1209be4461eb3b7...
commit 9a1a1209be4461eb3b7ff40eed23aa35ab0c54e2
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
debug
diff --git a/amiga/gui.c b/amiga/gui.c
index a081a52..45b0b41 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1049,7 +1049,7 @@ bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
ns_y *= gwin->bw->scale;
if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
- return false;
+ /* outside screen bounds, but we don't care yet - return false */;
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/61241b731c4d92ed2dc...
commit 61241b731c4d92ed2dc77beb262645cea1593fdb
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
We need to adjust for the frontend needing to know the offsets based on where the scrollbars were, rather than where they are now.
diff --git a/desktop/browser.c b/desktop/browser.c
index 0ecb0ac..b7584c1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1963,16 +1963,19 @@ void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x
}
} else {
/* Core managed browser window */
+ int off_x = scrollbar_get_offset(bw->scroll_x) - bw->prev_scroll_x;
+ int off_y = scrollbar_get_offset(bw->scroll_y) - bw->prev_scroll_x;
+
browser_window_get_position(bw, true, &pos_x, &pos_y);
top = browser_window_get_root(bw);
- rect->x0 += pos_x / bw->scale;
- rect->y0 += pos_y / bw->scale;
- rect->x1 += pos_x / bw->scale;
- rect->y1 += pos_y / bw->scale;
+ rect->x0 += (pos_x + off_x) / bw->scale;
+ rect->y0 += (pos_y + off_y) / bw->scale;
+ rect->x1 += (pos_x + off_x) / bw->scale;
+ rect->y1 += (pos_y + off_y) / bw->scale;
- if(gui_window_copy_box(top->window, rect, x + pos_x, y + pos_y) == false) {
+ if(gui_window_copy_box(top->window, rect, x + pos_x + off_x, y + pos_y + off_y) == false) {
gui_window_update_box(top->window, rect);
}
}
diff --git a/desktop/frames.c b/desktop/frames.c
index 88d49f2..e0b90e8 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -70,7 +70,7 @@ void browser_window_scroll_callback(void *client_data,
int dest_y;
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
-
+
rect_y.x0 = 0;
rect_y.x1 = bw->width;
rect_x.y0 = 0;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/bb260da36e2408421c5...
commit bb260da36e2408421c548f93cbfd28fc0052f50f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Turns out these were more correct the first time I wrote them.
diff --git a/desktop/frames.c b/desktop/frames.c
index 6dd0d09..88d49f2 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -66,8 +66,8 @@ void browser_window_scroll_callback(void *client_data,
struct rect rect_x;
struct rect rect_y;
struct rect copyrect;
- int dest_x = 0;
- int dest_y = 0;
+ int dest_x;
+ int dest_y;
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
@@ -77,41 +77,41 @@ void browser_window_scroll_callback(void *client_data,
rect_x.y1 = bw->height;
if(cur_y > bw->prev_scroll_y) {
- copyrect.y0 = cur_y - bw->prev_scroll_y;
- copyrect.y1 = bw->height;
- dest_y = 0;
+ copyrect.y0 = cur_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = bw->prev_scroll_y;
- rect_y.y0 = bw->height - copyrect.y0;
- rect_y.y1 = bw->height;
+ rect_y.y0 = copyrect.y0;
+ rect_y.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
rect_x.y0 = 0;
rect_x.y1 = rect_y.y0;
} else {
- copyrect.y0 = 0;
- copyrect.y1 = bw->height - (cur_y - bw->prev_scroll_y);
- dest_y = cur_y - bw->prev_scroll_y;
+ copyrect.y0 = bw->prev_scroll_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
+ dest_y = cur_y;
- rect_y.y0 = 0;
- rect_y.y1 = cur_y - bw->prev_scroll_y;
+ rect_y.y0 = cur_y;
+ rect_y.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
rect_x.y0 = rect_y.y1;
rect_x.y1 = bw->height;
}
if(cur_x > bw->prev_scroll_x) {
- copyrect.x0 = cur_x - bw->prev_scroll_x;
- copyrect.x1 = bw->width;
- dest_x = 0;
+ copyrect.x0 = cur_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = bw->prev_scroll_x;
- rect_x.x0 = bw->height - copyrect.x0;
- rect_x.x1 = bw->height;
+ rect_x.x0 = copyrect.x0;
+ rect_x.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
} else {
- copyrect.x0 = 0;
- copyrect.x1 = bw->width - (cur_x - bw->prev_scroll_x);
- dest_x = cur_x - bw->prev_scroll_x;
+ copyrect.x0 = bw->prev_scroll_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
+ dest_x = cur_x;
- rect_x.x0 = 0;
- rect_x.x1 = cur_x - bw->prev_scroll_x;
+ rect_x.x0 = cur_x;
+ rect_x.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
}
browser_window_copy_box(bw, ©rect, dest_x, dest_y);
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/64226af748844072504...
commit 64226af7488440725041e2ab1034cc735f16bb21
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Use ClipBlit as BltBitMapTags inexplicably doesn't work with overlapping areas.
diff --git a/amiga/gui.c b/amiga/gui.c
index 185049d..a081a52 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3613,18 +3613,10 @@ printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, des
if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
- BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
- BLITA_Source, gwin->win->RPort,
- BLITA_SrcX, src_x,
- BLITA_SrcY, src_y,
- BLITA_DestType, BLITT_RASTPORT,
- BLITA_Dest, gwin->win->RPort,
- BLITA_DestX, dest_x,
- BLITA_DestY, dest_y,
- BLITA_Width, src_x1 - src_x,
- BLITA_Height, src_y1 - src_y,
- TAG_DONE);
-
+ ClipBlit(gwin->win->RPort, src_x, src_y,
+ gwin->win->RPort, dest_x, dest_y,
+ src_x1 - src_x, src_y1 - src_y, 0xC0);
+
return true;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/e310dac092797fa3400...
commit e310dac092797fa34008fea203a07291f5838ba1
Merge: 78e460e 6589c7c
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/frame-scroll
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 18 +-
atari/Makefile.target | 2 +-
atari/{global_evnt.c => deskmenu.c} | 757 +++++++++++++++++------------------
atari/deskmenu.h | 12 +
atari/global_evnt.c | 534 +------------------------
atari/global_evnt.h | 23 +-
atari/gui.c | 47 ++-
atari/misc.c | 3 +-
atari/settings.c | 5 +-
desktop/browser.c | 13 +-
desktop/frames.c | 46 +-
javascript/jsapi.h | 80 +++--
javascript/jsapi/htmldocument.bnd | 49 ++-
test/js/dom-body-enumerate.html | 27 ++
test/js/dom-node-enumerate.html | 6 +-
test/js/index.html | 5 +
16 files changed, 587 insertions(+), 1040 deletions(-)
copy atari/{global_evnt.c => deskmenu.c} (52%)
mode change 100755 => 100644
create mode 100644 atari/deskmenu.h
create mode 100644 test/js/dom-body-enumerate.html
diff --git a/amiga/gui.c b/amiga/gui.c
index 185049d..45b0b41 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1049,7 +1049,7 @@ bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
ns_y *= gwin->bw->scale;
if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
- return false;
+ /* outside screen bounds, but we don't care yet - return false */;
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
@@ -3613,18 +3613,10 @@ printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, des
if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
- BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
- BLITA_Source, gwin->win->RPort,
- BLITA_SrcX, src_x,
- BLITA_SrcY, src_y,
- BLITA_DestType, BLITT_RASTPORT,
- BLITA_Dest, gwin->win->RPort,
- BLITA_DestX, dest_x,
- BLITA_DestY, dest_y,
- BLITA_Width, src_x1 - src_x,
- BLITA_Height, src_y1 - src_y,
- TAG_DONE);
-
+ ClipBlit(gwin->win->RPort, src_x, src_y,
+ gwin->win->RPort, dest_x, dest_y,
+ src_x1 - src_x, src_y1 - src_y, 0xC0);
+
return true;
}
diff --git a/atari/Makefile.target b/atari/Makefile.target
index ad90807..f7e1a63 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c
+ ctxmenu.c settings.c msgbox.c deskmenu.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/global_evnt.c b/atari/deskmenu.c
old mode 100755
new mode 100644
similarity index 52%
copy from atari/global_evnt.c
copy to atari/deskmenu.c
index 3b15af8..38e3539
--- a/atari/global_evnt.c
+++ b/atari/deskmenu.c
@@ -1,73 +1,59 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <windom.h>
-
-#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
-#include "utils/log.h"
+#include <stdlib.h>
+#include <windom.h>
+
+#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
-
-#include "atari/gui.h"
-#include "atari/browser_win.h"
-#include "atari/toolbar.h"
-#include "atari/browser.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/deskmenu.h"
#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
-#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
+#include "atari/history.h"
+#include "atari/toolbar.h"
+#include "atari/settings.h"
+#include "atari/search.h"
+#include "atari/misc.h"
+#include "atari/gui.h"
#include "atari/findfile.h"
-#include "atari/settings.h"
-#include "cflib.h"
-
-extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
-extern int mouse_click_time[3];
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
-extern bool html_redraw_debug;
+#include "atari/browser.h"
+#include "atari/browser_win.h"
+
+typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
+
+static void register_menu_str(struct s_menu_item_evnt * mi);
+static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
+
+extern void *h_gem_rsrc;
+extern bool html_redraw_debug;
+extern struct gui_window * input_window;
+extern char options[PATH_MAX];
extern const char * option_homepage_url;
extern int option_window_width;
extern int option_window_height;
extern int option_window_x;
extern int option_window_y;
-extern char options[PATH_MAX];
+
+static OBJECT * h_gem_menu;
+
/* Zero based resource tree ids: */
#define T_ABOUT 0
@@ -80,33 +66,184 @@ extern char options[PATH_MAX];
/* Count of the above defines: */
#define NUM_MENU_TITLES 7
-/* Global event handlers: */
-static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
+
+static void __CDECL menu_about(short item, short title, void *data);
+static void __CDECL menu_new_win(short item, short title, void *data);
+static void __CDECL menu_open_url(short item, short title, void *data);
+static void __CDECL menu_open_file(short item, short title, void *data);
+static void __CDECL menu_close_win(short item, short title, void *data);
+static void __CDECL menu_save_page(short item, short title, void *data);
+static void __CDECL menu_quit(short item, short title, void *data);
+static void __CDECL menu_cut(short item, short title, void *data);
+static void __CDECL menu_copy(short item, short title, void *data);
+static void __CDECL menu_paste(short item, short title, void *data);
+static void __CDECL menu_find(short item, short title, void *data);
+static void __CDECL menu_choices(short item, short title, void *data);
+static void __CDECL menu_stop(short item, short title, void *data);
+static void __CDECL menu_reload(short item, short title, void *data);
+static void __CDECL menu_toolbars(short item, short title, void *data);
+static void __CDECL menu_savewin(short item, short title, void *data);
+static void __CDECL menu_debug_render(short item, short title, void *data);
+static void __CDECL menu_fg_images(short item, short title, void *data);
+static void __CDECL menu_bg_images(short item, short title, void *data);
+static void __CDECL menu_back(short item, short title, void *data);
+static void __CDECL menu_forward(short item, short title, void *data);
+static void __CDECL menu_home(short item, short title, void *data);
+static void __CDECL menu_lhistory(short item, short title, void *data);
+static void __CDECL menu_ghistory(short item, short title, void *data);
+static void __CDECL menu_add_bookmark(short item, short title, void *data);
+static void __CDECL menu_bookmarks(short item, short title, void *data);
+static void __CDECL menu_vlog(short item, short title, void *data);
+static void __CDECL menu_help_content(short item, short title, void *data);
+
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
+};
+
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ OBJECT *gem_menu = deskmenu_get_obj_tree();
+
+ assert(gem_menu != NULL);
+
+ char * str = ObjcString( gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+ while (i > 2) {
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+
+ deskmenu_dispatch_item(buff[3], buff[4]);
+}
+
+/*
+ Menu item event handlers:
+*/
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_about(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
char buf[PATH_MAX];
strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ strncat((char*)&buf, (char*)"./doc/README.TXT",
+ PATH_MAX - (strlen("file://")+1) );
browser_window_create((char*)&buf, 0, 0, true, false);
}
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_new_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
browser_window_create(option_homepage_url, 0, 0, true, false);
}
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_url(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -128,7 +265,7 @@ static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
tb_url_input( gw, NK_DEL );
}
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_file(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -145,7 +282,7 @@ static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_close_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -153,7 +290,7 @@ static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
gui_window_destroy( input_window );
}
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_save_page(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
static bool init = true;
@@ -181,49 +318,49 @@ static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_quit(short item, short title, void *data)
{
short buff[8];
memset( &buff, 0, sizeof(short)*8 );
LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
+ netsurf_quit = true;
}
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_cut(short item, short title, void *data)
{
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
}
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_copy(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
}
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_paste(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_PASTE);
}
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_find(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
open_browser_search( input_window );
}
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_choices(short item, short title, void *data)
{
static WINDOW * settings_dlg = NULL;
LOG(("%s", __FUNCTION__));
settings_dlg = open_settings();
}
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -232,7 +369,7 @@ static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_reload(short item, short title, void *data)
{
if( input_window == NULL)
return;
@@ -240,7 +377,7 @@ static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
LOG(("%s", __FUNCTION__));
}
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_toolbars(short item, short title, void *data)
{
static int state = 0;
LOG(("%s", __FUNCTION__));
@@ -250,7 +387,7 @@ static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_savewin(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
@@ -269,12 +406,13 @@ static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_debug_render(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
html_redraw_debug = !html_redraw_debug;
if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ if ( input_window->browser != NULL
+ && input_window->browser->bw != NULL) {
LGRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
@@ -285,19 +423,21 @@ static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *da
}
}
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_fg_images(short item, short title, void *data)
{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
}
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_bg_images(short item, short title, void *data)
{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
}
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_back(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -305,7 +445,7 @@ static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
tb_back_click( input_window );
}
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_forward(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -313,7 +453,7 @@ static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
tb_forward_click( input_window );
}
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_home(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -321,191 +461,169 @@ static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
tb_home_click( input_window );
}
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_lhistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
}
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_ghistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
global_history_open();
}
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- if( input_window ) {
+ if (input_window) {
if( input_window->browser->bw->current_content != NULL ){
atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
NULL
);
}
}
}
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_bookmarks(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
hotlist_open();
}
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_vlog(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
verbose_log = !verbose_log;
MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
}
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_help_content(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
-{
- int i = 0;
- LOG((""));
- netsurf_quit = true;
}
-
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
-{
- struct gui_window * gw = input_window;
- static bool prev_url = false;
- static short prev_x=0;
- static short prev_y=0;
- bool within = false;
- LGRECT urlbox, bwbox, sbbox;
- int nx, ny;
-
- if( gw == NULL)
- return;
+/*
+ Public deskmenu interface:
+*/
- if( prev_x == evnt.mx && prev_y == evnt.my ){
- return;
+
+/**
+* Setup & display an desktop menu.
+*/
+
+void deskmenu_init(void)
+{
+ int i;
+
+ h_gem_menu = get_tree(MAINMENU);
+
+ // TODO: remove that call somehow...
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ /* Update menu string if not null: */
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
+ menu_evnt_tbl[i].menustr);
+ }
+ i++;
}
+ deskmenu_update();
- short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ menu_bar(h_gem_menu, 100);
+ menu_bar(h_gem_menu, 1);
- // The window found at x,y is an gui_window
- // and it's the input window.
-
- browser_get_rect( gw, BR_CONTENT, &bwbox );
-
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
- within = true;
- browser_window_mouse_track(
- input_window->browser->bw,
- 0,
- evnt.mx - bwbox.g_x + gw->browser->scroll.current.x,
- evnt.my - bwbox.g_y + gw->browser->scroll.current.y
- );
- }
+ // TODO: remove windom dependency.
+ EvntAttach(NULL, MN_SELECTED, evnt_menu);
+}
- if( gw->root->toolbar && within == false ) {
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
- (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
- gem_set_cursor( &gem_cursors.ibeam );
- prev_url = true;
- } else {
- if( prev_url ) {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
- }
- }
- }
- } else {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
+/**
+* Uninstall the desktop menu
+*/
+void deskmenu_destroy(void)
+{
+ int i;
+
+ /* Remove menu from desktop: */
+ menu_bar(h_gem_menu, 0);
+
+ /* Free modified menu titles: */
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
}
+}
- prev_x = evnt.mx;
- prev_y = evnt.my;
-}
-
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
-{
- char sascii;
- long kstate = 0;
- long kcode = 0;
- unsigned short nkc = 0;
- unsigned short nks = 0;
-
- int i=0;
- bool done = false;
- struct gui_window * gw = input_window;
- struct gui_window * gw_tmp;
- if( gw == NULL )
- return;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
- nkc= gem_to_norm( (short)kstate, (short)kcode );
- nks = (nkc & 0xFF00);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
- /* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
- } else {
- gw_tmp = window_list;
- /* search for active browser component: */
- while( gw_tmp != NULL && done == false ) {
- /* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
- break;
- } else {
- gw_tmp = gw_tmp->next;
+/**
+* Return the deskmenu AES OBJECT tree
+*/
+OBJECT * deskmenu_get_obj_tree(void)
+{
+ return(h_gem_menu);
+}
+
+/**
+* Handle an menu item event
+*/
+int deskmenu_dispatch_item(short title, short item)
+{
+ int i=0;
+ int retval = 0;
+ OBJECT * menu_root = deskmenu_get_obj_tree();
+
+ menu_tnormal(menu_root, item, 1);
+ menu_tnormal(menu_root, title, 1);
+ menu_bar(menu_root, 1);
+
+ // legacy code, is this sensible?:
+ /*
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ */
+
+
+ while (menu_evnt_tbl[i].rid != -1) {
+ if (menu_evnt_tbl[i].rid == item) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func(item, title, NULL);
}
+ break;
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ i++;
+ }
+
+ return(retval);
+}
+
+/**
+* Handle an keypress (check for accelerator)
+*/
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ char sascii;
+ bool done = 0;
+ int i = 0;
+
+ sascii = keybd2ascii(kcode, K_LSHIFT);
+
+ /* Iterate through the menu function table: */
while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ if( kstate == menu_evnt_tbl[i].accel.mod
+ && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
@@ -513,165 +631,30 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
/* the accel code hides in the keycode: */
if( menu_evnt_tbl[i].accel.keycode != 0) {
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
+ kstate == menu_evnt_tbl[i].accel.mod) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
}
}
i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
+ }
+ return((done==true) ? 1 : 0);
+}
+/**
+* Refresh the desk menu, reflecting netsurf current state.
*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
+void deskmenu_update(void)
{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
+ OBJECT * gem_menu = deskmenu_get_obj_tree();
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-
-/* Bind global and menu events to event handler functions, create accelerators */
-void bind_global_events( void )
-{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
- memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
- EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
- EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+ menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
-}
-
-void unbind_global_events( void )
-{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
new file mode 100644
index 0000000..6ab00dc
--- /dev/null
+++ b/atari/deskmenu.h
@@ -0,0 +1,12 @@
+#ifndef DESKMENU_H_INCLUDED
+#define DESKMENU_H_INCLUDED
+
+void deskmenu_init(void);
+void deskmenu_destroy(void);
+int deskmenu_dispatch_item(short title, short item);
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
+OBJECT * deskmenu_get_obj_tree(void);
+void deskmenu_update( void );
+
+#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 3b15af8..e3a93a0 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,379 +26,31 @@
#include <windom.h>
#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
-#include "atari/findfile.h"
-#include "atari/settings.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
-extern bool html_redraw_debug;
-
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-extern char options[PATH_MAX];
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
-}
-
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window ) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
+void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
{
int i = 0;
LOG((""));
@@ -406,7 +58,7 @@ void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
}
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
+static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -416,23 +68,23 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if( gw == NULL)
+ if (gw == NULL)
return;
- if( prev_x == evnt.mx && prev_y == evnt.my ){
+ if (prev_x == evnt.mx && prev_y == evnt.my) {
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ if (input_window->root->handle->handle == ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -442,7 +94,7 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
);
}
- if( gw->root->toolbar && within == false ) {
+ if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -466,7 +118,6 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -500,178 +151,23 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
- }
- }
- i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
-
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
}
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
-
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
}
void unbind_global_events( void )
{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
+
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1e13264..76e73fc 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,6 +18,8 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
+
+#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -32,31 +34,14 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
+struct s_evnt_data evnt_data;
/*
- Global & Menu event handlers
+ Global event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
-void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index c2158e0..fdcb752 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,7 +73,8 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
+#include "atari/search.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -82,9 +83,8 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-OBJECT * h_gem_menu;
-OBJECT **rsc_trindex;
-short rsc_ntree;
+//OBJECT **rsc_trindex;
+//short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,6 +789,8 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
+
+ unbind_global_events();
while( gw ) {
tmp = gw->next;
@@ -802,10 +804,8 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- RsrcXtype( 0, rsc_trindex, rsc_ntree);
- unbind_global_events();
- MenuBar( h_gem_menu , 0 );
+
+ deskmenu_destroy();
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,7 +885,8 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form,
+ MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -928,16 +929,18 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ if (rsrc_load(buf)==0) {
+ die("Uable to open GEM Resource file!");
+ }
+ //h_gem_rsrc = RsrcXload( (char*) &buf );
- if( !h_gem_rsrc )
- die("Uable to open GEM Resource file!");
- rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ //if( !h_gem_rsrc )
+ // die("Uable to open GEM Resource file!");
+ //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
- RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -981,19 +984,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
+ plot_init(nsoption_charp(atari_font_driver));
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- MenuBar( h_gem_menu , 1 );
- bind_global_events();
+ deskmenu_init();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ }
+ bind_global_events();
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index 8b745fd..e5b0dc1 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,7 +273,8 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ rsrc_gaddr(R_TREE, idx, &tree);
+ //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 8143cdc..25e0c0f 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,7 +31,8 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-#include "atari/global_evnt.h"
+//#include "atari/global_evnt.h"
+#include "atari/deskmenu.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -232,7 +233,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- main_menu_update();
+ deskmenu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
diff --git a/desktop/browser.c b/desktop/browser.c
index 0ecb0ac..b7584c1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1963,16 +1963,19 @@ void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x
}
} else {
/* Core managed browser window */
+ int off_x = scrollbar_get_offset(bw->scroll_x) - bw->prev_scroll_x;
+ int off_y = scrollbar_get_offset(bw->scroll_y) - bw->prev_scroll_x;
+
browser_window_get_position(bw, true, &pos_x, &pos_y);
top = browser_window_get_root(bw);
- rect->x0 += pos_x / bw->scale;
- rect->y0 += pos_y / bw->scale;
- rect->x1 += pos_x / bw->scale;
- rect->y1 += pos_y / bw->scale;
+ rect->x0 += (pos_x + off_x) / bw->scale;
+ rect->y0 += (pos_y + off_y) / bw->scale;
+ rect->x1 += (pos_x + off_x) / bw->scale;
+ rect->y1 += (pos_y + off_y) / bw->scale;
- if(gui_window_copy_box(top->window, rect, x + pos_x, y + pos_y) == false) {
+ if(gui_window_copy_box(top->window, rect, x + pos_x + off_x, y + pos_y + off_y) == false) {
gui_window_update_box(top->window, rect);
}
}
diff --git a/desktop/frames.c b/desktop/frames.c
index 6dd0d09..e0b90e8 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -66,52 +66,52 @@ void browser_window_scroll_callback(void *client_data,
struct rect rect_x;
struct rect rect_y;
struct rect copyrect;
- int dest_x = 0;
- int dest_y = 0;
+ int dest_x;
+ int dest_y;
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
-
+
rect_y.x0 = 0;
rect_y.x1 = bw->width;
rect_x.y0 = 0;
rect_x.y1 = bw->height;
if(cur_y > bw->prev_scroll_y) {
- copyrect.y0 = cur_y - bw->prev_scroll_y;
- copyrect.y1 = bw->height;
- dest_y = 0;
+ copyrect.y0 = cur_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = bw->prev_scroll_y;
- rect_y.y0 = bw->height - copyrect.y0;
- rect_y.y1 = bw->height;
+ rect_y.y0 = copyrect.y0;
+ rect_y.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
rect_x.y0 = 0;
rect_x.y1 = rect_y.y0;
} else {
- copyrect.y0 = 0;
- copyrect.y1 = bw->height - (cur_y - bw->prev_scroll_y);
- dest_y = cur_y - bw->prev_scroll_y;
+ copyrect.y0 = bw->prev_scroll_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
+ dest_y = cur_y;
- rect_y.y0 = 0;
- rect_y.y1 = cur_y - bw->prev_scroll_y;
+ rect_y.y0 = cur_y;
+ rect_y.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
rect_x.y0 = rect_y.y1;
rect_x.y1 = bw->height;
}
if(cur_x > bw->prev_scroll_x) {
- copyrect.x0 = cur_x - bw->prev_scroll_x;
- copyrect.x1 = bw->width;
- dest_x = 0;
+ copyrect.x0 = cur_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = bw->prev_scroll_x;
- rect_x.x0 = bw->height - copyrect.x0;
- rect_x.x1 = bw->height;
+ rect_x.x0 = copyrect.x0;
+ rect_x.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
} else {
- copyrect.x0 = 0;
- copyrect.x1 = bw->width - (cur_x - bw->prev_scroll_x);
- dest_x = cur_x - bw->prev_scroll_x;
+ copyrect.x0 = bw->prev_scroll_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
+ dest_x = cur_x;
- rect_x.x0 = 0;
- rect_x.x1 = cur_x - bw->prev_scroll_x;
+ rect_x.x0 = cur_x;
+ rect_x.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
}
browser_window_copy_box(bw, ©rect, dest_x, dest_y);
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index ca672e1..8b7fe51 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -35,30 +35,26 @@
#include <string.h>
-/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
- * parameters, native function code should not conflict with these
- */
# ifndef JSVERSION_LATEST
# define JSVERSION_LATEST JS_VERSION
# endif
-/* five parameter jsapi native call */
-#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
-/* five parameter function descriptor with no JS_FS macro */
-#define JSAPI_FS(name, nargs, flags) \
- { #name, jsapi_native_##name, nargs, flags, 0 }
-/* function descriptor end */
-#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+/* *CAUTION* these native function macros introduce and use jsapi_this
+ * and jsapi_rval variables, native function code should not conflict
+ * with these
+ */
-/* return value */
+/* native function definition with five parameters */
+#define JSAPI_NATIVE(name, cx, argc, vp) \
+ jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
+
+/* native function return value */
#define JSAPI_RVAL(cx, vp) (jsapi_rval)
-/* return value setter */
+/* native function return value setter with no JS_SET_RVAL */
#define JSAPI_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
-#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
/* arguments */
#define JSAPI_ARGV(cx, vp) (vp)
@@ -66,27 +62,47 @@
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
-/* The object instance in a native call */
-/* "this" JSObject getter */
-JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
-#define JSAPI_THIS_OBJECT(cx, vp) \
- js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+/* native function specifier with five parameters and no JS_FS macro */
+#define JSAPI_FS(name, nargs, flags) \
+ { #name, jsapi_native_##name, nargs, flags, 0 }
-/* proprty native calls */
+/* native function specifier list end */
+#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+
+
+
+
+/* native proprty definition */
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
jsapi_property_##name##_get(cx, obj, jsval id, vp)
#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
jsapi_property_##name##_set(cx, obj, jsval id, vp)
-/* property specifier */
+/* native property getter return value */
+#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
+
+/* native property specifier */
#define JSAPI_PS(name, tinyid, flags) \
{ #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
+/* native property specifier with no setter */
#define JSAPI_PS_RO(name, tinyid, flags) \
{ #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
+/* native property specifier list end */
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+#define JS_StrictPropertyStub JS_PropertyStub
+
+
+
+
+/* The object instance in a native call */
+/* "this" JSObject getter */
+JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
+#define JSAPI_THIS_OBJECT(cx, vp) \
+ js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -100,7 +116,6 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
return global;
}
-#define JS_StrictPropertyStub JS_PropertyStub
#define JSString_to_char(injsstring, outchar, outlen) \
outchar = JS_GetStringBytes(injsstring); \
@@ -111,7 +126,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
-/* GC marking */
+/* Garbage Collector */
+
+/* macros for GC marking */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
@@ -122,7 +139,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_MarkGCThing(cx, thing, "object", arg)
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
#elif JS_VERSION == 180
@@ -199,13 +219,15 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
+/* Garbage Collector */
+
/* GC marking */
#ifdef JSCLASS_MARK_IS_TRACE
-/* mark requires casting */
+/* mark function pointer requires casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE JSCLASS_MARK_IS_TRACE
#define JSAPI_JSCLASS_MARKOP(x) ((JSMarkOp)x)
#else
-/* mark does not require casting */
+/* mark function pointer does not require casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
#endif
@@ -216,6 +238,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#else /* #if JS_VERSION == 180 */
@@ -305,6 +331,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
+
#endif
#define JSLOG(args...) LOG((args))
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 80a30bb..7ca4948 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -181,19 +181,22 @@ operation createTextNode %{
dom_exception exc;
dom_text *text;
- JSLOG("Creating text node for string \"%s\"", data);
- exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (data != NULL) {
- exc = dom_document_create_text_node(private->node, data_dom, &text);
- dom_string_unref(data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ JSLOG("Creating text node for string \"%s\"", data);
+ exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ exc = dom_document_create_text_node(private->node, data_dom, &text);
+ dom_string_unref(data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
@@ -205,19 +208,21 @@ operation createElement %{
dom_exception exc;
dom_element *element;
- JSLOG("Creating text node for string \"%s\"", localName);
- exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (localName != NULL) {
+ JSLOG("Creating text node for string \"%s\"", localName);
+ exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- exc = dom_document_create_element(private->node, localName_dom, &element);
- dom_string_unref(localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ exc = dom_document_create_element(private->node, localName_dom, &element);
+ dom_string_unref(localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
diff --git a/test/js/dom-body-enumerate.html b/test/js/dom-body-enumerate.html
new file mode 100644
index 0000000..3ff1054
--- /dev/null
+++ b/test/js/dom-body-enumerate.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>Body element interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Body element interface enumeration</h1>
+
+<script>
+function output(x,y) {
+ document.body.appendChild(document.createTextNode(x));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+
+for(var key in document.body){
+output(key, document.body[key]);
+}
+</script>
+</body>
+</html>
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-node-enumerate.html
index 6cbff24..573e27b 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-node-enumerate.html
@@ -9,7 +9,11 @@
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
- document.body.appendChild(document.createTextNode(" = "));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
diff --git a/test/js/index.html b/test/js/index.html
index e94e8e8..f02c4df 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -29,6 +29,11 @@
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
</ul>
+<h3>Enumeration tests</h3>
+<ul>
+<li><a href="dom-node-enumerate.html">Node element interface</a></li>
+<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+</ul>
<h3>Document element specific</h3>
<ul>
<li><a href="dom-doc-cookie.html">Cookie dispaly (only from server)</a></li>
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. 6589c7cc196863d0d0694d6bd14c39386b27ae81
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6589c7cc196863d0d0694...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6589c7cc196863d0d0694d6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6589c7cc196863d0d0694d6bd...
The branch, master has been updated
via 6589c7cc196863d0d0694d6bd14c39386b27ae81 (commit)
from 82cae102843de3f9d638648556592cf9d09c9638 (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/commitdiff/6589c7cc196863d0d06...
commit 6589c7cc196863d0d0694d6bd14c39386b27ae81
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add Garbage colelction root set macros
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index ca672e1..8b7fe51 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -35,30 +35,26 @@
#include <string.h>
-/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
- * parameters, native function code should not conflict with these
- */
# ifndef JSVERSION_LATEST
# define JSVERSION_LATEST JS_VERSION
# endif
-/* five parameter jsapi native call */
-#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
-/* five parameter function descriptor with no JS_FS macro */
-#define JSAPI_FS(name, nargs, flags) \
- { #name, jsapi_native_##name, nargs, flags, 0 }
-/* function descriptor end */
-#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+/* *CAUTION* these native function macros introduce and use jsapi_this
+ * and jsapi_rval variables, native function code should not conflict
+ * with these
+ */
-/* return value */
+/* native function definition with five parameters */
+#define JSAPI_NATIVE(name, cx, argc, vp) \
+ jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
+
+/* native function return value */
#define JSAPI_RVAL(cx, vp) (jsapi_rval)
-/* return value setter */
+/* native function return value setter with no JS_SET_RVAL */
#define JSAPI_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
-#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
/* arguments */
#define JSAPI_ARGV(cx, vp) (vp)
@@ -66,27 +62,47 @@
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
-/* The object instance in a native call */
-/* "this" JSObject getter */
-JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
-#define JSAPI_THIS_OBJECT(cx, vp) \
- js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+/* native function specifier with five parameters and no JS_FS macro */
+#define JSAPI_FS(name, nargs, flags) \
+ { #name, jsapi_native_##name, nargs, flags, 0 }
-/* proprty native calls */
+/* native function specifier list end */
+#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+
+
+
+
+/* native proprty definition */
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
jsapi_property_##name##_get(cx, obj, jsval id, vp)
#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
jsapi_property_##name##_set(cx, obj, jsval id, vp)
-/* property specifier */
+/* native property getter return value */
+#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
+
+/* native property specifier */
#define JSAPI_PS(name, tinyid, flags) \
{ #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
+/* native property specifier with no setter */
#define JSAPI_PS_RO(name, tinyid, flags) \
{ #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
+/* native property specifier list end */
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+#define JS_StrictPropertyStub JS_PropertyStub
+
+
+
+
+/* The object instance in a native call */
+/* "this" JSObject getter */
+JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
+#define JSAPI_THIS_OBJECT(cx, vp) \
+ js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -100,7 +116,6 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
return global;
}
-#define JS_StrictPropertyStub JS_PropertyStub
#define JSString_to_char(injsstring, outchar, outlen) \
outchar = JS_GetStringBytes(injsstring); \
@@ -111,7 +126,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
-/* GC marking */
+/* Garbage Collector */
+
+/* macros for GC marking */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
@@ -122,7 +139,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_MarkGCThing(cx, thing, "object", arg)
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
#elif JS_VERSION == 180
@@ -199,13 +219,15 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
+/* Garbage Collector */
+
/* GC marking */
#ifdef JSCLASS_MARK_IS_TRACE
-/* mark requires casting */
+/* mark function pointer requires casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE JSCLASS_MARK_IS_TRACE
#define JSAPI_JSCLASS_MARKOP(x) ((JSMarkOp)x)
#else
-/* mark does not require casting */
+/* mark function pointer does not require casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
#endif
@@ -216,6 +238,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#else /* #if JS_VERSION == 180 */
@@ -305,6 +331,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
+
#endif
#define JSLOG(args...) LOG((args))
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi.h | 80 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 55 insertions(+), 25 deletions(-)
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index ca672e1..8b7fe51 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -35,30 +35,26 @@
#include <string.h>
-/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
- * parameters, native function code should not conflict with these
- */
# ifndef JSVERSION_LATEST
# define JSVERSION_LATEST JS_VERSION
# endif
-/* five parameter jsapi native call */
-#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
-/* five parameter function descriptor with no JS_FS macro */
-#define JSAPI_FS(name, nargs, flags) \
- { #name, jsapi_native_##name, nargs, flags, 0 }
-/* function descriptor end */
-#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+/* *CAUTION* these native function macros introduce and use jsapi_this
+ * and jsapi_rval variables, native function code should not conflict
+ * with these
+ */
-/* return value */
+/* native function definition with five parameters */
+#define JSAPI_NATIVE(name, cx, argc, vp) \
+ jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
+
+/* native function return value */
#define JSAPI_RVAL(cx, vp) (jsapi_rval)
-/* return value setter */
+/* native function return value setter with no JS_SET_RVAL */
#define JSAPI_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
-#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
/* arguments */
#define JSAPI_ARGV(cx, vp) (vp)
@@ -66,27 +62,47 @@
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
-/* The object instance in a native call */
-/* "this" JSObject getter */
-JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
-#define JSAPI_THIS_OBJECT(cx, vp) \
- js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+/* native function specifier with five parameters and no JS_FS macro */
+#define JSAPI_FS(name, nargs, flags) \
+ { #name, jsapi_native_##name, nargs, flags, 0 }
-/* proprty native calls */
+/* native function specifier list end */
+#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
+
+
+
+
+/* native proprty definition */
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
jsapi_property_##name##_get(cx, obj, jsval id, vp)
#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
jsapi_property_##name##_set(cx, obj, jsval id, vp)
-/* property specifier */
+/* native property getter return value */
+#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
+
+/* native property specifier */
#define JSAPI_PS(name, tinyid, flags) \
{ #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
+/* native property specifier with no setter */
#define JSAPI_PS_RO(name, tinyid, flags) \
{ #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
+/* native property specifier list end */
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+#define JS_StrictPropertyStub JS_PropertyStub
+
+
+
+
+/* The object instance in a native call */
+/* "this" JSObject getter */
+JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
+#define JSAPI_THIS_OBJECT(cx, vp) \
+ js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -100,7 +116,6 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
return global;
}
-#define JS_StrictPropertyStub JS_PropertyStub
#define JSString_to_char(injsstring, outchar, outlen) \
outchar = JS_GetStringBytes(injsstring); \
@@ -111,7 +126,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
-/* GC marking */
+/* Garbage Collector */
+
+/* macros for GC marking */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
@@ -122,7 +139,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_MarkGCThing(cx, thing, "object", arg)
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
#elif JS_VERSION == 180
@@ -199,13 +219,15 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
+/* Garbage Collector */
+
/* GC marking */
#ifdef JSCLASS_MARK_IS_TRACE
-/* mark requires casting */
+/* mark function pointer requires casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE JSCLASS_MARK_IS_TRACE
#define JSAPI_JSCLASS_MARKOP(x) ((JSMarkOp)x)
#else
-/* mark does not require casting */
+/* mark function pointer does not require casting */
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
#define JSAPI_JSCLASS_MARKOP(x) (x)
#endif
@@ -216,6 +238,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#else /* #if JS_VERSION == 180 */
@@ -305,6 +331,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
+/* Macros for manipulating GC root */
+#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
+#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
+
#endif
#define JSLOG(args...) LOG((args))
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. 3d3e27d666c7c35ab95f450c68766a9ba996a485
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/3d3e27d666c7c35ab...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/3d3e27d666c7c35ab95...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/3d3e27d666c7c35ab95f4...
The branch, master has been updated
via 3d3e27d666c7c35ab95f450c68766a9ba996a485 (commit)
from 24d68eb4e19e48c80a44af324499e1e16863e768 (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/nsgenjsbind.git/commitdiff/3d3e27d666c7c35...
commit 3d3e27d666c7c35ab95f450c68766a9ba996a485
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
generate macros for adding object to root GC set
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 476c99e..df36be8 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -361,7 +361,7 @@ output_class_new(struct binding *binding)
/* root object to stop it being garbage collected */
fprintf(binding->outfile,
- "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\tif (JSAPI_ADD_OBJECT_ROOT(cx, &newobject) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
"\t}\n\n");
@@ -395,7 +395,7 @@ output_class_new(struct binding *binding)
/* root object to stop it being garbage collected */
fprintf(binding->outfile,
- "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\tif (JSAPI_ADD_OBJECT_ROOT(cx, &newobject) != JS_TRUE) {\n"
"\t\treturn NULL;\n"
"\t}\n\n");
@@ -413,7 +413,7 @@ output_class_new(struct binding *binding)
/* unroot object and return it */
fprintf(binding->outfile,
- "\tJS_RemoveRoot(cx, &newobject);\n"
+ "\tJSAPI_REMOVE_OBJECT_ROOT(cx, &newobject);\n"
"\n"
"\treturn newobject;\n"
"}\n");
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 476c99e..df36be8 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -361,7 +361,7 @@ output_class_new(struct binding *binding)
/* root object to stop it being garbage collected */
fprintf(binding->outfile,
- "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\tif (JSAPI_ADD_OBJECT_ROOT(cx, &newobject) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
"\t}\n\n");
@@ -395,7 +395,7 @@ output_class_new(struct binding *binding)
/* root object to stop it being garbage collected */
fprintf(binding->outfile,
- "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\tif (JSAPI_ADD_OBJECT_ROOT(cx, &newobject) != JS_TRUE) {\n"
"\t\treturn NULL;\n"
"\t}\n\n");
@@ -413,7 +413,7 @@ output_class_new(struct binding *binding)
/* unroot object and return it */
fprintf(binding->outfile,
- "\tJS_RemoveRoot(cx, &newobject);\n"
+ "\tJSAPI_REMOVE_OBJECT_ROOT(cx, &newobject);\n"
"\n"
"\treturn newobject;\n"
"}\n");
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch master updated. 82cae102843de3f9d638648556592cf9d09c9638
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/82cae102843de3f9d6386...
...commit http://git.netsurf-browser.org/netsurf.git/commit/82cae102843de3f9d638648...
...tree http://git.netsurf-browser.org/netsurf.git/tree/82cae102843de3f9d63864855...
The branch, master has been updated
via 82cae102843de3f9d638648556592cf9d09c9638 (commit)
from e36b8f657997ffca3d1cc1fe1a7130854d247262 (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/commitdiff/82cae102843de3f9d63...
commit 82cae102843de3f9d638648556592cf9d09c9638
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
more enumeration tests and update test index
diff --git a/test/js/dom-body-enumerate.html b/test/js/dom-body-enumerate.html
new file mode 100644
index 0000000..3ff1054
--- /dev/null
+++ b/test/js/dom-body-enumerate.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>Body element interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Body element interface enumeration</h1>
+
+<script>
+function output(x,y) {
+ document.body.appendChild(document.createTextNode(x));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+
+for(var key in document.body){
+output(key, document.body[key]);
+}
+</script>
+</body>
+</html>
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-node-enumerate.html
index 261d680..573e27b 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-node-enumerate.html
@@ -9,19 +9,17 @@
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
- document.body.appendChild(document.createTextNode(" = "));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
for(var key in Node){
output(key, Node[key]);
}
-
- document.body.appendChild(document.createElement('hr'));
-
-for(var key in document.body){
-output(key, document.body[key]);
-}
</script>
</body>
</html>
diff --git a/test/js/index.html b/test/js/index.html
index e94e8e8..f02c4df 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -29,6 +29,11 @@
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
</ul>
+<h3>Enumeration tests</h3>
+<ul>
+<li><a href="dom-node-enumerate.html">Node element interface</a></li>
+<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+</ul>
<h3>Document element specific</h3>
<ul>
<li><a href="dom-doc-cookie.html">Cookie dispaly (only from server)</a></li>
-----------------------------------------------------------------------
Summary of changes:
...node-enumerate.html => dom-body-enumerate.html} | 14 +++++++-------
test/js/dom-node-enumerate.html | 12 +++++-------
test/js/index.html | 5 +++++
3 files changed, 17 insertions(+), 14 deletions(-)
copy test/js/{dom-node-enumerate.html => dom-body-enumerate.html} (56%)
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-body-enumerate.html
similarity index 56%
copy from test/js/dom-node-enumerate.html
copy to test/js/dom-body-enumerate.html
index 261d680..3ff1054 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-body-enumerate.html
@@ -1,23 +1,23 @@
<html>
<head>
-<title>Node interface enumeration</title>
+<title>Body element interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Node interface enumeration</h1>
+<h1>Body element interface enumeration</h1>
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
- document.body.appendChild(document.createTextNode(" = "));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
-for(var key in Node){
-output(key, Node[key]);
-}
- document.body.appendChild(document.createElement('hr'));
for(var key in document.body){
output(key, document.body[key]);
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-node-enumerate.html
index 261d680..573e27b 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-node-enumerate.html
@@ -9,19 +9,17 @@
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
- document.body.appendChild(document.createTextNode(" = "));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+document.body.appendChild(document.createTextNode(y.length));
+}
+ document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
for(var key in Node){
output(key, Node[key]);
}
-
- document.body.appendChild(document.createElement('hr'));
-
-for(var key in document.body){
-output(key, document.body[key]);
-}
</script>
</body>
</html>
diff --git a/test/js/index.html b/test/js/index.html
index e94e8e8..f02c4df 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -29,6 +29,11 @@
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
</ul>
+<h3>Enumeration tests</h3>
+<ul>
+<li><a href="dom-node-enumerate.html">Node element interface</a></li>
+<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+</ul>
<h3>Document element specific</h3>
<ul>
<li><a href="dom-doc-cookie.html">Cookie dispaly (only from server)</a></li>
--
NetSurf Browser
10 years, 6 months