本文整理汇总了C++中gwen::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: onSelect
void onSelect( Gwen::Controls::Base* pControl )
{
Gwen::Controls::ComboBox* but = (Gwen::Controls::ComboBox*) pControl;
Gwen::String str = Gwen::Utility::UnicodeToString( but->GetSelectedItem()->GetText());
if (m_callback)
(*m_callback)(m_buttonId,str.c_str(),m_userPointer);
}
开发者ID:Ochakko,项目名称:MameBake3D,代码行数:9,代码来源:GwenParameterInterface.cpp
示例2: onButtonC
void onButtonC(Gwen::Controls::Base* pControl)
{
Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl;
Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText();
Gwen::String laa = Gwen::Utility::UnicodeToString(la);
const char* ha = laa.c_str();
// printf("onButtonC ! %s\n", ha);
}
开发者ID:NateWardawg,项目名称:bullet3,代码行数:10,代码来源:main.cpp
示例3: LoadTexture
virtual void LoadTexture(Gwen::Texture* pTexture)
{
Gwen::String namestr = pTexture->name.Get();
const char* n = namestr.c_str();
GLint* texIdPtr = m_hashMap[n];
if (texIdPtr)
{
pTexture->m_intData = *texIdPtr;
}
}
开发者ID:Ochakko,项目名称:MameBake3D,代码行数:10,代码来源:OpenGLExampleBrowser.cpp
示例4: onButtonB
void onButtonB(Gwen::Controls::Base* pControl)
{
Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl;
Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText();
Gwen::String laa = Gwen::Utility::UnicodeToString(la);
const char* ha = laa.c_str();
selectDemo(sCurrentHightlighted);
saveCurrentDemoEntry(sCurrentDemoIndex, startFileName);
}
开发者ID:NateWardawg,项目名称:bullet3,代码行数:11,代码来源:main.cpp
示例5: GetColorFromName
Gwen::String ColorPicker::GetColorFromName( Gwen::String name )
{
if ( name.find("Red") != Gwen::String::npos )
return "Red";
if ( name.find("Green") != Gwen::String::npos )
return "Green";
if ( name.find("Blue") != Gwen::String::npos )
return "Blue";
if ( name.find("Alpha") != Gwen::String::npos )
return "Alpha";
else
return "";
}
开发者ID:dabroz,项目名称:gwen-mirror,代码行数:13,代码来源:ColorPicker.cpp
示例6: onButtonA
void onButtonA(Gwen::Controls::Base* pControl)
{
const Gwen::String& name = pControl->GetName();
Gwen::Controls::TreeNode* node = (Gwen::Controls::TreeNode*)pControl;
Gwen::Controls::Label* l = node->GetButton();
Gwen::UnicodeString la = node->GetButton()->GetText();// node->GetButton()->GetName();// GetText();
Gwen::String laa = Gwen::Utility::UnicodeToString(la);
const char* ha = laa.c_str();
//printf("selected %s\n", ha);
//int dep = but->IsDepressed();
//int tog = but->GetToggleState();
// if (m_data->m_toggleButtonCallback)
// (*m_data->m_toggleButtonCallback)(m_buttonId, tog);
}
开发者ID:NateWardawg,项目名称:bullet3,代码行数:16,代码来源:main.cpp
示例7: GetColorFromName
gwen::String ColorPicker::GetColorFromName( gwen::String name )
{
if ( name.find( "Red" ) != gwen::String::npos )
{ return "Red"; }
if ( name.find( "Green" ) != gwen::String::npos )
{ return "Green"; }
if ( name.find( "Blue" ) != gwen::String::npos )
{ return "Blue"; }
if ( name.find( "Alpha" ) != gwen::String::npos )
{ return "Alpha"; }
else
{ return ""; }
}
开发者ID:MegaThorx,项目名称:GWEN,代码行数:16,代码来源:ColorPicker.cpp
示例8: MeasureText
Gwen::Point Base::MeasureText( Gwen::Font* pFont, const Gwen::String& text )
{
Gwen::Point p;
p.x = pFont->size * Scale() * (float)text.length() * 0.4;
p.y = pFont->size * Scale();
return p;
}
开发者ID:gered,项目名称:MyGameFramework,代码行数:8,代码来源:gwen_baserender.cpp
示例9:
bool Gwen::Utility::Strings::To::Bool( const Gwen::String& str )
{
if ( str.size() == 0 ) return false;
if ( str[0] == 'T' || str[0] == 't' || str[0] == 'y' || str[0] == 'Y' ) return true;
if ( str[0] == 'F' || str[0] == 'f' || str[0] == 'n' || str[0] == 'N' ) return false;
if ( str[0] == '0' ) return false;
return true;
}
开发者ID:charliesome,项目名称:battlecars,代码行数:8,代码来源:Utility.cpp
示例10: SplitWords
void SplitWords(const Gwen::String &s, char delim, stl::vector<Gwen::String> &elems)
{
Gwen::String str;
for ( unsigned int i=0; i<s.length(); i++ )
{
if ( s[i] == '\n' )
{
if ( !str.empty() ) elems.push_back( str );
elems.push_back( "\n" );
str.clear();
continue;
}
if ( s[i] == ' ' )
{
str += s[i];
elems.push_back( str );
str.clear();
continue;
}
str += s[i];
}
if ( !str.empty() ) elems.push_back( str );
}
开发者ID:gered,项目名称:MyGameFramework,代码行数:27,代码来源:gwen_text.cpp
示例11: Translate
void SDL2Renderer::RenderText(Gwen::Font* pFont, Gwen::Point pos, const Gwen::String& text)
{
TTF_Font *tfont = static_cast<TTF_Font*>(pFont->data);
Translate(pos.x, pos.y);
SDL_Surface *surf = TTF_RenderUTF8_Blended(tfont, text.c_str(), m_color);
SDL_Texture *texture = SDL_CreateTextureFromSurface(m_renderer, surf);
SDL_FreeSurface(surf);
int w, h;
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
const SDL_Rect dest = { pos.x,pos.y, w,h };
SDL_RenderCopy(m_renderer, texture, NULL, &dest);
SDL_DestroyTexture(texture);
}
开发者ID:Catchouli-old,项目名称:ca2d,代码行数:17,代码来源:SDL2Renderer.cpp
示例12: RenderText
void Base::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::String& text )
{
float fSize = pFont->size * Scale();
for ( float i=0; i<text.length(); i++ )
{
char chr = text[i];
if ( chr == ' ' ) continue;
Gwen::Rect r( pos.x + i * fSize * 0.4, pos.y, fSize * 0.4 -1, fSize );
/*
This isn't important, it's just me messing around changing the
shape of the rect based on the letter.. just for fun.
*/
if ( chr == 'l' || chr == 'i' || chr == '!' || chr == 't' )
{
r.w = 1;
}
else if ( chr >= 'a' && chr <= 'z' )
{
r.y += fSize * 0.5f;
r.h -= fSize * 0.4f;
}
else if ( chr == '.' || chr == ',' )
{
r.x += 2;
r.y += r.h - 2;
r.w = 2;
r.h = 2;
}
else if ( chr == '\'' || chr == '`' || chr == '"' )
{
r.x += 3;
r.w = 2;
r.h = 2;
}
if ( chr == 'o' || chr == 'O' || chr == '0' )
DrawLinedRect( r );
else
DrawFilledRect( r );
}
}
开发者ID:gered,项目名称:MyGameFramework,代码行数:46,代码来源:gwen_baserender.cpp
示例13: Point
Gwen::Point SDL2Renderer::MeasureText(Gwen::Font* pFont, const Gwen::String& text)
{
TTF_Font *tfont = static_cast<TTF_Font*>(pFont->data);
// If the font doesn't exist, or the font size should be changed.
if (!tfont || pFont->realsize != pFont->size*Scale())
{
FreeFont(pFont);
LoadFont(pFont);
tfont = static_cast<TTF_Font*>(pFont->data);
}
if (!tfont)
return Gwen::Point(0, 0);
int w,h;
TTF_SizeUTF8(tfont, text.c_str(), &w,&h);
return Point(w,h);
}
开发者ID:Catchouli-old,项目名称:ca2d,代码行数:20,代码来源:SDL2Renderer.cpp
示例14: InsertText
void TextBox::InsertText( const Gwen::String& strInsert )
{
// TODO: Make sure fits (implement maxlength)
if ( HasSelection() )
{
EraseSelection();
}
if ( m_iCursorPos > TextLength() ) m_iCursorPos = TextLength();
if ( !IsTextAllowed( strInsert, m_iCursorPos ) )
return;
String str = GetText().Get();
str.insert( m_iCursorPos, strInsert );
SetText( str );
m_iCursorPos += (int) strInsert.size();
m_iCursorEnd = m_iCursorPos;
m_iCursorLine = 0;
RefreshCursorBounds();
}
开发者ID:fpoussin,项目名称:ChibiOS-Gwen,代码行数:24,代码来源:TextBox.cpp
示例15: atoi
int Gwen::Utility::Strings::To::Int( const Gwen::String& str )
{
if ( str == "" ) return 0;
return atoi( str.c_str() );
}
开发者ID:charliesome,项目名称:battlecars,代码行数:5,代码来源:Utility.cpp
示例16: RefreshSizeWrap
void Text::RefreshSizeWrap()
{
RemoveAllChildren();
m_Lines.clear();
stl::vector<Gwen::String> words;
SplitWords( GetText().Get(), ' ', words );
// Adding a bullshit word to the end simplifies the code below
// which is anything but simple.
words.push_back( "" );
if ( !GetFont() )
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
return;
}
Point pFontSize = GetSkin()->GetRender()->MeasureText( GetFont(), " " );
int w = GetParent()->Width();
int x = 0, y = 0;
Gwen::String strLine;
stl::vector<Gwen::String>::iterator it = words.begin();
for (; it != words.end(); ++it )
{
bool bFinishLine = false;
//bool bWrapped = false;
// If this word is a newline - make a newline (we still add it to the text)
if ( (*it).c_str()[0] == '\n' ) bFinishLine = true;
// Does adding this word drive us over the width?
{
strLine += (*it);
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), strLine );
if ( p.x > Width() ) {
bFinishLine = true; /*bWrapped = true;*/
}
}
// If this is the last word then finish the line
// if ( --words.end() == it )
// NOTE: replaced above commented out 'if' statement with this to appease
// the GCC compiler that comes with Marmalade SDK 6.0
stl::vector<Gwen::String>::iterator temp = words.end() - 1;
if ( temp == it )
{
bFinishLine = true;
}
if ( bFinishLine )
{
Text* t = new Text( this );
t->SetFont( GetFont() );
t->SetString( strLine.substr( 0, strLine.length() - (*it).length() ) );
t->RefreshSize();
t->SetPos( x, y );
m_Lines.push_back( t );
// newline should start with the word that was too big
strLine = *it;
// Position the newline
y += pFontSize.y;
x = 0;
//if ( strLine[0] == ' ' ) x -= pFontSize.x;
}
}
// Size to children height and parent width
{
Point childsize = ChildrenSize();
SetSize( w, childsize.y );
}
InvalidateParent();
Invalidate();
}
开发者ID:gered,项目名称:MyGameFramework,代码行数:83,代码来源:gwen_text.cpp
注:本文中的gwen::String类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论