当前位置: 首页>>代码示例>>C++>>正文


C++ stringw::size方法代码示例

本文整理汇总了C++中core::stringw::size方法的典型用法代码示例。如果您正苦于以下问题:C++ stringw::size方法的具体用法?C++ stringw::size怎么用?C++ stringw::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core::stringw的用法示例。


在下文中一共展示了stringw::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processInput

void RecoveryDialog::processInput()
{
    const core::stringw username = m_username_widget->getText().trim();
    const core::stringw email = m_email_widget->getText().trim();
    if (username.size() < 4 || username.size() > 30 ||
        email.size() < 4    || email.size() > 50       )
    {
        SFXManager::get()->quickSound("anvil");
        m_info_widget->setErrorColor();
        m_info_widget->setText(_("Username and/or email address invalid."),
                               false);
    }
    else
    {
        m_info_widget->setDefaultColor();
        m_options_widget->setActive(false);

        m_recovery_request = new XMLRequest();

        // This function also works when the current user is not logged in
        PlayerManager::setUserDetails(m_recovery_request, "recover");
        m_recovery_request->addParameter("username", username);
        m_recovery_request->addParameter("email",    email   );
        m_recovery_request->queue();
    }
}   // processInput
开发者ID:Flakebi,项目名称:stk-code,代码行数:26,代码来源:recovery_dialog.cpp

示例2: doesRowStartWith

bool GUITable::doesRowStartWith(const Row *row, const core::stringw &str) const
{
	if (row == NULL)
		return false;

	for (s32 j = 0; j < row->cellcount; ++j) {
		Cell *cell = &row->cells[j];
		if (cell->content_type == COLUMN_TYPE_TEXT) {
			const core::stringw &cellstr = m_strings[cell->content_index];
			if (cellstr.size() >= str.size() &&
					str.equals_ignore_case(cellstr.subString(0, str.size())))
				return true;
		}
	}
	return false;
}
开发者ID:Bremaweb,项目名称:minetest,代码行数:16,代码来源:guiTable.cpp

示例3: Hud

Text::Text(const core::stringw& str, f32 x, f32 y, FontStyle style, u8 speed) : Hud()
{
  textStr = str;
  currentSize = 24;
  currentSpeed = speed;
  font = new TextFont(style);
  currentCharPos = pos = core::dimension2df(x, y);
  currentDisplayChar = 0;
  updateTiles();

  speedTimer = NULL;
  if (currentSpeed > 0) {
    speedTimer = new Timer(0.01f, boost::bind(&Text::nextChar, this), str.size());
  }
}
开发者ID:jsj2008,项目名称:Invisible-Spirit,代码行数:15,代码来源:Text.cpp

示例4: processInput

void RecoveryDialog::processInput()
{
    const core::stringw username = m_username_widget->getText().trim();
    const core::stringw email = m_email_widget->getText().trim();
    if (username.size() < 4 || username.size() > 30 || 
        email.size() < 4    || email.size() > 50       )
    {
        sfx_manager->quickSound("anvil");
        m_info_widget->setErrorColor();
        m_info_widget->setText(_("Username and/or email address invalid."),
                               false);
    }
    else
    {
        m_info_widget->setDefaultColor();
        m_options_widget->setDeactivated();
        m_recovery_request = new XMLRequest();
        m_recovery_request->setServerURL("client-user.php");
        m_recovery_request->addParameter("action", "recovery");
        m_recovery_request->addParameter("username", username);
        m_recovery_request->addParameter("email", email);
        m_recovery_request->queue();
    }
}   // processInput
开发者ID:Podmuch,项目名称:stk-code,代码行数:24,代码来源:recovery_dialog.cpp

示例5: draw

//! draws some text and clips it to the specified rectangle if wanted
void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position,
                    video::SColor color,
                    bool hcenter, bool vcenter, const core::rect<s32>* clip
                   )
{
    if (!Driver)
        return;

    core::dimension2d<s32> textDimension;	// NOTE: don't make this u32 or the >> later on can fail when the dimension width is < position width
    core::position2d<s32> offset = position.UpperLeftCorner;

    if (hcenter || vcenter || clip)
        textDimension = getDimension(text.c_str());

    if (hcenter)
        offset.X += (position.getWidth() - textDimension.Width) >> 1;

    if (vcenter)
        offset.Y += (position.getHeight() - textDimension.Height) >> 1;

    if (clip)
    {
        core::rect<s32> clippedRect(offset, textDimension);
        clippedRect.clipAgainst(*clip);
        if (!clippedRect.isValid())
            return;
    }

    core::array<u32> indices(text.size());
    core::array<core::position2di> offsets(text.size());

    for(u32 i = 0; i < text.size(); i++)
    {
        wchar_t c = text[i];

        bool lineBreak=false;
        if ( c == L'\r') // Mac or Windows breaks
        {
            lineBreak = true;
            if ( text[i + 1] == L'\n') // Windows breaks
                c = text[++i];
        }
        else if ( c == L'\n') // Unix breaks
        {
            lineBreak = true;
        }

        if (lineBreak)
        {
            offset.Y += MaxHeight;
            offset.X = position.UpperLeftCorner.X;

            if ( hcenter )
            {
                offset.X += (position.getWidth() - textDimension.Width) >> 1;
            }
            continue;
        }

        SFontArea& area = Areas[getAreaFromCharacter(c)];

        offset.X += area.underhang;
        if ( Invisible.findFirst ( c ) < 0 )
        {
            indices.push_back(area.spriteno);
            offsets.push_back(offset);
        }

        offset.X += area.width + area.overhang + GlobalKerningWidth;
    }

    SpriteBank->draw2DSpriteBatch(indices, offsets, clip, color);
}
开发者ID:teddBroiler,项目名称:irrlicht-android,代码行数:74,代码来源:CGUIFont.cpp

示例6: render

// ----------------------------------------------------------------------------
void FontWithFace::render(const core::stringw& text,
                          const core::rect<s32>& position,
                          const video::SColor& color, bool hcenter,
                          bool vcenter, const core::rect<s32>* clip,
                          FontSettings* font_settings,
                          FontCharCollector* char_collector)
{
    const bool is_bold_face = dynamic_cast<BoldFace*>(this);
    const bool black_border = font_settings ?
        font_settings->useBlackBorder() : false;
    const bool rtl = font_settings ? font_settings->isRTL() : false;
    const float scale = font_settings ? font_settings->getScale() : 1.0f;
    const float shadow = font_settings ? font_settings->useShadow() : false;

    if (shadow)
    {
        assert(font_settings);
        // Avoid infinite recursion
        font_settings->setShadow(false);

        core::rect<s32> shadowpos = position;
        shadowpos.LowerRightCorner.X += 2;
        shadowpos.LowerRightCorner.Y += 2;
        render(text, shadowpos, font_settings->getShadowColor(), hcenter,
            vcenter, clip, font_settings);

        // Set back
        font_settings->setShadow(true);
    }

    core::position2d<float> offset(float(position.UpperLeftCorner.X),
        float(position.UpperLeftCorner.Y));
    core::dimension2d<s32> text_dimension;

    if (rtl || hcenter || vcenter || clip)
    {
        text_dimension = getDimension(text.c_str(), font_settings);

        if (hcenter)
            offset.X += (position.getWidth() - text_dimension.Width) / 2;
        else if (rtl)
            offset.X += (position.getWidth() - text_dimension.Width);

        if (vcenter)
            offset.Y += (position.getHeight() - text_dimension.Height) / 2;
        if (clip)
        {
            core::rect<s32> clippedRect(core::position2d<s32>
                (s32(offset.X), s32(offset.Y)), text_dimension);
            clippedRect.clipAgainst(*clip);
            if (!clippedRect.isValid()) return;
        }
    }

    // Collect character locations
    const unsigned int text_size = text.size();
    core::array<s32> indices(text_size);
    core::array<core::position2d<float>> offsets(text_size);
    std::vector<bool> fallback(text_size);

    // Test again if lazy load char is needed,
    // as some text isn't drawn with getDimension
    insertCharacters(text.c_str());
    updateCharactersList();

    for (u32 i = 0; i < text_size; i++)
    {
        wchar_t c = text[i];

        if (c == L'\r' ||          // Windows breaks
            c == L'\n'    )        // Unix breaks
        {
            if (c==L'\r' && text[i+1]==L'\n')
                c = text[++i];
            offset.Y += m_font_max_height * scale;
            offset.X  = position.UpperLeftCorner.X;
            if (hcenter)
                offset.X += (position.getWidth() - text_dimension.Width) >> 1;
            continue;
        }   // if lineBreak

        bool use_fallback_font = false;
        const FontArea &area   = getAreaFromCharacter(c, &use_fallback_font);
        fallback[i]            = use_fallback_font;
        if (char_collector == NULL)
        {
            float glyph_offset_x = area.bearing_x *
                (fallback[i] ? m_fallback_font_scale : scale);
            float glyph_offset_y = area.offset_y *
                (fallback[i] ? m_fallback_font_scale : scale);
            offset.X += glyph_offset_x;
            offset.Y += glyph_offset_y;
            offsets.push_back(offset);
            offset.X -= glyph_offset_x;
            offset.Y -= glyph_offset_y;
        }
        else
        {
            // Prevent overwriting texture used by billboard text when
//.........这里部分代码省略.........
开发者ID:robclark,项目名称:stk-code,代码行数:101,代码来源:font_with_face.cpp

示例7: doDraw

//! draws some text and clips it to the specified rectangle if wanted
void ScalableFont::doDraw(const core::stringw& text,
                          const core::rect<s32>& position, video::SColor color,
                          bool hcenter, bool vcenter,
                          const core::rect<s32>* clip,
                          FontCharCollector* charCollector)
{
    if (!Driver) return;

    if (m_shadow)
    {
        m_shadow = false; // avoid infinite recursion

        core::rect<s32> shadowpos = position;
        shadowpos.LowerRightCorner.X += 2;
        shadowpos.LowerRightCorner.Y += 2;

        draw(text, shadowpos, m_shadow_color, hcenter, vcenter, clip);

        m_shadow = true; // set back
    }

    core::position2d<s32> offset = position.UpperLeftCorner;
    core::dimension2d<s32> text_dimension;

    if (m_rtl || hcenter || vcenter || clip)
    {
        text_dimension = getDimension(text.c_str());

        if (hcenter)    offset.X += (position.getWidth() - text_dimension.Width) / 2;
        else if (m_rtl) offset.X += (position.getWidth() - text_dimension.Width);

        if (vcenter)    offset.Y += (position.getHeight() - text_dimension.Height) / 2;
        if (clip)
        {
            core::rect<s32> clippedRect(offset, text_dimension);
            clippedRect.clipAgainst(*clip);
            if (!clippedRect.isValid()) return;
        }
    }

    // ---- collect character locations
    const unsigned int text_size = text.size();
    core::array<s32>               indices(text_size);
    core::array<core::position2di> offsets(text_size);
    std::vector<bool>              fallback(text_size);

    for (u32 i = 0; i<text_size; i++)
    {
        wchar_t c = text[i];

        if (c == L'\r' ||          // Windows breaks
            c == L'\n'    )        // Unix breaks
        {
            if(c==L'\r' && text[i+1]==L'\n') c = text[++i];
            offset.Y += (int)(MaxHeight*m_scale);
            offset.X  = position.UpperLeftCorner.X;
            if (hcenter)
                offset.X += (position.getWidth() - text_dimension.Width) >> 1;
            continue;
        }   // if lineBreak

        bool use_fallback_font = false;
        const SFontArea &area  = getAreaFromCharacter(c, &use_fallback_font);
        fallback[i]            = use_fallback_font;
        offset.X              += area.underhang;
        offsets.push_back(offset);
        // Invisible character. add something to the array anyway so that
        // indices from the various arrays remain in sync
        indices.push_back( Invisible.findFirst(c) < 0  ? area.spriteno
                                                       : -1            );
        offset.X += getCharWidth(area, fallback[i]);
    }   // for i<text_size

    // ---- do the actual rendering
    const int indiceAmount                    = indices.size();
    core::array< SGUISprite >& sprites        = SpriteBank->getSprites();
    core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
    core::array< SGUISprite >* fallback_sprites;
    core::array< core::rect<s32> >* fallback_positions;
    if(m_fallback_font!=NULL)
    {
        fallback_sprites   = &m_fallback_font->SpriteBank->getSprites();
        fallback_positions = &m_fallback_font->SpriteBank->getPositions();
    }
    else
    {
        fallback_sprites   = NULL;
        fallback_positions = NULL;
    }

    const int spriteAmount      = sprites.size();
    for (int n=0; n<indiceAmount; n++)
    {
        const int spriteID = indices[n];
        if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount)) continue;
        if (indices[n] == -1) continue;

        //assert(sprites[spriteID].Frames.size() > 0);

//.........这里部分代码省略.........
开发者ID:Charence,项目名称:stk-code,代码行数:101,代码来源:scalable_font.cpp

示例8: doDraw

void ScalableFont::doDraw(const core::stringw& text,
                          const core::rect<s32>& position, video::SColor color,
                          bool hcenter, bool vcenter,
                          const core::rect<s32>* clip,
                          FontCharCollector* charCollector)
{
    if (!m_video_driver) return;

    GUIEngine::GlyphPageCreator* gp_creator = GUIEngine::getGlyphPageCreator();

    if (m_shadow)
    {
        m_shadow = false; // avoid infinite recursion

        core::rect<s32> shadowpos = position;
        shadowpos.LowerRightCorner.X += 2;
        shadowpos.LowerRightCorner.Y += 2;

        draw(text, shadowpos, m_shadow_color, hcenter, vcenter, clip);

        m_shadow = true; // set back
    }

    core::position2d<s32> offset = position.UpperLeftCorner;
    core::dimension2d<s32> text_dimension;

    if (m_rtl || hcenter || vcenter || clip)
    {
        text_dimension = getDimension(text.c_str());

        if (hcenter)    offset.X += (position.getWidth() - text_dimension.Width) / 2;
        else if (m_rtl) offset.X += (position.getWidth() - text_dimension.Width);

        if (vcenter)    offset.Y += (position.getHeight() - text_dimension.Height) / 2;
        if (clip)
        {
            core::rect<s32> clippedRect(offset, text_dimension);
            clippedRect.clipAgainst(*clip);
            if (!clippedRect.isValid()) return;
        }
    }

    // ---- collect character locations
    const unsigned int text_size = text.size();
    core::array<s32>               indices(text_size);
    core::array<core::position2di> offsets(text_size);
    std::vector<bool>              fallback(text_size);

    if (m_type == T_NORMAL || T_BOLD) //lazy load char, have to do this again
    {                                 //because some text isn't drawn with getDimension
        for (u32 i = 0; i < text_size; i++)
        {
            wchar_t c = text[i];
            if (c == L'\r' ||  c == L'\n' || c == L' ' || c < 32) continue;
            if (!GUIEngine::getFont()->hasThisChar(c))
                gp_creator->insertChar(c);

            if (charCollector != NULL && m_type == T_NORMAL && m_spritebank->getSprites()
                [GUIEngine::getFont()->getSpriteNoFromChar(&c)].Frames[0].textureNumber
                == m_spritebank->getTextureCount() - 1) //Prevent overwriting texture used by billboard text
            {
                 Log::debug("ScalableFont::doDraw",
                            "Character used by billboard text is in the last "
                            "glyph page of normal font. Create a new glyph "
                            "page for new characters inserted later to prevent "
                            "it from being removed.");
                 GUIEngine::getFont()->forceNewPage();
            }
        }

        if (gp_creator->getNewChar().size() > 0 && !m_is_hollow_copy && m_scale == 1)
        {
            Log::debug("ScalableFont::doDraw",
                       "New character(s) %s discoverd, perform lazy loading",
                       StringUtils::wideToUtf8(gp_creator->getNewChar()).c_str());

            if (!GUIEngine::getFont()->lazyLoadChar())
                Log::error("ScalableFont::lazyLoadChar",
                           "Can't insert new char into glyph pages.");
        }
    }

    for (u32 i = 0; i < text_size; i++)
    {
        wchar_t c = text[i];

        if (c == L'\r' ||          // Windows breaks
            c == L'\n'    )        // Unix breaks
        {
            if(c==L'\r' && text[i+1]==L'\n') c = text[++i];
            offset.Y += (int)(m_max_height*m_scale);
            offset.X  = position.UpperLeftCorner.X;
            if (hcenter)
                offset.X += (position.getWidth() - text_dimension.Width) >> 1;
            continue;
        }   // if lineBreak

        bool use_fallback_font = false;
        const SFontArea &area  = getAreaFromCharacter(c, &use_fallback_font);
        fallback[i]            = use_fallback_font;
//.........这里部分代码省略.........
开发者ID:Cav098,项目名称:stk-code-fix_1797,代码行数:101,代码来源:scalable_font.cpp


注:本文中的core::stringw::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。