2008-08-02 18:31:32 +04:00
/*
2009-01-11 00:31:21 +03:00
* Copyright 2008 - 9 Chris Young < chris @ unsatisfactorysoftware . co . uk >
2008-08-02 18:31:32 +04:00
*
* This file is part of NetSurf , http : //www.netsurf-browser.org/
*
* NetSurf is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; version 2 of the License .
*
* NetSurf is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2008-10-05 03:29:17 +04:00
# include "amiga/gui.h"
2008-08-02 18:31:32 +04:00
# include "desktop/netsurf.h"
2008-08-03 20:13:57 +04:00
# include "desktop/options.h"
2008-08-02 18:31:32 +04:00
# include "utils/messages.h"
# include <proto/exec.h>
# include <proto/intuition.h>
# include "amiga/plotters.h"
2008-08-03 20:13:57 +04:00
# include "amiga/schedule.h"
# include <proto/timer.h>
2008-08-09 19:19:04 +04:00
# include "content/urldb.h"
# include <libraries/keymap.h>
2008-08-10 00:27:36 +04:00
# include "desktop/history_core.h"
# include <proto/locale.h>
# include <proto/dos.h>
2008-08-11 21:53:45 +04:00
# include <intuition/icclass.h>
# include <proto/utility.h>
2008-08-09 02:38:13 +04:00
# include <proto/graphics.h>
2008-08-11 21:53:45 +04:00
# include <proto/Picasso96API.h>
2008-08-17 20:22:40 +04:00
# include "render/form.h"
# include <graphics/rpattr.h>
2008-08-19 22:31:56 +04:00
# include <libraries/gadtools.h>
2008-08-22 01:41:42 +04:00
# include <proto/layers.h>
# include <proto/asl.h>
2008-09-14 02:39:48 +04:00
# include <datatypes/pictureclass.h>
2008-08-22 01:41:42 +04:00
# include "desktop/selection.h"
2008-08-23 20:17:51 +04:00
# include "utils/utf8.h"
# include "amiga/utf8.h"
2008-08-24 01:56:49 +04:00
# include "amiga/hotlist.h"
2008-08-25 17:32:26 +04:00
# include "amiga/menu.h"
# include "amiga/options.h"
# include <libraries/keymap.h>
# include "desktop/textinput.h"
2008-08-31 21:34:00 +04:00
# include <intuition/pointerclass.h>
# include <math.h>
2008-09-04 02:02:41 +04:00
# include <workbench/workbench.h>
2008-09-11 23:33:40 +04:00
# include <proto/datatypes.h>
2008-09-23 00:41:01 +04:00
# include <proto/icon.h>
# include <workbench/icon.h>
2008-09-28 00:55:11 +04:00
# include "amiga/tree.h"
2008-09-29 02:50:13 +04:00
# include "utils/utils.h"
# include "amiga/login.h"
# include "utils/url.h"
# include <string.h>
2008-09-29 23:35:30 +04:00
# include "amiga/arexx.h"
2008-10-12 01:38:04 +04:00
# include "amiga/hotlist.h"
# include "amiga/history.h"
2008-10-21 22:04:27 +04:00
# include "amiga/context_menu.h"
# include "amiga/cookies.h"
2008-10-25 20:37:08 +04:00
# include "amiga/clipboard.h"
2008-10-26 15:25:26 +03:00
# include <proto/keymap.h>
2008-11-09 02:08:55 +03:00
# include "amiga/save_complete.h"
2008-11-15 18:28:17 +03:00
# include "amiga/fetch_file.h"
2008-12-14 02:25:42 +03:00
# include "amiga/fetch_mailto.h"
# include "amiga/search.h"
2009-01-11 00:31:21 +03:00
# include <devices/inputevent.h>
2008-08-11 21:53:45 +04:00
2008-12-28 15:24:18 +03:00
# ifdef NS_AMIGA_CAIRO
# include <cairo/cairo-amigaos.h>
# endif
2008-08-15 21:19:57 +04:00
# ifdef WITH_HUBBUB
# include <hubbub/hubbub.h>
# endif
2008-08-09 02:38:13 +04:00
# include <proto/window.h>
# include <proto/layout.h>
# include <proto/bitmap.h>
# include <proto/string.h>
2008-08-09 19:19:04 +04:00
# include <proto/button.h>
2008-08-11 21:53:45 +04:00
# include <proto/space.h>
2008-08-18 23:07:12 +04:00
# include <proto/popupmenu.h>
2008-08-23 20:17:51 +04:00
# include <proto/fuelgauge.h>
2008-09-28 00:55:11 +04:00
# include <proto/clicktab.h>
2008-08-09 02:38:13 +04:00
# include <classes/window.h>
2008-08-23 20:17:51 +04:00
# include <gadgets/fuelgauge.h>
2008-08-09 02:38:13 +04:00
# include <gadgets/layout.h>
# include <gadgets/string.h>
2008-08-09 19:19:04 +04:00
# include <gadgets/scroller.h>
# include <gadgets/button.h>
2008-08-09 02:38:13 +04:00
# include <images/bitmap.h>
2008-08-11 21:53:45 +04:00
# include <gadgets/space.h>
2008-09-28 00:55:11 +04:00
# include <gadgets/clicktab.h>
2008-08-18 23:07:12 +04:00
# include <classes/popupmenu.h>
2008-08-09 02:38:13 +04:00
# include <reaction/reaction_macros.h>
2008-08-02 18:31:32 +04:00
char * default_stylesheet_url ;
char * adblock_stylesheet_url ;
2008-08-09 19:19:04 +04:00
2008-09-04 02:02:41 +04:00
struct MsgPort * appport ;
2008-08-03 20:13:57 +04:00
struct MsgPort * msgport ;
struct Device * TimerBase ;
struct TimerIFace * ITimer ;
2008-08-18 23:07:12 +04:00
struct Library * PopupMenuBase = NULL ;
struct PopupMenuIFace * IPopupMenu = NULL ;
2008-10-26 15:25:26 +03:00
struct Library * KeymapBase = NULL ;
struct KeymapIFace * IKeymap = NULL ;
2008-08-09 02:38:13 +04:00
2008-09-14 02:39:48 +04:00
struct BitMap * throbber = NULL ;
2008-10-18 17:56:12 +04:00
ULONG throbber_width , throbber_height , throbber_frames ;
2008-10-20 22:06:46 +04:00
BOOL rmbtrapped ;
2008-12-08 00:50:04 +03:00
BOOL locked_screen = FALSE ;
2008-09-11 23:33:40 +04:00
2008-09-23 00:41:01 +04:00
# define AMI_LASTPOINTER GUI_POINTER_PROGRESS+1
Object * mouseptrobj [ AMI_LASTPOINTER + 1 ] ;
2008-08-31 21:34:00 +04:00
struct BitMap * mouseptrbm [ AMI_LASTPOINTER + 1 ] ;
2008-09-23 00:41:01 +04:00
int mouseptrcurrent = 0 ;
2008-08-31 21:34:00 +04:00
char * ptrs [ AMI_LASTPOINTER + 1 ] = {
2008-12-14 02:25:42 +03:00
" ptr_default " ,
" ptr_point " ,
" ptr_caret " ,
" ptr_menu " ,
" ptr_up " ,
" ptr_down " ,
" ptr_left " ,
" ptr_right " ,
" ptr_rightup " ,
" ptr_leftdown " ,
" ptr_leftup " ,
" ptr_rightdown " ,
" ptr_cross " ,
" ptr_move " ,
" ptr_wait " , // not used
" ptr_help " ,
" ptr_nodrop " ,
" ptr_notallowed " ,
" ptr_progress " ,
" ptr_blank " } ;
char * ptrs32 [ AMI_LASTPOINTER + 1 ] = {
" ptr32_default " ,
" ptr32_point " ,
" ptr32_caret " ,
" ptr32_menu " ,
" ptr32_up " ,
" ptr32_down " ,
" ptr32_left " ,
" ptr32_right " ,
" ptr32_rightup " ,
" ptr32_leftdown " ,
" ptr32_leftup " ,
" ptr32_rightdown " ,
" ptr32_cross " ,
" ptr32_move " ,
" ptr32_wait " , // not used
" ptr32_help " ,
" ptr32_nodrop " ,
" ptr32_notallowed " ,
" ptr32_progress " ,
" ptr32_blank " } ;
2008-08-31 21:34:00 +04:00
2008-11-02 03:21:49 +03:00
void ami_update_throbber ( struct gui_window_2 * g , bool redraw ) ;
2008-10-05 03:29:17 +04:00
void ami_update_buttons ( struct gui_window_2 * ) ;
2008-08-15 21:19:57 +04:00
void ami_scroller_hook ( struct Hook * , Object * , struct IntuiMessage * ) ;
2008-08-18 23:07:12 +04:00
uint32 ami_popup_hook ( struct Hook * hook , Object * item , APTR reserved ) ;
2009-01-11 00:31:21 +03:00
void ami_do_redraw ( struct gui_window_2 * g , bool scroll ) ;
2008-09-23 00:41:01 +04:00
void ami_init_mouse_pointers ( void ) ;
2008-10-21 22:04:27 +04:00
void ami_switch_tab ( struct gui_window_2 * gwin , bool redraw ) ;
2008-08-15 21:19:57 +04:00
# ifdef WITH_HUBBUB
static void * myrealloc ( void * ptr , size_t len , void * pw ) ;
# endif
2008-08-10 00:27:36 +04:00
2008-08-02 18:31:32 +04:00
void gui_init ( int argc , char * * argv )
{
2008-08-10 00:27:36 +04:00
struct Locale * locale ;
2008-10-18 17:56:12 +04:00
char lang [ 100 ] , throbberfile [ 100 ] ;
2008-08-10 00:27:36 +04:00
bool found = FALSE ;
int i ;
2008-10-13 22:01:25 +04:00
BPTR lock = 0 , amiupdatefh ;
2008-09-14 02:39:48 +04:00
Object * dto ;
2008-08-10 00:27:36 +04:00
2008-08-03 20:13:57 +04:00
msgport = AllocSysObjectTags ( ASOT_PORT ,
ASO_NoTrack , FALSE ,
TAG_DONE ) ;
2008-12-20 13:54:59 +03:00
tioreq = ( struct TimeRequest * ) AllocSysObjectTags ( ASOT_IOREQUEST ,
ASOIOR_Size , sizeof ( struct TimeRequest ) ,
2008-08-03 20:13:57 +04:00
ASOIOR_ReplyPort , msgport ,
ASO_NoTrack , FALSE ,
TAG_DONE ) ;
2008-08-02 18:31:32 +04:00
2008-09-08 22:14:14 +04:00
OpenDevice ( " timer.device " , UNIT_WAITUNTIL , ( struct IORequest * ) tioreq , 0 ) ;
2008-08-03 20:13:57 +04:00
2008-12-20 13:54:59 +03:00
TimerBase = ( struct Device * ) tioreq - > Request . io_Device ;
2008-08-03 20:13:57 +04:00
ITimer = ( struct TimerIFace * ) GetInterface ( ( struct Library * ) TimerBase , " main " , 1 , NULL ) ;
2008-09-04 02:02:41 +04:00
if ( ! ( appport = AllocSysObjectTags ( ASOT_PORT ,
ASO_NoTrack , FALSE ,
TAG_DONE ) ) ) die ( messages_get ( " NoMemory " ) ) ;
2008-09-05 02:41:26 +04:00
if ( ! ( sport = AllocSysObjectTags ( ASOT_PORT ,
ASO_NoTrack , FALSE ,
TAG_DONE ) ) ) die ( messages_get ( " NoMemory " ) ) ;
2008-08-18 23:07:12 +04:00
if ( PopupMenuBase = OpenLibrary ( " popupmenu.class " , 0 ) )
{
IPopupMenu = ( struct PopupMenuIFace * ) GetInterface ( PopupMenuBase , " main " , 1 , NULL ) ;
}
2008-10-26 15:25:26 +03:00
if ( KeymapBase = OpenLibrary ( " keymap.library " , 37 ) )
{
IKeymap = ( struct KeymapIFace * ) GetInterface ( KeymapBase , " main " , 1 , NULL ) ;
}
2008-08-22 01:41:42 +04:00
2008-10-25 20:37:08 +04:00
ami_clipboard_init ( ) ;
2008-08-22 01:41:42 +04:00
2008-09-28 00:55:11 +04:00
win_destroyed = false ;
2008-08-25 17:32:26 +04:00
options_read ( " Resources/Options " ) ;
verbose_log = option_verbose_log ;
2008-10-26 15:25:26 +03:00
2009-01-15 15:26:06 +03:00
filereq = ( struct FileRequester * ) AllocAslRequest ( ASL_FileRequest , NULL ) ;
savereq = ( struct FileRequester * ) AllocAslRequestTags ( ASL_FileRequest ,
ASLFR_DoSaveMode , TRUE ,
ASLFR_RejectIcons , TRUE ,
ASLFR_InitialDrawer , option_download_dir ,
TAG_DONE ) ;
2008-08-23 20:17:51 +04:00
nsscreentitle = ASPrintf ( " NetSurf %s " , netsurf_version ) ;
2008-08-10 00:27:36 +04:00
if ( lock = Lock ( " Resources/LangNames " , ACCESS_READ ) )
2008-08-09 19:19:04 +04:00
{
2008-08-10 00:27:36 +04:00
UnLock ( lock ) ;
messages_load ( " Resources/LangNames " ) ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 00:27:36 +04:00
locale = OpenLocale ( NULL ) ;
for ( i = 0 ; i < 10 ; i + + )
2008-08-09 19:19:04 +04:00
{
2008-08-10 00:27:36 +04:00
strcpy ( & lang , " Resources/ " ) ;
if ( locale - > loc_PrefLanguages [ i ] )
{
strcat ( & lang , messages_get ( locale - > loc_PrefLanguages [ i ] ) ) ;
}
else
{
continue ;
}
strcat ( & lang , " /messages " ) ;
2008-08-23 20:17:51 +04:00
// printf("%s\n",lang);
2008-08-10 00:27:36 +04:00
if ( lock = Lock ( lang , ACCESS_READ ) )
{
UnLock ( lock ) ;
found = TRUE ;
break ;
}
}
if ( ! found )
{
strcpy ( & lang , " Resources/en/messages " ) ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 00:27:36 +04:00
CloseLocale ( locale ) ;
messages_load ( lang ) ; // check locale language and read appropriate file
2008-11-15 18:28:17 +03:00
default_stylesheet_url = " file:///Resources/default.css " ; //"http://www.unsatisfactorysoftware.co.uk/newlook.css"; //path_to_url(buf);
adblock_stylesheet_url = " file:///Resources/adblock.css " ;
2008-08-15 21:19:57 +04:00
# ifdef WITH_HUBBUB
if ( hubbub_initialise ( " Resources/Aliases " , myrealloc , NULL ) ! = HUBBUB_OK )
{
die ( messages_get ( " NoMemory " ) ) ;
}
# endif
2008-12-14 02:25:42 +03:00
css_screen_dpi = 72 ;
2008-08-12 21:47:35 +04:00
if ( ( ! option_cookie_file ) | | ( option_cookie_file [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_cookie_file = ( char * ) strdup ( " Resources/Cookies " ) ;
2008-08-10 00:27:36 +04:00
2008-08-25 17:32:26 +04:00
if ( ( ! option_hotlist_file ) | | ( option_hotlist_file [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_hotlist_file = ( char * ) strdup ( " Resources/Hotlist " ) ;
2008-08-25 17:32:26 +04:00
if ( ( ! option_url_file ) | | ( option_url_file [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_url_file = ( char * ) strdup ( " Resources/URLs " ) ;
2008-08-25 17:32:26 +04:00
2008-10-12 01:38:04 +04:00
if ( ( ! option_recent_file ) | | ( option_recent_file [ 0 ] = = ' \0 ' ) )
option_recent_file = ( char * ) strdup ( " Resources/Recent " ) ;
2008-08-25 17:32:26 +04:00
/*
2008-08-12 21:47:35 +04:00
if ( ( ! option_cookie_jar ) | | ( option_cookie_jar [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_cookie_jar = ( char * ) strdup ( " Resources/CookieJar " ) ;
2008-08-25 17:32:26 +04:00
*/
2008-08-10 00:27:36 +04:00
2008-08-12 21:47:35 +04:00
if ( ( ! option_ca_bundle ) | | ( option_ca_bundle [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_ca_bundle = ( char * ) strdup ( " devs:curl-ca-bundle.crt " ) ;
2008-08-10 13:57:41 +04:00
2008-08-12 21:47:35 +04:00
if ( ( ! option_font_sans ) | | ( option_font_sans [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_font_sans = ( char * ) strdup ( " DejaVu Sans " ) ;
2008-08-10 13:57:41 +04:00
2008-08-12 21:47:35 +04:00
if ( ( ! option_font_serif ) | | ( option_font_serif [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_font_serif = ( char * ) strdup ( " DejaVu Serif " ) ;
2008-08-10 13:57:41 +04:00
2008-08-12 21:47:35 +04:00
if ( ( ! option_font_mono ) | | ( option_font_mono [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_font_mono = ( char * ) strdup ( " DejaVu Sans Mono " ) ;
2008-08-10 13:57:41 +04:00
2008-08-12 21:47:35 +04:00
if ( ( ! option_font_cursive ) | | ( option_font_cursive [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_font_cursive = ( char * ) strdup ( " DejaVu Sans " ) ;
2008-08-10 13:57:41 +04:00
2008-08-25 17:32:26 +04:00
if ( ( ! option_font_fantasy ) | | ( option_font_fantasy [ 0 ] = = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
option_font_fantasy = ( char * ) strdup ( " DejaVu Serif " ) ;
2008-08-10 00:27:36 +04:00
2008-10-18 17:56:12 +04:00
if ( ( ! option_theme ) | | ( option_theme [ 0 ] = = ' \0 ' ) )
option_theme = ( char * ) strdup ( " Resources/Themes/Default " ) ;
Added ability to load toolbar images from a different path.
Default is still TBImages: (ie AISS, http://www.masonicons.de)
All of the following must be present, in any format that bitmap.image will load
(usually this means any picture.datatype subclasses):
home, home_g, home_s - Home button
nav_east, nav_east_g, nav_east_s - History forward
nav_west, nav_west_g, nav_west_s - History back
reload, reload_g, reload_s - Reload
stop, stop_g, stop_s - Stop
The _g and _s files are ghosted and selected versions respectively.
To set the path, use toolbar_images:<path> in Options.
svn path=/trunk/netsurf/; revision=5304
2008-09-12 01:32:55 +04:00
2008-10-26 15:25:26 +03:00
if ( ( ! option_arexx_dir ) | | ( option_arexx_dir [ 0 ] = = ' \0 ' ) )
option_arexx_dir = ( char * ) strdup ( " Rexx " ) ;
2008-08-18 23:07:12 +04:00
if ( ! option_window_width ) option_window_width = 800 ;
if ( ! option_window_height ) option_window_height = 600 ;
2009-01-16 23:05:21 +03:00
ami_init_fonts ( ) ;
2008-08-02 18:31:32 +04:00
plot = amiplot ;
2008-08-03 20:13:57 +04:00
2008-10-13 22:01:25 +04:00
/* AmiUpdate */
if ( ( ( lock = Lock ( " ENVARC:AppPaths " , SHARED_LOCK ) ) = = 0 ) )
{
lock = CreateDir ( " ENVARC:AppPaths " ) ;
}
UnLock ( lock ) ;
if ( lock = GetCurrentDir ( ) )
{
char filename [ 1024 ] ;
DevNameFromLock ( lock , ( STRPTR ) & filename , 1024L , DN_FULLPATH ) ;
amiupdatefh = FOpen ( " ENVARC:AppPaths/NetSurf " , MODE_NEWFILE , 0 ) ;
FPuts ( amiupdatefh , ( CONST_STRPTR ) & filename ) ;
FClose ( amiupdatefh ) ;
}
/* end Amiupdate */
2008-08-25 17:32:26 +04:00
ami_init_menulabs ( ) ;
2008-10-25 20:37:08 +04:00
if ( option_context_menu ) ami_context_menu_init ( ) ;
2008-08-25 17:32:26 +04:00
2008-08-03 20:13:57 +04:00
schedule_list = NewObjList ( ) ;
2008-08-09 19:19:04 +04:00
window_list = NewObjList ( ) ;
2008-08-25 17:32:26 +04:00
urldb_load ( option_url_file ) ;
2008-08-09 19:19:04 +04:00
urldb_load_cookies ( option_cookie_file ) ;
2008-10-13 22:01:25 +04:00
if ( lock = Lock ( option_hotlist_file , SHARED_LOCK ) )
{
UnLock ( lock ) ;
hotlist = options_load_tree ( option_hotlist_file ) ;
}
2008-08-03 20:13:57 +04:00
2008-08-24 01:56:49 +04:00
if ( ! hotlist ) ami_hotlist_init ( & hotlist ) ;
2008-10-12 01:38:04 +04:00
ami_global_history_initialise ( ) ;
ami_cookies_initialise ( ) ;
2008-11-09 02:08:55 +03:00
save_complete_init ( ) ;
2008-09-14 02:39:48 +04:00
2008-10-18 17:56:12 +04:00
strcpy ( & throbberfile , option_theme ) ;
AddPart ( & throbberfile , " Theme " , 100 ) ;
messages_load ( throbberfile ) ;
2008-12-14 02:25:42 +03:00
ami_init_mouse_pointers ( ) ;
2008-10-18 17:56:12 +04:00
ami_get_theme_filename ( & throbberfile , " theme_throbber " ) ;
throbber_frames = atoi ( messages_get ( " theme_throbber_frames " ) ) ;
if ( dto = NewDTObject ( throbberfile ,
2008-09-14 02:39:48 +04:00
DTA_GroupID , GID_PICTURE ,
PDTA_DestMode , PMODE_V43 ,
TAG_DONE ) )
{
struct BitMapHeader * throbber_bmh ;
struct RastPort throbber_rp ;
if ( GetDTAttrs ( dto , PDTA_BitMapHeader , & throbber_bmh , TAG_DONE ) )
{
2008-10-18 17:56:12 +04:00
throbber_width = throbber_bmh - > bmh_Width / throbber_frames ;
2008-09-14 02:39:48 +04:00
throbber_height = throbber_bmh - > bmh_Height ;
InitRastPort ( & throbber_rp ) ;
if ( throbber = p96AllocBitMap ( throbber_bmh - > bmh_Width ,
throbber_height , 32 ,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED ,
NULL , RGBFB_A8R8G8B8 ) )
{
struct RenderInfo ri ;
2008-11-02 03:21:49 +03:00
UBYTE * throbber_tempmem = AllocVec ( throbber_bmh - > bmh_Width * throbber_height * 4 , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-09-14 02:39:48 +04:00
throbber_rp . BitMap = throbber ;
ri . Memory = throbber_tempmem ;
ri . BytesPerRow = 4 * throbber_bmh - > bmh_Width ;
ri . RGBFormat = RGBFB_A8R8G8B8 ;
IDoMethod ( dto , PDTM_READPIXELARRAY , ri . Memory , PBPAFMT_ARGB , ri . BytesPerRow , 0 , 0 , throbber_bmh - > bmh_Width , throbber_height ) ;
p96WritePixelArray ( ( struct RenderInfo * ) & ri , 0 , 0 , & throbber_rp , 0 , 0 , throbber_bmh - > bmh_Width , throbber_height ) ;
FreeVec ( throbber_tempmem ) ;
}
}
DisposeDTObject ( dto ) ;
}
2008-08-02 18:31:32 +04:00
}
void gui_init2 ( int argc , char * * argv )
{
2008-11-16 17:42:40 +03:00
struct browser_window * bw = NULL ;
2008-08-18 23:07:12 +04:00
ULONG id ;
2008-09-29 02:50:13 +04:00
long rarray [ ] = { 0 } ;
struct RDArgs * args ;
STRPTR template = " URL/A " ;
2008-11-09 02:08:55 +03:00
STRPTR temp_homepage_url = NULL ;
2008-11-16 17:42:40 +03:00
BOOL notalreadyrunning ;
2008-09-29 02:50:13 +04:00
enum
{
A_URL
} ;
2008-08-02 18:31:32 +04:00
2008-11-16 17:42:40 +03:00
notalreadyrunning = ami_arexx_init ( ) ;
2008-11-15 18:28:17 +03:00
ami_fetch_file_register ( ) ;
2009-01-11 00:31:21 +03:00
ami_openurl_open ( ) ;
2008-11-15 18:28:17 +03:00
2008-11-16 17:42:40 +03:00
if ( notalreadyrunning )
2008-09-29 02:50:13 +04:00
{
2008-11-16 17:42:40 +03:00
if ( ( option_modeid ) & & ( option_modeid [ 0 ] ! = ' \0 ' ) )
2008-09-29 02:50:13 +04:00
{
2008-11-16 17:42:40 +03:00
id = strtoul ( option_modeid , NULL , 0 ) ;
2008-09-29 02:50:13 +04:00
}
2008-11-16 17:42:40 +03:00
else
{
2009-01-11 00:31:21 +03:00
struct ScreenModeRequester * screenmodereq = NULL ;
if ( screenmodereq = AllocAslRequest ( ASL_ScreenModeRequest , NULL ) )
{
AslRequestTags ( screenmodereq ,
ASLSM_MinDepth , 16 ,
ASLSM_MaxDepth , 32 ,
TAG_DONE ) ;
2008-08-18 23:07:12 +04:00
2009-01-11 00:31:21 +03:00
id = screenmodereq - > sm_DisplayID ;
option_modeid = malloc ( 20 ) ;
sprintf ( option_modeid , " 0x%lx " , id ) ;
FreeAslRequest ( screenmodereq ) ;
}
2008-11-16 17:42:40 +03:00
}
2008-08-18 23:07:12 +04:00
2009-01-11 00:31:21 +03:00
if ( ! option_use_pubscreen | | option_use_pubscreen [ 0 ] = = ' \0 ' )
2008-11-16 17:42:40 +03:00
{
scrn = OpenScreenTags ( NULL ,
2009-01-11 00:31:21 +03:00
// SA_Width,option_window_screen_width,
// SA_Height,option_window_screen_height,
// SA_Depth,option_screen_depth,
2008-08-18 23:07:12 +04:00
SA_DisplayID , id ,
2008-08-23 20:17:51 +04:00
SA_Title , nsscreentitle ,
2008-12-06 13:43:25 +03:00
SA_Type , CUSTOMSCREEN ,
SA_PubName , " NetSurf " ,
2008-08-09 02:38:13 +04:00
SA_LikeWorkbench , TRUE ,
TAG_DONE ) ;
2008-12-06 13:43:25 +03:00
2008-12-08 00:50:04 +03:00
if ( scrn )
{
PubScreenStatus ( scrn , 0 ) ;
}
else
{
if ( scrn = LockPubScreen ( " NetSurf " ) )
{
locked_screen = TRUE ;
}
else
{
2009-01-11 00:31:21 +03:00
option_use_pubscreen = " Workbench " ;
2008-12-08 00:50:04 +03:00
}
}
}
2009-01-11 00:31:21 +03:00
if ( option_use_pubscreen & & option_use_pubscreen [ 0 ] ! = ' \0 ' )
2008-12-08 00:50:04 +03:00
{
2009-01-11 00:31:21 +03:00
if ( scrn = LockPubScreen ( option_use_pubscreen ) )
{
locked_screen = TRUE ;
}
else
{
scrn = LockPubScreen ( " Workbench " ) ;
}
2008-11-16 17:42:40 +03:00
}
2008-08-09 02:38:13 +04:00
2008-12-28 15:35:55 +03:00
/* init shared bitmaps */
glob . bm = p96AllocBitMap ( scrn - > Width , scrn - > Height , 32 ,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED ,
scrn - > RastPort . BitMap , RGBFB_A8R8G8B8 ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
if ( ! glob . bm ) warn_user ( " NoMemory " , " " ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
InitRastPort ( & glob . rp ) ;
glob . rp . BitMap = glob . bm ;
SetDrMd ( & glob . rp , BGBACKFILL ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
glob . layerinfo = NewLayerInfo ( ) ;
glob . rp . Layer = CreateUpfrontLayer ( glob . layerinfo , glob . bm , 0 , 0 ,
scrn - > Width - 1 , scrn - > Height - 1 , 0 , NULL ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
glob . areabuf = AllocVec ( 100 , MEMF_PRIVATE | MEMF_CLEAR ) ;
glob . rp . AreaInfo = AllocVec ( sizeof ( struct AreaInfo ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
if ( ( ! glob . areabuf ) | | ( ! glob . rp . AreaInfo ) ) warn_user ( " NoMemory " , " " ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
InitArea ( glob . rp . AreaInfo , glob . areabuf , 100 / 5 ) ;
glob . rp . TmpRas = AllocVec ( sizeof ( struct TmpRas ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
glob . tmprasbuf = AllocVec ( scrn - > Width * scrn - > Height , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
if ( ( ! glob . tmprasbuf ) | | ( ! glob . rp . TmpRas ) ) warn_user ( " NoMemory " , " " ) ;
2008-12-26 22:04:57 +03:00
2008-12-28 15:35:55 +03:00
InitTmpRas ( glob . rp . TmpRas , glob . tmprasbuf , scrn - > Width * scrn - > Height ) ;
currp = & glob . rp ;
2008-12-28 15:24:18 +03:00
# ifdef NS_AMIGA_CAIRO
2008-12-28 15:35:55 +03:00
glob . surface = cairo_amigaos_surface_create ( glob . bm ) ;
glob . cr = cairo_create ( glob . surface ) ;
2008-12-28 15:24:18 +03:00
# endif
2008-12-28 15:35:55 +03:00
/* init shared bitmaps */
}
2008-12-26 22:04:57 +03:00
2008-11-16 17:42:40 +03:00
if ( argc ) // argc==0 is started from wb
2008-11-09 02:08:55 +03:00
{
2008-11-16 17:42:40 +03:00
if ( args = ReadArgs ( template , rarray , NULL ) )
{
if ( rarray [ A_URL ] )
{
temp_homepage_url = ( char * ) strdup ( rarray [ A_URL ] ) ;
if ( notalreadyrunning )
{
bw = browser_window_create ( temp_homepage_url , 0 , 0 , true , false ) ;
free ( temp_homepage_url ) ;
}
}
FreeArgs ( args ) ;
}
2008-11-09 02:08:55 +03:00
}
else
{
2008-11-16 17:42:40 +03:00
struct WBStartup * WBenchMsg = ( struct WBStartup * ) argv ;
struct WBArg * wbarg ;
int first = 0 , i = 0 ;
char fullpath [ 1024 ] ;
for ( i = 0 , wbarg = WBenchMsg - > sm_ArgList ; i < WBenchMsg - > sm_NumArgs ; i + + , wbarg + + )
{
if ( i = = 0 ) continue ;
if ( ( wbarg - > wa_Lock ) & & ( * wbarg - > wa_Name ) )
{
DevNameFromLock ( wbarg - > wa_Lock , & fullpath , 1024 , DN_FULLPATH ) ;
AddPart ( & fullpath , wbarg - > wa_Name , 1024 ) ;
if ( ! temp_homepage_url ) temp_homepage_url = path_to_url ( fullpath ) ;
if ( notalreadyrunning )
{
if ( ! first )
{
bw = browser_window_create ( temp_homepage_url , 0 , 0 , true , false ) ;
first = 1 ;
}
else
{
bw = browser_window_create ( temp_homepage_url , bw , 0 , true , false ) ;
}
free ( temp_homepage_url ) ;
temp_homepage_url = NULL ;
}
}
}
}
if ( ( ! option_homepage_url ) | | ( option_homepage_url [ 0 ] = = ' \0 ' ) )
option_homepage_url = ( char * ) strdup ( NETSURF_HOMEPAGE ) ;
if ( ! notalreadyrunning )
{
STRPTR sendcmd = NULL ;
if ( temp_homepage_url )
{
sendcmd = ASPrintf ( " OPEN \" %s \" NEW " , temp_homepage_url ) ;
free ( temp_homepage_url ) ;
}
else
{
sendcmd = ASPrintf ( " OPEN \" %s \" NEW " , option_homepage_url ) ;
}
IDoMethod ( arexx_obj , AM_EXECUTE , sendcmd , " NETSURF " , NULL , NULL , NULL , NULL ) ;
IDoMethod ( arexx_obj , AM_EXECUTE , " TOFRONT " , " NETSURF " , NULL , NULL , NULL , NULL ) ;
FreeVec ( sendcmd ) ;
netsurf_quit = true ;
return ;
2008-11-09 02:08:55 +03:00
}
2008-11-16 17:42:40 +03:00
if ( ! bw ) bw = browser_window_create ( option_homepage_url , 0 , 0 , true , false ) ;
2008-12-08 00:50:04 +03:00
if ( locked_screen ) UnlockPubScreen ( NULL , scrn ) ;
2008-08-02 18:31:32 +04:00
}
2009-01-11 00:31:21 +03:00
void ami_update_quals ( struct gui_window_2 * gwin )
{
2009-01-11 02:10:54 +03:00
uint32 quals = 0 ;
GetAttr ( WINDOW_Qualifier , gwin - > objects [ OID_MAIN ] , ( uint32 * ) & quals ) ;
2009-01-11 00:31:21 +03:00
gwin - > key_state = 0 ;
if ( ( quals & IEQUALIFIER_LSHIFT ) | | ( quals & IEQUALIFIER_RSHIFT ) )
{
gwin - > key_state | = BROWSER_MOUSE_MOD_1 ;
}
if ( quals & IEQUALIFIER_CONTROL )
{
gwin - > key_state | = BROWSER_MOUSE_MOD_2 ;
}
}
2008-09-05 02:41:26 +04:00
void ami_handle_msg ( void )
2008-08-02 18:31:32 +04:00
{
struct IntuiMessage * message = NULL ;
2008-08-19 22:31:56 +04:00
ULONG class , result , storage = 0 , x , y , xs , ys , width = 800 , height = 600 ;
2009-01-11 00:31:21 +03:00
uint16 code , quals ;
2008-08-11 21:53:45 +04:00
struct IBox * bbox ;
2008-08-09 19:19:04 +04:00
struct nsObject * node ;
struct nsObject * nnode ;
2008-10-05 03:29:17 +04:00
struct gui_window_2 * gwin , * destroywin = NULL ;
2008-08-19 22:31:56 +04:00
struct MenuItem * item ;
2008-09-28 17:55:40 +04:00
struct InputEvent * ie ;
2008-10-05 03:29:17 +04:00
struct Node * tabnode ;
2009-01-25 14:18:42 +03:00
UBYTE buffer [ 20 ] ;
int chars ;
2008-08-02 18:31:32 +04:00
2008-12-06 13:43:25 +03:00
if ( IsMinListEmpty ( window_list ) )
{
/* no windows in list, so NetSurf should not be running */
netsurf_quit = true ;
return ;
}
2008-10-06 22:20:16 +04:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
2008-08-02 18:31:32 +04:00
2008-10-06 22:20:16 +04:00
do
2008-08-09 02:38:13 +04:00
{
2008-10-06 22:20:16 +04:00
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
2008-08-09 19:19:04 +04:00
gwin = node - > objstruct ;
2008-09-28 17:55:40 +04:00
if ( node - > Type = = AMINS_TVWINDOW )
{
2008-10-05 03:29:17 +04:00
if ( ami_tree_event ( ( struct treeview_window * ) gwin ) )
2008-09-28 17:55:40 +04:00
{
2008-09-28 18:40:19 +04:00
if ( IsMinListEmpty ( window_list ) )
{
/* last window closed, so exit */
netsurf_quit = true ;
}
2008-09-28 17:55:40 +04:00
break ;
}
else
{
node = nnode ;
continue ;
}
}
2008-12-14 02:25:42 +03:00
else if ( node - > Type = = AMINS_FINDWINDOW )
{
if ( ami_search_event ( ) )
{
if ( IsMinListEmpty ( window_list ) )
{
/* last window closed, so exit */
netsurf_quit = true ;
}
break ;
}
else
{
node = nnode ;
continue ;
}
}
2008-09-28 17:55:40 +04:00
2008-08-09 19:19:04 +04:00
while ( ( result = RA_HandleInput ( gwin - > objects [ OID_MAIN ] , & code ) ) ! = WMHI_LASTMSG )
{
2008-08-09 02:38:13 +04:00
//printf("class %ld\n",class);
2008-08-09 19:19:04 +04:00
switch ( result & WMHI_CLASSMASK ) // class
2008-09-05 02:41:26 +04:00
{
2008-08-09 19:19:04 +04:00
case WMHI_MOUSEMOVE :
2008-09-29 02:50:13 +04:00
GetAttr ( SPACE_AreaBox , gwin - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-08-11 21:53:45 +04:00
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_HSCROLL ] , ( ULONG * ) & xs ) ;
2009-02-01 02:45:25 +03:00
x = gwin - > win - > MouseX - bbox - > Left + xs ; // mousex should be in intuimessage
2008-08-11 21:53:45 +04:00
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_VSCROLL ] , ( ULONG * ) & ys ) ;
2008-08-11 21:53:45 +04:00
y = gwin - > win - > MouseY - bbox - > Top + ys ;
2008-08-09 19:19:04 +04:00
2009-01-25 03:36:30 +03:00
x / = gwin - > bw - > scale ;
y / = gwin - > bw - > scale ;
2008-08-11 21:53:45 +04:00
width = bbox - > Width ;
height = bbox - > Height ;
2008-08-18 23:07:12 +04:00
2008-08-11 21:53:45 +04:00
if ( ( x > = xs ) & & ( y > = ys ) & & ( x < width + xs ) & & ( y < height + ys ) )
2008-08-09 19:19:04 +04:00
{
2009-01-11 02:10:54 +03:00
ami_update_quals ( gwin ) ;
2009-01-11 00:31:21 +03:00
2008-10-20 22:06:46 +04:00
if ( option_context_menu & & rmbtrapped = = FALSE )
{
2009-01-26 21:38:47 +03:00
SetWindowAttr ( gwin - > win , WA_RMBTrap , TRUE , 1 ) ;
rmbtrapped = TRUE ; // crash points to this line
2008-10-20 22:06:46 +04:00
}
2008-08-18 23:07:12 +04:00
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_1 )
{
2008-09-01 22:03:40 +04:00
browser_window_mouse_track ( gwin - > bw , BROWSER_MOUSE_DRAG_1 | gwin - > key_state , x , y ) ;
2008-08-18 23:07:12 +04:00
gwin - > mouse_state = BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON ;
}
else if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_2 )
{
2008-09-01 22:03:40 +04:00
browser_window_mouse_track ( gwin - > bw , BROWSER_MOUSE_DRAG_2 | gwin - > key_state , x , y ) ;
2008-08-18 23:07:12 +04:00
gwin - > mouse_state = BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON ;
}
else
{
2008-09-01 22:03:40 +04:00
browser_window_mouse_track ( gwin - > bw , gwin - > mouse_state | gwin - > key_state , x , y ) ;
2008-08-18 23:07:12 +04:00
}
2008-08-09 19:19:04 +04:00
}
2008-09-04 02:02:41 +04:00
else
{
2008-10-20 22:06:46 +04:00
if ( option_context_menu & & rmbtrapped = = TRUE )
{
2009-01-26 21:38:47 +03:00
SetWindowAttr ( gwin - > win , WA_RMBTrap , FALSE , 1 ) ;
2008-10-20 22:06:46 +04:00
rmbtrapped = FALSE ;
}
2008-10-05 03:29:17 +04:00
if ( ! gwin - > mouse_state ) ami_update_pointer ( gwin - > win , GUI_POINTER_DEFAULT ) ;
2008-09-04 02:02:41 +04:00
}
2008-08-09 19:19:04 +04:00
break ;
case WMHI_MOUSEBUTTONS :
2008-09-05 02:41:26 +04:00
GetAttr ( SPACE_AreaBox , gwin - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_HSCROLL ] , ( ULONG * ) & xs ) ;
2008-08-11 21:53:45 +04:00
x = gwin - > win - > MouseX - bbox - > Left + xs ;
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_VSCROLL ] , ( ULONG * ) & ys ) ;
2008-08-11 21:53:45 +04:00
y = gwin - > win - > MouseY - bbox - > Top + ys ;
2008-08-09 19:19:04 +04:00
2009-01-25 03:36:30 +03:00
x / = gwin - > bw - > scale ;
y / = gwin - > bw - > scale ;
2008-08-11 21:53:45 +04:00
width = bbox - > Width ;
height = bbox - > Height ;
2009-01-11 02:10:54 +03:00
ami_update_quals ( gwin ) ;
2009-01-11 00:31:21 +03:00
2008-08-11 21:53:45 +04:00
if ( ( x > = xs ) & & ( y > = ys ) & & ( x < width + xs ) & & ( y < height + ys ) )
2008-08-09 19:19:04 +04:00
{
2008-08-19 22:31:56 +04:00
//code = code>>16;
2008-08-09 19:19:04 +04:00
switch ( code )
{
case SELECTDOWN :
2008-09-01 22:03:40 +04:00
browser_window_mouse_click ( gwin - > bw , BROWSER_MOUSE_PRESS_1 | gwin - > key_state , x , y ) ;
2008-08-18 23:07:12 +04:00
gwin - > mouse_state = BROWSER_MOUSE_PRESS_1 ;
2008-08-09 19:19:04 +04:00
break ;
case MIDDLEDOWN :
2008-09-01 22:03:40 +04:00
browser_window_mouse_click ( gwin - > bw , BROWSER_MOUSE_PRESS_2 | gwin - > key_state , x , y ) ;
2008-08-18 23:07:12 +04:00
gwin - > mouse_state = BROWSER_MOUSE_PRESS_2 ;
2008-08-09 19:19:04 +04:00
break ;
2008-10-21 22:04:27 +04:00
case MENUDOWN :
2008-10-25 20:37:08 +04:00
if ( ! option_sticky_context_menu ) ami_context_menu_show ( gwin , x , y ) ;
break ;
case MENUUP :
if ( option_sticky_context_menu ) ami_context_menu_show ( gwin , x , y ) ;
2008-10-21 22:04:27 +04:00
break ;
2008-08-09 19:19:04 +04:00
}
}
2008-09-04 02:02:41 +04:00
if ( x < xs ) x = xs ;
if ( y < ys ) y = ys ;
if ( x > = width + xs ) x = width + xs - 1 ;
if ( y > = height + ys ) y = height + ys - 1 ;
switch ( code )
{
case SELECTUP :
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_1 )
{
browser_window_mouse_click ( gwin - > bw , BROWSER_MOUSE_CLICK_1 | gwin - > key_state , x , y ) ;
}
else
{
browser_window_mouse_drag_end ( gwin - > bw , 0 , x , y ) ;
}
gwin - > mouse_state = 0 ;
break ;
case MIDDLEUP :
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_2 )
{
browser_window_mouse_click ( gwin - > bw , BROWSER_MOUSE_CLICK_2 | gwin - > key_state , x , y ) ;
}
else
{
browser_window_mouse_drag_end ( gwin - > bw , 0 , x , y ) ;
}
gwin - > mouse_state = 0 ;
break ;
}
2008-08-09 19:19:04 +04:00
break ;
case WMHI_GADGETUP :
switch ( result & WMHI_GADGETMASK ) //gadaddr->GadgetID) //result & WMHI_GADGETMASK)
{
2008-10-05 03:29:17 +04:00
case GID_TABS :
2008-10-05 17:17:18 +04:00
ami_switch_tab ( gwin , true ) ;
2008-10-06 01:20:12 +04:00
break ;
2008-10-05 03:29:17 +04:00
2008-10-06 01:20:12 +04:00
case GID_CLOSETAB :
browser_window_destroy ( gwin - > bw ) ;
2008-10-05 03:29:17 +04:00
break ;
2008-08-09 19:19:04 +04:00
case GID_URL :
2008-09-29 02:50:13 +04:00
GetAttr ( STRINGA_TextVal , gwin - > gadgets [ GID_URL ] , ( ULONG * ) & storage ) ;
2008-08-10 00:27:36 +04:00
browser_window_go ( gwin - > bw , ( char * ) storage , NULL , true ) ;
2008-08-10 13:57:41 +04:00
//printf("%s\n",(char *)storage);
2008-08-09 19:19:04 +04:00
break ;
case GID_HOME :
2008-09-05 02:41:26 +04:00
browser_window_go ( gwin - > bw , option_homepage_url , NULL , true ) ;
2008-08-09 19:19:04 +04:00
break ;
case GID_STOP :
browser_window_stop ( gwin - > bw ) ;
break ;
case GID_RELOAD :
2009-01-11 02:10:54 +03:00
ami_update_quals ( gwin ) ;
2009-01-11 00:31:21 +03:00
2008-10-26 15:25:26 +03:00
if ( gwin - > key_state & BROWSER_MOUSE_MOD_1 )
{
browser_window_reload ( gwin - > bw , true ) ;
}
else
{
browser_window_reload ( gwin - > bw , false ) ;
}
2008-08-09 19:19:04 +04:00
break ;
2008-08-10 00:27:36 +04:00
case GID_BACK :
if ( history_back_available ( gwin - > bw - > history ) )
{
history_back ( gwin - > bw , gwin - > bw - > history ) ;
}
2008-09-05 02:41:26 +04:00
2008-08-10 00:27:36 +04:00
ami_update_buttons ( gwin ) ;
break ;
case GID_FORWARD :
if ( history_forward_available ( gwin - > bw - > history ) )
{
history_forward ( gwin - > bw , gwin - > bw - > history ) ;
}
ami_update_buttons ( gwin ) ;
break ;
2008-08-10 13:57:41 +04:00
2008-08-31 01:32:05 +04:00
case GID_LOGIN :
2008-09-05 02:41:26 +04:00
ami_401login_login ( ( struct gui_login_window * ) gwin ) ;
win_destroyed = true ;
2008-08-31 01:32:05 +04:00
break ;
case GID_CANCEL :
if ( gwin - > node - > Type = = AMINS_LOGINWINDOW )
{
ami_401login_close ( ( struct gui_login_window * ) gwin ) ;
win_destroyed = true ;
}
break ;
2008-08-10 13:57:41 +04:00
default :
2008-08-31 15:21:47 +04:00
// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
2008-08-10 13:57:41 +04:00
break ;
2008-08-09 19:19:04 +04:00
}
break ;
2008-08-19 22:31:56 +04:00
case WMHI_MENUPICK :
item = ItemAddress ( gwin - > win - > MenuStrip , code ) ;
while ( code ! = MENUNULL )
{
2008-10-15 02:43:02 +04:00
ami_menupick ( code , gwin , item ) ;
2008-08-25 17:32:26 +04:00
if ( win_destroyed ) break ;
2008-08-19 22:31:56 +04:00
code = item - > NextSelect ;
}
break ;
2008-08-25 17:32:26 +04:00
case WMHI_RAWKEY :
storage = result & WMHI_GADGETMASK ;
2008-09-28 17:55:40 +04:00
GetAttr ( WINDOW_InputEvent , gwin - > objects [ OID_MAIN ] , ( ULONG * ) & ie ) ;
2008-10-26 15:25:26 +03:00
2008-08-25 17:32:26 +04:00
switch ( storage )
{
case RAWKEY_CRSRUP :
2009-02-01 16:01:46 +03:00
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_PAGE_UP ) ;
}
else if ( ie - > ie_Qualifier & IEQUALIFIER_RALT )
{
browser_window_key_press ( gwin - > bw , KEY_TEXT_START ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_UP ) ;
2008-08-25 17:32:26 +04:00
break ;
case RAWKEY_CRSRDOWN :
2009-02-01 16:01:46 +03:00
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_PAGE_DOWN ) ;
}
else if ( ie - > ie_Qualifier & IEQUALIFIER_RALT )
{
browser_window_key_press ( gwin - > bw , KEY_TEXT_END ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_DOWN ) ;
2008-08-25 17:32:26 +04:00
break ;
case RAWKEY_CRSRLEFT :
2009-02-01 16:01:46 +03:00
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_LINE_START ) ;
}
else if ( ie - > ie_Qualifier & IEQUALIFIER_RALT )
{
browser_window_key_press ( gwin - > bw , KEY_WORD_LEFT ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_LEFT ) ;
2008-08-25 17:32:26 +04:00
break ;
case RAWKEY_CRSRRIGHT :
2009-02-01 16:01:46 +03:00
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_LINE_END ) ;
}
else if ( ie - > ie_Qualifier & IEQUALIFIER_RALT )
{
browser_window_key_press ( gwin - > bw , KEY_WORD_RIGHT ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_RIGHT ) ;
2008-08-25 17:32:26 +04:00
break ;
case RAWKEY_ESC :
2009-02-01 16:01:46 +03:00
browser_window_key_press ( gwin - > bw , KEY_ESCAPE ) ;
break ;
case RAWKEY_PAGEUP :
browser_window_key_press ( gwin - > bw , KEY_PAGE_UP ) ;
break ;
case RAWKEY_PAGEDOWN :
browser_window_key_press ( gwin - > bw , KEY_PAGE_DOWN ) ;
break ;
case RAWKEY_HOME :
browser_window_key_press ( gwin - > bw , KEY_TEXT_START ) ;
break ;
case RAWKEY_END :
browser_window_key_press ( gwin - > bw , KEY_TEXT_END ) ;
break ;
case RAWKEY_BACKSPACE :
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_DELETE_LINE_START ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_DELETE_LEFT ) ;
break ;
case RAWKEY_DEL :
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_DELETE_LINE_END ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_DELETE_RIGHT ) ;
break ;
case RAWKEY_TAB :
if ( ie - > ie_Qualifier & IEQUALIFIER_RSHIFT )
{
browser_window_key_press ( gwin - > bw , KEY_SHIFT_TAB ) ;
}
else browser_window_key_press ( gwin - > bw , KEY_TAB ) ;
2008-08-25 17:32:26 +04:00
break ;
2008-10-26 15:25:26 +03:00
default :
2009-01-25 14:18:42 +03:00
if ( ( chars = MapRawKey ( ie , buffer , 20 , NULL ) ) > 0 )
2009-01-25 03:36:30 +03:00
{
if ( ie - > ie_Qualifier & IEQUALIFIER_RCOMMAND )
{
/* We are duplicating the menu shortcuts here, as if RMBTRAP is active
* ( ie . when context menus are enabled and the mouse is over the browser
* rendering area ) , Intuition also does not catch the menu shortcut
2009-02-01 16:01:46 +03:00
* key presses . Context menus need to be changed to use MENUVERIFY not RMBTRAP */
2009-01-25 03:36:30 +03:00
switch ( buffer [ 0 ] )
{
case ' c ' :
2009-02-01 16:01:46 +03:00
browser_window_key_press ( gwin - > bw , KEY_COPY_SELECTION ) ;
browser_window_key_press ( gwin - > bw , KEY_ESCAPE ) ;
2009-01-25 03:36:30 +03:00
break ;
case ' v ' :
2009-02-01 16:01:46 +03:00
browser_window_key_press ( gwin - > bw , KEY_PASTE ) ;
2009-01-25 03:36:30 +03:00
break ;
}
}
else
{
browser_window_key_press ( gwin - > bw , buffer [ 0 ] ) ;
}
}
2008-10-26 15:25:26 +03:00
break ;
2008-08-25 17:32:26 +04:00
}
break ;
2008-08-11 21:53:45 +04:00
case WMHI_NEWSIZE :
2008-09-28 00:55:11 +04:00
switch ( node - > Type )
{
case AMINS_WINDOW :
2008-11-02 03:21:49 +03:00
ami_update_throbber ( gwin , true ) ;
// fall through
2008-09-28 00:55:11 +04:00
case AMINS_FRAME :
GetAttr ( SPACE_AreaBox , gwin - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
browser_window_reformat ( gwin - > bw , bbox - > Width , bbox - > Height ) ;
gwin - > redraw_required = true ;
break ;
}
2008-08-11 21:53:45 +04:00
break ;
2008-08-19 22:31:56 +04:00
case WMHI_CLOSEWINDOW :
2008-10-06 11:07:33 +04:00
ami_close_all_tabs ( gwin ) ;
2008-09-05 02:41:26 +04:00
break ;
2008-10-26 02:22:34 +03:00
case WMHI_ACTIVE :
curbw = gwin - > bw ;
break ;
2008-09-05 02:41:26 +04:00
case WMHI_INTUITICK :
2008-09-08 22:14:14 +04:00
break ;
2008-08-09 19:19:04 +04:00
2008-09-05 02:41:26 +04:00
default :
// printf("class: %ld\n",(result & WMHI_CLASSMASK));
break ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 13:57:41 +04:00
2008-08-22 01:41:42 +04:00
if ( win_destroyed )
{
2008-09-05 02:41:26 +04:00
/* we can't be sure what state our window_list is in, so let's
2008-08-22 01:41:42 +04:00
jump out of the function and start again */
win_destroyed = false ;
return ;
}
2008-08-10 13:57:41 +04:00
2008-08-22 01:41:42 +04:00
// ReplyMsg((struct Message *)message);
2008-08-02 18:31:32 +04:00
}
2008-08-10 13:57:41 +04:00
2009-01-11 00:31:21 +03:00
if ( ( node - > Type = = AMINS_WINDOW ) | | ( node - > Type = = AMINS_FRAME ) )
{
2009-02-05 15:20:23 +03:00
if ( gwin - > redraw_required )
ami_do_redraw ( gwin , false ) ;
2008-08-17 20:22:40 +04:00
2009-01-11 00:31:21 +03:00
if ( gwin - > throbber_frame )
ami_update_throbber ( gwin , false ) ;
2008-09-14 02:39:48 +04:00
2008-10-19 15:33:05 +04:00
if ( gwin - > bw - > window - > c_h )
{
// struct gui_window tgw;
// tgw.shared = gwin;
gui_window_place_caret ( gwin - > bw - > window , gwin - > bw - > window - > c_x , gwin - > bw - > window - > c_y , gwin - > bw - > window - > c_h ) ;
}
2008-10-05 03:29:17 +04:00
}
2008-10-06 22:20:16 +04:00
} while ( node = nnode ) ;
2008-09-05 02:41:26 +04:00
}
void ami_handle_appmsg ( void )
{
struct AppMessage * appmsg ;
2008-10-05 03:29:17 +04:00
struct gui_window_2 * gwin ;
2008-09-07 19:58:11 +04:00
struct IBox * bbox ;
ULONG x , y , xs , ys , width , height , len ;
struct WBArg * appwinargs ;
STRPTR filename ;
struct box * box , * file_box = 0 , * text_box = 0 ;
struct content * content ;
int box_x = 0 , box_y = 0 ;
BPTR fh = 0 ;
char * utf8text , * urlfilename ;
2008-09-04 02:02:41 +04:00
2008-09-05 02:41:26 +04:00
while ( appmsg = ( struct AppMessage * ) GetMsg ( appport ) )
2008-09-04 02:02:41 +04:00
{
2008-09-29 02:50:13 +04:00
GetAttr ( WINDOW_UserData , ( struct Window * ) appmsg - > am_ID , ( ULONG * ) & gwin ) ;
2008-09-07 19:58:11 +04:00
2008-09-05 02:41:26 +04:00
if ( appmsg - > am_Type = = AMTYPE_APPWINDOW )
2008-09-07 19:58:11 +04:00
{
2008-09-29 02:50:13 +04:00
GetAttr ( SPACE_AreaBox , gwin - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-09-05 02:41:26 +04:00
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_HSCROLL ] , ( ULONG * ) & xs ) ;
2008-09-07 19:58:11 +04:00
x = ( appmsg - > am_MouseX ) - ( bbox - > Left ) + xs ;
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , gwin - > objects [ OID_VSCROLL ] , ( ULONG * ) & ys ) ;
2008-09-07 19:58:11 +04:00
y = appmsg - > am_MouseY - bbox - > Top + ys ;
width = bbox - > Width ;
height = bbox - > Height ;
if ( appwinargs = appmsg - > am_ArgList )
2008-09-05 02:41:26 +04:00
{
2008-11-02 03:21:49 +03:00
if ( filename = AllocVec ( 1024 , MEMF_PRIVATE | MEMF_CLEAR ) )
2008-09-07 19:58:11 +04:00
{
if ( appwinargs - > wa_Lock )
{
NameFromLock ( appwinargs - > wa_Lock , filename , 1024 ) ;
}
AddPart ( filename , appwinargs - > wa_Name , 1024 ) ;
if ( ( ! gwin - > bw - > current_content | | gwin - > bw - > current_content - > type ! = CONTENT_HTML ) | | ( ! ( ( x > = xs ) & & ( y > = ys ) & & ( x < width + xs ) & & ( y < height + ys ) ) ) )
{
urlfilename = path_to_url ( filename ) ;
browser_window_go ( gwin - > bw , urlfilename , NULL , true ) ;
free ( urlfilename ) ;
}
else
{
content = gwin - > bw - > current_content ;
box = content - > data . html . layout ;
while ( ( box = box_at_point ( box , x , y , & box_x , & box_y , & content ) ) )
{
if ( box - > style & & box - > style - > visibility = = CSS_VISIBILITY_HIDDEN ) continue ;
if ( box - > gadget )
{
switch ( box - > gadget - > type )
{
case GADGET_FILE :
file_box = box ;
break ;
case GADGET_TEXTBOX :
case GADGET_TEXTAREA :
case GADGET_PASSWORD :
text_box = box ;
break ;
default :
break ;
}
}
}
if ( ! file_box & & ! text_box )
2008-09-29 02:50:13 +04:00
return ;
2008-09-07 19:58:11 +04:00
if ( file_box )
{
utf8_convert_ret ret ;
char * utf8_fn ;
if ( utf8_from_local_encoding ( filename , 0 , & utf8_fn ) ! = UTF8_CONVERT_OK )
{
2008-09-29 02:50:13 +04:00
warn_user ( " NoMemory " , " " ) ;
2008-09-07 19:58:11 +04:00
return ;
}
free ( file_box - > gadget - > value ) ;
file_box - > gadget - > value = utf8_fn ;
2008-09-29 02:50:13 +04:00
box_coords ( file_box , ( int * ) & x , ( int * ) & y ) ;
2008-09-07 19:58:11 +04:00
gui_window_redraw ( gwin - > bw - > window , x , y ,
x + file_box - > width ,
y + file_box - > height ) ;
}
else
{
browser_window_mouse_click ( gwin - > bw , BROWSER_MOUSE_PRESS_1 , x , y ) ;
2008-09-08 22:14:14 +04:00
/* This bit pastes a plain text file into a form. Really we should be using
Datatypes for this to support more formats */
2008-09-07 19:58:11 +04:00
if ( fh = FOpen ( filename , MODE_OLDFILE , 0 ) )
{
while ( len = FRead ( fh , filename , 1 , 1024 ) )
{
if ( utf8_from_local_encoding ( filename , len , & utf8text ) = = UTF8_CONVERT_OK )
{
browser_window_paste_text ( gwin - > bw , utf8text , strlen ( utf8text ) , true ) ;
free ( utf8text ) ;
}
}
FClose ( fh ) ;
}
}
}
FreeVec ( filename ) ;
}
2008-09-05 02:41:26 +04:00
}
}
2008-09-04 02:02:41 +04:00
ReplyMsg ( ( struct Message * ) appmsg ) ;
2008-09-08 22:14:14 +04:00
if ( gwin - > redraw_required )
2009-01-11 00:31:21 +03:00
ami_do_redraw ( gwin , false ) ;
2008-09-04 02:02:41 +04:00
}
2008-08-02 18:31:32 +04:00
}
2008-09-05 02:41:26 +04:00
void ami_get_msg ( void )
2008-08-02 18:31:32 +04:00
{
2008-09-05 02:41:26 +04:00
ULONG winsignal = 1L < < sport - > mp_SigBit ;
ULONG appsig = 1L < < appport - > mp_SigBit ;
2008-09-08 22:14:14 +04:00
ULONG schedulesig = 1L < < msgport - > mp_SigBit ;
2008-09-29 23:35:30 +04:00
ULONG signalmask = winsignal | appsig | schedulesig | rxsig ;
2008-09-05 02:41:26 +04:00
ULONG signal ;
2008-09-08 22:14:14 +04:00
struct Message * timermsg = NULL ;
2008-08-02 18:31:32 +04:00
2008-09-05 02:41:26 +04:00
signal = Wait ( signalmask ) ;
2008-08-02 18:31:32 +04:00
2008-09-05 02:41:26 +04:00
if ( signal & winsignal )
{
ami_handle_msg ( ) ;
}
else if ( signal & appsig )
{
ami_handle_appmsg ( ) ;
}
2008-09-29 23:35:30 +04:00
else if ( signal & rxsig )
{
ami_arexx_handle ( ) ;
}
2008-09-08 22:14:14 +04:00
else if ( signal & schedulesig )
{
while ( GetMsg ( msgport ) )
schedule_run ( ) ;
}
2008-09-05 02:41:26 +04:00
}
2008-08-02 18:31:32 +04:00
2008-09-05 02:41:26 +04:00
void gui_multitask ( void )
{
/* This seems a bit topsy-turvy to me, but in this function, NetSurf is doing
stuff and we need to poll for user events */
2008-08-02 18:31:32 +04:00
2008-09-05 02:41:26 +04:00
ami_handle_msg ( ) ;
ami_handle_appmsg ( ) ;
2008-11-02 03:21:49 +03:00
ami_arexx_handle ( ) ;
2008-08-02 18:31:32 +04:00
}
void gui_poll ( bool active )
{
2008-09-05 02:41:26 +04:00
/* However, down here we are waiting for the user to do something or for a
2008-09-08 22:14:14 +04:00
scheduled event to kick in ( scheduled events are signalled using
timer . device , but NetSurf seems to still be wanting to run code . We ask
Intuition to send IDCMP_INTUITICKS messages every 1 / 10 s to our active
window to break us out of ami_get_msg to stop NetSurf stalling ( the active
variable seems to have no real bearing on reality , but is supposed to
indicate that NetSurf wants control back ASAP , so we poll in that case ) .
schedule_run checks every event , really they need to be sorted so only
the first event needs to be run on each signal . */
if ( active )
{
gui_multitask ( ) ;
schedule_run ( ) ;
}
else
{
ami_get_msg ( ) ;
2008-09-14 02:53:38 +04:00
schedule_run ( ) ; // run on intuitick
2008-09-08 22:14:14 +04:00
}
2008-08-02 18:31:32 +04:00
}
2008-10-05 17:17:18 +04:00
void ami_switch_tab ( struct gui_window_2 * gwin , bool redraw )
{
struct Node * tabnode ;
if ( gwin - > tabs = = 0 ) return ;
2008-11-09 02:08:55 +03:00
gui_window_get_scroll ( gwin - > bw - > window , & gwin - > bw - > window - > scrollx , & gwin - > bw - > window - > scrolly ) ;
2008-10-05 17:17:18 +04:00
GetAttr ( CLICKTAB_CurrentNode , gwin - > gadgets [ GID_TABS ] , ( ULONG * ) & tabnode ) ;
GetClickTabNodeAttrs ( tabnode ,
TNA_UserData , & gwin - > bw ,
TAG_DONE ) ;
2008-10-26 02:22:34 +03:00
curbw = gwin - > bw ;
2008-10-05 17:17:18 +04:00
ami_update_buttons ( gwin ) ;
if ( redraw )
{
2008-12-14 02:25:42 +03:00
struct IBox * bbox ;
GetAttr ( SPACE_AreaBox , gwin - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2009-01-17 19:13:56 +03:00
p96RectFill ( gwin - > win - > RPort , bbox - > Left , bbox - > Top , bbox - > Width + bbox - > Left , bbox - > Height + bbox - > Top , 0xffffffff ) ;
2008-12-14 02:25:42 +03:00
2008-10-05 17:17:18 +04:00
browser_window_update ( gwin - > bw , false ) ;
2008-11-09 17:02:04 +03:00
if ( ( gwin - > bw - > window - > scrollx ) | | ( gwin - > bw - > window - > scrolly ) )
{
gui_window_set_scroll ( gwin - > bw - > window , gwin - > bw - > window - > scrollx , gwin - > bw - > window - > scrolly ) ;
}
2008-10-19 15:33:05 +04:00
if ( gwin - > bw - > current_content )
gui_window_set_url ( gwin - > bw - > window , gwin - > bw - > current_content - > url ) ;
2008-10-05 17:17:18 +04:00
}
}
2008-10-06 21:47:31 +04:00
void ami_quit_netsurf ( void )
{
struct nsObject * node ;
struct nsObject * nnode ;
struct gui_window_2 * gwin ;
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do
{
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
switch ( node - > Type )
{
case AMINS_TVWINDOW :
ami_tree_close ( ( struct treeview_window * ) gwin ) ;
break ;
case AMINS_WINDOW :
ami_close_all_tabs ( gwin ) ;
break ;
}
node = nnode ;
} while ( node = nnode ) ;
if ( IsMinListEmpty ( window_list ) )
{
/* last window closed, so exit */
netsurf_quit = true ;
}
}
2008-08-02 18:31:32 +04:00
void gui_quit ( void )
{
2008-08-31 21:34:00 +04:00
int i ;
2008-09-14 02:39:48 +04:00
p96FreeBitMap ( throbber ) ;
2008-09-11 23:33:40 +04:00
2008-08-25 17:32:26 +04:00
urldb_save ( option_url_file ) ;
2008-08-09 19:19:04 +04:00
urldb_save_cookies ( option_cookie_file ) ;
2008-08-25 17:32:26 +04:00
options_save_tree ( hotlist , option_hotlist_file , messages_get ( " TreeHotlist " ) ) ;
2008-10-12 01:38:04 +04:00
void ami_global_history_save ( ) ;
ami_cookies_free ( ) ;
ami_global_history_free ( ) ;
2008-08-09 19:19:04 +04:00
2008-08-15 21:19:57 +04:00
# ifdef WITH_HUBBUB
hubbub_finalise ( myrealloc , NULL ) ;
# endif
2008-12-08 00:50:04 +03:00
ami_arexx_cleanup ( ) ;
2008-12-28 15:24:18 +03:00
# ifdef NS_AMIGA_CAIRO
cairo_destroy ( glob . cr ) ;
cairo_surface_destroy ( glob . surface ) ;
# endif
2008-12-26 22:04:57 +03:00
DeleteLayer ( 0 , glob . rp . Layer ) ;
DisposeLayerInfo ( glob . layerinfo ) ;
p96FreeBitMap ( glob . bm ) ;
FreeVec ( glob . rp . TmpRas ) ;
FreeVec ( glob . rp . AreaInfo ) ;
FreeVec ( glob . tmprasbuf ) ;
FreeVec ( glob . areabuf ) ;
2009-01-16 23:05:21 +03:00
ami_close_fonts ( ) ;
2008-12-08 00:50:04 +03:00
if ( ! locked_screen ) /* set if we are using somebody else's screen */
{
while ( ! CloseScreen ( scrn ) ) ;
}
2009-02-14 15:29:07 +03:00
else
{
/* have a go at closing the public screen, apparently this is OK to do */
CloseScreen ( scrn ) ;
}
2008-12-26 22:04:57 +03:00
2008-08-23 20:17:51 +04:00
FreeVec ( nsscreentitle ) ;
2008-10-25 20:37:08 +04:00
if ( option_context_menu ) ami_context_menu_free ( ) ;
2008-08-25 17:32:26 +04:00
ami_free_menulabs ( ) ;
2008-08-31 21:34:00 +04:00
for ( i = 0 ; i < = AMI_LASTPOINTER ; i + + )
{
if ( mouseptrbm [ i ] )
{
FreeRaster ( mouseptrbm [ i ] - > Planes [ 0 ] , 16 , 16 ) ;
FreeRaster ( mouseptrbm [ i ] - > Planes [ 1 ] , 16 , 16 ) ;
FreeVec ( mouseptrbm [ i ] ) ;
}
}
2008-10-25 20:37:08 +04:00
ami_clipboard_free ( ) ;
2008-08-22 01:41:42 +04:00
2008-09-04 02:02:41 +04:00
FreeSysObject ( ASOT_PORT , appport ) ;
2008-09-05 02:41:26 +04:00
FreeSysObject ( ASOT_PORT , sport ) ;
2008-09-04 02:02:41 +04:00
2008-08-22 01:41:42 +04:00
FreeAslRequest ( filereq ) ;
2009-01-11 00:31:21 +03:00
FreeAslRequest ( savereq ) ;
ami_openurl_close ( ) ;
2008-08-09 02:38:13 +04:00
2008-08-18 23:07:12 +04:00
if ( IPopupMenu ) DropInterface ( ( struct Interface * ) IPopupMenu ) ;
if ( PopupMenuBase ) CloseLibrary ( PopupMenuBase ) ;
2008-10-26 15:25:26 +03:00
if ( IKeymap ) DropInterface ( ( struct Interface * ) IKeymap ) ;
if ( KeymapBase ) CloseLibrary ( KeymapBase ) ;
2008-08-03 20:13:57 +04:00
if ( ITimer )
{
DropInterface ( ( struct Interface * ) ITimer ) ;
}
CloseDevice ( ( struct IORequest * ) tioreq ) ;
FreeSysObject ( ASOT_IOREQUEST , tioreq ) ;
FreeSysObject ( ASOT_PORT , msgport ) ;
FreeObjList ( schedule_list ) ;
2008-08-10 00:27:36 +04:00
FreeObjList ( window_list ) ;
}
2008-10-05 03:29:17 +04:00
void ami_update_buttons ( struct gui_window_2 * gwin )
2008-08-10 00:27:36 +04:00
{
2008-10-06 11:07:33 +04:00
bool back = FALSE , forward = TRUE , tabclose = FALSE ;
2008-08-10 00:27:36 +04:00
if ( ! history_back_available ( gwin - > bw - > history ) )
{
back = TRUE ;
}
if ( history_forward_available ( gwin - > bw - > history ) )
{
forward = FALSE ;
}
2008-10-06 11:07:33 +04:00
if ( gwin - > tabs < = 1 )
{
tabclose = TRUE ;
}
2008-08-10 00:27:36 +04:00
RefreshSetGadgetAttrs ( gwin - > gadgets [ GID_BACK ] , gwin - > win , NULL ,
GA_Disabled , back ,
TAG_DONE ) ;
RefreshSetGadgetAttrs ( gwin - > gadgets [ GID_FORWARD ] , gwin - > win , NULL ,
GA_Disabled , forward ,
TAG_DONE ) ;
2008-10-06 11:07:33 +04:00
if ( gwin - > tabs )
{
RefreshSetGadgetAttrs ( gwin - > gadgets [ GID_CLOSETAB ] , gwin - > win , NULL ,
GA_Disabled , tabclose ,
TAG_DONE ) ;
}
2008-08-19 22:31:56 +04:00
}
2008-10-18 17:56:12 +04:00
void ami_get_theme_filename ( char * filename , char * themestring )
{
if ( messages_get ( themestring ) [ 0 ] = = ' * ' ) strncpy ( filename , messages_get ( themestring ) + 1 , 100 ) ;
else
{
strcpy ( filename , option_theme ) ;
AddPart ( filename , messages_get ( themestring ) , 100 ) ;
}
}
2008-08-02 18:31:32 +04:00
struct gui_window * gui_create_browser_window ( struct browser_window * bw ,
2008-08-24 21:17:33 +04:00
struct browser_window * clone , bool new_tab )
2008-08-02 18:31:32 +04:00
{
2008-08-25 17:32:26 +04:00
struct NewMenu * menu ;
2008-08-02 18:31:32 +04:00
struct gui_window * gwin = NULL ;
2008-08-10 00:27:36 +04:00
bool closegadg = TRUE ;
2008-10-05 03:29:17 +04:00
struct Node * node ;
2008-09-04 02:02:41 +04:00
ULONG curx = option_window_x , cury = option_window_y , curw = option_window_width , curh = option_window_height ;
Added ability to load toolbar images from a different path.
Default is still TBImages: (ie AISS, http://www.masonicons.de)
All of the following must be present, in any format that bitmap.image will load
(usually this means any picture.datatype subclasses):
home, home_g, home_s - Home button
nav_east, nav_east_g, nav_east_s - History forward
nav_west, nav_west_g, nav_west_s - History back
reload, reload_g, reload_s - Reload
stop, stop_g, stop_s - Stop
The _g and _s files are ghosted and selected versions respectively.
To set the path, use toolbar_images:<path> in Options.
svn path=/trunk/netsurf/; revision=5304
2008-09-12 01:32:55 +04:00
char nav_west [ 100 ] , nav_west_s [ 100 ] , nav_west_g [ 100 ] ;
char nav_east [ 100 ] , nav_east_s [ 100 ] , nav_east_g [ 100 ] ;
char stop [ 100 ] , stop_s [ 100 ] , stop_g [ 100 ] ;
char reload [ 100 ] , reload_s [ 100 ] , reload_g [ 100 ] ;
char home [ 100 ] , home_s [ 100 ] , home_g [ 100 ] ;
2009-02-18 23:04:59 +03:00
char closetab [ 100 ] , closetab_s [ 100 ] , closetab_g [ 100 ] ;
2008-09-04 02:02:41 +04:00
2008-11-15 18:28:17 +03:00
if ( ( bw - > browser_window_type = = BROWSER_WINDOW_IFRAME ) & & option_no_iframes ) return NULL ;
2008-10-05 18:22:02 +04:00
if ( option_kiosk_mode ) new_tab = false ;
2009-02-07 19:40:56 +03:00
bw - > scale = 1.0 ;
2008-10-05 18:22:02 +04:00
2008-09-04 02:02:41 +04:00
if ( clone )
{
if ( clone - > window )
{
2008-10-05 03:29:17 +04:00
curx = clone - > window - > shared - > win - > LeftEdge ;
cury = clone - > window - > shared - > win - > TopEdge ;
curw = clone - > window - > shared - > win - > Width ;
curh = clone - > window - > shared - > win - > Height ;
2008-09-04 02:02:41 +04:00
}
}
2008-11-02 03:21:49 +03:00
gwin = AllocVec ( sizeof ( struct gui_window ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-08-09 02:38:13 +04:00
2008-08-02 18:31:32 +04:00
if ( ! gwin )
{
2008-09-29 02:50:13 +04:00
warn_user ( " NoMemory " , " " ) ;
2008-08-31 01:32:05 +04:00
return NULL ;
2008-08-02 18:31:32 +04:00
}
2008-11-15 18:28:17 +03:00
/*
if ( bw - > browser_window_type = = BROWSER_WINDOW_IFRAME )
{
gwin - > shared = bw - > parent - > window - > shared ;
gwin - > bw = bw ;
return gwin ;
}
*/
2008-10-05 17:17:18 +04:00
if ( new_tab & & clone & & ( bw - > browser_window_type = = BROWSER_WINDOW_NORMAL ) )
2008-10-05 03:29:17 +04:00
{
gwin - > shared = clone - > window - > shared ;
2008-10-06 01:20:12 +04:00
gwin - > tab = gwin - > shared - > next_tab ;
2008-08-31 01:32:05 +04:00
2008-10-05 03:29:17 +04:00
SetGadgetAttrs ( gwin - > shared - > gadgets [ GID_TABS ] , gwin - > shared - > win , NULL ,
CLICKTAB_Labels , ~ 0 ,
TAG_DONE ) ;
gwin - > tab_node = AllocClickTabNode ( TNA_Text , messages_get ( " NetSurf " ) ,
2008-10-06 01:20:12 +04:00
TNA_Number , gwin - > tab ,
2008-10-05 03:29:17 +04:00
TNA_UserData , bw ,
TAG_DONE ) ;
AddTail ( & gwin - > shared - > tab_list , gwin - > tab_node ) ;
RefreshSetGadgetAttrs ( gwin - > shared - > gadgets [ GID_TABS ] , gwin - > shared - > win , NULL ,
CLICKTAB_Labels , & gwin - > shared - > tab_list ,
TAG_DONE ) ;
2008-10-05 17:17:18 +04:00
if ( option_new_tab_active )
{
RefreshSetGadgetAttrs ( gwin - > shared - > gadgets [ GID_TABS ] , gwin - > shared - > win , NULL ,
2008-10-06 01:20:12 +04:00
CLICKTAB_Current , gwin - > tab ,
2008-10-05 17:17:18 +04:00
TAG_DONE ) ;
}
RethinkLayout ( gwin - > shared - > gadgets [ GID_TABLAYOUT ] , gwin - > shared - > win , NULL , TRUE ) ;
2008-10-05 03:29:17 +04:00
gwin - > shared - > tabs + + ;
2008-10-05 17:17:18 +04:00
gwin - > shared - > next_tab + + ;
if ( option_new_tab_active ) ami_switch_tab ( gwin - > shared , false ) ;
2008-10-05 03:29:17 +04:00
2008-11-09 02:08:55 +03:00
ami_update_buttons ( gwin - > shared ) ;
2008-10-05 03:29:17 +04:00
return gwin ;
}
2008-11-02 03:21:49 +03:00
gwin - > shared = AllocVec ( sizeof ( struct gui_window_2 ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-10-05 03:29:17 +04:00
if ( ! gwin - > shared )
{
warn_user ( " NoMemory " , " " ) ;
return NULL ;
}
gwin - > shared - > scrollerhook . h_Entry = ami_scroller_hook ;
2008-10-12 01:38:04 +04:00
gwin - > shared - > scrollerhook . h_Data = gwin - > shared ;
2008-08-25 17:32:26 +04:00
2008-08-09 19:19:04 +04:00
switch ( bw - > browser_window_type )
{
2008-08-25 17:32:26 +04:00
case BROWSER_WINDOW_IFRAME :
2008-08-09 19:19:04 +04:00
case BROWSER_WINDOW_FRAMESET :
case BROWSER_WINDOW_FRAME :
2008-10-05 17:17:18 +04:00
gwin - > tab = 0 ;
gwin - > shared - > tabs = 0 ;
gwin - > tab_node = NULL ;
gwin - > shared - > objects [ OID_MAIN ] = WindowObject ,
2008-08-23 20:17:51 +04:00
WA_ScreenTitle , nsscreentitle ,
2008-08-28 02:19:25 +04:00
// WA_Title, messages_get("NetSurf"),
2008-08-25 17:32:26 +04:00
WA_Activate , FALSE ,
2008-08-11 21:53:45 +04:00
WA_DepthGadget , TRUE ,
WA_DragBar , TRUE ,
WA_CloseGadget , FALSE ,
2008-09-04 02:02:41 +04:00
WA_Top , cury ,
WA_Left , curx ,
WA_Width , curw ,
WA_Height , curh ,
2008-08-11 21:53:45 +04:00
WA_SizeGadget , TRUE ,
WA_CustomScreen , scrn ,
WA_ReportMouse , TRUE ,
WA_IDCMP , IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS |
2009-01-25 03:36:30 +03:00
IDCMP_NEWSIZE | IDCMP_RAWKEY | IDCMP_GADGETUP |
IDCMP_IDCMPUPDATE | IDCMP_INTUITICKS | IDCMP_EXTENDEDMOUSE ,
2008-08-11 21:53:45 +04:00
// WINDOW_IconifyGadget, TRUE,
2008-10-05 17:17:18 +04:00
// WINDOW_NewMenu,menu,
2008-08-11 21:53:45 +04:00
WINDOW_HorizProp , 1 ,
WINDOW_VertProp , 1 ,
2008-10-05 03:29:17 +04:00
WINDOW_IDCMPHook , & gwin - > shared - > scrollerhook ,
2008-09-04 02:02:41 +04:00
WINDOW_IDCMPHookBits , IDCMP_IDCMPUPDATE ,
WINDOW_AppPort , appport ,
WINDOW_AppWindow , TRUE ,
2008-12-28 15:24:18 +03:00
WINDOW_BuiltInScroll , TRUE ,
2008-09-05 02:41:26 +04:00
WINDOW_SharedPort , sport ,
2008-10-05 03:29:17 +04:00
WINDOW_UserData , gwin - > shared ,
2008-08-18 23:07:12 +04:00
// WINDOW_Position, WPOS_CENTERSCREEN,
2008-08-15 21:19:57 +04:00
// WINDOW_CharSet,106,
2008-10-05 03:29:17 +04:00
WINDOW_ParentGroup , gwin - > shared - > gadgets [ GID_MAIN ] = VGroupObject ,
2008-08-15 21:19:57 +04:00
// LAYOUT_CharSet,106,
2008-08-11 21:53:45 +04:00
LAYOUT_SpaceOuter , TRUE ,
2008-10-05 03:29:17 +04:00
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_BROWSER ] = SpaceObject ,
2008-08-11 21:53:45 +04:00
GA_ID , GID_BROWSER ,
2008-08-15 21:19:57 +04:00
/*
2008-08-11 21:53:45 +04:00
GA_RelVerify , TRUE ,
GA_Immediate , TRUE ,
GA_FollowMouse , TRUE ,
2008-08-15 21:19:57 +04:00
*/
2008-08-11 21:53:45 +04:00
SpaceEnd ,
EndGroup ,
EndWindow ;
2008-08-10 00:27:36 +04:00
break ;
2008-08-09 19:19:04 +04:00
case BROWSER_WINDOW_NORMAL :
2008-10-05 18:22:02 +04:00
if ( ! option_kiosk_mode )
{
menu = ami_create_menu ( bw - > browser_window_type ) ;
NewList ( & gwin - > shared - > tab_list ) ;
gwin - > tab_node = AllocClickTabNode ( TNA_Text , messages_get ( " NetSurf " ) ,
TNA_Number , 0 ,
TNA_UserData , bw ,
TAG_DONE ) ;
AddTail ( & gwin - > shared - > tab_list , gwin - > tab_node ) ;
gwin - > shared - > tabs = 1 ;
gwin - > shared - > next_tab = 1 ;
2008-10-18 17:56:12 +04:00
ami_get_theme_filename ( nav_west , " theme_nav_west " ) ;
ami_get_theme_filename ( nav_west_s , " theme_nav_west_s " ) ;
ami_get_theme_filename ( nav_west_g , " theme_nav_west_g " ) ;
ami_get_theme_filename ( nav_east , " theme_nav_east " ) ;
ami_get_theme_filename ( nav_east_s , " theme_nav_east_s " ) ;
ami_get_theme_filename ( nav_east_g , " theme_nav_east_g " ) ;
ami_get_theme_filename ( stop , " theme_stop " ) ;
ami_get_theme_filename ( stop_s , " theme_stop_s " ) ;
ami_get_theme_filename ( stop_g , " theme_stop_g " ) ;
ami_get_theme_filename ( reload , " theme_reload " ) ;
ami_get_theme_filename ( reload_s , " theme_reload_s " ) ;
ami_get_theme_filename ( reload_g , " theme_reload_g " ) ;
ami_get_theme_filename ( home , " theme_home " ) ;
ami_get_theme_filename ( home_s , " theme_home_s " ) ;
ami_get_theme_filename ( home_g , " theme_home_g " ) ;
ami_get_theme_filename ( closetab , " theme_closetab " ) ;
2009-02-18 23:04:59 +03:00
ami_get_theme_filename ( closetab_s , " theme_closetab_s " ) ;
ami_get_theme_filename ( closetab_g , " theme_closetab_g " ) ;
2008-10-05 18:22:02 +04:00
gwin - > shared - > objects [ OID_MAIN ] = WindowObject ,
WA_ScreenTitle , nsscreentitle ,
// WA_Title, messages_get("NetSurf"),
WA_Activate , TRUE ,
WA_DepthGadget , TRUE ,
WA_DragBar , TRUE ,
WA_CloseGadget , TRUE ,
WA_SizeGadget , TRUE ,
WA_Top , cury ,
WA_Left , curx ,
WA_Width , curw ,
WA_Height , curh ,
WA_CustomScreen , scrn ,
WA_ReportMouse , TRUE ,
WA_IDCMP , IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
2009-01-25 03:36:30 +03:00
IDCMP_RAWKEY |
2008-10-05 18:22:02 +04:00
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
2008-12-28 15:24:18 +03:00
IDCMP_INTUITICKS | IDCMP_ACTIVEWINDOW |
IDCMP_EXTENDEDMOUSE ,
2008-10-05 18:22:02 +04:00
// WINDOW_IconifyGadget, TRUE,
WINDOW_NewMenu , menu ,
WINDOW_HorizProp , 1 ,
WINDOW_VertProp , 1 ,
WINDOW_IDCMPHook , & gwin - > shared - > scrollerhook ,
WINDOW_IDCMPHookBits , IDCMP_IDCMPUPDATE ,
WINDOW_AppPort , appport ,
WINDOW_AppWindow , TRUE ,
WINDOW_SharedPort , sport ,
2008-12-28 15:24:18 +03:00
WINDOW_BuiltInScroll , TRUE ,
2008-10-05 18:22:02 +04:00
WINDOW_UserData , gwin - > shared ,
// WINDOW_Position, WPOS_CENTERSCREEN,
// WINDOW_CharSet,106,
WINDOW_ParentGroup , gwin - > shared - > gadgets [ GID_MAIN ] = VGroupObject ,
// LAYOUT_CharSet,106,
LAYOUT_SpaceOuter , TRUE ,
LAYOUT_AddChild , HGroupObject ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_BACK ] = ButtonObject ,
GA_ID , GID_BACK ,
GA_RelVerify , TRUE ,
GA_Disabled , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , nav_west ,
BITMAP_SelectSourceFile , nav_west_s ,
BITMAP_DisabledSourceFile , nav_west_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_FORWARD ] = ButtonObject ,
GA_ID , GID_FORWARD ,
GA_RelVerify , TRUE ,
GA_Disabled , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , nav_east ,
BITMAP_SelectSourceFile , nav_east_s ,
BITMAP_DisabledSourceFile , nav_east_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_STOP ] = ButtonObject ,
GA_ID , GID_STOP ,
GA_RelVerify , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , stop ,
BITMAP_SelectSourceFile , stop_s ,
BITMAP_DisabledSourceFile , stop_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_RELOAD ] = ButtonObject ,
GA_ID , GID_RELOAD ,
GA_RelVerify , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , reload ,
BITMAP_SelectSourceFile , reload_s ,
BITMAP_DisabledSourceFile , reload_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_HOME ] = ButtonObject ,
GA_ID , GID_HOME ,
GA_RelVerify , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , home ,
BITMAP_SelectSourceFile , home_s ,
BITMAP_DisabledSourceFile , home_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_URL ] = StringObject ,
GA_ID , GID_URL ,
GA_RelVerify , TRUE ,
StringEnd ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_THROBBER ] = SpaceObject ,
GA_ID , GID_THROBBER ,
SPACE_MinWidth , throbber_width ,
SPACE_MinHeight , throbber_height ,
SpaceEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LayoutEnd ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_TABLAYOUT ] = HGroupObject ,
2008-10-06 01:20:12 +04:00
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_CLOSETAB ] = ButtonObject ,
GA_ID , GID_CLOSETAB ,
GA_RelVerify , TRUE ,
BUTTON_Transparent , TRUE ,
BUTTON_RenderImage , BitMapObject ,
BITMAP_SourceFile , closetab ,
2009-02-18 23:04:59 +03:00
BITMAP_SelectSourceFile , closetab_s ,
BITMAP_DisabledSourceFile , closetab_g ,
2008-10-06 01:20:12 +04:00
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2008-10-05 18:22:02 +04:00
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_TABS ] = ClickTabObject ,
GA_ID , GID_TABS ,
GA_RelVerify , TRUE ,
2009-02-01 16:26:21 +03:00
GA_Underscore , 13 , // disable kb shortcuts
2008-10-05 18:22:02 +04:00
CLICKTAB_Labels , & gwin - > shared - > tab_list ,
CLICKTAB_LabelTruncate , TRUE ,
ClickTabEnd ,
CHILD_CacheDomain , FALSE ,
LayoutEnd ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_BROWSER ] = SpaceObject ,
GA_ID , GID_BROWSER ,
SpaceEnd ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_STATUS ] = StringObject ,
GA_ID , GID_STATUS ,
GA_ReadOnly , TRUE ,
StringEnd ,
CHILD_WeightedHeight , 0 ,
EndGroup ,
EndWindow ;
}
else
{
/* borderless kiosk mode window */
gwin - > tab = 0 ;
gwin - > shared - > tabs = 0 ;
gwin - > tab_node = NULL ;
gwin - > shared - > objects [ OID_MAIN ] = WindowObject ,
WA_ScreenTitle , nsscreentitle ,
WA_Activate , TRUE ,
WA_DepthGadget , FALSE ,
WA_DragBar , FALSE ,
WA_CloseGadget , FALSE ,
WA_Borderless , TRUE ,
WA_RMBTrap , TRUE ,
WA_Top , 0 ,
WA_Left , 0 ,
2009-01-11 00:31:21 +03:00
WA_Width , option_window_width ,
WA_Height , option_window_height ,
2008-10-05 18:22:02 +04:00
WA_SizeGadget , FALSE ,
WA_CustomScreen , scrn ,
WA_ReportMouse , TRUE ,
WA_IDCMP , IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
2009-01-25 03:36:30 +03:00
IDCMP_RAWKEY |
2008-10-05 18:22:02 +04:00
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
2008-12-28 15:24:18 +03:00
IDCMP_INTUITICKS | IDCMP_EXTENDEDMOUSE ,
2008-10-05 18:22:02 +04:00
WINDOW_HorizProp , 1 ,
WINDOW_VertProp , 1 ,
WINDOW_IDCMPHook , & gwin - > shared - > scrollerhook ,
WINDOW_IDCMPHookBits , IDCMP_IDCMPUPDATE ,
WINDOW_AppPort , appport ,
WINDOW_AppWindow , TRUE ,
WINDOW_SharedPort , sport ,
WINDOW_UserData , gwin - > shared ,
2008-12-28 15:24:18 +03:00
WINDOW_BuiltInScroll , TRUE ,
2008-10-05 18:22:02 +04:00
WINDOW_ParentGroup , gwin - > shared - > gadgets [ GID_MAIN ] = VGroupObject ,
LAYOUT_SpaceOuter , TRUE ,
LAYOUT_AddChild , gwin - > shared - > gadgets [ GID_BROWSER ] = SpaceObject ,
GA_ID , GID_BROWSER ,
SpaceEnd ,
EndGroup ,
EndWindow ;
}
2008-08-11 21:53:45 +04:00
break ;
}
2008-10-05 03:29:17 +04:00
gwin - > shared - > win = ( struct Window * ) RA_OpenWindow ( gwin - > shared - > objects [ OID_MAIN ] ) ;
2008-08-10 13:57:41 +04:00
2008-10-05 03:29:17 +04:00
if ( ! gwin - > shared - > win )
2008-08-31 01:32:05 +04:00
{
2008-09-29 02:50:13 +04:00
warn_user ( " NoMemory " , " " ) ;
2008-10-05 03:29:17 +04:00
FreeVec ( gwin - > shared ) ;
2008-08-31 01:32:05 +04:00
FreeVec ( gwin ) ;
return NULL ;
}
2008-10-05 03:29:17 +04:00
gwin - > shared - > bw = bw ;
2008-12-26 22:04:57 +03:00
//currp = &glob.rp; // WINDOW.CLASS: &gwin->rp; //gwin->win->RPort;
2008-08-30 20:57:35 +04:00
2008-09-11 23:33:40 +04:00
// GetRPAttrs(&gwin->rp,RPTAG_Font,&origrpfont,TAG_DONE);
// ami_tte_setdefaults(&gwin->rp,gwin->win);
2008-08-17 20:22:40 +04:00
2008-10-05 03:29:17 +04:00
GetAttr ( WINDOW_HorizObject , gwin - > shared - > objects [ OID_MAIN ] , ( ULONG * ) & gwin - > shared - > objects [ OID_HSCROLL ] ) ;
GetAttr ( WINDOW_VertObject , gwin - > shared - > objects [ OID_MAIN ] , ( ULONG * ) & gwin - > shared - > objects [ OID_VSCROLL ] ) ;
2008-08-10 13:57:41 +04:00
2008-10-05 03:29:17 +04:00
RefreshSetGadgetAttrs ( ( APTR ) gwin - > shared - > objects [ OID_VSCROLL ] , gwin - > shared - > win , NULL ,
2008-08-10 13:57:41 +04:00
GA_ID , OID_VSCROLL ,
2008-08-11 21:53:45 +04:00
ICA_TARGET , ICTARGET_IDCMP ,
TAG_DONE ) ;
2008-10-05 03:29:17 +04:00
RefreshSetGadgetAttrs ( ( APTR ) gwin - > shared - > objects [ OID_HSCROLL ] , gwin - > shared - > win , NULL ,
2008-08-11 21:53:45 +04:00
GA_ID , OID_HSCROLL ,
ICA_TARGET , ICTARGET_IDCMP ,
2008-08-10 13:57:41 +04:00
TAG_DONE ) ;
2008-08-10 00:27:36 +04:00
2008-10-26 02:22:34 +03:00
curbw = bw ;
2008-10-05 03:29:17 +04:00
gwin - > shared - > node = AddObject ( window_list , AMINS_WINDOW ) ;
gwin - > shared - > node - > objstruct = gwin - > shared ;
2008-08-02 18:31:32 +04:00
return gwin ;
}
2008-10-06 11:07:33 +04:00
void ami_close_all_tabs ( struct gui_window_2 * gwin )
{
struct Node * tab ;
struct Node * ntab ;
if ( gwin - > tabs )
{
tab = GetHead ( & gwin - > tab_list ) ;
2008-10-06 22:20:16 +04:00
do
2008-10-06 11:07:33 +04:00
{
2008-10-06 22:20:16 +04:00
ntab = GetSucc ( tab ) ;
2008-10-06 11:07:33 +04:00
GetClickTabNodeAttrs ( tab ,
TNA_UserData , & gwin - > bw ,
TAG_DONE ) ;
browser_window_destroy ( gwin - > bw ) ;
2008-10-06 22:20:16 +04:00
} while ( tab = ntab ) ;
2008-10-06 11:07:33 +04:00
}
else
{
browser_window_destroy ( gwin - > bw ) ;
}
}
2008-08-02 18:31:32 +04:00
void gui_window_destroy ( struct gui_window * g )
{
2008-10-05 17:17:18 +04:00
struct Node * ptab ;
ULONG ptabnum ;
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2009-01-11 01:57:23 +03:00
// if(g->shared->searchwin)
// if(g->shared->searchwin->gwin == g) ami_search_close();
2008-10-05 03:29:17 +04:00
if ( g - > shared - > tabs > 1 )
{
2008-10-05 17:17:18 +04:00
SetGadgetAttrs ( g - > shared - > gadgets [ GID_TABS ] , g - > shared - > win , NULL ,
CLICKTAB_Labels , ~ 0 ,
TAG_DONE ) ;
2008-10-06 01:20:12 +04:00
ptab = GetSucc ( g - > tab_node ) ;
if ( ! ptab ) ptab = GetPred ( g - > tab_node ) ;
2008-10-05 17:17:18 +04:00
GetClickTabNodeAttrs ( ptab , TNA_Number , ( ULONG * ) & ptabnum , TAG_DONE ) ;
Remove ( g - > tab_node ) ;
FreeClickTabNode ( g - > tab_node ) ;
RefreshSetGadgetAttrs ( g - > shared - > gadgets [ GID_TABS ] , g - > shared - > win , NULL ,
CLICKTAB_Labels , & g - > shared - > tab_list ,
CLICKTAB_Current , ptabnum ,
TAG_DONE ) ;
RethinkLayout ( g - > shared - > gadgets [ GID_TABLAYOUT ] , g - > shared - > win , NULL , TRUE ) ;
2008-10-05 03:29:17 +04:00
g - > shared - > tabs - - ;
2008-10-05 17:17:18 +04:00
ami_switch_tab ( g - > shared , true ) ;
FreeVec ( g ) ;
2008-10-05 03:29:17 +04:00
return ;
}
2008-10-26 02:22:34 +03:00
curbw = NULL ;
2008-10-05 03:29:17 +04:00
DisposeObject ( g - > shared - > objects [ OID_MAIN ] ) ;
DelObject ( g - > shared - > node ) ;
2008-10-05 17:17:18 +04:00
if ( g - > tab_node )
{
Remove ( g - > tab_node ) ;
FreeClickTabNode ( g - > tab_node ) ;
}
FreeVec ( g ) ; // g->shared should be freed by DelObject()
2008-08-09 19:19:04 +04:00
if ( IsMinListEmpty ( window_list ) )
{
/* last window closed, so exit */
2008-08-25 17:32:26 +04:00
netsurf_quit = true ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 13:57:41 +04:00
win_destroyed = true ;
2008-08-02 18:31:32 +04:00
}
void gui_window_set_title ( struct gui_window * g , const char * title )
{
2008-10-05 03:29:17 +04:00
struct Node * node ;
2008-10-05 17:17:18 +04:00
ULONG cur_tab = 0 ;
2009-02-01 16:26:21 +03:00
STRPTR newtitle = NULL ;
2008-10-19 15:33:05 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-05 03:29:17 +04:00
if ( g - > tab_node )
{
node = g - > tab_node ;
2008-10-19 15:33:05 +04:00
2008-10-05 03:29:17 +04:00
SetGadgetAttrs ( g - > shared - > gadgets [ GID_TABS ] , g - > shared - > win , NULL ,
CLICKTAB_Labels , ~ 0 ,
TAG_DONE ) ;
2009-02-01 16:26:21 +03:00
newtitle = ami_utf8_easy ( title ) ;
2009-02-01 16:30:47 +03:00
SetClickTabNodeAttrs ( node , TNA_Text , newtitle , TAG_DONE ) ;
2009-02-01 16:26:21 +03:00
if ( newtitle ) ami_utf8_free ( newtitle ) ;
2008-10-05 03:29:17 +04:00
RefreshSetGadgetAttrs ( g - > shared - > gadgets [ GID_TABS ] , g - > shared - > win , NULL ,
CLICKTAB_Labels , & g - > shared - > tab_list ,
TAG_DONE ) ;
2008-10-05 17:17:18 +04:00
RethinkLayout ( g - > shared - > gadgets [ GID_TABLAYOUT ] , g - > shared - > win , NULL , TRUE ) ;
2008-10-05 03:29:17 +04:00
GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
}
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
if ( g - > shared - > win - > Title ) ami_utf8_free ( g - > shared - > win - > Title ) ;
SetWindowTitles ( g - > shared - > win , ami_utf8_easy ( title ) , nsscreentitle ) ;
}
2008-08-02 18:31:32 +04:00
}
2009-02-02 01:54:31 +03:00
void ami_do_redraw_limits ( struct gui_window * g , struct content * c , int x0 , int y0 , int x1 , int y1 )
2008-08-02 18:31:32 +04:00
{
2009-02-01 02:45:25 +03:00
ULONG hcurrent , vcurrent , xoffset , yoffset , width = 800 , height = 600 ;
struct IBox * bbox ;
ULONG cur_tab = 0 ;
if ( ! g ) return ;
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
if ( ! ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) ) )
{
return ;
}
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_HSCROLL ] , ( ULONG * ) & hcurrent ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_VSCROLL ] , ( ULONG * ) & vcurrent ) ;
if ( ! c ) return ;
if ( c - > locked ) return ;
current_redraw_browser = g - > shared - > bw ;
width = bbox - > Width ;
height = bbox - > Height ;
2009-02-02 00:28:59 +03:00
xoffset = bbox - > Left ;
yoffset = bbox - > Top ;
2009-02-01 02:45:25 +03:00
plot = amiplot ;
2009-02-07 19:40:56 +03:00
//DebugPrintF("%ld %ld %ld %ld old\n%ld %ld %ld %ld x0-xc etc\n",x0,y0,x1,y1,x0-hcurrent,y0-vcurrent,width+x0,height+y0);
2009-02-04 21:10:10 +03:00
2009-02-10 21:53:17 +03:00
if ( ( ( y1 - y0 ) + ( yoffset + y0 - vcurrent ) < 0 ) | | ( ( y0 - ( int ) vcurrent ) > height ) ) return ;
if ( ( ( x1 - x0 ) + ( xoffset + x0 - hcurrent ) < 0 ) | | ( ( x0 - ( int ) hcurrent ) > width ) ) return ;
2009-02-07 19:40:56 +03:00
if ( ( x0 - ( int ) hcurrent ) < 0 ) x0 = hcurrent ;
if ( ( y0 - ( int ) vcurrent ) < 0 ) y0 = vcurrent ;
if ( ( x1 - x0 ) + ( xoffset + x0 - hcurrent ) > ( width ) ) x1 = ( width - ( x0 - hcurrent ) + x0 ) ;
if ( ( y1 - y0 ) + ( yoffset + y0 - vcurrent ) > ( height ) ) y1 = ( height - ( y0 - vcurrent ) + y0 ) ;
2009-02-04 21:10:10 +03:00
2009-02-01 02:45:25 +03:00
content_redraw ( c ,
2009-02-04 21:10:10 +03:00
- hcurrent , - vcurrent , width - hcurrent , height - vcurrent ,
2009-02-02 00:28:59 +03:00
floorf ( ( x0 *
g - > shared - > bw - > scale ) - hcurrent ) ,
ceilf ( ( y0 *
g - > shared - > bw - > scale ) - vcurrent ) ,
( x1 *
2009-02-07 19:40:56 +03:00
g - > shared - > bw - > scale ) - hcurrent ,
2009-02-02 00:28:59 +03:00
( y1 *
2009-02-07 19:40:56 +03:00
g - > shared - > bw - > scale ) - vcurrent ,
2009-02-01 02:45:25 +03:00
g - > shared - > bw - > scale ,
0xFFFFFF ) ;
current_redraw_browser = NULL ;
2009-02-05 15:20:23 +03:00
// ami_update_buttons(g->shared);
2009-02-01 02:45:25 +03:00
2009-02-02 00:28:59 +03:00
BltBitMapRastPort ( glob . bm , x0 - hcurrent , y0 - vcurrent , g - > shared - > win - > RPort , xoffset + x0 - hcurrent , yoffset + y0 - vcurrent , x1 - x0 , y1 - y0 , 0x0C0 ) ;
2009-02-07 19:40:56 +03:00
/*
DebugPrintF ( " %ld %ld %ld %ld draw area \n %ld %ld %ld %ld clip rect \n %ld %ld bitmap src \n %ld %ld %ld %ld bitmap dest \n \n " , - hcurrent , - vcurrent , width - hcurrent , height - vcurrent ,
( ULONG ) floorf ( ( x0 *
g - > shared - > bw - > scale ) - ( int ) hcurrent ) ,
( ULONG ) ceilf ( ( y0 *
g - > shared - > bw - > scale ) - ( int ) vcurrent ) ,
( ULONG ) x1 - hcurrent ,
( ULONG ) y1 - vcurrent , x0 - hcurrent , y0 - vcurrent , xoffset + x0 - hcurrent , yoffset + y0 - vcurrent , x1 - x0 , y1 - y0 ) ;
*/
2008-08-02 18:31:32 +04:00
}
2009-02-02 01:54:31 +03:00
void gui_window_redraw ( struct gui_window * g , int x0 , int y0 , int x1 , int y1 )
{
struct content * c ;
c = g - > shared - > bw - > current_content ;
ami_do_redraw_limits ( g , c , x0 , y0 , x1 , y1 ) ;
}
2008-08-02 18:31:32 +04:00
void gui_window_redraw_window ( struct gui_window * g )
2008-08-15 21:19:57 +04:00
{
2008-10-05 18:22:02 +04:00
ULONG cur_tab = 0 ;
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-05 18:22:02 +04:00
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
g - > shared - > redraw_required = true ;
g - > shared - > redraw_data = NULL ;
}
2008-08-15 21:19:57 +04:00
}
void gui_window_update_box ( struct gui_window * g ,
const union content_msg_data * data )
{
2009-02-08 13:12:27 +03:00
ami_do_redraw_limits ( g , g - > shared - > bw - > current_content ,
2009-02-02 01:54:31 +03:00
data - > redraw . x , data - > redraw . y ,
data - > redraw . width + data - > redraw . x ,
data - > redraw . height + data - > redraw . y ) ;
2008-08-15 21:19:57 +04:00
}
2009-01-11 00:31:21 +03:00
void ami_do_redraw ( struct gui_window_2 * g , bool scroll )
2008-08-02 18:31:32 +04:00
{
2008-08-30 20:57:35 +04:00
struct Region * reg = NULL ;
struct Rectangle rect ;
2008-08-07 22:44:28 +04:00
struct content * c ;
2008-08-11 21:53:45 +04:00
ULONG hcurrent , vcurrent , xoffset , yoffset , width = 800 , height = 600 ;
struct IBox * bbox ;
2009-01-11 00:31:21 +03:00
ULONG oldh = g - > oldh , oldv = g - > oldv ;
2008-08-09 19:19:04 +04:00
2008-08-11 21:53:45 +04:00
GetAttr ( SPACE_AreaBox , g - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-09-29 02:50:13 +04:00
GetAttr ( SCROLLER_Top , g - > objects [ OID_HSCROLL ] , ( ULONG * ) & hcurrent ) ;
GetAttr ( SCROLLER_Top , g - > objects [ OID_VSCROLL ] , ( ULONG * ) & vcurrent ) ;
2008-08-07 22:44:28 +04:00
2008-08-30 20:57:35 +04:00
// DebugPrintF("DOING REDRAW\n");
2008-08-07 22:44:28 +04:00
c = g - > bw - > current_content ;
2008-08-10 00:27:36 +04:00
if ( ! c ) return ;
2008-08-18 23:07:12 +04:00
if ( c - > locked ) return ;
2008-08-10 00:27:36 +04:00
2008-08-07 22:44:28 +04:00
current_redraw_browser = g - > bw ;
2009-01-11 00:31:21 +03:00
// currp = &glob.rp;
2008-08-30 20:57:35 +04:00
2008-08-11 21:53:45 +04:00
width = bbox - > Width ;
height = bbox - > Height ;
xoffset = bbox - > Left ;
yoffset = bbox - > Top ;
2008-08-26 05:20:01 +04:00
plot = amiplot ;
2008-08-10 00:27:36 +04:00
// if (c->type == CONTENT_HTML) scale = 1;
2009-02-02 01:54:31 +03:00
if ( scroll & & c - > type = = CONTENT_HTML )
2009-01-11 00:31:21 +03:00
{
2009-02-02 01:54:31 +03:00
ScrollWindowRaster ( g - > win , hcurrent - oldh , vcurrent - oldv , xoffset , yoffset , xoffset + width , yoffset + height ) ;
2009-02-02 00:28:59 +03:00
2009-02-07 19:40:56 +03:00
if ( ( vcurrent - oldv ) > 0 )
2009-02-05 15:20:23 +03:00
{
2009-02-07 19:40:56 +03:00
ami_do_redraw_limits ( g - > bw - > window , c , 0 , height - ( vcurrent - oldv ) , width , ( vcurrent - oldv ) ) ;
// BltBitMapRastPort(glob.bm,0,vcurrent-oldv,g->win->RPort,xoffset,yoffset+(vcurrent-oldv),width,height-(vcurrent-oldv),0x0C0); // this shouldn't be needed but the blit in ami_do_redraw_limits isn't working in this instance
2009-02-05 15:20:23 +03:00
}
2009-02-07 19:40:56 +03:00
else if ( ( vcurrent - oldv ) < 0 )
2009-02-05 15:20:23 +03:00
{
ami_do_redraw_limits ( g - > bw - > window , c , 0 , 0 , width , oldv - vcurrent ) ;
}
2009-02-02 00:28:59 +03:00
2009-02-07 19:40:56 +03:00
if ( ( hcurrent - oldh ) > 0 )
2009-02-05 15:20:23 +03:00
{
2009-02-07 19:40:56 +03:00
ami_do_redraw_limits ( g - > bw - > window , c , width - ( hcurrent - oldh ) , 0 , ( hcurrent - oldh ) , height ) ;
// BltBitMapRastPort(glob.bm,vcurrent-oldv,0,g->win->RPort,xoffset+(hcurrent-oldh),yoffset,width-(hcurrent-oldh),height,0x0C0); // this shouldn't be needed but the blit in ami_do_redraw_limits isn't working in this instance
2009-02-05 15:20:23 +03:00
}
2009-02-07 19:40:56 +03:00
else if ( ( hcurrent - oldh ) < 0 )
2009-02-05 15:20:23 +03:00
{
ami_do_redraw_limits ( g - > bw - > window , c , 0 , 0 , oldh - hcurrent , height ) ;
}
2008-08-15 21:19:57 +04:00
}
else
{
2009-02-02 01:54:31 +03:00
ami_clg ( 0xffffff ) ;
2009-02-01 02:45:25 +03:00
2009-02-04 21:10:10 +03:00
if ( c - > type = = CONTENT_HTML )
{
content_redraw ( c , - hcurrent /* * g->bw->scale */ ,
2009-01-15 23:03:15 +03:00
- vcurrent /* * g->bw->scale */ ,
2009-02-04 21:10:10 +03:00
width - hcurrent /* * g->bw->scale */ ,
height - vcurrent /* * g->bw->scale */ ,
0 , 0 , width /* * g->bw->scale */ ,
2009-02-02 01:54:31 +03:00
height /* * g->bw->scale */ ,
2009-02-04 21:10:10 +03:00
g - > bw - > scale , 0xFFFFFF ) ;
}
else
{
content_redraw ( c , - hcurrent /* * g->bw->scale */ ,
- vcurrent /* * g->bw->scale */ ,
width - hcurrent /* * g->bw->scale */ ,
height - vcurrent /* * g->bw->scale */ ,
2009-01-15 23:03:15 +03:00
0 , 0 , c - > width /* * g->bw->scale */ ,
c - > height /* * g->bw->scale */ ,
g - > bw - > scale , 0xFFFFFF ) ;
2009-02-04 21:10:10 +03:00
}
2009-02-02 01:54:31 +03:00
2009-02-02 00:28:59 +03:00
BltBitMapRastPort ( glob . bm , 0 , 0 , g - > win - > RPort , xoffset , yoffset , width , height , 0x0C0 ) ;
2009-01-15 23:03:15 +03:00
}
2008-08-10 00:27:36 +04:00
2009-01-15 23:03:15 +03:00
current_redraw_browser = NULL ;
2008-08-15 21:19:57 +04:00
2009-01-15 23:03:15 +03:00
ami_update_buttons ( g ) ;
2008-08-11 21:53:45 +04:00
2009-01-11 00:31:21 +03:00
g - > oldh = hcurrent ;
g - > oldv = vcurrent ;
2008-08-30 20:57:35 +04:00
2008-08-15 21:19:57 +04:00
g - > redraw_required = false ;
g - > redraw_data = NULL ;
2008-08-02 18:31:32 +04:00
}
bool gui_window_get_scroll ( struct gui_window * g , int * sx , int * sy )
{
2008-10-05 03:29:17 +04:00
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_HSCROLL ] , ( ULONG * ) sx ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_VSCROLL ] , ( ULONG * ) sy ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_set_scroll ( struct gui_window * g , int sx , int sy )
{
2008-10-06 01:20:12 +04:00
ULONG cur_tab = 0 ;
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-06 21:47:31 +04:00
if ( sx < 0 ) sx = 0 ;
if ( sy < 0 ) sy = 0 ;
2009-01-25 03:36:30 +03:00
if ( ! g - > shared - > bw | | ! g - > shared - > bw - > current_content ) return ;
2008-12-14 02:25:42 +03:00
if ( sx > g - > shared - > bw - > current_content - > width ) sx = g - > shared - > bw - > current_content - > width ;
if ( sy > g - > shared - > bw - > current_content - > height ) sy = g - > shared - > bw - > current_content - > height ;
2008-10-06 21:47:31 +04:00
2008-10-06 01:20:12 +04:00
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
2008-08-31 01:32:05 +04:00
2008-10-06 01:20:12 +04:00
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
RefreshSetGadgetAttrs ( ( APTR ) g - > shared - > objects [ OID_VSCROLL ] , g - > shared - > win , NULL ,
SCROLLER_Top , sy ,
TAG_DONE ) ;
2008-08-09 19:19:04 +04:00
2008-10-06 01:20:12 +04:00
RefreshSetGadgetAttrs ( ( APTR ) g - > shared - > objects [ OID_HSCROLL ] , g - > shared - > win , NULL ,
SCROLLER_Top , sx ,
TAG_DONE ) ;
2008-08-19 22:31:56 +04:00
2008-10-06 01:20:12 +04:00
g - > shared - > redraw_required = true ;
g - > shared - > redraw_data = NULL ;
2008-10-19 15:33:05 +04:00
}
2008-08-02 18:31:32 +04:00
}
void gui_window_scroll_visible ( struct gui_window * g , int x0 , int y0 ,
int x1 , int y1 )
{
2008-12-14 02:25:42 +03:00
gui_window_set_scroll ( g , x0 , y0 ) ;
2009-01-11 00:31:21 +03:00
ami_do_redraw ( g - > shared , false ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_position_frame ( struct gui_window * g , int x0 , int y0 ,
int x1 , int y1 )
{
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-11-15 18:28:17 +03:00
2008-10-05 03:29:17 +04:00
ChangeWindowBox ( g - > shared - > win , x0 , y0 , x1 - x0 , y1 - y0 ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_get_dimensions ( struct gui_window * g , int * width , int * height ,
bool scaled )
{
2008-08-11 21:53:45 +04:00
struct IBox * bbox ;
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-08-07 22:44:28 +04:00
2008-10-05 03:29:17 +04:00
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-08-11 21:53:45 +04:00
* width = bbox - > Width ;
* height = bbox - > Height ;
2008-08-07 22:44:28 +04:00
if ( scaled )
{
2009-01-11 00:31:21 +03:00
* width / = g - > shared - > bw - > scale ;
* height / = g - > shared - > bw - > scale ;
2008-08-07 22:44:28 +04:00
}
2008-08-02 18:31:32 +04:00
}
void gui_window_update_extent ( struct gui_window * g )
{
2008-08-17 20:22:40 +04:00
struct IBox * bbox ;
2008-10-19 15:33:05 +04:00
ULONG cur_tab = 0 ;
2008-08-17 20:22:40 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-20 22:06:46 +04:00
if ( ! g - > shared - > bw - > current_content ) return ;
2008-08-31 01:32:05 +04:00
2008-10-19 15:33:05 +04:00
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
2008-08-09 19:19:04 +04:00
2008-08-22 01:41:42 +04:00
/*
2008-08-09 19:19:04 +04:00
printf ( " upd ext %ld,%ld \n " , g - > bw - > current_content - > width , // * g->bw->scale,
g - > bw - > current_content - > height ) ; // * g->bw->scale);
2008-08-22 01:41:42 +04:00
*/
2008-08-09 19:19:04 +04:00
2008-10-19 15:33:05 +04:00
RefreshSetGadgetAttrs ( ( APTR ) g - > shared - > objects [ OID_VSCROLL ] , g - > shared - > win , NULL ,
SCROLLER_Total , g - > shared - > bw - > current_content - > height ,
SCROLLER_Visible , bbox - > Height ,
SCROLLER_Top , 0 ,
TAG_DONE ) ;
2008-08-09 19:19:04 +04:00
2008-10-19 15:33:05 +04:00
RefreshSetGadgetAttrs ( ( APTR ) g - > shared - > objects [ OID_HSCROLL ] , g - > shared - > win , NULL ,
SCROLLER_Total , g - > shared - > bw - > current_content - > width ,
SCROLLER_Visible , bbox - > Width ,
SCROLLER_Top , 0 ,
TAG_DONE ) ;
}
2008-08-02 18:31:32 +04:00
}
void gui_window_set_status ( struct gui_window * g , const char * text )
{
2008-10-19 15:33:05 +04:00
ULONG cur_tab = 0 ;
if ( ! g ) return ;
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
RefreshSetGadgetAttrs ( g - > shared - > gadgets [ GID_STATUS ] , g - > shared - > win , NULL , STRINGA_TextVal , text , TAG_DONE ) ;
}
2008-08-02 18:31:32 +04:00
}
void gui_window_set_pointer ( struct gui_window * g , gui_pointer_shape shape )
2008-10-05 03:29:17 +04:00
{
2008-10-19 15:33:05 +04:00
if ( shape = = GUI_POINTER_DEFAULT & & g - > shared - > bw - > throbbing ) shape = GUI_POINTER_PROGRESS ;
2008-10-05 03:29:17 +04:00
ami_update_pointer ( g - > shared - > win , shape ) ;
}
void ami_update_pointer ( struct Window * win , gui_pointer_shape shape )
2008-08-02 18:31:32 +04:00
{
2008-09-23 00:41:01 +04:00
if ( mouseptrcurrent = = shape ) return ;
if ( option_use_os_pointers )
2008-08-07 22:44:28 +04:00
{
2008-09-23 00:41:01 +04:00
switch ( shape )
{
case GUI_POINTER_DEFAULT :
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win , TAG_DONE ) ;
2008-09-23 00:41:01 +04:00
break ;
2008-08-31 21:34:00 +04:00
2008-09-23 00:41:01 +04:00
case GUI_POINTER_WAIT :
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win ,
2008-09-23 00:41:01 +04:00
WA_BusyPointer , TRUE ,
WA_PointerDelay , TRUE ,
TAG_DONE ) ;
break ;
2008-08-07 22:44:28 +04:00
2008-09-23 00:41:01 +04:00
default :
if ( mouseptrobj [ shape ] )
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win , WA_Pointer , mouseptrobj [ shape ] , TAG_DONE ) ;
2008-09-23 00:41:01 +04:00
}
else
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win , TAG_DONE ) ;
2008-09-23 00:41:01 +04:00
}
break ;
}
}
else
{
if ( mouseptrobj [ shape ] )
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win , WA_Pointer , mouseptrobj [ shape ] , TAG_DONE ) ;
2008-09-23 00:41:01 +04:00
}
else
{
2008-09-24 01:41:52 +04:00
if ( shape = = GUI_POINTER_WAIT )
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win ,
2008-09-24 01:41:52 +04:00
WA_BusyPointer , TRUE ,
WA_PointerDelay , TRUE ,
TAG_DONE ) ;
}
else
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( win , TAG_DONE ) ;
2008-09-24 01:41:52 +04:00
}
2008-09-23 00:41:01 +04:00
}
2008-08-07 22:44:28 +04:00
}
2008-08-31 21:34:00 +04:00
2008-09-23 00:41:01 +04:00
mouseptrcurrent = shape ;
2008-08-02 18:31:32 +04:00
}
void gui_window_hide_pointer ( struct gui_window * g )
{
2008-09-23 00:41:01 +04:00
if ( mouseptrcurrent ! = AMI_LASTPOINTER )
{
2008-10-05 03:29:17 +04:00
SetWindowPointer ( g - > shared - > win , WA_Pointer , mouseptrobj [ AMI_LASTPOINTER ] , TAG_DONE ) ;
2008-09-23 00:41:01 +04:00
mouseptrcurrent = AMI_LASTPOINTER ;
}
}
void ami_init_mouse_pointers ( void )
{
int i ;
struct RastPort mouseptr ;
struct DiskObject * dobj ;
uint32 format = IDFMT_BITMAPPED ;
int32 mousexpt = 0 , mouseypt = 0 ;
InitRastPort ( & mouseptr ) ;
for ( i = 0 ; i < = AMI_LASTPOINTER ; i + + )
{
BPTR ptrfile = 0 ;
mouseptrbm [ i ] = NULL ;
mouseptrobj [ i ] = NULL ;
2008-12-14 02:25:42 +03:00
char ptrfname [ 1024 ] ;
2008-09-23 00:41:01 +04:00
if ( option_truecolour_mouse_pointers )
{
2008-12-14 02:25:42 +03:00
ami_get_theme_filename ( & ptrfname , ptrs32 [ i ] ) ;
if ( dobj = GetIconTags ( ptrfname , ICONGETA_UseFriendBitMap , TRUE , TAG_DONE ) )
2008-09-23 00:41:01 +04:00
{
if ( IconControl ( dobj , ICONCTRLA_GetImageDataFormat , & format , TAG_DONE ) )
{
if ( IDFMT_DIRECTMAPPED = = format )
{
int32 width = 0 , height = 0 ;
uint8 * data = 0 ;
IconControl ( dobj ,
ICONCTRLA_GetWidth , & width ,
ICONCTRLA_GetHeight , & height ,
ICONCTRLA_GetImageData1 , & data ,
TAG_DONE ) ;
if ( width > 0 & & width < = 64 & & height > 0 & & height < = 64 & & data )
{
STRPTR tooltype ;
if ( tooltype = FindToolType ( dobj - > do_ToolTypes , " XOFFSET " ) )
mousexpt = atoi ( tooltype ) ;
if ( tooltype = FindToolType ( dobj - > do_ToolTypes , " YOFFSET " ) )
mouseypt = atoi ( tooltype ) ;
if ( mousexpt < 0 | | mousexpt > = width )
mousexpt = 0 ;
if ( mouseypt < 0 | | mouseypt > = height )
mouseypt = 0 ;
static uint8 dummyPlane [ 64 * 64 / 8 ] ;
static struct BitMap dummyBitMap = { 64 / 8 , 64 , 0 , 2 , 0 , { dummyPlane , dummyPlane , 0 , 0 , 0 , 0 , 0 , 0 } , } ;
mouseptrobj [ i ] = NewObject ( NULL , POINTERCLASS ,
POINTERA_BitMap , & dummyBitMap ,
POINTERA_XOffset , - mousexpt ,
POINTERA_YOffset , - mouseypt ,
POINTERA_WordWidth , ( width + 15 ) / 16 ,
POINTERA_XResolution , POINTERXRESN_SCREENRES ,
POINTERA_YResolution , POINTERYRESN_SCREENRESASPECT ,
2008-12-20 13:54:59 +03:00
POINTERA_ImageData , data ,
POINTERA_Width , width ,
POINTERA_Height , height ,
2008-09-23 00:41:01 +04:00
TAG_DONE ) ;
}
}
}
}
}
if ( ! mouseptrobj [ i ] )
{
2008-12-14 02:25:42 +03:00
ami_get_theme_filename ( & ptrfname , ptrs [ i ] ) ;
if ( ptrfile = Open ( ptrfname , MODE_OLDFILE ) )
2008-09-23 00:41:01 +04:00
{
int mx , my ;
2008-11-02 03:21:49 +03:00
UBYTE * pprefsbuf = AllocVec ( 1061 , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-09-23 00:41:01 +04:00
Read ( ptrfile , pprefsbuf , 1061 ) ;
2008-11-02 03:21:49 +03:00
mouseptrbm [ i ] = AllocVec ( sizeof ( struct BitMap ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-09-23 00:41:01 +04:00
InitBitMap ( mouseptrbm [ i ] , 2 , 32 , 32 ) ;
mouseptrbm [ i ] - > Planes [ 0 ] = AllocRaster ( 32 , 32 ) ;
mouseptrbm [ i ] - > Planes [ 1 ] = AllocRaster ( 32 , 32 ) ;
mouseptr . BitMap = mouseptrbm [ i ] ;
for ( my = 0 ; my < 32 ; my + + )
{
for ( mx = 0 ; mx < 32 ; mx + + )
{
SetAPen ( & mouseptr , pprefsbuf [ ( my * ( 33 ) ) + mx ] - ' 0 ' ) ;
WritePixel ( & mouseptr , mx , my ) ;
}
}
mousexpt = ( ( pprefsbuf [ 1056 ] - ' 0 ' ) * 10 ) + ( pprefsbuf [ 1057 ] - ' 0 ' ) ;
mouseypt = ( ( pprefsbuf [ 1059 ] - ' 0 ' ) * 10 ) + ( pprefsbuf [ 1060 ] - ' 0 ' ) ;
mouseptrobj [ i ] = NewObject ( NULL , " pointerclass " ,
POINTERA_BitMap , mouseptrbm [ i ] ,
POINTERA_WordWidth , 2 ,
POINTERA_XOffset , - mousexpt ,
POINTERA_YOffset , - mouseypt ,
POINTERA_XResolution , POINTERXRESN_SCREENRES ,
POINTERA_YResolution , POINTERYRESN_SCREENRESASPECT ,
TAG_DONE ) ;
FreeVec ( pprefsbuf ) ;
Close ( ptrfile ) ;
}
}
} // for
2008-08-02 18:31:32 +04:00
}
void gui_window_set_url ( struct gui_window * g , const char * url )
{
2008-10-05 17:17:18 +04:00
ULONG cur_tab = 0 ;
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-19 15:33:05 +04:00
if ( ! url ) return ;
2008-08-31 01:32:05 +04:00
2008-10-05 17:17:18 +04:00
if ( g - > tab_node ) GetAttr ( CLICKTAB_Current , g - > shared - > gadgets [ GID_TABS ] , ( ULONG * ) & cur_tab ) ;
if ( ( cur_tab = = g - > tab ) | | ( g - > shared - > tabs = = 0 ) )
{
RefreshSetGadgetAttrs ( g - > shared - > gadgets [ GID_URL ] , g - > shared - > win , NULL , STRINGA_TextVal , url , TAG_DONE ) ;
}
2008-08-02 18:31:32 +04:00
}
void gui_window_start_throbber ( struct gui_window * g )
{
2008-09-14 02:39:48 +04:00
struct IBox * bbox ;
2008-10-05 03:29:17 +04:00
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_THROBBER ] , ( ULONG * ) & bbox ) ;
2008-09-14 02:39:48 +04:00
2008-10-05 03:29:17 +04:00
g - > shared - > throbber_frame = 1 ;
2008-09-14 02:39:48 +04:00
2008-10-05 03:29:17 +04:00
BltBitMapRastPort ( throbber , throbber_width , 0 , g - > shared - > win - > RPort , bbox - > Left , bbox - > Top , throbber_width , throbber_height , 0x0C0 ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_stop_throbber ( struct gui_window * g )
{
2008-09-14 02:39:48 +04:00
struct IBox * bbox ;
2008-10-05 03:29:17 +04:00
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_THROBBER ] , ( ULONG * ) & bbox ) ;
2008-09-14 02:39:48 +04:00
2008-10-05 03:29:17 +04:00
BltBitMapRastPort ( throbber , 0 , 0 , g - > shared - > win - > RPort , bbox - > Left , bbox - > Top , throbber_width , throbber_height , 0x0C0 ) ;
2008-09-14 02:39:48 +04:00
2008-10-05 03:29:17 +04:00
g - > shared - > throbber_frame = 0 ;
2008-09-14 02:39:48 +04:00
}
2008-11-02 03:21:49 +03:00
void ami_update_throbber ( struct gui_window_2 * g , bool redraw )
2008-09-14 02:39:48 +04:00
{
struct IBox * bbox ;
2008-10-05 18:22:02 +04:00
if ( ! g - > gadgets [ GID_THROBBER ] ) return ;
2008-11-02 03:21:49 +03:00
if ( ! redraw )
2008-09-14 02:39:48 +04:00
{
2008-11-02 03:21:49 +03:00
if ( g - > throbber_update_count < 1000 )
{
g - > throbber_update_count + + ;
return ;
}
2008-09-14 02:39:48 +04:00
2008-11-02 03:21:49 +03:00
g - > throbber_update_count = 0 ;
2008-09-14 02:39:48 +04:00
2008-11-02 03:21:49 +03:00
g - > throbber_frame + + ;
if ( g - > throbber_frame > ( throbber_frames - 1 ) )
g - > throbber_frame = 1 ;
}
2008-09-14 02:39:48 +04:00
2008-11-02 03:21:49 +03:00
GetAttr ( SPACE_AreaBox , g - > gadgets [ GID_THROBBER ] , ( ULONG * ) & bbox ) ;
2008-09-14 02:39:48 +04:00
BltBitMapRastPort ( throbber , throbber_width * g - > throbber_frame , 0 , g - > win - > RPort , bbox - > Left , bbox - > Top , throbber_width , throbber_height , 0x0C0 ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_place_caret ( struct gui_window * g , int x , int y , int height )
{
2008-08-22 01:41:42 +04:00
struct IBox * bbox ;
2008-09-28 00:55:11 +04:00
ULONG xs , ys ;
2008-08-22 01:41:42 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-09-28 00:55:11 +04:00
gui_window_remove_caret ( g ) ;
2008-10-05 03:29:17 +04:00
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_HSCROLL ] , & xs ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_VSCROLL ] , & ys ) ;
2008-08-22 01:41:42 +04:00
2008-10-05 03:29:17 +04:00
SetAPen ( g - > shared - > win - > RPort , 3 ) ;
2008-09-28 01:33:00 +04:00
// if(((x-xs) < bbox->Left) || ((x-xs) > (bbox->Left+bbox->Width)) || ((y-ys) < bbox->Top) || ((y-ys) > (bbox->Top+bbox->Height))) return;
2008-10-05 03:29:17 +04:00
RectFill ( g - > shared - > win - > RPort , x + bbox - > Left - xs , y + bbox - > Top - ys , x + bbox - > Left + 2 - xs , y + bbox - > Top + height - ys ) ;
2008-09-28 01:33:00 +04:00
2008-10-19 15:33:05 +04:00
g - > c_x = x ;
g - > c_y = y ;
g - > c_h = height ;
2008-08-02 18:31:32 +04:00
}
void gui_window_remove_caret ( struct gui_window * g )
{
2008-08-22 01:41:42 +04:00
struct IBox * bbox ;
2008-09-28 01:33:00 +04:00
int xs , ys ;
2008-08-22 01:41:42 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-10-05 03:29:17 +04:00
GetAttr ( SPACE_AreaBox , g - > shared - > gadgets [ GID_BROWSER ] , ( ULONG * ) & bbox ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_HSCROLL ] , ( ULONG * ) & xs ) ;
GetAttr ( SCROLLER_Top , g - > shared - > objects [ OID_VSCROLL ] , ( ULONG * ) & ys ) ;
2008-08-22 01:41:42 +04:00
2009-02-01 21:36:17 +03:00
BltBitMapRastPort ( glob . bm , g - > c_x - xs , g - > c_y - ys , g - > shared - > win - > RPort , bbox - > Left + g - > c_x - xs , bbox - > Top + g - > c_y - ys , 2 + 1 , g - > c_h + 1 , 0x0C0 ) ;
2008-09-23 00:41:01 +04:00
2008-10-19 15:33:05 +04:00
g - > c_h = 0 ;
2008-08-02 18:31:32 +04:00
}
void gui_window_new_content ( struct gui_window * g )
{
2008-08-30 20:57:35 +04:00
// DebugPrintF("new content\n");
2008-08-02 18:31:32 +04:00
}
bool gui_window_scroll_start ( struct gui_window * g )
{
2008-08-30 20:57:35 +04:00
DebugPrintF ( " scroll start \n " ) ;
2008-08-02 18:31:32 +04:00
}
bool gui_window_box_scroll_start ( struct gui_window * g ,
int x0 , int y0 , int x1 , int y1 )
{
2008-08-30 20:57:35 +04:00
DebugPrintF ( " box scroll start \n " ) ;
2008-08-02 18:31:32 +04:00
}
bool gui_window_frame_resize_start ( struct gui_window * g )
{
2008-08-07 22:44:28 +04:00
printf ( " resize frame \n " ) ;
2008-08-02 18:31:32 +04:00
}
void gui_window_save_as_link ( struct gui_window * g , struct content * c )
{
}
void gui_window_set_scale ( struct gui_window * g , float scale )
{
2008-08-07 22:44:28 +04:00
printf ( " set scale \n " ) ;
2008-08-02 18:31:32 +04:00
}
struct gui_download_window * gui_download_window_create ( const char * url ,
const char * mime_type , struct fetch * fetch ,
unsigned int total_size , struct gui_window * gui )
{
2008-08-30 20:57:35 +04:00
char fname [ 1024 ] ;
2008-08-23 20:17:51 +04:00
struct gui_download_window * dw ;
APTR va [ 3 ] ;
2008-08-22 01:41:42 +04:00
2009-02-01 02:45:25 +03:00
if ( gui - > dlfilename )
{
strcpy ( fname , gui - > dlfilename ) ;
free ( gui - > dlfilename ) ;
gui - > dlfilename = NULL ;
}
else
2008-08-22 01:41:42 +04:00
{
2009-02-01 02:45:25 +03:00
if ( AslRequestTags ( savereq ,
ASLFR_TitleText , messages_get ( " NetSurf " ) ,
ASLFR_Screen , scrn ,
ASLFR_InitialFile , FilePart ( url ) ,
TAG_DONE ) )
{
strlcpy ( & fname , savereq - > fr_Drawer , 1024 ) ;
AddPart ( ( STRPTR ) & fname , savereq - > fr_File , 1024 ) ;
}
else return NULL ;
2008-08-22 01:41:42 +04:00
}
2008-08-23 20:17:51 +04:00
2008-11-02 03:21:49 +03:00
dw = AllocVec ( sizeof ( struct gui_download_window ) , MEMF_PRIVATE | MEMF_CLEAR ) ;
2008-08-23 20:17:51 +04:00
dw - > size = total_size ;
dw - > downloaded = 0 ;
2008-08-31 21:34:00 +04:00
va [ 0 ] = ( APTR ) dw - > downloaded ;
va [ 1 ] = ( APTR ) dw - > size ;
2008-08-23 20:17:51 +04:00
va [ 2 ] = 0 ;
2008-08-31 21:34:00 +04:00
if ( ! ( dw - > fh = FOpen ( ( STRPTR ) & fname , MODE_NEWFILE , 0 ) ) )
2008-08-23 20:17:51 +04:00
{
FreeVec ( dw ) ;
return NULL ;
}
2008-09-29 02:50:13 +04:00
SetComment ( fname , url ) ;
2008-09-01 22:03:40 +04:00
2008-08-23 20:17:51 +04:00
dw - > objects [ OID_MAIN ] = WindowObject ,
WA_ScreenTitle , nsscreentitle ,
WA_Title , url ,
WA_Activate , TRUE ,
WA_DepthGadget , TRUE ,
WA_DragBar , TRUE ,
WA_CloseGadget , FALSE ,
WA_SizeGadget , TRUE ,
WA_CustomScreen , scrn ,
WINDOW_IconifyGadget , TRUE ,
2008-08-31 01:32:05 +04:00
WINDOW_LockHeight , TRUE ,
2008-08-23 20:17:51 +04:00
WINDOW_Position , WPOS_CENTERSCREEN ,
WINDOW_ParentGroup , dw - > gadgets [ GID_MAIN ] = VGroupObject ,
LAYOUT_AddChild , dw - > gadgets [ GID_STATUS ] = FuelGaugeObject ,
GA_ID , GID_STATUS ,
GA_Text , messages_get ( " amiDownload " ) ,
FUELGAUGE_Min , 0 ,
FUELGAUGE_Max , total_size ,
FUELGAUGE_Level , 0 ,
2008-10-05 03:29:17 +04:00
FUELGAUGE_Ticks , 11 ,
FUELGAUGE_ShortTicks , TRUE ,
2008-08-23 20:17:51 +04:00
FUELGAUGE_VarArgs , va ,
FUELGAUGE_Percent , FALSE ,
FUELGAUGE_Justification , FGJ_CENTER ,
StringEnd ,
CHILD_NominalSize , TRUE ,
CHILD_WeightedHeight , 0 ,
EndGroup ,
EndWindow ;
dw - > win = ( struct Window * ) RA_OpenWindow ( dw - > objects [ OID_MAIN ] ) ;
dw - > node = AddObject ( window_list , AMINS_DLWINDOW ) ;
dw - > node - > objstruct = dw ;
return dw ;
2008-08-02 18:31:32 +04:00
}
void gui_download_window_data ( struct gui_download_window * dw , const char * data ,
unsigned int size )
{
2008-08-23 20:17:51 +04:00
APTR va [ 3 ] ;
if ( ! dw ) return ;
FWrite ( dw - > fh , data , 1 , size ) ;
dw - > downloaded = dw - > downloaded + size ;
2008-08-31 01:32:05 +04:00
va [ 0 ] = ( APTR ) dw - > downloaded ;
va [ 1 ] = ( APTR ) dw - > size ;
2008-08-23 20:17:51 +04:00
va [ 2 ] = 0 ;
if ( dw - > size )
{
RefreshSetGadgetAttrs ( dw - > gadgets [ GID_STATUS ] , dw - > win , NULL ,
FUELGAUGE_Level , dw - > downloaded ,
GA_Text , messages_get ( " amiDownload " ) ,
FUELGAUGE_VarArgs , va ,
TAG_DONE ) ;
}
else
{
RefreshSetGadgetAttrs ( dw - > gadgets [ GID_STATUS ] , dw - > win , NULL ,
FUELGAUGE_Level , dw - > downloaded ,
GA_Text , messages_get ( " amiDownloadU " ) ,
FUELGAUGE_VarArgs , va ,
TAG_DONE ) ;
}
2008-08-02 18:31:32 +04:00
}
void gui_download_window_error ( struct gui_download_window * dw ,
const char * error_msg )
{
2008-09-29 02:50:13 +04:00
warn_user ( " Unwritten " , " " ) ;
2008-08-23 20:17:51 +04:00
gui_download_window_done ( dw ) ;
2008-08-02 18:31:32 +04:00
}
void gui_download_window_done ( struct gui_download_window * dw )
{
2008-08-23 20:17:51 +04:00
if ( ! dw ) return ;
FClose ( dw - > fh ) ;
DisposeObject ( dw - > objects [ OID_MAIN ] ) ;
DelObject ( dw - > node ) ;
2008-08-02 18:31:32 +04:00
}
void gui_drag_save_object ( gui_save_type type , struct content * c ,
struct gui_window * g )
{
}
void gui_create_form_select_menu ( struct browser_window * bw ,
struct form_control * control )
{
2008-08-18 23:07:12 +04:00
struct gui_window * gwin = bw - > window ;
2008-08-19 22:31:56 +04:00
struct form_option * opt = control - > data . select . items ;
ULONG i = 0 ;
2008-08-18 23:07:12 +04:00
2008-10-21 22:04:27 +04:00
if ( gwin - > shared - > objects [ OID_MENU ] ) DisposeObject ( gwin - > shared - > objects [ OID_MENU ] ) ;
2008-10-05 03:29:17 +04:00
gwin - > shared - > popuphook . h_Entry = ami_popup_hook ;
gwin - > shared - > popuphook . h_Data = gwin ;
2008-08-18 23:07:12 +04:00
2008-10-05 03:29:17 +04:00
gwin - > shared - > control = control ;
2008-08-18 23:07:12 +04:00
2008-10-21 22:04:27 +04:00
gwin - > shared - > objects [ OID_MENU ] = PMMENU ( ami_utf8_easy ( control - > name ) ) ,
2008-10-05 03:29:17 +04:00
PMA_MenuHandler , & gwin - > shared - > popuphook , End ;
2008-08-18 23:07:12 +04:00
2008-08-19 22:31:56 +04:00
while ( opt )
{
2008-10-05 03:29:17 +04:00
IDoMethod ( gwin - > shared - > objects [ OID_MENU ] , PM_INSERT , NewObject ( POPUPMENU_GetItemClass ( ) , NULL , PMIA_Title , ( ULONG ) ami_utf8_easy ( opt - > text ) , PMIA_ID , i , PMIA_CheckIt , TRUE , PMIA_Checked , opt - > selected , TAG_DONE ) , ~ 0 ) ;
2008-08-18 23:07:12 +04:00
2008-08-19 22:31:56 +04:00
opt = opt - > next ;
i + + ;
}
2008-08-18 23:07:12 +04:00
2008-09-01 22:03:40 +04:00
gui_window_set_pointer ( gwin , GUI_POINTER_DEFAULT ) ; // Clear the menu-style pointer
2008-10-05 03:29:17 +04:00
IDoMethod ( gwin - > shared - > objects [ OID_MENU ] , PM_OPEN , gwin - > shared - > win ) ;
2008-08-18 23:07:12 +04:00
2008-08-02 18:31:32 +04:00
}
2008-08-11 21:53:45 +04:00
void ami_scroller_hook ( struct Hook * hook , Object * object , struct IntuiMessage * msg )
{
ULONG gid , x , y ;
2008-10-12 01:38:04 +04:00
struct gui_window_2 * gwin = hook - > h_Data ;
2008-08-11 21:53:45 +04:00
if ( msg - > Class = = IDCMP_IDCMPUPDATE )
{
gid = GetTagData ( GA_ID , 0 , msg - > IAddress ) ;
switch ( gid )
{
case OID_HSCROLL :
case OID_VSCROLL :
2009-02-05 15:20:23 +03:00
if ( ! option_faster_scroll )
gwin - > redraw_required = true ;
else ami_do_redraw ( gwin , true ) ;
2008-08-11 21:53:45 +04:00
break ;
}
2008-08-15 21:19:57 +04:00
}
// ReplyMsg((struct Message *)msg);
2008-08-11 21:53:45 +04:00
}
2008-08-18 23:07:12 +04:00
uint32 ami_popup_hook ( struct Hook * hook , Object * item , APTR reserved )
{
int32 itemid = 0 ;
struct gui_window * gwin = hook - > h_Data ;
if ( GetAttr ( PMIA_ID , item , & itemid ) )
{
2008-10-05 03:29:17 +04:00
browser_window_form_select ( gwin - > shared - > bw , gwin - > shared - > control , itemid ) ;
2008-08-18 23:07:12 +04:00
}
return itemid ;
}
2008-08-11 21:53:45 +04:00
2008-08-02 18:31:32 +04:00
void gui_cert_verify ( struct browser_window * bw , struct content * c ,
const struct ssl_cert_info * certs , unsigned long num )
{
}
2008-08-15 21:19:57 +04:00
# ifdef WITH_HUBBUB
static void * myrealloc ( void * ptr , size_t len , void * pw )
{
return realloc ( ptr , len ) ;
}
# endif