Exemplo n.º 1
0
LRESULT CDemoView::OnNewImage(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	CDemoDoc* pDoc = GetDocument();
	pDoc->UpdateAllViews(0,WM_USER_NEWIMAGE);
	pDoc->UpdateStatusBar();
	return 0;
}
Exemplo n.º 2
0
void CDemoView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CDemoDoc* pDoc = GetDocument();
	if (pDoc) {
		switch(pDoc->m_tool){
		case 0: // select
		case 1:
			{
#ifdef VATI_EXTENSIONS
				if ( nFlags & MK_SHIFT )
					pDoc->m_isRectSel = 1;
				else
					pDoc->m_isRectSel = 0;
#endif
				CxImage* ima = pDoc->GetImage();
				if (ima) {
					m_RefScroll = GetScrollPosition();
					m_RefPoint.x = point.x;
					m_RefPoint.y = point.y;
				}
			}
			break;
		case 2: // zoom
			if (!pDoc->GetWaitingClick()) PostMessage(WM_COMMAND,ID_VIEW_ZOOMIN);
			break;
		case 4: // tracker
			{
				if (m_tracker.HitTest(point) < 0)
				{
					CRectTracker track;
					if (track.TrackRubberBand(this, point, true)) {
						track.m_rect.NormalizeRect();
						m_tracker.m_rect = track.m_rect;
						SetImageRectSelection(pDoc,&(m_tracker.m_rect));
					} else {
						m_tracker.m_rect = CRect(0,0,0,0);
					}
				} else {
					if (m_tracker.Track(this, point, true)){
						m_tracker.m_rect.NormalizeRect();
						SetImageRectSelection(pDoc,&(m_tracker.m_rect));
					} else {
						m_tracker.m_rect = CRect(0,0,0,0);
					}
				}
				OnUpdate(0,0,0);
			}
			break;
		case 3: //text
			{
				//pDoc->m_tool=-1;
				CxImage* ima = pDoc->GetImage();
				if (ima){
					pDoc->SubmitUndo();
					long x = point.x;
					long y = point.y;
					GetImageXY(pDoc, ima, &x,&y);
#ifndef VATI_EXTENSIONS
					RGBQUAD c = ima->RGBtoRGBQUAD(pDoc->m_color);
					c.rgbReserved=255;
					ima->DrawString(0,x,y,pDoc->m_text,c,
								pDoc->m_font.lfFaceName,
								pDoc->m_font.lfHeight,
								pDoc->m_font.lfWeight,
								pDoc->m_font.lfItalic,
								pDoc->m_font.lfUnderline,
								true);
#else
					ima->DrawStringEx(0,x,y,&theApp.m_text );
#endif
				}
				Invalidate(0);
			}
			break;
		case 5: //flood fill
			{
				CxImage* ima = pDoc->GetImage();
				if (ima){
					DlgFloodFill* pDlg = ((CMainFrame *)(AfxGetApp()->m_pMainWnd))->m_pDlgFlood;
					if (pDlg){
						pDlg->UpdateData(1);
						theApp.m_FloodColor = ima->RGBtoRGBQUAD(pDlg->m_color);
						theApp.m_FloodTolerance = pDlg->m_tol;
						theApp.m_FloodOpacity = pDlg->m_opacity;
						theApp.m_FloodSelect = pDlg->m_select;
					}
					pDoc->SubmitUndo();
					long x = point.x;
					long y = point.y;
					GetImageXY(pDoc, ima, &x,&y);
					long yflip = ima->GetHeight() - y - 1;
					ima->FloodFill(x,yflip,theApp.m_FloodColor,theApp.m_FloodTolerance,theApp.m_FloodOpacity,theApp.m_FloodSelect!=0);
					Invalidate(0);
				}
			}
			break;
		}

		if (pDoc->GetWaitingClick()){
			pDoc->SetWaitingClick(0);
			CxImage* ima = pDoc->GetImage();
			if (ima) {
				long x = point.x;
				long y = point.y;
				GetImageXY(pDoc, ima, &x,&y);
				if (ima->IsInside(x,y))	{
					pDoc->SubmitUndo();
					long yflip = ima->GetHeight() - y - 1;
					ima->SetTransIndex(ima->GetPixelIndex(x,yflip));
					// <DP> RGB transparency
					ima->SetTransColor(ima->GetPixelColor(x,yflip));
					pDoc->UpdateAllViews(NULL);
				}
			}
		}
#if CXIMAGE_DEMO_SELECT
		 else {
			KillTimer(1);
			pDoc->m_NumSel=0;
			m_SelShift=0;
		}
#endif
	}
	CScrollView::OnLButtonDown(nFlags, point);
}