示例#1
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them. Most
        /// subclasses should override.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// -----------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case 1:                     // LexEntry
                vwenv.OpenParagraph();
                vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, 2);
                vwenv.AddObjVecItems(LexEntryTags.kflidSenses, this, 3);
                vwenv.CloseParagraph();
                break;

            case 2:                     // MoForm
                vwenv.AddStringAltMember(MoFormTags.kflidForm, m_cache.DefaultVernWs, this);
                NoteItemWidth(vwenv, hvo, MoFormTags.kflidForm, m_cache.DefaultVernWs);
                break;

            case 3:                     // LexSense
                vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this);
                NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs);
                int flid = m_cache.MetaDataCacheAccessor.GetFieldId("LexSense", "LexSenseReferences", false);
                vwenv.AddObjVecItems(flid, this, 4);
                break;

            case 4:                     // LexReference
                vwenv.AddObjVecItems(LexReferenceTags.kflidTargets, this, 5);
                break;

            case 5:                     // target of lex reference, which in our test data is made to be a sense
                vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this);
                NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs);
                break;
            }
        }
示例#2
0
 public override void Display(IVwEnv vwenv, int hvo, int frag)
 {
     CheckDisposed();
     if (m_wsDefault == -1)
     {
         // Set the underlying paragraph to RTL if the first writing system in the
         // string is RTL.
         if (m_cache != null)
         {
             ITsString    tss = m_cache.MainCacheAccessor.get_StringProp(hvo, m_flid);
             ITsTextProps ttp = tss.get_Properties(0);
             int          var;
             int          ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
             if (ws != 0)
             {
                 SetParaRTLIfNeeded(vwenv, ws);
             }
         }
         vwenv.AddStringProp(m_flid, this);
     }
     else
     {
         SetParaRTLIfNeeded(vwenv, m_wsDefault);
         vwenv.AddStringAltMember(m_flid, m_wsDefault, this);
     }
 }
示例#3
0
        private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i)
        {
            XmlNode node = m_columns[i - 1];
            // Make a cell and embed an editable virtual string for the column.
            var editable = XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);

            if (!editable)
            {
                vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, NoEditBackgroundColor);
            }
            vwenv.OpenTableCell(1, 1);
            int flid = XMLViewsDataCache.ktagEditColumnBase + i;
            int ws   = WritingSystemServices.GetWritingSystem(m_cache, node, null,
                                                              m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle).Handle;

            // Paragraph directionality must be set before the paragraph is opened.
            bool fRTL = IsWsRTL(ws);

            vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                  (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                  (int)FwTextPropVar.ktpvEnum,
                                  fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);

            // Fill in the cell with the virtual property.
            vwenv.OpenParagraph();
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
            vwenv.AddStringAltMember(flid, ws, this);
            vwenv.CloseParagraph();
            vwenv.CloseTableCell();
        }
示例#4
0
        private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i)
        {
            string  sField = ksEditColumnBaseName + i;
            XmlNode node   = m_columns[i - 1] as XmlNode;

            // Make a cell and embed an editable virtual string for the column.
            vwenv.OpenTableCell(1, 1);
            // Initialize the virtual property.
            IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField);

            Debug.Assert(vh != null);
            int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false);
            int ws   = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs);

            // Paragraph directionality must be set before the paragraph is opened.
            bool fRTL = IsWsRTL(ws);

            vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                  (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                  (int)FwTextPropVar.ktpvEnum,
                                  fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);

            vh.Load(khvoNewItem, flid, ws, cda);
            // Fill in the cell with the virtual property.
            vwenv.OpenParagraph();
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptIsEditable);
            vwenv.AddStringAltMember(flid, ws, this);
            vwenv.CloseParagraph();
            vwenv.CloseTableCell();
        }
示例#5
0
        internal void AddDoublePara(IVwEnv vwenv, int hvo)
        {
            // We use a table to display the source WS in column 1, and the dest ws in column 2.
            FwViews.VwLength vlTable;             // we use this to specify that the table takes 100% of the width.
            vlTable.nVal = 10000;
            vlTable.unit = FwViews.VwUnit.kunPercent100;

            FwViews.VwLength vlColumn;             // and this one to specify half the width for each column
            vlColumn.nVal = 5000;
            vlColumn.unit = FwViews.VwUnit.kunPercent100;

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

            vwenv.OpenTable(2,                                // Two columns.
                            ref vlTable,                      // Table uses 100% of available width.
                            0,                                // Border thickness.
                            FwViews.VwAlignment.kvaLeft,      // Default alignment.
                            FwViews.VwFramePosition.kvfpVoid, // No border.
                            FwViews.VwRule.kvrlNone,          // No rules between cells.
                            3000,                             // Three points of space between cells.
                            3000);                            // Three points padding inside cells.
            // Specify column widths. The first argument is the number of columns,
            // not a column index.
            vwenv.MakeColumns(2, vlColumn);

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

            // Source cell, not editable
            vwenv.OpenTableCell(1, 1);
            vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptEditable, (int)FwKernelLib.FwTextPropVar.ktpvEnum,
                                  (int)FwKernelLib.TptEditable.ktptNotEditable);
            vwenv.AddStringAltMember(ktagParaContents, m_wsSrc, this);
            vwenv.CloseTableCell();

            // Dest cell, editable, therefore with white background.
            vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault,
                                  m_colorEditable);
            vwenv.OpenTableCell(1, 1);
            vwenv.AddStringAltMember(ktagParaContents, m_wsDst, this);
            vwenv.CloseTableCell();

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

                break;

            default:
                throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
            }
        }
            private void DisplayWordform(IVwEnv vwenv, int ws, int choiceIndex)
            {
                // For the wordform line we only want an icon on the first line (which is always wordform).
                bool fWantIcon = m_sandbox.ShowAnalysisCombo && choiceIndex == 0;

                // This has to be BEFORE we open the paragraph, so the indent applies to the whole
                // paragraph, and not some string box inside it.
                if (!fWantIcon)
                {
                    SetIndentForMissingIcon(vwenv);
                }
                vwenv.OpenParagraph();
                // The actual icon, if present, has to be INSIDE the paragraph.
                if (fWantIcon)
                {
                    AddPullDownIcon(vwenv, ktagAnalysisIcon);
                }
                //Set the background of the wordform to the 'WordFormBGColor' which is set when ChangeOrCreateSandbox
                //is called
                SetBGColor(vwenv, MultipleOptionBGColor);
                if (ws != m_sandbox.RawWordformWs)
                {
                    // Any other Ws we can edit.
                    MakeNextFlowObjectEditable(vwenv);
                    vwenv.OpenInnerPile();                     // So white background occupies full width
                    vwenv.AddStringAltMember(ktagSbWordForm, ws, this);
                    vwenv.CloseInnerPile();
                }
                else
                {
                    MakeNextFlowObjectReadOnly(vwenv);
                    //vwenv.AddString(m_sandbox.RawWordform);
                    vwenv.AddStringAltMember(ktagSbWordForm, ws, this);
                }
                vwenv.CloseParagraph();
            }
示例#8
0
 public override void Display(IVwEnv vwenv, int hvo, int frag)
 {
     if (m_fMultilingual)
     {
         SetParaRtlIfNeeded(vwenv, m_wsDefault);
         vwenv.AddStringAltMember(m_flid, m_wsDefault, this);
     }
     else
     {
         // Set the underlying paragraph to RTL if the first writing system in the
         // string is RTL.
         if (m_cache != null)
         {
             ITsString    tss = m_cache.DomainDataByFlid.get_StringProp(hvo, m_flid);
             ITsTextProps ttp = tss.get_Properties(0);
             int          var;
             int          ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
             if (ws == 0)
             {
                 ws = m_wsDefault;
             }
             if (ws == 0)
             {
                 ws = m_cache.DefaultAnalWs;
             }
             if (ws != 0)
             {
                 SetParaRtlIfNeeded(vwenv, ws);
                 if (m_fShowWsLabel)
                 {
                     DisplayWithWritingSystemLabel(vwenv, ws);
                     return;
                 }
             }
         }
         vwenv.AddStringProp(m_flid, this);
     }
 }
示例#9
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;
			}
		}
            private void DisplayWordGloss(IVwEnv vwenv, int hvo, int ws, int choiceIndex)
            {
                // Count how many glosses there are for the current analysis:
                int cGlosses = 0;
                // Find a wfi analysis (existing or guess) to determine whether to provide an icon for selecting
                // multiple word glosses for IhWordGloss.SetupCombo (cf. LT-1428)
                IWfiAnalysis wa = m_sandbox.GetWfiAnalysisInUse();

                if (wa != null)
                {
                    cGlosses = wa.MeaningsOC.Count;
                }

                SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));

                // Icon only if we want icons at all (currently always true) and there is at least one WfiGloss to choose
                // and this is the first word gloss line.
                bool fWantIcon = m_fIconsForAnalysisChoices &&
                                 (cGlosses > 0 || m_sandbox.ShouldAddWordGlossToLexicon) &&
                                 m_choices.IsFirstOccurrenceOfFlid(choiceIndex);

                // If there isn't going to be an icon, add an indent.
                if (!fWantIcon)
                {
                    SetIndentForMissingIcon(vwenv);
                }
                vwenv.OpenParagraph();
                if (fWantIcon)
                {
                    AddPullDownIcon(vwenv, ktagWordGlossIcon);
                    m_fIconForWordGloss = true;
                }
                else if (m_fIconForWordGloss == true && cGlosses == 0)
                {
                    // reset
                    m_fIconForWordGloss = false;
                }
                //if there is more than one gloss set the background color to give visual indication
                if (cGlosses > 1)
                {
                    //set directly to the MultipleApproved color rather than the stored one
                    //the state of the two could be different.
                    SetBGColor(vwenv, InterlinVc.MultipleApprovedGuessColor);
                    ITsStrFactory fact  = TsStrFactoryClass.Create();
                    ITsString     count = TsStringUtils.MakeTss(fact, Cache.DefaultUserWs, "" + cGlosses);
                    //make the number black.
                    SetColor(vwenv, 0);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
                                          (int)FwTextPropVar.ktpvMilliPoint, kmpIconMargin);
                    vwenv.AddString(count);
                }

                //Set the margin and padding values
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
                                      (int)FwTextPropVar.ktpvMilliPoint,
                                      kmpIconMargin);
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing,
                                      (int)FwTextPropVar.ktpvMilliPoint,
                                      2000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
                                      (int)FwTextPropVar.ktpvMilliPoint,
                                      2000);
                SetBGColor(vwenv, krgbEditable);
                vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum,
                                      (int)SpellingModes.ksmNormalCheck);
                vwenv.OpenInnerPile();

                // Set the appropriate paragraph direction for the writing system.
                bool fWsRtl = m_caches.MainCache.ServiceLocator.WritingSystemManager.Get(ws).RightToLeftScript;

                if (fWsRtl != RightToLeft)
                {
                    vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                          (int)FwTextPropVar.ktpvEnum,
                                          fWsRtl ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff);
                }

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

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

							}
						}

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

					case InterlinLineChoices.kflidLexPos:
						// LexPOS line:
						int hvoMsa = 0;
						if (wmb != null && wmb.MsaRA != null)
							hvoMsa = wmb.MsaRA.Hvo;
						if (hvoMsa == 0)
						{
							if (hvo != 0)
								vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMsa }, 1);
							vwenv.AddString(m_tssMissingMsa);
						}
						else
						{
							// Use a special view constructor that knows how to display the
							// interlinear view of whatever kind of MSA it is.
							// Enhance JohnT: ideally we would have one of these VCs for each writing system,
							// perhaps stored in the InterlinLineSpec. Currently displaying multiple Wss of LexPos
							// is not useful, though it is possible.
							// Enhancement RickM: we set the m_msaVc.DefaultWs to the selected writing system
							//		of each LexPos line in interlinear. This is used extract the LexPos abbreviation
							//		for the specific writing system.
							m_msaVc.DefaultWs = spec.WritingSystem;
							vwenv.AddObjProp(WfiMorphBundleTags.kflidMsa,
								m_msaVc, (int)VcFrags.kfragInterlinearAbbr);
						}
						break;
				}
			}
			vwenv.CloseInnerPile();
		}
示例#13
0
        private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo)
        {
            ISilDataAccess sda   = vwenv.DataAccess;
            int            hvoLf = sda.get_ObjectProp(hvo,
                                                      LexEntryTags.kflidLexemeForm);
            int hvoType = 0;

            if (hvoLf != 0)
            {
                hvoType = sda.get_ObjectProp(hvoLf,
                                             MoFormTags.kflidMorphType);
            }

            // If we have a type of morpheme, show the appropriate prefix that indicates it.
            // We want vernacular so it will match the point size of any aligned vernacular text.
            // (The danger is that the vernacular font doesn't have these characters...not sure what
            // we can do about that, but most do, and it looks awful in analysis if that is a
            // much different size from vernacular.)
            string sPrefix = null;

            if (hvoType != 0)
            {
                sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix);
            }

            // LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form.
            bool fGotLabel = false;
            int  wsActual  = 0;

            if (hvoLf != 0)
            {
                // if we have a lexeme form and its label is non-empty, use it.
                if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual))
                {
                    m_wsActual = wsActual;
                    fGotLabel  = true;
                    if (sPrefix != null)
                    {
                        vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
                    }
                    vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm);
                }
            }
            if (!fGotLabel)
            {
                // If we didn't get a useful form from the lexeme form try the citation form.
                if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual))
                {
                    m_wsActual = wsActual;
                    if (sPrefix != null)
                    {
                        vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
                    }
                    vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this);
                    fGotLabel = true;
                }
            }
            int defUserWs = m_cache.WritingSystemFactory.UserWs;

            if (!fGotLabel)
            {
                // If that fails just show two questions marks.
                if (sPrefix != null)
                {
                    vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
                }
                vwenv.AddString(m_cache.TsStrFactory.MakeString(FdoUiStrings.ksQuestions, defUserWs));                                  // was "??", not "???"
            }

            // If we have a lexeme form type show the appropriate postfix.
            if (hvoType != 0)
            {
                vwenv.AddString(TsStringUtils.MakeTss(
                                    sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual));
            }

            // Show homograph number if non-zero.
            int nHomograph = sda.get_IntProp(hvo,
                                             LexEntryTags.kflidHomographNumber);

            vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1);
            if (nHomograph > 0)
            {
                // Use a string builder to embed the properties in with the TsString.
                // this allows our TsStringCollectorEnv to properly encode the superscript.
                // ideally, TsStringCollectorEnv could be made smarter to handle SetIntPropValues
                // since AppendTss treats the given Tss as atomic.
                ITsIncStrBldr tsBldr = TsIncStrBldrClass.Create();
                tsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                        (int)FwTextPropVar.ktpvEnum,
                                        (int)FwSuperscriptVal.kssvSub);
                tsBldr.SetIntPropValues((int)FwTextPropType.ktptBold,
                                        (int)FwTextPropVar.ktpvEnum,
                                        (int)FwTextToggleVal.kttvForceOn);
                tsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                        (int)FwTextPropVar.ktpvDefault, defUserWs);
                var hc = m_cache.ServiceLocator.GetInstance <HomographConfiguration>();
                StringServices.InsertHomographNumber(tsBldr, nHomograph, hc, HomographConfiguration.HeadwordVariant.Main, m_cache);
                vwenv.AddString(tsBldr.GetString());
            }
        }
示例#14
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case kfragStText:                     // The whole text, root object for the InterlinDocChild.
                if (hvo == 0)
                {
                    return;                                     // What if the user deleted all the texts?  See LT-6727.
                }
                IStText stText = m_coRepository.GetObject(hvo) as IStText;
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvDefault,
                                      (int)TptEditable.ktptNotEditable);
                vwenv.OpenDiv();
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 6000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, 24000);
                // Add both vernacular and analysis if we have them (LT-5561).
                bool fAddedVernacular = false;
                int  wsVernTitle      = 0;
                //
                if (stText.Title.TryWs(WritingSystemServices.kwsFirstVern, out wsVernTitle))
                {
                    vwenv.OpenParagraph();
                    vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this);
                    vwenv.CloseParagraph();
                    fAddedVernacular = true;
                }
                int wsAnalysisTitle = 0;
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                vwenv.OpenParagraph();
                ITsString tssAnal;
                if (stText.Title.TryWs(WritingSystemServices.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) &&
                    !tssAnal.Equals(stText.Title.BestVernacularAlternative))
                {
                    if (fAddedVernacular)
                    {
                        // display analysis title at smaller font size.
                        vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                              (int)FwTextPropVar.ktpvMilliPoint, 12000);
                    }
                    vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this);
                }
                else
                {
                    // just add a blank title.
                    ITsString blankTitle = TsStringUtils.EmptyString(m_wsAnalysis);
                    vwenv.AddString(blankTitle);
                }
                vwenv.CloseParagraph();
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                int wsSource = 0;
                if (stText.Source.TryWs(WritingSystemServices.kwsFirstVernOrAnal, out wsSource))
                {
                    vwenv.OpenParagraph();
                    vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                          (int)FwTextPropVar.ktpvMilliPoint, 12000);
                    vwenv.AddStringAltMember(vtagStTextSource, wsSource, this);
                    vwenv.CloseParagraph();
                }
                else
                {
                    // just add a blank source.
                    ITsString tssBlank = TsStringUtils.EmptyString(m_wsAnalysis);
                    vwenv.AddString(tssBlank);
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                vwenv.OpenParagraph();
                if (stText.OwningFlid == TextTags.kflidContents)
                {
                    vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription);
                }
                vwenv.CloseParagraph();
                base.Display(vwenv, hvo, frag);
                vwenv.CloseDiv();
                break;

            case kfragTextDescription:
                vwenv.AddStringAltMember(CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
示例#15
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				if (hvo == 0)
					return;

				int wsAnal = m_ws;
				ITsStrFactory tsf = TsStrFactoryClass.Create();
				ICmObject co;
				switch(frag)
				{
					case (int)VcFrags.kfragHeadWord:
						co = CmObject.CreateFromDBObject(m_cache, hvo);
						ILexEntry le = co as ILexEntry;
						if (le != null)
							vwenv.AddString(le.HeadWord);
						else
							vwenv.AddString(tsf.MakeString(co.ShortName, wsAnal));
						break;
					case (int)VcFrags.kfragShortName:
						co = CmObject.CreateFromDBObject(m_cache, hvo);
						vwenv.AddString(tsf.MakeString(co.ShortName, wsAnal));
						break;
					case (int)VcFrags.kfragPosAbbrAnalysis:
						vwenv.AddStringAltMember((int)CmPossibility.CmPossibilityTags.kflidAbbreviation, wsAnal, this);
						break;
					case (int)VcFrags.kfragName:
					default:
						co = CmObject.CreateFromDBObject(m_cache, hvo);
						vwenv.AddString(tsf.MakeString(co.ToString(), wsAnal));
						break;
				}
			}
			private void DisplayWordGloss(IVwEnv vwenv, int hvo, int ws, int choiceIndex)
			{
				// Count how many glosses there are for the current analysis:
				int cGlosses = 0;
				// Find a wfi analysis (existing or guess) to determine whether to provide an icon for selecting
				// multiple word glosses for IhWordGloss.SetupCombo (cf. LT-1428)
				IWfiAnalysis wa = m_sandbox.GetWfiAnalysisInUse();
				if (wa != null)
					cGlosses = wa.MeaningsOC.Count;

				SetColor(vwenv, m_choices.LabelRGBFor(choiceIndex));

				// Icon only if we want icons at all (currently always true) and there is at least one WfiGloss to choose
				// and this is the first word gloss line.
				bool fWantIcon = m_fIconsForAnalysisChoices &&
					(cGlosses > 0 || m_sandbox.ShouldAddWordGlossToLexicon) &&
					m_choices.IsFirstOccurrenceOfFlid(choiceIndex);
				// If there isn't going to be an icon, add an indent.
				if (!fWantIcon)
				{
					SetIndentForMissingIcon(vwenv);
				}
				vwenv.OpenParagraph();
				if (fWantIcon)
				{
					AddPullDownIcon(vwenv, ktagWordGlossIcon);
					m_fIconForWordGloss = true;
				}
				else if (m_fIconForWordGloss == true && cGlosses == 0)
				{
					// reset
					m_fIconForWordGloss = false;
				}
				//if there is more than one gloss set the background color to give visual indication
				if (cGlosses > 1)
				{
					//set directly to the MultipleApproved color rather than the stored one
					//the state of the two could be different.
					SetBGColor(vwenv, InterlinVc.MultipleApprovedGuessColor);
					ITsStrFactory fact = TsStrFactoryClass.Create();
					ITsString count = TsStringUtils.MakeTss(fact, Cache.DefaultUserWs, "" + cGlosses);
					//make the number black.
					SetColor(vwenv, 0);
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
										  (int)FwTextPropVar.ktpvMilliPoint, kmpIconMargin);
					vwenv.AddString(count);
				}

				//Set the margin and padding values
				vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
					(int)FwTextPropVar.ktpvMilliPoint,
					kmpIconMargin);
				vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing,
					(int)FwTextPropVar.ktpvMilliPoint,
					2000);
				vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
					(int)FwTextPropVar.ktpvMilliPoint,
					2000);
				SetBGColor(vwenv, krgbEditable);
				vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum,
					(int)SpellingModes.ksmNormalCheck);
				vwenv.OpenInnerPile();

				// Set the appropriate paragraph direction for the writing system.
				bool fWsRtl = m_caches.MainCache.ServiceLocator.WritingSystemManager.Get(ws).RightToLeftScript;
				if (fWsRtl != RightToLeft)
					vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
						(int)FwTextPropVar.ktpvEnum,
						fWsRtl ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff);

				vwenv.AddStringAltMember(ktagSbWordGloss, ws, this);
				vwenv.CloseInnerPile();
				vwenv.CloseParagraph();
			}
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				try
				{
					switch (frag)
					{
						case kfragBundle: // One annotated word bundle, in this case, the whole view.
							if (hvo == 0)
								return;
							vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum,
								(int)SpellingModes.ksmDoNotCheck);
							vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
								(int)FwTextPropVar.ktpvDefault, krgbBackground);
							vwenv.OpenDiv();
							vwenv.OpenParagraph();
							// Since embedded in a pile with context, we need another layer of pile here,.
							// It's an overlay sandbox: draw a box around it.
							vwenv.OpenInnerPile();
							// Inside that division we need a paragraph which does not have any border
							// or background. This suppresses the 'infinite width' behavior for the
							// nested paragraphs that may have grey border.
							vwenv.OpenParagraph();

							// This makes a little separation between left border and arrows.
							vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
								(int)FwTextPropVar.ktpvMilliPoint, 1000);
							if (m_fRtl)
							{
								// This must not be on the outer paragraph or we get infinite width behavior.
								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.OpenInnerPile();
							for (int ispec = 0; ispec < m_choices.Count; )
							{
								InterlinLineSpec spec = m_choices[ispec];
								if (!spec.WordLevel)
									break;
								if (spec.MorphemeLevel)
								{
									DisplayMorphBundles(vwenv, hvo);
									ispec = m_choices.LastMorphemeIndex + 1;
									continue;
								}
								switch (spec.Flid)
								{
									case InterlinLineChoices.kflidWord:
										int ws = GetActualWs(hvo, spec.StringFlid, spec.WritingSystem);
										DisplayWordform(vwenv, ws, ispec);
										break;
									case InterlinLineChoices.kflidWordGloss:
										DisplayWordGloss(vwenv, hvo, spec.WritingSystem, ispec);
										break;
									case InterlinLineChoices.kflidWordPos:
										DisplayWordPOS(vwenv, hvo, spec.WritingSystem, ispec);
										break;
								}
								ispec++;
							}
							vwenv.CloseInnerPile();

							vwenv.CloseParagraph();
							vwenv.CloseInnerPile();

							vwenv.CloseParagraph();
							vwenv.CloseDiv();
							break;
						case kfragFirstMorph: // first morpheme in word
						case kfragMorph: // The bundle of 4 lines representing a morpheme.
							vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
								(int)FwTextPropVar.ktpvMilliPoint, 10000);
							vwenv.OpenInnerPile();
							for (int ispec = m_choices.FirstMorphemeIndex; ispec <= m_choices.LastMorphemeIndex; ispec++)
							{
								int tagLexEntryIcon = 0;
								if (m_choices.FirstLexEntryIndex == ispec)
									tagLexEntryIcon = ktagMorphEntryIcon;
								InterlinLineSpec spec = m_choices[ispec];
								switch (spec.Flid)
								{
									case InterlinLineChoices.kflidMorphemes:
										DisplayMorphForm(vwenv, hvo, frag, spec.WritingSystem, ispec);
										break;
									case InterlinLineChoices.kflidLexEntries:
										AddOptionalNamedObj(vwenv, hvo, ktagSbMorphEntry, ktagMissingEntry,
											kfragMissingEntry, tagLexEntryIcon, spec.WritingSystem, ispec);
										break;
									case InterlinLineChoices.kflidLexGloss:
										AddOptionalNamedObj(vwenv, hvo, ktagSbMorphGloss, ktagMissingMorphGloss,
											kfragMissingMorphGloss, tagLexEntryIcon, spec.WritingSystem, ispec);
										break;
									case InterlinLineChoices.kflidLexPos:
										AddOptionalNamedObj(vwenv, hvo, ktagSbMorphPos, ktagMissingMorphPos,
											kfragMissingMorphPos, tagLexEntryIcon, spec.WritingSystem, ispec);
										break;
								}
							}
							vwenv.CloseInnerPile();

							break;
						default:
							if (frag >= kfragNamedObjectNameChoices && frag < kfragNamedObjectNameChoices + m_choices.Count)
							{
								InterlinLineSpec spec = m_choices[frag - kfragNamedObjectNameChoices];
								int wsActual = GetActualWs(hvo, ktagSbNamedObjName, spec.WritingSystem);
								vwenv.AddStringAltMember(ktagSbNamedObjName, wsActual, this);
							}
							else
							{
								throw new Exception("Bad fragment ID in SandboxVc.Display");
							}
							break;
					}
				}
				catch
				{
					Debug.Assert(false, "Exception thrown in the display of the SandboxVc (About to be eaten)");
				}
			}
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			TriggerDisplay(vwenv);

			// We use a table to display
			// encodings in column one and the strings in column two.
			// The table uses 100% of the available width.
			VwLength vlTable;
			vlTable.nVal = 10000;
			vlTable.unit = VwUnit.kunPercent100;

			// The width of the writing system column is determined from the width of the
			// longest one which will be displayed.
			m_mDxmpLabelWidth = 0;
			for (int i = 0; i < m_rgws.Count; ++i)
			{
				int dxs;	// Width of displayed string.
				int dys;	// Height of displayed string (not used here).

				// Set qtss to a string representing the writing system.
				vwenv.get_StringWidth(NameOfWs(i), m_ttpLabel, out dxs, out dys);
				m_mDxmpLabelWidth = Math.Max(m_mDxmpLabelWidth, dxs);
			}
			VwLength vlColWs; // 5-pt space plus max label width.
			vlColWs.nVal = m_mDxmpLabelWidth + 5000;
			vlColWs.unit = VwUnit.kunPoint1000;

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

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

			vwenv.OpenTable(2, // Two columns.
				vlTable, // Table uses 100% of available width.
				0, // Border thickness.
				VwAlignment.kvaLeft, // Default alignment.
				VwFramePosition.kvfpVoid, // No border.
				VwRule.kvrlNone, // No rules between cells.
				0, // No forced space between cells.
				0, // No padding inside cells.
				false);
			// Specify column widths. The first argument is the number of columns,
			// not a column index. The writing system column only occurs at all if its
			// width is non-zero.
			vwenv.MakeColumns(1, vlColWs);
			vwenv.MakeColumns(1, vlColMain);

			vwenv.OpenTableBody();
			var visibleWss = new Set<ILgWritingSystem>();
			// if we passed in a view and have WritingSystemsToDisplay
			// then we'll load that list in order to filter our larger m_rgws list.
			AddViewWritingSystems(visibleWss);
			for (int i = 0; i < m_rgws.Count; ++i)
			{
				if (SkipEmptyWritingSystem(visibleWss, i, hvo))
					continue;
				vwenv.OpenTableRow();

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

				// Second cell has the string contents for the alternative.
				// DN version has some property setting, including trailing margin and
				// RTL.
				if (m_rgws[i].RightToLeftScript)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
						(int)FwTextPropVar.ktpvEnum,
						(int)FwTextToggleVal.kttvForceOn);
					vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
						(int)FwTextPropVar.ktpvEnum,
						(int)FwTextAlign.ktalTrailing);
				}
				if (!m_editable)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
				}
				vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
				vwenv.OpenTableCell(1,1);
				var wsdef = m_rgws[i] as WritingSystemDefinition;
				if (wsdef != null && wsdef.IsVoice)
				{
					// We embed it in a conc paragraph to ensure it never takes more than a line.
					// It will typically be covered up by a sound control.
					// Also set foreground color to match the window, so nothing shows even if the sound doesn't overlap it perfectly.
					// (transparent does not seem to work as a foreground color)
					vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Window)));
					// Must not spell-check a conc para, leads to layout failures when the paragraph tries to cast the source to
					// a conc text source, if it is overridden by a spelling text source.
					vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck);
					vwenv.OpenConcPara(0, 1, VwConcParaOpts.kcpoDefault, 0);
					vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this);
					vwenv.CloseParagraph();
				}
				else
				{
					if (!string.IsNullOrEmpty(TextStyle))
					{
						vwenv.set_StringProperty((int) FwTextPropType.ktptNamedStyle, TextStyle);

					}
					vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this);
				}
				vwenv.CloseTableCell();

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

			vwenv.CloseTable();
		}
示例#19
0
文件: StVc.cs 项目: sillsdev/WorldPad
        /// -----------------------------------------------------------------------------------
        /// <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;
            }
        }
示例#20
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				switch(frag)
				{
					case (int)VcFrags.kfragName: // Use the name for both name and short name.
					case (int)VcFrags.kfragShortName:
					default:
						int wsUi = vwenv.DataAccess.WritingSystemFactory.UserWs;
						vwenv.AddStringAltMember(m_flidName, wsUi, this);
						break;
				}
			}
示例#21
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;
            }
        }
示例#22
0
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			ITsStrFactory tsf = null;
			switch (frag)
			{
				case kfragStText: // The whole text, root object for the InterlinDocChild.
					if (hvo == 0)
						return;		// What if the user deleted all the texts?  See LT-6727.
					IStText stText = m_coRepository.GetObject(hvo) as IStText;
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvDefault,
						(int)TptEditable.ktptNotEditable);
					vwenv.OpenDiv();
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 6000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
						(int)FwTextPropVar.ktpvMilliPoint, 24000);
					// Add both vernacular and analysis if we have them (LT-5561).
					bool fAddedVernacular = false;
					int wsVernTitle = 0;
					//
					if (stText.Title.TryWs(WritingSystemServices.kwsFirstVern, out wsVernTitle))
					{
						vwenv.OpenParagraph();
						vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this);
						vwenv.CloseParagraph();
						fAddedVernacular = true;
					}
					int wsAnalysisTitle = 0;
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					vwenv.OpenParagraph();
					ITsString tssAnal;
					if (stText.Title.TryWs(WritingSystemServices.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) &&
						!tssAnal.Equals(stText.Title.BestVernacularAlternative))
					{
						if (fAddedVernacular)
						{
							// display analysis title at smaller font size.
							vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
								(int)FwTextPropVar.ktpvMilliPoint, 12000);
						}
						vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this);
					}
					else
					{
						// just add a blank title.
						tsf = TsStrFactoryClass.Create();
						ITsString blankTitle = tsf.MakeString("", m_wsAnalysis);
						vwenv.AddString(blankTitle);
					}
					vwenv.CloseParagraph();
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					int wsSource = 0;
					if (stText.Source.TryWs(WritingSystemServices.kwsFirstVernOrAnal, out wsSource))
					{
						vwenv.OpenParagraph();
						vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
							(int)FwTextPropVar.ktpvMilliPoint, 12000);
						vwenv.AddStringAltMember(vtagStTextSource, wsSource, this);
						vwenv.CloseParagraph();
					}
					else
					{
						// just add a blank source.
						tsf = TsStrFactoryClass.Create();
						ITsString tssBlank = tsf.MakeString("", m_wsAnalysis);
						vwenv.AddString(tssBlank);
					}
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					vwenv.OpenParagraph();
					if (stText.OwningFlid == TextTags.kflidContents)
					{
						vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription);
					}
					vwenv.CloseParagraph();
					base.Display(vwenv, hvo, frag);
					vwenv.CloseDiv();
					break;
				case kfragTextDescription:
					vwenv.AddStringAltMember(CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
					break;
				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
			private void DisplayWordform(IVwEnv vwenv, int ws, int choiceIndex)
			{
				// For the wordform line we only want an icon on the first line (which is always wordform).
				bool fWantIcon = m_sandbox.ShowAnalysisCombo && choiceIndex == 0;
				// This has to be BEFORE we open the paragraph, so the indent applies to the whole
				// paragraph, and not some string box inside it.
				if (!fWantIcon)
					SetIndentForMissingIcon(vwenv);
				vwenv.OpenParagraph();
				// The actual icon, if present, has to be INSIDE the paragraph.
				if (fWantIcon)
					AddPullDownIcon(vwenv, ktagAnalysisIcon);
				//Set the background of the wordform to the 'WordFormBGColor' which is set when ChangeOrCreateSandbox
				//is called
				SetBGColor(vwenv, MultipleOptionBGColor);
				if (ws != m_sandbox.RawWordformWs)
				{
					// Any other Ws we can edit.
					MakeNextFlowObjectEditable(vwenv);
					vwenv.OpenInnerPile(); // So white background occupies full width
					vwenv.AddStringAltMember(ktagSbWordForm, ws, this);
					vwenv.CloseInnerPile();
				}
				else
				{
					MakeNextFlowObjectReadOnly(vwenv);
					//vwenv.AddString(m_sandbox.RawWordform);
					vwenv.AddStringAltMember(ktagSbWordForm, ws, this);
				}
				vwenv.CloseParagraph();
			}
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				ISilDataAccess da = vwenv.DataAccess;
				switch (frag)
				{
					default:
					{
						Debug.Assert(false, "Unrecognized fragment.");
						break;
					}
					case ReversalIndexEntrySliceView.kFragMainObject:
					{
						// The hvo here is for the sense.

						// We use a table to display
						// encodings in column one and the strings in column two.
						// The table uses 100% of the available width.
						VwLength vlTable;
						vlTable.nVal = 10000;
						vlTable.unit = VwUnit.kunPercent100;
						// The width of the writing system column is determined from the width of the
						// longest one which will be displayed.
						int dxs;	// Width of displayed string.
						int dys;	// Height of displayed string (not used here).
						int dxsMax = 0;	// Max width required.
						ISilDataAccess silDaCache = vwenv.DataAccess;
						IVwCacheDa vwCache = silDaCache as IVwCacheDa;
						foreach (IReversalIndex idx in m_usedIndices)
						{
							vwenv.get_StringWidth(silDaCache.get_StringProp(idx.WritingSystemRAHvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr),
								m_ttpLabel,
								out dxs,
								out dys);
							dxsMax = Math.Max(dxsMax, dxs);
						}
						VwLength vlColWs; // 5-pt space plus max label width.
						vlColWs.nVal = dxsMax + 5000;
						vlColWs.unit = VwUnit.kunPoint1000;
						// Enhance JohnT: possibly allow for right-to-left UI by reversing columns?
						// The Main column is relative and uses the rest of the space.
						VwLength vlColMain;
						vlColMain.nVal = 1;
						vlColMain.unit = VwUnit.kunRelative;

						vwenv.OpenTable(2, // Two columns.
							vlTable, // Table uses 100% of available width.
							0, // Border thickness.
							VwAlignment.kvaLeft, // Default alignment.
							VwFramePosition.kvfpVoid, // No border.
							VwRule.kvrlNone, // No rules between cells.
							0, // No forced space between cells.
							0, // No padding inside cells.
							false);
						// Specify column widths. The first argument is the number of columns,
						// not a column index. The writing system column only occurs at all if its
						// width is non-zero.
						vwenv.MakeColumns(1, vlColWs);
						vwenv.MakeColumns(1, vlColMain);

						vwenv.OpenTableBody();
						// Do vector of rows. Each row essentially is a reversal index, but shows other information.
						vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidIndices, this, ReversalIndexEntrySliceView.kFragIndices);
						vwenv.CloseTableBody();
						vwenv.CloseTable();
						break;
					}
					case ReversalIndexEntrySliceView.kFragIndexMain:
					{
						// First cell has writing system abbreviation displayed using m_ttpLabel.
						int wsHvo = 0;
						foreach (ReversalIndex idx in m_usedIndices)
						{
							if (idx.Hvo == hvo)
							{
								wsHvo = idx.WritingSystemRAHvo;
								break;
							}
						}
						Debug.Assert(wsHvo > 0, "Could not find writing system.");

						int wsOldDefault = this.DefaultWs;
						this.DefaultWs = wsHvo;

						// Cell 1 shows the ws abbreviation.
						vwenv.OpenTableCell(1,1);
						vwenv.Props = m_ttpLabel;
						vwenv.AddObj(wsHvo, this, ReversalIndexEntrySliceView.kFragWsAbbr);
						vwenv.CloseTableCell();

						// Second cell has the contents for the reversal entries.
						vwenv.OpenTableCell(1,1);
						// This displays the field flush right for RTL data, but gets arrow keys to
						// behave reasonably.  See comments on LT-5287.
						IWritingSystem lgws = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(this.DefaultWs);
						if (lgws != null && lgws.RightToLeft)
						{
							vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
								(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
						}
						vwenv.OpenParagraph();
						// Do vector of entries in the second column.
						vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidEntries, this, ReversalIndexEntrySliceView.kFragEntries);
						vwenv.CloseParagraph();
						vwenv.CloseTableCell();

						this.DefaultWs = wsOldDefault;
						break;
					}
					case ReversalIndexEntrySliceView.kFragEntryForm:
					{
						vwenv.AddStringAltMember((int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm,
							this.DefaultWs, this);
						int hvoCurrent = vwenv.CurrentObject();
						if (hvoCurrent > 0)
						{
							IReversalIndexEntry rie = ReversalIndexEntry.CreateFromDBObject(m_cache, hvoCurrent);
							Debug.Assert(rie != null);
							int[] rgWs = m_cache.LangProject.GetReversalIndexWritingSystems(rie.Hvo, false);
							int wsAnal = m_cache.DefaultAnalWs;
							ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
							tisb.SetIntPropValues((int)FwTextPropType.ktptWs,
								(int)FwTextPropVar.ktpvDefault, wsAnal);
							tisb.SetIntPropValues((int)FwTextPropType.ktptEditable,
								(int)FwTextPropVar.ktpvEnum,
								(int)TptEditable.ktptNotEditable);
							tisb.Append(" [");
							int cstr = 0;
							ITsTextProps ttpBase = null;
							for (int i = 0; i < rgWs.Length; ++i)
							{
								int ws = rgWs[i];
								if (ws == this.DefaultWs)
									continue;
								string sForm = rie.ReversalForm.GetAlternative(ws);
								if (sForm != null && sForm.Length != 0)
								{
									if (cstr > 0)
										tisb.Append(", ");
									++cstr;
									string sWs = m_cache.GetMultiUnicodeAlt(ws,
										(int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, wsAnal,
										"LgWritingSystem_Abbr");
									if (sWs != null && sWs.Length != 0)
									{
										ITsString tssWs = m_tsf.MakeStringWithPropsRgch(sWs, sWs.Length, m_ttpLabel);
										tisb.AppendTsString(tssWs);
										// We have to totally replace the properties set by m_ttpLabel.  The
										// simplest way is to create another ITsString with the simple base
										// property of only the default analysis writing system.
										if (ttpBase == null)
										{
											ITsPropsBldr tpbBase = TsPropsBldrClass.Create();
											tpbBase.SetIntPropValues((int)FwTextPropType.ktptWs,
												(int)FwTextPropVar.ktpvDefault, wsAnal);
											ttpBase = tpbBase.GetTextProps();
										}
										ITsString tssSpace = m_tsf.MakeStringWithPropsRgch(" ", 1, ttpBase);
										tisb.AppendTsString(tssSpace);
									}
									tisb.SetIntPropValues((int)FwTextPropType.ktptWs,
										(int)FwTextPropVar.ktpvDefault, ws);
									tisb.Append(sForm);
									tisb.SetIntPropValues((int)FwTextPropType.ktptWs,
										(int)FwTextPropVar.ktpvDefault, wsAnal);
								}
							}
							if (cstr > 0)
							{
								tisb.Append("]");
								ITsString tss = tisb.GetString();
								vwenv.AddString(tss);
							}
						}
						break;
					}
					case ReversalIndexEntrySliceView.kFragWsAbbr:
					{
						vwenv.AddString(da.get_StringProp(hvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr));
						break;
					}
				}
			}
示例#25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display a view of the LexEntry (or fragment thereof).
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case (int)VcFrags.kfragHeadWord:
                // This case should stay in sync with
                // LexEntry.LexemeFormMorphTypeAndHomographStatic
                vwenv.OpenParagraph();
                AddHeadwordWithHomograph(vwenv, hvo);
                vwenv.CloseParagraph();
                break;

            case kfragEntryAndVariant:
                var wfb = m_cache.ServiceLocator.GetInstance <IWfiMorphBundleRepository>().GetObject(hvo);
                //int hvoMf = wfb.MorphRA.Hvo;
                //int hvoLexEntry = m_cache.GetOwnerOfObject(hvoMf);
                // if morphbundle morph (entry) is in a variant relationship to the morph bundle sense
                // display its entry headword and variant type information (LT-4053)
                ILexEntryRef ler;
                var          variant = wfb.MorphRA.Owner as ILexEntry;
                if (variant.IsVariantOfSenseOrOwnerEntry(wfb.SenseRA, out ler))
                {
                    // build Headword from sense's entry
                    vwenv.OpenParagraph();
                    vwenv.OpenInnerPile();
                    vwenv.AddObj(wfb.SenseRA.EntryID, this, (int)VcFrags.kfragHeadWord);
                    vwenv.CloseInnerPile();
                    vwenv.OpenInnerPile();
                    // now add variant type info
                    vwenv.AddObj(ler.Hvo, this, kfragVariantTypes);
                    vwenv.CloseInnerPile();
                    vwenv.CloseParagraph();
                    break;
                }

                // build Headword even though we aren't in a variant relationship.
                vwenv.AddObj(variant.Hvo, this, (int)VcFrags.kfragHeadWord);
                break;

            case kfragVariantTypes:
                ler = m_cache.ServiceLocator.GetInstance <ILexEntryRefRepository>().GetObject(hvo);
                bool fNeedInitialPlus = true;
                vwenv.OpenParagraph();
                foreach (var let in ler.VariantEntryTypesRS.Where(let => let.ClassID == LexEntryTypeTags.kClassId))
                {
                    // just concatenate them together separated by comma.
                    ITsString tssVariantTypeRevAbbr = let.ReverseAbbr.BestAnalysisAlternative;
                    if (tssVariantTypeRevAbbr != null && tssVariantTypeRevAbbr.Length > 0)
                    {
                        if (fNeedInitialPlus)
                        {
                            vwenv.AddString(TsStringUtils.MakeString("+", m_cache.DefaultUserWs));
                        }
                        else
                        {
                            vwenv.AddString(TsStringUtils.MakeString(",", m_cache.DefaultUserWs));
                        }
                        vwenv.AddString(tssVariantTypeRevAbbr);
                        fNeedInitialPlus = false;
                    }
                }
                vwenv.CloseParagraph();
                break;

            case kfragFormForm:                     // form of MoForm
                vwenv.AddStringAltMember(MoFormTags.kflidForm, m_wsActual, this);
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
示例#26
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            TriggerDisplay(vwenv);

            // We use a table to display
            // encodings in column one and the strings in column two.
            // The table uses 100% of the available width.
            VwLength vlTable;

            vlTable.nVal = 10000;
            vlTable.unit = VwUnit.kunPercent100;

            // The width of the writing system column is determined from the width of the
            // longest one which will be displayed.
            m_mDxmpLabelWidth = 0;
            for (int i = 0; i < m_rgws.Count; ++i)
            {
                int dxs;                        // Width of displayed string.
                int dys;                        // Height of displayed string (not used here).

                // Set qtss to a string representing the writing system.
                vwenv.get_StringWidth(NameOfWs(i), m_ttpLabel, out dxs, out dys);
                m_mDxmpLabelWidth = Math.Max(m_mDxmpLabelWidth, dxs);
            }
            VwLength vlColWs;             // 5-pt space plus max label width.

            vlColWs.nVal = m_mDxmpLabelWidth + 5000;
            vlColWs.unit = VwUnit.kunPoint1000;

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

            // The Main column is relative and uses the rest of the space.
            VwLength vlColMain;

            vlColMain.nVal = 1;
            vlColMain.unit = VwUnit.kunRelative;

            vwenv.OpenTable(2,                        // Two columns.
                            vlTable,                  // Table uses 100% of available width.
                            0,                        // Border thickness.
                            VwAlignment.kvaLeft,      // Default alignment.
                            VwFramePosition.kvfpVoid, // No border.
                            VwRule.kvrlNone,          // No rules between cells.
                            0,                        // No forced space between cells.
                            0,                        // No padding inside cells.
                            false);
            // Specify column widths. The first argument is the number of columns,
            // not a column index. The writing system column only occurs at all if its
            // width is non-zero.
            vwenv.MakeColumns(1, vlColWs);
            vwenv.MakeColumns(1, vlColMain);

            vwenv.OpenTableBody();
            var visibleWss = new HashSet <ILgWritingSystem>();

            // if we passed in a view and have WritingSystemsToDisplay
            // then we'll load that list in order to filter our larger m_rgws list.
            AddViewWritingSystems(visibleWss);
            for (int i = 0; i < m_rgws.Count; ++i)
            {
                if (SkipEmptyWritingSystem(visibleWss, i, hvo))
                {
                    continue;
                }
                vwenv.OpenTableRow();

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

                // Second cell has the string contents for the alternative.
                // DN version has some property setting, including trailing margin and
                // RTL.
                if (m_rgws[i].RightToLeftScript)
                {
                    vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                          (int)FwTextPropVar.ktpvEnum,
                                          (int)FwTextToggleVal.kttvForceOn);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                          (int)FwTextPropVar.ktpvEnum,
                                          (int)FwTextAlign.ktalTrailing);
                }
                if (!m_editable)
                {
                    vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                          (int)TptEditable.ktptNotEditable);
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
                vwenv.OpenTableCell(1, 1);
                CoreWritingSystemDefinition wsdef = m_rgws[i];
                if (wsdef != null && wsdef.IsVoice)
                {
                    // We embed it in a conc paragraph to ensure it never takes more than a line.
                    // It will typically be covered up by a sound control.
                    // Also set foreground color to match the window, so nothing shows even if the sound doesn't overlap it perfectly.
                    // (transparent does not seem to work as a foreground color)
                    vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                          (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Window)));
                    // Must not spell-check a conc para, leads to layout failures when the paragraph tries to cast the source to
                    // a conc text source, if it is overridden by a spelling text source.
                    vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck);
                    vwenv.OpenConcPara(0, 1, VwConcParaOpts.kcpoDefault, 0);
                    vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this);
                    vwenv.CloseParagraph();
                }
                else
                {
                    if (!string.IsNullOrEmpty(TextStyle))
                    {
                        vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle);
                    }
                    vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this);
                }
                vwenv.CloseTableCell();

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

            vwenv.CloseTable();
        }
示例#27
0
        private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo)
        {
            ISilDataAccess sda   = vwenv.DataAccess;
            int            hvoLf = sda.get_ObjectProp(hvo,
                                                      LexEntryTags.kflidLexemeForm);
            int hvoType = 0;

            if (hvoLf != 0)
            {
                hvoType = sda.get_ObjectProp(hvoLf,
                                             MoFormTags.kflidMorphType);
            }

            // If we have a type of morpheme, show the appropriate prefix that indicates it.
            // We want vernacular so it will match the point size of any aligned vernacular text.
            // (The danger is that the vernacular font doesn't have these characters...not sure what
            // we can do about that, but most do, and it looks awful in analysis if that is a
            // much different size from vernacular.)
            string sPrefix = null;

            if (hvoType != 0)
            {
                sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix);
            }

            // Show homograph number if non-zero.
            int defUserWs  = m_cache.WritingSystemFactory.UserWs;
            int nHomograph = sda.get_IntProp(hvo, LexEntryTags.kflidHomographNumber);
            var hc         = m_cache.ServiceLocator.GetInstance <HomographConfiguration>();

            //Insert HomographNumber when position is Before
            if (hc.HomographNumberBefore)
            {
                InsertHomographNumber(vwenv, hc, nHomograph, defUserWs);
            }

            // LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form.
            bool fGotLabel = false;
            int  wsActual  = 0;

            if (hvoLf != 0)
            {
                // if we have a lexeme form and its label is non-empty, use it.
                if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual))
                {
                    m_wsActual = wsActual;
                    fGotLabel  = true;
                    if (sPrefix != null)
                    {
                        vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual));
                    }
                    vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm);
                }
            }
            if (!fGotLabel)
            {
                // If we didn't get a useful form from the lexeme form try the citation form.
                if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual))
                {
                    m_wsActual = wsActual;
                    if (sPrefix != null)
                    {
                        vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual));
                    }
                    vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this);
                    fGotLabel = true;
                }
            }

            if (!fGotLabel)
            {
                // If that fails just show two questions marks.
                if (sPrefix != null)
                {
                    vwenv.AddString(TsStringUtils.MakeString(sPrefix, wsActual));
                }
                vwenv.AddString(TsStringUtils.MakeString(FdoUiStrings.ksQuestions, defUserWs));                                 // was "??", not "???"
            }

            // If we have a lexeme form type show the appropriate postfix.
            if (hvoType != 0)
            {
                vwenv.AddString(TsStringUtils.MakeString(
                                    sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual));
            }

            vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1);
            //Insert HomographNumber when position is After
            if (!hc.HomographNumberBefore)
            {
                InsertHomographNumber(vwenv, hc, nHomograph, defUserWs);
            }
        }
示例#28
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);
		}
示例#29
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				if (hvo == 0)
					return;

				int wsAnal = DefaultWs;
				ITsStrFactory tsf = m_cache.TsStrFactory;
				ICmObject co;
				switch (frag)
				{
					case (int)VcFrags.kfragHeadWord:
						co = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo);
						var le = co as ILexEntry;
						vwenv.AddString(le != null ? le.HeadWord : tsf.MakeString(co.ShortName, wsAnal));
						break;
					case (int)VcFrags.kfragShortName:
						co = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo);
						vwenv.AddString(tsf.MakeString(co.ShortName, wsAnal));
						break;
					case (int)VcFrags.kfragPosAbbrAnalysis:
						vwenv.AddStringAltMember(CmPossibilityTags.kflidAbbreviation, wsAnal, this);
						break;
					default:
						co = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo);
						vwenv.AddString(tsf.MakeString(co.ToString(), wsAnal));
						break;
				}
			}
示例#30
0
		private void DisplayMorphForm(IVwEnv vwenv, int hvo, int ws)
		{
			var mf = (IMoForm)m_coRepository.GetObject(hvo);
			// The form of an MoForm. Hvo is some sort of MoMorph. Display includes its prefix
			// and suffix.
			// Todo: make prefix and suffix read-only.
			vwenv.OpenParagraph(); // group prefix, form, suffix on one line.
			// It may not have a morph type at all.
			// RBR says: "So why take the chance of a null ref exception (which I ran into, in my ZPI data, of course)? :-)
			// int typeID = mf.MorphTypeRA.Hvo;
			var morphType = mf.MorphTypeRA;
			if (morphType != null)
				vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPrefix);
			vwenv.AddStringAltMember(MoFormTags.kflidForm,
				ws, this);
			if (morphType != null)
				vwenv.AddObjProp(MoFormTags.kflidMorphType, this, kfragPostfix);
			vwenv.CloseParagraph();
		}
示例#31
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				int wsUi = vwenv.DataAccess.WritingSystemFactory.UserWs;
				vwenv.AddStringAltMember(m_flidName, wsUi, this);
			}
            public override void Display(IVwEnv vwenv, int hvo, int frag)
            {
                CheckDisposed();

                try
                {
                    switch (frag)
                    {
                    case kfragBundle:                             // One annotated word bundle, in this case, the whole view.
                        if (hvo == 0)
                        {
                            return;
                        }
                        vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum,
                                              (int)SpellingModes.ksmDoNotCheck);
                        vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
                                              (int)FwTextPropVar.ktpvDefault, krgbBackground);
                        vwenv.OpenDiv();
                        vwenv.OpenParagraph();
                        // Since embedded in a pile with context, we need another layer of pile here,.
                        // It's an overlay sandbox: draw a box around it.
                        vwenv.OpenInnerPile();
                        // Inside that division we need a paragraph which does not have any border
                        // or background. This suppresses the 'infinite width' behavior for the
                        // nested paragraphs that may have grey border.
                        vwenv.OpenParagraph();

                        // This makes a little separation between left border and arrows.
                        vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
                                              (int)FwTextPropVar.ktpvMilliPoint, 1000);
                        if (m_fRtl)
                        {
                            // This must not be on the outer paragraph or we get infinite width behavior.
                            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.OpenInnerPile();
                        for (int ispec = 0; ispec < m_choices.Count;)
                        {
                            InterlinLineSpec spec = m_choices[ispec];
                            if (!spec.WordLevel)
                            {
                                break;
                            }
                            if (spec.MorphemeLevel)
                            {
                                DisplayMorphBundles(vwenv, hvo);
                                ispec = m_choices.LastMorphemeIndex + 1;
                                continue;
                            }
                            switch (spec.Flid)
                            {
                            case InterlinLineChoices.kflidWord:
                                int ws = GetActualWs(hvo, spec.StringFlid, spec.WritingSystem);
                                DisplayWordform(vwenv, ws, ispec);
                                break;

                            case InterlinLineChoices.kflidWordGloss:
                                DisplayWordGloss(vwenv, hvo, spec.WritingSystem, ispec);
                                break;

                            case InterlinLineChoices.kflidWordPos:
                                DisplayWordPOS(vwenv, hvo, spec.WritingSystem, ispec);
                                break;
                            }
                            ispec++;
                        }
                        vwenv.CloseInnerPile();

                        vwenv.CloseParagraph();
                        vwenv.CloseInnerPile();

                        vwenv.CloseParagraph();
                        vwenv.CloseDiv();
                        break;

                    case kfragFirstMorph:                        // first morpheme in word
                    case kfragMorph:                             // The bundle of 4 lines representing a morpheme.
                        vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
                                              (int)FwTextPropVar.ktpvMilliPoint, 10000);
                        vwenv.OpenInnerPile();
                        for (int ispec = m_choices.FirstMorphemeIndex; ispec <= m_choices.LastMorphemeIndex; ispec++)
                        {
                            int tagLexEntryIcon = 0;
                            if (m_choices.FirstLexEntryIndex == ispec)
                            {
                                tagLexEntryIcon = ktagMorphEntryIcon;
                            }
                            InterlinLineSpec spec = m_choices[ispec];
                            switch (spec.Flid)
                            {
                            case InterlinLineChoices.kflidMorphemes:
                                DisplayMorphForm(vwenv, hvo, frag, spec.WritingSystem, ispec);
                                break;

                            case InterlinLineChoices.kflidLexEntries:
                                AddOptionalNamedObj(vwenv, hvo, ktagSbMorphEntry, ktagMissingEntry,
                                                    kfragMissingEntry, tagLexEntryIcon, spec.WritingSystem, ispec);
                                break;

                            case InterlinLineChoices.kflidLexGloss:
                                AddOptionalNamedObj(vwenv, hvo, ktagSbMorphGloss, ktagMissingMorphGloss,
                                                    kfragMissingMorphGloss, tagLexEntryIcon, spec.WritingSystem, ispec);
                                break;

                            case InterlinLineChoices.kflidLexPos:
                                AddOptionalNamedObj(vwenv, hvo, ktagSbMorphPos, ktagMissingMorphPos,
                                                    kfragMissingMorphPos, tagLexEntryIcon, spec.WritingSystem, ispec);
                                break;
                            }
                        }
                        vwenv.CloseInnerPile();

                        break;

                    default:
                        if (frag >= kfragNamedObjectNameChoices && frag < kfragNamedObjectNameChoices + m_choices.Count)
                        {
                            InterlinLineSpec spec = m_choices[frag - kfragNamedObjectNameChoices];
                            int wsActual          = GetActualWs(hvo, ktagSbNamedObjName, spec.WritingSystem);
                            vwenv.AddStringAltMember(ktagSbNamedObjName, wsActual, this);
                        }
                        else
                        {
                            throw new Exception("Bad fragment ID in SandboxVc.Display");
                        }
                        break;
                    }
                }
                catch
                {
                    Debug.Assert(false, "Exception thrown in the display of the SandboxVc (About to be eaten)");
                }
            }
示例#33
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				switch (frag)
				{
					case (int)VcFrags.kfragShortName:
						int wsUi = vwenv.DataAccess.WritingSystemFactory.UserWs;
						vwenv.AddStringAltMember(m_flidAbbr, wsUi, this);
						break;
					default:
						base.Display(vwenv, hvo, frag);
						break;
				}
			}
示例#34
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;
            }
        }
示例#35
0
		private void DisplayMissingMarker(IVwEnv vwenv)
		{
			vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment,
									 m_cache.DefaultUserWs, this);
		}
示例#36
0
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			ITsStrFactory tsf = null;
			switch (frag)
			{
				case kfragStText: // The whole text, root object for the InterlinDocChild.
					if (hvo == 0)
						return;		// What if the user deleted all the texts?  See LT-6727.
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvDefault,
						(int)TptEditable.ktptNotEditable);
					vwenv.OpenDiv();
					StText stText = new StText(m_cache, hvo);
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 6000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
						(int)FwTextPropVar.ktpvMilliPoint, 24000);
					// Add both vernacular and analysis if we have them (LT-5561).
					bool fAddedVernacular = false;
					int wsVernTitle = 0;
					//
					if (stText.Title.TryWs(LangProject.kwsFirstVern, out wsVernTitle))
					{
						vwenv.OpenParagraph();
						vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this);
						vwenv.CloseParagraph();
						fAddedVernacular = true;
					}
					int wsAnalysisTitle = 0;
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					vwenv.OpenParagraph();
					ITsString tssAnal;
					if (stText.Title.TryWs(LangProject.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) &&
						!tssAnal.Equals(stText.Title.BestVernacularAlternative))
					{
						if (fAddedVernacular)
						{
							// display analysis title at smaller font size.
							vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
								(int)FwTextPropVar.ktpvMilliPoint, 12000);
						}
						vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this);
					}
					else
					{
						// just add a blank title.
						tsf = TsStrFactoryClass.Create();
						ITsString blankTitle = tsf.MakeString("", m_wsAnalysis);
						vwenv.AddString(blankTitle);
					}
					vwenv.CloseParagraph();
					int wsSource = 0;
					ITsString tssSource = stText.SourceOfTextForWs(m_wsVernForDisplay);
					if (tssSource == null || tssSource.Length == 0)
					{
						tssSource = stText.SourceOfTextForWs(m_wsAnalysis);
						if (tssSource != null && tssSource.Length > 0)
							wsSource = m_wsAnalysis;
					}
					else
					{
						wsSource = m_wsVernForDisplay;
					}
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					if (tssSource != null && tssSource.Length > 0)
					{
						vwenv.OpenParagraph();
						vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
							(int)FwTextPropVar.ktpvMilliPoint, 12000);
						vwenv.AddStringAltMember(vtagStTextSource, wsSource, this);
						vwenv.CloseParagraph();
					}
					else
					{
						// just add a blank source.
						tsf = TsStrFactoryClass.Create();
						ITsString tssBlank = tsf.MakeString("", m_wsAnalysis);
						vwenv.AddString(tssBlank);
					}
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 10000);
					vwenv.OpenParagraph();
					if (stText.OwningFlid == (int)Text.TextTags.kflidContents)
					{
						vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription);
					}
					vwenv.CloseParagraph();
					base.Display(vwenv, hvo, frag);
					vwenv.CloseDiv();
					break;
				case kfragTextDescription:
					vwenv.AddStringAltMember((int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
					break;
				case kfragSegFf: // One freeform annotation.
					int[] wssAnalysis = m_WsList.AnalysisWsIds;
					if (wssAnalysis.Length == 0)
						break; // This is bizarre, but for the sake of paranoia...
					tsf = TsStrFactoryClass.Create();
					int hvoType = m_cache.MainCacheAccessor.get_ObjectProp(hvo, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType);
					string label = "";
					if (hvoType == NoteSegmentDefn)
						label = ITextStrings.ksNt;
					else if (hvoType == FtSegmentDefn)
						label = ITextStrings.ksFT;
					else if (hvoType == LtSegmentDefn)
						label = ITextStrings.ksLT;
					else
						throw new Exception("Unexpected FF annotation type");
					ITsString tssLabel = tsf.MakeString(label, m_cache.DefaultUserWs);
					ISilDataAccess sda = vwenv.DataAccess;
					if (wssAnalysis.Length == 1)
					{
						ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs);
						if (tss.Length == 0)
							break;
						vwenv.OpenParagraph();
						vwenv.AddString(tssLabel);
						vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs, this);
						vwenv.CloseParagraph();
					}
					else
					{
						int labelWidth, labelHeight;
						vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight);
						// This roughly corresponds to the width of the space at the end of FT.
						// The nice way to do it (here and in the base class) would be a table or 'interlinear' paragraph.
						labelWidth += 3000;
						int cNonBlank = 0;
						for (int i = 0; i < wssAnalysis.Length; i++)
						{
							ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i]);
							if (tss.Length == 0)
								continue;
							if (cNonBlank != 0)
							{
								// Indent subsequent paragraphs by the width of the main label.
								vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
									(int) FwTextPropVar.ktpvMilliPoint, labelWidth);
							}
							vwenv.OpenParagraph();
							if (cNonBlank == 0)
								vwenv.AddString(tssLabel);
							cNonBlank++; // after tests above!
							m_WsList.AddWsLabel(vwenv, i);
							vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i], this);
							vwenv.CloseParagraph();
						}
					}
					break;
				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case kfragRoot: // the root; Display the paragraph
					using (new VwConstructorServices.ParagraphBoxHelper(vwenv,
							() =>
								{
									if (m_displayOptions.ReadOnlyView)
									{
										vwenv.set_IntProperty(
										(int)FwTextPropType.ktptEditable,
										(int)FwTextPropVar.ktpvEnum,
										(int)TptEditable.ktptNotEditable);
									}
								}))
					{
						if (m_displayOptions.LiteralStringLabels)
						{
							using (new VwConstructorServices.InnerPileHelper(vwenv))
							{
								ITsStrFactory factory = TsStrFactoryClass.Create();
								foreach (var ws in WsOrder)
								{
									using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
									{
										if (m_displayOptions.LiteralStringLabels)
											vwenv.AddString(factory.MakeString("Label" + ws, ws));
									}
								}
							}
						}
						using (new VwConstructorServices.InnerPileHelper(vwenv))
						{
							ITsStrFactory factory = TsStrFactoryClass.Create();
							foreach (var ws in WsOrder)
							{
								using (new VwConstructorServices.ParagraphBoxHelper(vwenv))
								{
									//if (m_displayOptions.LiteralStringLabels)
									//    vwenv.AddString(factory.MakeString("Label" + ws, ws));
									vwenv.AddStringAltMember(kflidMultiString, ws, null);
								}
							}
						}
					}

					break;
				default:
					throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
			}
		}
示例#38
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();
				if (m_wsDefault == -1)
				{
					// Set the underlying paragraph to RTL if the first writing system in the
					// string is RTL.
					if (m_cache != null)
					{
						ITsString tss = m_cache.MainCacheAccessor.get_StringProp(hvo, m_flid);
						ITsTextProps ttp = tss.get_Properties(0);
						int var;
						int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
						if (ws != 0)
							SetParaRTLIfNeeded(vwenv, ws);
					}
					vwenv.AddStringProp(m_flid, this);
				}
				else
				{
					SetParaRTLIfNeeded(vwenv, m_wsDefault);
					vwenv.AddStringAltMember(m_flid, m_wsDefault, this);
				}
			}
示例#39
0
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			TriggerDisplay(vwenv);
			//if (m_rgws.Length == 1)
			//{
			//    // Single option...don't bother with labels.
			//    if (m_rgws[0].RightToLeft)
			//    {
			//        vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
			//            (int)FwTextPropVar.ktpvEnum,
			//            (int)FwTextToggleVal.kttvForceOn);
			//        vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
			//            (int)FwTextPropVar.ktpvEnum,
			//            (int)FwTextAlign.ktalTrailing);
			//    }
			//    vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000);
			//    vwenv.AddStringAltMember(m_flid, m_rgws[0].Hvo, this);
			//    return;
			//}
			ITsStrFactory tsf = TsStrFactoryClass.Create();
			// We use a table to display
			// encodings in column one and the strings in column two.
			// The table uses 100% of the available width.
			VwLength vlTable;
			vlTable.nVal = 10000;
			vlTable.unit = VwUnit.kunPercent100;

			// The width of the writing system column is determined from the width of the
			// longest one which will be displayed.
			int dxs;	// Width of displayed string.
			int dys;	// Height of displayed string (not used here).
			int dxsMax = 0;	// Max width required.
			for (int i = 0; i < m_rgws.Length; ++i)
			{
				// Set qtss to a string representing the writing system.
				vwenv.get_StringWidth(NameOfWs(tsf, i),
					m_ttpLabel, out dxs, out dys);
				dxsMax = Math.Max(dxsMax, dxs);
			}
			VwLength vlColWs; // 5-pt space plus max label width.
			vlColWs.nVal = dxsMax + 5000;
			vlColWs.unit = VwUnit.kunPoint1000;

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

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

			vwenv.OpenTable(2, // Two columns.
				vlTable, // Table uses 100% of available width.
				0, // Border thickness.
				VwAlignment.kvaLeft, // Default alignment.
				VwFramePosition.kvfpVoid, // No border.
				VwRule.kvrlNone, // No rules between cells.
				0, // No forced space between cells.
				0, // No padding inside cells.
				false);
			// Specify column widths. The first argument is the number of columns,
			// not a column index. The writing system column only occurs at all if its
			// width is non-zero.
			vwenv.MakeColumns(1, vlColWs);
			vwenv.MakeColumns(1, vlColMain);

			vwenv.OpenTableBody();
			Set<ILgWritingSystem> visibleWss = new Set<ILgWritingSystem>();
			// if we passed in a view and have WritingSystemsToDisplay
			// then we'll load that list in order to filter our larger m_rgws list.
			AddViewWritingSystems(visibleWss);
			for (int i = 0; i < m_rgws.Length; ++i)
			{
				if (SkipEmptyWritingSystem(visibleWss, i, hvo))
					continue;
				vwenv.OpenTableRow();

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

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

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

			vwenv.CloseTable();
		}
示例#40
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				const int kfragAbbr = 17; // arbitrary const from reserved range.
				const int kfragName = 18;
				switch (frag)
				{
					case (int)VcFrags.kfragInterlinearAbbr:
					case (int)VcFrags.kfragInterlinearName:  // abbr is probably more appropriate in interlinear.
					case (int)VcFrags.kfragShortName:
						if (HandleObjMissing(vwenv, hvo))
							vwenv.AddObjProp(m_flidRef, this, kfragAbbr);
						break;
					case kfragAbbr:
						vwenv.AddStringAltMember(CmPossibilityTags.kflidAbbreviation,
							m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle,
							this);
						break;
					case (int)VcFrags.kfragName:
						if (HandleObjMissing(vwenv, hvo))
							vwenv.AddObjProp(m_flidRef, this, kfragName);
						break;
					default:
						vwenv.AddStringAltMember(CmPossibilityTags.kflidName,
							m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle,
							this);
						break;
				}
			}
示例#41
0
		private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i)
		{
			string sField = ksEditColumnBaseName + i;
			XmlNode node = m_columns[i - 1] as XmlNode;
			// Make a cell and embed an editable virtual string for the column.
			vwenv.OpenTableCell(1, 1);
			// Initialize the virtual property.
			IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField);
			Debug.Assert(vh != null);
			int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false);
			int ws = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs);

			// Paragraph directionality must be set before the paragraph is opened.
			bool fRTL = IsWsRTL(ws);
			vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
				(int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum,
				fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);

			vh.Load(khvoNewItem, flid, ws, cda);
			// Fill in the cell with the virtual property.
			vwenv.OpenParagraph();
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum,
				(int)TptEditable.ktptIsEditable);
			vwenv.AddStringAltMember(flid, ws, this);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();
		}
示例#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)
        {
            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;
            }
        }
示例#43
0
		internal void AddDoublePara(IVwEnv vwenv, int hvo)
		{
			// We use a table to display the source WS in column 1, and the dest ws in column 2.
			FwViews.VwLength vlTable; // we use this to specify that the table takes 100% of the width.
			vlTable.nVal = 10000;
			vlTable.unit = FwViews.VwUnit.kunPercent100;

			FwViews.VwLength vlColumn; // and this one to specify half the width for each column
			vlColumn.nVal = 5000;
			vlColumn.unit = FwViews.VwUnit.kunPercent100;

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

			vwenv.OpenTable(2, // Two columns.
				ref vlTable, // Table uses 100% of available width.
				0, // Border thickness.
				FwViews.VwAlignment.kvaLeft, // Default alignment.
				FwViews.VwFramePosition.kvfpVoid, // No border.
				FwViews.VwRule.kvrlNone, // No rules between cells.
				3000, // Three points of space between cells.
				3000); // Three points padding inside cells.
			// Specify column widths. The first argument is the number of columns,
			// not a column index.
			vwenv.MakeColumns(2, vlColumn);

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

			// Source cell, not editable
			vwenv.OpenTableCell(1,1);
			vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptEditable, (int)FwKernelLib.FwTextPropVar.ktpvEnum,
				(int)FwKernelLib.TptEditable.ktptNotEditable);
			vwenv.AddStringAltMember(ktagParaContents, m_wsSrc, this);
			vwenv.CloseTableCell();

			// Dest cell, editable, therefore with white background.
			vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault,
				m_colorEditable);
			vwenv.OpenTableCell(1,1);
			vwenv.AddStringAltMember(ktagParaContents, m_wsDst, this);
			vwenv.CloseTableCell();

			vwenv.CloseTableRow();
			vwenv.CloseTableBody();
			vwenv.CloseTable();
		}
示例#44
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				if (m_fMultilingual)
				{
					SetParaRtlIfNeeded(vwenv, m_wsDefault);
					vwenv.AddStringAltMember(m_flid, m_wsDefault, this);
				}
				else
				{
					// Set the underlying paragraph to RTL if the first writing system in the
					// string is RTL.
					if (m_cache != null)
					{
						ITsString tss = m_cache.DomainDataByFlid.get_StringProp(hvo, m_flid);
						ITsTextProps ttp = tss.get_Properties(0);
						int var;
						int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
						if (ws == 0)
							ws = m_wsDefault;
						if (ws == 0)
							ws = m_cache.DefaultAnalWs;
						if (ws != 0)
						{
							SetParaRtlIfNeeded(vwenv, ws);
							if (m_fShowWsLabel)
							{
								DisplayWithWritingSystemLabel(vwenv, ws);
								return;
							}
						}
					}
					vwenv.AddStringProp(m_flid, this);
				}
			}
示例#45
0
		private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i)
		{
			XmlNode node = m_columns[i - 1];
			// Make a cell and embed an editable virtual string for the column.
			var editable = XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
			if (!editable)
				vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, NoEditBackgroundColor);
			vwenv.OpenTableCell(1, 1);
			int flid = XMLViewsDataCache.ktagEditColumnBase + i;
			int ws = WritingSystemServices.GetWritingSystem(m_cache, node, null,
				m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle).Handle;

			// Paragraph directionality must be set before the paragraph is opened.
			bool fRTL = IsWsRTL(ws);
			vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
				(int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum,
				fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);

			// Fill in the cell with the virtual property.
			vwenv.OpenParagraph();
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum,
				editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
			vwenv.AddStringAltMember(flid, ws, this);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();
		}
示例#46
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            ITsStrFactory tsf = null;

            switch (frag)
            {
            case kfragStText:                     // The whole text, root object for the InterlinDocChild.
                if (hvo == 0)
                {
                    return;                                     // What if the user deleted all the texts?  See LT-6727.
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvDefault,
                                      (int)TptEditable.ktptNotEditable);
                vwenv.OpenDiv();
                StText stText = new StText(m_cache, hvo);
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 6000);
                vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, 24000);
                // Add both vernacular and analysis if we have them (LT-5561).
                bool fAddedVernacular = false;
                int  wsVernTitle      = 0;
                //
                if (stText.Title.TryWs(LangProject.kwsFirstVern, out wsVernTitle))
                {
                    vwenv.OpenParagraph();
                    vwenv.AddStringAltMember(vtagStTextTitle, wsVernTitle, this);
                    vwenv.CloseParagraph();
                    fAddedVernacular = true;
                }
                int wsAnalysisTitle = 0;
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                vwenv.OpenParagraph();
                ITsString tssAnal;
                if (stText.Title.TryWs(LangProject.kwsFirstAnal, out wsAnalysisTitle, out tssAnal) &&
                    !tssAnal.Equals(stText.Title.BestVernacularAlternative))
                {
                    if (fAddedVernacular)
                    {
                        // display analysis title at smaller font size.
                        vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                              (int)FwTextPropVar.ktpvMilliPoint, 12000);
                    }
                    vwenv.AddStringAltMember(vtagStTextTitle, wsAnalysisTitle, this);
                }
                else
                {
                    // just add a blank title.
                    tsf = TsStrFactoryClass.Create();
                    ITsString blankTitle = tsf.MakeString("", m_wsAnalysis);
                    vwenv.AddString(blankTitle);
                }
                vwenv.CloseParagraph();
                int       wsSource  = 0;
                ITsString tssSource = stText.SourceOfTextForWs(m_wsVernForDisplay);
                if (tssSource == null || tssSource.Length == 0)
                {
                    tssSource = stText.SourceOfTextForWs(m_wsAnalysis);
                    if (tssSource != null && tssSource.Length > 0)
                    {
                        wsSource = m_wsAnalysis;
                    }
                }
                else
                {
                    wsSource = m_wsVernForDisplay;
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                if (tssSource != null && tssSource.Length > 0)
                {
                    vwenv.OpenParagraph();
                    vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                          (int)FwTextPropVar.ktpvMilliPoint, 12000);
                    vwenv.AddStringAltMember(vtagStTextSource, wsSource, this);
                    vwenv.CloseParagraph();
                }
                else
                {
                    // just add a blank source.
                    tsf = TsStrFactoryClass.Create();
                    ITsString tssBlank = tsf.MakeString("", m_wsAnalysis);
                    vwenv.AddString(tssBlank);
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
                                      (int)FwTextPropVar.ktpvMilliPoint, 10000);
                vwenv.OpenParagraph();
                if (stText.OwningFlid == (int)Text.TextTags.kflidContents)
                {
                    vwenv.AddObjProp((int)CmObjectFields.kflidCmObject_Owner, this, kfragTextDescription);
                }
                vwenv.CloseParagraph();
                base.Display(vwenv, hvo, frag);
                vwenv.CloseDiv();
                break;

            case kfragTextDescription:
                vwenv.AddStringAltMember((int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
                break;

            case kfragSegFf:                     // One freeform annotation.
                int[] wssAnalysis = m_WsList.AnalysisWsIds;
                if (wssAnalysis.Length == 0)
                {
                    break;                             // This is bizarre, but for the sake of paranoia...
                }
                tsf = TsStrFactoryClass.Create();
                int    hvoType = m_cache.MainCacheAccessor.get_ObjectProp(hvo, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType);
                string label   = "";
                if (hvoType == NoteSegmentDefn)
                {
                    label = ITextStrings.ksNt;
                }
                else if (hvoType == FtSegmentDefn)
                {
                    label = ITextStrings.ksFT;
                }
                else if (hvoType == LtSegmentDefn)
                {
                    label = ITextStrings.ksLT;
                }
                else
                {
                    throw new Exception("Unexpected FF annotation type");
                }
                ITsString      tssLabel = tsf.MakeString(label, m_cache.DefaultUserWs);
                ISilDataAccess sda      = vwenv.DataAccess;
                if (wssAnalysis.Length == 1)
                {
                    ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs);
                    if (tss.Length == 0)
                    {
                        break;
                    }
                    vwenv.OpenParagraph();
                    vwenv.AddString(tssLabel);
                    vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_cache.DefaultAnalWs, this);
                    vwenv.CloseParagraph();
                }
                else
                {
                    int labelWidth, labelHeight;
                    vwenv.get_StringWidth(tssLabel, null, out labelWidth, out labelHeight);
                    // This roughly corresponds to the width of the space at the end of FT.
                    // The nice way to do it (here and in the base class) would be a table or 'interlinear' paragraph.
                    labelWidth += 3000;
                    int cNonBlank = 0;
                    for (int i = 0; i < wssAnalysis.Length; i++)
                    {
                        ITsString tss = sda.get_MultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i]);
                        if (tss.Length == 0)
                        {
                            continue;
                        }
                        if (cNonBlank != 0)
                        {
                            // Indent subsequent paragraphs by the width of the main label.
                            vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent,
                                                  (int)FwTextPropVar.ktpvMilliPoint, labelWidth);
                        }
                        vwenv.OpenParagraph();
                        if (cNonBlank == 0)
                        {
                            vwenv.AddString(tssLabel);
                        }
                        cNonBlank++;                                 // after tests above!
                        m_WsList.AddWsLabel(vwenv, i);
                        vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, wssAnalysis[i], this);
                        vwenv.CloseParagraph();
                    }
                }
                break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
示例#47
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// This is the main interesting method of displaying objects and fragments of them. Most
		/// subclasses should override.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// -----------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case 1: // LexEntry
					vwenv.OpenParagraph();
					vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, 2);
					vwenv.AddObjVecItems(LexEntryTags.kflidSenses, this, 3);
					vwenv.CloseParagraph();
					break;
				case 2: // MoForm
					vwenv.AddStringAltMember(MoFormTags.kflidForm, m_cache.DefaultVernWs, this);
					NoteItemWidth(vwenv, hvo, MoFormTags.kflidForm, m_cache.DefaultVernWs);
					break;
				case 3: // LexSense
					vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this);
					NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs);
					int flid = m_cache.MetaDataCacheAccessor.GetFieldId("LexSense", "LexSenseReferences", false);
					vwenv.AddObjVecItems(flid, this, 4);
					break;
				case 4: // LexReference
					vwenv.AddObjVecItems(LexReferenceTags.kflidTargets, this, 5);
					break;
				case 5: // target of lex reference, which in our test data is made to be a sense
					vwenv.AddStringAltMember(LexSenseTags.kflidGloss, m_cache.DefaultAnalWs, this);
					NoteItemWidth(vwenv, hvo, LexSenseTags.kflidGloss, m_cache.DefaultAnalWs);
					break;
			}
		}
示例#48
0
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			// Ignore 0 hvo's. RootObject may have not been set. FWNX-613.
			if (hvo == 0)
				return;

			switch(frag)
			{
				case kfragRoot:
					if (m_dxLabWidth == 0)
					{
						int dmpx1, dmpy;	//, dmpx2;
						vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy);
						//vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy);
						//m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin.
						m_dxLabWidth = dmpx1 + 13000; // add 3 pt spacing to box, 10 to margin.

						m_dxWsLabWidth = 0;
						foreach (ITsString tssLabel in m_WsLabels)
						{
							vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy);
							m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1);
						}
						m_dxWsLabWidth += 18000; // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety.
					}
					VwLength vlTable;
					vlTable.nVal = 10000;
					vlTable.unit = VwUnit.kunPercent100;

					VwLength vlColLabels; // 5-pt space plus max label width.
					vlColLabels.nVal = m_dxLabWidth;
					vlColLabels.unit = VwUnit.kunPoint1000;

					VwLength vlColWsLabels; // 5-pt space plus max ws label width.
					vlColWsLabels.nVal = m_dxWsLabWidth;
					vlColWsLabels.unit = VwUnit.kunPoint1000;

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

					// The Padding column allows for the the trailing margin and border.
					VwLength vlColPadding;
					vlColPadding.nVal = 10000;
					vlColPadding.unit = VwUnit.kunPoint1000;

					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
						(int) FwTextPropVar.ktpvMilliPoint, 5000);
					vwenv.OpenTable(4, // Four columns.
						vlTable, // Table uses 100% of available width.
						0, // Border thickness.
						VwAlignment.kvaLeft, // Default alignment.
						VwFramePosition.kvfpVoid, // No border.
						VwRule.kvrlNone, // No rules between cells.
						0, // No forced space between cells.
						0, // no padding inside cells.
						false);
					vwenv.MakeColumns(1, vlColLabels);
					vwenv.MakeColumns(1, vlColWsLabels);
					vwenv.MakeColumns(1, vlColMain);
					vwenv.MakeColumns(1, vlColPadding);

					vwenv.OpenTableBody();

					for (int i = 0; i < m_writingSystems.Length; i++)
					{
						vwenv.OpenTableRow();

						// First cell has 'Title' label in bold.
						vwenv.Props = m_ttpBold;
						vwenv.OpenTableCell(1,1);
						vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading,
							(int) FwTextPropVar.ktpvMilliPoint, 10000);
						if (i == 0) // only on the first row
						{
							// We want this fixed at 10 point, since it's considered a UI component, not data.
							// See LT-4816
							vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
								(int)FwTextPropVar.ktpvMilliPoint, 10000);
							vwenv.AddString(m_tssTitle);
						}
						vwenv.CloseTableCell();

						// Second cell has ws labels.
						vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
							(int) FwTextPropVar.ktpvDefault, m_editBackColor);
						vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading,
							(int)FwTextPropVar.ktpvMilliPoint, 1000);
						if (i == 0)
							vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
								(int)FwTextPropVar.ktpvMilliPoint, 1000);
						if (i == m_writingSystems.Length - 1)
							vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
								(int)FwTextPropVar.ktpvMilliPoint, 1000);
						vwenv.OpenTableCell(1,1);
						vwenv.Props = m_ttpDataCellProps;

						vwenv.Props = m_ttpWsLabel;
						vwenv.AddString(m_WsLabels[i]);
						vwenv.CloseTableCell();

						// Third cell has the Title property, in a box.

						vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
							(int) FwTextPropVar.ktpvDefault, m_editBackColor);
						// Set the underlying directionality so that arrow keys work properly.
						bool fRTL = m_writingSystems[i].RightToLeftScript;
						vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
							(int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
						vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
							(int)FwTextPropVar.ktpvEnum,
							fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);
						if (i == 0)
							vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
								(int)FwTextPropVar.ktpvMilliPoint, 1000);
						if (i == m_writingSystems.Length - 1)
							vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
								(int)FwTextPropVar.ktpvMilliPoint, 1000);
						vwenv.OpenTableCell(1,1);
						vwenv.OpenParagraph();
						vwenv.Props = m_ttpDataCellProps;
						vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
								this.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
						if (IsScripture)
						{
							vwenv.AddStringAltMember(m_vtagStTextTitle, m_writingSystems[i].Handle, this);
						}
						else
						{
							vwenv.AddStringAltMember(CmMajorObjectTags.kflidName, m_writingSystems[i].Handle, this);
						}
						vwenv.CloseParagraph();
						vwenv.CloseTableCell();

						vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
							(int)FwTextPropVar.ktpvMilliPoint, 10000);
						vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing,
							(int)FwTextPropVar.ktpvMilliPoint, 1000);
						vwenv.OpenTableCell(1, 1);
						vwenv.CloseTableCell();

						vwenv.CloseTableRow();
					}

					//// Second row.
					//vwenv.OpenTableRow();
					//
					//// First cell has 'Comments' label in bold.
					//vwenv.Props = m_ttpBold;
					//vwenv.OpenTableCell(1,1);
					//vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading,
					//	(int)FwTextPropVar.ktpvMilliPoint, 10000);
					//vwenv.AddString(m_tssComments);
					//vwenv.CloseTableCell();
					//
					//// Second cell has the Description property, in a box.
					//vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
					//	(int)FwTextPropVar.ktpvMilliPoint, 10000);
					//vwenv.OpenTableCell(1,1);
					//vwenv.Props = m_ttpDataCellProps;
					//vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
					//	(int)FwTextPropVar.ktpvMilliPoint, 1000);
					//vwenv.AddStringAltMember(
					//	(int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
					//vwenv.CloseTableCell();
					//
					//vwenv.CloseTableRow();

					vwenv.CloseTableBody();

					vwenv.CloseTable();

					break;
				default:
					throw new Exception("Bad frag id in TitleContentsVc");
			}
		}
示例#49
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Display a view of the LexEntry (or fragment thereof).
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			switch (frag)
			{
				case (int)VcFrags.kfragHeadWord:
					// This case should stay in sync with
					// LexEntry.LexemeFormMorphTypeAndHomographStatic
					vwenv.OpenParagraph();
					AddHeadwordWithHomograph(vwenv, hvo);
					vwenv.CloseParagraph();
					break;
				case kfragEntryAndVariant:
					var wfb = m_cache.ServiceLocator.GetInstance<IWfiMorphBundleRepository>().GetObject(hvo);
					//int hvoMf = wfb.MorphRA.Hvo;
					//int hvoLexEntry = m_cache.GetOwnerOfObject(hvoMf);
					// if morphbundle morph (entry) is in a variant relationship to the morph bundle sense
					// display its entry headword and variant type information (LT-4053)
					ILexEntryRef ler;
					var variant = wfb.MorphRA.Owner as ILexEntry;
					if (variant.IsVariantOfSenseOrOwnerEntry(wfb.SenseRA, out ler))
					{
						// build Headword from sense's entry
						vwenv.OpenParagraph();
						vwenv.OpenInnerPile();
						vwenv.AddObj(wfb.SenseRA.EntryID, this, (int)VcFrags.kfragHeadWord);
						vwenv.CloseInnerPile();
						vwenv.OpenInnerPile();
						// now add variant type info
						vwenv.AddObj(ler.Hvo, this, kfragVariantTypes);
						vwenv.CloseInnerPile();
						vwenv.CloseParagraph();
						break;
					}

					// build Headword even though we aren't in a variant relationship.
					vwenv.AddObj(variant.Hvo, this, (int)VcFrags.kfragHeadWord);
					break;
				case kfragVariantTypes:
					ler = m_cache.ServiceLocator.GetInstance<ILexEntryRefRepository>().GetObject(hvo);
					bool fNeedInitialPlus = true;
					vwenv.OpenParagraph();
					foreach (var let in ler.VariantEntryTypesRS.Where(let => let.ClassID == LexEntryTypeTags.kClassId))
					{
						// just concatenate them together separated by comma.
						ITsString tssVariantTypeRevAbbr = let.ReverseAbbr.BestAnalysisAlternative;
						if (tssVariantTypeRevAbbr != null && tssVariantTypeRevAbbr.Length > 0)
						{
							if (fNeedInitialPlus)
								vwenv.AddString(TsStringUtils.MakeTss("+", m_cache.DefaultUserWs));
							else
								vwenv.AddString(TsStringUtils.MakeTss(",", m_cache.DefaultUserWs));
							vwenv.AddString(tssVariantTypeRevAbbr);
							fNeedInitialPlus = false;
						}
					}
					vwenv.CloseParagraph();
					break;
				case kfragFormForm: // form of MoForm
					vwenv.AddStringAltMember(MoFormTags.kflidForm, m_wsActual, this);
					break;
				default:
					base.Display(vwenv, hvo, frag);
					break;
			}
		}
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            // Ignore 0 hvo's. RootObject may have not been set. FWNX-613.
            if (hvo == 0)
            {
                return;
            }

            switch (frag)
            {
            case kfragRoot:
                if (m_dxLabWidth == 0)
                {
                    int dmpx1, dmpy;                                    //, dmpx2;
                    vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy);
                    //vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy);
                    //m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin.
                    m_dxLabWidth = dmpx1 + 13000;                             // add 3 pt spacing to box, 10 to margin.

                    m_dxWsLabWidth = 0;
                    foreach (ITsString tssLabel in m_WsLabels)
                    {
                        vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy);
                        m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1);
                    }
                    m_dxWsLabWidth += 18000;                             // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety.
                }
                VwLength vlTable;
                vlTable.nVal = 10000;
                vlTable.unit = VwUnit.kunPercent100;

                VwLength vlColLabels;                         // 5-pt space plus max label width.
                vlColLabels.nVal = m_dxLabWidth;
                vlColLabels.unit = VwUnit.kunPoint1000;

                VwLength vlColWsLabels;                         // 5-pt space plus max ws label width.
                vlColWsLabels.nVal = m_dxWsLabWidth;
                vlColWsLabels.unit = VwUnit.kunPoint1000;

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

                // The Padding column allows for the the trailing margin and border.
                VwLength vlColPadding;
                vlColPadding.nVal = 10000;
                vlColPadding.unit = VwUnit.kunPoint1000;

                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
                                      (int)FwTextPropVar.ktpvMilliPoint, 5000);
                vwenv.OpenTable(4,                        // Four columns.
                                vlTable,                  // Table uses 100% of available width.
                                0,                        // Border thickness.
                                VwAlignment.kvaLeft,      // Default alignment.
                                VwFramePosition.kvfpVoid, // No border.
                                VwRule.kvrlNone,          // No rules between cells.
                                0,                        // No forced space between cells.
                                0,                        // no padding inside cells.
                                false);
                vwenv.MakeColumns(1, vlColLabels);
                vwenv.MakeColumns(1, vlColWsLabels);
                vwenv.MakeColumns(1, vlColMain);
                vwenv.MakeColumns(1, vlColPadding);

                vwenv.OpenTableBody();

                for (int i = 0; i < m_writingSystems.Length; i++)
                {
                    vwenv.OpenTableRow();

                    // First cell has 'Title' label in bold.
                    vwenv.Props = m_ttpBold;
                    vwenv.OpenTableCell(1, 1);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading,
                                          (int)FwTextPropVar.ktpvMilliPoint, 10000);
                    if (i == 0)                             // only on the first row
                    {
                        // We want this fixed at 10 point, since it's considered a UI component, not data.
                        // See LT-4816
                        vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                              (int)FwTextPropVar.ktpvMilliPoint, 10000);
                        vwenv.AddString(m_tssTitle);
                    }
                    vwenv.CloseTableCell();

                    // Second cell has ws labels.
                    vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
                                          (int)FwTextPropVar.ktpvDefault, m_editBackColor);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading,
                                          (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    if (i == 0)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
                                              (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    }
                    if (i == m_writingSystems.Length - 1)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
                                              (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    }
                    vwenv.OpenTableCell(1, 1);
                    vwenv.Props = m_ttpDataCellProps;

                    vwenv.Props = m_ttpWsLabel;
                    vwenv.AddString(m_WsLabels[i]);
                    vwenv.CloseTableCell();

                    // Third cell has the Title property, in a box.

                    vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
                                          (int)FwTextPropVar.ktpvDefault, m_editBackColor);
                    // Set the underlying directionality so that arrow keys work properly.
                    bool fRTL = m_writingSystems[i].RightToLeftScript;
                    vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                          (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                          (int)FwTextPropVar.ktpvEnum,
                                          fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);
                    if (i == 0)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
                                              (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    }
                    if (i == m_writingSystems.Length - 1)
                    {
                        vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
                                              (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    }
                    vwenv.OpenTableCell(1, 1);
                    vwenv.OpenParagraph();
                    vwenv.Props = m_ttpDataCellProps;
                    vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                          this.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
                    if (IsScripture)
                    {
                        vwenv.AddStringAltMember(m_vtagStTextTitle, m_writingSystems[i].Handle, this);
                    }
                    else
                    {
                        vwenv.AddStringAltMember(CmMajorObjectTags.kflidName, m_writingSystems[i].Handle, this);
                    }
                    vwenv.CloseParagraph();
                    vwenv.CloseTableCell();

                    vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
                                          (int)FwTextPropVar.ktpvMilliPoint, 10000);
                    vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing,
                                          (int)FwTextPropVar.ktpvMilliPoint, 1000);
                    vwenv.OpenTableCell(1, 1);
                    vwenv.CloseTableCell();

                    vwenv.CloseTableRow();
                }

                //// Second row.
                //vwenv.OpenTableRow();
                //
                //// First cell has 'Comments' label in bold.
                //vwenv.Props = m_ttpBold;
                //vwenv.OpenTableCell(1,1);
                //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading,
                //	(int)FwTextPropVar.ktpvMilliPoint, 10000);
                //vwenv.AddString(m_tssComments);
                //vwenv.CloseTableCell();
                //
                //// Second cell has the Description property, in a box.
                //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
                //	(int)FwTextPropVar.ktpvMilliPoint, 10000);
                //vwenv.OpenTableCell(1,1);
                //vwenv.Props = m_ttpDataCellProps;
                //vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
                //	(int)FwTextPropVar.ktpvMilliPoint, 1000);
                //vwenv.AddStringAltMember(
                //	(int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this);
                //vwenv.CloseTableCell();
                //
                //vwenv.CloseTableRow();

                vwenv.CloseTableBody();

                vwenv.CloseTable();

                break;

            default:
                throw new Exception("Bad frag id in TitleContentsVc");
            }
        }
示例#51
0
		private void AddHeadwordWithHomograph(IVwEnv vwenv, int hvo)
		{
					ISilDataAccess sda = vwenv.DataAccess;
					int hvoLf = sda.get_ObjectProp(hvo,
						LexEntryTags.kflidLexemeForm);
					int hvoType = 0;
					if (hvoLf != 0)
					{
						hvoType = sda.get_ObjectProp(hvoLf,
							MoFormTags.kflidMorphType);
					}

					// If we have a type of morpheme, show the appropriate prefix that indicates it.
					// We want vernacular so it will match the point size of any aligned vernacular text.
					// (The danger is that the vernacular font doesn't have these characters...not sure what
					// we can do about that, but most do, and it looks awful in analysis if that is a
					// much different size from vernacular.)
					string sPrefix = null;
					if (hvoType != 0)
					{
						sPrefix = sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPrefix);
					}

					// LexEntry.ShortName1; basically tries for form of the lexeme form, then the citation form.
					bool fGotLabel = false;
					int wsActual = 0;
					if (hvoLf != 0)
					{
						// if we have a lexeme form and its label is non-empty, use it.
						if (TryMultiStringAlt(sda, hvoLf, MoFormTags.kflidForm, out wsActual))
						{
							m_wsActual = wsActual;
							fGotLabel = true;
							if (sPrefix != null)
								vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
							vwenv.AddObjProp(LexEntryTags.kflidLexemeForm, this, kfragFormForm);
						}
					}
					if (!fGotLabel)
					{
						// If we didn't get a useful form from the lexeme form try the citation form.
						if (TryMultiStringAlt(sda, hvo, LexEntryTags.kflidCitationForm, out wsActual))
						{
							m_wsActual = wsActual;
							if (sPrefix != null)
								vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
							vwenv.AddStringAltMember(LexEntryTags.kflidCitationForm, wsActual, this);
							fGotLabel = true;
						}
					}
					int defUserWs = m_cache.WritingSystemFactory.UserWs;
					if (!fGotLabel)
					{
						// If that fails just show two questions marks.
						if (sPrefix != null)
							vwenv.AddString(TsStringUtils.MakeTss(sPrefix, wsActual));
						vwenv.AddString(m_cache.TsStrFactory.MakeString(FdoUiStrings.ksQuestions, defUserWs));	// was "??", not "???"
					}

					// If we have a lexeme form type show the appropriate postfix.
					if (hvoType != 0)
					{
						vwenv.AddString(TsStringUtils.MakeTss(
							sda.get_UnicodeProp(hvoType, MoMorphTypeTags.kflidPostfix), wsActual));
					}

					// Show homograph number if non-zero.
					int nHomograph = sda.get_IntProp(hvo,
						LexEntryTags.kflidHomographNumber);
					vwenv.NoteDependency(new[] { hvo }, new[] { LexEntryTags.kflidHomographNumber }, 1);
					if (nHomograph > 0)
					{
						// Use a string builder to embed the properties in with the TsString.
						// this allows our TsStringCollectorEnv to properly encode the superscript.
						// ideally, TsStringCollectorEnv could be made smarter to handle SetIntPropValues
						// since AppendTss treats the given Tss as atomic.
						ITsIncStrBldr tsBldr = TsIncStrBldrClass.Create();
						tsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
							(int)FwTextPropVar.ktpvEnum,
							(int)FwSuperscriptVal.kssvSub);
						tsBldr.SetIntPropValues((int)FwTextPropType.ktptBold,
							(int)FwTextPropVar.ktpvEnum,
							(int)FwTextToggleVal.kttvForceOn);
						tsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
							(int)FwTextPropVar.ktpvDefault, defUserWs);
						tsBldr.Append(nHomograph.ToString());
						vwenv.AddString(tsBldr.GetString());
					}
		}