ZKButton.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * ZKButton.h
  3. *
  4. * Created on: Jun 10, 2017
  5. * Author: guoxs
  6. */
  7. #ifndef _CONTROL_ZKBUTTON_H_
  8. #define _CONTROL_ZKBUTTON_H_
  9. #include "ZKTextView.h"
  10. class ZKButtonPrivate;
  11. /**
  12. * @brief 按钮控件
  13. */
  14. class ZKButton : public ZKTextView {
  15. ZK_DECLARE_PRIVATE(ZKButton)
  16. public:
  17. ZKButton(ZKBase *pParent);
  18. virtual ~ZKButton();
  19. /**
  20. * @brief 设置状态背景图
  21. * @param status 状态
  22. * 正常状态: ZK_CONTROL_STATUS_NORMAL
  23. * 按下状态: ZK_CONTROL_STATUS_PRESSED
  24. * 选中状态: ZK_CONTROL_STATUS_SELECTED
  25. * 选中按下状态: ZK_CONTROL_STATUS_PRESSED | ZK_CONTROL_STATUS_SELECTED
  26. * 无效状态: ZK_CONTROL_STATUS_INVALID
  27. * @param pPicPath 图片路径
  28. */
  29. void setButtonStatusPic(int status, const char *pPicPath);
  30. /**
  31. * @brief 设置图标位置
  32. * @param position 位置
  33. */
  34. void setIconPosition(const LayoutPosition &position);
  35. protected:
  36. ZKButton(ZKBase *pParent, ZKBasePrivate *pBP);
  37. virtual void onBeforeCreateWindow(const Json::Value &json);
  38. virtual const char* getClassName() const { return ZK_BUTTON; }
  39. virtual void onDraw(ZKCanvas *pCanvas);
  40. private:
  41. void parseButtonAttributeFromJson(const Json::Value &json);
  42. };
  43. #endif /* _CONTROL_ZKBUTTON_H_ */