-Remove a bunch of code which was intended to handle framed-pages. It's better handled by the OS, because frames won't be handled within the frontend anymore.

- Clear window when no content is available

svn path=/trunk/netsurf/; revision=13125
This commit is contained in:
Ole Loots 2011-11-05 15:18:19 +00:00
parent 5f10479c26
commit 044fec706f
5 changed files with 263 additions and 325 deletions

View File

@ -78,7 +78,7 @@ static bool frameinit = true;
/*
Create an browser component window (undcomented WinDom structure).
Create an browser component.
Currently, this area is the area which is used to display HTML content.
However, it could also contains other areas, these need to be handled within
"browser_get_rect" function.
@ -109,43 +109,33 @@ struct s_browser * browser_create
bw->scale = clone->scale;
else
bw->scale = 1;
bnew->redraw.areas_used = 0;
bnew->compwin = mt_WindCreate( &app, VSLIDE|HSLIDE, 1, 1, app.w, app.h);
bnew->compwin->w_u = 1;
bnew->compwin->h_u = 1;
/* needs to be adjusted when content width is known: */
bnew->compwin->ypos_max = w;
bnew->compwin->xpos_max = w;
mt_WindSlider( &app, bnew->compwin, HSLIDER|VSLIDER);
bnew->comp = (COMPONENT*)comp_widget_create( (void*)&app, (WINDOW*)bnew->compwin, 1, 1 );
bnew->redraw.areas_used = 0;
bnew->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, 100, 1);
if( bnew->comp == NULL ) {
free(bnew);
return(NULL);
}
/* Attach events to the component: */
mt_EvntDataAdd( &app, bnew->compwin, WM_XBUTTON,
browser_evnt_mbutton, (void*)gw, EV_BOT );
mt_CompEvntDataAdd( &app, bnew->comp, WM_XBUTTON,
browser_evnt_mbutton, (void*)gw, EV_BOT
);
mt_CompEvntDataAttach( &app, bnew->comp, WM_REDRAW,
browser_evnt_redraw, (void*)gw );
mt_EvntDataAttach( &app, bnew->compwin , WM_REDRAW, browser_evnt_redraw_x, NULL );
mt_EvntDataAttach( &app, bnew->compwin, WM_SLIDEXY,
browser_evnt_slider, gw );
mt_EvntDataAttach( &app, bnew->compwin, WM_ARROWED,
browser_evnt_arrowed, gw );
browser_evnt_redraw, (void*)gw
);
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
browser_evnt_destroy, (void*)bnew );
/* just stub, as an reminder: */
mt_EvntDataAttach( &app, bnew->compwin, WM_DESTROY,
browser_evnt_wdestroy, (void*)bnew );
browser_evnt_destroy, (void*)bnew
);
/* Set the gui_window owner. */
/* it is an link to the netsurf window system */
mt_CompDataAttach( &app, bnew->comp, CDT_OWNER, gw );
bnew->scroll.requested.y = 0;
bnew->scroll.requested.x = 0;
bnew->scroll.current.x = 0;
bnew->scroll.current.y = 0;
bnew->scroll.current.y = 0;
}
return( bnew );
}
@ -153,20 +143,14 @@ struct s_browser * browser_create
bool browser_destroy( struct s_browser * b )
{
LOG(("%s\n", b->bw->name ));
LOG(("%s\n", b->bw->name ));
assert( b != NULL );
assert( b->comp != NULL );
assert( b->bw != NULL );
if( b->compwin != NULL ) {
/* TODO: Only do this when it's the last browser viewport within the root win: */
COMPONENT * old = b->comp;
WINDOW * oldwin = b->compwin;
b->comp = NULL;
b->compwin = NULL;
/* I'm not sure about the correct order of these 2 calls: */
WindDelete( oldwin );
mt_CompDelete(&app, old );
if( b->comp != NULL ){
mt_CompDelete(&app, b->comp );
}
return( true );
}
@ -175,46 +159,22 @@ bool browser_destroy( struct s_browser * b )
Query the browser component for widget rectangles.
*/
void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out)
{
GRECT work;
assert( out != NULL);
int slider_v_w = 20;
int slider_v_h = 22;
int slider_h_w = 20;
int slider_h_h = 22;
{
LGRECT cur;
/* Query component for it's current size: */
WindGetGrect( gw->browser->compwin, WF_WORKXYWH, &work);
mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
/* And extract the different widget dimensions: */
/* Redraw area of html content: */
if( type == BR_CONTENT ){
out->g_w = work.g_w;
out->g_h = work.g_h;
out->g_x = work.g_x;
out->g_y = work.g_y;
out->g_w = cur.g_w;
out->g_h = cur.g_h;
out->g_x = cur.g_x;
out->g_y = cur.g_y;
return;
}
/* Horizontal scroller: */
LGRECT cur;
mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
if( type == BR_HSLIDER ){
out->g_x = cur.g_x;
out->g_y = cur.g_y + work.g_h;
out->g_h = cur.g_h - work.g_h;
out->g_w = cur.g_w;
}
/* Vertical scroller: */
if( type == BR_VSLIDER ){
out->g_x = cur.g_x + work.g_w;
out->g_y = cur.g_y;
out->g_w = cur.g_w - work.g_w;
out->g_h = work.g_h;
}
}
/* Report an resize to the COMPONENT interface */
@ -233,9 +193,11 @@ void browser_set_content_size(struct gui_window * gw, int w, int h)
{
CMP_BROWSER b = gw->browser;
LGRECT work;
browser_get_rect( gw, BR_CONTENT, &work );
b->compwin->ypos_max = h;
b->compwin->xpos_max = w;
browser_get_rect( gw, BR_CONTENT, &work );
gw->root->handle->xpos_max = w;
gw->root->handle->ypos_max = h;
if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
/* let the scroll routine detect invalid scroll values... */
browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
@ -245,12 +207,6 @@ void browser_set_content_size(struct gui_window * gw, int w, int h)
}
}
static void __CDECL browser_evnt_wdestroy( WINDOW * c, short buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
LOG((""));
}
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
@ -259,75 +215,16 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da
assert( b != NULL );
assert( gw != NULL );
assert( b->comp == NULL );
free( b );
gw->browser = NULL;
LOG(("evnt_destroy done!"));
}
static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data)
{
bool abs = false;
int value = BROWSER_SCROLL_SVAL;
struct gui_window * gw = data;
LGRECT cwork;
if( input_window == NULL || input_window != gw ) {
return;
}
browser_get_rect( gw, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
case WA_DNPAGE:
value = cwork.g_h;
break;
case WA_LFPAGE:
case WA_RTPAGE:
value = cwork.g_w;
break;
default:
break;
}
browser_scroll( gw, buff[4], value, abs );
}
void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data)
{
int dx = buff[4];
int dy = buff[5];
GRECT work, screen;
struct gui_window * gw = data;
if (!dx && !dy) return;
if( input_window == NULL || input_window != gw ) {
return;
}
/* update the sliders _before_ we call redraw (which might depend on the slider possitions) */
mt_WindSlider( &app, win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
if( dy > 0 )
browser_scroll( gw, WA_DNPAGE, abs(dy), false );
else if ( dy < 0)
browser_scroll( gw, WA_UPPAGE, abs(dy), false );
if( dx > 0 )
browser_scroll( gw, WA_RTPAGE, abs(dx), false );
else if( dx < 0 )
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
/*
Mouse Button handler for browser component.
*/
static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data)
static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
{
long lbuff[8];
short mx, my, dummy, mbut;
@ -582,10 +479,11 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
}
b->scroll.requested.y = 0;
b->scroll.requested.x = 0;
gw->browser->compwin->xpos = b->scroll.current.x;
gw->browser->compwin->ypos = b->scroll.current.y;
mt_WindSlider( &app, gw->browser->compwin, HSLIDER|VSLIDER);
gw->root->handle->xpos = b->scroll.current.x;
gw->root->handle->ypos = b->scroll.current.y;
mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
}
/*
@ -751,13 +649,6 @@ bool browser_input( struct gui_window * gw, unsigned short nkc )
return( r );
}
static void __CDECL browser_evnt_redraw_x( WINDOW * c, short buf[8], void * data)
{
/* just an stub to prevent wndclear */
/* Probably the browser redraw is better placed here? dunno! */
return;
}
/* determines if a browser window needs redraw */
bool browser_redraw_required( struct gui_window * gw)
{
@ -1031,7 +922,6 @@ void browser_redraw( struct gui_window * gw )
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
{
short pxy[8];
WINDOW * w;
struct gui_window * gw = (struct gui_window *) data;
CMP_BROWSER b = gw->browser;
LGRECT work, lclip, rwork;
@ -1043,13 +933,23 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
int xoff,yoff,width,heigth;
short cw, ch, cellw, cellh;
/* use that instead of browser_find_root() ? */
w = (WINDOW*)mt_CompGetPtr( &app, c, CF_WINDOW );
browser_get_rect( gw, BR_CONTENT, &work );
lclip = work;
if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;
if( b->bw->current_content == NULL )
return;
if( b->bw->current_content == NULL ){
short pxy[4];
pxy[0] = lclip.g_x;
pxy[1] = lclip.g_y;
pxy[2] = lclip.g_x + lclip.g_w - 1;
pxy[3] = lclip.g_y + lclip.g_h - 1;
vsf_color( gw->root->handle->graf->handle, WHITE );
vsf_perimeter( gw->root->handle->graf->handle, 0);
vsf_interior( gw->root->handle->graf->handle, FIS_SOLID );
vsf_style( gw->root->handle->graf->handle, 1);
v_bar( gw->root->handle->graf->handle, (short*)&pxy );
return;
}
/* convert redraw coords to framebuffer coords: */
lclip.g_x -= work.g_x;
@ -1064,11 +964,12 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
lclip.g_h = work.g_h + lclip.g_y;
lclip.g_y = 0;
}
if( lclip.g_h > 0 && lclip.g_w > 0 ) {
if( lclip.g_h > 0 && lclip.g_w > 0 ) {
browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,
lclip.g_x + lclip.g_w, lclip.g_y + lclip.g_h
);
);
}
return;

View File

@ -97,7 +97,6 @@ struct s_browser
{
int type;
COMPONENT * comp;
WINDOW * compwin;
struct browser_window * bw;
struct s_scroll_info scroll;
struct s_browser_redrw_info redraw;
@ -137,9 +136,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x, short y, short w,
static void __CDECL browser_evnt_resize( COMPONENT * c, long buff[8], void * data);
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data);
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data);
static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data);
static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data);
static void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data);
static void __CDECL browser_evnt_redraw_x( WINDOW * c, short buff[8], void * data);
static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data);
#endif

View File

@ -74,36 +74,6 @@ void __CDECL std_mvd( WINDOW * win, short buff[8], void * );
/* -------------------------------------------------------------------------- */
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
{
bool abs = false;
LGRECT cwork;
int value = BROWSER_SCROLL_SVAL;
if( input_window == NULL ) {
return;
}
browser_get_rect( input_window, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
case WA_DNPAGE:
value = cwork.g_h;
break;
case WA_LFPAGE:
case WA_RTPAGE:
value = cwork.g_w;
break;
default:
break;
}
browser_scroll( input_window, buff[4], value, abs );
}
/*
track the mouse state and
finally checks for released buttons.
@ -175,100 +145,26 @@ static void window_track_mouse_state( LGRECT * bwrect, bool within, short mx, sh
}
}
static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
{
struct gui_window * gw = input_window;
static bool prev_url = false;
static bool prev_sb = false;
short mx, my, mbut, mkstate;
bool a = false; /* flags if mouse is within controls or browser canvas */
bool within = false;
LGRECT urlbox, bwbox, sbbox;
int nx, ny; /* relative mouse position */
if( gw == NULL)
return;
if( gw != input_window ){
return;
}
graf_mkstate(&mx, &my, &mbut, &mkstate);
browser_get_rect( gw, BR_CONTENT, &bwbox );
if( gw->root->toolbar )
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( gw->root->statusbar )
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &sbbox);
if( mx > bwbox.g_x && mx < bwbox.g_x + bwbox.g_w &&
my > bwbox.g_y && my < bwbox.g_y + bwbox.g_h ){
within = true;
}
if( evnt.m1_flag == MO_LEAVE ) {
if( MOUSE_IS_DRAGGING() ){
window_track_mouse_state( &bwbox, within, mx, my, mbut, mkstate );
}
if( gw->root->toolbar && within == false ) {
if( (mx > urlbox.g_x && mx < urlbox.g_x + urlbox.g_w ) &&
(my > urlbox.g_y && my < + urlbox.g_y + urlbox.g_h )) {
gem_set_cursor( &gem_cursors.ibeam );
prev_url = a = true;
}
}
if( gw->root->statusbar && within == false /* && a == false */ ) {
if( mx >= sbbox.g_x + (sbbox.g_w-MOVER_WH) && mx <= sbbox.g_x + sbbox.g_w &&
my >= sbbox.g_y + (sbbox.g_h-MOVER_WH) && my <= sbbox.g_y + sbbox.g_h ) {
/* mouse within sizer box ( bottom right ) */
prev_sb = a = true;
gem_set_cursor( &gem_cursors.sizenwse );
}
}
if( !a ) {
if( prev_sb )
gw->root->statusbar->resize_init = true;
if( prev_url || prev_sb ) {
gem_set_cursor( &gem_cursors.arrow );
prev_url = false;
prev_sb = false;
}
/* report mouse move in the browser window */
if( within ){
nx = mx - bwbox.g_x;
ny = my - bwbox.g_y;
if( ( abs(mx-last_drag_x)>5 || abs(mx-last_drag_y)>5 ) ||
!MOUSE_IS_DRAGGING() ){
browser_window_mouse_track(
input_window->browser->bw,
bmstate,
nx + gw->browser->scroll.current.x,
ny + gw->browser->scroll.current.y
);
if( MOUSE_IS_DRAGGING() ){
last_drag_x = mx;
last_drag_y = my;
}
}
}
}
} else {
/* set input window? */
}
}
int window_create( struct gui_window * gw, struct browser_window * bw, unsigned long inflags)
{
short buff[8];
OBJECT * tbtree;
int err = 0;
bool tb, sb;
bool tb, sb;
short sc;
short w,h, wx, wy, wh, ww;
int flags;
tb = (inflags & WIDGET_TOOLBAR );
sb = (inflags & WIDGET_STATUSBAR);
short w,h, wx, wy, wh, ww;
int flags = CLOSER | MOVER | NAME | FULLER | SMALLER ;
sb = (inflags & WIDGET_STATUSBAR );
flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
if( inflags & WIDGET_SCROLL ){
flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
}
if( inflags & WIDGET_RESIZE ){
flags |= ( SIZER );
}
gw->root = malloc( sizeof(struct s_gui_win_root) );
if( gw->root == NULL )
@ -280,10 +176,17 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
free( gw->root->title );
free( gw->root );
return( -1 );
}
}
/* set scroll / content granularity ( 1 unit ) */
gw->root->handle->w_u = 1;
gw->root->handle->h_u = 1;
/* Create Root component: */
gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
/* create toolbar component: */
if( tb ) {
gw->root->toolbar = tb_create( gw );
assert( gw->root->toolbar );
@ -292,10 +195,12 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
} else {
gw->root->toolbar = NULL;
}
/* create browser component: */
gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
/* create statusbar component: */
if( sb ) {
gw->root->statusbar = sb_create( gw );
mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
@ -321,10 +226,12 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
EvntDataAttach( gw->root->handle, WM_XM1, evnt_window_m1, gw );
EvntDataAttach( gw->root->handle, WM_XM1, evnt_window_m1, gw );
EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
/* TODO: check if window is openend as "foreground" window... */
window_set_focus( gw, BROWSER, gw->browser);
window_set_focus( gw, BROWSER, gw->browser);
return (err);
}
@ -332,7 +239,7 @@ int window_destroy( struct gui_window * gw)
{
short buff[8];
int err = 0;
search_destroy( gw );
if( input_window == gw )
input_window = NULL;
@ -347,12 +254,10 @@ int window_destroy( struct gui_window * gw)
search_destroy( gw );
LOG(("Freeing browser window"));
if( gw->browser )
browser_destroy( gw->browser );
/* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
LOG(("Freeing root window"));
if( gw->root ) {
/* TODO: check if no other browser is bound to this root window! */
if( gw->root->title )
@ -373,12 +278,16 @@ int window_destroy( struct gui_window * gw)
void window_open( struct gui_window * gw)
{
LGRECT br;
GRECT dim;
WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
GRECT dim;
WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
WindClear( gw->root->handle );
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
/* apply focus to the root frame: */
long lfbuff[8] = { CM_GETFOCUS };
mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
/* recompute the nested component sizes and positions: */
browser_update_rects( gw );
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
@ -388,8 +297,8 @@ void window_open( struct gui_window * gw)
gw->browser->attached = true;
if( gw->root->statusbar != NULL ){
gw->root->statusbar->attached = true;
}
snd_rdw( gw->root->handle );
}
/*TBD: get already present content and set size? */
}
@ -400,28 +309,6 @@ void window_update_back_forward( struct gui_window * gw)
tb_update_buttons( gw );
}
static void window_redraw_controls(struct gui_window *gw, uint32_t flags)
{
LGRECT rect;
/* redraw sliders manually, dunno why this is needed (mt_WindSlider should do the job anytime)!*/
browser_get_rect( gw, BR_VSLIDER, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
browser_get_rect( gw, BR_HSLIDER, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
/* send redraw to toolbar & statusbar & scrollbars: */
mt_CompGetLGrect(&app, gw->root->toolbar->comp, WF_WORKXYWH, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
}
void window_set_stauts( struct gui_window * gw , char * text )
{
if( gw->root == NULL )
@ -469,6 +356,40 @@ bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t,
}
assert( gw->root != NULL );
return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
}
/* -------------------------------------------------------------------------- */
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
{
bool abs = false;
LGRECT cwork;
int value = BROWSER_SCROLL_SVAL;
if( input_window == NULL ) {
return;
}
browser_get_rect( input_window, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
case WA_DNPAGE:
value = cwork.g_h;
break;
case WA_LFPAGE:
case WA_RTPAGE:
value = cwork.g_w;
break;
default:
break;
}
browser_scroll( input_window, buff[4], value, abs );
}
static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
@ -588,11 +509,92 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
}
error:
ddclose( dd_hdl);
}
static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
{
struct gui_window * gw = input_window;
static bool prev_url = false;
static bool prev_sb = false;
short mx, my, mbut, mkstate;
bool a = false; //flags if mouse is within controls or browser
bool within = false;
LGRECT urlbox, bwbox, sbbox;
int nx, ny; // relative mouse position
if( gw == NULL)
return;
if( gw != input_window ){
return;
}
graf_mkstate(&mx, &my, &mbut, &mkstate);
browser_get_rect( gw, BR_CONTENT, &bwbox );
if( gw->root->toolbar )
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( gw->root->statusbar )
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &sbbox);
if( mx > bwbox.g_x && mx < bwbox.g_x + bwbox.g_w &&
my > bwbox.g_y && my < bwbox.g_y + bwbox.g_h ){
within = true;
}
if( evnt.m1_flag == MO_LEAVE ) {
if( MOUSE_IS_DRAGGING() ){
window_track_mouse_state( &bwbox, within, mx, my, mbut, mkstate );
}
if( gw->root->toolbar && within == false ) {
if( (mx > urlbox.g_x && mx < urlbox.g_x + urlbox.g_w ) &&
(my > urlbox.g_y && my < + urlbox.g_y + urlbox.g_h )) {
gem_set_cursor( &gem_cursors.ibeam );
prev_url = a = true;
}
}
if( gw->root->statusbar && within == false /* && a == false */ ) {
if( mx >= sbbox.g_x + (sbbox.g_w-MOVER_WH) && mx <= sbbox.g_x + sbbox.g_w &&
my >= sbbox.g_y + (sbbox.g_h-MOVER_WH) && my <= sbbox.g_y + sbbox.g_h ) {
/* mouse within sizer box ( bottom right ) */
prev_sb = a = true;
gem_set_cursor( &gem_cursors.sizenwse );
}
}
if( !a ) {
if( prev_sb )
gw->root->statusbar->resize_init = true;
if( prev_url || prev_sb ) {
gem_set_cursor( &gem_cursors.arrow );
prev_url = false;
prev_sb = false;
}
/* report mouse move in the browser window */
if( within ){
nx = mx - bwbox.g_x;
ny = my - bwbox.g_y;
if( ( abs(mx-last_drag_x)>5 || abs(mx-last_drag_y)>5 ) ||
!MOUSE_IS_DRAGGING() ){
browser_window_mouse_track(
input_window->browser->bw,
bmstate,
nx + gw->browser->scroll.current.x,
ny + gw->browser->scroll.current.y
);
if( MOUSE_IS_DRAGGING() ){
last_drag_x = mx;
last_drag_y = my;
}
}
}
}
} else {
/* set input window? */
}
}
/* -------------------------------------------------------------------------- */
/* Non Public Modul event handlers: */
/* -------------------------------------------------------------------------- */
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
{
LOG(("%s\n", __FUNCTION__ ));
@ -612,8 +614,6 @@ static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
input_window = (struct gui_window *) data;
LOG(("newtop: iw: %p, win: %p", input_window, win ));
assert( input_window != NULL );
/* window_redraw_controls(input_window, 0); */
}
static void __CDECL evnt_window_shaded( WINDOW *win, short buff[8], void *data )
@ -624,15 +624,40 @@ static void __CDECL evnt_window_shaded( WINDOW *win, short buff[8], void *data )
if(buff[0] == WM_UNSHADED){
}
}
}
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
{
int dx = buff[4];
int dy = buff[5];
GRECT work, screen;
struct gui_window * gw = data;
if (!dx && !dy) return;
if( input_window == NULL || input_window != gw ) {
return;
}
/* update the sliders _before_ we call redraw (which might depend on the slider possitions) */
WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
if( dy > 0 )
browser_scroll( gw, WA_DNPAGE, abs(dy), false );
else if ( dy < 0)
browser_scroll( gw, WA_UPPAGE, abs(dy), false );
if( dx > 0 )
browser_scroll( gw, WA_RTPAGE, abs(dx), false );
else if( dx < 0 )
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void * data )
{
short x,y,w,h;
struct gui_window * gw = (struct gui_window*)data;
LOG((""));
WindClear( win);
WindGet( win, WF_WORKXYWH, &x, &y, &w, &h);
if( gw->icon == NULL ) {
@ -719,14 +744,26 @@ static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * da
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
browser_get_rect( gw, BR_CONTENT, &rect );
if( gw->browser->bw->current_content != NULL )
browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
else
WindClear( gw->root->handle );
gw->root->toolbar->url.scrollx = 0;
window_redraw_controls(gw, 0);
/* send complete redraw to toolbar & statusbar: */
mt_CompGetLGrect(&app, gw->root->toolbar->comp, WF_WORKXYWH, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h
);
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
rect.g_x, rect.g_y, rect.g_w, rect.g_h
);
/* TODO: recalculate scroll position, instead of zeroing? */
} else {
if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
browser_update_rects( gw );
}
}
}
}

View File

@ -24,6 +24,8 @@
#define WIDGET_STATUSBAR 0x1
#define WIDGET_TOOLBAR 0x2
#define WIDGET_SCROLL 0x4
#define WIDGET_RESIZE 0x8
/* WinDom & Custom bindings for gui window */
@ -79,5 +81,6 @@ static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data
static void __CDECL evnt_window_keybd(WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_mbutton(WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
#endif

View File

@ -198,7 +198,7 @@ gui_create_browser_window(struct browser_window *bw,
memset( gw, 0, sizeof(struct gui_window) );
LOG(("new window: %p, bw: %p\n", gw, bw));
window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR );
window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
if( gw->root->handle ) {
window_open( gw );
/* Recalculate windows browser area now */