Пример #1
0
static nserror
ami_history_global_create_window(struct ami_history_global_window *history_win)
{
	struct ami_corewindow *ami_cw = (struct ami_corewindow *)&history_win->core;
	ULONG refresh_mode = WA_SmartRefresh;

	if(nsoption_bool(window_simple_refresh) == true) {
		refresh_mode = WA_SimpleRefresh;
	}

	ami_cw->objects[GID_CW_WIN] = WindowObj,
  	    WA_ScreenTitle, ami_gui_get_screen_title(),
       	WA_Title, ami_cw->wintitle,
       	WA_Activate, TRUE,
       	WA_DepthGadget, TRUE,
       	WA_DragBar, TRUE,
       	WA_CloseGadget, TRUE,
       	WA_SizeGadget, TRUE,
		WA_SizeBRight, TRUE,
		WA_Top, nsoption_int(history_window_ypos),
		WA_Left, nsoption_int(history_window_xpos),
		WA_Width, nsoption_int(history_window_xsize),
		WA_Height, nsoption_int(history_window_ysize),
		WA_PubScreen, scrn,
		WA_ReportMouse, TRUE,
		refresh_mode, TRUE,
		WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
				IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
				IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW,
		WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
		WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE |
				IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW,
		WINDOW_SharedPort, sport,
		WINDOW_HorizProp, 1,
		WINDOW_VertProp, 1,
		WINDOW_UserData, history_win,
		WINDOW_MenuStrip, ami_history_global_menu_create(history_win),
		WINDOW_MenuUserData, WGUD_HOOK,
		WINDOW_IconifyGadget, FALSE,
		WINDOW_Position, WPOS_CENTERSCREEN,
		WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
			LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
				GA_ID, GID_CW_DRAW,
				SPACE_Transparent, TRUE,
				SPACE_BevelStyle, BVS_DISPLAY,
				GA_RelVerify, TRUE,
   			SpaceEnd,
		EndGroup,
	EndWindow;

	if(ami_cw->objects[GID_CW_WIN] == NULL) {
		return NSERROR_NOMEM;
	}

	return NSERROR_OK;
}
Пример #2
0
void ami_print_progress(void)
{
	ami_print_info.objects[OID_MAIN] = WindowObj,
      	    WA_ScreenTitle, ami_gui_get_screen_title(),
           	WA_Title, messages_get("Printing"),
           	WA_Activate, TRUE,
           	WA_DepthGadget, TRUE,
           	WA_DragBar, TRUE,
           	WA_CloseGadget, FALSE,
           	WA_SizeGadget, TRUE,
			WA_PubScreen,scrn,
			//WINDOW_SharedPort,sport,
			WINDOW_UserData, &ami_print_info,
			WINDOW_IconifyGadget, FALSE,
			WINDOW_LockHeight,TRUE,
         	WINDOW_Position, WPOS_CENTERSCREEN,
           	WINDOW_ParentGroup, ami_print_info.gadgets[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, ami_print_info.gadgets[GID_STATUS] = FuelGaugeObj,
					GA_ID,GID_STATUS,
					FUELGAUGE_Min,0,
					FUELGAUGE_Max,ami_print_info.pages,
					FUELGAUGE_Level,0,
					FUELGAUGE_Ticks,11,
					FUELGAUGE_ShortTicks,TRUE,
					FUELGAUGE_Percent,TRUE,
					FUELGAUGE_Justification,FGJ_CENTER,
				FuelGaugeEnd,
				CHILD_NominalSize,TRUE,
				CHILD_WeightedHeight,0,
/*
				LAYOUT_AddChild, ami_print_info.gadgets[GID_CANCEL] = ButtonObj,
					GA_ID,GID_CANCEL,
					GA_Disabled,TRUE,
					GA_RelVerify,TRUE,
					GA_Text,messages_get("Abort"),
					GA_TabCycle,TRUE,
				ButtonEnd,
*/
			EndGroup,
		EndWindow;

	ami_print_info.win = (struct Window *)RA_OpenWindow(ami_print_info.objects[OID_MAIN]);
}
Пример #3
0
static struct gui_download_window *gui_download_window_create(download_context *ctx,
		struct gui_window *gui)
{
	const char *url = nsurl_access(download_context_get_url(ctx));
	unsigned long total_size = download_context_get_total_length(ctx);
	struct gui_download_window *dw;
	char *dl_filename = ami_utf8_easy(download_context_get_filename(ctx));
	APTR va[3];

	dw = ami_misc_allocvec_clear(sizeof(struct gui_download_window), 0);

	if(gui && (!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url)))
	{
		strcpy(dw->fname, dw->dln->filename);
		free(dw->dln->node.ln_Name);
		dw->dln->node.ln_Name = NULL;
	}
	else
	{
		if(AslRequestTags(savereq,
			ASLFR_Window, gui->shared->win,
			ASLFR_SleepWindow, TRUE,
			ASLFR_TitleText, messages_get("NetSurf"),
			ASLFR_Screen, scrn,
			ASLFR_InitialFile, dl_filename,
			TAG_DONE))
		{
			strlcpy(dw->fname, savereq->fr_Drawer, 1024);
			AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
			if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size))
			{
				FreeVec(dw);
				return NULL;
			}
		}
		else
		{
			FreeVec(dw);
			return NULL;
		}
	}

	if(dl_filename) ami_utf8_free(dl_filename);
	dw->size = total_size;
	dw->downloaded = 0;
	if(gui) dw->bw = gui->bw;
	dw->url = url;

	va[0] = (APTR)dw->downloaded;
	va[1] = (APTR)dw->size;
	va[2] = 0;

	if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0)))
	{
		FreeVec(dw);
		return NULL;
	}

	dw->objects[OID_MAIN] = WindowObj,
      	    WA_ScreenTitle, ami_gui_get_screen_title(),
           	WA_Title, dw->url,
           	WA_Activate, TRUE,
           	WA_DepthGadget, TRUE,
           	WA_DragBar, TRUE,
           	WA_CloseGadget, FALSE,
           	WA_SizeGadget, TRUE,
			WA_PubScreen,scrn,
			WINDOW_SharedPort,sport,
			WINDOW_UserData,dw,
			WINDOW_IconifyGadget, FALSE,
			WINDOW_LockHeight,TRUE,
         	WINDOW_Position, WPOS_CENTERSCREEN,
           	WINDOW_ParentGroup, dw->objects[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, dw->objects[GID_STATUS] = FuelGaugeObj,
					GA_ID,GID_STATUS,
					GA_Text,messages_get("amiDownload"),
					FUELGAUGE_Min,0,
					FUELGAUGE_Max,total_size,
					FUELGAUGE_Level,0,
					FUELGAUGE_Ticks,11,
					FUELGAUGE_ShortTicks,TRUE,
					FUELGAUGE_VarArgs,va,
					FUELGAUGE_Percent,FALSE,
					FUELGAUGE_Justification,FGJ_CENTER,
				FuelGaugeEnd,
				CHILD_NominalSize,TRUE,
				CHILD_WeightedHeight,0,
				LAYOUT_AddChild, dw->objects[GID_CANCEL] = ButtonObj,
					GA_ID,GID_CANCEL,
					GA_RelVerify,TRUE,
					GA_Text,messages_get("Abort"),
					GA_TabCycle,TRUE,
				ButtonEnd,
			EndGroup,
		EndWindow;

	dw->win = (struct Window *)RA_OpenWindow(dw->objects[OID_MAIN]);
	dw->ctx = ctx;

	dw->node = AddObject(window_list,AMINS_DLWINDOW);
	dw->node->objstruct = dw;

	downloads_in_progress++;

	return dw;
}
Пример #4
0
/**
 * Change the displayed search status.
 *
 * \param gwin gui window to open search for.
 */
void ami_search_open(struct gui_window *gwin)
{
	search_insert = true;

	if(fwin)
	{
		browser_window_search_clear(fwin->gwin->bw);
		fwin->gwin->shared->searchwin = NULL;
		fwin->gwin = gwin;
		gwin->shared->searchwin = fwin;
		WindowToFront(fwin->win);
		ActivateWindow(fwin->win);
		return;
	}

	fwin = ami_misc_allocvec_clear(sizeof(struct find_window), 0);

	fwin->objects[OID_MAIN] = WindowObj,
      	WA_ScreenTitle, ami_gui_get_screen_title(),
       	WA_Title,messages_get("FindTextNS"),
       	WA_Activate, TRUE,
       	WA_DepthGadget, TRUE,
       	WA_DragBar, TRUE,
       	WA_CloseGadget, TRUE,
       	WA_SizeGadget, TRUE,
		WA_PubScreen,scrn,
		WINDOW_SharedPort,sport,
		WINDOW_UserData,fwin,
		WINDOW_IconifyGadget, FALSE,
		WINDOW_LockHeight,TRUE,
         	WINDOW_Position, WPOS_CENTERSCREEN,
           	WINDOW_ParentGroup, fwin->objects[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, fwin->objects[GID_SEARCHSTRING] = StringObj,
					GA_ID,GID_SEARCHSTRING,
					GA_TabCycle,TRUE,
					GA_RelVerify,TRUE,
				StringEnd,
				CHILD_WeightedHeight,0,
				LAYOUT_AddChild, fwin->objects[GID_CASE] = CheckBoxObj,
					GA_ID,GID_CASE,
					GA_Text,messages_get("CaseSens"),
					GA_Selected,FALSE,
					GA_TabCycle,TRUE,
					GA_RelVerify,TRUE,
				CheckBoxEnd,
				LAYOUT_AddChild, fwin->objects[GID_SHOWALL] = CheckBoxObj,
					GA_ID,GID_SHOWALL,
					GA_Text,messages_get("ShowAll"),
					GA_Selected,FALSE,
					GA_TabCycle,TRUE,
					GA_RelVerify,TRUE,
				CheckBoxEnd,

				LAYOUT_AddChild, LayoutHObj,
					LAYOUT_AddChild, fwin->objects[GID_PREV] = ButtonObj,
						GA_ID,GID_PREV,
						GA_RelVerify,TRUE,
						GA_Text,messages_get("Prev"),
						GA_TabCycle,TRUE,
						GA_Disabled,TRUE,
					ButtonEnd,
					CHILD_WeightedHeight,0,
					LAYOUT_AddChild, fwin->objects[GID_NEXT] = ButtonObj,
						GA_ID,GID_NEXT,
						GA_RelVerify,TRUE,
						GA_Text,messages_get("Next"),
						GA_TabCycle,TRUE,
						GA_Disabled,TRUE,
					ButtonEnd,
				LayoutEnd,
				CHILD_WeightedHeight,0,
			EndGroup,
		EndWindow;

	fwin->win = (struct Window *)RA_OpenWindow(fwin->objects[OID_MAIN]);
	fwin->gwin = gwin;
	fwin->node = AddObject(window_list,AMINS_FINDWINDOW);
	fwin->node->objstruct = fwin;
	gwin->shared->searchwin = fwin;
	
	ActivateLayoutGadget((struct Gadget *)fwin->objects[GID_MAIN], fwin->win,
			NULL, (ULONG)fwin->objects[GID_SEARCHSTRING]);
}
Пример #5
0
void ami_print_ui(struct hlcache_handle *c)
{
	char filename[30];
	int i;

	struct ami_print_window *pw = ami_misc_allocvec_clear(sizeof(struct ami_print_window), 0);

	pw->c = c;

	printers[0] = ami_misc_allocvec_clear(50, 0);
	ami_print_readunit("ENV:Sys/printer.prefs", printers[0], 50, 0);

	strcpy(filename,"ENV:Sys/printerN.prefs");
	for (i = 1; i < 10; i++)
	{
		filename[15] = '0' + i;
		printers[i] = AllocVecTagList(50, NULL);
		if(!ami_print_readunit(filename, printers[i], 50, i))
		{
			FreeVec(printers[i]);
			printers[i] = NULL;
			break;
		}

	}

	ami_print_ui_setup();

	pw->objects[OID_MAIN] = WindowObj,
      	    WA_ScreenTitle, ami_gui_get_screen_title(),
           	WA_Title, gadlab[PGID_PRINT],
           	WA_Activate, TRUE,
           	WA_DepthGadget, TRUE,
           	WA_DragBar, TRUE,
           	WA_CloseGadget, TRUE,
           	WA_SizeGadget, FALSE,
			WA_PubScreen, scrn,
			WINDOW_SharedPort, sport,
			WINDOW_UserData, pw,
			WINDOW_IconifyGadget, FALSE,
         	WINDOW_Position, WPOS_CENTERSCREEN,
           	WINDOW_ParentGroup, pw->gadgets[PGID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, ChooserObject,
					GA_ID, PGID_PRINTER,
					GA_RelVerify, TRUE,
					GA_TabCycle, TRUE,
					CHOOSER_LabelArray, printers,
					CHOOSER_Selected, nsoption_int(printer_unit),
				ChooserEnd,
				CHILD_Label, LabelObject,
					LABEL_Text, gadlab[PGID_PRINTER],
				LabelEnd,
				LAYOUT_AddChild, IntegerObject,
					GA_ID, PGID_COPIES,
					GA_RelVerify, TRUE,
					GA_TabCycle, TRUE,
					INTEGER_Number, 1,
					INTEGER_Minimum, 1,
					INTEGER_Maximum, 100,
					INTEGER_Arrows, TRUE,
				IntegerEnd,
				CHILD_Label, LabelObject,
					LABEL_Text, gadlab[PGID_COPIES],
				LabelEnd,
				LAYOUT_AddChild, HGroupObject,
					LAYOUT_LabelColumn, PLACETEXT_RIGHT,
					LAYOUT_AddChild, pw->gadgets[PGID_SCALE] = IntegerObj,
						GA_ID, PGID_SCALE,
						GA_RelVerify, TRUE,
						GA_TabCycle, TRUE,
						INTEGER_Number, nsoption_int(print_scale),
						INTEGER_Minimum, 0,
						INTEGER_Maximum, 100,
						INTEGER_Arrows, TRUE,
					IntegerEnd,
					CHILD_WeightedWidth, 0,
					CHILD_Label, LabelObject,
						LABEL_Text, "%",
					LabelEnd,
				LayoutEnd,
				CHILD_Label, LabelObject,
					LABEL_Text, gadlab[PGID_SCALE],
				LabelEnd,
				LAYOUT_AddChild, HGroupObject,
					LAYOUT_AddChild, pw->gadgets[PGID_PRINT] = ButtonObj,
						GA_ID, PGID_PRINT,
						GA_RelVerify,TRUE,
						GA_Text, gadlab[PGID_PRINT],
						GA_TabCycle,TRUE,
					ButtonEnd,
					CHILD_WeightedHeight,0,
					LAYOUT_AddChild, pw->gadgets[GID_CANCEL] = ButtonObj,
						GA_ID, PGID_CANCEL,
						GA_RelVerify, TRUE,
						GA_Text, gadlab[PGID_CANCEL],
						GA_TabCycle,TRUE,
					ButtonEnd,
				LayoutEnd,
				CHILD_WeightedHeight,0,
			EndGroup,
		EndWindow;

	pw->win = (struct Window *)RA_OpenWindow(pw->objects[OID_MAIN]);

	pw->node = AddObject(window_list, AMINS_PRINTWINDOW);
	pw->node->objstruct = pw;
}
Пример #6
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;
}