예제 #1
0
void AfDeFeSt::MakeRoot(IVwGraphics * pvg, ILgWritingSystemFactory * pwsf, IVwRootBox ** pprootb)
{
	AssertPtrN(pwsf);
	*pprootb = NULL;

	// Do we have a real text object? If not, make a fake one.
	int cpara = 0;
	ISilDataAccessPtr qsda = m_qcvd;
	if (m_hvoText)
		CheckHr(qsda->get_VecSize(m_hvoText, kflidStText_Paragraphs, &cpara));
	if (!cpara)
	{
		// We make a dummy text that is complete enough to edit, in a separate data access
		// object. On loss of focus, if this data access is dirty, we make corresponding
		// real objects.
		if (!m_hvoText)
			m_hvoText = -1;
		HVO hvoPara = -2;
		m_qvcdMissing.CreateInstance(CLSID_VwCacheDa);
		CheckHr(m_qvcdMissing->QueryInterface(IID_ISilDataAccess, (void **)&qsda));
		m_qvcdMissing->CacheVecProp(m_hvoText, kflidStText_Paragraphs, &hvoPara,1);
		ITsStrFactoryPtr qtsf;
		qtsf.CreateInstance(CLSID_TsStrFactory);
		ITsStringPtr qtssMissing;
		CheckHr(qtsf->MakeStringRgch(L"", 0, m_ws, &qtssMissing));
		m_qvcdMissing->CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtssMissing);
	}

	IVwRootBoxPtr qrootb;
	qrootb.CreateInstance(CLSID_VwRootBox);
	CheckHr(qrootb->SetSite(this)); // pass root site
	int frag = kfrText;
	IVwViewConstructor * pvvc = m_qstvc;
	if (pwsf)
		CheckHr(qsda->putref_WritingSystemFactory(pwsf));
	CheckHr(qrootb->putref_DataAccess(qsda));
	CheckHr(qrootb->SetRootObjects(&m_hvoText, &pvvc, &frag,
		GetLpInfo()->GetAfStylesheet(), 1));
	*pprootb = qrootb;
	(*pprootb)->AddRef();

	RecMainWnd * prmw = dynamic_cast<RecMainWnd *>(m_qadsc->MainWindow());
	if (prmw)
		prmw->RegisterRootBox(qrootb);
}
예제 #2
0
/*----------------------------------------------------------------------------------------------
	Make the root box.
----------------------------------------------------------------------------------------------*/
void TssEdit::MakeRoot(IVwGraphics * pvg, ILgWritingSystemFactory * pwsf, IVwRootBox ** pprootb)
{
	AssertPtr(pvg);
	AssertPtrN(pwsf);
	AssertPtr(pprootb);

	*pprootb = NULL;

	IVwRootBoxPtr qrootb;
	qrootb.CreateInstance(CLSID_VwRootBox);
	CheckHr(qrootb->SetSite(this));
	HVO hvo = khvoString;
	int frag = kfrString;

	// Set up a new view constructor.
	ComBool fRTL = FALSE;
	IWritingSystemPtr qws;
	Assert(pwsf == m_qwsf.Ptr());
	CheckHr(pwsf->get_EngineOrNull(m_wsBase, &qws));
	if (qws)
		CheckHr(qws->get_RightToLeft(&fRTL));
	TssEditVcPtr qtevc;
	qtevc.Attach(NewObj TssEditVc(this, m_nEditable, m_fShowTags, fRTL));

	CheckHr(m_qcda->putref_WritingSystemFactory(pwsf));
	CheckHr(qrootb->putref_DataAccess(m_qcda));

	AfMainWnd * pafw = MainWindow();
	AssertPtrN(pafw);
	AfStylesheet * pss = NULL;
	AfLpInfo * plpi = pafw->GetLpInfo();
	if (plpi)
	{
		pss = plpi->GetAfStylesheet();
		// This allows it to receive updates to style defns.
		pafw->RegisterRootBox(qrootb);
	}
	IVwViewConstructor * pvvc = qtevc;
	CheckHr(qrootb->SetRootObjects(&hvo, &pvvc, &frag, pss, 1));

	*pprootb = qrootb.Detach();
}
예제 #3
0
//----------------------------------------------------------------------------------------------
void VwTestRootSite::SetAvailWidth(IVwRootBoxPtr ptb, int iwidth)
{
	m_twWidth = iwidth;
	ptb->Layout(m_pvg, iwidth);
}