LRESULT CSaveModifiedItemsDialog::OnListViewPaint(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	if(wParam != NULL)
	{
		CMemDC memdc((HDC)wParam, NULL);

		//memdc.FillSolidRect(&memdc.m_rc, ::GetSysColor(COLOR_WINDOW));
		m_list.DefWindowProc( WM_ERASEBKGND, (WPARAM)memdc.m_hDC, 0);
		m_list.DefWindowProc( uMsg, (WPARAM)memdc.m_hDC, 0);

		if(m_header.IsWindow())
		{
			m_header.SendMessage(WM_PAINT, (WPARAM)memdc.m_hDC, 0);
			m_header.ValidateRect(&memdc.m_rc);
		}
	}
	else
	{
		CPaintDC dc(m_list);
		CMemDC memdc(dc.m_hDC, &dc.m_ps.rcPaint);

		//memdc.FillSolidRect(&dc.m_ps.rcPaint, ::GetSysColor(COLOR_WINDOW));
		m_list.DefWindowProc( WM_ERASEBKGND, (WPARAM)memdc.m_hDC, 0);
		m_list.DefWindowProc( uMsg, (WPARAM)memdc.m_hDC, 0);

		if(m_header.IsWindow())
		{
			m_header.SendMessage(WM_PAINT, (WPARAM)memdc.m_hDC, 0);
			m_header.ValidateRect(&dc.m_ps.rcPaint);
		}
	}
	return 0;
}
Пример #2
0
BOOL CDragWnd::BeginDrag( HBITMAP hBmp,POINT ptHot ,COLORREF crKey, BYTE byAlpha,DWORD dwFlags)
{
	if(s_pCurDragWnd) return FALSE;
	s_pCurDragWnd=new CDragWnd;
	BITMAP bm;
	GetObject(hBmp,sizeof(bm),&bm);

	if(!s_pCurDragWnd->Create(NULL,WS_POPUP,WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_LAYERED,0,0,bm.bmWidth,bm.bmHeight,0,NULL))
	{
		delete s_pCurDragWnd;
		s_pCurDragWnd=NULL;
		return FALSE;
	}

	if(bm.bmBitsPixel==32)
	{
		CDCHandle dc=s_pCurDragWnd->GetDC();
		CMemDC memdc(dc,hBmp);
		BLENDFUNCTION bf={AC_SRC_OVER,0,byAlpha,AC_SRC_ALPHA};
		s_pCurDragWnd->UpdateLayeredWindow(dc,&CPoint(0,0),&CSize(bm.bmWidth,bm.bmHeight),memdc,&CPoint(0,0),crKey,&bf,LWA_ALPHA);
		s_pCurDragWnd->ReleaseDC(dc);
	}else
	{
		s_pCurDragWnd->SetLayeredWindowAttributes(crKey,byAlpha,dwFlags);
		CDCHandle dc=s_pCurDragWnd->GetDC();
		s_pCurDragWnd->m_memdc.CreateCompatibleDC(dc);
		s_pCurDragWnd->m_memdc.SelectBitmap(hBmp);
		s_pCurDragWnd->ReleaseDC(dc);
	}
	s_pCurDragWnd->m_ptHot=ptHot;
	return TRUE;
}
Пример #3
0
LRESULT CAboutDlg::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
/*
	HBITMAP hPicture = LoadBitmap(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDB_LOGO));

	BITMAP bm;
	GetObject(hPicture, sizeof (BITMAP), (LPSTR)&bm);

	CMemDC memdc((HDC)wParam, NULL);
	HDC hdcCompatible = CreateCompatibleDC(memdc);
	HBITMAP hOldBMP = (HBITMAP)SelectObject(hdcCompatible, hPicture);
	RECT rcClient;
	GetClientRect(&rcClient);
	memdc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE));

	memdc.TransparentBlt(107-bm.bmWidth/2, 116-bm.bmHeight/2, bm.bmWidth, bm.bmHeight, hdcCompatible, 
						 0, 0, bm.bmWidth, bm.bmHeight, 0xff00ff);

	SelectObject(hdcCompatible, hOldBMP);
	DeleteDC(hdcCompatible);
	DeleteObject(hPicture);
/*/
	CImage Image;
	LoadImage(&Image, _Module.GetModuleInstance(), IDB_LOGO);

	CMemDC memdc((HDC)wParam, NULL);

	RECT rcClient;
	GetClientRect(&rcClient);
	memdc.FillRect(&rcClient, COLOR_3DFACE);
	Image.AlphaBlend(memdc, 107-Image.GetWidth()/2, 116-Image.GetHeight()/2, Image.GetWidth(), Image.GetHeight(), 0, 0, Image.GetWidth(), Image.GetHeight());
/**/
	return 0;

}
Пример #4
0
wxBitmap* gdiplusResize(wxBitmap* bitmap, const FloatSize& size)
{
    IntSize intSize = IntSize(ceilf(size.width()), ceilf(size.height()));
    if (intSize.width() == bitmap->GetWidth() && intSize.height() == bitmap->GetHeight())
        return new wxBitmap(*bitmap); // just return a copy if the asked for the same size

    wxBitmap* newBitmap = new wxBitmap(intSize.width(), intSize.height(), 32);
    newBitmap->UseAlpha();

    wxMemoryDC memdc(*newBitmap);
    wxGraphicsContext* gc = wxGraphicsContext::Create(memdc);
    wxGraphicsBitmap gcbitmap(gc->CreateBitmap(*bitmap));

    Graphics* graphics = (Graphics*)gc->GetNativeContext();
    graphics->Clear(Gdiplus::Color(0, 0, 0, 0));

    // Only use HighQualityBicubic when downsampling.
    InterpolationMode mode;
    if (size.width() < (int)bitmap->GetWidth() && size.height() < (int)bitmap->GetHeight())
        mode = InterpolationModeHighQualityBicubic;
    else
        mode = InterpolationModeBicubic;

    graphics->SetInterpolationMode(mode);
    graphics->DrawImage((Bitmap*)gcbitmap.GetNativeBitmap(), 0.0, 0.0, size.width(), size.height());
    
    premultiplyAlpha(*newBitmap);

    delete gc;

    return newBitmap;
}
Пример #5
0
void wxGenericColourButton::UpdateColour()
{
    if ( !m_colour.Ok() )
    {
#if wxCLRBTN_USES_BMP_BUTTON
        wxBitmap empty(1,1);
        SetBitmapLabel(empty);
#else
        if ( HasFlag(wxCLRP_SHOW_LABEL) )
            SetLabel(wxEmptyString);
#endif
        return;
    }

    // some combinations of the fg/bg colours may be unreadable, so we invert
    // the colour to make sure fg colour is different enough from m_colour
    wxColour colFg(~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue());

#if wxCLRBTN_USES_BMP_BUTTON
    wxSize sz = GetSize();
    sz.x -= 2*GetMarginX();
    sz.y -= 2*GetMarginY();

    wxPoint topleft;
    
    if ( sz.x < 1 )
        sz.x = 1;
    else
    if ( sz.y < 1 )
        sz.y = 1;
    
    wxBitmap bmp(sz.x, sz.y);
    {
        wxMemoryDC memdc(bmp);
        memdc.SetPen(colFg);
        memdc.SetBrush(m_colour);
        memdc.DrawRectangle(topleft,sz);
        if ( HasFlag(wxCLRP_SHOW_LABEL) )
        {
            int x, y, leading, desc;
            wxString label = m_colour.GetAsString(wxC2S_HTML_SYNTAX);
            memdc.GetTextExtent(label,&x,&y,&desc,&leading);
            if ( x <= sz.x && y <= sz.y )
            {
                topleft.x += (sz.x-x)/2;
                topleft.y += (sz.y-y)/2;
                memdc.SetTextForeground(colFg);
                memdc.DrawText(label,topleft);
            }
        }
    }
    SetBitmapLabel(bmp);
#else
    SetForegroundColour(colFg);
    SetBackgroundColour(m_colour);

    if ( HasFlag(wxCLRP_SHOW_LABEL) )
        SetLabel(m_colour.GetAsString(wxC2S_HTML_SYNTAX));
#endif
}
Пример #6
0
void DrawForPrinting(wxDC *printerdc, const CalChartConfiguration& config, const CalChartDoc& show, const CC_sheet& sheet, unsigned ref, bool landscape)
{
    auto boundingBox = GetMarcherBoundingBox(sheet.GetPoints());
    bool forced_landscape = !landscape && (boundingBox.second.x - boundingBox.first.x) > Int2Coord(kFieldStepSizeNorthSouth[0]);

    auto bitmapWidth = (landscape || forced_landscape ? kSizeXLandscape : kSizeX)*kBitmapScale;
    auto bitmapHeight = (landscape || forced_landscape ? kSizeYLandscape : kSizeY)*kBitmapScale;
    // construct a bitmap for drawing on.  This should
    wxBitmap membm(bitmapWidth, bitmapHeight);
    // first convert to image
    wxMemoryDC memdc(membm);
    DrawForPrintingHelper(memdc, config, show, sheet, ref, landscape || forced_landscape);

    auto image = membm.ConvertToImage();
    if (forced_landscape)
    {
        image = image.Rotate90(false);
    }
    wxBitmap rotate_membm(image);
    wxMemoryDC tmemdc(rotate_membm);

    int printerW, printerH;
    printerdc->GetSize(&printerW, &printerH);
    auto scaleX = printerW/float(rotate_membm.GetWidth());
    auto scaleY = printerH/float(rotate_membm.GetHeight());
    printerdc->SetUserScale(scaleX, scaleY);
    printerdc->Blit(0, 0, rotate_membm.GetWidth(), rotate_membm.GetHeight(), &tmemdc, 0, 0);
}
Пример #7
0
void PropertyTree::OnPaint() 
{
    CPaintDC dc(this);

    ClearVisibleList();

    // get client rect
    CRect rc;
    GetClientRect( rc );

    // draw control background
    CMemDC memdc( &dc );
    memdc.FillSolidRect( rc, Globals::Preferences->GetBtnFaceColor() );

    PropertyTreeItem* pItem;
    LONG nTotal = 0;

    ASSERT(GetRootItem()!=NULL);

    // create clip region
    HRGN hRgn = CreateRectRgn( rc.left, rc.top, rc.right, rc.bottom );
    SelectClipRgn( memdc.m_hDC, hRgn );

    // build a list of visible items prior to drawing. if
    // we decide to later implement trees with more than
    // one level, we will need a recursive function call
    // to do this.

    pItem = GetRootItem()->GetChild();
    while ( pItem )
    {
        m_pVisibleList.push_back( pItem );
        if ( pItem->IsExpanded() && pItem->GetChild() )
        {
            PropertyTreeItem* pNext = pItem->GetChild();
            while ( pNext )
            {
                m_pVisibleList.push_back( pNext );
                pNext = pNext->GetNext();
            }
        }
        pItem = pItem->GetNext();
    }

    // determine if the scrollbar is visible
    CheckScrollVisible();

    // actually draw the items
    for ( size_t i = 0; i < m_pVisibleList.size(); i++ )
    {
        LONG nHeight = m_pVisibleList.at( i )->DrawItem(&memdc, rc, 0, nTotal);
        nTotal += nHeight;
    }

    // remove clip region
    SelectClipRgn(memdc.m_hDC, NULL);
    DeleteObject(hRgn);
}
Пример #8
0
// COrigGattooView drawing
void COrigGattooView::OnDraw(CDC* pDC)
{
	CGattooDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc) return;

	CRect rc;
	GetClientRect(&rc);

	CMemDC memdc(*pDC, this);

	memdc.GetDC().FillSolidRect(&rc, GetSysColor(COLOR_APPWORKSPACE));

	CSize imSize = GetDocument()->getImgSize();
	if (imSize.cx == 0 || imSize.cy == 0)
		return;

	CBitmap *bmp = memdc.GetDC().GetCurrentBitmap();

	if (bmp)
	{
		CDC dcCache;
		CBitmap bmpCache;

		int iWidth  = std::min<int>(rc.Width(), imSize.cx);
		int iHeight = std::min<int>(rc.Height(), imSize.cy);

		bmpCache.CreateCompatibleBitmap(pDC, iWidth, iHeight);
		dcCache.CreateCompatibleDC(pDC);
		HGDIOBJ pOldBmp = dcCache.SelectObject(bmpCache);

		CPoint ptStart;
		
		ptStart.x = (rc.Width() > imSize.cx) ? (rc.Width() - imSize.cx) / 2 : 0;
		ptStart.y = (rc.Height() > imSize.cy) ? (rc.Height() - imSize.cy) / 2 : 0;

		if (imSize.cx - m_ptViewPoint.x < rc.Width())
			m_ptViewPoint.x = std::max<int>(imSize.cx - rc.Width(), 0);

		if (imSize.cy - m_ptViewPoint.y < rc.Height())
			m_ptViewPoint.y = std::max<int>(imSize.cy - rc.Height(), 0);

		pDoc->PerformDrawing(bmpCache, m_ptViewPoint);

		memdc.GetDC().BitBlt(ptStart.x, ptStart.y, iWidth, iHeight, &dcCache, 0, 0, SRCCOPY);

		dcCache.SelectObject(pOldBmp);
	}
}
Пример #9
0
bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
                   const wxColour& col, int style)
{
    if (dc->GetBrush().GetStyle() == wxTRANSPARENT)
        return true;

    int height = 0;
    int width  = 0;
    dc->GetSize(&width, &height);

    //it would be nice to fail if we don't get a sensible size...
    wxCHECK_MSG(width >= 1 && height >= 1, false,
                wxT("In FloodFill, dc.GetSize routine failed, method not supported by this DC"));

    const int x_dev = dc->LogicalToDeviceX(x);
    const int y_dev = dc->LogicalToDeviceY(y);

    // if start point is outside dc, can't do anything
    if (!wxRect(0, 0, width, height).Contains(x_dev, y_dev))
        return false;

    wxBitmap bitmap(width, height);
    wxMemoryDC memdc(bitmap);
    // match dc scales
    double sx, sy;
    dc->GetUserScale(&sx, &sy);
    memdc.SetUserScale(sx, sy);
    dc->GetLogicalScale(&sx, &sy);
    memdc.SetLogicalScale(sx, sy);

    // get logical size and origin
    const int w_log = dc->DeviceToLogicalXRel(width);
    const int h_log = dc->DeviceToLogicalYRel(height);
    const int x0_log = dc->DeviceToLogicalX(0);
    const int y0_log = dc->DeviceToLogicalY(0);

    memdc.Blit(0, 0, w_log, h_log, dc, x0_log, y0_log);
    memdc.SelectObject(wxNullBitmap);

    wxImage image = bitmap.ConvertToImage();
    wxImageFloodFill(&image, x_dev, y_dev, dc->GetBrush(), col, style,
                     dc->GetLogicalFunction());
    bitmap = wxBitmap(image);
    memdc.SelectObject(bitmap);
    dc->Blit(x0_log, y0_log, w_log, h_log, &memdc, 0, 0);

    return true;
}
Пример #10
0
	HBITMAP CDuiHeaderCtrl::CreateDragImage( int iItem )
	{
		if(iItem<0 || iItem>=m_arrItems.GetCount()) return NULL;
		CRect rcClient;
		GetClient(rcClient);
		CRect rcItem(0,0,m_arrItems[iItem].cx,rcClient.Height());
		
		CDCHandle dc=GetDuiDC(NULL,OLEDC_NODRAW);
		CMemDC memdc(dc,rcItem);
		CDCHandle hmemdc=memdc;
		BeforePaintEx(hmemdc);
		DrawItem(hmemdc,rcItem,m_arrItems.GetData()+iItem);
		HBITMAP hItemBmp=memdc.SelectBitmap(NULL);
		ReleaseDuiDC(dc);
		return hItemBmp;
	}
Пример #11
0
//////////////////
// Windows should have provided DrawBitmap, but didn't, so here it is.
// Code is from Petzold.
// 
void WPDevContext::drawBitmap(int x, int y, WPBitmap* bitmap, DWORD rop)
{
	if (bitmap) {
		BITMAP bm;
		bitmap->getObject(bm);
		WPMemDC memdc(this, bitmap);
		WPRect dest;
		dest.origin(x, y);
		WPPoint p(bm.bmWidth, bm.bmHeight);
		DP2LP(&p, 1);
		dest.extent(p.x, p.y);
		p.x = p.y = 0;
		DP2LP(&p, 1);
		bitBlt(dest, memdc, p, rop);
	}
}
Пример #12
0
void CComboBoxBT::OnPaint()
{
	CPaintDC dc(this);
	//CPaintDC subdc(m_pane);
	CMemDCEx memdc(&dc, this);
	memdc.SetBkMode(TRANSPARENT);
	m_imgBK.Draw(memdc.GetSafeHdc());
	CRect rc;
	GetClientRect(rc);
	rc.left += 5;
	rc.right -= rc.Height();
	memdc.SelectObject(&m_font);
	int index = GetCurSel();
	if (index != CB_ERR)
	{
		GetLBText(index, m_strSel);
	}
	memdc.SetTextColor(m_clrText);
	memdc.DrawText(m_strSel, rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER);

}
Пример #13
0
void CTextureCtrl::Draw(HDC hdc)
{
	// buffered context
	CMemDC memdc(hdc,*this,false);

	CRect rect;
	CBrush brush;

	GetClientRect(&rect);

	// draw a grey rect if disabled
	if(!IsWindowEnabled())
	{
		brush.CreateSolidBrush(RGB(128,128,128));
		FillRect(memdc,&rect,brush);
		return;
	}

	// create destination context for drawing the bitmaps
	HDC bmp_dc=CreateCompatibleDC(memdc);

	// select grid
	HBITMAP old_bmp=(HBITMAP)SelectObject(bmp_dc,grid);
	// draw grid
	for(int x=0; x<rect.Width(); x+=grid.w)
		for(int y=0; y<rect.Height(); y+=grid.h)
			BitBlt(memdc,x,y,64,64,bmp_dc,0,0,SRCCOPY);

	// draw bitmap, if one is loaded
	if(texture.w>0 && texture.h>0)
	{
		SelectObject(bmp_dc,texture);
		//TransparentBlt(memdc,0,0,texture.w,texture.h,bmp_dc,0,0,texture.w,texture.h,RGB(255,0,255));
		BitBlt(memdc,0,0,texture.w,texture.h,bmp_dc,0,0,SRCCOPY);
	}

	// flush memory dc
	SelectObject(bmp_dc,old_bmp);
	DeleteObject(bmp_dc);
}
Пример #14
0
//=============================================================================
// paint the bitmap currently pointed to with m_pCurBtn
//=============================================================================
void CButtonBT::PaintBtn(CDC *pDC, BOOL mark)
{
	CRect rect;
	GetClientRect(rect);
	CMemDCEx memdc(pDC, this);
	memdc.BitBlt(0, 0, rect.Width(), rect.Height(), m_pCurBtn, 0, 0, SRCCOPY);

	if (m_bISTextSelf)
	{
		memdc.SetBkMode(TRANSPARENT);
		memdc.SelectObject(m_font);
		CRect rc(rect);
		rc.left += 6;
		memdc.DrawText(m_strText, rc, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
	}
	if (mark)
	{
		return;
	}

	if (m_bISFrame)
	{
		CPoint pt(5,5);
		CBrush *bru;
		CPen pen;
		pen.CreatePen(PS_SOLID, 1, RGB(138,138,138));
		bru = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
		CBrush *oldbru = memdc.SelectObject(bru);
		CPen *oldpen = memdc.SelectObject(&pen);
		memdc.RoundRect(rect, pt);
		//pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_pCurBtn, 0, 0, SRCCOPY);
		memdc.SelectObject(oldbru);
		memdc.SelectObject(oldpen);
	}

}
Пример #15
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CButtonBT::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_imgStd.IsValid())
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDCEx memdc(pScreenDC, rect);
		//CGDIPMemDC pDC(pScreenDC, rect);

		//Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{

			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(&memdc);

			//graphics.DrawImage(*m_pStdImage, 0, 0);
			m_imgStd.Draw(memdc.GetSafeHdc());
		
			m_dcStd.CreateCompatibleDC(&memdc);
			bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(&memdc);

				if (m_bISMove)
				{
					//graphics.DrawImage(*m_pStdImage, 1, 1);
					m_imgStd.Draw(memdc.GetSafeHdc(), 1, 1);
				}
				else
				{
					//graphics.DrawImage(*m_pStdImage, 0, 0);
					m_imgStd.Draw(memdc.GetSafeHdc());
				}
				

				m_dcStdP.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgStd;
				imgtemp.ShiftRGB(20,20,20);
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcStdH.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgStd;
				imgtemp.GrayScale();
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcGS.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(&memdc);

			//graphics.DrawImage(*m_pAltImage, 0, 0);
			m_imgAlt.Draw(memdc.GetSafeHdc());
		
			m_dcAlt.CreateCompatibleDC(&memdc);
			bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(&memdc);

				if (m_bISMove)
				{
					//graphics.DrawImage(*m_pAltImage, 1, 1);
					m_imgAlt.Draw(memdc.GetSafeHdc(), 1, 1);
				}
				else
				{
					//graphics.DrawImage(*m_pAltImage, 0, 0);
					m_imgAlt.Draw(memdc.GetSafeHdc());
				}
				
			
				m_dcAltP.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgAlt;
				imgtemp.ShiftRGB(20,20,20);
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcAltH.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		if(m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Пример #16
0
void
MFCArrangeView::OnDraw(CDC* pdc)
{
	CRect	clipBox;
	int		cbType;
	cbType = pdc->GetClipBox(&clipBox);
	CDocument* pDoc = GetDocument();
	// COMPLEXREGION 3
	// SIMPLEREGION 2
	// NULLREGION 1
	// ERROR 0

#ifdef QUA_V_GDI_PLUS
	CMemDC memdc(pdc);
	Graphics graphics(memdc);
	CPoint sp = GetScrollPosition();

//  graphics.TranslateTransform(-sp.x, -sp.y);
//	SetWindowOrgEx(pdc->m_hDC, ps.x, ps.y, NULL);
//	std::cerr << "MFCArrangeView OnDraw " << " clip box " << cbType << ", scroll " << sp.x << ", " << sp.y << "; "
//		<< clipBox.left << ", " << clipBox.top << ", " << clipBox.right << ", "  << clipBox.bottom;
//	clipBox -= sp;
//	std::cerr << ", now box " << cbType << clipBox.left << ", " << clipBox.top << ", " << clipBox.right << ", " << clipBox.bottom << endl;

	DrawGridGraphics(graphics, clipBox);
	
	for (short i=0; i<NIR(); i++) {
		MFCInstanceView *ir = (MFCInstanceView *)IR(i);
//		cerr << "instance " << ir->bounds.left << ", " << ir->bounds.right << endl;
		if (ir->bounds.Intersects(clipBox)) {
//			cerr << "instersects" << endl;
			ir->Draw(graphics, clipBox);
		}
	}
	for (short i=0; i<NItemR(); i++) {
		MFCEditorItemView *ir = ItemR(i);
		if (ir->type != MFCEditorItemView::DISCRETE && ir->BoundingBox().Intersects(clipBox)) {
			ir->Draw(graphics, clipBox);
		}
	}
	for (short i=0; i<NItemR(); i++) {
		MFCEditorItemView *ir = ItemR(i);
		if (ir->type == MFCEditorItemView::DISCRETE && ir->BoundingBox().Intersects(clipBox)) {
			ir->Draw(graphics, clipBox);
		}
	}
	// draw envelopes

	// draw cursor (erase old one?)
	DrawCursor(graphics, clipBox);
#else
	DrawGrid(pdc, &clipBox);
	for (short i=0; i<NIR(); i++) {
		MFCInstanceView *ir = (MFCInstanceView *)IR(i);
		ir->Draw(pdc, &clipBox);
	}
	// draw envelopes

	// draw cursor (erase old one?)
	DrawCursor(pdc, &clipBox);
#endif
}