Exemplo 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
Exemplo 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