Beispiel #1
0
CMemDC1::CMemDC1(CDC* pDC):CDC()
{

	ASSERT(pDC!=NULL);

	m_pDC=pDC;
	m_pOldBitmap=NULL;
	m_bMemDC=!pDC->IsPrinting();
	//
	if(m_bMemDC)
	{
		pDC->GetClipBox(&m_rect);
		CreateCompatibleDC(pDC);
		m_bitmap.CreateCompatibleBitmap(pDC,m_rect.Width(),m_rect.Height());
		m_pOldBitmap=SelectObject(&m_bitmap);
		SetWindowOrg(m_rect.left,m_rect.top);
	}
	else		//为相关的现有设备准备打印
	{
		m_bPrinting=pDC->m_bPrinting;
		m_hDC=pDC->m_hDC;
		m_hAttribDC=pDC->m_hAttribDC;
	}

}
Beispiel #2
0
CMemDC::CMemDC (CDC* pDC)
 : CDC(), m_pDC(pDC), m_pOldBitmap(NULL), m_pThis(NULL)
{
#ifdef _DEBUG
	ASSERT(m_pDC != NULL);
#else
	if (NULL == m_pDC)
		throw ERROR_BAD_ENVIRONMENT;
#endif
	m_bMemDC = !(m_pDC->IsPrinting());

	if (m_bMemDC)	// Create a Memory DC
	{
		int	nRes=m_pDC->GetClipBox(&m_rect);
		ASSERT(nRes != ERROR);

		VERIFY(CreateCompatibleDC(m_pDC));
		VERIFY(m_bitmap.CreateCompatibleBitmap(m_pDC, m_rect.Width(), m_rect.Height()));
		m_pOldBitmap = SelectObject(&m_bitmap);

		CPoint	prevPt=SetWindowOrg(m_rect.left, m_rect.top);
	}
	else		// Make a copy of the relevent parts of the current DC for printing
	{
		m_bPrinting = m_pDC->m_bPrinting;
		m_hDC		= m_pDC->m_hDC;
		m_hAttribDC = m_pDC->m_hAttribDC;
	}

	m_pThis = this;
}
Beispiel #3
0
//KMemDC
KMemDC::KMemDC(HDC hDC, const RECT* pRect):KDC(){
	assert(hDC!=NULL);
	// Some initialization
	m_hDCPaint=hDC;

	// Get the rectangle to draw
	if(!pRect)
		::GetClipBox(hDC,&m_rect);
	else 
		m_rect=*pRect;

	// Create a Memory DC
	CreateCompatibleDC(hDC);
	::LPtoDP(hDC,(POINT*)(&m_rect),2);

	m_bitmap=::CreateCompatibleBitmap(hDC, m_rect.right-m_rect.left,m_rect.bottom-m_rect.top);
	m_oldBitmap=(HBITMAP)SelectObject(m_bitmap);

	SetMapMode(::GetMapMode(hDC));

	SIZE size;
	::GetWindowExtEx(hDC,&size);	
	SetWindowExt(size);
	::GetViewportExtEx(hDC,&size);
	SetViewportExt(size);

	::DPtoLP(hDC,(POINT*)(&m_rect),2);
	SetWindowOrg(m_rect.left, m_rect.top);

	// Fill background
	FillSolidRect(&m_rect, ::GetBkColor(hDC));
}
Beispiel #4
0
/////////////////////////////////////////////////////////////////////
// TMapDC
// ------
//
void
TMapDC::SetupOrg()
{
#ifdef WINDOWS_SCALING
	// Set window and viewport scale and extension
	SetMapMode (MM_ANISOTROPIC);
	SetViewportOrg (TPoint(ScrCenterX, ScrCenterY));
	SetWindowOrg (TPoint(OrigX, OrigY)) ;
	if ( Scale > 1.0 )
	{
		// dc.SetWindowExt (TSize(ScrMaxX, ScrMaxY));
		// dc.SetViewportExt (TSize(ScrMaxX * MUL_SCALE, -ScrMaxY * MUL_SCALE));
		SetWindowExt (TSize(1, 1));
		SetViewportExt (TSize(MUL_SCALE, -MUL_SCALE));
	}
	else if (Scale <= 1.0 )
	{
		SetWindowExt (TSize(ScrMaxX * DIV_SCALE, ScrMaxY * DIV_SCALE));
		SetViewportExt (TSize(ScrMaxX, -ScrMaxY));
	}

	/*
	for (int x = MIN_MAP_X ; x <= MAX_MAP_X ; x+=1000)
		for (SHORT y = MIN_MAP_Y ; y <= MAX_MAP_Y ; y+=1000)
		{
			char msg[80];
			wsprintf (msg,"(%d:%d)", x/1000, y/1000);
			dc.TextOut (x, y, msg);
		}
	*/

#endif
}
Beispiel #5
0
void QnDC::CreateFromDC(CDC* pDC, CWnd* pWnd)
{
	m_pWnd = pWnd;
	m_pWnd->GetClientRect(m_dcRect);
	CreateCompatibleDC(pDC);
	m_bitmap.CreateDiscardableBitmap(pDC, m_dcRect.Width(), m_dcRect.Height());
	m_pOldBitmap = SelectObject(&m_bitmap);
	SetWindowOrg(m_dcRect.left, m_dcRect.top);
}
Beispiel #6
0
/*
 * PaintMonitor - redraw the monitor window
 */
static void PaintMonitor( HWND hwnd, HDC dc, LocalMonInfo *info ) {

    RECT        area;
    WORD        i;
    char        buf[80];
    WORD        xpos, ypos;
    HBRUSH      white;

    SaveDC( dc );
    GetClientRect( hwnd, &area );
    white = GetStockObject( WHITE_BRUSH );
    FillRect( dc, &area, white );
    SetMapMode( dc, MM_ANISOTROPIC );
    SetWindowOrg( dc, 0, 0 );
    SetWindowExt( dc, MONITOR_WIDTH, MONITOR_HITE );
    SetViewportOrg( dc, 0, 0 );
    SetViewportExt( dc, area.right, area.bottom );

    area.top = BAR_HITE;
    area.bottom = 2 * BAR_HITE;
    area.left = BAR_XPOS;
    for( i=0; i < SIZE_CNT; i++ ) {
        if( info->sizes[i] == 0 ) continue;
        area.right = area.left + SECTION_WIDTH( info->sizes[i],
                                                info->total_size );
        FillRect( dc, &area, Brushes.brush[i] );

        xpos = ( area.left + area.right ) / 2;
        MoveTo( dc, xpos, area.bottom );
        ypos = area.bottom + TEXT_SPACE + ( SIZE_CNT - i ) * TEXT_HITE;
        LineTo( dc, xpos, ypos );
        xpos += TICK_LENGTH;
        LineTo( dc, xpos, ypos );
        if( i == STACK_SIZE ) {
            sprintf( buf, MonitorLabels[i], info->sizes[i],
                     info->stack_used );
        } else {
            sprintf( buf, MonitorLabels[i], info->sizes[i] );
        }
        TextOut( dc, xpos, ypos, buf, strlen( buf ) );
        area.left = area.right;
    }

    area.left = BAR_XPOS;
    area.right = area.left + BAR_LENGTH;
    MoveTo( dc, area.left, area.top );
    LineTo( dc, area.right, area.top );
    LineTo( dc, area.right, area.bottom );
    LineTo( dc, area.left, area.bottom );
    LineTo( dc, area.left, area.top );

    TextOut( dc, 0, BAR_HITE, "0", 1 );
    sprintf( buf, "%u", info->total_size );
    TextOut( dc, area.right + area.left, BAR_HITE, buf, strlen( buf ) );
    RestoreDC( dc, -1 );
}
Beispiel #7
0
void CMemDCX::SetSize(CDC *pDC,int width, int height)
{
	ASSERT(m_oldbitmap!=NULL);
	ASSERT(width>0);
	ASSERT(height>0);

	if ((m_rect.Width()==width)&&(m_rect.Height()==height)) return;

	m_rect.SetRect(0,0,width,height);
	SelectObject(&m_oldbitmap);
	m_bitmap.DeleteObject();
	m_bitmap.CreateCompatibleBitmap(pDC, width, height);
	m_oldbitmap = SelectObject(&m_bitmap);
	SetWindowOrg(0,0);
}
Beispiel #8
0
void CMemDCX::create(CDC *pDC, int width, int height)
{
	ASSERT(pDC!=NULL);
	ASSERT(m_oldbitmap==NULL);
	ASSERT(width>0);
	ASSERT(height>0);
	ASSERT(pDC->IsPrinting()!=TRUE);

	// create a memory dc
	CreateCompatibleDC(pDC);
	m_rect.SetRect(0,0,width,height);
	m_bitmap.CreateCompatibleBitmap(pDC, width, height);
	m_oldbitmap = SelectObject(&m_bitmap);
	SetWindowOrg(0,0);
}
Beispiel #9
0
/**********************************************************************
        SetELightMapping
**********************************************************************/
static int SetupRLightMapping(HWND hWnd, HDC hDC, WORD wMaxWidth,
                              WORD wTextHeight, WORD wNumPossValues)
{
    short sXWinExt, sYWinExt, sXWinOrg, sYWinOrg;
    short sXViewExt, sYViewExt, sXViewOrg, sYViewOrg;
    RECT rect;

    SetMapMode(hDC, MM_ISOTROPIC);

    sYWinExt = wNumPossValues * ((2 * VERT_PAD) + wTextHeight)
        + (2 * VERT_PAD) + wTextHeight;
    sXWinExt = wMaxWidth + (2 * VERT_PAD);

    /* Get clients rectangle */
    GetClientRect(hWnd, (LPRECT) & rect);

    sXViewExt = rect.right - rect.left;
    sYViewExt = rect.bottom - rect.top;

    if (sXViewExt > sXWinExt)
        sXViewOrg = rect.left + (short) ((double) sXViewExt / 2.0);
    else
        sXViewOrg = rect.left + (short) ((double) sXWinExt / 2.0);

    if (sYViewExt > sYWinExt)
        sYViewOrg = rect.bottom -
            (short) ((double) (sYViewExt - sYWinExt) / 2.0);
    else
        sYViewOrg = rect.bottom;

    sXWinOrg = 0;
    sYWinOrg = 0;

    /* Set the mappings */
    SetWindowExt(hDC, sXWinExt, sYWinExt);
    SetWindowOrg(hDC, sXWinOrg, sYWinOrg);

    SetViewportExt(hDC, sXWinExt, -sYWinExt);
    SetViewportOrg(hDC, sXViewOrg, sYViewOrg);

    return TRUE;
}
Beispiel #10
0
CMemDC::CMemDC(CDC* pDC, const CRect* pRect) : CDC()
{
	ASSERT(pDC != NULL); 

	// Some initialization
	m_pDC = pDC;
	m_oldBitmap = NULL;
	m_bMemDC = !pDC->IsPrinting();

	// Get the rectangle to draw
	if (pRect == NULL) {
		pDC->GetClipBox(&m_rect);
	} else {
		m_rect = *pRect;
	}

	if (m_bMemDC) {
		// Create a Memory DC
		CreateCompatibleDC(pDC);
		pDC->LPtoDP(&m_rect);

		m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
		m_oldBitmap = SelectObject(&m_bitmap);

		SetMapMode(pDC->GetMapMode());

		SetWindowExt(pDC->GetWindowExt());
		SetViewportExt(pDC->GetViewportExt());

		pDC->DPtoLP(&m_rect);
		SetWindowOrg(m_rect.left, m_rect.top);
	} else {
		// Make a copy of the relevent parts of the current DC for printing
		m_bPrinting = pDC->m_bPrinting;
		m_hDC       = pDC->m_hDC;
		m_hAttribDC = pDC->m_hAttribDC;
	}

	// Fill background 
	FillSolidRect(m_rect, pDC->GetBkColor());
}
Beispiel #11
0
/*
*       -- 更改坐标系 --
*       ViewOrg_X, ViewOrg_Y: 视图原点; ViewExt_X, ViewExt_Y:  视图范围;
*       WindOrg_X, WindOrg_Y: 视图原点; WindExt_X, WindExt_Y: 窗口范围
*/
void  ChangeZBX(HDC hdc, int ViewOrg_X, int ViewOrg_Y, int ViewExt_X, int ViewExt_Y, int WindOrg_X, int WindOrg_Y, int WindExt_X, int WindExt_Y)
{
        POINT Pt_ViewOrg;
        POINT Pt_ViewExt;
        POINT Pt_WindExt;
        POINT Pt_WindOrg;
        
        
        Pt_ViewOrg.x = ViewOrg_X;
        Pt_ViewOrg.y = ViewOrg_Y;
        Pt_ViewExt.x = ViewExt_X;
        Pt_ViewExt.y = ViewExt_Y;
        Pt_WindOrg.x = WindOrg_X;
        Pt_WindOrg.y = WindOrg_Y;
        Pt_WindExt.x = WindExt_X;
        Pt_WindExt.y = WindExt_Y;
        
        SetMapMode(hdc, MM_ANISOTROPIC);
        SetViewportOrg(hdc, &Pt_ViewOrg);
        SetViewportExt(hdc, &Pt_ViewExt);
        SetWindowExt(hdc, &Pt_WindExt);
        SetWindowOrg(hdc, &Pt_WindOrg );
}
 // constructor sets up the memory DC
    CMyMemDC(CDC* pDC) : CDC()
    {
        ASSERT(pDC != NULL);

        m_pDC = pDC;
        m_pOldBitmap = NULL;
        m_bMemDC = !pDC->IsPrinting();
              
        if (m_bMemDC)    // Create a Memory DC
        {
            pDC->GetClipBox(&m_rect);
    CreateCompatibleDC(pDC);
            m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
            m_pOldBitmap = SelectObject(&m_bitmap);
            SetWindowOrg(m_rect.left, m_rect.top);
        }
        else        // Make a copy of the relevent parts of the current DC for printing
        {
            m_bPrinting = pDC->m_bPrinting;
            m_hDC       = pDC->m_hDC;
            m_hAttribDC = pDC->m_hAttribDC;
        }
    }