예제 #1
0
파일: common_windows.c 프로젝트: sjn1978/ui
void paintControlBackground(HWND hwnd, HDC dc)
{
    HWND parent;
    RECT r;
    POINT p, pOrig;

    parent = hwnd;
    for (;;) {
        parent = GetParent(parent);
        if (parent == NULL)
            xpanic("error getting parent control of control in paintControlBackground()", GetLastError());
        // wine sends these messages early, yay...
        if (parent == msgwin)
            return;
        // skip groupboxes; they're (supposed to be) transparent
        if (windowClassOf(parent, L"button", NULL) != 0)
            break;
    }
    if (GetWindowRect(hwnd, &r) == 0)
        xpanic("error getting control's window rect in paintControlBackground()", GetLastError());
    // the above is a window rect; convert to client rect
    p.x = r.left;
    p.y = r.top;
    if (ScreenToClient(parent, &p) == 0)
        xpanic("error getting client origin of control in paintControlBackground()", GetLastError());
    if (SetWindowOrgEx(dc, p.x, p.y, &pOrig) == 0)
        xpanic("error moving window origin in paintControlBackground()", GetLastError());
    SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) dc, PRF_CLIENT);
    if (SetWindowOrgEx(dc, pOrig.x, pOrig.y, NULL) == 0)
        xpanic("error resetting window origin in paintControlBackground()", GetLastError());
}
예제 #2
0
// could use Window event table for this stuff
BOOL Window::WndProc(TMSG &Msg)
{
	// handle internal actions
	switch (Msg.Msg)
	{
		case WM_QUERYENDSESSION:
		case WM_CLOSE:
			if (!CanClose()) return TRUE; //returns 0
			break;
		case WM_DESTROY:  // quit if main window
			if (this==App::MainWindow) App::Quit();
			if (Flags & W_SAVEPOS) SaveWindowState();
			Flags|=W_DESTROYED;
			Destroy();
			// MainWindow is deleted on program exit
			if (this==App::MainWindow) App::Quit();
			else delete this;
			return TRUE;
		case WM_PAINT:
			PAINTSTRUCT  ps;
			BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);
			SetWindowOrgEx(ps.hdc,xPos,yPos,NULL);
			Paint(ps.hdc,ps.fErase,ps.rcPaint);

			if (StatBar) // draw statbar after window
			{
				SetWindowOrgEx(ps.hdc,0,0,NULL); // dont scroll statbar
				StatBar->Paint(ps.hdc);
			}
			EndPaint(hWnd, (LPPAINTSTRUCT) &ps);
			break;

		case WM_HSCROLL:			HScroll(Msg); break;
		case WM_VSCROLL:			VScroll(Msg); break;
		case WM_SIZE:				WMSize(Msg); break;
		case WM_GETMINMAXINFO:	WMGetMinMaxInfo(Msg); break;
		case WM_COMMAND:
		{
			int id=LOWORD(Msg.wParam);
			if (id>MRU_ID && id<=MRU_ID+MRU_MAX)
			{
				OpenFile(MruList[id-MRU_ID-1]);
				return TRUE;
			}
			else if (id>MRU2_ID && id<=MRU2_ID+MRU_MAX)
			{
				OpenFile2(MruList2[id-MRU2_ID-1]);
				return TRUE;
			}
			break;
		}
		case WM_INITMENU:
			InitMenu((HMENU) Msg.wParam); // handle of menu to initialize 
			break;
 	}
	if (StatBar) StatBar->EV_FIND(Msg);
	//allow user to grab any message
	return EV_FIND(Msg);
}
예제 #3
0
void ExecutionLogWindow::PaintContent(HWND hwnd, PAINTSTRUCT* pps)
{
    POINT ptOrgPrev;
    OffsetRect(&pps->rcPaint, 0, m_yOrigin * m_cyLine);
    GetWindowOrgEx(pps->hdc, &ptOrgPrev);
    SetWindowOrgEx(pps->hdc, ptOrgPrev.x, ptOrgPrev.y + m_yOrigin * m_cyLine, NULL);

    PaintSimpleContent(hwnd, pps);

    SetWindowOrgEx(pps->hdc, ptOrgPrev.x, ptOrgPrev.y, NULL);
}
예제 #4
0
BOOL CALLBACK ProgressProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
	switch(message)
	{
		case WM_INITDIALOG:		
			SetCursor(LoadCursor(NULL,IDC_WAIT));
			rcContext.hProgressWnd=hWnd;
			
			SetWindowLong(GetDlgItem(hWnd,IDC_STATIC1),GWL_WNDPROC,(LONG)Static1WndProc); 

			hWndGif= GetDlgItem(hWnd,IDC_STATIC2);
			if (hWndGif)
			{
				m_wndBanner.SubclassWindow(hWndGif);
				if (m_wndBanner.Load(MAKEINTRESOURCE(IDR_BUSY),_T("GIF"))){
					m_wndBanner.Draw();
				}
			};
			SetCursor(LoadCursor(NULL,IDC_ARROW));
			return TRUE;
		case WM_ERASEBKGND:
			{
				RECT bgRect;
				GetWindowRect(hWnd,&bgRect);
				HRGN bgRgn=CreateRectRgnIndirect(&bgRect);
				HWND hIDC1=GetDlgItem(hWnd,IDC_STATIC1);
				RECT idc1Rect;
				GetWindowRect(hIDC1,&idc1Rect);
				HRGN idc1Rgn=CreateRectRgnIndirect(&idc1Rect);
				if (!CombineRgn(bgRgn, bgRgn,idc1Rgn, RGN_XOR)) return FALSE;
				HBRUSH hBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
				POINT pt;
				HDC hdc=(HDC)wParam;
				GetWindowOrgEx(hdc,&pt);
				SetWindowOrgEx(hdc,bgRect.left,bgRect.top,NULL);
				FillRgn(hdc,bgRgn,hBrush);
				SetWindowOrgEx(hdc,pt.x,pt.y,NULL);
				DeleteObject(hBrush);
			}
			return FALSE;
		case WM_CTLCOLORSTATIC:
			SetBkMode((HDC)wParam,TRANSPARENT);
			return (BOOL)GetStockObject(NULL_BRUSH);
		case WM_DESTROY:
			SetCursor(LoadCursor(NULL,IDC_WAIT));
			CloseHandle(rcContext.hThread);
			rcContext.hProgressWnd=0;
			EndDialog(hWnd,0);
			SetCursor(LoadCursor(NULL,IDC_ARROW));
			return TRUE;
		default:
			return FALSE;
	}
}
예제 #5
0
파일: Fl_Gdi.cpp 프로젝트: GustavoMOG/efltk
void Fl_Gdi::place(double x, double y, double w, double h, double tx, double ty, double tw, double th,int align)
{


    double dx, dy;
    double s = tw/w;
    if(s<(th/h)) {
        dx = 0;
        dy = (th - s * h)*iy/144;
    } else {
        s=th/h;
        dy =0;
        dx = (tw - s * w)*ix/144;
    }

    if(align & 3)
        if(align & FL_ALIGN_TOP)
            dy=0;
        else
            dy *=2;
    if(align & 12)
        if(align & FL_ALIGN_LEFT)
            dx=0;
        else
            dx *=2;

    SetViewportOrgEx(gc_, VOx = (int)(ix * (lm_+tx) /72 - ox + dx), VOy = (int)( iy *(tm_+th) /72 - oy + dy),0); //setting origin to the upper left corner inside margins
    SetWindowOrgEx(gc_, WOx = (int)x,  WOy = (int)y,0);
    SetViewportExtEx(gc_,  VEx =(int)(ix*s),  VEy =(int)(iy*s), 0);
    SetWindowExtEx(gc_, WEx = 72, WEy = 72,0);

};
예제 #6
0
//*******************************************************************
// helper to set scaling for print/preview
static void SetScale(HDC dc, int uthei, int utwi, const OUT_PAR * po)
{
	int width, height, mul, div;
	float yfact, xfact;
	long left, right, low, high;
	low = (int) (po->ymin - MARGIN);
	high = (int) (po->ymax + MARGIN);
	left = (int) po->xmin - MARGIN;
	right = (int) po->xmax + MARGIN;

	width = right - left;
	height = high - low;
	//to this point only used dest coords
	yfact = uthei / (float) height;
	xfact = utwi / (float) width;
	SetMapMode(dc, MM_ANISOTROPIC);
	if (fabs(yfact) < fabs(xfact)) {
		div = height;
		mul = uthei;
	} else {
		div = width;
		mul = utwi;
	}

	SetViewportExtEx(dc, mul, -mul, NULL);	// size mult
	SetWindowExtEx(dc, div, div, NULL);	// size divisor
	SetWindowOrgEx(dc, left, high, NULL);	// where was origo
	SetViewportOrgEx(dc, 0, 0, NULL);	// where do i want origo
}
예제 #7
0
LRESULT CAddressBand::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
    POINT                                   pt;
    POINT                                   ptOrig;
    HWND                                    parentWindow;
    LRESULT                                 result;

    if (fGoButtonShown == false)
    {
        bHandled = FALSE;
        return 0;
    }
    pt.x = 0;
    pt.y = 0;
    parentWindow = GetParent();
    ::MapWindowPoints(m_hWnd, parentWindow, &pt, 1);
    OffsetWindowOrgEx(reinterpret_cast<HDC>(wParam), pt.x, pt.y, &ptOrig);
    result = SendMessage(parentWindow, WM_ERASEBKGND, wParam, 0);
    SetWindowOrgEx(reinterpret_cast<HDC>(wParam), ptOrig.x, ptOrig.y, NULL);
    if (result == 0)
    {
        bHandled = FALSE;
        return 0;
    }
    return result;
}
예제 #8
0
파일: Fl_Gdi.cpp 프로젝트: GustavoMOG/efltk
void Fl_Gdi::fit(double x, double y, double w, double h, int align)
{


    double dx, dy;
    double pwp = pw_ - lm_ - rm_;
    double php = ph_ - tm_ - bm_;

    double s = pwp/w;
    if(s<(php/h)) {
        dx = 0;
        dy = (php - s * h)*iy/144;
    } else {
        s=php/h;
        dy =0;
        dx = (pwp - s * w)*ix/144;
    }

    if(align & 3)
        if(align & FL_ALIGN_TOP)
            dy=0;
        else
            dy *=2;
    if(align & 12)
        if(align & FL_ALIGN_LEFT)
            dx=0;
        else
            dx *=2;

    SetViewportOrgEx(gc_, VOx = (int)(ix * lm_ /72 - ox + dx), VOy = (int)( iy *tm_ /72 - oy + dy),0); //setting origin to the upper left corner inside margins
    SetWindowOrgEx(gc_, WOx = (int)x, WOy = (int)y,0);
    SetViewportExtEx(gc_,  VEx =(int) (ix*s),  VEy =(int) (iy*s), 0);
    SetWindowExtEx(gc_, WEx = 72,  WEy = 72,0);
};
예제 #9
0
HDC CMouseTracker::GetDC()
{
	HDC hDC=GetDCEx(m_hWnd, NULL, DCX_PARENTCLIP|DCX_LOCKWINDOWUPDATE);
	POINT pt=GetScrollOffset();
	SetWindowOrgEx(hDC, pt.x, pt.y, NULL);
	return hDC;
}
static GpStatus METAFILE_PlaybackGetDC(GpMetafile *metafile)
{
    GpStatus stat = Ok;

    stat = GdipGetDC(metafile->playback_graphics, &metafile->playback_dc);

    if (stat == Ok)
    {
        /* The result of GdipGetDC always expects device co-ordinates, but the
         * device co-ordinates of the source metafile do not correspond to
         * device co-ordinates of the destination. Therefore, we set up the DC
         * so that the metafile's bounds map to the destination points where we
         * are drawing this metafile. */
        SetMapMode(metafile->playback_dc, MM_ANISOTROPIC);

        SetWindowOrgEx(metafile->playback_dc, metafile->bounds.X, metafile->bounds.Y, NULL);
        SetWindowExtEx(metafile->playback_dc, metafile->bounds.Width, metafile->bounds.Height, NULL);

        SetViewportOrgEx(metafile->playback_dc, metafile->playback_points[0].X, metafile->playback_points[0].Y, NULL);
        SetViewportExtEx(metafile->playback_dc,
            metafile->playback_points[1].X - metafile->playback_points[0].X,
            metafile->playback_points[2].Y - metafile->playback_points[0].Y, NULL);
    }

    return stat;
}
예제 #11
0
파일: mapping.c 프로젝트: NVIDIA/winex_lgpl
/***********************************************************************
 *           SetWindowOrgEx    (GDI.482)
 */
BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
{
    POINT pt32;
    BOOL16 ret = SetWindowOrgEx( hdc, x, y, &pt32 );
    if (pt) CONV_POINT32TO16( &pt32, pt );
    return ret;
}
예제 #12
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HMETAFILE hmf ;
     static int       cxClient, cyClient ;
     HBRUSH           hBrush ;
     HDC              hdc, hdcMeta ;
     int              x, y ;
     PAINTSTRUCT      ps ;
     
     switch (message)
     {
     case WM_CREATE:
          hdcMeta = CreateMetaFile (NULL) ;
          hBrush  = CreateSolidBrush (RGB (0, 0, 255)) ;
          
          Rectangle (hdcMeta, 0, 0, 100, 100) ;
          
          MoveToEx (hdcMeta,   0,   0, NULL) ;
          LineTo   (hdcMeta, 100, 100) ;
          MoveToEx (hdcMeta,   0, 100, NULL) ;
          LineTo   (hdcMeta, 100,   0) ;
          
          SelectObject (hdcMeta, hBrush) ;
          Ellipse (hdcMeta, 20, 20, 80, 80) ;
          
          hmf = CloseMetaFile (hdcMeta) ;
          
          DeleteObject (hBrush) ;
          return 0 ;
          
     case WM_SIZE:
          cxClient = LOWORD (lParam) ;
          cyClient = HIWORD (lParam) ;
          return 0 ;
          
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          
          SetMapMode (hdc, MM_ANISOTROPIC) ;
          SetWindowExtEx (hdc, 1000, 1000, NULL) ;
          SetViewportExtEx (hdc, cxClient, cyClient, NULL) ;
          
          for (x = 0 ; x < 10 ; x++)
          for (y = 0 ; y < 10 ; y++)
          {
               SetWindowOrgEx (hdc, -100 * x, -100 * y, NULL) ;
               PlayMetaFile (hdc, hmf) ;
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;
               
     case WM_DESTROY:
          DeleteMetaFile (hmf) ;
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
HDC TextViewMetrics::ClientToText( HDC hdc, POINT* oldOrigin ) const
{
	POINT clientOrigin = { 0, 0 };
	clientOrigin = ClientToText( clientOrigin );

	GetWindowOrgEx( hdc, oldOrigin );
	SetWindowOrgEx( hdc, oldOrigin->x + clientOrigin.x, oldOrigin->y + clientOrigin.y, oldOrigin );
	return hdc;
}
예제 #14
0
void uCheckBox::OnPaint() 
{
	CDC MemDC, TmpDC;
	CRect rect;
	CBitmap *pMemOldBitmap, *pTmpOld, bm, *pSrcBitmap;

	RECT DstRect;
	POINT pt = {0, 0};

	CPaintDC dc(this); // device context for painting

	// Draw

	// Get Size of Display area
    GetClientRect(rect);

    // Create memory DCs
    if (!TmpDC.CreateCompatibleDC(&dc)) return;
	MemDC.CreateCompatibleDC(&dc);
	bm.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
	pMemOldBitmap = (CBitmap*) MemDC.SelectObject(&bm);

	CopyRect(&DstRect, &Size);

	// Draw Transparency
		MapWindowPoints(pParentWindow, &pt, 1);
		OffsetWindowOrgEx(MemDC.m_hDC, pt.x, pt.y, &pt);
		::SendMessage(pParentWindow->m_hWnd, WM_ERASEBKGND, (WPARAM) MemDC.m_hDC, 0);
		SetWindowOrgEx(MemDC.m_hDC, pt.x, pt.y, NULL);

	// Draw Lamp
	CopyRect(&DstRect, &LmpRect);
	pSrcBitmap = (State & UC_STATE_CHECKED) ? &bmpOn : &bmpOff;
	pTmpOld = (CBitmap*) TmpDC.SelectObject(pSrcBitmap);
	MemDC.BitBlt(EXPANDRECTWH(DstRect), &TmpDC, 0, 0, SRCCOPY);
	
/*
	char Caption[MAX_LABEL_STRING];
	int tcount = GetWindowText(Caption, MAX_LABEL_STRING);
	if (tcount) 
	{
		// Draw Text
		MemDC.SelectObject(uCore->GetFont((Style & ULS_FONTMASK) >> ULS_FONTSHIFT));
		MemDC.SetBkMode(TRANSPARENT);
		MemDC.SetTextColor(CaptionColor);
		MemDC.DrawText(Caption, tcount, &DstRect, Style & ULS_TEXT_MASK);
	}
*/

	dc.BitBlt(/*EXPANDRECTWH(DstRect)*/ 0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, SRCCOPY);
	
	TmpDC.SelectObject(pTmpOld);
	MemDC.SelectObject(pMemOldBitmap);

	// Do not call CWnd::OnPaint() for painting messages
}
예제 #15
0
//
//	function for drawing the custom-draw inserted buttons
//	Called from the WM_NOTIFY handler (HandleCustomDraw)
//
UINT CALLBACK CoolSB_DrawProc(HDC hdc, UINT uCmdId, UINT uButflags, RECT *rect)
{
	RECT rc;
	POINT pt;
	HPEN hpen, hold;

	HBITMAP hbm, oldbm;
	HDC hdcmem;

	if(hemf == 0)
		InitMetaFile();

	SetRect(&rc, 0, 0, 120, rect->bottom-rect->top);

	hdcmem = CreateCompatibleDC(hdc);
	hbm = CreateCompatibleBitmap(hdc, rc.right, rc.bottom);
	oldbm = SelectObject(hdcmem, hbm);

	SetWindowOrgEx(hdc, -rect->left, -rect->top, &pt);
	PlayEnhMetaFile(hdcmem, hemf, &rc);
	BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcmem, 0, 0, SRCCOPY);
	
	SetRect(&rc, 120, 0, rect->right-rect->left, rect->bottom-rect->top);
	FillRect(hdc, &rc, GetSysColorBrush(COLOR_3DFACE));
	
	hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW));
	hold = SelectObject(hdc, hpen);
	MoveToEx(hdc, 120, 0, 0);
	LineTo(hdc, rect->right-rect->left, 0);
	
	SetWindowOrgEx(hdc, pt.x, pt.y, 0);		

	
	SelectObject(hdc, hold);
	SelectObject(hdcmem, oldbm);
	DeleteObject(hbm);
	DeleteDC(hdcmem);
	DeleteObject(hpen);
	
	UNREFERENCED_PARAMETER(uButflags);
	UNREFERENCED_PARAMETER(uCmdId);
	return 0;
}
예제 #16
0
void track_bar_impl::draw_background (HDC dc, const RECT * rc) const
{
    HWND wnd_parent = GetParent(get_wnd());
    POINT pt = {0, 0}, pt_old = {0,0};
    MapWindowPoints(get_wnd(), wnd_parent, &pt, 1);
    OffsetWindowOrgEx(dc, pt.x, pt.y, &pt_old);
    if (SendMessage(wnd_parent, WM_ERASEBKGND,(WPARAM)dc, 0) == FALSE)
        SendMessage(wnd_parent, WM_PRINTCLIENT,(WPARAM)dc, PRF_ERASEBKGND);
    SetWindowOrgEx(dc, pt_old.x, pt_old.y, 0);
}
예제 #17
0
HFONT CRetrySplashScreen::CreateDialogFont (HDC hdc, TCHAR *szFaceName, int ptSize, DWORD dwWeight, BOOL bUnderline)
{
    
    POINT pt;
    FLOAT cxDPI, cyDPI;
    HFONT hFont;
    LOGFONT lf;
    
    int iDeciPtWidth = 0;
    int iDeciPtHeight = 10 * ptSize;
    int iSavedDC = SaveDC(hdc);
    
    SetGraphicsMode (hdc, GM_ADVANCED);
    ModifyWorldTransform(hdc, NULL, MWT_IDENTITY);
    SetViewportOrgEx (hdc, 0,0, NULL);
    SetWindowOrgEx (hdc, 0,0, NULL);
    
    cxDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX);
    cyDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY);
    
    pt.x = (int) (iDeciPtWidth * cxDPI / 72);
    pt.y = (int) (iDeciPtHeight * cyDPI / 72);
    
    DPtoLP(hdc, &pt, 1);
    lf.lfHeight = - (int) (fabs ((double) pt.y) / 10.0 + 0.5);
    lf.lfWidth = 0;
    lf.lfEscapement = 0;
    lf.lfOrientation = 0;
    lf.lfWeight = dwWeight;
    lf.lfItalic = 0;
    lf.lfUnderline = (bUnderline ? 1 : 0);
    lf.lfStrikeOut = 0;
    lf.lfCharSet = 0;
    lf.lfOutPrecision = 0;
    lf.lfClipPrecision = 0;
    lf.lfQuality = 0;
    lf.lfPitchAndFamily = 0;
    
    TCHAR szLocaleData[BUFFER_SIZE];
    int iRet = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGCOUNTRY, szLocaleData, BUFFER_SIZE);

    if (strncmp(szLocaleData, "Japan", 5) != 0){
	strcpy (lf.lfFaceName, szFaceName);
    } else {
	strcpy (lf.lfFaceName, TEXT("MS UI Gothic"));
    }

    hFont = CreateFontIndirect(&lf);
    RestoreDC (hdc, iSavedDC);

    return hFont;

}
예제 #18
0
void MCWidgetContextBeginOffscreen(MCContext *p_context, void*& r_dc)
{
	RECT t_rect;
	t_rect . left = 0;
	t_rect . top = 0;
	t_rect . right = (p_context -> getclip() . width * 2540 + 95) / 96;
	t_rect . bottom = (p_context -> getclip() . height * 2540 + 95) / 96;

	HDC t_metafile_dc;
	t_metafile_dc = CreateEnhMetaFileA(NULL, NULL, &t_rect, NULL);

	SetWindowOrgEx(t_metafile_dc, p_context -> getclip() . x, p_context -> getclip() . y, NULL);

	r_dc = t_metafile_dc;
}
예제 #19
0
파일: pager.c 프로젝트: howard5888/wineT
static LRESULT
PAGER_EraseBackground (PAGER_INFO* infoPtr, HDC hdc)
{
    POINT pt, ptorig;
    HWND parent;

    pt.x = 0;
    pt.y = 0;
    parent = GetParent(infoPtr->hwndSelf);
    MapWindowPoints(infoPtr->hwndSelf, parent, &pt, 1);
    OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
    SendMessageW (parent, WM_ERASEBKGND, (WPARAM)hdc, 0);
    SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);

    return 0;
}
예제 #20
0
void AtlMapZoom(ATL_DRAWINFO& di)
{
	// Quit if not zoomed
	if (!di.bZoomed)
		return;

	RECT& rc = *(RECT*)di.prcBounds;
	
	// Setup mapping mode...
	SetMapMode(di.hdcDraw, MM_ANISOTROPIC);
	SetViewportExtEx(di.hdcDraw, di.ZoomNum.cx, di.ZoomNum.cy, NULL);
	SetWindowExtEx(di.hdcDraw, di.ZoomDen.cx, di.ZoomDen.cy, NULL);
	SetWindowOrgEx(di.hdcDraw, rc.left, rc.top, NULL);
	SetViewportOrgEx(di.hdcDraw, rc.left, rc.top, NULL);

	// Scale bounds...
	rc.right=rc.left + (rc.right-rc.left) * di.ZoomDen.cx / di.ZoomNum.cx;
	rc.bottom=rc.top + (rc.bottom-rc.top) * di.ZoomDen.cy / di.ZoomNum.cy;
}
예제 #21
0
LRESULT WINAPI container_window::window_proc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{
	container_window * p_this;
	
	if(msg == WM_NCCREATE)
	{
		LPVOID * create_params = reinterpret_cast<LPVOID *>(((CREATESTRUCT *)(lp))->lpCreateParams);
		p_this = reinterpret_cast<container_window *>(create_params[0]); //retrieve pointer to class
		SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)p_this);//store it for future use
		if (p_this) p_this->wnd_host = wnd;
		
	}
	else
		p_this = reinterpret_cast<container_window*>(GetWindowLongPtr(wnd,GWLP_USERDATA));//if isnt wm_create, retrieve pointer to class
	
	if (p_this && p_this->get_class_data().want_transparent_background)
	{
		if (msg == WM_ERASEBKGND)
		{
			HDC dc = (HDC)wp;
			
			if (dc)
			{
				HWND wnd_parent = GetParent(wnd);
				POINT pt = {0, 0}, pt_old = {0,0};
				MapWindowPoints(wnd, wnd_parent, &pt, 1);
				OffsetWindowOrgEx(dc, pt.x, pt.y, &pt_old);
				SendMessage(wnd_parent, WM_ERASEBKGND,wp, 0);
				SetWindowOrgEx(dc, pt_old.x, pt_old.y, 0);
			}
			return TRUE;
		}
		else if (msg==WM_WINDOWPOSCHANGING && p_this)
		{
			HWND meh_lazy = GetWindow(wnd, GW_CHILD);
			RedrawWindow(meh_lazy, 0, 0, RDW_ERASE);
		}
	}
	
	return p_this ? p_this->on_message(wnd, msg, wp, lp) : DefWindowProc(wnd, msg, wp, lp);
}
예제 #22
0
파일: Fl_Gdi.cpp 프로젝트: GustavoMOG/efltk
void Fl_Gdi::set_page(int page)
{
    DEVMODE * mode = (DEVMODE *) GlobalLock(mode_);
    if(page) {
        ResetDC(gc_,mode);
        SetMapMode(gc_, MM_ANISOTROPIC);
        SetTextAlign(gc_, TA_BASELINE|TA_LEFT);
        SetBkMode(gc_, TRANSPARENT);
        StartPage(gc_);
        ix = GetDeviceCaps(gc_, LOGPIXELSX);
        iy = GetDeviceCaps(gc_, LOGPIXELSY);
        ox = GetDeviceCaps(gc_, PHYSICALOFFSETX);
        oy = GetDeviceCaps(gc_, PHYSICALOFFSETY);
    }
    GlobalUnlock(mode_);

    SetViewportOrgEx(gc_,VOx = (int)(ix * lm_ /72 - ox), VOy =(int)( iy *tm_ /72 - oy),0); //setting origin to the upper left corner inside margins
    SetViewportExtEx(gc_, VEx = (int)(ix * pw_ / 72),  (int)(VEy = iy * ph_ / 72),0);
    SetWindowExtEx(gc_, WEx = (int) pw_,  WEy = (int)ph_,0); //72 pixels per inch mapping
    SetWindowOrgEx(gc_, WOx = 0, WOy = 0,0);
}
예제 #23
0
static HDC getBitmapDC(void *imageData) {
    HDC hdc;
    HANDLE  *mutex = (HANDLE*) TlsGetValue(tlsId);

    if(mutex == NULL) {
        mutex = (HANDLE*)malloc(sizeof(HANDLE));
        if(mutex == NULL) {
            return NULL;
        }
        TlsSetValue(tlsId, mutex);
        *mutex = CreateMutex(0, JAVACALL_FALSE, "hPhoneBitmapMutex");
    }

    if(lastImage != imageData) {
        if(hMemDC != NULL) {
            DeleteDC(hMemDC);
        }

        hdc = GetDC(hMainWindow);
        hMemDC = CreateCompatibleDC(hdc);
        ReleaseDC(hMainWindow, hdc);
        lastImage = imageData;
    }

    WaitForSingleObject(*mutex, INFINITE);

    if(imageData == NULL) {
        CHECK_RETURN(getBitmapDCtmp = SelectObject(hMemDC, hPhoneBitmap));
        SetWindowOrgEx(hMemDC, -x_offset, -(Y_SCREEN_OFFSET), NULL);
    } else if(imageData == UNTRANSLATED_SCREEN_BITMAP) {
        CHECK_RETURN(getBitmapDCtmp = SelectObject(hMemDC, hPhoneBitmap));
    } else {
        myBitmapStruct *bmp = (myBitmapStruct *)imageData;
        if(bmp->mutable) {
            getBitmapDCtmp = SelectObject(hMemDC, bmp->bitmap);
        }
    }

    return hMemDC;
}
예제 #24
0
파일: Fl_Gdi.cpp 프로젝트: GustavoMOG/efltk
void Fl_Gdi::place(double x, double y, double w, double h, double tx, double ty, double tw, double th, double dpi, int align)
{
    double s = 72/dpi;
    double dy = (th - s * h)*iy/144;
    double dx = (tw - s * w)*ix/144;

    if(align & 3)
        if(align & FL_ALIGN_TOP)
            dy=0;
        else
            dy *=2;
    if(align & 12)
        if(align & FL_ALIGN_LEFT)
            dx=0;
        else
            dx *=2;

    SetViewportOrgEx(gc_, VOx = (int)(ix * (lm_+tx) /72 - ox + dx), VOy = (int)( iy *(tm_+ty) /72 - oy + dy),0);
    SetWindowOrgEx(gc_, WOx = (int)x,  WOy = (int)y,0);
    SetViewportExtEx(gc_,  VEx = (int)(ix*s),  VEy = (int)(iy*s), 0);
    SetWindowExtEx(gc_, WEx = 72,  WEy = 72,0);
};
예제 #25
0
///////////////////////////////////////////////////////////////////////////////
// Descripcion:
// - Crea la fuente true type, pero NO la selecciona. 
// Parametros:
// - hdc. DC a la superficie sobre la que se va a crear la fuente.
// - swDeciPt. Tamaño de la fuentes en puntos por 10. Si nuestra fuente va a
//   tener un tamaño de 16, debera de valer 16x10 = 160.
// Devuelve:
// Notas:
///////////////////////////////////////////////////////////////////////////////
void 
CFont::CreateTTFont(const HDC& hdc, const sword& swDeciPt)
{
  // SOLO si los parametros son validos
  ASSERT(hdc);
  ASSERT(swDeciPt);

  // Configura el DC recibido  
  SetGraphicsMode(hdc, GM_ADVANCED);
  ModifyWorldTransform(hdc, NULL, MWT_IDENTITY);
  SetViewportOrgEx(hdc, 0, 0, NULL);
  SetWindowOrgEx(hdc, 0, 0, NULL);

  // Se establece la res. logica
  float cxDpi = (float) GetDeviceCaps(hdc, LOGPIXELSX);
  float cyDpi = (float) GetDeviceCaps(hdc, LOGPIXELSY);

  // Define ptos. por pulgada
  POINT pt;
  pt.x = 0;
  pt.y = (sword) (swDeciPt * cyDpi / 72);
  DPtoLP(hdc, &pt, 1);

  // Configura y crea la fuente
  LOGFONT lf;
  memset(&lf, 0, sizeof(lf));
  lf.lfHeight = -(sword) (fabs(pt.y) / 10.0 + 0.5);
  strcpy(lf.lfFaceName, m_FontInfo.szName.c_str());
  m_FontInfo.hFont = CreateFontIndirect(&lf);
  lf.lfQuality = ANTIALIASED_QUALITY;

  // Se obtiene datos sobre metrica y anchura
  m_FontInfo.hPrevFont = (HFONT) SelectObject(hdc, m_FontInfo.hFont);
  GetTextMetrics(hdc, &m_FontInfo.tm);
  GetCharABCWidths(hdc, 32, 255, m_FontInfo.abc);

  // Restaura el estado del hdc anterior  
}
예제 #26
0
파일: drawdialoggl.c 프로젝트: doolin/ntdda
/* Also sets radius variable used to draw points.
 */
static void
handleInit(HWND hDlg)
{
   RECT winSize;
	 	RECT drawSize;
		 int orig_x,orig_y,ext_x,ext_y;
	 	//char mess [240]; /*used for debugging message text*/
   //hdc = GetDC(hDlg);


   jointlist = make_dl();
   pointlist = make_dl();


			GetWindowRect(hDlg, &winSize);
			GetWindowRect(GetDlgItem(hDlg,IDC_DRAWSPACE), &drawSize);
			hdc = GetDC(GetDlgItem(hDlg,IDC_DRAWSPACE)); /*get device context of the draw area*/

			SetClassLong(GetDlgItem(hDlg,IDC_DRAWSPACE), GCL_HCURSOR, (long)LoadCursor(NULL,"IDC_CROSS "));

			hCurrentPen = drawPen[1];  // black
			
			SetMapMode(hdc, MM_ISOTROPIC);
						
  /*
			sprintf(mess, "Dialog top is %d bottom is %d\nDraw top is %d bottom is %d.\n\nClick to continue.", 
									winSize.top,winSize.bottom,drawSize.top,drawSize.bottom);
			MessageBox( hDlg, mess, "Geometry: Window Size", MB_ICONINFORMATION );
		 */
	
			orig_x= drawSize.left-winSize.left;
			orig_y= drawSize.top-winSize.top;
			ext_x=drawSize.right-drawSize.left;
			ext_y=drawSize.bottom-drawSize.top;

			
			SetWindowOrgEx(hdc,orig_x,orig_y, NULL);
			SetWindowExtEx(hdc,ext_x,ext_y,NULL);

			// want square area to draw in

			maxSize = ext_x-orig_x; /*> ury-lly ? urx : ury;*/
			if (ury-lly>maxSize) 
      maxSize=ext_y-orig_y; 


			SetViewportOrgEx(hdc,orig_x,ext_y-orig_y-1, NULL); /*device units*/
			SetViewportExtEx(hdc, maxSize, -maxSize, NULL); /*device units*/
  /*
			sprintf(mess, "Viewport origin x is %d y is %d\nExtent x is %d y is %d.\n\nClick to continue.", 
									orig_x,ext_y-orig_y-1,maxSize,-maxSize);
			MessageBox( hDlg, mess, "Geometry: Window Size", MB_ICONINFORMATION );
			*/
//			EnableOpenGL (hDlg, &hdc, &hRC1);
//			hRC1 = wglCreateContext( hdc );
//			wglMakeCurrent( hdc, hRC1 );
//			glViewport (drawSize.left,drawSize.top,urx,ury);
//			glViewport (0,0,urx, ury);
//			glMatrixMode (GL_PROJECTION);
//			glLoadIdentity();
//			gluOrtho2D(0.0,1.0,1.0,0.0);
//			glutMouseFunc(Mouse);
			
			   
			radius = (int) ((urx-llx)/20);
			SetDlgItemInt(hDlg,IDC_MINX,llx,TRUE);
			SetDlgItemInt(hDlg,IDC_MINY,lly,TRUE);
			SetDlgItemInt(hDlg,IDC_MAXX,urx,TRUE);
			SetDlgItemInt(hDlg,IDC_MAXY,ury,TRUE);
			SetDlgItemInt(hDlg,IDC_GRID,gridSp,TRUE);
			ScaleX=Scale(urx,llx);
			ScaleY=Scale(ury,lly);
			CheckRadioButton(hDlg, DD_J1, DD_HP, DD_J1);
			CheckRadioButton(hDlg, DD_GRON, DD_GROFF, DD_GROFF);
 
			if(jp) 
				free(jp);
			if(pp) 
				free(pp);

			jp = (Joint *) malloc(sizeof(Joint) * estNumJts);
			pp = (DPoint *) malloc(sizeof(DPoint) * estNumPts);

			nLines=0; nPoints=0; nfp=0; nmp=0; nlp=0; nhp=0;
			tool=0; type=1; inside = TRUE;

//   if (grid == TRUE)
//      SendMessage(hDlg, WM_COMMAND, DD_GRON, 0L);

			//ReleaseDC(hDlg, hdc);

}  /* close handleInit() */
예제 #27
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam)
{

	static BOOL           f24Hour, fSuppress ;

	static HBRUSH         hBrushRed ;

	static int            cxClient, cyClient ;

	HDC                   hdc ;

	PAINTSTRUCT   ps ;

	TCHAR                 szBuffer [2] ;


	switch (message)
	{

	case   WM_CREATE:

		hBrushRed = CreateSolidBrush (RGB (255, 0, 0)) ;

		SetTimer (hwnd, ID_TIMER, 1000, NULL) ;// fall through


	case   WM_SETTINGCHANGE:

		GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME, szBuffer, 2) ;
		f24Hour = (szBuffer[0] == '1') ;

		GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITLZERO, szBuffer, 2) ;
		fSuppress = (szBuffer[0] == '0') ;

		InvalidateRect (hwnd, NULL, TRUE) ;
		return 0 ;


	case   WM_SIZE:

		cxClient = LOWORD (lParam) ;

		cyClient = HIWORD (lParam) ;

		return 0 ;


	case   WM_TIMER:

		InvalidateRect (hwnd, NULL, TRUE) ;

		return 0 ;


	case   WM_PAINT:

		hdc = BeginPaint (hwnd, &ps) ;

		SetMapMode (hdc, MM_ISOTROPIC) ;

		SetWindowExtEx (hdc, 276, 72, NULL) ;
		SetViewportExtEx (hdc, cxClient, cyClient, NULL) ;


		SetWindowOrgEx (hdc, 138, 36, NULL) ;
		SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;

		SelectObject (hdc, GetStockObject (NULL_PEN)) ;
		SelectObject (hdc, hBrushRed) ;


		DisplayTime (hdc, f24Hour, fSuppress) ;


		EndPaint (hwnd, &ps) ;

		return 0 ;


	case   WM_DESTROY:

		KillTimer (hwnd, ID_TIMER) ;

		DeleteObject (hBrushRed) ;

		PostQuitMessage (0) ;

		return 0 ;

	}

	return DefWindowProc (hwnd, message, wParam, lParam) ;

}
예제 #28
0
파일: LPtoDP.c 프로젝트: Moteesh/reactos
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);
    }
}
예제 #29
0
파일: buffer.c 프로젝트: AndreRH/wine
/***********************************************************************
 *      BeginBufferedPaint                                 (UXTHEME.@)
 */
HPAINTBUFFER WINAPI BeginBufferedPaint(HDC targetdc, const RECT *rect,
        BP_BUFFERFORMAT format, BP_PAINTPARAMS *params, HDC *retdc)
{
    char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
    BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
    struct paintbuffer *buffer;

    TRACE("(%p %s %d %p %p)\n", targetdc, wine_dbgstr_rect(rect), format,
          params, retdc);

    if (retdc)
        *retdc = NULL;

    if (!targetdc || IsRectEmpty(rect))
        return NULL;

    if (params)
        FIXME("painting parameters are ignored\n");

    buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer));
    buffer->targetdc = targetdc;
    buffer->rect = *rect;
    buffer->memorydc = CreateCompatibleDC(targetdc);

    switch (format)
    {
    case BPBF_COMPATIBLEBITMAP:
        buffer->bitmap = CreateCompatibleBitmap(targetdc, rect->right - rect->left, rect->bottom - rect->top);
        buffer->bits = NULL;
        break;
    case BPBF_DIB:
    case BPBF_TOPDOWNDIB:
    case BPBF_TOPDOWNMONODIB:
        /* create DIB section */
        memset(bmi, 0, sizeof(bmibuf));
        bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
        bmi->bmiHeader.biHeight = format == BPBF_DIB ? rect->bottom - rect->top :
                -(rect->bottom - rect->top);
        bmi->bmiHeader.biWidth = rect->right - rect->left;
        bmi->bmiHeader.biBitCount = format == BPBF_TOPDOWNMONODIB ? 1 : 32;
        bmi->bmiHeader.biPlanes = 1;
        bmi->bmiHeader.biCompression = BI_RGB;
        buffer->bitmap = CreateDIBSection(buffer->memorydc, bmi, DIB_RGB_COLORS, &buffer->bits, NULL, 0);
        break;
    default:
        WARN("Unknown buffer format %d\n", format);
        buffer->bitmap = NULL;
        free_paintbuffer(buffer);
        return NULL;
    }

    if (!buffer->bitmap)
    {
        WARN("Failed to create buffer bitmap\n");
        free_paintbuffer(buffer);
        return NULL;
    }

    SetWindowOrgEx(buffer->memorydc, rect->left, rect->top, NULL);
    IntersectClipRect(buffer->memorydc, rect->left, rect->top, rect->right, rect->bottom);
    DeleteObject(SelectObject(buffer->memorydc, buffer->bitmap));

    *retdc = buffer->memorydc;

    return (HPAINTBUFFER)buffer;
}
예제 #30
0
HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
                    int iDeciPtWidth, int iAttributes, BOOL fLogRes)
{
    FLOAT      cxDpi, cyDpi ;
    HFONT      hFont ;
    LOGFONT    lf ;
    POINT      pt ;
    TEXTMETRIC tm ;

    SaveDC (hdc) ;

#ifndef HAVE_API_WIN32_CE
    SetGraphicsMode (hdc, GM_ADVANCED) ;
    ModifyWorldTransform (hdc, NULL, MWT_IDENTITY) ;
#endif
    SetViewportOrgEx (hdc, 0, 0, NULL) ;
#ifndef HAVE_API_WIN32_CE
    SetWindowOrgEx   (hdc, 0, 0, NULL) ;
#endif

    if (fLogRes)
    {
        cxDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSX) ;
        cyDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSY) ;
    }
    else
    {
        cxDpi = (FLOAT) (25.4 * GetDeviceCaps (hdc, HORZRES) /
                         GetDeviceCaps (hdc, HORZSIZE)) ;

        cyDpi = (FLOAT) (25.4 * GetDeviceCaps (hdc, VERTRES) /
                         GetDeviceCaps (hdc, VERTSIZE)) ;
    }

    pt.x = (int) (iDeciPtWidth  * cxDpi / 72) ;
    pt.y = (int) (iDeciPtHeight * cyDpi / 72) ;

#ifndef HAVE_API_WIN32_CE
    DPtoLP (hdc, &pt, 1) ;
#endif
    lf.lfHeight         = - (int) (fabs (pt.y) / 10.0 + 0.5) ;
    lf.lfWidth          = 0 ;
    lf.lfEscapement     = 0 ;
    lf.lfOrientation    = 0 ;
    lf.lfWeight         = iAttributes & EZ_ATTR_BOLD      ? 700 : 0 ;
    lf.lfItalic         = iAttributes & EZ_ATTR_ITALIC    ?   1 : 0 ;
    lf.lfUnderline      = iAttributes & EZ_ATTR_UNDERLINE ?   1 : 0 ;
    lf.lfStrikeOut      = iAttributes & EZ_ATTR_STRIKEOUT ?   1 : 0 ;
    lf.lfCharSet        = DEFAULT_CHARSET ;
    lf.lfOutPrecision   = 0 ;
    lf.lfClipPrecision  = 0 ;
    lf.lfQuality        = 0 ;
    lf.lfPitchAndFamily = 0 ;

    lstrcpy (lf.lfFaceName, szFaceName) ;

    hFont = CreateFontIndirect (&lf) ;

    if (iDeciPtWidth != 0)
    {
        hFont = (HFONT) SelectObject (hdc, hFont) ;

        GetTextMetrics (hdc, &tm) ;

        DeleteObject (SelectObject (hdc, hFont)) ;

        lf.lfWidth = (int) (tm.tmAveCharWidth *
                            fabs (pt.x) / fabs (pt.y) + 0.5) ;

        hFont = CreateFontIndirect (&lf) ;
    }

    RestoreDC (hdc, -1) ;
    return hFont ;
}