private void DisplayMinMax(int numLines, IVwEnv vwenv)
        {
            int superOffset = 0;

            if (numLines == 1)
            {
                // if the inner context is a single line, then make the min value a subscript and the max value a superscript.
                // I tried to use the Views subscript and superscript properties, but they added extra space so that it would
                // have the same line height of a normal character, which is not what I wanted, so I compute the size myself
                int fontHeight     = GetFontHeight(m_cache.DefaultUserWs);
                int superSubHeight = (fontHeight * 2) / 3;
                vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, superSubHeight);
                vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight, (int)FwTextPropVar.ktpvMilliPoint, -superSubHeight);
                superOffset = superSubHeight / 2;
            }
            else
            {
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
            }
            vwenv.OpenInnerPile();
            if (numLines == 1)
            {
                vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, superOffset);
            }
            vwenv.OpenParagraph();
            vwenv.AddProp(ktagRightNonBoundary, this, kfragNodeMax);
            vwenv.CloseParagraph();
            AddExtraLines(numLines - 2, ktagRightNonBoundary, vwenv);
            vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, 0);
            vwenv.OpenParagraph();
            vwenv.AddProp(ktagRightBoundary, this, kfragNodeMin);
            vwenv.CloseParagraph();
            vwenv.CloseInnerPile();
        }
        private void DisplayInflFeatureLines(IVwEnv vwenv, IDictionary <IFsFeatDefn, object> inflFeatures, bool openPara)
        {
            IDictionary <IFsFeatDefn, object> lastInflFeatures = m_curInflFeatures;

            m_curInflFeatures = inflFeatures;
            foreach (KeyValuePair <IFsFeatDefn, object> kvp in inflFeatures)
            {
                if (kvp.Key is IFsComplexFeature)
                {
                    if (openPara)
                    {
                        vwenv.OpenParagraph();
                    }
                    vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine);
                    DisplayInflFeatures(vwenv, (IDictionary <IFsFeatDefn, object>)kvp.Value);
                    if (openPara)
                    {
                        vwenv.CloseParagraph();
                    }
                }
                else
                {
                    vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine);
                }
            }
            m_curInflFeatures = lastInflFeatures;
        }
            /// <summary>
            /// Add to the vwenv a display of property tag of object hvo, which stores an
            /// SbNamedObj.  If the property is non-null, display the name of the SbNamedObj.
            /// If not, display the dummyTag 'property' using the dummyFrag.
            /// </summary>
            /// <param name="vwenv"></param>
            /// <param name="hvo"></param>
            /// <param name="tag"></param>
            /// <param name="dummyTag"></param>
            /// <param name="dummyFrag"></param>
            /// <param name="tagIcon">If non-zero, display a pull-down icon before the item, marked with this tag.</param>
            /// <param name="ws">which alternative of the name to display</param>
            /// <param name="choiceIndex">which item in m_choices this comes from. The icon is displayed
            /// only if it is the first one for its flid.</param>
            protected void AddOptionalNamedObj(IVwEnv vwenv, int hvo, int tag, int dummyTag,
                                               int dummyFrag, int tagIcon, int ws, int choiceIndex)
            {
                int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, tag);

                SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));
                bool fWantIcon = false;

                fWantIcon = tagIcon != 0 && m_choices.IsFirstOccurrenceOfFlid(choiceIndex);
                if (m_fIconsForAnalysisChoices && !fWantIcon)
                {
                    // This line does not have one, but add some white space to line things up.
                    vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
                                          (int)FwTextPropVar.ktpvMilliPoint,
                                          m_dxmpArrowPicWidth + kmpIconMargin);
                }
                vwenv.OpenParagraph();
                if (fWantIcon)
                {
                    AddPullDownIcon(vwenv, tagIcon);
                }
                // The NoteDependency is needed whether or not hvoNo is set, in case we update
                // to a sense which has a null MSA.  See LT-4246.
                vwenv.NoteDependency(new int[] { hvo }, new int[] { tag }, 1);
                if (hvoNo == 0)
                {
                    vwenv.AddProp(dummyTag, this, dummyFrag);
                }
                else
                {
                    vwenv.AddObjProp(tag, this, kfragNamedObjectNameChoices + choiceIndex);
                }
                vwenv.CloseParagraph();
            }
Exemple #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Check the given translation to see if the text is empty. If so, then insert a
        /// user prompt.
        /// </summary>
        /// <param name="vwenv">view environment</param>
        /// <param name="trans">translation to be displayed</param>
        /// <returns>true if an empty string was substituted for missing/empty StText</returns>
        /// ------------------------------------------------------------------------------------
        protected override bool InsertTranslationUserPrompt(IVwEnv vwenv, ICmTranslation trans)
        {
            // No user prompt in any of these conditions
            if (trans == null || m_updatedPrompts.Contains(trans.Hvo))             // user interaction has updated prompt
            {
                return(false);
            }

            // If there is text in the translation then do not add a prompt.
            if (trans.Translation.get_String(m_wsDefault).Length > 0)
            {
                return(false);
            }

            // If there is no text in the parent paragraph then do not place a prompt in the
            // back translation.
            if (((IStTxtPara)trans.Owner).Contents.Length == 0)
            {
                return(false);
            }

            // Insert the prompt.
            vwenv.NoteDependency(new int[] { trans.Hvo },
                                 new int[] { CmTranslationTags.kflidTranslation }, 1);
            vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmTranslationTags.kflidTranslation);
            return(true);
        }
 public virtual void AddProp(int tag, IVwViewConstructor _vwvc, int frag)
 {
     if (!IsRtL)
     {
         m_vwEnv.AddProp(tag, _vwvc, frag);
         return;
     }
     throw new NotImplementedException();
 }
Exemple #6
0
 protected void CloseContextPile(IVwEnv vwenv, bool addBoundary)
 {
     if (addBoundary)
     {
         vwenv.Props = m_bracketProps;
         vwenv.AddProp(ktagRightBoundary, this, kfragZeroWidthSpace);
     }
     vwenv.CloseParagraph();
     vwenv.CloseInnerPile();
 }
Exemple #7
0
 protected void AddExtraLines(int numLines, int tag, IVwEnv vwenv)
 {
     for (int i = 0; i < numLines; i++)
     {
         vwenv.Props = m_bracketProps;
         vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
         vwenv.OpenParagraph();
         vwenv.AddProp(tag, this, kfragEmpty);
         vwenv.CloseParagraph();
     }
 }
Exemple #8
0
 protected void OpenContextPile(IVwEnv vwenv, bool addBoundary)
 {
     vwenv.Props = m_pileProps;
     vwenv.OpenInnerPile();
     AddExtraLines(MaxNumLines - 1, vwenv);
     vwenv.OpenParagraph();
     if (addBoundary)
     {
         vwenv.Props = m_bracketProps;
         vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace);
     }
 }
        private void DisplayInflFeatures(IVwEnv vwenv, IDictionary <IFsFeatDefn, object> inflFeatures)
        {
            int numLines = GetNumLines(inflFeatures);

            if (numLines == 1)
            {
                // use normal brackets for a single line constraint
                vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

                DisplayInflFeatureLines(vwenv, inflFeatures, false);

                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);
            }
            else
            {
                // left bracket pile
                vwenv.Props = m_bracketProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                vwenv.OpenInnerPile();
                vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                for (int i = 1; i < numLines - 1; i++)
                {
                    vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                }
                vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                vwenv.CloseInnerPile();

                // feature pile
                vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                vwenv.OpenInnerPile();
                DisplayInflFeatureLines(vwenv, inflFeatures, true);
                vwenv.CloseInnerPile();

                // right bracket pile
                vwenv.Props = m_bracketProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                vwenv.OpenInnerPile();
                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketUpHook);
                for (int i = 1; i < numLines - 1; i++)
                {
                    vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketExt);
                }
                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketLowHook);
                vwenv.CloseInnerPile();
            }
        }
Exemple #10
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// In certain contexts, check the given paragraph to see if it is empty. If so,
        /// insert a user prompt.
        /// </summary>
        /// <param name="vwenv">view environment</param>
        /// <param name="paraHvo">HVO of the paragraph to be displayed</param>
        /// <returns>true if an empty string was substituted for missing/empty StText</returns>
        /// -----------------------------------------------------------------------------------
        protected override bool InsertParaContentsUserPrompt(IVwEnv vwenv, int paraHvo)
        {
            Debug.Assert(!DisplayTranslation);

            // No user prompt in any of these conditions
            IStTxtPara para = m_cache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(paraHvo);

            if (!(para is IScrTxtPara) ||
                !Options.ShowEmptyParagraphPromptsSetting ||                 // tools options setting
                m_target == LayoutViewTarget.targetPrint ||                 // any print layout view
                m_updatedPrompts.Contains(para.Hvo))                    // user interaction has updated prompt
            {
                return(false);
            }

            // User prompt is only for title & heading paras
            IStText text = (IStText)para.Owner;             // para owner

            if (text.OwningFlid != ScrBookTags.kflidTitle &&
                text.OwningFlid != ScrSectionTags.kflidHeading)
            {
                return(false);
            }

            int paraCount = text.ParagraphsOS.Count;

            Debug.Assert(paraCount != 0,
                         "We shouldn't come here if StText doesn't contain any paragraphs");
            // By design, if there is more than one para, don't display the user prompt.
            if (paraCount != 1)
            {
                return(false);
            }

            // If first para is empty, insert user prompt for paragraph content
            if (text[0].Contents.Text == null)
            {
                vwenv.NoteDependency(new int[] { para.Hvo },
                                     new int[] { StTxtParaTags.kflidContents }, 1);
                vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, text.OwningFlid);
                return(true);
            }

            return(false);
        }
 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();
         }
     }
 }
            private void DisplayLexGloss(IVwEnv vwenv, int hvo, int ws, int choiceIndex)
            {
                int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, ktagSbMorphGloss);

                SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));
                if (m_fIconsForAnalysisChoices)
                {
                    // This line does not have one, but add some white space to line things up.
                    vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
                                          (int)FwTextPropVar.ktpvMilliPoint,
                                          m_dxmpArrowPicWidth + kmpIconMargin);
                }
                if (hvoNo == 0)
                {
                    // One of these is enough, the regeneration will redo an outer object and get
                    // all the alternatives.
                    vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSbMorphGloss }, 1);
                    vwenv.AddProp(ktagMissingMorphGloss, this, kfragMissingMorphGloss);
                }
                else
                {
                    vwenv.AddObjProp(ktagSbMorphGloss, this, kfragNamedObjectNameChoices + choiceIndex);
                }
            }
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();
			switch (frag)
			{
				case kfragRHS:
					m_rhs = new PhSegRuleRHS(m_cache, hvo);
					IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO);

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

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

					int maxNumLines = MaxNumLines;
					int maxCtxtHeight = maxNumLines * spaceHeight;

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

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

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

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

					vwenv.MakeColumns(1, ctxtLen);

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

					vwenv.MakeColumns(1, ctxtLen);

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

					vwenv.MakeColumns(1, ctxtLen);

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

					// LHS cell
					vwenv.Props = m_ctxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					vwenv.AddObjProp(m_cache.GetFlid(hvo, null, "OwningRule"), this, kfragRule);
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

					// RHS cell
					vwenv.Props = m_ctxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_cache.GetVectorSize(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange) > 0)
					{
						vwenv.AddObjVecItems((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragContext);
					}
					else
					{
						OpenContextPile(vwenv, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty);
						CloseContextPile(vwenv, false);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

					// left context cell
					vwenv.Props = m_ctxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext) != 0)
					{
						vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragContext);
					}
					else
					{
						OpenContextPile(vwenv, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty);
						CloseContextPile(vwenv, false);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

					// right context cell
					vwenv.Props = m_ctxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext) != 0)
					{
						vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragContext);
					}
					else
					{
						OpenContextPile(vwenv, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty);
						CloseContextPile(vwenv, false);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

				case kfragRule:
					if (m_cache.GetVectorSize(hvo, (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc) > 0)
					{
						vwenv.AddObjVecItems((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragContext);
					}
					else
					{
						OpenContextPile(vwenv, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty);
						CloseContextPile(vwenv, false);
					}
					break;

				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
Exemple #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check the given translation to see if the text is empty. If so, then insert a
		/// user prompt.
		/// </summary>
		/// <param name="vwenv">view environment</param>
		/// <param name="hvo">id of translation to be displayed</param>
		/// <returns>true if an empty string was substituted for missing/empty StText</returns>
		/// ------------------------------------------------------------------------------------
		protected override bool InsertTranslationUserPrompt(IVwEnv vwenv, int hvo)
		{
			// No user prompt in any of these conditions
			if (hvo == 0
				|| Cache.GetClassOfObject(hvo) != (int)CmTranslation.kClassId
				|| m_updatedPrompts.Contains(hvo)) // user interaction has updated prompt
			{
				return false;
			}

			// If there is text in the translation then do not add a prompt.
			CmTranslation trans = new CmTranslation(Cache, hvo);
			if (trans.Translation.GetAlternative(m_wsDefault).Text != null)
				return false;

			// If there is no text in the parent paragraph then do not place a prompt in the
			// back translation.
			StTxtPara parentPara = new StTxtPara(Cache, trans.OwnerHVO);
			if (parentPara.Contents.Text == null)
				return false;

			// Insert the prompt.
			vwenv.NoteDependency(new int[] { hvo },
				new int[] { (int)CmTranslation.CmTranslationTags.kflidTranslation}, 1);
			vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this,
				(int)CmTranslation.CmTranslationTags.kflidTranslation);
			return true;
		}
Exemple #15
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// Here a text is displayed by displaying its paragraphs;
        /// and a paragraph is displayed by invoking its style rule, making a paragraph,
        /// and displaying its contents.
        /// </summary>
        /// <param name="vwenv">view environment</param>
        /// <param name="hvo">id of object to be displayed</param>
        /// <param name="frag">fragment of data</param>
        /// -----------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case (int)StTextFrags.kfrFootnote:
            {
                if (HandleEmptyText(vwenv, hvo))
                {
                    break;
                }
                IStFootnote footnote = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>().GetObject(hvo);
                if (footnote.DisplayFootnoteMarker)
                {
                    // We need to note this dependency here (for the update of the footnote
                    // marker) instead of in the frag for the marker because noting the
                    // dependency at the frag for the marker caused some weird problems
                    // with the VwNotifiers which caused the view to sometimes update
                    // incorrectly. (FWR-1299) It also makes more sense for it to be here
                    // since the dependency would be on the whole footnote in either case
                    // anyways.
                    vwenv.NoteDependency(new int[] { footnote.Owner.Hvo }, new int[] { footnote.OwningFlid }, 1);
                }
                vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
                                     (int)StTextFrags.kfrFootnotePara);
                break;
            }

            case (int)StTextFrags.kfrText:
            {
                if (HandleEmptyText(vwenv, hvo))
                {
                    break;
                }
                if (hvo == 0)
                {
                    return;                             // leave view empty, better than crashing.
                }
                if (m_fLazy)
                {
                    vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this,
                                          (int)StTextFrags.kfrPara);
                }
                else
                {
                    vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
                                         (int)StTextFrags.kfrPara);
                }
                break;
            }

            case (int)StTextFrags.kfrFootnoteMarker:
            {
                IStFootnote footnote = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>().GetObject(hvo);
                if (footnote.DisplayFootnoteMarker)
                {
                    DisplayFootnoteMarker(vwenv, footnote);
                }
                break;
            }

            case (int)StTextFrags.kfrLabel:
            {
                // The label is not editable.
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)TptEditable.ktptNotEditable);
                vwenv.AddString(m_tssLabel);
                break;
            }

            case (int)StTextFrags.kfrPara:
            case (int)StTextFrags.kfrFootnotePara:
            {
                InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
                break;
            }

            case (int)StTextFrags.kfrTranslation:
            {
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                      Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
                // Display the translation, or its user prompt
                ICmTranslation trans = Cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo);
                if (!InsertTranslationUserPrompt(vwenv, trans))
                {
                    vwenv.AddStringAltMember(CmTranslationTags.kflidTranslation, m_wsDefault, this);
                }
                break;
            }

            case (int)StTextFrags.kfrSegmentFreeTranslations:
                // Hvo is one segment of an StTxtPara.
                ISegment seg = Cache.ServiceLocator.GetInstance <ISegmentRepository>().GetObject(hvo);
                if (seg.IsLabel)
                {
                    // Added dependencies to get labels to update automatically (FWR-1341, FWR-1342, FWR-1417)
                    vwenv.NoteStringValDependency(seg.Paragraph.Hvo, StTxtParaTags.kflidContents, 0, seg.Paragraph.Contents);
                    vwenv.NoteDependency(new [] { seg.Paragraph.Hvo }, new [] { StTxtParaTags.kflidSegments }, 1);
                    vwenv.AddString(GetBackTransLabelText(seg));
                    vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 1200, 0, 0);                             // a narrow space, font-neutral
                }
                else
                {
                    // Hvo is a segment whose Contents are the free/back translation.
                    vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault,
                                          (int)ColorUtil.ConvertColorToBGR(SystemColors.Window));
                    ITsString tssVal = seg.FreeTranslation.get_String(BackTranslationWS);
                    if (tssVal.Length == 0 && !SuppressPrompt(hvo, SegmentTags.kflidFreeTranslation))
                    {
                        vwenv.NoteDependency(new[] { hvo }, new[] { SegmentTags.kflidFreeTranslation }, 1);
                        vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, SegmentTags.kflidFreeTranslation);
                        // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing
                        // into the margin.
                        vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0);
                    }
                    else
                    {
                        ITsStrBldr bldr = tssVal.GetBldr();
                        bldr.Replace(0, bldr.Length, "", null);                                 // reduce to empty string in ws.
                        // We want it to change back to the prompt if all is deleted.
                        vwenv.NoteStringValDependency(hvo, SegmentTags.kflidFreeTranslation, BackTranslationWS, bldr.GetString());
                        vwenv.AddStringAltMember(SegmentTags.kflidFreeTranslation, BackTranslationWS, this);
                        // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty,
                        // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run.
                        vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 100, 0, 0);
                    }
                    vwenv.AddString(OneSpaceString);
                }
                break;
            }
        }
Exemple #16
0
		protected void CloseSingleLinePile(IVwEnv vwenv, bool addBoundary)
		{
			if (addBoundary)
			{
				vwenv.Props = m_bracketProps;
				vwenv.AddProp(ktagRightBoundary, this, kfragZeroWidthSpace);
			}
			vwenv.CloseParagraph();
			vwenv.CloseInnerPile();
		}
Exemple #17
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case kfragContext:
                IPhContextOrVar ctxtOrVar       = PhContextOrVar.CreateFromDBObject(m_cache, hvo);
                bool            isOuterIterCtxt = false;
                // are we inside an iteration context? this is important since we only open a context pile if we are not
                // in an iteration context, since an iteration context does it for us
                if (vwenv.EmbeddingLevel > 0)
                {
                    int outerHvo, outerTag, outerIndex;
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex);
                    isOuterIterCtxt = m_cache.GetClassOfObject(outerHvo) == PhIterationContext.kclsidPhIterationContext;
                }

                switch (ctxtOrVar.ClassID)
                {
                case PhSequenceContext.kclsidPhSequenceContext:
                    if (m_cache.GetVectorSize(hvo, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) > 0)
                    {
                        vwenv.AddObjVecItems((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragContext);
                    }
                    else
                    {
                        OpenContextPile(vwenv, false);
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragEmpty);
                        CloseContextPile(vwenv, false);
                    }
                    break;

                case PhSimpleContextNC.kclsidPhSimpleContextNC:
                    IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC;
                    if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
                    {
                        // Natural class simple context with a feature-based natural class
                        IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;

                        int numLines = GetNumLines(ncCtxt);
                        if (numLines == 0)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else if (numLines == 1)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            // use normal brackets for a single line context
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

                            // special consonant and vowel natural classes only display the abbreviation
                            if (natClass.Abbreviation.AnalysisDefaultWritingSystem == "C" ||
                                natClass.Abbreviation.AnalysisDefaultWritingSystem == "V")
                            {
                                vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                            }
                            else
                            {
                                if (natClass.FeaturesOAHvo != 0 && natClass.FeaturesOA.FeatureSpecsOC.Count > 0)
                                {
                                    vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                                }
                                else if (ncCtxt.PlusConstrRS.Count > 0)
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                                }
                                else
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                                }
                            }
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else
                        {
                            // multiline context

                            // left bracket pile
                            int maxNumLines = MaxNumLines;
                            vwenv.Props = m_bracketProps;
                            vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                            }
                            vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                            vwenv.CloseInnerPile();

                            // feature and variable pile
                            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, vwenv);
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                            vwenv.CloseInnerPile();

                            // right bracket pile
                            vwenv.Props = m_bracketProps;
                            if (!isOuterIterCtxt)
                            {
                                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            }
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv);
                            vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
                            }
                            vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
                            vwenv.CloseInnerPile();
                        }
                    }
                    else
                    {
                        // natural class context with segment-based natural class
                        if (!isOuterIterCtxt)
                        {
                            OpenContextPile(vwenv);
                        }

                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                        if (ncCtxt.FeatureStructureRAHvo != 0)
                        {
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                        }
                        else
                        {
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                        }
                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                        if (!isOuterIterCtxt)
                        {
                            CloseContextPile(vwenv);
                        }
                    }
                    break;

                case PhIterationContext.kclsidPhIterationContext:
                    IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
                    if (iterCtxt.MemberRAHvo != 0)
                    {
                        int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext);
                        if (numLines > 1)
                        {
                            vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            DisplayIterCtxt(iterCtxt, numLines, vwenv);
                        }
                        else
                        {
                            OpenContextPile(vwenv);
                            if (iterCtxt.MemberRA.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC)
                            {
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            }
                            else
                            {
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen);
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen);
                            }
                            DisplayIterCtxt(iterCtxt, 1, vwenv);
                            // Views doesn't handle selection properly when we have an inner pile with strings on either side,
                            // so we don't add a zero-width space at the end
                            CloseContextPile(vwenv, false);
                        }
                    }
                    else
                    {
                        OpenContextPile(vwenv);
                        vwenv.AddProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragQuestions);
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextSeg.kclsidPhSimpleContextSeg:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextBdry.kclsidPhSimpleContextBdry:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhVariable.kclsidPhVariable:
                    OpenContextPile(vwenv);
                    vwenv.AddProp(ktagXVariable, this, kfragXVariable);
                    CloseContextPile(vwenv);
                    break;
                }
                break;

            case kfragNC:
                int ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation);
                if (ncWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, ncWs, this);
                }
                else
                {
                    ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidName);
                    if (ncWs != 0)
                    {
                        vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidName, ncWs, this);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions);
                    }
                }
                break;

            case kfragTerminalUnit:
                int tuWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstVern, hvo, (int)PhTerminalUnit.PhTerminalUnitTags.kflidName);
                if (tuWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, tuWs, this);
                }
                else
                {
                    vwenv.AddProp((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, this, kfragQuestions);
                }
                break;

            case kfragFeatNC:
                vwenv.AddObjProp((int)PhNCFeatures.PhNCFeaturesTags.kflidFeatures, this, kfragFeats);
                break;

            case kfragFeats:
                vwenv.AddObjVecItems((int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature);
                break;

            case kfragFeature:
                vwenv.AddProp(ktagFeature, this, kfragFeatureLine);
                break;

            case kfragPlusVariable:
                vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine);
                break;

            case kfragMinusVariable:
                vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
                break;
            }
        }
			private void DisplayLexGloss(IVwEnv vwenv, int hvo, int ws, int choiceIndex)
			{
				int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, ktagSbMorphGloss);
				SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));
				if (m_fIconsForAnalysisChoices)
				{
					// This line does not have one, but add some white space to line things up.
					vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
						(int)FwTextPropVar.ktpvMilliPoint,
						m_dxmpArrowPicWidth + kmpIconMargin);
				}
				if (hvoNo == 0)
				{
					// One of these is enough, the regeneration will redo an outer object and get
					// all the alternatives.
					vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSbMorphGloss }, 1);
					vwenv.AddProp(ktagMissingMorphGloss, this, kfragMissingMorphGloss);
				}
				else
				{
					vwenv.AddObjProp(ktagSbMorphGloss, this, kfragNamedObjectNameChoices + choiceIndex);
				}
			}
Exemple #19
0
		protected void AddExtraLines(int numLines, int tag, IVwEnv vwenv)
		{
			for (int i = 0; i < numLines; i++)
			{
				vwenv.Props = m_bracketProps;
				vwenv.set_IntProperty((int) FwTextPropType.ktptEditable, (int) FwTextPropVar.ktpvEnum, (int) TptEditable.ktptNotEditable);
				vwenv.OpenParagraph();
				vwenv.AddProp(tag, this, kfragEmpty);
				vwenv.CloseParagraph();
			}
		}
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case kfragPattern:
					VwLength tableLen;
					tableLen.nVal = 10000;
					tableLen.unit = VwUnit.kunPercent100;
					vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false);
					VwLength patternLen;
					patternLen.nVal = 1;
					patternLen.unit = VwUnit.kunRelative;
					vwenv.MakeColumns(1, patternLen);
					vwenv.OpenTableBody();
					vwenv.OpenTableRow();

					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray));
					vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
					vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (((ComplexConcPatternSda) vwenv.DataAccess).Root.IsLeaf)
					{
						OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty);
						CloseSingleLinePile(vwenv, false);
					}
					else
					{
						vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

				case kfragNode:
					ComplexConcPatternNode node = ((ComplexConcPatternSda) vwenv.DataAccess).Nodes[hvo];
					int maxNumLines = GetMaxNumLines(vwenv);
					if (node is ComplexConcOrNode)
					{
						OpenSingleLinePile(vwenv, maxNumLines);
						vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR);
						CloseSingleLinePile(vwenv, false);
					}
					else if (node is ComplexConcWordBdryNode)
					{
						OpenSingleLinePile(vwenv, maxNumLines);
						vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash);
						CloseSingleLinePile(vwenv);
					}
					else if (node is ComplexConcGroupNode)
					{
						int numLines = GetNumLines(node);
						bool hasMinMax = node.Maximum != 1 || node.Minimum != 1;
						if (numLines == 1)
						{
							OpenSingleLinePile(vwenv, maxNumLines, false);
							// use normal parentheses for a single line group
							vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen);

							vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);

							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen);
							if (hasMinMax)
								DisplayMinMax(numLines, vwenv);
							CloseSingleLinePile(vwenv, false);
						}
						else
						{
							vwenv.Props = m_bracketProps;
							vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
							vwenv.OpenInnerPile();
							AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
							vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook);
							for (int i = 1; i < numLines - 1; i++)
								vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt);
							vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook);
							vwenv.CloseInnerPile();

							vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);

							vwenv.Props = m_bracketProps;
							vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
							vwenv.OpenInnerPile();
							AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv);
							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook);
							for (int i = 1; i < numLines - 1; i++)
								vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt);
							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook);
							vwenv.CloseInnerPile();
							if (hasMinMax)
								DisplayMinMax(numLines, vwenv);
						}
					}
					else
					{
						bool hasMinMax = node.Maximum != 1 || node.Minimum != 1;
						int numLines = GetNumLines(node);
						if (numLines == 1)
						{
							OpenSingleLinePile(vwenv, maxNumLines, false);
							// use normal brackets for a single line constraint
							vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket);

							DisplayFeatures(vwenv, node);

							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket);
							if (hasMinMax)
								DisplayMinMax(numLines, vwenv);
							CloseSingleLinePile(vwenv, false);
						}
						else
						{
							// left bracket pile
							vwenv.Props = m_bracketProps;
							vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
							vwenv.OpenInnerPile();
							AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
							vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
							for (int i = 1; i < numLines - 1; i++)
								vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
							vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
							vwenv.CloseInnerPile();

							// feature pile
							vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalLeft);
							vwenv.OpenInnerPile();
							AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv);
							DisplayFeatures(vwenv, node);
							vwenv.CloseInnerPile();

							// right bracket pile
							vwenv.Props = m_bracketProps;
							vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
							vwenv.OpenInnerPile();
							AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv);
							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook);
							for (int i = 1; i < numLines - 1; i++)
								vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt);
							vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook);
							vwenv.CloseInnerPile();
							if (hasMinMax)
								DisplayMinMax(numLines, vwenv);
						}
					}
					break;
			}
		}
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();
            switch (frag)
            {
            case kfragRHS:
                m_rhs = new PhSegRuleRHS(m_cache, hvo);
                IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO);

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

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

                int maxNumLines   = MaxNumLines;
                int maxCtxtHeight = maxNumLines * spaceHeight;

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

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

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

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

                vwenv.MakeColumns(1, ctxtLen);

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

                vwenv.MakeColumns(1, ctxtLen);

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

                vwenv.MakeColumns(1, ctxtLen);

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

                // LHS cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                vwenv.AddObjProp(m_cache.GetFlid(hvo, null, "OwningRule"), this, kfragRule);
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

                // RHS cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_cache.GetVectorSize(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange) > 0)
                {
                    vwenv.AddObjVecItems((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragContext);
                }
                else
                {
                    OpenContextPile(vwenv, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty);
                    CloseContextPile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

                // left context cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext) != 0)
                {
                    vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragContext);
                }
                else
                {
                    OpenContextPile(vwenv, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty);
                    CloseContextPile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

                // right context cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext) != 0)
                {
                    vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragContext);
                }
                else
                {
                    OpenContextPile(vwenv, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty);
                    CloseContextPile(vwenv, false);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

            case kfragRule:
                if (m_cache.GetVectorSize(hvo, (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc) > 0)
                {
                    vwenv.AddObjVecItems((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragContext);
                }
                else
                {
                    OpenContextPile(vwenv, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty);
                    CloseContextPile(vwenv, false);
                }
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
		private void DisplayInflFeatureLines(IVwEnv vwenv, IDictionary<IFsFeatDefn, object> inflFeatures, bool openPara)
		{
			IDictionary<IFsFeatDefn, object> lastInflFeatures = m_curInflFeatures;
			m_curInflFeatures = inflFeatures;
			foreach (KeyValuePair<IFsFeatDefn, object> kvp in inflFeatures)
			{
				if (kvp.Key is IFsComplexFeature)
				{
					if (openPara)
						vwenv.OpenParagraph();
					vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine);
					DisplayInflFeatures(vwenv, (IDictionary<IFsFeatDefn, object>) kvp.Value);
					if (openPara)
						vwenv.CloseParagraph();
				}
				else
				{
					vwenv.AddProp(kvp.Key.Hvo, this, kfragFeatureLine);
				}
			}
			m_curInflFeatures = lastInflFeatures;
		}
		private void DisplayInflFeatures(IVwEnv vwenv, IDictionary<IFsFeatDefn, object> inflFeatures)
		{
			int numLines = GetNumLines(inflFeatures);
			if (numLines == 1)
			{
				// use normal brackets for a single line constraint
				vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

				DisplayInflFeatureLines(vwenv, inflFeatures, false);

				vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);
			}
			else
			{
				// left bracket pile
				vwenv.Props = m_bracketProps;
				vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
				vwenv.OpenInnerPile();
				vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
				for (int i = 1; i < numLines - 1; i++)
					vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
				vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
				vwenv.CloseInnerPile();

				// feature pile
				vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalLeft);
				vwenv.OpenInnerPile();
				DisplayInflFeatureLines(vwenv, inflFeatures, true);
				vwenv.CloseInnerPile();

				// right bracket pile
				vwenv.Props = m_bracketProps;
				vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin);
				vwenv.OpenInnerPile();
				vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketUpHook);
				for (int i = 1; i < numLines - 1; i++)
					vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketExt);
				vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracketLowHook);
				vwenv.CloseInnerPile();
			}
		}
		private void DisplayFeatures(IVwEnv vwenv, ComplexConcPatternNode node)
		{
			vwenv.AddProp(ktagType, this, kfragFeatureLine);
			var morphNode = node as ComplexConcMorphNode;
			if (morphNode != null)
			{
				if (morphNode.Form != null)
					vwenv.AddProp(ktagForm, this, kfragFeatureLine);
				if (morphNode.Entry != null)
					vwenv.AddProp(ktagEntry, this, kfragFeatureLine);
				if (morphNode.Category != null)
					vwenv.AddProp(ktagCategory, this, kfragFeatureLine);
				if (morphNode.Gloss != null)
					vwenv.AddProp(ktagGloss, this, kfragFeatureLine);
				if (morphNode.InflFeatures.Count > 0)
				{
					vwenv.OpenParagraph();
					vwenv.AddProp(ktagInfl, this, kfragFeatureLine);
					DisplayInflFeatures(vwenv, morphNode.InflFeatures);
					vwenv.CloseParagraph();
				}
			}
			else
			{
				var wordNode = node as ComplexConcWordNode;
				if (wordNode != null)
				{
					if (wordNode.Form != null)
						vwenv.AddProp(ktagForm, this, kfragFeatureLine);
					if (wordNode.Category != null)
						vwenv.AddProp(ktagCategory, this, kfragFeatureLine);
					if (wordNode.Gloss != null)
						vwenv.AddProp(ktagGloss, this, kfragFeatureLine);
					if (wordNode.InflFeatures.Count > 0)
					{
						vwenv.OpenParagraph();
						vwenv.AddProp(ktagInfl, this, kfragFeatureLine);
						DisplayInflFeatures(vwenv, wordNode.InflFeatures);
						vwenv.CloseParagraph();
					}
				}
				else
				{
					var tagNode = node as ComplexConcTagNode;
					if (tagNode != null)
					{
						if (tagNode.Tag != null)
							vwenv.AddProp(ktagTag, this, kfragFeatureLine);
					}
				}
			}
		}
			/// <summary>
			/// Add to the vwenv a display of property tag of object hvo, which stores an
			/// SbNamedObj.  If the property is non-null, display the name of the SbNamedObj.
			/// If not, display the dummyTag 'property' using the dummyFrag.
			/// </summary>
			/// <param name="vwenv"></param>
			/// <param name="hvo"></param>
			/// <param name="tag"></param>
			/// <param name="dummyTag"></param>
			/// <param name="dummyFrag"></param>
			/// <param name="tagIcon">If non-zero, display a pull-down icon before the item, marked with this tag.</param>
			/// <param name="ws">which alternative of the name to display</param>
			/// <param name="choiceIndex">which item in m_choices this comes from. The icon is displayed
			/// only if it is the first one for its flid.</param>
			protected void AddOptionalNamedObj(IVwEnv vwenv, int hvo, int tag, int dummyTag,
				int dummyFrag, int tagIcon, int ws, int choiceIndex)
			{
				int hvoNo = vwenv.DataAccess.get_ObjectProp(hvo, tag);
				SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));
				bool fWantIcon = false;
				fWantIcon = tagIcon != 0 && m_choices.IsFirstOccurrenceOfFlid(choiceIndex);
				if (m_fIconsForAnalysisChoices && !fWantIcon)
				{
					// This line does not have one, but add some white space to line things up.
					vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
						(int)FwTextPropVar.ktpvMilliPoint,
						m_dxmpArrowPicWidth + kmpIconMargin);
				}
				vwenv.OpenParagraph();
				if (fWantIcon)
					AddPullDownIcon(vwenv, tagIcon);
				// The NoteDependency is needed whether or not hvoNo is set, in case we update
				// to a sense which has a null MSA.  See LT-4246.
				vwenv.NoteDependency(new int[] { hvo }, new int[] { tag }, 1);
				if (hvoNo == 0)
					vwenv.AddProp(dummyTag, this, dummyFrag);
				else
					vwenv.AddObjProp(tag, this, kfragNamedObjectNameChoices + choiceIndex);
				vwenv.CloseParagraph();
			}
			private void 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 #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check the given translation to see if the text is empty. If so, then insert a
		/// user prompt.
		/// </summary>
		/// <param name="vwenv">view environment</param>
		/// <param name="trans">translation to be displayed</param>
		/// <returns>true if an empty string was substituted for missing/empty StText</returns>
		/// ------------------------------------------------------------------------------------
		protected override bool InsertTranslationUserPrompt(IVwEnv vwenv, ICmTranslation trans)
		{
			// No user prompt in any of these conditions
			if (trans == null || m_updatedPrompts.Contains(trans.Hvo)) // user interaction has updated prompt
				return false;

			// If there is text in the translation then do not add a prompt.
			if (trans.Translation.get_String(m_wsDefault).Length > 0)
				return false;

			// If there is no text in the parent paragraph then do not place a prompt in the
			// back translation.
			if (((IStTxtPara)trans.Owner).Contents.Length == 0)
				return false;

			// Insert the prompt.
			vwenv.NoteDependency(new int[] { trans.Hvo },
				new int[] { CmTranslationTags.kflidTranslation}, 1);
			vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmTranslationTags.kflidTranslation);
			return true;
		}
Exemple #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays an annotation expanded or contracted
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="ann"></param>
		/// <param name="expanded"></param>
		/// ------------------------------------------------------------------------------------
		private void DisplayAnnotation(IVwEnv vwenv, IScrScriptureNote ann, bool expanded)
		{
			#region First row has status, ref, category, & quote
			SetBackgroundColorForNote(ann, vwenv);

			OpenTableRow(vwenv, ann);

			// Display expand box (+/-) in the first cell
			//InsertNoteSeparator(vwenv);
			vwenv.OpenTableCell(1, 1);
			vwenv.AddObj(ann.Hvo, this, (int)NotesFrags.kfrExpansion);
			vwenv.CloseTableCell();

			// Display status in the second cell
			vwenv.OpenTableCell(1, 1);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop,
				(int)FwTextPropVar.ktpvMilliPoint, 1000);

			if (ann.AnnotationType == NoteType.CheckingError)
			{
				// When the annotation is a checking error, we don't want clicking on the status
				// to change the status. Therefore, make the min and max the same.
				vwenv.AddIntPropPic((int)ScrScriptureNoteTags.kflidResolutionStatus,
					this, (int)NotesFrags.kfrStatus, 0, 0);
			}
			else
			{
				vwenv.AddIntPropPic((int)ScrScriptureNoteTags.kflidResolutionStatus,
					this, (int)NotesFrags.kfrStatus, (int)NoteStatus.Open, (int)NoteStatus.Closed);
			}
			vwenv.CloseTableCell();

			// Display reference in the third cell and make it readonly.
			vwenv.OpenTableCell(1, 1);
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, 0);
			vwenv.OpenParagraph();
			vwenv.AddProp((int)CmBaseAnnotationTags.kflidBeginRef, this, (int)NotesFrags.kfrScrRef);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			// Display CONNOT category in the fourth (and possibly fifth and sixth) cell(s)
			vwenv.OpenTableCell(1, expanded ? 3 : 1);
			IStTxtPara quotePara = ann.QuoteOA[0];
			bool fQuoteParaRtoL = IsParaRightToLeft(quotePara);

			// Conc paragraphs don't work well for R-to-L: If the text doesn't fit, it will
			// show the trailing text rather than the leading text.
			if (fQuoteParaRtoL || expanded)
				vwenv.OpenParagraph();
			else
				vwenv.OpenConcPara(0, 0, 0, 0);
			vwenv.AddObjVec((int)ScrScriptureNoteTags.kflidCategories, this,
				(int)NotesFrags.kfrConnotCategory);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			// Display CONNOT category chooser button in the penultimate or last cell
			vwenv.OpenTableCell(1, 1);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop,
				(int)FwTextPropVar.ktpvMilliPoint, 1000);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
				(int)FwTextPropVar.ktpvMilliPoint, 2000);

			vwenv.AddPicture(m_picChooser, -(int)NotesFrags.kfrConnotCategory, 0, 0);
			vwenv.CloseTableCell();

			// If not expanded, display the quote in the last cell
			if (!expanded)
			{
				vwenv.OpenTableCell(1, 1);
				SetupWsAndDirectionForPara(vwenv, quotePara.Hvo);
				if (fQuoteParaRtoL)
					vwenv.OpenParagraph(); // Conc paragraphs don't work well for R-to-L
				else
					vwenv.OpenConcPara(0, 0, 0, 0);
				vwenv.AddString(quotePara.Contents);
				vwenv.CloseParagraph();
				vwenv.CloseTableCell();
			}

			CloseTableRow(vwenv, ann);
			#endregion

			if (!expanded)
				return;

			#region Second through fifth rows
			bool fRegularAnnotation = ann.AnnotationType != NoteType.CheckingError;
			//Second row has quote
			DisplayExpandableAnnotation(vwenv, ann,
				(int)ScrScriptureNoteTags.kflidQuote,
				ann.QuoteOA.Hvo, ann.QuoteOA,
				fRegularAnnotation ? m_quoteLabel : m_detailsLabel, !fRegularAnnotation);

			// Third row has discussion
			DisplayExpandableAnnotation(vwenv, ann,
				ScrScriptureNoteTags.kflidDiscussion,
				ann.DiscussionOA.Hvo, ann.DiscussionOA,
				fRegularAnnotation ? m_discussionLabel : m_messageLabel, !fRegularAnnotation);

			// Fourth row has recommendation (i.e. suggestion)
			DisplayExpandableAnnotation(vwenv, ann,
				ScrScriptureNoteTags.kflidRecommendation,
				ann.RecommendationOA.Hvo, ann.RecommendationOA, m_suggestionLabel);

			// Fifth row has resolution
			DisplayExpandableAnnotation(vwenv, ann,
				ScrScriptureNoteTags.kflidResolution,
				ann.ResolutionOA.Hvo, ann.ResolutionOA, m_resolutionLabel);

			#endregion

			#region Sixth row has author
			SetBackgroundColorForNote(ann, vwenv);
			OpenTableRow(vwenv, ann);

			// Display empty first and second cell
			vwenv.OpenTableCell(1, 2);
			vwenv.CloseTableCell();

			// Display author in third cell
			vwenv.OpenTableCell(1, 3);
			vwenv.OpenParagraph();
			SetDisabledColorForNote(vwenv);
			vwenv.AddString(m_authorLabel);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			CloseTableRow(vwenv, ann);
			#endregion

			#region Seventh row has dates
			SetBackgroundColorForNote(ann, vwenv);
			OpenTableRow(vwenv, ann);

			// Display empty first and second cell
			vwenv.OpenTableCell(1, 2);
			vwenv.CloseTableCell();

			// Display date created in third cell
			vwenv.OpenTableCell(1, 1);
			vwenv.OpenParagraph();
			vwenv.AddString(m_createdLabel);
			vwenv.AddTimeProp(CmAnnotationTags.kflidDateCreated, 0);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			// Display date modified in fourth/fifth cells
			vwenv.OpenTableCell(1, 2);
			vwenv.OpenParagraph();
			vwenv.AddString(m_modifiedLabel);
			vwenv.AddTimeProp(CmAnnotationTags.kflidDateModified, 0);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			// Display date resolved in last two cells
			vwenv.OpenTableCell(1, 2);
			vwenv.OpenParagraph();
			if (ann.ResolutionStatus == NoteStatus.Closed)
			{
				SetDisabledColorForNote(vwenv);
				vwenv.AddString(m_resolvedLabel);
				// TODO (TE-4039) This date is incorrect
				//vwenv.AddTimeProp(ScrScriptureNote.ScrScriptureNoteTags.kflidDateResolved, 0);
			}
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();

			CloseTableRow(vwenv, ann);
			#endregion
		}
        private void DisplayFeatures(IVwEnv vwenv, ComplexConcPatternNode node)
        {
            vwenv.AddProp(ktagType, this, kfragFeatureLine);
            var morphNode = node as ComplexConcMorphNode;

            if (morphNode != null)
            {
                if (morphNode.Form != null)
                {
                    vwenv.AddProp(ktagForm, this, kfragFeatureLine);
                }
                if (morphNode.Entry != null)
                {
                    vwenv.AddProp(ktagEntry, this, kfragFeatureLine);
                }
                if (morphNode.Category != null)
                {
                    vwenv.AddProp(ktagCategory, this, kfragFeatureLine);
                }
                if (morphNode.Gloss != null)
                {
                    vwenv.AddProp(ktagGloss, this, kfragFeatureLine);
                }
                if (morphNode.InflFeatures.Count > 0)
                {
                    vwenv.OpenParagraph();
                    vwenv.AddProp(ktagInfl, this, kfragFeatureLine);
                    DisplayInflFeatures(vwenv, morphNode.InflFeatures);
                    vwenv.CloseParagraph();
                }
            }
            else
            {
                var wordNode = node as ComplexConcWordNode;
                if (wordNode != null)
                {
                    if (wordNode.Form != null)
                    {
                        vwenv.AddProp(ktagForm, this, kfragFeatureLine);
                    }
                    if (wordNode.Category != null)
                    {
                        vwenv.AddProp(ktagCategory, this, kfragFeatureLine);
                    }
                    if (wordNode.Gloss != null)
                    {
                        vwenv.AddProp(ktagGloss, this, kfragFeatureLine);
                    }
                    if (wordNode.InflFeatures.Count > 0)
                    {
                        vwenv.OpenParagraph();
                        vwenv.AddProp(ktagInfl, this, kfragFeatureLine);
                        DisplayInflFeatures(vwenv, wordNode.InflFeatures);
                        vwenv.CloseParagraph();
                    }
                }
                else
                {
                    var tagNode = node as ComplexConcTagNode;
                    if (tagNode != null)
                    {
                        if (tagNode.Tag != null)
                        {
                            vwenv.AddProp(ktagTag, this, kfragFeatureLine);
                        }
                    }
                }
            }
        }
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case kfragRule:
					m_rule = m_cache.ServiceLocator.GetInstance<IPhMetathesisRuleRepository>().GetObject(hvo);
					if (m_rule.Disabled)
					{
						vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text");
					}

					int maxNumLines = GetMaxNumLines();

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

					VwLength ctxtLen;
					ctxtLen.nVal = 1;
					ctxtLen.unit = VwUnit.kunRelative;

					int resultx, inputx, dmpy;
					vwenv.get_StringWidth(m_resultStr, m_colHeaderProps, out resultx, out dmpy);
					vwenv.get_StringWidth(m_inputStr, m_colHeaderProps, out inputx, out dmpy);
					VwLength headerLen;
					headerLen.nVal = Math.Max(resultx, inputx) + 8000;
					headerLen.unit = VwUnit.kunPoint1000;

					vwenv.MakeColumns(1, headerLen);
					vwenv.MakeColumns(4, ctxtLen);

					vwenv.OpenTableBody();

					vwenv.OpenTableRow();

					vwenv.OpenTableCell(1, 1);
					vwenv.CloseTableCell();

					// left context header cell
					vwenv.Props = m_colHeaderProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_leftEnvStr);
					vwenv.CloseTableCell();

					// switch header cell
					vwenv.Props = m_colHeaderProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.OpenTableCell(1, 2);
					vwenv.AddString(m_switchStr);
					vwenv.CloseTableCell();

					// right context header cell
					vwenv.Props = m_colHeaderProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_rightEnvStr);
					vwenv.CloseTableCell();

					vwenv.CloseTableRow();

					vwenv.OpenTableRow();

					// input header cell
					vwenv.Props = m_rowHeaderProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_inputStr);
					vwenv.CloseTableCell();

					// input left context cell
					vwenv.Props = m_inputCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.LeftEnvIndex == -1)
					{
						OpenSingleLinePile(vwenv, maxNumLines, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp(ktagLeftEnv, this, kfragEmpty);
						CloseSingleLinePile(vwenv, false);
					}
					else
					{
						for (int i = 0; i < m_rule.LeftEnvLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// input left switch cell
					vwenv.Props = m_inputCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.LeftSwitchIndex == -1)
					{
						OpenSingleLinePile(vwenv, maxNumLines, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp(ktagLeftSwitch, this, kfragEmpty);
						CloseSingleLinePile(vwenv, false);
					}
					else
					{
						for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);

						if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch)
						{
							for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
								vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
						}
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// input right switch cell
					vwenv.Props = m_inputCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.RightSwitchIndex == -1)
					{
						OpenSingleLinePile(vwenv, maxNumLines, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp(ktagRightSwitch, this, kfragEmpty);
						CloseSingleLinePile(vwenv, false);
					}
					else
					{
						if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch)
						{
							for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
								vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
						}

						for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// input right context cell
					vwenv.Props = m_inputCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.RightEnvIndex == -1)
					{
						OpenSingleLinePile(vwenv, maxNumLines, false);
						vwenv.Props = m_bracketProps;
						vwenv.AddProp(ktagRightEnv, this, kfragEmpty);
						CloseSingleLinePile(vwenv, false);
					}
					else
					{
						for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					vwenv.CloseTableRow();

					vwenv.OpenTableRow();

					// input result header cell
					vwenv.Props = m_rowHeaderProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_resultStr);
					vwenv.CloseTableCell();

					// result left context cell
					vwenv.Props = m_resultCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.LeftEnvIndex != -1)
					{
						for (int i = 0; i < m_rule.LeftEnvLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// result right switch cell
					vwenv.Props = m_resultCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.RightSwitchIndex != -1)
					{
						for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch)
					{
						for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// result left switch cell
					vwenv.Props = m_resultCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();

					if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch)
					{
						for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					if (m_rule.LeftSwitchIndex != -1)
					{
						for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// result right context cell
					vwenv.Props = m_resultCtxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.RightEnvIndex != -1)
					{
						for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++)
							vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
					}
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					vwenv.CloseTableRow();

					vwenv.CloseTableBody();

					vwenv.CloseTable();
					break;

				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
Exemple #31
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragContext:
                var  ctxtOrVar       = m_cache.ServiceLocator.GetInstance <IPhContextOrVarRepository>().GetObject(hvo);
                bool isOuterIterCtxt = false;
                // are we inside an iteration context? this is important since we only open a context pile if we are not
                // in an iteration context, since an iteration context does it for us
                if (vwenv.EmbeddingLevel > 0)
                {
                    int outerHvo, outerTag, outerIndex;
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex);
                    var outerObj = m_cache.ServiceLocator.GetObject(outerHvo);
                    isOuterIterCtxt = outerObj.ClassID == PhIterationContextTags.kClassId;
                }

                switch (ctxtOrVar.ClassID)
                {
                case PhSequenceContextTags.kClassId:
                    var seqCtxt = (IPhSequenceContext)ctxtOrVar;
                    if (seqCtxt.MembersRS.Count > 0)
                    {
                        vwenv.AddObjVecItems(PhSequenceContextTags.kflidMembers, this, kfragContext);
                    }
                    else
                    {
                        OpenSingleLinePile(vwenv, GetMaxNumLines(), false);
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp(PhSequenceContextTags.kflidMembers, this, kfragEmpty);
                        CloseSingleLinePile(vwenv, false);
                    }
                    break;

                case PhSimpleContextNCTags.kClassId:
                    var ncCtxt = (IPhSimpleContextNC)ctxtOrVar;
                    if (ncCtxt.FeatureStructureRA != null && ncCtxt.FeatureStructureRA.ClassID == PhNCFeaturesTags.kClassId)
                    {
                        // Natural class simple context with a feature-based natural class
                        var natClass = (IPhNCFeatures)ncCtxt.FeatureStructureRA;

                        int numLines = GetNumLines(ncCtxt);
                        if (numLines == 0)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenSingleLinePile(vwenv, GetMaxNumLines());
                            }

                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                            vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseSingleLinePile(vwenv);
                            }
                        }
                        else if (numLines == 1)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenSingleLinePile(vwenv, GetMaxNumLines());
                            }

                            // use normal brackets for a single line context
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

                            // special consonant and vowel natural classes only display the abbreviation
                            if (natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "C" ||
                                natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "V")
                            {
                                vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                            }
                            else
                            {
                                if (natClass.FeaturesOA != null && natClass.FeaturesOA.FeatureSpecsOC.Count > 0)
                                {
                                    vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                                }
                                else if (ncCtxt.PlusConstrRS.Count > 0)
                                {
                                    vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                                }
                                else
                                {
                                    vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                                }
                            }
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseSingleLinePile(vwenv);
                            }
                        }
                        else
                        {
                            // multiline context

                            // left bracket pile
                            int maxNumLines = GetMaxNumLines();
                            vwenv.Props = m_bracketProps;
                            vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                            }
                            vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                            vwenv.CloseInnerPile();

                            // feature and variable pile
                            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, vwenv);
                            vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                            vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                            vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                            vwenv.CloseInnerPile();

                            // right bracket pile
                            vwenv.Props = m_bracketProps;
                            if (!isOuterIterCtxt)
                            {
                                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                            }
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv);
                            vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
                            }
                            vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
                            vwenv.CloseInnerPile();
                        }
                    }
                    else
                    {
                        // natural class context with segment-based natural class
                        if (!isOuterIterCtxt)
                        {
                            OpenSingleLinePile(vwenv, GetMaxNumLines());
                        }

                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                        if (ncCtxt.FeatureStructureRA != null)
                        {
                            vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                        }
                        else
                        {
                            vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                        }
                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                        if (!isOuterIterCtxt)
                        {
                            CloseSingleLinePile(vwenv);
                        }
                    }
                    break;

                case PhIterationContextTags.kClassId:
                    var iterCtxt = (IPhIterationContext)ctxtOrVar;
                    if (iterCtxt.MemberRA != null)
                    {
                        int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext);
                        if (numLines > 1)
                        {
                            vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
                            DisplayIterCtxt(numLines, vwenv);
                        }
                        else
                        {
                            OpenSingleLinePile(vwenv, GetMaxNumLines());
                            if (iterCtxt.MemberRA.ClassID == PhSimpleContextNCTags.kClassId)
                            {
                                vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
                            }
                            else
                            {
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen);
                                vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen);
                            }
                            DisplayIterCtxt(1, vwenv);
                            // Views doesn't handle selection properly when we have an inner pile with strings on either side,
                            // so we don't add a zero-width space at the end
                            CloseSingleLinePile(vwenv, false);
                        }
                    }
                    else
                    {
                        OpenSingleLinePile(vwenv, GetMaxNumLines());
                        vwenv.AddProp(PhIterationContextTags.kflidMember, this, kfragQuestions);
                        CloseSingleLinePile(vwenv);
                    }
                    break;

                case PhSimpleContextSegTags.kClassId:
                    if (!isOuterIterCtxt)
                    {
                        OpenSingleLinePile(vwenv, GetMaxNumLines());
                    }

                    var segCtxt = (IPhSimpleContextSeg)ctxtOrVar;
                    if (segCtxt.FeatureStructureRA != null)
                    {
                        vwenv.AddObjProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseSingleLinePile(vwenv);
                    }
                    break;

                case PhSimpleContextBdryTags.kClassId:
                    if (!isOuterIterCtxt)
                    {
                        OpenSingleLinePile(vwenv, GetMaxNumLines());
                    }

                    var bdryCtxt = (IPhSimpleContextBdry)ctxtOrVar;
                    if (bdryCtxt.FeatureStructureRA != null)
                    {
                        vwenv.AddObjProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseSingleLinePile(vwenv);
                    }
                    break;

                case PhVariableTags.kClassId:
                    OpenSingleLinePile(vwenv, GetMaxNumLines());
                    vwenv.AddProp(ktagXVariable, this, kfragXVariable);
                    CloseSingleLinePile(vwenv);
                    break;
                }
                break;

            case kfragNC:
                int ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo,
                                                          PhNaturalClassTags.kflidAbbreviation);
                if (ncWs != 0)
                {
                    vwenv.AddStringAltMember(PhNaturalClassTags.kflidAbbreviation, ncWs, this);
                }
                else
                {
                    ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo,
                                                          PhNaturalClassTags.kflidName);
                    if (ncWs != 0)
                    {
                        vwenv.AddStringAltMember(PhNaturalClassTags.kflidName, ncWs, this);
                    }
                    else
                    {
                        vwenv.AddProp(PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions);
                    }
                }
                break;

            case kfragTerminalUnit:
                int tuWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstVern,
                                                          hvo, PhTerminalUnitTags.kflidName);
                if (tuWs != 0)
                {
                    vwenv.AddStringAltMember(PhTerminalUnitTags.kflidName, tuWs, this);
                }
                else
                {
                    vwenv.AddProp(PhTerminalUnitTags.kflidName, this, kfragQuestions);
                }
                break;

            case kfragFeatNC:
                vwenv.AddObjProp(PhNCFeaturesTags.kflidFeatures, this, kfragFeats);
                break;

            case kfragFeats:
                vwenv.AddObjVecItems(FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature);
                break;

            case kfragFeature:
                vwenv.AddProp(ktagFeature, this, kfragFeatureLine);
                break;

            case kfragPlusVariable:
                vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine);
                break;

            case kfragMinusVariable:
                vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
                break;
            }
        }
Exemple #32
0
		private void AddFreeformComment(IVwEnv vwenv, int hvo, int ws, int flidTarget)
		{
			if (flidTarget != ActiveFreeformFlid || hvo != m_hvoActiveFreeform || ws != ActiveFreeformWs)
			{
				vwenv.AddStringAltMember(flidTarget, ws, this); // display normally, not the current prop
				return;
			}
			ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo, flidTarget, ws);
			if (tssVal.Length != 0)
			{
				// Display normally, length is not zero. This is probably redundant, we don't set m_hvoActiveFreeform etc
				// if the length is zero. For that reason, putting in the following note dependency doesn't help.
				// Even if we did set them for a non-empty string, we'd have to
				// do a lot of other work to get the selection restored appropriately when the length goes to zero.
				// vwenv.NoteStringValDependency(hvo, CmAnnotationTags.kflidComment, ws, tsf.MakeString("", ws));
				vwenv.AddStringAltMember(flidTarget, ws, this);
				return;
			}
			// If anything causes the comment to change, get rid of the prompt.
			vwenv.NoteDependency(new [] { hvo }, new [] { flidTarget }, 1);
			// Passing the ws where we normally pass a tag, but DisplayVariant doesn't need the tag and does need to
			// know which writing system.
			vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, ws);
		}
Exemple #33
0
		protected void OpenSingleLinePile(IVwEnv vwenv, int maxNumLines, bool addBoundary)
		{
			vwenv.Props = m_pileProps;
			vwenv.OpenInnerPile();
			AddExtraLines(maxNumLines - 1, vwenv);
			vwenv.OpenParagraph();
			if (addBoundary)
			{
				vwenv.Props = m_bracketProps;
				vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace);
			}
		}
		void CloseIndexPile(IVwEnv vwenv)
		{
			vwenv.Props = m_bracketProps;
			vwenv.AddProp(ktagRightBoundary, this, kfragZeroWidthSpace);
			vwenv.CloseParagraph();
			vwenv.CloseInnerPile();
		}
		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;
			}
		}
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragRule:
                m_rule = m_cache.ServiceLocator.GetInstance <IPhMetathesisRuleRepository>().GetObject(hvo);
                if (m_rule.Disabled)
                {
                    vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text");
                }

                int maxNumLines = GetMaxNumLines();

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

                VwLength ctxtLen;
                ctxtLen.nVal = 1;
                ctxtLen.unit = VwUnit.kunRelative;

                int resultx, inputx, dmpy;
                vwenv.get_StringWidth(m_resultStr, m_colHeaderProps, out resultx, out dmpy);
                vwenv.get_StringWidth(m_inputStr, m_colHeaderProps, out inputx, out dmpy);
                VwLength headerLen;
                headerLen.nVal = Math.Max(resultx, inputx) + 8000;
                headerLen.unit = VwUnit.kunPoint1000;

                vwenv.MakeColumns(1, headerLen);
                vwenv.MakeColumns(4, ctxtLen);

                vwenv.OpenTableBody();

                vwenv.OpenTableRow();

                vwenv.OpenTableCell(1, 1);
                vwenv.CloseTableCell();

                // left context header cell
                vwenv.Props = m_colHeaderProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_leftEnvStr);
                vwenv.CloseTableCell();

                // switch header cell
                vwenv.Props = m_colHeaderProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.OpenTableCell(1, 2);
                vwenv.AddString(m_switchStr);
                vwenv.CloseTableCell();

                // right context header cell
                vwenv.Props = m_colHeaderProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_rightEnvStr);
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();

                vwenv.OpenTableRow();

                // input header cell
                vwenv.Props = m_rowHeaderProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_inputStr);
                vwenv.CloseTableCell();

                // input left context cell
                vwenv.Props = m_inputCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.LeftEnvIndex == -1)
                {
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ktagLeftEnv, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                else
                {
                    for (int i = 0; i < m_rule.LeftEnvLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // input left switch cell
                vwenv.Props = m_inputCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.LeftSwitchIndex == -1)
                {
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ktagLeftSwitch, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                else
                {
                    for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }

                    if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch)
                    {
                        for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
                        {
                            vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                        }
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // input right switch cell
                vwenv.Props = m_inputCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.RightSwitchIndex == -1)
                {
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ktagRightSwitch, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                else
                {
                    if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch)
                    {
                        for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
                        {
                            vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                        }
                    }

                    for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // input right context cell
                vwenv.Props = m_inputCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.RightEnvIndex == -1)
                {
                    OpenSingleLinePile(vwenv, maxNumLines, false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ktagRightEnv, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                else
                {
                    for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();

                vwenv.OpenTableRow();

                // input result header cell
                vwenv.Props = m_rowHeaderProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_resultStr);
                vwenv.CloseTableCell();

                // result left context cell
                vwenv.Props = m_resultCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.LeftEnvIndex != -1)
                {
                    for (int i = 0; i < m_rule.LeftEnvLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // result right switch cell
                vwenv.Props = m_resultCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.RightSwitchIndex != -1)
                {
                    for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch)
                {
                    for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // result left switch cell
                vwenv.Props = m_resultCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();

                if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch)
                {
                    for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                if (m_rule.LeftSwitchIndex != -1)
                {
                    for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // result right context cell
                vwenv.Props = m_resultCtxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.RightEnvIndex != -1)
                {
                    for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++)
                    {
                        vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext);
                    }
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();

                vwenv.CloseTableBody();

                vwenv.CloseTable();
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
Exemple #37
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            int userWs = m_cache.DefaultUserWs;

            switch (frag)
            {
            case kfragRule:
                m_rule = m_cache.ServiceLocator.GetInstance <IMoAffixProcessRepository>().GetObject(hvo);

                int maxNumLines = GetMaxNumLines();

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

                VwLength inputLen;
                inputLen.nVal = 0;
                inputLen.unit = VwUnit.kunPoint1000;

                int      indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv);
                int      inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv);
                VwLength headerLen;
                headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000;
                headerLen.unit = VwUnit.kunPoint1000;
                inputLen.nVal += headerLen.nVal;

                VwLength leftEmptyLen;
                leftEmptyLen.nVal = 8000 + (PileMargin * 2) + 2000;
                leftEmptyLen.unit = VwUnit.kunPoint1000;
                inputLen.nVal    += leftEmptyLen.nVal;

                var ctxtLens = new VwLength[m_rule.InputOS.Count];
                vwenv.NoteDependency(new[] { m_rule.Hvo }, new[] { MoAffixProcessTags.kflidInput }, 1);
                for (int i = 0; i < m_rule.InputOS.Count; i++)
                {
                    int idxWidth  = GetStrWidth(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv);
                    int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv);
                    ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000;
                    ctxtLens[i].unit = VwUnit.kunPoint1000;
                    inputLen.nVal   += ctxtLens[i].nVal;
                }

                VwLength rightEmptyLen;
                rightEmptyLen.nVal = 8000 + (PileMargin * 2) + 1000;
                rightEmptyLen.unit = VwUnit.kunPoint1000;
                inputLen.nVal     += rightEmptyLen.nVal;

                vwenv.MakeColumns(1, inputLen);

                VwLength arrowLen;
                arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000;
                arrowLen.unit = VwUnit.kunPoint1000;
                vwenv.MakeColumns(1, arrowLen);

                VwLength outputLen;
                outputLen.nVal = 1;
                outputLen.unit = VwUnit.kunRelative;
                vwenv.MakeColumns(1, outputLen);

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

                // input table cell
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false);
                vwenv.MakeColumns(1, headerLen);
                vwenv.MakeColumns(1, leftEmptyLen);
                foreach (VwLength ctxtLen in ctxtLens)
                {
                    vwenv.MakeColumns(1, ctxtLen);
                }
                vwenv.MakeColumns(1, rightEmptyLen);

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

                // input header cell
                vwenv.Props = m_headerProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_inputStr);
                vwenv.CloseTableCell();

                // input left empty cell
                vwenv.Props = m_ctxtProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                OpenSingleLinePile(vwenv, maxNumLines, false);
                vwenv.Props = m_bracketProps;
                vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty);
                CloseSingleLinePile(vwenv, false);
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                // input context cells
                vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput);

                // input right empty cell
                vwenv.Props = m_ctxtProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                OpenSingleLinePile(vwenv, maxNumLines, false);
                vwenv.Props = m_bracketProps;
                vwenv.AddProp(ktagRightEmpty, this, kfragEmpty);
                CloseSingleLinePile(vwenv, false);
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();
                vwenv.OpenTableRow();

                // index header cell
                vwenv.Props = m_headerProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_indexStr);
                vwenv.CloseTableCell();

                // index left empty cell
                vwenv.Props = m_indexProps;
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.OpenTableCell(1, 1);
                vwenv.CloseTableCell();

                // index cells
                for (int i = 0; i < m_rule.InputOS.Count; i++)
                {
                    vwenv.Props = m_indexProps;
                    vwenv.OpenTableCell(1, 1);
                    vwenv.AddString(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs));
                    vwenv.CloseTableCell();
                }

                // index right empty cell
                vwenv.Props = m_indexProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.CloseTableCell();

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

                // double arrow cell
                vwenv.Props = m_arrowProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_doubleArrow);
                vwenv.CloseTableCell();

                // result table cell
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false);
                vwenv.MakeColumns(1, outputLen);

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

                // result header cell
                vwenv.Props = m_headerProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.AddString(m_resultStr);
                vwenv.CloseTableCell();

                vwenv.CloseTableRow();
                vwenv.OpenTableRow();

                // result cell
                vwenv.Props = m_resultProps;
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (m_rule.OutputOS.Count == 0)
                {
                    vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty);
                }
                else
                {
                    vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

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

            case kfragRuleMapping:
                var mapping = m_cache.ServiceLocator.GetInstance <IMoRuleMappingRepository>().GetObject(hvo);
                switch (mapping.ClassID)
                {
                case MoCopyFromInputTags.kClassId:
                    var copy = (IMoCopyFromInput)mapping;
                    OpenSingleLinePile(vwenv, GetOutputMaxNumLines());
                    if (copy.ContentRA == null)
                    {
                        vwenv.AddProp(ktagIndex, this, 0);
                    }
                    else
                    {
                        vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1);
                    }
                    CloseSingleLinePile(vwenv);
                    break;

                case MoInsertPhonesTags.kClassId:
                    OpenSingleLinePile(vwenv, GetOutputMaxNumLines());
                    vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit);
                    CloseSingleLinePile(vwenv);
                    break;

                case MoModifyFromInputTags.kClassId:
                    var modify            = (IMoModifyFromInput)mapping;
                    int outputMaxNumLines = GetOutputMaxNumLines();
                    int numLines          = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count;

                    // index pile
                    vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                    vwenv.OpenInnerPile();
                    AddExtraLines(outputMaxNumLines - 1, vwenv);
                    vwenv.OpenParagraph();
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace);
                    if (modify.ContentRA == null)
                    {
                        vwenv.AddProp(ktagIndex, this, 0);
                    }
                    else
                    {
                        vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1);
                    }
                    vwenv.CloseParagraph();
                    vwenv.CloseInnerPile();

                    // left bracket pile
                    // right align brackets in left bracket pile, since the index could have a greater width, then the bracket
                    if (numLines == 1)
                    {
                        vwenv.OpenInnerPile();
                        AddExtraLines(outputMaxNumLines - 1, vwenv);
                        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
                        vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket);
                        vwenv.CloseInnerPile();
                    }
                    else
                    {
                        vwenv.OpenInnerPile();
                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
                        vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.Props = m_bracketProps;
                            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                        }
                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
                        vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook);
                        vwenv.CloseInnerPile();
                    }

                    // feature pile
                    vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                    vwenv.OpenInnerPile();
                    AddExtraLines(outputMaxNumLines - numLines, vwenv);
                    if (numLines == 0)
                    {
                        vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions);
                    }
                    else
                    {
                        vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC);
                    }
                    vwenv.CloseInnerPile();

                    // right bracket pile
                    if (numLines == 1)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        AddExtraLines(outputMaxNumLines - 1, vwenv);
                        vwenv.OpenInnerPile();
                        vwenv.AddProp(ktagRightBoundary, this, kfragRightBracket);
                        vwenv.CloseInnerPile();
                    }
                    else
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        vwenv.OpenInnerPile();
                        AddExtraLines(outputMaxNumLines - numLines, vwenv);
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.Props = m_bracketProps;
                            vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
                        }
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
                        vwenv.CloseInnerPile();
                    }
                    break;
                }
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
Exemple #38
0
		/// <summary>
		///
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo">WfiMorphBundle</param>
		private void DisplayMorphBundle(IVwEnv vwenv, int hvo)
		{
			vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 10000);
			vwenv.OpenInnerPile();
			int first = m_lineChoices.FirstMorphemeIndex;
			int last = m_lineChoices.LastMorphemeIndex;
			int hvoMf = 0;
			if (hvo != 0)
			{
				hvoMf = m_cache.GetObjProperty(hvo,
					(int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph);
			}
			if (vwenv is CollectorEnv && hvoMf != 0)
			{
				// Collectors are given an extra initial chance to 'collect' the morph type, if any.
				vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph,
					this, kfragMorphType);

			}
			for (int i = first; i <= last; i++)
			{
				InterlinLineSpec spec = m_lineChoices[i];
				int ws = 0;
				if (hvo != 0)
				{
					ws = GetRealWs(hvo, spec);
				}
				SetColor(vwenv, LabelRGBFor(spec));
				switch (spec.Flid)
				{
					case InterlinLineChoices.kflidMorphemes:
						if (hvo == 0)
						{
							vwenv.AddString(m_tssMissingMorph);
						}
						else if (hvoMf == 0)
						{
							// If no morph, use the form of the morph bundle (and the entry is of
							// course missing)
							if (ws == 0)
							{
								ws = m_cache.LangProject.ActualWs(spec.WritingSystem, hvo,
									(int)WfiMorphBundle.WfiMorphBundleTags.kflidForm);
							}
							vwenv.AddStringAltMember(
								(int)WfiMorphBundle.WfiMorphBundleTags.kflidForm, ws, this);
						}
						else
						{
							// Got a morph, show it.
							vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph,
								this, kfragMorphFormChoices + i);
							// And the LexEntry line.
						}
						break;
					case InterlinLineChoices.kflidLexEntries:
						if (hvoMf == 0)
						{
							if (hvo != 0)
								vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph }, 1);
							vwenv.AddString(m_tssMissingEntry);
						}
						else
						{
							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 hvoSense = 0;
						if (hvo != 0)
						{
							hvoSense = m_cache.GetObjProperty(hvo,
								(int)WfiMorphBundle.WfiMorphBundleTags.kflidSense);
						}
						if (hvoSense == 0)
						{
							int virtFlid = 0;
							if (hvo != 0)
							{
								vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense }, 1);
								virtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
							}
							if (hvo != 0 && ShowDefaultSense && m_cache.GetObjProperty(hvo, virtFlid) > 0)
							{
								// Switch values when using the default sense, rather than the missing row '***'.
								SetGuessing(vwenv, false);
								vwenv.AddObjProp(virtFlid, this, kfragLineChoices + i);
							}
							else
							{
								vwenv.AddProp(ktagBundleMissingSense, this, kfragBundleMissingSense);
							}
						}
						else
						{
							vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidSense,
								this, kfragLineChoices + i);
						}
						break;

					case InterlinLineChoices.kflidLexPos:
						// LexPOS line:
						int hvoMsa = 0;
						if (hvo != 0)
							hvoMsa = m_cache.GetObjProperty(hvo, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa);
						if (hvoMsa == 0)
						{
							if (hvo != 0)
								vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.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.WritingSystemCode 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.WritingSystemCode = spec.WritingSystem;
							vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa,
								m_msaVc, (int)VcFrags.kfragInterlinearAbbr);
						}
						break;
				}
			}
			vwenv.CloseInnerPile();
		}
Exemple #39
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// In certain contexts, check the given paragraph to see if it is empty. If so,
		/// insert a user prompt.
		/// </summary>
		/// <param name="vwenv">view environment</param>
		/// <param name="hvo">id of paragraph to be displayed</param>
		/// <returns>true if an empty string was substituted for missing/empty StText</returns>
		/// -----------------------------------------------------------------------------------
		protected override bool InsertParaContentsUserPrompt(IVwEnv vwenv, int hvo)
		{
			Debug.Assert((Cache == null && vwenv.DataAccess != null) ||
				Cache.MainCacheAccessor == vwenv.DataAccess,
				"Oops! We don't expect to get a different data access object from IVwEnv");
			Debug.Assert(!DisplayTranslation);

			// No user prompt in any of these conditions
			if (hvo == 0
				|| Cache.GetClassOfObject(hvo) != (int)StTxtPara.kClassId
				|| !Options.ShowEmptyParagraphPromptsSetting // tools options setting
				|| m_target == LayoutViewTarget.targetPrint // any print layout view
				|| m_updatedPrompts.Contains(hvo)) // user interaction has updated prompt
			{
				return false;
			}

			// User prompt is only for title & heading paras
			StText text = new StText(Cache, Cache.GetOwnerOfObject(hvo)); // para owner
			if (text.OwningFlid != (int)ScrBook.ScrBookTags.kflidTitle &&
				text.OwningFlid != (int)ScrSection.ScrSectionTags.kflidHeading)
				return false;

			int paraCount = text.ParagraphsOS.Count;
			Debug.Assert(paraCount != 0,
				"We shouldn't come here if StText doesn't contain any paragraphs");
			// By design, if there is more than one para, don't display the user prompt.
			if (paraCount != 1)
				return false;

			// If first para is empty, insert user prompt for paragraph content
			if (((StTxtPara)text.ParagraphsOS.FirstItem).Contents.Text == null)
			{
				vwenv.NoteDependency(new int[] { hvo },
					new int[] { (int)StTxtPara.StTxtParaTags.kflidContents}, 1);
				vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, text.OwningFlid);
				return true;
			}

			return false;
		}
		void OpenIndexPile(IVwEnv vwenv)
		{
			vwenv.Props = m_pileProps;
			vwenv.OpenInnerPile();
			vwenv.OpenParagraph();
			vwenv.Props = m_bracketProps;
			vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace);
		}
Exemple #41
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// This is the main interesting method of displaying objects and fragments of them.
		/// Here a text is displayed by displaying its paragraphs;
		/// and a paragraph is displayed by invoking its style rule, making a paragraph,
		/// and displaying its contents.
		/// </summary>
		/// <param name="vwenv">view environment</param>
		/// <param name="hvo">id of object to be displayed</param>
		/// <param name="frag">fragment of data</param>
		/// -----------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			switch(frag)
			{
				case (int)StTextFrags.kfrFootnote:
				{
					if (HandleEmptyText(vwenv, hvo))
						break;
					vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
						(int)StTextFrags.kfrFootnotePara);
					break;
				}

				case (int)StTextFrags.kfrText:
				{
					if (HandleEmptyText(vwenv, hvo))
						break;
					if (m_fLazy)
					{
						vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this,
							(int)StTextFrags.kfrPara);
					}
					else
					{
						vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
							(int)StTextFrags.kfrPara);
					}
					break;
				}
				case (int)StTextFrags.kfrFootnoteMarker:
				{
					StFootnote footnote = new StFootnote(Cache, hvo);
					if (footnote.DisplayFootnoteMarker)
						DisplayFootnoteMarker(vwenv);
					break;
				}
				case (int)StTextFrags.kfrLabel:
				{
					// The label is not editable.
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
					vwenv.AddString(m_tssLabel);
					break;
				}

				case (int)StTextFrags.kfrPara:
				case (int)StTextFrags.kfrFootnotePara:
				{
					InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
					break;
				}

				case (int)StTextFrags.kfrTranslation:
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvEnum,
						Editable ? (int)TptEditable.ktptIsEditable
						: (int)TptEditable.ktptNotEditable);
					// Display the translation, or its user prompt
					if (!InsertTranslationUserPrompt(vwenv, hvo))
					{
						vwenv.AddStringAltMember((int)CmTranslation.CmTranslationTags.kflidTranslation,
							m_wsDefault, this);
					}
					break;
				}
				case (int)StTextFrags.kfrSegmentFreeTranslations:
					// Hvo is a CmBaseAnnotation of one segment of an StTxtPara.
					if (IsLabelSegment(hvo))
					{
						CmBaseAnnotation segment = (CmBaseAnnotation)CmBaseAnnotation.CreateFromDBObject(Cache, hvo, false);
						vwenv.AddString(GetBackTransLabelText(segment));
						vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 1200, 0, 0); // a narrow space, font-neutral
					}
					else
					{
						vwenv.AddObjProp(StTxtPara.SegmentFreeTranslationFlid(Cache), this, (int)StTextFrags.kfrFreeTrans);
						vwenv.AddString(OneSpaceString);
					}
					break;
				case (int)StTextFrags.kfrFreeTrans:
					// Hvo is a CmIndirectAnnotation whose Contents are the free/back translation.
					vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(SystemColors.Window));
					ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo,
						(int) CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS);
					if (tssVal.Length == 0 && !SuppressPrompt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment))
					{
						vwenv.NoteDependency(new int[] {hvo}, new int[] {(int)CmAnnotation.CmAnnotationTags.kflidComment}, 1);
						vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmAnnotation.CmAnnotationTags.kflidComment);
						// Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing
						// into the margin.
						vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0);
					}
					else
					{
						ITsStrBldr bldr = tssVal.GetBldr();
						bldr.Replace(0, bldr.Length, "", null); // reduce to empty string in ws.
						// We want it to change back to the prompt if all is deleted.
						vwenv.NoteStringValDependency(hvo, (int) CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, bldr.GetString());
						vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, this);
						// This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty,
						// and if there is ordinary text following, it is difficult to get an IP displayed in an empty run.
						vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0);
					}
					break;
			}
		}
Exemple #42
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// Here a text is displayed by displaying its paragraphs;
        /// and a paragraph is displayed by invoking its style rule, making a paragraph,
        /// and displaying its contents.
        /// </summary>
        /// <param name="vwenv">view environment</param>
        /// <param name="hvo">id of object to be displayed</param>
        /// <param name="frag">fragment of data</param>
        /// -----------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case (int)StTextFrags.kfrFootnote:
            {
                if (HandleEmptyText(vwenv, hvo))
                {
                    break;
                }
                vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
                                     (int)StTextFrags.kfrFootnotePara);
                break;
            }

            case (int)StTextFrags.kfrText:
            {
                if (HandleEmptyText(vwenv, hvo))
                {
                    break;
                }
                if (m_fLazy)
                {
                    vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this,
                                          (int)StTextFrags.kfrPara);
                }
                else
                {
                    vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
                                         (int)StTextFrags.kfrPara);
                }
                break;
            }

            case (int)StTextFrags.kfrFootnoteMarker:
            {
                StFootnote footnote = new StFootnote(Cache, hvo);
                if (footnote.DisplayFootnoteMarker)
                {
                    DisplayFootnoteMarker(vwenv);
                }
                break;
            }

            case (int)StTextFrags.kfrLabel:
            {
                // The label is not editable.
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)TptEditable.ktptNotEditable);
                vwenv.AddString(m_tssLabel);
                break;
            }

            case (int)StTextFrags.kfrPara:
            case (int)StTextFrags.kfrFootnotePara:
            {
                InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
                break;
            }

            case (int)StTextFrags.kfrTranslation:
            {
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      Editable ? (int)TptEditable.ktptIsEditable
                                                : (int)TptEditable.ktptNotEditable);
                // Display the translation, or its user prompt
                if (!InsertTranslationUserPrompt(vwenv, hvo))
                {
                    vwenv.AddStringAltMember((int)CmTranslation.CmTranslationTags.kflidTranslation,
                                             m_wsDefault, this);
                }
                break;
            }

            case (int)StTextFrags.kfrSegmentFreeTranslations:
                // Hvo is a CmBaseAnnotation of one segment of an StTxtPara.
                if (IsLabelSegment(hvo))
                {
                    CmBaseAnnotation segment = (CmBaseAnnotation)CmBaseAnnotation.CreateFromDBObject(Cache, hvo, false);
                    vwenv.AddString(GetBackTransLabelText(segment));
                    vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 1200, 0, 0);                             // a narrow space, font-neutral
                }
                else
                {
                    vwenv.AddObjProp(StTxtPara.SegmentFreeTranslationFlid(Cache), this, (int)StTextFrags.kfrFreeTrans);
                    vwenv.AddString(OneSpaceString);
                }
                break;

            case (int)StTextFrags.kfrFreeTrans:
                // Hvo is a CmIndirectAnnotation whose Contents are the free/back translation.
                vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault,
                                      (int)ColorUtil.ConvertColorToBGR(SystemColors.Window));
                ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo,
                                                                       (int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS);
                if (tssVal.Length == 0 && !SuppressPrompt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment))
                {
                    vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)CmAnnotation.CmAnnotationTags.kflidComment }, 1);
                    vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, (int)CmAnnotation.CmAnnotationTags.kflidComment);
                    // Almost invisibly narrow, but the Views code doesn't know it is invisible so it should prevent the prompts collapsing
                    // into the margin.
                    vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0);
                }
                else
                {
                    ITsStrBldr bldr = tssVal.GetBldr();
                    bldr.Replace(0, bldr.Length, "", null);                             // reduce to empty string in ws.
                    // We want it to change back to the prompt if all is deleted.
                    vwenv.NoteStringValDependency(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, bldr.GetString());
                    vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS, this);
                    // This little separator is useful here, too. Temporarily the comment may be displayed this way even when empty,
                    // and if there is ordinary text following, it is difficult to get an IP displayed in an empty run.
                    vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 100, 0, 0);
                }
                break;
            }
        }
Exemple #43
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// In certain contexts, check the given paragraph to see if it is empty. If so,
		/// insert a user prompt.
		/// </summary>
		/// <param name="vwenv">view environment</param>
		/// <param name="paraHvo">HVO of the paragraph to be displayed</param>
		/// <returns>true if an empty string was substituted for missing/empty StText</returns>
		/// -----------------------------------------------------------------------------------
		protected override bool InsertParaContentsUserPrompt(IVwEnv vwenv, int paraHvo)
		{
			Debug.Assert(!DisplayTranslation);

			// No user prompt in any of these conditions
			IStTxtPara para = m_cache.ServiceLocator.GetInstance<IStTxtParaRepository>().GetObject(paraHvo);
			if (!(para is IScrTxtPara)
				|| !Options.ShowEmptyParagraphPromptsSetting // tools options setting
				|| m_target == LayoutViewTarget.targetPrint // any print layout view
				|| m_updatedPrompts.Contains(para.Hvo)) // user interaction has updated prompt
			{
				return false;
			}

			// User prompt is only for title & heading paras
			IStText text = (IStText)para.Owner; // para owner
			if (text.OwningFlid != ScrBookTags.kflidTitle &&
				text.OwningFlid != ScrSectionTags.kflidHeading)
				return false;

			int paraCount = text.ParagraphsOS.Count;
			Debug.Assert(paraCount != 0,
				"We shouldn't come here if StText doesn't contain any paragraphs");
			// By design, if there is more than one para, don't display the user prompt.
			if (paraCount != 1)
				return false;

			// If first para is empty, insert user prompt for paragraph content
			if (text[0].Contents.Text == null)
			{
				vwenv.NoteDependency(new int[] { para.Hvo },
					new int[] { StTxtParaTags.kflidContents}, 1);
				vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, text.OwningFlid);
				return true;
			}

			return false;
		}
Exemple #44
0
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case kfragContext:
					var ctxtOrVar = m_cache.ServiceLocator.GetInstance<IPhContextOrVarRepository>().GetObject(hvo);
					bool isOuterIterCtxt = false;
					// are we inside an iteration context? this is important since we only open a context pile if we are not
					// in an iteration context, since an iteration context does it for us
					if (vwenv.EmbeddingLevel > 0)
					{
						int outerHvo, outerTag, outerIndex;
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex);
						var outerObj = m_cache.ServiceLocator.GetObject(outerHvo);
						isOuterIterCtxt = outerObj.ClassID == PhIterationContextTags.kClassId;
					}

					switch (ctxtOrVar.ClassID)
					{
						case PhSequenceContextTags.kClassId:
							var seqCtxt = ctxtOrVar as IPhSequenceContext;
							if (seqCtxt.MembersRS.Count > 0)
							{
								vwenv.AddObjVecItems(PhSequenceContextTags.kflidMembers, this, kfragContext);
							}
							else
							{
								OpenContextPile(vwenv, false);
								vwenv.Props = m_bracketProps;
								vwenv.AddProp(PhSequenceContextTags.kflidMembers, this, kfragEmpty);
								CloseContextPile(vwenv, false);
							}
							break;

						case PhSimpleContextNCTags.kClassId:
							var ncCtxt = ctxtOrVar as IPhSimpleContextNC;
							if (ncCtxt.FeatureStructureRA != null && ncCtxt.FeatureStructureRA.ClassID == PhNCFeaturesTags.kClassId)
							{
								// Natural class simple context with a feature-based natural class
								var natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;

								int numLines = GetNumLines(ncCtxt);
								if (numLines == 0)
								{
									if (!isOuterIterCtxt)
										OpenContextPile(vwenv);

									vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
									vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
									vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

									if (!isOuterIterCtxt)
										CloseContextPile(vwenv);
								}
								else if (numLines == 1)
								{
									if (!isOuterIterCtxt)
										OpenContextPile(vwenv);

									// use normal brackets for a single line context
									vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

									// special consonant and vowel natural classes only display the abbreviation
									if (natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "C"
										|| natClass.Abbreviation.AnalysisDefaultWritingSystem.Text == "V")
									{
										vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
									}
									else
									{
										if (natClass.FeaturesOA != null && natClass.FeaturesOA.FeatureSpecsOC.Count > 0)
											vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
										else if (ncCtxt.PlusConstrRS.Count > 0)
											vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
										else
											vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
									}
									vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

									if (!isOuterIterCtxt)
										CloseContextPile(vwenv);
								}
								else
								{
									// multiline context

									// left bracket pile
									int maxNumLines = MaxNumLines;
									vwenv.Props = m_bracketProps;
									vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
									vwenv.OpenInnerPile();
									AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
									vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
									for (int i = 1; i < numLines - 1; i++)
										vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
									vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
									vwenv.CloseInnerPile();

									// feature and variable pile
									vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
									vwenv.OpenInnerPile();
									AddExtraLines(maxNumLines - numLines, vwenv);
									vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
									vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
									vwenv.AddObjVecItems(PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
									vwenv.CloseInnerPile();

									// right bracket pile
									vwenv.Props = m_bracketProps;
									if (!isOuterIterCtxt)
										vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
									vwenv.OpenInnerPile();
									AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv);
									vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
									for (int i = 1; i < numLines - 1; i++)
										vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
									vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
									vwenv.CloseInnerPile();
								}
							}
							else
							{
								// natural class context with segment-based natural class
								if (!isOuterIterCtxt)
									OpenContextPile(vwenv);

								vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
								if (ncCtxt.FeatureStructureRA != null)
									vwenv.AddObjProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
								else
									vwenv.AddProp(PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
								vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

								if (!isOuterIterCtxt)
									CloseContextPile(vwenv);
							}
							break;

						case PhIterationContextTags.kClassId:
							IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
							if (iterCtxt.MemberRA != null)
							{
								int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext);
								if (numLines > 1)
								{
									vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
									DisplayIterCtxt(iterCtxt, numLines, vwenv);
								}
								else
								{
									OpenContextPile(vwenv);
									if (iterCtxt.MemberRA.ClassID == PhSimpleContextNCTags.kClassId)
									{
										vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
									}
									else
									{
										vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen);
										vwenv.AddObjProp(PhIterationContextTags.kflidMember, this, kfragContext);
										vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen);
									}
									DisplayIterCtxt(iterCtxt, 1, vwenv);
									// Views doesn't handle selection properly when we have an inner pile with strings on either side,
									// so we don't add a zero-width space at the end
									CloseContextPile(vwenv, false);
								}
							}
							else
							{
								OpenContextPile(vwenv);
								vwenv.AddProp(PhIterationContextTags.kflidMember, this, kfragQuestions);
								CloseContextPile(vwenv);
							}
							break;

						case PhSimpleContextSegTags.kClassId:
							if (!isOuterIterCtxt)
								OpenContextPile(vwenv);

							var segCtxt = ctxtOrVar as IPhSimpleContextSeg;
							if (segCtxt.FeatureStructureRA != null)
								vwenv.AddObjProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit);
							else
								vwenv.AddProp(PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions);

							if (!isOuterIterCtxt)
								CloseContextPile(vwenv);
							break;

						case PhSimpleContextBdryTags.kClassId:
							if (!isOuterIterCtxt)
								OpenContextPile(vwenv);

							var bdryCtxt = ctxtOrVar as IPhSimpleContextBdry;
							if (bdryCtxt.FeatureStructureRA != null)
								vwenv.AddObjProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit);
							else
								vwenv.AddProp(PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions);

							if (!isOuterIterCtxt)
								CloseContextPile(vwenv);
							break;

						case PhVariableTags.kClassId:
							OpenContextPile(vwenv);
							vwenv.AddProp(ktagXVariable, this, kfragXVariable);
							CloseContextPile(vwenv);
							break;
					}
					break;

				case kfragNC:
					int ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo,
						PhNaturalClassTags.kflidAbbreviation);
					if (ncWs != 0)
					{
						vwenv.AddStringAltMember(PhNaturalClassTags.kflidAbbreviation, ncWs, this);
					}
					else
					{
						ncWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo,
							PhNaturalClassTags.kflidName);
						if (ncWs != 0)
							vwenv.AddStringAltMember(PhNaturalClassTags.kflidName, ncWs, this);
						else
							vwenv.AddProp(PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions);
					}
					break;

				case kfragTerminalUnit:
					int tuWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstVern,
						hvo, PhTerminalUnitTags.kflidName);
					if (tuWs != 0)
						vwenv.AddStringAltMember(PhTerminalUnitTags.kflidName, tuWs, this);
					else
						vwenv.AddProp(PhTerminalUnitTags.kflidName, this, kfragQuestions);
					break;

				case kfragFeatNC:
					vwenv.AddObjProp(PhNCFeaturesTags.kflidFeatures, this, kfragFeats);
					break;

				case kfragFeats:
					vwenv.AddObjVecItems(FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature);
					break;

				case kfragFeature:
					vwenv.AddProp(ktagFeature, this, kfragFeatureLine);
					break;

				case kfragPlusVariable:
					vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine);
					break;

				case kfragMinusVariable:
					vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
					break;
			}
		}
Exemple #45
0
		/// <summary>
		/// Assuming the current object is hvoAnalysis, add a display of its Category property,
		/// the WordPOS line of the interlinear display.
		/// If choiceOffset is -1, display the current analysis writing systems, otherwise,
		/// display the one indicated.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvoAnalysis"></param>
		protected void AddAnalysisPos(IVwEnv vwenv, int hvoAnalysis, int choiceIndex)
		{
			int hvoPos = m_cache.GetObjProperty(hvoAnalysis, (int)WfiAnalysis.WfiAnalysisTags.kflidCategory);
			SetColor(vwenv, LabelRGBFor(choiceIndex));
			if (hvoPos == 0)
			{
				vwenv.OpenParagraph();
				vwenv.NoteDependency(new int[] {hvoAnalysis},
					new int[] {(int)WfiAnalysis.WfiAnalysisTags.kflidCategory}, 1);
				vwenv.AddProp(ktagAnalysisMissingPos, this, kfragAnalysisMissingPos);
				vwenv.CloseParagraph();
			}
			else if (choiceIndex < 0)
			{
				vwenv.AddObjProp((int)WfiAnalysis.WfiAnalysisTags.kflidCategory, this, kfragCategory);
			}
			else
			{
				vwenv.AddObjProp((int)WfiAnalysis.WfiAnalysisTags.kflidCategory, this, kfragLineChoices + choiceIndex);
			}
		}
Exemple #46
0
		void DisplayIterCtxt(IPhIterationContext iterCtxt, int numLines, IVwEnv vwenv)
		{
			int superOffset = 0;
			if (numLines == 1)
			{
				// if the inner context is a single line, then make the min value a subscript and the max value a superscript.
				// I tried to use the Views subscript and superscript properties, but they added extra space so that it would
				// have the same line height of a normal character, which is not what I wanted, so I compute the size myself
				int fontHeight = GetFontHeight(m_cache.DefaultUserWs);
				int superSubHeight = (fontHeight * 2) / 3;
				vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, superSubHeight);
				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight, (int)FwTextPropVar.ktpvMilliPoint, -superSubHeight);
				superOffset = superSubHeight / 2;
			}
			else
			{
				vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
			}
			vwenv.OpenInnerPile();
			if (numLines == 1)
				vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, superOffset);
			vwenv.OpenParagraph();
			vwenv.AddProp(PhIterationContextTags.kflidMaximum, this, kfragIterCtxtMax);
			vwenv.CloseParagraph();
			AddExtraLines(numLines - 2, vwenv);
			vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, 0);
			vwenv.OpenParagraph();
			vwenv.AddIntProp(PhIterationContextTags.kflidMinimum);
			vwenv.CloseParagraph();
			vwenv.CloseInnerPile();
		}
Exemple #47
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)
		{
			var tsf = m_cache.TsStrFactory;
			var userWs = m_cache.DefaultUserWs;
			switch (frag)
			{
				case kfragRule:
					m_rule = m_cache.ServiceLocator.GetInstance<IMoAffixProcessRepository>().GetObject(hvo);

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

					VwLength inputLen;
					inputLen.nVal = 0;
					inputLen.unit = VwUnit.kunPoint1000;

					int indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv);
					int inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv);
					VwLength headerLen;
					headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000;
					headerLen.unit = VwUnit.kunPoint1000;
					inputLen.nVal += headerLen.nVal;

					VwLength leftEmptyLen;
					leftEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 2000;
					leftEmptyLen.unit = VwUnit.kunPoint1000;
					inputLen.nVal += leftEmptyLen.nVal;

					var ctxtLens = new VwLength[m_rule.InputOS.Count];
					vwenv.NoteDependency(new[] {m_rule.Hvo}, new[] {MoAffixProcessTags.kflidInput}, 1 );
					for (int i = 0; i < m_rule.InputOS.Count; i++)
					{
						int idxWidth = GetStrWidth(tsf.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv);
						int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv);
						ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000;
						ctxtLens[i].unit = VwUnit.kunPoint1000;
						inputLen.nVal += ctxtLens[i].nVal;
					}

					VwLength rightEmptyLen;
					rightEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 1000;
					rightEmptyLen.unit = VwUnit.kunPoint1000;
					inputLen.nVal += rightEmptyLen.nVal;

					vwenv.MakeColumns(1, inputLen);

					VwLength arrowLen;
					arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000;
					arrowLen.unit = VwUnit.kunPoint1000;
					vwenv.MakeColumns(1, arrowLen);

					VwLength outputLen;
					outputLen.nVal = 1;
					outputLen.unit = VwUnit.kunRelative;
					vwenv.MakeColumns(1, outputLen);

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

					// input table cell
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false);
					vwenv.MakeColumns(1, headerLen);
					vwenv.MakeColumns(1, leftEmptyLen);
					foreach (VwLength ctxtLen in ctxtLens)
						vwenv.MakeColumns(1, ctxtLen);
					vwenv.MakeColumns(1, rightEmptyLen);

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

					// input header cell
					vwenv.Props = m_headerProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_inputStr);
					vwenv.CloseTableCell();

					// input left empty cell
					vwenv.Props = m_ctxtProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					OpenContextPile(vwenv, false);
					vwenv.Props = m_bracketProps;
					vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty);
					CloseContextPile(vwenv, false);
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					// input context cells
					vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput);

					// input right empty cell
					vwenv.Props = m_ctxtProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					OpenContextPile(vwenv, false);
					vwenv.Props = m_bracketProps;
					vwenv.AddProp(ktagRightEmpty, this, kfragEmpty);
					CloseContextPile(vwenv, false);
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

					vwenv.CloseTableRow();
					vwenv.OpenTableRow();

					// index header cell
					vwenv.Props = m_headerProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_indexStr);
					vwenv.CloseTableCell();

					// index left empty cell
					vwenv.Props = m_indexProps;
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000);
					vwenv.OpenTableCell(1, 1);
					vwenv.CloseTableCell();

					// index cells
					for (int i = 0; i < m_rule.InputOS.Count; i++)
					{
						vwenv.Props = m_indexProps;
						vwenv.OpenTableCell(1, 1);
						vwenv.AddString(tsf.MakeString(Convert.ToString(i + 1), userWs));
						vwenv.CloseTableCell();
					}

					// index right empty cell
					vwenv.Props = m_indexProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.CloseTableCell();

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

					// double arrow cell
					vwenv.Props = m_arrowProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_doubleArrow);
					vwenv.CloseTableCell();

					// result table cell
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false);
					vwenv.MakeColumns(1, outputLen);

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

					// result header cell
					vwenv.Props = m_headerProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.AddString(m_resultStr);
					vwenv.CloseTableCell();

					vwenv.CloseTableRow();
					vwenv.OpenTableRow();

					// result cell
					vwenv.Props = m_resultProps;
					vwenv.OpenTableCell(1, 1);
					vwenv.OpenParagraph();
					if (m_rule.OutputOS.Count == 0)
						vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty);
					else
						vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping);
					vwenv.CloseParagraph();
					vwenv.CloseTableCell();

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

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

				case kfragRuleMapping:
					var mapping = m_cache.ServiceLocator.GetInstance<IMoRuleMappingRepository>().GetObject(hvo);
					switch (mapping.ClassID)
					{
						case MoCopyFromInputTags.kClassId:
							var copy = (IMoCopyFromInput) mapping;
							OpenIndexPile(vwenv);
							if (copy.ContentRA == null)
								vwenv.AddProp(ktagIndex, this, 0);
							else
								vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1);
							CloseIndexPile(vwenv);
							break;

						case MoInsertPhonesTags.kClassId:
							OpenIndexPile(vwenv);
							vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit);
							CloseIndexPile(vwenv);
							break;

						case MoModifyFromInputTags.kClassId:
							var modify = (IMoModifyFromInput) mapping;
							var numLines = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count;
							// left bracket pile
							vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
							vwenv.OpenInnerPile();

							vwenv.Props = m_bracketProps;
							vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace);

							// put index in the left bracket pile
							if (modify.ContentRA == null)
								vwenv.AddProp(ktagIndex, this, 0);
							else
								vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1);
							// right align brackets in left bracket pile, since the index could have a greater width, then the bracket
							if (numLines > 1)
							{
								vwenv.Props = m_bracketProps;
								vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
								vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
								for (int i = 1; i < numLines - 1; i++)
								{
									vwenv.Props = m_bracketProps;
									vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
									vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
								}
								vwenv.Props = m_bracketProps;
								vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
								vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook);
							}
							else
							{
								vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight);
								vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket);
							}
							vwenv.CloseInnerPile();

							// feature pile
							vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
							vwenv.OpenInnerPile();
							AddExtraLines(1, vwenv);
							if (numLines == 0)
								vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions);
							else
								vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC);
							vwenv.CloseInnerPile();

							// right bracket pile
							vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
							vwenv.OpenInnerPile();
							vwenv.Props = m_bracketProps;
							vwenv.AddProp(ktagRightBoundary, this, kfragSpace);
							if (numLines > 1)
							{
								vwenv.Props = m_bracketProps;
								vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
								for (int i = 1; i < numLines - 1; i++)
								{
									vwenv.Props = m_bracketProps;
									vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
								}
								vwenv.Props = m_bracketProps;
								vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketLowHook);
							}
							else
							{
								vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracket);
							}
							vwenv.CloseInnerPile();
							break;
					}
					break;

				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragPattern:
                VwLength tableLen;
                tableLen.nVal = 10000;
                tableLen.unit = VwUnit.kunPercent100;
                vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false);
                VwLength patternLen;
                patternLen.nVal = 1;
                patternLen.unit = VwUnit.kunRelative;
                vwenv.MakeColumns(1, patternLen);
                vwenv.OpenTableBody();
                vwenv.OpenTableRow();

                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray));
                vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.OpenTableCell(1, 1);
                vwenv.OpenParagraph();
                if (((ComplexConcPatternSda)vwenv.DataAccess).Root.IsLeaf)
                {
                    OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false);
                    vwenv.Props = m_bracketProps;
                    vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty);
                    CloseSingleLinePile(vwenv, false);
                }
                else
                {
                    vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);
                }
                vwenv.CloseParagraph();
                vwenv.CloseTableCell();

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

            case kfragNode:
                ComplexConcPatternNode node = ((ComplexConcPatternSda)vwenv.DataAccess).Nodes[hvo];
                int maxNumLines             = GetMaxNumLines(vwenv);
                if (node is ComplexConcOrNode)
                {
                    OpenSingleLinePile(vwenv, maxNumLines);
                    vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR);
                    CloseSingleLinePile(vwenv, false);
                }
                else if (node is ComplexConcWordBdryNode)
                {
                    OpenSingleLinePile(vwenv, maxNumLines);
                    vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash);
                    CloseSingleLinePile(vwenv);
                }
                else if (node is ComplexConcGroupNode)
                {
                    int  numLines  = GetNumLines(node);
                    bool hasMinMax = node.Maximum != 1 || node.Minimum != 1;
                    if (numLines == 1)
                    {
                        OpenSingleLinePile(vwenv, maxNumLines, false);
                        // use normal parentheses for a single line group
                        vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen);

                        vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);

                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen);
                        if (hasMinMax)
                        {
                            DisplayMinMax(numLines, vwenv);
                        }
                        CloseSingleLinePile(vwenv, false);
                    }
                    else
                    {
                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        vwenv.OpenInnerPile();
                        AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                        vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt);
                        }
                        vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook);
                        vwenv.CloseInnerPile();

                        vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode);

                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        vwenv.OpenInnerPile();
                        AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv);
                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt);
                        }
                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook);
                        vwenv.CloseInnerPile();
                        if (hasMinMax)
                        {
                            DisplayMinMax(numLines, vwenv);
                        }
                    }
                }
                else
                {
                    bool hasMinMax = node.Maximum != 1 || node.Minimum != 1;
                    int  numLines  = GetNumLines(node);
                    if (numLines == 1)
                    {
                        OpenSingleLinePile(vwenv, maxNumLines, false);
                        // use normal brackets for a single line constraint
                        vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket);

                        DisplayFeatures(vwenv, node);

                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket);
                        if (hasMinMax)
                        {
                            DisplayMinMax(numLines, vwenv);
                        }
                        CloseSingleLinePile(vwenv, false);
                    }
                    else
                    {
                        // left bracket pile
                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        vwenv.OpenInnerPile();
                        AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                        vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                        }
                        vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                        vwenv.CloseInnerPile();

                        // feature pile
                        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                        vwenv.OpenInnerPile();
                        AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv);
                        DisplayFeatures(vwenv, node);
                        vwenv.CloseInnerPile();

                        // right bracket pile
                        vwenv.Props = m_bracketProps;
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin);
                        vwenv.OpenInnerPile();
                        AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv);
                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook);
                        for (int i = 1; i < numLines - 1; i++)
                        {
                            vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt);
                        }
                        vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook);
                        vwenv.CloseInnerPile();
                        if (hasMinMax)
                        {
                            DisplayMinMax(numLines, vwenv);
                        }
                    }
                }
                break;
            }
        }
Exemple #50
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
		}
Exemple #51
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 #52
0
		private void AddFreeformComment(IVwEnv vwenv, int hvo, int ws, int hvoType)
		{
			if (hvoType == NoteSegmentDefn || hvo != m_hvoActiveFreeform || ws != m_wsActiveFreeform)
			{
				vwenv.AddStringAltMember((int) CmAnnotation.CmAnnotationTags.kflidComment, ws, this);
				return;
			}
			ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo, (int) CmAnnotation.CmAnnotationTags.kflidComment, ws);
			if (tssVal.Length != 0)
			{
				//ITsStrFactory tsf = TsStrFactoryClass.Create();
				// This allows us to put the prompt back if all the text is deleted. But doing that is dubious...will have to
				// do a lot of other work to get the selection restored appropriately.
				// vwenv.NoteStringValDependency(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, ws, tsf.MakeString("", ws));
				vwenv.AddStringAltMember((int) CmAnnotation.CmAnnotationTags.kflidComment, ws, this);
				return;
			}
			// If anything causes the comment to change, get rid of the prompt.
			vwenv.NoteDependency(new int[] { hvo },
				new int[] { (int)CmAnnotation.CmAnnotationTags.kflidComment }, 1);
			// Passing the ws where we normally pass a tag, but DisplayVariant doesn't need the tag and does need to
			// know which writing system.
			vwenv.AddProp(SimpleRootSite.kTagUserPrompt, this, ws);
		}