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> /// This is the basic method needed for the view constructor. /// </summary> public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case VectorReferenceView.kfragTargetVector: if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.OpenParagraph(); vwenv.AddObjVec(m_flid, this, frag); vwenv.CloseParagraph(); break; case VectorReferenceView.kfragTargetObj: // Display one object by displaying the fake string property of that object which our special // private decorator stores for it. vwenv.AddStringProp(PossibilityVectorReferenceView.kflidFake, this); break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
/// <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 AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { string sField = ksEditColumnBaseName + i; XmlNode node = m_columns[i - 1] as XmlNode; // Make a cell and embed an editable virtual string for the column. vwenv.OpenTableCell(1, 1); // Initialize the virtual property. IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField); Debug.Assert(vh != null); int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false); int ws = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs); // 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); vh.Load(khvoNewItem, flid, ws, cda); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptIsEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
/// ----------------------------------------------------------------------------------- /// <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; } }
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 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); 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; ITsString tss = TsStringUtils.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 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; }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonAnnotations: if (hvo == 0) { return; } vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.AnnotationListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: if (m_ribbon.SelLimAnn == hvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified vwenv. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="hvo">The hvo.</param> /// <param name="frag">The frag.</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragLazyScripture: { // The configure method insists on trying to make an initial selection. // If there isn't something selectable there, it expands everything. vwenv.AddStringProp((int)Scripture.ScriptureTags.kflidChapterVerseSepr, this); vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this, kfragLazyBook); break; } case kfragLazyBook: { vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this, kfragDummySection); break; } case kfragDummySection: { vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this, kfragDummyStText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this, kfragDummyStText); break; } case kfragDummyStText: { vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, m_fParaWithContent ? kfragDummyParaWithContent : kfragDummyPara); break; } case kfragDummyPara: { // Display each dummy paragraph as a rectangle an inch high, which allows us // to accurately predict the height of a known number of them. vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0); break; } case kfragDummyParaWithContent: { vwenv.OpenMappedTaggedPara(); vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); vwenv.CloseParagraph(); break; } } }
/// <summary/> protected virtual void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (fDisposing && !IsDisposed) { // dispose managed and unmanaged objects m_vwenv.CloseParagraph(); } IsDisposed = true; }
protected void CloseContextPile(IVwEnv vwenv, bool addBoundary) { if (addBoundary) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragZeroWidthSpace); } vwenv.CloseParagraph(); vwenv.CloseInnerPile(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// The main method just displays the deletion text with the appropriate properties. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); vwenv.OpenParagraph(); if (m_textbox.Tss != null) { vwenv.AddString(m_textbox.Tss); } vwenv.CloseParagraph(); }
protected void AddExtraLines(int numLines, int tag, IVwEnv vwenv) { for (int i = 0; i < numLines; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenParagraph(); vwenv.AddProp(tag, this, kfragEmpty); vwenv.CloseParagraph(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the current paragraph's contents (either once or thrice, depending on display /// flags) and then close the paragraph if necessary. /// </summary> /// <param name="vwenv">The view environment</param> /// ------------------------------------------------------------------------------------ private void AddParagraphContents(IVwEnv vwenv) { vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null); if ((m_displayType & DisplayType.kOnlyDisplayContentsOnce) != DisplayType.kOnlyDisplayContentsOnce) { vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null); vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null); } if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara) { vwenv.CloseParagraph(); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { // Enhance JohnT: change background if this is the selected slice. vwenv.OpenParagraph(); if (m_info.Hvo == 0 || m_info.ContentStringFlid == 0) { vwenv.AddString(m_info.ContentString); } else { Debug.Assert(hvo == m_info.Hvo); vwenv.AddStringProp(m_info.ContentStringFlid, this); } vwenv.CloseParagraph(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Inserts the missing content paragraph. /// </summary> /// <param name="vwenv">The view environment.</param> /// ------------------------------------------------------------------------------------ private void InsertMissingContentPara(IVwEnv vwenv) { vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)kHighlightColor); vwenv.set_IntProperty((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.AddString(TsStringUtils.MakeTss( TeDiffViewResources.kstidContentMissing, Cache.DefaultUserWs)); vwenv.CloseParagraph(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add a column to the header/footer /// </summary> /// <param name="vwenv"></param> /// <param name="align"></param> /// <param name="flid"></param> /// ------------------------------------------------------------------------------------ private void AddColumn(IVwEnv vwenv, FwTextAlign align, PubHeader.PubHeaderTags flid) { vwenv.OpenTableCell(1, 1); if (HeaderFooterParaStyle != null && HeaderFooterParaStyle != string.Empty) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, HeaderFooterParaStyle); } vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)align); vwenv.OpenMappedPara(); vwenv.AddStringProp((int)flid, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
internal override void PerformDisplay(XmlVc vc, int fragId, int hvo, IVwEnv vwenv) { int level = vwenv.EmbeddingLevel; int hvoDum, tag, ihvo; vwenv.GetOuterObject(level - 2, out hvoDum, out tag, out ihvo); m_creator.SetupParagraph(m_paraStyle, m_tssBefore, m_listDelimitNode); m_creator.AddItemEmbellishments(m_listDelimitNode, m_numberItems, hvo, ihvo, m_xaNum, m_ttpNum, m_delayNumber, ref DelayedNumber); // This is the display of the object we wanted to wrap the paragraph etc around. // We want to produce an effect rather like // vwenv.AddObj(hvo, m_creator.m_viewConstructor, WrappedFragId); // except we do NOT want to open/close an object in the VC, since we are already inside the addition of this object. m_creator.m_viewConstructor.Display(vwenv, hvo, WrappedFragId); // Close Paragraph if displaying paragraphs vwenv.CloseParagraph(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { // Enhance JohnT: make the alignment position a function of window width. // Enhance JohnT: change background if this is the selected context line. vwenv.OpenConcPara(m_info.ContextStringStartOffset, m_info.ContextStringStartOffset + m_info.ContextStringLength, VwConcParaOpts.kcpoDefault, 72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints. if (m_info.Hvo == 0 || m_info.ContentStringFlid == 0) { vwenv.AddString(m_info.ContentString); } else { Debug.Assert(hvo == m_info.Hvo); vwenv.AddStringProp(m_info.ContentStringFlid, this); } vwenv.CloseParagraph(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case InterlinRibbon.kfragRibbonWordforms: if (hvo == 0) { return; } if (m_ribbon.IsRightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); } vwenv.OpenParagraph(); vwenv.AddObjVecItems(m_ribbon.OccurenceListId, this, InterlinVc.kfragBundle); vwenv.CloseParagraph(); break; case kfragBundle: // Review: will this lead to multiple spurious blue lines? var realHvo = (m_ribbon.Decorator as InterlinRibbonDecorator).OccurrenceFromHvo(hvo).Analysis.Hvo; if (m_ribbon.SelLimOccurrence != null && m_ribbon.SelLimOccurrence.Analysis.Hvo == realHvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Blue)); } base.Display(vwenv, hvo, frag); break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case AtomicReferenceView.kFragAtomicRef: // Display a paragraph with a single item. vwenv.OpenParagraph(); // vwenv.OpenMappedPara(); if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.AddStringProp(PossibilityAtomicReferenceView.kflidFake, this); vwenv.CloseParagraph(); break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a paragraph (gray line) to the preview. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="props">Text props, or <c>null</c>.</param> /// <param name="fAddSpaceBefore"><c>true</c> to add 6pt space before the paragraph</param> /// ------------------------------------------------------------------------------------ private void AddPreviewPara(IVwEnv vwenv, ITsTextProps props, bool fAddSpaceBefore) { // (width is -1, meaning "use the rest of the line") if (props != null) { vwenv.Props = props; } else if (fAddSpaceBefore) { vwenv.set_IntProperty((int)FwTextPropType.ktptSpaceBefore, (int)FwTextPropVar.ktpvMilliPoint, 6000); } vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, m_fRtl ? -1 : 0); vwenv.OpenParagraph(); vwenv.AddSimpleRect(Color.LightGray.ToArgb(), -1, kdmpFakeHeight, 0); vwenv.CloseParagraph(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { default: break; case InterlinearView.kfrText: vwenv.OpenParagraph(); vwenv.AddObjVecItems(InterlinearView.ktagText_Words, this, InterlinearView.kfrWord); vwenv.CloseParagraph(); break; case InterlinearView.kfrWord: vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptMarginTrailing, (int)FwKernelLib.FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); vwenv.AddStringProp(InterlinearView.ktagWord_Form, this); vwenv.AddStringProp(InterlinearView.ktagWord_Type, this); vwenv.CloseInnerPile(); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { 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"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case AudioVisualView.kfragPathname: // Display the filename. ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); ITsString tss; Debug.Assert(hvo != 0); Debug.Assert(m_cache != null); ICmFile file = CmFile.CreateFromDBObject(m_cache, hvo); Debug.Assert(file != null); string path; if (Path.IsPathRooted(file.InternalPath)) { path = file.InternalPath; } else { path = Path.Combine(m_cache.LangProject.ExternalLinkRootDir, file.InternalPath); } tss = m_cache.MakeUserTss(path); vwenv.OpenParagraph(); vwenv.AddString(tss); vwenv.CloseParagraph(); break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
/// <summary> /// Add to the vwenv the label(s) for a gloss line. /// If multiple glosses are wanted, it generates a set of labels /// </summary> public void AddGlossLabels(IVwEnv vwenv, ITsStrFactory tsf, int color, string baseLabel, FdoCache cache, WsListManager wsList) { if (wsList != null && wsList.AnalysisWsLabels.Length > 1) { ITsString tssBase = MakeUiElementString(baseLabel, cache.DefaultUserWs, null); ITsString space = tsf.MakeString(" ", cache.DefaultUserWs); foreach (ITsString tssLabel in wsList.AnalysisWsLabels) { SetColor(vwenv, color); vwenv.OpenParagraph(); vwenv.AddString(tssBase); vwenv.AddString(space); vwenv.AddString(tssLabel); vwenv.CloseParagraph(); } } else { AddColoredString(vwenv, color, tsf, cache.DefaultAnalWs, baseLabel); } }
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { switch (frag) { case kfragInput: // input context cell foreach (var ctxt in m_rule.InputOS) { vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObj(ctxt.Hvo, this, kfragContext); vwenv.CloseParagraph(); vwenv.CloseTableCell(); } break; default: base.DisplayVec(vwenv, hvo, tag, frag); break; } }
private void DisplayMorphBundles(IVwEnv vwenv, int hvo) { if (m_fShowMorphBundles) { // Don't allow direct editing of the morph bundle lines. MakeNextFlowObjectReadOnly(vwenv); if (vwenv.DataAccess.get_VecSize(hvo, ktagSbWordMorphs) == 0) { SetColor(vwenv, m_choices.LabelRGBFor(m_choices.IndexOf(InterlinLineChoices.kflidMorphemes))); vwenv.AddProp(ktagMissingMorphs, this, kfragMissingMorphs); // Blank lines to fill up the gap; LexEntry line vwenv.AddString(m_tssEmptyVern); vwenv.AddString(m_tssEmptyAnalysis); // LexGloss line vwenv.AddString(m_tssEmptyAnalysis); // LexPos line } else { vwenv.OpenParagraph(); vwenv.AddObjVec(ktagSbWordMorphs, this, kfragMorph); vwenv.CloseParagraph(); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the notes paragraph. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="notes">The notes.</param> /// <param name="styleProps">The style props.</param> /// ------------------------------------------------------------------------------------ private void CreateNotesParagraph(IVwEnv vwenv, List <int> notes, ITsTextProps styleProps) { // Don't create a completely empty paragraph. The way the Views system handles such paragraphs // doesn't work for a MappedTaggedPara. Also, we want the footnote to take up no height at all // if there are none. if (notes.Count == 0) { return; } vwenv.set_IntProperty((int)FwTextPropType.ktptBaseWs, (int)FwTextPropVar.ktpvDefault, DefaultWs); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (RightToLeft ? -1 : 0)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, RightToLeft ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); vwenv.Props = styleProps; // The body of the paragraph is either editable or not. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); vwenv.OpenMappedTaggedPara(); for (int ihvo = 0; ihvo < notes.Count; ihvo++) { // Optimize JohnT: could make this string once and save it in a member variable. if (ihvo != 0) { vwenv.AddString(m_cache.TsStrFactory.MakeString(" ", m_cache.DefaultVernWs)); } vwenv.AddObj(notes[ihvo], this, (int)FootnoteFrags.kfrFootnoteWithinPagePara); } vwenv.CloseParagraph(); }
protected virtual void AddFreeformComment(IVwEnv vwenv, int hvoSeg, int lineChoiceIndex) { int[] wssAnalysis = m_lineChoices.AdjacentWssAtIndex(lineChoiceIndex); if (wssAnalysis.Length == 0) return; vwenv.OpenDiv(); SetParaDirectionAndAlignment(vwenv, wssAnalysis[0]); vwenv.OpenMappedPara(); string label; int flid; InterlinearExporter exporter = vwenv as InterlinearExporter; int dummyFlid = m_lineChoices[lineChoiceIndex].Flid; switch (dummyFlid) { case InterlinLineChoices.kflidFreeTrans: label = ITextStrings.ksFree_; flid = SegmentTags.kflidFreeTranslation; if (exporter != null) exporter.FreeAnnotationType = "gls"; break; case InterlinLineChoices.kflidLitTrans: label = ITextStrings.ksLit_; flid = SegmentTags.kflidLiteralTranslation; if (exporter != null) exporter.FreeAnnotationType = "lit"; break; case InterlinLineChoices.kflidNote: label = ITextStrings.ksNote_; flid = NoteTags.kflidContent; if (exporter != null) exporter.FreeAnnotationType = "note"; break; default: throw new Exception("Unexpected FF annotation type"); } SetNoteLabelProps(vwenv); // REVIEW: Should we set the label to a special color as well? ITsString tssLabel = MakeUiElementString(label, m_cache.DefaultUserWs, propsBldr => propsBldr.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn)); ITsStrBldr labelBldr = tssLabel.GetBldr(); AddLineIndexProperty(labelBldr, lineChoiceIndex); tssLabel = labelBldr.GetString(); int labelWidth = 0; int labelHeight; // unused if (wssAnalysis.Length > 1) vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight); if (IsWsRtl(wssAnalysis[0]) != m_fRtl) { ITsStrBldr bldr = tssLabel.GetBldr(); bldr.Replace(bldr.Length - 1, bldr.Length, null, null); ITsString tssLabelNoSpace = bldr.GetString(); // (First) analysis language is upstream; insert label at end. vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvoSeg, wssAnalysis[0], flid); vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); if (wssAnalysis.Length != 1) { // Insert WS label for first line vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[0])); } vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(tssLabelNoSpace); vwenv.AddString(m_tssDir); } else { vwenv.AddString(m_tssDir); vwenv.AddString(tssLabel); vwenv.AddString(m_tssDir); if (wssAnalysis.Length == 1) { vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvoSeg, wssAnalysis[0], flid); } else { SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[0])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); // label width unfortunately does not include trailing space. vwenv.AddString(m_tssDir); vwenv.AddString(GetTssDirForWs(wssAnalysis[0])); AddFreeformComment(vwenv, hvoSeg, wssAnalysis[0], flid); } } // Add any other lines, each in its appropriate direction. for (int i = 1; i < wssAnalysis.Length; i++) { vwenv.CloseParagraph(); // Indent subsequent paragraphs by the width of the main label. if (IsWsRtl(wssAnalysis[i]) != m_fRtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptTrailingIndent, (int)FwTextPropVar.ktpvMilliPoint, labelWidth); } else { vwenv.set_IntProperty((int) FwTextPropType.ktptLeadingIndent, (int) FwTextPropVar.ktpvMilliPoint, labelWidth); } SetParaDirectionAndAlignment(vwenv, wssAnalysis[i]); vwenv.OpenParagraph(); if (IsWsRtl(wssAnalysis[i]) != m_fRtl) { // upstream...reverse everything. vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); AddFreeformComment(vwenv, hvoSeg, wssAnalysis[i], flid); vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); } else { vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); SetNoteLabelProps(vwenv); vwenv.AddString(WsListManager.WsLabel(m_cache, wssAnalysis[i])); vwenv.AddString(m_tssDir); vwenv.AddString(m_tssSpace); vwenv.AddString(m_tssDir); vwenv.AddString(GetTssDirForWs(wssAnalysis[i])); AddFreeformComment(vwenv, hvoSeg, wssAnalysis[i], flid); } } vwenv.CloseParagraph(); vwenv.CloseDiv(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch(frag) { case 1: { // The top-level. // Enhance JohnT: add a property setting to make the key bold // Roughly, vwenv.set_IntProperty(ktptBold, ktpvEnum, kttvForceOn); // If we can get an hvo and flid, display that property of that object. int flid = 0; if (hvo != 0) { flid = m_cp.FlidFor(m_index, hvo); } if (flid != 0) { // Warning (JohnT): this option not yet tested... vwenv.AddStringProp(flid, this); return; } else { // Otherwise display a literal string straight from the policy object. vwenv.AddString(m_cp.KeyFor(m_index, hvo)); } if (m_fExpanded) { vwenv.AddLazyVecItems(m_ni.ListFlid, this, 2); } break; } case 2: { // One line of context. // Figure the index of this object in the next object out (the root). int hvoOuter, tagOuter, ihvo; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tagOuter, out ihvo); int ichKey = m_ni.ContextStringStartOffset(ihvo, hvo); int cchKey = m_ni.ContextStringLength(ihvo, hvo); // Enhance JohnT: make the alignment position a function of window width. // Enhance JohnT: change background if this is the selected context line. vwenv.OpenConcPara(ichKey, ichKey + cchKey, VwConcParaOpts.kcpoDefault, 72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints. int flidKey = m_ni.ContextStringFlid(ihvo, hvo); if (flidKey == 0) { // Not tested yet. vwenv.AddString(m_ni.ContextString(ihvo, hvo)); } else { vwenv.AddStringProp(flidKey, this); } vwenv.CloseParagraph(); break; } } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance<IPhMetathesisRuleRepository>().GetObject(hvo); if (m_rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int maxNumLines = GetMaxNumLines(); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(5, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; int resultx, inputx, dmpy; vwenv.get_StringWidth(m_resultStr, m_colHeaderProps, out resultx, out dmpy); vwenv.get_StringWidth(m_inputStr, m_colHeaderProps, out inputx, out dmpy); VwLength headerLen; headerLen.nVal = Math.Max(resultx, inputx) + 8000; headerLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(4, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // left context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_leftEnvStr); vwenv.CloseTableCell(); // switch header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 2); vwenv.AddString(m_switchStr); vwenv.CloseTableCell(); // right context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_rightEnvStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = 0; i < m_rule.LeftEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input left switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input result header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); // result left context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex != -1) { for (int i = 0; i < m_rule.LeftEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex != -1) { for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result left switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } if (m_rule.LeftSwitchIndex != -1) { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex != -1) { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// The main method just displays the text with the appropriate properties. /// </summary> /// <param name="vwenv">The view environment</param> /// <param name="hvo">The HVo of the object to display</param> /// <param name="frag">The fragment to lay out</param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case InnerFwListBox.kfragRoot: Font f = m_listbox.Font; if (m_listbox.StyleSheet == null) { // Try to get items a reasonable size based on whatever font has been set for the // combo as a whole. We don't want to do this if a stylesheet has been set, because // it will override the sizes specified in the stylesheet. // Enhance JohnT: there are several more properties we could readily copy over // from the font, but this is a good start. vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, (int)(f.SizeInPoints * 1000)); } // Setting the font family here appears to override the fonts associated with the // TsString data. This causes trouble for non-Microsoft Sans Serif writing systems. // See LT-551 for the bug report that revealed this problem. // vwenv.set_StringProperty((int) FwTextPropType.ktptFontFamily, // f.FontFamily.Name); vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(m_listbox.ForeColor)); DisplayList(vwenv); break; case InnerFwListBox.kfragItems: int index, hvoDummy, tagDummy; int clev = vwenv.EmbeddingLevel; vwenv.GetOuterObject(clev - 1, out hvoDummy, out tagDummy, out index); bool fHighlighted = m_listbox.Owner.IsHighlighted(index); if (fHighlighted && m_listbox.ShowHighlight) { vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.HighlightText))); vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Highlight))); } vwenv.OpenParagraph(); if (fHighlighted && m_listbox.ShowHighlight) { // Insert a string that has the foreground color not set, so the foreground color set above can take effect. ITsStrBldr bldr = vwenv.DataAccess.get_StringProp(hvo, InnerFwListBox.ktagText).GetBldr(); bldr.SetIntPropValues(0, bldr.Length, (int) FwTextPropType.ktptForeColor, -1, -1); vwenv.AddString(bldr.GetString()); } else { vwenv.AddStringProp(InnerFwListBox.ktagText, this); } vwenv.AddString(m_tssBlanks); vwenv.CloseParagraph(); break; } }
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); */ }
/// <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 } }
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> /// 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; } } }
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"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); // Enhance JohnT: make the alignment position a function of window width. // Enhance JohnT: change background if this is the selected context line. vwenv.OpenConcPara(m_info.ContextStringStartOffset, m_info.ContextStringStartOffset + m_info.ContextStringLength, VwConcParaOpts.kcpoDefault, 72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints. if (m_info.Hvo == 0 || m_info.ContentStringFlid == 0) { vwenv.AddString(m_info.ContentString); } else { Debug.Assert(hvo == m_info.Hvo); vwenv.AddStringProp(m_info.ContentStringFlid, this); } vwenv.CloseParagraph(); }
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { CheckDisposed(); switch (frag) { case kfragSegFf: // freeform annotations. (Cf override in InterlinPrintVc) { // Note that changes here may need to be refleced in FreeformAdder's code // for selecting a newly created annotation. AddFreeformAnnotations(vwenv, hvo); break; } default: if (frag >= kfragWordGlossWs && frag < kfragWordGlossWs + m_WsList.AnalysisWsIds.Length) { // Displaying one ws of all the glosses of an analysis, separated by commas. vwenv.OpenParagraph(); IWfiAnalysis wa = m_coRepository.GetObject(hvo) as IWfiAnalysis; int i = 0; foreach (IWfiGloss gloss in wa.MeaningsOC) { if (i != 0) vwenv.AddString(CommaSpaceString); vwenv.AddObj(gloss.Hvo, this, frag); i++; } vwenv.CloseParagraph(); } else { base.DisplayVec (vwenv, hvo, tag, frag); } break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); // Enhance JohnT: change background if this is the selected slice. vwenv.OpenParagraph(); if (m_info.Hvo == 0 || m_info.ContentStringFlid == 0) { vwenv.AddString(m_info.ContentString); } else { Debug.Assert(hvo == m_info.Hvo); vwenv.AddStringProp(m_info.ContentStringFlid, this); } vwenv.CloseParagraph(); }
protected void AddExtraLines(int numLines, int tag, IVwEnv vwenv) { for (int i = 0; i < numLines; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptEditable, (int) FwTextPropVar.ktpvEnum, (int) TptEditable.ktptNotEditable); vwenv.OpenParagraph(); vwenv.AddProp(tag, this, kfragEmpty); vwenv.CloseParagraph(); } }
/// <summary> /// NOTE: this routine is ignorant of calling context, so caller must provide NoteDependency to the possibleVariant and the sense /// (e.g. vwenv.NoteDependency(new[] { wfiMorphBundle.Hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1); /// vwenv.NoteDependency(new[] { wfiMorphBundle.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1); /// </summary> /// <param name="vwenv"></param> /// <param name="possibleVariant"></param> /// <param name="sense"></param> /// <param name="spec"></param> /// <param name="inflType"></param> /// <returns>true if there was anything to display </returns> internal bool DisplayLexGlossWithInflType(IVwEnv vwenv, ILexEntry possibleVariant, ILexSense sense, InterlinLineSpec spec, ILexEntryInflType inflType) { int iLineChoice = m_lineChoices.IndexOf(spec); ILexEntryRef ler; if (possibleVariant.IsVariantOfSenseOrOwnerEntry(sense, out ler)) { var wsPreferred = GetRealWsOrBestWsForContext(sense.Hvo, spec); var wsGloss = Cache.ServiceLocator.WritingSystemManager.Get(wsPreferred); var wsUser = Cache.ServiceLocator.WritingSystemManager.UserWritingSystem; var testGloss = sense.Gloss.get_String(wsPreferred); // don't bother adding anything for an empty gloss. if (testGloss.Text != null && testGloss.Text.Length >= 0) { vwenv.OpenParagraph(); // see if we have an irregularly inflected form type reference var leitFirst = ler.VariantEntryTypesRS.Where( let => let.ClassID == LexEntryInflTypeTags.kClassId).FirstOrDefault(); // add any GlossPrepend info if (leitFirst != null) { vwenv.OpenInnerPile(); // TODO: add dependency to VariantType GlossPrepend/Append names vwenv.NoteDependency(new[] { ler.Hvo }, new[] { LexEntryRefTags.kflidVariantEntryTypes }, 1); vwenv.OpenParagraph(); ITsString tssPrepend = null; if (inflType != null) { tssPrepend = MorphServices.AddTssGlossAffix(null, inflType.GlossPrepend, wsGloss, wsUser); } else { ITsIncStrBldr sbPrepend; ITsIncStrBldr sbAppend; JoinGlossAffixesOfInflVariantTypes(ler, wsPreferred, out sbPrepend, out sbAppend); if (sbPrepend.Text != null) tssPrepend = sbPrepend.GetString(); } if (tssPrepend != null) vwenv.AddString(tssPrepend); vwenv.CloseParagraph(); vwenv.CloseInnerPile(); } // add gloss of main entry or sense { vwenv.OpenInnerPile(); // NOTE: remember to NoteDependency from OuterObject vwenv.AddObj(sense.Hvo, this, kfragLineChoices + iLineChoice); vwenv.CloseInnerPile(); } // now add variant type info if (leitFirst != null) { vwenv.OpenInnerPile(); // TODO: add dependency to VariantType GlossPrepend/Append names vwenv.NoteDependency(new[] { ler.Hvo }, new[] { LexEntryRefTags.kflidVariantEntryTypes }, 1); vwenv.OpenParagraph(); ITsString tssAppend = null; if (inflType != null) { tssAppend = MorphServices.AddTssGlossAffix(null, inflType.GlossAppend, wsGloss, wsUser); } else { ITsIncStrBldr sbPrepend; ITsIncStrBldr sbAppend; JoinGlossAffixesOfInflVariantTypes(ler, wsPreferred, out sbPrepend, out sbAppend); if (sbAppend.Text != null) tssAppend = sbAppend.GetString(); } { // Use AddProp/DisplayVariant to store GlossAppend with m_tssPendingGlossAffix // this allows InterlinearExporter to know to export a glsAppend item try { if (tssAppend != null) m_tssPendingGlossAffix = tssAppend; else m_tssPendingGlossAffix = m_tssMissingGlossAppend; vwenv.AddProp(ktagGlossAppend, this, 0); } finally { m_tssPendingGlossAffix = null; } } vwenv.CloseParagraph(); vwenv.CloseInnerPile(); } vwenv.CloseParagraph(); return true; } } return false; }
protected void CloseSingleLinePile(IVwEnv vwenv, bool addBoundary) { if (addBoundary) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragZeroWidthSpace); } vwenv.CloseParagraph(); vwenv.CloseInnerPile(); }
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 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> /// The main method just displays the text with the appropriate properties. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)RGB(m_innerTextBox.ForeColor)); if (m_rtl) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); } vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)m_innerTextBox.Alignment); vwenv.OpenParagraph(); vwenv.AddStringProp(InnerFwTextBox.ktagText, this); if (m_fSaveSize) { ITsString tss = vwenv.DataAccess.get_StringProp(hvo, InnerFwTextBox.ktagText); vwenv.get_StringWidth(tss, null, out m_dxWidth, out m_dyHeight); } vwenv.CloseParagraph(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a paragraph (gray line) to the preview. /// </summary> /// <param name="vwenv">The vwenv.</param> /// <param name="props">Text props, or <c>null</c>.</param> /// <param name="fAddSpaceBefore"><c>true</c> to add 6pt space before the paragraph</param> /// ------------------------------------------------------------------------------------ private void AddPreviewPara(IVwEnv vwenv, ITsTextProps props, bool fAddSpaceBefore) { // (width is -1, meaning "use the rest of the line") if (props != null) vwenv.Props = props; else if (fAddSpaceBefore) { vwenv.set_IntProperty((int)FwTextPropType.ktptSpaceBefore, (int)FwTextPropVar.ktpvMilliPoint, 6000); } vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, m_fRtl ? -1 : 0); vwenv.OpenParagraph(); vwenv.AddSimpleRect(Color.LightGray.ToArgb(), -1, kdmpFakeHeight, 0); vwenv.CloseParagraph(); }
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) { // Ignore 0 hvo's. RootObject may have not been set. FWNX-613. if (hvo == 0) return; switch(frag) { case kfragRoot: if (m_dxLabWidth == 0) { int dmpx1, dmpy; //, dmpx2; vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy); //vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy); //m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin. m_dxLabWidth = dmpx1 + 13000; // add 3 pt spacing to box, 10 to margin. m_dxWsLabWidth = 0; foreach (ITsString tssLabel in m_WsLabels) { vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy); m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1); } m_dxWsLabWidth += 18000; // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety. } VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColLabels; // 5-pt space plus max label width. vlColLabels.nVal = m_dxLabWidth; vlColLabels.unit = VwUnit.kunPoint1000; VwLength vlColWsLabels; // 5-pt space plus max ws label width. vlColWsLabels.nVal = m_dxWsLabWidth; vlColWsLabels.unit = VwUnit.kunPoint1000; // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; // The Padding column allows for the the trailing margin and border. VwLength vlColPadding; vlColPadding.nVal = 10000; vlColPadding.unit = VwUnit.kunPoint1000; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int) FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenTable(4, // Four 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); vwenv.MakeColumns(1, vlColLabels); vwenv.MakeColumns(1, vlColWsLabels); vwenv.MakeColumns(1, vlColMain); vwenv.MakeColumns(1, vlColPadding); vwenv.OpenTableBody(); for (int i = 0; i < m_writingSystems.Length; i++) { vwenv.OpenTableRow(); // First cell has 'Title' label in bold. vwenv.Props = m_ttpBold; vwenv.OpenTableCell(1,1); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, 10000); if (i == 0) // only on the first row { // We want this fixed at 10 point, since it's considered a UI component, not data. // See LT-4816 vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.AddString(m_tssTitle); } vwenv.CloseTableCell(); // Second cell has ws labels. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int) FwTextPropVar.ktpvDefault, m_editBackColor); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == 0) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == m_writingSystems.Length - 1) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1,1); vwenv.Props = m_ttpDataCellProps; vwenv.Props = m_ttpWsLabel; vwenv.AddString(m_WsLabels[i]); vwenv.CloseTableCell(); // Third cell has the Title property, in a box. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int) FwTextPropVar.ktpvDefault, m_editBackColor); // Set the underlying directionality so that arrow keys work properly. bool fRTL = m_writingSystems[i].RightToLeftScript; 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); if (i == 0) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == m_writingSystems.Length - 1) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1,1); vwenv.OpenParagraph(); vwenv.Props = m_ttpDataCellProps; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, this.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); if (IsScripture) { vwenv.AddStringAltMember(m_vtagStTextTitle, m_writingSystems[i].Handle, this); } else { vwenv.AddStringAltMember(CmMajorObjectTags.kflidName, m_writingSystems[i].Handle, this); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); } //// Second row. //vwenv.OpenTableRow(); // //// First cell has 'Comments' label in bold. //vwenv.Props = m_ttpBold; //vwenv.OpenTableCell(1,1); //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.AddString(m_tssComments); //vwenv.CloseTableCell(); // //// Second cell has the Description property, in a box. //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.OpenTableCell(1,1); //vwenv.Props = m_ttpDataCellProps; //vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, // (int)FwTextPropVar.ktpvMilliPoint, 1000); //vwenv.AddStringAltMember( // (int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); //vwenv.CloseTableCell(); // //vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: throw new Exception("Bad frag id in TitleContentsVc"); } }
/// <summary> /// Add the pile of labels used to identify the lines in interlinear text. /// </summary> /// <param name="vwenv"></param> /// <param name="tsf"></param> /// <param name="cache"></param> /// <param name="wsList">Null if don't want multiple writing systems.</param> /// <param name="fShowMutlilingGlosses"></param> public void AddLabelPile(IVwEnv vwenv, ITsStrFactory tsf, FdoCache cache, bool fWantMultipleSenseGloss, bool fShowMorphemes) { CheckDisposed(); int wsUI = cache.DefaultUserWs; var spaceStr = TsStringUtils.MakeTss(" ", wsUI); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.set_IntProperty((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 5000); // default spacing is fine for all embedded paragraphs. vwenv.OpenInnerPile(); for (var i = 0; i < m_lineChoices.Count; i++) { InterlinLineSpec spec = m_lineChoices[i]; if (!spec.WordLevel) break; SetColor(vwenv, LabelRGBFor(spec)); ITsString tss = MakeUiElementString(m_lineChoices.LabelFor(spec.Flid), wsUI, null); var bldr = tss.GetBldr(); if (m_lineChoices.RepetitionsOfFlid(spec.Flid) > 1) { bldr.Append(spaceStr); bldr.Append(spec.WsLabel(cache)); AddLineIndexProperty(bldr, i); // Enhance GJM: Might be able to do without paragraph now? vwenv.OpenParagraph(); vwenv.AddString(bldr.GetString()); vwenv.CloseParagraph(); } else { AddLineIndexProperty(bldr, i); vwenv.AddString(bldr.GetString()); } } vwenv.CloseInnerPile(); }
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; } } }
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 }
void DisplayIterCtxt(IPhIterationContext iterCtxt, 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, PILE_MARGIN); } vwenv.OpenInnerPile(); if (numLines == 1) vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, superOffset); vwenv.OpenParagraph(); vwenv.AddProp(PhIterationContextTags.kflidMaximum, this, kfragIterCtxtMax); vwenv.CloseParagraph(); AddExtraLines(numLines - 2, vwenv); vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, 0); vwenv.OpenParagraph(); vwenv.AddIntProp(PhIterationContextTags.kflidMinimum); vwenv.CloseParagraph(); vwenv.CloseInnerPile(); }
/// ----------------------------------------------------------------------------------- /// <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"); } }
private void CreateNotesParagraph(IVwEnv vwenv, List<int> notes, ITsTextProps styleProps) { // Don't create a completely empty paragraph. The way the Views system handles such paragraphs // doesn't work for a MappedTaggedPara. Also, we want the footnote to take up no height at all // if there are none. if (notes.Count == 0) return; vwenv.set_IntProperty((int)FwTextPropType.ktptBaseWs, (int)FwTextPropVar.ktpvDefault, DefaultWs); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (RightToLeft ? -1 : 0)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, RightToLeft ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); vwenv.Props = styleProps; // The body of the paragraph is either editable or not. vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); vwenv.OpenMappedTaggedPara(); for (int ihvo = 0; ihvo < notes.Count; ihvo++) { // Optimize JohnT: could make this string once and save it in a member variable. if (ihvo != 0) vwenv.AddString(m_cache.MakeVernTss(" ")); vwenv.AddObj(notes[ihvo], this, (int)FootnoteFrags.kfrFootnoteWithinPagePara); } vwenv.CloseParagraph(); }