/**
** 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/QLineEdit>
#include "UIGQWidgetBase.h"

namespace UIGQtLib
{
	class UIGQLineEditImpl;
	class UIGEARSQTLIB_EXPORT UIGQLineEdit : public QLineEdit, public IUIGQWidgetBase
	{
        Q_OBJECT

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

		UIG_QT_CTRL_DEF("qtdedit", UIGQLineEdit);

		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(UIGQtLib::CtrlState state, const TextStyleDesc& style);
		const TextStyleDesc& getPlaceholderTextStyle(UIGQtLib::CtrlState state);

		void setHotkeyMode(bool hotkeyMode);
		bool getHotkeyMode();

		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 setIsPassword(bool password);
		bool getIsPassword();

	protected:
		void keyPressEvent(QKeyEvent *event);
		void paintEvent(QPaintEvent * evt);

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

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

	private:
		UIGQLineEditImpl* _ctrlImpl;

		UIGQT_GET_CONTROLBASE;
	};
}
