Exemple #1
0
	void VideoMode::SetWindowResolution(const sf::Vector2i &resolution, bool sameVirtual)
	{
		windowResolution = resolution;

		if (sameVirtual)
			SetVirtualResolution(resolution);
	}
Exemple #2
0
	void VideoMode::SetWindowResolution(int width, int height, bool sameVirtual)
	{
		windowResolution.x = width;
		windowResolution.y = height;

		if (sameVirtual)
			SetVirtualResolution(width, height);
	}
Exemple #3
0
/**********************************************************************
 *	     MFDRV_AllocMetaFile
 */
static DC *MFDRV_AllocMetaFile(void)
{
    DC *dc;
    METAFILEDRV_PDEVICE *physDev;

    if (!(dc = alloc_dc_ptr( &MFDRV_Funcs, OBJ_METADC ))) return NULL;

    physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
    if (!physDev)
    {
        free_dc_ptr( dc );
        return NULL;
    }
    dc->physDev = (PHYSDEV)physDev;
    physDev->hdc = dc->hSelf;

    if (!(physDev->mh = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev->mh) )))
    {
        HeapFree( GetProcessHeap(), 0, physDev );
        free_dc_ptr( dc );
        return NULL;
    }

    physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
    physDev->handles_size = HANDLE_LIST_INC;
    physDev->cur_handles = 0;

    physDev->hFile = 0;

    physDev->mh->mtHeaderSize   = sizeof(METAHEADER) / sizeof(WORD);
    physDev->mh->mtVersion      = 0x0300;
    physDev->mh->mtSize         = physDev->mh->mtHeaderSize;
    physDev->mh->mtNoObjects    = 0;
    physDev->mh->mtMaxRecord    = 0;
    physDev->mh->mtNoParameters = 0;

    SetVirtualResolution(dc->hSelf, 0, 0, 0, 0);

    return dc;
}
Exemple #4
0
/**********************************************************************
 *          CreateEnhMetaFileW   (GDI32.@)
 */
HDC WINAPI CreateEnhMetaFileW(
    HDC           hdc,        /* [in] optional reference DC */
    LPCWSTR       filename,   /* [in] optional filename for disk metafiles */
    const RECT*   rect,       /* [in] optional bounding rectangle */
    LPCWSTR       description /* [in] optional description */
    )
{
    static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
    HDC ret;
    DC *dc;
    EMFDRV_PDEVICE *physDev;
    HANDLE hFile;
    DWORD size = 0, length = 0;

    TRACE("%s\n", debugstr_w(filename) );

    if (!(dc = alloc_dc_ptr( OBJ_ENHMETADC ))) return 0;

    physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
    if (!physDev) {
        free_dc_ptr( dc );
        return 0;
    }
    if(description) { /* App name\0Title\0\0 */
        length = lstrlenW(description);
	length += lstrlenW(description + length + 1);
	length += 3;
	length *= 2;
    }
    size = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4;

    if (!(physDev->emh = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size))) {
        HeapFree( GetProcessHeap(), 0, physDev );
        free_dc_ptr( dc );
        return 0;
    }

    push_dc_driver( &dc->physDev, &physDev->dev, &EMFDRV_Funcs );

    physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
    physDev->handles_size = HANDLE_LIST_INC;
    physDev->cur_handles = 1;
    physDev->hFile = 0;
    physDev->dc_brush = 0;
    physDev->dc_pen = 0;
    physDev->screen_dc = 0;
    physDev->restoring = 0;
    if (hdc)  /* if no ref, use current display */
        physDev->ref_dc = hdc;
    else
        physDev->ref_dc = physDev->screen_dc = CreateDCW( displayW, NULL, NULL, NULL );

    SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0);

    physDev->emh->iType = EMR_HEADER;
    physDev->emh->nSize = size;

    physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
    physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;

    if(rect) {
        physDev->emh->rclFrame.left   = rect->left;
	physDev->emh->rclFrame.top    = rect->top;
	physDev->emh->rclFrame.right  = rect->right;
	physDev->emh->rclFrame.bottom = rect->bottom;
    } else {  /* Set this to {0,0 - -1,-1} and update it at the end */
        physDev->emh->rclFrame.left = physDev->emh->rclFrame.top = 0;
	physDev->emh->rclFrame.right = physDev->emh->rclFrame.bottom = -1;
    }

    physDev->emh->dSignature = ENHMETA_SIGNATURE;
    physDev->emh->nVersion = 0x10000;
    physDev->emh->nBytes = physDev->emh->nSize;
    physDev->emh->nRecords = 1;
    physDev->emh->nHandles = 1;

    physDev->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */
    physDev->emh->nDescription = length / 2;

    physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;

    physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */

    /* Size in pixels */
    physDev->emh->szlDevice.cx = GetDeviceCaps( physDev->ref_dc, HORZRES );
    physDev->emh->szlDevice.cy = GetDeviceCaps( physDev->ref_dc, VERTRES );

    /* Size in millimeters */
    physDev->emh->szlMillimeters.cx = GetDeviceCaps( physDev->ref_dc, HORZSIZE );
    physDev->emh->szlMillimeters.cy = GetDeviceCaps( physDev->ref_dc, VERTSIZE );

    /* Size in micrometers */
    physDev->emh->szlMicrometers.cx = physDev->emh->szlMillimeters.cx * 1000;
    physDev->emh->szlMicrometers.cy = physDev->emh->szlMillimeters.cy * 1000;

    memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);

    if (filename)  /* disk based metafile */
    {
        if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
				 NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
            free_dc_ptr( dc );
            return 0;
        }
        if (!WriteFile( hFile, physDev->emh, size, NULL, NULL )) {
            free_dc_ptr( dc );
            CloseHandle( hFile );
            return 0;
	}
	physDev->hFile = hFile;
    }

    TRACE("returning %p\n", physDev->dev.hdc);
    ret = physDev->dev.hdc;
    release_dc_ptr( dc );

    return ret;
}
Exemple #5
0
/**********************************************************************
 *          CreateEnhMetaFileW   (GDI32.@)
 */
HDC WINAPI CreateEnhMetaFileW(
    HDC           hdc,        /* [in] optional reference DC */
    LPCWSTR       filename,   /* [in] optional filename for disk metafiles */
    const RECT*   rect,       /* [in] optional bounding rectangle */
    LPCWSTR       description /* [in] optional description */
    )
{
    static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
    HDC ret;
    DC *dc;
    HDC hRefDC = hdc ? hdc : CreateDCW(displayW,NULL,NULL,NULL); 
        /* If no ref, use current display */
    EMFDRV_PDEVICE *physDev;
    HANDLE hFile;
    DWORD size = 0, length = 0;

    TRACE("%s\n", debugstr_w(filename) );

    if (!(dc = alloc_dc_ptr( &EMFDRV_Funcs, OBJ_ENHMETADC ))) return 0;

    physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
    if (!physDev) {
        free_dc_ptr( dc );
        return 0;
    }
    dc->physDev = (PHYSDEV)physDev;
    physDev->hdc = dc->hSelf;

    if(description) { /* App name\0Title\0\0 */
        length = lstrlenW(description);
	length += lstrlenW(description + length + 1);
	length += 3;
	length *= 2;
    }
    size = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4;

    if (!(physDev->emh = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size))) {
        HeapFree( GetProcessHeap(), 0, physDev );
        free_dc_ptr( dc );
        return 0;
    }

    physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
    physDev->handles_size = HANDLE_LIST_INC;
    physDev->cur_handles = 1;
    physDev->hFile = 0;

    physDev->horzres = GetDeviceCaps(hRefDC, HORZRES);
    physDev->vertres = GetDeviceCaps(hRefDC, VERTRES);
    physDev->logpixelsx = GetDeviceCaps(hRefDC, LOGPIXELSX);
    physDev->logpixelsy = GetDeviceCaps(hRefDC, LOGPIXELSY);
    physDev->horzsize = GetDeviceCaps(hRefDC, HORZSIZE);
    physDev->vertsize = GetDeviceCaps(hRefDC, VERTSIZE);
    physDev->bitspixel = GetDeviceCaps(hRefDC, BITSPIXEL);
    physDev->textcaps = GetDeviceCaps(hRefDC, TEXTCAPS);
    physDev->rastercaps = GetDeviceCaps(hRefDC, RASTERCAPS);
    physDev->technology = GetDeviceCaps(hRefDC, TECHNOLOGY);
    physDev->planes = GetDeviceCaps(hRefDC, PLANES);
    physDev->numcolors = GetDeviceCaps(hRefDC, NUMCOLORS);
    physDev->restoring = 0;

    SetVirtualResolution(dc->hSelf, 0, 0, 0, 0);

    physDev->emh->iType = EMR_HEADER;
    physDev->emh->nSize = size;

    physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
    physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;

    if(rect) {
        physDev->emh->rclFrame.left   = rect->left;
	physDev->emh->rclFrame.top    = rect->top;
	physDev->emh->rclFrame.right  = rect->right;
	physDev->emh->rclFrame.bottom = rect->bottom;
    } else {  /* Set this to {0,0 - -1,-1} and update it at the end */
        physDev->emh->rclFrame.left = physDev->emh->rclFrame.top = 0;
	physDev->emh->rclFrame.right = physDev->emh->rclFrame.bottom = -1;
    }

    physDev->emh->dSignature = ENHMETA_SIGNATURE;
    physDev->emh->nVersion = 0x10000;
    physDev->emh->nBytes = physDev->emh->nSize;
    physDev->emh->nRecords = 1;
    physDev->emh->nHandles = 1;

    physDev->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */
    physDev->emh->nDescription = length / 2;

    physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;

    physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */

    /* Size in pixels */
    physDev->emh->szlDevice.cx = physDev->horzres;
    physDev->emh->szlDevice.cy = physDev->vertres;

    /* Size in millimeters */
    physDev->emh->szlMillimeters.cx = physDev->horzsize;
    physDev->emh->szlMillimeters.cy = physDev->vertsize;

    /* Size in micrometers */
    physDev->emh->szlMicrometers.cx = physDev->horzsize * 1000;
    physDev->emh->szlMicrometers.cy = physDev->vertsize * 1000;

    memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);

    if (filename)  /* disk based metafile */
    {
        if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
				 NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
            EMFDRV_DeleteDC( dc );
            return 0;
        }
        if (!WriteFile( hFile, physDev->emh, size, NULL, NULL )) {
            EMFDRV_DeleteDC( dc );
            return 0;
	}
	physDev->hFile = hFile;
    }

    TRACE("returning %p\n", dc->hSelf);
    ret = dc->hSelf;
    release_dc_ptr( dc );

    if( !hdc )
      DeleteDC( hRefDC );

    return ret;
}