/// <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(); }
private void DisplayMinMax(int numLines, IVwEnv vwenv) { int superOffset = 0; if (numLines == 1) { // if the inner context is a single line, then make the min value a subscript and the max value a superscript. // I tried to use the Views subscript and superscript properties, but they added extra space so that it would // have the same line height of a normal character, which is not what I wanted, so I compute the size myself int fontHeight = GetFontHeight(m_cache.DefaultUserWs); int superSubHeight = (fontHeight * 2) / 3; vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, superSubHeight); vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight, (int)FwTextPropVar.ktpvMilliPoint, -superSubHeight); superOffset = superSubHeight / 2; } else { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); } vwenv.OpenInnerPile(); if (numLines == 1) { vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, superOffset); } vwenv.OpenParagraph(); vwenv.AddProp(ktagRightNonBoundary, this, kfragNodeMax); vwenv.CloseParagraph(); AddExtraLines(numLines - 2, ktagRightNonBoundary, vwenv); vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, 0); vwenv.OpenParagraph(); vwenv.AddProp(ktagRightBoundary, this, kfragNodeMin); vwenv.CloseParagraph(); vwenv.CloseInnerPile(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load data needed to display the specified objects using the specified fragment. /// This is called before attempting to Display an item that has been listed for lazy /// display using AddLazyItems. It may be used to load the necessary data into the /// DataAccess object. /// </summary> /// <param name="vwenv"></param> /// <param name="rghvo"></param> /// <param name="chvo"></param> /// <param name="hvoParent"></param> /// <param name="tag"></param> /// <param name="frag"></param> /// <param name="ihvoMin"></param> /// ------------------------------------------------------------------------------------ public override void LoadDataFor(IVwEnv vwenv, int[] rghvo, int chvo, int hvoParent, int tag, int frag, int ihvoMin) { CheckDisposed(); // we do nothing in our test }
protected int GetStrWidth(ITsString tss, ITsTextProps props, IVwEnv vwenv) { int dmpx, dmpy; vwenv.get_StringWidth(tss, props, out dmpx, out dmpy); return(dmpx); }
/// ------------------------------------------------------------------------------------ /// <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) { if (!m_VcImpl.Display(vwenv, hvo, frag)) { base.Display(vwenv, hvo, frag); } }
/// <summary> /// Set the indent needed when the icon is missing. /// </summary> /// <param name="vwenv"></param> private void SetIndentForMissingIcon(IVwEnv vwenv) { vwenv.set_IntProperty( (int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, m_dxmpArrowPicWidth + kmpIconMargin); }
public void UserPromptForBookTitleWithEmptyPara() { CheckDisposed(); // Set up title with an empty paragraph StText title = m_inMemoryCache.AddTitleToMockedBook(m_book.Hvo, m_emptyTsString, StyleUtils.ParaStyleTextProps(ScrStyleNames.MainBookTitle)); Options.ShowEmptyParagraphPromptsSetting = true; DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs); CreateExpectedUserPrompt(stVc, title.ParagraphsOS.FirstItem.Hvo, (int)ScrBook.ScrBookTags.kflidTitle, (int)StTxtPara.StTxtParaTags.kflidContents); m_vwenvMock.ExpectAndReturn("CurrentObject", title.ParagraphsOS.FirstItem.Hvo); IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance; bool fTextAdded = stVc.CallInsertUserPrompt(vwEnv, title.ParagraphsOS.FirstItem.Hvo); Assert.IsTrue(fTextAdded, "User prompt not added"); ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null, (int)ScrBook.ScrBookTags.kflidTitle); string difference; bool fEqual = TsStringHelper.TsStringsAreEqual( ExpectedUserPrompt("Type book title for Philemon here", m_inMemoryCache.Cache.DefaultVernWs), text, out difference); Assert.IsTrue(fEqual, difference); m_vwenvMock.Verify(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. Most /// subclasses should override. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRoot: // assume the root object has been loaded. base.Display(vwenv, hvo, frag); vwenv.AddObj(khvoNewItem, this, kfragEditRow); break; case kfragEditRow: AddEditRow(vwenv, hvo); break; case kfragListItem: if (hvo != khvoNewItem) { base.Display(vwenv, hvo, frag); } break; default: base.Display(vwenv, hvo, frag); break; } }
private bool InEditableRow(IVwEnv vwenv) { int hvoTop, tag, ihvo; vwenv.GetOuterObject(1, out hvoTop, out tag, out ihvo); return(m_editableHvos.Contains(hvoTop)); }
/// <summary> /// Processes the empty vector. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="flid">The flid.</param> private void ProcessEmptyVector(IVwEnv vwenv, int hvo, int flid) { // If we're collecting displayed items, and we could have a list of items but don't, // add an hvo of 0 to the collection for use in filtering on missing information. // See LT-9687. if (vwenv is XmlBrowseViewBaseVc.ItemsCollectorEnv) { // The complexities of LexEntryRef objects makes the following special case code // necessary to achieve satisfactory results for LT-9687. if (flid == LexEntryRefTags.kflidComplexEntryTypes) { int type = m_sda.get_IntProp(hvo, LexEntryRefTags.kflidRefType); if (type != LexEntryRefTags.krtComplexForm) { return; } } else if (flid == LexEntryRefTags.kflidVariantEntryTypes) { int type = m_sda.get_IntProp(hvo, LexEntryRefTags.kflidRefType); if (type != LexEntryRefTags.krtVariant) { return; } } if ((vwenv as XmlBrowseViewBaseVc.ItemsCollectorEnv).HvosCollectedInCell.Count == 0) { (vwenv as XmlBrowseViewBaseVc.ItemsCollectorEnv).HvosCollectedInCell.Add(0); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) { return; // not much we can display without a valid object } switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(m_sectionTag, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// <summary> /// /// </summary> public override void TestTearDown() { Options.ShowEmptyParagraphPromptsSetting = m_oldPromptSetting; m_book = null; m_vwenvMock = null; base.TestTearDown(); }
private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { XmlNode node = m_columns[i - 1]; // Make a cell and embed an editable virtual string for the column. var editable = XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true); if (!editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, NoEditBackgroundColor); } vwenv.OpenTableCell(1, 1); int flid = XMLViewsDataCache.ktagEditColumnBase + i; int ws = WritingSystemServices.GetWritingSystem(m_cache, node, null, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle).Handle; // Paragraph directionality must be set before the paragraph is opened. bool fRTL = IsWsRTL(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
public override ITsString DisplayVariant(IVwEnv vwenv, int tag, int frag) { CheckDisposed(); switch (frag) { case kfragMissingMorphs: return(m_tssMissingMorphs); case kfragMissingEntry: return(m_tssMissingEntry); case kfragMissingMorphGloss: return(m_tssMissingMorphGloss); case kfragMissingMorphPos: return(m_tssMissingMorphPos); case kfragMissingWordPos: return(m_tssMissingWordPos); default: throw new Exception("Bad fragment ID in SandboxVc.DisplayVariant"); } }
public override ITsString DisplayVariant(IVwEnv vwenv, int tag, int frag) { // we use display variant to display literal strings that are editable ITsString tss; switch (frag) { case kfragFeatureLine: var value = m_cache.ServiceLocator.GetInstance <IFsClosedValueRepository>().GetObject(vwenv.CurrentObject()); tss = CreateFeatureLine(value); break; case kfragPlusVariableLine: case kfragMinusVariableLine: var var = m_cache.ServiceLocator.GetInstance <IPhFeatureConstraintRepository>().GetObject(vwenv.CurrentObject()); tss = CreateVariableLine(var, frag == kfragPlusVariableLine); break; case kfragIterCtxtMax: // if the max value is -1, it indicates that it is infinite int i = m_cache.DomainDataByFlid.get_IntProp(vwenv.CurrentObject(), tag); tss = i == -1 ? m_infinity : TsStringUtils.MakeString(Convert.ToString(i), m_cache.DefaultUserWs); break; case kfragXVariable: tss = m_x; break; default: tss = base.DisplayVariant(vwenv, tag, frag); break; } return(tss); }
int GetNCFeatsWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv) { int maxLen = 0; IPhNCFeatures natClass = ctxt.FeatureStructureRA as IPhNCFeatures; foreach (IFsFeatureSpecification spec in natClass.FeaturesOA.FeatureSpecsOC) { IFsClosedValue curVal = spec as IFsClosedValue; ITsString featLine = CreateFeatureLine(curVal); int len = GetStrWidth(featLine, null, vwenv); if (len > maxLen) { maxLen = len; } } int plusLen = GetVariablesWidth(ctxt, vwenv, true); if (plusLen > maxLen) { maxLen = plusLen; } int minusLen = GetVariablesWidth(ctxt, vwenv, false); if (minusLen > maxLen) { maxLen = minusLen; } return(maxLen); }
public void NoUserPromptForBTWithEmptyPara() { CheckDisposed(); // Set up a section and empty paragraph IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); section.AdjustReferences(); // Add an empty translation to the paragraph int wsBT = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT); m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null); DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs); m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName, typeof(int[]).FullName, typeInt }); m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt, typeof(IVwViewConstructor).FullName, typeInt }); // verify that the prompt does not get added IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance; bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo); Assert.IsFalse(fTextAdded, "User prompt was added and should not have been"); // verify the mock m_vwenvMock.Verify(); }
/// <summary> /// Gets the width of the specified context or variable. /// </summary> /// <param name="ctxtOrVar">The context or variable.</param> /// <param name="vwenv">The vwenv.</param> /// <returns></returns> protected int GetWidth(IPhContextOrVar ctxtOrVar, IVwEnv vwenv) { if (ctxtOrVar == null) { return(0); } switch (ctxtOrVar.ClassID) { case PhSequenceContext.kclsidPhSequenceContext: IPhSequenceContext seqCtxt = ctxtOrVar as IPhSequenceContext; int totalLen = 0; foreach (IPhPhonContext cur in seqCtxt.MembersRS) { totalLen += GetWidth(cur, vwenv); } return(totalLen); case PhIterationContext.kclsidPhIterationContext: return(GetIterCtxtWidth(ctxtOrVar as IPhIterationContext, vwenv) + (PILE_MARGIN * 2)); case PhVariable.kclsidPhVariable: return(GetStrWidth(m_x, null, vwenv) + (PILE_MARGIN * 2)); default: return(GetSimpleCtxtWidth(ctxtOrVar as IPhSimpleContext, vwenv) + (PILE_MARGIN * 2)); } }
int GetIterCtxtWidth(IPhIterationContext ctxt, IVwEnv vwenv) { if (ctxt.MemberRAHvo != 0) { int len = GetSimpleCtxtWidth(ctxt.MemberRA as IPhSimpleContext, vwenv); int numLines = GetNumLines(ctxt.MemberRA); if (numLines > 1) { len += GetMinMaxWidth(ctxt, null, vwenv); } else { if (ctxt.MemberRA.ClassID != PhSimpleContextNC.kclsidPhSimpleContextNC) { len += GetStrWidth(m_leftParen, null, vwenv); len += GetStrWidth(m_rightParen, null, vwenv); } int fontHeight = GetFontHeight(m_cache.DefaultUserWs); int superSubHeight = (fontHeight * 2) / 3; ITsPropsBldr tpb = TsPropsBldrClass.Create(); tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, superSubHeight); len += GetMinMaxWidth(ctxt, tpb.GetTextProps(), vwenv); } return(len); } else { return(GetStrWidth(m_questions, null, vwenv)); } }
/// ------------------------------------------------------------------------------------ /// <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> /// Check the given translation to see if the text is empty. If so, then insert a /// user prompt. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="trans">translation to be displayed</param> /// <returns>true if an empty string was substituted for missing/empty StText</returns> /// ------------------------------------------------------------------------------------ protected override bool InsertTranslationUserPrompt(IVwEnv vwenv, ICmTranslation trans) { // No user prompt in any of these conditions if (trans == null || m_updatedPrompts.Contains(trans.Hvo)) // user interaction has updated prompt { return(false); } // If there is text in the translation then do not add a prompt. if (trans.Translation.get_String(m_wsDefault).Length > 0) { return(false); } // If there is no text in the parent paragraph then do not place a prompt in the // back translation. if (((IStTxtPara)trans.Owner).Contents.Length == 0) { return(false); } // Insert the prompt. vwenv.NoteDependency(new int[] { trans.Hvo }, new int[] { CmTranslationTags.kflidTranslation }, 1); vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmTranslationTags.kflidTranslation); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by 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. 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> /// Insert end of paragraph or section marks, if needed. Highlight the markers if /// they are part of a diff range in a paragraph split, merge or structure change. /// </summary> /// <param name="vwenv"></param> /// <param name="paraHvo"></param> /// ------------------------------------------------------------------------------------ protected override void InsertEndOfParaMarks(IVwEnv vwenv, int paraHvo) { IStTxtPara para = m_cache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(paraHvo); Difference rootDiff = m_Differences.CurrentDifference; bool fParaNeedsBoundaryHighlight = NeedsBoundaryHighlight(rootDiff, para); if (m_target == LayoutViewTarget.targetDraft && fParaNeedsBoundaryHighlight) { // Set up for an end mark. // If this is the last paragraph of a section then insert an // end of section mark, otherwise insert a paragraph mark. VwBoundaryMark boundaryMark; IFdoOwningSequence <IStPara> paraArray = ((IStText)para.Owner).ParagraphsOS; if (para == paraArray[paraArray.Count - 1]) { boundaryMark = VwBoundaryMark.endofSectionHighlighted; // "§" } else { boundaryMark = VwBoundaryMark.endOfParagraphHighlighted; // "¶" } vwenv.SetParagraphMark(boundaryMark); } }
private void DisplayInflFeatureLines(IVwEnv vwenv, IDictionary <IFsFeatDefn, object> inflFeatures, bool openPara) { IDictionary <IFsFeatDefn, object> lastInflFeatures = m_curInflFeatures; m_curInflFeatures = inflFeatures; foreach (KeyValuePair <IFsFeatDefn, object> kvp in inflFeatures) { if (kvp.Key is IFsComplexFeature) { if (openPara) { vwenv.OpenParagraph(); } vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine); DisplayInflFeatures(vwenv, (IDictionary <IFsFeatDefn, object>)kvp.Value); if (openPara) { vwenv.CloseParagraph(); } } else { vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine); } } m_curInflFeatures = lastInflFeatures; }
private void MakeNextFlowObjectReadOnly(IVwEnv vwenv) { vwenv.set_IntProperty( (int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); }
public void UserPromptForSectionHeadWithEmptyPara() { CheckDisposed(); // Set up section head with an empty paragraph IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "", ScrStyleNames.SectionHead); section.AdjustReferences(); Options.ShowEmptyParagraphPromptsSetting = true; DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs); CreateExpectedUserPrompt(stVc, para.Hvo, (int)ScrSection.ScrSectionTags.kflidHeading, (int)StTxtPara.StTxtParaTags.kflidContents); IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance; bool fTextAdded = stVc.CallInsertUserPrompt(vwEnv, para.Hvo); Assert.IsTrue(fTextAdded, "User prompt not added"); ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null, (int)ScrSection.ScrSectionTags.kflidHeading); string difference; bool fEqual = TsStringHelper.TsStringsAreEqual( ExpectedUserPrompt("Type section head here", m_inMemoryCache.Cache.DefaultVernWs), text, out difference); Assert.IsTrue(fEqual, difference); m_vwenvMock.Verify(); }
// This evaluates a paragraph to find out whether to display a user prompt, and if so, // inserts one. protected override bool InsertParaContentsUserPrompt(IVwEnv vwenv, int paraHvo) { // The only easy solution for LT-1437 "Pasting in a text produces unequal results" // is to not have the user prompt! return(false); //ISilDataAccess sda = vwenv.DataAccess; // If our hvo is not the first and only paragraph of an owning StText, it isn't // interesting. //int hvoOwner = sda.get_ObjectProp(hvo, // (int)CmObjectFields.kflidCmObject_Owner); //if (sda.get_VecItem(hvoOwner, (int) StText.StTextTags.kflidParagraphs, 0) != hvo) // return false; //if (sda.get_VecSize(hvoOwner, (int) StText.StTextTags.kflidParagraphs) > 1) // return false; // Also if it isn't empty. //if (sda.get_StringProp(hvo, (int)StTxtPara.StTxtParaTags.kflidContents). // Length > 0) //{ // return false; //} //vwenv.NoteDependency(new int[] { hvo}, // new int[] { (int)StTxtPara.StTxtParaTags.kflidContents}, 1); //vwenv.AddProp(kTagUserPrompt, this, 1); //return true; }
/// ------------------------------------------------------------------------------------ /// <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 = 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> /// We need to show something, since the current view code can't handle a property /// containing no boxes. Check to see if the StText is missing or if there are /// no paragraphs. If so, then put in an empty string placeholder. /// TODO (FWR-1688): If we prevent the occurrence of texts with no paragraphs in FDO, /// this code can be removed. /// </summary> /// <param name="vwenv">view environment</param> /// <param name="hvo">id of object to be displayed</param> /// <returns>true if an empty string was substituted for missing/empty StText</returns> /// ----------------------------------------------------------------------------------- protected bool HandleEmptyText(IVwEnv vwenv, int hvo) { if (hvo == 0 || vwenv.DataAccess.get_VecSize(hvo, StTextTags.kflidParagraphs) > 0) { return(false); } // Either we have no ST object at all, or it is empty of paragraphs. The // current view code can't handle either, so stick something in. // ENHANCE JohnT: come up with a real solution. This makes it look right, // but we should (a) be able to edit and have the first paragraph and // if necessary the text itself be created; and (b) if someone adds a real // paragraph and/or text in some other view, have them show up. int ws = vwenv.DataAccess.WritingSystemFactory.UserWs; ITsString tssMissing = TsStringUtils.EmptyString(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor, (int)FwTextPropVar.ktpvDefault, m_BackColor.ToArgb()); vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, m_sDefaultParaStyle); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); // This sets the current default writing system from the relevant field spec. vwenv.set_IntProperty((int)FwTextPropType.ktptBaseWs, (int)FwTextPropVar.ktpvDefault, m_wsDefault); vwenv.AddString(tssMissing); return(true); }
/// <summary> /// Gets the width of the specified context or variable. /// </summary> /// <param name="ctxtOrVar">The context or variable.</param> /// <param name="vwenv">The vwenv.</param> /// <returns></returns> protected int GetWidth(IPhContextOrVar ctxtOrVar, IVwEnv vwenv) { if (ctxtOrVar == null) { return(0); } switch (ctxtOrVar.ClassID) { case PhSequenceContextTags.kClassId: var seqCtxt = (IPhSequenceContext)ctxtOrVar; int totalLen = 0; foreach (IPhPhonContext cur in seqCtxt.MembersRS) { totalLen += GetWidth(cur, vwenv); } return(totalLen); case PhIterationContextTags.kClassId: return(GetIterCtxtWidth(ctxtOrVar as IPhIterationContext, vwenv) + (PileMargin * 2)); case PhVariableTags.kClassId: return(GetStrWidth(m_x, null, vwenv) + (PileMargin * 2)); default: return(GetSimpleCtxtWidth(ctxtOrVar as IPhSimpleContext, vwenv) + (PileMargin * 2)); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case kfrBook: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 24000); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBold, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptAlign, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextAlign.ktalCenter); vwenv.AddStringProp(ktagBookName, this); vwenv.AddLazyVecItems(ktagBookSections, this, kfrSection); break; case kfrSection: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptItalic, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.OpenParagraph(); vwenv.AddStringProp(ktagSectionTitle, this); vwenv.AddString(m_tssLeftParen); vwenv.AddStringProp(ktagSectionRefs, this); vwenv.AddString(m_tssRightParen); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagSectionParas, this, kfrDoublePara); break; case kfrDoublePara: AddDoublePara(vwenv, hvo); // Now insert an interlinear version of the paragraph. This is basically editable. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault, m_colorEditable); vwenv.OpenParagraph(); vwenv.AddObjVecItems(ktagParaBundles, this, kfrBundle); vwenv.CloseParagraph(); break; case kfrBundle: // Put a little space after each bundle to separate them. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptMarginTrailing, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenInnerPile(); vwenv.AddStringProp(ktagBundleBase, this); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBold, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.FwTextToggleVal.kttvOn); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 13000); vwenv.AddStringProp(ktagBundleIdiom, this); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptFontSize, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 8000); vwenv.AddStringProp(ktagBundleLing, this); vwenv.CloseInnerPile(); break; } }
/// <summary> /// For testing without a 'real' vwEnv object. /// </summary> public ChartRowEnvDecorator() { m_vwEnv = null; IsRtL = false; m_numOfCalls = 0; m_calledMethods = new List<StoredMethod>(); m_iStartEmbedding = new List<int>(); m_fInRegurgitation = false; }
protected override int HvoOfObjectToDisplay(IVwEnv vwenv, int hvo) { ISilDataAccess sda = vwenv.DataAccess; int chvo = sda.get_VecSize(hvo, m_flid); if (chvo < 1) return 0; else return sda.get_VecItem(hvo, m_flid, 0); }
protected override int HvoOfObjectToDisplay(IVwEnv vwenv, int hvo) { ISilDataAccess sda = vwenv.DataAccess; int chvo = sda.get_VecSize(hvo, m_flid); if (chvo < 2) return 0; int hvoItem = sda.get_VecItem(hvo, m_flid, 0); if (hvoItem == m_hvoDisplayParent) hvoItem = sda.get_VecItem(hvo, m_flid, 1); return hvoItem; }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case HelloViewView.kfrText: vwenv.AddStringProp(HelloViewView.ktagProp, this); break; } }
/// <summary> /// The method object's constructor. /// </summary> /// <param name="vc">The view constructor</param> /// <param name="vwenv">The view environment</param> /// <param name="hvo">A handle on the root object</param> /// <param name="flid">The field ID</param> /// <param name="frag">A code identifying the current part of the display</param> public XmlVcDisplayVec(XmlVc vc, IVwEnv vwenv, int hvo, int flid, int frag) { m_viewConstructor = vc; m_vwEnv = vwenv; m_hvo = hvo; m_flid = flid; m_frag = frag; m_cache = m_viewConstructor.Cache; m_sda = m_viewConstructor.DataAccess; if (vwenv.DataAccess != null) m_sda = vwenv.DataAccess; m_objRepo = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>(); m_stringTable = m_viewConstructor.StringTbl; }
/// <summary> /// Calling vwenv.AddObjVec() in Display() and implementing DisplayVec() seems to /// work better than calling vwenv.AddObjVecItems() in Display(). Theoretically /// this should not be case, but experience trumps theory every time. :-) :-( /// </summary> public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { CheckDisposed(); ISilDataAccess da = vwenv.DataAccess; int count = da.get_VecSize(hvo, tag); // Tree Branches consist of everything FOLLOWING the first element which is the Tree root. for (int i = 1; i < count; ++i) { vwenv.AddObj(da.get_VecItem(hvo, tag, i), this, VectorReferenceView.kfragTargetObj); vwenv.AddSeparatorBar(); } }
/// ------------------------------------------------------------------------------------ /// <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) { 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(ScriptureTags.kflidChapterLabel, this); vwenv.AddLazyVecItems(ScriptureTags.kflidScriptureBooks, this, kfragLazyBook); break; } case kfragLazyBook: { vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, kfragDummySection); break; } case kfragDummySection: { vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, kfragDummyStText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, kfragDummyStText); break; } case kfragDummyStText: { vwenv.AddObjVecItems(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(StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Display some simple rectangles to represent a header and a footer. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { // Display each dummy header or footer as a rectangle, which allows us // to accurately predict the height. switch(hvo) { case DummyHeaderFooterConfigurer.khvoHeader: vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch / 4, 0); break; case DummyHeaderFooterConfigurer.khvoFooter: vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0); break; default: Assert.Fail(); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case InterlinearView.kfrText: vwenv.OpenParagraph(); vwenv.AddObjVecItems(InterlinearView.ktagText_Words, this, InterlinearView.kfrWord); vwenv.CloseParagraph(); break; case InterlinearView.kfrWord: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptMarginTrailing, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); vwenv.AddStringProp(InterlinearView.ktagWord_Form, this); vwenv.AddStringProp(InterlinearView.ktagWord_Type, this); vwenv.CloseInnerPile(); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.AddLazyVecItems(ScriptureTags.kflidScriptureBooks, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrBook: { vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, m_stvc, (int)StTextFrags.kfrFootnote); break; } default: Debug.Assert(false); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified vwenv. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="frag">The frag.</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragScrFootnotes: { vwenv.AddObjVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragBookFootnotes); break; } case kfragBookFootnotes: { vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this, kfragFootnote); break; } case kfragFootnote: { // Display each dummy footnote as a rectangle a half inch high, which allows us // to accurately predict the height of a known number of them. Also put in a very // short editable string, which we use for some other tests, but should not // affect the paragraph height. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 10); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 5); vwenv.OpenParagraph(); if (m_fWantStrings) vwenv.AddStringProp((int)StFootnote.StFootnoteTags.kflidFootnoteMarker, this); vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch / 2, MiscUtils.kdzmpInch / 2, 0); vwenv.CloseParagraph(); break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); if (hvo == 0) return; // not much we can display without a valid object switch (frag) { case (int)ScrFrags.kfrBook: vwenv.OpenDiv(); vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new int[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.NoteDependency(new int[] { hvo }, new int[] { ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// This override provides special difference highlighting for a footnote paragraph. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { switch(frag) { case (int)StTextFrags.kfrFootnotePara: { IScrTxtPara para = Cache.ServiceLocator.GetInstance<IScrTxtParaRepository>().GetObject(hvo); // Even if we don't display BT yet we want to create the translations, so // it will be included in the undo action sequence. // Otherwise we're having problems with Undo after the Diff dialog // is closed (TE-4896). GetTranslationForPara(para.Hvo); m_DispPropOverrides.Clear(); // If the given footnote paragraph has differences to be highlighted, // add appropriate properties. // Note: When the diff type is ParagraphMissingInCurrent, we don't scan the new // para for text diffs - we will just copy all of it including its footnotes. // So there may be no sub-diffs created for the footnotes present. Thus we won't // be highlighting those footnotes. if (m_fNeedHighlight) AddOverridesToHighlightFootnoteDiff(para); // the base Display will do the actual displaying of the FootnotePara frag base.Display(vwenv, hvo, frag); break; } default: // handle all other frags base.Display(vwenv, hvo, frag); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// Handles displaying the vector of words with commas except after the last /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="tag"></param> /// <param name="frag"></param> /// ----------------------------------------------------------------------------------- public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { CheckDisposed(); Debug.Assert(frag == kfragWords); ISilDataAccess sda = vwenv.DataAccess; int cwords = sda.get_VecSize(hvo, ktagWords); for (int i = 0; i < cwords; i++) { vwenv.AddObj(sda.get_VecItem(hvo, ktagWords, i), this, kfragName); if (i != cwords - 1) vwenv.AddString(m_tssComma); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ----------------------------------------------------------------------------------- public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case kfragRoot: ITsString tssWord = vwenv.DataAccess.get_StringProp(hvo, ktagCf); ITsStrBldr tsbSdRelation = m_tssSdRelation.GetBldr(); ITsStrBldr tsbLexRel = m_tssLexRelation.GetBldr(); if (tssWord != null && tssWord.Length > 0) { int ich = tsbSdRelation.Text.IndexOf("{0}"); if (ich >= 0) tsbSdRelation.ReplaceTsString(ich, ich + 3, tssWord); ich = tsbLexRel.Text.IndexOf("{0}"); if (ich >= 0) tsbLexRel.ReplaceTsString(ich, ich + 3, tssWord); } int cDomains = vwenv.DataAccess.get_VecSize(hvo, ktagDomains); int cLexRels = vwenv.DataAccess.get_VecSize(hvo, ktagLexRels); Debug.Assert(cDomains > 0 || cLexRels > 0); if (cDomains > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbSdRelation.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagDomains, this, kfragEntryList); } if (cLexRels > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 6000); vwenv.OpenParagraph(); vwenv.AddString(tsbLexRel.GetString()); vwenv.CloseParagraph(); vwenv.AddLazyVecItems(ktagLexRels, this, kfragEntryList); } break; case kfragEntryList: vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.AddStringProp(ktagName, this); vwenv.AddString (m_tssColon); vwenv.AddObjVec(ktagWords, this, kfragWords); vwenv.CloseParagraph(); break; case kfragName: vwenv.AddStringProp(ktagName, this); break; default: throw new Exception("bad case in RelatedWordsVc.Display"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// pre-load any required data about a particular domain. /// </summary> /// <param name="vwenv"></param> /// <param name="rghvo"></param> /// <param name="chvo"></param> /// <param name="hvoParent"></param> /// <param name="tag"></param> /// <param name="frag"></param> /// <param name="ihvoMin"></param> /// ------------------------------------------------------------------------------------ public override void LoadDataFor(IVwEnv vwenv, int[] rghvo, int chvo, int hvoParent, int tag, int frag, int ihvoMin) { CheckDisposed(); // Nothing to do, all data already loaded. }
protected override void AddWordBundleInternal(int hvo, IVwEnv vwenv) { // Determine whether it is the focus box occurrence. if (FocusBoxOccurrence != null) { int hvoSeg, tag, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoSeg, out tag, out ihvo); if (hvoSeg == FocusBoxOccurrence.Segment.Hvo && ihvo == FocusBoxOccurrence.Index) { // Leave room for the Sandbox instead of displaying the internlinear data. // The first argument makes it invisible in case a little bit of it shows around // the sandbox. // The last argument puts the 'Baseline' of the sandbox (which aligns with the base of the // first line of text) an appropriate distance from the top of the Sandbox. This aligns it's // top line of text properly. // Enhance JohnT: 90% of font height is not always exactly right, but it's the closest // I can get wihtout a new API to get the exact ascent of the font. int dympBaseline = Common.Widgets.FontHeightAdjuster. GetFontHeightForStyle("Normal", m_stylesheet, m_wsVernForDisplay, m_cache.LanguageWritingSystemFactoryAccessor) * 9 / 10; uint transparent = 0xC0000000; // FwTextColor.kclrTransparent won't convert to uint vwenv.AddSimpleRect((int)transparent, FocusBoxSize.Width, FocusBoxSize.Height, -(FocusBoxSize.Height - dympBaseline)); return; } } base.AddWordBundleInternal(hvo, vwenv); }
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { CheckDisposed(); ISilDataAccess da = vwenv.DataAccess; int count = da.get_VecSize(hvo, tag); for (int i = 0; i < count; ++i) { if (i != 0) vwenv.AddSeparatorBar(); vwenv.AddObj(da.get_VecItem(hvo, tag, i), this, PhoneEnvReferenceView.kFragEnvironmentObj); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case PhoneEnvReferenceView.kFragEnvironmentObj: vwenv.AddStringProp(PhoneEnvReferenceView.kEnvStringRep, this); break; case PhoneEnvReferenceView.kFragEnvironments: vwenv.OpenParagraph(); vwenv.AddObjVec(PhoneEnvReferenceView.kMainObjEnvironments, this, frag); vwenv.CloseParagraph(); break; //case PhoneEnvReferenceView.kFragAnnotation: // break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
protected override void DisplayObjectProperty(IVwEnv vwenv, int hvo) { vwenv.NoteDependency(new int[] {m_hvoOwner}, new int[] {m_flid}, 1); vwenv.AddObj(hvo, this, AtomicReferenceView.kFragObjName); }
/// <summary></summary> internal void TriggerDisplay(IVwEnv vwenv) { CheckDisposed(); m_innerView.TriggerDisplay(vwenv); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main (not very) interesting method of displaying objects and fragments /// of them. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case AudioVisualView.kfragPathname: // Display the filename. ILgWritingSystemFactory wsf = m_cache.WritingSystemFactory; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); ITsString tss; ITsStrFactory tsf = m_cache.TsStrFactory; Debug.Assert(hvo != 0); Debug.Assert(m_cache != null); var file = m_cache.ServiceLocator.GetInstance<ICmFileRepository>().GetObject(hvo); Debug.Assert(file != null); string path = file.AbsoluteInternalPath; tss = tsf.MakeString(path, m_cache.WritingSystemFactory.UserWs); vwenv.OpenParagraph(); vwenv.NoteDependency( new [] { m_cache.LangProject.Hvo, file.Hvo}, new [] {LangProjectTags.kflidLinkedFilesRootDir, CmFileTags.kflidInternalPath}, 2); vwenv.AddString(tss); vwenv.CloseParagraph(); break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
private void SetTrailingAlignmentIfNeeded(IVwEnv vwenv, int hvoWfic) { ITsString tss = Cache.GetTsStringProperty(hvoWfic, TextTagAnnotFlid); Debug.Assert(tss != null, "Should get something for a TsString here!"); string tssText = tss.Text; if (tssText == null || tssText.Length == 0) return; if (TagEndsWithThisWfic(tssText) && !TagStartsWithThisWfic(tssText)) { // set trailing alignment vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } }
/// <summary> /// The hvo is for a Wfic (CmBaseAnnotation). /// </summary> /// <param name="vwenv"></param> /// <param name="hvoWfic"></param> internal override void AddExtraTwficRows(IVwEnv vwenv, int hvoWfic) { SetTrailingAlignmentIfNeeded(vwenv, hvoWfic); vwenv.AddStringProp(TextTagAnnotFlid, this); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ISilDataAccess da = vwenv.DataAccess; switch (frag) { default: { Debug.Assert(false, "Unrecognized fragment."); break; } case ReversalIndexEntrySliceView.kFragMainObject: { // The hvo here is for the sense. // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). int dxsMax = 0; // Max width required. ISilDataAccess silDaCache = vwenv.DataAccess; IVwCacheDa vwCache = silDaCache as IVwCacheDa; foreach (IReversalIndex idx in m_usedIndices) { vwenv.get_StringWidth(silDaCache.get_StringProp(idx.WritingSystemRAHvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr), m_ttpLabel, out dxs, out dys); dxsMax = Math.Max(dxsMax, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = dxsMax + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); // Do vector of rows. Each row essentially is a reversal index, but shows other information. vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidIndices, this, ReversalIndexEntrySliceView.kFragIndices); vwenv.CloseTableBody(); vwenv.CloseTable(); break; } case ReversalIndexEntrySliceView.kFragIndexMain: { // First cell has writing system abbreviation displayed using m_ttpLabel. int wsHvo = 0; foreach (ReversalIndex idx in m_usedIndices) { if (idx.Hvo == hvo) { wsHvo = idx.WritingSystemRAHvo; break; } } Debug.Assert(wsHvo > 0, "Could not find writing system."); int wsOldDefault = this.DefaultWs; this.DefaultWs = wsHvo; // Cell 1 shows the ws abbreviation. vwenv.OpenTableCell(1,1); vwenv.Props = m_ttpLabel; vwenv.AddObj(wsHvo, this, ReversalIndexEntrySliceView.kFragWsAbbr); vwenv.CloseTableCell(); // Second cell has the contents for the reversal entries. vwenv.OpenTableCell(1,1); // This displays the field flush right for RTL data, but gets arrow keys to // behave reasonably. See comments on LT-5287. IWritingSystem lgws = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(this.DefaultWs); if (lgws != null && lgws.RightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); } vwenv.OpenParagraph(); // Do vector of entries in the second column. vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidEntries, this, ReversalIndexEntrySliceView.kFragEntries); vwenv.CloseParagraph(); vwenv.CloseTableCell(); this.DefaultWs = wsOldDefault; break; } case ReversalIndexEntrySliceView.kFragEntryForm: { vwenv.AddStringAltMember((int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm, this.DefaultWs, this); int hvoCurrent = vwenv.CurrentObject(); if (hvoCurrent > 0) { IReversalIndexEntry rie = ReversalIndexEntry.CreateFromDBObject(m_cache, hvoCurrent); Debug.Assert(rie != null); int[] rgWs = m_cache.LangProject.GetReversalIndexWritingSystems(rie.Hvo, false); int wsAnal = m_cache.DefaultAnalWs; ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); tisb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); tisb.Append(" ["); int cstr = 0; ITsTextProps ttpBase = null; for (int i = 0; i < rgWs.Length; ++i) { int ws = rgWs[i]; if (ws == this.DefaultWs) continue; string sForm = rie.ReversalForm.GetAlternative(ws); if (sForm != null && sForm.Length != 0) { if (cstr > 0) tisb.Append(", "); ++cstr; string sWs = m_cache.GetMultiUnicodeAlt(ws, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, wsAnal, "LgWritingSystem_Abbr"); if (sWs != null && sWs.Length != 0) { ITsString tssWs = m_tsf.MakeStringWithPropsRgch(sWs, sWs.Length, m_ttpLabel); tisb.AppendTsString(tssWs); // We have to totally replace the properties set by m_ttpLabel. The // simplest way is to create another ITsString with the simple base // property of only the default analysis writing system. if (ttpBase == null) { ITsPropsBldr tpbBase = TsPropsBldrClass.Create(); tpbBase.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); ttpBase = tpbBase.GetTextProps(); } ITsString tssSpace = m_tsf.MakeStringWithPropsRgch(" ", 1, ttpBase); tisb.AppendTsString(tssSpace); } tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, ws); tisb.Append(sForm); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); } } if (cstr > 0) { tisb.Append("]"); ITsString tss = tisb.GetString(); vwenv.AddString(tss); } } break; } case ReversalIndexEntrySliceView.kFragWsAbbr: { vwenv.AddString(da.get_StringProp(hvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr)); break; } } }