From f7ee2a03876bf4a5cf66b3a433955e4e55d91362 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 21 Dec 2012 00:56:50 +0100 Subject: [PATCH] - started to work on settings dialog - some WIP in treeview widgets. Changed destroy / and init handling. It requires some optimization, when the widget is closed it must remove itself from the guiwin list, for perfomance. --- atari/Makefile.defaults | 2 +- atari/Makefile.target | 5 +- atari/deskmenu.c | 3 +- atari/download.c | 9 +- atari/gemtk/aestabs.c | 173 +++++++ atari/gemtk/aestabs.h | 56 +++ atari/gemtk/gemtk.h | 77 +-- atari/gemtk/guiwin.c | 41 +- atari/gui.c | 4 +- atari/gui.h | 1 + atari/history.c | 14 +- atari/hotlist.c | 103 ++-- atari/misc.c | 3 +- atari/res/netsurf.rsc | Bin 35786 -> 36642 bytes atari/res/netsurf.rsh | 17 + atari/res/netsurf.rsm | 22 +- atari/rootwin.c | 37 +- atari/settings.c | 1043 +++++---------------------------------- atari/settings.h | 2 +- 19 files changed, 572 insertions(+), 1040 deletions(-) create mode 100644 atari/gemtk/aestabs.c create mode 100644 atari/gemtk/aestabs.h diff --git a/atari/Makefile.defaults b/atari/Makefile.defaults index 150358843..155ba8d2d 100644 --- a/atari/Makefile.defaults +++ b/atari/Makefile.defaults @@ -42,7 +42,7 @@ # enable optimizations # -O2 is currently broken with m68000 / m68020-60 builds - CFLAGS += -O1 + CFLAGS += -O3 # override warning flags removing -Wall WARNFLAGS = -W -Wundef -Wpointer-arith \ diff --git a/atari/Makefile.target b/atari/Makefile.target index e7755d56f..275eb5653 100644 --- a/atari/Makefile.target +++ b/atari/Makefile.target @@ -106,10 +106,11 @@ S_ATARI := \ plot/eddi.s \ plot/font_freetype.c \ plot/font_internal.c \ - gemtk/utils.c \ + gemtk/aestabs.c \ gemtk/dragdrop.c \ + gemtk/guiwin.c \ gemtk/msgbox.c \ - gemtk/guiwin.c + gemtk/utils.c S_ATARI := $(addprefix atari/,$(S_ATARI)) diff --git a/atari/deskmenu.c b/atari/deskmenu.c index 646a09c05..601ba9931 100644 --- a/atari/deskmenu.c +++ b/atari/deskmenu.c @@ -353,9 +353,8 @@ static void __CDECL menu_find(short item, short 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(); + open_settings(); } static void __CDECL menu_stop(short item, short title, void *data) diff --git a/atari/download.c b/atari/download.c index e35f31d9e..bf3105f5b 100755 --- a/atari/download.c +++ b/atari/download.c @@ -204,9 +204,10 @@ static void gui_download_window_destroy( struct gui_download_window * gdw) } if (gdw->fbuf != NULL) { free( gdw->fbuf ); - } - wind_close(gdw->aes_handle); - guiwin_remove(gdw->guiwin); + } + guiwin_remove(gdw->guiwin); + wind_close(gdw->aes_handle); + wind_delete(gdw->aes_handle); free(gdw); } @@ -269,7 +270,7 @@ struct gui_download_window * gui_download_window_create(download_context *ctx, gemdos_realpath(nsoption_charp(downloads_path), gdos_path); dstsize = strlen(gdos_path) + strlen(filename) + 2; destination = malloc( dstsize ); - snprintf( destination, dstsize, "%s/%s", gdos_path, filename ); + snprintf(destination, dstsize, "%s/%s", gdos_path, filename); } gdw = calloc(1, sizeof(struct gui_download_window)); diff --git a/atari/gemtk/aestabs.c b/atari/gemtk/aestabs.c new file mode 100644 index 000000000..414d5c290 --- /dev/null +++ b/atari/gemtk/aestabs.c @@ -0,0 +1,173 @@ +#include +#include +#include +#include +#include "aestabs.h" + +#ifndef NDEBUG +# define DEBUG_PRINT(x) printf x +#else +# define DEBUG_PRINT(x) +#endif + + +AES_TABLIST * tablist_declare(OBJECT *tree, aes_tablist_user_func user_func) +{ + AES_TABLIST * newlist = malloc(sizeof(AES_TABLIST)); + + newlist->first = NULL; + newlist->tree = tree; + newlist->user_func = user_func; + DEBUG_PRINT(("aes_tablist_declare: %p\n", newlist)); + return(newlist); +} + + +AES_TAB * tablist_add(AES_TABLIST * tablist, short obj_tab, OBJECT * page_tree, + short obj_page) +{ + AES_TAB * newtab = malloc(sizeof(AES_TAB)); + + assert(newtab); + assert(tablist); + + newtab->next = NULL; + newtab->prev = NULL; + newtab->obj_tab = obj_tab; + newtab->obj_page = obj_page; + newtab->page_tree = page_tree; + + if(newtab->page_tree == NULL){ + newtab->page_tree = tablist->tree; + } + + if (tablist->first == NULL) { + tablist->first = newtab; + set_state(tablist->tree, newtab->obj_tab, OS_SELECTED, 0); + } else { + AES_TAB *tmp = tablist->first; + while( tmp->next != NULL ) { + tmp = tmp->next; + } + tmp->next = newtab; + newtab->prev = tmp; + newtab->next = NULL; + set_state(tablist->tree, newtab->obj_tab, OS_SELECTED, 0); + } + + // TODO: Set the visible flag on that register? + + DEBUG_PRINT(("tablist_add: Tab=%p\n", newtab)); + + return(newtab); +} + + +short tablist_activate(AES_TABLIST * tablist, short tab, short options) +{ + AES_TAB *tmp, *activated=NULL, *deactivated=NULL; + struct aes_tab_s *active; + short activated_pg = -1; + short is_tab = 0; + + assert(tablist); + assert(tablist->first); + + active = tablist_get_active(tablist); + + if (active != NULL) { + if ((options & AES_TABLIST_OPTION_FORCE_EVENTS) == 0) { + if(active->obj_tab == tab) + return(0); + } + } + + tmp = tablist->first; + while (tmp != NULL) { + if(tmp->obj_tab == tab) { + is_tab = 1; + } + tmp = tmp->next; + } + + if(is_tab == 0) { + return(0); + } + + tmp = tablist->first; + while ( tmp != NULL ) { + if(tab != tmp->obj_tab) { + if (get_state(tablist->tree, tmp->obj_tab, OS_SELECTED) != 0) { + deactivated = tmp; + set_state(tablist->tree, tmp->obj_tab, OS_SELECTED, 0); + } + // the tab registers can share the same page, consider that: + if (tablist->tree == tmp->page_tree + && activated_pg != tmp->obj_page) { + + set_flag(tablist->tree, tmp->obj_page, OF_HIDETREE, 1); + } + } else { + activated = tmp; + // this tab must the selected / visible + set_state(tablist->tree, tmp->obj_tab, OS_SELECTED, 1); + if(tablist->tree == tmp->page_tree) + set_flag(tablist->tree, tmp->obj_page, OF_HIDETREE, 0); + activated_pg = tmp->obj_page; + } + tmp = tmp->next; + } + + if(tablist->user_func != NULL) { + AES_TABLIST_FUNC_ARGS args; + if(deactivated){ + args.event = AES_TABLIST_TAB_DEACTIVATED; + args.tab = deactivated; + tablist->user_func(tablist, &args); + } + if(activated){ + args.event = AES_TABLIST_TAB_ACTIVATED; + args.tab = activated; + tablist->user_func(tablist, &args); + } + } + return(1); +} + +struct aes_tab_s *tablist_get_active(AES_TABLIST * tablist) +{ + AES_TAB *tmp = tablist->first; + while( tmp != NULL ) { + if(get_state(tablist->tree, tmp->obj_tab, OS_SELECTED) != 0) { + // that's the one + return(tmp); + } + tmp = tmp->next; + } + return(NULL); +} + +AES_TAB * tablist_find(AES_TABLIST * tablist, OBJECT * page, short tab) +{ + AES_TAB *tmp = tablist->first; + while( tmp != NULL ) { + if((tmp->page_tree == page) && (tab == tmp->obj_tab)) { + return(tmp); + } + tmp = tmp->next; + } + return(NULL); +} + +void tablist_delete(AES_TABLIST *tablist) +{ + AES_TAB *tmp = tablist->first, *cur; + while ( tmp != NULL ) { + cur = tmp; + tmp = tmp->next; + DEBUG_PRINT(("tablist_delete, Freeing tab: %p\n", cur)); + free(cur); + } + DEBUG_PRINT(("tablist_delete, Freeing list: %p\n", tablist)); + free(tablist); +} diff --git a/atari/gemtk/aestabs.h b/atari/gemtk/aestabs.h new file mode 100644 index 000000000..c72054acc --- /dev/null +++ b/atari/gemtk/aestabs.h @@ -0,0 +1,56 @@ +#ifndef AESTABS_H_INCLUDED +#define AESTABS_H_INCLUDED + +struct aes_tab_s; +struct aes_tablist_s; +typedef struct aes_tab_s AES_TAB; +typedef struct aes_tablist_s AES_TABLIST; + +#define AES_TABLIST_TAB_ACTIVATED 0x01 +#define AES_TABLIST_TAB_DEACTIVATED 0x02 + +#define AES_TABLIST_OPTION_FORCE_EVENTS 0x01 // do not eat events which do + // not changed the internal state + // this is required for tabs which + // require "activate" events + // for tabs which are already + // selected. + + +struct aes_tablist_user_args_s +{ + short event; + AES_TAB *tab; +}; + +typedef struct aes_tablist_user_args_s AES_TABLIST_FUNC_ARGS; + +typedef void (*aes_tablist_user_func)(AES_TABLIST * list, + AES_TABLIST_FUNC_ARGS * args); + +struct aes_tab_s { + short obj_tab; + short obj_page; + OBJECT * page_tree; + AES_TAB * next, *prev; +}; + +struct aes_tablist_s { + OBJECT *tree; + AES_TAB * first; + aes_tablist_user_func user_func; +}; + + + +AES_TABLIST * tablist_declare(OBJECT *tree, aes_tablist_user_func user_func); +void tablist_delete(AES_TABLIST * tablist); +AES_TAB * tablist_add(AES_TABLIST * tablist, short tab, OBJECT *page_tree, + short page); +short tablist_activate(AES_TABLIST * tablist, short tab, short option); +struct aes_tab_s *tablist_get_active(AES_TABLIST * tablist); +AES_TAB * tablist_find(AES_TABLIST * tablist, OBJECT *page, short tab); + +#define AES_TAB_IS_ACTIVE(l, x) (tablist_get_active(l) == x) + +#endif // AESTABS_H_INCLUDED diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index 1225a0ccd..9c341ba5c 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -7,6 +7,10 @@ #include #include +/* -------------------------------------------------------------------------- */ +/* Utils */ +/* -------------------------------------------------------------------------- */ + /* System type detection added by [GS] */ /* detect the system type, AES + kernel */ #define SYS_TOS 0x0001 @@ -23,16 +27,34 @@ #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 -*/ +#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 + +#ifndef RC_WITHIN +# define RC_WITHIN(a,b) \ + (((a)->g_x >= (b)->g_x) \ + && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \ + && (((a)->g_y >= (b)->g_y) \ + && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h))) +#endif + +#ifndef MAX +# define MAX(_a,_b) ((_a>_b) ? _a : _b) +#endif + +#ifndef MIN +# define MIN(_a,_b) ((_a<_b) ? _a : _b) +#endif + + +/* -------------------------------------------------------------------------- */ +/* 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); @@ -45,17 +67,17 @@ 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 -*/ +/* -------------------------------------------------------------------------- */ +/* Message Box module */ +/* -------------------------------------------------------------------------- */ #define MSG_BOX_ALERT 1 #define MSG_BOX_CONFIRM 2 short msg_box_show(short type, const char * msg); -/* - Guiwin -*/ +/* -------------------------------------------------------------------------- */ +/* GUIWIN Module */ +/* -------------------------------------------------------------------------- */ #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 @@ -120,29 +142,12 @@ bool guiwin_has_intersection(GUIWIN *win, GRECT *work); void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip); void guiwin_clear(GUIWIN *win); -/* -* AES Scroller Object -*/ +/* -------------------------------------------------------------------------- */ +/* AES Scroller module */ +/* -------------------------------------------------------------------------- */ -#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 - -#ifndef RC_WITHIN -#define RC_WITHIN(a,b) \ - (((a)->g_x >= (b)->g_x) \ - && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \ - && (((a)->g_y >= (b)->g_y) \ - && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h))) -#endif - -#ifndef MAX -#define MAX(_a,_b) ((_a>_b) ? _a : _b) -#endif - -#ifndef MIN -#define MIN(_a,_b) ((_a<_b) ? _a : _b) -#endif +/* -------------------------------------------------------------------------- */ +/* AES Tabs module */ +/* -------------------------------------------------------------------------- */ #endif // GEMTK_H_INCLUDED diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c index e587b97d1..6e8cfa29d 100644 --- a/atari/gemtk/guiwin.c +++ b/atari/gemtk/guiwin.c @@ -1,4 +1,20 @@ -//#include "global.h" +/* + * Copyright 2012 Ole Loots + * + * 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 . + */ #include #include @@ -10,8 +26,8 @@ #include #include "gemtk.h" -//#define DEBUG_PRINT(x) printf x -#define DEBUG_PRINT(x) +#define DEBUG_PRINT(x) printf x +//#define DEBUG_PRINT(x) struct gui_window_s { short handle; @@ -170,13 +186,20 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8]) case WM_SIZED: case WM_REPOSED: + wind_get_grect(gw->handle, WF_FULLXYWH, &g2); wind_get_grect(gw->handle, WF_CURRXYWH, &g); - wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]); - if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) { - if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)) { - guiwin_send_redraw(gw, NULL); - } + g.g_w = MIN(msg[6], g2.g_w); + g.g_h = MIN(msg[7], g2.g_h); + if(g2.g_w != g.g_w || g2.g_h != g.g_h){ + wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, g.g_w, g.g_h); + if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) { + if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)) { + guiwin_send_redraw(gw, NULL); + } + } } + + break; case WM_FULLED: @@ -315,7 +338,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) if (obj_idx > 0) { if ((dest->toolbar[obj_idx].ob_flags & OF_SELECTABLE)!=0 && ((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) - && ((dest->flags & GW_FLAG_TOOLBAR_REDRAW) == 0)) { + && ((dest->flags & GW_FLAG_TOOLBAR_REDRAW) == 1)) { dest->toolbar[obj_idx].ob_state |= OS_SELECTED; // TODO: optimize redraw by setting the object clip: guiwin_toolbar_redraw(dest, NULL); diff --git a/atari/gui.c b/atari/gui.c index 51865b987..888f82d37 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -144,8 +144,8 @@ void gui_poll(bool active) } /* this suits for stuff with lower priority */ /* TBD: really be spare on redraws??? */ - //hotlist_redraw(); - //global_history_redraw(); + hotlist_redraw(); + global_history_redraw(); } // Handle events until there are no more messages pending or diff --git a/atari/gui.h b/atari/gui.h index 0fc1a2c3c..e12cf44f4 100755 --- a/atari/gui.h +++ b/atari/gui.h @@ -98,6 +98,7 @@ typedef struct s_browser * CMP_BROWSER; */ struct s_gui_win_root { + short aes_handle; GUIWIN *win; CMP_TOOLBAR toolbar; CMP_STATUSBAR statusbar; diff --git a/atari/history.c b/atari/history.c index f9faef555..77df2c921 100755 --- a/atari/history.c +++ b/atari/history.c @@ -38,6 +38,10 @@ #include "atari/res/netsurf.rsh" #include "atari/history.h" + +//TODO: remove/add guiwin handle on close / open - so that the list +// is kept tiny. + extern char * tree_directory_icon_name; extern GRECT desk_area; @@ -46,6 +50,7 @@ struct s_atari_global_history gl_history; void global_history_open( void ) { + global_history_init(); if (gl_history.init == false ) { return; } @@ -132,10 +137,6 @@ bool global_history_init( void ) void global_history_destroy( void ) { -void global_history_redraw( void ) -{ - atari_treeview_redraw( gl_history.tv ); -} if( gl_history.init == false ) { return; } @@ -152,4 +153,9 @@ void global_history_redraw( void ) LOG(("done")); } +void global_history_redraw( void ) +{ + atari_treeview_redraw( gl_history.tv ); +} + diff --git a/atari/hotlist.c b/atari/hotlist.c index 66e7560ea..ccba088a6 100755 --- a/atari/hotlist.c +++ b/atari/hotlist.c @@ -44,6 +44,9 @@ #include "atari/gemtk/gemtk.h" #include "atari/res/netsurf.rsh" +//TODO: remove/add guiwin handle on close / open - so that the list +// is kept tiny. + extern GRECT desk_area; struct atari_hotlist hl; @@ -86,7 +89,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) break; case WM_CLOSED: - hotlist_close(); + hotlist_destroy(); break; default: break; @@ -101,49 +104,51 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) void hotlist_init(void) { - if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){ - atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" ); - } else { - strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); - } - - LOG(("Hotlist: %s", (char*)&hl.path )); - - if( hl.window == NULL ){ - int flags = ATARI_TREEVIEW_WIDGETS; - short handle = -1; - GRECT desk; - OBJECT * tree = get_tree(TOOLBAR_HOTLIST); - assert( tree ); - hl.open = false; - - handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h); - hl.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL); - if( hl.window == NULL ) { - LOG(("Failed to allocate Hotlist")); - return; - } - wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist")); - guiwin_set_toolbar(hl.window, tree, 0, 0); - hl.tv = atari_treeview_create( - hotlist_get_tree_flags(), - hl.window, - handle_event - ); - if (hl.tv == NULL) { - /* handle it properly, clean up previous allocs */ - LOG(("Failed to allocate treeview")); - return; + if (hl.init == false) { + if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){ + atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" ); + } else { + strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); } - hotlist_initialise( - hl.tv->tree, - (char*)&hl.path, - "dir.png" - ); + LOG(("Hotlist: %s", (char*)&hl.path )); - } else { + if( hl.window == NULL ){ + int flags = ATARI_TREEVIEW_WIDGETS; + short handle = -1; + GRECT desk; + OBJECT * tree = get_tree(TOOLBAR_HOTLIST); + assert( tree ); + hl.open = false; + handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h); + hl.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL); + if( hl.window == NULL ) { + LOG(("Failed to allocate Hotlist")); + return; + } + wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist")); + guiwin_set_toolbar(hl.window, tree, 0, 0); + hl.tv = atari_treeview_create( + hotlist_get_tree_flags(), + hl.window, + handle_event + ); + if (hl.tv == NULL) { + /* handle it properly, clean up previous allocs */ + LOG(("Failed to allocate treeview")); + return; + } + + hotlist_initialise( + hl.tv->tree, + (char*)&hl.path, + "dir.png" + ); + + } else { + + } } hl.init = true; } @@ -151,6 +156,7 @@ void hotlist_init(void) void hotlist_open(void) { + hotlist_init(); if( hl.init == false ) { return; } @@ -181,17 +187,12 @@ void hotlist_close(void) void hotlist_destroy(void) { -void hotlist_redraw(void) -{ - int i = 01; - atari_treeview_redraw(hl.tv); -} - if( hl.init == false ) { + if( hl.init == false) { return; } if( hl.window != NULL ) { hotlist_cleanup( (char*)&hl.path ); - if( hl.open ) + if (hl.open) hotlist_close(); wind_delete(guiwin_get_handle(hl.window)); guiwin_remove(hl.window); @@ -202,6 +203,12 @@ void hotlist_redraw(void) LOG(("done")); } +void hotlist_redraw(void) +{ + int i = 01; + atari_treeview_redraw(hl.tv); +} + struct node; void atari_hotlist_add_page( const char * url, const char * title ) @@ -212,6 +219,8 @@ void atari_hotlist_add_page( const char * url, const char * title ) NSTREEVIEW tv = hl.tv; if(hl.tv == NULL ) return; + // TODO: do no open hotlist, and remove guiwin on close... + hotlist_open(); if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){ hotlist_add_page_xy( url, hl.tv->click.x, hl.tv->click.y ); } else { diff --git a/atari/misc.c b/atari/misc.c index d0d4cd5c0..27c68b664 100755 --- a/atari/misc.c +++ b/atari/misc.c @@ -488,8 +488,7 @@ const char * file_select( const char * title, const char * name ) { } if( FselInput( path, tmpname, (char*)"", use_title, NULL, NULL)) { - strncpy( fullname, path, PATH_MAX-1 ); - strncat( fullname, tmpname, PATH_MAX-strlen(fullname)-1 ); + snprintf(fullname, PATH_MAX, "%s%s", path, tmpname); return( (const char*)&fullname ); } return( NULL ); diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc index cb8a3a046aa4c83f0d7b62b91e30664c3062d7c6..da3d2510c2c3ffd5b9c8f61bd2d90dc759d09d37 100755 GIT binary patch delta 4764 zcmZ{odvH|s701uL`^z!lRL*v>`l1Ofe}0Vw(vufQCoA z3o;%4ur=g3Rjg$)?X*lE){JpF*y^~|p>@a>z+sf```plT=M@CPDI`aQq9yU88! zmpRMc^Ev1DIKT5d_qV+Mg#LpwdV=h9)OTWeOHIIc!gnI>@tvSHt&u#`NG{R{ZDmi_ z#_j9n+u}CTwRt0+j}kfWCUVt51|Uxpxx0yS>_oZvp7$Y9{%)dzHlo4^1gz*NQN^1? z#-sD|bn3`vz2??aQ(mKH73HBrmrWz*JR14U;c7a@G|-Jyf#+OMw}sxralv1uC~!Wo zZoz}xqjeZH2UTBQET~XnAD-PrHQ(Ztcz+*{Itlh{K|oP8(A^2Wko5DsGV}`Z;JR|rxutQ;=1wX|e zn^&)WoZpxu9eTBle(?a2UVey zK-LP1y5TW9`uGmM>WYRe^cju|ehJvFaDxS3;vT_Qft?CR7UTM*JPKUj0PI#cYQb%s zvU~OVPM)?$je6u0S~(`T(qeUl{SH`-af<_1r~Ti*KFCN}dwgH!Bx1OJ_h)0ooUe(|ocbEmsQ_l@(D?x^8=(QZc? zRl?Hj#BjRADsY}>++IEK245B9X>QN)8on!3faype9jeQW@drEv9QYVJQKG7V%UmQ5 zweqA*rC@1xU(>-S3b?jLin76zoyQ#xmRU&RSPTs z$P$ z+)Z{DXa(Z7gbXLqD4c)HagSFIo#pkOs9rV2Bc2XD^dhH3d7h_5`60WDp`7Nztd;kS`S4qAq;D$+))mC=7yO_K9>8#PgLCS2j`(CBnKPG+WFxh1#5 z|KrpWuhHNJbgA5qt9|w%1i%d?JS(^o6EcHl*0D;v8-bweZuXZVXd@~j5e#vw^3LGL zxl`~2umkbT)VBhRt{E%-}^yzv@O2>uj)@Wl8F^^J%kIXqM9)gwiG zwX|bpqy%}0;sDu9tEelp?ue8ObKPsHoz`GS)RB)=@KBl8h%^Fg$SRH2q{FCU9a+WW zg0}(KR7R|)b#!OeyPu~7Kcots6Gk2Bs9|E5+Be3$px;(OD*#=qsA1Q%lc3+@xEB*Y z!|T1+&wulXw?mIS%PH}BN$tDzxQRNcGdtibJS+G$0CT!s*+64Jzn%R{y+%_T%4q@q zG#a2S)UARrMbxx`I|bjRyqmGL+tQ0wIn%U>lfZsSTOBE{(RK^|2~P-a18~p^eD1J} zy`5)(qhG@Y%L_xJEf#!$J>|fM0dlGNnu~TS>_Y}6iK35iyWl5)ZB&ZSo-D?~qCexI z@`nunC`!LsT=!Ty|M^%&RQJEe@rn*3dNG^&-C~4uqm~!F%%c?;;!~=}0CKX;T4gwQ zVFZe4oPu}EX(Jp~U4~IZV7C-@vES%V;F71oyVR`5#X<;q)(D-B^fC4G&`TGe#}=3` z7|C=r|NAO5&7fwD_F*Wr*dQWmQ>R$H)=F?6l2aTz4!wE0RY|18GNi4IWB@fobY#Bh z7V8~q5VMTS#YzS^O%3pql9r=ZwO}vrGTAS)u4nAe!rr0m%?o1MK7oOQ0OF9ZI!eE| zVlP0Kr&6xK9KgOBbJSp8487Q!*VuFWdcaHL)*C>&<(u6aiVl1ytcYN=Qx@ zTL%6sI(JbK^yW?1u&dpUeT3P&)HW~4+G7)9S5%deel(>|pT@Wj`;`$l@W0~$zg3Lb&LHh64dqVSWl zNWmXMUV!{6-6?#*?ioxM1 z1&o5zkiS7@EKL1Y3%&e;hsZ+qP&C<>CoGdcNVck2F~G??SSMf zsHYuW$ao4r48i_~6N?G$g?mBGZKH12r6nJd6ErxO5Zv zE>Rm{F`7hykVz_Tl-|%qXFm3J|-0k1J&p){Dfd9a7@2;=YU44B+{{9E{ zAJ{j1sFmWk(Eaz*Agvwf>mAOhsjKh7gMIrC_y_jw>K*87g^4t}bL$uV1HFTL5BBbb yvTu;q4DWk*KSn`I(M;Ry9arbC&(D2xe)4?e3%c{M8vH-g03VBwOrDIb>Ha@?1>14} delta 5312 zcmZ{odyEx#701s!?qgqY_rbC|`?`Dg&fM4RWm#TZrKJn>@{j_BZK35Uk_K&wwUxTD z=q#k|q($(1&hO6bj^L0p z-1|A_cYf!0e!n?q?jC(sKl7CCkx8T0c=v^#v(~sZ?jEnwQF=c9*Mv_GIZ&Dtq6<$&_zrMGcw>a` z0XKy=Mff;)j7mIlb3}0jint7@i||+c5xwlCPeF~`V%W@x`dv^>cw2=316&v0K9%?K z?is?ZkYnAwZQ!Qxj*tWO4&sJ*dE(Ac!2?!85tjiiA?E=*eb*@O=-rFYM4cFxj;Nmk zg)2yJg#Q#=7oG_@PxCgoA-pT(K)o0J6Gqv~#PFG@8}6K`>P!Yy6P^n>++}V7*M;Xp z4wTt~n<2aqa<<%@F0KdCRrY|PMRjN(giE!)`}oPT9t-Qx7`oP^0kS3|-!8GzjWRK#AD6XRK zRDQBABxCTy)nAoSOCM(c*;jS#QAS!E766D0_vh6do4)=|2*x( z1Vw*t!&a|j00W2|+=JxEqU=E=()^$KIo=^qlPuV)bEHJ!k!qX=ShDIrvv?MWt?r$)Qol3EWg$3HDX-bKt72sL%uZkHJ-2 zQK_r)&J?(6D?#Yur_%*TJ>s?!#I6*}p-^olh+XlW;0b9rwQ`Ds3C6&aQ`%6#p8>BG zuFmZYvloOqkK(4nppMtq%68a8^it#UhTN7Q60GCAmj_*n+f|Q zxa5F29|vdgmAcEC&RlX3+OK?hAW3EdTyhZFul*bI5-ZvfK{Hu#qQ~LrF4@aL`<`iMBkgz=-Jx_%ekO79bO)x%y*>f%6_5b{0=`E^j8IAqn1 z1OIPO3L38-x5;+Q6Q2RWy9`A7WD`!eB>i0wgVMO$C<)nc?Vo@oXdVtt4+k39=i-tD zF3#zx3&^#B8>n3xWvSO6Ys%D_-tV9NQRm zz)IdnFyAo8mwQ%v8JE-r)KBw~fH6)$?#Cc10YP6(a!tv-3?9Qt)F^0biXVq{LTb}M zHEzXE!x9PO8b3RtcpJ-6JEgj2mzhLvscSpc!;uSn)rFWNpsu~(n((>eC$K*ZZU~W*&TV9}y>e41yy0JIsd$Ccl09yc>uC|K3o>4K6GY9k1c!5RIL}+) z1`cP8hIxU(Nh$mZ9LE{5IKn>!Q6+8BR9@tW4D$HAFQ=unESR9!hBB%qxQz!8&N?5B zq9dJ_hgF1EpQU0yh$csIS;$d9iZ{cHfj+6xlByp~8wdX!{20<#*U*Z3S{+Wj+F#X* z6MD(t+gkC8+r%voUmm(e+KRj7m4w5%gVxg8aP)&94akc@YuG->OL0{Ea9-AlAKrId z-CPuSzp%f;x$AM*m$3W>@_6F=X@oY*hP(p>KcZ?wHq)K7DV+FIaCVfWyQ&jQzDi8- zGYGOFGI16}M{Ut)W5oV$5K~U|-IFJjBfS-h7|q80o`|E(AaUWFgjYAjwQ!obc4{;d zu^+_~t@`GA+CujQ3vi3Dtfl#%BxtMhgAC0ZBXZ}66Mp^J7Ag>sy9~r2=G!BDlmFGW zhpp}>@M5H15AGFpknx}RW_wxh{+&O!y|U6h5LTMaY!y@>_i1oLj@oV+ZN>R%A@?Oz z%oZuzs^eMlF9?6t|8;xCa(|8^#d*cVYMAQu?l1hTwadfn>=nFLnUENAiAT1P2Xk*l z|IIc)&_A<_FdP-PaSZR0S20^R7#d0TPRK(y(Cq_%0`equ@Pl#a-tr7m_6OikLw*RI z#}l&CYsxTt5(@m($ntkw)d?*uk!<`QsCj-SeE)Zm|hkOz8C5)>s0y=)pAp1VZ z1CXzXPU8gz<2?I8D832tB1$fyWRF4iLk?7(;yVWN6Gk>3So?dB$0Itfiew*xV1+iX zaB_i?Q5!#>?dKsch|UXE&rcQEFG5a2PKi>bJ6OeO@IOG#MV#_WAldkFZT|)GK}4q( z@mKJFLjD!eai1akW9+|!4-OxX$w(y_2OHqvCz~@PqT>!oPAeo2DMWN!GRfHixfjA) zflJbT6%R1Zn1f6^k3#lWb(o(Ilv2I|#m^uoM5$K?CeUgqmxEycbF;2@ntK@h5y)6X z$H$p+XNmF%BR>G$fT&al!RkvJLLHAwqnuF*sV*Ia zydKdxgw>T!LOwu=;IhLLj!Cvf=b|XO8RXy1N0f0+lZ)TbE}jf`PgRG(L7?u}z`qXp z#tn4r5BuwW`vy9^fxGw_k&UM~7Ik?kyvrm}o#b*a6ZN;jBr(M#V$nYYi;b{I{$Gnx zSR95$4J>3aaLqmvm`ASuemo_mouse.p_x, ev_out->emo_mouse.p_y); - if (guiwin_get_handle(data->rootwin->win)==ghandle) { + if (data->rootwin->aes_handle==ghandle) { // The window found at x,y is an gui_window // and it's the input window. window_get_grect(data->rootwin, BROWSER_AREA_CONTENT, @@ -204,7 +204,6 @@ int window_create(struct gui_window * gw, int err = 0; bool tb, sb; int flags; - short aes_handle; tb = (inflags & WIDGET_TOOLBAR); sb = (inflags & WIDGET_STATUSBAR); @@ -229,13 +228,13 @@ int window_create(struct gui_window * gw, redraw_slots_init(&gw->root->redraw_slots, 8); // TODO: use desk size - aes_handle = wind_create(flags, 40, 40, app.w, app.h); - if(aes_handle<0) { + gw->root->aes_handle = wind_create(flags, 40, 40, app.w, app.h); + if(gw->root->aes_handle<0) { free(gw->root->title); free(gw->root); return( -1 ); } - gw->root->win = guiwin_add(aes_handle, + gw->root->win = guiwin_add(gw->root->aes_handle, GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event); struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s)); @@ -265,10 +264,10 @@ int window_create(struct gui_window * gw, } // Setup some window defaults: - wind_set_str(aes_handle, WF_ICONTITLE, (char*)"NetSurf"); - wind_set(aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0); - wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0); - wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0); + wind_set_str(gw->root->aes_handle, WF_ICONTITLE, (char*)"NetSurf"); + wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0); + wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0); + wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0); if (inflags & WIN_TOP) { window_set_focus(gw->root, BROWSER, gw->browser); @@ -332,6 +331,8 @@ int window_destroy(ROOTWIN *rootwin) free(rootwin->title); guiwin_remove(rootwin->win); + wind_close(rootwin->aes_handle); + wind_delete(rootwin->aes_handle); free(rootwin); return(err); } @@ -344,9 +345,8 @@ void window_open(ROOTWIN *rootwin, GRECT pos) assert(rootwin->active_gui_window != NULL); - short aes_handle = guiwin_get_handle(rootwin->win); - wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h ); - wind_set_str(aes_handle, WF_NAME, (char *)""); + wind_open(rootwin->aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h ); + wind_set_str(rootwin->aes_handle, WF_NAME, (char *)""); rootwin->active_gui_window->browser->attached = true; if(rootwin->statusbar != NULL) { @@ -387,7 +387,7 @@ void window_set_stauts(struct s_gui_win_root *rootwin, char * text) void window_set_title(struct s_gui_win_root * rootwin, char *title) { - wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title); + wind_set_str(rootwin->aes_handle, WF_NAME, title); } void window_scroll_by(ROOTWIN *root, int sx, int sy) @@ -662,13 +662,12 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area, void window_process_redraws(ROOTWIN * rootwin) { GRECT work, visible_ro, tb_area, content_area; - short aes_handle, i; + short i; bool toolbar_rdrw_required; struct guiwin_scroll_info_s *slid =NULL; redraw_active = true; - aes_handle = guiwin_get_handle(rootwin->win); guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area); guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area); @@ -685,7 +684,7 @@ void window_process_redraws(ROOTWIN * rootwin) while(plot_lock() == false); - wind_get_grect(aes_handle, WF_FIRSTXYWH, &visible_ro); + wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible_ro); while (visible_ro.g_w > 0 && visible_ro.g_h > 0) { // TODO: optimze the rectangle list - @@ -717,7 +716,7 @@ void window_process_redraws(ROOTWIN * rootwin) } } - wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro); + wind_get_grect(rootwin->aes_handle, WF_NEXTXYWH, &visible_ro); } vs_clip(guiwin_get_vdi_handle(rootwin->win), 0, pxy_clip); rootwin->redraw_slots.areas_used = 0; @@ -985,10 +984,8 @@ static void on_redraw(ROOTWIN *rootwin, short msg[8]) static void on_resized(ROOTWIN *rootwin) { GRECT g; - short handle; struct gui_window *gw; - handle = guiwin_get_handle(rootwin->win); gw = window_get_active_gui_window(rootwin); //printf("resized...\n"); @@ -998,7 +995,7 @@ static void on_resized(ROOTWIN *rootwin) if(gw == NULL) return; - wind_get_grect(handle, WF_CURRXYWH, &g); + wind_get_grect(rootwin->aes_handle, WF_CURRXYWH, &g); if (rootwin->loc.g_w != g.g_w || rootwin->loc.g_h != g.g_h) { if ( gw->browser->bw->current_content != NULL ) { diff --git a/atari/settings.c b/atari/settings.c index 0aa78cc52..785d6f3f7 100644 --- a/atari/settings.c +++ b/atari/settings.c @@ -1,20 +1,3 @@ -/* - * Copyright 2012 Ole Loots - * - * 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 . - */ #include #include @@ -38,10 +21,10 @@ #include "atari/findfile.h" #include "atari/gemtk/gemtk.h" -extern char options[PATH_MAX]; +extern char options[PATH_MAX]; +extern GRECT desk_area; + -static OBJECT * dlgtree; -static WINDOW * dlgwin; static float tmp_option_memory_cache_size; static float tmp_option_minimum_gif_delay; @@ -52,893 +35,139 @@ static unsigned int tmp_option_min_reflow_period; static unsigned int tmp_option_max_fetchers; static unsigned int tmp_option_max_fetchers_per_host; static unsigned int tmp_option_max_cached_fetch_handles; -static colour tmp_option_atari_toolbar_bg; - -/* Tab forms and their buttons: */ -static int frms[] = { - CHOICES_TAB_BROWSER, - CHOICES_TAB_RENDER, - CHOICES_TAB_STYLE, - CHOICES_TAB_NETWORK, - CHOICES_TAB_PATH, - CHOICES_TAB_CACHE -}; - -static int buts[] = { - CHOICES_REG_BROWSER, - CHOICES_REG_RENDER, - CHOICES_REG_STYLE, - CHOICES_REG_NETWORK, - CHOICES_REG_PATH, - CHOICES_REG_CACHE -}; - -#define OBJ_SELECTED(idx) ((dlgtree[idx].ob_state & SELECTED)!=0) -#define OBJ_CHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 1); -#define OBJ_UNCHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 0); - -#define DISABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 1); \ - ObjcDraw( OC_FORM, dlgwin, idx, 1 ) - -#define ENABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 0); \ - ObjcDraw( OC_FORM, dlgwin, idx, 1 ) - -#define FORMEVENT(idx) form_event( NULL, idx, 0, NULL ); - -#define INPUT_HOMEPAGE_URL_MAX_LEN 44 -#define INPUT_LOCALE_MAX_LEN 6 -#define INPUT_PROXY_HOST_MAX_LEN 31 -#define INPUT_PROXY_USERNAME_MAX_LEN 36 -#define INPUT_PROXY_PASSWORD_MAX_LEN 36 -#define INPUT_PROXY_PORT_MAX_LEN 5 -#define INPUT_MIN_REFLOW_PERIOD_MAX_LEN 4 -#define LABEL_FONT_RENDERER_MAX_LEN 8 -#define LABEL_PATH_MAX_LEN 43 -#define LABEL_ICONSET_MAX_LEN 8 -#define INPUT_TOOLBAR_COLOR_MAX_LEN 6 - -static void toggle_objects( void ); -static void display_settings( void ); -static void apply_settings( void ); -static void __CDECL onclose( WINDOW *win, short buff[8] ); -static void __CDECL - closeform( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - saveform( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - form_event( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - clear_history( WINDOW *win, int index, int unused, void *unused2); - - - -WINDOW * open_settings() -{ - - if( dlgtree == NULL){ - dlgtree = get_tree(CHOICES); - if( dlgtree == NULL ){ - return( NULL ); - } - } - - if( dlgwin == NULL){ - // TODO: localize title - dlgwin = FormCreate(dlgtree, WAT_FORM, NULL, (char*)"Settings", - NULL, TRUE, FALSE); - if( !dlgwin ){ - return( NULL ); - } - FormThumb( dlgwin, frms, buts, sizeof(frms) / sizeof(int) ); - - /* Atach events to dialog buttons: */ - ObjcAttachFormFunc( dlgwin, CHOICES_ABORT, closeform, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_OK, saveform, NULL); - - /* Connect interactive dialog elements to generic event handler: */ - ObjcAttachFormFunc( dlgwin, CHOICES_CB_USE_PROXY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_CB_PROXY_AUTH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_DOWNLOAD_PATH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_HOTLIST_FILE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_BUNDLE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_CERTS_PATH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_EDITOR, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_GIF_DELAY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_GIF_DELAY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_INCREMENTAL_REFLOW, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_INCREMENTAL_REFLOW, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_CACHED_CONNECTIONS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_CACHED_CONNECTIONS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS_PER_HOST, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS_PER_HOST, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_DEF_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_DEF_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MIN_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MIN_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MEM_CACHE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MEM_CACHE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_HISTORY_AGE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_HISTORY_AGE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_FONT_RENDERER, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_LOCALE, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_TOOLBAR_ICONSET, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_CLEAR_HISTORY, - clear_history, NULL); - - EvntAdd( dlgwin, WM_CLOSED, onclose, EV_TOP ); - display_settings(); - toggle_objects(); - - } else { - WindTop( dlgwin ); - display_settings(); - toggle_objects(); - } - return( dlgwin ); -} - -void close_settings(void) -{ - if( dlgwin != NULL ){ - /* Duplicated form tree must be free'd manualy? */ - WindClose(dlgwin); - dlgwin = NULL; - } - -} - -static void set_text( short idx, char * text, int len ) -{ - char spare[255]; - - if( len > 254 ) - len = 254; - if( text != NULL ){ - strncpy( spare, text, 254); - ObjcStrFmt( spare, text, len ); - } else { - strcpy(spare, ""); - } - ObjcStrCpy( dlgtree, idx, spare ); - -} - - -static void __CDECL onclose( WINDOW *win, short buff[8] ) -{ - close_settings(); -} - -static void __CDECL -closeform( WINDOW *win, int index, int unused, void *unused2) -{ - ObjcChange( OC_FORM, win, index, ~SELECTED, TRUE); - close_settings(); -} - -static void __CDECL -saveform( WINDOW *win, int index, int unused, void *unused2) -{ - apply_settings(); - // Save settings - nsoption_write( (const char*)&options ); - nsoption_read( (const char*)&options ); - close_settings(); - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - form_alert(1, "[1][Some options require an netsurf restart!][OK]"); - deskmenu_update(); -} - -static void __CDECL clear_history( WINDOW *win, int index, int unused, - void *unused2) -{ - -} - - -static colour color_popup(int x, int y, colour current) -{ -#define GRID_ROWS 9 -#define GRID_COLS 27 - colour retval = current; - int boxwidth=6, boxheight=8; - struct bitmap *palette_img; - MFDB bg, screen; - GRECT bgarea = {x, y, GRID_COLS*boxwidth+4, GRID_ROWS*boxheight+4}; - short web_std_colors[6] = {0, 51, 102, 153, 204, 255}; - int r,g,b; - int xpos = 0, ypos = 0; - colour palette[216+8]; - int i=0; - - plot_style_t drawcolour = { - .stroke_type = PLOT_OP_TYPE_NONE, - .fill_type = PLOT_OP_TYPE_SOLID, - .fill_colour = 0 - }; - - plot_style_t outline = { - .stroke_type = PLOT_OP_TYPE_SOLID, - .stroke_colour = 0xAAAAAA, - .stroke_width = 2, - .fill_type = PLOT_OP_TYPE_NONE, - .fill_colour = 0 - }; - - /* create a palette array (web colors): */ - for (r=0; r<6; r++) { - for (g=0; g<6; g++) { - for (b=0; b<6; b++) { - palette[i] = ((web_std_colors[b]<<16) - | (web_std_colors[g]<<8) - | web_std_colors[r]); - i++; - } - } - } - - /* setup the gray color values: */ - int z = 0; - colour grays[15] = {0x111111, 0x222222, 0x333333, 0x444444, - 0x555555, 0x666666, 0x777777, 0x888888, - 0x999999, 0x999999, 0xAAAAAA, 0xBBBBBB, - 0xCCCCCC, 0xDDDDDD, 0xEEEEEE}; - for (z=0;i<243;i++) { - if (z<15) - palette[i] = grays[z]; - else - palette[i] = 0x000000; - z++; - } - - plot_set_dimensions(x, y, - (GRID_COLS*boxwidth)+4, (GRID_ROWS*boxheight)+4); - plot_lock(); - - // store background: - short pxy[8]; - init_mfdb(app.nplanes, bgarea.g_w, bgarea.g_h, 0, &bg); - init_mfdb(0, bgarea.g_w, bgarea.g_h, 0, &screen); - - pxy[0] = bgarea.g_x; - pxy[1] = bgarea.g_y; - pxy[2] = bgarea.g_x + bgarea.g_w - 1; - pxy[3] = bgarea.g_y + bgarea.g_h - 1; - pxy[4] = 0; - pxy[5] = 0; - pxy[6] = bgarea.g_w - 1; - pxy[7] = bgarea.g_h - 1; - - /* copy screen image */ - vro_cpyfm (app.graf.handle, S_ONLY, pxy, &screen, &bg); - - plot_line(x, y, x+(GRID_COLS*boxwidth)+2, y, - &outline); - - plot_line(x, y+(GRID_ROWS*boxheight)+2, x+(GRID_COLS*boxwidth)+2, - y+(GRID_ROWS*boxheight)+2, - &outline); - - /* draw a 27*8 grid: */ - for (i=0; i<243; i++){ - drawcolour.fill_colour = palette[i]; - plot_rectangle(xpos+2, ypos+2, xpos+boxwidth+2, ypos+boxheight+2, - &drawcolour); - xpos += boxwidth; - if (xpos >= GRID_COLS*boxwidth) { - xpos = 0; - ypos += boxheight; - } +static colour tmp_option_atari_toolbar_bg; + +static short h_aes_win = 0; +static GUIWIN * settings_guiwin = NULL; +static OBJECT * dlgtree; + +static void on_close(void); +static void on_redraw(GRECT *clip); + + +static void on_redraw(GRECT *clip) +{ + GRECT visible, work, clip_ro; + int scroll_px_x, scroll_px_y; + struct guiwin_scroll_info_s *slid; + + /*Walk the AES rectangle list and redraw the visible areas of the window: */ + guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &work); + slid = guiwin_get_scroll_info(settings_guiwin); + + dlgtree->ob_x = work.g_x - (slid->x_pos * slid->x_unit_px); + dlgtree->ob_y = work.g_y - (slid->y_pos * slid->y_unit_px); + + wind_get_grect(h_aes_win, WF_FIRSTXYWH, &visible); + while (visible.g_x && visible.g_y) { + if (rc_intersect(clip, &visible)) { + objc_draw_grect(dlgtree, 0, 8, &visible); + } + wind_get_grect(h_aes_win, WF_NEXTXYWH, &visible); } +} - // enable mouse cursor (screen keeps beeing locked): - graf_mouse(M_ON, NULL); - - /* fetch mouse event: */ - mt_EvntDisable(&app, dlgwin, WM_XBUTTON); - EvntWindom(MU_BUTTON); - mt_EvntEnable(&app, dlgwin, WM_XBUTTON); - - /* calulate clicked grid coords: */ - int row = ((evnt.my-y)/boxheight); - int col = ((evnt.mx-x)/boxwidth); - - if (row >= 0 && row <= GRID_ROWS-1 && col >= 0 && col <= GRID_COLS-1) { - assert( (GRID_COLS*row)+(col) >= 0 ); - assert( (GRID_COLS*row)+(col) < 243 ); - retval = palette[(GRID_COLS*row)+(col)]; - } - - /* restore background: */ - w_put_bkgr(&app, bgarea.g_x, bgarea.g_y, bgarea.g_w, bgarea.g_h, &bg); - free(bg.fd_addr); - - plot_unlock(); - -#undef GRID_COLS -#undef GRID_ROWS - - return(retval); -} - -/** -* Displays a popup to select available icon sets, - the returned string is no longer than 8 characters. -* \param x x pos of popup -* \param y y pos of popup -* \return the selected string or NULL on failure. -*/ -static char * toolbar_iconset_popup( int x, int y ) -{ - #define MAX_SETS 24 - DIR *dp; - struct dirent *ep; - struct stat statbuf; - char * current = NULL; - char *avail[MAX_SETS]; - int selected = 0, navail = 0, i, choice=-1; - static char toolbar_folder[PATH_MAX]; - char fullpath[PATH_MAX]; - - strncpy( fullpath, nsoption_charp(tree_icons_path), 255 ); - path_add_part( fullpath, 255, "toolbar/" ); - - /* Get current set (for pre-selection): */ - memset( avail, 0, MAX_SETS ); - current = ""; - - /* locate the toolbar folder: */ - atari_find_resource( toolbar_folder, fullpath, fullpath ); - - /* search for iconset folders: */ - dp = opendir (toolbar_folder); - if (dp != NULL){ - while (ep = readdir (dp)) { - if (strlen(ep->d_name) < 3) - continue; - snprintf(fullpath, PATH_MAX-1, "%s/%s", toolbar_folder, ep->d_name ); - if (is_dir(fullpath)) { - if (strcmp(ep->d_name, current) == 0) - selected = navail; - /* store the folder name: */ - avail[navail] = malloc( strlen(ep->d_name)+1 ); - sprintf( avail[navail], "%s", ep->d_name ); - navail++; - if( navail >= MAX_SETS ) - break; - } - } - (void) closedir (dp); - } - - - if (navail > 0){ - choice = MenuPopUp( avail, x, y, navail, - -1, selected, P_LIST | P_CHCK ); - if (choice > 0) - snprintf( toolbar_folder, 9, "%s", avail[choice-1] ); - } - - for (i=0;i 0) - return( toolbar_folder ); - else - return( NULL ); - #undef MAX_SETS -} - -static void __CDECL -form_event( WINDOW *win, int index, int external, void *unused2) -{ - char spare[255]; - bool is_button = false; - bool checked = OBJ_SELECTED( index ); - char * tmp; - - /* For font driver popup: */ - const char *font_driver_items[] = {"freetype", "internal" }; - int num_font_drivers = (sizeof(font_driver_items)/sizeof(char*)); - - /* - Just a small collection of locales, each country has at least one - ATARI-clone user! :) - */ - const char *locales[] = { - "cs", "de", "de-de" , "en", "en-gb", "en-us", "es", - "fr", "it", "nl", "no", "pl", "ru", "sk", "sv" - }; - int num_locales = (sizeof(locales)/sizeof(char*)); - short x, y; - int choice; +static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) +{ + short retval = 0; + GRECT clip, work; - switch( index ){ - - case CHOICES_CB_USE_PROXY: - if( checked ){ - ENABLE_OBJ( CHOICES_EDIT_PROXY_HOST ); - ENABLE_OBJ( CHOICES_CB_PROXY_AUTH ); - } - else { - DISABLE_OBJ( CHOICES_EDIT_PROXY_HOST ); - DISABLE_OBJ( CHOICES_CB_PROXY_AUTH ); - } - FORMEVENT( CHOICES_CB_PROXY_AUTH ); - ObjcDrawParent(OC_FORM, dlgwin, index, 9, 1 ); - break; - - case CHOICES_CB_PROXY_AUTH: - if( checked && OBJ_SELECTED( CHOICES_CB_USE_PROXY ) ){ - ENABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME); - ENABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD); - } - else { - DISABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME); - DISABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD); - } - break; - - case CHOICES_CB_ENABLE_ANIMATION: - if( checked ){ - ENABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY ); - } - else { - DISABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY ); - } - break; - - case CHOICES_BT_SEL_FONT_RENDERER: - if( external ){ - objc_offset( FORM(win), CHOICES_BT_SEL_FONT_RENDERER, &x, &y); - choice = MenuPopUp ( font_driver_items, x, y, - num_font_drivers, - -1, -1, P_LIST + P_WNDW + P_CHCK ); - if( choice > 0 && - choice <= num_font_drivers ){ - ObjcStrCpy( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, - (char*)font_driver_items[choice-1] ); - } - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - } - tmp = ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL); - if( strcmp(tmp, "freetype") == 0 ){ - ENABLE_OBJ( CHOICES_CB_ANTI_ALIASING ); - } else { - DISABLE_OBJ( CHOICES_CB_ANTI_ALIASING ); - } - break; - - case CHOICES_BT_SEL_LOCALE: - objc_offset( FORM(win), CHOICES_BT_SEL_LOCALE, &x, &y); - choice = MenuPopUp ( locales, x, y, - num_locales, - -1, -1, P_LIST + P_WNDW + P_CHCK ); - if( choice > 0 && choice <= num_locales ){ - ObjcStrCpy( dlgtree, CHOICES_BT_SEL_LOCALE, - (char*)locales[choice-1] ); - } - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - break; - - case CHOICES_INPUT_TOOLBAR_BGCOLOR: - objc_offset( FORM(win), CHOICES_INPUT_TOOLBAR_BGCOLOR, &x, &y ); - choice = color_popup(x, y, tmp_option_atari_toolbar_bg); - snprintf( spare, 255, "%06x", choice ); - tmp_option_atari_toolbar_bg = choice; - ObjcStrCpy( dlgtree, CHOICES_INPUT_TOOLBAR_BGCOLOR, - spare ); - is_button = true; - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR, 2, 1 ); - break; - - case CHOICES_BT_TOOLBAR_ICONSET: - objc_offset( FORM(win), CHOICES_BT_TOOLBAR_ICONSET, &x, &y ); - tmp = toolbar_iconset_popup(x,y); - if( tmp != NULL ){ - ObjcStrCpy( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, tmp ); - } - is_button = true; - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - break; - - case CHOICES_INC_MEM_CACHE: - case CHOICES_DEC_MEM_CACHE: - if( index == CHOICES_DEC_MEM_CACHE ) - tmp_option_memory_cache_size -= 0.1; - else - tmp_option_memory_cache_size += 0.1; - - if( tmp_option_memory_cache_size < 0.5 ) - tmp_option_memory_cache_size = 0.5; - if( tmp_option_memory_cache_size > 999.9 ) - tmp_option_memory_cache_size = 999.9; - snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); - set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_STR_MAX_MEM_CACHE, 2, 1 ); - break; - - case CHOICES_INC_CACHED_CONNECTIONS: - case CHOICES_DEC_CACHED_CONNECTIONS: - if( index == CHOICES_INC_CACHED_CONNECTIONS ) - tmp_option_max_cached_fetch_handles += 1; - else - tmp_option_max_cached_fetch_handles -= 1; - if( tmp_option_max_cached_fetch_handles > 31 ) - tmp_option_max_cached_fetch_handles = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); - set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, - 2, 1 ); - break; - - case CHOICES_INC_MAX_FETCHERS: - case CHOICES_DEC_MAX_FETCHERS: - if( index == CHOICES_INC_MAX_FETCHERS ) - tmp_option_max_fetchers += 1; - else - tmp_option_max_fetchers -= 1; - if( tmp_option_max_fetchers > 31 ) - tmp_option_max_fetchers = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); - set_text( CHOICES_EDIT_MAX_FETCHERS, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS, - 3, 1 ); - break; - - case CHOICES_INC_MAX_FETCHERS_PER_HOST: - case CHOICES_DEC_MAX_FETCHERS_PER_HOST: - if( index == CHOICES_INC_MAX_FETCHERS_PER_HOST ) - tmp_option_max_fetchers_per_host += 1; - else - tmp_option_max_fetchers_per_host -= 1; - if( tmp_option_max_fetchers_per_host > 31 ) - tmp_option_max_fetchers_per_host = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); - set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, - 2, 1 ); - break; - - case CHOICES_INC_HISTORY_AGE: - case CHOICES_DEC_HISTORY_AGE: - if( index == CHOICES_INC_HISTORY_AGE ) - tmp_option_expire_url += 1; - else - tmp_option_expire_url -= 1; - - if( tmp_option_expire_url > 99 ) - tmp_option_expire_url = 0; - - snprintf( spare, 255, "%02d", tmp_option_expire_url ); - set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_HISTORY_AGE, - 3, 1 ); - break; - - case CHOICES_INC_GIF_DELAY: - case CHOICES_DEC_GIF_DELAY: - if( index == CHOICES_INC_GIF_DELAY ) - tmp_option_minimum_gif_delay += 0.1; - else - tmp_option_minimum_gif_delay -= 0.1; - - if( tmp_option_minimum_gif_delay < 0.1 ) - tmp_option_minimum_gif_delay = 0.1; - if( tmp_option_minimum_gif_delay > 9.0 ) - tmp_option_minimum_gif_delay = 9.0; - snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); - set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_GIF_DELAY, 3, 1 ); - break; - - case CHOICES_INC_MIN_FONT_SIZE: - case CHOICES_DEC_MIN_FONT_SIZE: - if( index == CHOICES_INC_MIN_FONT_SIZE ) - tmp_option_font_min_size += 1; - else - tmp_option_font_min_size -= 1; - - if( tmp_option_font_min_size > 500 ) - tmp_option_font_min_size = 500; - if( tmp_option_font_min_size < 10 ) - tmp_option_font_min_size = 10; - - snprintf( spare, 255, "%03d", tmp_option_font_min_size ); - set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_FONT_SIZE, - 3, 1 ); - break; - - case CHOICES_INC_DEF_FONT_SIZE: - case CHOICES_DEC_DEF_FONT_SIZE: - if( index == CHOICES_INC_DEF_FONT_SIZE ) - tmp_option_font_size += 1; - else - tmp_option_font_size -= 1; - - if( tmp_option_font_size > 999 ) - tmp_option_font_size = 999; - if( tmp_option_font_size < 50 ) - tmp_option_font_size = 50; - - snprintf( spare, 255, "%03d", tmp_option_font_size ); - set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_DEF_FONT_SIZE, - 3, 1 ); - - break; - - case CHOICES_INC_INCREMENTAL_REFLOW: - case CHOICES_DEC_INCREMENTAL_REFLOW: - if( index == CHOICES_INC_INCREMENTAL_REFLOW ) - tmp_option_min_reflow_period += 1; - else - tmp_option_min_reflow_period -= 1; - - if( tmp_option_min_reflow_period > 9999 ) - tmp_option_min_reflow_period = 10; - - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); - set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_REFLOW_PERIOD, - 3, 1 ); - break; - - default: break; - } - if( is_button ){ - // remove selection indicator from button element: - OBJ_UNCHECK( index ); - ObjcDraw( OC_FORM, dlgwin, index, 1 ); - } -} - -/** - * Toogle all objects which are directly influenced by other GUI elements - * ( like checkbox ) - */ -static void toggle_objects( void ) -{ - /* enable / disable (refresh) objects depending on radio button values: */ - FORMEVENT(CHOICES_CB_USE_PROXY); - FORMEVENT(CHOICES_CB_PROXY_AUTH); - FORMEVENT(CHOICES_BT_SEL_FONT_RENDERER); -} - - -/* this gets called each time the settings dialog is opened: */ -static void display_settings( void ) -{ - char spare[255]; - // read current settings and display them - - /* "Browser" tab: */ - set_text( CHOICES_EDIT_HOMEPAGE, nsoption_charp(homepage_url), - INPUT_HOMEPAGE_URL_MAX_LEN ); - - if( nsoption_bool(block_ads) ){ - OBJ_CHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); - } else { - OBJ_UNCHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); - } - if( nsoption_bool(target_blank) ){ - OBJ_UNCHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); - } else { - OBJ_CHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); - } - if( nsoption_bool(send_referer) ){ - OBJ_CHECK( CHOICES_CB_SEND_HTTP_REFERRER ); - } else { - OBJ_UNCHECK( CHOICES_CB_SEND_HTTP_REFERRER ); - } - if( nsoption_bool(do_not_track) ){ - OBJ_CHECK( CHOICES_CB_SEND_DO_NOT_TRACK ); - } else { - OBJ_UNCHECK( CHOICES_CB_SEND_DO_NOT_TRACK ); - } - - set_text( CHOICES_BT_SEL_LOCALE, - nsoption_charp(accept_language) ? nsoption_charp(accept_language) : (char*)"en", - INPUT_LOCALE_MAX_LEN ); - - tmp_option_expire_url = nsoption_int(expire_url); - snprintf( spare, 255, "%02d", nsoption_int(expire_url) ); - set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 ); - - /* "Cache" tab: */ - tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / 100000; - snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); - set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 ); - - /* "Paths" tab: */ - set_text( CHOICES_EDIT_DOWNLOAD_PATH, nsoption_charp(downloads_path), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_HOTLIST_FILE, nsoption_charp(hotlist_file), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_BUNDLE, nsoption_charp(ca_bundle), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_CERTS_PATH, nsoption_charp(ca_path), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_EDITOR, nsoption_charp(atari_editor), - LABEL_PATH_MAX_LEN ); - - /* "Rendering" tab: */ - set_text( CHOICES_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver), - LABEL_FONT_RENDERER_MAX_LEN ); - SET_BIT(dlgtree[CHOICES_CB_TRANSPARENCY].ob_state, - SELECTED, nsoption_int(atari_transparency) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_ENABLE_ANIMATION].ob_state, - SELECTED, nsoption_bool(animate_images) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_INCREMENTAL_REFLOW].ob_state, - SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_ANTI_ALIASING].ob_state, - SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 ); - - tmp_option_min_reflow_period = nsoption_int(min_reflow_period); - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); - set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, - INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); - - tmp_option_minimum_gif_delay = (float)nsoption_int(minimum_gif_delay) / (float)100; - snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); - set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 ); - - /* "Network" tab: */ - set_text( CHOICES_EDIT_PROXY_HOST, nsoption_charp(http_proxy_host), - INPUT_PROXY_HOST_MAX_LEN ); - snprintf( spare, 255, "%5d", nsoption_int(http_proxy_port) ); - set_text( CHOICES_EDIT_PROXY_PORT, spare, - INPUT_PROXY_PORT_MAX_LEN ); - - set_text( CHOICES_EDIT_PROXY_USERNAME, nsoption_charp(http_proxy_auth_user), - INPUT_PROXY_USERNAME_MAX_LEN ); - set_text( CHOICES_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass), - INPUT_PROXY_PASSWORD_MAX_LEN ); - SET_BIT(dlgtree[CHOICES_CB_USE_PROXY].ob_state, - SELECTED, nsoption_bool(http_proxy) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_PROXY_AUTH].ob_state, - SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_FG_IMAGES].ob_state, - SELECTED, nsoption_bool(foreground_images) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_BG_IMAGES].ob_state, - SELECTED, nsoption_bool(background_images) ? 1 : 0 ); - - tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles); - snprintf( spare, 255, "%2d", nsoption_int(max_cached_fetch_handles) ); - set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 ); - - tmp_option_max_fetchers = nsoption_int(max_fetchers); - snprintf( spare, 255, "%2d", nsoption_int(max_fetchers) ); - set_text( CHOICES_EDIT_MAX_FETCHERS, spare , 2 ); - - tmp_option_max_fetchers_per_host = nsoption_int(max_fetchers_per_host); - snprintf( spare, 255, "%2d", nsoption_int(max_fetchers_per_host) ); - set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 ); - - - /* "Style" tab: */ - tmp_option_font_min_size = nsoption_int(font_min_size); - snprintf( spare, 255, "%3d", nsoption_int(font_min_size) ); - set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare , 3 ); - - tmp_option_font_size = nsoption_int(font_size); - snprintf( spare, 255, "%3d", nsoption_int(font_size) ); - set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 ); - - /* Only first tab is refreshed: */ - ObjcDraw( OC_FORM, dlgwin, CHOICES_TAB_BROWSER, 4 ); - - // update elements (enable/disable) chained to form events: - toggle_objects(); -} - -static void apply_settings( void ) -{ - /* "Network" tab: */ - nsoption_set_bool(http_proxy, OBJ_SELECTED(CHOICES_CB_USE_PROXY)); - if ( OBJ_SELECTED(CHOICES_CB_PROXY_AUTH) ) { - nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); - } else { - nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); - } - nsoption_set_charp(http_proxy_auth_pass, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_PASSWORD, NULL)); - nsoption_set_charp(http_proxy_auth_user, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_USERNAME, NULL)); - nsoption_set_charp(http_proxy_host, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_HOST, NULL)); - nsoption_set_int(http_proxy_port, - atoi( ObjcString( dlgtree, CHOICES_EDIT_PROXY_PORT, NULL) )); - nsoption_set_int(max_fetchers_per_host, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, NULL))); - nsoption_set_int(max_cached_fetch_handles, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, NULL))); - nsoption_set_int(max_fetchers, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS, NULL) )); - nsoption_set_bool(foreground_images, - OBJ_SELECTED( CHOICES_CB_FG_IMAGES )); - nsoption_set_bool(background_images, - OBJ_SELECTED( CHOICES_CB_BG_IMAGES )); - - /* "Style" tab: */ - nsoption_set_int(font_min_size, tmp_option_font_min_size); - nsoption_set_int(font_size, tmp_option_font_size); - - /* "Rendering" tab: */ - nsoption_set_charp(atari_font_driver, - ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL)); - nsoption_set_bool(atari_transparency, - OBJ_SELECTED(CHOICES_CB_TRANSPARENCY)); - nsoption_set_bool(animate_images, - OBJ_SELECTED(CHOICES_CB_ENABLE_ANIMATION)); - nsoption_set_int(minimum_gif_delay, - (int)(tmp_option_minimum_gif_delay*100+0.5)); - nsoption_set_bool(incremental_reflow, - OBJ_SELECTED(CHOICES_CB_INCREMENTAL_REFLOW)); - nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period); - nsoption_set_int(atari_font_monochrom, - !OBJ_SELECTED( CHOICES_CB_ANTI_ALIASING )); - - /* "Paths" tabs: */ - nsoption_set_charp(ca_bundle, - ObjcString( dlgtree, CHOICES_EDIT_CA_BUNDLE, NULL)); - nsoption_set_charp(ca_path, - ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); - nsoption_set_charp(homepage_url, - ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); - nsoption_set_charp(hotlist_file, - ObjcString( dlgtree, CHOICES_EDIT_HOTLIST_FILE, NULL)); - nsoption_set_charp(atari_editor, - ObjcString( dlgtree, CHOICES_EDIT_EDITOR, NULL)); - nsoption_set_charp(downloads_path, - ObjcString( dlgtree, CHOICES_EDIT_DOWNLOAD_PATH, NULL)); - - /* "Cache" tab: */ - nsoption_set_int(memory_cache_size, - tmp_option_memory_cache_size * 100000); - - /* "Browser" tab: */ - nsoption_set_bool(target_blank, - !OBJ_SELECTED(CHOICES_CB_DISABLE_POPUP_WINDOWS)); - nsoption_set_bool(block_ads, - OBJ_SELECTED(CHOICES_CB_HIDE_ADVERTISEMENT)); - nsoption_set_charp(accept_language, - ObjcString( dlgtree, CHOICES_BT_SEL_LOCALE, NULL)); - nsoption_set_int(expire_url, - atoi(ObjcString( dlgtree, CHOICES_EDIT_HISTORY_AGE, NULL))); - nsoption_set_bool(send_referer, - OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER)); - nsoption_set_bool(do_not_track, - OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER)); - nsoption_set_charp(homepage_url, - ObjcString( dlgtree, CHOICES_EDIT_HOMEPAGE, NULL)); -} - -#undef OBJ_SELECTED -#undef OBJ_CHECK -#undef OBJ_UNCHECK -#undef DISABLE_OBJ -#undef ENABLE_OBJ -#undef FORMEVENT - + if ((ev_out->emo_events & MU_MESAG) != 0) { + // handle message + printf("settings win msg: %d\n", msg[0]); + switch (msg[0]) { + + case WM_REDRAW: + clip.g_x = msg[4]; + clip.g_y = msg[5]; + clip.g_w = msg[6]; + clip.g_h = msg[7]; + on_redraw(&clip); + break; + + case WM_CLOSED: + // TODO: this needs to iterate through all gui windows and + // check if the rootwin is this window... + close_settings(); + break; + + case WM_SIZED: + guiwin_update_slider(win, GUIWIN_VH_SLIDER); + break; + + case WM_TOOLBAR: + switch(msg[4]){ + default: break; + } + break; + + default: + break; + } + } + if ((ev_out->emo_events & MU_KEYBD) != 0) { + + + } + if ((ev_out->emo_events & MU_BUTTON) != 0) { + + struct guiwin_scroll_info_s *slid; + + guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &work); + slid = guiwin_get_scroll_info(settings_guiwin); + dlgtree->ob_x = work.g_x - (slid->x_pos * slid->x_unit_px); + dlgtree->ob_y = work.g_y - (slid->y_pos * slid->y_unit_px); + + short obj = objc_find(dlgtree, 0, 8, ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_y); + printf("clicked: %d\n", obj); + evnt_timer(150); + } + + return(retval); +} + +void open_settings(void) +{ + if (h_aes_win == 0) { + + GRECT curr, area; + struct guiwin_scroll_info_s *slid; + uint32_t kind = CLOSER | NAME | MOVER | VSLIDE | HSLIDE | UPARROW + | DNARROW | LFARROW | RTARROW | SIZER | FULLER; + + dlgtree = get_tree(SETTINGS); + area.g_x = area.g_y = 0; + area.g_w = MIN(dlgtree->ob_width, desk_area.g_w); + area.g_h = MIN(dlgtree->ob_height, desk_area.g_h); + wind_calc_grect(WC_BORDER, kind, &area, &area); + h_aes_win = wind_create_grect(kind, &area); + wind_set_str(h_aes_win, WF_NAME, "Settings"); + settings_guiwin = guiwin_add(h_aes_win, GW_FLAG_DEFAULTS, + on_aes_event); + curr.g_w = MIN(dlgtree->ob_width, desk_area.g_w); + curr.g_h = 200; + curr.g_x = (desk_area.g_w / 2) - (curr.g_w / 2); + curr.g_y = (desk_area.g_h / 2) - (curr.g_h / 2); + wind_calc_grect(WC_BORDER, kind, &curr, &curr); + wind_open_grect(h_aes_win, &curr); + + slid = guiwin_get_scroll_info(settings_guiwin); + slid->y_unit_px = 32; + slid->x_unit_px = 32; + guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &area); + slid->x_units = (dlgtree->ob_width/slid->x_unit_px); + slid->y_units = (dlgtree->ob_height/slid->y_unit_px); + guiwin_update_slider(settings_guiwin, GUIWIN_VH_SLIDER); + } +} + +void close_settings(void) +{ + printf("settings close\n"); + guiwin_remove(settings_guiwin); + settings_guiwin = NULL; + wind_close(h_aes_win); + wind_delete(h_aes_win); + h_aes_win = 0; +} diff --git a/atari/settings.h b/atari/settings.h index 97b194111..ef6ae8195 100644 --- a/atari/settings.h +++ b/atari/settings.h @@ -3,7 +3,7 @@ #include -WINDOW * open_settings(void); +void open_settings(void); void close_settings(void); #endif