Refactored a lot of browser window code,... still totally WIP.

...but it compiles...
This commit is contained in:
Ole Loots 2012-11-27 02:12:09 +01:00
parent 6ea22068aa
commit fe0e2508e6
19 changed files with 1001 additions and 1504 deletions

View File

@ -62,14 +62,14 @@ extern struct gui_window *input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect );
static void browser_process_scroll( struct gui_window * gw, GRECT bwrect );
static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
struct rect * area );
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8],
static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8],
void * data);
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8],
static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8],
void * data);
static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8],
static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8],
void * data);
@ -104,7 +104,9 @@ struct s_browser * browser_create
return(NULL);
}
/* Attach events to the component: */
/* Attach events to the component: */
// TODO: implement event chaining in rootwin
/*
mt_CompEvntDataAdd( &app, bnew->comp, WM_XBUTTON,
browser_evnt_mbutton, (void*)gw, EV_BOT
);
@ -113,7 +115,8 @@ struct s_browser * browser_create
);
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
browser_evnt_destroy, (void*)bnew
);
);
*/
/* Set the gui_window owner. */
/* it is an link to the netsurf window system */
@ -135,76 +138,69 @@ bool browser_destroy( struct s_browser * b )
LOG(("%s\n", b->bw->name ));
assert( b != NULL );
assert( b->comp != NULL );
assert( b->bw != NULL );
struct gui_window * gw = b->bw->window;
LOG(("%s\n",gw->browser->bw->name));
assert( b != NULL );
assert( gw != NULL );
free( b );
gw->browser = NULL;
if( b->comp != NULL ){
mt_CompDelete(&app, b->comp );
}
return( true );
}
/*
Query the browser component for widget rectangles.
*/
void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out)
void browser_get_rect( struct gui_window * gw, enum browser_rect type, GRECT * out)
{
LGRECT cur;
GRECT cur;
// TODO: update browser get grect
/* Query component for it's current size: */
mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
/* And extract the different widget dimensions: */
if( type == BR_CONTENT ){
out->g_w = cur.g_w;
out->g_h = cur.g_h;
out->g_x = cur.g_x;
out->g_y = cur.g_y;
}
if (type == BR_CONTENT ) {
guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, out);
}
else if (type==BR_URL_INPUT) {
// TODO: calculate url input area somehow
guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
}
else if (type==BR_THROBBER) {
// TODO: calculate throbber area somehow
guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
}
return;
}
/* Report an resize to the COMPONENT interface */
void browser_update_rects(struct gui_window * gw )
{
short buff[8];
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&buff[4]);
buff[0] = CM_REFLOW;
buff[1] = _AESapid;
buff[2] = 0;
EvntExec(gw->root->handle, buff);
}
void browser_set_content_size(struct gui_window * gw, int w, int h)
{
CMP_BROWSER b = gw->browser;
LGRECT work;
GRECT work;
browser_get_rect( gw, BR_CONTENT, &work );
// TODO: implement new content size setter
//gw->root->handle->xpos_max = w;
//gw->root->handle->ypos_max = h;
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 );
browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
/* force update of scrollbars: */
b->scroll.required = true;
}
// 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 );
// browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
// /* force update of scrollbars: */
// b->scroll.required = true;
// }
}
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data)
static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
struct gui_window * gw = b->bw->window;
LOG(("%s\n",gw->browser->bw->name));
assert( b != NULL );
assert( gw != NULL );
free( b );
gw->browser = NULL;
LOG(("evnt_destroy done!"));
}
@ -212,10 +208,10 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da
Mouse Button handler for browser component.
*/
static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8], void * data)
{
short mx, my, dummy, mbut;
LGRECT cwork;
GRECT cwork;
browser_mouse_state bmstate = 0;
struct gui_window * gw = data;
@ -223,8 +219,8 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
input_window = gw;
}
window_set_focus( gw, BROWSER, (void*)gw->browser );
browser_get_rect( gw, BR_CONTENT, &cwork );
window_set_focus(gw->root, BROWSER, (void*)gw->browser );
browser_get_rect(gw, BR_CONTENT, &cwork );
/* convert screen coords to component coords: */
mx = evnt.mx - cwork.g_x;
@ -309,7 +305,7 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
*/
void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
{
LGRECT work;
GRECT work;
int max_y_scroll;
int max_x_scroll;
int oldx = gw->browser->scroll.current.x;
@ -399,7 +395,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
bwrect -> the dimensions of the browser, so that this function
doesn't need to get it.
*/
static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
static void browser_process_scroll( struct gui_window * gw, GRECT bwrect )
{
struct s_browser * b = gw->browser;
GRECT src;
@ -486,11 +482,12 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
if( b->caret.requested.g_w > 0 ){
b->caret.redraw = true;
}
// TODO: implement new sliding
//gw->root->handle->xpos = b->scroll.current.x;
//gw->root->handle->ypos = b->scroll.current.y;
gw->root->handle->xpos = b->scroll.current.x;
gw->root->handle->ypos = b->scroll.current.y;
mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
//mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
}
/*
@ -502,7 +499,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
*/
bool browser_input( struct gui_window * gw, unsigned short nkc )
{
LGRECT work;
GRECT work;
bool r = false;
unsigned char ascii = (nkc & 0xFF);
long ucs4;
@ -604,7 +601,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
{
assert( gw != NULL );
CMP_BROWSER b = gw->browser;
LGRECT work;
GRECT work;
if( y1 < 0 || x1 < 0 )
return;
@ -644,10 +641,10 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
/*
area: the browser canvas
*/
void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
void browser_restore_caret_background( struct gui_window * gw, GRECT * area)
{
CMP_BROWSER b = gw->browser;
LGRECT rect;
GRECT rect;
if( area == NULL ){
browser_get_rect( gw, BR_CONTENT, &rect );
area = &rect;
@ -668,7 +665,7 @@ void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
/*
area: the browser canvas
*/
void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
void browser_redraw_caret( struct gui_window * gw, GRECT * area )
{
if( gw->browser->caret.redraw && gw->browser->caret.requested.g_w > 0 ){
@ -677,12 +674,12 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
/* Only redraw caret when window is topped. */
wind_get( 0, WF_TOP, &wind_info[0], &wind_info[1], &wind_info[2], &wind_info[3]);
if (gw->root->handle->handle != wind_info[0]) {
if (guiwin_get_handle(gw->root->win) != wind_info[0]) {
return;
}
LGRECT caret;
GRECT caret;
struct s_browser * b = gw->browser;
struct rect old_clip;
struct rect clip;
@ -695,7 +692,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
caret.g_x -= b->scroll.current.x - area->g_x;
caret.g_y -= b->scroll.current.y - area->g_y;
if( !rc_lintersect( area, &caret ) ) {
if( !rc_intersect( area, &caret ) ) {
return;
}
@ -745,7 +742,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
void browser_redraw( struct gui_window * gw )
{
LGRECT bwrect;
GRECT bwrect;
struct s_browser * b = gw->browser;
short todo[4];
struct rect clip;
@ -788,7 +785,7 @@ void browser_redraw( struct gui_window * gw )
wind_get( 0, WF_TOP, &wf_top[0], &wf_top[1],
&wf_top[2], &wf_top[3] );
if( wf_top[0] == gw->root->handle->handle
if( wf_top[0] == guiwin_get_handle(gw->root->win)
&& wf_top[1] == _AESapid ){
/* The window is on top, so there is no need to walk the */
/* AES rectangle list. */
@ -824,8 +821,9 @@ void browser_redraw( struct gui_window * gw )
}
}
} else {
/* walk the AES rectangle list: */
if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
/* walk the AES rectangle list: */
short aes_handle = guiwin_get_handle(gw->root->win);
if( wind_get(aes_handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
/* convert screen to framebuffer coords: */
@ -862,7 +860,7 @@ void browser_redraw( struct gui_window * gw )
}
}
if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
if (wind_get(aes_handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@ -894,7 +892,7 @@ void browser_redraw( struct gui_window * gw )
b->redraw.areas_used = 0;
}
if( b->caret.redraw == true && b->bw->current_content != NULL ) {
LGRECT area;
GRECT area;
todo[0] = bwrect.g_x;
todo[1] = bwrect.g_y;
todo[2] = todo[0] + bwrect.g_w;
@ -912,27 +910,18 @@ void browser_redraw( struct gui_window * gw )
/* TODO: if we use offscreen bitmap, trigger content redraw here */
}
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8], void * data)
{
struct gui_window * gw = (struct gui_window *) data;
CMP_BROWSER b = gw->browser;
LGRECT work, lclip;
GRECT work, lclip;
browser_get_rect( gw, BR_CONTENT, &work );
lclip = work;
if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;
if ( !rc_intersect( (GRECT*)&buff[4], &lclip ) ) 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 );
if( b->bw->current_content == NULL ){
guiwin_clear(gw->root->win);
return;
}
@ -953,13 +942,15 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
if( lclip.g_h > 0 && lclip.g_w > 0 ) {
if( gw->browser->reformat_pending == true ){
LGRECT newsize;
GRECT newsize;
gw->browser->reformat_pending = false;
browser_get_rect(gw, BR_CONTENT, &newsize);
/* this call will also schedule an redraw for the complete */
/* area. */
/* Resize must be handled here, because otherwise */
/* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
/* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
// TODO: this was introduced because
// of bad knowledge about the AES system...
browser_window_reformat(b->bw, false, newsize.g_w, newsize.g_h );
} else {
browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,

View File

@ -35,10 +35,9 @@
enum browser_rect
{
BR_CONTENT = 1,
BR_FULL = 2,
BR_HSLIDER = 3,
BR_VSLIDER = 4
BR_CONTENT = 1,
BR_URL_INPUT,
BR_THROBBER
};
@ -60,8 +59,8 @@ struct s_scroll_info
*/
struct s_caret
{
LGRECT requested;
LGRECT current;
GRECT requested;
GRECT current;
bool redraw;
MFDB background;
};
@ -89,17 +88,21 @@ struct s_browser
bool reformat_pending;
};
struct s_browser * browser_create( struct gui_window * gw, struct browser_window * clone, struct browser_window *bw, int lt, int w, int flex );
struct s_browser * browser_create( struct gui_window * gw,
struct browser_window * clone,
struct browser_window *bw, int lt, int w,
int flex );
bool browser_destroy( struct s_browser * b );
void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out);
void browser_get_rect( struct gui_window * gw, enum browser_rect type,
GRECT * out);
bool browser_input( struct gui_window * gw, unsigned short nkc ) ;
void browser_redraw( struct gui_window * gw );
void browser_set_content_size(struct gui_window * gw, int w, int h);
void browser_scroll( struct gui_window * gw, short MODE, int value, bool abs );
struct gui_window * browser_find_root( struct gui_window * gw );
bool browser_redraw_required( struct gui_window * gw);
void browser_redraw_caret( struct gui_window * gw, LGRECT * area);
void browser_restore_caret_background(struct gui_window * gw, LGRECT * area);
void browser_redraw_caret( struct gui_window * gw, GRECT * area);
void browser_restore_caret_background(struct gui_window * gw, GRECT * area);
/* update loc / size of the browser widgets: */
void browser_update_rects(struct gui_window * gw );
/*

View File

@ -17,9 +17,11 @@
*/
#ifndef NS_ATARI_CLIPBOARD_H
#define NS_ATARI_CLIPBOARD_H
#define NS_ATARI_CLIPBOARD_H
#include <windom.h>
int scrap_txt_write( APPvar app, char *str);
char *scrap_txt_read( APPvar app );
#endif
#endif

View File

@ -68,7 +68,7 @@ struct s_context_info ctxinfo;
static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
{
hlcache_handle *h;
LGRECT bwrect;
GRECT bwrect;
struct contextual_content ccdata;
struct browser_window * bw = gw->browser->bw;

View File

@ -254,16 +254,15 @@ static void __CDECL menu_open_url(short item, short title, void *data)
if( gw == NULL ) {
bw = browser_window_create("", 0, 0, true, false);
gw = bw->window;
}
/* Loose focus: */
window_set_focus( gw, WIDGET_NONE, NULL );
window_set_focus(gw->root, WIDGET_NONE, NULL );
/* trigger on-focus event (select all text): */
window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
window_set_focus(gw->root, URL_WIDGET, NULL);
/* delete selection: */
tb_url_input( gw, NK_DEL );
toolbar_key_input(gw->root->toolbar, NK_DEL);
}
static void __CDECL menu_open_file(short item, short title, void *data)
@ -273,7 +272,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
const char * filename = file_select( messages_get("OpenFile"), "" );
const char * filename = file_select(messages_get("OpenFile"), "");
if( filename != NULL ){
char * url = local_file_to_url( filename );
if( url ){
@ -365,16 +364,18 @@ static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
tb_stop_click( input_window );
return;
assert(input_window->root);
toolbar_stop_click(input_window->root->toolbar);
}
static void __CDECL menu_reload(short item, short title, void *data)
{
if( input_window == NULL)
if(input_window == NULL)
return;
tb_reload_click( input_window );
toolbar_reload_click(input_window->root->toolbar);
LOG(("%s", __FUNCTION__));
}
@ -384,7 +385,8 @@ static void __CDECL menu_toolbars(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window != null && input_window->root->toolbar != null ){
state = !state;
tb_hide( input_window, state );
// TODO: implement toolbar hide
//toolbar_hide(input_window->root->toolbar, state );
}
}
@ -393,7 +395,8 @@ static void __CDECL menu_savewin(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
GRECT rect;
wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
wind_get_grect(guiwin_get_handle(input_window->root->win), WF_CURRXYWH,
&rect);
option_window_width = rect.g_w;
option_window_height = rect.g_h;
option_window_x = rect.g_x;
@ -414,7 +417,7 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
if( input_window != NULL ) {
if ( input_window->browser != NULL
&& input_window->browser->bw != NULL) {
LGRECT rect;
GRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
@ -443,7 +446,7 @@ static void __CDECL menu_back(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
tb_back_click( input_window );
toolbar_back_click(input_window->root->toolbar);
}
static void __CDECL menu_forward(short item, short title, void *data)
@ -451,7 +454,7 @@ static void __CDECL menu_forward(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
tb_forward_click( input_window );
toolbar_forward_click(input_window->root->toolbar);
}
static void __CDECL menu_home(short item, short title, void *data)
@ -459,7 +462,7 @@ static void __CDECL menu_home(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
tb_home_click( input_window );
toolbar_home_click(input_window->root->toolbar);
}
static void __CDECL menu_lhistory(short item, short title, void *data)

View File

@ -60,9 +60,11 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
#define GW_FLAG_TOOLBAR_REDRAW 0x10 // enable internal toolbar redraw
#define GW_FLAG_CUSTOM_SCROLLING 0x20 // no internal scroller handling
#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM)
#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM \
| GW_FLAG_TOOLBAR_REDRAW)
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
@ -112,7 +114,8 @@ bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip);
void guiwin_clear(GUIWIN *win);
/*
@ -124,6 +127,14 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
&& (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
#endif
#ifndef RC_WITHIN
#define RC_WITHIN(a,b) \
(((a)->g_x >= (b)->g_x) \
&& (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
&& (((a)->g_y >= (b)->g_y) \
&& (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
#endif
#ifndef MAX
#define MAX(_a,_b) ((_a>_b) ? _a : _b)
#endif

View File

@ -5,6 +5,8 @@
#include <assert.h>
#include <cflib.h>
#include <gem.h>
#include <mt_gem.h>
#include "gemtk.h"
@ -27,13 +29,15 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
static void move_rect(GRECT *rect, int dx, int dy)
static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
{
INT16 xy[ 8];
long dum = 0L;
GRECT g;
while( !wind_update(BEG_UPDATE));
VdiHdl vh = guiwin_get_vdi_handle(win);
while(!wind_update(BEG_UPDATE));
graf_mouse(M_OFF, 0L);
/* get intersection with screen area */
@ -47,7 +51,7 @@ static void move_rect(GRECT *rect, int dx, int dy)
xy[5] = xy[1] + dy;
xy[6] = xy[2] + dx;
xy[7] = xy[3] + dy;
vro_cpyfm(v_vdi_h, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
vro_cpyfm(vh, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
graf_mouse(M_ON, 0L);
wind_update(END_UPDATE);
@ -81,7 +85,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_h -= abs_pix;
move_rect(&g, 0, abs_pix);
move_rect(gw, &g, 0, abs_pix);
g.g_y = g_ro.g_y;
g.g_h = abs_pix;
redraw = &g;
@ -89,7 +93,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_y += abs_pix;
g.g_h -= abs_pix;
move_rect(&g, 0, -abs_pix);
move_rect(gw, &g, 0, -abs_pix);
g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
g.g_h = abs_pix;
redraw = &g;
@ -112,7 +116,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_w -= abs_pix;
move_rect(&g, abs_pix, 0);
move_rect(gw, &g, abs_pix, 0);
g.g_x = g_ro.g_x;
g.g_w = abs_pix;
redraw = &g;
@ -120,7 +124,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_x += abs_pix;
g.g_w -= abs_pix;
move_rect(&g, -abs_pix, 0);
move_rect(gw, &g, -abs_pix, 0);
g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
g.g_w = abs_pix;
redraw = &g;
@ -292,7 +296,8 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_REDRAW:
if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
if ((gw->flags & GW_FLAG_TOOLBAR_REDRAW)
&& (gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
g.g_x = msg[4];
g.g_y = msg[5];
g.g_w = msg[6];
@ -375,8 +380,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
// toolbar handling:
if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
dest->toolbar != NULL) {
if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0
&& dest->toolbar != NULL) {
GRECT tb_area;
guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x,
@ -394,10 +399,12 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if (((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0)
&& obj_idx > 0) {
dest->toolbar[obj_idx].ob_state |= OS_SELECTED;
// TODO: optimize redraw by setting the object clip:
guiwin_toolbar_redraw(dest, NULL);
}
short oldevents = ev_out->emo_events;
ev_out->emo_events = MU_MESAG;
// notify the window about toolbar click:
dest->handler_func(dest, ev_out, msg_out);
handler_called=true;
ev_out->emo_events = oldevents;
@ -590,6 +597,11 @@ short guiwin_get_handle(GUIWIN *win)
return(win->handle);
}
VdiHdl guiwin_get_vdi_handle(GUIWIN *win)
{
return(v_vdi_h);
}
uint32_t guiwin_get_state(GUIWIN *win)
{
return(win->state);
@ -649,13 +661,6 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
{
#define RC_WITHIN(a,b) \
(((a)->g_x >= (b)->g_x) \
&& (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
&& (((a)->g_y >= (b)->g_y) \
&& (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
GRECT area, mywork;
bool retval = true;
@ -674,9 +679,6 @@ bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
}
return(retval);
#undef RC_WITHIN
}
void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
@ -684,9 +686,6 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
GRECT tb_area, tb_area_ro, g;
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
if(tb_area_ro.g_h <= 0 || tb_area_ro.g_w <= 0) {
return;
}
if(clip == NULL) {
clip = &tb_area_ro;
@ -695,6 +694,7 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
tb_area = tb_area_ro;
if(rc_intersect(clip, &tb_area)) {
// Update object position:
gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
@ -712,11 +712,37 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
}
}
}
/*
void guiwin_exec_redraw(){
void guiwin_clear(GUIWIN *win)
{
GRECT area, g;
short pxy[4];
VdiHdl vh;
vh = guiwin_get_vdi_handle(win);
if(win->state & GW_STATUS_ICONIFIED){
// also clear the toolbar area when iconified:
guiwin_get_grect(win, GUIWIN_AREA_WORK, &area);
} else {
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
}
vsf_interior(vh, FIS_SOLID);
vsf_color(vh, 0);
vswr_mode(vh, MD_REPLACE);
wind_get_grect(win->handle, WF_FIRSTXYWH, &g);
while (g.g_h > 0 || g.g_w > 0) {
if(rc_intersect(&area, &g)) {
pxy[0] = g.g_x;
pxy[1] = g.g_y;
pxy[2] = g.g_x+g.g_w-1;
pxy[3] = g.g_y+g.g_h-1;
v_bar(vh, pxy);
}
wind_get_grect(win->handle, WF_NEXTXYWH, &g);
}
}
*/

View File

@ -65,7 +65,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
static short prev_x=0;
static short prev_y=0;
bool within = false;
LGRECT urlbox, bwbox, sbbox;
GRECT urlbox, bwbox, sbbox;
int nx, ny;
if (gw == NULL)
@ -76,15 +76,13 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
short ghandle = wind_find( evnt.mx, evnt.my );
if (input_window->root->handle->handle == ghandle) {
if (guiwin_get_handle(input_window->root->win)==ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
browser_get_rect(gw, BR_CONTENT, &bwbox);
if (POINT_WITHIN(evnt.mx, evnt.my, bwbox)) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@ -95,9 +93,8 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
browser_get_rect(gw, BR_URL_INPUT, &urlbox);
if(POINT_WITHIN(evnt.mx, evnt.my, urlbox)) {
gem_set_cursor( &gem_cursors.ibeam );
prev_url = true;
} else {
@ -116,7 +113,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
prev_y = evnt.my;
}
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
{
long kstate = 0;
long kcode = 0;
@ -134,18 +131,19 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
nkc= gem_to_norm( (short)kstate, (short)kcode );
nks = (nkc & 0xFF00);
if( kstate & (K_LSHIFT|K_RSHIFT))
kstate |= K_LSHIFT|K_RSHIFT;
if( window_url_widget_has_focus( gw ) ) {
kstate |= K_LSHIFT|K_RSHIFT;
if(window_url_widget_has_focus((void*)gw->root)) {
/* make sure we report for the root window and report...: */
done = tb_url_input( gw, nkc );
done = toolbar_key_input(gw->root->toolbar, nkc);
} else {
gw_tmp = window_list;
/* search for active browser component: */
while( gw_tmp != NULL && done == false ) {
/* todo: only handle when input_window == ontop */
if( window_widget_has_focus( (struct gui_window *)input_window,
BROWSER,(void*)gw_tmp->browser)) {
done = browser_input( gw_tmp, nkc );
if( window_widget_has_focus(input_window->root, BROWSER,
(void*)gw_tmp->browser)) {
done = browser_input(gw_tmp, nkc);
break;
} else {
gw_tmp = gw_tmp->next;

View File

@ -116,47 +116,6 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
unsigned short nks = 0;
int i=0;
bool done = false;
struct gui_window * gw = input_window;
struct gui_window * gw_tmp;
if( gw == NULL )
return;
kstate = evnt.mkstate;
kcode = evnt.keybd;
nkc= gem_to_norm( (short)kstate, (short)kcode);
nks = (nkc & 0xFF00);
if( kstate & (K_LSHIFT|K_RSHIFT))
kstate |= K_LSHIFT|K_RSHIFT;
if( window_url_widget_has_focus( gw ) ) {
/* make sure we report for the root window and report...: */
done = tb_url_input( gw, nkc );
} else {
gw_tmp = window_list;
/* search for active browser component: */
while( gw_tmp != NULL && done == false ) {
/* todo: only handle when input_window == ontop */
if( window_widget_has_focus( (struct gui_window *)input_window,
BROWSER,(void*)gw_tmp->browser)) {
done = browser_input( gw_tmp, nkc );
break;
} else {
gw_tmp = gw_tmp->next;
}
}
}
if(!done)
deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
void gui_poll(bool active)
{
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
@ -167,11 +126,30 @@ void gui_poll(bool active)
aes_event_in.emi_tlow = schedule_run();
//printf("time: ");
if(active || rendering)
aes_event_in.emi_tlow = 0;
struct gui_window * g;
for( g = window_list; g != NULL; g=g->next ) {
if( browser_redraw_required( g ) ) {
browser_redraw(g);
}
if(g->root->toolbar) {
//if(g->root->toolbar->url.redraw ) {
// TODO: implement toolbar redraw mechanism
//tb_url_redraw( g );
//}
}
}
if( !active ) {
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
global_history_redraw();
}
// Handle events until there are no more messages pending or
// until the engine indicates activity:
do {
@ -201,66 +179,8 @@ void gui_poll(bool active)
}
} while ( gui_poll_repeat && !(active||rendering));
if( !active ) {
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
global_history_redraw();
}
}
void gui_poll_old(bool active)
{
short winloc[4];
// int timeout; /* timeout in milliseconds */
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
short mx, my, dummy;
evnt.timer = schedule_run();
if( active || rendering ) {
if( clock() >= next_poll ) {
evnt.timer = 0;
flags |= MU_TIMER;
EvntWindom( flags );
next_poll = clock() + (CLOCKS_PER_SEC>>3);
}
} else {
if (input_window != NULL) {
wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
if (winloc[1] == _AESapid) {
/* only check for mouse move when netsurf is on top: */
// move that into m1 event handler
graf_mkstate( &mx, &my, &dummy, &dummy );
flags |= MU_M1;
evnt.m1_flag = MO_LEAVE;
evnt.m1_w = evnt.m1_h = 1;
evnt.m1_x = mx;
evnt.m1_y = my;
}
}
flags |= MU_TIMER;
EvntWindom( flags );
}
struct gui_window * g;
for( g = window_list; g != NULL; g=g->next ) {
if( browser_redraw_required( g ) ) {
browser_redraw( g );
}
if( g->root->toolbar ) {
if(g->root->toolbar->url.redraw ) {
tb_url_redraw( g );
}
}
}
if( evnt.timer != 0 && !active ) {
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
global_history_redraw();
}
}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
@ -271,22 +191,24 @@ gui_create_browser_window(struct browser_window *bw,
(int)new_tab
));
gw = malloc( sizeof(struct gui_window) );
gw = calloc( sizeof(struct gui_window), 1);
if (gw == NULL)
return NULL;
memset( gw, 0, sizeof(struct gui_window) );
LOG(("new window: %p, bw: %p\n", gw, bw));
window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
if( gw->root->handle ) {
window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
|WIDGET_SCROLL);
if (gw->root->win) {
GRECT pos = {
option_window_x, option_window_y,
option_window_width, option_window_height
};
window_open( gw , pos );
gui_window_set_url(gw, "");
gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
window_set_active_gui_window(gw->root, gw);
window_open(gw->root, pos );
/* Recalculate windows browser area now */
browser_update_rects( gw );
tb_update_buttons( gw, -1 );
toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@ -319,7 +241,11 @@ void gui_window_destroy(struct gui_window *w)
input_window = NULL;
window_destroy(w);
search_destroy(w);
browser_destroy(w->browser);
free(w->status);
free(w->title);
free(w->url);
/* unlink the window: */
if(w->prev != NULL ) {
@ -330,16 +256,21 @@ void gui_window_destroy(struct gui_window *w)
if( w->next != NULL ) {
w->next->prev = w->prev;
}
window_unref_gui_window(w->root, w);
free(w);
w = NULL;
w = window_list;
while( w != NULL ) {
if( w->root ) {
input_window = w;
break;
if(input_window == NULL){
w = window_list;
while( w != NULL ) {
if(w->root) {
input_window = w;
break;
}
w = w->next;
}
w = w->next;
}
}
@ -348,7 +279,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
{
if (w == NULL)
return;
LGRECT rect;
GRECT rect;
browser_get_rect( w, BR_CONTENT, &rect );
*width = rect.g_w;
*height = rect.g_h;
@ -356,21 +287,34 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
void gui_window_set_title(struct gui_window *gw, const char *title)
{
int l;
char * conv;
if (gw == NULL)
return;
if( gw->root ) {
l = strlen(title);
if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
if (gw->root) {
int l;
char * conv;
l = strlen(title)+1;
if (utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
l = MIN((uint32_t)atari_sysinfo.aes_max_win_title_len, strlen(conv));
if(gw->title == NULL)
gw->title = malloc(l);
else
gw->title = realloc(gw->title, l);
strncpy(gw->title, conv, l);
free( conv );
} else {
strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
l = MIN((size_t)atari_sysinfo.aes_max_win_title_len, strlen(title));
if(gw->title == NULL)
gw->title = malloc(l);
else
gw->title = realloc(gw->title, l);
strncpy(gw->title, title, l);
}
gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
if(input_window == gw)
window_set_title(gw->root, gw->title);
}
}
@ -379,20 +323,34 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
*/
void gui_window_set_status(struct gui_window *w, const char *text)
{
if (w == NULL || text == NULL )
int l;
if (w == NULL || text == NULL)
return;
window_set_stauts(w, (char*)text );
assert(w->root);
l = strlen(text)+1;
if(w->status == NULL)
w->status = malloc(l);
else
w->status = realloc(w->status, l);
strncpy(w->status, text, l);
w->status[l-1] = 0;
if(input_window == w)
window_set_stauts(w->root, (char*)text);
}
void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;
LGRECT rect;
GRECT rect;
if (gw == NULL)
return;
b = gw->browser;
browser_get_rect( gw, BR_CONTENT, &rect );
browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
browser_get_rect(gw, BR_CONTENT, &rect);
browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
@ -479,75 +437,80 @@ void gui_clear_selection(struct gui_window *g)
/**
* set the pointer shape
*/
void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
{
if (w == NULL)
if (gw == NULL)
return;
switch (shape) {
case GUI_POINTER_POINT: /* link */
gem_set_cursor(&gem_cursors.hand);
gw->cursor = &gem_cursors.hand;
break;
case GUI_POINTER_MENU:
gem_set_cursor(&gem_cursors.menu);
gw->cursor = &gem_cursors.menu;
break;
case GUI_POINTER_CARET: /* input */
gem_set_cursor(&gem_cursors.ibeam);
gw->cursor = &gem_cursors.ibeam;
break;
case GUI_POINTER_CROSS:
gem_set_cursor(&gem_cursors.cross);
gw->cursor = &gem_cursors.cross;
break;
case GUI_POINTER_MOVE:
gem_set_cursor(&gem_cursors.sizeall);
gw->cursor = &gem_cursors.sizeall;
break;
case GUI_POINTER_RIGHT:
case GUI_POINTER_LEFT:
gem_set_cursor(&gem_cursors.sizewe);
gw->cursor = &gem_cursors.sizewe;
break;
case GUI_POINTER_UP:
case GUI_POINTER_DOWN:
gem_set_cursor(&gem_cursors.sizens);
gw->cursor = &gem_cursors.sizens;
break;
case GUI_POINTER_RU:
case GUI_POINTER_LD:
gem_set_cursor(&gem_cursors.sizenesw);
gw->cursor = &gem_cursors.sizenesw;
break;
case GUI_POINTER_RD:
case GUI_POINTER_LU:
gem_set_cursor(&gem_cursors.sizenwse);
gw->cursor = &gem_cursors.sizenwse;
break;
case GUI_POINTER_WAIT:
gem_set_cursor(&gem_cursors.wait);
gw->cursor = &gem_cursors.wait;
break;
case GUI_POINTER_PROGRESS:
gem_set_cursor(&gem_cursors.appstarting);
gw->cursor = &gem_cursors.appstarting;
break;
case GUI_POINTER_NO_DROP:
gem_set_cursor(&gem_cursors.nodrop);
gw->cursor = &gem_cursors.nodrop;
break;
case GUI_POINTER_NOT_ALLOWED:
gem_set_cursor(&gem_cursors.deny);
gw->cursor = &gem_cursors.deny;
break;
case GUI_POINTER_HELP:
gem_set_cursor(&gem_cursors.help);
gw->cursor = &gem_cursors.help;
break;
default:
gem_set_cursor(&gem_cursors.arrow);
gw->cursor = &gem_cursors.arrow;
break;
}
if (input_window == gw) {
gem_set_cursor(gw->cursor);
}
}
void gui_window_hide_pointer(struct gui_window *w)
@ -558,9 +521,23 @@ void gui_window_hide_pointer(struct gui_window *w)
void gui_window_set_url(struct gui_window *w, const char *url)
{
int l;
if (w == NULL)
return;
tb_url_set(w, (char*)url );
l = strlen(url)+1;
if (w->url == NULL) {
w->url = malloc(l);
} else {
w->url = realloc(w->url, l);
}
strncpy(w->url, url, l);
if(input_window == w->root->active_gui_window){
toolbar_set_url(w->root->toolbar, url);
}
}
static void throbber_advance( void * data )
@ -571,32 +548,33 @@ static void throbber_advance( void * data )
return;
if( gw->root->toolbar == NULL )
return;
if( gw->root->toolbar->throbber.running == false )
return;
mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
WF_WORKXYWH, &work);
gw->root->toolbar->throbber.index++;
if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
// TODO: implement access to throbber
//if( gw->root->toolbar->throbber.running == false)
// return;
// mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
// WF_WORKXYWH, &work);
// gw->root->toolbar->throbber.index++;
// if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
// gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
// ApplWrite(_AESapid, WM_REDRAW, guiwin_get_handle(gw->root->win),
// work.g_x, work.g_y, work.g_w, work.g_h);
schedule(100, throbber_advance, gw );
}
void gui_window_start_throbber(struct gui_window *w)
{
LGRECT work;
GRECT work;
if (w == NULL)
return;
if( w->root->toolbar->throbber.running == true )
return;
mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
WF_WORKXYWH, &work);
w->root->toolbar->throbber.running = true;
w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
// TODO: implement throbber acess
//if( w->root->toolbar->throbber.running == true )
// return;
// browser_get_rect(w, BR_THROBBER, &work);
// w->root->toolbar->throbber.running = true;
// w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
schedule(100, throbber_advance, w );
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
// work.g_x, work.g_y, work.g_w, work.g_h );
rendering = true;
}
@ -606,20 +584,22 @@ void gui_window_stop_throbber(struct gui_window *w)
LGRECT work;
if (w == NULL)
return;
if( w->root->toolbar->throbber.running == false )
return;
// TODO: implement something like throbber_is_running();
//if( w->root->toolbar->throbber.running == false )
// return;
schedule_remove(throbber_advance, w);
/* refresh toolbar buttons: */
tb_update_buttons( w, -1 );
toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
/* redraw throbber: */
mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
WF_WORKXYWH, &work);
w->root->toolbar->throbber.running = false;
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
// mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
// WF_WORKXYWH, &work);
// w->root->toolbar->throbber.running = false;
// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
// work.g_x, work.g_y, work.g_w, work.g_h );
// TODO: send throbber redraw
rendering = false;
}
@ -663,8 +643,11 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
struct bitmap *bmp_icon;
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
g->icon = bmp_icon;
window_set_icon(g, bmp_icon);
if(input_window == g){
window_set_icon(g->root, bmp_icon);
}
}
void

View File

@ -19,7 +19,7 @@
#ifndef NS_ATARI_GUI_H_
#define NS_ATARI_GUI_H_
#include <windom.h>
#include "atari/gemtk/gemtk.h"
struct point_s {
int x;
@ -96,17 +96,18 @@ typedef struct s_browser * CMP_BROWSER;
*/
struct s_gui_win_root
{
WINDOW * handle;
GUIWIN *win;
CMP_TOOLBAR toolbar;
CMP_STATUSBAR statusbar;
COMPONENT * cmproot;
MFORM_EX cursor;
struct s_focus_info focus;
float scale;
char * title;
struct bitmap * icon;
struct gui_window *active_gui_window;
/* current size of window on screen: */
GRECT loc;
};
typedef struct s_gui_win_root ROOTWIN;
/*
This is the part of the gui which is known by netsurf core.
@ -117,7 +118,11 @@ struct s_gui_win_root
struct gui_window {
struct s_gui_win_root * root;
CMP_BROWSER browser;
MFORM_EX *cursor;
/* icon to be drawn when iconified, or NULL for default resource. */
char * status;
char * title;
char * url;
struct bitmap * icon;
struct gui_window *next, *prev;
};

View File

@ -121,8 +121,8 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
while(gw != NULL) {
if( gw->root->handle != NULL
&& gw->root->handle->handle == handle ) {
if( gw->root->win != NULL
&& guiwin_get_handle(gw->root->win) == handle ) {
return(gw);
}
else
@ -133,21 +133,6 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
struct gui_window * find_cmp_window( COMPONENT * c )
{
struct gui_window * gw;
gw = window_list;
while( gw != NULL ) {
assert( gw->browser != NULL );
if( gw->browser->comp == c ) {
return( gw );
}
else
gw = gw->next;
}
return( NULL );
}
static int scan_process_list(scan_process_callback cb, void *data)
{
int pid, count = 0;

View File

@ -19,6 +19,7 @@
#ifndef NS_ATARI_MISC_H
#define NS_ATARI_MISC_H
#include <windom.h>
#include "cflib.h"
#include "content/content.h"
#include "content/hlcache.h"
@ -43,7 +44,6 @@
typedef int (*scan_process_callback)(int pid, void *data);
struct gui_window * find_guiwin_by_aes_handle(short handle);
struct gui_window * find_cmp_window( COMPONENT * c );
bool is_process_running(const char * name);
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,

Binary file not shown.

View File

@ -41,11 +41,14 @@
#define MAINMENU_M_HELP_CONTENT 61 /* STRING in tree MAINMENU */
#define TOOLBAR 1 /* form/dial */
#define TOOLBAR_NAVIGATION_AREA 1 /* BOX in tree TOOLBAR */
#define TOOLBAR_BT_BACK 2 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_HOME 3 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_FORWARD 4 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_STOP 5 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_RELOAD 6 /* CICON in tree TOOLBAR */
#define TOOLBAR_URL_AREA 7 /* BOX in tree TOOLBAR */
#define TOOLBAR_THROBBER_AREA 8 /* BOX in tree TOOLBAR */
#define ICONIFY 2 /* form/dial */
#define ICONIFY_GLOBE 1 /* CICON in tree ICONIFY */

View File

@ -3,7 +3,7 @@ ResourceMaster v3.65
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
#M 20010100@0@7728@610@
#M 20010100@0@7728@618@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@ -43,12 +43,15 @@ ResourceMaster v3.65
#O 58@28@M_CHOICES@@
#O 59@28@M_VLOG@@
#O 61@28@M_HELP_CONTENT@@
#T 1@2@TOOLBAR@@7@@
#T 1@2@TOOLBAR@@9@@
#O 1@20@NAVIGATION_AREA@@
#O 2@33@BT_BACK@@
#O 3@33@BT_HOME@@
#O 4@33@BT_FORWARD@@
#O 5@33@BT_STOP@@
#O 6@33@BT_RELOAD@@
#O 7@20@URL_AREA@@
#O 8@20@THROBBER_AREA@@
#T 2@2@ICONIFY@@3@@
#O 1@33@GLOBE@@
#T 3@2@FAVICON@@2@@
@ -195,4 +198,4 @@ ResourceMaster v3.65
#O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
#c 2361@
#c 770@

View File

@ -61,23 +61,19 @@
extern struct gui_window *input_window;
struct rootwin_data_s {
struct s_gui_win_root *rootwin;
};
/* -------------------------------------------------------------------------- */
/* Static module methods follow here: */
/* Static module methods: */
/* -------------------------------------------------------------------------- */
//static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
//void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
static void redraw(GUIWIN *win, short msg[8]);
static void resized(GUIWIN *win);
static void file_dropped(GUIWIN *win, short msg[8]);
//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
#define FIND_NS_GUI_WINDOW(w) \
find_guiwin_by_aes_handle(guiwin_get_handle(w));
@ -90,6 +86,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
struct gui_window * gw;
struct rootwin_data_s * data = guiwin_get_user_data(win);
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
// handle message
printf("root win msg: %d\n", msg[0]);
@ -107,8 +105,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_ICONIFY:
gw = FIND_NS_GUI_WINDOW(win);
if( input_window == gw) {
data = guiwin_get_user_data(win);
if( input_window->root == data->rootwin) {
input_window = NULL;
}
break;
@ -116,13 +114,17 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
input_window = FIND_NS_GUI_WINDOW(win);
data = guiwin_get_user_data(win);
input_window = data->rootwin->active_gui_window;
break;
case WM_CLOSED:
gw = FIND_NS_GUI_WINDOW(win);
// TODO: this needs to iterate through all gui windows and
// check if the rootwin is this window...
data = guiwin_get_user_data(win);
gw = data->rootwin->active_gui_window;
if( gw != NULL ) {
browser_window_destroy(gw->browser->bw );
browser_window_destroy(gw->browser->bw);
}
break;
@ -185,176 +187,177 @@ int window_create(struct gui_window * gw,
return( -1 );
memset( gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
gw->root->handle = WindCreate(flags, 40, 40, app.w, app.h);
if( gw->root->handle == NULL ) {
// TODO: use desk size
short aes_handle = wind_create(flags, 40, 40, app.w, app.h);
if(aes_handle<0) {
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);
gw->root->win = guiwin_add(aes_handle,
GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
/* create toolbar component: */
if( tb ) {
gw->root->toolbar = tb_create( gw );
assert( gw->root->toolbar );
mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
gw->root->toolbar = toolbar_create(gw->root);
assert(gw->root->toolbar);
} else {
gw->root->toolbar = NULL;
}
/* create browser component: */
gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
/* create statusbar component: */
if( sb ) {
gw->root->statusbar = sb_create( gw );
#ifdef WITH_COMOPONENT_STATUSBAR
mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
#endif
} else {
gw->root->statusbar = NULL;
}
WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
wind_set_str(aes_handle, WF_ICONTITLE, (char*)"NetSurf");
wind_set(aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0);
wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0);
wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0);
/* Event Handlers: */
// EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
/* capture resize/move events so we can handle that manually */
// EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
// EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
// EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
EvntDataAdd(gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
EvntDataAdd(gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
// EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
// EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
// EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
// EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
// EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
// EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
data->rootwin = gw->root;
guiwin_set_user_data(gw->root->win, (void*)data);
if (inflags & WIN_TOP) {
window_set_focus( gw, BROWSER, gw->browser);
window_set_focus(gw->root, BROWSER, gw->browser);
}
GUIWIN * guiwin = guiwin_add(gw->root->handle->handle,
GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
guiwin_set_toolbar(guiwin, get_tree(TOOLBAR), 0, 0);
return (err);
}
int window_destroy(struct gui_window * gw)
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
{
struct gui_window *w;
input_window = NULL;
LOG(("window: %p, gui_window: %p", rootwin, gw));
w = window_list;
// find the next active tab:
while( w != NULL ) {
if(w->root == rootwin && w != gw) {
input_window = w;
break;
}
w = w->next;
}
if(input_window == NULL){
// the last gui window for this rootwin was removed:
window_destroy(rootwin);
}
}
int window_destroy(ROOTWIN *rootwin)
{
int err = 0;
struct gui_window *w;
search_destroy( gw );
if( input_window == gw )
input_window = NULL;
assert(rootwin != NULL);
if( gw->root ) {
if( gw->root->toolbar )
tb_destroy( gw->root->toolbar );
LOG(("%p", rootwin));
if( gw->root->statusbar )
sb_destroy( gw->root->statusbar );
if (guiwin_get_user_data(rootwin->win) != NULL) {
free(guiwin_get_user_data(rootwin->win));
}
search_destroy( gw );
guiwin_remove(guiwin_find(gw->root->handle->handle));
if( gw->browser )
browser_destroy( gw->browser );
/* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
if( gw->root ) {
/* TODO: check if no other browser is bound to this root window! */
/* only needed for tabs */
if( gw->root->title )
free( gw->root->title );
if( gw->root->cmproot )
mt_CompDelete( &app, gw->root->cmproot );
ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
EvntWindom( MU_MESAG );
gw->root->handle = NULL;
free(gw->root);
gw->root = NULL;
// make sure we do not destroy windows which have gui_windows attached:
w = window_list;
while( w != NULL ) {
if(w->root == rootwin) {
assert(rootwin == NULL);
}
w = w->next;
}
if (rootwin->toolbar)
toolbar_destroy(rootwin->toolbar);
if(rootwin->statusbar)
sb_destroy(rootwin->statusbar);
if(rootwin->title)
free(rootwin->title);
guiwin_remove(rootwin->win);
free(rootwin);
return(err);
}
void window_open( struct gui_window * gw, GRECT pos )
void window_open(ROOTWIN *rootwin, GRECT pos)
{
LGRECT br;
GRECT br;
WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
WindClear( gw->root->handle );
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
short aes_handle = guiwin_get_handle(rootwin->win);
wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
wind_set_str(aes_handle, WF_NAME, (char *)"");
/* apply focus to the root frame: */
long lfbuff[8] = { CM_GETFOCUS };
mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
/* recompute the nested component sizes and positions: */
browser_update_rects( gw );
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
browser_get_rect( gw, BR_CONTENT, &br );
plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
gw->browser->attached = true;
if( gw->root->statusbar != NULL ) {
sb_attach(gw->root->statusbar, gw);
rootwin->active_gui_window->browser->attached = true;
if(rootwin->statusbar != NULL) {
sb_attach(rootwin->statusbar, rootwin->active_gui_window);
}
tb_adjust_size( gw );
/*TBD: get already present content and set size? */
input_window = gw;
window_set_focus( gw, BROWSER, gw->browser );
input_window = rootwin->active_gui_window;
window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
}
/* update back forward buttons (see tb_update_buttons (bug) ) */
void window_update_back_forward( struct gui_window * gw)
void window_update_back_forward(struct s_gui_win_root *rootwin)
{
tb_update_buttons( gw, -1 );
struct gui_window * active_gw = rootwin->active_gui_window;
toolbar_update_buttons(rootwin->toolbar, active_gw->browser->bw, -1);
}
void window_set_stauts(struct gui_window * gw , char * text )
void window_set_stauts(struct s_gui_win_root *rootwin, char * text)
{
if( gw->root == NULL )
assert(rootwin != NULL);
CMP_STATUSBAR sb = rootwin->statusbar;
if( sb == NULL)
return;
CMP_STATUSBAR sb = gw->root->statusbar;
if(text != NULL)
sb_set_text(sb, text);
else
sb_set_text(sb, "");
}
if( sb == NULL || gw->browser->attached == false )
return;
sb_set_text( sb, text );
void window_set_title(struct s_gui_win_root * rootwin, char *title)
{
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
/* set focus to an arbitary element */
void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element)
void window_set_focus(struct s_gui_win_root *rootwin,
enum focus_element_type type, void * element)
{
if( gw->root->focus.type != type || gw->root->focus.element != element ) {
struct text_area * ta;
assert(rootwin != NULL);
if (rootwin->focus.type != type || rootwin->focus.element != element) {
LOG(("Set focus: %p (%d)\n", element, type));
gw->root->focus.type = type;
gw->root->focus.element = element;
rootwin->focus.type = type;
rootwin->focus.element = element;
if( element != NULL ) {
switch( type ) {
case URL_WIDGET:
textarea_keypress(((struct s_url_widget*)(element))->textarea,
KEY_SELECT_ALL );
// TODO: make something like: toolbar_text_select_all();
ta = toolbar_get_textarea(rootwin->toolbar,
URL_INPUT_TEXT_AREA);
textarea_keypress(ta, KEY_SELECT_ALL);
break;
default:
@ -366,63 +369,82 @@ void window_set_focus(struct gui_window * gw, enum focus_element_type type, void
}
/* check if the url widget has focus */
bool window_url_widget_has_focus( struct gui_window * gw )
bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
{
assert( gw );
assert( gw->root );
if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
assert( GUIWIN_VISIBLE(gw) );
assert(rootwin != NULL);
if (rootwin->focus.type == URL_WIDGET) {
return true;
}
return false;
}
/* check if an arbitary window widget / or frame has the focus */
bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
bool window_widget_has_focus(struct s_gui_win_root *rootwin,
enum focus_element_type t, void * element)
{
if( gw == NULL )
return( false );
assert(rootwin != NULL);
if( element == NULL ) {
assert( 1 != 0 );
return( (gw->root->focus.type == t ) );
return((rootwin->focus.type == t));
}
assert( gw->root != NULL );
return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
return((element == rootwin->focus.element && t == rootwin->focus.type));
}
void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
{
gw->icon = bmp;
rootwin->icon = bmp;
/* redraw window when it is iconyfied: */
if (gw->icon != NULL) {
if (rootwin->icon != NULL) {
short info, dummy;
WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
if (info == 1) {
window_redraw_favicon(gw, NULL);
if (guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
window_redraw_favicon(rootwin, NULL);
}
}
}
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
{
if (rootwin->active_gui_window != NULL) {
if(rootwin->active_gui_window == gw){
return;
}
}
rootwin->active_gui_window = gw;
window_set_icon(rootwin, gw->icon);
window_set_stauts(rootwin, gw->status);
window_set_title(rootwin, gw->title);
toolbar_set_url(rootwin->toolbar, gw->url);
// TODO: implement window_restore_browser()
// window_restore_browser(gw->browser);
}
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
{
return(rootwin->active_gui_window);
}
/**
* Redraw the favicon
*/
void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
{
GRECT work;
assert(gw->root);
assert(rootwin);
WINDOW * bw = gw->root->handle;
guiwin_clear(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
WindClear(bw);
WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
if (clip == NULL) {
clip = &work;
} else {
if(!rc_intersect(&work, clip)){
return;
}
}
if (gw->icon == NULL) {
if (rootwin->icon == NULL) {
OBJECT * tree = get_tree(ICONIFY);
tree->ob_x = work.g_x;
tree->ob_y = work.g_y;
@ -439,7 +461,7 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
}
plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
plot_clip(&work_clip);
atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
atari_plotters.bitmap(0, 0, work.g_w, work.g_h, rootwin->icon, 0xffffff, 0);
}
}
@ -448,16 +470,16 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
{
bool abs = false;
LGRECT cwork;
GRECT cwork;
struct gui_window * gw = data;
int value = BROWSER_SCROLL_SVAL;
assert( gw != NULL );
browser_get_rect( gw, BR_CONTENT, &cwork );
browser_get_rect(gw, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
@ -602,31 +624,56 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
static void redraw(GUIWIN *win, short msg[8])
{
short handle;
struct gui_window *gw;
handle = guiwin_get_handle(win);
gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
assert(gw != NULL);
struct rootwin_data_s *data = guiwin_get_user_data(win);
ROOTWIN *rootwin = data->rootwin;
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(gw, &clip);
window_redraw_favicon(rootwin, &clip);
} else {
GRECT content_area, tb_area;
short pxy[8];
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area);
guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
struct rect clip = {0,0,content_area.g_w,content_area.g_h};
plot_set_dimensions(content_area.g_x, content_area.g_y,
content_area.g_w,content_area.g_h);
//plot_clip(&clip);
plot_rectangle(0, 0, content_area.g_w,
content_area.g_h, plot_style_broken_object);
if (rc_intersect(&tb_area, &clip)) {
toolbar_set_dimensions(rootwin->toolbar, &tb_area);
toolbar_redraw(rootwin->toolbar, clip);
}
//WindClear(gw->root->handle);
CMP_BROWSER browser = rootwin->active_gui_window->browser;
if (browser->reformat_pending == true) {
browser_window_reformat(browser->bw, false, content_area.g_w,
content_area.g_h );
} else {
if(rc_intersect(&content_area, &clip)){
GRECT lclip = content_area;
/* convert redraw coords to framebuffer coords: */
lclip.g_x -= content_area.g_x;
lclip.g_y -= content_area.g_y;
if( lclip.g_x < 0 ) {
lclip.g_w = content_area.g_w + lclip.g_x;
lclip.g_x = 0;
}
if( lclip.g_y < 0 ) {
lclip.g_h = content_area.g_h + lclip.g_y;
lclip.g_y = 0;
}
browser_schedule_redraw(rootwin->active_gui_window,
lclip.g_x, lclip.g_y,
lclip.g_x + lclip.g_w,
lclip.g_y + lclip.g_h);
}
}
//guiwin_clear(win);
}
}
@ -635,37 +682,40 @@ static void resized(GUIWIN *win)
short x,y,w,h;
short handle;
struct gui_window *gw;
struct rootwin_data_s *data = guiwin_get_user_data(win);
ROOTWIN *rootwin = data->rootwin;
printf("resized win: %p\n", win);
handle = guiwin_get_handle(win);
gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
assert( gw != NULL );
printf("resized handle: %d\n", handle);
gw = data->rootwin->active_gui_window;
assert(gw != NULL);
printf("resized gw: %p\n", gw);
if(gw == NULL)
return;
//assert( gw != NULL );
wind_get(handle, WF_CURRXYWH, &x, &y, &w, &h);
if (gw->root->loc.g_w != w || gw->root->loc.g_h != h) {
// resized
tb_adjust_size( gw );
if (rootwin->loc.g_w != w || rootwin->loc.g_h != h) {
if ( gw->browser->bw->current_content != NULL ) {
/* Reformat will happen when next redraw message arrives: */
gw->browser->reformat_pending = true;
/* but on xaaes an resize doesn't trigger an redraw, */
/* when the window is shrinked, deal with it: */
if( sys_XAAES() ) {
if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ) {
ApplWrite(_AESapid, WM_REDRAW, gw->root->handle->handle,
x, y, w, h);
}
}
/* Reformat will happen when redraw is processed: */
rootwin->active_gui_window->browser->reformat_pending = true;
}
}
if (gw->root->loc.g_x != x || gw->root->loc.g_y != y) {
if (rootwin->loc.g_x != x || rootwin->loc.g_y != y) {
// moved
}
gw->root->loc.g_x = x;
gw->root->loc.g_y = y;
gw->root->loc.g_w = w;
gw->root->loc.g_h = h;
rootwin->loc.g_x = x;
rootwin->loc.g_y = y;
rootwin->loc.g_w = w;
rootwin->loc.g_h = h;
}
static void __CDECL file_dropped(GUIWIN *win, short msg[8])
@ -712,7 +762,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
size, mx, my
));
{
LGRECT bwrect;
GRECT bwrect;
struct browser_window * bw = gw->browser->bw;
browser_get_rect( gw, BR_CONTENT, &bwrect );
mx = mx - bwrect.g_x;

View File

@ -17,7 +17,9 @@
*/
#ifndef NS_ATARI_BROWSER_WIN_H
#define NS_ATARI_BROWSER_WIN_H
#define NS_ATARI_BROWSER_WIN_H
#include <atari/gui.h>
#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
@ -36,31 +38,39 @@
/* -------------------------------------------------------------------------- */
/* Creates an normal Browser window with [toolbar], [statusbar] */
int window_create( struct gui_window * gw,
int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
int window_destroy( struct gui_window * gw );
int window_destroy(struct s_gui_win_root * rootwin);
/* show the window */
void window_open( struct gui_window * gw, GRECT pos);
void window_open(struct s_gui_win_root * rootwin, GRECT pos);
void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
void window_update_back_forward(struct gui_window * gw);
void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
/* set focus element */
void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
void window_set_focus(struct s_gui_win_root * rootwin,
enum focus_element_type type, void * element );
/* adjust scroll settings */
void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
int content_w);
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
bool window_url_widget_has_focus( struct gui_window * gw );
void window_set_url( struct gui_window * gw, const char * text);
void window_set_stauts( struct gui_window * gw , char * text );
void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
bool window_widget_has_focus(struct s_gui_win_root * rootwin,
enum focus_element_type t, void * element);
bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
void window_set_url(struct s_gui_win_root * rootwin, const char * text);
void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
void window_set_title(struct s_gui_win_root * rootwin, char * text);
void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
/* -------------------------------------------------------------------------- */

1172
atari/toolbar.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

142
atari/toolbar.h Executable file → Normal file
View File

@ -1,118 +1,38 @@
/*
* Copyright 2010 Ole Loots <ole@monochrom.net>
*
* 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/>.
*/
#ifndef NS_ATARI_TOOLBAR_H
#ifndef NS_ATARI_TOOLBAR_H
#define NS_ATARI_TOOLBAR_H
#include <stdbool.h>
#include <stdint.h>
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "content/hlcache.h"
#include "atari/browser.h"
#define TB_BUTTON_WIDTH 32
#define THROBBER_WIDTH 32
#define THROBBER_MIN_INDEX 1
#define THROBBER_MAX_INDEX 12
#define THROBBER_INACTIVE_INDEX 13
#include "desktop/browser.h"
#define TOOLBAR_URL_MARGIN_LEFT 2
#define TOOLBAR_URL_MARGIN_RIGHT 2
#define TOOLBAR_URL_MARGIN_TOP 2
#define TOOLBAR_URL_MARGIN_BOTTOM 2
enum e_toolbar_button_states {
button_on = 0,
button_off = 1
};
#define TOOLBAR_BUTTON_NUM_STATES 2
struct s_tb_button
{
short rsc_id;
void (*cb_click)(struct gui_window * gw);
COMPONENT * comp;
hlcache_handle * icon[TOOLBAR_BUTTON_NUM_STATES];
struct gui_window * gw;
short state;
short index;
};
struct s_url_widget
{
bool redraw; /* widget is only redrawn when this flag is set */
struct text_area *textarea;
COMPONENT * comp;
GRECT rdw_area;
};
struct s_throbber_widget
{
COMPONENT * comp;
short index;
short max_index;
bool running;
};
struct s_toolbar;
struct s_toolbar
{
COMPONENT * comp;
struct gui_window * owner;
struct s_url_widget url;
struct s_throbber_widget throbber;
GRECT btdim;
/* size & location of buttons: */
struct s_tb_button * buttons;
bool hidden;
int btcnt;
int style;
bool redraw;
};
enum toolbar_textarea {
URL_INPUT_TEXT_AREA = 1
};
/* interface to the toolbar */
/* Must be called before any other toolbar function is called: */
void toolbar_init( void );
/*Must be called when netsurf exits to free toolbar resources: */
void toolbar_init(void);
struct s_toolbar *toolbar_create(struct s_gui_win_root *owner);
void toolbar_destroy(struct s_toolbar * tb);
void toolbar_exit( void );
CMP_TOOLBAR tb_create( struct gui_window * gw );
void tb_destroy( CMP_TOOLBAR tb );
/* recalculate size/position of nested controls within the toolbar: */
void tb_adjust_size( struct gui_window * gw );
/* report click to toolbar, relative coords : */
void tb_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
void tb_back_click( struct gui_window * gw );
void tb_reload_click( struct gui_window * gw );
void tb_forward_click( struct gui_window * gw );
void tb_home_click( struct gui_window * gw );
void tb_stop_click( struct gui_window * gw );
/* enable / disable buttons etc. */
void tb_update_buttons( struct gui_window * gw, short buttonid );
/* handles clicks on url widget: */
void tb_url_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
/* handle keybd event while url widget has focus:*/
bool tb_url_input( struct gui_window * gw, short keycode );
/* set the url: */
void tb_url_set( struct gui_window * gw, char * text );
/* perform redraw of invalidated url textinput areas: */
void tb_url_redraw( struct gui_window * gw );
struct gui_window * tb_gui_window( CMP_TOOLBAR tb );
/* hide toolbar, mode = 1: hide, mode = 0: show */
void tb_hide( struct gui_window * gw, short mode );
#endif
void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
void toolbar_set_url(struct s_toolbar *tb, const char *text);
bool toolbar_text_input(struct s_toolbar *tb, char *text);
bool toolbar_key_input(struct s_toolbar *tb, short nkc);
void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
short idx);
void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *g);
struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
enum toolbar_textarea which);
/* public events handlers: */
void toolbar_back_click(struct s_toolbar *tb);
void toolbar_reload_click(struct s_toolbar *tb);
void toolbar_forward_click(struct s_toolbar *tb);
void toolbar_home_click(struct s_toolbar *tb);
void toolbar_stop_click(struct s_toolbar *tb);
#endif