Exemplo n.º 1
0
void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);

	glob = &hw->gg;
	ami_clg(0xffffff);

	history_redraw_rectangle(history_current, xs, ys,
		bbox->Width + xs, bbox->Height + ys, 0, 0);

	glob = &browserglob;

	ami_clearclipreg(&hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg.bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);
}
Exemplo n.º 2
0
static void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &amiplot
	};

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	if(ami_gui_get_space_box(hw->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
		amiga_warn_user("NoMemory", "");
		return;
	}

	glob = hw->gg;

	SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
	RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);

	browser_window_history_redraw_rectangle(hw->gw->bw, xs, ys,
			bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);

	ami_gui_set_default_gg();

	ami_clearclipreg(hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg->bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);

	ami_gui_free_space_box(bbox);
}


/* exported interface documented in amiga/history_local.h */
void ami_history_open(struct gui_window *gw)
{
	struct history *history;
	int width, height;

	if (gw->bw == NULL)
		return;

	history = browser_window_get_history(gw->bw);
	if (history == NULL)
		return;

	if(!gw->hw)
	{
		gw->hw = ami_misc_allocvec_clear(sizeof(struct history_window), 0);
		gw->hw->gg = ami_misc_allocvec_clear(sizeof(struct gui_globals), 0);

		ami_init_layers(gw->hw->gg, scrn->Width, scrn->Height, false);

		gw->hw->gw = gw;
		browser_window_history_size(gw->bw, &width, &height);

		gw->hw->scrollerhook.h_Entry = (void *)ami_history_scroller_hook;
		gw->hw->scrollerhook.h_Data = gw->hw;

		gw->hw->objects[OID_MAIN] = WindowObj,
			WA_ScreenTitle, ami_gui_get_screen_title(),
			WA_Title, messages_get("History"),
			WA_Activate, TRUE,
			WA_DepthGadget, TRUE,
			WA_DragBar, TRUE,
			WA_CloseGadget, TRUE,
			WA_SizeGadget, TRUE,
			WA_PubScreen,scrn,
			WA_InnerWidth,width,
			WA_InnerHeight,height + 10,
			WINDOW_SharedPort,sport,
			WINDOW_UserData,gw->hw,
			WINDOW_IconifyGadget, FALSE,
			WINDOW_GadgetHelp, TRUE,
			WINDOW_Position, WPOS_CENTERSCREEN,
			WINDOW_HorizProp,1,
			WINDOW_VertProp,1,
			WINDOW_IDCMPHook,&gw->hw->scrollerhook,
			WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE,
//			WA_ReportMouse,TRUE,
			WA_IDCMP,IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE, // | IDCMP_MOUSEMOVE,
			WINDOW_ParentGroup, gw->hw->objects[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, gw->hw->objects[GID_BROWSER] = SpaceObj,
					GA_ID,GID_BROWSER,
//					SPACE_MinWidth,width,
//					SPACE_MinHeight,height,
				SpaceEnd,
			EndGroup,
		EndWindow;

		gw->hw->win = (struct Window *)RA_OpenWindow(gw->hw->objects[OID_MAIN]);
		gw->hw->node = AddObject(window_list,AMINS_HISTORYWINDOW);
		gw->hw->node->objstruct = gw->hw;

		GetAttr(WINDOW_HorizObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_HSCROLL]);
		GetAttr(WINDOW_VertObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_VSCROLL]);

		RefreshSetGadgetAttrs((APTR)gw->hw->objects[OID_VSCROLL],gw->hw->win,NULL,
			GA_ID,OID_VSCROLL,
			SCROLLER_Top,0,
			ICA_TARGET,ICTARGET_IDCMP,
			TAG_DONE);

		RefreshSetGadgetAttrs((APTR)gw->hw->objects[OID_HSCROLL],gw->hw->win,NULL,
			GA_ID,OID_HSCROLL,
			SCROLLER_Top,0,
			ICA_TARGET,ICTARGET_IDCMP,
			TAG_DONE);
	}

	ami_history_redraw(gw->hw);
}


/**
 * Handle mouse clicks in the history window.
 *
 * \return true if the event was handled, false to pass it on
 */

static bool ami_history_click(struct history_window *hw, uint16 code)
{
	int x, y;
	struct IBox *bbox;
	ULONG xs, ys;

	if(ami_gui_get_space_box(hw->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
		amiga_warn_user("NoMemory", "");
		return false;
	}

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	x = hw->win->MouseX - bbox->Left +xs;
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	y = hw->win->MouseY - bbox->Top + ys;

	ami_gui_free_space_box(bbox);

	switch(code)
	{
		case SELECTUP:
			browser_window_history_click(hw->gw->bw, x, y, false);
			ami_history_redraw(hw);
			ami_schedule_redraw(hw->gw->shared, true);
		break;

		case MIDDLEUP:
			browser_window_history_click(hw->gw->bw, x, y, true);
			ami_history_redraw(hw);
		break;
	}

	return true;
}
Exemplo n.º 3
0
bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
	const char *url)
{
	struct BitScaleArgs bsa;
	int plot_width;
	int plot_height;
	int redraw_tile_size = nsoption_int(redraw_tile_size_x);
	struct redraw_context ctx = {
		.interactive = false,
		.background_images = true,
		.plot = &amiplot
	};

	if(nsoption_int(redraw_tile_size_y) < nsoption_int(redraw_tile_size_x))
		redraw_tile_size = nsoption_int(redraw_tile_size_y);

	plot_width = MIN(content_get_width(content), redraw_tile_size);
	plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
			bitmap->width;

	bitmap->nativebm = p96AllocBitMap(bitmap->width, bitmap->height, 32,
							BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
							browserglob.bm, RGBFB_A8R8G8B8);

	bitmap->nativebmwidth = bitmap->width;
	bitmap->nativebmheight = bitmap->height;
	ami_clearclipreg(&browserglob);

	thumbnail_redraw(content, plot_width, plot_height, &ctx);

	if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
	{
		float resample_scale = bitmap->width / (float)plot_width;
		uint32 flags = COMPFLAG_IgnoreDestAlpha | COMPFLAG_SrcAlphaOverride;
		if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter;

		CompositeTags(COMPOSITE_Src,browserglob.bm,bitmap->nativebm,
					COMPTAG_ScaleX,
					COMP_FLOAT_TO_FIX(resample_scale),
					COMPTAG_ScaleY,
					COMP_FLOAT_TO_FIX(resample_scale),
					COMPTAG_Flags,flags,
					COMPTAG_DestX,0,
					COMPTAG_DestY,0,
					COMPTAG_DestWidth,bitmap->width,
					COMPTAG_DestHeight,bitmap->height,
					COMPTAG_OffsetX,0,
					COMPTAG_OffsetY,0,
					TAG_DONE);
	}
	else
	{
		bsa.bsa_SrcX = 0;
		bsa.bsa_SrcY = 0;
		bsa.bsa_SrcWidth = plot_width;
		bsa.bsa_SrcHeight = plot_height;
		bsa.bsa_DestX = 0;
		bsa.bsa_DestY = 0;
	//	bsa.bsa_DestWidth = width;
	//	bsa.bsa_DestHeight = height;
		bsa.bsa_XSrcFactor = plot_width;
		bsa.bsa_XDestFactor = bitmap->width;
		bsa.bsa_YSrcFactor = plot_height;
		bsa.bsa_YDestFactor = bitmap->height;
		bsa.bsa_SrcBitMap = browserglob.bm;
		bsa.bsa_DestBitMap = bitmap->nativebm;
		bsa.bsa_Flags = 0;

		BitMapScale(&bsa);
	}

	if (url) urldb_set_thumbnail(url, bitmap);

	return true;
}
Exemplo n.º 4
0
void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &amiplot
	};

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);

	glob = &hw->gg;

	SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
	RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);

	history_redraw_rectangle(history_current, xs, ys,
			bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);

	glob = &browserglob;

	ami_clearclipreg(&hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg.bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);
}

/**
 * Handle mouse clicks in the history window.
 *
 * \return true if the event was handled, false to pass it on
 */

bool ami_history_click(struct history_window *hw,uint16 code)
{
	int x, y;
	struct IBox *bbox;
	ULONG width,height,xs,ys;

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);	

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	x = hw->win->MouseX - bbox->Left +xs;
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	y = hw->win->MouseY - bbox->Top + ys;

	width=bbox->Width;
	height=bbox->Height;

	switch(code)
	{
		case SELECTUP:
			history_click(hw->bw,history_current,x,y,false);
			ami_history_redraw(hw);
			ami_do_redraw(hw->bw->window->shared);
		break;

		case MIDDLEUP:
			history_click(hw->bw,history_current,x,y,true);
			ami_history_redraw(hw);
		break;

	}

	return true;
}