AddPageElement() protected method

Adds a page element, representing a layout stream in a particular location on the page.
protected AddPageElement ( SIL.FieldWorks.Common.PrintLayout.DivisionLayoutMgr division, IVwLayoutStream stream, bool fPageElementOwnsStream, Rectangle locationOnPage, int dypOffsetToTopOfDataOnPage, bool fMainStream, int currentColumn, int totalColumns, int columnGap, int columnHeight, int dypOverlapWithPreviousElement, bool isRightToLeft, bool fReducesFreeSpaceFromTop ) : void
division SIL.FieldWorks.Common.PrintLayout.DivisionLayoutMgr The division
stream IVwLayoutStream The stream (rootbox) which supplies data for this element
fPageElementOwnsStream bool true if this element is responsible for /// closing its stream when it is destoyed
locationOnPage System.Drawing.Rectangle Location where this stream is laid out, in printer /// pixels, relative to the top left of the physical page
dypOffsetToTopOfDataOnPage int Offset in stream to top of data being shown /// on this page, in printer pixels
fMainStream bool true if this element is for a "main" stream; /// false if it's for a subordinate stream or a Header/Footer stream
currentColumn int The current column (1-based).
totalColumns int The total columns in the specified stream.
columnGap int The gap between the columns.
columnHeight int The height of the current column.
dypOverlapWithPreviousElement int
isRightToLeft bool if set to true the stream is right-to-left. /// Otherwise, it is left-to-right.
fReducesFreeSpaceFromTop bool Flag indicating whether additoin of this /// element reduces the free space from top or bottom.
return void
Exemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add page header and footer elements to the given page.
		/// </summary>
		/// <param name="page">The page to add the header to</param>
		/// <param name="xpLeftMargin">Left margin in printer pixels (we could recalc this, but
		/// since the caller already has it, it's faster to just pass it)</param>
		/// ------------------------------------------------------------------------------------
		private void AddHeaderAndFooter(Page page, int xpLeftMargin)
		{
			// Create the header stream
			IHeaderFooterConfigurer hfconfig = m_configurer.HFConfigurer;
			if (hfconfig == null)
			{
				// This configurer doesn't think we need headers and footers at all (test only?)
				return;
			}
			// TODO: re-use existing header/footer on page. Currently we create a new one
			// everytime we layout the page (e.g. after inserting a footnote).

			// TODO (TE-5845): If this is the first page in the division and this division starts
			// on a new page, treat it as the first page for the purpose of deciding which
			// PubHeaderFooter to use for laying out.
			int hvoHdrRoot = hfconfig.GetHvoRoot(page.PageNumber, true, m_fDifferentFirstHF,
				m_fDifferentEvenHF);
			if (hvoHdrRoot > 0)
			{
				int dypHdrHeight;
				var hfVc = hfconfig.MakeHeaderVc(page);
				m_CreatedHfVcs.Add(hfVc);
				IVwLayoutStream hdrStream = CreateHeaderOrFooter(hfVc,
					hvoHdrRoot, xpLeftMargin, m_dympHeaderPos, out dypHdrHeight);

				PublicationControl.SetAccessibleStreamName(hdrStream,
					Publication.AccessibleName + "_Header");

				// Add the header to the page's collection of elements
				int ypHeaderPosInPrinterPixels = (int)(m_dympHeaderPos *
					Publication.DpiYPrinter / MiscUtils.kdzmpInch) - dypHdrHeight;
				Rectangle locationOnPage = new Rectangle(xpLeftMargin,
					ypHeaderPosInPrinterPixels,
					AvailablePageWidthInPrinterPixels,
					dypHdrHeight);
				page.AddPageElement(this, hdrStream, true, locationOnPage, 0, false, 1, 1, 0,
					dypHdrHeight, 0, MainStreamIsRightToLeft, false);
			}
			int hvoFtrRoot = hfconfig.GetHvoRoot(page.PageNumber, false, m_fDifferentFirstHF,
				m_fDifferentEvenHF);
			if (hvoFtrRoot > 0)
			{
				int dypFtrHeight;
				var hfVc = hfconfig.MakeFooterVc(page);
				m_CreatedHfVcs.Add(hfVc);
				IVwLayoutStream ftrStream = CreateHeaderOrFooter(hfVc,
					hvoFtrRoot, xpLeftMargin, m_dympFooterPos, out dypFtrHeight);

				PublicationControl.SetAccessibleStreamName(ftrStream,
					Publication.AccessibleName + "_Footer");

				// Add the footer to the page's collection of elements
				int ypFooterPosInPrinterPixels = Publication.PageHeightInPrinterPixels -
					(int)(m_dympFooterPos * Publication.DpiYPrinter / MiscUtils.kdzmpInch);
				Rectangle locationOnPage = new Rectangle(xpLeftMargin,
					ypFooterPosInPrinterPixels,
					AvailablePageWidthInPrinterPixels,
					dypFtrHeight);
				page.AddPageElement(this, ftrStream, true, locationOnPage, 0, false, 1, 1, 0,
					dypFtrHeight, 0, MainStreamIsRightToLeft, false);
			}
		}
Exemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add the page element.
		/// </summary>
		/// <param name="page">The page.</param>
		/// <param name="dysSpaceUsedOnPage">The amount of vertical space taken up by this
		/// element on this page.</param>
		/// <param name="currentColumn">The 1-based index of the current column.</param>
		/// <param name="numberColumns">The total number columns for the stream.</param>
		/// <param name="leftMargin">The left margin.</param>
		/// <param name="offsetFromTopOfDiv">The offset from top of division.</param>
		/// <param name="columnHeight">The height of the column.</param>
		/// <param name="dypOverlapWithPreviousElement"></param>
		/// ------------------------------------------------------------------------------------
		protected void AddElement(Page page, int dysSpaceUsedOnPage,
			int currentColumn, int numberColumns, int leftMargin,
			int offsetFromTopOfDiv, int columnHeight, int dypOverlapWithPreviousElement)
		{
			Debug.Assert(!page.IsDisposed);
			Rectangle rect = page.GetElementBounds(this, dysSpaceUsedOnPage, currentColumn,
				numberColumns, leftMargin, offsetFromTopOfDiv, columnHeight);

			page.AddPageElement(this, MainLayoutStream, false, rect, offsetFromTopOfDiv, true,
				currentColumn, numberColumns, ColumnGapWidthInPrinterPixels, columnHeight,
				dypOverlapWithPreviousElement, MainStreamIsRightToLeft, true);
		}
Exemplo n.º 3
-12
//		/// ------------------------------------------------------------------------------------
//		/// <summary>
//		/// Determine the gap between the columns.
//		/// </summary>
//		/// <param name="numberColumns">The total number of columns.</param>
//		/// <returns>
//		/// If the element spans the whole width of the page, the column gap is 0.
//		/// Otherwise, it is ColumnGapWidthInPrinterPixels;
//		/// </returns>
//		/// ------------------------------------------------------------------------------------
//		private int ColumnGap(int numberColumns)
//		{
//			return (numberColumns > 1) ? ColumnGapWidthInPrinterPixels : 0;
//		}

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds or adjusts the page element. Note that this is used ONLY for dependent objects,
		/// it arranges them from the bottom up. These elements don't overlap, so no overlap is
		/// passed.
		/// </summary>
		/// <param name="page">The page.</param>
		/// <param name="ysTopOfPrevElement">The top of the previous element.</param>
		/// <param name="ysStreamHeight">Height of the stream.</param>
		/// <param name="stream">The stream.</param>
		/// <param name="pagePosition">The page position.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private int AddOrAdjustPageElement(Page page, int ysTopOfPrevElement, int ysStreamHeight,
			IVwLayoutStream stream, int pagePosition)
		{
			Debug.Assert(!page.IsDisposed);

			if (ysStreamHeight <= 0)
				return ysTopOfPrevElement;

			int ysTopOfThisElement = ysTopOfPrevElement - ysStreamHeight;
			Rectangle rectLocationOnPage = new Rectangle(LeftMarginInPrinterPixels(page),
				ysTopOfThisElement,
				AvailablePageWidthInPrinterPixels,
				ysStreamHeight);

			PageElement element = page.GetFirstElementForStream(stream);
			if (element == null)
			{
				// Create page element
				page.AddPageElement(this, stream, false, rectLocationOnPage,
					pagePosition, false, 1, 1, 0,
					ysStreamHeight, 0, MainStreamIsRightToLeft, false);
			}
			else
			{
				// Increase size of page element
				if (element.LocationOnPage.Height != ysStreamHeight)
				{
					// Increase size of/move location
					page.AdjustPageElement(element, rectLocationOnPage, false);
				}
			}
			return ysTopOfThisElement;
		}