Exemple #1
0
            /// ------------------------------------------------------------------------------------
            /// <summary>
            ///
            /// </summary>
            /// <param name="vwenv"></param>
            /// <param name="hvo"></param>
            /// <param name="frag"></param>
            /// ------------------------------------------------------------------------------------
            public override void Display(IVwEnv vwenv, int hvo, int frag)
            {
                CheckDisposed();

                int       hvoOuter, tag, ihvo;
                ITsString tss;

                switch (frag)
                {
                case 1:                         // A ScrBook; display the title.
                    vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, 2);
                    break;

                case 2:                         // An StText; display the paragraphs.
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
                    tss = TsStringHelper.MakeTSS(
                        "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
                        InMemoryFdoCache.s_wsHvos.Fr);
                    vwenv.AddString(tss);
                    vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 3);
                    break;

                case 3:                         // StTxtPara, display details of our outer object
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
                    tss = TsStringHelper.MakeTSS(
                        "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
                        InMemoryFdoCache.s_wsHvos.Fr);
                    vwenv.AddString(tss);
                    break;

                default:
                    throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
                }
            }
Exemple #2
0
            /// ------------------------------------------------------------------------------------
            /// <summary>
            ///
            /// </summary>
            /// <param name="vwenv"></param>
            /// <param name="hvo"></param>
            /// <param name="frag"></param>
            /// ------------------------------------------------------------------------------------
            public override void Display(IVwEnv vwenv, int hvo, int frag)
            {
                int       frWs = vwenv.DataAccess.WritingSystemFactory.GetWsFromStr("fr");
                int       hvoOuter, tag, ihvo;
                ITsString tss;

                switch (frag)
                {
                case 1:                         // A ScrBook; display the title.
                    vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 2);
                    break;

                case 2:                         // An StText; display the paragraphs.
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
                    tss = TsStringUtils.MakeString(
                        "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
                        frWs);
                    vwenv.AddString(tss);
                    vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 3);
                    break;

                case 3:                         // StTxtPara, display details of our outer object
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
                    tss = TsStringUtils.MakeString(
                        "Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
                        frWs);
                    vwenv.AddString(tss);
                    break;

                default:
                    throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
                }
            }
Exemple #3
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// We need to show something, since the current view code can't handle a property
        /// containing no boxes.  Check to see if the StText is missing or if there are
        /// no paragraphs.  If so, then put in an empty string placeholder.
        /// TODO (FWR-1688): If we prevent the occurrence of texts with no paragraphs in FDO,
        /// this code can be removed.
        /// </summary>
        /// <param name="vwenv">view environment</param>
        /// <param name="hvo">id of object to be displayed</param>
        /// <returns>true if an empty string was substituted for missing/empty StText</returns>
        /// -----------------------------------------------------------------------------------
        protected bool HandleEmptyText(IVwEnv vwenv, int hvo)
        {
            if (hvo == 0 || vwenv.DataAccess.get_VecSize(hvo, StTextTags.kflidParagraphs) > 0)
            {
                return(false);
            }

            // Either we have no ST object at all, or it is empty of paragraphs. The
            // current view code can't handle either, so stick something in.
            // ENHANCE JohnT: come up with a real solution. This makes it look right,
            // but we should (a) be able to edit and have the first paragraph and
            // if necessary the text itself be created; and (b) if someone adds a real
            // paragraph and/or text in some other view, have them show up.
            int       ws         = vwenv.DataAccess.WritingSystemFactory.UserWs;
            ITsString tssMissing = TsStringUtils.EmptyString(ws);

            vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor,
                                  (int)FwTextPropVar.ktpvDefault, m_BackColor.ToArgb());
            vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
                                     m_sDefaultParaStyle);
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);
            // This sets the current default writing system from the relevant field spec.
            vwenv.set_IntProperty((int)FwTextPropType.ktptBaseWs,
                                  (int)FwTextPropVar.ktpvDefault, m_wsDefault);
            vwenv.AddString(tssMissing);
            return(true);
        }
Exemple #4
0
        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");
            }
        }
Exemple #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            if (m_displayOptions.LiteralStringLabels)
            {
                ITsStrFactory factory = TsStrFactoryClass.Create();
                vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault));
            }
            switch (frag)
            {
            case kfragRoot:                     // the root; Display the paragraph
                AddParagraphBoxContents(vwenv, () =>
                {
                    if (m_displayOptions.ReadOnlyView)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                              (int)FwTextPropVar.ktpvEnum,
                                              (int)TptEditable.ktptNotEditable);
                    }
                });
                break;

            default:
                throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
            }
        }
Exemple #6
0
        /// <summary>
        /// Add to the current display (a paragraph should be open) a label followed by colon, in the standard style,
        /// that identifies a particular writing system from the current list.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="iws"></param>
        public void AddWsLabel(IVwEnv vwenv, int iws)
        {
            CheckDisposed();

            if (m_tssColon == null)
            {
                m_tssColon = TsStringUtils.MakeString(": ", m_lp.Cache.DefaultUserWs);
            }
            if (m_ttpLabelStyle == null)
            {
                m_ttpLabelStyle = LanguageCodeStyle;
            }
            vwenv.Props = m_ttpLabelStyle;
            vwenv.OpenSpan();
            vwenv.AddString(AnalysisWsLabels[iws]);
            vwenv.AddString(m_tssColon);
            vwenv.CloseSpan();
        }
Exemple #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Displays the footnote reference.
        /// </summary>
        /// <param name="vwenv">The view environment.</param>
        /// <param name="hvoFootnote">The HVO of the footnote.</param>
        /// ------------------------------------------------------------------------------------
        internal void DisplayFootnoteReference(IVwEnv vwenv, int hvoFootnote)
        {
            IScrFootnote footnote = m_cache.ServiceLocator.GetInstance <IScrFootnoteRepository>().GetObject(hvoFootnote);
            ITsString    tssRef   = TsStringUtils.MakeTss(footnote.GetReference(m_wsDefault),
                                                          m_wsDefault, ScrStyleNames.FootnoteTargetRef);

            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            vwenv.AddString(tssRef);
        }
Exemple #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragRoot:                     // the root; Display the paragraph
                using (new VwConstructorServices.ParagraphBoxHelper(vwenv,
                                                                    () =>
                {
                    if (m_displayOptions.ReadOnlyView)
                    {
                        vwenv.set_IntProperty(
                            (int)FwTextPropType.ktptEditable,
                            (int)FwTextPropVar.ktpvEnum,
                            (int)TptEditable.ktptNotEditable);
                    }
                }))
                {
                    if (m_displayOptions.LiteralStringLabels)
                    {
                        using (new VwConstructorServices.InnerPileHelper(vwenv))
                        {
                            ITsStrFactory factory = TsStrFactoryClass.Create();
                            foreach (var ws in WsOrder)
                            {
                                using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
                                {
                                    if (m_displayOptions.LiteralStringLabels)
                                    {
                                        vwenv.AddString(factory.MakeString("Label" + ws, ws));
                                    }
                                }
                            }
                        }
                    }
                    using (new VwConstructorServices.InnerPileHelper(vwenv))
                    {
                        ITsStrFactory factory = TsStrFactoryClass.Create();
                        foreach (var ws in WsOrder)
                        {
                            using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
                            {
                                //if (m_displayOptions.LiteralStringLabels)
                                //    vwenv.AddString(factory.MakeString("Label" + ws, ws));
                                vwenv.AddStringAltMember(kflidMultiString, ws, null);
                            }
                        }
                    }
                }

                break;

            default:
                throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
            }
        }
Exemple #9
0
 private void OutputItemNumber(IVwEnv vwenv, ITsString tssNumber)
 {
     if (vwenv is ConfiguredExport)
     {
         (vwenv as ConfiguredExport).OutputItemNumber(tssNumber, m_numberPartRef);
     }
     else
     {
         vwenv.AddString(tssNumber);
     }
 }
Exemple #10
0
                /// ------------------------------------------------------------------------------------
                /// <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();
                }
Exemple #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display the footnote marker.
        /// </summary>
        /// <param name="vwenv">View environment</param>
        /// <param name="footnote">The footnote.</param>
        /// ------------------------------------------------------------------------------------
        protected override void DisplayFootnoteMarker(IVwEnv vwenv, IStFootnote footnote)
        {
            // The footnote marker is not editable.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);

            ITsStrBldr strBldr = ((IScrFootnote)footnote).MakeFootnoteMarker(DefaultWs);

            strBldr.ReplaceTsString(strBldr.Length, strBldr.Length, OneSpaceString);
            vwenv.AddString(strBldr.GetString());
        }
Exemple #12
0
 public override void Display(IVwEnv vwenv, int hvo, int frag)
 {
     CheckDisposed();
     vwenv.set_StringProperty((int)FwTextPropType.ktptFontFamily,
                              StStyle.DefaultHeadingFont);
     vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
                           (int)FwTextPropVar.ktpvDefault,
                           (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.ControlDarkDark)));
     vwenv.set_IntProperty((int)FwTextPropType.ktptBold,
                           (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
     vwenv.AddString(m_text);
 }
Exemple #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display the footnote marker
        /// </summary>
        /// <param name="vwenv">View environment</param>
        /// <param name="footnote">The footnote.</param>
        /// ------------------------------------------------------------------------------------
        protected virtual void DisplayFootnoteMarker(IVwEnv vwenv, IStFootnote footnote)
        {
            // The footnote marker is not editable.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            vwenv.AddStringProp(StFootnoteTags.kflidFootnoteMarker, null);

            // add a read-only space after the footnote marker
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            vwenv.AddString(OneSpaceString);
        }
 /// <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);
     }
 }
Exemple #15
0
        /// <summary>
        /// Add to the current display (a paragraph should be open) a label followed by colon, in the standard style,
        /// that identifies a particular writing system from the current list.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="iws"></param>
        public void AddWsLabel(IVwEnv vwenv, int iws)
        {
            CheckDisposed();

            if (m_tssColon == null)
            {
                ITsStrFactory tsf = TsStrFactoryClass.Create();
                m_tssColon = tsf.MakeString(": ", m_lp.Cache.DefaultUserWs);
            }
            if (m_ttpLabelStyle == null)
            {
                ITsPropsFactory tpf = TsPropsFactoryClass.Create();
                // Get a ttp invoking the style "Language Code" style for the writing system
                // which corresponds to the user's environment.
                m_ttpLabelStyle = tpf.MakeProps("Language Code", m_lp.Cache.DefaultUserWs, 0);
            }
            vwenv.Props = m_ttpLabelStyle;
            vwenv.OpenSpan();
            vwenv.AddString(AnalysisWsLabels[iws]);
            vwenv.AddString(m_tssColon);
            vwenv.CloseSpan();
        }
 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();
         }
     }
 }
Exemple #17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display the footnote marker.
        /// </summary>
        /// <param name="vwenv">View environment</param>
        /// <param name="footnote">The footnote.</param>
        /// ------------------------------------------------------------------------------------
        private void DisplayFootnoteMarker(IVwEnv vwenv, ScrFootnote footnote)
        {
            vwenv.NoteDependency(new int[] { footnote.Hvo },
                                 new int[] { (int)StFootnote.StFootnoteTags.kflidFootnoteMarker }, 1);
            // The footnote marker is not editable.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);

            ITsStrBldr strBldr = footnote.MakeFootnoteMarker(DefaultWs);

            strBldr.Replace(strBldr.Length, strBldr.Length, " ", null);
            vwenv.AddString(strBldr.GetString());
        }
 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();
 }
Exemple #20
0
        /// <summary>
        /// This is for an IAnalysis object at a particular index of a Segment.
        /// </summary>
        internal override void AddExtraBundleRows(IVwEnv vwenv, AnalysisOccurrence analysis)
        {
            ITsString tss;
            var       key = GetDictKey(analysis);

            if (m_tagStrings.TryGetValue(key, out tss))
            {
                var stText = analysis.Segment.Owner.Owner;
                // If either the Segment's analyses sequence or the tags on the text change, we want to redraw this
                vwenv.NoteDependency(new [] { analysis.Segment.Hvo, stText.Hvo },
                                     new [] { SegmentTags.kflidAnalyses, StTextTags.kflidTags }, 2);
                SetTrailingAlignmentIfNeeded(vwenv, tss);
                vwenv.AddString(tss);
            }
        }
Exemple #21
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Handles displaying the vector of words with commas except after the last
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="tag"></param>
        /// <param name="frag"></param>
        /// -----------------------------------------------------------------------------------
        public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag)
        {
            Debug.Assert(frag == kfragWords);
            ISilDataAccess sda    = vwenv.DataAccess;
            int            cwords = sda.get_VecSize(hvo, ktagWords);

            for (int i = 0; i < cwords; i++)
            {
                vwenv.AddObj(sda.get_VecItem(hvo, ktagWords, i), this, kfragName);
                if (i != cwords - 1)
                {
                    vwenv.AddString(m_tssComma);
                }
            }
        }
Exemple #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display the footnote marker
        /// </summary>
        /// <param name="vwenv">View environment</param>
        /// ------------------------------------------------------------------------------------
        private void DisplayFootnoteMarker(IVwEnv vwenv)
        {
            // The footnote marker is not editable.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);
            vwenv.AddStringProp((int)StFootnote.StFootnoteTags.kflidFootnoteMarker, null);

            // add a read-only space after the footnote marker
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);
            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.Append(" ");
            vwenv.AddString(strBldr.GetString());
        }
Exemple #23
0
 public override void Display(IVwEnv vwenv, int hvo, int frag)
 {
     vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
                           (int)FwTextPropVar.ktpvDefault,
                           (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.ControlDarkDark)));
     // By default, the paragraph that is created automatically by AddString will automatically inherit
     // the background color of the whole view (typically white). A paragraph with a background color
     // of white rather than transparent is automatically as wide as it is allowed to be (so as to display
     // the background color over the whole area the user things of as being that paragraph).
     // However, we want LiteralLabelView to adjust its size so it is just big enough to show the label,
     // so we can use the rest of the space for the command menu items. So we need to make the paragraph
     // transparent background, which allows it to be just as wide as the text content.
     vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
                           (int)FwTextPropVar.ktpvDefault,
                           (int)FwTextColor.kclrTransparent);
     vwenv.set_IntProperty((int)FwTextPropType.ktptBold,
                           (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
     vwenv.AddString(m_text);
 }
 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();
 }
Exemple #25
0
        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");
            }
        }
Exemple #26
0
        /// ------------------------------------------------------------------------------------
        /// <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();
        }
Exemple #27
0
        /// <summary>
        /// Method to insert the homograph number with settings into the Text
        /// </summary>
        private void InsertHomographNumber(IVwEnv vwenv, HomographConfiguration hc, int nHomograph, int defUserWs)
        {
            if (nHomograph <= 0)
            {
                return;
            }

            // Use a string builder to embed the properties in with the TsString.
            // this allows our TsStringCollectorEnv to properly encode the superscript.
            // ideally, TsStringCollectorEnv could be made smarter to handle SetIntPropValues
            // since AppendTss treats the given Tss as atomic.
            ITsIncStrBldr tsBldr = TsStringUtils.MakeIncStrBldr();

            tsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                    (int)FwTextPropVar.ktpvEnum,
                                    (int)FwSuperscriptVal.kssvSub);
            tsBldr.SetIntPropValues((int)FwTextPropType.ktptBold,
                                    (int)FwTextPropVar.ktpvEnum,
                                    (int)FwTextToggleVal.kttvForceOn);
            tsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                    (int)FwTextPropVar.ktpvDefault, defUserWs);
            StringServices.InsertHomographNumber(tsBldr, nHomograph, hc, HomographConfiguration.HeadwordVariant.Main, m_cache);
            vwenv.AddString(tsBldr.GetString());
        }
Exemple #28
0
		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)
		{
			// 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");
			}
		}
Exemple #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays the footnote reference.
		/// </summary>
		/// <param name="vwenv">The view environment.</param>
		/// <param name="hvoFootnote">The HVO of the footnote.</param>
		/// ------------------------------------------------------------------------------------
		internal void DisplayFootnoteReference(IVwEnv vwenv, int hvoFootnote)
		{
			IScrFootnote footnote = m_cache.ServiceLocator.GetInstance<IScrFootnoteRepository>().GetObject(hvoFootnote);
			ITsString tssRef = TsStringUtils.MakeTss(footnote.GetReference(m_wsDefault),
				m_wsDefault, ScrStyleNames.FootnoteTargetRef);
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
			vwenv.AddString(tssRef);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case kfragRoot: // the root; Display the paragraph
					using (new VwConstructorServices.ParagraphBoxHelper(vwenv,
							() =>
								{
									if (m_displayOptions.ReadOnlyView)
									{
										vwenv.set_IntProperty(
										(int)FwTextPropType.ktptEditable,
										(int)FwTextPropVar.ktpvEnum,
										(int)TptEditable.ktptNotEditable);
									}
								}))
					{
						if (m_displayOptions.LiteralStringLabels)
						{
							using (new VwConstructorServices.InnerPileHelper(vwenv))
							{
								ITsStrFactory factory = TsStrFactoryClass.Create();
								foreach (var ws in WsOrder)
								{
									using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
									{
										if (m_displayOptions.LiteralStringLabels)
											vwenv.AddString(factory.MakeString("Label" + ws, ws));
									}
								}
							}
						}
						using (new VwConstructorServices.InnerPileHelper(vwenv))
						{
							ITsStrFactory factory = TsStrFactoryClass.Create();
							foreach (var ws in WsOrder)
							{
								using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
								{
									//if (m_displayOptions.LiteralStringLabels)
									//    vwenv.AddString(factory.MakeString("Label" + ws, ws));
									vwenv.AddStringAltMember(kflidMultiString, ws, null);
								}
							}
						}
					}

					break;
				default:
					throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
			}
		}
Exemple #32
0
		/// ------------------------------------------------------------------------------------
		/// <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;
			}
		}
Exemple #33
0
		/// <summary>
		/// Add the specified string in the specified color to the display, using the UI Writing system.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="color"></param>
		/// <param name="str"></param>
		protected void AddColoredString(IVwEnv vwenv, int color, string str)
		{
			SetColor(vwenv, color);
			vwenv.AddString(m_tsf.MakeString(str, m_wsUi));
		}
Exemple #34
0
		/// -----------------------------------------------------------------------------------
		/// <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");
			}
		}
        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");
            }
        }
Exemple #36
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragRHS:
                m_rhs = m_cache.ServiceLocator.GetInstance <IPhSegRuleRHSRepository>().GetObject(hvo);
                var rule = m_rhs.OwningRule;
                if (rule.Disabled)
                {
                    vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text");
                }

                int arrowWidth, slashWidth, underscoreWidth, charHeight;
                vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight);
                int maxCharHeight = charHeight;
                vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight);
                maxCharHeight = Math.Max(charHeight, maxCharHeight);
                vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight);
                maxCharHeight = Math.Max(charHeight, maxCharHeight);

                int dmpx, spaceHeight;
                vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight);

                int maxNumLines   = GetMaxNumLines();
                int maxCtxtHeight = maxNumLines * spaceHeight;

                int maxHeight   = Math.Max(maxCharHeight, maxCtxtHeight);
                int charOffset  = maxHeight;
                int ctxtPadding = maxHeight - maxCtxtHeight;

                VwLength tableLen;
                tableLen.nVal = 10000;
                tableLen.unit = VwUnit.kunPercent100;
                vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false);

                VwLength ctxtLen;
                ctxtLen.nVal = 1;
                ctxtLen.unit = VwUnit.kunRelative;
                VwLength charLen;
                charLen.unit = VwUnit.kunPoint1000;
                vwenv.MakeColumns(1, ctxtLen);

                charLen.nVal = arrowWidth + 4000;
                vwenv.MakeColumns(1, charLen);

                vwenv.MakeColumns(1, ctxtLen);

                charLen.nVal = slashWidth + 4000;
                vwenv.MakeColumns(1, charLen);

                vwenv.MakeColumns(1, ctxtLen);

                charLen.nVal = underscoreWidth + 4000;
                vwenv.MakeColumns(1, charLen);

                vwenv.MakeColumns(1, ctxtLen);

                vwenv.OpenTableBody();
                vwenv.OpenTableRow();

                // LHS cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                vwenv.AddObjProp(m_cache.MetaDataCacheAccessor.GetFieldId2(PhSegRuleRHSTags.kClassId, "OwningRule", false), this, kfragRule);
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // arrow cell
                vwenv.Props = m_charProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset);
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_arrow);
                vwenv.CloseTableCell();

                // RHS cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rhs.StrucChangeOS.Count > 0)
                {
                    vwenv.AddObjVecItems(PhSegRuleRHSTags.kflidStrucChange, this, kfragContext);
                }
                else
                {
                    vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidStrucChange }, 1);
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // slash cell
                vwenv.Props = m_charProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset);
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_slash);
                vwenv.CloseTableCell();

                // left context cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rhs.LeftContextOA != null)
                {
                    vwenv.AddObjProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragContext);
                }
                else
                {
                    vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidLeftContext }, 1);
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // underscore cell
                vwenv.Props = m_charProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset);
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_underscore);
                vwenv.CloseTableCell();

                // right context cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rhs.RightContextOA != null)
                {
                    vwenv.AddObjProp(PhSegRuleRHSTags.kflidRightContext, this, kfragContext);
                }
                else
                {
                    vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidRightContext }, 1);
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();
                vwenv.CloseTableBody();
                vwenv.CloseTable();
                break;

            case kfragRule:
                if (m_rhs.OwningRule.StrucDescOS.Count > 0)
                {
                    vwenv.AddObjVecItems(PhSegmentRuleTags.kflidStrucDesc, this, kfragContext);
                }
                else
                {
                    OpenSingleLinePile(vwenv, GetMaxNumLines(), false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
Exemple #37
0
		/// ------------------------------------------------------------------------------------
		/// <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();
		}
Exemple #38
0
		/// <summary>
		/// Add a segment number appropriate to the current segment being displayed.
		/// (See LT-1236.)
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		private void AddSegmentReference(IVwEnv vwenv, int hvo)
		{
			ITsString tssSegNum;
			StringBuilder sbSegNum = new StringBuilder();
			int flid = 0;
			var seg = m_segRepository.GetObject(hvo);
			var para = seg.Paragraph;
			if (para != null)
			{
				ISilDataAccess sda = vwenv.DataAccess;
				int cseg = para.SegmentsOS.Count;
				int idxSeg = para.SegmentsOS.IndexOf(seg); // sda.GetObjIndex(hvoStPara, ktagParaSegments, hvo);
				IStText stText = para.Owner as IStText;
				if (stText != null)
					flid = stText.OwningFlid;
				if (flid == ScrSectionTags.kflidContent)
				{
					var scrPara = para as IScrTxtPara;
					// With null book name and trimmed it should have just chapter:v{a,b}.
					// The {a,b} above would not be the segment identifiers we add for multiple segments in
					// a verse, but the letters indicating that the verse label is for only part of the verse.
					// There is therefore a pathological case where, say, verse 4a as labeled in the main text
					// gets another letter because 4a has multiple segments 4aa, 4ab, etc.
					string chapRef = ScriptureServices.FullScrRef(scrPara, seg.BeginOffset, "").Trim();
					sbSegNum.Append(chapRef + ScriptureServices.VerseSegLabel(scrPara, idxSeg));
				}
				else
				{
					int idxPara = para.OwnOrd;
					if (idxPara >= 0)
					{
						sbSegNum.AppendFormat("{0}", idxPara + 1);
						if (idxSeg >= 0 && cseg > 1)
							sbSegNum.AppendFormat(".{0}", idxSeg + 1);
					}
				}
			}
			ITsStrBldr tsbSegNum = m_tsf.GetBldr();
			tsbSegNum.ReplaceTsString(0, tsbSegNum.Length, TsStringUtils.MakeTss(sbSegNum.ToString(), m_cache.DefaultUserWs));
			tsbSegNum.SetIntPropValues(0, tsbSegNum.Length, (int)FwTextPropType.ktptBold,
				(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
			tssSegNum = tsbSegNum.GetString();
			vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 10000);
			vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
				(int)FwTextPropVar.ktpvDefault, (int)CmObjectUi.RGB(SystemColors.ControlText));
			try
			{
				m_fIsAddingSegmentReference = true;
				vwenv.OpenInnerPile();
				vwenv.AddString(tssSegNum);
				vwenv.CloseInnerPile();
			}
			finally
			{
				m_fIsAddingSegmentReference = false;
			}
		}
Exemple #39
0
		/// <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;
			}
		}
Exemple #41
0
		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)
		{
			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;
			}
		}
Exemple #43
0
			private void DisplayWithWritingSystemLabel(IVwEnv vwenv, int ws)
			{
				ITsString tssLabel = NameOfWs(ws);
				// 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;

				int dxs;	// Width of displayed string.
				int dys;	// Height of displayed string (not used here).
				vwenv.get_StringWidth(tssLabel, null, out dxs, out dys);
				VwLength vlColWs; // 5-pt space plus max label width.
				vlColWs.nVal = dxs + 5000;
				vlColWs.unit = VwUnit.kunPoint1000;

				// The Main column is relative and uses the rest of the space.
				VwLength vlColMain;
				vlColMain.nVal = 1;
				vlColMain.unit = VwUnit.kunRelative;

				// Enhance JohnT: possibly allow for right-to-left UI by reversing columns?

				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();
				vwenv.OpenTableRow();

				// First cell has writing system abbreviation displayed using m_ttpLabel.
				//vwenv.Props = m_ttpLabel;
				vwenv.OpenTableCell(1, 1);
				vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
					(int)TptEditable.ktptNotEditable);
				vwenv.AddString(tssLabel);
				vwenv.CloseTableCell();

				// Second cell has the string contents for the alternative.
				// DN version has some property setting, including trailing margin and RTL.
				if (m_fRtlScript)
				{
					vwenv.set_IntProperty((int) FwTextPropType.ktptRightToLeft,
										  (int) FwTextPropVar.ktpvEnum,
										  (int) FwTextToggleVal.kttvForceOn);
					vwenv.set_IntProperty((int) FwTextPropType.ktptAlign,
										  (int) FwTextPropVar.ktpvEnum,
										  (int) FwTextAlign.ktalTrailing);
				}
				//if (!m_editable)
				//{
				//    vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
				//        (int)TptEditable.ktptNotEditable);
				//}

				vwenv.set_IntProperty((int) FwTextPropType.ktptPadTop, (int) FwTextPropVar.ktpvMilliPoint, 2000);
				vwenv.OpenTableCell(1, 1);
				vwenv.AddStringProp(m_flid, this);
				vwenv.CloseTableCell();
				vwenv.CloseTableRow();
				vwenv.CloseTableBody();
				vwenv.CloseTable();
			}
			/// ------------------------------------------------------------------------------------
			/// <summary>
			///
			/// </summary>
			/// <param name="vwenv"></param>
			/// <param name="hvo"></param>
			/// <param name="frag"></param>
			/// ------------------------------------------------------------------------------------
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				int hvoOuter, tag, ihvo;
				ITsString tss;
				switch (frag)
				{
					case 1: // A ScrBook; display the title.
						vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, 2);
						break;
					case 2: // An StText; display the paragraphs.
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							InMemoryFdoCache.s_wsHvos.Fr);
						vwenv.AddString(tss);
						vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 3);
						break;
					case 3: // StTxtPara, display details of our outer object
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							InMemoryFdoCache.s_wsHvos.Fr);
						vwenv.AddString(tss);
						break;
					default:
						throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
				}
			}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			if (m_displayOptions.LiteralStringLabels)
			{
				ITsStrFactory factory = TsStrFactoryClass.Create();
				vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault));
			}
			switch (frag)
			{
				case kfragRoot: // the root; Display the paragraph
					AddParagraphBoxContents(vwenv, () =>
					{
						if (m_displayOptions.ReadOnlyView)
						{
							vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
								(int)FwTextPropVar.ktpvEnum,
								(int)TptEditable.ktptNotEditable);
						}
					});
					break;
				default:
					throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
			}
		}
Exemple #46
0
			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;
					}
				}
			}
Exemple #47
0
		/// <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();
		}
Exemple #48
0
		/// <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;
		}
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			TriggerDisplay(vwenv);
			//if (m_rgws.Length == 1)
			//{
			//    // Single option...don't bother with labels.
			//    if (m_rgws[0].RightToLeft)
			//    {
			//        vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
			//            (int)FwTextPropVar.ktpvEnum,
			//            (int)FwTextToggleVal.kttvForceOn);
			//        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
			//            (int)FwTextPropVar.ktpvEnum,
			//            (int)FwTextAlign.ktalTrailing);
			//    }
			//    vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
			//    vwenv.AddStringAltMember(m_flid, m_rgws[0].Hvo, this);
			//    return;
			//}
			ITsStrFactory tsf = TsStrFactoryClass.Create();
			// 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.
			for (int i = 0; i < m_rgws.Length; ++i)
			{
				// Set qtss to a string representing the writing system.
				vwenv.get_StringWidth(NameOfWs(tsf, i),
					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();
			Set<ILgWritingSystem> visibleWss = new Set<ILgWritingSystem>();
			// if we passed in a view and have WritingSystemsToDisplay
			// then we'll load that list in order to filter our larger m_rgws list.
			AddViewWritingSystems(visibleWss);
			for (int i = 0; i < m_rgws.Length; ++i)
			{
				if (SkipEmptyWritingSystem(visibleWss, i, hvo))
					continue;
				vwenv.OpenTableRow();

				// First cell has writing system abbreviation displayed using m_ttpLabel.
				vwenv.Props = m_ttpLabel;
				vwenv.OpenTableCell(1,1);
				vwenv.AddString(NameOfWs(tsf, i));
				vwenv.CloseTableCell();

				// Second cell has the string contents for the alternative.
				// DN version has some property setting, including trailing margin and
				// RTL.
				if (m_rgws[i].RightToLeft)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
						(int)FwTextPropVar.ktpvEnum,
						(int)FwTextToggleVal.kttvForceOn);
					vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
						(int)FwTextPropVar.ktpvEnum,
						(int)FwTextAlign.ktalTrailing);
				}
				if (!m_editable)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
				}
				vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
				vwenv.OpenTableCell(1,1);
				vwenv.AddStringAltMember(m_flid, m_rgws[i].Hvo, this);
				vwenv.CloseTableCell();

				vwenv.CloseTableRow();
			}
			vwenv.CloseTableBody();

			vwenv.CloseTable();
		}
Exemple #50
0
			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();
			}
Exemple #51
0
			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();
			}
Exemple #52
0
		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
		}
			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;
					}
				}
			}
Exemple #54
0
		/// <summary>
		/// Displays a MorphBundle, setting the colors of its parts.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo">WfiMorphBundle</param>
		private void DisplayMorphBundle(IVwEnv vwenv, int hvo)
		{
			IWfiMorphBundle wmb = null;
			if (hvo != 0)
				wmb = m_wmbRepository.GetObject(hvo);
			vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 10000);
			vwenv.OpenInnerPile();
			int first = m_lineChoices.FirstMorphemeIndex;
			int last = m_lineChoices.LastMorphemeIndex;
			IMoForm mf = null;
			if (wmb != null)
				mf = wmb.MorphRA;
			if (vwenv is CollectorEnv && mf != null)
			{
				// Collectors are given an extra initial chance to 'collect' the morph type, if any.
				vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph,
					this, kfragMorphType);

			}
			for (int i = first; i <= last; i++)
			{
				InterlinLineSpec spec = m_lineChoices[i];
				SetColor(vwenv, LabelRGBFor(spec));
				switch (spec.Flid)
				{
					case InterlinLineChoices.kflidMorphemes:
						if (wmb == null)
						{
							vwenv.AddString(m_tssMissingMorph);
						}
						else if (mf == null)
						{
							// displaying morphemes should be
							int ws = 0;
							if (wmb.MorphRA != null)
							{
								Debug.Assert(spec.StringFlid == MoFormTags.kflidForm);
								ws = GetRealWsOrBestWsForContext(wmb.MorphRA.Hvo, spec);
							}
							// If no morph, use the form of the morph bundle (and the entry is of
							// course missing)
							if (ws == 0)
							{
								ws = WritingSystemServices.ActualWs(m_cache, spec.WritingSystem, wmb.Hvo,
									WfiMorphBundleTags.kflidForm);
							}
							vwenv.AddStringAltMember(
								WfiMorphBundleTags.kflidForm, ws, this);
						}
						else
						{
							// Got a morph, show it.
							vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph,
								this, kfragMorphFormChoices + i);
							// And the LexEntry line.
						}
						break;
					case InterlinLineChoices.kflidLexEntries:
						if (mf == null)
						{
							if (hvo != 0)
								vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMorph }, 1);
							vwenv.AddString(m_tssMissingEntry);
						}
						else
						{
							int ws = GetRealWsOrBestWsForContext(mf.Hvo, spec);
							if (ws == 0)
								ws = spec.WritingSystem;
							LexEntryVc vcEntry = new LexEntryVc(m_cache);
							vcEntry.WritingSystemCode = ws;
							vwenv.AddObj(hvo, vcEntry, LexEntryVc.kfragEntryAndVariant);
						}
						break;
					case InterlinLineChoices.kflidLexGloss:
						int flid = 0;
						if (wmb != null)
						{
							vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidMorph }, 1);
							vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1);
							vwenv.NoteDependency(new[] { hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1);
							if (wmb.SenseRA == null)
							{
								if (ShowDefaultSense && wmb.DefaultSense != null && UsingGuess)
								{
									flid = wmb.Cache.MetaDataCacheAccessor.GetFieldId2(WfiMorphBundleTags.kClassId,
										"DefaultSense", false);
								}
							}
							else
							{
								flid = WfiMorphBundleTags.kflidSense;
								if (wmb.MorphRA != null &&
									DisplayLexGlossWithInflType(vwenv, wmb.MorphRA.Owner as ILexEntry, wmb.SenseRA, spec, wmb.InflTypeRA))
								{
									break;
								}

							}
						}

						if (flid == 0)
							vwenv.AddString(m_tssMissingSense);
						else
							vwenv.AddObjProp(flid, this, kfragLineChoices + i);
						break;

					case InterlinLineChoices.kflidLexPos:
						// LexPOS line:
						int hvoMsa = 0;
						if (wmb != null && wmb.MsaRA != null)
							hvoMsa = wmb.MsaRA.Hvo;
						if (hvoMsa == 0)
						{
							if (hvo != 0)
								vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMsa }, 1);
							vwenv.AddString(m_tssMissingMsa);
						}
						else
						{
							// Use a special view constructor that knows how to display the
							// interlinear view of whatever kind of MSA it is.
							// Enhance JohnT: ideally we would have one of these VCs for each writing system,
							// perhaps stored in the InterlinLineSpec. Currently displaying multiple Wss of LexPos
							// is not useful, though it is possible.
							// Enhancement RickM: we set the m_msaVc.DefaultWs to the selected writing system
							//		of each LexPos line in interlinear. This is used extract the LexPos abbreviation
							//		for the specific writing system.
							m_msaVc.DefaultWs = spec.WritingSystem;
							vwenv.AddObjProp(WfiMorphBundleTags.kflidMsa,
								m_msaVc, (int)VcFrags.kfragInterlinearAbbr);
						}
						break;
				}
			}
			vwenv.CloseInnerPile();
		}
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			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");
			}
		}
Exemple #56
0
		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();
		}
Exemple #57
0
        /// <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:
                // Check for an empty vector.
                if (hvo == 0 || m_cache.DomainDataByFlid.get_VecSize(hvo, m_flid) == 0)
                {
                    vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
                                          (int)FwTextPropVar.ktpvDefault,
                                          (int)ColorUtil.ConvertColorToBGR(Color.Gray));
                    vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
                                          (int)FwTextPropVar.ktpvMilliPoint, 18000);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                          (int)FwTextPropVar.ktpvDefault,
                                          (int)TptEditable.ktptNotEditable);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                          (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
                    //vwenv.AddString(m_cache.MakeUserTss("Click to select -->"));
                    if (hvo != 0)
                    {
                        vwenv.NoteDependency(new[] { hvo }, new[] { m_flid }, 1);
                    }
                }
                else
                {
                    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 from the vector.
            {
                ILgWritingSystemFactory wsf =
                    m_cache.WritingSystemFactory;

                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvDefault,
                                      (int)TptEditable.ktptNotEditable);
                ITsString tss;
                Debug.Assert(hvo != 0);
#if USEBESTWS
                if (m_displayWs != null && m_displayWs.StartsWith("best"))
                {
                    // The flid can be a variety of types, so deal with those.
                    Debug.WriteLine("Using 'best ws': " + m_displayWs);
                    int magicWsId = LgWritingSystem.GetMagicWsIdFromName(m_displayWs);
                    int actualWS  = m_cache.LanguageProject.ActualWs(magicWsId, hvo, m_flid);
                    Debug.WriteLine("Actual ws: " + actualWS.ToString());
                }
                else
                {
#endif
                // Use reflection to get a prebuilt name if we can.  Otherwise
                // settle for piecing together a string.
                Debug.Assert(m_cache != null);
                var obj = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo);
                Debug.Assert(obj != null);
                Type type = obj.GetType();
                System.Reflection.PropertyInfo pi = type.GetProperty("TsName",
                                                                     System.Reflection.BindingFlags.Instance |
                                                                     System.Reflection.BindingFlags.Public |
                                                                     System.Reflection.BindingFlags.FlattenHierarchy);
                if (pi != null)
                {
                    tss = (ITsString)pi.GetValue(obj, null);
                }
                else
                {
                    if (!string.IsNullOrEmpty(m_displayNameProperty))
                    {
                        pi = type.GetProperty(m_displayNameProperty,
                                              System.Reflection.BindingFlags.Instance |
                                              System.Reflection.BindingFlags.Public |
                                              System.Reflection.BindingFlags.FlattenHierarchy);
                    }
                    int ws = wsf.GetWsFromStr(obj.SortKeyWs);
                    if (ws == 0)
                    {
                        ws = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                    }
                    if (pi != null)
                    {
                        object s = pi.GetValue(obj, null);
                        if (s is ITsString)
                        {
                            tss = (ITsString)s;
                        }
                        else
                        {
                            tss = TsStringUtils.MakeString((string)s, ws);
                        }
                    }
                    else
                    {
                        // ShortNameTss sometimes gets PropChanged, so worth letting the view know that's
                        // what we're inserting.
                        var flid = Cache.MetaDataCacheAccessor.GetFieldId2(obj.ClassID, "ShortNameTSS", true);
                        vwenv.AddStringProp(flid, this);
                        break;
                    }
#if USEBESTWS
                }
#endif
                }
                if (!string.IsNullOrEmpty(TextStyle))
                {
                    vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle);
                }
                vwenv.AddString(tss);
            }
            break;

            default:
                throw new ArgumentException(
                          "Don't know what to do with the given frag.", "frag");
            }
        }
Exemple #58
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Display the footnote marker.
		/// </summary>
		/// <param name="vwenv">View environment</param>
		/// <param name="footnote">The footnote.</param>
		/// ------------------------------------------------------------------------------------
		private void DisplayFootnoteMarker(IVwEnv vwenv, ScrFootnote footnote)
		{
			vwenv.NoteDependency(new int[] { footnote.Hvo },
				new int[] { (int)StFootnote.StFootnoteTags.kflidFootnoteMarker }, 1);
			// The footnote marker is not editable.
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum,
				(int)TptEditable.ktptNotEditable);

			ITsStrBldr strBldr = footnote.MakeFootnoteMarker(DefaultWs);
			strBldr.Replace(strBldr.Length, strBldr.Length, " ", null);
			vwenv.AddString(strBldr.GetString());
		}
Exemple #59
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Handles displaying the vector of words with commas except after the last
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="tag"></param>
		/// <param name="frag"></param>
		/// -----------------------------------------------------------------------------------
		public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag)
		{
			CheckDisposed();

			Debug.Assert(frag == kfragWords);
			ISilDataAccess sda = vwenv.DataAccess;
			int cwords = sda.get_VecSize(hvo, ktagWords);
			for (int i = 0; i < cwords; i++)
			{
				vwenv.AddObj(sda.get_VecItem(hvo, ktagWords, i), this, kfragName);
				if (i != cwords - 1)
					vwenv.AddString(m_tssComma);
			}
		}
Exemple #60
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is the main interesting method of displaying objects and fragments of them.
		/// Scripture Footnotes are displayed by displaying each footnote's reference and text.
		/// The text is displayed using the standard view constructor for StText.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			switch (frag)
			{
				case (int)FootnoteFrags.kfrScripture:
				{
					vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo },
						new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1);
					vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook);
					break;
				}
				case (int)FootnoteFrags.kfrRootInPageSeq:
				{
					int tag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor,
						"Scripture", "FootnotesOnPage",
						(int)CellarModuleDefns.kcptReferenceSequence).Tag;
					// Get the list of footnotes to display
					int[] hvos = m_cache.GetVectorProperty(hvo, tag, true);
					if (hvos.Length > 0)
					{
						int ownerHvo = m_cache.GetOwnerOfObject(hvos[0]);
						// The ownerHvo should be the HVO of the book
						vwenv.NoteDependency(new int[] { ownerHvo },
							new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, 1);
					}
					vwenv.AddObjVec(tag, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara);
					break;
				}
				case (int)FootnoteFrags.kfrFootnoteWithinPagePara:
				{
					// Note a dependency on the footnote options so that the footnote will
					// be refreshed when these are changed.
					int[] depHvos = { hvo };
					int[] depTags = { StFootnote.ktagFootnoteOptions };
					vwenv.NoteDependency(depHvos, depTags, 1);

					// Insert the marker and reference
					vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker);
					vwenv.AddObj(hvo,  this,(int)StTextFrags.kfrFootnoteReference);

					// Insert (we hope only one) paragraph contents.
					vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
						(int)FootnoteFrags.kfrFootnoteParaWithinPagePara);
					break;
				}
				case (int) FootnoteFrags.kfrFootnoteParaWithinPagePara:
				{
					if (!InsertParaContentsUserPrompt(vwenv, hvo))
					{
						// Display the text paragraph contents, or its user prompt.
						vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
					}
					break;
				}
				case (int)FootnoteFrags.kfrBook:
				{
					vwenv.OpenDiv();
					vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this,
						(int)StTextFrags.kfrFootnote);
					vwenv.CloseDiv();
					break;
				}
				case (int)StTextFrags.kfrFootnoteMarker:
				{
					ScrFootnote footnote = new ScrFootnote(Cache, hvo);
					if (footnote.DisplayFootnoteMarker)
						DisplayFootnoteMarker(vwenv, footnote);
					break;
				}
				case (int)StTextFrags.kfrFootnoteReference:
				{
					ITsStrFactory tsStrFactory = TsStrFactoryClass.Create();
					ITsPropsFactory tpf = TsPropsFactoryClass.Create();
					ITsTextProps ttp = tpf.MakeProps(ScrStyleNames.FootnoteTargetRef, m_wsDefault, 0);

					ScrFootnote footnote = new ScrFootnote(m_cache, hvo);
					string footnoteRef = footnote.GetReference(m_wsDefault);
					ITsString tssRef = tsStrFactory.MakeStringWithPropsRgch(footnoteRef,
						footnoteRef.Length, ttp);
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
					vwenv.AddString(tssRef);
					break;
				}
				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}