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

namespace UIGQtLib
{
	class UIGQScrollBarImpl;
	class UIGEARSQTLIB_EXPORT UIGQScrollBar : public QScrollBar, public IUIGQWidgetBase
	{
        Q_OBJECT

	public:
		explicit UIGQScrollBar(QWidget *parent = Q_NULLPTR);
		explicit UIGQScrollBar(Qt::Orientation, QWidget *parent = Q_NULLPTR);
		~UIGQScrollBar();

		UIG_QT_CTRL_DEF("qtscrollbar", UIGQScrollBar);

		void setWidthHeight(int size);
		void setScrollbarBackground(CommonCtrlState state, const FillStyle& fillStyle);
		void setScrollbarUpButton(CtrlState state, const FillStyle& fillStyle);
		void setScrollbarDownButton(CtrlState state, const FillStyle& fillStyle);
		void setScrollbarThumb(CtrlState state, const FillStyle& fillStyle);
		void setScrollbarBtnIcon(bool isUpOrLeft, const QString& icon);
		void setScrollbarIconStyle(bool isUpOrLeft, const IconStyleDesc& style);
		void setScrollbarThumbIcon(const QString& thumb);

		int getWidthHeight();
		const FillStyle& getScrollbarBackground(CommonCtrlState state);
		const FillStyle& getScrollbarUpButton(CtrlState state);
		const FillStyle& getScrollbarDownButton(CtrlState state);
		const FillStyle& getScrollbarThumb(CtrlState state);
		const QString& getScrollbarBtnIcon(bool isUpOrLeft);
		const IconStyleDesc& getScrollbarIconStyle(bool isUpOrLeft);
		const QString& getScrollbarThumbIcon();
		void initStyleOption(QStyleOptionSlider *option);

	protected:
		void mousePressEvent(QMouseEvent *event);
		void mouseReleaseEvent(QMouseEvent *event);
		void leaveEvent(QEvent *event);
		void mouseMoveEvent(QMouseEvent *event);

	protected:
		void paintEvent(QPaintEvent * evt);
		QSize sizeHint() const;

	private:
		UIGQScrollBarImpl* _ctrlImpl;

		UIGQT_GET_CONTROLBASE;
	};
}

