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

#pragma once

#ifdef _MSC_VER
#include <QWidget>
#include <QVector>
#include <qglobal.h>
#else
#include <QtWidgets/QWidget>
#include <QtCore/QVector>
#include <QtCore/qglobal.h>
#endif


#include "UIGQWidgetBase.h"

namespace UIGQtLib
{
	struct UIGGlobalConfig
	{
		QString globalFontFamily;
		bool buttonFadeEnabled = false;
		int buttonFadeDuration = 150;
	};

	class UIGQContainer;
	class UIGQMenu;
	typedef QWidget* (*createControlFun)();
	typedef QWidget* (*customControlCreateFun)(const QString& name, const QString& type);

	UIGEARSQTLIB_EXPORT void init();
	UIGEARSQTLIB_EXPORT void initEx();
	UIGEARSQTLIB_EXPORT void initHttpServer(const QString& resPath);
	UIGEARSQTLIB_EXPORT bool init3DWidget(bool useOpenGLES = false);

	UIGEARSQTLIB_EXPORT void shutdown();

	UIGEARSQTLIB_EXPORT void uigInitQtControl();

	UIGEARSQTLIB_EXPORT QVector<ControlInfo*> uigGetAllControlInfo();
	UIGEARSQTLIB_EXPORT ControlInfo* uigGetControlInfo(const QString& name);

	UIGEARSQTLIB_EXPORT const QVector<FillStyle>& uigGetAllFillStyle();
	UIGEARSQTLIB_EXPORT const QVector<TextStyleDesc>& uigGetAllTextStyle();

	UIGEARSQTLIB_EXPORT QStyle* uigGetStyle();

	UIGEARSQTLIB_EXPORT bool uigLoadThemeFile(const char* path);
	UIGEARSQTLIB_EXPORT bool uigLoadThemeDir(const char* path);

	UIGEARSQTLIB_EXPORT bool uigLoadSkinFile(const QString& strinPath, float scaleFactor = 1.0);
	UIGEARSQTLIB_EXPORT bool uigSetSkinFilePath(const QString& filePath, float scaleFactor = 1.0);
	UIGEARSQTLIB_EXPORT bool uigSetProjectFilePath(const QString& filePath);

    UIGEARSQTLIB_EXPORT float uigGetScaleFactor();
	
	UIGEARSQTLIB_EXPORT void uigRegisterDefaultControl(const char* name, createControlFun pFun);
	UIGEARSQTLIB_EXPORT void uigRegisterQtControl(const char* name, createControlFun pFun, ControlInfo pInfo, bool supportTempCtrl = true);
	
	UIGEARSQTLIB_EXPORT QVector<PropertyDef>* uigGetPropFuns(const char* name);
	UIGEARSQTLIB_EXPORT void uigBindControlCreateFunction(customControlCreateFun pFun);

	UIGEARSQTLIB_EXPORT bool uigGetTextStyle(const QString& name, TextStyleDesc& style);
	UIGEARSQTLIB_EXPORT bool uigGetFillStyle(const QString& name, FillStyle& style);
	UIGEARSQTLIB_EXPORT void uigSetGlobalConfig(const UIGGlobalConfig& config);
	UIGEARSQTLIB_EXPORT const UIGGlobalConfig& uigGetGlobalConfig();
	UIGEARSQTLIB_EXPORT void uigSetGlobalFontFamily(const QString& fontFamily);
	UIGEARSQTLIB_EXPORT QString uigGetGlobalFontFamily();

	UIGEARSQTLIB_EXPORT void uigSetTextStyle(const QString& name, TextStyleDesc& style);
	UIGEARSQTLIB_EXPORT void uigSetFillStyle(const QString& name, FillStyle& style);

	UIGEARSQTLIB_EXPORT bool uigGetProjectTextStyle(const QString& name, TextStyleDesc& style);
	UIGEARSQTLIB_EXPORT bool uigGetProjectFillStyle(const QString& name, FillStyle& style);

	UIGEARSQTLIB_EXPORT void uigSetProjectTextStyle(const QString& name, TextStyleDesc& style);
	UIGEARSQTLIB_EXPORT void uigSetProjectFillStyle(const QString& name, FillStyle& style);

	UIGEARSQTLIB_EXPORT UIGQMenu* uigCreateMenuByFileName(QWidget* pMainWidget, QString pageFilePath);
	UIGEARSQTLIB_EXPORT UIGQContainer* uigCreatePageByFileName(QWidget* pMainWidget, QString pagePath);
	UIGEARSQTLIB_EXPORT bool uigIsQtEmulator();
    UIGEARSQTLIB_EXPORT bool uigIsInDesigner();
    UIGEARSQTLIB_EXPORT void uigSetIsInDesigner(bool isDesigner);

    UIGEARSQTLIB_EXPORT void uigEnableSerializeChild(bool enable);
    UIGEARSQTLIB_EXPORT bool uigIsSerializeChild();

    UIGEARSQTLIB_EXPORT bool uigNotifyThemeChange();

	//UIGEARSQTLIB_EXPORT QWidget* createSampleScene(QWidget* pParent);
}
