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

namespace UIGQtLib
{
	class UIGQScrollViewImpl;
	class UIGEARSQTLIB_EXPORT UIGQScrollView : public QScrollArea, public IUIGQWidgetBase
	{
        Q_OBJECT
	public:
		UIGQScrollView(QWidget* pParent = nullptr);
		~UIGQScrollView();

		UIG_QT_CTRL_DEF("qtscrollview", UIGQScrollView);
	
		void setBackground(CommonCtrlState state, const FillStyle& style);
		const FillStyle& getBackground(CommonCtrlState state);

		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);
		int getVScrollPos();
		void setVScrollPos(int pos);
		int getHScrollPos();
		void setHScrollPos(int pos);

	Q_SIGNALS:
		void scrollPosChanged(int dx, int dy);

	protected:
		void scrollContentsBy(int dx, int dy);
		void paintEvent(QPaintEvent * evt);
		void resizeEvent(QResizeEvent* evt);
		bool eventFilter(QObject * watched, QEvent * event);

	protected:
		UIGQScrollBar*		_verScrollBar;
		UIGQScrollBar*		_horScrollBar;
		UIGQScrollViewImpl* _ctrlImpl;
		QWidget*			_container;

		UIGQT_GET_CONTROLBASE;
	};
}
