/**
** This file is owned by VisualGear Technology Co., Ltd.
** Unauthorized copying of this file, via any medium is strictly prohibited
** Otherwise VisualGear Technology Co., Ltd. will have the right to pursue
** maximum responsibilities within scope of legal.
**
** Copyright 2018-2020 VisualGear All rights reserved.
**/

#pragma once

#include <QtWidgets/QTextEdit>
#include "UIGQWidgetBase.h"
#include "UIGQScrollBar.h"

namespace UIGQtLib
{
	class UIGQTextEditImpl;
	class UIGEARSQTLIB_EXPORT UIGQTextEdit : public QTextEdit, public IUIGQWidgetBase
	{
        Q_OBJECT

	public:
		UIGQTextEdit(QWidget* pParent = nullptr);
		~UIGQTextEdit();

		UIG_QT_CTRL_DEF("qttext", UIGQTextEdit);

		void setBackground(UIGQtLib::CtrlState state, const FillStyle& style);
		const FillStyle& getBackground(UIGQtLib::CtrlState state);

		void setTextStyle(UIGQtLib::CtrlState state, const TextStyleDesc& style);
		const TextStyleDesc& getTextStyle(UIGQtLib::CtrlState state);

		void setPlaceholderTextStyle(const TextStyleDesc& style);
		const TextStyleDesc& getPlaceholderTextStyle();

		void setPlaceholderText(const QString& text);
		const QString& getPlaceholderText();

		void setEditMargin(int up, int down, int left, int right);
		void getEditMargin(int& up, int& down, int& left, int& right);

		void setScrollbarBtnSize(bool isHorizontalScrollbar, int size);
		void setScrollbarSize(bool isHorizontalScrollbar, int size);
		void setScrollbarBackgroundStyle(bool isHorizontalScrollbar, const FillStyle& background);
		void setScrollbarThumbStyle(bool isHorizontalScrollbar, CtrlState state, const FillStyle& style);
		void setScrollbarButtonStyle(bool isHorizontalScrollbar, bool isUp, CtrlState state, const FillStyle& style);
		void setScrollbarButtonIcon(bool isHorizontalScrollbar, bool isUpOrLeft, const QString& iconPath);
		void setScrollbarButtonIconStyle(bool isHorizontalScrollbar, bool isUpOrLeft, const IconStyleDesc& style);
		void setScrollbarThumb(bool isHorizontalScrollbar, const QString& thumb);

	protected:
		void paintEvent(QPaintEvent * evt);

		void enterEvent(QEvent *event);
		void leaveEvent(QEvent *event);

		void focusInEvent(QFocusEvent *);
		void focusOutEvent(QFocusEvent *);

		bool eventFilter(QObject * pObj, QEvent * pEvent);
			
	private:
		UIGQTextEditImpl*			_ctrlImpl;
		UIGQScrollBar*				_horScrollBar;
		UIGQScrollBar*				_verScrollBar;

		UIGQT_GET_CONTROLBASE;
	};
}
