Esempio n. 1
0
/**
 * handler for toolkit window redraw event
 */
static int fb_cw_draw_event(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	struct fb_corewindow *fb_cw;
	nsfb_bbox_t rbox;
	struct rect clip;

	fb_cw = (struct fb_corewindow *)cbi->context;

	rbox.x0 = fbtk_get_absx(widget);
	rbox.y0 = fbtk_get_absy(widget);

	rbox.x1 = rbox.x0 + fbtk_get_width(widget);
	rbox.y1 = rbox.y0 + fbtk_get_height(widget);

	nsfb_claim(fbtk_get_nsfb(widget), &rbox);

	clip.x0 = fb_cw->scrollx;
	clip.y0 = fb_cw->scrolly;
	clip.x1 = fbtk_get_width(widget) + fb_cw->scrollx;
	clip.y1 = fbtk_get_height(widget) + fb_cw->scrolly;

	fb_cw->draw(fb_cw, &clip);

	nsfb_update(fbtk_get_nsfb(widget), &rbox);

	return 0;
}
Esempio n. 2
0
static int
fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
    nsfb_bbox_t bbox;
    nsfb_bbox_t rect;
    nsfb_t *nsfb;

    nsfb = fbtk_get_nsfb(widget);

    fbtk_get_bbox(widget, &bbox);

    rect = bbox;

    nsfb_claim(nsfb, &bbox);

    /* clear background */
    if ((widget->bg & 0xFF000000) != 0) {
        /* transparent polygon filling isnt working so fake it */
        nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
    }

    /* plot the image */
    nsfb_plot_bitmap(nsfb,
                     &rect,
                     (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata,
                     widget->u.bitmap.bitmap->width,
                     widget->u.bitmap.bitmap->height,
                     widget->u.bitmap.bitmap->width,
                     !widget->u.bitmap.bitmap->opaque);

    nsfb_update(nsfb, &bbox);

    return 0;
}
Esempio n. 3
0
static int
fb_redraw_fill(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	nsfb_bbox_t bbox;
	nsfb_t *nsfb;

	nsfb = fbtk_get_nsfb(widget);

	fbtk_get_bbox(widget, &bbox);

	nsfb_claim(nsfb, &bbox);

	/* clear background */
	if ((widget->bg & 0xFF000000) != 0) {
		/* transparent polygon filling isnt working so fake it */
		nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
	}

	nsfb_update(nsfb, &bbox);

	return 0;
}
Esempio n. 4
0
static int
localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	struct gui_localhistory *glh = cbi->context;
	nsfb_bbox_t rbox;

	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &fb_plotters
	};

	rbox.x0 = fbtk_get_absx(widget);
	rbox.y0 = fbtk_get_absy(widget);

	rbox.x1 = rbox.x0 + fbtk_get_width(widget);
	rbox.y1 = rbox.y0 + fbtk_get_height(widget);

	nsfb_claim(fbtk_get_nsfb(widget), &rbox);

	nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);

	history_redraw_rectangle(glh->bw->history,
				 glh->scrollx,
				 glh->scrolly,
				 fbtk_get_width(widget) + glh->scrollx,
				 fbtk_get_height(widget) + glh->scrolly,
				 0, 0, &ctx);

	nsfb_update(fbtk_get_nsfb(widget), &rbox);

	return 0;
}

static int
localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	struct gui_localhistory *glh = cbi->context;

	if (cbi->event->type != NSFB_EVENT_KEY_UP)
		return 0;

	history_click(glh->bw, glh->bw->history, cbi->x, cbi->y, false);

	fbtk_set_mapping(glh->window, false);

	return 1;
}

struct gui_localhistory *
fb_create_localhistory(struct browser_window *bw,
		       fbtk_widget_t *parent,
		       int furniture_width)
{
	struct gui_localhistory *glh;
	glh = calloc(1, sizeof(struct gui_localhistory));

	if (glh == NULL)
		return NULL;

	glh->bw = bw;

	/* container window */
	glh->window = fbtk_create_window(parent, 0, 0, 0, 0, 0);

	glh->history = fbtk_create_user(glh->window, 0, 0, -furniture_width, -furniture_width, glh);

	fbtk_set_handler(glh->history, FBTK_CBT_REDRAW, localhistory_redraw, glh);
	fbtk_set_handler(glh->history, FBTK_CBT_CLICK, localhistory_click, glh);
	/*
	  fbtk_set_handler(gw->localhistory, FBTK_CBT_INPUT, fb_browser_window_input, gw);
	  fbtk_set_handler(gw->localhistory, FBTK_CBT_POINTERMOVE, fb_browser_window_move, bw);
	*/

	/* create horizontal scrollbar */
	glh->hscroll = fbtk_create_hscroll(glh->window,
					   0,
					   fbtk_get_height(glh->window) - furniture_width,
					   fbtk_get_width(glh->window) - furniture_width,
					   furniture_width,
					   FB_SCROLL_COLOUR,
					   FB_FRAME_COLOUR,
					   NULL,
					   NULL);

	glh->vscroll = fbtk_create_vscroll(glh->window,
					   fbtk_get_width(glh->window) - furniture_width,
					   0,
					   furniture_width,
					   fbtk_get_height(glh->window) - furniture_width,
					   FB_SCROLL_COLOUR,
					   FB_FRAME_COLOUR,
					   NULL,
					   NULL);

	fbtk_create_fill(glh->window,
			 fbtk_get_width(glh->window) - furniture_width,
			 fbtk_get_height(glh->window) - furniture_width,
			 furniture_width,
			 furniture_width,
			 FB_FRAME_COLOUR);

	return glh;
}

void
fb_localhistory_map(struct gui_localhistory * glh)
{
	fbtk_set_zorder(glh->window, INT_MIN);
	fbtk_set_mapping(glh->window, true);
}
Esempio n. 5
0
static void
fb_redraw(fbtk_widget_t *widget,
	  struct browser_widget_s *bwidget,
	  struct browser_window *bw)
{
	int x;
	int y;
	int caret_x, caret_y, caret_h;
	struct rect clip;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &fb_plotters
	};
	nsfb_t *nsfb = fbtk_get_nsfb(widget);
	float scale = browser_window_get_scale(bw);

	LOG(("%d,%d to %d,%d",
	     bwidget->redraw_box.x0,
	     bwidget->redraw_box.y0,
	     bwidget->redraw_box.x1,
	     bwidget->redraw_box.y1));

	x = fbtk_get_absx(widget);
	y = fbtk_get_absy(widget);

	/* adjust clipping co-ordinates according to window location */
	bwidget->redraw_box.y0 += y;
	bwidget->redraw_box.y1 += y;
	bwidget->redraw_box.x0 += x;
	bwidget->redraw_box.x1 += x;

	nsfb_claim(nsfb, &bwidget->redraw_box);

	/* redraw bounding box is relative to window */
	clip.x0 = bwidget->redraw_box.x0;
	clip.y0 = bwidget->redraw_box.y0;
	clip.x1 = bwidget->redraw_box.x1;
	clip.y1 = bwidget->redraw_box.y1;

	browser_window_redraw(bw,
			(x - bwidget->scrollx) / scale,
			(y - bwidget->scrolly) / scale,
			&clip, &ctx);

	if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
		/* This widget has caret, so render it */
		nsfb_bbox_t line;
		nsfb_plot_pen_t pen;

		line.x0 = x - bwidget->scrollx + caret_x;
		line.y0 = y - bwidget->scrolly + caret_y;
		line.x1 = x - bwidget->scrollx + caret_x;
		line.y1 = y - bwidget->scrolly + caret_y + caret_h;

		pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
		pen.stroke_width = 1;
		pen.stroke_colour = 0xFF0000FF;

		nsfb_plot_line(nsfb, &line, &pen);
	}

	nsfb_update(fbtk_get_nsfb(widget), &bwidget->redraw_box);

	bwidget->redraw_box.y0 = bwidget->redraw_box.x0 = INT_MAX;
	bwidget->redraw_box.y1 = bwidget->redraw_box.x1 = INT_MIN;
	bwidget->redraw_required = false;
}

static int
fb_browser_window_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	struct gui_window *gw = cbi->context;
	struct browser_widget_s *bwidget;

	bwidget = fbtk_get_userpw(widget);
	if (bwidget == NULL) {
		LOG(("browser widget from widget %p was null", widget));
		return -1;
	}

	if (bwidget->pan_required) {
		fb_pan(widget, bwidget, gw->bw);
	}

	if (bwidget->redraw_required) {
		fb_redraw(widget, bwidget, gw->bw);
	} else {
		bwidget->redraw_box.x0 = 0;
		bwidget->redraw_box.y0 = 0;
		bwidget->redraw_box.x1 = fbtk_get_width(widget);
		bwidget->redraw_box.y1 = fbtk_get_height(widget);
		fb_redraw(widget, bwidget, gw->bw);
	}
	return 0;
}

static int fb_browser_window_destroy(fbtk_widget_t *widget,
		fbtk_callback_info *cbi)
{
	struct browser_widget_s *browser_widget;

	if (widget == NULL) {
		return 0;
	}

	/* Free private data */
	browser_widget = fbtk_get_userpw(widget);
	free(browser_widget);

	return 0;
}


static const char *fename;
static int febpp;
static int fewidth;
static int feheight;
static const char *feurl;

static bool
process_cmdline(int argc, char** argv)
{
	int opt;

	LOG(("argc %d, argv %p", argc, argv));

	fename = "mtl";
	febpp = 32;

	fewidth = nsoption_int(window_width);
	if (fewidth <= 0) {
		fewidth = 800;
	}
	feheight = nsoption_int(window_height);
	if (feheight <= 0) {
		feheight = 480;
	}

	if ((nsoption_charp(homepage_url) != NULL) && 
	    (nsoption_charp(homepage_url)[0] != '\0')) {
		feurl = nsoption_charp(homepage_url);
	} else {
		feurl = NETSURF_HOMEPAGE;
	}

	while((opt = getopt(argc, argv, "f:b:w:h:")) != -1) {
		switch (opt) {
		case 'f':
			fename = optarg;
			break;

		case 'b':
			febpp = atoi(optarg);
			break;

		case 'w':
			fewidth = atoi(optarg);
			break;

		case 'h':
			feheight = atoi(optarg);
			break;

		default:
			fprintf(stderr,
				"Usage: %s [-f frontend] [-b bpp] url\n",
				argv[0]);
			return false;
		}
	}

	if (optind < argc) {
		feurl = argv[optind];
	}

	return true;
}
Esempio n. 6
0
static void
fb_pan(fbtk_widget_t *widget,
       struct browser_widget_s *bwidget,
       struct browser_window *bw)
{
	int x;
	int y;
	int width;
	int height;
	nsfb_bbox_t srcbox;
	nsfb_bbox_t dstbox;

	nsfb_t *nsfb = fbtk_get_nsfb(widget);

	height = fbtk_get_height(widget);
	width = fbtk_get_width(widget);

	LOG(("panning %d, %d", bwidget->panx, bwidget->pany));

	x = fbtk_get_absx(widget);
	y = fbtk_get_absy(widget);

	/* if the pan exceeds the viewport size just redraw the whole area */
	if (bwidget->pany >= height || bwidget->pany <= -height ||
	    bwidget->panx >= width || bwidget->panx <= -width) {

		bwidget->scrolly += bwidget->pany;
		bwidget->scrollx += bwidget->panx;
		fb_queue_redraw(widget, 0, 0, width, height);

		/* ensure we don't try to scroll again */
		bwidget->panx = 0;
		bwidget->pany = 0;
		bwidget->pan_required = false;
		return;
	}

	if (bwidget->pany < 0) {
		/* pan up by less then viewport height */
		srcbox.x0 = x;
		srcbox.y0 = y;
		srcbox.x1 = srcbox.x0 + width;
		srcbox.y1 = srcbox.y0 + height + bwidget->pany;

		dstbox.x0 = x;
		dstbox.y0 = y - bwidget->pany;
		dstbox.x1 = dstbox.x0 + width;
		dstbox.y1 = dstbox.y0 + height + bwidget->pany;

		/* move part that remains visible up */
		nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox);

		/* redraw newly exposed area */
		bwidget->scrolly += bwidget->pany;
		fb_queue_redraw(widget, 0, 0, width, - bwidget->pany);

	} else if (bwidget->pany > 0) {
		/* pan down by less then viewport height */
		srcbox.x0 = x;
		srcbox.y0 = y + bwidget->pany;
		srcbox.x1 = srcbox.x0 + width;
		srcbox.y1 = srcbox.y0 + height - bwidget->pany;

		dstbox.x0 = x;
		dstbox.y0 = y;
		dstbox.x1 = dstbox.x0 + width;
		dstbox.y1 = dstbox.y0 + height - bwidget->pany;

		/* move part that remains visible down */
		nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox);

		/* redraw newly exposed area */
		bwidget->scrolly += bwidget->pany;
		fb_queue_redraw(widget, 0, height - bwidget->pany,
				width, height);
	}

	if (bwidget->panx < 0) {
		/* pan left by less then viewport width */
		srcbox.x0 = x;
		srcbox.y0 = y;
		srcbox.x1 = srcbox.x0 + width + bwidget->panx;
		srcbox.y1 = srcbox.y0 + height;

		dstbox.x0 = x - bwidget->panx;
		dstbox.y0 = y;
		dstbox.x1 = dstbox.x0 + width + bwidget->panx;
		dstbox.y1 = dstbox.y0 + height;

		/* move part that remains visible left */
		nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox);

		/* redraw newly exposed area */
		bwidget->scrollx += bwidget->panx;
		fb_queue_redraw(widget, 0, 0, -bwidget->panx, height);

	} else if (bwidget->panx > 0) {
		/* pan right by less then viewport width */
		srcbox.x0 = x + bwidget->panx;
		srcbox.y0 = y;
		srcbox.x1 = srcbox.x0 + width - bwidget->panx;
		srcbox.y1 = srcbox.y0 + height;

		dstbox.x0 = x;
		dstbox.y0 = y;
		dstbox.x1 = dstbox.x0 + width - bwidget->panx;
		dstbox.y1 = dstbox.y0 + height;

		/* move part that remains visible right */
		nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox);

		/* redraw newly exposed area */
		bwidget->scrollx += bwidget->panx;
		fb_queue_redraw(widget, width - bwidget->panx, 0,
				width, height);
	}

	bwidget->pan_required = false;
	bwidget->panx = 0;
	bwidget->pany = 0;
}
Esempio n. 7
0
static int
fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
	LOG(("REDRAW BITMAP"));
	//__menuet__debug_out("REDRAW BITMAP");
	nsfb_bbox_t bbox;
	nsfb_bbox_t rect;
	nsfb_t *nsfb;

	LOG(("REDRAW BITMAP 1 "));
	//__menuet__debug_out("REDRAW BITMAP 1");


	nsfb = fbtk_get_nsfb(widget);

	LOG(("REDRAW BITMAP 2"));
	//__menuet__debug_out("REDRAW BITMAP 2");


	fbtk_get_bbox(widget, &bbox);

	rect = bbox;

	LOG(("REDRAW BITMAP 3 "));
	//__menuet__debug_out("REDRAW BITMAP 3");


	nsfb_claim(nsfb, &bbox);

	LOG(("REDRAW BITMAP 4"));
	//__menuet__debug_out("REDRAW BITMAP 4");

	/* clear background */
	if ((widget->bg & 0xFF000000) != 0) {
		/* transparent polygon filling isnt working so fake it */
		
			LOG(("REDRAW BITMAP 5"));
	//__menuet__debug_out("REDRAW BITMAP 5");

		nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
	}

	LOG(("REDRAW BITMAP 6"));
	//__menuet__debug_out("REDRAW BITMAP 6\n");

	/* plot the image */
	
	LOG(("STUB: DON'T REAL DRAW"));
	//__menuet__debug_out("STUB: DON'T REAL DRAW\n");
	
	
	LOG(("pixdata is %x", (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata));
	LOG(("pixdata is w:%d h:%d",widget->u.bitmap.bitmap->width,
			 widget->u.bitmap.bitmap->height));
	
	//hmm
	
	//int zap;
	//if (widget->u.bitmap.bitmap->width % 4 != 0) {
	//	zap = widget->u.bitmap.bitmap->width + 2; }
	
	//nsfb_plot_rectangle_fill(nsfb, &rect, 0xFFFFFF);
	
	
	nsfb_plot_bitmap(nsfb,
			 &rect,
			 (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata,
			 //0, 0, 0, 
			 widget->u.bitmap.bitmap->width,
			 widget->u.bitmap.bitmap->height,
			 widget->u.bitmap.bitmap->width, 
			 !widget->u.bitmap.bitmap->opaque);
	
	
		
	
	
	LOG(("REDRAW BITMAP 7"));
	//__menuet__debug_out("REDRAW BITMAP 7\n");

	nsfb_update(nsfb, &bbox);

	LOG(("REDRAW BITMAP OK\n"));
	//__menuet__debug_out("REDRAW BITMAP OK\n");

	return 0;
}
Esempio n. 8
0
/** Text redraw callback.
 *
 * Called when a text widget requires redrawing.
 *
 * @param widget The widget to be redrawn.
 * @param cbi The callback parameters.
 * @return The callback result.
 */
static int
fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
{
	nsfb_bbox_t bbox;
	nsfb_bbox_t rect;
	fbtk_widget_t *root;
	plot_font_style_t font_style;
	int caret_x, caret_y, caret_h;
	int fh;
	int padding;
	int scroll = 0;
	bool caret = false;

	fb_text_font_style(widget, &fh, &padding, &font_style);

	if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
		caret = true;
	}

	root = fbtk_get_root_widget(widget);

	fbtk_get_bbox(widget, &bbox);

	rect = bbox;

	nsfb_claim(root->u.root.fb, &bbox);

	/* clear background */
	if ((widget->bg & 0xFF000000) != 0) {
		/* transparent polygon filling isnt working so fake it */
		nsfb_plot_rectangle_fill(root->u.root.fb, &bbox, widget->bg);
	}

	/* widget can have a single pixel outline border */
	if (widget->u.text.outline) {
		rect.x1--;
		rect.y1--;
		nsfb_plot_rectangle(root->u.root.fb, &rect, 1,
				0x00000000, false, false);
	}

	if (widget->u.text.text != NULL) {
		int x = bbox.x0 + padding;
		int y = bbox.y0 + ((fh * 3 + 2) / 4) + padding;

#ifdef FB_USE_FREETYPE
		/* Freetype renders text higher */
		y += 1;
#endif

		if (caret && widget->width - padding - padding < caret_x) {
			scroll = (widget->width - padding - padding) - caret_x;
			x +=  scroll;
		}

		/* Call the fb text plotting, baseline is 3/4 down the font */
		fb_plotters.text(x, y, widget->u.text.text,
				widget->u.text.len, &font_style);
	}

	if (caret) {
		/* This widget has caret, so render it */
		nsfb_t *nsfb = fbtk_get_nsfb(widget);
		nsfb_bbox_t line;
		nsfb_plot_pen_t pen;

		line.x0 = bbox.x0 + caret_x + scroll;
		line.y0 = bbox.y0 + caret_y;
		line.x1 = bbox.x0 + caret_x + scroll;
		line.y1 = bbox.y0 + caret_y + caret_h;

		pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
		pen.stroke_width = 1;
		pen.stroke_colour = 0xFF0000FF;

		nsfb_plot_line(nsfb, &line, &pen);
	}

	nsfb_update(root->u.root.fb, &bbox);

	return 0;
}