fixed #1749: Fixed compilation errors for win32.

This commit is contained in:
James Chen 2013-02-25 22:50:15 +08:00
parent 56797db85c
commit 0ece3056ee
3 changed files with 37 additions and 6 deletions

View File

@ -66,14 +66,16 @@ bool CCEditBoxImplWin::initWithSize(const CCSize& size)
{ {
//! int fontSize = getFontSizeAccordingHeightJni(size.height-12); //! int fontSize = getFontSizeAccordingHeightJni(size.height-12);
m_pLabel = CCLabelTTF::create("", "", size.height-12); m_pLabel = CCLabelTTF::create("", "", size.height-12);
m_pLabel->setAnchorPoint(ccp(0, 0)); // align the text vertically center
m_pLabel->setPosition(ccp(5, 2)); m_pLabel->setAnchorPoint(ccp(0, 0.5f));
m_pLabel->setPosition(ccp(5, size.height / 2.0f));
m_pLabel->setColor(m_colText); m_pLabel->setColor(m_colText);
m_pEditBox->addChild(m_pLabel); m_pEditBox->addChild(m_pLabel);
m_pLabelPlaceHolder = CCLabelTTF::create("", "", size.height-12); m_pLabelPlaceHolder = CCLabelTTF::create("", "", size.height-12);
m_pLabelPlaceHolder->setAnchorPoint(ccp(0, 0)); // align the text vertically center
m_pLabelPlaceHolder->setPosition(ccp(5, 2)); m_pLabelPlaceHolder->setAnchorPoint(ccp(0, 0.5f));
m_pLabelPlaceHolder->setPosition(ccp(5, size.height / 2.0f));
m_pLabelPlaceHolder->setVisible(false); m_pLabelPlaceHolder->setVisible(false);
m_pLabelPlaceHolder->setColor(m_colPlaceHolder); m_pLabelPlaceHolder->setColor(m_colPlaceHolder);
m_pEditBox->addChild(m_pLabelPlaceHolder); m_pEditBox->addChild(m_pLabelPlaceHolder);
@ -82,12 +84,33 @@ bool CCEditBoxImplWin::initWithSize(const CCSize& size)
return true; return true;
} }
void CCEditBoxImplWin::setFont(const char* pFontName, int fontSize)
{
if(m_pLabel != NULL) {
m_pLabel->setFontName(pFontName);
m_pLabel->setFontSize(fontSize);
}
if(m_pLabelPlaceHolder != NULL) {
m_pLabelPlaceHolder->setFontName(pFontName);
m_pLabelPlaceHolder->setFontSize(fontSize);
}
}
void CCEditBoxImplWin::setFontColor(const ccColor3B& color) void CCEditBoxImplWin::setFontColor(const ccColor3B& color)
{ {
m_colText = color; m_colText = color;
m_pLabel->setColor(color); m_pLabel->setColor(color);
} }
void CCEditBoxImplWin::setPlaceholderFont(const char* pFontName, int fontSize)
{
if(m_pLabelPlaceHolder != NULL) {
m_pLabelPlaceHolder->setFontName(pFontName);
m_pLabelPlaceHolder->setFontSize(fontSize);
}
}
void CCEditBoxImplWin::setPlaceholderFontColor(const ccColor3B& color) void CCEditBoxImplWin::setPlaceholderFontColor(const ccColor3B& color)
{ {
m_colPlaceHolder = color; m_colPlaceHolder = color;
@ -191,6 +214,11 @@ void CCEditBoxImplWin::setContentSize(const CCSize& size)
{ {
} }
void CCEditBoxImplWin::setAnchorPoint(const CCPoint& anchorPoint)
{ // don't need to be implemented on win32 platform.
}
void CCEditBoxImplWin::visit(void) void CCEditBoxImplWin::visit(void)
{ {
} }

View File

@ -44,7 +44,9 @@ public:
virtual ~CCEditBoxImplWin(); virtual ~CCEditBoxImplWin();
virtual bool initWithSize(const CCSize& size); virtual bool initWithSize(const CCSize& size);
virtual void setFont(const char* pFontName, int fontSize);
virtual void setFontColor(const ccColor3B& color); virtual void setFontColor(const ccColor3B& color);
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
virtual void setPlaceholderFontColor(const ccColor3B& color); virtual void setPlaceholderFontColor(const ccColor3B& color);
virtual void setInputMode(EditBoxInputMode inputMode); virtual void setInputMode(EditBoxInputMode inputMode);
virtual void setInputFlag(EditBoxInputFlag inputFlag); virtual void setInputFlag(EditBoxInputFlag inputFlag);
@ -58,6 +60,7 @@ public:
virtual void setPlaceHolder(const char* pText); virtual void setPlaceHolder(const char* pText);
virtual void setPosition(const CCPoint& pos); virtual void setPosition(const CCPoint& pos);
virtual void setContentSize(const CCSize& size); virtual void setContentSize(const CCSize& size);
virtual void setAnchorPoint(const CCPoint& anchorPoint);
virtual void visit(void); virtual void visit(void);
virtual void doAnimationWhenKeyboardMove(float duration, float distance); virtual void doAnimationWhenKeyboardMove(float duration, float distance);
virtual void openKeyboard(); virtual void openKeyboard();

View File

@ -55,9 +55,9 @@ EditBoxTest::EditBoxTest()
m_pEditPassword = CCEditBox::create(editBoxSize, CCScale9Sprite::create("extensions/orange_edit.png")); m_pEditPassword = CCEditBox::create(editBoxSize, CCScale9Sprite::create("extensions/orange_edit.png"));
m_pEditPassword->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); m_pEditPassword->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
m_pEditPassword->setFont("A Damn Mess", 30); m_pEditPassword->setFont("American Typewriter", 30);
#else #else
m_pEditPassword->setFont("fonts/A Damn Mess.ttf", 30); m_pEditPassword->setFont("fonts/American Typewriter.ttf", 30);
#endif #endif
m_pEditPassword->setFontColor(ccGREEN); m_pEditPassword->setFontColor(ccGREEN);
m_pEditPassword->setPlaceHolder("Password:"); m_pEditPassword->setPlaceHolder("Password:");