Example #1
0
void CThumbnail::OnPaint() 
{
	PAINTSTRUCT paintstruct;
	CDC* pDC;
	pDC=BeginPaint(&paintstruct);
	paintstruct.fErase=TRUE;
	CRect rect;
	GetClientRect(rect);
	// first draw scaled version of thumbnail underneath title bar
	CRButton* button;
	button=GETDLGITEM(IDJ_TITLE);
	CRect buttonrect;
	button->GetClientRect(buttonrect);
	rect.top+=buttonrect.bottom;
	// +1 prevents gaps
	int halfheight=rect.Height()/2+1;
	int offset=rect.Height()/8+1;
	int offset2=rect.Height()/16+1;
	DrawScaledBitmap(pDC,FIL_THUMBTOP,rect.left,rect.top-offset,rect.Width(),halfheight+offset2);
	DrawScaledBitmap(pDC,FIL_THUMBBOT,rect.left,rect.top+halfheight-offset2,rect.Width(),halfheight+offset2);
	// now draw the box in the appropriate position
	CRect rect2;
	m_pView->GetClientRect(rect2);
	m_boxSize=CSize((rect.right*rect2.right)/m_pView->m_size.cx,
					(rect.Height()*rect2.bottom)/m_pView->m_size.cy);
	if(m_LButtonDown==FALSE)
	{
		m_point=CPoint(((m_pView->m_scrollpoint.x*rect.right)/m_pView->m_size.cx)+(m_boxSize.cx/2),
					   ((m_pView->m_scrollpoint.y*rect.Height())/m_pView->m_size.cy)+(m_boxSize.cy/2)+rect.top);
		m_point=m_point+offsetfix;			//quick thumbnail fix
	}
	m_point.x=max(m_boxSize.cx/2,m_point.x);
	m_point.y=max((m_boxSize.cy/2)+rect.top,m_point.y);
	m_point.x=min(rect.right-(m_boxSize.cx/2),m_point.x);
	m_point.y=min(rect.bottom-(m_boxSize.cy/2),m_point.y);
	CPen pen;
	pen.CreatePen(PS_SOLID,2,RGB(255,0,0)); // red pen
	pDC->SelectObject(&pen);

	if (m_boxSize.cx<20) 
	{
		pDC->MoveTo(m_point.x-10,m_point.y);
		pDC->LineTo(m_point.x-m_boxSize.cx/2,m_point.y);
		pDC->MoveTo(m_point.x+10,m_point.y);
		pDC->LineTo(m_point.x+m_boxSize.cx/2,m_point.y);
	}
	if (m_boxSize.cy<20)
	{
		pDC->MoveTo(m_point.x,m_point.y-10);
		pDC->LineTo(m_point.x,m_point.y-m_boxSize.cy/2);
		pDC->MoveTo(m_point.x,m_point.y+10);
		pDC->LineTo(m_point.x,m_point.y+m_boxSize.cy/2);
	}
	pDC->MoveTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2));
	pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2));
	pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	EndPaint(&paintstruct);
}
Example #2
0
void CThumbnail::InvalidateMapOnly()
{
	CRect rect;
	GetClientRect(rect);
	CRButton* button;
	button=GETDLGITEM(IDJ_TITLE);
	CRect buttonrect;
	button->GetClientRect(buttonrect);
	rect.top=buttonrect.bottom;
	InvalidateRect(rect);
}
Example #3
0
void CThumbnail::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CRButton* button;
	button=GETDLGITEM(IDJ_TITLE);
	CRect buttonrect;
	button->GetClientRect(buttonrect);
	if (point.y<=buttonrect.bottom)
		CDialog::OnLButtonDown(nFlags, point);
	else
	{
		m_LButtonDown=TRUE;
		SetCapture();
		m_point=point;
//		m_point.y+=buttonrect.bottom;
		InvalidateMapOnly();
	}
}
Example #4
0
void CThumbnail::UpdateView()
{
//	if (m_pView->m_drawing) return;
	CRect rect;
	GetClientRect(rect);
	CRButton* button;
	button=GETDLGITEM(IDJ_TITLE);
	CRect buttonrect;
	button->GetClientRect(buttonrect);
	rect.top=buttonrect.bottom;
//	CPoint oldscrollpoint=m_pView->m_scrollpoint;
	m_pView->m_scrollpoint=CPoint((((m_point.x-(m_boxSize.cx/2))*m_pView->m_size.cx)/rect.right)+1,
								  (((m_point.y-(m_boxSize.cy/2)-rect.top)*m_pView->m_size.cy)/(rect.Height()))+1);
	if (m_pView->m_scrollpoint.x<0) m_pView->m_scrollpoint.x=0;
	if (m_pView->m_scrollpoint.y<0) m_pView->m_scrollpoint.y=0;
//	if (m_pView->m_scrollpoint!=oldscrollpoint)
//	{
//		m_pView->m_drawing=TRUE;
//		m_pView->UpdateScrollbars();
//		m_pView->m_mapdlg.ScrollWindow(oldscrollpoint.x-m_pView->m_scrollpoint.x,oldscrollpoint.y-m_pView->m_scrollpoint.y);
//	}
	m_pView->m_mapdlg.Invalidate();
	m_pView->UpdateScrollbars();
}