/// ----------------------------------------------------------------------------------- /// <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 1: // LexEntry vwenv.OpenParagraph(); vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, 2); vwenv.AddObjVecItems(LexEntryTags.kflidSenses, this, 3); vwenv.CloseParagraph(); break; case 2: // MoForm vwenv.AddStringAltMember(MoFormTags.kflidForm, m_cache.DefaultVernWs, this); NoteItemWidth(vwenv, hvo, MoFormTags.kflidForm, m_cache.DefaultVernWs); break; case 3: // LexSense vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this); NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs); int flid = m_cache.MetaDataCacheAccessor.GetFieldId("LexSense", "LexSenseReferences", false); vwenv.AddObjVecItems(flid, this, 4); break; case 4: // LexReference vwenv.AddObjVecItems(LexReferenceTags.kflidTargets, this, 5); break; case 5: // target of lex reference, which in our test data is made to be a sense vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this); NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs); 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) { CheckDisposed(); int hvoOuter, tag, ihvo; ITsString tss; switch (frag) { case 1: // A ScrBook; display the title. vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, 2); break; case 2: // An StText; display the paragraphs. vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringHelper.MakeTSS( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, InMemoryFdoCache.s_wsHvos.Fr); vwenv.AddString(tss); vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 3); break; case 3: // StTxtPara, display details of our outer object vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringHelper.MakeTSS( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, InMemoryFdoCache.s_wsHvos.Fr); vwenv.AddString(tss); break; default: throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc"); } }
/// ------------------------------------------------------------------------------------ /// <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> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { int frWs = vwenv.DataAccess.WritingSystemFactory.GetWsFromStr("fr"); int hvoOuter, tag, ihvo; ITsString tss; switch (frag) { case 1: // A ScrBook; display the title. vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 2); break; case 2: // An StText; display the paragraphs. vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringUtils.MakeString( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, frWs); vwenv.AddString(tss); vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 3); break; case 3: // StTxtPara, display details of our outer object vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringUtils.MakeString( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, frWs); vwenv.AddString(tss); break; default: throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonAnnotations: if (hvo == 0) { return; } vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.AnnotationListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: if (m_ribbon.SelLimAnn == hvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); 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> /// 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 kfragScrFootnotes: { vwenv.AddObjVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragBookFootnotes); break; } case kfragBookFootnotes: { vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this, kfragFootnote); break; } case kfragFootnote: { // Display each dummy footnote as a rectangle a half inch high, which allows us // to accurately predict the height of a known number of them. Also put in a very // short editable string, which we use for some other tests, but should not // affect the paragraph height. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 10); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 5); vwenv.OpenParagraph(); if (m_fWantStrings) vwenv.AddStringProp((int)StFootnote.StFootnoteTags.kflidFootnoteMarker, this); vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch / 2, MiscUtils.kdzmpInch / 2, 0); vwenv.CloseParagraph(); 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) { CheckDisposed(); switch (frag) { case 1: //The root is an StText, display paragraphs not lazily. vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 2); break; case 2: // StTxtPara, display contents vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); break; default: throw new ApplicationException("Unexpected frag in SimpleViewVc"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonWordforms: if (hvo == 0) { return; } if (m_ribbon.IsRightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); } vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.OccurenceListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: // Review: will this lead to multiple spurious blue lines? var realHvo = (m_ribbon.Decorator as InterlinRibbonDecorator).OccurrenceFromHvo(hvo).Analysis.Hvo; if (m_ribbon.SelLimOccurrence != null && m_ribbon.SelLimOccurrence.Analysis.Hvo == realHvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case InterlinearView.kfrText: vwenv.OpenParagraph(); vwenv.AddObjVecItems(InterlinearView.ktagText_Words, this, InterlinearView.kfrWord); vwenv.CloseParagraph(); break; case InterlinearView.kfrWord: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptMarginTrailing, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); vwenv.AddStringProp(InterlinearView.ktagWord_Form, this); vwenv.AddStringProp(InterlinearView.ktagWord_Type, this); vwenv.CloseInnerPile(); 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; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonWordforms: if (hvo == 0) return; if (m_ribbon.IsRightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); } vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.OccurenceListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: // Review: will this lead to multiple spurious blue lines? var realHvo = (m_ribbon.Decorator as InterlinRibbonDecorator).OccurrenceFromHvo(hvo).Analysis.Hvo; if (m_ribbon.SelLimOccurrence != null && m_ribbon.SelLimOccurrence.Analysis.Hvo == realHvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } 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. /// 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) { switch (frag) { case kfragPrintChart: // the whole chart with headings for printing. if (hvo == 0) return; PrintColumnGroupHeaders(hvo, vwenv); PrintIndividualColumnHeaders(hvo, vwenv); // Rest is same as kfragChart DisplayChartBody(vwenv); break; case kfragTemplateHeader: // Display the template as group headers. vwenv.AddObjVecItems(CmPossibilityTags.kflidSubPossibilities, this, kfragColumnGroupHeader); break; // This is only used for printing, the headers in the screen version are a separate control. case kfragColumnGroupHeader: var ccols = vwenv.DataAccess.get_VecSize(hvo, CmPossibilityTags.kflidSubPossibilities); // If there are no subitems, we still want a blank cell as a placeholder. MakeCellsMethod.OpenStandardCell(vwenv, Math.Max(ccols, 1), true); if (ccols > 0) { // It's a group, include its name var possGroup = m_cache.ServiceLocator.GetInstance<ICmPossibilityRepository>().GetObject(hvo); vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalCenter); vwenv.OpenParagraph(); vwenv.AddString(possGroup.Name.BestAnalysisAlternative); vwenv.CloseParagraph(); } vwenv.CloseTableCell(); break; case kfragChart: // the whole chart, a DsConstChart. if (hvo == 0) return; DisplayChartBody(vwenv); break; case kfragChartRow: // one row, a ConstChartRow { MakeTableAndRowWithStdWidths(vwenv, hvo, false); MakeCells(vwenv, hvo); vwenv.CloseTableRow(); vwenv.CloseTable(); } break; case kfragCellPart: // a single group of words, the contents of one cell. if (m_chart.Logic.IsWordGroup(hvo)) DisplayWordforms(vwenv, hvo); else { // it's a moved text or clause reference placeholder. int hvoClause; if (m_chart.Logic.IsClausePlaceholder(hvo, out hvoClause)) DisplayClausePlaceholder(vwenv, hvoClause); else DisplayMovedTextTag(hvo, vwenv); } break; case kfragMovedTextCellPart: // a single group of words (ConstChartWordGroup), // the contents of one cell, which is considered moved-within-line. // Can't be a placeholder. var formatTag = m_chart.Logic.MovedTextTag(hvo); ApplyFormatting(vwenv, formatTag); vwenv.OpenSpan(); InsertOpenBracket(vwenv, formatTag); DisplayWordforms(vwenv, hvo); InsertCloseBracket(vwenv, formatTag); vwenv.CloseSpan(); break; case kfragChartListItem: // a single ConstChartTag, referring to a list item. // can't be a placeholder. ApplyFormatting(vwenv, "marker"); vwenv.OpenSpan(); InsertOpenBracket(vwenv, "marker"); vwenv.AddObjProp(ConstChartTagTags.kflidTag, this, kfragPossibility); InsertCloseBracket(vwenv, "marker"); vwenv.CloseSpan(); break; case kfragPossibility: // A CmPossibility, show it's abbreviation var flid = CmPossibilityTags.kflidAbbreviation; var retWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, flid); if (retWs == 0) { // No Abbreviation! Switch to Name flid = CmPossibilityTags.kflidName; retWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, flid); } // Unless we didn't get anything, go ahead and insert the best option we found. if (retWs != 0) vwenv.AddStringAltMember(flid, retWs, this); break; case kfragBundle: // One annotated word bundle; hvo is IAnalysis object. Overrides behavior of InterlinVc AddWordBundleInternal(hvo, vwenv); break; case kfragNotesString: // notes text vwenv.AddStringProp(ConstChartRowTags.kflidNotes, this); break; case kfragComment: // hvo is a ConstChartRow vwenv.AddStringProp(ConstChartRowTags.kflidLabel, this); break; case kfragMTMarker: var mtt = m_partRepo.GetObject(vwenv.OpenObject) as IConstChartMovedTextMarker; Debug.Assert(mtt != null, "Invalid MovedTextMarker?"); vwenv.AddString(mtt.Preposed ? m_sMovedTextBefore : m_sMovedTextAfter); // Need to regenerate this if the row my WordGroup is in changes. vwenv.NoteDependency(new[] {mtt.WordGroupRA.Owner.Hvo}, new int[] {ConstChartRowTags.kflidCells}, 1); break; default: base.Display(vwenv, hvo, frag); break; } }
protected virtual void AddFreeformAnnotations(IVwEnv vwenv, int hvoSeg) { // Add them in the order specified. Each iteration adds a group with the same flid but (typically) // different writing systems. for (int ispec = m_lineChoices.FirstFreeformIndex; ispec < m_lineChoices.Count; ispec += m_lineChoices.AdjacentWssAtIndex(ispec).Length) { int flid = m_lineChoices[ispec].Flid; switch(flid) { case InterlinLineChoices.kflidFreeTrans: case InterlinLineChoices.kflidLitTrans: // These are properties of the current object. AddFreeformComment(vwenv, hvoSeg, ispec); break; case InterlinLineChoices.kflidNote: // There's a sequence of these, we use a trick with the frag to indicate which // index into line choices we want to use to display each of them. vwenv.AddObjVecItems(SegmentTags.kflidNotes, this, kfragSegFfChoices + ispec); break; default: break; // unknown type, ignore it. } } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { int userWs = m_cache.DefaultUserWs; switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance <IMoAffixProcessRepository>().GetObject(hvo); int maxNumLines = GetMaxNumLines(); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(3, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength inputLen; inputLen.nVal = 0; inputLen.unit = VwUnit.kunPoint1000; int indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv); int inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv); VwLength headerLen; headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000; headerLen.unit = VwUnit.kunPoint1000; inputLen.nVal += headerLen.nVal; VwLength leftEmptyLen; leftEmptyLen.nVal = 8000 + (PileMargin * 2) + 2000; leftEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += leftEmptyLen.nVal; var ctxtLens = new VwLength[m_rule.InputOS.Count]; vwenv.NoteDependency(new[] { m_rule.Hvo }, new[] { MoAffixProcessTags.kflidInput }, 1); for (int i = 0; i < m_rule.InputOS.Count; i++) { int idxWidth = GetStrWidth(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv); int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv); ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000; ctxtLens[i].unit = VwUnit.kunPoint1000; inputLen.nVal += ctxtLens[i].nVal; } VwLength rightEmptyLen; rightEmptyLen.nVal = 8000 + (PileMargin * 2) + 1000; rightEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += rightEmptyLen.nVal; vwenv.MakeColumns(1, inputLen); VwLength arrowLen; arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000; arrowLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, arrowLen); VwLength outputLen; outputLen.nVal = 1; outputLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(1, leftEmptyLen); foreach (VwLength ctxtLen in ctxtLens) { vwenv.MakeColumns(1, ctxtLen); } vwenv.MakeColumns(1, rightEmptyLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left empty cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty); CloseSingleLinePile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input context cells vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput); // input right empty cell vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEmpty, this, kfragEmpty); CloseSingleLinePile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // index header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_indexStr); vwenv.CloseTableCell(); // index left empty cell vwenv.Props = m_indexProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // index cells for (int i = 0; i < m_rule.InputOS.Count; i++) { vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs)); vwenv.CloseTableCell(); } // index right empty cell vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); // double arrow cell vwenv.Props = m_arrowProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_doubleArrow); vwenv.CloseTableCell(); // result table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // result header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // result cell vwenv.Props = m_resultProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.OutputOS.Count == 0) { vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty); } else { vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRuleMapping: var mapping = m_cache.ServiceLocator.GetInstance <IMoRuleMappingRepository>().GetObject(hvo); switch (mapping.ClassID) { case MoCopyFromInputTags.kClassId: var copy = (IMoCopyFromInput)mapping; OpenSingleLinePile(vwenv, GetOutputMaxNumLines()); if (copy.ContentRA == null) { vwenv.AddProp(ktagIndex, this, 0); } else { vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1); } CloseSingleLinePile(vwenv); break; case MoInsertPhonesTags.kClassId: OpenSingleLinePile(vwenv, GetOutputMaxNumLines()); vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit); CloseSingleLinePile(vwenv); break; case MoModifyFromInputTags.kClassId: var modify = (IMoModifyFromInput)mapping; int outputMaxNumLines = GetOutputMaxNumLines(); int numLines = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count; // index pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.OpenParagraph(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace); if (modify.ContentRA == null) { vwenv.AddProp(ktagIndex, this, 0); } else { vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1); } vwenv.CloseParagraph(); vwenv.CloseInnerPile(); // left bracket pile // right align brackets in left bracket pile, since the index could have a greater width, then the bracket if (numLines == 1) { vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket); vwenv.CloseInnerPile(); } else { vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); } // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - numLines, vwenv); if (numLines == 0) { vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions); } else { vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC); } vwenv.CloseInnerPile(); // right bracket pile if (numLines == 1) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.OpenInnerPile(); vwenv.AddProp(ktagRightBoundary, this, kfragRightBracket); vwenv.CloseInnerPile(); } else { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - numLines, vwenv); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } break; } 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> /// Insert the back translation segments. TeStVc overrides to make sure they are loaded properly. /// </summary> protected virtual void InsertBtSegments(StVc vc, IVwEnv vwenv, int hvo) { vwenv.AddObjVecItems(StTxtPara.SegmentsFlid(Cache), vc, (int)StTextFrags.kfrSegmentFreeTranslations); }
/// ----------------------------------------------------------------------------------- /// <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) { case kfragRHS: m_rhs = m_cache.ServiceLocator.GetInstance<IPhSegRuleRHSRepository>().GetObject(hvo); var rule = m_rhs.OwningRule; if (rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = GetMaxNumLines(); int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.MetaDataCacheAccessor.GetFieldId2(PhSegRuleRHSTags.kClassId, "OwningRule", false), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.StrucChangeOS.Count > 0) { vwenv.AddObjVecItems(PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { vwenv.NoteDependency(new[] {hvo}, new[] {PhSegRuleRHSTags.kflidStrucChange}, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.LeftContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidLeftContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.RightContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidRightContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_rhs.OwningRule.StrucDescOS.Count > 0) { vwenv.AddObjVecItems(PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenSingleLinePile(vwenv, GetMaxNumLines(), false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } 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) { CheckDisposed(); switch (frag) { case kfragContext: IPhContextOrVar ctxtOrVar = PhContextOrVar.CreateFromDBObject(m_cache, hvo); bool isOuterIterCtxt = false; // are we inside an iteration context? this is important since we only open a context pile if we are not // in an iteration context, since an iteration context does it for us if (vwenv.EmbeddingLevel > 0) { int outerHvo, outerTag, outerIndex; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex); isOuterIterCtxt = m_cache.GetClassOfObject(outerHvo) == PhIterationContext.kclsidPhIterationContext; } switch (ctxtOrVar.ClassID) { case PhSequenceContext.kclsidPhSequenceContext: if (m_cache.GetVectorSize(hvo, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) > 0) { vwenv.AddObjVecItems((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragEmpty); CloseContextPile(vwenv, false); } break; case PhSimpleContextNC.kclsidPhSimpleContextNC: IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC; if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures) { // Natural class simple context with a feature-based natural class IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures; int numLines = GetNumLines(ncCtxt); if (numLines == 0) { if (!isOuterIterCtxt) { OpenContextPile(vwenv); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } else if (numLines == 1) { if (!isOuterIterCtxt) { OpenContextPile(vwenv); } // use normal brackets for a single line context vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); // special consonant and vowel natural classes only display the abbreviation if (natClass.Abbreviation.AnalysisDefaultWritingSystem == "C" || natClass.Abbreviation.AnalysisDefaultWritingSystem == "V") { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { if (natClass.FeaturesOAHvo != 0 && natClass.FeaturesOA.FeatureSpecsOC.Count > 0) { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); } else if (ncCtxt.PlusConstrRS.Count > 0) { vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); } else { vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); } } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } else { // multiline context // left bracket pile int maxNumLines = MaxNumLines; vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature and variable pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, vwenv); vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; if (!isOuterIterCtxt) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); } vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv); vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } } else { // natural class context with segment-based natural class if (!isOuterIterCtxt) { OpenContextPile(vwenv); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); if (ncCtxt.FeatureStructureRAHvo != 0) { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } break; case PhIterationContext.kclsidPhIterationContext: IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext; if (iterCtxt.MemberRAHvo != 0) { int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext); if (numLines > 1) { vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); DisplayIterCtxt(iterCtxt, numLines, vwenv); } else { OpenContextPile(vwenv); if (iterCtxt.MemberRA.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC) { vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); } else { vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen); vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen); } DisplayIterCtxt(iterCtxt, 1, vwenv); // Views doesn't handle selection properly when we have an inner pile with strings on either side, // so we don't add a zero-width space at the end CloseContextPile(vwenv, false); } } else { OpenContextPile(vwenv); vwenv.AddProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragQuestions); CloseContextPile(vwenv); } break; case PhSimpleContextSeg.kclsidPhSimpleContextSeg: if (!isOuterIterCtxt) { OpenContextPile(vwenv); } if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure) != 0) { vwenv.AddObjProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseContextPile(vwenv); } break; case PhSimpleContextBdry.kclsidPhSimpleContextBdry: if (!isOuterIterCtxt) { OpenContextPile(vwenv); } if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure) != 0) { vwenv.AddObjProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseContextPile(vwenv); } break; case PhVariable.kclsidPhVariable: OpenContextPile(vwenv); vwenv.AddProp(ktagXVariable, this, kfragXVariable); CloseContextPile(vwenv); break; } break; case kfragNC: int ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation); if (ncWs != 0) { vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, ncWs, this); } else { ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidName); if (ncWs != 0) { vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidName, ncWs, this); } else { vwenv.AddProp((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions); } } break; case kfragTerminalUnit: int tuWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstVern, hvo, (int)PhTerminalUnit.PhTerminalUnitTags.kflidName); if (tuWs != 0) { vwenv.AddStringAltMember((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, tuWs, this); } else { vwenv.AddProp((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, this, kfragQuestions); } break; case kfragFeatNC: vwenv.AddObjProp((int)PhNCFeatures.PhNCFeaturesTags.kflidFeatures, this, kfragFeats); break; case kfragFeats: vwenv.AddObjVecItems((int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature); break; case kfragFeature: vwenv.AddProp(ktagFeature, this, kfragFeatureLine); break; case kfragPlusVariable: vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine); break; case kfragMinusVariable: vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonAnnotations: if (hvo == 0) return; vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.AnnotationListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: if (m_ribbon.SelLimAnn == hvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert the body of a paragraph. This is normally (with fApplyProps true) the body /// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses /// need to separate this from applying the properties. /// </summary> /// <param name="vwenv"></param> /// <param name="paraHvo"></param> /// <param name="frag"></param> /// <param name="fApplyProps"></param> /// <param name="contentType"></param> /// <param name="vc">The view constructor used to create the paragraphs</param> /// ------------------------------------------------------------------------------------ protected void InsertParagraphBody(IVwEnv vwenv, int paraHvo, int frag, bool fApplyProps, ContentTypes contentType, StVc vc) { vc.SetupWsAndDirectionForPara(vwenv, paraHvo); if (fApplyProps) { ApplyParagraphStyleProps(vwenv, paraHvo, vc); } // This was causing assertions in the layoutmgr // TODO (TE-5777): Should be able to do this with an in-memory stylesheet. // if (DisplayTranslation) // { // // display the back translation text as double spaced // vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight, // (int)FwTextPropVar.ktpvRelative, 20000); // } // The body of the paragraph is either editable or not. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, vc.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); // Make the paragraph containing the paragraph contents. OpenPara(vwenv, paraHvo); // Cause a regenerate when the style changes...this is mainly used for Undo. vwenv.NoteDependency(new[] { paraHvo }, new[] { StParaTags.kflidStyleRules }, 1); // Insert the label if it is the first paragraph. if (vc.Label != null) { int lev = vwenv.EmbeddingLevel; int hvoOuter; int ihvoItem; int tagOuter; vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem); if (ihvoItem == 0) { vwenv.AddObj(paraHvo, vc, (int)StTextFrags.kfrLabel); } } if (frag == (int)StTextFrags.kfrFootnotePara) { int lev = vwenv.EmbeddingLevel; int hvoOuter; int ihvoItem; int tagOuter; vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem); // Note a dependency on the footnote options so that the footnote will // be refreshed when these are changed. // If this is the 1st paragraph in the footnote... if (ihvoItem == 0) { vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteReference); } } if (contentType == ContentTypes.kctSimpleBT) { // If a translation is being shown instead of the paragraph, then show it instead // of the text of the paragraph. vwenv.AddObj(GetTranslationForPara(paraHvo), vc, (int)StTextFrags.kfrTranslation); if (!PrintLayout) { // This dependency is here so that the "Missing" prompt will be added to the // view when the first character is typed in the contents. But to solve the // problem with losing the IP when typing (FWR-1415), the dependency is not // added in print layout views. The missing prompt seems less of a problem // than the problem with typing. vwenv.NoteDependency(new[] { paraHvo }, new[] { StTxtParaTags.kflidContents }, 1); } } else if (contentType == ContentTypes.kctSegmentBT) { vwenv.AddObjVecItems(StTxtParaTags.kflidSegments, vc, (int)StTextFrags.kfrSegmentFreeTranslations); } else if (!InsertParaContentsUserPrompt(vwenv, paraHvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp(StTxtParaTags.kflidContents, null); } // Display an "end-of-paragraph" marker if needed InsertEndOfParaMarks(vwenv, paraHvo); vwenv.CloseParagraph(); }
/// ------------------------------------------------------------------------------------ /// <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> /// Displays the list of items in the list box. /// </summary> /// <param name="vwenv">The view environment</param> /// ------------------------------------------------------------------------------------ protected virtual void DisplayList(IVwEnv vwenv) { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)InnerFwListBox.ktagItems, this, (int)InnerFwListBox.kfragItems); vwenv.CloseDiv(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { int frWs = vwenv.DataAccess.WritingSystemFactory.GetWsFromStr("fr"); int hvoOuter, tag, ihvo; ITsString tss; switch (frag) { case 1: // A ScrBook; display the title. vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 2); break; case 2: // An StText; display the paragraphs. vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringHelper.MakeTSS( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, frWs); vwenv.AddString(tss); vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 3); break; case 3: // StTxtPara, display details of our outer object vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); tss = TsStringHelper.MakeTSS( "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, frWs); vwenv.AddString(tss); break; default: throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc"); } }
/// ------------------------------------------------------------------------------------ /// <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.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. /// 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) { var tsf = m_cache.TsStrFactory; var userWs = m_cache.DefaultUserWs; switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance<IMoAffixProcessRepository>().GetObject(hvo); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(3, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength inputLen; inputLen.nVal = 0; inputLen.unit = VwUnit.kunPoint1000; int indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv); int inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv); VwLength headerLen; headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000; headerLen.unit = VwUnit.kunPoint1000; inputLen.nVal += headerLen.nVal; VwLength leftEmptyLen; leftEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 2000; leftEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += leftEmptyLen.nVal; var ctxtLens = new VwLength[m_rule.InputOS.Count]; vwenv.NoteDependency(new[] {m_rule.Hvo}, new[] {MoAffixProcessTags.kflidInput}, 1 ); for (int i = 0; i < m_rule.InputOS.Count; i++) { int idxWidth = GetStrWidth(tsf.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv); int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv); ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000; ctxtLens[i].unit = VwUnit.kunPoint1000; inputLen.nVal += ctxtLens[i].nVal; } VwLength rightEmptyLen; rightEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 1000; rightEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += rightEmptyLen.nVal; vwenv.MakeColumns(1, inputLen); VwLength arrowLen; arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000; arrowLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, arrowLen); VwLength outputLen; outputLen.nVal = 1; outputLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(1, leftEmptyLen); foreach (VwLength ctxtLen in ctxtLens) vwenv.MakeColumns(1, ctxtLen); vwenv.MakeColumns(1, rightEmptyLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left empty cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty); CloseContextPile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input context cells vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput); // input right empty cell vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEmpty, this, kfragEmpty); CloseContextPile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // index header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_indexStr); vwenv.CloseTableCell(); // index left empty cell vwenv.Props = m_indexProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // index cells for (int i = 0; i < m_rule.InputOS.Count; i++) { vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(tsf.MakeString(Convert.ToString(i + 1), userWs)); vwenv.CloseTableCell(); } // index right empty cell vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); // double arrow cell vwenv.Props = m_arrowProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_doubleArrow); vwenv.CloseTableCell(); // result table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // result header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // result cell vwenv.Props = m_resultProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.OutputOS.Count == 0) vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty); else vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRuleMapping: var mapping = m_cache.ServiceLocator.GetInstance<IMoRuleMappingRepository>().GetObject(hvo); switch (mapping.ClassID) { case MoCopyFromInputTags.kClassId: var copy = (IMoCopyFromInput) mapping; OpenIndexPile(vwenv); if (copy.ContentRA == null) vwenv.AddProp(ktagIndex, this, 0); else vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1); CloseIndexPile(vwenv); break; case MoInsertPhonesTags.kClassId: OpenIndexPile(vwenv); vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit); CloseIndexPile(vwenv); break; case MoModifyFromInputTags.kClassId: var modify = (IMoModifyFromInput) mapping; var numLines = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count; // left bracket pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace); // put index in the left bracket pile if (modify.ContentRA == null) vwenv.AddProp(ktagIndex, this, 0); else vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1); // right align brackets in left bracket pile, since the index could have a greater width, then the bracket if (numLines > 1) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook); } else { vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket); } vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(1, vwenv); if (numLines == 0) vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions); else vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC); vwenv.CloseInnerPile(); // right bracket pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragSpace); if (numLines > 1) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketLowHook); } else { vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracket); } vwenv.CloseInnerPile(); break; } 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> /// /// </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 1: //The root is an StText, display paragraphs not lazily. vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 2); break; case 2: // StTxtPara, display contents vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); break; default: throw new ApplicationException("Unexpected frag in SimpleViewVc"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragContext: var ctxtOrVar = m_cache.ServiceLocator.GetInstance<IPhContextOrVarRepository>().GetObject(hvo); bool isOuterIterCtxt = false; // are we inside an iteration context? this is important since we only open a context pile if we are not // in an iteration context, since an iteration context does it for us if (vwenv.EmbeddingLevel > 0) { int outerHvo, outerTag, outerIndex; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex); var outerObj = m_cache.ServiceLocator.GetObject(outerHvo); isOuterIterCtxt = outerObj.ClassID == PhIterationContextTags.kClassId; } switch (ctxtOrVar.ClassID) { case PhSequenceContextTags.kClassId: var seqCtxt = ctxtOrVar as IPhSequenceContext; if (seqCtxt.MembersRS.Count > 0) { vwenv.AddObjVecItems(PhSequenceContextTags.kflidMembers, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSequenceContextTags.kflidMembers, this, kfragEmpty); CloseContextPile(vwenv, false); } break; case PhSimpleContextNCTags.kClassId: var ncCtxt = ctxtOrVar as IPhSimpleContextNC; if (ncCtxt.FeatureStructureRA != null && ncCtxt.FeatureStructureRA.ClassID == PhNCFeaturesTags.kClassId) { // Natural class simple context with a feature-based natural class var natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures; int numLines = GetNumLines(ncCtxt); if (numLines == 0) { if (!isOuterIterCtxt) OpenContextPile(vwenv); vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) CloseContextPile(vwenv); } else if (numLines == 1) { if (!isOuterIterCtxt) OpenContextPile(vwenv); // use normal brackets for a single line context vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); // special consonant and vowel natural classes only display the abbreviation if (natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "C" || natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "V") { vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { if (natClass.FeaturesOA != null && natClass.FeaturesOA.FeatureSpecsOC.Count > 0) vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); else if (ncCtxt.PlusConstrRS.Count > 0) vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); else vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) CloseContextPile(vwenv); } else { // multiline context // left bracket pile int maxNumLines = MaxNumLines; vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature and variable pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, vwenv); vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; if (!isOuterIterCtxt) vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv); vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } } else { // natural class context with segment-based natural class if (!isOuterIterCtxt) OpenContextPile(vwenv); vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); if (ncCtxt.FeatureStructureRA != null) vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); else vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) CloseContextPile(vwenv); } break; case PhIterationContextTags.kClassId: IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext; if (iterCtxt.MemberRA != null) { int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext); if (numLines > 1) { vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); DisplayIterCtxt(iterCtxt, numLines, vwenv); } else { OpenContextPile(vwenv); if (iterCtxt.MemberRA.ClassID == PhSimpleContextNCTags.kClassId) { vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); } else { vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen); vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen); } DisplayIterCtxt(iterCtxt, 1, vwenv); // Views doesn't handle selection properly when we have an inner pile with strings on either side, // so we don't add a zero-width space at the end CloseContextPile(vwenv, false); } } else { OpenContextPile(vwenv); vwenv.AddProp(PhIterationContextTags.kflidMember, this, kfragQuestions); CloseContextPile(vwenv); } break; case PhSimpleContextSegTags.kClassId: if (!isOuterIterCtxt) OpenContextPile(vwenv); var segCtxt = ctxtOrVar as IPhSimpleContextSeg; if (segCtxt.FeatureStructureRA != null) vwenv.AddObjProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit); else vwenv.AddProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions); if (!isOuterIterCtxt) CloseContextPile(vwenv); break; case PhSimpleContextBdryTags.kClassId: if (!isOuterIterCtxt) OpenContextPile(vwenv); var bdryCtxt = ctxtOrVar as IPhSimpleContextBdry; if (bdryCtxt.FeatureStructureRA != null) vwenv.AddObjProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit); else vwenv.AddProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions); if (!isOuterIterCtxt) CloseContextPile(vwenv); break; case PhVariableTags.kClassId: OpenContextPile(vwenv); vwenv.AddProp(ktagXVariable, this, kfragXVariable); CloseContextPile(vwenv); break; } break; case kfragNC: int ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, PhNaturalClassTags.kflidAbbreviation); if (ncWs != 0) { vwenv.AddStringAltMember(PhNaturalClassTags.kflidAbbreviation, ncWs, this); } else { ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, PhNaturalClassTags.kflidName); if (ncWs != 0) vwenv.AddStringAltMember(PhNaturalClassTags.kflidName, ncWs, this); else vwenv.AddProp(PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions); } break; case kfragTerminalUnit: int tuWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstVern, hvo, PhTerminalUnitTags.kflidName); if (tuWs != 0) vwenv.AddStringAltMember(PhTerminalUnitTags.kflidName, tuWs, this); else vwenv.AddProp(PhTerminalUnitTags.kflidName, this, kfragQuestions); break; case kfragFeatNC: vwenv.AddObjProp(PhNCFeaturesTags.kflidFeatures, this, kfragFeats); break; case kfragFeats: vwenv.AddObjVecItems(FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature); break; case kfragFeature: vwenv.AddProp(ktagFeature, this, kfragFeatureLine); break; case kfragPlusVariable: vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine); break; case kfragMinusVariable: vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine); 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; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPattern: VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength patternLen; patternLen.nVal = 1; patternLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, patternLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (((ComplexConcPatternSda) vwenv.DataAccess).Root.IsLeaf) { OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false); vwenv.Props = m_bracketProps; vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragNode: ComplexConcPatternNode node = ((ComplexConcPatternSda) vwenv.DataAccess).Nodes[hvo]; int maxNumLines = GetMaxNumLines(vwenv); if (node is ComplexConcOrNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR); CloseSingleLinePile(vwenv, false); } else if (node is ComplexConcWordBdryNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash); CloseSingleLinePile(vwenv); } else if (node is ComplexConcGroupNode) { int numLines = GetNumLines(node); bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal parentheses for a single line group vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen); if (hasMinMax) DisplayMinMax(numLines, vwenv); CloseSingleLinePile(vwenv, false); } else { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt); vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook); vwenv.CloseInnerPile(); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook); vwenv.CloseInnerPile(); if (hasMinMax) DisplayMinMax(numLines, vwenv); } } else { bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; int numLines = GetNumLines(node); if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal brackets for a single line constraint vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket); DisplayFeatures(vwenv, node); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket); if (hasMinMax) DisplayMinMax(numLines, vwenv); CloseSingleLinePile(vwenv, false); } else { // left bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv); DisplayFeatures(vwenv, node); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); if (hasMinMax) DisplayMinMax(numLines, vwenv); } } break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragRHS: m_rhs = new PhSegRuleRHS(m_cache, hvo); IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO); int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = MaxNumLines; int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.GetFlid(hvo, null, "OwningRule"), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetVectorSize(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange) > 0) { vwenv.AddObjVecItems((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext) != 0) { vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext) != 0) { vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_cache.GetVectorSize(hvo, (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc) > 0) { vwenv.AddObjVecItems((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseContextPile(vwenv, false); } break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragContext: var ctxtOrVar = m_cache.ServiceLocator.GetInstance <IPhContextOrVarRepository>().GetObject(hvo); bool isOuterIterCtxt = false; // are we inside an iteration context? this is important since we only open a context pile if we are not // in an iteration context, since an iteration context does it for us if (vwenv.EmbeddingLevel > 0) { int outerHvo, outerTag, outerIndex; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex); var outerObj = m_cache.ServiceLocator.GetObject(outerHvo); isOuterIterCtxt = outerObj.ClassID == PhIterationContextTags.kClassId; } switch (ctxtOrVar.ClassID) { case PhSequenceContextTags.kClassId: var seqCtxt = (IPhSequenceContext)ctxtOrVar; if (seqCtxt.MembersRS.Count > 0) { vwenv.AddObjVecItems(PhSequenceContextTags.kflidMembers, this, kfragContext); } else { OpenSingleLinePile(vwenv, GetMaxNumLines(), false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSequenceContextTags.kflidMembers, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } break; case PhSimpleContextNCTags.kClassId: var ncCtxt = (IPhSimpleContextNC)ctxtOrVar; if (ncCtxt.FeatureStructureRA != null && ncCtxt.FeatureStructureRA.ClassID == PhNCFeaturesTags.kClassId) { // Natural class simple context with a feature-based natural class var natClass = (IPhNCFeatures)ncCtxt.FeatureStructureRA; int numLines = GetNumLines(ncCtxt); if (numLines == 0) { if (!isOuterIterCtxt) { OpenSingleLinePile(vwenv, GetMaxNumLines()); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseSingleLinePile(vwenv); } } else if (numLines == 1) { if (!isOuterIterCtxt) { OpenSingleLinePile(vwenv, GetMaxNumLines()); } // use normal brackets for a single line context vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); // special consonant and vowel natural classes only display the abbreviation if (natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "C" || natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "V") { vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { if (natClass.FeaturesOA != null && natClass.FeaturesOA.FeatureSpecsOC.Count > 0) { vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); } else if (ncCtxt.PlusConstrRS.Count > 0) { vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); } else { vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); } } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseSingleLinePile(vwenv); } } else { // multiline context // left bracket pile int maxNumLines = GetMaxNumLines(); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature and variable pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, vwenv); vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; if (!isOuterIterCtxt) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); } vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv); vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } } else { // natural class context with segment-based natural class if (!isOuterIterCtxt) { OpenSingleLinePile(vwenv, GetMaxNumLines()); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); if (ncCtxt.FeatureStructureRA != null) { vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseSingleLinePile(vwenv); } } break; case PhIterationContextTags.kClassId: var iterCtxt = (IPhIterationContext)ctxtOrVar; if (iterCtxt.MemberRA != null) { int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext); if (numLines > 1) { vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); DisplayIterCtxt(numLines, vwenv); } else { OpenSingleLinePile(vwenv, GetMaxNumLines()); if (iterCtxt.MemberRA.ClassID == PhSimpleContextNCTags.kClassId) { vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); } else { vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen); vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen); } DisplayIterCtxt(1, vwenv); // Views doesn't handle selection properly when we have an inner pile with strings on either side, // so we don't add a zero-width space at the end CloseSingleLinePile(vwenv, false); } } else { OpenSingleLinePile(vwenv, GetMaxNumLines()); vwenv.AddProp(PhIterationContextTags.kflidMember, this, kfragQuestions); CloseSingleLinePile(vwenv); } break; case PhSimpleContextSegTags.kClassId: if (!isOuterIterCtxt) { OpenSingleLinePile(vwenv, GetMaxNumLines()); } var segCtxt = (IPhSimpleContextSeg)ctxtOrVar; if (segCtxt.FeatureStructureRA != null) { vwenv.AddObjProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseSingleLinePile(vwenv); } break; case PhSimpleContextBdryTags.kClassId: if (!isOuterIterCtxt) { OpenSingleLinePile(vwenv, GetMaxNumLines()); } var bdryCtxt = (IPhSimpleContextBdry)ctxtOrVar; if (bdryCtxt.FeatureStructureRA != null) { vwenv.AddObjProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseSingleLinePile(vwenv); } break; case PhVariableTags.kClassId: OpenSingleLinePile(vwenv, GetMaxNumLines()); vwenv.AddProp(ktagXVariable, this, kfragXVariable); CloseSingleLinePile(vwenv); break; } break; case kfragNC: int ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, PhNaturalClassTags.kflidAbbreviation); if (ncWs != 0) { vwenv.AddStringAltMember(PhNaturalClassTags.kflidAbbreviation, ncWs, this); } else { ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, PhNaturalClassTags.kflidName); if (ncWs != 0) { vwenv.AddStringAltMember(PhNaturalClassTags.kflidName, ncWs, this); } else { vwenv.AddProp(PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions); } } break; case kfragTerminalUnit: int tuWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstVern, hvo, PhTerminalUnitTags.kflidName); if (tuWs != 0) { vwenv.AddStringAltMember(PhTerminalUnitTags.kflidName, tuWs, this); } else { vwenv.AddProp(PhTerminalUnitTags.kflidName, this, kfragQuestions); } break; case kfragFeatNC: vwenv.AddObjProp(PhNCFeaturesTags.kflidFeatures, this, kfragFeats); break; case kfragFeats: vwenv.AddObjVecItems(FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature); break; case kfragFeature: vwenv.AddProp(ktagFeature, this, kfragFeatureLine); break; case kfragPlusVariable: vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine); break; case kfragMinusVariable: vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine); 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"); } }
private void RegurgitateIVwEnvCall(StoredMethod storedMethod) { int tag; int frag; IVwViewConstructor vc; switch (storedMethod.MethodType) { case DecoratorMethodTypes.AddObj: var hvo = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObj(hvo, vc, frag); break; case DecoratorMethodTypes.AddObjProp: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjProp(tag, vc, frag); break; case DecoratorMethodTypes.AddObjVec: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjVec(tag, vc, frag); break; case DecoratorMethodTypes.AddObjVecItems: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjVecItems(tag, vc, frag); break; case DecoratorMethodTypes.AddString: var tsStr = (ITsString)storedMethod.ParamArray[0]; m_vwEnv.AddString(tsStr); break; case DecoratorMethodTypes.AddStringProp: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; m_vwEnv.AddStringProp(tag, vc); break; case DecoratorMethodTypes.CloseParagraph: m_vwEnv.CloseParagraph(); break; case DecoratorMethodTypes.CloseTableCell: m_vwEnv.CloseTableCell(); break; case DecoratorMethodTypes.NoteDependency: var _rghvo = (int[])storedMethod.ParamArray[0]; var _rgtag = (int[])storedMethod.ParamArray[1]; var chvo = (int)storedMethod.ParamArray[2]; m_vwEnv.NoteDependency(_rghvo, _rgtag, chvo); break; case DecoratorMethodTypes.OpenParagraph: m_vwEnv.OpenParagraph(); break; case DecoratorMethodTypes.OpenTableCell: var nRows = (int)storedMethod.ParamArray[0]; var nCols = (int)storedMethod.ParamArray[1]; m_vwEnv.OpenTableCell(nRows, nCols); break; case DecoratorMethodTypes.SetIntProperty: var tpt = (int)storedMethod.ParamArray[0]; var tpv = (int)storedMethod.ParamArray[1]; var nValue = (int)storedMethod.ParamArray[2]; m_vwEnv.set_IntProperty(tpt, tpv, nValue); break; case DecoratorMethodTypes.PropsSetter: var value = (ITsTextProps)storedMethod.ParamArray[0]; m_vwEnv.Props = value; break; default: Debug.Assert(false, "Unknown DecoratorMethodType!"); 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); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRHS: m_rhs = m_cache.ServiceLocator.GetInstance <IPhSegRuleRHSRepository>().GetObject(hvo); var rule = m_rhs.OwningRule; if (rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = GetMaxNumLines(); int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.MetaDataCacheAccessor.GetFieldId2(PhSegRuleRHSTags.kClassId, "OwningRule", false), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.StrucChangeOS.Count > 0) { vwenv.AddObjVecItems(PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidStrucChange }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.LeftContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidLeftContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.RightContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidRightContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_rhs.OwningRule.StrucDescOS.Count > 0) { vwenv.AddObjVecItems(PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenSingleLinePile(vwenv, GetMaxNumLines(), false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } 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> /// 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> /// Display a response to an annotation. /// </summary> /// <param name="vwenv"></param> /// <param name="text">StJournalText containing the response</param> /// <param name="expanded">whether response should be expanded</param> /// ------------------------------------------------------------------------------------ private void DisplayResponse(IVwEnv vwenv, IStJournalText text, bool expanded) { #region Response text // Display response text vwenv.OpenTableRow(); // Display empty first, second, and third cells vwenv.OpenTableCell(1, 3); vwenv.CloseTableCell(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 500); vwenv.OpenTableCell(1, 2); vwenv.AddObjVecItems((int)StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); vwenv.CloseTableCell(); vwenv.CloseTableRow(); #endregion #region Author and creation date // Author and creation date vwenv.OpenTableRow(); // Display empty first, second, and third cells vwenv.OpenTableCell(1, 3); vwenv.CloseTableCell(); // Display author in the third cell vwenv.OpenTableCell(1, 1); SetDisabledColorForNote(vwenv); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_authorLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display creation date in the fourth cell vwenv.OpenTableCell(1, 1); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_createdLabel); vwenv.AddString(m_tsStrFactory.MakeString(text.DateCreated.ToShortDateString(), m_cache.DefaultUserWs)); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); #endregion }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPrintChart: // the whole chart with headings for printing. if (hvo == 0) return; PrintColumnGroupHeaders(hvo, vwenv); PrintIndividualColumnHeaders(hvo, vwenv); // Rest is same as kfragChart DisplayChartBody(vwenv); break; case kfragTemplateHeader: // Display the template as group headers. vwenv.AddObjVecItems((int)CmPossibility.CmPossibilityTags.kflidSubPossibilities, this, kfragColumnGroupHeader); break; // This is only used for printing, the headers in the screen version are a separate control. case kfragColumnGroupHeader: int ccols = vwenv.DataAccess.get_VecSize(hvo, (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities); // If there are no subitems, we still want a blank cell as a placeholder. MakeCellsMethod.OpenStandardCell(vwenv, Math.Max(ccols, 1), true); if (ccols > 0) { // It's a group, include its name vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.OpenParagraph(); vwenv.AddString(CmPossibility.BestAnalysisName(m_cache, hvo)); vwenv.CloseParagraph(); } vwenv.CloseTableCell(); break; case kfragChart: // the whole chart, a DsConstChart. if (hvo == 0) return; DisplayChartBody(vwenv); break; case kfragChartRow: // one row, a CmIndirectAnnotation { MakeTableAndRowWithStdWidths(vwenv, hvo, false); MakeCells(vwenv, hvo); vwenv.CloseTableRow(); vwenv.CloseTable(); } break; case kfragCca: // a single group of words, the contents of one cell. if (ConstituentChartLogic.IsWficGroup(m_cache, hvo)) vwenv.AddObjVec(kflidAppliesTo, this, kfragBundleVec); else { // it's a moved text or missing-item placeholder. int hvoClause; if (m_chart.Logic.IsClausePlaceholder(hvo, out hvoClause)) DisplayClausePlaceholder(vwenv, hvoClause); else if (vwenv.DataAccess.get_VecSize(hvo, kflidAppliesTo) == 0) DisplayMissingMarker(vwenv); else DisplayMovedTextTag(hvo, vwenv); } break; case kfragCcaMoved: // a single group of words, the contents of one cell, which is considered moved-within-line. // can't be a placeholder. string formatTag = m_chart.Logic.MovedTextTag(hvo); ApplyFormatting(vwenv, formatTag); vwenv.OpenSpan(); InsertOpenBracket(vwenv, formatTag); vwenv.AddObjVec(kflidAppliesTo, this, kfragBundleVec); InsertCloseBracket(vwenv, formatTag); vwenv.CloseSpan(); break; case kfragCcaListItem: // a single CCA, referring to a list item. // can't be a placeholder. ApplyFormatting(vwenv, "marker"); vwenv.OpenSpan(); InsertOpenBracket(vwenv, "marker"); vwenv.AddObjProp((int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject, this, kfragPossibility); InsertCloseBracket(vwenv, "marker"); vwenv.CloseSpan(); break; case kfragPossibility: // A CmPossibility, show it's abbreviation int flid = (int)CmPossibility.CmPossibilityTags.kflidAbbreviation; int retWs; m_cache.LangProject.GetMagicStringAlt(LangProject.kwsFirstAnal, hvo, flid, false, out retWs); // If we didn't find an abbreviation try for the name ITsString tss = null; if (retWs != 0) tss = m_cache.GetMultiStringAlt(hvo, flid, retWs); if (tss == null || string.IsNullOrEmpty(tss.Text)) { flid = (int)CmPossibility.CmPossibilityTags.kflidName; m_cache.LangProject.GetMagicStringAlt(LangProject.kwsFirstAnal, hvo, flid, false, out retWs); } // Unless we didn't get anything, go ahead and insert the best option we found. if (retWs != 0) vwenv.AddStringAltMember(flid, retWs, this); // retWS was m_cache.DefaultAnalWs, this fixes LT-7838 break; case kfragBundle: // One annotated word bundle; hvo is CmBaseAnnotation. Overrides behavior of InterlinVc { SetupForTwfic(hvo); // 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.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeading); 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); 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); } //vwenv.AddObjProp(ktagTwficDefault, this, kfragTwficAnalysis); vwenv.CloseInnerPile(); // revert back to the paragraph vernWs. SetupForTwfic(0); } break; case kfragNotesText: // notes structured text vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, kfragNotesPara); break; case kfragNotesPara: vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, this); break; case kfragComment: // hvo is a CmAnnotation, a row vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_chart.Logic.WsLineNumber, this); break; default: base.Display(vwenv, hvo, frag); break; } }
/// <summary> /// Insert a display of the relevant property for the indicated object, which is a sequence or collection. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> public void InsertSeq(IVwEnv vwenv, int hvo) { vwenv.AddObjVecItems(FakePropTag, this, kfragName); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPattern: VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength patternLen; patternLen.nVal = 1; patternLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, patternLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (((ComplexConcPatternSda)vwenv.DataAccess).Root.IsLeaf) { OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false); vwenv.Props = m_bracketProps; vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragNode: ComplexConcPatternNode node = ((ComplexConcPatternSda)vwenv.DataAccess).Nodes[hvo]; int maxNumLines = GetMaxNumLines(vwenv); if (node is ComplexConcOrNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR); CloseSingleLinePile(vwenv, false); } else if (node is ComplexConcWordBdryNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash); CloseSingleLinePile(vwenv); } else if (node is ComplexConcGroupNode) { int numLines = GetNumLines(node); bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal parentheses for a single line group vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } CloseSingleLinePile(vwenv, false); } else { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook); vwenv.CloseInnerPile(); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt); } vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook); vwenv.CloseInnerPile(); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } } } else { bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; int numLines = GetNumLines(node); if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal brackets for a single line constraint vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket); DisplayFeatures(vwenv, node); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } CloseSingleLinePile(vwenv, false); } else { // left bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv); DisplayFeatures(vwenv, node); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } } } 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> /// Displays the annotation fragment. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayAnnotationFragment(IVwEnv vwenv, int hvo) { IScrScriptureNote ann = m_cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(hvo); bool isExpanded = (m_expandTable.ContainsKey(hvo) && m_expandTable[hvo]); int hvoFirstResponse = ann.ResponsesOS.Count > 0 ? ann.ResponsesOS[0].Hvo : 0; bool responseExpanded = m_expandTable.ContainsKey(hvoFirstResponse) && m_expandTable[hvoFirstResponse]; // put the separator at the top of the note InsertNoteSeparator(vwenv); // Open a table to display the first line of the annotation. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; int borderThickness = 2000; int columnCount = 9; VwFramePosition framePos = VwFramePosition.kvfpVoid; if (ann.Hvo == SelectedNoteHvo) { columnCount = 7; framePos = (ann.ResponsesOS.Count == 0 || !isExpanded || !responseExpanded) ? VwFramePosition.kvfpBox : (VwFramePosition.kvfpAbove | VwFramePosition.kvfpVsides); } vwenv.OpenTable(columnCount, vlTable, // Table uses 100% of available width. borderThickness, VwAlignment.kvaLeft, // Default alignment. framePos, //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); vwenv.NoteDependency(new int[] { hvo, hvo }, new int[]{m_expansionTag, ScrScriptureNoteTags.kflidResponses}, 2); // Specify column widths. The first argument is the number of columns, // not a column index. VwLength vlColumn; if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vlColumn.nVal = 13000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(2, vlColumn); vlColumn.nVal = 60000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); vlColumn.nVal = 2; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the CONNOT categories vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when showing quote vlColumn.nVal = 3; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the quote when collapsed vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when not showing quote if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vwenv.OpenTableBody(); DisplayAnnotation(vwenv, ann, isExpanded); // Only display the responses if this note is expanded and has responses. if (!isExpanded || ann.ResponsesOS.Count == 0) { // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); return; } vwenv.NoteDependency(new int[] { ann.ResponsesOS.ToHvoArray()[0] }, new int[] { m_expansionTag }, 1); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display expand box (+/-) in the second cell vwenv.OpenTableCell(1, 1); vwenv.AddObj(ann.ResponsesOS.ToHvoArray()[0], this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display response label in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_responseLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); if (responseExpanded) { vwenv.AddObjVecItems((int)ScrScriptureNoteTags.kflidResponses, this, (int)NotesFrags.kfrResponse); } }