Ejemplo n.º 1
0
Archivo: xrgen.c Proyecto: noikiy/VICAR
FUNCTION VOID BRIDGE2_NAME(xrstr)
(
    TAEINT		*block,		/* in: parameter block		*/
    FORSTR		*name,		/* in: parameter name		*/
    TAEINT		*dimen,		/* in: dimension of string	*/
    FORSTR		*string,	/* out: FOR-77 string(s)	*/
    TAEINT		length[],	/* out: length of each string	*/
    TAEINT		*n,		/* out: number of strings	*/
    TAEINT		*status	/* out: status code		*/

)
{
    IMPORT TEXT		pm_dim[],pk_dim[],pm_type[],pk_type[];
    struct PARBLK *parblk;
    struct VARIABLE *v;
    TEXT	**s;			/* ptr to value vector in block	*/
    TEXT	c_name[STRINGSIZ+1];	/* name in C string format	*/
    COUNT	i;
    CODE	code;


    parblk = (struct PARBLK *) block;
    s_for2c(name, c_name, 0);			/* convert name to C string	*/
    s_strip(c_name);				/* remove trailing blanks	*/
    *n = 0;					/* caution in case error	*/

    v = p_find(parblk, c_name);
    if (v == NULL) goto p__bnerr;
    if ((*v).v_type != V_STRING) goto p__bterr; /* error if not string    */
    s = (TEXT **) (*v).v_cvp;			/* value pointer          */
    *status = SUCCESS;
    *n = (*v).v_count;				/* number of strings 		*/
    for (i=0; i < (*v).v_count && i < *dimen; i++)
    {
        length[i] = s_length(s[i]);		/* pass this length to caller	*/
        code = s_c2for(s[i], string, i);	/* copy string to caller	*/
        if (code != SUCCESS)
        {
            x_error((*parblk).mode, "String size overflows buffer",
                    "TAE-OVER", 0, 0, 0);
            *status = P_OVER;
            return;
        }
    }
    if ((*v).v_count > *dimen)
    {
        x_error((*parblk).mode, pm_dim, pk_dim,(uintptr_t) c_name, 0, 0);
        *status = P_BADCOUNT;		/* bad count		*/
    }
    return;

p__bnerr:
    *status = P_BADNAME;
    return;

p__bterr:
    *status = P_BADTYPE;
    x_error((*parblk).mode, pm_type, pk_type, (uintptr_t) c_name, 0, 0);
    return;
}
Ejemplo n.º 2
0
Archivo: xrgen.c Proyecto: noikiy/VICAR
/*
 *	XRINTG.  Get integer parameters/variables.
 */
FUNCTION VOID BRIDGE2_NAME(xrintg)
(
    TAEINT		*block,		/* in: parameter block		*/
    FORSTR		*name,		/* in: parameter name		*/
    TAEINT		*dimen,		/* in: max # of values(dim of intg)	*/
    int			intg[],		/* out: array with intger var	*/
    TAEINT		*n,		/* out: integer value count	*/
    TAEINT		*status	/* out: status code		*/

)
{
    IMPORT TEXT		pm_dim[],pk_dim[],pm_type[],pk_type[];
    struct 	PARBLK 	*parblk;
    struct	VARIABLE *v;
    TEXT		c_name[STRINGSIZ+1];	/* name in C string format	*/
    COUNT		i;


    parblk = (struct PARBLK *) block;
    s_for2c(name, c_name, 0);			/* convert name to C string	*/
    s_strip(c_name);				/* remove trailing blanks	*/
    *n = 0;					/* caution in case error	*/

    v = p_find(parblk, c_name);
    if (v == NULL) goto p__bnerr;
    if ((*v).v_type != V_INTEGER) goto p__bterr;
    if ((*v).v_count > *dimen) goto p__bcerr;
    *n = (*v).v_count;
    for (i = 0; i < (*v).v_count; i++)
        intg[i] = IVAL(*v, i);
    *status = SUCCESS;
    return;

p__bnerr:
    *status = P_BADNAME;
    return;

p__bterr:
    *status = P_BADTYPE;
    x_error((*parblk).mode, pm_type, pk_type, (uintptr_t) c_name, 0, 0);
    return;

p__bcerr:
    *status = P_BADCOUNT;
    x_error((*parblk).mode, pm_dim, pk_dim, (uintptr_t) c_name, 0, 0);
    return;
}
Ejemplo n.º 3
0
static int dx_alloc_buffers(char **b1, char **b2)
{
    DWORD ddrval;
    DDSURFACEDESC ddsd;
    int i;
    currentbuff = 0;
    memset(surface, 0, sizeof(DDSURFACEDESC) * 2);
    memset(&ddsd, 0, sizeof(DDSURFACEDESC));
    ddsd.dwSize = sizeof(ddsd);
    if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &ddsd) != DD_OK) {
	DeInitDD();
	x_error("Failed to get pixel format");
	return 0;
    }
    for (i = 0; i < 2; i++) {
	ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
	ddsd.dwWidth = displayX;
	ddsd.dwHeight = displayY;
	ddsd.ddsCaps.dwCaps =
	    DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;

	ddrval =
	    IDirectDraw_CreateSurface(lpDD, &ddsd, &BackSurface[i], NULL);
	if (ddrval != DD_OK) {
	    DeInitDD();
	    x_error("Failed to create back surface");
	    return 0;
	}
    }
    for (i = 0; i < 2; i++) {
	surface[i].dwSize = sizeof(DDSURFACEDESC);
	ddrval = IDirectDrawSurface_Lock(BackSurface[i], NULL, surface + i,
					 DDLOCK_WAIT, NULL);
	if (ddrval != DD_OK) {
	    DeInitDD();
	    x_fatalerror("Failed to lock offscreen surfaces");
	}
    }
    buffer1 = *b1 = (char *) surface[0].lpSurface;
    buffer2 = *b2 = (char *) surface[1].lpSurface;
    lineSize = surface[0].u1.lPitch;
    initialized = 1;
    return lineSize;
}
Ejemplo n.º 4
0
void win32_help(struct uih_context *c, CONST char *name)
{
#ifdef HTML_HELP
    FILE *f;
    char *n;
    if (helpname == NULL) {
	if (directX == DXFULLSCREEN)
	    ShowWindow(hWnd, SW_MINIMIZE);
	n = xio_fixpath("\01\\help\\xaoshelp.chm");
	if ((f = fopen(n, "r"))) {
	    fclose(f);
	} else {
	    free(n);
	    n = xio_fixpath("\01\\..\\help\\xaoshelp.chm");
	    if ((f = fopen(n, "r"))) {
		fclose(f);
	    } else
		n = strdup("..\\help\\xaoshelp.chm");
	}
	helpname = n;
    }
    HH_AKLINK link;
    link.cbStruct =     sizeof(HH_AKLINK) ;
    link.fReserved =    FALSE ;
    link.pszKeywords =  name ;
    link.pszUrl =       NULL ;
    link.pszMsgText =   NULL ;
    link.pszMsgTitle =  NULL ;
    link.pszWindow =    NULL ;
    link.fIndexOnFail = TRUE ;

    if (!HtmlHelp(hWnd, helpname, HH_ALINK_LOOKUP, (DWORD) &link)) {
	x_error("Could not display help for topic %s from file %s", name, helpname);
    }
#else
    x_error("Help support not included in this executable.");
#endif
}
Ejemplo n.º 5
0
static void win32_copy(struct uih_context *uih)
{
    char *c = ui_getpos();
    HANDLE hData = GlobalAlloc(GMEM_DDESHARE, strlen(c) + 1);
    char *data;
    if (!hData) {
	x_error("Out of memory");
	free(c);
	return;
    }
    if (!(data = GlobalLock(hData))) {
	x_error("Out of memory");
	free(c);
	return;
    }
    memcpy(hData, c, strlen(c) + 1);
    GlobalUnlock(hData);
    if (OpenClipboard(hWnd)) {
	EmptyClipboard();
	SetClipboardData(clipboard_format, hData);
    }
    free(c);
}
Ejemplo n.º 6
0
static int dx_imgparams(void)
{
    DDSURFACEDESC s;
    memset(&s, 0, sizeof(s));
    s.dwSize = sizeof(s);
    if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &s) != DD_OK) {
	DeInitDD();
	x_error("Failed to get pixel format");
	return 0;
    }
    switch (s.ddpfPixelFormat.u1.dwRGBBitCount) {
    case 8:
	dxw_driver.imagetype = UI_C256;
	dxf_driver.imagetype = UI_C256;
	break;
    case 16:
    case 15:
	dxw_driver.imagetype = UI_TRUECOLOR16;
	dxf_driver.imagetype = UI_TRUECOLOR16;
	break;
    case 24:
	dxw_driver.imagetype = UI_TRUECOLOR24;
	dxf_driver.imagetype = UI_TRUECOLOR24;
	break;
    case 32:
	dxw_driver.imagetype = UI_TRUECOLOR;
	dxf_driver.imagetype = UI_TRUECOLOR;
	break;
    default:
	x_fatalerror
	    ("Unsupported bit depth! Only 8bpp, 16bpp, 24bpp and 32bpp modes supported\n");
	return 0;
    }
    dxw_driver.rmask = s.ddpfPixelFormat.u2.dwRBitMask;
    dxw_driver.gmask = s.ddpfPixelFormat.u3.dwGBitMask;
    dxw_driver.bmask = s.ddpfPixelFormat.u4.dwBBitMask;
    dxf_driver.rmask = s.ddpfPixelFormat.u2.dwRBitMask;
    dxf_driver.gmask = s.ddpfPixelFormat.u3.dwGBitMask;
    dxf_driver.bmask = s.ddpfPixelFormat.u4.dwBBitMask;
    dxf_driver.textwidth = fontWidth;
    dxf_driver.textheight = fontHeight;
    dxw_driver.textwidth = fontWidth;
    dxw_driver.textheight = fontHeight;
    return 1;
}
Ejemplo n.º 7
0
static void win32_paste(void)
{
    if (OpenClipboard(hWnd)) {
	HANDLE hClipData;
	char *text;
	if (!(hClipData = GetClipboardData(clipboard_format))) {
	    CloseClipboard();
	    return;
	}
	if (!(text = GlobalLock(hClipData))) {
	    x_error("Out of memory");
	    CloseClipboard();
	}
	ui_loadstr(strdup(text));
	GlobalUnlock(hClipData);
	CloseClipboard();
    }
}
Ejemplo n.º 8
0
    FUNCTION CODE old_Co_WriteFile (

    	Id		c,		/* in: collection of Vm objects */
        TEXT		*filespec	/* in: file specification 	*/
    )
    {
    CODE		code;
    struct SFILE	f;

    code = f_opnspc (&f, 1, filespec, "", "", "res", F_WRITE);
    if (code != SUCCESS)
        {
	x_error(P_CONT, "Error opening resource file '%s'.  %s.", "TAE-PFOPN",
		(uintptr_t)filespec, (uintptr_t)f.errmsg, 0);
        return (FAIL);
        }
    f_write (&f, AR_SENTINEL);			/* archive sentinel string */ 
    code = old_Co_ForEach ((struct COLLECTION *)c, (coFunction)writeVmToFile, (GENPTR)&f);
    f_close (&f, F_KEEP);
    if (code != 0)
	return (FAIL);			/* premature Co_ForEach termination */
    return (SUCCESS);
    }
Ejemplo n.º 9
0
Archivo: zinit.c Proyecto: E-LLP/VICAR
FUNCTION  FILE *z_init
(
#ifdef LARGE_PARBLK_FIX
    struct LARGE_PARBLK *block,         /* out: parameter block         */
#else
    struct	PARBLK	*block,		/* out: parameter block		*/
#endif
    FUNINT		mode		/* in: mode: P_ABORT or P_CONT  */

 )
    {
    IMPORT  FILE	*stdo_file;	/* pointer to stdout file	*/
    IMPORT  BOOL	term_std;	/* true if terminal is stdout   */
    IMPORT  CODE	applic_type;	/* application type ('c')	*/
    IMPORT  TEXT	pm_type[], pk_type[];
    struct VARIABLE	*v;
    CODE		termtype;
    COUNT		termlines;
    COUNT		termcols;
    TEXT		msgbuf[STRINGSIZ+1];
    TEXT		**stdr_ptr = 0;	/* stdrec string vector pointer	*/
    COUNT		len;
    CODE		code;
    TEXT		filemode[2];	/* create or append		*/
    FILE		*stdo_ptr;

    t_init(&termlines, &termcols, &termtype);	/* initialize terminal pkg */
#ifdef LARGE_PARBLK_FIX
    code = p_inim((struct PARBLK *)block, sizeof(struct LARGE_PARBLK), mode);    
#else
    code = p_inim(block, sizeof(struct PARBLK), mode);	
#endif
                                                /* receive parblk from TM  */
    if (code != SUCCESS)
	return (NULL);
    z_call ((struct PARBLK *)block);		/* application init	   */

    v = p_find ((struct PARBLK *)block, "_STDOUT");  /* get the string	*/	
    if ((*v).v_type != V_STRING)
      x_error ((*block).mode, pm_type, pk_type, (uintptr_t) "_STDOUT", 0, 0);
    else
	stdr_ptr = (TEXT **) (*v).v_cvp;	/* get value pointer	*/
    term_std = (s_equal(TERMINAL, stdr_ptr[0]));   /* filename = terminal ? */
#ifdef VICAR_BATCH_LOG
#ifdef VAX_VMS
    if (s_equal("SYS$OUTPUT:.;", stdr_ptr[0]))  /* alternate form of terminal */
        term_std = TRUE;
#endif
#endif
    s_copy("w", filemode);			/* assume create	    */
    if (!s_equal(stdr_ptr[1] , "CREATE"))
	s_copy("a", filemode);
#ifdef UNIX
    s_lower(stdr_ptr[0]);			/* make file name lower case */
#endif
    stdo_ptr = fopen(stdr_ptr[0], filemode);    	/* open the file */
    if (stdo_ptr == NULL)
	{
	if (mode == P_ABORT)
	    {
	    len = s_copy("Could not open standard output file ", msgbuf);
	    s_bcopy(stdr_ptr[0], &msgbuf[len], STRINGSIZ);
	    t_write(msgbuf, T_STDCC);			/* errmsg to terminal*/
	    z_exit(-1, "TAE-STDOPEN");			/* set SFI, SKEY     */
 	    }
	stdo_ptr = stdout;	/* Allow running with no terminal! */
				/* (without triggering shell-vicar) */
	}
    else
	stdo_file = stdo_ptr;			/* save stdout ptr globally */
    applic_type = C_TYPE;			/* 'c' language application */
    return (stdo_ptr);
    }
Ejemplo n.º 10
0
Archivo: xrfile.c Proyecto: E-LLP/VICAR
FUNCTION VOID BRIDGE2_NAME(xrfile) 
(
    TAEINT		*block,		/* in: parameter block		*/
    FORSTR		*name,		/* in: parameter name		*/
    TAEINT		*dimen,		/* in: dimension of string	*/
    FORSTR		*tae_file,	/* out: FOR-77 tae file string(s)	*/
    TAEINT		tae_length[],	/* out: length of each tae file string	*/
    FORSTR		*host_file,	/* out: FOR-77 host file string(s)	*/
    TAEINT		host_length[],	/* out: length of each host file string	*/
    TAEINT		*n,		/* out: number of strings	*/
    TAEINT		*status	/* out: status code		*/

 )
    {
    struct PARBLK 	*parblk;
    TEXT		**s;			/* ptr to value vector in block	*/
    TEXT		c_name[STRINGSIZ+1];	/* name in C string format	*/
    COUNT		i;
    struct VARIABLE	*v;		/* variable in parm block		*/
    TEXT		temp[FSPECSIZ+1];
    TAEINT 		filemode;
    CODE		code;

    parblk = (struct PARBLK *) block;
    s_for2c(name, c_name, 0);			/* convert name to C string	*/
    s_strip(c_name);				/* remove trailing blanks	*/
    *n = 0;					/* caution in case error	*/ 

    v = p_find(parblk, c_name);			/* get string			*/
    if (v == NULL) goto p__bnerr;		/* check for name error		*/
    if ((*v).v_type != V_STRING) goto p__bterr; /* check for type error		*/
    s = (TEXT **) (*v).v_cvp;			/* value pointer		*/

    if (!(*v).v_file) goto p__bterr;
    filemode = (*v).v_filemode;
    *status = SUCCESS;				
    *n = (*v).v_count;				/* number of strings		*/
    for (i=0; i < (*v).v_count && i < *dimen; i++) /* get all tae & host files	*/
	{
	tae_length[i] = s_length(s[i]);	/* pass this length to caller	*/
	code = s_c2for(s[i], tae_file, i);	/* copy tae file to caller*/
        if (code != SUCCESS)
	    {
	    x_error((*parblk).mode, "File name longer than buffer size.",
		    "TAE-OVER", 0, 0, 0);
   	    *status = P_OVER;
	    return;
	    }
	xzhost(s[i], temp, &filemode, status);	/* get host spec	*/
	if (*status != SUCCESS)
	    {
	      x_error((*parblk).mode, (TEXT *) pm_trans, (TEXT *) pk_trans, 
		      (uintptr_t) s[i], 0, 0);
	    *status = P_FAIL;			/* failed to translate	*/
	    return;
	    }
	host_length[i] = s_length(temp);	/* pass this length to caller	*/
	s_c2for(temp, host_file, i);	/* copy host file to caller	*/
	}
    if ((*v).v_count > *dimen)
	*status = P_BADCOUNT;		/* bad count			*/
    return;

p__bnerr:
    *status = P_BADNAME;
    return;

p__bterr:
    x_error((*parblk).mode, (TEXT *) pm_type, (TEXT *) pk_type, 
	    (uintptr_t) (*v).v_name, 0, 0);
    *status = P_BADTYPE;
    return;
    }
Ejemplo n.º 11
0
/* init DirectX */
static int InitDD(int fullscreen)
{
    HRESULT ddrval;
    HDC hDC;
    directX = fullscreen ? DXFULLSCREEN : DXWINDOWED;

    if (!hModule)
	hModule = LoadLibrary("ddraw");
    if (!hModule) {
	/*x_error ("Unable to load DirectX (ddraw.dll)"); */
	return 0;
    }
    /* DirectDraw don't support 16 color modes. Don't even try to initialize
       it then. Also avoid unsupported bit depths in the windowed driver */
    hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
    bitDepth = GetDeviceCaps(hDC, BITSPIXEL);
    DeleteDC(hDC);

    if (!DXSUPPORTEDDEPTH(fullscreen, bitDepth))
	return 0;


    DirectDrawCreatePtr =
	(ddrawcreateptr) GetProcAddress(hModule, "DirectDrawCreate");
    if (!DirectDrawCreatePtr) {
	x_error
	    ("Unable to get hook DirectDrawCreate in ddraw.dll. Check your DirectX installation");
	return 0;
    }

    lpDD = NULL;
    lpDD2 = NULL;
    lpSurfaces[0] = NULL;
    lpSurfaces[1] = NULL;
    buffer1 = buffer2 = NULL;

    bitDepth = 8;

    InitWindow();
    UpdateWindow(hWnd);
    SetFocus(hWnd);


    /* contact DirectX */
    ddrval = DirectDrawCreatePtr(NULL, &lpDD, NULL);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to create DirectDraw object");
	return 0;
    }

    /* get IDirectDraw2 interface */
    ddrval =
	IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2,
				   (LPVOID *) & lpDD2);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to get DirectDraw2 object");
	return 0;
    }
    /* enumerate modes */
#ifdef DDRAW_DRIVER
    if (!nresolutions && directX == DXFULLSCREEN)
	IDirectDraw2_EnumDisplayModes(lpDD2, 0, NULL, NULL,
				      EnumModesCallback);
#endif


    if (!ResizeDD(fullscreen))
	return 0;
    if (fullscreen) {
	SetCapture(hWnd);	// make sure no other windows get mouse messages

	captured = 1;
    }

    return 1;
}
Ejemplo n.º 12
0
static int ResizeDD(int fullscreen)
{
    HRESULT ddrval;
    DDSURFACEDESC ddsd;
    /*DDCAPS2 ddscaps; */
    LPDIRECTDRAWCLIPPER pClipper;
    int dxwidth;
    int dxheight;
    int dxbpp;

    // free DirectX objects
    if (lpSurfaces[0])
	IDirectDrawSurface_Release(lpSurfaces[0]);
    lpSurfaces[0] = NULL;
    if (dxPalette)
	IDirectDrawPalette_Release(dxPalette);
    dxPalette = NULL;
    /* Set cooperative level */
    ddrval = IDirectDraw2_SetCooperativeLevel(lpDD2, hWnd,
					      fullscreen
					      ? (DDSCL_FULLSCREEN |
						 DDSCL_EXCLUSIVE |
						 DDSCL_ALLOWREBOOT)
					      : DDSCL_NORMAL);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to set cooperative level");
	return 0;
    }

    if (fullscreen) {
	if (sscanf(dxsize, "%ix%ix%i", &dxwidth, &dxheight, &dxbpp) != 3) {
	    dxwidth = DXWIDTH;
	    dxheight = DXHEIGHT;
	    dxbpp = DXBPP;
	}
	displayX = dxwidth;
	displayY = dxheight;
	bitDepth = dxbpp;
	if (bitDepth < 10)
	    bitDepth = 8;
	if (bitDepth >= 10 && bitDepth < 20)
	    bitDepth = 16;
	if (bitDepth >= 20 && bitDepth < 28)
	    bitDepth = 24;
	if (bitDepth >= 32 && bitDepth < 32)
	    bitDepth = 32;

	/* set resolution and bit depth */
	ddrval =
	    IDirectDraw2_SetDisplayMode(lpDD2, displayX, displayY,
					bitDepth, 0, 0);
	if (ddrval != DD_OK) {
	    /* The display mode cannot be changed. 
	       The mode is either not supported or 
	       another application has exclusive mode.

	       Try 320x200x256 and 640x480x256 modes before giving up */
	    displayX = 320;
	    displayY = 200;
	    bitDepth = 8;
	    ddrval =
		IDirectDraw2_SetDisplayMode(lpDD2, displayX, displayY,
					    bitDepth, 0, 0);
	    if (ddrval != DD_OK) {
		displayY = 240;
		if (ddrval != DD_OK) {
		    displayX = 640;
		    displayY = 480;
		    ddrval =
			IDirectDraw2_SetDisplayMode(lpDD2, displayX,
						    displayY, bitDepth, 0,
						    0);
		    if (ddrval != DD_OK) {
			/* Bad luck... give up. */
			DeInitDD();
			return 0;
		    }
		}
	    }
	}
	SetRect(&rcViewport, 0, 0, displayX, displayY);
	rcScreen = rcViewport;
    } else {
	/* Get the dimensions of the viewport and screen bounds */
	GetClientRect(hWnd, &rcViewport);
	GetClientRect(hWnd, &rcScreen);
	ClientToScreen(hWnd, (POINT *) & rcScreen.left);
	ClientToScreen(hWnd, (POINT *) & rcScreen.right);
	/*bitDepth = GetDeviceCaps (hDC, BITSPIXEL); */

	/* Create clipper object for window */
	ddrval = IDirectDraw_CreateClipper(lpDD, 0, &pClipper, NULL);
	if (ddrval != DD_OK) {
	    DeInitDD();
	    x_error("Failed to create clipper object");
	    return 0;
	}
	/* Asociate it */
	IDirectDrawClipper_SetHWnd(pClipper, 0, hWnd);
    }
    /* Create the primary surface with one back buffer */
    CalculateBITMAPINFO();	// calculate BITMAPINFO structure

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    ddrval = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSurfaces[0], NULL);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to create flipping surface");
	return 0;
    }

    if (!fullscreen) {
	IDirectDrawSurface_SetClipper(lpSurfaces[0], pClipper);
	IDirectDrawClipper_Release(pClipper);
	if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &ddsd) !=
	    DD_OK) {
	    DeInitDD();
	    x_error("Failed to get pixel format");
	    return 0;
	}
	bitDepth = ddsd.ddpfPixelFormat.u1.dwRGBBitCount;
    }

    if (bitDepth == 8) {
	/* create palette */
	ddrval =
	    IDirectDraw_CreatePalette(lpDD, DDPCAPS_8BIT,
				      (LPPALETTEENTRY) bmp->bmiColors,
				      &dxPalette, NULL);
	if (ddrval != DD_OK) {
	    DeInitDD();
	    x_error("Failed to create palette");
	    return 0;
	}

	/* set palette */
	IDirectDrawSurface_SetPalette(lpSurfaces[0], dxPalette);
    }
    if (fullscreen)
	SetCursor(NULL);
    needredraw = 1;
    return 1;

}
Ejemplo n.º 13
0
/*Create Xaos Window. It is either used for normal window mode or
   as basis for DirectX */
static int InitWindow(void)
{
    int width = CW_USEDEFAULT, height = CW_USEDEFAULT;
    int xpos = CW_USEDEFAULT, ypos = CW_USEDEFAULT;
    LOGPALETTE *logPalette;
    WNDCLASS wndClass;
    LOGFONT logFont;
    ATOM a;
    HDC hDC;
    TEXTMETRIC textMetric;
    HGLOBAL oldFont;
    RECT r;
    closeFlag = FALSE;

    altPressed = arrowsPressed = 0;
    if (hIcon == NULL)
	hIcon = LoadIcon(hInstance, "BIG");
    mouseButtons = 0;
    mouseX = 0;
    mouseY = 0;
    {
	static FARPROC proc;
	if (hModule2 == NULL) {
	    hModule2 = LoadLibrary("user32");
	    proc = GetProcAddress(hModule2, "RegisterClassExA");
	}
	if (proc != NULL) {
	    WNDCLASSEX ExWndClass;
	    memset(&ExWndClass, 0, sizeof(WNDCLASSEX));
	    if (hIconSm == NULL)
		hIconSm = LoadIcon(hInstance, "SMALL");
	    ExWndClass.hIconSm = hIconSm;
	    memset(&ExWndClass, 0, sizeof(WNDCLASSEX));
	    ExWndClass.style = CS_OWNDC;
	    ExWndClass.cbSize = sizeof(WNDCLASSEX);
	    ExWndClass.lpfnWndProc = WindowProc;
	    ExWndClass.hInstance = hInstance;
	    ExWndClass.hIcon = hIcon;
	    ExWndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	    ExWndClass.lpszClassName = "XaosWindow";
	    ExWndClass.hbrBackground =
		(HBRUSH) GetStockObject(BLACK_BRUSH);
	    a = (ATOM) proc(&ExWndClass);
	} else {
	    memset(&wndClass, 0, sizeof(WNDCLASS));
	    wndClass.style = CS_OWNDC;
	    wndClass.lpfnWndProc = WindowProc;
	    wndClass.hInstance = hInstance;
	    wndClass.hIcon = hIcon;
	    wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	    wndClass.lpszClassName = "XaosWindow";
	    wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
	    a = RegisterClass(&wndClass);
	}
    }
    if (!a) {
	x_error("Unable to create windows class");
	return 0;
    }

    /* First time use defaut size, otherwise use saved sizes */
    if (sscanf(size, "%ix%ix", &width, &height) != 2) {
	width = WWIDTH;
	height = WHEIGHT;
    }
    if (windowpos) {
	xpos = rcWindow.left;
	ypos = rcWindow.top;
	width = rcWindow.right - rcWindow.left;
	height = rcWindow.bottom - rcWindow.top;
    }

    /* create main window */
    if (directX == DXFULLSCREEN)
	hWnd =
	    CreateWindowEx(WS_EX_TOPMOST, "XaoSWindow", "XaoS", WS_POPUP,
			   0, 0, GetSystemMetrics(SM_CXSCREEN),
			   GetSystemMetrics(SM_CYSCREEN), NULL, NULL,
			   hInstance, NULL);
    else

	hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "XaoSWindow", "XaoS",
			      WS_OVERLAPPEDWINDOW | WS_EX_LEFTSCROLLBAR,
			      xpos, ypos, width, height, NULL, NULL,
			      hInstance, NULL);

    if (!hWnd) {
	x_error("Unable to create app window");
	return 0;
    }

    clipboard_format = RegisterClipboardFormat("image/x-xaos.position");


    /* create font */
    memset(&logFont, 0, sizeof(LOGFONT));
    hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
    logFont.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    logFont.lfWeight = FW_NORMAL;
    logFont.lfPitchAndFamily = FIXED_PITCH;
    strcpy(logFont.lfFaceName, "Courier");

    hFont = CreateFontIndirect(&logFont);
    oldFont = SelectObject(hDC, hFont);
    GetTextMetrics(hDC, &textMetric);
    SelectObject(hDC, oldFont);
    DeleteDC(hDC);

    fontHeight = textMetric.tmHeight;
    fontWidth = textMetric.tmAveCharWidth;

    ShowWindow(hWnd, SW_NORMAL);

    GetClientRect(hWnd, &r);
    displayX = r.right;
    displayY = r.bottom;

    /* create palette */
    CalculateBITMAPINFO();	/* calculate BITMAPINFO structure */
    logPalette = malloc(sizeof(LOGPALETTE) + 4 * 256);
    logPalette->palVersion = 0x300;
    logPalette->palNumEntries = 256;
    memcpy(logPalette->palPalEntry, bmp->bmiColors, 4 * 256);
    hPalette = CreatePalette(logPalette);
    free(logPalette);

    /* select and realize palette */
    hDC = GetDC(hWnd);
    SelectPalette(hDC, hPalette, FALSE);
    RealizePalette(hDC);
    ReleaseDC(hWnd, hDC);

    // increase priority of XaoS
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);

    MyHelpMsg = RegisterWindowMessage(HELPMSGSTRING);

    return 1;
}
Ejemplo n.º 14
0
void Plot1D::setThePlot_error(string fileName, string fileName_ex,
                              int gridSize)
{
  // function for plotting the error
  setWindowTitle("Error PLot");

  QVector<double> x(gridSize), y(gridSize);
  QVector<double> x_ex(gridSize), y_ex(gridSize);
  QVector<double> x_error(gridSize), y_error(gridSize);

  ifstream inFile,inFile_ex;
  double maxX, minX, maxY, minY;
  maxX = 0;
  minX = 0;
  maxY = 0;
  minY = 0;

  inFile.open(fileName.c_str());
  inFile_ex.open(fileName_ex.c_str());
  string firstLine, firstLine_ex;
  getline(inFile, firstLine);
  getline(inFile_ex, firstLine_ex);

  for (int i = 0; i < gridSize; i++)
  {
    inFile >> x[i];
    inFile_ex >> x_ex[i];
    // update the minX
    if (x[i] < minX)
    {
      minX = x[i];
    }

    // update the maxX
    if (x[i] > maxX)
    {
      maxX = x[i];
    }

    inFile >> y[i];
    inFile_ex >> y_ex[i];
    y_error[i] = y[i] - y_ex[i];

    // update the minY
    if (y_error[i] < minY)
    {
      minY = y_error[i];
    }

    // update the maxY
    if (y_error[i] > maxY)
    {
      maxY = y_error[i];
    }
  }

  // create graph and assign data to it:
  ui->customPlot->addGraph();
  ui->customPlot->graph(0)->setData(x, y_error);
  ui->customPlot->graph(0)->setName("Error");

  // define the properties of the plot
  QPen pen;
  pen.setColor(QColor(255, 0, 0, 255));
  ui->customPlot->graph()->setLineStyle(QCPGraph::lsLine);
  ui->customPlot->graph()->setPen(pen);
  // give the axes some labels:
  ui->customPlot->xAxis->setLabel("r");
  ui->customPlot->yAxis->setLabel("Phi");
  // set axes ranges, so we see all data:
  ui->customPlot->xAxis->setRange(minX, maxX);
  ui->customPlot->yAxis->setRange(minY, maxY);
  ui->customPlot->setInteraction(QCP::iRangeDrag, true);
  ui->customPlot->setInteraction(QCP::iRangeZoom, true);
  ui->customPlot->setInteraction(QCP::iSelectPlottables, true);
  ui->customPlot->setInteraction(QCP::iMultiSelect, true);
  ui->customPlot->setInteraction(QCP::iSelectAxes, true);

  ui->customPlot->replot();
}
Ejemplo n.º 15
0
    FUNCTION CODE old_Co_ReadFile (

    	Id 			c,		/* in: existing collection  */
        TEXT			*filespec,	/* in: name of file to read */
	CODE			mode		/* in: mode for the vm objs */
    )
    {
    struct SFILE	f;
    union {
          struct PARHDR	ph;			/* standard header          */	
	  TEXT		padding[300];		/* in case reading new file */
	  } headBuffer;
    CODE		code;
    COUNT		recsize;
    Id			vm;
    TEXT		record [STRINGSIZ+2];
    BOOL		archive;
    TEXT		fullSpec[STRINGSIZ+1];
    struct	FSBLOCK fsblock;		/* to dig out file name     */
    TEXT		errstr[STRINGSIZ+1];
    COUNT		islash;

#ifdef UNIX
    union 
        {
	TEXT record [STRINGSIZ+1];		/* padding for long records */
	struct ar_hdr header;			/* the real archive header  */
	} hdrRecord;
#endif


    code = f_opnspc (&f, 1, filespec, "", "", "res", F_READ);
    if (code != SUCCESS)
	{
        x_error(mode, "Unable to open resource file '%s'.  %s.", "TAE-PFOPN",
	    (uintptr_t)filespec, (uintptr_t)f.errmsg, 0);
        return (FAIL);	
	}

    /*	determine whether file is concatenated or archive format */
    code = f_read (&f, record);
    if (code == SUCCESS  &&  s_equal (record, AR_SENTINEL)) 
	archive = TRUE;
    else
	{
	archive = FALSE;	
	f_rewind (&f);				/* re-start at beginning  */
	}

    /*	read each Vm object from the file */

    while (FOREVER)
	{
	if (archive)					/* skip header 	    */
	    {
#ifdef UNIX
	    code = f_read (&f, (TEXT *)&hdrRecord);	/* read hdr or pad  */
	    if (code == SUCCESS  &&  hdrRecord.record[0] == EOS)
		code = f_read (&f, (TEXT *)&hdrRecord);	/* skip EOF padding */
	    if (code == F_EOF)
	   	{
		code = SUCCESS;
		break;
		}
	    else if (code != SUCCESS)
		{
	        f_close(&f, F_KEEP);
	        x_error (mode, "File '%s' not correctly formatted.",
			 "TAE-RESFORMAT", (uintptr_t)filespec, 0, 0);
	        return (FAIL);
		}
#ifdef AIX
	    s_bcopy (hdrRecord.header._ar_name.ar_name, fullSpec,
                               sizeof(hdrRecord.header._ar_name.ar_name));
#else
	    s_bcopy (hdrRecord.header.ar_name, fullSpec, 
				sizeof(hdrRecord.header.ar_name));
#endif
	    s_strip (fullSpec);		/* remove trailing blanks */
	    islash = s_index (fullSpec, '/');		/*  HP (and others?)  */
	    if (islash >= 0)				/* term with slash    */
		fullSpec[islash] = EOS;			/* clip at slash      */
	    f_crack (fullSpec, "", "", "", &fsblock, errstr);     /* dig name */
#else
	    x_error (mode, "File '%s' not correctly formatted.",
			"TAE-RESFORMAT", filespec, 0, 0);
	    return (FAIL);
#endif
	    }
	code = f_bread (&f, (GENPTR)&headBuffer, sizeof (headBuffer), &recsize);
	if (code == F_EOF)
	    {
	    code = SUCCESS;			/* normal end-of-file	*/
	    break;
	    }
	else if (code == SUCCESS && 
		s_equal (headBuffer.ph.sentinel, "<<new par-file>>"))
	    {
	    f_close(&f, F_KEEP);
	    x_error(mode, "Resource file '%s' has already been converted.", 
		"TAE-VNEWFORMAT", (uintptr_t)filespec, 0, 0);
	    return (FAIL);
	    }
	else if(code != SUCCESS || !s_equal(headBuffer.ph.sentinel, P_SENTINEL))
            {
	    f_close(&f, F_KEEP);
	    x_error(mode, "Error reading resource file '%s'.  %s.", "TAE-PFRD",
		(uintptr_t)filespec, (uintptr_t)f.errmsg, 0);
	    return (FAIL);
            }
	vm = Vm_New (mode);			/* create new vm object   */
	code = Vm_ReadVm ((struct VM_STRUCT *)vm, &f); 		/* read parblk records    */
	if (code != SUCCESS)
	    break;				/* x_error already called */
	if (archive)
	    old_Co_Add ((struct COLLECTION *)c, vm, fsblock.name, C_VM);
	else	
	    old_Co_Add ((struct COLLECTION *)c, vm, headBuffer.ph.filename, C_VM);
	}    
    f_close (&f, F_KEEP);
    return (code);
    }