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

                int       hvoOuter, tag, ihvo;
                ITsString tss;

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

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

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

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

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

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

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

                default:
                    throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
                }
            }
Exemple #3
0
        private bool InEditableRow(IVwEnv vwenv)
        {
            int hvoTop, tag, ihvo;

            vwenv.GetOuterObject(1, out hvoTop, out tag, out ihvo);
            return(m_editableHvos.Contains(hvoTop));
        }
			/// ------------------------------------------------------------------------------------
			/// <summary>
			///
			/// </summary>
			/// <param name="vwenv"></param>
			/// <param name="hvo"></param>
			/// <param name="frag"></param>
			/// ------------------------------------------------------------------------------------
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				int frWs = vwenv.DataAccess.WritingSystemFactory.GetWsFromStr("fr");
				int hvoOuter, tag, ihvo;
				ITsString tss;
				switch (frag)
				{
					case 1: // A ScrBook; display the title.
						vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 2);
						break;
					case 2: // An StText; display the paragraphs.
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							frWs);
						vwenv.AddString(tss);
						vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 3);
						break;
					case 3: // StTxtPara, display details of our outer object
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							frWs);
						vwenv.AddString(tss);
						break;
					default:
						throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
				}
			}
Exemple #5
0
            internal override void PerformDisplay(XmlVc vc, int fragId, int hvo, IVwEnv vwenv)
            {
                int level = vwenv.EmbeddingLevel;
                int hvoDum, tag, ihvo;

                vwenv.GetOuterObject(level - 2, out hvoDum, out tag, out ihvo);
                m_creator.SetupParagraph(m_paraStyle, m_tssBefore, m_listDelimitNode);
                m_creator.AddItemEmbellishments(m_listDelimitNode, m_numberItems, hvo, ihvo, m_xaNum, m_ttpNum, m_delayNumber, ref DelayedNumber);

                // This is the display of the object we wanted to wrap the paragraph etc around.
                // We want to produce an effect rather like
                // vwenv.AddObj(hvo, m_creator.m_viewConstructor, WrappedFragId);
                // except we do NOT want to open/close an object in the VC, since we are already inside the addition of this object.
                m_creator.m_viewConstructor.Display(vwenv, hvo, WrappedFragId);

                // Close Paragraph if displaying paragraphs
                vwenv.CloseParagraph();
            }
Exemple #6
0
        /// <summary>
        /// All our display method does is to display the name of each item in the fake virtual property.
        /// If it is the active object we are editing, at the relevant position in the relevant owner,
        /// we display the name using the special marker property.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            int hvoParent, tag, ihvo;

            switch (frag)
            {
            case kfragName:
                vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoParent, out tag, out ihvo);
                if (m_fGotFocus && hvo == m_hvoTa && hvoParent == m_hvoParent && ihvo == m_ihvoTa)
                {
                    vwenv.AddStringProp(m_taTagName, this);
                }
                else
                {
                    vwenv.AddStringProp(m_snTagName, this);
                }
                break;

            default:
                throw new Exception("Unexpected fragment ID in TypeAheadSupportVc");
            }
        }
Exemple #7
0
 private bool IsExcluded(string exclude, int ihvo, int[] rghvo)
 {
     if (String.IsNullOrEmpty(exclude))
     {
         return(false);
     }
     if (exclude == "this" && rghvo[ihvo] == m_hvo)
     {
         return(true);
     }
     if (exclude == "parent")
     {
         int hvoParent, tagDummy, ihvoDummy;
         m_vwEnv.GetOuterObject(m_vwEnv.EmbeddingLevel - 1, out hvoParent,
                                out tagDummy, out ihvoDummy);
         if (rghvo[ihvo] == hvoParent)
         {
             return(true);
         }
     }
     return(false);
 }
		/// <summary>
		/// Add a new table/row to the view for one existing object.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		protected virtual void AddTableRow(IVwEnv vwenv, int hvo, int frag)
		{
			// set the border color
			vwenv.set_IntProperty((int )FwTextPropType.ktptBorderColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)RGB(m_BorderColor));

			// If we're using this special mode where just one column is editable, we need to make
			// sure as far as possible that everything else is not.
			if (OverrideAllowEditColumn >= 0)
				vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int) FwTextPropVar.ktpvEnum,
					(int)TptEditable.ktptNotEditable);

			int index, hvoDummy, tagDummy;
			int clev = vwenv.EmbeddingLevel;
			vwenv.GetOuterObject(clev - 2, out hvoDummy, out tagDummy, out index);
			if (index >= Cache.MainCacheAccessor.get_VecSize(hvoDummy, tagDummy))
				return; // something to fix.

			if (index == m_xbv.SelectedIndex && m_xbv.SelectedRowHighlighting != XmlBrowseViewBase.SelectionHighlighting.none)
			{
				vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
					(int)FwTextPropVar.ktpvDefault,
					//	(int)RGB(Color.FromKnownColor(KnownColor.Highlight)));
					SelectedRowBackgroundColor(hvo));
				if (m_xbv.SelectedRowHighlighting == XmlBrowseViewBase.SelectionHighlighting.border)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
						(int)FwTextPropVar.ktpvMilliPoint,
						3000);
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor,
						(int)FwTextPropVar.ktpvDefault,
						(int)RGB(Color.FromKnownColor(KnownColor.Highlight)));
				}
			}

			// Make a table.
			VwLength[] rglength = m_xbv.GetColWidthInfo();
			int colCount = m_columns.Count;
			if (m_fShowSelected)
				colCount++;

			// LT-7014, 7058: add the additional columns that are needed
			if (rglength.Length < colCount)
			{
				VwLength[] rglengthNEW = new VwLength[colCount];
				for (int ii = 0; ii < colCount; ii++)
				{
					if (ii < rglength.Length)
						rglengthNEW[ii] = rglength[ii];
					else
						rglengthNEW[ii] = rglength[0];
				}
				rglength = rglengthNEW;
			}

			// If the only columns specified are custom fields which have been deleted,
			// we can't show anything!  (and we don't want to crash -- see LT-6449)
			if (rglength.Length == 0)
				return;

			VwLength vl100; // Length representing 100% of the table width.
			vl100.unit = rglength[0].unit;
			vl100.nVal = 1;
			for (int i = 0; i < colCount; ++i)
			{
				Debug.Assert(vl100.unit == rglength[i].unit);
				vl100.nVal += rglength[i].nVal;
			}

			vwenv.OpenTable(colCount, // this many columns
				vl100, // using 100% of available space
				72000 / 96, //0, // no border
				VwAlignment.kvaLeft, // cells by default left aligned
				//	VwFramePosition.kvfpBelow, //.kvfpBox, //.kvfpVoid, // no frame
				VwFramePosition.kvfpBelow | VwFramePosition.kvfpRhs,
				VwRule.kvrlCols, // vertical lines between columns
				0, // no space between cells
				0, // no padding within cell.
				false);
			// Set column widths.
			for (int i = 0; i < colCount; ++i)
				vwenv.MakeColumns(1, rglength[i]);
			// the table only has a body (no header or footer), and only one row.
			vwenv.OpenTableBody();
			vwenv.OpenTableRow();

			if (m_fShowSelected)
				AddSelectionCell(vwenv, hvo);
			// Make the cells.
			int hvoRoot, tagDummy2, ihvoDummy;
			vwenv.GetOuterObject(0, out hvoRoot, out tagDummy2, out ihvoDummy);
			int icolActive = GetActiveColumn(vwenv, hvoRoot);
			// if m_fShowSelected is true, we get an extra column of checkmarks that gives us
			// a different index into the columns. This allows the one-based indexing to work
			// in the call to ColumnSortedFromEnd. Without this, the one-based indexing has to
			// be adjusted to zero-based indexing.
			int cAdjCol = m_fShowSelected ? 0 : 1;
			if (m_fShowColumnsRTL)
			{
				for (int icol = m_columns.Count; icol > 0; --icol)
					AddTableCell(vwenv, hvo, index, hvoRoot, icolActive, cAdjCol, icol);
			}
			else
			{
				for (int icol = 1; icol <= m_columns.Count; ++icol)
					AddTableCell(vwenv, hvo, index, hvoRoot, icolActive, cAdjCol, icol);
			}
			vwenv.CloseTableRow();
			vwenv.CloseTableBody();
			vwenv.CloseTable();
		}
Exemple #9
0
		/// <summary>
		///
		/// </summary>
		/// <param name="hvo">the IAnalysis object</param>
		/// <param name="vwenv"></param>
		protected virtual void AddWordBundleInternal(int hvo, IVwEnv vwenv)
		{
			SetupAndOpenInnerPile(vwenv);
			// we assume we're in the context of a segment with analyses here.
			// we'll need this info down in DisplayAnalysisAndCloseInnerPile()
			int hvoSeg;
			int tagDummy;
			int index;
			vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoSeg, out tagDummy, out index);
			var analysisOccurrence = new AnalysisOccurrence(m_segRepository.GetObject(hvoSeg), index);
			DisplayAnalysisAndCloseInnerPile(vwenv, analysisOccurrence, true);
		}
		private void AddTableCell(IVwEnv vwenv, int hvo, int index, int hvoRoot, int icolActive, int cAdjCol, int icol)
		{
			XmlNode node = m_columns[icol - 1];
			// Figure out the underlying Right-To-Left value.
			bool fRightToLeft = false;
			// look for a writing system ID.
			XmlAttribute xa = node.Attributes["ws"];
			XmlNode xn = node;
			if (xa == null)
				xn = XmlUtils.FindNode(node, "string");
			m_wsBest = 0;
			if (xn != null)
			{
				int hvoBest = 0;
				int flidBest = 0;
				if (LangProject.GetWsRequiresObject(xn))
				{
					// The 'best' ws series needs the hvo and flid in order to work.
					// Some others (e.g., 'reversal' which require the hvo don't need a flid.
					hvoBest = hvo; // Wonder it isn't really the hvoRoot that is to be used.
					string flidname = XmlUtils.GetOptionalAttributeValue(xn, "field");
					if (flidname != null)
					{
						string classname;
						xa = xn.Attributes["class"];
						if (xa == null)
						{
							// Get it from the meta data cache.
							classname = m_cache.GetClassName((uint)m_cache.GetClassOfObject(hvo));
						}
						else
						{
							classname = xa.Value;
						}
						flidBest = (int)m_mdc.GetFieldId(classname, flidname, true);
					}
				}
				m_wsBest = LangProject.GetWritingSystem(xn, m_cache, null, hvoBest, flidBest, m_cache.DefaultAnalWs);
				IWritingSystem lgWs = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_wsBest);
				if (lgWs != null)
					fRightToLeft = lgWs.RightToLeft;
			}
			bool fSortedFromEnd = m_xbv.ColumnSortedFromEnd(icol - cAdjCol);
			int tal;
			if (fRightToLeft)
			{
				if (fSortedFromEnd)
					tal = (int)FwTextAlign.ktalLeft;
				else
					tal = (int)FwTextAlign.ktalRight;
			}
			else
			{
				if (fSortedFromEnd)
					tal = (int)FwTextAlign.ktalRight;
				else
					tal = (int)FwTextAlign.ktalLeft;
			}
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum, tal);

			bool fIsCellActive = false;
			if (icolActive != 0 && m_PreviewArrowPic != null)
			{
				// The display depends on which column is active and whether the current row is selected.
				vwenv.NoteDependency(new int[] { hvoRoot, hvo, hvo }, new int[] { ktagActiveColumn, ktagItemSelected, ktagItemEnabled }, 3);
				// We're doing the active column thing.
				if (icol == icolActive)
				{
					fIsCellActive = vwenv.DataAccess.get_IntProp(hvo, ktagItemSelected) != 0
						&& vwenv.DataAccess.get_IntProp(hvo, ktagItemEnabled) != 0;
				}
			}
			// Make a cell and embed the contents of the column node.
			ProcessProperties(node, vwenv);
			SetCellProperties(index, icol, node, hvo, vwenv, fIsCellActive);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			vwenv.OpenTableCell(1, 1);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			if (node.Name == "column")
			{
				// Paragraph directionality must be set before the paragraph is opened.
				vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
					(int)FwTextPropVar.ktpvEnum, IsWritingSystemRTL(node) ? -1 : 0);
			}

			// According to LT-8947, in bulk edit preview mode, we want to try to show the
			// original cell contents on the same line with the preview arrow and the new cell contents.
			// to accomplish this, we use 3 InnerPiles in a paragraph
			// to try to keep them on the same line (or wrap otherwise).
			// NOTE: the bottom two inner piles will only be present if fIsCellActive is true.
			//
			// <Paragraph>
			//		<InnerPile>
			//			<paragraph> Original cell contents </paragraph>
			//		</InnerPile>
			//		<InnerPile>
			//			<paragraph> Arrow Picture </paragraph>
			//		</InnerPile>
			//		<InnerPile>
			//			<paragraph> Alternate cell contents </paragraph>
			//		</InnerPile>
			// </Paragraph>
			//

			vwenv.OpenParagraph();			// <Paragraph>
			bool multiPara = XmlUtils.GetOptionalBooleanAttributeValue(node, "multipara", false);
			vwenv.OpenInnerPile();			//		<InnerPile>
			// if the multi-para attribute is not specified, create a paragraph to wrap the cell contents.
			bool fParaOpened = false;
			if (!multiPara)
			{
				vwenv.OpenParagraph();		//			<paragraph>
				fParaOpened = true;
			}

			if (m_sortItemProvider == null)
			{
				try
				{
					if (node.Name == "column")
					{
						SetForcedWs(node);
					}
					XmlNode nodeToProcess = GetColumnNode(node, hvo, m_cache.MainCacheAccessor, m_layouts);
					ProcessChildren(nodeToProcess, vwenv, hvo, null);
				}
				finally
				{
					// reset the ws for next column in the row.
					WsForce = 0;
				}
			}
			else
			{
				int level = vwenv.EmbeddingLevel;
				int hvoDum, tag, ihvo;
				vwenv.GetOuterObject(level - 2, out hvoDum, out tag, out ihvo);
				Debug.Assert(tag == m_fakeFlid);
				ManyOnePathSortItem item = m_sortItemProvider.SortItemAt(ihvo);
				if (item != null)
					DisplayCell(item, node, hvo, vwenv);	// (Original) cell contents
			}

			if (fParaOpened)
			{
				vwenv.CloseParagraph();		//			   (Original) cell contents </paragraph>
				fParaOpened = false;
			}
			vwenv.CloseInnerPile();			//		</InnerPile>
			if (fIsCellActive)
				AddPreviewPiles(vwenv, node);
			vwenv.CloseParagraph();			// </Paragraph>
			vwenv.CloseTableCell();
			m_wsBest = 0;
		}
Exemple #11
0
            public override void Display(IVwEnv vwenv, int hvo, int frag)
            {
                switch (frag)
                {
                case 1:
                {
                    // The top-level.
                    // Enhance JohnT: add a property setting to make the key bold
                    // Roughly, vwenv.set_IntProperty(ktptBold, ktpvEnum, kttvForceOn);
                    // If we can get an hvo and flid, display that property of that object.
                    int flid = 0;
                    if (hvo != 0)
                    {
                        flid = m_cp.FlidFor(m_index, hvo);
                    }
                    if (flid != 0)
                    {
                        // Warning (JohnT): this option not yet tested...
                        vwenv.AddStringProp(flid, this);
                        return;
                    }
                    else
                    {
                        // Otherwise display a literal string straight from the policy object.
                        vwenv.AddString(m_cp.KeyFor(m_index, hvo));
                    }

                    if (m_fExpanded)
                    {
                        vwenv.AddLazyVecItems(m_ni.ListFlid, this, 2);
                    }
                    break;
                }

                case 2:
                {
                    // One line of context.

                    // Figure the index of this object in the next object out (the root).
                    int hvoOuter, tagOuter, ihvo;
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1,
                                         out hvoOuter, out tagOuter, out ihvo);
                    int ichKey = m_ni.ContextStringStartOffset(ihvo, hvo);
                    int cchKey = m_ni.ContextStringLength(ihvo, hvo);
                    // Enhance JohnT: make the alignment position a function of window width.
                    // Enhance JohnT: change background if this is the selected context line.
                    vwenv.OpenConcPara(ichKey, ichKey + cchKey,
                                       VwConcParaOpts.kcpoDefault,
                                       72 * 2 * 1000);                  // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints.
                    int flidKey = m_ni.ContextStringFlid(ihvo, hvo);
                    if (flidKey == 0)
                    {
                        // Not tested yet.
                        vwenv.AddString(m_ni.ContextString(ihvo, hvo));
                    }
                    else
                    {
                        vwenv.AddStringProp(flidKey, this);
                    }
                    vwenv.CloseParagraph();
                    break;
                }
                }
            }
Exemple #12
0
		/// <summary>
		/// Make a 'standard' row. Used for both header and body.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="fHeader">true if it is a header; hvo is a chart instead of a row.</param>
		private void MakeTableAndRowWithStdWidths(IVwEnv vwenv, int hvo, bool fHeader)
		{
			VwLength tableWidth = new VwLength();
			if (m_colWidths == null)
			{
				tableWidth.nVal = 10000; // 100%
				tableWidth.unit = VwUnit.kunPercent100;
			}
			else
			{
				tableWidth.nVal = 0;
				foreach (VwLength w in m_colWidths)
					tableWidth.nVal += w.nVal;
				tableWidth.unit = VwUnit.kunPoint1000;
			}
			if (!fHeader)
				SetRowStyle(vwenv, hvo);

			VwFramePosition fpos = VwFramePosition.kvfpVsides;
			if (fHeader)
			{
				fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpAbove);
			}
			else
			{
				int hvoOuter, tagOuter, ihvoRow;
				vwenv.GetOuterObject(0, out hvoOuter, out tagOuter, out ihvoRow);
				if (ihvoRow == 0)
				{
					fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpAbove);
				}
				if (ihvoRow == vwenv.DataAccess.get_VecSize(hvoOuter, tagOuter) - 1
					|| ConstituentChartLogic.GetFeature(vwenv.DataAccess, hvo, "endPara"))
				{
					fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpBelow);
				}
			}
			// We seem to typically inherit a white background as a side effect of setting our stylesheet,
			// but borders on table rows don't show through if backcolor is set to white, because the
			// cells entirely cover the row (LT-9068). So force the back color to be transparent, and allow
			// the row border to show through the cell.
			vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)FwTextColor.kclrTransparent);
			vwenv.OpenTable(m_chart.AllColumns.Length + ConstituentChartLogic.NumberOfExtraColumns,
				tableWidth,
				1500, // borderWidth
				VwAlignment.kvaLeft, // Todo: handle RTL
				fpos,
				VwRule.kvrlNone,
				0, // cell spacing
				2000, // cell padding
				true); // selections limited to one cell.
			if (m_colWidths == null)
			{
				VwLength numColWidth = new VwLength();
				numColWidth.nVal = NumColWidth;
				numColWidth.unit = VwUnit.kunPoint1000;
				vwenv.MakeColumns(1, numColWidth);
				VwLength colWidth = new VwLength();
				colWidth.nVal = 1;
				colWidth.unit = VwUnit.kunRelative;
				int followingCols = ConstituentChartLogic.NumberOfExtraColumns -
					ConstituentChartLogic.IndexOfFirstTemplateColumn;
				vwenv.MakeColumns(m_chart.AllColumns.Length + followingCols, colWidth);
			}
			else
			{
				foreach (VwLength colWidth in m_colWidths)
				{
					vwenv.MakeColumns(1, colWidth);
				}
			}
			// Set row bottom border color and size of table body rows
			if (!fHeader)
			{
				if (ConstituentChartLogic.GetFeature(vwenv.DataAccess, hvo, "endSent"))
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor,
						(int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(Color.Black));
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 1000);
				}
				else
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor,
						(int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(Color.LightGray));
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 500);
				}
			}

			vwenv.OpenTableRow();
		}
Exemple #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
        /// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
        /// need to separate this from applying the properties.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="paraHvo"></param>
        /// <param name="frag"></param>
        /// <param name="fApplyProps"></param>
        /// <param name="contentType"></param>
        /// <param name="vc">The view constructor used to create the paragraphs</param>
        /// ------------------------------------------------------------------------------------
        protected void InsertParagraphBody(IVwEnv vwenv, int paraHvo, int frag, bool fApplyProps,
                                           ContentTypes contentType, StVc vc)
        {
            vc.SetupWsAndDirectionForPara(vwenv, paraHvo);

            if (fApplyProps)
            {
                ApplyParagraphStyleProps(vwenv, paraHvo, vc);
            }

            // This was causing assertions in the layoutmgr
            // TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
            //			if (DisplayTranslation)
            //			{
            //				// display the back translation text as double spaced
            //				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
            //					(int)FwTextPropVar.ktpvRelative, 20000);
            //			}
            // The body of the paragraph is either editable or not.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                  vc.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
            // Make the paragraph containing the paragraph contents.
            OpenPara(vwenv, paraHvo);
            // Cause a regenerate when the style changes...this is mainly used for Undo.
            vwenv.NoteDependency(new[] { paraHvo }, new[] { StParaTags.kflidStyleRules }, 1);
            // Insert the label if it is the first paragraph.
            if (vc.Label != null)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(paraHvo, vc, (int)StTextFrags.kfrLabel);
                }
            }
            if (frag == (int)StTextFrags.kfrFootnotePara)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                // Note a dependency on the footnote options so that the footnote will
                // be refreshed when these are changed.
                // If this is the 1st paragraph in the footnote...
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteReference);
                }
            }

            if (contentType == ContentTypes.kctSimpleBT)
            {
                // If a translation is being shown instead of the paragraph, then show it instead
                // of the text of the paragraph.
                vwenv.AddObj(GetTranslationForPara(paraHvo), vc, (int)StTextFrags.kfrTranslation);
                if (!PrintLayout)
                {
                    // This dependency is here so that the "Missing" prompt will be added to the
                    // view when the first character is typed in the contents. But to solve the
                    // problem with losing the IP when typing (FWR-1415), the dependency is not
                    // added in print layout views. The missing prompt seems less of a problem
                    // than the problem with typing.
                    vwenv.NoteDependency(new[] { paraHvo }, new[] { StTxtParaTags.kflidContents }, 1);
                }
            }
            else if (contentType == ContentTypes.kctSegmentBT)
            {
                vwenv.AddObjVecItems(StTxtParaTags.kflidSegments, vc, (int)StTextFrags.kfrSegmentFreeTranslations);
            }
            else if (!InsertParaContentsUserPrompt(vwenv, paraHvo))
            {
                // Display the text paragraph contents, or its user prompt.
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
            }

            // Display an "end-of-paragraph" marker if needed
            InsertEndOfParaMarks(vwenv, paraHvo);

            vwenv.CloseParagraph();
        }
Exemple #14
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;
            }
        }
Exemple #15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            if ((m_displayType & DisplayType.kLiteralStringLabels) != 0)
            {
                ITsStrFactory factory = TsStrFactoryClass.Create();
                vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault));
            }
            switch (frag)
            {
            case 1:                     // the root; display the subitems, first using non-lazy view, then lazy one.
                if ((m_displayType & DisplayType.kBookFootnoteDetailsSeparateParas) == DisplayType.kBookFootnoteDetailsSeparateParas)
                {
                    vwenv.AddObjVecItems(m_flid, this, 10);
                }
                if ((m_displayType & DisplayType.kBookFootnoteDetailsSinglePara) == DisplayType.kBookFootnoteDetailsSinglePara)
                {
                    vwenv.AddObjVecItems(m_flid, this, 11);
                }
                else
                {
                    if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal)
                    {
                        vwenv.AddObjVecItems(m_flid, this, 3);
                    }
                    if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy)
                    {
                        vwenv.AddObjVecItems(m_flid, this, 2);
                    }
                }
                if ((m_displayType & DisplayType.kBookTitle) == DisplayType.kBookTitle)
                {
                    vwenv.AddObjProp(ScrBookTags.kflidTitle, this, 3);
                }
                if (m_displayType == DisplayType.kOuterObjDetails)
                {
                    vwenv.AddObjVecItems(m_flid, this, 6);
                }
                break;

            case 2:                     // An StText, display paragraphs lazily
                if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin)
                {
                    vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 4);
                }
                vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, 5);
                break;

            case 3:                     // An StText, display paragraphs not lazily.
                if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin)
                {
                    vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 4);
                }
                vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5);
                if ((m_displayType & DisplayType.kDuplicateParagraphs) != 0)
                {
                    vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 5);
                }
                break;

            case 4:                     // StTxtPara, display contents with top margin
                if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara)
                {
                    vwenv.OpenMappedPara();
                }
                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
                                      (int)FwTextPropVar.ktpvMilliPoint, kMarginTop);
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara)
                {
                    vwenv.CloseParagraph();
                }
                break;

            case 5:                     // StTxtPara, display contents without top margin
                                        //vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
                                        //    (int)FwTextPropVar.ktpvMilliPoint, 15000);
                if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara)
                {
                    vwenv.OpenMappedPara();
                }
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                if ((m_displayType & DisplayType.kMappedPara) == DisplayType.kMappedPara)
                {
                    vwenv.CloseParagraph();
                }
                break;

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

            case ScrBookTags.kflidSections:
                vwenv.AddObjVecItems(ScrBookTags.kflidSections, this,
                                     ScrSectionTags.kflidContent);
                break;

            case ScrSectionTags.kflidHeading:
            case ScrSectionTags.kflidContent:
                if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal)
                {
                    vwenv.AddObjProp(frag, this, 3);
                }
                if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy)
                {
                    vwenv.AddObjProp(frag, this, 2);
                }
                break;

            case 7:                     // ScrBook
                vwenv.OpenDiv();
                vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this, 8);
                vwenv.CloseDiv();
                break;

            case 8:                     // StFootnote
                vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
                                     9);
                break;

            case 9:                     // StTxtPara
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                break;

            case 10:
                // Display a Footnote by displaying its "FootnoteMarker" in a paragraph
                // by itself, followed by the sequence of paragraphs.
                vwenv.AddStringProp(StFootnoteTags.kflidFootnoteMarker, null);
                vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
                                     9);
                break;

            case 11:
                // Display a Footnote by displaying its "FootnoteMarker" followed by the
                // contents of its first paragraph (similar to the way footnotes are displayed in
                // real life.
                vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this, 12);
                break;

            case 12:                     // Footnote paragraph with marker
                vwenv.OpenMappedTaggedPara();
                // The footnote marker is not editable.
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)TptEditable.ktptNotEditable);

                // add a read-only space after the footnote marker
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)TptEditable.ktptNotEditable);
                ITsStrFactory strFactory = TsStrFactoryClass.Create();
                vwenv.AddString(strFactory.MakeString(" ", DefaultWs));
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
                vwenv.CloseParagraph();
                break;

            default:
                throw new ApplicationException("Unexpected frag in DummyBasicViewVc");
            }
        }
Exemple #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			if ((m_displayType & DisplayType.kLiteralStringLabels) != 0)
			{
				ITsStrFactory factory = TsStrFactoryClass.Create();
				vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault));
			}
			switch(frag)
			{
				case 1: // the root; display the subitems, first using non-lazy view, then lazy one.
					if ((m_displayType & DisplayType.kFootnoteDetailsSeparateParas) == DisplayType.kFootnoteDetailsSeparateParas)
						vwenv.AddObjVecItems(m_flid, this, 10);
					if ((m_displayType & DisplayType.kFootnoteDetailsSinglePara) == DisplayType.kFootnoteDetailsSinglePara)
						vwenv.AddObjVecItems(m_flid, this, 11);
					else
					{
						if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal)
						{
							vwenv.AddObjVecItems(m_flid, this, 3);
						}
						if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy)
						{
							vwenv.AddObjVecItems(m_flid, this, 2);
						}
					}
					if ((m_displayType & DisplayType.kTitle) == DisplayType.kTitle)
						vwenv.AddObjProp(SimpleRootsiteTestsConstants.kflidDocTitle, this, 3);
					if (m_displayType == DisplayType.kOuterObjDetails)
						vwenv.AddObjVecItems(m_flid, this, 6);
					break;
				case 2: // An StText, display paragraphs lazily
					if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin)
						vwenv.AddLazyVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 4);
					vwenv.AddLazyVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5);
					break;
				case 3: // An StText, display paragraphs not lazily.
					if ((m_displayType & DisplayType.kWithTopMargin) == DisplayType.kWithTopMargin)
						vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 4);
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5);
					if ((m_displayType & DisplayType.kDuplicateParagraphs) != 0)
						vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 5);
					break;
				case 4: // StTxtPara, display contents with top margin
					OpenParaIfNeeded(vwenv, hvo);
					vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
						(int)FwTextPropVar.ktpvMilliPoint, kMarginTop);
					AddParagraphContents(vwenv);
					break;
				case 5: // StTxtPara, display contents without top margin
					OpenParaIfNeeded(vwenv, hvo);
					AddParagraphContents(vwenv);
					break;
				case 6: // StTxtPara, display details of our outer object
					int hvoOuter, tag, ihvo;
					vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
					ITsString tss = TsStringHelper.MakeTSS("Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
						m_wsDefault);
					vwenv.AddString(tss);
					break;
				case SimpleRootsiteTestsConstants.kflidDocDivisions:
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidDocDivisions, this,
						SimpleRootsiteTestsConstants.kflidSectionStuff);
					break;
				case SimpleRootsiteTestsConstants.kflidSectionStuff:
					if ((m_displayType & DisplayType.kNormal) == DisplayType.kNormal)
						vwenv.AddObjProp(frag, this, 3);
					if ((m_displayType & DisplayType.kLazy) == DisplayType.kLazy)
						vwenv.AddObjProp(frag, this, 2);
					break;
				case 7: // ScrBook
					vwenv.OpenDiv();
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidDocFootnotes, this, 8);
					vwenv.CloseDiv();
					break;
				case 8: // StFootnote
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this,
						9);
					break;
				case 9: // StTxtPara
					vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null);
					break;
				case 10:
					// Display a Footnote by displaying its "FootnoteMarker" in a paragraph
					// by itself, followed by the sequence of paragraphs.
					vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidFootnoteMarker, null);
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this,
						9);
					break;
				case 11:
					// Display a Footnote by displaying its "FootnoteMarker" followed by the
					// contents of its first paragraph (similar to the way footnotes are displayed in
					// real life.
					vwenv.AddObjVecItems(SimpleRootsiteTestsConstants.kflidTextParas, this, 12);
					break;
				case 12: // Footnote paragraph with marker
					vwenv.OpenMappedTaggedPara();
					// The footnote marker is not editable.
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
					vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidFootnoteMarker, null);

					// add a read-only space after the footnote marker
					vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
						(int)FwTextPropVar.ktpvEnum,
						(int)TptEditable.ktptNotEditable);
					ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();
					strBldr.Append(" ");
					vwenv.AddString(strBldr.GetString());
					vwenv.AddStringProp(SimpleRootsiteTestsConstants.kflidParaContents, null);
					vwenv.CloseParagraph();
					break;
				default:
					throw new ApplicationException("Unexpected frag in DummyBasicViewVc");
			}
		}
Exemple #17
0
			internal override void PerformDisplay(XmlVc vc, int fragId, int hvo, IVwEnv vwenv)
			{
				int level = vwenv.EmbeddingLevel;
				int hvoDum, tag, ihvo;
				vwenv.GetOuterObject(level - 2, out hvoDum, out tag, out ihvo);
				m_creator.SetupParagraph(m_paraStyle, m_tssBefore, m_listDelimitNode);
				m_creator.AddItemEmbellishments(m_listDelimitNode, m_numberItems, hvo, ihvo, m_xaNum, m_ttpNum, m_delayNumber, ref DelayedNumber);

				// This is the display of the object we wanted to wrap the paragraph etc around.
				// We want to produce an effect rather like
				// vwenv.AddObj(hvo, m_creator.m_viewConstructor, WrappedFragId);
				// except we do NOT want to open/close an object in the VC, since we are already inside the addition of this object.
				m_creator.m_viewConstructor.Display(vwenv, hvo, WrappedFragId);

				// Close Paragraph if displaying paragraphs
				vwenv.CloseParagraph();
			}
Exemple #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
        /// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
        /// need to separate this from applying the properties.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// <param name="fApplyProps"></param>
        /// <param name="contentType"></param>
        /// <param name="vc">The view constructor used to create the paragraphs</param>
        /// ------------------------------------------------------------------------------------
        protected void InsertParagraphBody(IVwEnv vwenv, int hvo, int frag, bool fApplyProps,
                                           ContentTypes contentType, StVc vc)
        {
            vc.SetupWsAndDirectionForPara(vwenv, hvo);

            if (fApplyProps)
            {
                ApplyParagraphStyleProps(vwenv, hvo, vc);
            }

            // This was causing assertions in the layoutmgr
            // TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
            //			if (DisplayTranslation)
            //			{
            //				// display the back translation text as double spaced
            //				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
            //					(int)FwTextPropVar.ktpvRelative, 20000);
            //			}
            // The body of the paragraph is either editable or not.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  vc.Editable ? (int)TptEditable.ktptIsEditable
                                : (int)TptEditable.ktptNotEditable);
            // Make the paragraph containing the paragraph contents.
            OpenPara(vwenv, hvo);
            // Cause a regenerate when the style changes...this is mainly used for Undo.
            vwenv.NoteDependency(new int[] { hvo },
                                 new int[] { (int)StPara.StParaTags.kflidStyleRules }, 1);
            // Insert the label if it is the first paragraph.
            if (vc.Label != null)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvo, vc, (int)StTextFrags.kfrLabel);
                }
            }
            if (frag == (int)StTextFrags.kfrFootnotePara)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                // Note a dependency on the footnote options so that the footnote will
                // be refreshed when these are changed.
                int[] depHvos = { hvoOuter };
                int[] depTags = { StFootnote.ktagFootnoteOptions };
                vwenv.NoteDependency(depHvos, depTags, 1);
                // If this is the 0th paragraph in the footnote...
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
                    vwenv.AddObj(hvoOuter, /*vc.Parent != null ? vc.Parent :*/ vc,
                                 (int)StTextFrags.kfrFootnoteReference);
                }
            }

            if (contentType == ContentTypes.kctSimpleBT)
            {
                // If a translation is being shown instead of the paragraph, then show it instead
                // of the text of the paragraph.
                int transHvo = GetTranslationForPara(hvo);
                vwenv.AddObj(transHvo, vc, (int)StTextFrags.kfrTranslation);
                vwenv.NoteDependency(new int[] { hvo },
                                     new int[] { (int)StTxtPara.StTxtParaTags.kflidContents }, 1);
            }
            else if (contentType == ContentTypes.kctSegmentBT)
            {
                InsertBtSegments(vc, vwenv, hvo);
            }
            else if (!InsertParaContentsUserPrompt(vwenv, hvo))
            {
                // Display the text paragraph contents, or its user prompt.
                vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
            }

            // Display an "end-of-paragraph" marker if needed
            InsertEndOfParaMarks(vwenv, hvo);

            vwenv.CloseParagraph();
        }
Exemple #19
0
		// Get a default analysis for the current twfic, which is the next object out
		// in the display hierarchy, if it's in the cache.
		// (If not don't try to read it, it's a fake property the cache doesn't know how to load.
		// Just return the hvoDefault, which is the current analysis of the twfic.)
		private int GetDefault(IVwEnv vwenv, int hvoDefault)
		{
			int hvoTwfic, tag, index;
			vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoTwfic, out tag, out index);
			if (m_cache.MainCacheAccessor.get_IsPropInCache(hvoTwfic, ktagTwficDefault,
				(int)CellarModuleDefns.kcptReferenceAtom, 0))
			{

				int hvoResult = m_cache.GetObjProperty(hvoTwfic, ktagTwficDefault);
				if (hvoResult != 0)
					return hvoResult;  // may have been cleared by setting to zero.
			}
			return hvoDefault;
		}
Exemple #20
0
		/// <summary>
		/// Make a 'standard' row. Used for both header and body.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="fHeader">true if it is a header; hvo is a chart instead of a row.</param>
		private void MakeTableAndRowWithStdWidths(IVwEnv vwenv, int hvo, bool fHeader)
		{
			IConstChartRow row = null;
			if (!fHeader)
				row = m_rowRepo.GetObject(hvo);
			var tableWidth = new VwLength();
			if (m_colWidths == null)
			{
				tableWidth.nVal = 10000; // 100%
				tableWidth.unit = VwUnit.kunPercent100;
			}
			else
			{
				tableWidth.nVal = 0;
				foreach (var w in m_colWidths)
					tableWidth.nVal += w.nVal;
				tableWidth.unit = VwUnit.kunPoint1000;
			}
			if (!fHeader)
				SetRowStyle(vwenv, row);

			var fpos = VwFramePosition.kvfpVsides;
			if (fHeader)
			{
				fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpAbove);
			}
			else
			{
				int hvoOuter, tagOuter, ihvoRow;
				vwenv.GetOuterObject(0, out hvoOuter, out tagOuter, out ihvoRow);
				if (ihvoRow == 0)
				{
					fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpAbove);
				}
				if (ihvoRow == vwenv.DataAccess.get_VecSize(hvoOuter, tagOuter) - 1
					|| row.EndParagraph)
				{
					fpos = (VwFramePosition)((int)fpos | (int)VwFramePosition.kvfpBelow);
				}
			}
			// We seem to typically inherit a white background as a side effect of setting our stylesheet,
			// but borders on table rows don't show through if backcolor is set to white, because the
			// cells entirely cover the row (LT-9068). So force the back color to be transparent, and allow
			// the row border to show through the cell.
			var fRtL = m_chart.IsRightToLeft;
			vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)FwTextColor.kclrTransparent);
			vwenv.OpenTable(m_chart.AllColumns.Length + ConstituentChartLogic.NumberOfExtraColumns,
				tableWidth,
				1500, // borderWidth
				fRtL ? VwAlignment.kvaRight : VwAlignment.kvaLeft, // Handle RTL
				fpos,
				VwRule.kvrlNone,
				0, // cell spacing
				2000, // cell padding
				true); // selections limited to one cell.
			if (m_colWidths == null)
			{
				if (fRtL)
				{
					MakeColumnsOtherThanRowNum(vwenv);
					MakeRowNumColumn(vwenv);
				}
				else
				{
					MakeRowNumColumn(vwenv);
					MakeColumnsOtherThanRowNum(vwenv);
				}
			}
			else
			{
				foreach (var colWidth in m_colWidths)
					vwenv.MakeColumns(1, colWidth);
			}
			// Set row bottom border color and size of table body rows
			if (!fHeader)
			{
				if (row.EndSentence)
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor,
						(int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(Color.Black));
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 1000);
				}
				else
				{
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor,
						(int)FwTextPropVar.ktpvDefault,
						(int)ColorUtil.ConvertColorToBGR(Color.LightGray));
					vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
						(int)FwTextPropVar.ktpvMilliPoint, 500);
				}
			}

			vwenv.OpenTableRow();
		}
Exemple #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 = ctxtOrVar as IPhSequenceContext;
							if (seqCtxt.MembersRS.Count > 0)
							{
								vwenv.AddObjVecItems(PhSequenceContextTags.kflidMembers, this, kfragContext);
							}
							else
							{
								OpenContextPile(vwenv, false);
								vwenv.Props = m_bracketProps;
								vwenv.AddProp(PhSequenceContextTags.kflidMembers, this, kfragEmpty);
								CloseContextPile(vwenv, false);
							}
							break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case kfragMinusVariable:
                vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
                break;
            }
        }
Exemple #23
0
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				switch(frag)
				{
					case 1:
					{
						// The top-level.
						// Enhance JohnT: add a property setting to make the key bold
						// Roughly, vwenv.set_IntProperty(ktptBold, ktpvEnum, kttvForceOn);
						// If we can get an hvo and flid, display that property of that object.
						int flid = 0;
						if (hvo != 0)
						{
							flid = m_cp.FlidFor(m_index, hvo);
						}
						if (flid != 0)
						{
							// Warning (JohnT): this option not yet tested...
							vwenv.AddStringProp(flid, this);
							return;
						}
						else
						{
							// Otherwise display a literal string straight from the policy object.
							vwenv.AddString(m_cp.KeyFor(m_index, hvo));
						}

						if (m_fExpanded)
						{
							vwenv.AddLazyVecItems(m_ni.ListFlid, this, 2);
						}
						break;
					}
					case 2:
					{
						// One line of context.

						// Figure the index of this object in the next object out (the root).
						int hvoOuter, tagOuter, ihvo;
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1,
							out hvoOuter, out tagOuter, out ihvo);
						int ichKey = m_ni.ContextStringStartOffset(ihvo, hvo);
						int cchKey = m_ni.ContextStringLength(ihvo, hvo);
						// Enhance JohnT: make the alignment position a function of window width.
						// Enhance JohnT: change background if this is the selected context line.
						vwenv.OpenConcPara(ichKey, ichKey + cchKey,
							VwConcParaOpts.kcpoDefault,
							72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints.
						int flidKey = m_ni.ContextStringFlid(ihvo, hvo);
						if (flidKey == 0)
						{
							// Not tested yet.
							vwenv.AddString(m_ni.ContextString(ihvo, hvo));
						}
						else
						{
							vwenv.AddStringProp(flidKey, this);
						}
						vwenv.CloseParagraph();
						break;
					}
				}
			}
			/// ------------------------------------------------------------------------------------
			/// <summary>
			///
			/// </summary>
			/// <param name="vwenv"></param>
			/// <param name="hvo"></param>
			/// <param name="frag"></param>
			/// ------------------------------------------------------------------------------------
			public override void Display(IVwEnv vwenv, int hvo, int frag)
			{
				CheckDisposed();

				int hvoOuter, tag, ihvo;
				ITsString tss;
				switch (frag)
				{
					case 1: // A ScrBook; display the title.
						vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, this, 2);
						break;
					case 2: // An StText; display the paragraphs.
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							InMemoryFdoCache.s_wsHvos.Fr);
						vwenv.AddString(tss);
						vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, 3);
						break;
					case 3: // StTxtPara, display details of our outer object
						vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoOuter, out tag, out ihvo);
						tss = TsStringHelper.MakeTSS(
							"Hvo = " + hvoOuter + "; Tag = " + tag + "; Ihvo = " + ihvo,
							InMemoryFdoCache.s_wsHvos.Fr);
						vwenv.AddString(tss);
						break;
					default:
						throw new ApplicationException("Unexpected frag in DummyCollectorEnvVc");
				}
			}
		private void AddTableCell(IVwEnv vwenv, int hvo, int index, int hvoRoot, int icolActive, int cAdjCol, int icol)
		{
			XmlNode node = m_columns[icol - 1];
			// Figure out the underlying Right-To-Left value.
			bool fRightToLeft = false;
			// Figure out if this column's writing system is audio.
			bool fVoice = false;
			m_wsBest = GetBestWsForNode(node, hvo);
			if (m_wsBest != 0)
			{
				var ws = m_cache.ServiceLocator.WritingSystemManager.Get(m_wsBest);
				if (ws != null)
				{
					fRightToLeft = ws.RightToLeftScript;
					var wsDef = ws as WritingSystemDefinition;
					fVoice = wsDef == null ? false : wsDef.IsVoice;
				}
			}
			bool fSortedFromEnd = m_xbv.ColumnSortedFromEnd(icol - cAdjCol);
			int tal;
			if (fRightToLeft)
			{
				if (fSortedFromEnd)
					tal = (int)FwTextAlign.ktalLeft;
				else
					tal = (int)FwTextAlign.ktalRight;
			}
			else
			{
				if (fSortedFromEnd)
					tal = (int)FwTextAlign.ktalRight;
				else
					tal = (int)FwTextAlign.ktalLeft;
			}
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum, tal);

			// If this cell is audio, don't allow editing.
			if (fVoice)
				SetCellEditability(vwenv, false);

			bool fIsCellActive = false;
			if (icolActive != 0 && m_PreviewArrowPic != null)
			{
				// The display depends on which column is active and whether the current row is selected.
				vwenv.NoteDependency(new int[] { hvoRoot, hvo, hvo }, new int[] { XMLViewsDataCache.ktagActiveColumn, XMLViewsDataCache.ktagItemSelected, XMLViewsDataCache.ktagItemEnabled }, 3);
				// We're doing the active column thing.
				if (MultiColumnPreview)
				{
					fIsCellActive = vwenv.DataAccess.get_IntProp(hvo, XMLViewsDataCache.ktagItemSelected) != 0
									&& vwenv.DataAccess.get_StringProp(hvo, XMLViewsDataCache.ktagAlternateValueMultiBase + icol).Length > 0;
				}
				else if (icol == icolActive)
				{
					fIsCellActive = vwenv.DataAccess.get_IntProp(hvo, XMLViewsDataCache.ktagItemSelected) != 0
						&& vwenv.DataAccess.get_IntProp(hvo, XMLViewsDataCache.ktagItemEnabled) != 0;
				}
			}
			// Make a cell and embed the contents of the column node.
			ProcessProperties(node, vwenv);
			SetCellProperties(index, icol, node, hvo, vwenv, fIsCellActive);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			vwenv.OpenTableCell(1, 1);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading,
				(int)FwTextPropVar.ktpvMilliPoint, 1607);
			if (node.Name == "column")
			{
				// Paragraph directionality must be set before the paragraph is opened.
				vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
					(int)FwTextPropVar.ktpvEnum, IsWritingSystemRTL(node) ? -1 : 0);
			}

			// According to LT-8947, in bulk edit preview mode, we want to try to show the
			// original cell contents on the same line with the preview arrow and the new cell contents.
			// to accomplish this, we use 3 InnerPiles in a paragraph
			// to try to keep them on the same line (or wrap otherwise).
			// NOTE: the bottom two inner piles will only be present if fIsCellActive is true.
			//
			// <Paragraph>
			//		<InnerPile>
			//			<paragraph> Original cell contents </paragraph>
			//		</InnerPile>
			//		<InnerPile>
			//			<paragraph> Arrow Picture </paragraph>
			//		</InnerPile>
			//		<InnerPile>
			//			<paragraph> Alternate cell contents </paragraph>
			//		</InnerPile>
			// </Paragraph>
			//

			vwenv.OpenParagraph();			// <Paragraph>
			bool multiPara = XmlUtils.GetOptionalBooleanAttributeValue(node, "multipara", false);
			vwenv.OpenInnerPile();			//		<InnerPile>
			// if the multi-para attribute is not specified, create a paragraph to wrap the cell contents.
			bool fParaOpened = false;
			if (!multiPara)
			{
				vwenv.OpenParagraph();		//			<paragraph>
				fParaOpened = true;
			}

			if (m_sortItemProvider == null)
			{
				try
				{
					if (node.Name == "column")
					{
						SetForcedWs(node);
					}
				XmlNode nodeToProcess = GetColumnNode(node, hvo, m_sda, m_layouts);
				ProcessChildren(nodeToProcess, vwenv, hvo, null);
			}
				finally
				{
					// reset the ws for next column in the row.
					WsForce = 0;
				}
			}
			else
			{
				int level = vwenv.EmbeddingLevel;
				int hvoDum, tag, ihvo;
				vwenv.GetOuterObject(level - 2, out hvoDum, out tag, out ihvo);
				Debug.Assert(tag == m_fakeFlid);
				IManyOnePathSortItem item = m_sortItemProvider.SortItemAt(ihvo);
				if (item != null)
				DisplayCell(item, node, hvo, vwenv);	// (Original) cell contents
			}

			if (fParaOpened)
			{
				vwenv.CloseParagraph();		//			   (Original) cell contents </paragraph>
				fParaOpened = false;
			}
			vwenv.CloseInnerPile();			//		</InnerPile>
			if (fIsCellActive)
				AddPreviewPiles(vwenv, node, icol);
			vwenv.CloseParagraph();			// </Paragraph>
			vwenv.CloseTableCell();
			m_wsBest = 0;
		}
Exemple #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The main method just displays the text with the appropriate properties.
		/// </summary>
		/// <param name="vwenv">The view environment</param>
		/// <param name="hvo">The HVo of the object to display</param>
		/// <param name="frag">The fragment to lay out</param>
		/// ------------------------------------------------------------------------------------
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			CheckDisposed();

			switch (frag)
			{
				case InnerFwListBox.kfragRoot:
					Font f = m_listbox.Font;
					if (m_listbox.StyleSheet == null)
					{
						// Try to get items a reasonable size based on whatever font has been set for the
						// combo as a whole. We don't want to do this if a stylesheet has been set, because
						// it will override the sizes specified in the stylesheet.
						// Enhance JohnT: there are several more properties we could readily copy over
						// from the font, but this is a good start.
						vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
							(int)FwTextPropVar.ktpvMilliPoint, (int)(f.SizeInPoints * 1000));
					}
					// Setting the font family here appears to override the fonts associated with the
					// TsString data.  This causes trouble for non-Microsoft Sans Serif writing systems.
					// See LT-551 for the bug report that revealed this problem.
					//				vwenv.set_StringProperty((int) FwTextPropType.ktptFontFamily,
					//					f.FontFamily.Name);
					vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
						(int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(m_listbox.ForeColor));
					DisplayList(vwenv);
					break;
				case InnerFwListBox.kfragItems:
					int index, hvoDummy, tagDummy;
					int clev = vwenv.EmbeddingLevel;
					vwenv.GetOuterObject(clev - 1, out hvoDummy, out tagDummy, out index);
					bool fHighlighted = m_listbox.Owner.IsHighlighted(index);
					if (fHighlighted && m_listbox.ShowHighlight)
					{
						vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
							(int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.HighlightText)));
						vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
							(int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Highlight)));
					}
					vwenv.OpenParagraph();
					if (fHighlighted && m_listbox.ShowHighlight)
					{
						// Insert a string that has the foreground color not set, so the foreground color set above can take effect.
						ITsStrBldr bldr = vwenv.DataAccess.get_StringProp(hvo, InnerFwListBox.ktagText).GetBldr();
						bldr.SetIntPropValues(0, bldr.Length, (int) FwTextPropType.ktptForeColor, -1, -1);
						vwenv.AddString(bldr.GetString());
					}
					else
					{
						vwenv.AddStringProp(InnerFwListBox.ktagText, this);
					}
					vwenv.AddString(m_tssBlanks);
					vwenv.CloseParagraph();
					break;
			}
		}
Exemple #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
		/// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
		/// need to separate this from applying the properties.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// <param name="fApplyProps"></param>
		/// <param name="contentType"></param>
		/// <param name="vc">The view constructor used to create the paragraphs</param>
		/// ------------------------------------------------------------------------------------
		protected void InsertParagraphBody(IVwEnv vwenv, int hvo, int frag, bool fApplyProps,
			ContentTypes contentType, StVc vc)
		{
			vc.SetupWsAndDirectionForPara(vwenv, hvo);

			if (fApplyProps)
				ApplyParagraphStyleProps(vwenv, hvo, vc);

			// This was causing assertions in the layoutmgr
			// TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
			//			if (DisplayTranslation)
			//			{
			//				// display the back translation text as double spaced
			//				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
			//					(int)FwTextPropVar.ktpvRelative, 20000);
			//			}
			// The body of the paragraph is either editable or not.
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum,
				vc.Editable ? (int)TptEditable.ktptIsEditable
				: (int)TptEditable.ktptNotEditable);
			// Make the paragraph containing the paragraph contents.
			OpenPara(vwenv, hvo);
			// Cause a regenerate when the style changes...this is mainly used for Undo.
			vwenv.NoteDependency(new int[] {hvo},
				new int[] {(int)StPara.StParaTags.kflidStyleRules}, 1);
			// Insert the label if it is the first paragraph.
			if (vc.Label != null)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				if (ihvoItem == 0)
					vwenv.AddObj(hvo, vc, (int)StTextFrags.kfrLabel);
			}
			if (frag == (int)StTextFrags.kfrFootnotePara)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				// Note a dependency on the footnote options so that the footnote will
				// be refreshed when these are changed.
				int[] depHvos = { hvoOuter };
				int[] depTags = { StFootnote.ktagFootnoteOptions };
				vwenv.NoteDependency(depHvos, depTags, 1);
				// If this is the 0th paragraph in the footnote...
				if (ihvoItem == 0)
				{
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
					vwenv.AddObj(hvoOuter, /*vc.Parent != null ? vc.Parent :*/ vc,
						(int)StTextFrags.kfrFootnoteReference);
				}
			}

			if (contentType == ContentTypes.kctSimpleBT)
			{
				// If a translation is being shown instead of the paragraph, then show it instead
				// of the text of the paragraph.
				int transHvo = GetTranslationForPara(hvo);
				vwenv.AddObj(transHvo, vc, (int)StTextFrags.kfrTranslation);
				vwenv.NoteDependency(new int[] {hvo},
					new int[] {(int)StTxtPara.StTxtParaTags.kflidContents}, 1);
			}
			else if (contentType == ContentTypes.kctSegmentBT)
			{
				InsertBtSegments(vc, vwenv, hvo);
			}
			else if (!InsertParaContentsUserPrompt(vwenv, hvo))
			{
				// Display the text paragraph contents, or its user prompt.
				vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
			}

			// Display an "end-of-paragraph" marker if needed
			InsertEndOfParaMarks(vwenv, hvo);

			vwenv.CloseParagraph();
		}
		/// <summary>
		/// All our display method does is to display the name of each item in the fake virtual property.
		/// If it is the active object we are editing, at the relevant position in the relevant owner,
		/// we display the name using the special marker property.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		public override void Display(IVwEnv vwenv, int hvo, int frag)
		{
			int hvoParent, tag, ihvo;
			switch(frag)
			{
			case kfragName:
				vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoParent, out tag, out ihvo);
				if (m_fGotFocus && hvo == m_hvoTa && hvoParent == m_hvoParent && ihvo == m_ihvoTa)
					vwenv.AddStringProp(m_taTagName, this);
				else
					vwenv.AddStringProp(m_snTagName, this);
				break;
			default:
				throw new Exception("Unexpected fragment ID in TypeAheadSupportVc");
			}
		}
		private bool InEditableRow(IVwEnv vwenv)
		{
			int hvoTop, tag, ihvo;
			vwenv.GetOuterObject(1, out hvoTop, out tag, out ihvo);
			return m_editableHvos.Contains(hvoTop);
		}
		protected override void AddWordBundleInternal(int hvo, IVwEnv vwenv)
		{
			// Determine whether it is the focus box occurrence.
			if (FocusBoxOccurrence != null)
			{
				int hvoSeg, tag, ihvo;
				vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoSeg, out tag, out ihvo);
				if (hvoSeg == FocusBoxOccurrence.Segment.Hvo && ihvo == FocusBoxOccurrence.Index)
				{
					// Leave room for the Sandbox instead of displaying the internlinear data.
					// The first argument makes it invisible in case a little bit of it shows around
					// the sandbox.
					// The last argument puts the 'Baseline' of the sandbox (which aligns with the base of the
					// first line of text) an appropriate distance from the top of the Sandbox. This aligns it's
					// top line of text properly.
					// Enhance JohnT: 90% of font height is not always exactly right, but it's the closest
					// I can get wihtout a new API to get the exact ascent of the font.
					int dympBaseline = Common.Widgets.FontHeightAdjuster.
						GetFontHeightForStyle("Normal", m_stylesheet, m_wsVernForDisplay,
						m_cache.LanguageWritingSystemFactoryAccessor) * 9 / 10;
					uint transparent = 0xC0000000; // FwTextColor.kclrTransparent won't convert to uint
					vwenv.AddSimpleRect((int)transparent,
										FocusBoxSize.Width, FocusBoxSize.Height, -(FocusBoxSize.Height - dympBaseline));
					return;
				}
			}
			base.AddWordBundleInternal(hvo, vwenv);
		}
Exemple #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
		/// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
		/// need to separate this from applying the properties.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="paraHvo"></param>
		/// <param name="frag"></param>
		/// <param name="fApplyProps"></param>
		/// <param name="contentType"></param>
		/// <param name="vc">The view constructor used to create the paragraphs</param>
		/// ------------------------------------------------------------------------------------
		protected void InsertParagraphBody(IVwEnv vwenv, int paraHvo, int frag, bool fApplyProps,
			ContentTypes contentType, StVc vc)
		{
			vc.SetupWsAndDirectionForPara(vwenv, paraHvo);

			if (fApplyProps)
				ApplyParagraphStyleProps(vwenv, paraHvo, vc);

			// This was causing assertions in the layoutmgr
			// TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
			//			if (DisplayTranslation)
			//			{
			//				// display the back translation text as double spaced
			//				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
			//					(int)FwTextPropVar.ktpvRelative, 20000);
			//			}
			// The body of the paragraph is either editable or not.
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
				vc.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
			// Make the paragraph containing the paragraph contents.
			OpenPara(vwenv, paraHvo);
			// Cause a regenerate when the style changes...this is mainly used for Undo.
			vwenv.NoteDependency(new[] {paraHvo}, new[] {StParaTags.kflidStyleRules}, 1);
			// Insert the label if it is the first paragraph.
			if (vc.Label != null)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				if (ihvoItem == 0)
					vwenv.AddObj(paraHvo, vc, (int)StTextFrags.kfrLabel);
			}
			if (frag == (int)StTextFrags.kfrFootnotePara)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				// Note a dependency on the footnote options so that the footnote will
				// be refreshed when these are changed.
				// If this is the 1st paragraph in the footnote...
				if (ihvoItem == 0)
				{
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteReference);
				}
			}

			if (contentType == ContentTypes.kctSimpleBT)
			{
				// If a translation is being shown instead of the paragraph, then show it instead
				// of the text of the paragraph.
				vwenv.AddObj(GetTranslationForPara(paraHvo), vc, (int)StTextFrags.kfrTranslation);
				if (!PrintLayout)
				{
					// This dependency is here so that the "Missing" prompt will be added to the
					// view when the first character is typed in the contents. But to solve the
					// problem with losing the IP when typing (FWR-1415), the dependency is not
					// added in print layout views. The missing prompt seems less of a problem
					// than the problem with typing.
					vwenv.NoteDependency(new[]{paraHvo}, new[]{StTxtParaTags.kflidContents}, 1);
				}
			}
			else if (contentType == ContentTypes.kctSegmentBT)
			{
				vwenv.AddObjVecItems(StTxtParaTags.kflidSegments, vc, (int)StTextFrags.kfrSegmentFreeTranslations);
			}
			else if (!InsertParaContentsUserPrompt(vwenv, paraHvo))
			{
				// Display the text paragraph contents, or its user prompt.
				vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
			}

			// Display an "end-of-paragraph" marker if needed
			InsertEndOfParaMarks(vwenv, paraHvo);

			vwenv.CloseParagraph();
		}