本文整理汇总了C++中TextNode类的典型用法代码示例。如果您正苦于以下问题:C++ TextNode类的具体用法?C++ TextNode怎么用?C++ TextNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:padenot,项目名称:XML_DTD_XSLT_Parser,代码行数:8,代码来源:SimpleCopyVisitor.cpp
示例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);
}
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:30,代码来源:TitleBar.cpp
示例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);
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:33,代码来源:FriendInvitationLayer.cpp
示例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());
}
开发者ID:shepmaster,项目名称:sxd-cpp,代码行数:8,代码来源:text-node-test.cpp
示例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;
}
开发者ID:rock-gui,项目名称:gui-osgviz-osgviz,代码行数:8,代码来源:PrimitivesFactory.cpp
示例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;
}
开发者ID:DreamLogics,项目名称:EPFText,代码行数:11,代码来源:paragraph.cpp
示例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;
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:12,代码来源:SceneGraph.cpp
示例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();
}
开发者ID:AlexanderYAPPO,项目名称:setest,代码行数:52,代码来源:XQTSOutputs.cpp
示例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);
}
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:16,代码来源:Card.cpp
示例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);
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:46,代码来源:BonusPanel.cpp
示例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;
}
开发者ID:DreamLogics,项目名称:EPFText,代码行数:39,代码来源:paragraph.cpp
示例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);
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:39,代码来源:CommDlg.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:101,代码来源:DeadDlg.cpp
示例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;
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:89,代码来源:RemindLayer.cpp
示例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;
}
开发者ID:vietlq,项目名称:cjango,代码行数:100,代码来源:Parser.cpp
示例16: layout
void Layout::layout(TextNode& text) const
{
OSG_NOTICE<<"Layout::layout"<<std::endl;
Font* font = text.getActiveFont();
Style* style = text.getActiveStyle();
TextTechnique* technique = text.getTextTechnique();
const String& str = text.getText();
if (!text.getTextTechnique())
{
OSG_NOTICE<<"Warning: no TextTechnique assigned to Layout"<<std::endl;
return;
}
osg::Vec3 pos(0.0f,0.0f,0.0f);
float characterSize = text.getCharacterSize();
osg::Vec3 size(characterSize, characterSize, 0.0);
if (style)
{
size.y() = characterSize;
size.z() = characterSize;
}
osgText::FontResolution resolution(32,32);
if (style)
{
resolution.first = static_cast<unsigned int>(static_cast<float>(resolution.first)*style->getSampleDensity());
resolution.second = static_cast<unsigned int>(static_cast<float>(resolution.second)*style->getSampleDensity());
}
float characterWidthScale = 1.0f;
bool textIs3D = (style && style->getThicknessRatio()!=0.0);
if (!textIs3D)
{
characterWidthScale = 1.0f/static_cast<float>(resolution.first);
}
osgText::KerningType kerningType = osgText::KERNING_DEFAULT;
technique->start();
unsigned int previousCharcode = 0;
for(unsigned int i=0; i<str.size(); ++i)
{
unsigned int charcode = str[i];
if (size.z()==0.0f)
{
osgText::Glyph* glyph = font->getGlyph(resolution, charcode);
if (glyph)
{
technique->addCharacter(pos, size, glyph, style);
pos += osg::Vec3(size.x()*(glyph->getHorizontalAdvance()*characterWidthScale), 0.0f ,0.0f);
}
}
else
{
osgText::Glyph3D* glyph = font->getGlyph3D(charcode);
OSG_NOTICE<<"pos = "<<pos<<", charcode="<<charcode<<", glyph="<<glyph<< std::endl;
if (glyph)
{
osg::Vec3 local_scale( size );
technique->addCharacter(pos, local_scale, glyph, style);
pos += osg::Vec3(size.x()*glyph->getWidth(), 0.0f ,0.0f);
}
}
if (previousCharcode!=0 && charcode!=0)
{
osg::Vec2 offset = font->getKerning(previousCharcode, charcode, kerningType);
OSG_NOTICE<<" offset = "<<offset<< std::endl;
pos.x() += offset.x();
pos.y() += offset.y();
}
previousCharcode = charcode;
}
technique->finish();
}
开发者ID:yueying,项目名称:osg,代码行数:83,代码来源:TextNode.cpp
示例17: ContainerNode
bool MyGame::LoadResource()
{
// Build scene graph
ContainerNode* root = new ContainerNode();
OrthographicProjectionNode* ortho = new OrthographicProjectionNode();
Texture* texTile = Texture::Get("!tile.png");
Texture* texStair = Texture::Get("!stair.png");
Font* texFont = Font::Get("!DroidSans.ttf|texture_size=256");
Cube* floor = new Cube(Vector3f(50.f, 1.f, 50.f), 50.f, "Floor");
floor->SetTexture(texTile);
root->AddChild(floor);
floor->AddToPhysic(0, Vector3f(0, -.5f, 0));
// Stair
float sw = 1.f; // stair depth
float sh = 1.0f; // stair height
for(int i = 0; i < 5; ++i)
{
Cube* stair = new Cube(Vector3f(6.f, sh, sw), 4);
stair->SetTexture(texStair);
root->AddChild(stair);
stair->AddToPhysic(0, Vector3f(0, sh / 2.f + (i * sh), 5 + (i * sw)));
}
TextNode* title = new TextNode(texFont, 12.f, "TAK game sample");
title->SetShader(Shader::Get("!nolight"));
title->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 25, 0);
ortho->AddChild(title);
TextNode* instruction = new TextNode(texFont, 12.f, "Drag and hold left mouse button to rotate, hold right mouse button to zoom");
instruction->SetShader(Shader::Get("!nolight"));
instruction->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 45, 0);
ortho->AddChild(instruction);
m_txtFps = new TextNode(texFont);
m_txtFps->SetShader(Shader::Get("!nolight"));
m_txtFps->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 65, 0);
ortho->AddChild(m_txtFps);
m_txtCubeCount = new TextNode(texFont);
m_txtCubeCount->SetShader(Shader::Get("!nolight"));
m_txtCubeCount->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 85, 0);
ortho->AddChild(m_txtCubeCount);
Cube* pc1;
// front wall
pc1 = new Cube(Vector3f(5.5f, 7.f, .5f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(0, pc1->GetSize().y / 2.f, 9.75f));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(-3, pc1->GetSize().y / 2.f, 5));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(3, pc1->GetSize().y / 2.f, 5));
// Flag engine logo
Sprite* flag = new Sprite(128, 128, Texture::Get("!engineflag.png"));
flag->SetShader(Shader::Get("!nolight"));
flag->SetPositionAbsolute(GetScene().GetParams().GetWidth() - flag->GetWidth() / 2.f, flag->GetHeight() / 2.f - 20.f, 0);
ortho->AddChild(flag);
root->AddChild(ortho);
GetScene().SetRoot(root);
// Setup camera:
Camera* camera = new LookAtCamera(Vector3f(0, 0, 5), 25.f);
GetScene().SetCamera(camera);
return true;
}
开发者ID:voidah,项目名称:taksample,代码行数:85,代码来源:mygame.cpp
示例18: switch
//setstate
void Card::setCardState(int state, int param1)
{
switch (state)
{
case EN_CARD_STATE_FNEGYIN:
{
if (param1 > 0)
{
Player* pPlayer = (Player*)getParent();
int iOccurOdds = getCanUseNumByAwakeId(enAwakeSkill_16) * 50;
if (SaveData::Inst()->getrand()%100+1 <= iOccurOdds || pPlayer->haveAwakeSkill_33()){ //新增
char fileName[100];
CCSprite* spAnim = CCSprite::spriteWithSpriteFrameName("blank.png");
addChild(spAnim,100,FENGYINDEFENSETAG);
spAnim->setPosition(getCardPos());
CCAnimation *animation1 = CCAnimation::animation();
for(int i=1;i<=9;i++)
{
sprintf(fileName, "dikang00%02d.png",i);
animation1->addFrameWithFileName(fileName);
}
animation1->setDelay(1.0/20.0);
CCAnimate* animate1 = CCAnimate::actionWithAnimation(animation1);
spAnim->runAction(animate1);
return;
}
}
m_FengYinCD += param1;
if (m_state == state)
{
char buf[10];
sprintf(buf, "%d",m_FengYinCD);
TextNode* tempText = (TextNode*)getChildByTag(FENGYINPNGTAG+1);
tempText->setString(buf);
}
else
{
if (param1 > 0)
{
if (m_idx == 0 || m_idx == 5)
{
Player* pPlayer = (Player*)getParent();
pPlayer->fengYinAutoSkill(m_idx);
}
}
CCSprite* cardLock = CCSprite::spriteWithSpriteFrameName("cardlock.png");
addChild(cardLock,100,FENGYINPNGTAG);
cardLock->setPosition(getCardPos());
cardLock->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actions(CCFadeIn::actionWithDuration(1.0),CCFadeOut::actionWithDuration(1.0),NULL)));
char buf[10];
sprintf(buf, "%d",m_FengYinCD);
TextNode* textCD = TextNode::textWithString(buf,55);
addChild(textCD,101,FENGYINPNGTAG+1);
textCD->setPosition(getCardPos());
textCD->setShadowColor(ccBLACK);
textCD->setColor(ccWHITE);
m_spCard->setColor(ccc3(60, 60, 60));
}
}
break;
case EN_CARD_STATE_NORMAL:
if (m_state == EN_CARD_STATE_FNEGYIN)
{
m_FengYinCD = 0;
removeChildByTag(FENGYINPNGTAG, true);
removeChildByTag(FENGYINPNGTAG+1, true);
removeChildByTag(FENGYINDEFENSETAG, true);
if (m_idx == 0 || m_idx == 5)
{
Player* pPlayer = (Player*)getParent();
pPlayer->unFengYinAutoSkill(m_idx);
}
}
m_spCard->setColor(ccWHITE);
break;
default:
break;
}
if (state!=m_state)
{
m_state = state;
if (Player *pPlayer = dynamic_cast<Player*>(getParent()))
{
pPlayer->updateNumByAwakeId();
}
if (EN_CARD_STATE_NORMAL==state)
{
//.........这里部分代码省略.........
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:101,代码来源:Card.cpp
示例19: visit
void OutputVisitor::visit(const TextNode& node)
{
_out << node.content() << endl;
}
开发者ID:padenot,项目名称:XML_DTD_XSLT_Parser,代码行数:4,代码来源:OutputVisitor.cpp
示例20: AddSFFloat
void AddSFFloat(float value)
{
switch (GetCurrentNodeType()) {
case VRML_NODETYPE_ELEVATIONGRID_HEIGHT:
{
ElevationGridNode *elev = (ElevationGridNode *)GetCurrentNodeObject();
elev->addHeight(value);
}
break;
case VRML_NODETYPE_BACKGROUND_GROUNDANGLE:
{
BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject();
bg->addGroundAngle(value);
}
break;
case VRML_NODETYPE_BACKGROUND_SKYANGLE:
{
BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject();
bg->addSkyAngle(value);
}
break;
case VRML_NODETYPE_INTERPOLATOR_KEY:
switch (GetPrevNodeType()) {
case VRML_NODETYPE_COLORINTERPOLATOR:
{
ColorInterpolatorNode *colorInterp = (ColorInterpolatorNode *)GetCurrentNodeObject();
colorInterp->addKey(value);
}
break;
case VRML_NODETYPE_COORDINATEINTERPOLATOR:
{
CoordinateInterpolatorNode *coordInterp = (CoordinateInterpolatorNode *)GetCurrentNodeObject();
coordInterp->addKey(value);
}
break;
case VRML_NODETYPE_NORMALINTERPOLATOR:
{
NormalInterpolatorNode *normInterp = (NormalInterpolatorNode *)GetCurrentNodeObject();
normInterp->addKey(value);
}
break;
case VRML_NODETYPE_ORIENTATIONINTERPOLATOR:
{
OrientationInterpolatorNode *oriInterp = (OrientationInterpolatorNode *)GetCurrentNodeObject();
oriInterp->addKey(value);
}
break;
case VRML_NODETYPE_POSITIONINTERPOLATOR:
{
PositionInterpolatorNode *posInterp = (PositionInterpolatorNode *)GetCurrentNodeObject();
posInterp->addKey(value);
}
break;
case VRML_NODETYPE_SCALARINTERPOLATOR:
{
ScalarInterpolatorNode *scalarInterp = (ScalarInterpolatorNode *)GetCurrentNodeObject();
scalarInterp->addKey(value);
}
break;
}
break;
case VRML_NODETYPE_INTERPOLATOR_KEYVALUE:
switch (GetPrevNodeType()) {
case VRML_NODETYPE_SCALARINTERPOLATOR:
{
ScalarInterpolatorNode *scalarInterp = (ScalarInterpolatorNode *)GetCurrentNodeObject();
scalarInterp->addKeyValue(value);
}
break;
}
break;
case VRML_NODETYPE_LOD_RANGE:
{
((LodNode *)GetCurrentNodeObject())->addRange(value);
}
break;
case VRML_NODETYPE_NAVIGATIONINFO_AVATARSIZE:
{
NavigationInfoNode *navInfo = (NavigationInfoNode *)GetCurrentNodeObject();
navInfo->addAvatarSize(value);
}
break;
case VRML_NODETYPE_TEXT_LENGTH:
{
TextNode *text = (TextNode *)GetCurrentNodeObject();
text->addLength(value);
}
break;
}
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:90,代码来源:VRMLSetInfo.cpp
|
请发表评论