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

#define UIG_DEFAULT_TAB_ITENSIZE 50

namespace UIGQtLib
{
	class UIGQTabWidgetImpl;
	class UIGEARSQTLIB_EXPORT UIGQTabWidget : public QWidget, public IUIGQWidgetBase
	{
		Q_OBJECT;
	public:
		enum TabDirection
		{
			kDirHorizontal = 0,
			kDirVertical
		};

		explicit UIGQTabWidget(QWidget *parent = Q_NULLPTR);
		~UIGQTabWidget();

		UIG_QT_CTRL_DEF("qttab", UIGQTabWidget);

		void addTab(const QString& itemName, const QString& icon = QString(), const QString& iconSelected = QString());
		QVariant getItemData(int index);
		bool setItemData(int index, QVariant data);

		int getTabCount();
		QString getTabText(int index);
		void removeTab(int index);
		void removeAllTab();
		void clear();
		
		void setItemSpace(int space);
		int getItemSpace();
		
		void setItemSize(int size);
		int getItemSize();

		void setBackground(const FillStyle& style);
		const FillStyle& getBackground();

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

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

		void setSelectedIndex(int selectedIdx);
		int getSelectedIndex();

		void setIsHor(bool bIsHor);
		bool getIsHor();

		void initDemoData();

		void setShowText(bool bShow);
		bool getShowText();

		void setShowIcon(bool bShow);
		bool getShowIcon();

	Q_SIGNALS:
		void currentChanged(int index);

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

	private:
		UIGQTabWidgetImpl* _ctrlImpl;

		UIGQT_GET_CONTROLBASE;
	};
}

