#pragma once

#include <QtWidgets/QLabel>
#include "UIGQWidgetBase.h"

#define DEF_SWITCH_MARGIN 2
#define DEF_SWITCH_THUMB_W	25
#define DEF_SWITCH_THUMB_H	25
#define UIG_SWITCH_SPEED 300

namespace UIGQtLib
{
	class UIGQSwitchImpl;
	class UIGEARSQTLIB_EXPORT UIGQSwitch : public QWidget, public IUIGQWidgetBase
	{
        Q_OBJECT

	public:
		enum SwitchPosition
		{
			kPosLeft = 0,
			kPosRight
		};


		UIGQSwitch(QWidget* pParent = nullptr);
		~UIGQSwitch();

		UIG_QT_CTRL_DEF("qtswitch", UIGQSwitch);

		void setLeftText(const QString& text);
		const QString& getLeftText();
		void setRightText(const QString& text);
		const QString& getRightText();

		void setBackgroundStyle(CommonCtrlState state, const FillStyle& style);
		const FillStyle& getBackgroundStyle(CommonCtrlState state);

		void setThumbStyle(CtrlState state, const FillStyle& style);
		const FillStyle& getThumbStyle(CtrlState state);

		void setShowAllText(bool bShow);
		bool getShowAllText();

		void setMargin(int size);
		int getMargin();
		
		void setThumbBtnSize(const QSize& size);
		const QSize& getThumbBtnSize();

		void setThumbSize(int w, int h);
		void getThumbSize(int& w, int& h);

		void setSwitchSpeed(unsigned int speed);
		unsigned int getSwitchSpeed();

		void setSwitchToLeft(bool toLeft);
		bool getIsSwitchToLeft();

		void setTextStyle(SwitchPosition isLeft, const TextStyleDesc& textStyle);
		const TextStyleDesc& getTextStyle(SwitchPosition isLeft);

	protected:
		void paintEvent(QPaintEvent * evt);
		
		void mousePressEvent(QMouseEvent *event);
		void mouseReleaseEvent(QMouseEvent *event);
		void enterEvent(QEvent *event);
		void leaveEvent(QEvent *event);

	private:
		UIGQSwitchImpl* _ctrlImpl;

		UIGQT_GET_CONTROLBASE;
	};
}
