本文整理汇总了C++中TextNode类的典型用法代码示例。如果您正苦于以下问题:C++ TextNode类的具体用法?C++ TextNode怎么用?C++ TextNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextNode
//----------------------------------------------------- M�thodes prot�g�es
void SimpleCopyVisitor::visit(const TextNode& node)
{
#ifdef XSL_TRANSFORM_TRACE
clog << "SimpleCopy on TextNode:" << node.content() << endl;
#endif
_copiedNode = new TextNode(_parentProxy, node.content());
}
示例2: removePreTitle
void TitleBar::setTitleSprite(const char *name)
{
removePreTitle();
CCSprite *titleSp = CCSprite::spriteWithSpriteFrameName(name);
if(strlen(name)==0)
return;
if (!titleSp) {
titleSp = CCSprite::spriteWithFile(name);
}
if(titleSp)
{
titleSp->setPosition(ccp(58, 45));
titleSp->setAnchorPoint(ccp(0, 0.5));
addChild(titleSp);
titleSp->setTag(kTitleBarSprite);
}
else {
TextNode* titleLabel = TextNode::textWithString(name,
CCSizeMake(300, 40),
CCTextAlignmentLeft,
40);
titleLabel->setAnchorPoint(CCPointMake(0.0, 0.5));
titleLabel->setPosition(CCPointMake(60, 45));
titleLabel->setShadowColor(ccBLACK);
addChild(titleLabel);
titleLabel->setTag(kTitleBarLabel);
}
}
示例3: addChild
void FriendInvitationLayer::showInvitationCode(const char *invitationCode) {
CCSprite *spInvitationBg = CCSprite::spriteWithFile("invitation_bg.png");
spInvitationBg->setPosition(CCPointMake(320, 440));
addChild(spInvitationBg);
CCSprite *tempSprite1 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
CCSprite *tempSprite2 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
CCMenuItem *menuItemSina = CCMenuItemImage::itemFromNormalSprite(tempSprite1,
tempSprite2,
this,
menu_selector(FriendInvitationLayer::inviteFriendFromWeibo));
menuItemSina->setAnchorPoint(CCPointMake(0, 0));
CCMenu *menu = CCMenu::menuWithItem(menuItemSina);
menu->setPosition(CCPointMake(280, 505));
addChild(menu);
if(CGameData::Inst()->getLoginType() == enLoginReqType_TencentLogin){
menuItemSina ->setIsVisible(CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}else if(CGameData::Inst()->getLoginType() == enLoginReqType_SinaLogin){
menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}else {
menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg|CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}
TextNode *lbInvitationCode = TextNode::textWithString(invitationCode, CCSizeMake(500, 40), CCTextAlignmentLeft, 32);
lbInvitationCode->setColor(ccRED);
lbInvitationCode->setPosition(CCPointMake(550, 646));
addChild(lbInvitationCode);
}
示例4: TEST_F
TEST_F(TextNodeTest, new_text_node)
{
TextNode *tn;
tn = doc.new_text_node("I am text");
ASSERT_EQ("I am text", tn->text());
}
示例5: TextNode
osg::ref_ptr<Object> PrimitivesFactory::createTextNode(const std::string& text,
double fontSize,
osg::Vec4 color)
{
TextNode* node = new TextNode(text, fontSize);
node->setColor(color);
return node;
}
示例6: heightForRange
int Paragraph::heightForRange(int start, int len) const
{
int h=0;
for (int i=0;i<m_p->nodes.size();i++)
{
TextNode node = m_p->nodes[i];
if (node.height() > h)
h = node.height();
}
return h;
}
示例7:
TextNode *SceneGraph::findTextNode(char *name) {
if (!name || strlen(name) <= 0)
return NULL;
for (TextNode *node = findTextNode(); node; node = node->nextTraversal()) {
const char *nodeName = node->getName();
if (nodeName && strlen(nodeName)) {
if (!strcmp(name, nodeName))
return node;
}
}
return NULL;
}
示例8: answerFile
bool TextOutput::check(sedna::Query &query)
{
#ifdef SETEST_DEBUG
std::cout << "TEST======A======TEST" << std::endl;
#endif
/* Wrapping text and result in XML Containers and compare them as xml */
if (query.resultCode != SEDNA_QUERY_SUCCEEDED) {
//Query exited with error or it was bulk load or update (incorrect test case)
return false;
}
#ifdef SETEST_DEBUG
std::cout << "TEST======B======TEST" << std::endl;
#endif
string answerString;
boost::filesystem::path answerFile(fileName);
answerString.resize(boost::filesystem::file_size(fileName));
boost::filesystem::ifstream answerFileStream(answerFile);
answerFileStream.read(&answerString[0], answerString.size());
Document answerDoc;
Element *answerRoot = answerDoc.create_root_node("TextOutput");
//answerRoot->add_child_text(answerString);
TextNode* tmpA = answerRoot->add_child_text(answerString);
Document resultDoc;
Element *resultRoot = answerDoc.create_root_node("TextOutput");
//resultRoot->add_child_text(query.resultString);
TextNode* tmpB = resultRoot->add_child_text(query.resultString);
#ifdef SETEST_DEBUG
std::cout << "TEST======D======TEST" << std::endl;
#endif
std::istringstream answerStream(answerDoc.write_to_string());
std::istringstream resultStream(answerDoc.write_to_string());
#ifdef SETEST_DEBUG
std::cout << "TEST======C======TEST" << std::endl;
std::cout << query.resultString << std::endl;
std::string tmpBB = string(tmpB->get_content());
std::cout << tmpBB << std::endl;
std::cout << "=====================" << std::endl;
std::cout << answerString << std::endl;
std::string tmpAA = string(tmpA->get_content());
std::cout << tmpAA << std::endl;
std::cout << "END======C=======END" << std::endl;
#endif
XmlDiff xmlDiff(answerStream, resultStream);
return !xmlDiff.diff();
}
示例9: setCardState
void Card::fengYinUpdate(int cd)
{
m_FengYinCD -= cd;
if (m_FengYinCD <= 0)
{
m_FengYinCD = 0;
setCardState(EN_CARD_STATE_NORMAL);
}
else
{
char buf[10];
sprintf(buf, "%d",m_FengYinCD);
TextNode* tempText = (TextNode*)getChildByTag(FENGYINPNGTAG+1);
tempText->setString(buf);
}
}
示例10: addChild
BonusPanel::BonusPanel()
{
m_commDlg = NULL;
m_cntryDialog = NULL;
m_lyPanel = CCLayer::node();
addChild(m_lyPanel);
CCSprite* spBg = CCSprite::spriteWithFile("bonuspanel.png");
if (spBg) {
m_lyPanel->addChild(spBg, -1);
spBg->setAnchorPoint(ccp(0,1));
spBg->setPosition(CCPointZero);
}
char buf[64];
//元宝数
long lGuildCoin = CGameData::Inst()->getGuildCoin();
snprintf(buf, sizeof(buf), "%s:%ld", CGameData::Inst()->getLanguageValue("deadDlgtip6"), lGuildCoin);
m_txtCoin = TextNode::textWithString(buf, 22);
m_txtCoin->setPosition(CCPointMake(307, -34));
m_txtCoin->setColor(ccBLACK);
m_lyPanel->addChild(m_txtCoin);
//成员、近5次伤害、上次伤害
TextNode* txtMember = TextNode::textWithString(CGameData::Inst()->getLanguageValue("cntry_member_alone"), 22);
txtMember->setPosition(CCPointMake(120, -70));
txtMember->setColor(ccc3(93, 0, 4));
m_lyPanel->addChild(txtMember);
TextNode* txtRecentScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_recentscore"), 22);
txtRecentScore->setPosition(CCPointMake(270, -70));
txtRecentScore->setColor(ccc3(93, 0, 4));
m_lyPanel->addChild(txtRecentScore);
TextNode* txtLastScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_lastscore"), 22);
txtLastScore->setPosition(CCPointMake(410, -70));
txtLastScore->setColor(ccc3(93, 0, 4));
m_lyPanel->addChild(txtLastScore);
//列表
m_pBonusList = new BonusList(this, callfuncO_selector(BonusPanel::cbBonusList));
m_lyPanel->addChild(m_pBonusList);
m_pBonusList->setPosition(CCPointZero);
}
示例11: widthForRange
int Paragraph::widthForRange(int start, int len) const
{
int pos,sz,spos,ln;
int width = 0;
pos = 0;
for (int i=0;i<m_p->nodes.size();i++)
{
TextNode node = m_p->nodes[i];
sz = node.text().size();
if (start > pos+sz)
{
pos += sz;
continue;
}
spos = start - pos;
if (spos + len > sz)
{
len = spos + len - sz;
ln = sz - spos;
}
else
ln = len;
width += node.widthForRange(spos,ln);
if (len == ln)
break;
else
start = pos + sz;
pos += sz;
}
return width;
}
示例12: addChild
//******************************************************************************
// initConnecting
//******************************************************************************
void CommDlg::initConnecting()
{
CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png");
if(sp){
addChild(sp);
}
char buf[100];
CCSprite *temSp = CCSprite::spriteWithSpriteFrameName("loading0001.png");
temSp->setPosition(CCPointMake(-120 - 15, 30));
addChild(temSp);
CCAnimation *loadingAnim = CCAnimation::animation();
char loadingAnimName[100] = {0};
for (int i = 1; i <= 8 ; i++) {
sprintf(loadingAnimName, "loading00%02d.png", i);
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( loadingAnimName );
loadingAnim->addFrame(frame);
}
loadingAnim->setDelay(1.0f / 8);
CCAnimate* loadingAction = CCAnimate::actionWithAnimation(loadingAnim, true);
temSp->runAction(CCRepeatForever::actionWithAction(loadingAction));
snprintf(buf, 99, "%s",OcProxy::Inst()->localizedStringStatic("loading_title"));
TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(200, 45), CCTextAlignmentCenter,45);
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
lbText->setPosition(CCPointMake(60 - 45, 20));
addChild(lbText, 2);
CCLabelTTF* ttfText = CCLabelTTF::labelWithString(OcProxy::Inst()->localizedStringStatic("loading_prompt"), CCSizeMake(360, 60), CCTextAlignmentCenter, "default.ttf", 20);
ttfText->setColor(ccc3(233, 183, 72));
ttfText->setPosition(CCPointMake(0, -80));
addChild(ttfText);
}
示例13: addChild
DeadDlg::DeadDlg(CCObject *listener,SEL_CallFuncO selector,int type)
{
// CCLayerColor *layer = CCLayerColor::layerWithColor)
m_listener = listener;
m_selector = selector;
m_backGround = CCSprite::spriteWithSpriteFrameName("fr_window2.png");
m_backGround->setScale(2.0);
addChild(m_backGround);
m_backGround->setPosition(ccp(320, 500));
CCSprite* spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_button.png");
CCSprite* spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_button.png");
sureItem = CCMenuItemImage::itemFromNormalSprite(spMenu1, spMenu2, this, menu_selector(DeadDlg::menuCallback));
sureItem->setTag(111);
sureItem->setPosition(ccp(88, 284));
int need;
long hold;
if (CGameData::Inst()->chkLogin()) {
need = CGameData::Inst()->getCommonInfo()->revive_coin;
}
else {
need = SaveData::Inst()->getReviveCoin();
}
if(CGameData::Inst()->getUsrInfo()->login_time > 0){
hold = CGameData::Inst()->getUsrInfo()->coin;
SaveData::Inst()->setCurCoin(hold);
}
else{
hold = SaveData::Inst()->getCurCoin();
}
char buf[100];
if(type == enDeadType_normal)
{
if (hold<need) {
strncpy(buf, CGameData::Inst()->getLanguageValue("shopTip14"), 99);
}
else
{
strncpy(buf, CGameData::Inst()->getLanguageValue("sureTip"), 99);
}
}
else if(type == enDeadType_free)
{
strncpy(buf, CGameData::Inst()->getLanguageValue("sureTip"), 99);
}
TextNode *sureLabel = TextNode::textWithString(buf, 42);
sureLabel->setColor(ccc3(255, 255, 255));
sureLabel->setShadowColor(ccBLACK);
sureLabel->setPosition(CCPointMake(spMenu1->getContentSize().width * 0.5 - 2,
spMenu1->getContentSize().height * 0.5 + 2));
sureItem->addChild(sureLabel);
spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_button.png");
spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_button.png");
cancelItem = CCMenuItemImage::itemFromNormalSprite(spMenu1, spMenu2, this, menu_selector(DeadDlg::menuCallback));
cancelItem->setTag(112);
cancelItem->setPosition(ccp(394, 284));
TextNode *cancelLabel = TextNode::textWithString(CGameData::Inst()->getLanguageValue("cancelTip"), 42);
cancelLabel->setColor(ccc3(255, 255, 255));
cancelLabel->setShadowColor(ccBLACK);
cancelLabel->setPosition(CCPointMake(spMenu1->getContentSize().width * 0.5 - 2,
spMenu1->getContentSize().height * 0.5 + 2));
cancelItem->addChild(cancelLabel);
sureItem->setAnchorPoint(ccp(0, 0));
cancelItem->setAnchorPoint(ccp(0, 0));
CCMenu *menu = CCMenu::menuWithItems(sureItem,cancelItem,NULL);
menu->setPosition(ccp(0, 0));
addChild(menu);
TextNode *titleLabel = TextNode::textWithString(CGameData::Inst()->getLanguageValue("deadDlgtip1"), 55);
titleLabel->setColor(ccc3(122, 37, 8));
addChild(titleLabel);
titleLabel->setPosition(ccp(320, 420+255));
if(type == enDeadType_normal)
{
if (hold<need) {
snprintf(buf, 99, "%s%d%s",CGameData::Inst()->getLanguageValue("deadDlgtip2"),need,CGameData::Inst()->getLanguageValue("deadDlgtip3"));
}
else
{
snprintf(buf, 99, "%s%d%s",CGameData::Inst()->getLanguageValue("deadDlgtip2"),need,CGameData::Inst()->getLanguageValue("deadDlgtip4"));
}
infoLabel = TextNode::textWithString(buf, CCSize(388, 70), CCTextAlignmentCenter, 30);
infoLabel->setPosition(ccp(320, 300+255));
infoLabel->setColor(ccc3(63, 23, 13));
addChild(infoLabel);
}
else if(type == enDeadType_free)
{
snprintf(buf, 99,CGameData::Inst()->getLanguageValue("deadDlgtip7"),CGameData::Inst()->getCommonInfo()->free_revive_lv);
infoLabel = TextNode::textWithString(buf, CCSize(388, 110), CCTextAlignmentCenter, 30);
//.........这里部分代码省略.........
示例14: CCLayer
CCLayer* RemindLayer::createRLayer(const char *tStr, int remindType){
CCLayer* layer = new CCLayer();
int tagOpen = 0;
int tagClose = 0;
bool typeOn;
switch (remindType) {
case EN_REMIND_ACTIVITY:
tagOpen = kActivityOnTag;
tagClose = kActivityOffTag;
typeOn = CGameData::Inst()->isActivityRemind;
break;
case EN_REMIND_TWOUP:
tagOpen = kTwoupOnTag;
tagClose = kTwoupOffTag;
typeOn = CGameData::Inst()->isTwoUpRemind;
break;
case EN_REMIND_CNTRYCD:
tagOpen = kCntryCdOnTag;
tagClose = kCntryCdOffTag;
typeOn = CGameData::Inst()->isCntryCdRemind;
break;
case EN_REMIND_POWER:{
tagOpen = kPowerOnTag;
tagClose = kPowerOffTag;
typeOn = CGameData::Inst()->intPowerRemind;
CCSprite* spMenu1 = CCSprite::spriteWithFile("pushConfig_tilizhi.png");
CCSprite* spMenu2 = CCSprite::spriteWithFile("pushConfig_tilizhi.png");
CCMenuItem* item = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,
this, menu_selector(RemindLayer::MoveUpKeyboard));
item->setPosition(ccp(0,0));
item->setAnchorPoint(CCPointZero);
CCMenu *menu = CCMenu::menuWithItems (item, NULL);
menu->setPosition(ccp(-50,20));
layer->addChild(menu, 2);
char buf[100];
snprintf(buf, 99,"%d", CGameData::Inst()->intPowerRemind);
powerNumber = CCTextFieldTTF::textFieldWithPlaceHolder(buf,CCSizeMake(100, 200) ,CCTextAlignmentCenter,"huakangfont.ttf", 32);
powerNumber->setPosition(ccp(12, 40));
powerNumber->setColor(ccWHITE);
powerNumber->setDelegate(this);
layer->addChild(powerNumber,10);
CCEGLView * pGlView = CCDirector::sharedDirector()->getOpenGLView();
pGlView->setIMEKeyboardNumber();
break;
}
default:
tagOpen = kActivityOnTag;
tagClose = kActivityOffTag;
typeOn = CGameData::Inst()->isCntryCdRemind;
break;
}
CCSprite* spFrame = CCSprite::spriteWithFile("pushConfig_Bg.png");
spFrame->setPosition(CCPointMake(2, 0));
layer->addChild(spFrame);
TextNode *remindLabel = TextNode::textWithString(tStr, 32);
remindLabel->setColor(ccc3(255, 255, 255));
remindLabel->setShadowColor(ccc3(0, 0, 0));
remindLabel->setPosition(ccp(0,40));
layer->addChild(remindLabel);
CCSprite* spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_open.png");
CCSprite* spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_open.png");
CCSprite* spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_open2.png");
CCMenuItem* item1 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3,
this, menu_selector(RemindLayer::switchOnOff));
item1->setPosition(ccp(-170, -50));
item1->setAnchorPoint(ccp(0, 0));
item1->setTag(tagOpen);
spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_close.png");
spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_close.png");
spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_close2.png");
CCMenuItem* item2 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3,
this, menu_selector(RemindLayer::switchOnOff));
item2->setPosition(ccp(30, -50));
item2->setAnchorPoint(ccp(0, 0));
item2->setTag(tagClose);
item1->setIsEnabled(!typeOn);
item2->setIsEnabled(typeOn);
CCMenu *menu = CCMenu::menuWithItems (item1,item2,
NULL);
menu->setPosition(ccp(0, 0));
layer->addChild(menu);
return layer;
}
示例15: TemplateNode
// FIXME: Most of the assertions below should be turn into parse errors and be
// reported in a cleaner way to the client side.
TemplateNode* Parser::parse()
{
TemplateNode* root = new TemplateNode();
Node* current = root;
m_insideClause = false;
Tokenizer::Token token;
do {
assert(m_lastTokenType != Tokenizer::Token::EndOfInput);
m_tokenizer->nextToken(token);
assert(token.type != Tokenizer::Token::None);
switch (token.type) {
case Tokenizer::Token::Text:
assert(m_lastTokenType != Tokenizer::Token::Text);
switch (m_lastTokenType) {
case Tokenizer::Token::OpenComment: {
assert(m_insideClause);
CommentNode* commentNode = new CommentNode(current);
commentNode->setText(token.contents);
break;
}
case Tokenizer::Token::OpenVariable: {
assert(m_insideClause);
std::string variable;
assert(splitVariableExpression(token.contents, variable));
VariableNode* variableNode = new VariableNode(current);
variableNode->setExpression(VariableExpression::parse(variable));
break;
}
case Tokenizer::Token::OpenTag: {
assert(m_insideClause);
std::string tagName;
std::vector<std::string> parameters;
assert(splitTagExpression(token.contents, tagName, parameters));
if (tagName.size() > 3 && tagName.substr(0, 3) == "end") {
std::string tagBaseName = tagName.substr(3);
if (TagNodeFactory::self()->isTagRegistered(tagBaseName.c_str())) {
assert(current->type() == Node::Tag);
TagNode* tagNode = static_cast<TagNode*>(current);
assert(tagNode->name() == tagBaseName);
assert(!tagNode->isSelfClosing());
current = current->parent();
} else {
TagNode* tagNode = new NullTagNode(current);
assert(tagNode->isSelfClosing());
}
} else {
if (TagNodeFactory::self()->isTagRegistered(tagName.c_str())) {
TagNode* tagNode = TagNodeFactory::self()->create(tagName.c_str(), current);
assert(tagNode);
tagNode->setName(tagName);
tagNode->setParameters(parameters);
if (!tagNode->isSelfClosing())
current = tagNode;
} else {
TagNode* tagNode = new NullTagNode(current);
assert(tagNode->isSelfClosing());
}
}
break;
}
default: {
TextNode* textNode = new TextNode(current);
textNode->setText(token.contents);
break;
}
}
break;
case Tokenizer::Token::OpenComment:
case Tokenizer::Token::OpenVariable:
case Tokenizer::Token::OpenTag:
assert(!m_insideClause);
m_insideClause = true;
break;
case Tokenizer::Token::CloseComment:
case Tokenizer::Token::CloseVariable:
case Tokenizer::Token::CloseTag:
assert(m_insideClause);
m_insideClause = false;
break;
case Tokenizer::Token::EndOfInput:
// Make sure all opening tags have their corresponding closing tags.
assert(current == root);
break;
}
m_lastTokenType = token.type;
assert(current);
} while (token.type != Tokenizer::Token::EndOfInput);
return root;
}