/**
** 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-2026 VisualGear All rights reserved.
**/

#pragma once

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

namespace UIGQtLib
{
	class UIGQStackContainerImpl;

	class UIGEARSQTLIB_EXPORT UIGQStackContainer : public QWidget, public IUIGQWidgetBase
	{
		Q_OBJECT

	public:
		explicit UIGQStackContainer(QWidget* parent = nullptr);
		~UIGQStackContainer();

		UIG_QT_CTRL_DEF("qtstackcontainer", UIGQStackContainer);

		void setBackgroundState(CtrlState state, const FillStyle& color);
		const FillStyle& getBackgroundState(CtrlState state);

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

		void setDisableBackground(const FillStyle& color);
		const FillStyle& getDisableBackground();

		void setDrawBackground(bool drawBackground);
		bool getDrawBackground();

		int addWidget(QWidget* widget);
		int insertWidget(int index, QWidget* widget);
		void removeWidget(QWidget* widget);
		QWidget* widget(int index) const;
		int count() const;

		void setCurrentIndex(int index);
		int currentIndex() const;
		void setCurrentWidget(QWidget* widget);
		QWidget* currentWidget() const;

	protected:
		void paintEvent(QPaintEvent* evt) override;
		void resizeEvent(QResizeEvent* evt) override;
		bool event(QEvent* evt) override;
		bool eventFilter(QObject* watched, QEvent* evt) override;

	private:
		void updatePageGeometry(QWidget* page);
		void refreshCurrentPage();

		UIGQStackContainerImpl* _ctrlImpl;

		UIGQT_GET_CONTROLBASE;
	};
}
