#pragma once

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

#define DEF_LV_ITEM_HEIGHT 20

namespace UIGQtLib
{
	class UIGQScrollBar;
	class UIGQListImpl;
	class UIGQListItemDelegate;

	class UIGEARSQTLIB_EXPORT UIGQList : public QListWidget, public IUIGQWidgetBase
	{
        Q_OBJECT

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

		UIG_QT_CTRL_DEF("qtlist", UIGQList);

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

		void setItemBackground(UIGQtLib::CtrlState state, const FillStyle& style);
		const FillStyle& getItemBackground(UIGQtLib::CtrlState state);

		void setItemTextStyle(UIGQtLib::CtrlState state, const TextStyleDesc& style);
		const TextStyleDesc& getItemTextStyle(UIGQtLib::CtrlState state);

		void setItemHeight(int height);
		int getItemHeight();

		void setIsMultiSelected(bool multiSelected);
		bool getIsMultiSelected();

		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 *e);
		bool eventFilter(QObject * watched, QEvent * event);

	private:
		UIGQListImpl*				_ctrlImpl;
		UIGQScrollBar*				_horScrollBar;
		UIGQScrollBar*				_verScrollBar;
		UIGQListItemDelegate*		_itemDelegate;

		UIGQT_GET_CONTROLBASE;
	};
}
