UIEditBoxImpl-tizen.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2012 James Chen
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __UIEDITBOXIMPLTIZEN_H__
  23. #define __UIEDITBOXIMPLTIZEN_H__
  24. #include "platform/CCPlatformConfig.h"
  25. #if (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
  26. #include "ui/UIEditBox/UIEditBoxImpl.h"
  27. #include "platform/CCGLView.h"
  28. NS_CC_BEGIN
  29. class Label;
  30. namespace ui {
  31. class EditBox;
  32. class EditBoxImplTizen : public EditBoxImpl
  33. {
  34. public:
  35. /**
  36. * @js NA
  37. */
  38. EditBoxImplTizen(EditBox* pEditText);
  39. /**
  40. * @js NA
  41. * @lua NA
  42. */
  43. virtual ~EditBoxImplTizen();
  44. virtual void draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) {};
  45. virtual bool initWithSize(const Size& size);
  46. virtual void setFont(const char* pFontName, int fontSize);
  47. virtual void setFontColor(const Color4B& color);
  48. virtual void setPlaceholderFont(const char* pFontName, int fontSize);
  49. virtual void setPlaceholderFontColor(const Color4B& color);
  50. virtual void setInputMode(EditBox::InputMode inputMode);
  51. virtual void setInputFlag(EditBox::InputFlag inputFlag);
  52. virtual void setMaxLength(int maxLength);
  53. virtual void setTextHorizontalAlignment(TextHAlignment alignment) { _alignment = alignment; };
  54. virtual int getMaxLength();
  55. virtual void setReturnType(EditBox::KeyboardReturnType returnType);
  56. virtual bool isEditing();
  57. virtual void setText(const char* pText);
  58. virtual const char* getText(void);
  59. virtual void setPlaceHolder(const char* pText);
  60. virtual const char* getPlaceHolder(void);
  61. virtual const char* getFontName() override { return _fontName.c_str(); }
  62. virtual int getFontSize() override { return _fontSize; }
  63. virtual const Color4B& getFontColor() override { return _colText; }
  64. virtual const char* getPlaceholderFontName() override { return _placeholderFontName.c_str(); }
  65. virtual int getPlaceholderFontSize() override { return _placeholderFontSize; }
  66. virtual const Color4B& getPlaceholderFontColor() override { return _colPlaceHolder; }
  67. virtual EditBox::InputMode getInputMode() override { return _editBoxInputMode; }
  68. virtual EditBox::InputFlag getInputFlag() override { return _editBoxInputFlag; }
  69. virtual EditBox::KeyboardReturnType getReturnType() override { return _keyboardReturnType; }
  70. virtual TextHAlignment getTextHorizontalAlignment() override { return _alignment; }
  71. virtual void setPosition(const Vec2& pos);
  72. virtual void setVisible(bool visible);
  73. virtual void setContentSize(const Size& size);
  74. virtual void setAnchorPoint(const Vec2& anchorPoint);
  75. /**
  76. * @js NA
  77. * @lua NA
  78. */
  79. virtual void visit(void);
  80. /**
  81. * @js NA
  82. * @lua NA
  83. */
  84. virtual void onEnter(void);
  85. virtual void doAnimationWhenKeyboardMove(float duration, float distance);
  86. virtual void openKeyboard();
  87. virtual void closeKeyboard();
  88. private:
  89. Label* _label;
  90. Label* _labelPlaceHolder;
  91. EditBox::InputMode _editBoxInputMode;
  92. EditBox::InputFlag _editBoxInputFlag;
  93. EditBox::KeyboardReturnType _keyboardReturnType;
  94. TextHAlignment _alignment;
  95. std::string _text;
  96. std::string _placeHolder;
  97. std::string _fontName;
  98. std::string _placeholderFontName;
  99. int _fontSize;
  100. int _placeholderFontSize;
  101. Color4B _colText;
  102. Color4B _colPlaceHolder;
  103. int _maxLength;
  104. Size _editSize;
  105. };
  106. }
  107. NS_CC_END
  108. #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) */
  109. #endif /* __UIEDITBOXIMPLTIZEN_H__ */