Esempio n. 1
0
        }        //end Glyph(cNow,iGlyphType)

        public bool TypeOnOneLine(ref RImage riDest, int xDest, int yDest, string sText, int iGlyphType)
        {
            //TODO: really, this should return a rect (e.g. html-style stretching of container)
            bool bGood = true;
            bool bSpacing;
            int  xNow = xDest;

            try {
                int iCursor = 0;
                for (int iChar = 0; iChar < sText.Length; iChar++)
                {
                    RImage riNow = Glyph(sText[iChar], iGlyphType);
                    if (xNow + riNow.Width < riDest.Width)
                    {
                        if (!RString.IsWhiteSpace(sText[iChar]))
                        {
                            riDest.DrawFromSmallerWithoutCropElseCancel(xNow, yDest, riNow, RImage.DrawMode_AlphaHardEdgeColor_KeepDestAlpha);
                        }
                    }
                    else
                    {
                        break;
                    }
                    xNow += WidthOf(sText[iChar], iGlyphType);
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "", "TypeOnOneLine(...,\"" + RString.ElipsisIfOver(sText, 10) + "\")");
                bGood = false;
            }
            return(bGood);
        }        //end TypeOnOneLine
Esempio n. 2
0
        }        //end SaveSeq

        /// <summary>
        /// Renders a line or returns false.
        /// </summary>
        /// <param name="riDest"></param>
        /// <param name="xDest"></param>
        /// <param name="yDest"></param>
        /// <param name="sText"></param>
        /// <param name="iGlyphType"></param>
        /// <param name="iCursor"></param>
        /// <param name="bAllowLineBreaking"></param>
        /// <returns></returns>
        public bool RenderLine(ref RImage riDest, int xDest, int yDest, string sText, int iGlyphType, ref int iCursor, bool bAllowLineBreaking)
        {
            //TODO: really, this should also output a rect (e.g. html-style stretching of container)
            bool bMore = false;
            bool bSpacing;
            int  xNow = xDest;
            int  iWidthNow;

            try {
                if (iCursor < sText.Length)
                {
                    int iNewLine = RString.IsNewLineAndGetLength(sText, iCursor);
                    while (iNewLine == 0 && iCursor < sText.Length)
                    {
                        iWidthNow = WidthOf(sText[iCursor], iGlyphType);
                        if (xNow + iWidthNow < riDest.Width)
                        {
                            if (!RString.IsHorizontalSpacingChar(sText[iCursor]))
                            {
                                riDest.DrawFromSmallerWithoutCropElseCancel(xNow, yDest, Glyph(sText[iCursor], iGlyphType), RImage.DrawMode_AlphaHardEdgeColor_KeepDestAlpha);
                            }
                        }
                        else
                        {
                            if (bAllowLineBreaking)
                            {
                                break;
                            }
                        }
                        xNow += iWidthNow;
                        iCursor++;
                        iNewLine = RString.IsNewLineAndGetLength(sText, iCursor);
                    }
                    iCursor += iNewLine;
                    bMore    = iCursor < sText.Length;
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "", "RenderLine(...,\"" + RString.ElipsisIfOver(sText, 10) + "\")");
                bMore = false;
            }
            return(bMore);
        }                                                                                                     //end RenderLine
Esempio n. 3
0
        }                                                                                                     //end RenderLine

        public bool Render(ref RImage riDest, IRect rectDest, string sText, int iGlyphType, int LineBreaking) //formerly typefast
        //TODO: really, this should return a rect (e.g. html-style stretching of container)
        {
            bool bGood = true;
            //IPoint ipDestNow;
            //IPoint ipDestLine;
            bool bSpacing;

            try {
                //ipDestNow=new IPoint();
                //ipDestNow.X=rectDest.X;
                //ipDestNow.Y=rectDest.Y;
                //ipDestLine.Set(ipDestNow);
                int    zone_Bottom = rectDest.Bottom;
                string sLine;
                int    iCursor     = 0;
                int    yDest       = rectDest.Y;
                int    iLineHeight = GlyphHeight(iGlyphType);
                int    iLine       = 0;
                //RImage.rpaintFore.SetRgb(0,0,0);
                //riDest.DrawRectCropped(rectDest);
                //string sDebugReadLineFile="0.debug-Typing.txt";//debug only
                //bool bDebug=!File.Exists(sDebugReadLineFile);
                CalculateSpacing(iGlyphType);
                if (LineBreaking == LineBreakingOnlyWhenEndOfTextLine)
                {
                    while (RenderLine(ref riDest, rectDest.X, yDest, sText, iGlyphType, ref iCursor, false))
                    {
                        yDest += iLineHeight;
                        if (yDest + iLineHeight >= zone_Bottom)
                        {
                            break;                                                        //+iLineHeight skips croppable chars
                        }
                        iLine++;
                    }
                }
                else if (LineBreaking == LineBreakingFast)
                {
                    while (RenderLine(ref riDest, rectDest.X, yDest, sText, iGlyphType, ref iCursor, true))
                    {
                        yDest += iLineHeight;
                        if (yDest + iLineHeight >= zone_Bottom)
                        {
                            break;                                                        //+iLineHeight skips croppable chars
                        }
                        iLine++;
                    }
                }
                else                  //assume LineBreakingSlowAccurate
                {
                    while (ReadLine(out sLine, sText, ref iCursor, rectDest, iGlyphType))
                    {
                        if (yDest < zone_Bottom)
                        {
                            TypeOnOneLine(ref riDest, rectDest.X, yDest, sLine, iGlyphType);
                        }
                        else
                        {
                            break;
                        }
                        yDest += iLineHeight;                      //+iLineHeight skips croppable chars
                        iLine++;
                    }
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "", "Render(...,\"" + RString.ElipsisIfOver(sText, 10) + "\")");
                bGood = false;
            }
            return(bGood);
        }