summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xatari/browser.c58
-rwxr-xr-xatari/browser_win.c165
-rwxr-xr-xatari/browser_win.h2
-rwxr-xr-xatari/doc/todo.txt19
-rwxr-xr-xatari/download.h2
-rwxr-xr-xatari/global_evnt.c161
-rwxr-xr-xatari/global_evnt.h4
-rwxr-xr-xatari/gui.c121
-rwxr-xr-xatari/gui.h8
-rwxr-xr-xatari/hotlist.c110
-rwxr-xr-xatari/hotlist.h29
-rwxr-xr-xatari/res/netsurf.rscbin23936 -> 28728 bytes
-rwxr-xr-xatari/res/netsurf.rsh18
-rwxr-xr-xatari/res/netsurf.rsm26
-rwxr-xr-xatari/treeview.c332
-rwxr-xr-xatari/treeview.h20
16 files changed, 715 insertions, 360 deletions
diff --git a/atari/browser.c b/atari/browser.c
index cdbf4e0b9..fd858c045 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -50,6 +50,9 @@ extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern GEM_PLOTTER plotter;
extern struct gui_window *input_window;
+extern short last_drag_x;
+extern short last_drag_y;
+
static void __CDECL browser_evnt_wdestroy( WINDOW * c, short buff[8], void * data);
@@ -347,40 +350,42 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data
{
long lbuff[8];
short i;
- short mbut, mkstat, mx, my;
- graf_mkstate(&mx, &my, &mbut, &mkstat);
+ short mx, my, dummy, mbut;
uint32_t tnow = clock()*1000 / CLOCKS_PER_SEC;
LGRECT cwork;
struct gui_window * gw = data;
input_window = gw;
window_set_focus( gw, BROWSER, (void*)gw->browser );
browser_get_rect( gw, BR_CONTENT, &cwork );
- mx = evnt.mx - cwork.g_x; /*+ gw->browser->scroll.current.x*/;
- my = evnt.my - cwork.g_y; /*+ gw->browser->scroll.current.y*/;
- LOG(("mevent within %s at %d / %d", gw->browser->bw->name, mx, my ));
+ mx = evnt.mx - cwork.g_x;
+ my = evnt.my - cwork.g_y;
+ LOG(("mevent (%d) within %s at %d / %d\n", evnt.nb_click, gw->browser->bw->name, mx, my ));
- if( (mkstat & K_RSHIFT) || (mkstat & K_LSHIFT) ){
+ if( evnt.mkstate & (K_RSHIFT | K_LSHIFT) ){
bmstate |= BROWSER_MOUSE_MOD_1;
} else {
bmstate &= ~(BROWSER_MOUSE_MOD_1);
}
- if( (mkstat & K_CTRL) ){
+ if( (evnt.mkstate & K_CTRL) ){
bmstate |= BROWSER_MOUSE_MOD_2;
} else {
- bmstate &= ~(BROWSER_MOUSE_MOD_1);
+ bmstate &= ~(BROWSER_MOUSE_MOD_2);
}
- if( (mkstat & K_ALT) ){
+ if( (evnt.mkstate & K_ALT) ){
bmstate |= BROWSER_MOUSE_MOD_3;
} else {
- bmstate &= ~(BROWSER_MOUSE_MOD_2);
- }
+ bmstate &= ~(BROWSER_MOUSE_MOD_3);
+ }
int sx = (mx + gw->browser->scroll.current.x);
int sy = (my + gw->browser->scroll.current.y);
+
+ graf_mkstate(&dummy, &dummy, &mbut, &dummy);
+ /* todo: if we need right button click, increase loop count */
for( i = 1; i<2; i++) {
- if( (mbut & i) ) {
+ if( (mbut & i) ) {
if( mouse_hold_start[i-1] == 0 ) {
- mouse_hold_start[i-1] = clock()*1000 / CLOCKS_PER_SEC;
- LOG(("Drag %d starts", i));
+ mouse_hold_start[i-1] = tnow;
+ LOG(("Drag %d starts at %d,%d\n", i, sx, sy));
if( i == 1 ) {
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
bmstate |= BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
@@ -397,17 +402,25 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data
bmstate |= BROWSER_MOUSE_DRAG_2 | BROWSER_MOUSE_DRAG_ON;
}
}
- } else {
- /* remember click time, so we can track double clicks: */
- /* this does not really work, because a normal double click is swallowed by evnt_multi */
- if( tnow - mouse_click_time[i-1] < 500 ) {
- /* double click */
+
+ if( i != 0 ){
+ if( (abs(mx-last_drag_x)>5) || (abs(mx-last_drag_y)>5) ){
+ browser_window_mouse_track(
+ gw->browser->bw,
+ bmstate,
+ sx, sy
+ );
+ last_drag_x = mx;
+ last_drag_y = my;
+ }
}
+
+ } else {
mouse_click_time[i-1] = tnow; /* clock in ms */
/* check if this event was during an drag op: */
- if( mouse_hold_start[i-1] < 10 ) {
+ if( mouse_hold_start[i-1] == 0 ) {
if( i == 1) {
- LOG(("Click within %s at %d / %d", gw->browser->bw->name, sx, sy ));
+ LOG(("Click within %s at %d / %d\n", gw->browser->bw->name, sx, sy ));
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_CLICK_1,sx,sy);
bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_CLICK_1);
@@ -422,7 +435,7 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data
}
mouse_hold_start[i-1] = 0;
}
- }
+ }
}
void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
@@ -1025,6 +1038,7 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
LGRECT work, lclip, rwork;
int xoff,yoff,width,heigth;
short cw, ch, cellw, cellh;
+ /* use that instead of browser_find_root() ? */
w = (WINDOW*)mt_CompGetPtr( &app, c, CF_WINDOW );
browser_get_rect( gw, BR_CONTENT, &work );
browser_get_rect( rgw, BR_CONTENT, &rwork );
diff --git a/atari/browser_win.c b/atari/browser_win.c
index 05131f0e0..f58bc8755 100755
--- a/atari/browser_win.c
+++ b/atari/browser_win.c
@@ -63,6 +63,11 @@ bool cfg_rt_move = false;
extern void * h_gem_rsrc;
extern struct gui_window *input_window;
extern GEM_PLOTTER plotter;
+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;
void __CDECL std_szd( WINDOW * win, short buff[8], void * );
void __CDECL std_mvd( WINDOW * win, short buff[8], void * );
@@ -102,6 +107,154 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data
browser_scroll( input_window, buff[4], value, abs );
}
+/*
+ this gets called at end of gui poll to track the mouse state and
+ finally checks for released buttons.
+ */
+static void window_track_mouse_state( LGRECT * bwrect, bool within, short mx, short my, short mbut, short mkstate ){
+ int i = 0;
+ int nx, ny;
+ struct gui_window * gw = input_window;
+
+ if( !gw ) {
+ bmstate = 0;
+ mouse_hold_start[0] = 0;
+ mouse_hold_start[1] = 0;
+ return;
+ }
+
+ /* todo: creat function find_browser_window( mx, my ) */
+ nx = (mx - bwrect->g_x + gw->browser->scroll.current.x);
+ ny = (my - bwrect->g_y + gw->browser->scroll.current.y);
+
+ if( mkstate & (K_RSHIFT | K_LSHIFT) ){
+ bmstate |= BROWSER_MOUSE_MOD_1;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_1);
+ }
+ if( (mkstate & K_CTRL) ){
+ bmstate |= BROWSER_MOUSE_MOD_2;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_2);
+ }
+ if( (mkstate & K_ALT) ){
+ bmstate |= BROWSER_MOUSE_MOD_3;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_3);
+ }
+
+ if( !(mbut&1) && !(mbut&2) ) {
+ if(bmstate & BROWSER_MOUSE_DRAG_ON )
+ bmstate &= ~( BROWSER_MOUSE_DRAG_ON );
+ }
+
+ /* todo: if we need right button click, increase loop count */
+ for( i = 1; i<2; i++ ) {
+ if( !(mbut & i) ) {
+ if( mouse_hold_start[i-1] > 0 ) {
+ mouse_hold_start[i-1] = 0;
+ /* TODO: not just use the input window browser, find the right one by component! */
+ if( i==1 ) {
+ LOG(("Drag for %d ended", i));
+ bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 ) ;
+ if( within ) {
+ browser_window_mouse_drag_end(
+ gw->browser->bw, 0, nx, ny
+ );
+ }
+ }
+ if( i==2 ) {
+ bmstate &= ~( BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_2 ) ;
+ LOG(("Drag for %d ended", i));
+ if( within ) {
+ browser_window_mouse_drag_end(
+ gw->browser->bw, 0, nx, ny
+ );
+ }
+ }
+ }
+ }
+ }
+}
+
+
+static void __CDECL evnt_window_m1( WINDOW * win, short buff[8])
+{
+ struct gui_window * gw = input_window;
+ static bool prev_url = false;
+ static bool prev_sb = false;
+ short mx, my, mbut, mkstate;
+ bool a = false; /* flags if mouse is within controls or browser canvas */
+ bool within = false;
+ LGRECT urlbox, bwbox, sbbox;
+ int nx, ny; /* relative mouse position */
+
+
+ if( gw == NULL)
+ return;
+
+ graf_mkstate(&mx, &my, &mbut, &mkstate);
+
+ browser_get_rect( gw, BR_CONTENT, &bwbox );
+ if( gw->root->toolbar )
+ mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
+ if( gw->root->statusbar )
+ mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &sbbox);
+
+ if( mx > bwbox.g_x && mx < bwbox.g_x + bwbox.g_w &&
+ my > bwbox.g_y && my < bwbox.g_y + bwbox.g_h ){
+ within = true;
+ }
+
+ if( evnt.m1_flag == MO_LEAVE ) {
+ if( MOUSE_IS_DRAGGING() ){
+ window_track_mouse_state( &bwbox, within, mx, my, mbut, mkstate );
+ }
+ if( gw->root->toolbar && within == false ) {
+ if( (mx > urlbox.g_x && mx < urlbox.g_x + urlbox.g_w ) &&
+ (my > urlbox.g_y && my < + urlbox.g_y + urlbox.g_h )) {
+ gem_set_cursor( &gem_cursors.ibeam );
+ prev_url = a = true;
+ }
+ }
+ if( gw->root->statusbar && within == false /* && a == false */ ) {
+ if( mx >= sbbox.g_x + (sbbox.g_w-MOVER_WH) && mx <= sbbox.g_x + sbbox.g_w &&
+ my >= sbbox.g_y + (sbbox.g_h-MOVER_WH) && my <= sbbox.g_y + sbbox.g_h ) {
+ /* mouse within sizer box ( bottom right ) */
+ prev_sb = a = true;
+ gem_set_cursor( &gem_cursors.sizenwse );
+ }
+ }
+ if( !a ) {
+ if( prev_url || prev_sb ) {
+ gem_set_cursor( &gem_cursors.arrow );
+ prev_url = false;
+ prev_sb = false;
+ }
+ /* report mouse move in the browser window */
+ if( within ){
+ nx = mx - bwbox.g_x;
+ ny = my - bwbox.g_y;
+ if( ( abs(mx-last_drag_x)>5 || abs(mx-last_drag_y)>5 ) ||
+ !MOUSE_IS_DRAGGING() ){
+ browser_window_mouse_track(
+ input_window->browser->bw,
+ bmstate,
+ nx + gw->browser->scroll.current.x,
+ ny + gw->browser->scroll.current.y
+ );
+ if( MOUSE_IS_DRAGGING() ){
+ last_drag_x = mx;
+ last_drag_y = my;
+ }
+ }
+ }
+ }
+ } else {
+ /* set input window? */
+ }
+}
+
int window_create( struct gui_window * gw, struct browser_window * bw, unsigned long inflags)
{
short buff[8];
@@ -119,6 +272,11 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
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 );
+ }
gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
@@ -163,6 +321,7 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, &evnt_data, EV_BOT);
EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, &evnt_data, EV_BOT);
EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
+ EvntAttach( gw->root->handle, WM_XM1, evnt_window_m1 );
/*
OBJECT * tbut;
@@ -199,10 +358,14 @@ int window_destroy( struct gui_window * gw)
sb_destroy( gw->root->statusbar );
}
+ search_destroy( gw );
+
LOG(("Freeing browser window"));
if( gw->browser )
browser_destroy( gw->browser );
+
+
/* destroy the icon: */
/*window_set_icon(gw, NULL, false );*/
@@ -223,6 +386,8 @@ int window_destroy( struct gui_window * gw)
return( err );
}
+
+
void window_open( struct gui_window * gw)
{
LGRECT br;
diff --git a/atari/browser_win.h b/atari/browser_win.h
index 37610c9f7..6dff2d0f0 100755
--- a/atari/browser_win.h
+++ b/atari/browser_win.h
@@ -78,4 +78,6 @@ 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_keybd(WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_mbutton(WINDOW *win, short buff[8], void *data );
+static void __CDECL evnt_window_m1( WINDOW * win, short buff[8]);
+
#endif
diff --git a/atari/doc/todo.txt b/atari/doc/todo.txt
index d62fbb35a..8a3bae0f4 100755
--- a/atari/doc/todo.txt
+++ b/atari/doc/todo.txt
@@ -1,11 +1,13 @@
TODO's (no priority order)
- - Optimize drawing of 1px width / height tiled bitmaps (stretch)
- Optimize remove / redraw of caret, use pixbuffer instead?
- Optimize drawing of bitmaps on Low-Memory machines
- Optimize Clipping for Plotters ( use OS clipping instead of own clipping )
+ ( partially done, needs improvement? )
- Restore the Palette when Windows get's the Focus
+ -> only needed for <= 256 colors
- Make drawing of tiled bitmaps optional ( they are slooow )
+ -> already optimized, still needed?
- Implement TreeView
- Implement TreeView Hotlits
- Implement TreeView History
@@ -29,12 +31,15 @@ TODO's (no priority order)
( at best, implement callback for this...)
- Yahoo.de / .com etc. still crashes - this is probably not an Atari-Version
fault, but applies to all other netsurf versions.
+ -> this is caused by regex stack exhaust within mintlib
- Have browser_window specific cursor, window specifc cursor
- - At some places I query for gdos version and use v_gtext when running
- classic TOS. This is maybe not really correct, altough the v_ftext work
- on the newer OS (MiNT) it doesn't mean I'm using it correct.
- When minimized (not iconyfied) NetSurf doesn't recognize that.
- - Iconify Code kompletieren ( favicon, icon nach oben schieben - icon name anzeigen)
- - fix ablend() function within vdi plotter, antialiased text only looks good when rendered
- on white / black backgrounds, maybe other colors, but red looks ugly.
+ - complete Iconify (webpage favicon )
+ - improve mouse tracking
+ - fix this:
+path2url in: ./res/icons/dir.png
+path2url out: file:///./res/icons/dir.png
+url2path in: file:///./res/icons/dir.png
+ - loesung fuer kompletten tree icons path finden
+ - schauen warum download_path nicht verwendet wird.
\ No newline at end of file
diff --git a/atari/download.h b/atari/download.h
index 52fe05df5..b0eff8a59 100755
--- a/atari/download.h
+++ b/atari/download.h
@@ -24,6 +24,8 @@
#define MAX_SLEN_LBL_SPEED 16
#define MAX_SLEN_LBL_FILE 256
+#define DOWNLOAD_BAR_MAX 300
+
typedef enum {
NSATARI_DOWNLOAD_NONE,
NSATARI_DOWNLOAD_WORKING,
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 0179ccf17..165208365 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -31,6 +31,7 @@
#include "desktop/browser.h"
#include "desktop/mouse.h"
#include "desktop/textinput.h"
+#include "desktop/hotlist.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -52,6 +53,8 @@ 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;
/* Zero based resource tree ids: */
#define T_ABOUT 0
@@ -235,6 +238,14 @@ static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
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(
+ content_get_url( input_window->browser->bw->current_content),
+ NULL
+ );
+ }
+ }
}
static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
@@ -303,19 +314,14 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
int i=0;
bool done = false;
- struct s_evnt_data * loc_evnt_data;
- loc_evnt_data = (struct s_event_data*)data;
struct gui_window * gw = input_window;
struct gui_window * gw_tmp;
if( gw == NULL )
return;
- if( loc_evnt_data->ignore )
- return;
kstate = evnt.mkstate;
kcode = evnt.keybd;
nkc= gem_to_norm( (short)kstate, (short)kcode );
nks = (nkc & 0xFF00);
- loc_evnt_data->ignore = false;
if( kstate & (K_LSHIFT|K_RSHIFT))
kstate |= K_LSHIFT|K_RSHIFT;
if( window_url_widget_has_focus( gw ) ) {
@@ -326,6 +332,7 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
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 );
@@ -364,148 +371,6 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
}
}
-/* this gets called at end of gui poll to track the mouse state and
- finally checks for released buttons.
- */
-void global_track_mouse_state( void ){
- int i = 0;
- int nx, ny;
- short mbut, mkstat, mx, my;
- long hold_time = 0;
- COMPONENT * cmp;
- LGRECT cmprect;
- struct gui_window * gw = input_window;
-
- if( !gw ) {
- bmstate = 0;
- mouse_hold_start[0] = 0;
- mouse_hold_start[1] = 0;
- return;
- }
-
- graf_mkstate(&mx, &my, &mbut, &mkstat);
-
- /* todo: creat function find_browser_window( mx, my ) */
- cmp = mt_CompFind( &app, gw->root->cmproot, mx, my );
- if( cmp == NULL ) {
- bmstate = 0;
- mouse_hold_start[0] = 0;
- mouse_hold_start[1] = 0;
- return;
- }
-
- browser_get_rect( gw, BR_CONTENT, &cmprect );
- nx = mx - cmprect.g_x;
- ny = my - cmprect.g_y;
- if( nx > cmprect.g_w ){
-
- }
-
- if( ny > cmprect.g_h ){
- browser_scroll( gw, WA_DNPAGE, 10 + (ny - cmprect.g_h) , false );
- return;
- }
-
- nx = (nx + gw->browser->scroll.current.x);
- ny = (ny + gw->browser->scroll.current.y);
- bmstate &= ~(BROWSER_MOUSE_MOD_1);
- bmstate &= ~(BROWSER_MOUSE_MOD_2);
- bmstate &= ~(BROWSER_MOUSE_MOD_3);
-
- if( !(mbut&1) && !(mbut&2) ) {
- if(bmstate & BROWSER_MOUSE_DRAG_ON )
- bmstate &= ~( BROWSER_MOUSE_DRAG_ON );
- }
-
- for( i = 1; i<3; i++ ) {
- if( !(mbut & i) ) {
- if( mouse_hold_start[i-1] > 0 ) {
- mouse_hold_start[i-1] = 0;
- /* TODO: not just use the input window browser, find the right one by component! */
- if( i==1 ) {
- bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 ) ;
- LOG(("Drag for %d ended", i));
- browser_window_mouse_drag_end(
- gw->browser->bw,
- 0, nx, ny
- );
- }
- if( i==2 ) {
- bmstate &= ~( BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_2 ) ;
- LOG(("Drag for %d ended", i));
- browser_window_mouse_drag_end(
- gw->browser->bw,
- 0, nx, ny
- );
- }
- }
- }
- }
- browser_window_mouse_track(gw->browser->bw, bmstate, nx, ny );
-}
-
-
-void __CDECL global_evnt_m1( WINDOW * win, short buff[8], void * data)
-{
- struct gui_window * gw = input_window;
- static bool prev_url = false;
- static bool prev_sb = false;
- bool a=false;
- LGRECT urlbox, bwbox, sbbox;
- int nx, ny; /* relative mouse position */
-
- if( gw == NULL)
- return;
-
- if( gw->root->toolbar )
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- /* todo: use get_browser_rect */
- mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &bwbox);
- mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &sbbox);
-
- if( evnt.m1_flag == MO_LEAVE && input_window != NULL ) {
- if( gw->root->toolbar ) {
- 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 = a = true;
- }
- }
- if( gw->root->statusbar && a == false ) {
- if( evnt.mx >= sbbox.g_x + (sbbox.g_w-MOVER_WH) && evnt.mx <= sbbox.g_x + sbbox.g_w &&
- evnt.my >= sbbox.g_y + (sbbox.g_h-MOVER_WH) && evnt.my <= sbbox.g_y + sbbox.g_h ) {
- /* mouse within mover */
- prev_sb = a = true;
- gem_set_cursor( &gem_cursors.sizenwse );
- }
- }
- if( !a ) {
- if( prev_url || prev_sb ) {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
- prev_sb = false;
- }
- /* report mouse move in the browser window */
- 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 ){
- /* TODO: use global mouse state instead of zero
- TODO: find COMPONENT and report to its browser, or maybe
- its better to catch mouse movements with component events?
- */
- nx = evnt.mx - bwbox.g_x;
- ny = evnt.my - bwbox.g_y;
- /*LOG(("m1 bw: %p, x: %d, y: %d, state: %d\n" , input_window->browser->bw, nx, ny, bmstate));*/
- browser_window_mouse_track(
- input_window->browser->bw,
- bmstate,
- nx + gw->browser->scroll.current.x,
- ny + gw->browser->scroll.current.y
- );
- }
- }
- }
-}
-
/*
mode = 0 -> return string ptr
(build from accel definition in s_accelerator accel)
@@ -665,7 +530,7 @@ void bind_global_events( void )
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
- EvntDataAttach( NULL, WM_XM1, global_evnt_m1, NULL );
+ /* EvntDataAttach( NULL, WM_XM1, global_evnt_m1, NULL ); */
/* TODO: maybe instant redraw after this is better! */
set_menu_title( MAINMENU_T_FILE, "Page");
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1653d56d1..33ff69dc1 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -59,7 +59,7 @@ struct s_menu_item_evnt {
void snd_redraw(short x, short y, short w, short h);
void snd_win_redraw(WINDOW * win, short x, short y, short w, short h);
/* Call this after each call to evnt_multi, to check for states that evnt_multi doesn't: */
-void global_track_mouse_state( void );
+void global_track_mouse_state( LGRECT * bwrect, bool within, short, short, short, short );
void bind_global_events( void );
void unbind_global_events( void );
@@ -68,7 +68,7 @@ void unbind_global_events( void );
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_keybd( WINDOW * win, short buff[8], void * data);
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8], void * data);
+
/* Menu event handlers: */
static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
diff --git a/atari/gui.c b/atari/gui.c
index 811ae10ea..b8a437778 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -81,7 +81,6 @@
char *default_stylesheet_url;
char *adblock_stylesheet_url;
char *quirks_stylesheet_url;
-char *options_file_location;
char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
@@ -90,11 +89,11 @@ OBJECT * h_gem_menu;
OBJECT **rsc_trindex;
short vdih;
short rsc_ntree;
-static clock_t last_multi_task;
int mouse_click_time[3] = { INT_MAX, INT_MAX, INT_MAX };
int mouse_hold_start[3];
+short last_drag_x;
+short last_drag_y;
browser_mouse_state bmstate;
-bool lck_multi = false;
/* Comandline / Options: */
int cfg_width;
@@ -107,66 +106,41 @@ extern GEM_PLOTTER plotter;
void gui_multitask(void)
{
short winloc[4];
+ short mx, my, dummy, aestop;
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_TIMER;
- if( /*((clock() * 1000 / CLOCKS_PER_SEC) - last_multi_task ) < 50 || */ lck_multi == true ) {
- return;
- }
- /* todo: instead of time, use dummy window message here,
- timer takes at least 10ms, WMs take about 1ms!
- */
- evnt.timer = 1;
- if(input_window) {
- wind_get(input_window->root->handle->handle, WF_WORKXYWH, &winloc[0],
- &winloc[1], &winloc[2], &winloc[3] );
- graf_mkstate( &prev_inp_state.mx, &prev_inp_state.my,
- &prev_inp_state.mbut, &prev_inp_state.mkstat );
- flags |= MU_M1;
- if( prev_inp_state.mx >= winloc[0] && prev_inp_state.mx <= winloc[0] + winloc[2] &&
- prev_inp_state.my >= winloc[1] && prev_inp_state.my <= winloc[1] + winloc[3] ){
- /* if the cursor is within workarea, capture an movement WITHIN: */
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = 2;
- evnt.m1_h = 2;
- evnt.m1_x = prev_inp_state.mx;
- evnt.m1_y = prev_inp_state.my;
- } else {
- /* otherwise capture mouse move INTO the work area: */
- evnt.m1_flag = MO_ENTER;
- evnt.m1_w = winloc[2];
- evnt.m1_h = winloc[3];
- evnt.m1_x = winloc[0];
- evnt.m1_y = winloc[1];
- }
- }
+ evnt.timer = 0;
EvntWindom( flags );
- if( MOUSE_IS_DRAGGING() )
- global_track_mouse_state();
- last_multi_task = clock()*1000 / CLOCKS_PER_SEC;
}
+
void gui_poll(bool active)
{
short winloc[4];
- int timeout = 50; /* timeout in milliseconds */
+ // int timeout; /* timeout in milliseconds */
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
- /* right now, schedule is only used for the spinner, */
- /* spinner code must be reviewed, so disable schedule for now */
- timeout = schedule_run();
+ short mx, my, dummy;
+ short aestop;
+
+ evnt.timer = schedule_run();
if ( active || browser_reformat_pending )
- timeout = 1;
+ evnt.timer = 0;
+
+ wind_get( 0, WF_TOP, &aestop, &winloc[1], &winloc[2], &winloc[3]);
+ if( winloc[1] != _AESapid ){
+ aestop = 0;
+ }
- if(input_window) {
+ if(aestop > 0) {
flags |= MU_M1;
- wind_get(input_window->root->handle->handle, WF_WORKXYWH, &winloc[0],
+ wind_get( aestop, WF_WORKXYWH, &winloc[0],
&winloc[1], &winloc[2], &winloc[3] );
- graf_mkstate( &prev_inp_state.mx, &prev_inp_state.my,
- &prev_inp_state.mbut, &prev_inp_state.mkstat );
- if( prev_inp_state.mx >= winloc[0] && prev_inp_state.mx <= winloc[0] + winloc[2] &&
- prev_inp_state.my >= winloc[1] && prev_inp_state.my <= winloc[1] + winloc[3] ){
+ graf_mkstate( &mx, &my, &dummy, &dummy );
+ /* this can be improved a lot under XaAES - there is an event for mouse move */
+ if( mx >= winloc[0] && mx <= winloc[0] + winloc[2] &&
+ my >= winloc[1] && my <= winloc[1] + winloc[3] ){
evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = 2;
- evnt.m1_h = 2;
- evnt.m1_x = prev_inp_state.mx;
- evnt.m1_y = prev_inp_state.my;
+ evnt.m1_w = evnt.m1_h = 1;
+ evnt.m1_x = mx;
+ evnt.m1_y = my;
} else {
evnt.m1_flag = MO_ENTER;
evnt.m1_w = winloc[2];
@@ -174,28 +148,19 @@ void gui_poll(bool active)
evnt.m1_x = winloc[0];
evnt.m1_y = winloc[1];
}
- /* if we have some state that can't be recognized by evnt_multi, don't block
- so tracking can take place after timeout: */
- if( MOUSE_IS_DRAGGING() )
- timeout = 1;
}
- if( timeout >= 0 ) {
+ if( evnt.timer >= 0 ) {
flags |= MU_TIMER;
- evnt.timer = timeout;
}
- lck_multi = true;
EvntWindom( flags );
- lck_multi = false;
- if( MOUSE_IS_DRAGGING() ) // MOUSE_EVNT_IN_PROGRESS()
- global_track_mouse_state();
- last_multi_task = clock()*1000 / CLOCKS_PER_SEC;
struct gui_window * g;
for( g = window_list; g != NULL; g=g->next ) {
if( browser_redraw_required( g ) ){
browser_redraw( g );
}
}
+ hotlist_redraw();
}
struct gui_window *
@@ -457,12 +422,6 @@ void gui_window_update_extent(struct gui_window *gw)
oldx = gw->browser->scroll.current.x;
oldy = gw->browser->scroll.current.y;
if( gw->browser->bw->current_content != NULL ) {
- /*printf("update_extent %p (\"%s\"), c_w: %d, c_h: %d, scale: %f\n",
- gw->browser->bw,gw->browser->bw->name,
- content_get_width(gw->browser->bw->current_content),
- content_get_height(gw->browser->bw->current_content),
- gw->browser->bw->scale
- );*/
browser_set_content_size( gw,
content_get_width(gw->browser->bw->current_content),
content_get_height(gw->browser->bw->current_content)
@@ -966,6 +925,9 @@ void gui_quit(void)
}
gw = tmp;
}
+
+ hotlist_destroy();
+
/* send WM_DESTROY to windows purely managed by windom: */
while( wglb.first ) {
ApplWrite( _AESapid, WM_DESTROY, wglb.first->handle, 0, 0, 0, 0);
@@ -974,7 +936,6 @@ void gui_quit(void)
urldb_save_cookies(option_cookie_file);
urldb_save(option_url_file);
- hotlist_destroy();
RsrcXtype( 0, rsc_trindex, rsc_ntree);
unbind_global_events();
@@ -1055,9 +1016,7 @@ char* gui_get_resource_url(const char *filename)
char buf[PATH_MAX];
int len;
char * ret;
- printf("gui_find_res: %s\n", filename);
atari_find_resource((char*)&buf, filename, filename);
- printf("found: %s\n", (char*)&buf);
/* TODO: handle failure? */
len = strlen( (char*)&buf ) + 1;
return( path_to_url((char*)&buf) );
@@ -1124,13 +1083,15 @@ static void gui_init(int argc, char** argv)
LOG(("Loading cookies from: %s", option_cookie_file ));
}
-
-
if (process_cmdline(argc,argv) != true)
die("unable to process command line.\n");
nkc_init();
atari_plotter_init( option_atari_screen_driver, option_atari_font_driver );
+ /* Interface colours */
+ option_gui_colour_bg_1 = 0xFFFFFF; /** Background (bbggrr) */
+ option_gui_colour_fg_1 = 0xFF0000; /** Foreground (bbggrr) */
+ option_gui_colour_fg_2 = 0x000000; /** Foreground selected (bbggrr) */
}
static char *theapp = "NetSurf";
@@ -1144,9 +1105,11 @@ static void gui_init2(int argc, char** argv)
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
}
+ tree_set_icon_dir( option_tree_icons_path );
+ hotlist_init();
}
-
+/* #define WITH_DBG_LOGFILE 1 */
/** Entry point from OS.
*
* /param argc The number of arguments in the string vector.
@@ -1170,9 +1133,8 @@ int main(int argc, char** argv)
graf_mouse(BUSY_BEE, NULL);
init_os_info();
- atari_find_resource(messages, "messages", "res/messages");
- atari_find_resource(options, "Choices", "Choices");
- options_file_location = strdup(options);
+ 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);
@@ -1181,13 +1143,12 @@ int main(int argc, char** argv)
graf_mouse( ARROW , NULL);
netsurf_main_loop();
netsurf_exit();
- if( options_file_location != NULL ){
- free( options_file_location );
- }
+
LOG(("ApplExit"));
ApplExit();
#ifdef WITH_DBG_LOGFILE
fclose(stdout);
+ fclose(stderr);
#endif
return 0;
diff --git a/atari/gui.h b/atari/gui.h
index 75c17eb26..24a71a1cb 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -103,14 +103,15 @@ struct s_focus_info
void * element;
};
-
+/*
struct s_gui_input_state {
short mbut;
short mkstat;
short mx;
short my;
+ browser_mouse_state bms;
} prev_inp_state;
-
+*/
#define TB_BUTTON_WIDTH 32
#define TB_BUTTON_HEIGHT 21 /* includes 1px 3d effect */
@@ -230,9 +231,6 @@ struct gui_window {
extern struct gui_window *window_list;
-/* scroll a window */
-void gem_window_scroll(struct browser_window * , int x, int y);
-
#define MOUSE_IS_DRAGGING() (mouse_hold_start[0] || mouse_hold_start[1])
diff --git a/atari/hotlist.c b/atari/hotlist.c
index e060c4a3d..2d2e1cf19 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -29,6 +29,7 @@
#include "desktop/options.h"
#include "desktop/hotlist.h"
#include "desktop/tree.h"
+#include "desktop/tree_url_node.h"
#include "desktop/gui.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -40,50 +41,61 @@
#include "atari/hotlist.h"
#include "atari/findfile.h"
#include "atari/res/netsurf.rsh"
+#include "atari/options.h"
-static struct atari_hotlist {
- WINDOW * window;
- NSTREEVIEW tv; /*< The hotlist treeview handle. */
- bool open;
-} hl;
-
+struct atari_hotlist hl;
static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
- int obj = buff[4]; /* Selected object */
-
- LOG(("item: %d clicked", obj ));
-
- switch( obj) {
+ /* handle toolbar object (index in buff[4] ) */
+ switch( buff[4] ) {
case TOOLBAR_HOTLIST_CREATE_FOLDER:
+ hotlist_add_folder();
break;
+
case TOOLBAR_HOTLIST_ADD:
+ atari_hotlist_add_page("http://www.de", "");
break;
+
case TOOLBAR_HOTLIST_DELETE:
+ hotlist_delete_selected();
break;
- }
- /* object state to normal and redraw object */
-/*
- ObjcChange( TOOLBAR_HOTLIST, hl.window, obj, SELECTED, 1);
- ObjcChange( TOOLBAR_HOTLIST, hl.window, obj, 0 , 1);
-*/
+ case TOOLBAR_HOTLIST_EDIT:
+ hotlist_edit_selected();
+ break;
+ }
+ ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
+
static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] )
{
hotlist_close();
}
+
+static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] )
+{
+ /* todo: implement popup?
+ if(evnt.mbut & 2) {
+
+ }
+ */
+}
+
+
void hotlist_init(void)
{
- char hlfilepath[PATH_MAX];
+ if( strcmp(option_hotlist_file, "") == 0 ){
+ atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" );
+ } else {
+ strncpy( (char*)&hl.path, option_hotlist_file, PATH_MAX-1 );
+ }
- atari_find_resource(
- (char*)&hlfilepath, "hotlist", "res/Hotlist"
- );
+ LOG(("Hotlist: %s", (char*)&hl.path ));
if( hl.window == NULL ){
- int flags = CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER ;
+ int flags = ATARI_TREEVIEW_WIDGETS;
OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
assert( tree );
hl.open = false;
@@ -94,58 +106,84 @@ void hotlist_init(void)
}
/* TODO: load hotlist strings from messages */
WindSetStr( hl.window, WF_NAME, (char*)"Hotlist" );
- WindSetPtr( hl.window, WF_TOOLBAR,
- tree,
- evnt_hl_toolbar
- );
+ WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar );
EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
+ EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton );
hl.tv = atari_treeview_create(
hotlist_get_tree_flags(),
hl.window
);
if (hl.tv == NULL) {
+ /* handle it properly, clean up previous allocs */
LOG(("Failed to allocate treeview"));
return;
}
+
hotlist_initialise(
- atari_treeview_get_tree(hl.tv),
- /* TODO: use option_hotlist_file or slt*/
- (char*)&hlfilepath,
- "dir.png"
- );
+ hl.tv->tree,
+ /* TODO: use option_hotlist_file or slt*/
+ (char*)&hl.path,
+ "dir.png"
+ );
+
} else {
}
+ hl.init = true;
}
void hotlist_open(void)
{
- hotlist_init();
+ if( hl.init == false ) {
+ return;
+ }
if( hl.open == false ) {
WindOpen( hl.window, -1, -1, app.w/3, app.h/2);
hl.open = true;
+ atari_treeview_open( hl.tv );
+ } else {
+ WindTop( hl.window );
}
- tree_set_redraw(atari_treeview_get_tree(hl.tv), true);
}
void hotlist_close(void)
{
WindClose(hl.window);
hl.open = false;
+ atari_treeview_close( hl.tv );
}
void hotlist_destroy(void)
{
+ if( hl.init == false ) {
+ return;
+ }
if( hl.window != NULL ) {
+ hotlist_cleanup( (char*)&hl.path );
if( hl.open )
hotlist_close();
WindDelete( hl.window );
- printf("delete hl tree");
- atari_treeview_destroy( hl.tv );
hl.window = NULL;
+ atari_treeview_destroy( hl.tv );
+ hl.init = false;
}
+ LOG(("done"));
}
+struct node;
-
+void atari_hotlist_add_page( const char * url, const char * title )
+{
+ struct node * root;
+ struct node * selected = NULL;
+ struct node * folder = NULL;
+ NSTREEVIEW tv = hl.tv;
+ if(hl.tv == NULL )
+ return;
+ 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 {
+ hotlist_add_page( url );
+ }
+}
diff --git a/atari/hotlist.h b/atari/hotlist.h
index 78a88e27c..27e9eba6e 100755
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -18,13 +18,32 @@
#ifndef NS_ATARI_HOTLIST_H
#define NS_ATARI_HOTLIST_H
-
+#include <stdbool.h>
+#include <windom.h>
+#include "desktop/tree.h"
+#include "atari/treeview.h"
/* The hotlist window, toolbar and treeview data. */
+struct atari_hotlist {
+ WINDOW * window;
+ NSTREEVIEW tv; /*< The hotlist treeview handle. */
+ bool open;
+ bool init;
+ char path[PATH_MAX];
+};
+
+extern struct atari_hotlist hl;
+
+void hotlist_init( void );
+void hotlist_open( void );
+void hotlist_close( void );
+void hotlist_destroy( void );
+void atari_hotlist_add_page( const char * url, const char * title );
-void hotlist_init(void);
-void hotlist_open(void);
-void hotlist_close(void);
-void hotlist_destroy(void);
+inline void hotlist_redraw( void );
+inline void hotlist_redraw( void )
+{
+ atari_treeview_redraw( hl.tv );
+}
#endif \ No newline at end of file
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index da067e657..13c096a4d 100755
--- a/atari/res/netsurf.rsc
+++ b/atari/res/netsurf.rsc
Binary files differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index a9d34ad47..49cccdfe7 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -93,9 +93,10 @@
#define SLIDER_BT_SCROLL_D 7 /* BOXCHAR in tree SLIDER */
#define TOOLBAR_HOTLIST 9 /* form/dial */
-#define TOOLBAR_HOTLIST_CREATE_FOLDER 1 /* BUTTON in tree TOOLBAR_HOTLIST */
-#define TOOLBAR_HOTLIST_ADD 2 /* BUTTON in tree TOOLBAR_HOTLIST */
-#define TOOLBAR_HOTLIST_DELETE 3 /* BUTTON in tree TOOLBAR_HOTLIST */
+#define TOOLBAR_HOTLIST_ADD 1 /* CICON in tree TOOLBAR_HOTLIST */
+#define TOOLBAR_HOTLIST_CREATE_FOLDER 2 /* CICON in tree TOOLBAR_HOTLIST */
+#define TOOLBAR_HOTLIST_DELETE 3 /* CICON in tree TOOLBAR_HOTLIST */
+#define TOOLBAR_HOTLIST_EDIT 4 /* CICON in tree TOOLBAR_HOTLIST */
#define SEARCH 10 /* form/dial */
#define SEARCH_TB_SRCH 1 /* FTEXT in tree SEARCH */
@@ -113,11 +114,10 @@
#define DOWNLOAD_PROGRESS_DONE 2 /* BOX in tree DOWNLOAD */
#define DOWNLOAD_FILENAME 3 /* TEXT in tree DOWNLOAD */
#define DOWNLOAD_BT_ABORT 4 /* BUTTON in tree DOWNLOAD */
-#define DOWNLOAD_BT_PAUSE 5 /* BUTTON in tree DOWNLOAD */
-#define DOWNLOAD_LBL_CLOSE_RDY 6 /* STRING in tree DOWNLOAD */
-#define DOWNLOAD_LBL_BYTES 7 /* TEXT in tree DOWNLOAD */
-#define DOWNLOAD_LBL_PERCENT 8 /* TEXT in tree DOWNLOAD */
-#define DOWNLOAD_LBL_SPEED 9 /* TEXT in tree DOWNLOAD */
-#define DOWNLOAD_CB_CLOSE_RDY 10 /* BUTTON in tree DOWNLOAD */
+#define DOWNLOAD_LBL_CLOSE_RDY 5 /* STRING in tree DOWNLOAD */
+#define DOWNLOAD_LBL_BYTES 6 /* TEXT in tree DOWNLOAD */
+#define DOWNLOAD_LBL_PERCENT 7 /* TEXT in tree DOWNLOAD */
+#define DOWNLOAD_LBL_SPEED 8 /* TEXT in tree DOWNLOAD */
+#define DOWNLOAD_CB_CLOSE_RDY 9 /* BUTTON in tree DOWNLOAD */
#define ABOUT 12 /* form/dial */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index 8a98ae19b..fcc8d97ef 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -3,7 +3,7 @@ ResourceMaster v3.65
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@17741@7728@559@
+#M 20010100@17741@7728@568@
#T 0@1@MAINMENU@@60@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -88,10 +88,11 @@ ResourceMaster v3.65
#O 6@20@BOX_V@@
#O 8@20@MOVER_V@@
#O 7@27@BT_SCROLL_D@@
-#T 9@2@TOOLBAR_HOTLIST@@4@@
-#O 1@26@CREATE_FOLDER@@
-#O 2@26@ADD@@
-#O 3@26@DELETE@@
+#T 9@2@TOOLBAR_HOTLIST@@5@@
+#O 1@33@ADD@@
+#O 2@33@CREATE_FOLDER@@
+#O 3@33@DELETE@@
+#O 4@33@EDIT@@
#T 10@2@SEARCH@@9@@
#O 1@29@TB_SRCH@@
#O 2@28@LBL_SHOWALL@@
@@ -101,16 +102,15 @@ ResourceMaster v3.65
#O 6@26@CB_CASESENSE@@
#O 7@26@CB_SHOWALL@@
#O 8@26@CB_FWD@@
-#T 11@2@DOWNLOAD@@11@@
+#T 11@2@DOWNLOAD@@10@@
#O 1@20@PROGRESS@Width ist 400, code depends on that! If you change it, change it in download.c@
#O 2@20@PROGRESS_DONE@@
#O 3@21@FILENAME@@
#O 4@26@BT_ABORT@@
-#O 5@26@BT_PAUSE@@
-#O 6@28@LBL_CLOSE_RDY@@
-#O 7@21@LBL_BYTES@@
-#O 8@21@LBL_PERCENT@@
-#O 9@21@LBL_SPEED@@
-#O 10@26@CB_CLOSE_RDY@@
+#O 5@28@LBL_CLOSE_RDY@@
+#O 6@21@LBL_BYTES@@
+#O 7@21@LBL_PERCENT@@
+#O 8@21@LBL_SPEED@@
+#O 9@26@CB_CLOSE_RDY@@
#T 12@2@ABOUT@@2@@
-#c 17889@
+#c 9597@
diff --git a/atari/treeview.c b/atari/treeview.c
index de2a9fcdc..b24e9aecb 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <time.h>
#include <windom.h>
+#include <cflib.h>
#include "content/urldb.h"
#include "desktop/browser.h"
@@ -29,16 +30,21 @@
#include "desktop/textinput.h"
#include "desktop/tree.h"
#include "desktop/tree_url_node.h"
+#include "desktop/textinput.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "atari/gui.h"
#include "atari/treeview.h"
+#include "atari/plot.h"
+#include "atari/misc.h"
-const char tree_directory_icon_name[] = "dir.png";
-const char tree_content_icon_name[] = "content.png";
+extern int mouse_hold_start[3];
+extern browser_mouse_state bmstate;
+extern short last_drag_x;
+extern short last_drag_y;
+extern GEM_PLOTTER plotter;
-static void atari_treeview_request_redraw(int x,int y,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);
@@ -50,10 +56,189 @@ static const struct treeview_table atari_tree_callbacks = {
atari_treeview_get_dimensions
};
+static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
+{
+ bool r=false;
+ long kstate = 0;
+ long kcode = 0;
+ unsigned short nkc = 0;
+ unsigned short nks = 0;
+ unsigned char ascii;
+ NSTREEVIEW tv = (NSTREEVIEW) data;
+ kstate = evnt.mkstate;
+ kcode = evnt.keybd;
+ nkc= gem_to_norm( (short)kstate, (short)kcode );
+ ascii = (nkc & 0xFF);
+ nkc = (nkc & (NKF_CTRL|NKF_SHIFT|0xFF));
+ if( (nkc & (NKF_SHIFT|NKF_CTRL) ) == 0 ) {
+ switch( ascii ) {
+ case NK_BS:
+ r = tree_keypress( tv->tree, KEY_DELETE_LEFT);
+ break;
+
+ case NK_DEL:
+ r = tree_keypress( tv->tree, KEY_DELETE_RIGHT);
+ break;
+
+ case NK_ENTER:
+ r = tree_keypress( tv->tree, KEY_NL);
+ break;
+
+ case NK_RET:
+ r = tree_keypress( tv->tree, KEY_CR);
+ break;
+
+ case NK_ESC:
+ r = tree_keypress( tv->tree, KEY_ESCAPE);
+ break;
+
+ case NK_RIGHT:
+ r = tree_keypress( tv->tree, KEY_RIGHT );
+ break;
+
+ case NK_LEFT:
+ r = tree_keypress( tv->tree, KEY_LEFT );
+ break;
+
+ default:
+ break;
+ }
+ }
+ if ( r == false && ( (nkc & NKF_CTRL)==0) ) {
+ int ucs4 = atari_to_ucs4(ascii);
+ tree_keypress( tv->tree, ucs4 );
+ }
+}
+
+
+static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
+{
+ GRECT work, clip;
+ NSTREEVIEW tv = (NSTREEVIEW) data;
+ if( tv == NULL )
+ return;
+ WindGetGrect( win, WF_WORKXYWH, &work );
+ clip = work;
+ if ( !rc_intersect( (GRECT*)&buff[4], &clip ) ) return;
+ clip.g_x -= work.g_x;
+ clip.g_y -= work.g_y;
+ if( clip.g_x < 0 ) {
+ clip.g_w = work.g_w + clip.g_x;
+ clip.g_x = 0;
+ }
+ if( clip.g_y < 0 ) {
+ clip.g_h = work.g_h + clip.g_y;
+ clip.g_y = 0;
+ }
+ if( clip.g_h > 0 && clip.g_w > 0 ) {
+ atari_treeview_request_redraw( win->xpos*win->w_u + clip.g_x, win->ypos*win->h_u + clip.g_y,
+ clip.g_w, clip.g_h, tv
+ );
+ }
+}
+
+
+static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
+{
+ GRECT work;
+ bool ignore=false;
+ NSTREEVIEW tv = (NSTREEVIEW) data;
+ if( tv == NULL )
+ return;
+ if( evnt.mbut & 2 ) {
+ /* do not handle right click */
+ return;
+ }
+
+ WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ int rx = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ int ry = (evnt.my-work.g_y)+(win->ypos*win->h_u);
+
+ if( rx >= 0 && ry >= 0 && evnt.mx < work.g_x + work.g_w &&
+ evnt.my < work.g_y + work.g_h ){
+
+ short mx, my, dummy, mbut;
+ uint32_t tnow = clock()*1000 / CLOCKS_PER_SEC;
+
+ if( evnt.mkstate & (K_RSHIFT | K_LSHIFT) ){
+ bmstate |= BROWSER_MOUSE_MOD_1;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_1);
+ }
+ if( (evnt.mkstate & K_CTRL) ){
+ bmstate |= BROWSER_MOUSE_MOD_2;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_2);
+ }
+ if( (evnt.mkstate & K_ALT) ){
+ bmstate |= BROWSER_MOUSE_MOD_3;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_3);
+ }
+
+ graf_mkstate(&dummy, &dummy, &mbut, &dummy);
+ if( evnt.nb_click == 2 ) {
+ bmstate = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK;
+ mouse_hold_start[0] = 0;
+ } else {
+ if( mbut & 1 ) {
+ bmstate |= BROWSER_MOUSE_DRAG_ON;
+ if( mouse_hold_start[0] == 0) {
+ mouse_hold_start[0] = tnow;
+ tv->startdrag.x = rx;
+ tv->startdrag.y = ry;
+ bmstate |= BROWSER_MOUSE_DRAG_1;
+ gem_set_cursor(&gem_cursors.cross);
+ } else {
+ /* todo: add more isual indication (grafbox?) */
+ ignore = true;
+ gem_set_cursor(&gem_cursors.cross);
+ }
+ } else {
+ if( bmstate & BROWSER_MOUSE_DRAG_ON ){
+ bmstate = 0;
+ tree_drag_end(tv->tree, bmstate, tv->startdrag.x, tv->startdrag.y, rx, ry);
+ gem_set_cursor(&gem_cursors.arrow);
+ ignore = true;
+ } else {
+ bmstate = BROWSER_MOUSE_CLICK_1;
+ mouse_hold_start[0] = 0;
+ }
+ }
+ }
+ if( !ignore ) {
+ tree_mouse_action(tv->tree, bmstate, rx, ry );
+ }
+ bmstate &= ~(BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1 );
+ }
+}
+
+static void __CDECL evnt_tv_m1( WINDOW *win, short buff[8], void * data)
+{
+ GRECT work;
+ NSTREEVIEW tv = (NSTREEVIEW) data;
+ if( tv == NULL )
+ return;
+
+ if( bmstate & BROWSER_MOUSE_DRAG_ON ) {
+
+ short mbut, dummy;
+ graf_mkstate(&dummy, &dummy, &mbut, &dummy);
+ if( !(mbut & 1) ){
+ WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ int rx = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ int ry = (evnt.my-work.g_y)+(win->ypos*win->h_u);
+ bmstate = 0;
+ tree_drag_end(tv->tree, bmstate, tv->startdrag.x, tv->startdrag.y, rx, ry);
+ gem_set_cursor(&gem_cursors.arrow);
+ }
+ }
+}
NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
{
- LOG(("flags: %d", flags));
+ if( win == NULL )
+ return( NULL );
NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
if (new == NULL)
return NULL;
@@ -64,41 +249,117 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
return NULL;
}
new->window = win;
+
+ win->w_u = 16;
+ win->h_u = 16;
+
+ EvntDataAdd( new->window, WM_XBUTTON, evnt_tv_mbutton, new, EV_BOT );
+ EvntDataAttach( new->window, WM_REDRAW, evnt_tv_redraw, new );
+ EvntDataAttach( new->window, WM_XKEYBD, evnt_tv_keybd, new );
+ EvntDataAttach( new->window, WM_XM1, evnt_tv_m1, new );
+
return(new);
}
void atari_treeview_open( NSTREEVIEW tv )
{
- LOG(("tree: %p", tv));
if( tv->window != NULL ) {
-
+ tree_set_redraw(tv->tree, true);
}
}
void atari_treeview_close( NSTREEVIEW tv )
{
if( tv->window != NULL ) {
-
+ tree_set_redraw(tv->tree, false);
}
}
void atari_treeview_destroy( NSTREEVIEW tv )
{
- LOG(("tree: %p", tv));
- if( tv->tree != NULL ) {
- tree_delete(tv->tree);
- tv->tree = NULL;
+ if( tv != NULL ){
+ tv->disposing = true;
+ LOG(("tree: %p", tv));
+ if( tv->tree != NULL ) {
+ tree_delete(tv->tree);
+ tv->tree = NULL;
+ }
+ free( tv );
}
}
-struct tree * atari_treeview_get_tree( NSTREEVIEW tv )
+bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
- return( tv->tree );
+ if( tv == NULL )
+ return ( false );
+ GRECT work;
+ WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
+ int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
+ tree_mouse_action(tv->tree, bms, rx, ry );
+ tv->click.x = rx;
+ tv->click.y = ry;
+ return( true );
}
-WINDOW * atari_tree_get_window( NSTREEVIEW tv )
+
+
+void atari_treeview_redraw( NSTREEVIEW tv)
{
- return( tv->window );
+ if (tv != NULL) {
+ if( tv->redraw && ((plotter->flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+ short todo[4];
+ GRECT work;
+ WindGetGrect( tv->window, WF_WORKXYWH, &work );
+
+ plotter->resize(plotter, work.g_w, work.g_h);
+ plotter->move(plotter, work.g_x, work.g_y );
+
+ todo[0] = work.g_x;
+ todo[1] = work.g_y;
+ todo[2] = todo[0] + work.g_w-1;
+ todo[3] = todo[1] + work.g_h-1;
+ vs_clip(plotter->vdi_handle, 1, (short*)&todo );
+
+ if( wind_get(tv->window->handle, WF_FIRSTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
+ while (todo[2] && todo[3]) {
+
+ /* convert screen to treeview coords: */
+ todo[0] = todo[0] - work.g_x + tv->window->xpos*tv->window->w_u;
+ todo[1] = todo[1] - work.g_y + tv->window->ypos*tv->window->h_u;
+ if( todo[0] < 0 ){
+ todo[2] = todo[2] + todo[0];
+ todo[0] = 0;
+ }
+ if( todo[1] < 0 ){
+ todo[3] = todo[3] + todo[1];
+ todo[1] = 0;
+ }
+
+ if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
+ tree_draw(tv->tree, -tv->window->xpos*16, -tv->window->ypos*16,
+ todo[0], todo[1], todo[2], todo[3]
+ );
+ }
+ if (wind_get(tv->window->handle, WF_NEXTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3])==0) {
+ break;
+ }
+ }
+ } else {
+ return;
+ }
+ vs_clip(plotter->vdi_handle, 0, (short*)&todo);
+ tv->redraw = false;
+ tv->rdw_area.g_x = 65000;
+ tv->rdw_area.g_y = 65000;
+ tv->rdw_area.g_w = -1;
+ tv->rdw_area.g_h = -1;
+ } else {
+ /* just copy stuff from the offscreen buffer */
+ }
+ }
}
@@ -113,13 +374,29 @@ WINDOW * atari_tree_get_window( NSTREEVIEW tv )
*/
void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
{
- LOG(("tree: %p", pw));
if (pw != NULL) {
NSTREEVIEW tv = (NSTREEVIEW) pw;
- tv->redraw.required = true;
+ if( tv->redraw == false ){
+ tv->redraw = true;
+ tv->rdw_area.g_x = x;
+ tv->rdw_area.g_y = y;
+ tv->rdw_area.g_w = w;
+ tv->rdw_area.g_h = h;
+ } else {
+ /* merge the redraw area to the new area.: */
+ int newx1 = x+w;
+ int newy1 = y+h;
+ int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
+ int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
+ tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
+ tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
+ tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
+ tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
+ }
}
}
+
/**
* Callback to notify us of a new overall tree size.
*
@@ -131,9 +408,15 @@ void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
{
- LOG(("tree: %p", pw));
if (pw != NULL) {
NSTREEVIEW tv = (NSTREEVIEW) pw;
+ if( tv->disposing )
+ return;
+ tv->extent.x = width;
+ tv->extent.y = height;
+ tv->window->ypos_max = (height / tv->window->w_u)+0.5;
+ tv->window->xpos_max = (width / tv->window->h_u)+0.5;
+ WindSlider( tv->window, HSLIDER|VSLIDER );
}
}
@@ -148,10 +431,8 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
void atari_treeview_scroll_visible(int y, int height, void *pw)
{
- LOG(("tree: %p", pw));
- if (pw != NULL) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
- }
+ /* we don't support dragging within the treeview */
+ /* so we don't need to implement this */
}
/**
@@ -165,9 +446,12 @@ void atari_treeview_scroll_visible(int y, int height, void *pw)
void atari_treeview_get_dimensions(int *width, int *height,
void *pw)
{
- LOG(("tree: %p", pw));
if (pw != NULL && (width != NULL || height != NULL)) {
NSTREEVIEW tv = (NSTREEVIEW) pw;
+ GRECT work;
+ WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ *width = work.g_w;
+ *height = work.g_h;
}
}
@@ -214,7 +498,7 @@ void tree_icon_name_from_content_type(char *buffer, content_type type)
case CONTENT_SVG:
#endif
default:
- sprintf(buffer, tree_content_icon_name);
+ strcpy( buffer, "content.png" );
break;
}
}
diff --git a/atari/treeview.h b/atari/treeview.h
index f5f16a57a..487479a67 100755
--- a/atari/treeview.h
+++ b/atari/treeview.h
@@ -24,18 +24,18 @@
#include "desktop/tree.h"
#include "atari/gui.h"
-/* defined in front end code */
-/*
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-*/
+#define ATARI_TREEVIEW_WIDGETS (CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER | VSLIDE | HSLIDE | UPARROW | DNARROW | LFARROW | RTARROW)
struct atari_treeview
{
struct tree * tree;
WINDOW * window;
- struct s_browser_redrw_info redraw;
- /*tree_drag_type drag;*/
+ bool disposing;
+ bool redraw;
+ GRECT rdw_area;
+ POINT click;
+ POINT extent;
+ POINT startdrag;
};
typedef struct atari_treeview * NSTREEVIEW;
@@ -44,8 +44,10 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW * win );
void atari_treeview_destroy( NSTREEVIEW tv );
void atari_treeview_open( NSTREEVIEW tv );
void atari_treeview_close( NSTREEVIEW tv );
-struct tree * atari_treeview_get_tree( NSTREEVIEW tv );
-WINDOW * atari_tree_get_window( NSTREEVIEW tv );
+void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw);
+void atari_treeview_redraw( NSTREEVIEW tv );
+bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y);
+
#endif \ No newline at end of file