From 9676253184e001d46a9ceb4e36c47484e169f272 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Mon, 19 Nov 2012 00:47:03 +0100 Subject: Imporved gemtk toolbar handling. --- atari/Makefile.target | 45 +++- atari/browser_win.c | 589 -------------------------------------------------- atari/browser_win.h | 70 ------ atari/dragdrop.c | 516 ------------------------------------------- atari/dragdrop.h | 19 -- atari/gemtk/gemtk.h | 7 +- atari/gemtk/guiwin.c | 30 +-- atari/msgbox.c | 84 ------- atari/msgbox.h | 10 - atari/res/netsurf.rsc | Bin 34322 -> 35768 bytes atari/res/netsurf.rsh | 11 + atari/res/netsurf.rsm | 15 +- atari/rootwin.c | 55 +---- 13 files changed, 91 insertions(+), 1360 deletions(-) delete mode 100755 atari/browser_win.c delete mode 100755 atari/browser_win.h delete mode 100755 atari/dragdrop.c delete mode 100755 atari/dragdrop.h delete mode 100644 atari/msgbox.c delete mode 100644 atari/msgbox.h (limited to 'atari') diff --git a/atari/Makefile.target b/atari/Makefile.target index ad908075b..9faa52d66 100644 --- a/atari/Makefile.target +++ b/atari/Makefile.target @@ -7,7 +7,7 @@ # manually via env. variables, because the m68k-atari-mint # toolchain is located in /usr/bin and the wildcard matching # fails then. So this wildcard matches only works for -# the netsurf environment! +# the netsurf environment! STRIP := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*strip) STACK := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*stack) @@ -73,15 +73,42 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib # S_ATARI are sources purely for the Atari FreeMiNT build -S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \ - download.c thumbnail.c login.c verify_ssl.c treeview.c hotlist.c history.c\ +S_ATARI := gui.c \ + findfile.c \ + filetype.c \ + misc.c \ + bitmap.c \ + schedule.c \ + download.c \ + thumbnail.c \ + login.c \ + verify_ssl.c \ + treeview.c \ + hotlist.c \ + history.c\ search.c font.c \ - plot/plot.c plot/fontplot.c plot/eddi.s \ - plot/font_freetype.c plot/font_internal.c \ - redrawslots.c encoding.c \ - browser_win.c toolbar.c statusbar.c browser.c \ - global_evnt.c osspec.c dragdrop.c system_colour.c \ - ctxmenu.c settings.c msgbox.c + redrawslots.c \ + encoding.c \ + rootwin.c \ + toolbar.c \ + statusbar.c \ + browser.c \ + global_evnt.c \ + osspec.c \ + system_colour.c \ + ctxmenu.c \ + settings.c \ + deskmenu.c \ + plot/plot.c \ + plot/fontplot.c \ + plot/eddi.s \ + plot/font_freetype.c \ + plot/font_internal.c \ + gemtk/utils.c \ + gemtk/dragdrop.c \ + gemtk/msgbox.c \ + gemtk/guiwin.c + S_ATARI := $(addprefix atari/,$(S_ATARI)) # This is the final source build list diff --git a/atari/browser_win.c b/atari/browser_win.c deleted file mode 100755 index f6daf37c4..000000000 --- a/atari/browser_win.c +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright 2010 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utils/log.h" -#include "desktop/gui.h" -#include "desktop/history_core.h" -#include "desktop/netsurf.h" -#include "desktop/browser.h" -#include "desktop/browser_private.h" -#include "desktop/mouse.h" -#include "desktop/plotters.h" -#include "desktop/textinput.h" -#include "content/content.h" -#include "content/hlcache.h" -#include "content/urldb.h" -#include "css/css.h" -#include "atari/gui.h" -#include "atari/browser_win.h" -#include "atari/browser.h" -#include "atari/misc.h" -#include "atari/plot/plot.h" -#include "atari/global_evnt.h" -#include "atari/res/netsurf.rsh" -#include "atari/browser.h" -#include "atari/toolbar.h" -#include "atari/statusbar.h" -#include "atari/dragdrop.h" -#include "atari/search.h" -#include "atari/osspec.h" -#include "atari/encoding.h" -#include "atari/toolbar.h" - -extern void * h_gem_rsrc; -extern struct gui_window *input_window; - -void __CDECL std_szd( WINDOW * win, short buff[8], void * ); -void __CDECL std_mvd( WINDOW * win, short buff[8], void * ); - - -/* -------------------------------------------------------------------------- */ -/* Static module methods follow here: */ -/* -------------------------------------------------------------------------- */ -static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data ); -void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data ); -static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data ); -static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date ); -static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ; -static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data); -static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ); -static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data ); - -/* -------------------------------------------------------------------------- */ -/* Module public functions: */ -/* -------------------------------------------------------------------------- */ - - -int window_create( struct gui_window * gw, - struct browser_window * bw, - unsigned long inflags ) -{ - int err = 0; - bool tb, sb; - int flags; - - tb = (inflags & WIDGET_TOOLBAR ); - sb = (inflags & WIDGET_STATUSBAR ); - - flags = CLOSER | MOVER | NAME | FULLER | SMALLER; - if( inflags & WIDGET_SCROLL ){ - flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE); - } - if( inflags & WIDGET_RESIZE ){ - flags |= ( SIZER ); - } - if( inflags & WIDGET_STATUSBAR ){ - flags |= ( INFO ); - } - - gw->root = malloc( sizeof(struct s_gui_win_root) ); - if( gw->root == NULL ) - return( -1 ); - memset( gw->root, 0, sizeof(struct s_gui_win_root) ); - gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1); - gw->root->handle = WindCreate( flags, 40, 40, app.w, app.h ); - if( gw->root->handle == NULL ) { - free( gw->root->title ); - free( gw->root ); - return( -1 ); - } - - /* set scroll / content granularity ( 1 unit ) */ - gw->root->handle->w_u = 1; - gw->root->handle->h_u = 1; - - /* Create Root component: */ - gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1); - WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL); - - /* create toolbar component: */ - if( tb ) { - gw->root->toolbar = tb_create( gw ); - assert( gw->root->toolbar ); - mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp ); - - } else { - gw->root->toolbar = NULL; - } - - /* create browser component: */ - gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 ); - mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp ); - - /* create statusbar component: */ - if( sb ) { - gw->root->statusbar = sb_create( gw ); -#ifdef WITH_COMOPONENT_STATUSBAR - mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp ); -#endif - } else { - gw->root->statusbar = NULL; - } - - WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf"); - - /* Event Handlers: */ - EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw ); - /* capture resize/move events so we can handle that manually */ - EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT ); - EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT ); - EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT ); - EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP ); - EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP ); - EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT); - EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT); - EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT); - EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT); - EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw ); - EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw); - EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw ); - - if (inflags & WIN_TOP) { - window_set_focus( gw, BROWSER, gw->browser); - } - - return (err); -} - -int window_destroy( struct gui_window * gw) -{ - int err = 0; - - search_destroy( gw ); - if( input_window == gw ) - input_window = NULL; - - if( gw->root ) { - if( gw->root->toolbar ) - tb_destroy( gw->root->toolbar ); - - if( gw->root->statusbar ) - sb_destroy( gw->root->statusbar ); - } - - search_destroy( gw ); - - if( gw->browser ) - browser_destroy( gw->browser ); - - /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */ - if( gw->root ) { - /* TODO: check if no other browser is bound to this root window! */ - /* only needed for tabs */ - if( gw->root->title ) - free( gw->root->title ); - if( gw->root->cmproot ) - mt_CompDelete( &app, gw->root->cmproot ); - ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0); - EvntWindom( MU_MESAG ); - gw->root->handle = NULL; - free( gw->root ); - gw->root = NULL; - } - return( err ); -} - - - -void window_open( struct gui_window * gw, GRECT pos ) -{ - LGRECT br; - - WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h ); - WindClear( gw->root->handle ); - WindSetStr( gw->root->handle, WF_NAME, (char *)"" ); - - /* apply focus to the root frame: */ - long lfbuff[8] = { CM_GETFOCUS }; - mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff ); - - /* recompute the nested component sizes and positions: */ - browser_update_rects( gw ); - mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc); - browser_get_rect( gw, BR_CONTENT, &br ); - plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h); - gw->browser->attached = true; - if( gw->root->statusbar != NULL ){ - sb_attach(gw->root->statusbar, gw); - } - tb_adjust_size( gw ); - /*TBD: get already present content and set size? */ - input_window = gw; - window_set_focus( gw, BROWSER, gw->browser ); -} - - - -/* update back forward buttons (see tb_update_buttons (bug) ) */ -void window_update_back_forward( struct gui_window * gw) -{ - tb_update_buttons( gw, -1 ); -} - -void window_set_stauts(struct gui_window * gw , char * text ) -{ - if( gw->root == NULL ) - return; - - CMP_STATUSBAR sb = gw->root->statusbar; - - if( sb == NULL || gw->browser->attached == false ) - return; - - sb_set_text( sb, text ); -} - -/* set focus to an arbitary element */ -void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element ) -{ - if( gw->root->focus.type != type || gw->root->focus.element != element ) { - LOG(("Set focus: %p (%d)\n", element, type)); - gw->root->focus.type = type; - gw->root->focus.element = element; - if( element != NULL ){ - switch( type ){ - - case URL_WIDGET: - textarea_keypress(((struct s_url_widget*)(element))->textarea, - KEY_SELECT_ALL ); - break; - - default: break; - - } - } - } -} - -/* check if the url widget has focus */ -bool window_url_widget_has_focus( struct gui_window * gw ) -{ - assert( gw ); - assert( gw->root ); - if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) { - assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) ); - assert( GUIWIN_VISIBLE(gw) ); - return true; - } - return false; -} - -/* check if an arbitary window widget / or frame has the focus */ -bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element ) -{ - if( gw == NULL ) - return( false ); - if( element == NULL ){ - assert( 1 != 0 ); - return( (gw->root->focus.type == t ) ); - } - assert( gw->root != NULL ); - return( ( element == gw->root->focus.element && t == gw->root->focus.type) ); -} - -void window_set_icon(struct gui_window *gw, struct bitmap * bmp ) -{ - gw->icon = bmp; - /* redraw window when it is iconyfied: */ - if (gw->icon != NULL) { - short info, dummy; - WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy); - if (info == 1) { - window_redraw_favicon(gw, NULL); - } - } -} - - -/** - * Redraw the favicon -*/ -void window_redraw_favicon(struct gui_window *gw, GRECT *clip) -{ - GRECT work; - - assert(gw->root); - - WINDOW * bw = gw->root->handle; - - WindClear(bw); - WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h); - if (clip == NULL) { - clip = &work; - } - - if (gw->icon == NULL) { - OBJECT * tree; - RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree); - tree->ob_x = work.g_x; - tree->ob_y = work.g_y; - tree->ob_width = work.g_w; - tree->ob_height = work.g_h; - objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h); - } else { - // TODO: consider the clipping rectangle - struct rect work_clip = { 0,0,work.g_w,work.g_h }; - int xoff=0; - if (work.g_w > work.g_h) { - xoff = ((work.g_w-work.g_h)/2); - work.g_w = work.g_h; - } - plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h); - plot_clip(&work_clip); - atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0); - } -} - - -/* -------------------------------------------------------------------------- */ -/* Event Handlers: */ -/* -------------------------------------------------------------------------- */ - -static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data ) -{ - bool abs = false; - LGRECT cwork; - struct gui_window * gw = data; - int value = BROWSER_SCROLL_SVAL; - - assert( gw != NULL ); - - browser_get_rect( gw, BR_CONTENT, &cwork ); - - switch( buff[4] ) { - case WA_UPPAGE: - case WA_DNPAGE: - value = cwork.g_h; - break; - - - case WA_LFPAGE: - case WA_RTPAGE: - value = cwork.g_w; - break; - - default: - break; - } - browser_scroll( gw, buff[4], value, abs ); -} - - -static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) -{ - struct gui_window * gw = (struct gui_window *)data; - char file[DD_NAMEMAX]; - char name[DD_NAMEMAX]; - char *buff=NULL; - int dd_hdl; - int dd_msg; /* pipe-handle */ - long size; - char ext[32]; - short mx,my,bmstat,mkstat; - graf_mkstate(&mx, &my, &bmstat, &mkstat); - - if( gw == NULL ) - return; - if( (win->status & WS_ICONIFY)) - return; - - dd_hdl = ddopen( wbuff[7], DD_OK); - if( dd_hdl<0) - return; /* pipe not open */ - memset( ext, 0, 32); - strcpy( ext, "ARGS"); - dd_msg = ddsexts( dd_hdl, ext); - if( dd_msg<0) - goto error; - dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size); - if( size+1 >= PATH_MAX ) - goto error; - if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) - { - ddreply(dd_hdl, DD_OK); - buff = (char*)malloc(sizeof(char)*(size+1)); - if (buff != NULL) - { - if (Fread(dd_hdl, size, buff ) == size) - buff[size] = 0; - LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n", - (char*)buff, (char*)&ext, - size, mx, my - )); - { - LGRECT bwrect; - struct browser_window * bw = gw->browser->bw; - browser_get_rect( gw, BR_CONTENT, &bwrect ); - mx = mx - bwrect.g_x; - my = my - bwrect.g_y; - if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ) - return; - - utf8_convert_ret ret; - char *utf8_fn; - - ret = utf8_from_local_encoding(buff, 0, &utf8_fn); - if (ret != UTF8_CONVERT_OK) { - free(buff); - /* A bad encoding should never happen */ - LOG(("utf8_from_local_encoding failed")); - assert(ret != UTF8_CONVERT_BADENC); - /* no memory */ - return; - } - browser_window_drop_file_at_point( gw->browser->bw, - mx+gw->browser->scroll.current.x, - my+gw->browser->scroll.current.y, - utf8_fn ); - free(utf8_fn); - free(buff); - } - } - } -error: - ddclose( dd_hdl); -} - -static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data ) -{ - LOG(("%s\n", __FUNCTION__ )); -} - -static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data ) -{ - struct gui_window * gw = (struct gui_window *) data ; - if( gw != NULL ) { - browser_window_destroy( gw->browser->bw ); - } -} - - -static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data ) -{ - input_window = (struct gui_window *) data; - window_set_focus( input_window, BROWSER, input_window->browser ); - LOG(("newtop gui window: %p, WINDOW: %p", input_window, win )); - assert( input_window != NULL ); -} - -static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data) -{ - int dx = buff[4]; - int dy = buff[5]; - struct gui_window * gw = data; - - if (!dx && !dy) return; - - if( input_window == NULL || input_window != gw ) { - return; - } - - /* update the sliders _before_ we call redraw - (which might depend on the slider possitions) */ - WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) ); - - if( dy > 0 ) - browser_scroll( gw, WA_DNPAGE, abs(dy), false ); - else if ( dy < 0) - browser_scroll( gw, WA_UPPAGE, abs(dy), false ); - if( dx > 0 ) - browser_scroll( gw, WA_RTPAGE, abs(dx), false ); - else if( dx < 0 ) - browser_scroll( gw, WA_LFPAGE, abs(dx), false ); -} - -static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ) -{ - struct gui_window * gw = (struct gui_window *)data; - - input_window = gw; - WindTop( gw->root->handle ); - window_set_focus( gw, BROWSER, gw->browser ); -} - -static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data ) -{ - struct gui_window * gw = (struct gui_window *)data; - if( input_window == gw){ - input_window = NULL; - } -} - - -static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data) -{ - struct gui_window *gw = (struct gui_window*) data; - GRECT clip = {buff[4], buff[5], buff[6], buff[7]}; - window_redraw_favicon(gw, &clip); -} - -/* perform the actual resize */ -static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data ) -{ - short x,y,w,h; - struct gui_window * gw; - - wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h ); - gw = (struct gui_window *)data; - - assert( gw != NULL ); - - if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){ - /* report resize to component interface: */ - browser_update_rects( gw ); - tb_adjust_size( gw ); - if( gw->browser->bw->current_content != NULL ){ - /* Reformat will happen when next redraw message arrives: */ - gw->browser->reformat_pending = true; - if( sys_XAAES() ){ - if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){ - ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle, - gw->root->loc.g_x, gw->root->loc.g_y, - gw->root->loc.g_w, gw->root->loc.g_h ); - } - } - mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, - (GRECT*)&gw->root->loc); - } - else { - WindClear( gw->root->handle ); - } - } else { - if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){ - mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc); - browser_update_rects( gw ); - } - } -} diff --git a/atari/browser_win.h b/atari/browser_win.h deleted file mode 100755 index 28001baad..000000000 --- a/atari/browser_win.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010 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 . - */ - -#ifndef NS_ATARI_BROWSER_WIN_H -#define NS_ATARI_BROWSER_WIN_H - -#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN) -#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN) - -#define WIDGET_STATUSBAR 0x1 -#define WIDGET_TOOLBAR 0x2 -#define WIDGET_SCROLL 0x4 -#define WIDGET_RESIZE 0x8 - -#define WIN_TOP 0x100 - -/* WinDom & Custom bindings for gui window */ - -/* -------------------------------------------------------------------------- */ -/* Public module functions: */ -/* -------------------------------------------------------------------------- */ - -/* Creates an normal Browser window with [toolbar], [statusbar] */ -int window_create( struct gui_window * gw, - struct browser_window * bw, unsigned long flags ); -/* Destroys WinDom part of gui_window */ -int window_destroy( struct gui_window * gw ); - -/* show the window */ -void window_open( struct gui_window * gw, GRECT pos); - -void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h ); -/* Update Shade / Unshade state of the fwd/back buttons*/ -void window_update_back_forward(struct gui_window * gw); -/* set root browser component: */ -void window_attach_browser( struct gui_window * gw, CMP_BROWSER b); - -/* set focus element */ -void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element ); -/* adjust scroll settings */ -void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w); -/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/ -bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element); -bool window_url_widget_has_focus( struct gui_window * gw ); -void window_set_url( struct gui_window * gw, const char * text); -void window_set_stauts( struct gui_window * gw , char * text ); -void window_set_icon(struct gui_window * gw, struct bitmap * bmp ); -void window_redraw_favicon(struct gui_window *gw, GRECT *clip); - - -/* -------------------------------------------------------------------------- */ -/* Public event handlers: */ -/* -------------------------------------------------------------------------- */ - -#endif diff --git a/atari/dragdrop.c b/atari/dragdrop.c deleted file mode 100755 index bc7f5659b..000000000 --- a/atari/dragdrop.c +++ /dev/null @@ -1,516 +0,0 @@ -/* -* Routine pour Drag and drop sous MultiTos -* source: D&D Atari, demo OEP (Alexander Lorenz) -* -* Struktur OEP (oep.apid): AES-ID der Applikation -* -* (Tab = 4) -*/ - -#ifdef __PUREC__ -#include -#else -#include -#include -#include -#endif - -#include -#include - -#include "windom.h" -#include "dragdrop.h" -#include "cflib.h" - -#ifndef EACCDN -#define EACCDN (-36) -#endif - -#ifndef FA_HIDDEN -#define FA_HIDDEN 0x02 -#endif - -static char pipename[] = "U:\\PIPE\\DRAGDROP.AA"; -static long pipesig; - -/* -* Routinen fr den Sender -*/ - -/* -* Erzeugt Pipe fr D&D -* -* Eingabeparameter: -* pipe - Pointer auf 2 Byte Buffer fr Pipeextension -* -* Ausgabeparameters: -* keine -* -* Returnwert: -* >0: Filehandle der Pipe -* -1: Fehler beim Erzeugen der Pipe -*/ - -short ddcreate(short *pipe) -{ - long fd = -1; - - pipename[17] = 'A'; - pipename[18] = 'A' - 1; - - do /* ouvre un pipe inoccup‚ */ - { - pipename[18]++; - if (pipename[18] > 'Z') - { - pipename[17]++; - if (pipename[17] > 'Z') - break; - else - pipename[18] = 'A'; - } - - /* FA_HIDDEN fr Pipe notwendig! */ - - fd = Fcreate(pipename, FA_HIDDEN); - - } while (fd == (long) EACCDN); - - if (fd < 0L) - return(-1); - - *pipe = (pipename[17] << 8) | pipename[18]; - - - /* Signalhandler konfigurieren */ - - ddgetsig(&pipesig); - - - return((short) fd); -} - - - -/* -* Sendet AP_DRAGDROP an Empf„ngerapplikation -* -* Eingabeparameter: -* apid - AES-ID der Emf„ngerapp. -* fd - Filehandle der D&D-Pipe -* winid - Handle des Zielfensters (0 fr Desktopfenster) -* mx/my - Maus X und Y Koord. -* (-1/-1 fr einen fake Drag&Drop) -* kstate - Sondertastenstatus -* pipename - Extension der D&D-Pipe -* -* Ausgabeparameter: -* keine -* -* Returnwert: -* >0: kein Fehler -* -1: Empf„ngerapp. gibt DD_NAK zurck -* -2: Empf„ngerapp. antwortet nicht (Timeout) -* -3: Fehler bei appl_write() -*/ - -short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipeid) -{ - char c; - short i, msg[8]; - long fd_mask; - - - /* AES-Message define and post */ - - msg[0] = AP_DRAGDROP; - msg[1] = _AESapid; - msg[2] = 0; - msg[3] = winid; - msg[4] = mx; - msg[5] = my; - msg[6] = kstate; - msg[7] = pipeid; - - i = appl_write(apid, 16, msg); - - if (i == 0) - { - ddclose(fd); - return(-3); - } - - - /* receiver reaction */ - - fd_mask = (1L << fd); - i = Fselect(DD_TIMEOUT, &fd_mask, 0L, 0L); - if (!i || !fd_mask) - { - /* Timeout eingetreten */ - - ddclose(fd); - return(-2); - } - - - /* le recepteur refuse (lecture du pipe) */ - - if (Fread(fd, 1L, &c) != 1L) - { - ddclose(fd); - return(-1); - } - - if (c != DD_OK) - { - ddclose(fd); - return(-1); - } - - return(1); -} - - - -/* -* Liest die 8 "bevorzugten" Extensionen der Empf„ngerapplikation -* -* Eingabeparameter: -* fd - Filehandle der D&D-Pipe -* -* Ausgabeparameters: -* exts - 32 Bytebuffer fr die 8 bevorzugten Extensionen -* der Zielapp. -* -* Returnwert: -* >0: kein Fehler -* -1: Fehler beim Lesen aus der Pipe -*/ - -short ddrexts(short fd, char *exts) -{ - if (Fread(fd, DD_EXTSIZE, exts) != DD_EXTSIZE) - { - ddclose(fd); - return(-1); - } - - return(1); -} - - - -/* -* Testet, ob der Empf„nger einen Datentyp akzeptiert -* -* Eingabeparameter: -* fd - Filehandle (von ddcreate()) -* ext - Zeiger auf Datentyp (4 Bytes zB. "ARGS") -* text - Zeiger auf Datenbeschreibung (optional, zB. "DESKTOP args") -* name - Zeiger auf Datendateiname (optional, zB. "SAMPLE.TXT") -* size - Anzahl Bytes der zu sendenden Daten -* -* Ausgabeparameter: -* keine -* -* Returnwert: -* DD_OK - Empf„nger akzeptiert Datentyp -* DD_NAK - Empf„nger brach Drag&Drop ab -* DD_EXT - Empf„nger lehnt Datentyp ab -* DD_LEN - Empf„nger kann Datenmenge nicht verarbeiten -* DD_TRASH - Drop erfolgte auf Mlleimer -* DD_PRINTER - Drop erfolgte auf Drucker -* DD_CLIPBOARD - Drop erfolgte auf Clipboard -*/ - -short ddstry(short fd, char *ext, char *text, char *name, long size) -{ - char c; - short hdrlen, i; - - /* 4 Bytes fr "ext", 4 Bytes fr "size", - 2 Bytes fr Stringendnullen */ - - hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1); - - - /* Header senden */ - - if (Fwrite(fd, 2L, &hdrlen) != 2L) - return(DD_NAK); - - i = (short) Fwrite(fd, 4L, ext); - i += (short) Fwrite(fd, 4L, &size); - i += (short) Fwrite(fd, strlen(text)+1, text); - i += (short) Fwrite(fd, strlen(name)+1, name); - - if (i != hdrlen) - return(DD_NAK); - - - /* auf die Antwort warten */ - - if (Fread(fd, 1L, &c) != 1L) - return(DD_NAK); - - return(c); -} - - - -/* Routinen fr Sender und Empf„nger */ - -/* -* Pipe schliežen (Drag&Drop beenden/abbrechen) -*/ - -void ddclose(short fd) -{ - /* Signalhandler restaurieren */ - - ddsetsig(pipesig); - - - Fclose(fd); -} - - -/* -* Signalhandler fr D&D konfigurieren -* -* Eingabeparameter: -* oldsig - Zeiger auf 4 Byte Puffer fr alten Handlerwert -* -* Ausgabeparameter: -* keine -* -* Returnwerte: -* keine -*/ - -void ddgetsig(long *oldsig) -{ - *oldsig = (long) Psignal(SIGPIPE, (void *) SIG_IGN); -} - - -/* -* Signalhandler nach D&D restaurieren -* -* Eingabeparameter: -* oldsig - Alter Handlerwert (von ddgetsig) -* -* Ausgabeparameter: -* keine -* -* Returnwerte: -* keine -*/ - -void ddsetsig(long oldsig) -{ - if (oldsig != -32L) - Psignal(SIGPIPE, (void *) oldsig); -} - - - -/* Routinen fr Empf„nger */ - -/* -* Drag&Drop Pipe ”ffnen -* -* Eingabeparameter: -* ddnam - Extension der Pipe (letztes short von AP_DRAGDROP) -* ddmsg - DD_OK oder DD_NAK -* -* Ausgabeparameter: -* keine -* -* Returnwerte: -* >0 - Filehandle der Drag&Drop pipe -* -1 - Drag&Drop abgebrochen -*/ - -short ddopen(short ddnam, char ddmsg) -{ - long fd; - - pipename[17] = (ddnam & 0xff00) >> 8; - pipename[18] = ddnam & 0x00ff; - - fd = Fopen(pipename, 2); - - if (fd < 0L) - return(-1); - - - /* Signalhandler konfigurieren */ - - ddgetsig(&pipesig); - - - if (Fwrite((short) fd, 1L, &ddmsg) != 1L) - { - ddclose((short) fd); - return(-1); - } - - return((short) fd); -} - - - -/* -* Schreibt die 8 "bevorzugten" Extensionen der Applikation -* -* Eingabeparameter: -* fd - Filehandle der D&D-Pipe -* exts - Liste aus acht 4 Byte Extensionen die verstanden -* werden. Diese Liste sollte nach bevorzugten Datentypen -* sortiert sein. Sollten weniger als DD_NUMEXTS -* Extensionen untersttzt werden, muž die Liste mit -* Nullen (0) aufgefllt werden! -* -* Ausgabeparameter: -* keine -* -* Returnwert: -* >0: kein Fehler -* -1: Fehler beim Schreiben in die Pipe -*/ - -short ddsexts(short fd, char *exts) -{ - if (Fwrite(fd, DD_EXTSIZE, exts) != DD_EXTSIZE) - { - ddclose(fd); - return(-1); - } - - return(1); -} - - - -/* -* N„chsten Header vom Sender holen -* -* Eingabeparameter: -* fd - Filehandle der Pipe (von ddopen()) -* -* Ausgabeparameters: -* name - Zeiger auf Buffer fr Datenbeschreibung (min. DD_NAMEMAX!) -* file - Zeiger auf Buffer fr Datendateiname (min. DD_NAMEMAX!) -* whichext- Zeiger auf Buffer fr Extension (4 Bytes) -* size - Zeiger auf Buffer fr Datengr”že (4 Bytes) -* -* Returnwert: -* >0: kein Fehler -* -1: Sender brach Drag&Drop ab -* -* On lit dans le pipe qui normalement est constitu‚ de: -* 1 short: taille du header -* 4 CHAR: type de donn‚e (extension) -* 1 long: taille des donn‚es -* STRING: description des donn‚es -* STRING: nom du fichiers -* soit au minimun 11 octets (cas ou les string sont r‚duites … \0) -* les string sont limit‚ a 128 octets -*/ - -short ddrtry(short fd, char *name, char *file, char *whichext, long *size) -{ - char buf[DD_NAMEMAX * 2]; - short hdrlen, i, len; - - if (Fread(fd, 2L, &hdrlen) != 2L) - return(-1); - - - if (hdrlen < 9) /* il reste au minimum 11 - 2 = 9 octets a lire */ - { - /* sollte eigentlich nie passieren */ - - return(-1); /* erreur taille incorrecte */ - } - - if (Fread(fd, 4L, whichext) != 4L) /* lecture de l'extension */ - return(-1); - - if (Fread(fd, 4L, size) != 4L) /* lecture de la longueurs des donn‚es */ - return(-1); - - hdrlen -= 8; /* on a lu 8 octets */ - - if (hdrlen > DD_NAMEMAX*2) - i = DD_NAMEMAX*2; - else - i = hdrlen; - - len = i; - - if (Fread(fd, (long) i, buf) != (long) i) - return(-1); - - hdrlen -= i; - - strncpy(name, buf, DD_NAMEMAX); - - i = (short) strlen(name) + 1; - - if (len - i > 0) - strncpy(file, buf + i, DD_NAMEMAX); - else - file[0] = '\0'; - - - /* weitere Bytes im Header in den Mll */ - - while (hdrlen > DD_NAMEMAX*2) - { - if (Fread(fd, DD_NAMEMAX*2, buf) != DD_NAMEMAX*2) - return(-1); - - hdrlen -= DD_NAMEMAX*2; - } - - if (hdrlen > 0) - { - if (Fread(fd, (long) hdrlen, buf) != (long) hdrlen) - return(-1); - } - - return(1); -} - - - -/* -* Sendet der Senderapplikation eine 1 Byte Antwort -* -* Eingabeparameter: -* fd - Filehandle der Pipe (von ddopen()) -* ack - Byte das gesendet werden soll (zB. DD_OK) -* -* Ausgabeparameter: -* keine -* -* Returnwert: -* >0: kein Fehler -* -1: Fehler (die Pipe wird automatisch geschlossen!) -*/ - -short ddreply(short fd, char ack) -{ - if (Fwrite(fd, 1L, &ack) != 1L) - { - ddclose(fd); - return(-1); - } - - return(1); -} - - diff --git a/atari/dragdrop.h b/atari/dragdrop.h deleted file mode 100755 index dccd3e371..000000000 --- a/atari/dragdrop.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -* MultiTOS Drag&Drop Header file -*/ - -/* -* Declarations -*/ - -short ddcreate(short *pipe); -short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename); -short ddrexts(short fd, char *exts); -short ddstry(short fd, char *ext, char *text, char *name, long size); -void ddclose(short fd); -void ddgetsig(long *oldsig); -void ddsetsig(long oldsig); -short ddopen(short ddnam, char ddmsg); -short ddsexts(short fd, char *exts); -short ddrtry(short fd, char *name, char *file, char *whichext, long *size); -short ddreply(short fd, char ack); diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index fe59209fe..1ac8935d7 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -55,9 +55,10 @@ short msg_box_show(short type, const char * msg); /* Guiwin */ -#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events -#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed -#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical +#define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events +#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed +#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical +#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling #define GW_STATUS_ICONIFIED 0x01 #define GW_STATUS_SHADED 0x02 diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c index 6d525c698..56a306434 100644 --- a/atari/gemtk/guiwin.c +++ b/atari/gemtk/guiwin.c @@ -68,18 +68,22 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8]) break; case WM_REDRAW: + if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) { guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro); tb_area = tb_area_ro; if(rc_intersect((GRECT*)&msg[4], &tb_area)){ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g); while (g.g_h > 0 || g.g_w > 0) { gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x; + gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w; gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y; + gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h; objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y, g.g_w, g.g_h); wind_get_grect(gw->handle, WF_NEXTXYWH, &g); } } + } break; default: @@ -145,13 +149,21 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) dest = guiwin_find(info[0]); if (dest) { DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func)); - if(dest->toolbar != NULL && dest->handler_func != NULL){ + + // toolbar handling: + if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 && + dest->toolbar != NULL && dest->handler_func != NULL){ GRECT tb_area; guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area); if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, tb_area)) { // send WM_TOOLBAR message - short obj_idx = 0; + dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x; + dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y; + short obj_idx = objc_find(dest->toolbar, + dest->toolbar_idx, 8, + ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_y); short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle, obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0}; short oldevents = ev_out->emo_events; @@ -161,14 +173,6 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) retval = 1; } } - /* - if (dest->flags&GW_FLAG_PREPROC_WM) { - preproc_wm(dest, ev_in, ev_out, msg); - } - if (dest->handler_func) { - retval = dest->handler_func(dest, ev_in, ev_out, msg); - } - */ } } } @@ -177,7 +181,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb) { - GUIWIN *win = malloc(sizeof(GUIWIN)); + GUIWIN *win = calloc(sizeof(GUIWIN),1); assert(win!=NULL); DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb)); @@ -259,9 +263,8 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest) dest->g_w -= tb_area.g_w; } else { dest->g_y += tb_area.g_h; - dest->g_w -= tb_area.g_h; + dest->g_h -= tb_area.g_h; } - dbg_grect("guiwin_get_grect content", dest); } else if (mode == GUIWIN_AREA_TOOLBAR) { if (win->toolbar != NULL) { @@ -274,7 +277,6 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest) dest->g_h = 0; dest->g_w = 0; } - dbg_grect("guiwin_get_grect toolbar", dest); } } diff --git a/atari/msgbox.c b/atari/msgbox.c deleted file mode 100644 index a9de5d299..000000000 --- a/atari/msgbox.c +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include -#include -#include "atari/msgbox.h" - -#ifndef min -# define min(x,y) ((xemo_mouse.p_x, - ev_out->emo_mouse.p_y); + printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_y, msg[4]); break; default: @@ -599,31 +599,6 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data browser_scroll( gw, WA_LFPAGE, abs(dx), false ); } -//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ) -//{ -// struct gui_window * gw = (struct gui_window *)data; -// -// input_window = gw; -// WindTop( gw->root->handle ); -// window_set_focus( gw, BROWSER, gw->browser ); -//} - -//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data ) -//{ -// struct gui_window * gw = (struct gui_window *)data; -// if( input_window == gw) { -// input_window = NULL; -// } -//} - - -//static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data) -//{ -// struct gui_window *gw = (struct gui_window*) data; -// GRECT clip = {buff[4], buff[5], buff[6], buff[7]}; -// window_redraw_favicon(gw, &clip); -//} - static void redraw(GUIWIN *win, short msg[8]) { short handle; @@ -638,23 +613,17 @@ static void redraw(GUIWIN *win, short msg[8]) GRECT clip = {msg[4], msg[5], msg[6], msg[7]}; window_redraw_favicon(gw, &clip); } else { - GRECT area; + GRECT content_area, tb_area; short pxy[8]; - guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area); - /* - pxy[0] = area.g_x; - pxy[1] = area.g_y; - pxy[2] = pxy[0] + area.g_w; - pxy[3] = pxy[1]; - pxy[4] = pxy[2]; - pxy[5] = pxy[1] + area.g_h; - pxy[6] = pxy[0]; - pxy[7] = pxy[5]; - */ - //const plot_style_fill_white - plot_rectangle(area.g_x, area.g_y, area.g_x+area.g_h, - area.g_y + area.g_h, - plot_style_fill_white); + + guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area); + guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area); + struct rect clip = {0,0,content_area.g_w,content_area.g_h}; + plot_set_dimensions(content_area.g_x, content_area.g_y, + content_area.g_w,content_area.g_h); + //plot_clip(&clip); + plot_rectangle(0, 0, content_area.g_w, + content_area.g_h, plot_style_broken_object); //WindClear(gw->root->handle); -- cgit v1.2.3