本文整理汇总了C++中cegui::String::find方法的典型用法代码示例。如果您正苦于以下问题:C++ String::find方法的具体用法?C++ String::find怎么用?C++ String::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::String
的用法示例。
在下文中一共展示了String::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendRenderedText
void ColouredRenderedStringParser::appendRenderedText(CEGUI::RenderedString& rs, const CEGUI::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 != CEGUI::String::npos) ? nlpos : text.length()) - cpos;
// construct new text component and append it.
if (len > 0) {
//If we're using colours different from those of the default colours we'll also use our own implementation which doesn't do modulation.
if (d_initialColours.d_bottom_left != d_colours.d_bottom_left || d_initialColours.d_top_left != d_colours.d_top_left || d_initialColours.d_top_right != d_colours.d_top_right || d_initialColours.d_bottom_right != d_colours.d_bottom_right) {
RenderedColourStringTextComponent 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);
} else {
CEGUI::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 != CEGUI::String::npos)
rs.appendLineBreak();
// advance current position. +1 to skip the \n char
cpos += len + 1;
}
}
示例2: AcceptsWindowAsChild
//------------------------------------------------------------------------
bool WindowContext::AcceptsWindowAsChild() const
{
// Validations
wxASSERT_MSG(m_pWindow != NULL, wxT("Window member is NULL"));
const CEGUI::String strWindowType = m_pWindow->getType();
// These require different parent / child handling.
// The current type must not be equal to the checks below
// Because of the "find" instead of exact matches, it works for different
// looknfeels, e.g. both "TaharezLook/Combobox" and "Windowslook/Combobox".
return strWindowType.find("Combobox") == CEGUI::String::npos &&
strWindowType.find("ComboDropList") == CEGUI::String::npos &&
strWindowType.find("ListHeader") == CEGUI::String::npos &&
strWindowType.find("Combobox") == CEGUI::String::npos &&
strWindowType.find("ListBox") == CEGUI::String::npos &&
strWindowType.find("MultiColumnList");
}
示例3: Parse
CEGUI::String LinkButtonParser::Parse(const CEGUI::String &str)
{
std::string szStr = CEGUIStringToAnsiChar( str );
size_t parentWinPos,IDPos,TextPos,ColorPos,endPos;
parentWinPos = IDPos = TextPos = ColorPos = endPos = CEGUI::String::npos;
char ParentWinName[128] = "";
char LinkID[32] = "";
char LinkText[128] = "";
char ColorVal[32] = "";
parentWinPos = str.find("WIN:");
IDPos = str.find("ID:");
TextPos = str.find("TEXT:");
ColorPos = str.find("COLOR:");
std::string wndName("LinkBtn_"),temp;
static DWORD LinkWndCounter = 0;
wndName += CEGUI::PropertyHelper::intToString(LinkWndCounter++).c_str();
CEGUI::Window *linkWnd = 0;
if (CEGUI::WindowManager::getSingleton().isWindowPresent(wndName) == false)
{
linkWnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button",wndName);
linkWnd->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LinkButtonParser::OnLinkBtnClicked,this));
//解析父窗口
if (parentWinPos != CEGUI::String::npos)
{
temp = szStr.substr(parentWinPos+5);
endPos = temp.find("'");
strcpy_s<128>(ParentWinName,temp.substr(0,endPos).c_str());
CEGUI::Window *pParentWnd = CEGUI::WindowManager::getSingleton().getWindow(ParentWinName);
pParentWnd->addChildWindow(linkWnd);
}
//解析ID
if (IDPos != CEGUI::String::npos)
{
temp = szStr.substr(IDPos+3);
endPos = temp.find(" ");
strcpy_s<32>(LinkID,temp.substr(0,endPos).c_str());
LinkMap[linkWnd] = LinkID;
}
//解析链接按钮文本
if (TextPos != CEGUI::String::npos)
{
temp = szStr.substr(TextPos+6);
endPos = temp.find("'");
strcpy_s<128>(LinkText,temp.substr(0,endPos).c_str());
float fWidth = linkWnd->getFont()->getTextExtent(LinkText);
float fheight = linkWnd->getFont()->getFontHeight();
linkWnd->setSize(CEGUI::UVector2(cegui_absdim(fWidth),cegui_absdim(fheight)));
//解析链接按钮文本的颜色
if (ColorPos != CEGUI::String::npos)
{
temp = szStr.substr(ColorPos+6);
endPos = temp.find(" ");
strcpy_s(ColorVal,temp.substr(0,endPos).c_str());
temp = "[COLOR ";
temp += ColorVal;
temp += "]";
temp += CEGUI::String(LinkText).c_str();
linkWnd->setText(ToCEGUIString(temp.c_str()));
}
else
linkWnd->setText(ToCEGUIString(LinkText));
}
}
return wndName;
}