/// ------------------------------------------------------------------------------------ /// <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> /// /// </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> /// /// </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"); } }
/// <summary> /// Add to the vwenv a display of property tag of object hvo, which stores an /// SbNamedObj. If the property is non-null, display the name of the SbNamedObj. /// If not, display the dummyTag 'property' using the dummyFrag. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="tag"></param> /// <param name="dummyTag"></param> /// <param name="dummyFrag"></param> /// <param name="tagIcon">If non-zero, display a pull-down icon before the item, marked with this tag.</param> /// <param name="ws">which alternative of the name to display</param> /// <param name="choiceIndex">which item in m_choices this comes from. The icon is displayed /// only if it is the first one for its flid.</param> protected void AddOptionalNamedObj(IVwEnv vwenv, int hvo, int tag, int dummyTag, int dummyFrag, int tagIcon, int ws, int choiceIndex) { int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, tag); SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex)); bool fWantIcon = false; fWantIcon = tagIcon != 0 && m_choices.IsFirstOccurrenceOfFlid(choiceIndex); if (m_fIconsForAnalysisChoices && !fWantIcon) { // This line does not have one, but add some white space to line things up. vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, m_dxmpArrowPicWidth + kmpIconMargin); } vwenv.OpenParagraph(); if (fWantIcon) { AddPullDownIcon(vwenv, tagIcon); } // The NoteDependency is needed whether or not hvoNo is set, in case we update // to a sense which has a null MSA. See LT-4246. vwenv.NoteDependency(new int[] { hvo }, new int[] { tag }, 1); if (hvoNo == 0) { vwenv.AddProp(dummyTag, this, dummyFrag); } else { vwenv.AddObjProp(tag, this, kfragNamedObjectNameChoices + choiceIndex); } vwenv.CloseParagraph(); }
/// ------------------------------------------------------------------------------------ /// <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. 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> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) return; // not much we can display without a valid object switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); // TODO (EberhardB): The gap between the intro division and the text // division probably needs to be configurable somewhere... // Add a 24 point gap at the bottom of the intro section vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(BackColor), -1, 24000, 0); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) { return; // not much we can display without a valid object } switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); // TODO (EberhardB): The gap between the intro division and the text // division probably needs to be configurable somewhere... // Add a 24 point gap at the bottom of the intro section vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(BackColor), -1, 24000, 0); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is displayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)ScrFrags.kfrScripture: vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; case (int)ScrFrags.kfrSection: vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; case (int)StTextFrags.kfrPara: if (m_hvosReadOnly.Contains(hvo)) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
/// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch ((ScrFrags)frag) { case ScrFrags.kfrScripture: { vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; } case ScrFrags.kfrBook: { vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, m_stvc, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); break; } case ScrFrags.kfrSection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, m_stvc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, m_stvc, (int)StTextFrags.kfrText); break; } default: Debug.Assert(false); break; } }
private void DisplayLexGloss(IVwEnv vwenv, int hvo, int ws, int choiceIndex) { int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, ktagSbMorphGloss); SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex)); if (m_fIconsForAnalysisChoices) { // This line does not have one, but add some white space to line things up. vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, m_dxmpArrowPicWidth + kmpIconMargin); } if (hvoNo == 0) { // One of these is enough, the regeneration will redo an outer object and get // all the alternatives. vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSbMorphGloss }, 1); vwenv.AddProp(ktagMissingMorphGloss, this, kfragMissingMorphGloss); } else { vwenv.AddObjProp(ktagSbMorphGloss, this, kfragNamedObjectNameChoices + choiceIndex); } }
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; } }
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; } }
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; } }
private void DisplayMorphForm(IVwEnv vwenv, int hvo, int frag, int ws, int choiceIndex) { int hvoMorphForm = vwenv.DataAccess.get_ObjectProp(hvo, ktagSbMorphForm); // Allow editing of the morpheme breakdown line. SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex)); // On this line we want an icon only for the first column (and only if it is the first // occurrence of the flid). bool fWantIcon = m_fIsMorphemeFormEditable && (frag == kfragFirstMorph) && m_choices.IsFirstOccurrenceOfFlid(choiceIndex); if (!fWantIcon) { SetIndentForMissingIcon(vwenv); } vwenv.OpenParagraph(); bool fFirstMorphLine = (m_choices.IndexOf(InterlinLineChoices.kflidMorphemes) == choiceIndex); if (fWantIcon) // Review JohnT: should we do the 'edit box' for all first columns? { AddPullDownIcon(vwenv, ktagMorphFormIcon); // Create an edit box that stays visible when the user deletes // the first morpheme (like the WordGloss box). // This is especially useful if the user wants to // delete the entire MorphForm line (cf. LT-1621). vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, kmpIconMargin); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, krgbEditable); } if (m_fIsMorphemeFormEditable) { MakeNextFlowObjectEditable(vwenv); } else { MakeNextFlowObjectReadOnly(vwenv); } vwenv.OpenInnerPile(); vwenv.OpenParagraph(); if (fFirstMorphLine) { vwenv.AddStringProp(ktagSbMorphPrefix, this); } // This is never missing, but may, or may not, be editable. vwenv.AddObjProp(ktagSbMorphForm, this, kfragNamedObjectNameChoices + choiceIndex); if (fFirstMorphLine) { vwenv.AddStringProp(ktagSbMorphPostfix, this); } // close the special edit box we opened for the first morpheme. vwenv.CloseParagraph(); vwenv.CloseInnerPile(); vwenv.CloseParagraph(); }
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; } }
/// <summary> /// Add a display of the category of hvoAnalysis. /// If choiceOffset is -1, display the current analysis writing systems, otherwise, /// display the one indicated (choiceIndex is an index into line choices). /// When choice index is not -1, hvoAnalysis may not be the current object. /// In that case, we invoke AddObj with a special flid which results in a recursive /// call to this, but with the correct current object. /// </summary> /// <param name="vwenv"></param> /// <param name="hvoAnalysis"></param> protected void AddAnalysisPos(IVwEnv vwenv, int hvoAnalysis, int hvoCurrent, int choiceIndex) { IWfiAnalysis wa = m_coRepository.GetObject(hvoAnalysis) as IWfiAnalysis; int hvoPos = wa.CategoryRA != null ? wa.CategoryRA.Hvo : 0; SetColor(vwenv, LabelRGBFor(choiceIndex)); if (hvoPos == 0) { vwenv.OpenParagraph(); vwenv.NoteDependency(new int[] {hvoAnalysis}, new int[] {WfiAnalysisTags.kflidCategory}, 1); vwenv.AddString(m_tssMissingAnalysisPos); vwenv.CloseParagraph(); } else if (choiceIndex < 0) { vwenv.AddObjProp(WfiAnalysisTags.kflidCategory, this, kfragCategory); } else { if (hvoCurrent == hvoAnalysis) vwenv.AddObjProp(WfiAnalysisTags.kflidCategory, this, kfragLineChoices + choiceIndex); else vwenv.AddObj(hvoAnalysis, this, kfragAnalysisCategoryChoices + choiceIndex); // causes recursive call with right hvoCurrent } }
private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo) { ISilDataAccess sda = vwenv.DataAccess; int hvoLf = sda.get_ObjectProp(hvo, LexEntryTags.kflidLexemeForm); int hvoType = 0; if (hvoLf != 0) { hvoType = sda.get_ObjectProp(hvoLf, MoFormTags.kflidMorphType); } // If we have a type of morpheme, show the appropriate prefix that indicates it. // We want vernacular so it will match the point size of any aligned vernacular text. // (The danger is that the vernacular font doesn't have these characters...not sure what // we can do about that, but most do, and it looks awful in analysis if that is a // much different size from vernacular.) string sPrefix = null; if (hvoType != 0) { sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix); } // Show homograph number if non-zero. int defUserWs = m_cache.WritingSystemFactory.UserWs; int nHomograph = sda.get_IntProp(hvo, LexEntryTags.kflidHomographNumber); var hc = m_cache.ServiceLocator.GetInstance <HomographConfiguration>(); //Insert HomographNumber when position is Before if (hc.HomographNumberBefore) { InsertHomographNumber(vwenv, hc, nHomograph, defUserWs); } // LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form. bool fGotLabel = false; int wsActual = 0; if (hvoLf != 0) { // if we have a lexeme form and its label is non-empty, use it. if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual)) { m_wsActual = wsActual; fGotLabel = true; if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual)); } vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm); } } if (!fGotLabel) { // If we didn't get a useful form from the lexeme form try the citation form. if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual)) { m_wsActual = wsActual; if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual)); } vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this); fGotLabel = true; } } if (!fGotLabel) { // If that fails just show two questions marks. if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual)); } vwenv.AddString(TsStringUtils.MakeString(FdoUiStrings.ksQuestions, defUserWs)); // was "??", not "???" } // If we have a lexeme form type show the appropriate postfix. if (hvoType != 0) { vwenv.AddString(TsStringUtils.MakeString( sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual)); } vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1); //Insert HomographNumber when position is After if (!hc.HomographNumberBefore) { InsertHomographNumber(vwenv, hc, nHomograph, defUserWs); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragStText: // The whole text, root object for the InterlinDocChild. if (hvo == 0) { return; // What if the user deleted all the texts? See LT-6727. } IStText stText = m_coRepository.GetObject(hvo) as IStText; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.OpenDiv(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 24000); // Add both vernacular and analysis if we have them (LT-5561). bool fAddedVernacular = false; int wsVernTitle = 0; // if (stText.Title.TryWs(WritingSystemServices.kwsFirstVern, out wsVernTitle)) { vwenv.OpenParagraph(); vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this); vwenv.CloseParagraph(); fAddedVernacular = true; } int wsAnalysisTitle = 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); ITsString tssAnal; if (stText.Title.TryWs(WritingSystemServices.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) && !tssAnal.Equals(stText.Title.BestVernacularAlternative)) { if (fAddedVernacular) { // display analysis title at smaller font size. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); } vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this); } else { // just add a blank title. ITsString blankTitle = TsStringUtils.EmptyString(m_wsAnalysis); vwenv.AddString(blankTitle); } vwenv.CloseParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); int wsSource = 0; if (stText.Source.TryWs(WritingSystemServices.kwsFirstVernOrAnal, out wsSource)) { vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.AddStringAltMember(vtagStTextSource, wsSource, this); vwenv.CloseParagraph(); } else { // just add a blank source. ITsString tssBlank = TsStringUtils.EmptyString(m_wsAnalysis); vwenv.AddString(tssBlank); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); if (stText.OwningFlid == TextTags.kflidContents) { vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription); } vwenv.CloseParagraph(); base.Display(vwenv, hvo, frag); vwenv.CloseDiv(); break; case kfragTextDescription: vwenv.AddStringAltMember(CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); break; default: base.Display(vwenv, hvo, frag); break; } }
private void DisplayMorphForm(IVwEnv vwenv, int hvo, int frag, int ws, int choiceIndex) { int hvoMorphForm = vwenv.DataAccess.get_ObjectProp(hvo, ktagSbMorphForm); // Allow editing of the morpheme breakdown line. SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex)); // On this line we want an icon only for the first column (and only if it is the first // occurrence of the flid). bool fWantIcon = m_fIsMorphemeFormEditable && (frag == kfragFirstMorph) && m_choices.IsFirstOccurrenceOfFlid(choiceIndex); if (!fWantIcon) SetIndentForMissingIcon(vwenv); vwenv.OpenParagraph(); bool fFirstMorphLine = (m_choices.IndexOf(InterlinLineChoices.kflidMorphemes) == choiceIndex); if (fWantIcon) // Review JohnT: should we do the 'edit box' for all first columns? { AddPullDownIcon(vwenv, ktagMorphFormIcon); // Create an edit box that stays visible when the user deletes // the first morpheme (like the WordGloss box). // This is especially useful if the user wants to // delete the entire MorphForm line (cf. LT-1621). vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, kmpIconMargin); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, krgbEditable); } // Per LT-14891, morpheme form is not editable except for the default vernacular. if (m_fIsMorphemeFormEditable && m_choices.IsFirstOccurrenceOfFlid(choiceIndex)) MakeNextFlowObjectEditable(vwenv); else MakeNextFlowObjectReadOnly(vwenv); vwenv.OpenInnerPile(); vwenv.OpenParagraph(); if (fFirstMorphLine) vwenv.AddStringProp(ktagSbMorphPrefix, this); // This is never missing, but may, or may not, be editable. vwenv.AddObjProp(ktagSbMorphForm, this, kfragNamedObjectNameChoices + choiceIndex); if (fFirstMorphLine) vwenv.AddStringProp(ktagSbMorphPostfix, this); // close the special edit box we opened for the first morpheme. vwenv.CloseParagraph(); vwenv.CloseInnerPile(); vwenv.CloseParagraph(); }
/// <summary> /// Add to the vwenv a display of property tag of object hvo, which stores an /// SbNamedObj. If the property is non-null, display the name of the SbNamedObj. /// If not, display the dummyTag 'property' using the dummyFrag. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="tag"></param> /// <param name="dummyTag"></param> /// <param name="dummyFrag"></param> /// <param name="tagIcon">If non-zero, display a pull-down icon before the item, marked with this tag.</param> /// <param name="ws">which alternative of the name to display</param> /// <param name="choiceIndex">which item in m_choices this comes from. The icon is displayed /// only if it is the first one for its flid.</param> protected void AddOptionalNamedObj(IVwEnv vwenv, int hvo, int tag, int dummyTag, int dummyFrag, int tagIcon, int ws, int choiceIndex) { int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, tag); SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex)); bool fWantIcon = false; fWantIcon = tagIcon != 0 && m_choices.IsFirstOccurrenceOfFlid(choiceIndex); if (m_fIconsForAnalysisChoices && !fWantIcon) { // This line does not have one, but add some white space to line things up. vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, m_dxmpArrowPicWidth + kmpIconMargin); } vwenv.OpenParagraph(); if (fWantIcon) AddPullDownIcon(vwenv, tagIcon); // The NoteDependency is needed whether or not hvoNo is set, in case we update // to a sense which has a null MSA. See LT-4246. vwenv.NoteDependency(new int[] { hvo }, new int[] { tag }, 1); if (hvoNo == 0) vwenv.AddProp(dummyTag, this, dummyFrag); else vwenv.AddObjProp(tag, this, kfragNamedObjectNameChoices + choiceIndex); vwenv.CloseParagraph(); }
protected virtual void DisplayObjectProperty(IVwEnv vwenv, int hvo) { vwenv.AddObjProp(m_flid, this, AtomicReferenceView.kFragObjName); }
/// <summary> /// Insert a display of the relevant property for the indicated object, which is atomic. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> public void Insert(IVwEnv vwenv, int hvo) { CheckDisposed(); vwenv.AddObjProp(FakePropTag, this, kfragName); }
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 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 a MorphBundle, setting the colors of its parts. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo">WfiMorphBundle</param> private void DisplayMorphBundle(IVwEnv vwenv, int hvo) { IWfiMorphBundle wmb = null; if (hvo != 0) wmb = m_wmbRepository.GetObject(hvo); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); int first = m_lineChoices.FirstMorphemeIndex; int last = m_lineChoices.LastMorphemeIndex; IMoForm mf = null; if (wmb != null) mf = wmb.MorphRA; if (vwenv is CollectorEnv && mf != null) { // Collectors are given an extra initial chance to 'collect' the morph type, if any. vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph, this, kfragMorphType); } for (int i = first; i <= last; i++) { InterlinLineSpec spec = m_lineChoices[i]; SetColor(vwenv, LabelRGBFor(spec)); switch (spec.Flid) { case InterlinLineChoices.kflidMorphemes: if (wmb == null) { vwenv.AddString(m_tssMissingMorph); } else if (mf == null) { // displaying morphemes should be int ws = 0; if (wmb.MorphRA != null) { Debug.Assert(spec.StringFlid == MoFormTags.kflidForm); ws = GetRealWsOrBestWsForContext(wmb.MorphRA.Hvo, spec); } // If no morph, use the form of the morph bundle (and the entry is of // course missing) if (ws == 0) { ws = WritingSystemServices.ActualWs(m_cache, spec.WritingSystem, wmb.Hvo, WfiMorphBundleTags.kflidForm); } vwenv.AddStringAltMember( WfiMorphBundleTags.kflidForm, ws, this); } else { // Got a morph, show it. vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph, this, kfragMorphFormChoices + i); // And the LexEntry line. } break; case InterlinLineChoices.kflidLexEntries: if (mf == null) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMorph }, 1); vwenv.AddString(m_tssMissingEntry); } else { int ws = GetRealWsOrBestWsForContext(mf.Hvo, spec); if (ws == 0) ws = spec.WritingSystem; LexEntryVc vcEntry = new LexEntryVc(m_cache); vcEntry.WritingSystemCode = ws; vwenv.AddObj(hvo, vcEntry, LexEntryVc.kfragEntryAndVariant); } break; case InterlinLineChoices.kflidLexGloss: int flid = 0; if (wmb != null) { vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidMorph }, 1); vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1); vwenv.NoteDependency(new[] { hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1); if (wmb.SenseRA == null) { if (ShowDefaultSense && wmb.DefaultSense != null && UsingGuess) { flid = wmb.Cache.MetaDataCacheAccessor.GetFieldId2(WfiMorphBundleTags.kClassId, "DefaultSense", false); } } else { flid = WfiMorphBundleTags.kflidSense; if (wmb.MorphRA != null && DisplayLexGlossWithInflType(vwenv, wmb.MorphRA.Owner as ILexEntry, wmb.SenseRA, spec, wmb.InflTypeRA)) { break; } } } if (flid == 0) vwenv.AddString(m_tssMissingSense); else vwenv.AddObjProp(flid, this, kfragLineChoices + i); break; case InterlinLineChoices.kflidLexPos: // LexPOS line: int hvoMsa = 0; if (wmb != null && wmb.MsaRA != null) hvoMsa = wmb.MsaRA.Hvo; if (hvoMsa == 0) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMsa }, 1); vwenv.AddString(m_tssMissingMsa); } else { // Use a special view constructor that knows how to display the // interlinear view of whatever kind of MSA it is. // Enhance JohnT: ideally we would have one of these VCs for each writing system, // perhaps stored in the InterlinLineSpec. Currently displaying multiple Wss of LexPos // is not useful, though it is possible. // Enhancement RickM: we set the m_msaVc.DefaultWs to the selected writing system // of each LexPos line in interlinear. This is used extract the LexPos abbreviation // for the specific writing system. m_msaVc.DefaultWs = spec.WritingSystem; vwenv.AddObjProp(WfiMorphBundleTags.kflidMsa, m_msaVc, (int)VcFrags.kfragInterlinearAbbr); } break; } } vwenv.CloseInnerPile(); }
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; } }
/// ------------------------------------------------------------------------------------ /// <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"); } }
private void DisplaySingleInterlinearAnalysisWithLabels(IVwEnv vwenv, int hvo) { /* // 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 bundle is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); if (m_fRtl) { // This must not be on the outer paragraph or we get infinite width. 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.OpenParagraph(); m_fHaveOpenedParagraph = true; AddLabelPile(vwenv, m_tsf, m_cache, true, m_fShowMorphBundles); try { // We use this rather than AddObj(hvo) so we can easily identify this object and select // it using MakeObjSel. vwenv.AddObjProp(m_selfFlid, this, kfragAnalysisMorphs); vwenv.CloseParagraph(); } finally { m_fHaveOpenedParagraph = false; } /* // This puts 3 points of margin on the first FF annotation, if any. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 0); // 3000 vwenv.AddObjVec(ktagSegFF, this, kfragSegFf); */ }
private void DisplayMorphForm(IVwEnv vwenv, int hvo, int ws) { var mf = (IMoForm)m_coRepository.GetObject(hvo); // The form of an MoForm. Hvo is some sort of MoMorph. Display includes its prefix // and suffix. // Todo: make prefix and suffix read-only. vwenv.OpenParagraph(); // group prefix, form, suffix on one line. // It may not have a morph type at all. // RBR says: "So why take the chance of a null ref exception (which I ran into, in my ZPI data, of course)? :-) // int typeID = mf.MorphTypeRA.Hvo; var morphType = mf.MorphTypeRA; if (morphType != null) vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPrefix); vwenv.AddStringAltMember(MoFormTags.kflidForm, ws, this); if (morphType != null) vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPostfix); vwenv.CloseParagraph(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { const int kfragAbbr = 17; // arbitrary const from reserved range. const int kfragName = 18; switch (frag) { case (int)VcFrags.kfragInterlinearAbbr: case (int)VcFrags.kfragInterlinearName: // abbr is probably more appropriate in interlinear. case (int)VcFrags.kfragShortName: if (HandleObjMissing(vwenv, hvo)) vwenv.AddObjProp(m_flidRef, this, kfragAbbr); break; case kfragAbbr: vwenv.AddStringAltMember(CmPossibilityTags.kflidAbbreviation, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle, this); break; case (int)VcFrags.kfragName: if (HandleObjMissing(vwenv, hvo)) vwenv.AddObjProp(m_flidRef, this, kfragName); break; default: vwenv.AddStringAltMember(CmPossibilityTags.kflidName, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle, this); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { #if __MonoCS__ // TODO-Linux: Randomly m_tsf seem to have been Release. // eg Marshal.ReleaseComObject(m_tsf); // However the Dispose method isn't called (which calls the Release) // Currently unsure what is doing this need to find out - very concerning // Hack - just recreate a new TsStrFactory each time... for now // seems to stop the problem. m_tsf = TsStrFactoryClass.Create(); #endif CheckDisposed(); if (hvo == 0) return; // Can't do anything without an hvo (except crash -- see LT-9348). #if DEBUG //TimeRecorder.Begin("Display"); #endif switch (frag) { case kfragStText: // new root object for InterlinDocChild. SetupRealVernWsForDisplay(WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph, hvo, StTextTags.kflidParagraphs)); vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, kfragInterlinPara); break; case kfragInterlinPara: // Whole StTxtPara. This can be the root fragment in DE view. if (vwenv.DataAccess.get_VecSize(hvo, StTxtParaTags.kflidSegments) == 0) { vwenv.NoteDependency(new int[] { hvo }, new int[] { StTxtParaTags.kflidSegments }, 1); vwenv.AddString(m_tssEmptyPara); } else { PreferredVernWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph, hvo, StTxtParaTags.kflidSegments); // Include the plain text version of the paragraph? vwenv.AddLazyVecItems(StTxtParaTags.kflidSegments, this, kfragParaSegment); } break; case kfragParaSegment: // Don't put anything in this segment if it is a 'label' segment (typically containing a verse // number for TE). var seg = m_segRepository.GetObject(hvo); if (seg.IsLabel) break; // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. var haveFreeform = seg.FreeTranslation != null || seg.LiteralTranslation != null || seg.NotesOS.Count > 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, !haveFreeform ? 5000 : 10000); vwenv.OpenDiv(); // Enhance JohnT: determine what the overall direction of the paragraph should // be and set it. if (m_mpBundleHeight == 0) { // First time...figure it out. int dmpx, dmpyAnal, dmpyVern; vwenv.get_StringWidth(m_tssEmptyAnalysis, null, out dmpx, out dmpyAnal); vwenv.get_StringWidth(m_tssEmptyVern, null, out dmpx, out dmpyVern); m_mpBundleHeight = dmpyAnal * 4 + dmpyVern * 3; } // The interlinear bundles are not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); if (m_fRtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalRight); } vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenParagraph(); AddSegmentReference(vwenv, hvo); // Calculate and display the segment reference. AddLabelPile(vwenv, m_tsf, m_cache, true, m_fShowMorphBundles); vwenv.AddObjVecItems(SegmentTags.kflidAnalyses, this, kfragBundle); // JohnT, 1 Feb 2008. Took this out as I can see no reason for it; AddObjVecItems handles // the dependency already. Adding it just means that any change to the forms list // regenerates a higher level than needed, which contributes to a great deal of scrolling // and flashing (LT-7470). // Originally added by Eric in revision 72 on the trunk as part of handling phrases. // Eric can't see any reason we need it now, either. If you find a need to re-insert it, // please document carefully the reasons it is needed and what bad consequences follow // from removing it. //vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSegmentForms }, 1); vwenv.CloseParagraph(); // We'd get the same visual effect from just calling AddFreeformAnnotations here. But then a regenerate // such as happens when hiding or showing a prompt has to redisplay the whole segment. This initially // makes it lazy, then the lazy stuff gets expanded. In the process we may get undesired scrolling (LT-12248). // So we insert another layer of object, allowing just the freeforms to be regenerated. var flidSelf = Cache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false); vwenv.AddObjProp(flidSelf, this, kfragFreeformBundle); vwenv.CloseDiv(); break; case kfragFreeformBundle: AddFreeformAnnotations(vwenv, hvo); break; case kfragBundle: // One annotated word bundle; hvo is the IAnalysis object. // checking AllowLayout (especially in context of Undo/Redo make/break phrase) // helps prevent us from rebuilding the display until we've finished // reconstructing the data and cache. Otherwise we can crash. if (m_rootsite != null && !m_rootsite.AllowLayout) return; AddWordBundleInternal(hvo, vwenv); break; case kfragIsolatedAnalysis: // This one is used for an isolated HVO that is surely an analysis. { var wa = m_analRepository.GetObject(hvo); vwenv.AddObj(wa.Owner.Hvo, this, kfragWordformForm); if (m_fShowMorphBundles) vwenv.AddObj(hvo, this, kfragAnalysisMorphs); int chvoGlosses = wa.MeaningsOC.Count; for (int i = 0; i < m_WsList.AnalysisWsIds.Length; ++i) { SetColor(vwenv, LabelRGBFor(m_lineChoices.IndexOf(InterlinLineChoices.kflidWordGloss, m_WsList.AnalysisWsIds[i]))); if (chvoGlosses == 0) { // There are no glosses, display something indicating it is missing. vwenv.AddProp(ktagAnalysisMissingGloss, this, kfragAnalysisMissingGloss); } else { vwenv.AddObjVec(WfiAnalysisTags.kflidMeanings, this, kfragWordGlossWs + i); } } AddAnalysisPos(vwenv, hvo, hvo, -1); } break; case kfragAnalysisMorphs: int cmorphs = 0; ICmObject co = m_coRepository.GetObject(hvo); if (co is IWfiAnalysis) cmorphs = (co as IWfiAnalysis).MorphBundlesOS.Count; // We really want a variable for this...there have been pathological cases where // m_fHaveOpenedParagraph changed during the construction of the paragraph, and we want to be // sure to close the paragraph if we opened it. var openedParagraph = !m_fHaveOpenedParagraph; if (openedParagraph) vwenv.OpenParagraph(); if (cmorphs == 0) { DisplayMorphBundle(vwenv, 0); } else { vwenv.AddObjVecItems(WfiAnalysisTags.kflidMorphBundles, this, kfragMorphBundle); } if (openedParagraph) vwenv.CloseParagraph(); break; case kfragMorphType: // for export only at present, display the vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPossibiltyAnalysisName); break; case kfragPossibiltyAnalysisName: vwenv.AddStringAltMember(CmPossibilityTags.kflidName, m_cache.DefaultAnalWs, this); break; case kfragMorphBundle: // the lines of morpheme information (hvo is a WfiMorphBundle) // Make an 'inner pile' to contain the bundle of morph information. // Give it 10 points of separation from whatever follows. DisplayMorphBundle(vwenv, hvo); break; case kfragSingleInterlinearAnalysisWithLabels: /* // This puts ten points between segments. There's always 5 points below each line of interlinear; // if there are no freeform annotations another 5 points makes 10 between segments. // If there are freeforms, we need the full 10 points after the last of them. int cfreeform = vwenv.get_DataAccess().get_VecSize(hvo, ktagSegFF); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, cfreeform == 0 ? 5000 : 10000); */ vwenv.OpenDiv(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseDiv(); break; // This frag is used to display a single interlin analysis that is always left-aligned, even for RTL languages case kfragSingleInterlinearAnalysisWithLabelsLeftAlign: vwenv.OpenDiv(); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, m_leftPadding); vwenv.OpenParagraph(); vwenv.OpenInnerPile(); DisplaySingleInterlinearAnalysisWithLabels(vwenv, hvo); vwenv.CloseInnerPile(); vwenv.CloseParagraph(); vwenv.CloseDiv(); break; //case kfragDefaultSense: // Some default sense // // NB: If the hvo is zero, then we need to go back to the normal missing sense display, after all. // // (hvo isn't zero, even for cases where there isn't even a default value.) // if (hvo > 0) // { // // Show default sense, in some other 'guess' color. // SetGuessing(vwenv, false); // foreach (int wsId in m_WsList.AnalysisWsIds) // vwenv.AddStringAltMember(LexSenseTags.kflidGloss, // wsId, this); // } // else // { // // Give up and show the missing sense row. // vwenv.AddString(m_tssMissingSense); // } // break; case kfragWordformForm: // The form of a WviWordform. vwenv.AddStringAltMember(WfiWordformTags.kflidForm, m_wsVernForDisplay, this); break; case kfragPrefix: vwenv.AddUnicodeProp(MoMorphTypeTags.kflidPrefix, m_wsVernForDisplay, this); break; case kfragPostfix: vwenv.AddUnicodeProp(MoMorphTypeTags.kflidPostfix, m_wsVernForDisplay, this); break; case kfragSenseName: // The name (gloss) of a LexSense. foreach (int wsId in m_WsList.AnalysisWsIds) vwenv.AddStringAltMember(LexSenseTags.kflidGloss, wsId, this); break; case kfragCategory: // the category of a WfiAnalysis, a part of speech; // display the Abbreviation property inherited from CmPossibility. foreach(var wsId in m_WsList.AnalysisWsIds) { vwenv.AddStringAltMember(CmPossibilityTags.kflidAbbreviation, wsId, this); } break; default: if (frag >= kfragWordGlossWs && frag < kfragWordGlossWs + m_WsList.AnalysisWsIds.Length) { // Displaying one ws of the form of a WfiGloss. int ws = m_WsList.AnalysisWsIds[frag - kfragWordGlossWs]; vwenv.AddStringAltMember(WfiGlossTags.kflidForm, ws, this); } else if (frag >= kfragLineChoices && frag < kfragLineChoices + m_lineChoices.Count) { var spec = m_lineChoices[frag - kfragLineChoices]; var ws = GetRealWsOrBestWsForContext(hvo, spec); vwenv.AddStringAltMember(spec.StringFlid, ws, this); } else if (frag >= kfragAnalysisCategoryChoices && frag < kfragAnalysisCategoryChoices + m_lineChoices.Count) { AddAnalysisPos(vwenv, hvo, hvo, frag - kfragAnalysisCategoryChoices); } else if (frag >= kfragMorphFormChoices && frag < kfragMorphFormChoices + m_lineChoices.Count) { InterlinLineSpec spec = m_lineChoices[frag - kfragMorphFormChoices]; int wsActual = GetRealWsOrBestWsForContext(hvo, spec); DisplayMorphForm(vwenv, hvo, wsActual); } else if (frag >= kfragSegFfChoices && frag < kfragSegFfChoices + m_lineChoices.Count) { AddFreeformComment(vwenv, hvo, frag - kfragSegFfChoices); } else { throw new Exception("Bad fragment ID in InterlinVc.Display"); } break; } #if DEBUG //TimeRecorder.End("Display"); #endif }
/// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch((ScrFrags)frag) { case ScrFrags.kfrScripture: { vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, (int)ScrFrags.kfrBook); break; } case ScrFrags.kfrBook: { vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, m_stvc, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); break; } case ScrFrags.kfrSection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, m_stvc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, m_stvc, (int)StTextFrags.kfrText); break; } default: Debug.Assert(false); break; } }
/// <summary> /// Insert a display of the relevant property for the indicated object, which is atomic. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> public void Insert(IVwEnv vwenv, int hvo) { vwenv.AddObjProp(FakePropTag, this, kfragName); }
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; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ITsStrFactory tsf = null; switch (frag) { case kfragStText: // The whole text, root object for the InterlinDocChild. if (hvo == 0) { return; // What if the user deleted all the texts? See LT-6727. } vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.OpenDiv(); StText stText = new StText(m_cache, hvo); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 24000); // Add both vernacular and analysis if we have them (LT-5561). bool fAddedVernacular = false; int wsVernTitle = 0; // if (stText.Title.TryWs(LangProject.kwsFirstVern, out wsVernTitle)) { vwenv.OpenParagraph(); vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this); vwenv.CloseParagraph(); fAddedVernacular = true; } int wsAnalysisTitle = 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); ITsString tssAnal; if (stText.Title.TryWs(LangProject.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) && !tssAnal.Equals(stText.Title.BestVernacularAlternative)) { if (fAddedVernacular) { // display analysis title at smaller font size. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); } vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this); } else { // just add a blank title. tsf = TsStrFactoryClass.Create(); ITsString blankTitle = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(blankTitle); } vwenv.CloseParagraph(); int wsSource = 0; ITsString tssSource = stText.SourceOfTextForWs(m_wsVernForDisplay); if (tssSource == null || tssSource.Length == 0) { tssSource = stText.SourceOfTextForWs(m_wsAnalysis); if (tssSource != null && tssSource.Length > 0) { wsSource = m_wsAnalysis; } } else { wsSource = m_wsVernForDisplay; } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); if (tssSource != null && tssSource.Length > 0) { vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.AddStringAltMember(vtagStTextSource, wsSource, this); vwenv.CloseParagraph(); } else { // just add a blank source. tsf = TsStrFactoryClass.Create(); ITsString tssBlank = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(tssBlank); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); if (stText.OwningFlid == (int)Text.TextTags.kflidContents) { vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription); } vwenv.CloseParagraph(); base.Display(vwenv, hvo, frag); vwenv.CloseDiv(); break; case kfragTextDescription: vwenv.AddStringAltMember((int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); break; case kfragSegFf: // One freeform annotation. int[] wssAnalysis = m_WsList.AnalysisWsIds; if (wssAnalysis.Length == 0) { break; // This is bizarre, but for the sake of paranoia... } tsf = TsStrFactoryClass.Create(); int hvoType = m_cache.MainCacheAccessor.get_ObjectProp(hvo, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType); string label = ""; if (hvoType == NoteSegmentDefn) { label = ITextStrings.ksNt; } else if (hvoType == FtSegmentDefn) { label = ITextStrings.ksFT; } else if (hvoType == LtSegmentDefn) { label = ITextStrings.ksLT; } else { throw new Exception("Unexpected FF annotation type"); } ITsString tssLabel = tsf.MakeString(label, m_cache.DefaultUserWs); ISilDataAccess sda = vwenv.DataAccess; if (wssAnalysis.Length == 1) { ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs); if (tss.Length == 0) { break; } vwenv.OpenParagraph(); vwenv.AddString(tssLabel); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs, this); vwenv.CloseParagraph(); } else { int labelWidth, labelHeight; vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight); // This roughly corresponds to the width of the space at the end of FT. // The nice way to do it (here and in the base class) would be a table or 'interlinear' paragraph. labelWidth += 3000; int cNonBlank = 0; for (int i = 0; i < wssAnalysis.Length; i++) { ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i]); if (tss.Length == 0) { continue; } if (cNonBlank != 0) { // Indent subsequent paragraphs by the width of the main label. vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, labelWidth); } vwenv.OpenParagraph(); if (cNonBlank == 0) { vwenv.AddString(tssLabel); } cNonBlank++; // after tests above! m_WsList.AddWsLabel(vwenv, i); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i], this); vwenv.CloseParagraph(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ITsStrFactory tsf = null; switch (frag) { case kfragStText: // The whole text, root object for the InterlinDocChild. if (hvo == 0) return; // What if the user deleted all the texts? See LT-6727. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.OpenDiv(); StText stText = new StText(m_cache, hvo); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 24000); // Add both vernacular and analysis if we have them (LT-5561). bool fAddedVernacular = false; int wsVernTitle = 0; // if (stText.Title.TryWs(LangProject.kwsFirstVern, out wsVernTitle)) { vwenv.OpenParagraph(); vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this); vwenv.CloseParagraph(); fAddedVernacular = true; } int wsAnalysisTitle = 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); ITsString tssAnal; if (stText.Title.TryWs(LangProject.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) && !tssAnal.Equals(stText.Title.BestVernacularAlternative)) { if (fAddedVernacular) { // display analysis title at smaller font size. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); } vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this); } else { // just add a blank title. tsf = TsStrFactoryClass.Create(); ITsString blankTitle = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(blankTitle); } vwenv.CloseParagraph(); int wsSource = 0; ITsString tssSource = stText.SourceOfTextForWs(m_wsVernForDisplay); if (tssSource == null || tssSource.Length == 0) { tssSource = stText.SourceOfTextForWs(m_wsAnalysis); if (tssSource != null && tssSource.Length > 0) wsSource = m_wsAnalysis; } else { wsSource = m_wsVernForDisplay; } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); if (tssSource != null && tssSource.Length > 0) { vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.AddStringAltMember(vtagStTextSource, wsSource, this); vwenv.CloseParagraph(); } else { // just add a blank source. tsf = TsStrFactoryClass.Create(); ITsString tssBlank = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(tssBlank); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); if (stText.OwningFlid == (int)Text.TextTags.kflidContents) { vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription); } vwenv.CloseParagraph(); base.Display(vwenv, hvo, frag); vwenv.CloseDiv(); break; case kfragTextDescription: vwenv.AddStringAltMember((int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); break; case kfragSegFf: // One freeform annotation. int[] wssAnalysis = m_WsList.AnalysisWsIds; if (wssAnalysis.Length == 0) break; // This is bizarre, but for the sake of paranoia... tsf = TsStrFactoryClass.Create(); int hvoType = m_cache.MainCacheAccessor.get_ObjectProp(hvo, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType); string label = ""; if (hvoType == NoteSegmentDefn) label = ITextStrings.ksNt; else if (hvoType == FtSegmentDefn) label = ITextStrings.ksFT; else if (hvoType == LtSegmentDefn) label = ITextStrings.ksLT; else throw new Exception("Unexpected FF annotation type"); ITsString tssLabel = tsf.MakeString(label, m_cache.DefaultUserWs); ISilDataAccess sda = vwenv.DataAccess; if (wssAnalysis.Length == 1) { ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs); if (tss.Length == 0) break; vwenv.OpenParagraph(); vwenv.AddString(tssLabel); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs, this); vwenv.CloseParagraph(); } else { int labelWidth, labelHeight; vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight); // This roughly corresponds to the width of the space at the end of FT. // The nice way to do it (here and in the base class) would be a table or 'interlinear' paragraph. labelWidth += 3000; int cNonBlank = 0; for (int i = 0; i < wssAnalysis.Length; i++) { ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i]); if (tss.Length == 0) continue; if (cNonBlank != 0) { // Indent subsequent paragraphs by the width of the main label. vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int) FwTextPropVar.ktpvMilliPoint, labelWidth); } vwenv.OpenParagraph(); if (cNonBlank == 0) vwenv.AddString(tssLabel); cNonBlank++; // after tests above! m_WsList.AddWsLabel(vwenv, i); vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i], this); vwenv.CloseParagraph(); } } 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) { ITsStrFactory tsf = null; switch (frag) { case kfragStText: // The whole text, root object for the InterlinDocChild. if (hvo == 0) return; // What if the user deleted all the texts? See LT-6727. IStText stText = m_coRepository.GetObject(hvo) as IStText; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.OpenDiv(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 24000); // Add both vernacular and analysis if we have them (LT-5561). bool fAddedVernacular = false; int wsVernTitle = 0; // if (stText.Title.TryWs(WritingSystemServices.kwsFirstVern, out wsVernTitle)) { vwenv.OpenParagraph(); vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this); vwenv.CloseParagraph(); fAddedVernacular = true; } int wsAnalysisTitle = 0; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); ITsString tssAnal; if (stText.Title.TryWs(WritingSystemServices.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) && !tssAnal.Equals(stText.Title.BestVernacularAlternative)) { if (fAddedVernacular) { // display analysis title at smaller font size. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); } vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this); } else { // just add a blank title. tsf = TsStrFactoryClass.Create(); ITsString blankTitle = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(blankTitle); } vwenv.CloseParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); int wsSource = 0; if (stText.Source.TryWs(WritingSystemServices.kwsFirstVernOrAnal, out wsSource)) { vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 12000); vwenv.AddStringAltMember(vtagStTextSource, wsSource, this); vwenv.CloseParagraph(); } else { // just add a blank source. tsf = TsStrFactoryClass.Create(); ITsString tssBlank = tsf.MakeString("", m_wsAnalysis); vwenv.AddString(tssBlank); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenParagraph(); if (stText.OwningFlid == TextTags.kflidContents) { vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription); } vwenv.CloseParagraph(); base.Display(vwenv, hvo, frag); vwenv.CloseDiv(); break; case kfragTextDescription: vwenv.AddStringAltMember(CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// <returns><c>true</c> if we dealt with the display, otherwise <c>false</c></returns> /// ------------------------------------------------------------------------------------ public bool Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. m_RealVc.ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { (int)ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(m_bookTag, m_RealVc, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBookTags.kflidTitle, m_RealVc, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems((int)ScrBookTags.kflidSections, m_RealVc, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBookTags.kflidFootnotes, m_RealVc, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrSectionTags.kflidHeading, m_RealVc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSectionTags.kflidContent, m_RealVc, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { // Open a table to display the vern para in column 1, and the BT para in column 2. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; vlColumn.nVal = 5000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = 2; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. true); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); if (m_RealVc.RightToLeft) { AddBtParagraph(vwenv, hvo, frag, false); AddVernParagraph(vwenv, hvo, frag, true); } else { AddVernParagraph(vwenv, hvo, frag, false); AddBtParagraph(vwenv, hvo, frag, true); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; } case (int)StTextFrags.kfrFootnoteReference: { m_RealVc.DisplayFootnoteReference(vwenv, hvo); break; } default: return(false); } return(true); }
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 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; } }
private void PrintColumnGroupHeaders(int hvo, IVwEnv vwenv) { MakeTableAndRowWithStdWidths(vwenv, hvo, true); MakeCellsMethod.OpenRowNumberCell(vwenv); // header for row numbers vwenv.AddString(m_cache.MakeAnalysisTss("#")); vwenv.CloseTableCell(); vwenv.AddObjProp((int)DsConstChart.DsChartTags.kflidTemplate, this, kfragTemplateHeader); MakeCellsMethod.OpenStandardCell(vwenv, 1, false); vwenv.AddString(m_cache.MakeAnalysisTss(DiscourseStrings.ksNotesColumnHeader)); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTable(); }
private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo) { ISilDataAccess sda = vwenv.DataAccess; int hvoLf = sda.get_ObjectProp(hvo, LexEntryTags.kflidLexemeForm); int hvoType = 0; if (hvoLf != 0) { hvoType = sda.get_ObjectProp(hvoLf, MoFormTags.kflidMorphType); } // If we have a type of morpheme, show the appropriate prefix that indicates it. // We want vernacular so it will match the point size of any aligned vernacular text. // (The danger is that the vernacular font doesn't have these characters...not sure what // we can do about that, but most do, and it looks awful in analysis if that is a // much different size from vernacular.) string sPrefix = null; if (hvoType != 0) { sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix); } // LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form. bool fGotLabel = false; int wsActual = 0; if (hvoLf != 0) { // if we have a lexeme form and its label is non-empty, use it. if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual)) { m_wsActual = wsActual; fGotLabel = true; if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); } vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm); } } if (!fGotLabel) { // If we didn't get a useful form from the lexeme form try the citation form. if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual)) { m_wsActual = wsActual; if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); } vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this); fGotLabel = true; } } int defUserWs = m_cache.WritingSystemFactory.UserWs; if (!fGotLabel) { // If that fails just show two questions marks. if (sPrefix != null) { vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); } vwenv.AddString(m_cache.TsStrFactory.MakeString(FdoUiStrings.ksQuestions, defUserWs)); // was "??", not "???" } // If we have a lexeme form type show the appropriate postfix. if (hvoType != 0) { vwenv.AddString(TsStringUtils.MakeTss( sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual)); } // Show homograph number if non-zero. int nHomograph = sda.get_IntProp(hvo, LexEntryTags.kflidHomographNumber); vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1); if (nHomograph > 0) { // Use a string builder to embed the properties in with the TsString. // this allows our TsStringCollectorEnv to properly encode the superscript. // ideally, TsStringCollectorEnv could be made smarter to handle SetIntPropValues // since AppendTss treats the given Tss as atomic. ITsIncStrBldr tsBldr = TsIncStrBldrClass.Create(); tsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvSub); tsBldr.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); tsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, defUserWs); var hc = m_cache.ServiceLocator.GetInstance <HomographConfiguration>(); StringServices.InsertHomographNumber(tsBldr, nHomograph, hc, HomographConfiguration.HeadwordVariant.Main, m_cache); vwenv.AddString(tsBldr.GetString()); } }
private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo) { ISilDataAccess sda = vwenv.DataAccess; int hvoLf = sda.get_ObjectProp(hvo, LexEntryTags.kflidLexemeForm); int hvoType = 0; if (hvoLf != 0) { hvoType = sda.get_ObjectProp(hvoLf, MoFormTags.kflidMorphType); } // If we have a type of morpheme, show the appropriate prefix that indicates it. // We want vernacular so it will match the point size of any aligned vernacular text. // (The danger is that the vernacular font doesn't have these characters...not sure what // we can do about that, but most do, and it looks awful in analysis if that is a // much different size from vernacular.) string sPrefix = null; if (hvoType != 0) { sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix); } // LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form. bool fGotLabel = false; int wsActual = 0; if (hvoLf != 0) { // if we have a lexeme form and its label is non-empty, use it. if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual)) { m_wsActual = wsActual; fGotLabel = true; if (sPrefix != null) vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm); } } if (!fGotLabel) { // If we didn't get a useful form from the lexeme form try the citation form. if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual)) { m_wsActual = wsActual; if (sPrefix != null) vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this); fGotLabel = true; } } int defUserWs = m_cache.WritingSystemFactory.UserWs; if (!fGotLabel) { // If that fails just show two questions marks. if (sPrefix != null) vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual)); vwenv.AddString(m_cache.TsStrFactory.MakeString(FdoUiStrings.ksQuestions, defUserWs)); // was "??", not "???" } // If we have a lexeme form type show the appropriate postfix. if (hvoType != 0) { vwenv.AddString(TsStringUtils.MakeTss( sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual)); } // Show homograph number if non-zero. int nHomograph = sda.get_IntProp(hvo, LexEntryTags.kflidHomographNumber); vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1); if (nHomograph > 0) { // Use a string builder to embed the properties in with the TsString. // this allows our TsStringCollectorEnv to properly encode the superscript. // ideally, TsStringCollectorEnv could be made smarter to handle SetIntPropValues // since AppendTss treats the given Tss as atomic. ITsIncStrBldr tsBldr = TsIncStrBldrClass.Create(); tsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvSub); tsBldr.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); tsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, defUserWs); tsBldr.Append(nHomograph.ToString()); vwenv.AddString(tsBldr.GetString()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { if ((m_displayType & DisplayType.kLiteralStringLabels) != 0) { ITsStrFactory factory = TsStrFactoryClass.Create(); vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault)); } switch (frag) { case 1: // the root; display the subitems, first using non-lazy view, then lazy one. if ((m_displayType & DisplayType.kBookFootnoteDetailsSeparateParas) == DisplayType.kBookFootnoteDetailsSeparateParas) { vwenv.AddObjVecItems(m_flid, this, 10); } if ((m_displayType & DisplayType.kBookFootnoteDetailsSinglePara) == DisplayType.kBookFootnoteDetailsSinglePara) { vwenv.AddObjVecItems(m_flid, this, 11); } else { if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) { vwenv.AddObjVecItems(m_flid, this, 3); } if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) { vwenv.AddObjVecItems(m_flid, this, 2); } } if ((m_displayType & DisplayType.kBookTitle) == DisplayType.kBookTitle) { vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 3); } if (m_displayType == DisplayType.kOuterObjDetails) { vwenv.AddObjVecItems(m_flid, this, 6); } break; case 2: // An StText, display paragraphs lazily if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) { vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 4); } vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 5); break; case 3: // An StText, display paragraphs not lazily. if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin) { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 4); } vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5); if ((m_displayType & DisplayType.kDuplicateParagraphs) != 0) { vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5); } break; case 4: // StTxtPara, display contents with top margin if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.OpenMappedPara(); } vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, kMarginTop); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.CloseParagraph(); } break; case 5: // StTxtPara, display contents without top margin //vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, // (int)FwTextPropVar.ktpvMilliPoint, 15000); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.OpenMappedPara(); } vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.CloseParagraph(); } break; case 6: // StTxtPara, display details of our outer object int hvoOuter, tag, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo); ITsString tss = TsStringHelper.MakeTSS("Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo, m_wsDefault); vwenv.AddString(tss); break; case ScrBookTags.kflidSections: vwenv.AddObjVecItems(ScrBookTags.kflidSections, this, ScrSectionTags.kflidContent); break; case ScrSectionTags.kflidHeading: case ScrSectionTags.kflidContent: if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal) { vwenv.AddObjProp(frag, this, 3); } if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy) { vwenv.AddObjProp(frag, this, 2); } break; case 7: // ScrBook vwenv.OpenDiv(); vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, 8); vwenv.CloseDiv(); break; case 8: // StFootnote vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 9); break; case 9: // StTxtPara vwenv.AddStringProp(StTxtParaTags.kflidContents, null); break; case 10: // Display a Footnote by displaying its "FootnoteMarker" in a paragraph // by itself, followed by the sequence of paragraphs. vwenv.AddStringProp(StFootnoteTags.kflidFootnoteMarker, null); vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 9); break; case 11: // Display a Footnote by displaying its "FootnoteMarker" followed by the // contents of its first paragraph (similar to the way footnotes are displayed in // real life. vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 12); break; case 12: // Footnote paragraph with marker vwenv.OpenMappedTaggedPara(); // The footnote marker is not editable. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); // add a read-only space after the footnote marker vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); ITsStrFactory strFactory = TsStrFactoryClass.Create(); vwenv.AddString(strFactory.MakeString(" ", DefaultWs)); vwenv.AddStringProp(StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; default: throw new ApplicationException("Unexpected frag in DummyBasicViewVc"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an expandable annotation of the specified type. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayExpandableAnnotation(IVwEnv vwenv, IScrScriptureNote ann, int tag, int hvo, IStJournalText paras, ITsString label, bool readOnly) { vwenv.NoteDependency(new int[] { hvo }, new int[] { m_expansionTag }, 1); SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display +/- in the second cell, unless this is read-only vwenv.OpenTableCell(1, 1); if (!readOnly) vwenv.AddObjProp(tag, this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display text in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(label); if (!m_expandTable.ContainsKey(hvo)) vwenv.AddString(paras[0].Contents); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); if (!m_expandTable.ContainsKey(hvo)) return; SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display text in cells 3-7 vwenv.OpenTableCell(1, 5); if (!readOnly) SetEditBackground(vwenv); vwenv.AddObjProp(tag, this, (int)StTextFrags.kfrText); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } if (!PrintLayout) { InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert(m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) { picture = m_CheckedPic; } else if (status == BackTranslationStatus.Finished.ToString()) { picture = m_FinishedPic; } else { picture = m_UnfinishedPic; } vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] { hvo }, new [] { CmTranslationTags.kflidStatus }, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by 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 specified vwenv. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="frag">The frag.</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case kfragLazyScripture: { // The configure method insists on trying to make an initial selection. // If there isn't something selectable there, it expands everything. vwenv.AddStringProp((int)Scripture.ScriptureTags.kflidChapterVerseSepr, this); vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragLazyBook); break; } case kfragLazyBook: { vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, kfragDummySection); break; } case kfragDummySection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, kfragDummyStText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, kfragDummyStText); break; } case kfragDummyStText: { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, m_fParaWithContent ? kfragDummyParaWithContent : kfragDummyPara); break; } case kfragDummyPara: { // Display each dummy paragraph as a rectangle an inch high, which allows us // to accurately predict the height of a known number of them. vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0); break; } case kfragDummyParaWithContent: { vwenv.OpenMappedTaggedPara(); vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[]{m_cache.LanguageProject.TranslatedScriptureOA.Hvo}, new[]{ScriptureTags.kflidScriptureBooks}, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); if (!PrintLayout) InsertBookSeparator(hvo, vwenv); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert (m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance<IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance<ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) picture = m_CheckedPic; else if (status == BackTranslationStatus.Finished.ToString()) picture = m_FinishedPic; else picture = m_UnfinishedPic; vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] {hvo}, new [] {CmTranslationTags.kflidStatus}, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }