示例#1
0
        private Tuple <bool, IRenderEngine> GetRenderingEngine(string fontName, IVwGraphics vg, ILgWritingSystem ws)
        {
            // NB: Even if the ws claims graphite is enabled, this might not be a graphite font
            if (ws.IsGraphiteEnabled)
            {
                var graphiteEngine = GraphiteEngineClass.Create();

                string fontFeatures = null;
                if (fontName == ws.DefaultFontName)
                {
                    fontFeatures = GraphiteFontFeatures.ConvertFontFeatureCodesToIds(ws.DefaultFontFeatures);
                }
                graphiteEngine.InitRenderer(vg, fontFeatures);
                // check if the font is a valid Graphite font
                if (graphiteEngine.FontIsValid)
                {
                    graphiteEngine.RenderEngineFactory  = this;
                    graphiteEngine.WritingSystemFactory = ws.WritingSystemFactory;
                    return(new Tuple <bool, IRenderEngine>(ws.IsGraphiteEnabled, graphiteEngine));
                }
                // It wasn't really a graphite font - release the graphite one and create a Uniscribe below
                Marshal.ReleaseComObject(graphiteEngine);
            }
            return(new Tuple <bool, IRenderEngine>(ws.IsGraphiteEnabled, GetUniscribeEngine(vg, ws)));
        }
        public override Rectangle GetSelectionLocation(IVwGraphics vg, PaintTransform ptrans)
        {
            var rectStart = Start.Para.GetRangeLocation(this, vg, Start.Para.Container.ChildTransformFromRootTransform(ptrans));

            if (Start.Para == End.Para)
            {
                return(rectStart);
            }
            var rectEnd = End.Para.GetRangeLocation(this, vg, End.Para.Container.ChildTransformFromRootTransform(ptrans));
            var result  = Sum(rectStart, rectEnd);
            // Boxes in between are just added in their entirety.

            var  stopAt = End.Para;
            bool first  = true;

            for (Box box = Start.Para.Next; box != null && box != End.Para; box = box.NextInSelectionSequence(true))
            {
                // We don't want to automatically include the whole of a containing box if the selection ends somewhere inside it.
                // For example, the selection may extend into a following division.
                if (box.Contains(stopAt))
                {
                    continue;
                }
                var boxTrans = box.Container.ChildTransformFromRootTransform(ptrans);
                result = Sum(result, ptrans.ToPaint(box.Bounds));
            }
            return(result);
        }
        /// <summary>
        /// See C++ documentation
        /// </summary>
        public void DrawTheRootAt(IVwRootBox prootb, IntPtr hdc, Rect rcpDraw, uint bkclr,
                                  bool fDrawSel, IVwGraphics pvg, Rect rcSrc, Rect rcDst, int ysTop, int dysHeight)
        {
            IVwGraphicsWin32 qvg32 = VwGraphicsWin32Class.Create();

            using (Graphics screen = Graphics.FromHdc(hdc))
            {
                Rectangle rcp    = rcpDraw;
                Rectangle rcFill = new Rect(0, 0, rcp.Width, rcp.Height);

                using (var memoryBuffer = new MemoryBuffer(rcp.Width, rcp.Height))
                {
                    memoryBuffer.Graphics.FillRectangle(new SolidBrush(ColorUtil.ConvertBGRtoColor(bkclr)), rcFill);

                    qvg32.Initialize(memoryBuffer.Graphics.GetHdc());
                    qvg32.XUnitsPerInch = rcDst.right - rcDst.left;
                    qvg32.YUnitsPerInch = rcDst.bottom - rcDst.top;

                    try
                    {
                        prootb.DrawRoot2(qvg32, rcSrc, rcDst, fDrawSel, ysTop, dysHeight);
                    }
                    catch (Exception)
                    {
                        qvg32.ReleaseDC();
                        throw;
                    }

                    screen.DrawImageUnscaled(memoryBuffer.Bitmap, rcp);

                    qvg32.ReleaseDC();
                }
            }
        }
示例#4
0
		public IRenderEngine GetRenderer(int ws, IVwGraphics vg)
		{
			IRenderEngine result;
			if (m_renderers.TryGetValue(ws, out result))
				return result;
			return Renderer;
		}
示例#5
0
            /// --------------------------------------------------------------------------------
            /// <summary>
            /// Initializes a new instance of the <see cref="T:HoldDummyGraphics"/> class.
            /// </summary>
            /// <param name="fontName">Name of the font.</param>
            /// <param name="fBold">if set to <c>true</c> [f bold].</param>
            /// <param name="fItalic">if set to <c>true</c> [f italic].</param>
            /// <param name="ctrl">The parent control</param>
            /// --------------------------------------------------------------------------------
            public HoldDummyGraphics(string fontName, bool fBold, bool fItalic, Control ctrl)
            {
                // Make a VwGraphics and initialize it.
                IVwGraphicsWin32 vwGraphics32 = VwGraphicsWin32Class.Create();

                m_vwGraphics = vwGraphics32;
                m_graphics   = ctrl.CreateGraphics();
                m_hdc        = m_graphics.GetHdc();
                ((IVwGraphicsWin32)m_vwGraphics).Initialize(m_hdc);

                // Select our font into it.
                var chrp = new LgCharRenderProps();

                chrp.szFaceName = new ushort[32];
                for (int ich = 0; ich < fontName.Length; ++ich)
                {
                    if (ich < 32)
                    {
                        chrp.szFaceName[ich] = fontName[ich];
                    }
                }
                if (fontName.Length < 32)
                {
                    chrp.szFaceName[fontName.Length] = 0;
                }
                else
                {
                    chrp.szFaceName[31] = 0;
                }
                chrp.ttvBold = (int)(fBold ? FwTextToggleVal.kttvForceOn
                                        : FwTextToggleVal.kttvOff);
                chrp.ttvItalic = (int)(fItalic ? FwTextToggleVal.kttvForceOn
                                        : FwTextToggleVal.kttvOff);
                m_vwGraphics.SetupGraphics(ref chrp);
            }
示例#6
0
        /// <summary>
        /// Given xd, yd somewhere in the overlap, find an xd that will represent a point on our page.
        /// </summary>
        /// <param name="xd"></param>
        /// <param name="yd"></param>
        /// <param name="fToLeft">If true, closest to the left, otherwise, to the right</param>
        /// <returns></returns>
        internal int ClosestXInOurPartOfOverlap(int xd, int yd, bool fToLeft)
        {
            int xTry      = xd;
            int lastLeft  = Int32.MinValue;
            int lastRight = Int32.MinValue;

            for (; ;)
            {
                IVwGraphics vg = m_division.Publication.PrinterGraphics;                 // Todo: where can we get the publication??
                int         left, right;
                bool        inPageAbove = m_stream.IsInPageAbove(xTry, yd, this.OffsetToTopPageBoundary, vg, out left, out right);
                m_division.Publication.ReleaseGraphics(vg);
                if (!inPageAbove)
                {
                    return(xTry);
                }
                // It's just possible we could, pathologically, loop forever if we keep getting the same line.
                // I don't think it can happen but let's play safe. Returning an invalid x at worst puts us
                // on the wrong page by one.
                if (lastLeft == left && lastRight == right)
                {
                    return(xTry);
                }
                if (fToLeft)
                {
                    xTry = left - 1;
                }
                else
                {
                    xTry = right + 1;
                }
            }
        }
示例#7
0
        /// <summary>
        /// Given xd, yd somewhere in the overlap, find an xd that is NOT in our
        /// part of the overlap, that is, it's part of a line on the previous page.
        /// Enhance JohnT: it would be nicer to find the CLOSEST x that's in a line of
        /// the previous page, but that's more difficult. Usally we only have two columns
        /// so it's not an issue.
        /// </summary>
        /// <param name="xd"></param>
        /// <param name="yd"></param>
        /// <param name="fToLeft">If true, the left end of the previous page line, otherwise, the right end.</param>
        /// <returns></returns>
        internal int XNotInOurPartOfOverlap(int xd, int yd, bool fToLeft)
        {
            IVwGraphics vg = m_division.Publication.PrinterGraphics;             // Todo: where can we get the publication??
            int         left, right;
            bool        inPageAbove = m_stream.IsInPageAbove(xd, yd, this.OffsetToTopPageBoundary, vg, out left, out right);

            m_division.Publication.ReleaseGraphics(vg);
            if (inPageAbove)
            {
                return(xd);                // original point is fine
            }
            if (left == 0 && right == 0)
            {
                return(xd);                // nothing we can do, don't think this can happen.
            }
            // OK, left and right are the boundaries of the lowest line on the previous page.
            // Our point is outside the range. Move inside the range in the appropriate direction.
            // Since the initial xd is as far left or right as possible
            if (fToLeft)
            {
                return(left);
            }
            else
            {
                return(right);
            }
        }
示例#8
0
        private void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            // If the print rootsite hasn't been initialized yet, do so now.
            if (m_rootb == null)
            {
                Init(e);

                if (m_rootb == null || !m_morePagesToPrint)
                {
                    e.HasMorePages = false;
                    return;
                }
            }

            // Initialize the IVwGraphics with the hDC from the .Net graphics object.
            IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
            IntPtr      hdc        = e.Graphics.GetHdc();

            ((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
            m_vwPrintContext.SetGraphics(vwGraphics);

            // Print the next page
            m_rootb.PrintSinglePage(m_vwPrintContext, m_nextPageToPrint);

            // Release these things here or bad things will happen.
            vwGraphics.ReleaseDC();
            if (hdc != IntPtr.Zero)
            {
                e.Graphics.ReleaseHdc(hdc);
            }

            // If more lines exist, print another page.
            Advance();
            e.HasMorePages = m_morePagesToPrint;
        }
示例#9
0
 public bool PositionOfRange(int ichBase, IVwGraphics _vg, Rect rcSrc, Rect rcDst, int ichMin, int ichLim, int ydTop, int ydBottom, bool fIsLastLineOfSelection, out Rect rsBounds)
 {
     LastDrawRangeCall = new DrawRangeArgs
     {
         IchBase  = ichBase,
         Graphics = _vg,
         RcSrc    = rcSrc,
         RcDst    = rcDst,
         IchMin   = ichMin,
         IchLim   = ichLim,
         YdTop    = ydTop,
         YdBottom = ydBottom,
         IsLastLineOfSelection = fIsLastLineOfSelection
     };
     if (NextPositionOfRange == null)
     {
         rsBounds = new Rect(-1, -1, -1, -1);
         return(false);
     }
     else
     {
         rsBounds = NextPositionOfRange.RsBounds;
         return(NextPositionOfRange.DisplayedInSegment);
     }
 }
示例#10
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Get a graphics object in an appropriate state for drawing and measuring in the view.
 /// The calling method should pass the IVwGraphics back to ReleaseGraphics() before
 /// it returns. In particular, problems will arise if OnPaint() gets called before the
 /// ReleaseGraphics() method.
 /// </summary>
 /// <param name="pRoot"></param>
 /// <param name="pvg"></param>
 /// <param name="rcSrcRoot"></param>
 /// <param name="rcDstRoot"></param>
 /// -----------------------------------------------------------------------------------
 void IVwRootSite.GetGraphics(IVwRootBox pRoot, out IVwGraphics pvg, out Rect rcSrcRoot,
                              out Rect rcDstRoot)
 {
     pvg       = m_vwPrintContext.Graphics;
     rcSrcRoot = m_rcSrc;
     rcDstRoot = m_rcDst;
 }
示例#11
0
 /// <summary>
 /// The root box handles the overall paint.
 /// </summary>
 /// <param name="vg"></param>
 /// <param name="ptrans"></param>
 public void Paint(IVwGraphics vg, PaintTransform ptrans)
 {
     if (m_layoutCallbacks != null)
     {
         // In a state where we can't paint. Arrange for an invalidate AFTER the dangerous operation is over,
         // so what needs painting eventually does get painted.
         var bounds = Bounds;
         bounds.Inflate(10, 10);
         m_layoutCallbacks.Invalidate(bounds);
         return;
     }
     // First we paint the overall background. This basically covers everything but text.
     PaintBackground(vg, ptrans);
     // Then the text.
     PaintForeground(vg, ptrans);
     // And finally the selection.
     if (Selection != null && m_selectionShowing)
     {
         if (Selection.IsValid)
         {
             Selection.Draw(vg, ptrans);
         }
         else
         {
             Selection = null;
         }
     }
 }
示例#12
0
        private static bool GetRangeLocationInBox(Box box, IVwGraphics vg, PaintTransform ptrans, int top, int bottom, int ichMin, int ichLim,
                                                  bool first, ref Rect bounds)
        {
            var sb = box as StringBox;

            if (sb == null)
            {
                return(first);                // didn't get one here, no change to first
            }
            PaintTransform segTrans = ptrans.PaintTransformOffsetBy(sb.Left, sb.Top);
            Rect           bounds1;

            if (sb.Segment.PositionOfRange(sb.IchMin, vg, segTrans.SourceRect,
                                           segTrans.DestRect, ichMin, ichLim, top, bottom, true, out bounds1) &&
                bounds1.right > bounds1.left)
            {
                if (first)
                {
                    bounds = bounds1;
                }
                else
                {
                    bounds = new Rect(Math.Min(bounds.left, bounds1.left),
                                      Math.Min(bounds.top, bounds1.top),
                                      Math.Max(bounds.right, bounds1.right),
                                      Math.Max(bounds.bottom, bounds1.bottom));
                }
                return(false);        // got first rectangle, no longer looking for first one
            }
            return(first);            // didn't get one yet, no change to first.
        }
示例#13
0
 public void PositionsOfIP(int ichBase, IVwGraphics _vg, Rect rcSrc, Rect rcDst, int ich, bool fAssocPrev, LgIPDrawMode dm,
                           out Rect rectPrimary, out Rect rectSecondary, out bool fPrimaryHere, out bool fSecHere)
 {
     LastPosIpCall           = new PositionsOfIpArgs();
     LastPosIpCall.IchBase   = ichBase;
     LastPosIpCall.Graphics  = _vg;
     LastPosIpCall.RcSrc     = rcSrc;
     LastPosIpCall.RcDst     = rcDst;
     LastPosIpCall.Ich       = ich;
     LastPosIpCall.AssocPrev = fAssocPrev;
     LastPosIpCall.DrawMode  = dm;
     if (NextPosIpResult != null)
     {
         rectPrimary   = NextPosIpResult.RectPrimary;
         rectSecondary = new Rect();       // NextPosIpResult.RectSecondary;
         fPrimaryHere  = NextPosIpResult.PrimaryHere;
         fSecHere      = false;            // NextPosIpResult.SecHere;
     }
     else
     {
         rectPrimary   = new Rect(0, 0, 0, 0);
         rectSecondary = new Rect(0, 0, 0, 0);
         fPrimaryHere  = true;                // useful result when we don't care to prepare for this call.
         fSecHere      = false;
     }
 }
示例#14
0
        /// <summary>
        /// Get the location of the primary insertion point.
        /// Review JohnT: is it possible that more than one segment contains this, and we need to combine them?
        /// Or that none does?
        /// </summary>
        public Rectangle GetIpLocation(InsertionPoint ip, IVwGraphics vg, PaintTransform ptrans)
        {
            PaintTransform childTrans = ChildTransformFromRootTransform(ptrans);
            int            ichMin     = ip.RenderParaPosition;
            int            ichLim     = ip.LastRenderParaPosition;

            if (ichLim > ichMin)
            {
                // Displaying a substitute string.
                var  bounds = new Rect();
                bool first  = true;
                DoRangePaintingOp(ichMin, ichLim, vg, childTrans, (box, vg1, childTrans1, top, bottom, ichMin1, ichLim1) =>
                                  { first = GetRangeLocationInBox(box, vg1, childTrans1, top, bottom, ichMin1, ichLim1, first, ref bounds); });
                return(new Rectangle(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top));
            }
            for (Box current = FirstBox; current != null; current = current.Next)
            {
                var sb = current as StringBox;
                if (sb == null)
                {
                    continue;
                }
                bool      fLocHere;
                Rectangle temp = sb.GetIpLocation(ip, vg, childTrans, out fLocHere);
                if (fLocHere)
                {
                    return(temp);
                }
            }
            throw new ApplicationException("No paragraph segment has the location of the primary IP");
        }
示例#15
0
        /// <summary>
        /// Answer true if the box is entirely below the clip rectangle.
        /// Enhance JohnT: Could refine this to skip a box if only its margin is visible.
        /// Enhance JohnT: if we do separate page drawing, as in print preview, we may need
        /// a more precise way to eliminate boxes not on the page.
        /// Enhance JohnT: may need to include a box that is just out of sight, in case exceptionally
        /// high stacked diacritics extend above the top of the box?
        /// </summary>
        internal override bool IsAfterVisibleBoxes(Box box, IVwGraphics vg, PaintTransform ptrans)
        {
            int left, top, right, bottom;

            vg.GetClipRect(out left, out top, out right, out bottom);
            return(ptrans.ToPaintY(box.Top) > bottom);
        }
示例#16
0
        // Do a range-painting operation (actual painting, or measuring, which involve much of the same work
        // except for the innermost step) for a given range of rendered characters.
        // This may be called for an actual range, or for an insertion point rendered as a substitute prompt.
        private void DoRangePaintingOp(int ichMin, int ichLim, IVwGraphics vg, PaintTransform ptrans, RangePaintingOp op)
        {
            if (Lines.Count == 0)
            {
                return;
            }
            PaintTransform childTrans     = ptrans.PaintTransformOffsetBy(Left, Top);
            var            previousBottom = childTrans.ToPaintY(Lines[0].Top);

            for (int i = 0; i < Lines.Count; i++)
            {
                var line   = Lines[i];
                var bottom = line.Bottom;
                if (i != Lines.Count - 1)
                {
                    bottom = (Lines[i + 1].Top + bottom) / 2;                     // split the difference between this line and the next
                }
                bottom = childTrans.ToPaintY(bottom);
                foreach (var box in line.Boxes)
                {
                    op(box, vg, childTrans, previousBottom, bottom, ichMin, ichLim);
                }
                previousBottom = bottom;
            }
        }
示例#17
0
        internal void DrawIp(InsertionPoint ip, IVwGraphics vg, PaintTransform ptrans)
        {
            PaintTransform segTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            Segment.DrawInsertionPoint(IchMin, vg, segTrans.SourceRect, segTrans.DestRect,
                                       ip.RenderParaPosition, ip.AssociatePrevious, true, LgIPDrawMode.kdmNormal);
        }
示例#18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void Init(PrintPageEventArgs e)
        {
#if false
            long x1 = System.DateTime.Now.Ticks;
#endif
            // Set these now because the Graphics object will be locked below.
            m_rcDst         = m_rcSrc = new Rect(0, 0, (int)e.Graphics.DpiX, (int)e.Graphics.DpiY);
            m_dxpAvailWidth = PixelsFrom100ths(e.MarginBounds.Width, (int)e.Graphics.DpiX);

            // Create and initialize a print context.
            m_vwPrintContext = VwPrintContextWin32Class.Create();

            // TODO: When we provide a way for the user to specify the nFirstPageNo (i.e. the
            // first argument to SetPagePrintInfo), then change the arguments to
            // SetPagePrintInfo.
            m_vwPrintContext.SetPagePrintInfo(1, 1, 65535, 1, false);
            SetMargins(e);

            IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
            IntPtr      hdc        = IntPtr.Zero;
            try
            {
                // Get the printer's hdc and use it to initialize other stuff.
                hdc = e.Graphics.GetHdc();
                ((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
                m_vwPrintContext.SetGraphics(vwGraphics);

                // Make a rootbox for printing and initialize it.
                m_rootb = VwRootBoxClass.Create();
                m_rootb.SetSite(this);
                m_rootb.DataAccess = m_sda;
                m_rootb.SetRootObject(m_hvo, m_vc, m_frags, m_styleSheet);
                m_rootb.InitializePrinting(m_vwPrintContext);
                m_totalNumberOfPages = m_rootb.GetTotalPrintPages(m_vwPrintContext, null);
                m_psettings          = e.PageSettings.PrinterSettings;
                SetPrintRange();
            }
            catch
            {
                m_rootb = null;
                string errorMsg =
                    ResourceHelper.GetResourceString("kstidErrorCreatingPrintRootSite");

                // TODO: Add the help file and url when we have a help file.
                MessageBox.Show(errorMsg, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (hdc != IntPtr.Zero)
                {
                    vwGraphics.ReleaseDC();
                    e.Graphics.ReleaseHdc(hdc);
                }
            }
#if false
            long x2 = System.DateTime.Now.Ticks;
            Debug.WriteLine("PrintRootSite.Init() took " + DeltaTime(x1, x2) + " seconds.");
#endif
        }
示例#19
0
 /// <summary>
 /// Get a suitable rendering engine for the specified writing system when drawing in the specified graphics environment.
 /// </summary>
 public IRenderEngine GetRenderer(int ws, IVwGraphics vg)
 {
     if (ws == 0)
     {
         return(m_wsf.get_Renderer(m_wsf.UserWs, vg));
     }
     return(m_wsf.get_Renderer(ws, vg));
 }
示例#20
0
        public override void MakeRoot(IVwGraphics vg, ILgEncodingFactory encfParam, out IVwRootBox rootbParam)
        {
            rootbParam = null;

            // JohnT: this is a convenient though somewhat unconventional place to create and partly
            // initialize the combo box. We can't set its position yet, as that depends on what the user
            // clicks. Nor do we yet add it to our list of windows, nor make it visible.
            typeComboBox = new System.Windows.Forms.ComboBox();
            typeComboBox.Items.AddRange(new object[] { "sal", "noun", "verb", "det", "adj", "adv" });
            typeComboBox.DropDownWidth         = 280;     // Todo JohnT: make right for showing all options
            typeComboBox.SelectedValueChanged += new EventHandler(this.HandleComboSelChange);

            base.MakeRoot(vg, encfParam, out rootbParam);

            if (m_fdoCache == null || DesignMode)
            {
                return;
            }

            IVwRootBox rootb = (IVwRootBox) new FwViews.VwRootBoxClass();

            rootb.SetSite(this);

            int hvoRoot = khvoText;

            // Set up sample data (not in the database for now)
            ITsStrFactory tsf    = (ITsStrFactory) new FwKernelLib.TsStrFactoryClass();
            int           encEng = 0;   // TODO: Implement StrUtil::ParseEnc

            string[] words      = { "Hello", "world!", "This", "is", "an", "interlinear", "view" };
            string[] wordtypes  = { "sal", "noun", "det", "verb", "det", "adj", "noun" };
            int[]    rghvoWords = new int[(words.Length)];
            for (int i = 0; i < words.Length; ++i)
            {
                ITsString tss = tsf.MakeString(words[i], encEng);
                // Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
                m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Form, tss);
                tss = tsf.MakeString(wordtypes[i], encEng);
                // Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
                m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Type, tss);
                rghvoWords[i] = i + 1;
            }
            m_fdoCache.VwCacheDaAccessor.CacheVecProp(khvoText, ktagText_Words, rghvoWords, rghvoWords.Length);

            int frag = kfrText;

            m_iVc = new InterlinearVc();

            if (encfParam != null)
            {
                m_fdoCache.MainCacheAccessor.set_EncodingFactory(encfParam);
            }

            rootb.set_DataAccess(m_fdoCache.MainCacheAccessor);

            rootb.SetRootObject(hvoRoot, m_iVc, frag, null);
            rootbParam = rootb;
        }
示例#21
0
        internal override Selection MakeSelectionAt(Point where, IVwGraphics vg, PaintTransform ptrans)
        {
            var  segTrans = ptrans.PaintTransformOffsetBy(Left, Top);
            int  ich;
            bool assocPrev;

            Segment.PointToChar(IchMin, vg, segTrans.SourceRect, segTrans.DestRect, where, out ich, out assocPrev);
            return(Paragraph.SelectAt(ich, assocPrev));
        }
示例#22
0
        /// ------------------------------------------------------------------------------------------
        /// <summary>
        /// Don't allow user to press enter.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="modifiers"></param>
        /// <param name="graphics"></param>
        /// ------------------------------------------------------------------------------------------
        public override void OnKeyPress(KeyPressEventArgs e, Keys modifiers, IVwGraphics graphics)
        {
            CheckDisposed();

            if (e.KeyChar != (char)13)
            {
                base.OnKeyPress(e, modifiers, graphics);
            }
        }
示例#23
0
        public override void PaintBackground(IVwGraphics vg, PaintTransform ptrans)
        {
            base.PaintBackground(vg, ptrans);
            PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
            {
                box.PaintBackground(vg, childTrans);
            }
        }
示例#24
0
 public void PointToChar(int ichBase, IVwGraphics vg, Rect rcSrc, Rect rcDst, Point tdClickPosition, out int ich, out bool assocPrev)
 {
     PointToCharIchBase       = ichBase;
     PointToCharVg            = vg;
     PointToCharRcSrc         = rcSrc;
     PointToCharRcDst         = rcDst;
     PointToCharClickPosition = tdClickPosition;
     ich       = m_pointToCharOffset;
     assocPrev = m_pointToCharAssocPrev;
 }
示例#25
0
        private static void DrawSelectionInBox(Box box, IVwGraphics vg, PaintTransform childTrans, int top, int bottom, int ichMin, int ichLim)
        {
            var sb = box as StringBox;

            if (sb == null)
            {
                return;
            }
            sb.DrawRange(ichMin, ichLim, vg, childTrans, top, bottom);
        }
示例#26
0
        /// <summary>
        /// An insertion point is valid unless between a base character and diacritic.
        /// For simulation purposes the diacritics are '^' and '~".
        /// </summary>
        public LgIpValidResult IsValidInsertionPoint(int ichBase, IVwGraphics _vg, int ich)
        {
            int offset = ich - ichBase;

            if (offset >= 0 && offset < Text.Length && (Text[offset] == '~' || Text[offset] == '^'))
            {
                return(LgIpValidResult.kipvrBad);
            }
            return(LgIpValidResult.kipvrOK);
        }
示例#27
0
		public void DrawText(int ichBase, IVwGraphics vg, Rect rcSrc, Rect rcDst, out int dxdWidth)
		{
			dxdWidth = Width;
			var args = new SegDrawTextArgs();
			args.ichBase = ichBase;
			args.vg = vg;
			args.rcSrc = rcSrc;
			args.rcDst = rcDst;
			LastDrawTextCall = args;
		}
示例#28
0
        public IRenderEngine GetRenderer(int ws, IVwGraphics vg)
        {
            IRenderEngine result;

            if (m_renderers.TryGetValue(ws, out result))
            {
                return(result);
            }
            return(Renderer);
        }
示例#29
0
        /// -----------------------------------------------------------------------------------
        /// <summary>Member FwXYFromGlyphPoint</summary>
        /// <param name='chw'>chw</param>
        /// <param name='nPoint'>nPoint</param>
        /// <param name='_xRet'>_xRet</param>
        /// <param name='_yRet'>_yRet</param>
        /// -----------------------------------------------------------------------------------
        public void FwXYFromGlyphPoint(int chw, int nPoint, out int _xRet, out int _yRet)
        {
            Debug.Assert(m_bitmapGraphics != null);
            IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
            IntPtr      hdc        = m_bitmapGraphics.GetHdc();

            ((IVwGraphicsWin32)vwGraphics).FwInitialize(hdc);
            vwGraphics.FwXYFromGlyphPoint(chw, nPoint, out _xRet, out _yRet);
            m_bitmapGraphics.ReleaseHdc(hdc);
        }
示例#30
0
        public void DrawText(int ichBase, IVwGraphics vg, Rect rcSrc, Rect rcDst, out int dxdWidth)
        {
            dxdWidth = Width;
            var args = new SegDrawTextArgs();

            args.ichBase     = ichBase;
            args.vg          = vg;
            args.rcSrc       = rcSrc;
            args.rcDst       = rcDst;
            LastDrawTextCall = args;
        }
示例#31
0
        public override void PaintForeground(IVwGraphics vg, PaintTransform ptrans)
        {
            base.PaintForeground(vg, ptrans);
            PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
            {
                //vg.PushClipRect(new Rect(box.Left, box.Top, box.Right, box.Bottom));
                box.PaintForeground(vg, childTrans);
            }
        }
示例#32
0
        internal void DrawRange(int ichMin, int ichLim, IVwGraphics vg, PaintTransform ptrans, int topOfLine, int bottomOfLine)
        {
            PaintTransform segTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            // Todo JohnT: here or in client we need to handle ranges that don't start and end in this paragraph.
            // Todo JohnT: the last true appears to be what the old Views code normally passes, but there may be some case where
            // we should pass false.
            // Todo JohnT: passing the top and bottom of the string box as ydTop and ydBottom will not work when we have specified line spacing.
            Segment.DrawRange(IchMin, vg, segTrans.SourceRect, segTrans.DestRect,
                              ichMin, ichLim, topOfLine, bottomOfLine, true, true);
        }
示例#33
0
		public override void PaintForeground(IVwGraphics vg, PaintTransform ptrans)
		{
			if (Segment == null)
				return;
			int dxdWidth;
			PaintTransform segTrans = ptrans.PaintTransformOffsetBy(Left, Top);

			if (AnyColoredBackground)
				Segment.DrawTextNoBackground(IchMin, vg, segTrans.SourceRect, segTrans.DestRect, out dxdWidth);
			else
				Segment.DrawText(IchMin, vg, segTrans.SourceRect, segTrans.DestRect, out dxdWidth); // more efficient.
		}
示例#34
0
		public void FindBreakPoint(IVwGraphics vg, IVwTextSource _ts, IVwJustifier _vjus, int ichMin, int ichLim,
			int ichLimBacktrack, bool fNeedFinalBreak, bool fStartLine, int dxMaxWidth, LgLineBreak lbPref,
			LgLineBreak lbMax, LgTrailingWsHandling twsh, bool fParaRightToLeft,
			out ILgSegment segRet, out int dichLimSeg, out int dxWidth, out LgEndSegmentType est, ILgSegment _segPrev)
		{

			MockSegment seg;
			var key = new MockSegKey(ichMin, ichLim);
			if (lbPref != LgLineBreak.klbClipBreak && m_failOnPartialLine.Contains(key))
			{
				// fail.
				segRet = null;
				dichLimSeg = 0;
				dxWidth = 0;
				est = LgEndSegmentType.kestNothingFit;
				return;
			}
			if (m_potentialSegs.TryGetValue(key, out seg))
			{
				if (seg.Width < dxMaxWidth) // otherwise we meant it for the next line.
				{
					segRet = seg;
					dichLimSeg = seg.get_Lim(ichMin);
					dxWidth = seg.get_Width(ichMin, vg);
					est = seg.EndSegType;
					return;
				}
			}
			switch(OtherSegPolicy)
			{
				case UnexpectedSegments.DontFit:
				default: // to make compiler happy
					Assert.AreNotEqual(LgLineBreak.klbClipBreak, lbMax,
									   "FindBreakPoint called with unexpected arguments.");
					// If we aren't pre-prepared for the requested break, assume nothing fits with these arguments.
					segRet = null;
					dichLimSeg = 0;
					dxWidth = 0;
					est = LgEndSegmentType.kestNothingFit;
					break;
				case UnexpectedSegments.MakeOneCharSeg:
					// Make a very narrow segment that will fit and allow more stuff. This will usually give a test failure if not intentional.
					seg = new MockSegment(1, 2, 1, LgEndSegmentType.kestOkayBreak);
					// If we aren't pre-prepared for the requested break, assume nothing fits with these arguments.
					segRet = seg;
					dichLimSeg = 1;
					dxWidth = 2;
					est = LgEndSegmentType.kestOkayBreak;
					break;
			}
		}
		public void Layout(IVwGraphics _vg, int dxsAvailWidth)
		{
			throw new NotImplementedException();
		}
		public void DrawRoot(IVwGraphics _vg, Utils.Rect rcSrc, Utils.Rect rcDst, bool fDrawSel)
		{
			throw new NotImplementedException();
		}
		public VwPrepDrawResult PrepareToDraw(IVwGraphics _vg, Utils.Rect rcSrc, Utils.Rect rcDst)
		{
			throw new NotImplementedException();
		}
示例#38
0
		internal static LayoutInfo MakeLayoutInfo(int maxWidth, IVwGraphics vg, IRendererFactory factory)
		{
			return new LayoutInfo(2, 2, 96, 96, maxWidth, vg, factory);
		}
示例#39
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Inform the container when done with the graphics object.
		/// </summary>
		/// <param name="prootb"></param>
		/// <param name="pvg"></param>
		/// -----------------------------------------------------------------------------------
		void IVwRootSite.ReleaseGraphics(IVwRootBox prootb, IVwGraphics pvg)
		{
			// Do nothing for printing
		}
示例#40
0
		/// <summary>
		/// Make whatever selection is appropriate for the given click. The transformation is the usual one passed to this box,
		/// that is, it transforms where (which is in paint coords) into a point in the same coordinate system as our own top, left.
		/// </summary>
		internal virtual Selections.Selection MakeSelectionAt(Point where, IVwGraphics vg, PaintTransform leafTrans)
		{
			return null;
		}
		public void Location(IVwGraphics _vg, Utils.Rect rcSrc, Utils.Rect rcDst,
			out Utils.Rect _rdPrimary, out Utils.Rect _rdSecondary, out bool _fSplit,
			out bool _fEndBeforeAnchor)
		{
			_rdPrimary = default(Utils.Rect);
			_rdSecondary = default(Utils.Rect);
			_fSplit = false;
			_fEndBeforeAnchor = false;
		}
示例#42
0
		/// <summary>
		/// Returns information about possible drops with these arguments.
		/// </summary>
		public void OnDragEnter(DragEventArgs drgevent, Point location, IVwGraphics vg, PaintTransform ptrans)
		{
			if (DragState == WindowDragState.InternalMove)
			{
				// On a simple click (at least), Windows calls OnDragEnter AFTER OnQueryContinueDrag, attempting to drop
				// right where we clicked. OnQueryContinueDrag detects this; we must not reset it.
				return;
			}
			drgevent.Effect = DragDropEffects.None; // default
			var sel = GetSelectionAt(location, vg, ptrans) as InsertionPoint;
			if (sel == null)
				return;
			if (!sel.CanInsertText)
				return;
			var data = drgevent.Data.GetData(DataFormats.StringFormat);
			if (data == null)
				return;

			DragState = WindowDragState.DraggingHere;

			// We will copy if control is held down or move is not allowed.)
			if ((drgevent.KeyState & (int)DragDropKeyStates.ControlKey) != 0 ||
				(drgevent.AllowedEffect & DragDropEffects.Move) == 0)
			{
				//Log("DragEnter/Move: set effect to copy");
				drgevent.Effect = DragDropEffects.Copy;
			}
			else
			{
				//Log("DragEnter/Move: set effect to move");
				drgevent.Effect = DragDropEffects.Move;
			}
		}
示例#43
0
			public override void PaintForeground(IVwGraphics vg, PaintTransform ptrans)
			{
				((MockGraphics)vg).DrawActions.Add(this);
			}
示例#44
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// The layout manager is informed by this method that the (primary) layout stream 'lay'
		/// has determined that references to the objects objectGuids occur on the page. The input
		/// value of dysAvailHeight indicates how much of the height allocated to 'lay' for this
		/// page will remain available if the text containing these references is added to the
		/// page (assuming that adding them does not reduce the space available for 'lay').
		/// </summary>
		/// <param name="lay">The primary layout stream filling the page</param>
		/// <param name="vg">The graphics object being used to layout the page</param>
		/// <param name="hPage">The handle to the page being laid out</param>
		/// <param name="cguid">Number of elements in objectGuids array</param>
		/// <param name="objectGuids">Array of GUIDS representing objects to be laid out in a
		/// separate layout stream</param>
		/// <param name="fAllowFail">Indicates whether this method can fail (return
		/// <c>fFailed == true</c>). If this is false, this method should force the requested
		/// objects to be laid out within the available space, even if it requires omitting or
		/// truncating some or all of them</param>
		/// <param name="fFailed">If the available height would become negative (typically
		/// because the objects must share space with 'lay' and they don't fit in the available
		/// height), this will be set to true (unless fAllowFail is false).</param>
		/// <param name="dysAvailHeight">Input value indicates how much of the height allocated
		/// to 'lay' for this page will remain available if the text containing these references
		/// is added to the page, assuming that adding them does not reduce the space available
		/// for 'lay'. The output value indicates how much is left after laying out these
		/// dependent objects.</param>
		/// -------------------------------------------------------------------------------------
		public virtual void AddDependentObjects(IVwLayoutStream lay, IVwGraphics vg, int hPage,
			int cguid, Guid[] objectGuids, bool fAllowFail, out bool fFailed,
			ref int dysAvailHeight)
		{
			CheckDisposed();
			if (m_configurer.RootOnEachPage)
			{
				AddDependentObjectsToPageRoot(lay, vg, hPage,
					cguid, objectGuids, fAllowFail, out fFailed,
					ref dysAvailHeight);
				return;
			}

			int dysAvailableHeight = dysAvailHeight;
			fFailed = false;

			int[] rgHvo = new int[cguid];
			int i = 0;
			foreach (Guid guid in objectGuids)
			{
				rgHvo[i++] = m_configurer.GetIdFromGuid(guid);
			}

			// Attempt to add all objects to any stream(s) that care about them. Don't
			// commit changes to any streams until we see if everything will fit.
			int[] rgdysNewStreamHeight = new int[m_subStreams.Count];
			int iSubStream = -1;
			foreach (SubordinateStream subStream in m_subStreams)
			{
				subStream.m_stream.SetManager(this); // Set this every time for the sake of shared streams
				iSubStream++;
				int dysInitialPageHeight = subStream.m_stream.PageHeight(hPage);
				foreach (int hvo in rgHvo)
				{
					if (hvo == 0)
						continue; // Unable to find object in database. (TE-5007)
					SelLevInfo[] rgSelLevInfo = subStream.m_delegate.GetPathToObject(hvo);
					if (rgSelLevInfo == null)
						continue; // This stream doesn't display this object.

					subStream.m_stream.LayoutObj(vg, AvailablePageWidthInPrinterPixels, 0,
						rgSelLevInfo.Length, rgSelLevInfo, hPage);
				}
				int dysHeightWithAddedObjects = subStream.m_stream.PageHeight(hPage);
				rgdysNewStreamHeight[iSubStream] = dysHeightWithAddedObjects;

				int dysHeightUsed = dysHeightWithAddedObjects - dysInitialPageHeight;
				// If this stream is just now being added to the page, need to allow for gap between elements.
				if (dysInitialPageHeight == 0)
					dysHeightUsed += VerticalGapBetweenElements * vg.YUnitsPerInch / MiscUtils.kdzmpInch;

				if ((dysHeightUsed * m_numberMainStreamColumns) > dysAvailHeight)
				{
					// We can't add everything needed for the current chunk (in the main stream),
					// so we need to fail (if that's permitted), and roll everything back
					if (fAllowFail)
						fFailed = true;
					else
						dysAvailableHeight = 0;
					break;
				}
				else
				{
					// When we layout with multiple columns, we pretend to have one large
					// page. But the substreams are still only one column which means
					// they affect all columns, so we have to multiply the height used
					// with the number of columns.
					dysAvailableHeight -= (dysHeightUsed * m_numberMainStreamColumns);
				}
			}

			// Now we know all the objects fit (or else we weren't allowed to fail), so
			// remove or commit the objects we just added to any streams AND adjust
			// the rectangle occupied by each element so they "stack" properly.

			Page page = Publication.FindPage(hPage);

			// First time thru, the previous "element" is the bottom page margin.
			int ysTopOfPrevElement =
				Publication.PageHeightInPrinterPixels - BottomMarginInPrinterPixels;
			for (; iSubStream >= 0; iSubStream--)
			{
				SubordinateStream subStream = m_subStreams[iSubStream];
				if (fFailed)
				{
					subStream.m_stream.RollbackLayoutObjects(hPage);
				}
				else
				{
					subStream.m_stream.CommitLayoutObjects(hPage);

					ysTopOfPrevElement = AddOrAdjustPageElement(page, ysTopOfPrevElement,
						rgdysNewStreamHeight[iSubStream], subStream.m_stream,
						subStream.m_stream.PagePostion(hPage));
				}
			}

			if (!fFailed)
				dysAvailHeight = dysAvailableHeight;
		}
示例#45
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// The layout manager is informed by this method that the (primary) layout stream 'lay'
		/// has determined that references to the objects objectGuids occur on the page. The input
		/// value of dysAvailHeight indicates how much of the height allocated to 'lay' for this
		/// page will remain available if the text containing these references is added to the
		/// page (assuming that adding them does not reduce the space available for 'lay').
		/// This is an alternative implementation of AddDependentObjects for the case where
		/// RootOnEachPage is true.
		/// </summary>
		/// <param name="lay">The primary layout stream filling the page</param>
		/// <param name="vg">The graphics object being used to layout the page</param>
		/// <param name="hPage">The handle to the page being laid out</param>
		/// <param name="cguid">Number of elements in objectGuids array</param>
		/// <param name="objectGuids">Array of GUIDS representing objects to be laid out in a
		/// separate layout stream</param>
		/// <param name="fAllowFail">Indicates whether this method can fail (return
		/// <c>fFailed == true</c>). If this is false, this method should force the requested
		/// objects to be laid out within the available space, even if it requires omitting or
		/// truncating some or all of them</param>
		/// <param name="fFailed">If the available height would become negative (typically
		/// because the objects must share space with 'lay' and they don't fit in the available
		/// height), this will be set to true (unless fAllowFail is false).</param>
		/// <param name="dysAvailHeight">Input value indicates how much of the height allocated
		/// to 'lay' for this page will remain available if the text containing these references
		/// is added to the page, assuming that adding them does not reduce the space available
		/// for 'lay'. The output value indicates how much is left after laying out these
		/// dependent objects.</param>
		/// -------------------------------------------------------------------------------------
		public virtual void AddDependentObjectsToPageRoot(IVwLayoutStream lay, IVwGraphics vg,
			int hPage, int cguid, Guid[] objectGuids, bool fAllowFail, out bool fFailed,
			ref int dysAvailHeight)
		{
			int dysAvailableHeight = dysAvailHeight;
			fFailed = false;

			int[] rgHvo = new int[cguid];
			int i = 0;
			foreach (Guid guid in objectGuids)
			{
				int hvo = m_configurer.GetIdFromGuid(guid);
				if (hvo != 0)
					rgHvo[i++] = hvo; // only add the ones we can match.
				else
					cguid--; // found unmatched guid
			}
			Page page = Publication.FindPage(hPage);
			if (page.DoingTrialLayout)
			{
				page.NoteDependentRoots(rgHvo);
				// note that we do not need to adjust dysAvailHeight, because in trial mode the
				// INITIAL height is set to the space available minus the old dependent root
				// objects view's height.
				return;
			}

			// Collect some information we need
			IVwLayoutStream dependentStream = page.DependentObjectsRootStream;
			IVwRootBox dependentRootbox = (IVwRootBox)dependentStream;
			int hvoRoot = m_configurer.DependentRootHvo;
			int dependentObjTag = m_configurer.DependentRootTag;
			int dependentObjFrag = m_configurer.DependentRootFrag;
			IDependentObjectsVc depObjVc;
			ISilDataAccess sda = m_configurer.DataAccess;
			int oldHeight = 0;
			int startIndex = -1;
			int endIndex = -1;
			int prevStartIndex;
			int prevEndIndex;
			if (dependentRootbox == null)
			{
				// no pre-existing rootbox for this page so create a new one
				depObjVc = m_configurer.DependentRootVc;
				dependentStream = VwLayoutStreamClass.Create();
				dependentStream.SetManager(this);
				page.DependentObjectsRootStream = dependentStream;
				dependentRootbox = (IVwRootBox)dependentStream;
				dependentRootbox.SetSite(Publication);
				dependentRootbox.DataAccess = sda;
				dependentRootbox.SetRootObject(hvoRoot, depObjVc, dependentObjFrag, m_configurer.StyleSheet);
				// Set up the view constructor to show the correct objects
				if (cguid > 0)
				{
					startIndex = sda.GetObjIndex(hvoRoot, dependentObjTag, rgHvo[0]);
					endIndex = sda.GetObjIndex(hvoRoot, dependentObjTag, rgHvo[cguid - 1]);
					Debug.Assert(startIndex >= 0 && endIndex >= 0);
				}
				depObjVc.StartingObjIndex = startIndex;
				depObjVc.EndingObjIndex = endIndex;
				prevStartIndex = prevEndIndex = -1;
			}
			else
			{
				// A rootbox was already created for this page, just update what is shown
				oldHeight = dependentRootbox.Height;
				IVwViewConstructor vc;
				IVwStylesheet ss;
				dependentRootbox.GetRootObject(out hvoRoot, out vc, out dependentObjFrag, out ss);
				depObjVc = (IDependentObjectsVc)vc;

				prevStartIndex = depObjVc.StartingObjIndex;
				prevEndIndex = depObjVc.EndingObjIndex;
				// Update the view constructor with the new objects
				if (cguid > 0)
				{
					startIndex = sda.GetObjIndex(hvoRoot, dependentObjTag, rgHvo[0]);
					endIndex = sda.GetObjIndex(hvoRoot, dependentObjTag, rgHvo[cguid - 1]);
					Debug.Assert(startIndex >= 0 && endIndex >= 0);
					Debug.Assert(startIndex > depObjVc.EndingObjIndex && endIndex > depObjVc.EndingObjIndex);

					if (depObjVc.StartingObjIndex == -1)
					{
						// Most likely all the shown objects were removed from the view constructor.
						// We need to make sure we have a valid starting index.
						depObjVc.StartingObjIndex = startIndex;
					}
					depObjVc.EndingObjIndex = endIndex;
				}
			}

			if (startIndex < 0 || endIndex < 0)
			{
				fFailed = fAllowFail;
				return;
			}

			// update the rootbox with the new items.
			try
			{
				// propChanged generates a PageBroken notification we need to ignore.
				m_hPageBeingBuilt = hPage;
				int count = endIndex - startIndex + 1;
				dependentRootbox.PropChanged(hvoRoot, dependentObjTag, startIndex, count, count);
			}
			finally
			{
				m_hPageBeingBuilt = 0;
			}

			PublicationControl.SetAccessibleStreamName(dependentStream,
				"Dependent stream for page " + page.PageNumber);

			// The actual laying out is probably redundant, but this lets the dependent stream
			// know what page it's on, which is useful for notifications. With an interface
			// change we could do this more efficiently, I think.
			for (int ihvo = startIndex; ihvo <= endIndex; ihvo++)
			{
				SelLevInfo[] rgSelLevInfo = new SelLevInfo[1];
				rgSelLevInfo[0].tag = dependentObjTag;
				rgSelLevInfo[0].ihvo = ihvo - depObjVc.StartingObjIndex;

				dependentStream.LayoutObj(vg, AvailablePageWidthInPrinterPixels, 0,
					rgSelLevInfo.Length, rgSelLevInfo, hPage);
			}
			int newHeight = dependentRootbox.Height;
			int dysHeightUsed = newHeight - oldHeight;

			// If this stream is just now being added to the page, need to allow for gap between elements.
			if (oldHeight == 0)
				dysHeightUsed += VerticalGapBetweenElements * vg.YUnitsPerInch / MiscUtils.kdzmpInch;

			if ((dysHeightUsed * m_numberMainStreamColumns) > dysAvailHeight)
			{
				// We can't add everything needed for the current chunk (in the main stream),
				// so we need to fail (if that's permitted), and roll everything back
				if (fAllowFail)
				{
					fFailed = true;
					// roll back: remove the extra objects.
					try
					{
						int newStartObjIndex = depObjVc.StartingObjIndex;
						int newEndObjIndex = depObjVc.EndingObjIndex;

						depObjVc.StartingObjIndex = prevStartIndex;
						depObjVc.EndingObjIndex = prevEndIndex;
						int count = endIndex - newStartObjIndex + 1;
						dependentRootbox.PropChanged(hvoRoot, dependentObjTag, newStartObjIndex, count, count);
					}
					finally
					{
						m_hPageBeingBuilt = 0;
					}
					return;
				}
				else
					dysAvailableHeight = 0;
			}
			else
			{
				// When we layout with multiple columns, we pretend to have one large
				// page. But the substreams are still only one column which means
				// they affect all columns, so we have to multiply the height used
				// with the number of columns.
				dysAvailableHeight -= (dysHeightUsed * m_numberMainStreamColumns);
			}

			// Now we know all the objects fit (or else we weren't allowed to fail), so
			// adjust the rectangle occupied by the element.

			// First time thru, the previous "element" is the bottom page margin.
			// So far we only have one, but the code here shows vestiges of the loop in the
			// main AddDependentObjects.
			int ysTopOfPrevElement = Publication.PageHeightInPrinterPixels - BottomMarginInPrinterPixels;
			if (newHeight > 0)
				AddOrAdjustPageElement(page, ysTopOfPrevElement, newHeight, dependentStream, 0);

			dysAvailHeight = dysAvailableHeight;
		}
		public void DrawingErrors(IVwGraphics _vg)
		{
			throw new NotImplementedException();
		}
		public void DrawRoot2(IVwGraphics _vg, Utils.Rect rcSrc, Utils.Rect rcDst, bool fDrawSel,
			int ysTop, int dysHeight)
		{
			throw new NotImplementedException();
		}
		public IRenderEngine get_Renderer(int ws, IVwGraphics _vg)
		{
			return m_engine;
		}
示例#49
0
		/// <summary>
		/// See C++ documentation
		/// </summary>
		public void DrawTheRootAt(IVwRootBox prootb, IntPtr hdc, Rect rcpDraw, uint bkclr,
			bool fDrawSel, IVwGraphics pvg, Rect rcSrc, Rect rcDst, int ysTop, int dysHeight)
		{
			IVwGraphicsWin32 qvg32 = VwGraphicsWin32Class.Create();
			using (Graphics screen = Graphics.FromHdc(hdc))
			{
				Rectangle rcp = rcpDraw;
				Rectangle rcFill = new Rect(0, 0, rcp.Width, rcp.Height);

				using (var memoryBuffer = new MemoryBuffer(rcp.Width, rcp.Height))
				{
					memoryBuffer.Graphics.FillRectangle(new SolidBrush(ColorUtil.ConvertBGRtoColor(bkclr)), rcFill);

					qvg32.Initialize(memoryBuffer.Graphics.GetHdc());
					qvg32.XUnitsPerInch = rcDst.right - rcDst.left;
					qvg32.YUnitsPerInch = rcDst.bottom - rcDst.top;

					try
					{
						prootb.DrawRoot2(qvg32, rcSrc, rcDst, fDrawSel, ysTop, dysHeight);
					}
					catch (Exception)
					{
						qvg32.ReleaseDC();
						throw;
					}

					screen.DrawImageUnscaled(memoryBuffer.Bitmap, rcp);

					qvg32.ReleaseDC();
				}
			}
		}
		public void OnTyping(IVwGraphics _vg, string input, VwShiftStatus shiftStatus,
			ref int _wsPending)
		{
			const string BackSpace = "\b";

			if (input == BackSpace)
			{
				if (this.Text.Length <= 0)
					return;

				m_dummySelection.Anchor -= 1;
				m_dummySelection.End -= 1;
				this.Text = this.Text.Substring(0, this.Text.Length - 1);
				return;
			}

			var ws = m_dummySimpleRootSite.WritingSystemFactory.UserWs;
			m_dummySelection.ReplaceWithTsString(TsStringHelper.MakeTSS(input, ws));
		}
示例#51
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Get a graphics object in an appropriate state for drawing and measuring in the view.
		/// The calling method should pass the IVwGraphics back to ReleaseGraphics() before
		/// it returns. In particular, problems will arise if OnPaint() gets called before the
		/// ReleaseGraphics() method.
		/// </summary>
		/// <param name="pRoot"></param>
		/// <param name="pvg"></param>
		/// <param name="rcSrcRoot"></param>
		/// <param name="rcDstRoot"></param>
		/// -----------------------------------------------------------------------------------
		void IVwRootSite.GetGraphics(IVwRootBox pRoot, out IVwGraphics pvg, out Rect rcSrcRoot,
			out Rect rcDstRoot)
		{
			pvg = m_vwPrintContext.Graphics;
			rcSrcRoot = m_rcSrc;
			rcDstRoot = m_rcDst;
		}
		public void DeleteRangeIfComplex(IVwGraphics _vg, out bool _fWasComplex)
		{
			_fWasComplex = false;
		}
		public IRenderEngine get_Renderer(IVwGraphics _vg)
		{
			throw new NotImplementedException();
		}
			protected override void CallOnTyping(IVwGraphics vg, string str, int cchBackspace, int cchDelForward, char chFirst, Rectangle rcSrcRoot, Rectangle rcDstRoot)
			{
				base.CallOnTyping(vg, str, cchBackspace, cchDelForward, chFirst, rcSrcRoot, rcDstRoot);
				Cache.EnableUndo = false;	// Things have changed in a way we can't Undo.
			}
		public IRenderEngine get_RendererFromChrp(IVwGraphics vg, ref LgCharRenderProps _chrp)
		{
			throw new NotImplementedException();
		}
示例#56
0
		/// <summary>
		/// Draw the selection on the VwGraphics.
		/// </summary>
		internal abstract void Draw(IVwGraphics vg, PaintTransform ptrans);
示例#57
0
		/// <summary>
		/// Implement dragging to this view.
		/// </summary>
		public void OnDragDrop(DragEventArgs drgevent, Point location, IVwGraphics vg, PaintTransform ptrans)
		{
			var sel = GetSelectionAt(location, vg, ptrans) as InsertionPoint;
			if (sel == null)
				return;
			var rtf = drgevent.Data.GetData(DataFormats.Rtf);
			var data = drgevent.Data.GetData(DataFormats.StringFormat);
			if (data == null)
				return;
			var text = data.ToString(); // MS example of GetData does this, though for DataFormats.Text.

			if (DragState == WindowDragState.InternalMove)
			{
				DragState = WindowDragState.None;
				// We are dragging our own selection. Is it in the same property?
				var range = (RangeSelection)Selection;
				// Enhance JohnT: when we can drag a range that isn't all in one property, this needs more work.
				if (!Selection.IsInsertionPoint)
				{
					if (Selection.Contains(sel))
					{
						Selection = sel;
						return; // Can't drag to inside own selection.
					}
				}
				if (range.End.Hookup == sel.Hookup && range.End.StringPosition < sel.StringPosition)
				{
					// Dragging to later in the same property. If we delete first, we will mess up the insert
					// position. However, a simple solution is to insert first.
					//Log("Inserted dropped " + text + " before deleted range");
					if (rtf == null)
						sel.InsertText(text);
					else if (!sel.InsertRtfString(rtf.ToString()))
						sel.InsertText(text);
					range.Delete();
					return;
				}
				// The bit we're moving comes after the place to insert, or they are in separate properties.
				// We can just go ahead and delete the source first, since we already have a copy of the
				// text to insert.
				// Enhance JohnT: do we need to consider a special case where the source and destination are
				// different occurrences of the same property?
				//Log("Deleted selection");
				range.Delete();
			}
			DragState = WindowDragState.None;

			//Log("Dropped text: " + text);
			if (rtf == null)
				sel.InsertText(text);
			else if (!sel.InsertRtfString(rtf.ToString()))
				sel.InsertText(text);
		}
示例#58
0
		/// <summary>
		/// Get the location, in the coordinates indicated by the transform, of a rectangle that contains the
		/// primary insertion point.
		/// Todo JohnT: there should be a parallel routine to get the location of the secondary rectangle.
		/// </summary>
		public abstract Rectangle GetSelectionLocation(IVwGraphics graphics, PaintTransform transform);
示例#59
0
		internal static LayoutInfo MakeLayoutInfo(int maxWidth, IVwGraphics vg)
		{
			return new LayoutInfo(2, 2, 96, 96, maxWidth, vg, new MockRendererFactory());
		}
示例#60
0
		/// <summary>
		/// The root box handles the overall paint.
		/// </summary>
		/// <param name="vg"></param>
		/// <param name="ptrans"></param>
		public void Paint(IVwGraphics vg, PaintTransform ptrans)
		{
			if (m_layoutCallbacks != null)
			{
				// In a state where we can't paint. Arrange for an invalidate AFTER the dangerous operation is over,
				// so what needs painting eventually does get painted.
				var bounds = Bounds;
				bounds.Inflate(10, 10);
				m_layoutCallbacks.Invalidate(bounds);
				return;
			}
			// First we paint the overall background. This basically covers everything but text.
			PaintBackground(vg, ptrans);
			// Then the text.
			PaintForeground(vg, ptrans);
			// And finally the selection.
			if (Selection != null && m_selectionShowing)
			{
				if (Selection.IsValid)
					Selection.Draw(vg, ptrans);
				else
					Selection = null;
			}
		}