This class is responsible for laying out the components of a paragraph. It may do a complete layout, or redo the layout of a previously laid out paragraph that is being adjusted, typically because its contents have changed. Its primary organization is a process of assembling lines by adding stuff to them until they are full or there is nothing more to add. Initially, and after each line has been successfully added, its state may be thought of as follows: 1. We are trying to build a box sequence which will be stored in m_para.FirstBox. A chain of boxes built so far begins at m_firstBox (which may initially be null) and continues to m_lastBox. These boxes are organized into lines, stored in m_lines. They correspond to the text from the RenderRuns before m_renderRunIndex, plus the text from RenderRuns[m_renderRunIndex] == m_currentRenderRun, up to m_ichRendered. 2. There may also be a group of lines at the end of the paragraph which we hope to be able to reuse (though they will currently be relative to another, old, TextSource). These lines are stored in m_oldLines, and we have deduced that they correspond to the text in our current source from m_ichStartReusing onwards. If, after completing a line, we find that m_ichRendered == m_ichStartReusing, then we have resynchronized and can reuse the old lines, after adjusting their source and source offset. 3. Otherwise, we have to build a new line, starting with the material at m_ichRendered. Before doing this, if m_ichStartReusing > m_ichRendered, we must discard one (or more) lines of m_oldLines, since we are already past its position. The process of constructing a line is basically to add boxes and text runs (which become string boxes) to the line until it is full. At that point, it may be determined that the current end of the line is not a valid place to break the line. This typically comes about because the last thing on the line is a text box which terminated at a writing system change rather than at a point where the RenderEngine said we could break. When this happens we must backtrack, replacing the last (string) box with a shortened version ending at a good break, or removing it altogether if it is not the first box on the line. (We must always put something on a line, or we get an infinite loop.)
Пример #1
0
        /// <summary>
        /// Redo the layout of the paragraph given the Source changes indicated in the given details.
        /// </summary>
        /// <param name="details"></param>
        private void Relayout(SourceChangeDetails details)
        {
            // We would prefer to keep both sources intact, but we can't just do Source = details.NewSource,
            // because there is currently no way to change the Source of existing segments we may want to reuse.
            Source.Copyfrom(details.NewSource);
            var oldHeight = Height;
            var oldWidth  = Width;

            using (var gh = Root.Site.DrawingInfo)
            {
                // Enhance JohnT: margins: need to adjust MaxWidth for margins and padding of containing boxes.
                var info = new LayoutInfo(ChildTransformFromRootTransform(gh.Transform), Root.LastLayoutInfo.MaxWidth,
                                          gh.VwGraphics, Root.LastLayoutInfo.RendererFactory);
                var builder = new ParaBuilder(this, info);
                using (var lcb = new LayoutCallbacks(Root))
                {
                    builder.Relayout(details, lcb);
                    if (Height != oldHeight || Width != oldWidth)
                    {
                        RelayoutParents(gh);
                    }
                }
            }
        }
Пример #2
0
		public override void Layout(LayoutInfo transform)
		{
			var builder = new ParaBuilder(this, transform);
			builder.FullLayout();
		}
Пример #3
0
		/// <summary>
		/// Redo the layout of the paragraph given the Source changes indicated in the given details.
		/// </summary>
		/// <param name="details"></param>
		private void Relayout(SourceChangeDetails details)
		{
			// We would prefer to keep both sources intact, but we can't just do Source = details.NewSource,
			// because there is currently no way to change the Source of existing segments we may want to reuse.
			Source.Copyfrom(details.NewSource);
			var oldHeight = Height;
			var oldWidth = Width;
			using (var gh = Root.Site.DrawingInfo)
			{
				// Enhance JohnT: margins: need to adjust MaxWidth for margins and padding of containing boxes.
				var info = new LayoutInfo(ChildTransformFromRootTransform(gh.Transform), Root.LastLayoutInfo.MaxWidth,
					gh.VwGraphics, Root.LastLayoutInfo.RendererFactory);
				var builder = new ParaBuilder(this, info);
				using (var lcb = new LayoutCallbacks(Root))
				{
					builder.Relayout(details, lcb);
					if (Height != oldHeight || Width != oldWidth)
						RelayoutParents(gh);
				}
			}
		}
Пример #4
0
        public override void Layout(LayoutInfo transform)
        {
            var builder = new ParaBuilder(this, transform);

            builder.FullLayout();
        }