コード例 #1
0
//----------------------------------------------------------------------------//
void BasicRenderedStringParser::appendRenderedText(RenderedString& rs,
                                                   const String& text) const
{
    size_t cpos = 0;
    // split the given string into lines based upon the newline character
    while (text.length() > cpos)
    {
        // find next newline
        const size_t nlpos = text.find('\n', cpos);
        // calculate length of this substring
        const size_t len =
            ((nlpos != String::npos) ? nlpos : text.length()) - cpos;

        // construct new text component and append it.
        RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName);
        rtc.setPadding(d_padding);
        rtc.setColours(d_colours);
        rtc.setVerticalFormatting(d_vertAlignment);
        rtc.setAspectLock(d_aspectLock);
        rs.appendComponent(rtc);

        // break line if needed
        if (nlpos != String::npos)
            rs.appendLineBreak();

        // advance current position.  +1 to skip the \n char
        cpos += len + 1;
    }
}
コード例 #2
0
//----------------------------------------------------------------------------//
void BasicRenderedStringParser::handleWindow(RenderedString& rs, const String& value)
{
    RenderedStringWidgetComponent rwc(value);
    rwc.setPadding(d_padding);
    rwc.setVerticalFormatting(d_vertAlignment);
    rwc.setAspectLock(d_aspectLock);
    rs.appendComponent(rwc);
}
コード例 #3
0
//----------------------------------------------------------------------------//
void BasicRenderedStringParser::handleImage(RenderedString& rs, const String& value)
{
    RenderedStringImageComponent ric(
        PropertyHelper<Image*>::fromString(value));
    ric.setPadding(d_padding);
    ric.setColours(d_colours);
    ric.setVerticalFormatting(d_vertAlignment);
    ric.setSize(d_imageSize);
    ric.setAspectLock(d_aspectLock);
    rs.appendComponent(ric);
}
コード例 #4
0
//----------------------------------------------------------------------------//
void appendSubstring(RenderedString& rs,
                     const String& string,
                     const Font* initial_font,
                     const ColourRect* initial_colours)
{
    RenderedStringTextComponent rstc(string, initial_font);

    if (initial_colours)
        rstc.setColours(*initial_colours);

    rs.appendComponent(rstc);
}
コード例 #5
0
//----------------------------------------------------------------------------//
RenderedString DefaultRenderedStringParser::parse(
                                        const String& input_string,
                                        Font* initial_font,
                                        const ColourRect* initial_colours)
{
    RenderedString rs;
    RenderedStringTextComponent rstc(input_string, initial_font);

    if (initial_colours)
        rstc.setColours(*initial_colours);

    rs.appendComponent(rstc);
    return rs;
}