add constness to UITextField

This commit is contained in:
andyque 2014-05-27 11:03:38 +08:00
parent 5da1f1f78c
commit 884d4c5d1f
2 changed files with 60 additions and 43 deletions

View File

@ -246,7 +246,7 @@ void UICCTextField::setMaxLengthEnabled(bool enable)
_maxLengthEnabled = enable; _maxLengthEnabled = enable;
} }
bool UICCTextField::isMaxLengthEnabled() bool UICCTextField::isMaxLengthEnabled()const
{ {
return _maxLengthEnabled; return _maxLengthEnabled;
} }
@ -256,12 +256,12 @@ void UICCTextField::setMaxLength(int length)
_maxLength = length; _maxLength = length;
} }
int UICCTextField::getMaxLength() int UICCTextField::getMaxLength()const
{ {
return _maxLength; return _maxLength;
} }
int UICCTextField::getCharCount() int UICCTextField::getCharCount()const
{ {
return TextFieldTTF::getCharCount(); return TextFieldTTF::getCharCount();
} }
@ -271,7 +271,7 @@ void UICCTextField::setPasswordEnabled(bool enable)
_passwordEnabled = enable; _passwordEnabled = enable;
} }
bool UICCTextField::isPasswordEnabled() bool UICCTextField::isPasswordEnabled()const
{ {
return _passwordEnabled; return _passwordEnabled;
} }
@ -317,7 +317,7 @@ void UICCTextField::setAttachWithIME(bool attach)
_attachWithIME = attach; _attachWithIME = attach;
} }
bool UICCTextField::getAttachWithIME() bool UICCTextField::getAttachWithIME()const
{ {
return _attachWithIME; return _attachWithIME;
} }
@ -327,7 +327,7 @@ void UICCTextField::setDetachWithIME(bool detach)
_detachWithIME = detach; _detachWithIME = detach;
} }
bool UICCTextField::getDetachWithIME() bool UICCTextField::getDetachWithIME()const
{ {
return _detachWithIME; return _detachWithIME;
} }
@ -337,7 +337,7 @@ void UICCTextField::setInsertText(bool insert)
_insertText = insert; _insertText = insert;
} }
bool UICCTextField::getInsertText() bool UICCTextField::getInsertText()const
{ {
return _insertText; return _insertText;
} }
@ -347,7 +347,7 @@ void UICCTextField::setDeleteBackward(bool deleteBackward)
_deleteBackward = deleteBackward; _deleteBackward = deleteBackward;
} }
bool UICCTextField::getDeleteBackward() bool UICCTextField::getDeleteBackward()const
{ {
return _deleteBackward; return _deleteBackward;
} }
@ -455,7 +455,7 @@ bool TextField::hitTest(const Vec2 &pt)
return false; return false;
} }
Size TextField::getTouchSize() Size TextField::getTouchSize()const
{ {
return Size(_touchWidth, _touchHeight); return Size(_touchWidth, _touchHeight);
} }
@ -526,7 +526,7 @@ void TextField::setPlaceHolder(const std::string& value)
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
} }
const std::string& TextField::getPlaceHolder() const std::string& TextField::getPlaceHolder()const
{ {
return _textFieldRenderer->getPlaceHolder(); return _textFieldRenderer->getPlaceHolder();
} }
@ -538,7 +538,7 @@ void TextField::setFontSize(int size)
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
} }
int TextField::getFontSize() int TextField::getFontSize()const
{ {
return _textFieldRenderer->getSystemFontSize(); return _textFieldRenderer->getSystemFontSize();
} }
@ -550,7 +550,7 @@ void TextField::setFontName(const std::string& name)
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
} }
const std::string& TextField::getFontName() const std::string& TextField::getFontName()const
{ {
return _textFieldRenderer->getSystemFontName(); return _textFieldRenderer->getSystemFontName();
} }
@ -560,7 +560,7 @@ void TextField::didNotSelectSelf()
_textFieldRenderer->detachWithIME(); _textFieldRenderer->detachWithIME();
} }
const std::string& TextField::getStringValue() const std::string& TextField::getStringValue()const
{ {
return _textFieldRenderer->getString(); return _textFieldRenderer->getString();
} }
@ -580,7 +580,7 @@ void TextField::setMaxLengthEnabled(bool enable)
_textFieldRenderer->setMaxLengthEnabled(enable); _textFieldRenderer->setMaxLengthEnabled(enable);
} }
bool TextField::isMaxLengthEnabled() bool TextField::isMaxLengthEnabled()const
{ {
return _textFieldRenderer->isMaxLengthEnabled(); return _textFieldRenderer->isMaxLengthEnabled();
} }
@ -592,7 +592,7 @@ void TextField::setMaxLength(int length)
setText(getStringValue()); setText(getStringValue());
} }
int TextField::getMaxLength() int TextField::getMaxLength()const
{ {
return _textFieldRenderer->getMaxLength(); return _textFieldRenderer->getMaxLength();
} }
@ -602,7 +602,7 @@ void TextField::setPasswordEnabled(bool enable)
_textFieldRenderer->setPasswordEnabled(enable); _textFieldRenderer->setPasswordEnabled(enable);
} }
bool TextField::isPasswordEnabled() bool TextField::isPasswordEnabled()const
{ {
return _textFieldRenderer->isPasswordEnabled(); return _textFieldRenderer->isPasswordEnabled();
} }
@ -616,7 +616,7 @@ void TextField::setPasswordStyleText(const char *styleText)
setText(getStringValue()); setText(getStringValue());
} }
const char* TextField::getPasswordStyleText() const char* TextField::getPasswordStyleText()const
{ {
return _passwordStyleText.c_str(); return _passwordStyleText.c_str();
} }
@ -651,7 +651,7 @@ void TextField::update(float dt)
} }
} }
bool TextField::getAttachWithIME() bool TextField::getAttachWithIME()const
{ {
return _textFieldRenderer->getAttachWithIME(); return _textFieldRenderer->getAttachWithIME();
} }
@ -661,7 +661,7 @@ void TextField::setAttachWithIME(bool attach)
_textFieldRenderer->setAttachWithIME(attach); _textFieldRenderer->setAttachWithIME(attach);
} }
bool TextField::getDetachWithIME() bool TextField::getDetachWithIME()const
{ {
return _textFieldRenderer->getDetachWithIME(); return _textFieldRenderer->getDetachWithIME();
} }
@ -671,7 +671,7 @@ void TextField::setDetachWithIME(bool detach)
_textFieldRenderer->setDetachWithIME(detach); _textFieldRenderer->setDetachWithIME(detach);
} }
bool TextField::getInsertText() bool TextField::getInsertText()const
{ {
return _textFieldRenderer->getInsertText(); return _textFieldRenderer->getInsertText();
} }
@ -681,7 +681,7 @@ void TextField::setInsertText(bool insertText)
_textFieldRenderer->setInsertText(insertText); _textFieldRenderer->setInsertText(insertText);
} }
bool TextField::getDeleteBackward() bool TextField::getDeleteBackward()const
{ {
return _textFieldRenderer->getDeleteBackward(); return _textFieldRenderer->getDeleteBackward();
} }

View File

@ -59,22 +59,26 @@ public:
void closeIME(); void closeIME();
void setMaxLengthEnabled(bool enable); void setMaxLengthEnabled(bool enable);
bool isMaxLengthEnabled(); bool isMaxLengthEnabled()const;
void setMaxLength(int length); void setMaxLength(int length);
int getMaxLength(); int getMaxLength()const;
int getCharCount(); int getCharCount()const;
void setPasswordEnabled(bool enable); void setPasswordEnabled(bool enable);
bool isPasswordEnabled(); bool isPasswordEnabled()const;
void setPasswordStyleText(const std::string& styleText); void setPasswordStyleText(const std::string& styleText);
void setPasswordText(const std::string& text); void setPasswordText(const std::string& text);
void setAttachWithIME(bool attach); void setAttachWithIME(bool attach);
bool getAttachWithIME(); bool getAttachWithIME()const;
void setDetachWithIME(bool detach); void setDetachWithIME(bool detach);
bool getDetachWithIME(); bool getDetachWithIME()const;
void setInsertText(bool insert); void setInsertText(bool insert);
bool getInsertText(); bool getInsertText()const;
void setDeleteBackward(bool deleteBackward); void setDeleteBackward(bool deleteBackward);
bool getDeleteBackward(); bool getDeleteBackward()const;
protected: protected:
bool _maxLengthEnabled; bool _maxLengthEnabled;
int _maxLength; int _maxLength;
@ -123,36 +127,48 @@ public:
const std::string& fontName, const std::string& fontName,
int fontSize); int fontSize);
void setTouchSize(const Size &size); void setTouchSize(const Size &size);
Size getTouchSize(); Size getTouchSize()const;
void setTouchAreaEnabled(bool enable); void setTouchAreaEnabled(bool enable);
virtual bool hitTest(const Vec2 &pt); virtual bool hitTest(const Vec2 &pt);
void setText(const std::string& text);
void setPlaceHolder(const std::string& value); void setPlaceHolder(const std::string& value);
const std::string& getPlaceHolder(); const std::string& getPlaceHolder()const;
void setFontSize(int size); void setFontSize(int size);
int getFontSize(); int getFontSize()const;
void setFontName(const std::string& name); void setFontName(const std::string& name);
const std::string& getFontName(); const std::string& getFontName()const;
virtual void didNotSelectSelf(); virtual void didNotSelectSelf();
const std::string& getStringValue();
void setText(const std::string& text);
const std::string& getStringValue()const;
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
void setMaxLengthEnabled(bool enable); void setMaxLengthEnabled(bool enable);
bool isMaxLengthEnabled(); bool isMaxLengthEnabled()const;
void setMaxLength(int length); void setMaxLength(int length);
int getMaxLength(); int getMaxLength()const;
void setPasswordEnabled(bool enable); void setPasswordEnabled(bool enable);
bool isPasswordEnabled(); bool isPasswordEnabled()const;
void setPasswordStyleText(const char* styleText); void setPasswordStyleText(const char* styleText);
const char* getPasswordStyleText(); const char* getPasswordStyleText()const;
virtual void update(float dt) override; virtual void update(float dt) override;
bool getAttachWithIME();
bool getAttachWithIME()const;
void setAttachWithIME(bool attach); void setAttachWithIME(bool attach);
bool getDetachWithIME(); bool getDetachWithIME()const;
void setDetachWithIME(bool detach); void setDetachWithIME(bool detach);
bool getInsertText();
bool getInsertText()const;
void setInsertText(bool insertText); void setInsertText(bool insertText);
bool getDeleteBackward();
bool getDeleteBackward()const;
void setDeleteBackward(bool deleteBackward); void setDeleteBackward(bool deleteBackward);
CC_DEPRECATED_ATTRIBUTE void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor); CC_DEPRECATED_ATTRIBUTE void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor);
void addEventListener(const ccTextFieldCallback& callback); void addEventListener(const ccTextFieldCallback& callback);
@ -184,6 +200,7 @@ protected:
virtual void updateTextureOpacity() override; virtual void updateTextureOpacity() override;
virtual void updateTextureRGBA() override; virtual void updateTextureRGBA() override;
void textfieldRendererScaleChangedWithSize(); void textfieldRendererScaleChangedWithSize();
virtual Widget* createCloneInstance() override; virtual Widget* createCloneInstance() override;
virtual void copySpecialProperties(Widget* model) override; virtual void copySpecialProperties(Widget* model) override;
virtual void adaptRenderers() override; virtual void adaptRenderers() override;