/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified vwenv. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="frag">The frag.</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragLazyScripture: { // The configure method insists on trying to make an initial selection. // If there isn't something selectable there, it expands everything. vwenv.AddStringProp((int)Scripture.ScriptureTags.kflidChapterVerseSepr, this); vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragLazyBook); break; } case kfragLazyBook: { vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, kfragDummySection); break; } case kfragDummySection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, kfragDummyStText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, kfragDummyStText); break; } case kfragDummyStText: { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, m_fParaWithContent ? kfragDummyParaWithContent : kfragDummyPara); break; } case kfragDummyPara: { // Display each dummy paragraph as a rectangle an inch high, which allows us // to accurately predict the height of a known number of them. vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0); break; } case kfragDummyParaWithContent: { vwenv.OpenMappedTaggedPara(); vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) return; // not much we can display without a valid object switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); // TODO (EberhardB): The gap between the intro division and the text // division probably needs to be configurable somewhere... // Add a 24 point gap at the bottom of the intro section vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(BackColor), -1, 24000, 0); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) { return; // not much we can display without a valid object } switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); // TODO (EberhardB): The gap between the intro division and the text // division probably needs to be configurable somewhere... // Add a 24 point gap at the bottom of the intro section vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(BackColor), -1, 24000, 0); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrBook: { vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, m_stvc, (int)StTextFrags.kfrFootnote); break; } default: Debug.Assert(false); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) { return; // not much we can display without a valid object } switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is displayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)ScrFrags.kfrScripture: vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; case (int)ScrFrags.kfrSection: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; case (int)StTextFrags.kfrPara: if (m_hvosReadOnly.Contains(hvo)) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
/// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch ((ScrFrags)frag) { case ScrFrags.kfrScripture: { vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; } case ScrFrags.kfrBook: { vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, m_stvc, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); break; } case ScrFrags.kfrSection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, m_stvc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, m_stvc, (int)StTextFrags.kfrText); break; } default: Debug.Assert(false); break; } }
/// <summary></summary> public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)SampleFrags.kfrText: if (m_fontName != null && m_fontName.Length > 0) { vwenv.set_StringProperty((int)FwTextPropType.ktptFontFamily, m_fontName); } // Force to 12 point. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.OpenDiv(); vwenv.AddLazyVecItems((int)SampleTags.ktagTextParas, this, (int)SampleFrags.kfrPara); vwenv.CloseDiv(); break; case (int)SampleFrags.kfrPara: vwenv.AddStringProp((int)SampleTags.ktagParaContents, this); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) return; // not much we can display without a valid object switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. Most /// subclasses should override. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRoot: // assume the root object has been loaded (FWR-3171: and not deleted). if (hvo > 0) { var obj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo); if (obj is IReversalIndex) m_wsReversal = m_cache.ServiceLocator.WritingSystemManager.GetWsFromStr((obj as IReversalIndex).WritingSystem); vwenv.AddLazyVecItems(m_fakeFlid, this, kfragListItem); } break; case kfragListItemInner: AddTableRow(vwenv, hvo, frag); break; case kfragListItem: vwenv.AddObjProp(m_tagMe, this, kfragListItemInner); break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case 1: { // The top-level. // Enhance JohnT: add a property setting to make the key bold // Roughly, vwenv.set_IntProperty(ktptBold, ktpvEnum, kttvForceOn); // If we can get an hvo and flid, display that property of that object. int flid = 0; if (hvo != 0) { flid = m_cp.FlidFor(m_index, hvo); } if (flid != 0) { // Warning (JohnT): this option not yet tested... vwenv.AddStringProp(flid, this); return; } else { // Otherwise display a literal string straight from the policy object. vwenv.AddString(m_cp.KeyFor(m_index, hvo)); } if (m_fExpanded) { vwenv.AddLazyVecItems(m_ni.ListFlid, this, 2); } break; } case 2: { // One line of context. // Figure the index of this object in the next object out (the root). int hvoOuter, tagOuter, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tagOuter, out ihvo); int ichKey = m_ni.ContextStringStartOffset(ihvo, hvo); int cchKey = m_ni.ContextStringLength(ihvo, hvo); // Enhance JohnT: make the alignment position a function of window width. // Enhance JohnT: change background if this is the selected context line. vwenv.OpenConcPara(ichKey, ichKey + cchKey, VwConcParaOpts.kcpoDefault, 72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints. int flidKey = m_ni.ContextStringFlid(ihvo, hvo); if (flidKey == 0) { // Not tested yet. vwenv.AddString(m_ni.ContextString(ihvo, hvo)); } else { vwenv.AddStringProp(flidKey, this); } vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified vwenv. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="frag">The frag.</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case kfragLazyScripture: { // The configure method insists on trying to make an initial selection. // If there isn't something selectable there, it expands everything. vwenv.AddStringProp((int)Scripture.ScriptureTags.kflidChapterVerseSepr, this); vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragLazyBook); break; } case kfragLazyBook: { vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, kfragDummySection); break; } case kfragDummySection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, kfragDummyStText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, kfragDummyStText); break; } case kfragDummyStText: { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, m_fParaWithContent ? kfragDummyParaWithContent : kfragDummyPara); break; } case kfragDummyPara: { // Display each dummy paragraph as a rectangle an inch high, which allows us // to accurately predict the height of a known number of them. vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0); break; } case kfragDummyParaWithContent: { vwenv.OpenMappedTaggedPara(); vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. Most /// subclasses should override. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragRoot: // assume the root object has been loaded. if (hvo != 0) vwenv.AddLazyVecItems(m_fakeFlid, this, kfragListItem); break; case kfragListItemInner: AddTableRow(vwenv, hvo, frag); break; case kfragListItem: vwenv.AddObjProp(TagMe, this, kfragListItemInner); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRoot: ITsString tssWord = vwenv.DataAccess.get_StringProp(hvo, ktagCf); ITsStrBldr tsbSdRelation = m_tssSdRelation.GetBldr(); ITsStrBldr tsbLexRel = m_tssLexRelation.GetBldr(); if (tssWord != null && tssWord.Length > 0) { int ich = tsbSdRelation.Text.IndexOf("{0}"); if (ich >= 0) { tsbSdRelation.ReplaceTsString(ich, ich + 3, tssWord); } ich = tsbLexRel.Text.IndexOf("{0}"); if (ich >= 0) { tsbLexRel.ReplaceTsString(ich, ich + 3, tssWord); } } int cDomains = vwenv.DataAccess.get_VecSize(hvo, ktagDomains); int cLexRels = vwenv.DataAccess.get_VecSize(hvo, ktagLexRels); Debug.Assert(cDomains > 0 || cLexRels > 0); if (cDomains > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbSdRelation.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagDomains, this, kfragEntryList); } if (cLexRels > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbLexRel.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagLexRels, this, kfragEntryList); } break; case kfragEntryList: vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.AddStringProp(ktagName, this); vwenv.AddString(m_tssColon); vwenv.AddObjVec(ktagWords, this, kfragWords); vwenv.CloseParagraph(); break; case kfragName: vwenv.AddStringProp(ktagName, this); break; default: throw new Exception("bad case in RelatedWordsVc.Display"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrRootInPageSeq: { int tag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor, "Scripture", "FootnotesOnPage", (int)CellarModuleDefns.kcptReferenceSequence).Tag; // Get the list of footnotes to display int[] hvos = m_cache.GetVectorProperty(hvo, tag, true); if (hvos.Length > 0) { int ownerHvo = m_cache.GetOwnerOfObject(hvos[0]); // The ownerHvo should be the HVO of the book vwenv.NoteDependency(new int[] { ownerHvo }, new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, 1); } vwenv.AddObjVec(tag, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteWithinPagePara: { // Note a dependency on the footnote options so that the footnote will // be refreshed when these are changed. int[] depHvos = { hvo }; int[] depTags = { StFootnote.ktagFootnoteOptions }; vwenv.NoteDependency(depHvos, depTags, 1); // Insert the marker and reference vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteReference); // Insert (we hope only one) paragraph contents. vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)FootnoteFrags.kfrFootnoteParaWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteParaWithinPagePara: { if (!InsertParaContentsUserPrompt(vwenv, hvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); } break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrFootnoteMarker: { ScrFootnote footnote = new ScrFootnote(Cache, hvo); if (footnote.DisplayFootnoteMarker) { DisplayFootnoteMarker(vwenv, footnote); } break; } case (int)StTextFrags.kfrFootnoteReference: { ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); ITsPropsFactory tpf = TsPropsFactoryClass.Create(); ITsTextProps ttp = tpf.MakeProps(ScrStyleNames.FootnoteTargetRef, m_wsDefault, 0); ScrFootnote footnote = new ScrFootnote(m_cache, hvo); string footnoteRef = footnote.GetReference(m_wsDefault); ITsString tssRef = tsStrFactory.MakeStringWithPropsRgch(footnoteRef, footnoteRef.Length, ttp); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssRef); break; } default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { #if __MonoCS__ // TODO-Linux: Randomly m_tsf seem to have been Release. // eg Marshal.ReleaseComObject(m_tsf); // However the Dispose method isn't called (which calls the Release) // Currently unsure what is doing this need to find out - very concerning // Hack - just recreate a new TsStrFactory each time... for now // seems to stop the problem. m_tsf = TsStrFactoryClass.Create(); #endif CheckDisposed(); if (hvo == 0) return; // Can't do anything without an hvo (except crash -- see LT-9348). #if DEBUG //TimeRecorder.Begin("Display"); #endif switch (frag) { case kfragStText: // new root object for InterlinDocChild. SetupRealVernWsForDisplay(WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph, hvo, StTextTags.kflidParagraphs)); vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, kfragInterlinPara); break; case kfragInterlinPara: // Whole StTxtPara. This can be the root fragment in DE view. if (vwenv.DataAccess.get_VecSize(hvo, StTxtParaTags.kflidSegments) == 0) { vwenv.NoteDependency(new int[] { hvo }, new int[] { StTxtParaTags.kflidSegments }, 1); vwenv.AddString(m_tssEmptyPara); } else { PreferredVernWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph, hvo, StTxtParaTags.kflidSegments); // Include the plain text version of the paragraph? vwenv.AddLazyVecItems(StTxtParaTags.kflidSegments, this, kfragParaSegment); } break; case kfragParaSegment: // Don't put anything in this segment if it is a 'label' segment (typically containing a verse // number for TE). var seg = m_segRepository.GetObject(hvo); if (seg.IsLabel) break; // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. var haveFreeform = seg.FreeTranslation != null || seg.LiteralTranslation != null || seg.NotesOS.Count > 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, !haveFreeform ? 5000 : 10000); vwenv.OpenDiv(); // Enhance JohnT: determine what the overall direction of the paragraph should // be and set it. if (m_mpBundleHeight == 0) { // First time...figure it out. int dmpx, dmpyAnal, dmpyVern; vwenv.get_StringWidth(m_tssEmptyAnalysis, null, out dmpx, out dmpyAnal); vwenv.get_StringWidth(m_tssEmptyVern, null, out dmpx, out dmpyVern); m_mpBundleHeight = dmpyAnal * 4 + dmpyVern * 3; } // The interlinear bundles are not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); if (m_fRtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalRight); } vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenParagraph(); AddSegmentReference(vwenv, hvo); // Calculate and display the segment reference. AddLabelPile(vwenv, m_tsf, m_cache, true, m_fShowMorphBundles); vwenv.AddObjVecItems(SegmentTags.kflidAnalyses, this, kfragBundle); // JohnT, 1 Feb 2008. Took this out as I can see no reason for it; AddObjVecItems handles // the dependency already. Adding it just means that any change to the forms list // regenerates a higher level than needed, which contributes to a great deal of scrolling // and flashing (LT-7470). // Originally added by Eric in revision 72 on the trunk as part of handling phrases. // Eric can't see any reason we need it now, either. If you find a need to re-insert it, // please document carefully the reasons it is needed and what bad consequences follow // from removing it. //vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSegmentForms }, 1); vwenv.CloseParagraph(); // We'd get the same visual effect from just calling AddFreeformAnnotations here. But then a regenerate // such as happens when hiding or showing a prompt has to redisplay the whole segment. This initially // makes it lazy, then the lazy stuff gets expanded. In the process we may get undesired scrolling (LT-12248). // So we insert another layer of object, allowing just the freeforms to be regenerated. var flidSelf = Cache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false); vwenv.AddObjProp(flidSelf, this, kfragFreeformBundle); vwenv.CloseDiv(); break; case kfragFreeformBundle: AddFreeformAnnotations(vwenv, hvo); break; case kfragBundle: // One annotated word bundle; hvo is the IAnalysis object. // checking AllowLayout (especially in context of Undo/Redo make/break phrase) // helps prevent us from rebuilding the display until we've finished // reconstructing the data and cache. Otherwise we can crash. if (m_rootsite != null && !m_rootsite.AllowLayout) return; AddWordBundleInternal(hvo, vwenv); break; case kfragIsolatedAnalysis: // This one is used for an isolated HVO that is surely an analysis. { var wa = m_analRepository.GetObject(hvo); vwenv.AddObj(wa.Owner.Hvo, this, kfragWordformForm); if (m_fShowMorphBundles) vwenv.AddObj(hvo, this, kfragAnalysisMorphs); int chvoGlosses = wa.MeaningsOC.Count; for (int i = 0; i < m_WsList.AnalysisWsIds.Length; ++i) { SetColor(vwenv, LabelRGBFor(m_lineChoices.IndexOf(InterlinLineChoices.kflidWordGloss, m_WsList.AnalysisWsIds[i]))); if (chvoGlosses == 0) { // There are no glosses, display something indicating it is missing. vwenv.AddProp(ktagAnalysisMissingGloss, this, kfragAnalysisMissingGloss); } else { vwenv.AddObjVec(WfiAnalysisTags.kflidMeanings, this, kfragWordGlossWs + i); } } AddAnalysisPos(vwenv, hvo, hvo, -1); } break; case kfragAnalysisMorphs: int cmorphs = 0; ICmObject co = m_coRepository.GetObject(hvo); if (co is IWfiAnalysis) cmorphs = (co as IWfiAnalysis).MorphBundlesOS.Count; // We really want a variable for this...there have been pathological cases where // m_fHaveOpenedParagraph changed during the construction of the paragraph, and we want to be // sure to close the paragraph if we opened it. var openedParagraph = !m_fHaveOpenedParagraph; if (openedParagraph) vwenv.OpenParagraph(); if (cmorphs == 0) { DisplayMorphBundle(vwenv, 0); } else { vwenv.AddObjVecItems(WfiAnalysisTags.kflidMorphBundles, this, kfragMorphBundle); } if (openedParagraph) vwenv.CloseParagraph(); break; case kfragMorphType: // for export only at present, display the vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPossibiltyAnalysisName); break; case kfragPossibiltyAnalysisName: vwenv.AddStringAltMember(CmPossibilityTags.kflidName, m_cache.DefaultAnalWs, this); break; case kfragMorphBundle: // the lines of morpheme information (hvo is a WfiMorphBundle) // Make an 'inner pile' to contain the bundle of morph information. // Give it 10 points of separation from whatever follows. DisplayMorphBundle(vwenv, hvo); break; case kfragSingleInterlinearAnalysisWithLabels: /* // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. int cfreeform = vwenv.get_DataAccess().get_VecSize(hvo, ktagSegFF); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, cfreeform == 0 ? 5000 : 10000); */ vwenv.OpenDiv(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseDiv(); break; // This frag is used to display a single interlin analysis that is always left-aligned, even for RTL languages case kfragSingleInterlinearAnalysisWithLabelsLeftAlign: vwenv.OpenDiv(); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, m_leftPadding); vwenv.OpenParagraph(); vwenv.OpenInnerPile(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseInnerPile(); vwenv.CloseParagraph(); vwenv.CloseDiv(); break; //case kfragDefaultSense: // Some default sense // // NB: If the hvo is zero, then we need to go back to the normal missing sense display, after all. // // (hvo isn't zero, even for cases where there isn't even a default value.) // if (hvo > 0) // { // // Show default sense, in some other 'guess' color. // SetGuessing(vwenv, false); // foreach (int wsId in m_WsList.AnalysisWsIds) // vwenv.AddStringAltMember(LexSenseTags.kflidGloss, // wsId, this); // } // else // { // // Give up and show the missing sense row. // vwenv.AddString(m_tssMissingSense); // } // break; case kfragWordformForm: // The form of a WviWordform. vwenv.AddStringAltMember(WfiWordformTags.kflidForm, m_wsVernForDisplay, this); break; case kfragPrefix: vwenv.AddUnicodeProp(MoMorphTypeTags.kflidPrefix, m_wsVernForDisplay, this); break; case kfragPostfix: vwenv.AddUnicodeProp(MoMorphTypeTags.kflidPostfix, m_wsVernForDisplay, this); break; case kfragSenseName: // The name (gloss) of a LexSense. foreach (int wsId in m_WsList.AnalysisWsIds) vwenv.AddStringAltMember(LexSenseTags.kflidGloss, wsId, this); break; case kfragCategory: // the category of a WfiAnalysis, a part of speech; // display the Abbreviation property inherited from CmPossibility. foreach(var wsId in m_WsList.AnalysisWsIds) { vwenv.AddStringAltMember(CmPossibilityTags.kflidAbbreviation, wsId, this); } break; default: if (frag >= kfragWordGlossWs && frag < kfragWordGlossWs + m_WsList.AnalysisWsIds.Length) { // Displaying one ws of the form of a WfiGloss. int ws = m_WsList.AnalysisWsIds[frag - kfragWordGlossWs]; vwenv.AddStringAltMember(WfiGlossTags.kflidForm, ws, this); } else if (frag >= kfragLineChoices && frag < kfragLineChoices + m_lineChoices.Count) { var spec = m_lineChoices[frag - kfragLineChoices]; var ws = GetRealWsOrBestWsForContext(hvo, spec); vwenv.AddStringAltMember(spec.StringFlid, ws, this); } else if (frag >= kfragAnalysisCategoryChoices && frag < kfragAnalysisCategoryChoices + m_lineChoices.Count) { AddAnalysisPos(vwenv, hvo, hvo, frag - kfragAnalysisCategoryChoices); } else if (frag >= kfragMorphFormChoices && frag < kfragMorphFormChoices + m_lineChoices.Count) { InterlinLineSpec spec = m_lineChoices[frag - kfragMorphFormChoices]; int wsActual = GetRealWsOrBestWsForContext(hvo, spec); DisplayMorphForm(vwenv, hvo, wsActual); } else if (frag >= kfragSegFfChoices && frag < kfragSegFfChoices + m_lineChoices.Count) { AddFreeformComment(vwenv, hvo, frag - kfragSegFfChoices); } else { throw new Exception("Bad fragment ID in InterlinVc.Display"); } break; } #if DEBUG //TimeRecorder.End("Display"); #endif }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrRootInPageSeq: { int tag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor, "Scripture", "FootnotesOnPage", (int)CellarModuleDefns.kcptReferenceSequence).Tag; // Get the list of footnotes to display int[] hvos = m_cache.GetVectorProperty(hvo, tag, true); if (hvos.Length > 0) { int ownerHvo = m_cache.GetOwnerOfObject(hvos[0]); // The ownerHvo should be the HVO of the book vwenv.NoteDependency(new int[] { ownerHvo }, new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, 1); } vwenv.AddObjVec(tag, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteWithinPagePara: { // Note a dependency on the footnote options so that the footnote will // be refreshed when these are changed. int[] depHvos = { hvo }; int[] depTags = { StFootnote.ktagFootnoteOptions }; vwenv.NoteDependency(depHvos, depTags, 1); // Insert the marker and reference vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvo, this,(int)StTextFrags.kfrFootnoteReference); // Insert (we hope only one) paragraph contents. vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)FootnoteFrags.kfrFootnoteParaWithinPagePara); break; } case (int) FootnoteFrags.kfrFootnoteParaWithinPagePara: { if (!InsertParaContentsUserPrompt(vwenv, hvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); } break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrFootnoteMarker: { ScrFootnote footnote = new ScrFootnote(Cache, hvo); if (footnote.DisplayFootnoteMarker) DisplayFootnoteMarker(vwenv, footnote); break; } case (int)StTextFrags.kfrFootnoteReference: { ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); ITsPropsFactory tpf = TsPropsFactoryClass.Create(); ITsTextProps ttp = tpf.MakeProps(ScrStyleNames.FootnoteTargetRef, m_wsDefault, 0); ScrFootnote footnote = new ScrFootnote(m_cache, hvo); string footnoteRef = footnote.GetReference(m_wsDefault); ITsString tssRef = tsStrFactory.MakeStringWithPropsRgch(footnoteRef, footnoteRef.Length, ttp); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssRef); break; } default: base.Display(vwenv, hvo, frag); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Here a text is displayed by displaying its paragraphs; /// and a paragraph is displayed by invoking its style rule, making a paragraph, /// and displaying its contents. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="hvo">id of object to be displayed</param> /// <param name="frag">fragment of data</param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)StTextFrags.kfrFootnote: { if (HandleEmptyText(vwenv, hvo)) { break; } IStFootnote footnote = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>().GetObject(hvo); if (footnote.DisplayFootnoteMarker) { // We need to note this dependency here (for the update of the footnote // marker) instead of in the frag for the marker because noting the // dependency at the frag for the marker caused some weird problems // with the VwNotifiers which caused the view to sometimes update // incorrectly. (FWR-1299) It also makes more sense for it to be here // since the dependency would be on the whole footnote in either case // anyways. vwenv.NoteDependency(new int[] { footnote.Owner.Hvo }, new int[] { footnote.OwningFlid }, 1); } vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrFootnotePara); break; } case (int)StTextFrags.kfrText: { if (HandleEmptyText(vwenv, hvo)) { break; } if (hvo == 0) { return; // leave view empty, better than crashing. } if (m_fLazy) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } else { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } break; } case (int)StTextFrags.kfrFootnoteMarker: { IStFootnote footnote = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>().GetObject(hvo); if (footnote.DisplayFootnoteMarker) { DisplayFootnoteMarker(vwenv, footnote); } break; } case (int)StTextFrags.kfrLabel: { // The label is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(m_tssLabel); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); break; } case (int)StTextFrags.kfrTranslation: { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); // Display the translation, or its user prompt ICmTranslation trans = Cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); if (!InsertTranslationUserPrompt(vwenv, trans)) { vwenv.AddStringAltMember(CmTranslationTags.kflidTranslation, m_wsDefault, this); } break; } case (int)StTextFrags.kfrSegmentFreeTranslations: // Hvo is one segment of an StTxtPara. ISegment seg = Cache.ServiceLocator.GetInstance <ISegmentRepository>().GetObject(hvo); if (seg.IsLabel) { // Added dependencies to get labels to update automatically (FWR-1341, FWR-1342, FWR-1417) vwenv.NoteStringValDependency(seg.Paragraph.Hvo, StTxtParaTags.kflidContents, 0, seg.Paragraph.Contents); vwenv.NoteDependency(new [] { seg.Paragraph.Hvo }, new [] { StTxtParaTags.kflidSegments }, 1); vwenv.AddString(GetBackTransLabelText(seg)); vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 1200, 0, 0); // a narrow space, font-neutral } else { // Hvo is a segment whose Contents are the free/back translation. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(SystemColors.Window)); ITsString tssVal = seg.FreeTranslation.get_String(BackTranslationWS); if (tssVal.Length == 0 && !SuppressPrompt(hvo, SegmentTags.kflidFreeTranslation)) { vwenv.NoteDependency(new[] { hvo }, new[] { SegmentTags.kflidFreeTranslation }, 1); vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, SegmentTags.kflidFreeTranslation); // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing // into the margin. vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0); } else { ITsStrBldr bldr = tssVal.GetBldr(); bldr.Replace(0, bldr.Length, "", null); // reduce to empty string in ws. // We want it to change back to the prompt if all is deleted. vwenv.NoteStringValDependency(hvo, SegmentTags.kflidFreeTranslation, BackTranslationWS, bldr.GetString()); vwenv.AddStringAltMember(SegmentTags.kflidFreeTranslation, BackTranslationWS, this); // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty, // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run. vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0); } vwenv.AddString(OneSpaceString); } break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { if ((m_displayType & DisplayType.kLiteralStringLabels) != 0) { ITsStrFactory factory = TsStrFactoryClass.Create(); vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault)); } switch(frag) { case 1: // the root; display the subitems, first using non-lazy view, then lazy one. if ((m_displayType & DisplayType.kFootnoteDetailsSeparateParas) == DisplayType.kFootnoteDetailsSeparateParas) vwenv.AddObjVecItems(m_flid, this, 10); if ((m_displayType & DisplayType.kFootnoteDetailsSinglePara) == DisplayType.kFootnoteDetailsSinglePara) vwenv.AddObjVecItems(m_flid, this, 11); else { if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) { vwenv.AddObjVecItems(m_flid, this, 3); } if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) { vwenv.AddObjVecItems(m_flid, this, 2); } } if ((m_displayType & DisplayType.kTitle) == DisplayType.kTitle) vwenv.AddObjProp(SimpleRootsiteTestsConstants.kflidDocTitle, this, 3); if (m_displayType == DisplayType.kOuterObjDetails) vwenv.AddObjVecItems(m_flid, this, 6); break; case 2: // An StText, display paragraphs lazily if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) vwenv.AddLazyVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 4); vwenv.AddLazyVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5); break; case 3: // An StText, display paragraphs not lazily. if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 4); vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5); if ((m_displayType & DisplayType.kDuplicateParagraphs) != 0) vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5); break; case 4: // StTxtPara, display contents with top margin OpenParaIfNeeded(vwenv, hvo); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, kMarginTop); AddParagraphContents(vwenv); break; case 5: // StTxtPara, display contents without top margin OpenParaIfNeeded(vwenv, hvo); AddParagraphContents(vwenv); break; case 6: // StTxtPara, display details of our outer object int hvoOuter, tag, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); ITsString tss = TsStringHelper.MakeTSS("Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, m_wsDefault); vwenv.AddString(tss); break; case SimpleRootsiteTestsConstants.kflidDocDivisions: vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidDocDivisions, this, SimpleRootsiteTestsConstants.kflidSectionStuff); break; case SimpleRootsiteTestsConstants.kflidSectionStuff: if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) vwenv.AddObjProp(frag, this, 3); if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) vwenv.AddObjProp(frag, this, 2); break; case 7: // ScrBook vwenv.OpenDiv(); vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidDocFootnotes, this, 8); vwenv.CloseDiv(); break; case 8: // StFootnote vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 9); break; case 9: // StTxtPara vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null); break; case 10: // Display a Footnote by displaying its "FootnoteMarker" in a paragraph // by itself, followed by the sequence of paragraphs. vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidFootnoteMarker, null); vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 9); break; case 11: // Display a Footnote by displaying its "FootnoteMarker" followed by the // contents of its first paragraph (similar to the way footnotes are displayed in // real life. vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 12); break; case 12: // Footnote paragraph with marker vwenv.OpenMappedTaggedPara(); // The footnote marker is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidFootnoteMarker, null); // add a read-only space after the footnote marker vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); ITsIncStrBldr strBldr = TsIncStrBldrClass.Create(); strBldr.Append(" "); vwenv.AddString(strBldr.GetString()); vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null); vwenv.CloseParagraph(); break; default: throw new ApplicationException("Unexpected frag in DummyBasicViewVc"); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Here a text is displayed by displaying its paragraphs; /// and a paragraph is displayed by invoking its style rule, making a paragraph, /// and displaying its contents. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="hvo">id of object to be displayed</param> /// <param name="frag">fragment of data</param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case (int)StTextFrags.kfrFootnote: { if (HandleEmptyText(vwenv, hvo)) break; vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrFootnotePara); break; } case (int)StTextFrags.kfrText: { if (HandleEmptyText(vwenv, hvo)) break; if (m_fLazy) { vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } else { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } break; } case (int)StTextFrags.kfrFootnoteMarker: { StFootnote footnote = new StFootnote(Cache, hvo); if (footnote.DisplayFootnoteMarker) DisplayFootnoteMarker(vwenv); break; } case (int)StTextFrags.kfrLabel: { // The label is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(m_tssLabel); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); break; } case (int)StTextFrags.kfrTranslation: { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); // Display the translation, or its user prompt if (!InsertTranslationUserPrompt(vwenv, hvo)) { vwenv.AddStringAltMember((int)CmTranslation.CmTranslationTags.kflidTranslation, m_wsDefault, this); } break; } case (int)StTextFrags.kfrSegmentFreeTranslations: // Hvo is a CmBaseAnnotation of one segment of an StTxtPara. if (IsLabelSegment(hvo)) { CmBaseAnnotation segment = (CmBaseAnnotation)CmBaseAnnotation.CreateFromDBObject(Cache, hvo, false); vwenv.AddString(GetBackTransLabelText(segment)); vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 1200, 0, 0); // a narrow space, font-neutral } else { vwenv.AddObjProp(StTxtPara.SegmentFreeTranslationFlid(Cache), this, (int)StTextFrags.kfrFreeTrans); vwenv.AddString(OneSpaceString); } break; case (int)StTextFrags.kfrFreeTrans: // Hvo is a CmIndirectAnnotation whose Contents are the free/back translation. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(SystemColors.Window)); ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo, (int) CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS); if (tssVal.Length == 0 && !SuppressPrompt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment)) { vwenv.NoteDependency(new int[] {hvo}, new int[] {(int)CmAnnotation.CmAnnotationTags.kflidComment}, 1); vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmAnnotation.CmAnnotationTags.kflidComment); // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing // into the margin. vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0); } else { ITsStrBldr bldr = tssVal.GetBldr(); bldr.Replace(0, bldr.Length, "", null); // reduce to empty string in ws. // We want it to change back to the prompt if all is deleted. vwenv.NoteStringValDependency(hvo, (int) CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, bldr.GetString()); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, this); // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty, // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run. vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0); } break; } }
private void DisplayChartBody(IVwEnv vwenv) { vwenv.AddLazyVecItems((int)DsConstChart.DsConstChartTags.kflidRows, this, kfragChartRow); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[]{m_cache.LanguageProject.TranslatedScriptureOA.Hvo}, new[]{ScriptureTags.kflidScriptureBooks}, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); if (!PrintLayout) InsertBookSeparator(hvo, vwenv); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert (m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance<IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance<ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) picture = m_CheckedPic; else if (status == BackTranslationStatus.Finished.ToString()) picture = m_FinishedPic; else picture = m_UnfinishedPic; vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] {hvo}, new [] {CmTranslationTags.kflidStatus}, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) return; // Can't do anything without an hvo (except crash -- see LT-9348). #if DEBUG //TimeRecorder.Begin("Display"); #endif switch (frag) { case kfragText: // The whole text, root object for the InterlinDocChild. vwenv.AddObjProp((int)Text.TextTags.kflidContents, this, kfragStText); break; // case kfragTxtSection: // obsolete // // Enhance JohnT: possibly some extra space, bold the heading, or whatever? // vwenv.AddObjProp((int)TxtSection.TxtSectionTags.kflidHeading, this, kfragStText); // vwenv.AddObjProp((int)TxtSection.TxtSectionTags.kflidContents, this, kfragStText); // vwenv.AddLazyVecItems((int)TxtSection.TxtSectionTags.kflidSubsections, this, kfragTxtSection); // break; case kfragStText: // new root object for InterlinDocChild. SetupRealVernWsForDisplay(m_cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, hvo, (int)StText.StTextTags.kflidParagraphs)); vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this, kfragInterlinPara); break; case kfragInterlinPara: // Whole StTxtPara. This can be the root fragment in DE view. if (vwenv.DataAccess.get_VecSize(hvo, ktagParaSegments) == 0) { vwenv.NoteDependency(new int[] {hvo}, new int[] {ktagParaSegments}, 1); vwenv.AddString(m_tssEmptyPara); } else { PreferredVernWs = m_cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, hvo, ktagParaSegments); // Include the plain text version of the paragraph? vwenv.AddLazyVecItems(ktagParaSegments, this, kfragParaSegment); } break; case kfragParaSegment: // Don't put anything in this segment if it is a 'label' segment (typically containing a verse // number for TE). CmBaseAnnotation seg = CmObject.CreateFromDBObject(m_cache, hvo, false) as CmBaseAnnotation; StTxtPara para = seg.BeginObjectRA as StTxtPara; if (SegmentBreaker.HasLabelText(para.Contents.UnderlyingTsString, seg.BeginOffset, seg.EndOffset)) break; // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. int cfreeform = vwenv.DataAccess.get_VecSize(hvo, ktagSegFF); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, cfreeform == 0 ? 5000 : 10000); vwenv.OpenDiv(); // Enhance JohnT: determine what the overall direction of the paragraph should // be and set it. if (m_mpBundleHeight == 0) { // First time...figure it out. int dmpx, dmpyAnal, dmpyVern; vwenv.get_StringWidth(m_tssEmptyAnalysis, null, out dmpx, out dmpyAnal); vwenv.get_StringWidth(m_tssEmptyVern, null, out dmpx, out dmpyVern); m_mpBundleHeight = dmpyAnal * 4 + dmpyVern * 3; } // The interlinear bundles are not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); if (m_fRtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalRight); } vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenParagraph(); AddSegmentReference(vwenv, hvo); // Calculate and display the segment reference. AddLabelPile(vwenv, m_tsf, m_cache, true, m_fShowMorphBundles); vwenv.AddObjVecItems(ktagSegmentForms, this, kfragBundle); // JohnT, 1 Feb 2008. Took this out as I can see no reason for it; AddObjVecItems handles // the dependency already. Adding it just means that any change to the forms list // regenerates a higher level than needed, which contributes to a great deal of scrolling // and flashing (LT-7470). // Originally added by Eric in revision 72 on the trunk as part of handling phrases. // Eric can't see any reason we need it now, either. If you find a need to re-insert it, // please document carefully the reasons it is needed and what bad consequences follow // from removing it. //vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSegmentForms }, 1); vwenv.CloseParagraph(); // This puts 3 points of margin on the first FF annotation, if any. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 0); // 3000 vwenv.AddObjVec(ktagSegFF, this, kfragSegFf); vwenv.CloseDiv(); break; case kfragBundle: // One annotated word bundle; hvo is CmBaseAnnotation. // checking AllowLayout (especially in context of Undo/Redo make/break phrase) // helps prevent us from rebuilding the display until we've finished // reconstructing the data and cache. Otherwise we can crash. if (m_rootsite != null && !m_rootsite.AllowLayout) return; // set the display WS here even though it is set in the paragraph frag, since this frag might // get called on its own during a prop update int paraHvo = m_cache.GetObjProperty(hvo, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject); if (paraHvo != 0) PreferredVernWs = m_cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, paraHvo, ktagParaSegments); SetupForTwfic(hvo); // Give whatever box we make 10 points of separation from whatever follows. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); if (hvo == m_hvoSandboxAnnotation) { // Leave room for the Sandbox instead of displaying the internlinear data. // The first argument makes it invisible in case a little bit of it shows around // the sandbox. // The last argument puts the 'Baseline' of the sandbox (which aligns with the base of the // first line of text) an appropriate distance from the top of the Sandbox. This aligns it's // top line of text properly. // Enhance JohnT: 90% of font height is not always exactly right, but it's the closest // I can get wihtout a new API to get the exact ascent of the font. int dympBaseline = SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.GetFontHeightForStyle("Normal", m_stylesheet, m_wsCurrentTwfic, m_cache.LanguageWritingSystemFactoryAccessor) * 9 / 10; vwenv.AddSimpleRect(0xC0000000, // FwTextColor.kclrTransparent won't convert to uint SandboxSize.Width, SandboxSize.Height, -(SandboxSize.Height - dympBaseline)); SetupForTwfic(0); break; } // Make an 'inner pile' to contain the wordform and annotations. // 10 points below also helps space out the paragraph. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenInnerPile(); // Get the instanceOf property of the annotation and see whether it exists. If not it is // just a punctuation annotation, and we just insert the form. vwenv.NoteDependency(new int[] { hvo }, new int[] { InterlinDocChild.TagAnalysis }, 1); int hvoInstanceOf = vwenv.DataAccess.get_ObjectProp(hvo, InterlinDocChild.TagAnalysis); // Treat a non-vernacular word as unconnected to any kind of analysis. if (m_wsCurrentTwfic != m_wsVernForDisplay || !m_vernWss.Contains(m_wsCurrentTwfic)) { // Cf CanBeAnalyzed method. hvoInstanceOf = 0; } if (hvoInstanceOf == 0) { vwenv.AddStringProp(m_flidStringValue, this); } else { // It's a full Twfic annotation, display the full bundle. vwenv.AddObjProp(InterlinDocChild.TagAnalysis, this, kfragTwficAnalysis); } AddExtraTwficRows(vwenv, hvo); //vwenv.AddObjProp(ktagTwficDefault, this, kfragTwficAnalysis); vwenv.CloseInnerPile(); // revert back to the paragraph vernWs. SetupForTwfic(0); break; case kfragTwficAnalysis: new DisplayWordBundleMethod(vwenv, hvo, this, tagRealForm).Run(); break; case kfragIsolatedAnalysis: // This one is used for an isolated HVO that is surely an analyis. { // In some ways this is a simplified kfragTwficAnalysis. vwenv.AddObj(m_cache.GetOwnerOfObject(hvo), this, kfragWordformForm); if (m_fShowMorphBundles) vwenv.AddObj(hvo, this, kfragAnalysisMorphs); int chvoGlosses = m_cache.GetVectorSize(hvo, (int)WfiAnalysis.WfiAnalysisTags.kflidMeanings); for (int i = 0; i < m_WsList.AnalysisWsIds.Length; ++i) { SetColor(vwenv, LabelRGBFor(m_lineChoices.IndexOf(InterlinLineChoices.kflidWordGloss, m_WsList.AnalysisWsIds[i]))); if (chvoGlosses == 0) { // There are no glosses, display something indicating it is missing. vwenv.AddProp(ktagAnalysisMissingGloss, this, kfragAnalysisMissingGloss); } else { vwenv.AddObjVec((int)WfiAnalysis.WfiAnalysisTags.kflidMeanings, this, kfragWordGlossWs + i); } } AddAnalysisPos(vwenv, hvo, -1); } break; case kfragAnalysisMorphs: int cmorphs = m_cache.GetVectorSize(hvo, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles); if (!m_fHaveOpenedParagraph) vwenv.OpenParagraph(); if (cmorphs == 0) { DisplayMorphBundle(vwenv, 0); } else { vwenv.AddObjVecItems((int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles, this, kfragMorphBundle); } if (!m_fHaveOpenedParagraph) vwenv.CloseParagraph(); break; case kfragWordGloss: // displaying forms of a known WfiGloss. foreach (int wsId in m_WsList.AnalysisWsIds) { SetColor(vwenv, LabelRGBFor(m_lineChoices.IndexOf(InterlinLineChoices.kflidWordGloss, wsId))); vwenv.AddStringAltMember((int)WfiGloss.WfiGlossTags.kflidForm, wsId, this); } break; case kfragMorphType: // for export only at present, display the vwenv.AddObjProp((int)MoForm.MoFormTags.kflidMorphType, this, kfragPossibiltyAnalysisName); break; case kfragPossibiltyAnalysisName: vwenv.AddStringAltMember((int)CmPossibility.CmPossibilityTags.kflidName, m_cache.DefaultAnalWs, this); break; case kfragMorphBundle: // the lines of morpheme information (hvo is a WfiMorphBundle) // Make an 'inner pile' to contain the bundle of morph information. // Give it 10 points of separation from whatever follows. DisplayMorphBundle(vwenv, hvo); break; case kfragSingleInterlinearAnalysisWithLabels: /* // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. int cfreeform = vwenv.get_DataAccess().get_VecSize(hvo, ktagSegFF); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, cfreeform == 0 ? 5000 : 10000); */ vwenv.OpenDiv(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseDiv(); break; // This frag is used to display a single interlin analysis that is always left-aligned, even for RTL languages case kfragSingleInterlinearAnalysisWithLabelsLeftAlign: vwenv.OpenDiv(); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, m_leftPadding); vwenv.OpenParagraph(); vwenv.OpenInnerPile(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseInnerPile(); vwenv.CloseParagraph(); vwenv.CloseDiv(); break; //case kfragDefaultSense: // Some default sense // // NB: If the hvo is zero, then we need to go back to the normal missing sense display, after all. // // (hvo isn't zero, even for cases where there isn't even a default value.) // if (hvo > 0) // { // // Show default sense, in some other 'guess' color. // SetGuessing(vwenv, false); // foreach (int wsId in m_WsList.AnalysisWsIds) // vwenv.AddStringAltMember((int)LexSense.LexSenseTags.kflidGloss, // wsId, this); // } // else // { // // Give up and show the missing sense row. // vwenv.AddString(m_tssMissingSense); // } // break; case kfragWordformForm: // The form of a WviWordform. vwenv.AddStringAltMember((int)WfiWordform.WfiWordformTags.kflidForm, m_wsCurrentWordBundleVern, this); break; case kfragPrefix: vwenv.AddUnicodeProp((int)MoMorphType.MoMorphTypeTags.kflidPrefix, m_wsCurrentWordBundleVern, this); break; case kfragPostfix: vwenv.AddUnicodeProp((int)MoMorphType.MoMorphTypeTags.kflidPostfix, m_wsCurrentWordBundleVern, this); break; case kfragSenseName: // The name (gloss) of a LexSense. foreach (int wsId in m_WsList.AnalysisWsIds) vwenv.AddStringAltMember((int)LexSense.LexSenseTags.kflidGloss, wsId, this); break; case kfragCategory: // the category of a WfiAnalysis, a part of speech; // display the Abbreviation property inherited from CmPossibility. foreach(int wsId in m_WsList.AnalysisWsIds) { vwenv.AddStringAltMember( (int)CmPossibility.CmPossibilityTags.kflidAbbreviation, wsId, this); } break; default: if (frag >= kfragWordGlossWs && frag < kfragWordGlossWs + m_WsList.AnalysisWsIds.Length) { // Displaying one ws of the form of a WfiGloss. int ws = m_WsList.AnalysisWsIds[frag - kfragWordGlossWs]; vwenv.AddStringAltMember((int)WfiGloss.WfiGlossTags.kflidForm, ws, this); } else if (frag >= kfragLineChoices && frag < kfragLineChoices + m_lineChoices.Count) { InterlinLineSpec spec = m_lineChoices[frag - kfragLineChoices]; int ws = GetRealWs(hvo, spec); // The wrong value can be displayed in at least the LexGloss and WordCat fields, // both of which are analysis fields (at least if vern and anal ws are the same). // See LT-8682. bool fVernWs = IsVernWs(ws, spec.WritingSystem); if (m_wsCurrentTwfic != 0 && ws == m_wsCurrentTwfic && fVernWs) { if (m_cache.MainCacheAccessor.get_IsPropInCache(m_hvoCurrentTwfic, tagRealForm, (int)CellarModuleDefns.kcptString, 0)) { // overridden. vwenv.AddString(m_cache.MainCacheAccessor.get_StringProp(m_hvoCurrentTwfic, tagRealForm)); break; } } vwenv.AddStringAltMember(spec.StringFlid, ws, this); } else if (frag >= kfragAnalysisCategoryChoices && frag < kfragAnalysisCategoryChoices + m_lineChoices.Count) { AddAnalysisPos(vwenv, hvo, frag - kfragAnalysisCategoryChoices); } else if (frag >= kfragMorphFormChoices && frag < kfragMorphFormChoices + m_lineChoices.Count) { InterlinLineSpec spec = m_lineChoices[frag - kfragMorphFormChoices]; int wsActual = GetRealWs(hvo, spec); DisplayMorphForm(vwenv, hvo, wsActual); } else if (frag >= kfragSegFfChoices && frag < kfragSegFfChoices + m_lineChoices.Count) { int[] wssAnalysis = m_lineChoices.AdjacentWssAtIndex(frag - kfragSegFfChoices); if (wssAnalysis.Length == 0) break; // This is bizarre, but for the sake of paranoia... vwenv.OpenDiv(); SetParaDirectionAndAlignment(vwenv, wssAnalysis[0]); vwenv.OpenParagraph(); int hvoType = m_cache.MainCacheAccessor.get_ObjectProp(hvo, (int) CmAnnotation.CmAnnotationTags. kflidAnnotationType); string label = ""; if (hvoType == NoteSegmentDefn) label = ITextStrings.ksNote_; else if (hvoType == FtSegmentDefn) label = ITextStrings.ksFree_; else if (hvoType == LtSegmentDefn) label = ITextStrings.ksLit_; else throw new Exception("Unexpected FF annotation type"); InterlinearExporter exporter = vwenv as InterlinearExporter; if (exporter != null) { if (hvoType == NoteSegmentDefn) exporter.FreeAnnotationType = "note"; else if (hvoType == FtSegmentDefn) exporter.FreeAnnotationType = "gls"; else if (hvoType == LtSegmentDefn) exporter.FreeAnnotationType = "lit"; } SetNoteLabelProps(vwenv); ITsStrBldr tsbLabel = m_tsf.GetBldr(); tsbLabel.ReplaceTsString(0, tsbLabel.Length, m_cache.MakeUserTss(label)); tsbLabel.SetIntPropValues(0, tsbLabel.Length, (int) FwTextPropType.ktptBold, (int) FwTextPropVar.ktpvEnum, (int) FwTextToggleVal.kttvForceOn); // REVIEW: Should we set the label to a special color as well? ITsString tssLabel = tsbLabel.GetString(); int labelWidth = 0; int labelHeight; // unused if (wssAnalysis.Length > 1) vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight); if (IsWsRtl(wssAnalysis[0]) != m_fRtl) { ITsStrBldr bldr = tssLabel.GetBldr(); bldr.Replace(bldr.Length - 1, bldr.Length, null, null); ITsString tssLabelNoSpace = bldr.GetString(); // (First) analysis language is upstream; insert label at end. vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvo, wssAnalysis[0], hvoType); vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); if (wssAnalysis.Length != 1) { // Insert WS label for first line vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[0])); } vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(tssLabelNoSpace); vwenv.AddString(m_tssDir); } else { vwenv.AddString(m_tssDir); vwenv.AddString(tssLabel); vwenv.AddString(m_tssDir); if (wssAnalysis.Length == 1) { vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvo, wssAnalysis[0], hvoType); } else { SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[0])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); // label width unfortunately does not include trailing space. vwenv.AddString(m_tssDir); vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvo, wssAnalysis[0], hvoType); } } // Add any other lines, each in its appropriate direction. for (int i = 1; i < wssAnalysis.Length; i++) { vwenv.CloseParagraph(); // Indent subsequent paragraphs by the width of the main label. if (IsWsRtl(wssAnalysis[i]) != m_fRtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptTrailingIndent, (int)FwTextPropVar.ktpvMilliPoint, labelWidth); } else { vwenv.set_IntProperty((int) FwTextPropType.ktptLeadingIndent, (int) FwTextPropVar.ktpvMilliPoint, labelWidth); } SetParaDirectionAndAlignment(vwenv, wssAnalysis[i]); vwenv.OpenParagraph(); if (IsWsRtl(wssAnalysis[i]) != m_fRtl) { // upstream...reverse everything. vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); AddFreeformComment(vwenv, hvo, wssAnalysis[i], hvoType); vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); } else { vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); AddFreeformComment(vwenv, hvo, wssAnalysis[i], hvoType); } } vwenv.CloseParagraph(); vwenv.CloseDiv(); } else { throw new Exception("Bad fragment ID in InterlinVc.Display"); } break; } #if DEBUG //TimeRecorder.End("Display"); #endif }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by showing the style for each paragraph in the StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ISilDataAccess silDataAccess = vwenv.DataAccess; int wsUser = Cache.WritingSystemFactory.UserWs; switch(frag) { case (int)FootnoteFrags.kfrBook: case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); if (m_displayForFootnotes) { vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, (int)FootnoteFrags.kfrFootnoteStyles); } else { vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)ScrFrags.kfrTextStyles); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)ScrFrags.kfrTextStyles); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)ScrFrags.kfrTextStyles); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrTextStyles: { // We need to show something, since the current view code can't handle a property // containing no boxes. if (HandleEmptyText(vwenv, hvo)) break; if (m_fLazy) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); } else { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); } break; } case (int)FootnoteFrags.kfrFootnoteStyles: { if (HandleEmptyText(vwenv, hvo)) break; vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); break; } case (int)ScrFrags.kfrParaStyles: { var tsTextProps = silDataAccess.get_UnknownProp(hvo, StParaTags.kflidStyleRules) as ITsTextProps; string styleName = ScrStyleNames.Normal; if (tsTextProps != null) styleName = tsTextProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); // To insert it into the view it has to be an ITsString ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); // Last arg is writing system. Should we use English? UI writing system? // Note that when we support localization of style names this code will need // to be enhanced as the stylename from the TsTextProps will be a raw name or // GUID that the user shouldn't see. ITsString tssStyle = tsStrFactory.MakeStringRgch(styleName, styleName.Length, wsUser); // To make the pile align things properly, top and bottom margins for the // matching boxes must be the same as the original. // A 'concordance' paragraph is a way of preventing wrapping. vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(tssStyle); // Since we looked up this property directly rather than going through the vwenv (which // there seems to be no way to do for Unknown-type properties as yet), we need to tell // the view to update this paragraph if the properties of the paragraph are changed. vwenv.NoteDependency(new[] {hvo}, new[] {StParaTags.kflidStyleRules}, 1); vwenv.CloseParagraph(); break; } default: base.Display(vwenv, hvo, frag); break; } }
///// ------------------------------------------------------------------------------------ ///// <summary> ///// Gets the image padding. ///// </summary> ///// ------------------------------------------------------------------------------------ //private int GetImagePadding(IVwEnv vwenv, stdole.IPicture pic) //{ // ITsTextProps ttp = StyleUtils.CharStyleTextProps(ScrStyleNames.NotationTag, // m_cache.DefaultUserWs); // ITsStrBldr bldr = TsStrBldrClass.Create(); // bldr.Replace(0, 0, "X", ttp); // int dmpX, lineHeight; // vwenv.get_StringWidth(bldr.GetString(), ttp, out dmpX, out lineHeight); // float pixelsY = ((float)m_pixelHeights[pic] - 1f); // *m_zoomPercent; // float inchesY = pixelsY / (float)m_dpiY; // float milliptY = 72000f * inchesY; // return (int)(Math.Abs((float)lineHeight - milliptY) / 2f); //} #endregion #region Overridden methods /// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)ScrFrags.kfrScripture: { vwenv.AddObjVecItems((int)Scripture.ScriptureTags.kflidBookAnnotations, this, (int)ScrFrags.kfrBook); break; } case (int)ScrFrags.kfrBook: { // REVIEW: This dependency causes the relevent portions of the view to be // re-laid out when the underlying sequence property (kflidNotes) changes // because PropChanged never gets called for the virtual property, though // maybe it should. vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBookAnnotations.ScrBookAnnotationsTags.kflidNotes }, 1); vwenv.AddLazyVecItems(VirtualNotesTag, this, (int)NotesFrags.kfrAnnotation); break; } case (int)NotesFrags.kfrAnnotation: { DisplayAnnotationFragment(vwenv, hvo); break; } case (int)NotesFrags.kfrResponse: { DisplayResponseFragment(vwenv, hvo); break; } case (int)NotesFrags.kfrExpansion: { vwenv.OpenParagraph(); //if (m_expanderPadding == -1) // m_expanderPadding = GetImagePadding(vwenv, m_picMinus); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2500); vwenv.AddPicture((m_expandTable.ContainsKey(hvo) && m_expandTable[hvo]) ? m_picMinus : m_picPlus, m_cache.GetOwningFlidOfObject(hvo), 0, 0); vwenv.CloseParagraph(); break; } default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)StTextFrags.kfrFootnote: { // FWR-1640: Make the sequence of footnote paragraphs non-editable // since we only allow one para per footnote. This will cause // pasting multiple paragraphs to work correctly. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); base.Display(vwenv, hvo, frag); break; } case (int)FootnoteFrags.kfrScripture: { vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { (int)ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrRootInPageSeq: { vwenv.AddObjVec(ScrBookTags.kflidFootnotes, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteWithinPagePara: { // Insert the marker and reference vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvo, this,(int)StTextFrags.kfrFootnoteReference); // Insert (we hope only one) paragraph contents. vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)FootnoteFrags.kfrFootnoteParaWithinPagePara); break; } case (int) FootnoteFrags.kfrFootnoteParaWithinPagePara: { if (!InsertParaContentsUserPrompt(vwenv, hvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp(StTxtParaTags.kflidContents, null); } break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrFootnoteReference: { DisplayFootnoteReference(vwenv, hvo); break; } default: base.Display(vwenv, hvo, frag); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Here a text is displayed by displaying its paragraphs; /// and a paragraph is displayed by invoking its style rule, making a paragraph, /// and displaying its contents. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="hvo">id of object to be displayed</param> /// <param name="frag">fragment of data</param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)StTextFrags.kfrFootnote: { if (HandleEmptyText(vwenv, hvo)) { break; } vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrFootnotePara); break; } case (int)StTextFrags.kfrText: { if (HandleEmptyText(vwenv, hvo)) { break; } if (m_fLazy) { vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } else { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } break; } case (int)StTextFrags.kfrFootnoteMarker: { StFootnote footnote = new StFootnote(Cache, hvo); if (footnote.DisplayFootnoteMarker) { DisplayFootnoteMarker(vwenv); } break; } case (int)StTextFrags.kfrLabel: { // The label is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(m_tssLabel); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); break; } case (int)StTextFrags.kfrTranslation: { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); // Display the translation, or its user prompt if (!InsertTranslationUserPrompt(vwenv, hvo)) { vwenv.AddStringAltMember((int)CmTranslation.CmTranslationTags.kflidTranslation, m_wsDefault, this); } break; } case (int)StTextFrags.kfrSegmentFreeTranslations: // Hvo is a CmBaseAnnotation of one segment of an StTxtPara. if (IsLabelSegment(hvo)) { CmBaseAnnotation segment = (CmBaseAnnotation)CmBaseAnnotation.CreateFromDBObject(Cache, hvo, false); vwenv.AddString(GetBackTransLabelText(segment)); vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 1200, 0, 0); // a narrow space, font-neutral } else { vwenv.AddObjProp(StTxtPara.SegmentFreeTranslationFlid(Cache), this, (int)StTextFrags.kfrFreeTrans); vwenv.AddString(OneSpaceString); } break; case (int)StTextFrags.kfrFreeTrans: // Hvo is a CmIndirectAnnotation whose Contents are the free/back translation. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(SystemColors.Window)); ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS); if (tssVal.Length == 0 && !SuppressPrompt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment)) { vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)CmAnnotation.CmAnnotationTags.kflidComment }, 1); vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmAnnotation.CmAnnotationTags.kflidComment); // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing // into the margin. vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0); } else { ITsStrBldr bldr = tssVal.GetBldr(); bldr.Replace(0, bldr.Length, "", null); // reduce to empty string in ws. // We want it to change back to the prompt if all is deleted. vwenv.NoteStringValDependency(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, bldr.GetString()); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, this); // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty, // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run. vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0); } break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case kfrBook: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 24000); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBold, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptAlign, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextAlign.ktalCenter); vwenv.AddStringProp(ktagBookName, this); vwenv.AddLazyVecItems(ktagBookSections, this, kfrSection); break; case kfrSection: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptItalic, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.OpenParagraph(); vwenv.AddStringProp(ktagSectionTitle, this); vwenv.AddString(m_tssLeftParen); vwenv.AddStringProp(ktagSectionRefs, this); vwenv.AddString(m_tssRightParen); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagSectionParas, this, kfrDoublePara); break; case kfrDoublePara: AddDoublePara(vwenv, hvo); // Now insert an interlinear version of the paragraph. This is basically editable. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault, m_colorEditable); vwenv.OpenParagraph(); vwenv.AddObjVecItems(ktagParaBundles, this, kfrBundle); vwenv.CloseParagraph(); break; case kfrBundle: // Put a little space after each bundle to separate them. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptMarginTrailing, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenInnerPile(); vwenv.AddStringProp(ktagBundleBase, this); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBold, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 13000); vwenv.AddStringProp(ktagBundleIdiom, this); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 8000); vwenv.AddStringProp(ktagBundleLing, this); vwenv.CloseInnerPile(); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)StTextFrags.kfrFootnote: { // FWR-1640: Make the sequence of footnote paragraphs non-editable // since we only allow one para per footnote. This will cause // pasting multiple paragraphs to work correctly. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); base.Display(vwenv, hvo, frag); break; } case (int)FootnoteFrags.kfrScripture: { vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { (int)ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrRootInPageSeq: { vwenv.AddObjVec(ScrBookTags.kflidFootnotes, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteWithinPagePara: { // Insert the marker and reference vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteReference); // Insert (we hope only one) paragraph contents. vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)FootnoteFrags.kfrFootnoteParaWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteParaWithinPagePara: { if (!InsertParaContentsUserPrompt(vwenv, hvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp(StTxtParaTags.kflidContents, null); } break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrFootnoteReference: { DisplayFootnoteReference(vwenv, hvo); break; } default: base.Display(vwenv, hvo, frag); break; } }
/// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch((ScrFrags)frag) { case ScrFrags.kfrScripture: { vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; } case ScrFrags.kfrBook: { vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, m_stvc, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); break; } case ScrFrags.kfrSection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, m_stvc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, m_stvc, (int)StTextFrags.kfrText); break; } default: Debug.Assert(false); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)ScrFrags.kfrScripture: { vwenv.AddLazyVecItems(ScriptureTags.kflidBookAnnotations, this, (int)ScrFrags.kfrBook); break; } case (int)ScrFrags.kfrBook: { vwenv.AddLazyVecItems(ScrBookAnnotationsTags.kflidNotes, this, (int)NotesFrags.kfrAnnotation); break; } case (int)NotesFrags.kfrAnnotation: { DisplayAnnotationFragment(vwenv, hvo); break; } case (int)NotesFrags.kfrResponse: { DisplayResponseFragment(vwenv, hvo); break; } case (int)NotesFrags.kfrExpansion: { vwenv.OpenParagraph(); //if (m_expanderPadding == -1) // m_expanderPadding = GetImagePadding(vwenv, m_picMinus); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2500); ICmObject obj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo); vwenv.AddPicture((m_expandTable.ContainsKey(hvo) && m_expandTable[hvo]) ? m_picMinus : m_picPlus, (int)obj.OwningFlid, 0, 0); vwenv.CloseParagraph(); break; } default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.AddLazyVecItems(ScriptureTags.kflidScriptureBooks, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrBook: { vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, m_stvc, (int)StTextFrags.kfrFootnote); break; } default: Debug.Assert(false); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { if ((m_displayType & DisplayType.kLiteralStringLabels) != 0) { ITsStrFactory factory = TsStrFactoryClass.Create(); vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault)); } switch (frag) { case 1: // the root; display the subitems, first using non-lazy view, then lazy one. if ((m_displayType & DisplayType.kBookFootnoteDetailsSeparateParas) == DisplayType.kBookFootnoteDetailsSeparateParas) { vwenv.AddObjVecItems(m_flid, this, 10); } if ((m_displayType & DisplayType.kBookFootnoteDetailsSinglePara) == DisplayType.kBookFootnoteDetailsSinglePara) { vwenv.AddObjVecItems(m_flid, this, 11); } else { if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) { vwenv.AddObjVecItems(m_flid, this, 3); } if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) { vwenv.AddObjVecItems(m_flid, this, 2); } } if ((m_displayType & DisplayType.kBookTitle) == DisplayType.kBookTitle) { vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 3); } if (m_displayType == DisplayType.kOuterObjDetails) { vwenv.AddObjVecItems(m_flid, this, 6); } break; case 2: // An StText, display paragraphs lazily if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 4); } vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 5); break; case 3: // An StText, display paragraphs not lazily. if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 4); } vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5); if ((m_displayType & DisplayType.kDuplicateParagraphs) != 0) { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5); } break; case 4: // StTxtPara, display contents with top margin if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.OpenMappedPara(); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, kMarginTop); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.CloseParagraph(); } break; case 5: // StTxtPara, display contents without top margin //vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, // (int)FwTextPropVar.ktpvMilliPoint, 15000); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.OpenMappedPara(); } vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.CloseParagraph(); } break; case 6: // StTxtPara, display details of our outer object int hvoOuter, tag, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); ITsString tss = TsStringHelper.MakeTSS("Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, m_wsDefault); vwenv.AddString(tss); break; case ScrBookTags.kflidSections: vwenv.AddObjVecItems(ScrBookTags.kflidSections, this, ScrSectionTags.kflidContent); break; case ScrSectionTags.kflidHeading: case ScrSectionTags.kflidContent: if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) { vwenv.AddObjProp(frag, this, 3); } if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) { vwenv.AddObjProp(frag, this, 2); } break; case 7: // ScrBook vwenv.OpenDiv(); vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, 8); vwenv.CloseDiv(); break; case 8: // StFootnote vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 9); break; case 9: // StTxtPara vwenv.AddStringProp(StTxtParaTags.kflidContents, null); break; case 10: // Display a Footnote by displaying its "FootnoteMarker" in a paragraph // by itself, followed by the sequence of paragraphs. vwenv.AddStringProp(StFootnoteTags.kflidFootnoteMarker, null); vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 9); break; case 11: // Display a Footnote by displaying its "FootnoteMarker" followed by the // contents of its first paragraph (similar to the way footnotes are displayed in // real life. vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 12); break; case 12: // Footnote paragraph with marker vwenv.OpenMappedTaggedPara(); // The footnote marker is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); // add a read-only space after the footnote marker vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); ITsStrFactory strFactory = TsStrFactoryClass.Create(); vwenv.AddString(strFactory.MakeString(" ", DefaultWs)); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; default: throw new ApplicationException("Unexpected frag in DummyBasicViewVc"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } if (!PrintLayout) { InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert(m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) { picture = m_CheckedPic; } else if (status == BackTranslationStatus.Finished.ToString()) { picture = m_FinishedPic; } else { picture = m_UnfinishedPic; } vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] { hvo }, new [] { CmTranslationTags.kflidStatus }, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// <returns><c>true</c> if we dealt with the display, otherwise <c>false</c></returns> /// ------------------------------------------------------------------------------------ public bool Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. m_RealVc.ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { (int)ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(m_bookTag, m_RealVc, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBookTags.kflidTitle, m_RealVc, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems((int)ScrBookTags.kflidSections, m_RealVc, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBookTags.kflidFootnotes, m_RealVc, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrSectionTags.kflidHeading, m_RealVc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSectionTags.kflidContent, m_RealVc, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { // Open a table to display the vern para in column 1, and the BT para in column 2. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; vlColumn.nVal = 5000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = 2; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. true); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); if (m_RealVc.RightToLeft) { AddBtParagraph(vwenv, hvo, frag, false); AddVernParagraph(vwenv, hvo, frag, true); } else { AddVernParagraph(vwenv, hvo, frag, false); AddBtParagraph(vwenv, hvo, frag, true); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; } case (int)StTextFrags.kfrFootnoteReference: { m_RealVc.DisplayFootnoteReference(vwenv, hvo); break; } default: return(false); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by showing the style for each paragraph in the StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ISilDataAccess silDataAccess = vwenv.DataAccess; int wsUser = Cache.WritingSystemFactory.UserWs; switch (frag) { case (int)FootnoteFrags.kfrBook: case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); if (m_displayForFootnotes) { vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, (int)FootnoteFrags.kfrFootnoteStyles); } else { vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)ScrFrags.kfrTextStyles); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)ScrFrags.kfrTextStyles); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)ScrFrags.kfrTextStyles); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrTextStyles: { // We need to show something, since the current view code can't handle a property // containing no boxes. if (HandleEmptyText(vwenv, hvo)) { break; } if (m_fLazy) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); } else { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); } break; } case (int)FootnoteFrags.kfrFootnoteStyles: { if (HandleEmptyText(vwenv, hvo)) { break; } vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)ScrFrags.kfrParaStyles); break; } case (int)ScrFrags.kfrParaStyles: { var tsTextProps = silDataAccess.get_UnknownProp(hvo, StParaTags.kflidStyleRules) as ITsTextProps; string styleName = ScrStyleNames.Normal; if (tsTextProps != null) { styleName = tsTextProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); } // To insert it into the view it has to be an ITsString ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); // Last arg is writing system. Should we use English? UI writing system? // Note that when we support localization of style names this code will need // to be enhanced as the stylename from the TsTextProps will be a raw name or // GUID that the user shouldn't see. ITsString tssStyle = tsStrFactory.MakeStringRgch(styleName, styleName.Length, wsUser); // To make the pile align things properly, top and bottom margins for the // matching boxes must be the same as the original. // A 'concordance' paragraph is a way of preventing wrapping. vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(tssStyle); // Since we looked up this property directly rather than going through the vwenv (which // there seems to be no way to do for Unknown-type properties as yet), we need to tell // the view to update this paragraph if the properties of the paragraph are changed. vwenv.NoteDependency(new[] { hvo }, new[] { StParaTags.kflidStyleRules }, 1); vwenv.CloseParagraph(); break; } default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch(frag) { case 1: { // The top-level. // Enhance JohnT: add a property setting to make the key bold // Roughly, vwenv.set_IntProperty(ktptBold, ktpvEnum, kttvForceOn); // If we can get an hvo and flid, display that property of that object. int flid = 0; if (hvo != 0) { flid = m_cp.FlidFor(m_index, hvo); } if (flid != 0) { // Warning (JohnT): this option not yet tested... vwenv.AddStringProp(flid, this); return; } else { // Otherwise display a literal string straight from the policy object. vwenv.AddString(m_cp.KeyFor(m_index, hvo)); } if (m_fExpanded) { vwenv.AddLazyVecItems(m_ni.ListFlid, this, 2); } break; } case 2: { // One line of context. // Figure the index of this object in the next object out (the root). int hvoOuter, tagOuter, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tagOuter, out ihvo); int ichKey = m_ni.ContextStringStartOffset(ihvo, hvo); int cchKey = m_ni.ContextStringLength(ihvo, hvo); // Enhance JohnT: make the alignment position a function of window width. // Enhance JohnT: change background if this is the selected context line. vwenv.OpenConcPara(ichKey, ichKey + cchKey, VwConcParaOpts.kcpoDefault, 72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints. int flidKey = m_ni.ContextStringFlid(ihvo, hvo); if (flidKey == 0) { // Not tested yet. vwenv.AddString(m_ni.ContextString(ihvo, hvo)); } else { vwenv.AddStringProp(flidKey, this); } vwenv.CloseParagraph(); break; } } }
/// <summary></summary> public override void Display(IVwEnv vwenv, int hvo, int frag) { switch(frag) { case (int)SampleFrags.kfrText: if (m_fontName != null && m_fontName.Length > 0) vwenv.set_StringProperty((int)FwTextPropType.ktptFontFamily, m_fontName); // Force to 12 point. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.OpenDiv(); vwenv.AddLazyVecItems((int)SampleTags.ktagTextParas, this, (int)SampleFrags.kfrPara); vwenv.CloseDiv(); break; case (int)SampleFrags.kfrPara: vwenv.AddStringProp((int)SampleTags.ktagParaContents, this); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case kfragRoot: ITsString tssWord = vwenv.DataAccess.get_StringProp(hvo, ktagCf); ITsStrBldr tsbSdRelation = m_tssSdRelation.GetBldr(); ITsStrBldr tsbLexRel = m_tssLexRelation.GetBldr(); if (tssWord != null && tssWord.Length > 0) { int ich = tsbSdRelation.Text.IndexOf("{0}"); if (ich >= 0) tsbSdRelation.ReplaceTsString(ich, ich + 3, tssWord); ich = tsbLexRel.Text.IndexOf("{0}"); if (ich >= 0) tsbLexRel.ReplaceTsString(ich, ich + 3, tssWord); } int cDomains = vwenv.DataAccess.get_VecSize(hvo, ktagDomains); int cLexRels = vwenv.DataAccess.get_VecSize(hvo, ktagLexRels); Debug.Assert(cDomains > 0 || cLexRels > 0); if (cDomains > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbSdRelation.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagDomains, this, kfragEntryList); } if (cLexRels > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbLexRel.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagLexRels, this, kfragEntryList); } break; case kfragEntryList: vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.AddStringProp(ktagName, this); vwenv.AddString (m_tssColon); vwenv.AddObjVec(ktagWords, this, kfragWords); vwenv.CloseParagraph(); break; case kfragName: vwenv.AddStringProp(ktagName, this); break; default: throw new Exception("bad case in RelatedWordsVc.Display"); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Here a text is displayed by displaying its paragraphs; /// and a paragraph is displayed by invoking its style rule, making a paragraph, /// and displaying its contents. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="hvo">id of object to be displayed</param> /// <param name="frag">fragment of data</param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { switch(frag) { case (int)StTextFrags.kfrFootnote: { if (HandleEmptyText(vwenv, hvo)) break; IStFootnote footnote = Cache.ServiceLocator.GetInstance<IStFootnoteRepository>().GetObject(hvo); if (footnote.DisplayFootnoteMarker) { // We need to note this dependency here (for the update of the footnote // marker) instead of in the frag for the marker because noting the // dependency at the frag for the marker caused some weird problems // with the VwNotifiers which caused the view to sometimes update // incorrectly. (FWR-1299) It also makes more sense for it to be here // since the dependency would be on the whole footnote in either case // anyways. vwenv.NoteDependency(new int[] { footnote.Owner.Hvo }, new int[] { footnote.OwningFlid }, 1); } vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrFootnotePara); break; } case (int)StTextFrags.kfrText: { if (HandleEmptyText(vwenv, hvo)) break; if (hvo == 0) return; // leave view empty, better than crashing. if (m_fLazy) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } else { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); } break; } case (int)StTextFrags.kfrFootnoteMarker: { IStFootnote footnote = Cache.ServiceLocator.GetInstance<IStFootnoteRepository>().GetObject(hvo); if (footnote.DisplayFootnoteMarker) DisplayFootnoteMarker(vwenv, footnote); break; } case (int)StTextFrags.kfrLabel: { // The label is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(m_tssLabel); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); break; } case (int)StTextFrags.kfrTranslation: { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); // Display the translation, or its user prompt ICmTranslation trans = Cache.ServiceLocator.GetInstance<ICmTranslationRepository>().GetObject(hvo); if (!InsertTranslationUserPrompt(vwenv, trans)) vwenv.AddStringAltMember(CmTranslationTags.kflidTranslation, m_wsDefault, this); break; } case (int)StTextFrags.kfrSegmentFreeTranslations: // Hvo is one segment of an StTxtPara. ISegment seg = Cache.ServiceLocator.GetInstance<ISegmentRepository>().GetObject(hvo); if (seg.IsLabel) { // Added dependencies to get labels to update automatically (FWR-1341, FWR-1342, FWR-1417) vwenv.NoteStringValDependency(seg.Paragraph.Hvo, StTxtParaTags.kflidContents, 0, seg.Paragraph.Contents); vwenv.NoteDependency(new [] {seg.Paragraph.Hvo}, new [] {StTxtParaTags.kflidSegments}, 1); vwenv.AddString(GetBackTransLabelText(seg)); vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 1200, 0, 0); // a narrow space, font-neutral } else { // Hvo is a segment whose Contents are the free/back translation. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(SystemColors.Window)); ITsString tssVal = seg.FreeTranslation.get_String(BackTranslationWS); if (tssVal.Length == 0 && !SuppressPrompt(hvo, SegmentTags.kflidFreeTranslation)) { vwenv.NoteDependency(new[] { hvo }, new[] { SegmentTags.kflidFreeTranslation }, 1); vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, SegmentTags.kflidFreeTranslation); // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing // into the margin. vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0); } else { ITsStrBldr bldr = tssVal.GetBldr(); bldr.Replace(0, bldr.Length, "", null); // reduce to empty string in ws. // We want it to change back to the prompt if all is deleted. vwenv.NoteStringValDependency(hvo, SegmentTags.kflidFreeTranslation, BackTranslationWS, bldr.GetString()); vwenv.AddStringAltMember(SegmentTags.kflidFreeTranslation, BackTranslationWS, this); // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty, // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run. vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0); } vwenv.AddString(OneSpaceString); } break; } }