#pragma once


#include <QtSvg/QSvgRenderer>
#include <QtCore/qglobal.h>
#include <QtWidgets/QGraphicsView>
#include <QtWidgets/QGraphicsItem>
#include "UIGearsQtLib.h"

namespace UIGQtLib
{
	class UIGQScrollBar;
	class UIGQSvgItem;
	class UIGQSvgViewImpl;
	class UIGQSvgView : public QGraphicsView, public IUIGQWidgetBase
	{
		Q_OBJECT;
		
	public:
		UIGQSvgView(QWidget* pParent = nullptr);
		~UIGQSvgView();

		UIG_QT_CTRL_DEF("qtsvgview", UIGQSvgView);

		bool loadSvgFile(QString svgPath);

		void setBackgroundStyle(const FillStyle& fillStyle);
		const FillStyle& getBackgroundStyle();

		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 * evt);
		void resizeEvent(QResizeEvent * event);
		void wheelEvent(QWheelEvent *event);
		void setScale(int scale);
		void setScale(qreal scale);

	signals:
		void scaleChanged(int);

	private:
		double				_scale;
		UIGQSvgItem*		_svgItem;
		QGraphicsScene*		_scene;
		UIGQSvgViewImpl*	_ctrlImpl;
		UIGQScrollBar*				_horScrollBar;
		UIGQScrollBar*				_verScrollBar;

		UIGQT_GET_CONTROLBASE;
	};
}
