Пример #1
0
static void __CDECL menu_open_url(short item, short title, void *data)
{
	struct gui_window * gw;
	struct browser_window * bw ;
	LOG(("%s", __FUNCTION__));

	gw = input_window;
	if( gw == NULL ) {
		browser_window_create(BROWSER_WINDOW_VERIFIABLE |
				      BROWSER_WINDOW_HISTORY,
				      NULL,
				      NULL,
				      NULL,
				      &bw);
		gw = bw->window;
	}
	/* Loose focus: */
	window_set_focus(gw->root, WIDGET_NONE, NULL );

	/* trigger on-focus event (select all text): */
	window_set_focus(gw->root, URL_WIDGET, NULL);

	/* delete selection: */
	toolbar_key_input(gw->root->toolbar, NK_DEL);
}
Пример #2
0
/**
 * Create and open a gui window for a browsing context.
 *
 * \param bw		bw to create gui_window for
 * \param existing	an existing gui_window, may be NULL
 * \param flags		flags for gui window creation
 * \return gui window, or NULL on error
 *
 * If GW_CREATE_CLONE flag is set existing is non-NULL.
 *
 * The created gui_window must include a reference to the browser
 * window passed in the bw param.
 */
static struct gui_window *
gui_window_create(struct browser_window *bw,
		  struct gui_window *existing,
		  gui_window_create_flags flags)
{
    struct gui_window *gw=NULL;
    LOG("gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, existing, (int)flags);

    gw = calloc(1, sizeof(struct gui_window));
    if (gw == NULL)
	return NULL;

    LOG("new window: %p, bw: %p\n", gw, bw);
    window_create(gw, bw, existing, 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
	};
	gui_window_set_url(gw, corestring_nsurl_about_blank);
	gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
	gui_set_input_gui_window(gw);
	window_open(gw->root, gw, pos);
    }

    /* add the window to the window list: */
    if( window_list == NULL ) {
	window_list = gw;
	gw->next = NULL;
	gw->prev = NULL;
    } else {
	struct gui_window * tmp = window_list;
	while( tmp->next != NULL ) {
	    tmp = tmp->next;
	}
	tmp->next = gw;
	gw->prev = tmp;
	gw->next = NULL;
    }

    /* Loose focus: */
    window_set_focus(gw->root, WIDGET_NONE, NULL );

    /* trigger on-focus event (select all text): */
    window_set_focus(gw->root, URL_WIDGET, NULL);

    /* delete selection: */
    toolbar_key_input(gw->root->toolbar, NK_DEL);

    return( gw );

}
Пример #3
0
static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
{
	struct gui_window * gw;
	struct browser_window * bw ;
	LOG(("%s", __FUNCTION__));

	gw = input_window;
	if( gw == NULL ) {
		bw = browser_window_create("", 0, 0, true, false);
		gw = bw->window;

	}
	/* Loose focus: */
	window_set_focus( gw, WIDGET_NONE, NULL );

	/* trigger on-focus event (select all text): */
	window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );

	/* delete selection: */
	tb_url_input( gw, NK_DEL );
}
Пример #4
0
void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
{
	int title = buff[ 3];
	INT16 x,y;
	char *str;
	struct gui_window * gw = window_list;
	int i=0;
	MenuTnormal( NULL, title, 1);
	while( gw ) {
		window_set_focus( gw, WIDGET_NONE, NULL  );
		gw = gw->next;
	}
	while( menu_evnt_tbl[i].rid != -1) {
		if( menu_evnt_tbl[i].rid ==  buff[4] ) {
			menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
			break;
		}
		i++;
	}
}
Пример #5
0
static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
{
	short mx, my, dummy, mbut;
	LGRECT cwork;
	browser_mouse_state bmstate = 0;
	struct gui_window * gw = data;

	if( input_window != gw ){
		input_window = gw;
	}

	window_set_focus( gw, BROWSER, (void*)gw->browser );
	browser_get_rect( gw, BR_CONTENT, &cwork );

	/* convert screen coords to component coords: */
	mx = evnt.mx - cwork.g_x;
	my = evnt.my - cwork.g_y;

	/* Translate GEM key state to netsurf mouse modifier */
	if( evnt.mkstate & (K_RSHIFT | K_LSHIFT) ){
		bmstate |= BROWSER_MOUSE_MOD_1;
	} else {
		bmstate &= ~(BROWSER_MOUSE_MOD_1);
	}
	if( (evnt.mkstate & K_CTRL) ){
		bmstate |= BROWSER_MOUSE_MOD_2;
	} else {
		bmstate &= ~(BROWSER_MOUSE_MOD_2);
	}
	if( (evnt.mkstate & K_ALT) ){
		bmstate |= BROWSER_MOUSE_MOD_3;
	} else {
		bmstate &= ~(BROWSER_MOUSE_MOD_3);
	}

	/* convert component coords to scrolled content coords: */
	int sx_origin = (mx + gw->browser->scroll.current.x);
	int sy_origin = (my + gw->browser->scroll.current.y);

	short rel_cur_x, rel_cur_y;
	short prev_x=sx_origin, prev_y=sy_origin;
	bool dragmode = 0;

	/* Detect left mouse button state and compare with event state: */
	graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
	if( (mbut & 1) && (evnt.mbut & 1) ){
		/* Mouse still pressed, report drag */
		rel_cur_x = (rel_cur_x - cwork.g_x) + gw->browser->scroll.current.x;
		rel_cur_y = (rel_cur_y - cwork.g_y) + gw->browser->scroll.current.y;
		browser_window_mouse_click( gw->browser->bw,
									BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
									sx_origin, sy_origin);
		do{
			if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ){
				browser_window_mouse_track( gw->browser->bw,
									BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
									rel_cur_x, rel_cur_y);
				prev_x = rel_cur_x;
				prev_y = rel_cur_y;
				dragmode = true;
			} else {
				if( dragmode == false ){
					browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
									rel_cur_x, rel_cur_y);
				}
			}
			if( browser_redraw_required( gw ) ){
				browser_redraw( gw );
			}
			graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
			rel_cur_x = (rel_cur_x - cwork.g_x) + gw->browser->scroll.current.x;
			rel_cur_y = (rel_cur_y - cwork.g_y) + gw->browser->scroll.current.y;
		} while( mbut & 1 );
		browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
	} else {
		/* Right button pressed? */
		if( (evnt.mbut & 2 ) ) {
			context_popup( gw, evnt.mx, evnt.my );
		} else {
			browser_window_mouse_click(gw->browser->bw,
										bmstate|BROWSER_MOUSE_PRESS_1,
										sx_origin,sy_origin);
			browser_window_mouse_click(gw->browser->bw,
										bmstate|BROWSER_MOUSE_CLICK_1,
										sx_origin,sy_origin);
		}
	}


}