Home | Products | Download | Purchase | Support 


   

NewMindMapLink Sample

 

 

The NewMindMapLink sample demonstrates how to create a mind - map like application, it can be used to create very complex diagram, there are over 10 types of mind - map links and you can use more than 100 exist shapes a the node for mind - map. E-XD++ is the first c++ source code kit for mind - map solution.

Steps:

1. Initial the canvas:


void CNewMindMapLinkView::DoChangeModel(CFODataModel * pModel)
{
	CFODrawView::DoChangeModel(pModel);
	// Adding your data model init codes here..
	CSize szCanvas = CSize(4000,4000);

	pModel->SetCanvasSize(szCanvas);
	pModel->SetBorderShow(FALSE);
	pModel->ShowMargin(FALSE);
	pModel->ShowGrid(FALSE);
}

void CNewMindMapLinkView::InitLinkShape()
{
	m_drawshape = m_nCurLinkType;
	m_bUpRightMode = FALSE;
	SetCurrentDrawingCursor(IDC_FO_DRAWLINK_CURSOR);
}

void CNewMindMapLinkView::OnInitialUpdate()
{
	SetCurrentModel(GetDocument()->m_pDataModel);
	CFODrawView::OnInitialUpdate();

	CNewMindMapLinkDoc* pDoc = GetDocument();
	if(pDoc->bNewDocument)
	{
		GetDocument()->m_pDataModel->InitData();
	}

	CRect rcClient;
	GetClientRect(&rcClient);
	CSize sz = GetCanvasOrginOffset();

	CSize szCanvas = GetCanvasSize();
	szCanvas -= rcClient.Size();

	if(sz.cx != 0 || sz.cy != 0)
	{
		CPoint ptScroll = CPoint((int)(sz.cx / 2.0 + szCanvas.cx/ 2.0),(int)(sz.cy / 2.0 + szCanvas.cy/ 2.0));
		DoMoveView(ptScroll);
	}

	InitLayersComboBox();
}

2. Printing and print preview:

BOOL CNewMindMapLinkView::OnPreparePrinting(CPrintInfo* pInfo)
{

	ComputePrintPosition();

	int nHorzPages = 0;
	int nVertPages = 0;

	CSize szTotal = GetCurrentModel()->GetCanvasSize();
	CSize szPrint = GetCurrentModel()->GetPrintPosition().Size();
	
	CSize m_szPageSize = szPrint;
	CSize szScrollTotal = szTotal;

	if (m_szPageSize.cx > 0)
	{
		nHorzPages = szScrollTotal.cx / m_szPageSize.cx;
		if ((szScrollTotal.cx % m_szPageSize.cx) > 0)
		{
			nHorzPages++;
		}
	}

	if (m_szPageSize.cy > 0)
	{
		nVertPages = szScrollTotal.cy / m_szPageSize.cy;
		if ((szScrollTotal.cy % m_szPageSize.cy) > 0)
		{
			nVertPages++;
		}
	}

	int nTotalPage = (nHorzPages * nVertPages);

	int nCount = 0;
	
	CRect rcPageRect;
	for(int idx=1;idx <= nTotalPage;idx++)
	{
		rcPageRect	= GetCurrentPrintPosition(idx);
		if(GetCurrentModel()->FindShapeWithIn(rcPageRect))
		{
			nCount ++;
		}
	}
	
	if(nCount == 0)
	{
		nCount = 1;
	}
	
	nTotalPage = nCount;
	
	
	GetCurrentModel()->SetTotalPrintPages(nTotalPage);
	pInfo->SetMaxPage(nTotalPage);

	// Update printers's measure.
	UpdatePrinterMeasure();

	GetCurrentModel()->UpdatePrinter();

	if (GetCurrentModel()->ValidatePrinter() != TRUE)
	{
		GetCurrentModel()->SetModifiedFlag(TRUE);
	}

	GetCurrentModel()->GetPrintDlg(pInfo->m_pPD->m_pd);

	if (pInfo->m_pPD->m_pd.hDC == NULL)
	{
		pInfo->m_pPD->CreatePrinterDC();
	}
	
	return DoPreparePrinting(pInfo);
}

[ Home | Products | Download Area | Purchase | SupportContact us ]


Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.com