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


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

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


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

示例1: WrapText

	void WrapText(Face* face, const rString& text, const rSize& size, std::function<void(Glyph**, size_t, int, int)> wordFunc){
		std::vector<Font::Glyph*> wordGlyphs;

		int xPos = 0;
		int yPos = face->GetAscender();

		int wordWidth = 0;
		int spaceLeft = size.x;

		int lineCount = 0;

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

			if (c == '\n'){
				if (wordWidth > spaceLeft){ //current word will not fit on this line
					yPos += face->GetLineHeight();
					xPos = 0;
				}

				wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
				wordGlyphs.clear();

				yPos += face->GetLineHeight();
				xPos = 0;
				spaceLeft = size.x;
				wordWidth = 0;

			}
			else{
				Font::Glyph* glyph = face->GetGlyph(c);

				if (c == ' '){
					if (wordWidth + glyph->advance > spaceLeft){ //current word will not fit on this line
						yPos += face->GetLineHeight();
						xPos = 0;
						spaceLeft = size.x;
					}

					wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
					wordGlyphs.clear();

					spaceLeft -= wordWidth + glyph->advance;
					xPos += wordWidth + glyph->advance;
					wordWidth = 0;

				}
				else{
					wordWidth += glyph->advance;
					wordGlyphs.push_back(glyph);
				}
			}
		}

		if (wordGlyphs.size() > 0){
			wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
			wordGlyphs.clear();
		}
	}
开发者ID:matthewcpp,项目名称:recondite,代码行数:59,代码来源:rFont.cpp

示例2: GetParseItemMethod

ruiOverlayLoader::ruiParseItemMethod ruiOverlayLoader::GetParseItemMethod (const rString& itemName){
	rString item = itemName;
	
	for (size_t i =0; i < itemName.size(); i++)
		item[i] = tolower(itemName[i]);

	if (s_parseItemMap.count(item))
		return s_parseItemMap[item];
	else
		return NULL;
}
开发者ID:aedotcom,项目名称:recondite,代码行数:11,代码来源:ruiOverlayLoader.cpp

示例3:

rString gfx::MaterialBank::GetDir(rString& filename)
{
	bool found = false;
	for (int i = static_cast<int>(filename.size()); i > 0; i--)
	{
		if (filename.c_str()[i] == '/' || filename.c_str()[i] == '\\' )
			found = true;
		if (!found)
		{
			filename.erase(i);
		}

	}
	return filename;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:15,代码来源:MaterialBank.cpp

示例4:

rString gfx::ShaderProgram::GetDir ( rString filename )
{
    bool found = false;
    for ( int i = static_cast<int> ( filename.size() ); i > 0; i-- )
    {
        if ( filename.c_str() [i] == '/' )
        {
            found = true;
        }
        if ( !found )
        {
            filename.erase ( i );
        }
    }
    return filename;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:16,代码来源:ShaderProgram.cpp

示例5:

rString gfx::TextureAtlas::GetDir ( rString str )
{
    bool found = false;
    for ( int i = static_cast<int> ( str.size() ); i > 0; i-- )
    {
        if ( str.c_str() [i] == '/' )
        {
            found = true;
        }
        if ( !found )
        {
            str.erase ( i );
        }

    }
    return str;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:17,代码来源:TextureAtlas.cpp


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