private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { XmlNode node = m_columns[i - 1]; // Make a cell and embed an editable virtual string for the column. var editable = XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true); if (!editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, NoEditBackgroundColor); } vwenv.OpenTableCell(1, 1); int flid = XMLViewsDataCache.ktagEditColumnBase + i; int ws = WritingSystemServices.GetWritingSystem(m_cache, node, null, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle).Handle; // Paragraph directionality must be set before the paragraph is opened. bool fRTL = IsWsRTL(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { string sField = ksEditColumnBaseName + i; XmlNode node = m_columns[i - 1] as XmlNode; // Make a cell and embed an editable virtual string for the column. vwenv.OpenTableCell(1, 1); // Initialize the virtual property. IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField); Debug.Assert(vh != null); int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false); int ws = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs); // Paragraph directionality must be set before the paragraph is opened. bool fRTL = IsWsRTL(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); vh.Load(khvoNewItem, flid, ws, cda); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptIsEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
internal void AddDoublePara(IVwEnv vwenv, int hvo) { // We use a table to display the source WS in column 1, and the dest ws in column 2. FwViews.VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = FwViews.VwUnit.kunPercent100; FwViews.VwLength vlColumn; // and this one to specify half the width for each column vlColumn.nVal = 5000; vlColumn.unit = FwViews.VwUnit.kunPercent100; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? vwenv.OpenTable(2, // Two columns. ref vlTable, // Table uses 100% of available width. 0, // Border thickness. FwViews.VwAlignment.kvaLeft, // Default alignment. FwViews.VwFramePosition.kvfpVoid, // No border. FwViews.VwRule.kvrlNone, // No rules between cells. 3000, // Three points of space between cells. 3000); // Three points padding inside cells. // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(2, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Source cell, not editable vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptEditable, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.TptEditable.ktptNotEditable); vwenv.AddStringAltMember(ktagParaContents, m_wsSrc, this); vwenv.CloseTableCell(); // Dest cell, editable, therefore with white background. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault, m_colorEditable); vwenv.OpenTableCell(1, 1); vwenv.AddStringAltMember(ktagParaContents, m_wsDst, this); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the vernacular paragraph to the table. /// </summary> /// <param name="vwenv">The IVwEnv</param> /// <param name="hvo">The hvo of the paragraph</param> /// <param name="frag">The frag for the paragraph</param> /// <param name="fBorderLeading">if set to <c>true</c> then the border will be on the /// leading edge of the paragraph, otherwise it will be on the trailing edge.</param> /// ------------------------------------------------------------------------------------ private void AddVernParagraph(IVwEnv vwenv, int hvo, int frag, bool fBorderLeading) { vwenv.set_IntProperty(fBorderLeading ? (int)FwTextPropType.ktptBorderLeading : (int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 500); vwenv.set_IntProperty(fBorderLeading ? (int)FwTextPropType.ktptPadLeading : (int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 18000); vwenv.OpenTableCell(1, 1); m_RealVc.InsertParagraphBody(vwenv, hvo, frag, true, StVc.ContentTypes.kctNormal, m_RealVc); vwenv.CloseTableCell(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add a column to the header/footer /// </summary> /// <param name="vwenv"></param> /// <param name="align"></param> /// <param name="flid"></param> /// ------------------------------------------------------------------------------------ private void AddColumn(IVwEnv vwenv, FwTextAlign align, PubHeader.PubHeaderTags flid) { vwenv.OpenTableCell(1, 1); if (HeaderFooterParaStyle != null && HeaderFooterParaStyle != string.Empty) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, HeaderFooterParaStyle); } vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)align); vwenv.OpenMappedPara(); vwenv.AddStringProp((int)flid, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the back translation paragraph to the table. /// </summary> /// <param name="vwenv">The IVwEnv</param> /// <param name="hvo">The hvo of the paragraph</param> /// <param name="frag">The frag for the paragraph</param> /// <param name="fBorderLeading">if set to <c>true</c> then the border will be on the /// leading edge of the paragraph, otherwise it will be on the trailing edge.</param> /// ------------------------------------------------------------------------------------ private void AddBtParagraph(IVwEnv vwenv, int hvo, int frag, bool fBorderLeading) { vwenv.set_IntProperty(fBorderLeading ? (int)FwTextPropType.ktptBorderLeading : (int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 500); vwenv.set_IntProperty(fBorderLeading ? (int)FwTextPropType.ktptPadLeading : (int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 18000); //if (Options.UseInterlinearBackTranslation) //{ // vwenv.set_IntProperty((int) FwTextPropType.ktptBackColor, (int) FwTextPropVar.ktpvDefault, // (int)ColorUtil.ConvertColorToBGR(TeResourceHelper.ReadOnlyTextBackgroundColor)); //} vwenv.OpenTableCell(1, 1); m_RealVc.InsertParagraphBody(vwenv, hvo, frag, true, BtContentType, m_btVc); vwenv.CloseTableCell(); }
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { switch (frag) { case kfragInput: // input context cell foreach (var ctxt in m_rule.InputOS) { vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObj(ctxt.Hvo, this, kfragContext); vwenv.CloseParagraph(); vwenv.CloseTableCell(); } break; default: base.DisplayVec(vwenv, hvo, tag, frag); break; } }
private void DisplayWithWritingSystemLabel(IVwEnv vwenv, int ws) { ITsString tssLabel = NameOfWs(ws); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). vwenv.get_StringWidth(tssLabel, null, out dxs, out dys); VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = dxs + 5000; vlColWs.unit = VwUnit.kunPoint1000; // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. //vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssLabel); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and RTL. if (m_fRtlScript) { vwenv.set_IntProperty((int) FwTextPropType.ktptRightToLeft, (int) FwTextPropVar.ktpvEnum, (int) FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalTrailing); } //if (!m_editable) //{ // vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, // (int)TptEditable.ktptNotEditable); //} vwenv.set_IntProperty((int) FwTextPropType.ktptPadTop, (int) FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.AddStringProp(m_flid, this); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragRHS: m_rhs = new PhSegRuleRHS(m_cache, hvo); IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO); int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = MaxNumLines; int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.GetFlid(hvo, null, "OwningRule"), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetVectorSize(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange) > 0) { vwenv.AddObjVecItems((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext) != 0) { vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_cache.GetObjProperty(hvo, (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext) != 0) { vwenv.AddObjProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseContextPile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_cache.GetVectorSize(hvo, (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc) > 0) { vwenv.AddObjVecItems((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseContextPile(vwenv, false); } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch(frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[]{m_cache.LanguageProject.TranslatedScriptureOA.Hvo}, new[]{ScriptureTags.kflidScriptureBooks}, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); if (!PrintLayout) InsertBookSeparator(hvo, vwenv); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert (m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance<IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance<ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) picture = m_CheckedPic; else if (status == BackTranslationStatus.Finished.ToString()) picture = m_FinishedPic; else picture = m_UnfinishedPic; vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] {hvo}, new [] {CmTranslationTags.kflidStatus}, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } if (!PrintLayout) { InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert(m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) { picture = m_CheckedPic; } else if (status == BackTranslationStatus.Finished.ToString()) { picture = m_FinishedPic; } else { picture = m_UnfinishedPic; } vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] { hvo }, new [] { CmTranslationTags.kflidStatus }, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an expandable annotation of the specified type. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayExpandableAnnotation(IVwEnv vwenv, IScrScriptureNote ann, int tag, int hvo, IStJournalText paras, ITsString label, bool readOnly) { vwenv.NoteDependency(new int[] { hvo }, new int[] { m_expansionTag }, 1); SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display +/- in the second cell, unless this is read-only vwenv.OpenTableCell(1, 1); if (!readOnly) vwenv.AddObjProp(tag, this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display text in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(label); if (!m_expandTable.ContainsKey(hvo)) vwenv.AddString(paras[0].Contents); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); if (!m_expandTable.ContainsKey(hvo)) return; SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display text in cells 3-7 vwenv.OpenTableCell(1, 5); if (!readOnly) SetEditBackground(vwenv); vwenv.AddObjProp(tag, this, (int)StTextFrags.kfrText); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPrintChart: // the whole chart with headings for printing. if (hvo == 0) return; PrintColumnGroupHeaders(hvo, vwenv); PrintIndividualColumnHeaders(hvo, vwenv); // Rest is same as kfragChart DisplayChartBody(vwenv); break; case kfragTemplateHeader: // Display the template as group headers. vwenv.AddObjVecItems((int)CmPossibility.CmPossibilityTags.kflidSubPossibilities, this, kfragColumnGroupHeader); break; // This is only used for printing, the headers in the screen version are a separate control. case kfragColumnGroupHeader: int ccols = vwenv.DataAccess.get_VecSize(hvo, (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities); // If there are no subitems, we still want a blank cell as a placeholder. MakeCellsMethod.OpenStandardCell(vwenv, Math.Max(ccols, 1), true); if (ccols > 0) { // It's a group, include its name vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.OpenParagraph(); vwenv.AddString(CmPossibility.BestAnalysisName(m_cache, hvo)); vwenv.CloseParagraph(); } vwenv.CloseTableCell(); break; case kfragChart: // the whole chart, a DsConstChart. if (hvo == 0) return; DisplayChartBody(vwenv); break; case kfragChartRow: // one row, a CmIndirectAnnotation { MakeTableAndRowWithStdWidths(vwenv, hvo, false); MakeCells(vwenv, hvo); vwenv.CloseTableRow(); vwenv.CloseTable(); } break; case kfragCca: // a single group of words, the contents of one cell. if (ConstituentChartLogic.IsWficGroup(m_cache, hvo)) vwenv.AddObjVec(kflidAppliesTo, this, kfragBundleVec); else { // it's a moved text or missing-item placeholder. int hvoClause; if (m_chart.Logic.IsClausePlaceholder(hvo, out hvoClause)) DisplayClausePlaceholder(vwenv, hvoClause); else if (vwenv.DataAccess.get_VecSize(hvo, kflidAppliesTo) == 0) DisplayMissingMarker(vwenv); else DisplayMovedTextTag(hvo, vwenv); } break; case kfragCcaMoved: // a single group of words, the contents of one cell, which is considered moved-within-line. // can't be a placeholder. string formatTag = m_chart.Logic.MovedTextTag(hvo); ApplyFormatting(vwenv, formatTag); vwenv.OpenSpan(); InsertOpenBracket(vwenv, formatTag); vwenv.AddObjVec(kflidAppliesTo, this, kfragBundleVec); InsertCloseBracket(vwenv, formatTag); vwenv.CloseSpan(); break; case kfragCcaListItem: // a single CCA, referring to a list item. // can't be a placeholder. ApplyFormatting(vwenv, "marker"); vwenv.OpenSpan(); InsertOpenBracket(vwenv, "marker"); vwenv.AddObjProp((int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject, this, kfragPossibility); InsertCloseBracket(vwenv, "marker"); vwenv.CloseSpan(); break; case kfragPossibility: // A CmPossibility, show it's abbreviation int flid = (int)CmPossibility.CmPossibilityTags.kflidAbbreviation; int retWs; m_cache.LangProject.GetMagicStringAlt(LangProject.kwsFirstAnal, hvo, flid, false, out retWs); // If we didn't find an abbreviation try for the name ITsString tss = null; if (retWs != 0) tss = m_cache.GetMultiStringAlt(hvo, flid, retWs); if (tss == null || string.IsNullOrEmpty(tss.Text)) { flid = (int)CmPossibility.CmPossibilityTags.kflidName; m_cache.LangProject.GetMagicStringAlt(LangProject.kwsFirstAnal, hvo, flid, false, out retWs); } // Unless we didn't get anything, go ahead and insert the best option we found. if (retWs != 0) vwenv.AddStringAltMember(flid, retWs, this); // retWS was m_cache.DefaultAnalWs, this fixes LT-7838 break; case kfragBundle: // One annotated word bundle; hvo is CmBaseAnnotation. Overrides behavior of InterlinVc { SetupForTwfic(hvo); // Make an 'inner pile' to contain the wordform and annotations. // 10 points below also helps space out the paragraph. vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeading); vwenv.OpenInnerPile(); // Get the instanceOf property of the annotation and see whether it exists. If not it is // just a punctuation annotation, and we just insert the form. vwenv.NoteDependency(new int[] { hvo }, new int[] { InterlinDocChild.TagAnalysis }, 1); int hvoInstanceOf = vwenv.DataAccess.get_ObjectProp(hvo, InterlinDocChild.TagAnalysis); if (hvoInstanceOf == 0) { vwenv.AddStringProp(m_flidStringValue, this); } else { // It's a full Twfic annotation, display the full bundle. vwenv.AddObjProp(InterlinDocChild.TagAnalysis, this, kfragTwficAnalysis); } //vwenv.AddObjProp(ktagTwficDefault, this, kfragTwficAnalysis); vwenv.CloseInnerPile(); // revert back to the paragraph vernWs. SetupForTwfic(0); } break; case kfragNotesText: // notes structured text vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, kfragNotesPara); break; case kfragNotesPara: vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, this); break; case kfragComment: // hvo is a CmAnnotation, a row vwenv.AddStringAltMember((int)CmAnnotation.CmAnnotationTags.kflidComment, m_chart.Logic.WsLineNumber, this); break; default: base.Display(vwenv, hvo, frag); break; } }
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; }
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag) { switch (frag) { case kfragInput: // input context cell int[] ctxtHvos = m_cache.GetVectorProperty(hvo, tag, false); foreach (int ctxtHvo in ctxtHvos) { vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObj(ctxtHvo, this, kfragContext); vwenv.CloseParagraph(); vwenv.CloseTableCell(); } break; default: base.DisplayVec(vwenv, hvo, tag, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { int userWs = m_cache.DefaultUserWs; switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance <IMoAffixProcessRepository>().GetObject(hvo); int maxNumLines = GetMaxNumLines(); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(3, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength inputLen; inputLen.nVal = 0; inputLen.unit = VwUnit.kunPoint1000; int indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv); int inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv); VwLength headerLen; headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000; headerLen.unit = VwUnit.kunPoint1000; inputLen.nVal += headerLen.nVal; VwLength leftEmptyLen; leftEmptyLen.nVal = 8000 + (PileMargin * 2) + 2000; leftEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += leftEmptyLen.nVal; var ctxtLens = new VwLength[m_rule.InputOS.Count]; vwenv.NoteDependency(new[] { m_rule.Hvo }, new[] { MoAffixProcessTags.kflidInput }, 1); for (int i = 0; i < m_rule.InputOS.Count; i++) { int idxWidth = GetStrWidth(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv); int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv); ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000; ctxtLens[i].unit = VwUnit.kunPoint1000; inputLen.nVal += ctxtLens[i].nVal; } VwLength rightEmptyLen; rightEmptyLen.nVal = 8000 + (PileMargin * 2) + 1000; rightEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += rightEmptyLen.nVal; vwenv.MakeColumns(1, inputLen); VwLength arrowLen; arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000; arrowLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, arrowLen); VwLength outputLen; outputLen.nVal = 1; outputLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(1, leftEmptyLen); foreach (VwLength ctxtLen in ctxtLens) { vwenv.MakeColumns(1, ctxtLen); } vwenv.MakeColumns(1, rightEmptyLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left empty cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty); CloseSingleLinePile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input context cells vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput); // input right empty cell vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEmpty, this, kfragEmpty); CloseSingleLinePile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // index header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_indexStr); vwenv.CloseTableCell(); // index left empty cell vwenv.Props = m_indexProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // index cells for (int i = 0; i < m_rule.InputOS.Count; i++) { vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(TsStringUtils.MakeString(Convert.ToString(i + 1), userWs)); vwenv.CloseTableCell(); } // index right empty cell vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); // double arrow cell vwenv.Props = m_arrowProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_doubleArrow); vwenv.CloseTableCell(); // result table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // result header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // result cell vwenv.Props = m_resultProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.OutputOS.Count == 0) { vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty); } else { vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRuleMapping: var mapping = m_cache.ServiceLocator.GetInstance <IMoRuleMappingRepository>().GetObject(hvo); switch (mapping.ClassID) { case MoCopyFromInputTags.kClassId: var copy = (IMoCopyFromInput)mapping; OpenSingleLinePile(vwenv, GetOutputMaxNumLines()); if (copy.ContentRA == null) { vwenv.AddProp(ktagIndex, this, 0); } else { vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1); } CloseSingleLinePile(vwenv); break; case MoInsertPhonesTags.kClassId: OpenSingleLinePile(vwenv, GetOutputMaxNumLines()); vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit); CloseSingleLinePile(vwenv); break; case MoModifyFromInputTags.kClassId: var modify = (IMoModifyFromInput)mapping; int outputMaxNumLines = GetOutputMaxNumLines(); int numLines = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count; // index pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.OpenParagraph(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace); if (modify.ContentRA == null) { vwenv.AddProp(ktagIndex, this, 0); } else { vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1); } vwenv.CloseParagraph(); vwenv.CloseInnerPile(); // left bracket pile // right align brackets in left bracket pile, since the index could have a greater width, then the bracket if (numLines == 1) { vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket); vwenv.CloseInnerPile(); } else { vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); } // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - numLines, vwenv); if (numLines == 0) { vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions); } else { vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC); } vwenv.CloseInnerPile(); // right bracket pile if (numLines == 1) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); AddExtraLines(outputMaxNumLines - 1, vwenv); vwenv.OpenInnerPile(); vwenv.AddProp(ktagRightBoundary, this, kfragRightBracket); vwenv.CloseInnerPile(); } else { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(outputMaxNumLines - numLines, vwenv); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } break; } break; default: base.Display(vwenv, hvo, frag); break; } }
private void PrintColumnGroupHeaders(int hvo, IVwEnv vwenv) { MakeTableAndRowWithStdWidths(vwenv, hvo, true); MakeCellsMethod.OpenRowNumberCell(vwenv); // header for row numbers vwenv.AddString(m_cache.MakeAnalysisTss("#")); vwenv.CloseTableCell(); vwenv.AddObjProp((int)DsConstChart.DsChartTags.kflidTemplate, this, kfragTemplateHeader); MakeCellsMethod.OpenStandardCell(vwenv, 1, false); vwenv.AddString(m_cache.MakeAnalysisTss(DiscourseStrings.ksNotesColumnHeader)); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTable(); }
private void PrintIndividualColumnHeaders(int hvo, IVwEnv vwenv) { MakeTableAndRowWithStdWidths(vwenv, hvo, true); MakeCellsMethod.OpenRowNumberCell(vwenv); // blank cell under header for row numbers vwenv.CloseTableCell(); for (int icol = 0; icol < m_chart.AllColumns.Length; icol++ ) { MakeCellsMethod.OpenStandardCell(vwenv, 1, m_chart.Logic.GroupEndIndices.Contains(icol)); vwenv.AddString(m_cache.MakeAnalysisTss(m_chart.Logic.GetColumnLabel(icol))); vwenv.CloseTableCell(); } MakeCellsMethod.OpenStandardCell(vwenv, 1, false); // blank cell below Notes header vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTable(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPrintChart: // the whole chart with headings for printing. if (hvo == 0) return; PrintColumnGroupHeaders(hvo, vwenv); PrintIndividualColumnHeaders(hvo, vwenv); // Rest is same as kfragChart DisplayChartBody(vwenv); break; case kfragTemplateHeader: // Display the template as group headers. vwenv.AddObjVecItems(CmPossibilityTags.kflidSubPossibilities, this, kfragColumnGroupHeader); break; // This is only used for printing, the headers in the screen version are a separate control. case kfragColumnGroupHeader: var ccols = vwenv.DataAccess.get_VecSize(hvo, CmPossibilityTags.kflidSubPossibilities); // If there are no subitems, we still want a blank cell as a placeholder. MakeCellsMethod.OpenStandardCell(vwenv, Math.Max(ccols, 1), true); if (ccols > 0) { // It's a group, include its name var possGroup = m_cache.ServiceLocator.GetInstance<ICmPossibilityRepository>().GetObject(hvo); vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalCenter); vwenv.OpenParagraph(); vwenv.AddString(possGroup.Name.BestAnalysisAlternative); vwenv.CloseParagraph(); } vwenv.CloseTableCell(); break; case kfragChart: // the whole chart, a DsConstChart. if (hvo == 0) return; DisplayChartBody(vwenv); break; case kfragChartRow: // one row, a ConstChartRow { MakeTableAndRowWithStdWidths(vwenv, hvo, false); MakeCells(vwenv, hvo); vwenv.CloseTableRow(); vwenv.CloseTable(); } break; case kfragCellPart: // a single group of words, the contents of one cell. if (m_chart.Logic.IsWordGroup(hvo)) DisplayWordforms(vwenv, hvo); else { // it's a moved text or clause reference placeholder. int hvoClause; if (m_chart.Logic.IsClausePlaceholder(hvo, out hvoClause)) DisplayClausePlaceholder(vwenv, hvoClause); else DisplayMovedTextTag(hvo, vwenv); } break; case kfragMovedTextCellPart: // a single group of words (ConstChartWordGroup), // the contents of one cell, which is considered moved-within-line. // Can't be a placeholder. var formatTag = m_chart.Logic.MovedTextTag(hvo); ApplyFormatting(vwenv, formatTag); vwenv.OpenSpan(); InsertOpenBracket(vwenv, formatTag); DisplayWordforms(vwenv, hvo); InsertCloseBracket(vwenv, formatTag); vwenv.CloseSpan(); break; case kfragChartListItem: // a single ConstChartTag, referring to a list item. // can't be a placeholder. ApplyFormatting(vwenv, "marker"); vwenv.OpenSpan(); InsertOpenBracket(vwenv, "marker"); vwenv.AddObjProp(ConstChartTagTags.kflidTag, this, kfragPossibility); InsertCloseBracket(vwenv, "marker"); vwenv.CloseSpan(); break; case kfragPossibility: // A CmPossibility, show it's abbreviation var flid = CmPossibilityTags.kflidAbbreviation; var retWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, flid); if (retWs == 0) { // No Abbreviation! Switch to Name flid = CmPossibilityTags.kflidName; retWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsFirstAnal, hvo, flid); } // Unless we didn't get anything, go ahead and insert the best option we found. if (retWs != 0) vwenv.AddStringAltMember(flid, retWs, this); break; case kfragBundle: // One annotated word bundle; hvo is IAnalysis object. Overrides behavior of InterlinVc AddWordBundleInternal(hvo, vwenv); break; case kfragNotesString: // notes text vwenv.AddStringProp(ConstChartRowTags.kflidNotes, this); break; case kfragComment: // hvo is a ConstChartRow vwenv.AddStringProp(ConstChartRowTags.kflidLabel, this); break; case kfragMTMarker: var mtt = m_partRepo.GetObject(vwenv.OpenObject) as IConstChartMovedTextMarker; Debug.Assert(mtt != null, "Invalid MovedTextMarker?"); vwenv.AddString(mtt.Preposed ? m_sMovedTextBefore : m_sMovedTextAfter); // Need to regenerate this if the row my WordGroup is in changes. vwenv.NoteDependency(new[] {mtt.WordGroupRA.Owner.Hvo}, new int[] {ConstChartRowTags.kflidCells}, 1); break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { TriggerDisplay(vwenv); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. m_mDxmpLabelWidth = 0; for (int i = 0; i < m_rgws.Count; ++i) { int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). // Set qtss to a string representing the writing system. vwenv.get_StringWidth(NameOfWs(i), m_ttpLabel, out dxs, out dys); m_mDxmpLabelWidth = Math.Max(m_mDxmpLabelWidth, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = m_mDxmpLabelWidth + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); var visibleWss = new HashSet <ILgWritingSystem>(); // if we passed in a view and have WritingSystemsToDisplay // then we'll load that list in order to filter our larger m_rgws list. AddViewWritingSystems(visibleWss); for (int i = 0; i < m_rgws.Count; ++i) { if (SkipEmptyWritingSystem(visibleWss, i, hvo)) { continue; } vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1, 1); vwenv.AddString(NameOfWs(i)); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and // RTL. if (m_rgws[i].RightToLeftScript) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } if (!m_editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); CoreWritingSystemDefinition wsdef = m_rgws[i]; if (wsdef != null && wsdef.IsVoice) { // We embed it in a conc paragraph to ensure it never takes more than a line. // It will typically be covered up by a sound control. // Also set foreground color to match the window, so nothing shows even if the sound doesn't overlap it perfectly. // (transparent does not seem to work as a foreground color) vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Window))); // Must not spell-check a conc para, leads to layout failures when the paragraph tries to cast the source to // a conc text source, if it is overridden by a spelling text source. vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenConcPara(0, 1, VwConcParaOpts.kcpoDefault, 0); vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); vwenv.CloseParagraph(); } else { if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); } vwenv.CloseTableCell(); vwenv.CloseTableRow(); } vwenv.CloseTableBody(); vwenv.CloseTable(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRHS: m_rhs = m_cache.ServiceLocator.GetInstance <IPhSegRuleRHSRepository>().GetObject(hvo); var rule = m_rhs.OwningRule; if (rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = GetMaxNumLines(); int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.MetaDataCacheAccessor.GetFieldId2(PhSegRuleRHSTags.kClassId, "OwningRule", false), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.StrucChangeOS.Count > 0) { vwenv.AddObjVecItems(PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidStrucChange }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.LeftContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidLeftContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.RightContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidRightContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_rhs.OwningRule.StrucDescOS.Count > 0) { vwenv.AddObjVecItems(PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenSingleLinePile(vwenv, GetMaxNumLines(), false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } break; default: base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Closes the table row. /// </summary> /// <param name="vwenv">The view environment.</param> /// <param name="ann">The annotation being displayed.</param> /// ------------------------------------------------------------------------------------ private void CloseTableRow(IVwEnv vwenv, IScrScriptureNote ann) { if (ann.Hvo != SelectedNoteHvo) { // Display cell used for padding (to right-indent unselected annotations by // the width of the frame used to highlight the selected annotation). vwenv.OpenTableCell(1, 1); vwenv.AddString(m_tssEmpty); vwenv.CloseTableCell(); } vwenv.CloseTableRow(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRHS: m_rhs = m_cache.ServiceLocator.GetInstance<IPhSegRuleRHSRepository>().GetObject(hvo); var rule = m_rhs.OwningRule; if (rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int arrowWidth, slashWidth, underscoreWidth, charHeight; vwenv.get_StringWidth(m_arrow, m_charProps, out arrowWidth, out charHeight); int maxCharHeight = charHeight; vwenv.get_StringWidth(m_slash, m_charProps, out slashWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); vwenv.get_StringWidth(m_underscore, m_charProps, out underscoreWidth, out charHeight); maxCharHeight = Math.Max(charHeight, maxCharHeight); int dmpx, spaceHeight; vwenv.get_StringWidth(m_zwSpace, m_bracketProps, out dmpx, out spaceHeight); int maxNumLines = GetMaxNumLines(); int maxCtxtHeight = maxNumLines * spaceHeight; int maxHeight = Math.Max(maxCharHeight, maxCtxtHeight); int charOffset = maxHeight; int ctxtPadding = maxHeight - maxCtxtHeight; VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(7, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; VwLength charLen; charLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, ctxtLen); charLen.nVal = arrowWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = slashWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); charLen.nVal = underscoreWidth + 4000; vwenv.MakeColumns(1, charLen); vwenv.MakeColumns(1, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // LHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddObjProp(m_cache.MetaDataCacheAccessor.GetFieldId2(PhSegRuleRHSTags.kClassId, "OwningRule", false), this, kfragRule); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // arrow cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_arrow); vwenv.CloseTableCell(); // RHS cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.StrucChangeOS.Count > 0) { vwenv.AddObjVecItems(PhSegRuleRHSTags.kflidStrucChange, this, kfragContext); } else { vwenv.NoteDependency(new[] {hvo}, new[] {PhSegRuleRHSTags.kflidStrucChange}, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidStrucChange, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // slash cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_slash); vwenv.CloseTableCell(); // left context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.LeftContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidLeftContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidLeftContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // underscore cell vwenv.Props = m_charProps; vwenv.set_IntProperty((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, -charOffset); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_underscore); vwenv.CloseTableCell(); // right context cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, ctxtPadding); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rhs.RightContextOA != null) { vwenv.AddObjProp(PhSegRuleRHSTags.kflidRightContext, this, kfragContext); } else { vwenv.NoteDependency(new[] { hvo }, new[] { PhSegRuleRHSTags.kflidRightContext }, 1); OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegRuleRHSTags.kflidRightContext, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRule: if (m_rhs.OwningRule.StrucDescOS.Count > 0) { vwenv.AddObjVecItems(PhSegmentRuleTags.kflidStrucDesc, this, kfragContext); } else { OpenSingleLinePile(vwenv, GetMaxNumLines(), false); vwenv.Props = m_bracketProps; vwenv.AddProp(PhSegmentRuleTags.kflidStrucDesc, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } break; default: base.Display(vwenv, hvo, frag); break; } }
private void PrintOneTemplateHeader(IVwEnv vwenv, ITsStrFactory tssFact, int analWs, int icol) { MakeCellsMethod.OpenStandardCell(vwenv, 1, m_chart.Logic.GroupEndIndices.Contains(icol)); vwenv.AddString(tssFact.MakeString(m_chart.Logic.GetColumnLabel(icol), analWs)); vwenv.CloseTableCell(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the annotation fragment. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayAnnotationFragment(IVwEnv vwenv, int hvo) { IScrScriptureNote ann = m_cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(hvo); bool isExpanded = (m_expandTable.ContainsKey(hvo) && m_expandTable[hvo]); int hvoFirstResponse = ann.ResponsesOS.Count > 0 ? ann.ResponsesOS[0].Hvo : 0; bool responseExpanded = m_expandTable.ContainsKey(hvoFirstResponse) && m_expandTable[hvoFirstResponse]; // put the separator at the top of the note InsertNoteSeparator(vwenv); // Open a table to display the first line of the annotation. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; int borderThickness = 2000; int columnCount = 9; VwFramePosition framePos = VwFramePosition.kvfpVoid; if (ann.Hvo == SelectedNoteHvo) { columnCount = 7; framePos = (ann.ResponsesOS.Count == 0 || !isExpanded || !responseExpanded) ? VwFramePosition.kvfpBox : (VwFramePosition.kvfpAbove | VwFramePosition.kvfpVsides); } vwenv.OpenTable(columnCount, vlTable, // Table uses 100% of available width. borderThickness, VwAlignment.kvaLeft, // Default alignment. framePos, //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); vwenv.NoteDependency(new int[] { hvo, hvo }, new int[]{m_expansionTag, ScrScriptureNoteTags.kflidResponses}, 2); // Specify column widths. The first argument is the number of columns, // not a column index. VwLength vlColumn; if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vlColumn.nVal = 13000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(2, vlColumn); vlColumn.nVal = 60000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); vlColumn.nVal = 2; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the CONNOT categories vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when showing quote vlColumn.nVal = 3; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the quote when collapsed vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when not showing quote if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vwenv.OpenTableBody(); DisplayAnnotation(vwenv, ann, isExpanded); // Only display the responses if this note is expanded and has responses. if (!isExpanded || ann.ResponsesOS.Count == 0) { // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); return; } vwenv.NoteDependency(new int[] { ann.ResponsesOS.ToHvoArray()[0] }, new int[] { m_expansionTag }, 1); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display expand box (+/-) in the second cell vwenv.OpenTableCell(1, 1); vwenv.AddObj(ann.ResponsesOS.ToHvoArray()[0], this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display response label in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_responseLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); if (responseExpanded) { vwenv.AddObjVecItems((int)ScrScriptureNoteTags.kflidResponses, this, (int)NotesFrags.kfrResponse); } }
private void DisplayWithWritingSystemLabel(IVwEnv vwenv, int ws) { ITsString tssLabel = NameOfWs(ws); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). vwenv.get_StringWidth(tssLabel, null, out dxs, out dys); VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = dxs + 5000; vlColWs.unit = VwUnit.kunPoint1000; // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. //vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssLabel); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and RTL. if (m_fRtlScript) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } //if (!m_editable) //{ // vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, // (int)TptEditable.ktptNotEditable); //} vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.AddStringProp(m_flid, this); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an annotation expanded or contracted /// </summary> /// <param name="vwenv"></param> /// <param name="ann"></param> /// <param name="expanded"></param> /// ------------------------------------------------------------------------------------ private void DisplayAnnotation(IVwEnv vwenv, IScrScriptureNote ann, bool expanded) { #region First row has status, ref, category, & quote SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display expand box (+/-) in the first cell //InsertNoteSeparator(vwenv); vwenv.OpenTableCell(1, 1); vwenv.AddObj(ann.Hvo, this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display status in the second cell vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (ann.AnnotationType == NoteType.CheckingError) { // When the annotation is a checking error, we don't want clicking on the status // to change the status. Therefore, make the min and max the same. vwenv.AddIntPropPic((int)ScrScriptureNoteTags.kflidResolutionStatus, this, (int)NotesFrags.kfrStatus, 0, 0); } else { vwenv.AddIntPropPic((int)ScrScriptureNoteTags.kflidResolutionStatus, this, (int)NotesFrags.kfrStatus, (int)NoteStatus.Open, (int)NoteStatus.Closed); } vwenv.CloseTableCell(); // Display reference in the third cell and make it readonly. vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, 0); vwenv.OpenParagraph(); vwenv.AddProp((int)CmBaseAnnotationTags.kflidBeginRef, this, (int)NotesFrags.kfrScrRef); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display CONNOT category in the fourth (and possibly fifth and sixth) cell(s) vwenv.OpenTableCell(1, expanded ? 3 : 1); IStTxtPara quotePara = ann.QuoteOA[0]; bool fQuoteParaRtoL = IsParaRightToLeft(quotePara); // Conc paragraphs don't work well for R-to-L: If the text doesn't fit, it will // show the trailing text rather than the leading text. if (fQuoteParaRtoL || expanded) vwenv.OpenParagraph(); else vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddObjVec((int)ScrScriptureNoteTags.kflidCategories, this, (int)NotesFrags.kfrConnotCategory); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display CONNOT category chooser button in the penultimate or last cell vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.AddPicture(m_picChooser, -(int)NotesFrags.kfrConnotCategory, 0, 0); vwenv.CloseTableCell(); // If not expanded, display the quote in the last cell if (!expanded) { vwenv.OpenTableCell(1, 1); SetupWsAndDirectionForPara(vwenv, quotePara.Hvo); if (fQuoteParaRtoL) vwenv.OpenParagraph(); // Conc paragraphs don't work well for R-to-L else vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(quotePara.Contents); vwenv.CloseParagraph(); vwenv.CloseTableCell(); } CloseTableRow(vwenv, ann); #endregion if (!expanded) return; #region Second through fifth rows bool fRegularAnnotation = ann.AnnotationType != NoteType.CheckingError; //Second row has quote DisplayExpandableAnnotation(vwenv, ann, (int)ScrScriptureNoteTags.kflidQuote, ann.QuoteOA.Hvo, ann.QuoteOA, fRegularAnnotation ? m_quoteLabel : m_detailsLabel, !fRegularAnnotation); // Third row has discussion DisplayExpandableAnnotation(vwenv, ann, ScrScriptureNoteTags.kflidDiscussion, ann.DiscussionOA.Hvo, ann.DiscussionOA, fRegularAnnotation ? m_discussionLabel : m_messageLabel, !fRegularAnnotation); // Fourth row has recommendation (i.e. suggestion) DisplayExpandableAnnotation(vwenv, ann, ScrScriptureNoteTags.kflidRecommendation, ann.RecommendationOA.Hvo, ann.RecommendationOA, m_suggestionLabel); // Fifth row has resolution DisplayExpandableAnnotation(vwenv, ann, ScrScriptureNoteTags.kflidResolution, ann.ResolutionOA.Hvo, ann.ResolutionOA, m_resolutionLabel); #endregion #region Sixth row has author SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display author in third cell vwenv.OpenTableCell(1, 3); vwenv.OpenParagraph(); SetDisabledColorForNote(vwenv); vwenv.AddString(m_authorLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); #endregion #region Seventh row has dates SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display date created in third cell vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddString(m_createdLabel); vwenv.AddTimeProp(CmAnnotationTags.kflidDateCreated, 0); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display date modified in fourth/fifth cells vwenv.OpenTableCell(1, 2); vwenv.OpenParagraph(); vwenv.AddString(m_modifiedLabel); vwenv.AddTimeProp(CmAnnotationTags.kflidDateModified, 0); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display date resolved in last two cells vwenv.OpenTableCell(1, 2); vwenv.OpenParagraph(); if (ann.ResolutionStatus == NoteStatus.Closed) { SetDisabledColorForNote(vwenv); vwenv.AddString(m_resolvedLabel); // TODO (TE-4039) This date is incorrect //vwenv.AddTimeProp(ScrScriptureNote.ScrScriptureNoteTags.kflidDateResolved, 0); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); #endregion }
/// ------------------------------------------------------------------------------------ /// <summary> /// Display a response to an annotation. /// </summary> /// <param name="vwenv"></param> /// <param name="text">StJournalText containing the response</param> /// <param name="expanded">whether response should be expanded</param> /// ------------------------------------------------------------------------------------ private void DisplayResponse(IVwEnv vwenv, IStJournalText text, bool expanded) { #region Response text // Display response text vwenv.OpenTableRow(); // Display empty first, second, and third cells vwenv.OpenTableCell(1, 3); vwenv.CloseTableCell(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 500); vwenv.OpenTableCell(1, 2); vwenv.AddObjVecItems((int)StTextTags.kflidParagraphs, this, (int)StTextFrags.kfrPara); vwenv.CloseTableCell(); vwenv.CloseTableRow(); #endregion #region Author and creation date // Author and creation date vwenv.OpenTableRow(); // Display empty first, second, and third cells vwenv.OpenTableCell(1, 3); vwenv.CloseTableCell(); // Display author in the third cell vwenv.OpenTableCell(1, 1); SetDisabledColorForNote(vwenv); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_authorLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display creation date in the fourth cell vwenv.OpenTableCell(1, 1); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_createdLabel); vwenv.AddString(m_tsStrFactory.MakeString(text.DateCreated.ToShortDateString(), m_cache.DefaultUserWs)); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); #endregion }
public override void Display(IVwEnv vwenv, int hvo, int frag) { var tsf = m_cache.TsStrFactory; var userWs = m_cache.DefaultUserWs; switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance<IMoAffixProcessRepository>().GetObject(hvo); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(3, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength inputLen; inputLen.nVal = 0; inputLen.unit = VwUnit.kunPoint1000; int indexWidth = GetStrWidth(m_indexStr, m_headerProps, vwenv); int inputWidth = GetStrWidth(m_inputStr, m_headerProps, vwenv); VwLength headerLen; headerLen.nVal = Math.Max(indexWidth, inputWidth) + 8000; headerLen.unit = VwUnit.kunPoint1000; inputLen.nVal += headerLen.nVal; VwLength leftEmptyLen; leftEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 2000; leftEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += leftEmptyLen.nVal; var ctxtLens = new VwLength[m_rule.InputOS.Count]; vwenv.NoteDependency(new[] {m_rule.Hvo}, new[] {MoAffixProcessTags.kflidInput}, 1 ); for (int i = 0; i < m_rule.InputOS.Count; i++) { int idxWidth = GetStrWidth(tsf.MakeString(Convert.ToString(i + 1), userWs), m_indexProps, vwenv); int ctxtWidth = GetWidth(m_rule.InputOS[i], vwenv); ctxtLens[i].nVal = Math.Max(idxWidth, ctxtWidth) + 8000 + 1000; ctxtLens[i].unit = VwUnit.kunPoint1000; inputLen.nVal += ctxtLens[i].nVal; } VwLength rightEmptyLen; rightEmptyLen.nVal = 8000 + (PILE_MARGIN * 2) + 1000; rightEmptyLen.unit = VwUnit.kunPoint1000; inputLen.nVal += rightEmptyLen.nVal; vwenv.MakeColumns(1, inputLen); VwLength arrowLen; arrowLen.nVal = GetStrWidth(m_doubleArrow, m_arrowProps, vwenv) + 8000; arrowLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, arrowLen); VwLength outputLen; outputLen.nVal = 1; outputLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(m_rule.InputOS.Count + 3, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(1, leftEmptyLen); foreach (VwLength ctxtLen in ctxtLens) vwenv.MakeColumns(1, ctxtLen); vwenv.MakeColumns(1, rightEmptyLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left empty cell vwenv.Props = m_ctxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEmpty, this, kfragEmpty); CloseContextPile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input context cells vwenv.AddObjVec(MoAffixProcessTags.kflidInput, this, kfragInput); // input right empty cell vwenv.Props = m_ctxtProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEmpty, this, kfragEmpty); CloseContextPile(vwenv, false); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // index header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_indexStr); vwenv.CloseTableCell(); // index left empty cell vwenv.Props = m_indexProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // index cells for (int i = 0; i < m_rule.InputOS.Count; i++) { vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(tsf.MakeString(Convert.ToString(i + 1), userWs)); vwenv.CloseTableCell(); } // index right empty cell vwenv.Props = m_indexProps; vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); // double arrow cell vwenv.Props = m_arrowProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_doubleArrow); vwenv.CloseTableCell(); // result table cell vwenv.OpenTableCell(1, 1); vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaLeft, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); vwenv.MakeColumns(1, outputLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // result header cell vwenv.Props = m_headerProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // result cell vwenv.Props = m_resultProps; vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.OutputOS.Count == 0) vwenv.AddProp(MoAffixProcessTags.kflidOutput, this, kfragEmpty); else vwenv.AddObjVecItems(MoAffixProcessTags.kflidOutput, this, kfragRuleMapping); vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragRuleMapping: var mapping = m_cache.ServiceLocator.GetInstance<IMoRuleMappingRepository>().GetObject(hvo); switch (mapping.ClassID) { case MoCopyFromInputTags.kClassId: var copy = (IMoCopyFromInput) mapping; OpenIndexPile(vwenv); if (copy.ContentRA == null) vwenv.AddProp(ktagIndex, this, 0); else vwenv.AddProp(ktagIndex, this, copy.ContentRA.IndexInOwner + 1); CloseIndexPile(vwenv); break; case MoInsertPhonesTags.kClassId: OpenIndexPile(vwenv); vwenv.AddObjVecItems(MoInsertPhonesTags.kflidContent, this, kfragTerminalUnit); CloseIndexPile(vwenv); break; case MoModifyFromInputTags.kClassId: var modify = (IMoModifyFromInput) mapping; var numLines = modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count; // left bracket pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftBoundary, this, kfragZeroWidthSpace); // put index in the left bracket pile if (modify.ContentRA == null) vwenv.AddProp(ktagIndex, this, 0); else vwenv.AddProp(ktagIndex, this, modify.ContentRA.IndexInOwner + 1); // right align brackets in left bracket pile, since the index could have a greater width, then the bracket if (numLines > 1) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketLowHook); } else { vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracket); } vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(1, vwenv); if (numLines == 0) vwenv.AddProp(MoModifyFromInputTags.kflidModification, this, kfragQuestions); else vwenv.AddObjProp(MoModifyFromInputTags.kflidModification, this, kfragFeatNC); vwenv.CloseInnerPile(); // right bracket pile vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightBoundary, this, kfragSpace); if (numLines > 1) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketLowHook); } else { vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracket); } vwenv.CloseInnerPile(); break; } break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance<IPhMetathesisRuleRepository>().GetObject(hvo); if (m_rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int maxNumLines = GetMaxNumLines(); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(5, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; int resultx, inputx, dmpy; vwenv.get_StringWidth(m_resultStr, m_colHeaderProps, out resultx, out dmpy); vwenv.get_StringWidth(m_inputStr, m_colHeaderProps, out inputx, out dmpy); VwLength headerLen; headerLen.nVal = Math.Max(resultx, inputx) + 8000; headerLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(4, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // left context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_leftEnvStr); vwenv.CloseTableCell(); // switch header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 2); vwenv.AddString(m_switchStr); vwenv.CloseTableCell(); // right context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_rightEnvStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = 0; i < m_rule.LeftEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input left switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input result header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); // result left context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex != -1) { for (int i = 0; i < m_rule.LeftEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex != -1) { for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result left switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } if (m_rule.LeftSwitchIndex != -1) { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex != -1) { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: base.Display(vwenv, hvo, frag); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { TriggerDisplay(vwenv); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. m_mDxmpLabelWidth = 0; for (int i = 0; i < m_rgws.Count; ++i) { int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). // Set qtss to a string representing the writing system. vwenv.get_StringWidth(NameOfWs(i), m_ttpLabel, out dxs, out dys); m_mDxmpLabelWidth = Math.Max(m_mDxmpLabelWidth, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = m_mDxmpLabelWidth + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); var visibleWss = new Set<ILgWritingSystem>(); // if we passed in a view and have WritingSystemsToDisplay // then we'll load that list in order to filter our larger m_rgws list. AddViewWritingSystems(visibleWss); for (int i = 0; i < m_rgws.Count; ++i) { if (SkipEmptyWritingSystem(visibleWss, i, hvo)) continue; vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1,1); vwenv.AddString(NameOfWs(i)); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and // RTL. if (m_rgws[i].RightToLeftScript) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } if (!m_editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1,1); var wsdef = m_rgws[i] as WritingSystemDefinition; if (wsdef != null && wsdef.IsVoice) { // We embed it in a conc paragraph to ensure it never takes more than a line. // It will typically be covered up by a sound control. // Also set foreground color to match the window, so nothing shows even if the sound doesn't overlap it perfectly. // (transparent does not seem to work as a foreground color) vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Window))); // Must not spell-check a conc para, leads to layout failures when the paragraph tries to cast the source to // a conc text source, if it is overridden by a spelling text source. vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenConcPara(0, 1, VwConcParaOpts.kcpoDefault, 0); vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); vwenv.CloseParagraph(); } else { if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int) FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); } vwenv.CloseTableCell(); vwenv.CloseTableRow(); } vwenv.CloseTableBody(); vwenv.CloseTable(); }
private void PrintNotesCellHeader(IVwEnv vwenv, int analWs) { MakeCellsMethod.OpenStandardCell(vwenv, 1, false); vwenv.AddString(m_tssFact.MakeString(DiscourseStrings.ksNotesColumnHeader, analWs)); vwenv.CloseTableCell(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); TriggerDisplay(vwenv); //if (m_rgws.Length == 1) //{ // // Single option...don't bother with labels. // if (m_rgws[0].RightToLeft) // { // vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, // (int)FwTextPropVar.ktpvEnum, // (int)FwTextToggleVal.kttvForceOn); // vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, // (int)FwTextPropVar.ktpvEnum, // (int)FwTextAlign.ktalTrailing); // } // vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); // vwenv.AddStringAltMember(m_flid, m_rgws[0].Hvo, this); // return; //} ITsStrFactory tsf = TsStrFactoryClass.Create(); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). int dxsMax = 0; // Max width required. for (int i = 0; i < m_rgws.Length; ++i) { // Set qtss to a string representing the writing system. vwenv.get_StringWidth(NameOfWs(tsf, i), m_ttpLabel, out dxs, out dys); dxsMax = Math.Max(dxsMax, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = dxsMax + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); Set<ILgWritingSystem> visibleWss = new Set<ILgWritingSystem>(); // if we passed in a view and have WritingSystemsToDisplay // then we'll load that list in order to filter our larger m_rgws list. AddViewWritingSystems(visibleWss); for (int i = 0; i < m_rgws.Length; ++i) { if (SkipEmptyWritingSystem(visibleWss, i, hvo)) continue; vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1,1); vwenv.AddString(NameOfWs(tsf, i)); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and // RTL. if (m_rgws[i].RightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } if (!m_editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1,1); vwenv.AddStringAltMember(m_flid, m_rgws[i].Hvo, this); vwenv.CloseTableCell(); vwenv.CloseTableRow(); } vwenv.CloseTableBody(); vwenv.CloseTable(); }
private void RegurgitateIVwEnvCall(StoredMethod storedMethod) { int tag; int frag; IVwViewConstructor vc; switch (storedMethod.MethodType) { case DecoratorMethodTypes.AddObj: var hvo = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObj(hvo, vc, frag); break; case DecoratorMethodTypes.AddObjProp: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjProp(tag, vc, frag); break; case DecoratorMethodTypes.AddObjVec: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjVec(tag, vc, frag); break; case DecoratorMethodTypes.AddObjVecItems: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; frag = (int)storedMethod.ParamArray[2]; m_vwEnv.AddObjVecItems(tag, vc, frag); break; case DecoratorMethodTypes.AddString: var tsStr = (ITsString)storedMethod.ParamArray[0]; m_vwEnv.AddString(tsStr); break; case DecoratorMethodTypes.AddStringProp: tag = (int)storedMethod.ParamArray[0]; vc = (IVwViewConstructor)storedMethod.ParamArray[1]; m_vwEnv.AddStringProp(tag, vc); break; case DecoratorMethodTypes.CloseParagraph: m_vwEnv.CloseParagraph(); break; case DecoratorMethodTypes.CloseTableCell: m_vwEnv.CloseTableCell(); break; case DecoratorMethodTypes.NoteDependency: var _rghvo = (int[])storedMethod.ParamArray[0]; var _rgtag = (int[])storedMethod.ParamArray[1]; var chvo = (int)storedMethod.ParamArray[2]; m_vwEnv.NoteDependency(_rghvo, _rgtag, chvo); break; case DecoratorMethodTypes.OpenParagraph: m_vwEnv.OpenParagraph(); break; case DecoratorMethodTypes.OpenTableCell: var nRows = (int)storedMethod.ParamArray[0]; var nCols = (int)storedMethod.ParamArray[1]; m_vwEnv.OpenTableCell(nRows, nCols); break; case DecoratorMethodTypes.SetIntProperty: var tpt = (int)storedMethod.ParamArray[0]; var tpv = (int)storedMethod.ParamArray[1]; var nValue = (int)storedMethod.ParamArray[2]; m_vwEnv.set_IntProperty(tpt, tpv, nValue); break; case DecoratorMethodTypes.PropsSetter: var value = (ITsTextProps)storedMethod.ParamArray[0]; m_vwEnv.Props = value; break; default: Debug.Assert(false, "Unknown DecoratorMethodType!"); break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { // Ignore 0 hvo's. RootObject may have not been set. FWNX-613. if (hvo == 0) return; switch(frag) { case kfragRoot: if (m_dxLabWidth == 0) { int dmpx1, dmpy; //, dmpx2; vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy); //vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy); //m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin. m_dxLabWidth = dmpx1 + 13000; // add 3 pt spacing to box, 10 to margin. m_dxWsLabWidth = 0; foreach (ITsString tssLabel in m_WsLabels) { vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy); m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1); } m_dxWsLabWidth += 18000; // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety. } VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColLabels; // 5-pt space plus max label width. vlColLabels.nVal = m_dxLabWidth; vlColLabels.unit = VwUnit.kunPoint1000; VwLength vlColWsLabels; // 5-pt space plus max ws label width. vlColWsLabels.nVal = m_dxWsLabWidth; vlColWsLabels.unit = VwUnit.kunPoint1000; // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; // The Padding column allows for the the trailing margin and border. VwLength vlColPadding; vlColPadding.nVal = 10000; vlColPadding.unit = VwUnit.kunPoint1000; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int) FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenTable(4, // Four columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // no padding inside cells. false); vwenv.MakeColumns(1, vlColLabels); vwenv.MakeColumns(1, vlColWsLabels); vwenv.MakeColumns(1, vlColMain); vwenv.MakeColumns(1, vlColPadding); vwenv.OpenTableBody(); for (int i = 0; i < m_writingSystems.Length; i++) { vwenv.OpenTableRow(); // First cell has 'Title' label in bold. vwenv.Props = m_ttpBold; vwenv.OpenTableCell(1,1); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, 10000); if (i == 0) // only on the first row { // We want this fixed at 10 point, since it's considered a UI component, not data. // See LT-4816 vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.AddString(m_tssTitle); } vwenv.CloseTableCell(); // Second cell has ws labels. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int) FwTextPropVar.ktpvDefault, m_editBackColor); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == 0) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == m_writingSystems.Length - 1) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1,1); vwenv.Props = m_ttpDataCellProps; vwenv.Props = m_ttpWsLabel; vwenv.AddString(m_WsLabels[i]); vwenv.CloseTableCell(); // Third cell has the Title property, in a box. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int) FwTextPropVar.ktpvDefault, m_editBackColor); // Set the underlying directionality so that arrow keys work properly. bool fRTL = m_writingSystems[i].RightToLeftScript; vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); if (i == 0) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == m_writingSystems.Length - 1) vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1,1); vwenv.OpenParagraph(); vwenv.Props = m_ttpDataCellProps; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, this.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); if (IsScripture) { vwenv.AddStringAltMember(m_vtagStTextTitle, m_writingSystems[i].Handle, this); } else { vwenv.AddStringAltMember(CmMajorObjectTags.kflidName, m_writingSystems[i].Handle, this); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); } //// Second row. //vwenv.OpenTableRow(); // //// First cell has 'Comments' label in bold. //vwenv.Props = m_ttpBold; //vwenv.OpenTableCell(1,1); //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.AddString(m_tssComments); //vwenv.CloseTableCell(); // //// Second cell has the Description property, in a box. //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.OpenTableCell(1,1); //vwenv.Props = m_ttpDataCellProps; //vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, // (int)FwTextPropVar.ktpvMilliPoint, 1000); //vwenv.AddStringAltMember( // (int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); //vwenv.CloseTableCell(); // //vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: throw new Exception("Bad frag id in TitleContentsVc"); } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPattern: VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength patternLen; patternLen.nVal = 1; patternLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, patternLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (((ComplexConcPatternSda) vwenv.DataAccess).Root.IsLeaf) { OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false); vwenv.Props = m_bracketProps; vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragNode: ComplexConcPatternNode node = ((ComplexConcPatternSda) vwenv.DataAccess).Nodes[hvo]; int maxNumLines = GetMaxNumLines(vwenv); if (node is ComplexConcOrNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR); CloseSingleLinePile(vwenv, false); } else if (node is ComplexConcWordBdryNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash); CloseSingleLinePile(vwenv); } else if (node is ComplexConcGroupNode) { int numLines = GetNumLines(node); bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal parentheses for a single line group vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen); if (hasMinMax) DisplayMinMax(numLines, vwenv); CloseSingleLinePile(vwenv, false); } else { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt); vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook); vwenv.CloseInnerPile(); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook); vwenv.CloseInnerPile(); if (hasMinMax) DisplayMinMax(numLines, vwenv); } } else { bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; int numLines = GetNumLines(node); if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal brackets for a single line constraint vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket); DisplayFeatures(vwenv, node); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket); if (hasMinMax) DisplayMinMax(numLines, vwenv); CloseSingleLinePile(vwenv, false); } else { // left bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginLeading, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int) FwTextPropType.ktptAlign, (int) FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv); DisplayFeatures(vwenv, node); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int) FwTextPropType.ktptMarginTrailing, (int) FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); if (hasMinMax) DisplayMinMax(numLines, vwenv); } } break; } }
private void PrintRowNumCellHeader(IVwEnv vwenv, int analWs) { MakeCellsMethod.OpenRowNumberCell(vwenv); // header for row numbers vwenv.AddString(m_tssFact.MakeString("#", analWs)); vwenv.CloseTableCell(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragPattern: VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(1, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 0, false); VwLength patternLen; patternLen.nVal = 1; patternLen.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, patternLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); vwenv.set_IntProperty((int)FwTextPropType.ktptPadBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (((ComplexConcPatternSda)vwenv.DataAccess).Root.IsLeaf) { OpenSingleLinePile(vwenv, GetMaxNumLines(vwenv), false); vwenv.Props = m_bracketProps; vwenv.AddProp(ComplexConcPatternSda.ktagChildren, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; case kfragNode: ComplexConcPatternNode node = ((ComplexConcPatternSda)vwenv.DataAccess).Nodes[hvo]; int maxNumLines = GetMaxNumLines(vwenv); if (node is ComplexConcOrNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragOR); CloseSingleLinePile(vwenv, false); } else if (node is ComplexConcWordBdryNode) { OpenSingleLinePile(vwenv, maxNumLines); vwenv.AddProp(ktagInnerNonBoundary, this, kfragHash); CloseSingleLinePile(vwenv); } else if (node is ComplexConcGroupNode) { int numLines = GetNumLines(node); bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal parentheses for a single line group vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParen); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParen); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } CloseSingleLinePile(vwenv, false); } else { vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftParenExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftParenLowHook); vwenv.CloseInnerPile(); vwenv.AddObjVecItems(ComplexConcPatternSda.ktagChildren, this, kfragNode); vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightParenExt); } vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightParenLowHook); vwenv.CloseInnerPile(); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } } } else { bool hasMinMax = node.Maximum != 1 || node.Minimum != 1; int numLines = GetNumLines(node); if (numLines == 1) { OpenSingleLinePile(vwenv, maxNumLines, false); // use normal brackets for a single line constraint vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracket); DisplayFeatures(vwenv, node); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracket); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } CloseSingleLinePile(vwenv, false); } else { // left bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagInnerNonBoundary, vwenv); DisplayFeatures(vwenv, node); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PileMargin); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, vwenv); vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.AddProp(hasMinMax ? ktagInnerNonBoundary : ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); if (hasMinMax) { DisplayMinMax(numLines, vwenv); } } } break; } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case kfragRule: m_rule = m_cache.ServiceLocator.GetInstance <IPhMetathesisRuleRepository>().GetObject(hvo); if (m_rule.Disabled) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, "Disabled Text"); } int maxNumLines = GetMaxNumLines(); VwLength tableLen; tableLen.nVal = 10000; tableLen.unit = VwUnit.kunPercent100; vwenv.OpenTable(5, tableLen, 0, VwAlignment.kvaCenter, VwFramePosition.kvfpVoid, VwRule.kvrlNone, 0, 4000, false); VwLength ctxtLen; ctxtLen.nVal = 1; ctxtLen.unit = VwUnit.kunRelative; int resultx, inputx, dmpy; vwenv.get_StringWidth(m_resultStr, m_colHeaderProps, out resultx, out dmpy); vwenv.get_StringWidth(m_inputStr, m_colHeaderProps, out inputx, out dmpy); VwLength headerLen; headerLen.nVal = Math.Max(resultx, inputx) + 8000; headerLen.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, headerLen); vwenv.MakeColumns(4, ctxtLen); vwenv.OpenTableBody(); vwenv.OpenTableRow(); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // left context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_leftEnvStr); vwenv.CloseTableCell(); // switch header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 2); vwenv.AddString(m_switchStr); vwenv.CloseTableCell(); // right context header cell vwenv.Props = m_colHeaderProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.AddString(m_rightEnvStr); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_inputStr); vwenv.CloseTableCell(); // input left context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = 0; i < m_rule.LeftEnvLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input left switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagLeftSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right switch cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightSwitch, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // input right context cell vwenv.Props = m_inputCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex == -1) { OpenSingleLinePile(vwenv, maxNumLines, false); vwenv.Props = m_bracketProps; vwenv.AddProp(ktagRightEnv, this, kfragEmpty); CloseSingleLinePile(vwenv, false); } else { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.OpenTableRow(); // input result header cell vwenv.Props = m_rowHeaderProps; vwenv.OpenTableCell(1, 1); vwenv.AddString(m_resultStr); vwenv.CloseTableCell(); // result left context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.LeftEnvIndex != -1) { for (int i = 0; i < m_rule.LeftEnvLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightSwitchIndex != -1) { for (int i = m_rule.RightSwitchIndex; i < m_rule.RightSwitchLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } if (m_rule.MiddleIndex != -1 && m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result left switch cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.MiddleIndex != -1 && !m_rule.IsMiddleWithLeftSwitch) { for (int i = m_rule.MiddleIndex; i < m_rule.MiddleLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } if (m_rule.LeftSwitchIndex != -1) { for (int i = m_rule.LeftSwitchIndex; i < m_rule.LeftSwitchLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); // result right context cell vwenv.Props = m_resultCtxtProps; vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); if (m_rule.RightEnvIndex != -1) { for (int i = m_rule.RightEnvIndex; i < m_rule.RightEnvLimit; i++) { vwenv.AddObj(m_rule.StrucDescOS[i].Hvo, this, kfragContext); } } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: base.Display(vwenv, hvo, frag); break; } }
internal void AddDoublePara(IVwEnv vwenv, int hvo) { // We use a table to display the source WS in column 1, and the dest ws in column 2. FwViews.VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = FwViews.VwUnit.kunPercent100; FwViews.VwLength vlColumn; // and this one to specify half the width for each column vlColumn.nVal = 5000; vlColumn.unit = FwViews.VwUnit.kunPercent100; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? vwenv.OpenTable(2, // Two columns. ref vlTable, // Table uses 100% of available width. 0, // Border thickness. FwViews.VwAlignment.kvaLeft, // Default alignment. FwViews.VwFramePosition.kvfpVoid, // No border. FwViews.VwRule.kvrlNone, // No rules between cells. 3000, // Three points of space between cells. 3000); // Three points padding inside cells. // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(2, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Source cell, not editable vwenv.OpenTableCell(1,1); vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptEditable, (int)FwKernelLib.FwTextPropVar.ktpvEnum, (int)FwKernelLib.TptEditable.ktptNotEditable); vwenv.AddStringAltMember(ktagParaContents, m_wsSrc, this); vwenv.CloseTableCell(); // Dest cell, editable, therefore with white background. vwenv.set_IntProperty((int)FwKernelLib.FwTextPropType.ktptBackColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault, m_colorEditable); vwenv.OpenTableCell(1,1); vwenv.AddStringAltMember(ktagParaContents, m_wsDst, this); vwenv.CloseTableCell(); vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); ISilDataAccess da = vwenv.DataAccess; switch (frag) { default: { Debug.Assert(false, "Unrecognized fragment."); break; } case ReversalIndexEntrySliceView.kFragMainObject: { // The hvo here is for the sense. // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). int dxsMax = 0; // Max width required. ISilDataAccess silDaCache = vwenv.DataAccess; IVwCacheDa vwCache = silDaCache as IVwCacheDa; foreach (IReversalIndex idx in m_usedIndices) { vwenv.get_StringWidth(silDaCache.get_StringProp(idx.WritingSystemRAHvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr), m_ttpLabel, out dxs, out dys); dxsMax = Math.Max(dxsMax, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = dxsMax + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); // Do vector of rows. Each row essentially is a reversal index, but shows other information. vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidIndices, this, ReversalIndexEntrySliceView.kFragIndices); vwenv.CloseTableBody(); vwenv.CloseTable(); break; } case ReversalIndexEntrySliceView.kFragIndexMain: { // First cell has writing system abbreviation displayed using m_ttpLabel. int wsHvo = 0; foreach (ReversalIndex idx in m_usedIndices) { if (idx.Hvo == hvo) { wsHvo = idx.WritingSystemRAHvo; break; } } Debug.Assert(wsHvo > 0, "Could not find writing system."); int wsOldDefault = this.DefaultWs; this.DefaultWs = wsHvo; // Cell 1 shows the ws abbreviation. vwenv.OpenTableCell(1,1); vwenv.Props = m_ttpLabel; vwenv.AddObj(wsHvo, this, ReversalIndexEntrySliceView.kFragWsAbbr); vwenv.CloseTableCell(); // Second cell has the contents for the reversal entries. vwenv.OpenTableCell(1,1); // This displays the field flush right for RTL data, but gets arrow keys to // behave reasonably. See comments on LT-5287. IWritingSystem lgws = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(this.DefaultWs); if (lgws != null && lgws.RightToLeft) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); } vwenv.OpenParagraph(); // Do vector of entries in the second column. vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidEntries, this, ReversalIndexEntrySliceView.kFragEntries); vwenv.CloseParagraph(); vwenv.CloseTableCell(); this.DefaultWs = wsOldDefault; break; } case ReversalIndexEntrySliceView.kFragEntryForm: { vwenv.AddStringAltMember((int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm, this.DefaultWs, this); int hvoCurrent = vwenv.CurrentObject(); if (hvoCurrent > 0) { IReversalIndexEntry rie = ReversalIndexEntry.CreateFromDBObject(m_cache, hvoCurrent); Debug.Assert(rie != null); int[] rgWs = m_cache.LangProject.GetReversalIndexWritingSystems(rie.Hvo, false); int wsAnal = m_cache.DefaultAnalWs; ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); tisb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); tisb.Append(" ["); int cstr = 0; ITsTextProps ttpBase = null; for (int i = 0; i < rgWs.Length; ++i) { int ws = rgWs[i]; if (ws == this.DefaultWs) continue; string sForm = rie.ReversalForm.GetAlternative(ws); if (sForm != null && sForm.Length != 0) { if (cstr > 0) tisb.Append(", "); ++cstr; string sWs = m_cache.GetMultiUnicodeAlt(ws, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, wsAnal, "LgWritingSystem_Abbr"); if (sWs != null && sWs.Length != 0) { ITsString tssWs = m_tsf.MakeStringWithPropsRgch(sWs, sWs.Length, m_ttpLabel); tisb.AppendTsString(tssWs); // We have to totally replace the properties set by m_ttpLabel. The // simplest way is to create another ITsString with the simple base // property of only the default analysis writing system. if (ttpBase == null) { ITsPropsBldr tpbBase = TsPropsBldrClass.Create(); tpbBase.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); ttpBase = tpbBase.GetTextProps(); } ITsString tssSpace = m_tsf.MakeStringWithPropsRgch(" ", 1, ttpBase); tisb.AppendTsString(tssSpace); } tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, ws); tisb.Append(sForm); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsAnal); } } if (cstr > 0) { tisb.Append("]"); ITsString tss = tisb.GetString(); vwenv.AddString(tss); } } break; } case ReversalIndexEntrySliceView.kFragWsAbbr: { vwenv.AddString(da.get_StringProp(hvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr)); break; } } }
private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { XmlNode node = m_columns[i - 1]; // Make a cell and embed an editable virtual string for the column. var editable = XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true); if (!editable) vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, NoEditBackgroundColor); vwenv.OpenTableCell(1, 1); int flid = XMLViewsDataCache.ktagEditColumnBase + i; int ws = WritingSystemServices.GetWritingSystem(m_cache, node, null, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle).Handle; // Paragraph directionality must be set before the paragraph is opened. bool fRTL = IsWsRTL(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { // Ignore 0 hvo's. RootObject may have not been set. FWNX-613. if (hvo == 0) { return; } switch (frag) { case kfragRoot: if (m_dxLabWidth == 0) { int dmpx1, dmpy; //, dmpx2; vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy); //vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy); //m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin. m_dxLabWidth = dmpx1 + 13000; // add 3 pt spacing to box, 10 to margin. m_dxWsLabWidth = 0; foreach (ITsString tssLabel in m_WsLabels) { vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy); m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1); } m_dxWsLabWidth += 18000; // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety. } VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColLabels; // 5-pt space plus max label width. vlColLabels.nVal = m_dxLabWidth; vlColLabels.unit = VwUnit.kunPoint1000; VwLength vlColWsLabels; // 5-pt space plus max ws label width. vlColWsLabels.nVal = m_dxWsLabWidth; vlColWsLabels.unit = VwUnit.kunPoint1000; // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; // The Padding column allows for the the trailing margin and border. VwLength vlColPadding; vlColPadding.nVal = 10000; vlColPadding.unit = VwUnit.kunPoint1000; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop, (int)FwTextPropVar.ktpvMilliPoint, 5000); vwenv.OpenTable(4, // Four columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // no padding inside cells. false); vwenv.MakeColumns(1, vlColLabels); vwenv.MakeColumns(1, vlColWsLabels); vwenv.MakeColumns(1, vlColMain); vwenv.MakeColumns(1, vlColPadding); vwenv.OpenTableBody(); for (int i = 0; i < m_writingSystems.Length; i++) { vwenv.OpenTableRow(); // First cell has 'Title' label in bold. vwenv.Props = m_ttpBold; vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, 10000); if (i == 0) // only on the first row { // We want this fixed at 10 point, since it's considered a UI component, not data. // See LT-4816 vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.AddString(m_tssTitle); } vwenv.CloseTableCell(); // Second cell has ws labels. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, m_editBackColor); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (i == 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); } if (i == m_writingSystems.Length - 1) { vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); } vwenv.OpenTableCell(1, 1); vwenv.Props = m_ttpDataCellProps; vwenv.Props = m_ttpWsLabel; vwenv.AddString(m_WsLabels[i]); vwenv.CloseTableCell(); // Third cell has the Title property, in a box. vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, m_editBackColor); // Set the underlying directionality so that arrow keys work properly. bool fRTL = m_writingSystems[i].RightToLeftScript; vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); if (i == 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); } if (i == m_writingSystems.Length - 1) { vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000); } vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.Props = m_ttpDataCellProps; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, this.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable); if (IsScripture) { vwenv.AddStringAltMember(m_vtagStTextTitle, m_writingSystems[i].Handle, this); } else { vwenv.AddStringAltMember(CmMajorObjectTags.kflidName, m_writingSystems[i].Handle, this); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); vwenv.CloseTableRow(); } //// Second row. //vwenv.OpenTableRow(); // //// First cell has 'Comments' label in bold. //vwenv.Props = m_ttpBold; //vwenv.OpenTableCell(1,1); //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.AddString(m_tssComments); //vwenv.CloseTableCell(); // //// Second cell has the Description property, in a box. //vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, // (int)FwTextPropVar.ktpvMilliPoint, 10000); //vwenv.OpenTableCell(1,1); //vwenv.Props = m_ttpDataCellProps; //vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom, // (int)FwTextPropVar.ktpvMilliPoint, 1000); //vwenv.AddStringAltMember( // (int)CmMajorObject.CmMajorObjectTags.kflidDescription, m_wsAnalysis, this); //vwenv.CloseTableCell(); // //vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; default: throw new Exception("Bad frag id in TitleContentsVc"); } }