Exemple #1
0
static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
{
    SIZE windowExt, windowExtAfter, viewportExt;
    POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;

    GetWindowOrgEx(hdc, &windowOrg);
    GetViewportOrgEx(hdc, &viewportOrg);
    GetWindowExtEx(hdc, &windowExt);

    SetViewportExtEx(hdc, cx, cy, NULL);
    GetViewportExtEx(hdc, &viewportExt);
    ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
        "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
        expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);

    GetWindowExtEx(hdc, &windowExtAfter);
    ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
       "Window extension changed from %dx%d to %dx%d\n",
       windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);

    GetWindowOrgEx(hdc, &windowOrgAfter);
    ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
        "Window origin changed from (%d,%d) to (%d,%d)\n",
        windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);

    GetViewportOrgEx(hdc, &viewportOrgAfter);
    ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
        "Viewport origin changed from (%d,%d) to (%d,%d)\n",
        viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
}
Exemple #2
0
void MacPrinterCanvas::start(float scale) {
	static char szMsg[] = "NEURON";
	scale_ = scale;
	if (!get()) {
		return;
	}
	//if (!Escape(hdc, STARTDOC, sizeof szMsg-1, szMsg, NULL)) {
		//DebugMessage("STARTDOC failed\n");
	//	abort();
	//}
	DOCINFO di;
  di.cbSize      = sizeof(DOCINFO);
  di.lpszDocName = "NEURON";
  di.lpszOutput  = NULL;
	
	StartDoc(hdc, &di);
	StartPage(hdc);
//	SetMapMode(hdc, MM_TWIPS);
	int a = GetMapMode(hdc);
	SIZE b; GetViewportExtEx(hdc, &b);
	POINT c; GetViewportOrgEx(hdc, &c);
	XFORM d; GetWorldTransform(hdc, &d);
	if (a < -10) { return; }
	damage_all();
	RECT r;
	//SetRectRgn(&r, 0, 0, hres_/2, vres_/2);
	r.left = 0; r.top=0; r.right = hres_; r.bottom=vres_;
	beginPaint(hdc, r);
	//SelectClipRgn(hdc, NULL);

	//d.eM11 = d.eM22 *= 2.;	
	//SetWorldTransform(hdc, &d);
}
Exemple #3
0
Rect GetViewport(HDC hdc)
{
	Point pt;
	Size sz;
	GetViewportOrgEx(hdc, pt);
	GetViewportExtEx(hdc, sz);
	return Rect(pt, sz);
}
Exemple #4
0
BOOL FAR PASCAL MGetViewportOrg(HDC hdc, INT FAR * px, INT FAR * py)
{
    DWORD dwSize;

    dwSize = GetViewportOrgEx(hdc);
    if (px != NULL) *px = (INT)LOWORD(dwSize);
    if (py != NULL) *py = (INT)HIWORD(dwSize);

    return(TRUE);
}
Exemple #5
0
// DC <- CDIB
void CDIB::ClipDraw(
	HDC dc, int dx, int dy, int dw, int dh, int sx, int sy
) {
	POINT p;
	GetViewportOrgEx(dc, &p);
	SelectClipRgn(dc, Rgn);
	OffsetClipRgn(dc, p.x+dx-sx, p.y+dy-sy);
	StretchBlt(dc, dx, dy, dw, dh, DC, sx, sy, dw, dh, SRCCOPY);
	SelectClipRgn(dc, NULL);
}
Exemple #6
0
BOOL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetViewportOrgEx );
    EMRSETVIEWPORTORGEX emr;
    POINT prev;

    GetViewportOrgEx( dev->hdc, &prev );

    emr.emr.iType = EMR_SETVIEWPORTORGEX;
    emr.emr.nSize = sizeof(emr);
    emr.ptlOrigin.x = prev.x + x;
    emr.ptlOrigin.y = prev.y + y;

    if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
    return next->funcs->pOffsetViewportOrgEx( next, x, y, pt );
}
Exemple #7
0
Fichier : dc.c Projet : dvdhoo/wine
BOOL CDECL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetViewportOrgEx );
    EMRSETVIEWPORTORGEX emr;
    EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;

    GetViewportOrgEx(physDev->hdc, pt);

    emr.emr.iType = EMR_SETVIEWPORTORGEX;
    emr.emr.nSize = sizeof(emr);
    emr.ptlOrigin.x = pt->x + x;
    emr.ptlOrigin.y = pt->y + y;

    if (!EMFDRV_WriteRecord( dev, &emr.emr )) return 0;
    return next->funcs->pOffsetViewportOrgEx( next, x, y, pt );
}
Exemple #8
0
BOOL CGdiAlpha::AlphaBackup(HDC hdc,LPCRECT pRect,ALPHAINFO &alphaInfo)
{
    HBITMAP hBmp=(HBITMAP)GetCurrentObject(hdc,OBJ_BITMAP);
    DUIASSERT(hBmp);
    BITMAP  bm;
    GetObject(hBmp,sizeof(BITMAP),&bm);

    if(bm.bmBitsPixel!=32) return FALSE;
    alphaInfo.rc=*pRect;
    POINT pt;
    GetViewportOrgEx(hdc,&pt);
    RECT rcImg= {0,0,bm.bmWidth,bm.bmHeight};
    OffsetRect(&alphaInfo.rc,pt.x,pt.y);
    IntersectRect(&alphaInfo.rc,&alphaInfo.rc,&rcImg);
    alphaInfo.lpBuf=ALPHABACKUP(&bm,alphaInfo.rc.left,alphaInfo.rc.top,alphaInfo.rc.right - alphaInfo.rc.left, alphaInfo.rc.bottom - alphaInfo.rc.top);
    return TRUE;
}
HDC
gfxWindowsNativeDrawing::BeginNativeDrawing()
{
    if (mRenderState == RENDER_STATE_INIT) {
        nsRefPtr<gfxASurface> surf;
        
        if (mContext->GetCairo()) {
          surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
        }

        if (surf && surf->CairoStatus())
            return nsnull;

        gfxMatrix m = mContext->CurrentMatrix();
        if (!m.HasNonTranslation())
            mTransformType = TRANSLATION_ONLY;
        else if (m.HasNonAxisAlignedTransform())
            mTransformType = COMPLEX;
        else
            mTransformType = AXIS_ALIGNED_SCALE;

        // if this is a native win32 surface, we don't have to
        // redirect rendering to our own HDC; in some cases,
        // we may be able to use the HDC from the surface directly.
        if (surf &&
            ((surf->GetType() == gfxASurface::SurfaceTypeWin32 ||
              surf->GetType() == gfxASurface::SurfaceTypeWin32Printing) &&
              (surf->GetContentType() == gfxASurface::CONTENT_COLOR ||
               (surf->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA &&
               (mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA)))))
        {
            // grab the DC. This can fail if there is a complex clipping path,
            // in which case we'll have to fall back.
            mWinSurface = static_cast<gfxWindowsSurface*>(static_cast<gfxASurface*>(surf.get()));
            mDC = mWinSurface->GetDCWithClip(mContext);

            if (mDC) {
                if (mTransformType == TRANSLATION_ONLY) {
                    mRenderState = RENDER_STATE_NATIVE_DRAWING;

                    mTranslation = m.GetTranslation();
                } else if (((mTransformType == AXIS_ALIGNED_SCALE)
                            && (mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE)) ||
                           (mNativeDrawFlags & CAN_COMPLEX_TRANSFORM))
                {
                    mWorldTransform.eM11 = (FLOAT) m.xx;
                    mWorldTransform.eM12 = (FLOAT) m.yx;
                    mWorldTransform.eM21 = (FLOAT) m.xy;
                    mWorldTransform.eM22 = (FLOAT) m.yy;
                    mWorldTransform.eDx  = (FLOAT) m.x0;
                    mWorldTransform.eDy  = (FLOAT) m.y0;

                    mRenderState = RENDER_STATE_NATIVE_DRAWING;
                }
            }
        }

        // If we couldn't do native drawing, then we have to do two-buffer drawing
        // and do alpha recovery
        if (mRenderState == RENDER_STATE_INIT) {
            mRenderState = RENDER_STATE_ALPHA_RECOVERY_BLACK;

            // We round out our native rect here, that way the snapping will
            // happen correctly.
            mNativeRect.RoundOut();

            // we only do the scale bit if we can do an axis aligned
            // scale; otherwise we scale (if necessary) after
            // rendering with cairo.  Note that if we're doing alpha recovery,
            // we cannot do a full complex transform with win32 (I mean, we could, but
            // it would require more code that's not here.)
            if (mTransformType == TRANSLATION_ONLY || !(mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE)) {
                mScale = gfxSize(1.0, 1.0);

                // Add 1 to the surface size; it's guaranteed to not be incorrect,
                // and it fixes bug 382458
                // There's probably a better fix, but I haven't figured out
                // the root cause of the problem.
                mTempSurfaceSize =
                    gfxIntSize((PRInt32) ceil(mNativeRect.Width() + 1),
                               (PRInt32) ceil(mNativeRect.Height() + 1));
            } else {
                // figure out the scale factors
                mScale = m.ScaleFactors(true);

                mWorldTransform.eM11 = (FLOAT) mScale.width;
                mWorldTransform.eM12 = 0.0f;
                mWorldTransform.eM21 = 0.0f;
                mWorldTransform.eM22 = (FLOAT) mScale.height;
                mWorldTransform.eDx  = 0.0f;
                mWorldTransform.eDy  = 0.0f;

                // See comment above about "+1"
                mTempSurfaceSize =
                    gfxIntSize((PRInt32) ceil(mNativeRect.Width() * mScale.width + 1),
                               (PRInt32) ceil(mNativeRect.Height() * mScale.height + 1));
            }
        }
    }

    if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
        // we can just do native drawing directly to the context's surface

        // do we need to use SetWorldTransform?
        if (mTransformType != TRANSLATION_ONLY) {
            SetGraphicsMode(mDC, GM_ADVANCED);
            GetWorldTransform(mDC, &mOldWorldTransform);
            SetWorldTransform(mDC, &mWorldTransform);
        }
        GetViewportOrgEx(mDC, &mOrigViewportOrigin);
        SetViewportOrgEx(mDC,
                         mOrigViewportOrigin.x + (int)mDeviceOffset.x,
                         mOrigViewportOrigin.y + (int)mDeviceOffset.y,
                         NULL);

        return mDC;
    } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK ||
               mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE)
    {
        // we're going to use mWinSurface to create our temporary surface here

        // get us a RGB24 DIB; DIB is important, because
        // we can later call GetImageSurface on it.
        mWinSurface = new gfxWindowsSurface(mTempSurfaceSize);
        mDC = mWinSurface->GetDC();

        RECT r = { 0, 0, mTempSurfaceSize.width, mTempSurfaceSize.height };
        if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK)
            FillRect(mDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
        else
            FillRect(mDC, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));

        if ((mTransformType != TRANSLATION_ONLY) &&
            (mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE))
        {
            SetGraphicsMode(mDC, GM_ADVANCED);
            SetWorldTransform(mDC, &mWorldTransform);
        }

        return mDC;
    } else {
        NS_ERROR("Bogus render state!");
        return nsnull;
    }
}
Exemple #10
0
static void DoTestEntry(HDC hDC, const TEST_ENTRY *entry)
{
    POINT pt, ptWnd, ptView;
    SIZE siz, sizWnd, sizView;
    INT ret;

    SetMapMode(hDC, entry->nMapMode);

    ret = SetWindowOrgEx(hDC, entry->preset.xWnd, entry->preset.yWnd, NULL);
    ok(ret == TRUE, "Line %d: SetWindowOrgEx failed\n", entry->lineno);

    ret = SetWindowExtEx(hDC, entry->preset.cxWnd, entry->preset.cyWnd, NULL);
    ok(ret == entry->bWndExt, "Line %d: SetWindowExtEx() expected %d, was %d\n", entry->lineno, entry->bWndExt, ret);

    ret = SetViewportOrgEx(hDC, entry->preset.xView, entry->preset.yView, NULL);
    ok(ret == TRUE, "Line %d: SetViewportOrgEx failed\n", entry->lineno);

    ret = SetViewportExtEx(hDC, entry->preset.cxView, entry->preset.cyView, NULL);
    ok(ret == TRUE, "Line %d: SetViewportExtEx failed\n", entry->lineno);

    ok(GetWindowOrgEx(hDC, &pt) == TRUE, "Line %d: GetWindowOrgEx failed\n", entry->lineno);
    ptWnd = pt;
    ok(GetWindowExtEx(hDC, &siz) == TRUE, "Line %d: GetWindowExtEx failed\n", entry->lineno);
    sizWnd = siz;

    ok(pt.x == entry->xWndOut && pt.y == entry->yWndOut,
       "Line %d: Window org expected (%ld, %ld), was (%ld, %ld)\n",
        entry->lineno, entry->xWndOut, entry->yWndOut, pt.x, pt.y);

    if (entry->cxWndOut == DISPLAY_SIZE || entry->cxWndOut == NEGA_DISPLAY_SIZE)
    {
        LONG cx = GetDeviceCaps(hDC, HORZRES);
        LONG cy = GetDeviceCaps(hDC, VERTRES);
        if (entry->cxWndOut == NEGA_DISPLAY_SIZE)
            cx = -cx;
        if (entry->cyWndOut == NEGA_DISPLAY_SIZE)
            cy = -cy;
        ok(siz.cx == cx && siz.cy == cy,
           "Line %d: Window ext expected display size (%ld, %ld), was (%ld, %ld)\n",
            entry->lineno, cx, cy, siz.cx, siz.cy);
    }
    else if (entry->cxWndOut != NO_CHECK)
    {
        ok(siz.cx == entry->cxWndOut && siz.cy == entry->cyWndOut,
           "Line %d: Window ext expected (%ld, %ld), was (%ld, %ld)\n",
            entry->lineno, entry->cxWndOut, entry->cyWndOut, siz.cx, siz.cy);
    }

    ok(GetViewportOrgEx(hDC, &pt) == TRUE, "Line %d: GetViewportOrgEx failed\n", entry->lineno);
    ptView = pt;
    ok(GetViewportExtEx(hDC, &siz) == TRUE, "Line %d: GetViewportExtEx failed\n", entry->lineno);
    sizView = siz;

    ok(pt.x == entry->xViewOut && pt.y == entry->yViewOut,
       "Line %d: Viewport org expected (%ld, %ld), was (%ld, %ld)\n",
        entry->lineno, entry->xViewOut , entry->yViewOut, pt.x, pt.y);

    if (entry->cxViewOut == DISPLAY_SIZE || entry->cxViewOut == NEGA_DISPLAY_SIZE)
    {
        LONG cx = GetDeviceCaps(hDC, HORZRES);
        LONG cy = GetDeviceCaps(hDC, VERTRES);
        if (entry->cxViewOut == NEGA_DISPLAY_SIZE)
            cx = -cx;
        if (entry->cyViewOut == NEGA_DISPLAY_SIZE)
            cy = -cy;
        ok(siz.cx == cx && siz.cy == cy,
           "Line %d: Viewport ext expected display size (%ld, %ld), was (%ld, %ld)\n",
            entry->lineno, cx, cy, siz.cx, siz.cy);
    }
    else if (entry->cxViewOut != NO_CHECK)
    {
        ok(siz.cx == entry->cxViewOut && siz.cy == entry->cyViewOut,
           "Line %d: Viewport ext expected (%ld, %ld), was (%ld, %ld)\n",
            entry->lineno, entry->cxViewOut, entry->cyViewOut, siz.cx, siz.cy);
    }

    pt = entry->ptSrc;

    SetLastError(0xDEADBEEF);
    ret = LPtoDP(hDC, &pt, 1);
    ok(ret == entry->ret, "Line %d: LPtoDP() expected %d, was %d\n", entry->lineno, entry->ret, ret);

    ok(GetLastError() == entry->error, "Line %d: GetLastError() expected %ld, was %ld\n",
       entry->lineno, entry->error, GetLastError());

    if (entry->ptDest.x == CALC_VALUE_1)
    {
        LONG x = MulDiv(entry->ptSrc.x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
        LONG y = MulDiv(entry->ptSrc.y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
        // TODO: make more accurate
        ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
           "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
           entry->lineno, x, y, pt.x, pt.y);
    }
    else if (entry->ptDest.x == CALC_VALUE_2)
    {
        XFORM xform;
        LONG x, y;
        SetXForm1(&xform);
        x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx);
        y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy);
        x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
        y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
        // TODO: make more accurate
        ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
           "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
           entry->lineno, x, y, pt.x, pt.y);
    }
    else if (entry->ptDest.x == CALC_VALUE_3)
    {
        XFORM xform;
        LONG x, y;
        SetXForm2(&xform);
        x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx);
        y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy);
        x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
        y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
        // TODO: make more accurate
        ok(labs(pt.x - x) <= 2 && labs(pt.y - y) <= 2,
           "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
           entry->lineno, x, y, pt.x, pt.y);
    }
    else if (entry->ptDest.x != NO_CHECK)
    {
        ok(pt.x == entry->ptDest.x && pt.y == entry->ptDest.y,
           "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
           entry->lineno, entry->ptDest.x, entry->ptDest.y, pt.x, pt.y);
    }
}
Exemple #11
0
static void test_dc_layout(void)
{
    INT ret, size_cx, size_cy, res_x, res_y, dpi_x, dpi_y;
    SIZE size;
    POINT pt;
    HBITMAP bitmap;
    RECT rc, ret_rc;
    HDC hdc;
    HRGN hrgn;

    if (!pGetLayout || !pSetLayout)
    {
        win_skip( "Don't have SetLayout\n" );
        return;
    }

    hdc = CreateCompatibleDC(0);
    bitmap = CreateCompatibleBitmap( hdc, 100, 100 );
    SelectObject( hdc, bitmap );

    size_cx = GetDeviceCaps(hdc, HORZSIZE);
    size_cy = GetDeviceCaps(hdc, VERTSIZE);
    res_x = GetDeviceCaps(hdc, HORZRES);
    res_y = GetDeviceCaps(hdc, VERTRES);
    dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
    dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);

    ret = GetMapMode( hdc );
    ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
    expect_viewport_ext(hdc, 1, 1);
    expect_window_ext(hdc, 1, 1);
    expect_world_transform(hdc, 1.0, 1.0);
    expect_LPtoDP(hdc, 1000, 1000);

    pSetLayout( hdc, LAYOUT_RTL );
    if (!pGetLayout( hdc ))
    {
        win_skip( "SetLayout not supported\n" );
        DeleteDC(hdc);
        return;
    }

    ret = GetMapMode( hdc );
    ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
    expect_viewport_ext(hdc, 1, 1);
    expect_window_ext(hdc, 1, 1);
    expect_world_transform(hdc, 1.0, 1.0);
    expect_LPtoDP(hdc, -1000 + 99, 1000);
    GetViewportOrgEx( hdc, &pt );
    ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y );
    GetWindowOrgEx( hdc, &pt );
    ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y );
    GetDCOrgEx( hdc, &pt );
    ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y );
    if (pGetTransform)
    {
        XFORM xform;
        BOOL ret = pGetTransform( hdc, 0x204, &xform ); /* World -> Device */
        ok( ret, "got %d\n", ret );
        ok( xform.eM11 == -1.0, "got %f\n", xform.eM11 );
        ok( xform.eM12 == 0.0, "got %f\n", xform.eM12 );
        ok( xform.eM21 == 0.0, "got %f\n", xform.eM21 );
        ok( xform.eM22 == 1.0, "got %f\n", xform.eM22 );
        ok( xform.eDx == 99.0, "got %f\n", xform.eDx );
        ok( xform.eDy == 0.0, "got %f\n", xform.eDy );
    }

    SetRect( &rc, 10, 10, 20, 20 );
    IntersectClipRect( hdc, 10, 10, 20, 20 );
    hrgn = CreateRectRgn( 0, 0, 0, 0 );
    GetClipRgn( hdc, hrgn );
    GetRgnBox( hrgn, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    pSetLayout( hdc, LAYOUT_LTR );
    SetRect( &rc, 80, 10, 90, 20 );
    GetClipRgn( hdc, hrgn );
    GetRgnBox( hrgn, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    GetClipBox( hdc, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    IntersectClipRect( hdc, 80, 10, 85, 20 );
    pSetLayout( hdc, LAYOUT_RTL );
    SetRect( &rc, 15, 10, 20, 20 );
    GetClipRgn( hdc, hrgn );
    GetRgnBox( hrgn, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    GetClipBox( hdc, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    SetRectRgn( hrgn, 60, 10, 80, 20 );
    pSetLayout( hdc, LAYOUT_LTR );
    ExtSelectClipRgn( hdc, hrgn, RGN_OR );
    pSetLayout( hdc, LAYOUT_RTL );
    SetRect( &rc, 15, 10, 40, 20 );
    GetClipRgn( hdc, hrgn );
    GetRgnBox( hrgn, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    GetClipBox( hdc, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );

    /* OffsetClipRgn mirrors too */
    OffsetClipRgn( hdc, 5, 5 );
    OffsetRect( &rc, 5, 5 );
    GetClipRgn( hdc, hrgn );
    GetRgnBox( hrgn, &ret_rc );
    ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );

    /* GetRandomRgn returns the raw region */
    if (pGetRandomRgn)
    {
        SetRect( &rc, 55, 15, 80, 25 );
        pGetRandomRgn( hdc, hrgn, 1 );
        GetRgnBox( hrgn, &ret_rc );
        ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n",
            ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom );
    }

    SetMapMode(hdc, MM_LOMETRIC);
    ret = GetMapMode( hdc );
    ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);

    expect_viewport_ext(hdc, res_x, -res_y);
    ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
    ok( rough_match( size.cx, size_cx * 10 ) ||
        rough_match( size.cx, MulDiv( res_x, 254, dpi_x )),  /* Vista uses a more precise method */
        "expected cx %d or %d, got %d\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
    ok( rough_match( size.cy, size_cy * 10 ) ||
        rough_match( size.cy, MulDiv( res_y, 254, dpi_y )),  /* Vista uses a more precise method */
        "expected cy %d or %d, got %d\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
    expect_world_transform(hdc, 1.0, 1.0);
    expect_LPtoDP(hdc, -MulDiv(1000 / 10, res_x, size_cx) + 99, -MulDiv(1000 / 10, res_y, size_cy));

    SetMapMode(hdc, MM_TEXT);
    ret = GetMapMode( hdc );
    ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
    pSetLayout( hdc, LAYOUT_LTR );
    ret = GetMapMode( hdc );
    ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
    SetMapMode(hdc, MM_TEXT);
    ret = GetMapMode( hdc );
    ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);

    DeleteDC(hdc);
    DeleteObject( bitmap );
}
Exemple #12
0
void KDCAttributes::DumpDC(HDC hDC)
{
	POINT pnt;
	SIZE  size;

	m_List.DeleteAll();

	Add(_T("Technology"),  _T("%d"), GetDeviceCaps(hDC, TECHNOLOGY));
	Add(_T("width"),	   _T("%d"), GetDeviceCaps(hDC, HORZRES));
	Add(_T("height"),	   _T("%d"), GetDeviceCaps(hDC, VERTRES));

	GetDCOrgEx(hDC, & pnt); 
	Add(_T("DC Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	TCHAR szTitle[MAX_PATH];

	szTitle[0] = 0;

	GetWindowText(WindowFromDC(hDC), szTitle, MAX_PATH);
	Add(_T("Window"),    _T("0x%X \"%s\""), WindowFromDC(hDC), szTitle);

	Add(_T("Bitmap"),        _T("0x%X"), GetCurrentObject(hDC, OBJ_BITMAP));

	Add(_T("Graphics Mode"), _T("%d"), GetGraphicsMode(hDC));
	Add(_T("Mapping Mode"),  _T("%d"), GetMapMode(hDC));

	GetViewportExtEx(hDC, & size);
	Add(_T("Viewport Extent"), _T("{ %d, %d }"), size.cx, size.cy);
	
	GetViewportOrgEx(hDC, & pnt);
	Add(_T("Viewport Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	GetWindowExtEx(hDC, & size);
	Add(_T("Window Extent"), _T("{ %d, %d }"), size.cx, size.cy);
	
	GetWindowOrgEx(hDC, & pnt);
	Add(_T("Window Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	XFORM xform;
	GetWorldTransform(hDC, & xform);

	Add(_T("World transformation"), _T("{ %f, %f, %f, %f, %f, %f }"),
		xform.eM11, xform.eM12, xform.eM21, xform.eM22, xform.eDx, xform.eDy);

	// transformation

	Add(_T("Background Color"), _T("0x%X"), GetBkColor(hDC));
	Add(_T("Text Color"),       _T("0x%X"), GetTextColor(hDC));
	Add(_T("Palette"),          _T("0x%X"), GetCurrentObject(hDC, OBJ_PAL));

	{
		COLORADJUSTMENT ca;
		GetColorAdjustment(hDC, & ca);
	
		Add(_T("Color Adjustment"), _T("{ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }"), 
			ca.caSize, ca.caFlags, ca.caIlluminantIndex,
			ca.caRedGamma, ca.caGreenGamma, ca.caBlueGamma, 
			ca.caReferenceBlack, ca.caReferenceWhite,
			ca.caContrast, ca.caBrightness, ca.caColorfulness, ca.caRedGreenTint);
	}

	Add(_T("Color Space"), _T("0x%X"), GetColorSpace(hDC));
	Add(_T("ICM Mode"),    _T("%d"),   SetICMMode(hDC, ICM_QUERY));

	{
		TCHAR szProfile[MAX_PATH];
		DWORD dwSize = MAX_PATH;

		szProfile[0] = 0;
		GetICMProfile(hDC, & dwSize, szProfile);

		Add(_T("ICM Profile"), _T("%s"), szProfile);
	}

	GetCurrentPositionEx(hDC, & pnt);
	Add(_T("Current Position"), _T("{ %d, %d }"), pnt.x, pnt.y);

	Add(_T("ROP2"),				_T("%d"),	GetROP2(hDC));
	Add(_T("Background Mode"),	_T("%d"),	GetBkMode(hDC));
	Add(_T("Logical Pen"),		_T("0x%X"), GetCurrentObject(hDC, OBJ_PEN));
	Add(_T("DC Pen Color"),     _T("0x%X"), GetDCPenColor(hDC));
	Add(_T("Arc Direction"),	_T("%d"),	GetArcDirection(hDC));

	FLOAT miter;
	GetMiterLimit(hDC, & miter);

	Add(_T("Miter Limit"),		_T("%f"),	miter);
	
	Add(_T("Logical Brush"),    _T("0x%X"), GetCurrentObject(hDC, OBJ_BRUSH));
	Add(_T("DC Brush Color"),   _T("0x%X"), GetDCBrushColor(hDC));

	GetBrushOrgEx(hDC, & pnt);
	Add(_T("Brush Origin"),     _T("{ %d, %d }"), pnt.x, pnt.y);

	Add(_T("Polygon Filling Mode"),   _T("%d"), GetPolyFillMode(hDC));
	Add(_T("Bitmap Stretching Mode"), _T("%d"), GetStretchBltMode(hDC));
	Add(_T("Logical Font"),			  _T("0x%X"), GetCurrentObject(hDC, OBJ_FONT));
	Add(_T("Inter-character spacing"), _T("%d"), GetTextCharacterExtra(hDC));

	DWORD flag = SetMapperFlags(hDC, 0);
	SetMapperFlags(hDC, flag);

	Add(_T("Font Mapper Flags"),       _T("0x%X"), flag);

	Add(_T("Text Alignment"),		   _T("0x%X"), GetTextAlign(hDC));

	Add(_T("Text Justification"),      _T("write only"), 0);

	Add(_T("Layout"),                  _T("%d"), GetLayout(hDC));

	Add(_T("Path"),					   _T("%d bytes"), GetPath(hDC, NULL, NULL, 0));

	RECT rect;

	int typ = GetClipBox(hDC, & rect);

	HRGN hRgn = CreateRectRgn(0, 0, 1, 1);
	
	GetClipRgn(hDC, hRgn);

	Add(_T("Clipping"),				   _T("type %d clip box { %d, %d, %d, %d } size %d bytes"), 
		typ, rect.left, rect.top, rect.right, rect.bottom,
		GetRegionData(hRgn, 0, NULL)
		);
	
	GetMetaRgn(hDC, hRgn);

	GetRgnBox(hRgn, & rect);
	Add(_T("Meta Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), 
		GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom);

	for (int i=1; i<=5; i++)
	{
		int rslt = GetRandomRgn(hDC, hRgn, i);

		if ( rslt==1 )
		{
			GetRgnBox(hRgn, & rect);
			Add(_T("Random Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), 
			GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom);
		}
		else if ( rslt==0 )
			Add(_T("Random Region"), _T("NULL"), 0);
		else
			Add(_T("Random Region"), _T("FAIL"), 0);
	}
	DeleteObject(hRgn);

	GetBoundsRect(hDC, & rect, 0);

	Add(_T("Bounds Rectangle"),		_T("{ %d, %d, %d, %d }"), 
		rect.left, rect.top, rect.right, rect.bottom);
}
Exemple #13
0
int CGridContainerNode::ClickContent(MSWindows::HDC hDC, LDraw::PointD point, UINT nFlags, bool bDblClk, CGridItem** pVal)
{
	ASSERT(0);
#if 0
	if (point.x >= 0 && point.y >= 0 && point.x < m_size.cx+2 && point.y < m_size.cy+2)
	{
		if (!bDblClk)
		{
			if (abs(m_size.cx-point.x) <= 2)
			{
				POINT org;
				GetViewportOrgEx(hDC, &org);

				HWND hwnd = m_pUI->m_hWnd;

				m_pUI->SetCapture();

				BOOL bLoop = TRUE;
				MSG msg;
				while (bLoop && GetMessage(&msg, hwnd, 0, 0))
				{
					TranslateMessage(&msg);

					switch (msg.message)
					{
					case WM_LBUTTONUP:
						{
							bLoop = FALSE;
						}
						break;

					case WM_MOUSEMOVE:
						{
							POINT pt;
							pt.x = (short)LOWORD(msg.lParam);
							pt.y = (short)HIWORD(msg.lParam);

							pt.x += org.x;
							pt.y += org.y;

							SizeContent(hDC, pt.x);
							m_pUI->Invalidate();
							m_pUI->OnSize();
						}
						break;

					default:
						DispatchMessage(&msg);
						break;
					}
				}

				ReleaseCapture();

				*pVal = this;
				return 0;
			}
		}
	}

	int y = 0;

// Children
	UPOSITION pos = m_childList.GetHeadPosition();
	while (pos)
	{
		CGridItem* pChild = (CGridItem*)m_childList.GetNext(pos);

		POINT childpoint = point;
		childpoint.y -= y;
		childpoint.x -= 0;

		POINT oldOrg;
		OffsetViewportOrgEx(hDC, 0, y, &oldOrg);

		int nClick = pChild->Click(hDC, childpoint, nFlags, bDblClk, pVal);

		SetViewportOrgEx(hDC, oldOrg.x, oldOrg.y, NULL);

		if (*pVal)
			return nClick;

		y += pChild->m_size.cy;
	}

	*pVal = NULL;
#endif
	return 0;
}
Exemple #14
0
void CLabel::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	DWORD dwFlags = 0;

	CRect rc;
	GetClientRect(rc);
	CString strText;
	GetWindowText(strText);
	CBitmap bmp;


	///////////////////////////////////////////////////////
	//
	// Set up for double buffering...
	//
	CDC* pDCMem;
	CBitmap*	pOldBitmap = NULL;

	if (!m_bTransparent)
	{
		pDCMem = new CDC;
		pDCMem->CreateCompatibleDC(&dc);
		bmp.CreateCompatibleBitmap(&dc,rc.Width(),rc.Height());
		pOldBitmap = pDCMem->SelectObject(&bmp);
	}
	else
	{
		pDCMem = &dc;
	}

	UINT nMode = pDCMem->SetBkMode(TRANSPARENT);


	COLORREF crText = pDCMem->SetTextColor(m_crText);
	CFont *pOldFont = pDCMem->SelectObject(&m_font);


	// Fill in backgound if not transparent
	if (!m_bTransparent)
	{
		if (m_fillmode == Normal)
		{
			CBrush br;
			
			if (m_hBackBrush != NULL)
				br.Attach(m_hBackBrush);
			else
				br.Attach(m_hwndBrush);
					
			pDCMem->FillRect(rc,&br);

			br.Detach();
		}
		else // Gradient Fill
		{
			DrawGradientFill(pDCMem, &rc, m_crLoColor, m_crHiColor, 100);
		}

	}
	

	// If the text is flashing turn the text color on
	// then to the color of the window background.

	LOGBRUSH lb;
	ZeroMemory(&lb,sizeof(lb));

	// Stop Checking complaining
	if (m_hBackBrush)
		::GetObject(m_hBackBrush,sizeof(lb),&lb);


	// Something to do with flashing
	if (!m_bState && m_Type == Text)
		pDCMem->SetTextColor(lb.lbColor);

	DWORD style = GetStyle();
	
	switch (style & SS_TYPEMASK)
	{
		case SS_RIGHT: 
			dwFlags = DT_RIGHT | DT_WORDBREAK; 
			break; 
		
		case SS_CENTER: 
			dwFlags = SS_CENTER | DT_WORDBREAK;
			break;

		case SS_LEFTNOWORDWRAP: 
			dwFlags = DT_LEFT; 
			break;

		default: // treat other types as left
			case SS_LEFT: 
				dwFlags = DT_LEFT | DT_WORDBREAK; 
				break;
	}	

		
	// Added to expand tabs...
	if(strText.Find(_T('\t')) != -1)
		dwFlags |= DT_EXPANDTABS;

	// If the text centered make an assumtion that
	// the will want to center verticly as well
	if (style & SS_CENTERIMAGE)
	{
		dwFlags = DT_CENTER;

		// Apply 
		if (strText.Find(_T("\r\n")) == -1)
		{
			dwFlags |= DT_VCENTER;

			// And because DT_VCENTER only works with single lines
			dwFlags |= DT_SINGLELINE; 
		}

	}

	//
	// 3333   DDDDD
	//     3  D    D
	//   33   D     D    E F X 
	//     3  D    D
	// 3333   DDDDD
	//
	//
	if (m_bRotation)
	{
		int nAlign = pDCMem->SetTextAlign (TA_BASELINE);

		CPoint pt;
		GetViewportOrgEx (pDCMem->m_hDC,&pt) ;
		SetViewportOrgEx (pDCMem->m_hDC,rc.Width() / 2, rc.Height() / 2, NULL) ;
		pDCMem->TextOut (0, 0, strText) ;
		SetViewportOrgEx (pDCMem->m_hDC,pt.x / 2, pt.y / 2, NULL) ;
		pDCMem->SetTextAlign (nAlign);
	}
	else
	{
		pDCMem->DrawText(strText,rc,dwFlags);
		if (m_bFont3d)
		{
			pDCMem->SetTextColor(m_cr3DHiliteColor);

			if (m_3dType == Raised)
				rc.OffsetRect(-1,-1);
			else
				rc.OffsetRect(1,1);

			pDCMem->DrawText(strText,rc,dwFlags);
			m_3dType;

		}
	}

	// Restore DC's State
	pDCMem->SetBkMode(nMode);
	pDCMem->SelectObject(pOldFont);
	pDCMem->SetTextColor(crText);

	if (!m_bTransparent)
	{
		dc.BitBlt(0,0,rc.Width(),rc.Height(),pDCMem,0,0,SRCCOPY);
		// continue DC restore 
		pDCMem->SelectObject ( pOldBitmap ) ;
		delete pDCMem;
	}
}