예제 #1
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