本文整理汇总了C++中gwen::UnicodeString类的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString类的具体用法?C++ UnicodeString怎么用?C++ UnicodeString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnicodeString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Point
Gwen::Point DirectX9::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString & text )
{
// If the font doesn't exist, or the font size should be changed
if ( !pFont->data || fabs( pFont->realsize - pFont->size * Scale() ) > 2 )
{
FreeFont( pFont );
LoadFont( pFont );
}
FontData* pFontData = ( FontData* ) pFont->data;
Gwen::Point size;
if ( text.empty() )
{
RECT rct = {0, 0, 0, 0};
pFontData->pFont->DrawTextW( NULL, L"W", -1, &rct, DT_CALCRECT, 0 );
return Gwen::Point( 0, rct.bottom );
}
RECT rct = {0, 0, 0, 0};
pFontData->pFont->DrawTextW( NULL, text.c_str(), -1, &rct, DT_CALCRECT | DT_LEFT | DT_TOP | DT_SINGLELINE, 0 );
for ( int i = text.length() - 1; i >= 0 && text[i] == L' '; i-- )
{
rct.right += pFontData->iSpaceWidth;
}
return Gwen::Point( rct.right / Scale(), rct.bottom / Scale() );
}
开发者ID:garrynewman,项目名称:GWEN,代码行数:29,代码来源:DirectX9.cpp
示例2: IsTextAllowed
bool TextBoxNumeric::IsTextAllowed( const Gwen::UnicodeString & str, int iPos )
{
const UnicodeString & strString = GetText().GetUnicode();
if ( str.length() == 0 )
{ return true; }
for ( size_t i = 0; i < str.length(); i++ )
{
if ( str[i] == L'-' )
{
// Has to be at the start
if ( i != 0 || iPos != 0 )
{ return false; }
// Can only be one
if ( std::count( strString.begin(), strString.end(), L'-' ) > 0 )
{ return false; }
continue;
}
if ( str[i] == L'0' ) { continue; }
if ( str[i] == L'1' ) { continue; }
if ( str[i] == L'2' ) { continue; }
if ( str[i] == L'3' ) { continue; }
if ( str[i] == L'4' ) { continue; }
if ( str[i] == L'5' ) { continue; }
if ( str[i] == L'6' ) { continue; }
if ( str[i] == L'7' ) { continue; }
if ( str[i] == L'8' ) { continue; }
if ( str[i] == L'9' ) { continue; }
if ( str[i] == L'.' )
{
// Already a fullstop
if ( std::count( strString.begin(), strString.end(), L'.' ) > 0 )
{ return false; }
continue;
}
return false;
}
return true;
}
开发者ID:darkf,项目名称:gwen,代码行数:56,代码来源:TextBoxNumeric.cpp
示例3: name
float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
{
profileIterator->First();
if (profileIterator->Is_Done())
return 0.f;
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
int i;
int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
//printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
float totalTime = 0.f;
int numChildren = 0;
Gwen::UnicodeString txt;
std::vector<Gwen::Controls::TreeNode*> nodes;
for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next())
{
numChildren++;
float current_total_time = profileIterator->Get_Current_Total_Time();
accumulated_time += current_total_time;
double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
Gwen::String name(profileIterator->Get_Current_Name());
Gwen::UnicodeString uname = Gwen::Utility::StringToUnicode(name);
txt = Gwen::Utility::Format(L"%s (%.2f %%) :: %.3f ms / frame (%d calls)",uname.c_str(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls());
Gwen::Controls::TreeNode* childNode = (Gwen::Controls::TreeNode*)profileIterator->Get_Current_UserPointer();
if (!childNode)
{
childNode = parentNode->AddNode(L"");
profileIterator->Set_Current_UserPointer(childNode);
}
childNode->SetText(txt);
nodes.push_back(childNode);
totalTime += current_total_time;
//recurse into children
}
for (i=0;i<numChildren;i++)
{
profileIterator->Enter_Child(i);
Gwen::Controls::TreeNode* curNode = nodes[i];
dumpRecursive(profileIterator, curNode);
profileIterator->Enter_Parent();
}
return accumulated_time;
}
开发者ID:Kelloggs,项目名称:experiments,代码行数:55,代码来源:AntTweakBar.cpp
示例4:
void Gwen::Utility::Strings::Strip( Gwen::UnicodeString& str, const Gwen::UnicodeString& chars )
{
Gwen::UnicodeString Source = str;
str = L"";
for ( int i =0; i<Source.length(); i++ )
{
if ( chars.find( Source[i] ) != Gwen::UnicodeString::npos )
continue;
str += Source[i];
}
}
开发者ID:charliesome,项目名称:battlecars,代码行数:13,代码来源:Utility.cpp
示例5: MeasureText
Gwen::Point Base::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString & text )
{
Gwen::Point p;
p.x = pFont->size * Scale() * ( float ) text.length() * 0.4;
p.y = pFont->size * Scale();
return p;
}
开发者ID:jjiezheng,项目名称:lfant,代码行数:7,代码来源:BaseRender.cpp
示例6: RenderText
void GDIPlus::RenderText( gwen::Font* pFont, gwen::Point pos, const gwen::UnicodeString & text )
{
Translate( pos.x, pos.y );
// If the font doesn't exist, or the font size should be changed
if ( !pFont->data || fabs( pFont->realsize - pFont->size * Scale() ) > 2 )
{
FreeFont( pFont );
LoadFont( pFont );
}
Gdiplus::StringFormat strFormat( Gdiplus::StringFormat::GenericDefault() );
Gdiplus::SolidBrush solidBrush( m_Colour );
Gdiplus::RectF r( pos.x, pos.y, 1000, 1000 );
Gdiplus::Font* pGDIFont = ( Gdiplus::Font* ) pFont->data;
graphics->DrawString( text.c_str(), text.length() + 1, pGDIFont, r, &strFormat, &solidBrush );
}
开发者ID:MegaThorx,项目名称:GWEN,代码行数:17,代码来源:GDIPlus.cpp
示例7: RenderText
void OpenGL_DebugFont::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text )
{
float fSize = pFont->size * Scale();
if ( !text.length() )
return;
Gwen::String converted_string = Gwen::Utility::UnicodeToString( text );
float yOffset=0.0f;
for ( int i=0; i<text.length(); i++ )
{
wchar_t chr = text[i];
char ch = converted_string[i];
float curSpacing = sGwenDebugFontSpacing[ch] * m_fLetterSpacing * fSize * m_fFontScale[0];
Gwen::Rect r( pos.x + yOffset, pos.y-fSize*0.2f, (fSize * m_fFontScale[0]), fSize * m_fFontScale[1] );
if ( m_pFontTexture )
{
float uv_texcoords[8]={0.,0.,1.,1.};
if ( ch >= 0 )
{
float cx= (ch%16)/16.0;
float cy= (ch/16)/16.0;
uv_texcoords[0] = cx;
uv_texcoords[1] = cy;
uv_texcoords[4] = float(cx+1.0f/16.0f);
uv_texcoords[5] = float(cy+1.0f/16.0f);
}
DrawTexturedRect( m_pFontTexture, r, uv_texcoords[0], uv_texcoords[5], uv_texcoords[4], uv_texcoords[1] );
yOffset+=curSpacing;
}
else
{
DrawFilledRect( r );
yOffset+=curSpacing;
}
}
}
开发者ID:Kelloggs,项目名称:experiments,代码行数:44,代码来源:OpenGL_DebugFont.cpp
示例8: MeasureText
Gwen::Point Chowdren::MeasureText( Gwen::Font* pFont,
const Gwen::UnicodeString & text )
{
FTSimpleLayout layout;
layout.SetLineLength(10000);
layout.SetFont(get_font(pFont->size));
FTBBox bbox = layout.BBox(text.c_str());
FTPoint size = bbox.Upper() - bbox.Lower();
return Gwen::Point((int)ceil(size.X()), (int)ceil(size.Y()));
}
开发者ID:joaormatos,项目名称:anaconda,代码行数:10,代码来源:GwenChowdrenRender.cpp
示例9: sizeof
bool Gwen::Platform::SetClipboardText( const Gwen::UnicodeString& str )
{
if ( !OpenClipboard( NULL ) ) return false;
EmptyClipboard();
// Create a buffer to hold the string
size_t iDataSize = (str.length()+1) * sizeof(wchar_t);
HGLOBAL clipbuffer = GlobalAlloc( GMEM_DDESHARE, iDataSize );
// Copy the string into the buffer
wchar_t* buffer = (wchar_t*) GlobalLock( clipbuffer );
wcscpy( buffer, str.c_str() );
GlobalUnlock(clipbuffer);
// Place it on the clipboard
SetClipboardData( CF_UNICODETEXT, clipbuffer );
CloseClipboard();
return true;
}
开发者ID:charliesome,项目名称:battlecars,代码行数:21,代码来源:Windows.cpp
示例10: SplitWords
void SplitWords(const Gwen::UnicodeString &s, wchar_t delim, std::vector<Gwen::UnicodeString> &elems)
{
Gwen::UnicodeString str;
for ( int i=0; i<s.length(); i++ )
{
if ( s[i] == L'\n' )
{
if ( !str.empty() ) elems.push_back( str );
elems.push_back( L"\n" );
str.clear();
continue;
}
if ( s[i] == L' ' )
{
str += s[i];
elems.push_back( str );
str.clear();
continue;
}
str += s[i];
}
if ( !str.empty() ) elems.push_back( str );
}
开发者ID:r-lyeh,项目名称:moon9,代码行数:27,代码来源:Text.cpp
示例11: RenderText
void Base::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString & text )
{
// std::cout << "tryinta render sum txt '" << Gwen::Utility::UnicodeToString(text) <<"'\n";
float fSize = pFont->size * Scale();
SetDrawColor(Gwen::Color(0,0,0,255));
for ( float i = 0; i < text.length(); i++ )
{
wchar_t 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
{
// std::cout << "drawing ur flld rct: " <<r.x<<','<<r.y<<','<<r.w<<','<<r.h<<"\n";
DrawFilledRect( r );
}
}
}
开发者ID:jjiezheng,项目名称:lfant,代码行数:51,代码来源:BaseRender.cpp
示例12: SplitLabel
void RichLabel::SplitLabel( const Gwen::UnicodeString & text, Gwen::Font* pFont, const DividedText & txt, int & x, int & y, int & lineheight )
{
Gwen::Utility::Strings::UnicodeList lst;
Gwen::Utility::Strings::Split( text, U" ", lst, true );
if ( lst.size() == 0 ) { return; }
int iSpaceLeft = Width() - x;
// Does the whole word fit in?
{
Gwen::Point StringSize = GetSkin()->GetRender()->MeasureText( pFont, text );
if ( iSpaceLeft > StringSize.x )
{
return CreateLabel( text, txt, x, y, lineheight, true );
}
}
// If the first word is bigger than the line, just give up.
{
Gwen::Point WordSize = GetSkin()->GetRender()->MeasureText( pFont, lst[0] );
if ( WordSize.x >= iSpaceLeft )
{
CreateLabel( lst[0], txt, x, y, lineheight, true );
if ( lst[0].size() >= text.size() ) { return; }
Gwen::UnicodeString LeftOver = text.substr( lst[0].size() + 1 );
return SplitLabel( LeftOver, pFont, txt, x, y, lineheight );
}
}
Gwen::UnicodeString strNewString = U"";
for ( size_t i = 0; i < lst.size(); i++ )
{
Gwen::Point WordSize = GetSkin()->GetRender()->MeasureText( pFont, strNewString + lst[i] );
if ( WordSize.x > iSpaceLeft )
{
CreateLabel( strNewString, txt, x, y, lineheight, true );
x = 0;
y += lineheight;
break;;
}
strNewString += lst[i];
}
if ( strNewString.size() >= text.size() ) return;
Gwen::UnicodeString LeftOver = text.substr( strNewString.size() + 1 );
return SplitLabel( LeftOver, pFont, txt, x, y, lineheight );
}
开发者ID:darkf,项目名称:gwen,代码行数:52,代码来源:RichLabel.cpp
示例13:
void DirectX9::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString & text )
{
Flush();
// If the font doesn't exist, or the font size should be changed
if ( !pFont->data || fabs( pFont->realsize - pFont->size * Scale() ) > 2 )
{
FreeFont( pFont );
LoadFont( pFont );
}
FontData* pFontData = ( FontData* ) pFont->data;
Translate( pos.x, pos.y );
RECT ClipRect = { pos.x, pos.y, 0, 0 };
pFontData->pFont->DrawTextW( NULL, text.c_str(), -1, &ClipRect, DT_LEFT | DT_TOP | DT_NOCLIP | DT_SINGLELINE, m_Color );
}
开发者ID:garrynewman,项目名称:GWEN,代码行数:16,代码来源:DirectX9.cpp
示例14: RenderText
void Chowdren::RenderText( Gwen::Font* pFont, Gwen::Point pos,
const Gwen::UnicodeString & text )
{
if (!init_font())
return;
FTTextureFont* font = get_font(pFont->size);
if (font) {
Translate(pos.x, pos.y);
FTTextureFont::color = m_Color;
FTSimpleLayout layout;
layout.SetLineLength(10000);
layout.SetFont(font);
layout.Render(text.c_str(), -1, FTPoint(pos.x, pos.y + font->Ascender()));
}
}
开发者ID:joaormatos,项目名称:anaconda,代码行数:16,代码来源:GwenChowdrenRender.cpp
示例15: RenderText
void Base::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text )
{
float fSize = pFont->size * Scale();
for ( float i=0; i<text.length(); i++ )
{
wchar_t 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:Azon099,项目名称:networked-iv,代码行数:46,代码来源:BaseRender.cpp
示例16: MeasureText
gwen::Point GDIPlus::MeasureText( gwen::Font* pFont, const gwen::UnicodeString & text )
{
gwen::Point p( 1, 1 );
if ( !pFont->data || fabs( pFont->realsize - pFont->size * Scale() ) > 2 )
{
FreeFont( pFont );
LoadFont( pFont );
}
Gdiplus::StringFormat strFormat( Gdiplus::StringFormat::GenericDefault() );
strFormat.SetFormatFlags( Gdiplus::StringFormatFlagsMeasureTrailingSpaces | strFormat.GetFormatFlags() );
Gdiplus::SizeF size;
Gdiplus::Graphics g( m_HWND );
Gdiplus::Font* pGDIFont = ( Gdiplus::Font* ) pFont->data;
g.MeasureString( text.c_str(), -1, pGDIFont, Gdiplus::SizeF( 10000, 10000 ), &strFormat, &size );
return gwen::Point( size.Width + 1, size.Height + 1 );
}
开发者ID:MegaThorx,项目名称:GWEN,代码行数:18,代码来源:GDIPlus.cpp
示例17: MeasureText
Gwen::Point OpenGL_DebugFont::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString& text )
{
Gwen::Point p;
float fSize = pFont->size * Scale();
Gwen::String converted_string = Gwen::Utility::UnicodeToString( text );
float spacing = 0.0f;
for ( int i=0; i<text.length(); i++ )
{
char ch = converted_string[i];
spacing += sGwenDebugFontSpacing[ch];
}
p.x = spacing*m_fLetterSpacing*fSize * m_fFontScale[0];
p.y = pFont->size * Scale() * m_fFontScale[1];
return p;
}
开发者ID:dabroz,项目名称:gwen-mirror,代码行数:18,代码来源:OpenGL_DebugFont.cpp
示例18: SplitWords
void Text::SplitWords(const Gwen::UnicodeString &s, std::vector<Gwen::UnicodeString> & elems )
{
Gwen::UnicodeString str;
int w = GetParent()->Width() - GetParent()->GetPadding().left-GetParent()->GetPadding().right;
for ( int i=0; i<(int)s.length(); i++ )
{
if ( s[i] == L'\n' )
{
if ( !str.empty() ) { elems.push_back( str ); }
elems.push_back( L"\n" );
str.clear();
continue;
}
if ( s[i] == L' ' )
{
str += s[i];
elems.push_back( str );
str.clear();
continue;
}
str += s[i];
//if adding character makes the word bigger than the textbox size
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), str );
if ( p.x > w )
{
int addSum = GetPadding().left+GetPadding().right;
//split words
str.pop_back();
elems.push_back( str );
str.clear();
--i;
continue;
}
}
if ( !str.empty() ) { elems.push_back( str ); }
}
开发者ID:jjiezheng,项目名称:lfant,代码行数:42,代码来源:Text.cpp
示例19: InsertText
void TextBox::InsertText( const Gwen::UnicodeString& strInsert )
{
// TODO: Make sure fits (implement maxlength)
if ( HasSelection() )
{
EraseSelection();
}
if ( m_iCursorPos > TextLength() ) m_iCursorPos = TextLength();
if ( !IsTextAllowed( strInsert, m_iCursorPos ) )
return;
UnicodeString str = GetText();
str.insert( m_iCursorPos, strInsert );
SetText( str );
m_iCursorPos += (int) strInsert.size();
m_iCursorEnd = m_iCursorPos;
RefreshCursorBounds();
}
开发者ID:dabroz,项目名称:gwen-mirror,代码行数:23,代码来源:TextBox.cpp
示例20: RefreshSizeWrap
void Text::RefreshSizeWrap()
{
RemoveAllChildren();
for ( TextLines::iterator it = m_Lines.begin(); it != m_Lines.end(); ++it )
{
delete *it;
}
m_Lines.clear();
std::vector<Gwen::UnicodeString> words;
SplitWords( GetText().GetUnicode(), words );
// Adding a bullshit word to the end simplifies the code below
// which is anything but simple.
words.push_back( L"" );
if ( !GetFont() )
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
return;
}
Point pFontSize = GetSkin()->GetRender()->MeasureText( GetFont(), L" " );
int w = GetParent()->Width() - GetParent()->GetPadding().left-GetParent()->GetPadding().right;
int x = 0, y = 0;
Gwen::UnicodeString strLine;
for ( std::vector<Gwen::UnicodeString>::iterator it = words.begin(); 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] == L'\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 > w ) { bFinishLine = true; bWrapped = true; }
}
// If this is the last word then finish the line
if ( --words.end() == it )
{
bFinishLine = true;
}
if ( bFinishLine )
{
Text* t = new Text( this );
t->SetFont( GetFont() );
t->SetTextColor( m_Color );
if(bWrapped)
{
t->SetString( strLine.substr( 0, strLine.length() - (*it).length() ) );
// newline should start with the word that was too big
strLine = *it;
}
else
{
t->SetString( strLine.substr( 0, strLine.length()) );
//new line is empty
strLine.clear();
}
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] == L' ' ) x -= pFontSize.x;
}
}
// Size to children height and parent width
Point childsize = ChildrenSize();
{
SetSize( w, childsize.y );
}
// Align the text within the parent
int y_offset = 0;
for ( TextLines::iterator it = m_Lines.begin(); it != m_Lines.end(); ++it )
{
Text* text = *it;
const Rect & bounds = GetInnerBounds();
int x = 0;
int y = 0;
if ( m_iAlign & Pos::Left ) { x = bounds.x; }
if ( m_iAlign & Pos::Right ) { x = bounds.x + ( bounds.w - text->Width() ); }
if ( m_iAlign & Pos::CenterH ) { x = bounds.x + ( bounds.w - text->Width() ) * 0.5; }
if ( m_iAlign & Pos::Top ) { y = bounds.y; }
//.........这里部分代码省略.........
开发者ID:guardian2433,项目名称:open-sauce,代码行数:101,代码来源:Text.cpp
注:本文中的gwen::UnicodeString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论