コード例 #1
0
ファイル: win32gui_extra.cpp プロジェクト: fdagosti/WinUAE
struct newresource *scaleresource (struct newresource *res, HWND parent)
{
	DLGTEMPLATEEX *d;
	DLGTEMPLATEEX_END *d2;
	DLGITEMTEMPLATEEX *dt;
	BYTE *p, *p2;
	int i;
	struct newresource *ns;

	d = (DLGTEMPLATEEX*)res->resource;
	d2 = (DLGTEMPLATEEX_END*)res->resource;

	if (d->dlgVer != 1 || d->signature != 0xffff)
		return 0;
	if (!(d->style & (DS_SETFONT | DS_SHELLFONT)))
		return 0;

	ns = xcalloc (struct newresource, 1);
	ns->inst = res->inst;
	ns->size = res->size;
	ns->tmpl = res->tmpl;
	ns->resource = (LPCDLGTEMPLATEW)xmalloc (uae_u8, ns->size);
	memcpy ((void*)ns->resource, res->resource, ns->size);

	d = (DLGTEMPLATEEX*)ns->resource;
	d2 = (DLGTEMPLATEEX_END*)ns->resource;
	p = (BYTE*)d + sizeof (DLGTEMPLATEEX);
	p = skiptext (p);
	p = skiptext (p);
	p = skiptext (p);
	d2 = (DLGTEMPLATEEX_END*)p;
	p2 = p;
	p2 += sizeof (DLGTEMPLATEEX_END);
	p2 = skiptextone (p2);
	p2 = todword (p2);

	modifytemplatefont (d, d2);

	p += sizeof (DLGTEMPLATEEX_END);
	p = skiptextone (p);
	p = todword (p);

	if (p != p2)
		memmove (p, p2, ns->size - (p2 - (BYTE*)ns->resource));

	modifytemplate(d, d2, ns->tmpl, mult);

	for (i = 0; i < d->cDlgItems; i++) {
		dt = (DLGITEMTEMPLATEEX*)p;
		modifyitem (d, d2, dt, ns->tmpl, mult);
		p += sizeof (DLGITEMTEMPLATEEX);
		p = skiptextone (p);
		p = skiptext (p);
		p += ((WORD*)p)[0];
		p += sizeof (WORD);
		p = todword (p);
	}

	ns->width = d->cx;
	ns->height = d->cy;
	return ns;
}
コード例 #2
0
ファイル: wbcli.c プロジェクト: apprisi/illumos-gate
/*
 * Evaluate the commands provided by the user (either as "-o" boot arguments
 * or interactively at the boot interpreter).
 */
static int
cli_eval_buf(char *inbuf, int wanted)
{
	char		*p, *varstr, *end_varstr, *valstr, *end_valstr;
	boolean_t	assign;
	cli_ent_t	*cliptr;

	for (p = inbuf; *p != '\0'; ) {
		skipspace(p);

		/* If nothing more on line, go get the next one */
		if (*p == '\0') {
			break;
		} else if (*p == ',') {		/* orphan ',' ? */
			++p;
			continue;
		}

		/* Get ptrs to start & end of variable */
		varstr = p;
		++p;
		skiptext(p);
		end_varstr = p;
		skipspace(p);

		/* See if we're doing an assignment */
		valstr = NULL;
		if (*p != '=') {	/* nope, just printing */
			assign = B_FALSE;
		} else {
			assign = B_TRUE;
			++p;			/* past '=' */
			skipspace(p);

			/* Assigning something? (else clear variable) */
			if (*p != '\0' && *p != ',') {
				/* Get ptrs to start & end of valstr */
				valstr = p;
				++p;
				skiptext(p);
				end_valstr = p;
				skipspace(p);
			}
		}

		/* Skip ',' delimiter if present */
		if (*p == ',') {
			++p;
		}

		/* Nul-terminate varstr and valstr (if appropriate) */
		*end_varstr = '\0';
		if (valstr != NULL) {
			*end_valstr = '\0';
		}

		if ((cliptr = find_cli_ent(varstr)) == NULL) {
			printf("Unknown variable '%s'; ignored\n", varstr);
			continue;
		}

		/*
		 * It's an error to specify a parameter which can only be a
		 * boot argument (and not a command) when not processing the
		 * boot arguments.
		 */
		if ((cliptr->flags & (CLF_CMD | CLF_ARG)) == CLF_ARG &&
		    (wanted & CLF_ARG) == 0) {
			printf("'%s' may only be specified as a "
			    "boot argument; ignored\n", varstr);
			continue;
		}

		/*
		 * When doing an assignment, verify that it's not a command
		 * or argument name, and that it is permissible in the current
		 * context.  An 'empty' assignment (var=) is treated the same
		 * as a null assignment (var="").
		 *
		 * If processing the boot arguments, it is an error to not
		 * assign a value to a non-argument parameter.
		 */
		if (assign) {
			if ((cliptr->flags & (CLF_CMD | CLF_ARG)) != 0) {
				printf("'%s' is a command and cannot "
				    "be assigned\n", varstr);
				return (CLI_FAIL);
			}
			if ((cliptr->flags & wanted) == 0) {
				printf("'%s' cannot be assigned\n", varstr);
				return (CLI_FAIL);
			}

			if (valstr == NULL) {
				cliptr->varlen = 0;
				CLF_MODVAL(cliptr);
				continue;
			}
		} else if ((wanted & CLF_ARG) != 0 &&
		    (cliptr->flags & (CLF_CMD | CLF_ARG)) == 0) {
			printf("'%s' must be assigned when specified in "
			    " the boot arguments\n", varstr);
			return (CLI_FAIL);
		}

		/*
		 * Pass 'wanted' to command-handling functions, in particular
		 * clprompt() and cllist().
		 */
		if ((cliptr->flags & CLF_CMD) != 0) {
			/* use uintptr_t to suppress the gcc warning */
			valstr = (char *)(uintptr_t)wanted;
		}

		/*
		 * Call the parameter's action function.
		 */
		switch (cliptr->action(cliptr, valstr, !assign)) {
		case CLI_SET:
			CLF_MODVAL(cliptr);
			break;
		case CLI_FAIL:
			printf("Incorrect format: variable '%s' not set\n",
			    cliptr->varname);
			break;
		case CLI_EXIT:
			return (CLI_EXIT);
		case CLI_CONT:
			if (!assign) {
				printf("\n");
			}
			break;
		}
	}

	return (CLI_CONT);
}
コード例 #3
0
ファイル: win32gui_extra.cpp プロジェクト: Blonder/WinUAE
static struct newresource *scaleresource2 (struct newresource *res, HWND parent, int resize, int fullscreen, DWORD exstyle)
{
	DLGTEMPLATEEX *d, *s;
	DLGTEMPLATEEX_END *d2, *s2;
	DLGITEMTEMPLATEEX *dt;
	BYTE *p, *p2, *ps, *ps2;
	int i;
	struct newresource *ns;

	listviewcnt = 0;

	d = (DLGTEMPLATEEX*)res->resource;
	d2 = (DLGTEMPLATEEX_END*)res->resource;

	if (d->dlgVer != 1 || d->signature != 0xffff)
		return 0;
	if (!(d->style & (DS_SETFONT | DS_SHELLFONT)))
		return 0;

	ns = xcalloc (struct newresource, 1);
	ns->inst = res->inst;
	ns->size = res->size;
	ns->tmpl = res->tmpl;
	ns->resource = (LPCDLGTEMPLATEW)xmalloc (uae_u8, ns->size + 32);
	memcpy ((void*)ns->resource, res->resource, ns->size);

	d = (DLGTEMPLATEEX*)ns->resource;
	s = (DLGTEMPLATEEX*)res->resource;

	int width = d->cx;
	int height = d->cy;

	if (resize > 0) {
		d->style &= ~DS_MODALFRAME;
		d->style |= WS_THICKFRAME;
	} else if (resize == 0) {
		d->style |= DS_MODALFRAME;
		d->style &= ~WS_THICKFRAME;
	}
	if (fullscreen > 0) {
		//d->style |= SW_MAXIMIZE;
		d->style |= WS_THICKFRAME;
	} else {
		d->style |= WS_MINIMIZEBOX;
	}
	d->exStyle |= exstyle;

	d2 = (DLGTEMPLATEEX_END*)ns->resource;
	p = (BYTE*)d + sizeof (DLGTEMPLATEEX);
	p = skiptext (p);
	p = skiptext (p);
	p = skiptext (p);

	s2 = (DLGTEMPLATEEX_END*)res->resource;
	ps = (BYTE*)s2 + sizeof (DLGTEMPLATEEX);
	ps = skiptext (ps);
	ps = skiptext (ps);
	ps = skiptext (ps);

	d2 = (DLGTEMPLATEEX_END*)p;
	p2 = p;
	p2 += sizeof (DLGTEMPLATEEX_END);
	p2 = skiptextone (p2);
	p2 = todword (p2);

	s2 = (DLGTEMPLATEEX_END*)ps;
	ps2 = ps;
	ps2 += sizeof (DLGTEMPLATEEX_END);
	ps2 = skiptextone (ps2);
	ps2 = todword (ps2);

	modifytemplatefont (d, d2);

	p += sizeof (DLGTEMPLATEEX_END);
	p = skiptextone (p);
	p = todword (p);

	memcpy (p, ps2, ns->size - (ps2 - (BYTE*)res->resource));

	modifytemplate(d, d2, ns->tmpl, fullscreen);

	for (i = 0; i < d->cDlgItems; i++) {
		dt = (DLGITEMTEMPLATEEX*)p;
		modifyitem (d, d2, dt, ns->tmpl);
		p += sizeof (DLGITEMTEMPLATEEX);
		p = skiptextone (p);
		p = skiptext (p);
		p += ((WORD*)p)[0];
		p += sizeof (WORD);
		p = todword (p);
	}

	ns->width = width;
	ns->height = height;
	return ns;
}
コード例 #4
0
ファイル: wbcli.c プロジェクト: apprisi/illumos-gate
/*ARGSUSED*/
static int
clprompt(cli_ent_t *cliptr, char *valstr, boolean_t out)
{
	char	*p;
	int	wanted = (int)(uintptr_t)valstr; /* use uintrptr_t for gcc */

	/*
	 * If processing boot arguments, simply note the fact that clprompt()
	 * should be invoked later when other parameters may be supplied.
	 */
	if ((wanted & CLF_ARG) != 0) {
		args_specified_prompt = B_TRUE;
		return (CLI_CONT);
	}
	wanted  &= ~(CLF_CMD | CLF_ARG);

	for (cliptr = cli_list; cliptr < &cli_list[num_cli_ent]; ++cliptr) {
		if ((cliptr->flags & wanted) == 0) {
			continue;
		}

		printf("%s", cliptr->varname);
		if (CLF_ISSET(cliptr)) {
			printf(" [");
			(void) cliptr->action(cliptr, NULL, B_TRUE);
			printf("]");
		}
		printf("? ");
		(void) editline(cmdbuf, sizeof (cmdbuf));
		printf("\n");

		p = cmdbuf;
		skipspace(p);
		if (*p == '\0') {	/* nothing there */
			continue;
		}

		/* Get valstr and nul terminate */
		valstr = p;
		++p;
		skiptext(p);
		*p = '\0';

		/* If empty value, do nothing */
		if (strlen(valstr) == 0) {
			continue;
		}

		switch (cliptr->action(cliptr, valstr, B_FALSE)) {
		case CLI_SET:
			CLF_MODVAL(cliptr);
			break;
		case CLI_FAIL:
			printf("Incorrect format, parameter unchanged!\n");
			break;
		case CLI_EXIT:
			return (CLI_EXIT);
		case CLI_CONT:
			break;
		}
	}

	return (CLI_CONT);
}