/**
** 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.
**/


#ifndef _UIGQT_INC_MACRO_H_H
#define _UIGQT_INC_MACRO_H_H

#ifndef BUILD_STATIC
# if defined(UIGEARSQTLIB_LIB)
#  define UIGEARSQTLIB_EXPORT Q_DECL_EXPORT
# else
#  define UIGEARSQTLIB_EXPORT Q_DECL_IMPORT
# endif
#else
# define UIGEARSQTLIB_EXPORT
#endif

#define UIG_QT_STYLE_FILE "style.json"
#define UIG_QT_LANGUAGE_FILE "language.txt"

#define KEY_WORD_MARK "|->"
#define WKEY_WORD_MARK L"|->"
#define KEY_WORD_MARK_SIZE 3

#define UIG_QT_EMPTY_STYLE "empty"

#define DEF_FOCUS_BORDER_COLOR 0xff3399ff

#define RES_JSON "json"
#define RES_PNG "PNG"
#define WindowTypeName ("Window")

// element base
#define ELEMENTS_KEY "elements"
#define ELEMENTS_NAME "name"
#define ELEMENTS_TYPE "type"
#define ELEMENTS_CHILD "child"
#define ELEMENTS_STYLE "style"
#define ELEMENTS_LAYOUT "layout"
#define ELEMENTS_VISIBLE "visibility"
#define ELEMENTS_MARK_DELETE "MarkDelete"
#define ELEMENTS_ENABLE "enable"
#define ELEMENTS_ALPHA "alpha"
#define ELEMENTS_THEME "theme"

#define IS_VISIBLE(pWidget) pWidget->property(ELEMENTS_VISIBLE).toBool() 
#ifndef SET_VISIBLE
#define SET_VISIBLE(pWidget, visible) pWidget->setProperty(ELEMENTS_VISIBLE, visible);pWidget->setVisible(false)
#endif

#define IS_DELETE(pWidget) pWidget->property(ELEMENTS_MARK_DELETE).toBool() 
#define SET_DELETE(pWidget, visible) pWidget->setProperty(ELEMENTS_MARK_DELETE, visible);

// mobile
#define ELEMENTS_MOBILE_DEVICETYPE "deviceType"
#define ELEMENTS_MOBILE_ORIENTATION "orientation"
#define ELEMENTS_MOBILE_IS_ITEMTEMP "itemTemp"
#define ELEMENTS_MOBILE_ITEMHEIGHT "itemHeight"

// layout base
#define LAYOUT_TYPE "type"


// percentage layout
#define PERCENT_X "x"
#define PERCENT_X_TYPE "xoffset"
#define PERCENT_Y "y"
#define PERCENT_Y_TYPE "yoffset"
#define PERCENT_W "w"
#define PERCENT_H "h"

// dock layout
/*
"layout": {
"type": 0,
"hor" : 2,
"ver" : 0,
"x" : 0,
"y" : 0
}
*/
#define DOCK_X "x"
#define DOCK_Y "y"
#define DOCK_R "r"
#define DOCK_B "b"
#define DOCK_HOR "hor"
#define DOCK_VER "ver"
#define DOCK_HOR_SIZETYPE "wType"
#define DOCK_VER_SIZETYPE "hType"
#define LAYOUT_RATIO "ratio"

// fill layout
#define FILL_X "x"
#define FILL_Y "y"
#define FILL_R "r"
#define FILL_B "b"

// style base
#define STYLE_KEY "style"
#define STYLE_TYPE "type"
#define STYLE_NAME "name"

// style
#define DEFAULT_STYLE_NAME "defaultStyle"

/*
{
"type": 1,
"name" : "background",
"fill" : 1,
"clr" : "fffafafa",
"border" : 1,
"borderClr" : "ffc5c9ca",
"img":"XX.png"
}
*/
// rect style
#define STYLE_RECT_CLR "clr"
#define STYLE_RECT_IMG "img"
#define STYLE_RECT_ISFILL "fill"
#define STYLE_RECT_MAGIN "margin"
#define	STYLE_RECT_SOURCE "source"
#define STYLE_RECT_DRAW_BORDER "border"
#define STYLE_RECT_BORDER_SIZE "borderSize"
#define STYLE_RECT_BORDER_CLR "borderclr"
#define STYLE_RECT_DARW_IMAGE "drawImg"
#define STYLE_RECT_CENTERIMG "centerImg"
#define STYLE_RECT_SHAPE "shape"
#define STYLE_RECT_ROUND "round"
#define STYLE_RECT_ROUND_TOP_LEFT "roundTopLeft"
#define STYLE_RECT_ROUND_TOP_RIGHT "roundTopRight"
#define STYLE_RECT_ROUND_BOTTOM_RIGHT "roundBottomRight"
#define STYLE_RECT_ROUND_BOTTOM_LEFT "roundBottomLeft"
#define STYLE_RECT_LEFT "leftBorder"
#define STYLE_RECT_TOP "topBorder"
#define STYLE_RECT_RIGHT "rightBorder"
#define STYLE_RECT_BOTTOM "bottomBorder"
#define STYLE_RECT_REPEAT_LEFT "repeatLeft"
#define STYLE_RECT_REPEAT_TOP "repeatTop"
#define STYLE_RECT_REPEAT_RIGHT "repeatRight"
#define STYLE_RECT_REPEAT_BOTTOM "repeatBottom"
#define STYLE_RECT_REPEAT_CENTER "repeatCenter"


// font style
#define DEFAULT_FONT_FAMILY "΢���ź�"
#define DEFAULT_FONT_SIZE	12
#define DEFAULT_FONT_COLOR 0xff000000
#define ELEMENT_FONT_FAMILY "family"
#define ELEMENT_FONT_SIZE "size"
#define ELEMENT_TEXT_STRING	"text"
#define ELEMENT_TEXT_HOR	"hor"
#define ELEMENT_TEXT_VER	"ver"
#define ELEMENT_TEXT_CLR	"clr"
#define ELEMENT_TEXT_OFFSETX	"x"
#define ELEMENT_TEXT_OFFSETY	"y"
#define ELEMENT_TEXT_BOLD		"bold"
#define ELEMENT_TEXT_UNDERLINE	"underline"
#define ELEMENT_TEXT_ITALIC		"italic"
#define ELEMENT_TEXT_SINGLELINE		"singleline"
#define ELEMENT_TEXT_IS_HOR		"isHor"


// image style
#define STYLE_IMG_ISICON	"isIcon"
#define STYLE_IMG_ISFILL	"isFill"
#define STYLE_IMG_PATH	"img"

// rect element
#define ELEMENT_RECT_X "x"
#define ELEMENT_RECT_Y "y"
#define ELEMENT_RECT_W "w"
#define ELEMENT_RECT_H "h"

// control
#define ELEMENT_CTRL_X "x"
#define ELEMENT_CTRL_Y "y"
#define ELEMENT_CTRL_W "w"
#define ELEMENT_CTRL_H "h"
#define ELEMENT_MOUSE_EVENT "handleMouse"
#define ELEMENT_CTRL_TOOLTIP "tooltip"

// event
#define EVENT_ENABLE  "evtEnable"
#define EVENT_NAME	"evtName"
#define EVENT_FUN	"eveFun"

// container
#define CONTAINTER_CHILD_LAYOUT "childLayout"
#define CONTAINTER_CHILD_LAYOUT_SPACE "space"
#define CONTAINTER_CHILD_PADDING_LEFT "paddingLeft"
#define CONTAINTER_CHILD_PADDING_TOP "paddingTop"
#define CONTAINTER_CHILD_PADDING_RIGHT "paddingRight"
#define CONTAINTER_CHILD_PADDING_BOTTOM "paddingBottom"
#define CONTAINTER_ABSOLUTE_DOCK_AUTO_SIZE "absoluteDockAutoSize"
#define CONTAINTER_NEED_CLICK "needClick"

// button
#define BTN_ATTR_HASICON "hasIcon"
#define BTN_SHOW_TEXT	"showText"
#define BTN_ICON_X		"iconX"
#define BTN_ICON_Y		"iconY"
#define BTN_TEXT_X		"txtX"
#define BTN_TEXT_Y		"txtY"
#define BTN_TEXT_STR	"text"
#define BTN_ICON_PATH	"iconPath"
#define BTN_HOTICON_PATH	"hotIconPath"
#define BTN_ICON_VER	"iconVer"
#define BTN_ICON_HOR	"iconHor"
#define BTN_ICON_USE_COLOR	"iconUseColor"
#define BTN_ICON_COLOR	"iconColor"
#define BTN_FADE_ENABLED	"fadeEnabled"
#define BTN_FADE_DURATION	"fadeDuration"
#define BTN_TEXT_CENTER "centerText"
#define BTN_EXT_HOT_ICON	"extHotIconPath"
#define BTN_EXT_ICON		"extIconPath" 
#define BTN_EXT_WIDTH		"extWidth"
#define BTN_IS_EXT_BTN		"isExtBtn"


// mobile
#define BTN_TEXT_COLOR	"textColor"
#define BTN_TEXT_SIZE	"textSize"
#define BTN_BACKGROUND	"background"

// groupbox
#define GB_SHOW_TEXT	"showText"
#define GB_TEXT_STR		"text"
#define GB_LINE_SIZE	"size"
#define GB_LINE_OFFSET	"offset"
#define GB_LINE_COLOR	"color"
#define GB_TEXT_POS		"pos"

// label
#define LABEL_TEXT		"text"
#define LABEL_SINGLELINE	"singleline"
#define LABEL_LCD			"lcd"
// mobile
#define LABEL_COLOR			"clr"

// lcd
#define LCD_TEXT	"text"
#define LCD_COLOR	"color"
#define LCD_DIGIT_COUNT	"digitCount"

// picture
#define PICTURE_IMAGE_PATH  "path"
#define PICTURE_FILL		"fill"
#define PICTURE_SVG_PATH	"svgPath"
#define PICTURE_SVG_USE_COLOR	"svgUseColor"
#define PICTURE_SVG_COLOR	"svgColor"

// checkbox
#define CHECKBOX_SHOW_TEXT				"showText"
#define CHECKBOX_SHOW_ICON				"showIcon"
#define CHECKBOX_TEXT					"text"
#define CHECKBOX_ICON_XOFFSET			"iconX"
#define CHECKBOX_ICON_YOFFSET			"iconY"
#define CHECKBOX_ICON_PATH				"iconPath"
#define CHECKBOX_HOTICON_PATH			"hotIconPath"
#define CHECKBOX_CHECKED_ICON_PATH		"siconPath"	
#define CHECKBOX_CHECKED_HOTICON_PATH	"sHotIconPath"
#define CHECKBOX_DISABLE_ICON_PATH		"disableIconPath"
#define CHECKBOX_CHECKED_DISABLE_ICON_PATH		"disableSIconPath"
#define CHECKBOX_ICON_VER				"iconVer"
#define CHECKBOX_ICON_HOR				"iconHor"
#define CHECKBOX_ALIGN_TEXT_TOLEFT		"alignTextLeft"
#define CHECKBOX_PUSHLIKE				"pushlike"

// radiobox
#define RADIOBOX_ID				"id"

// slider
#define SLIDER_IS_HOR		"isHor"
#define SLIDER_THUMN_W		"thumbW"
#define SLIDER_THUMN_H		"thumbH"
#define SLIDER_CHANNEL_SIZE	"channelSize"
#define SLIDER_MIN			"min"
#define SLIDER_MAX			"max"
#define SLIDER_VALUE		"val"

// progress
#define PROGRESS_FRONT_CLIP "frontClip"
#define PROGRESS_SHOW_TEXT "showText"

// scroll
#define	SCROLL_BTN_SIZE		"size"
#define SCROLL_IS_HOR		"hor"
#define SCROLL_UPBTN_ICON	"upicon"
#define SCROLL_DOWNBTN_ICON	"downicon"
#define SCROLL_THUMB_ICON	"thumbicon"


// list
#define LIST_ITEM_HEIGHT		"itemHeight"
#define LIST_ITEM_DRAWBORDER	"border"
#define LIST_ITEM_BORDERCLR		"borderClr"
#define LIST_ITEM_BORDERSIZE	"borderSize"
#define LIST_HASICON			"hasIcon"
#define LIST_ICON_OFFSET		"iconOffset"
#define LIST_CAN_CANCELSEL		"canCancelSel"
#define LIST_MULTI_SELECT		"multiselect"
#define LIST_DRAG_SELECT		"dragselect"
#define LIST_DRAG_ITEM			"dragItem"
#define LIST_EDITABLE			"editable"
#define LIST_MODE				"itemMode"
#define	LIST_ITEM_WIDTH			"itemWidth"
#define LIST_CHECKBOX_STYLE		"checkstyle"
#define LIST_CHECKED_IMAGE		"checkedImg"
#define LIST_UNCHECK_IMAGE		"uncheckImg"
#define LIST_ITEM_SPACING		"spacing"

// menulist
#define MENULIST_ARRAW_ICON		"arrawIcon"

// teamplateList
#define TEMPLATE_LIST_ITEM_TEMP "template"

// combo
#define COMBO_LIST_NAME "list"
#define COMBO_SCROLL_NAME "scroll"
#define COMBO_LIST_CONTAINER_NAME	"background"
#define COMBOBOX_LIST_DATA "data"
#define COMBOX_TEXT_ELE	"text"
#define COMBOBOX_SELECTED "selected"
#define COMBOBOX_ITEM_HEIGHT "itemHeight"
#define COMBOBOX_TEXT "text"
#define COMBOBOX_EDITABLE "editable"
#define COMBOBOX_BTN_ICON "btnIcon"
#define COMBOBOX_BTN_HOT_ICON "btnHotIcon"

// popupmenu
#define MENU_ID				"id"
#define MENU_TEXT			"text"
#define MENU_TYPE			"type"
#define MENU_ICON			"icon"
#define MENU_SUBMENU		"submenu"
#define MENU_ITEMS			"items"
#define MENU_SHORTCUT		"shortcut"
#define MENU_GROUPID		"groupid"

// menubar
#define UIGQtLib_POPUPMENU_WINDOW			("UIGQtLib_POPUPMENU_WINDOW")
#define UIGQtLib_COMBOMENU_WINDOW			("UIGQtLib_COMBOMENU_WINDOW")
#define UIGQtLib_SUB_POPUPMENU_WINDOW			("UIGQtLib_SUB_POPUPMENU_WINDOW")
#define MENU_RIGHT_SPACE					40
#define MENU_LEFT_ICON_SPACE				30

// tab
#define TAB_ITEMS			"items"
#define TAB_ICONS			"icons"
#define	TAB_ICONS_SELECTED	"iconSelected"
#define TAB_ITEM_SIZE		"itemSize"
#define TAB_IS_HOR			"isHor"
#define TAB_ITEM_SPACE		"itemSpace"
#define TAB_SHOW_TEXT		"showText"
#define TAB_HAS_ICON		"hasIcon"
#define TAB_ICON_X			"iconX"
#define TAB_ICON_Y			"iconY"
#define TAB_ICON_PATH		"iconPath"
#define TAB_ICON_VER		"iconVer"
#define TAB_ICON_HOR		"iconHor"

// menu bar
#define MENUBAR_BIND_MENU	"bindMenu"

// edit
// dedit
#define EDIT_TEXT			"text"
#define EDIT_PASSWORDCHAR	"passwordchar"
#define EDIT_ISPASSWORD		"ispassord"
#define EDIT_ISNUMBERONLY	"numberOnly"
#define EDIT_MAXNUM			"max"
#define EDIT_MINNUM			"min"
#define EDIT_NUMCOUNT		"numCount"
#define EDIT_DIGITNUMCOUNT	"digitNumCount"
#define EDIT_HASNEGATIVE	"hasNegative"
#define EDIT_LEFT_MARGIN	"leftMargin"
#define EDIT_RIGHT_MARGIN	"rightMargin"
#define EDIT_FONT_SIZE		"size"
#define EDIT_FONT_FAMILY	"family"
#define EDIT_TIP_TEXT		"tip"
#define EDIT_TXT_COLOR		"clr"
#define EDIT_TXT_DISCOLOR	"disClr"
#define EDIT_TIP_COLOR		"tipClr"
#define EDIT_IS_SHORTCUT	"shortcut"
#define EDIT_IS_READONLY	"readonly"
#define EDIT_IS_AUTOLOSTFOCUS	"autoLostFocus"
#define EDIT_IS_MULTIEDIT		"multi"
#define EDIT_LEFT_MARGIN		"leftMargin"
#define EDIT_RIGHT_MARGIN		"rightMargin"
#define EDIT_BOTTOM_MARGIN		"bottomMargin"
#define EDIT_TOP_MARGIN		"topMargin"


// datagrid
#define DATAGRID_MODE			"mode"
#define DATAGRID_HEADER_HEIGHT	"headerHeight"
#define DATAGRID_DRAW_VERGIRDLINE	"vline"
#define DATAGRID_DRAW_HORGIRDLINE	"hline"

// tree
#define	TREE_ITEM_OFFSET		"itemOffset"
#define	TREE_EXPAND_ICON		"expand"
#define	TREE_UNEXPAND_ICON		"unexpand"
#define	TREE_SHOW_ICON			"showIcon"
#define TREE_ICON_WIDTH			"iconWidth"
#define	TREE_SHOW_CHECKBOX		"showCheck"
#define	TREE_CHECK_ICON			"check"
#define	TREE_UNCHECK_ICON		"uncheck"
#define TREE_HALFCHECK_ICON		"half"
#define TREE_SHOW_HALF_CHECK	"showHalf"

// splitter
#define SPLITTER_LEFTTOP		"leftTop"
#define SPLITTER_RIGHTBOTTOM	"rightBottom"
#define SPLITTER_LIMITLEFTOP	"limitLeftTop"
#define SPLITTER_LIMITRIGHTBOTTOM "limitRightBottom"

// switch
#define SWITCH_LEFT_TEXT  "leftText"
#define SWITCH_RIGHT_TEXT "rightText"
#define SWITCH_THUMB_W "thumbW"
#define SWITCH_THUMB_H "thumbH"
#define SWITCH_MARGIN "margin"
#define SWITCH_SPEED "speed"
#define SWITCH_ON "on"

// webview
#define WEBVIEW_URL "url"

// tooltip
#define UIGQtLib_TOOLTIP_WINDOW			("UIGQtLib_TOOLTIP_WINDOW")


#define SAFE_DELETE(x) \
if (x) \
{ \
	delete x; \
	x = NULL; \
}

#define HAS_KEY(k) value.hasKey(k)
#define GET_JSON_BOOL(k) (value.hasKey(k)?value[k].asBool():false)
#define GET_JSON_BOOL_DEFVALUE(k, v) (value.hasKey(k)?value[k].asBool():v)
#define GET_JSON_UINT(k) (value.hasKey(k)?value[k].asUInt():0)
#define GET_JSON_STRING(k) (value.hasKey(k)?value[k].asString():"")
#define GET_JSON_INT(k) (value.hasKey(k)?value[k].asInt():0)
#define GET_JSON_INT_ARRAY(v,k) \
		if (value.hasKey(k)) \
		{ \
			Json::Value& arr = value[k]; \
			s32 size = value[k].size(); \
			for (s32 i = 0; i < size; ++i) \
			{ \
				v.push_back(arr[i].asUInt()); \
			} \
		} \

#define IS_HIT_IN_RECT (x > 0 && y > 0 && x < _w && y < _h)

#define IS_NOT_PRESEED _state != UI_PRESSED
#define SET_PRESSED	_state = UI_PRESSED

#define IS_NOT_HOVER _state != UI_HOVER
#define SET_HOVER	_state = UI_HOVER

#define IS_NOT_NORMAL _state != UI_NORMAL
#define SET_NORMAL	_state = UI_NORMAL

// window
#define WINDOW_WIDTH "w"
#define WINDOW_HEIGHT "h"
#define WINDOW_TRANSPARENT "trans"
#define WINDOW_DRAG	"drag"
#define WINDOW_ONLYDRAGCAPTION	"onlyDragCaption"
#define WINDOW_RESIZE	"resize"
#define WINDOW_BORDER_SIZE "bordersize"
#define WINDOW_MINWIDTH	 "minW"
#define WINDOW_MINHEIGHT "minH"
#define WINDOW_DBCLICKMAX "dbmax"
#define WINDOW_DBCLICKHEIGHT "dbheight"

// control element json
#define ELEMENT_DEFAULT_CONFIG "elementDefaultConfig.json"
#define ELEMENT_POUP_WINDOW "popupWindow.json"
#define ELEMENT_DEFAULT_STYLE "style.json"
#define ELEMENT_DEFAULT_LANGUAGE "language.json"
#define DEFAULT_STYLE_FILE "defaultStyle.json"
#define ELEMENT_THEME_CONFIG "theme.json"

#define ELEMENT_DEF "elements"
#define ELEMENT_STYLE "style"
#define ELEMENT_ATTIRUTE "attr"

namespace UIGQtLib 
{
	enum StyleType
	{
		STYLE_TYPE_POINT = 0,
		STYLE_TYPE_RECT,
		STYLE_TYPE_FONT,
		STYLE_TYPE_IMG,
		STYLE_TYPE_LAST
	};
}

#define GET_BOOL_VALUE(value, key) \
if (attr.hasKey(key))\
{\
	value = attr[key].asBool(); \
}

#define GET_INT_VALUE(value, key) \
if (attr.hasKey(key))\
{\
	value = attr[key].asInt(); \
}

#define GET_ENUM_VALUE(value, key, type) \
if (attr.hasKey(key))\
{\
	value = (type)attr[key].asInt(); \
}

#define GET_UINT_VALUE(value, key) \
if (attr.hasKey(key))\
{\
	value = attr[key].asUInt(); \
}

#define GET_TEXT_VALUE(value, key) \
if (attr.hasKey(key))\
{\
	value = getUnicodeString(attr[key].asString().c_str()); \
}\

#define GET_LANGUAGE_TEXT(text, keyText) \
if (text.indexOf(KEY_WORD_MARK) == 0) \
{\
	QString key = text.right(text.length() - KEY_WORD_MARK_SIZE); \
	keyText = key; \
	text = UIGQResourceManager::getInstance()->getString(key); \
}

#define GET_STRING_VALUE(value, key) \
if (attr.hasKey(key)) \
{\
	value = attr[key].asString().c_str();\
}

#define GET_STRING_VALUE_DATA(json, value, key) \
if (json.hasKey(key)) \
{\
	value = json[key].asString().c_str();\
}

#define SET_DEFAULT_STYLE(hitPos, array, value) \
if (pos == hitPos)\
{\
	for (int i = 1; i < 4; i++)\
	{\
		array[i] = value;\
	}\
}

#define UIG_CHECK_STATE(state) if (state < -1 || state > UIGQtLib::UIG_STATE_COUNT) \
{\
	state = UIG_NORMAL;\
}

#define DEF_LV_ITEM_HEIGHT 20
#define DEF_LV_ITEM_WIDTH 20

#define DEF_SCROLLBAR_SIZE 23

#define DEF_CHECKBOX_WIDTH 24
#define DEF_CHECKBOX_HEIGHT 24

#define UIG_DEF_CAPTION_HEIGHT 40

// res define 
#define UIG_EMPTY_FILL_STYLE "empty"
#define UIG_EMPTYRECT_FILL_STYLE "emptyRect"
#define UIG_RADIO_IMG_UNSELECTED "IDB_UNSELECT"
#define UIG_RADIO_IMG_SELECTED "IDB_SELECTED"
#define UIG_CBK_IMG_UNCHECK "IDB_UNCHECK"
#define UIG_CBK_IMG_CHECKED "IDB_CHECKED"

#define UIG_QT_EMULATOR "UIGearsQtEmulator"
#define UIG_QT_DESIGNER "NewQtDesigner"

// scrollbar 
#define UIG_QT_CREATE_SCROLLBAR  "createdSB"

#define IS_VISIBLE(pWidget) pWidget->property(ELEMENTS_VISIBLE).toBool() 

#ifndef SET_VISIBLE
#define SET_VISIBLE(pWidget, visible) pWidget->setProperty(ELEMENTS_VISIBLE, visible);pWidget->setVisible(visible)
#endif

#define IS_DELETE(pWidget) pWidget->property(ELEMENTS_MARK_DELETE).toBool() 
#define SET_DELETE(pWidget, visible) pWidget->setProperty(ELEMENTS_MARK_DELETE, visible);

#define UIG_QT_CTRL_DEF(type, class) static const char* typeName() { return type; } \
QString getTypeName() const\
{\
	return typeName();\
}\
bool getInnerVisible() const\
{\
	return IS_VISIBLE(this);\
}\
void setInnerVisible(bool visible)\
{\
	SET_VISIBLE(this, visible);\
}\
QString getInnerTypeName() const\
{\
	return typeName();\
}\
static 	QWidget* create##class()\
{\
	return new class;\
}\
static 	ControlInfo getProps(); \
void setDelegateItemVisible(bool visible); \
bool getDelegateItemVisible(); 

// impl name
#define UIG_IMPL_NAME "impl"

// theme define
#define UIG_THEME_BK_MAIN "mainBkg"
#define UIG_THEME_BK_SECOND "secondBkg"

// label style
#define UIG_THEME_LABEL_TITLE "labTitle"
#define UIG_THEME_LABEL_CONTENT "qtlabel"

// button style
#define UIG_THEME_TEXT_BUTTON "qtbutton"
#define UIG_THEME_ICON_WITH_TEXT_BUTTON "iconTextButton"
#define UIG_THEME_ICON_BUTTON "iconButton"
#define UIG_THEME_ICON_BUTTON2 "iconButton2"
#define UIG_THEME_ICON_BUTTON3 "iconButton3"
#define UIG_THEME_EXTENTSION_BUTTON "extButton"
#define UIG_THEME_ICON_EXTENTSION_BUTTON "iconExtButton"
#define UIG_THEME_ICON_TEXT_EXTENTSION_BUTTON "iconTextExtButton"

// checkbox
#define UIG_THEME_TEXT_CHECKBOX "qtcheckbox"
#define UIG_THEME_ICON_CHECKBOX "iconcheckbox"
#define UIG_THEME_ICON_CHECKBOX2 "iconcheckbox2"

// radiobutton
#define UIG_THEME_TEXT_RADIOBOX "qtradiobox"
#define UIG_THEME_ICON_RADIOBOX "qtradiobox2"
#define UIG_THEME_ICON_RADIOBOX2 "qtradiobox3"

// combobox
#define UIG_THEME_TEXT_COMBOBOX "qtcombobox"

// lineEdit
#define UIG_THEME_LINE_EDIT "qtdedit"

// TextEdit
#define UIG_THEME_TEXT_EDIT "qttext"

// spinbox
#define UIG_THEME_SPIN "qtspinbox"

// textedit
#define UIG_THEME_TEXT_EDIT "qttext"

// progressbar
#define UIG_THEME_PROGRESS_BAR "qtprogressbar"

// slider
#define UIG_THEME_SLIDER "qtslider"
#define UIG_THEME_SLIDER_VERTICAL "qtsliderv"

// menu
#define UIG_THEME_MENUBAR "qtmenubar"

// scrollbar
#define UIG_THEME_SCROLLBAR_HORIZONTAL "qtscrollbarh"
#define UIG_THEME_SCROLLBAR_VERTICAL "qtscrollbar"


// tableview
#define UIG_THEME_TABLEVIEW "qtdatagrid"

// tree
#define UIG_THEME_TREE "qttree"

// list
#define UIG_THEME_LIST "qtlist"

// menu
#define UIG_THEME_MENU "qtmenu"

// getstring
#define UIG_TRANSLATE(key) UIGQtLib::uigGetString(key)


#define DEFINE_PROP(_name, _tip, _type) { UIGQtLib::PropertyDef propDef; \
propDef.name = _name; \
propDef.tip = _tip;  \
propDef.type = _type; \
info.props.push_back(propDef); }

#define DEFINE_SET_MAXMINVALUE(min, max) \
info.props[info.props.size() - 1].maxValue = max; \
info.props[info.props.size() - 1].minValue = min;

#define DEFINE_STRING_GETSET(_get, _set) \
info.props[info.props.size() - 1].setStringFun = (UIGQtLib::SetStringFun)&_set; \
info.props[info.props.size() - 1].getStringFun = (UIGQtLib::GetStringFun)&_get;

#define DEFINE_STRING_GET(_get) \
info.props[info.props.size() - 1].getStringFun = (UIGQtLib::GetStringFun)&_get;

#define DEFINE_STRING_SET(_set) \
info.props[info.props.size() - 1].setStringFun = (UIGQtLib::SetStringFun)&_set;

#define DEFINE_BOOL_GETSET(_get, _set) \
info.props[info.props.size() - 1].setBoolFun = (UIGQtLib::SetBoolFun)&_set; \
info.props[info.props.size() - 1].getBoolFun = (UIGQtLib::GetBoolFun)&_get;

#define DEFINE_FILL_STYLE_GETSET(_get, _set) \
info.props[info.props.size() - 1].setFillStyleFun = (UIGQtLib::SetFillStyleFun)&_set; \
info.props[info.props.size() - 1].getFillStyleFun = (UIGQtLib::GetFillStyleFun)&_get;

#define DEFINE_TEXT_STYLE_GETSET(_get, _set) \
info.props[info.props.size() - 1].setTextStyleFun = (UIGQtLib::SetTextStyleFun)&_set; \
info.props[info.props.size() - 1].getTextStyleFun = (UIGQtLib::GetTextStyleFun)&_get;

#define DEFINE_NUM_GETSET(_get, _set) \
info.props[info.props.size() - 1].setNumFun = (UIGQtLib::SetNumFun)&_set; \
info.props[info.props.size() - 1].getNumFun = (UIGQtLib::GetNumFun)&_get;

#define DEFINE_2NUM_GETSET(_get, _set) \
info.props[info.props.size() - 1].set2NumFun = (UIGQtLib::Set2NumFun)&_set; \
info.props[info.props.size() - 1].get2NumFun = (UIGQtLib::Get2NumFun)&_get;

#define DEFINE_4NUM_GETSET(_get, _set) \
info.props[info.props.size() - 1].set4NumFun = (UIGQtLib::Set4NumFun)&_set; \
info.props[info.props.size() - 1].get4NumFun = (UIGQtLib::Get4NumFun)&_get;

#define DEFINE_EFFECT_OTHER(effect) \
info.props[info.props.size() - 1].effectOtherProp = effect;

#define DEFINE_STYLE_STATE(_state, _name) \
info.props[info.props.size() - 1].vecStates.push_back((int)_state); \
info.props[info.props.size() - 1].vecStatesName.push_back(_name);

#define DEFINE_BASE_EVENT() \
UIGQtLib::EventInfo eventInfo; \
eventInfo.eventName = _T("Base_Resize"); \
info.events.push_back(eventInfo);

#define DEFINE_EVENT(_name) \
eventInfo.eventName = _T(_name); \
info.events.push_back(eventInfo);

#define DEFINE_BASE_TOOLTIP_PROP(x) \
DEFINE_PROP(("Name"), (""), UIGQtLib::PT_EDIT);\
DEFINE_STRING_GETSET(x::objectName, x::setObjectName);\
DEFINE_PROP(("Type"), (""), UIGQtLib::PT_STATIC);\
DEFINE_STRING_GET(x::getInnerTypeName);\
DEFINE_PROP(("Visibility"), (""), UIGQtLib::PT_CHECK);\
DEFINE_BOOL_GETSET(x::getInnerVisible, x::setInnerVisible);\
DEFINE_PROP(("Enable"), (""), UIGQtLib::PT_CHECK);\
DEFINE_BOOL_GETSET(x::isEnabled, x::setEnabled)\
DEFINE_PROP(("Tooltip"), (""), UIGQtLib::PT_EDIT_TRANSLATE);\
DEFINE_STRING_GETSET(x::toolTip, x::setToolTip)\
DEFINE_PROP(("Alpha"), (""), UIGQtLib::PT_NUM); \
DEFINE_NUM_GETSET(x::getOpacity, x::setOpacity) \
DEFINE_PROP(("Line"), (""), UIGQtLib::PT_LINE);

#define DEFINE_BASE_PROP(x) \
DEFINE_PROP(_T("Name"), _T(""), UIGQtLib::PT_EDIT); \
DEFINE_STRING_GETSET(x::GetControlName, x::SetControlName) \
DEFINE_PROP(_T("Type"), _T(""), UIGQtLib::PT_STATIC); \
DEFINE_STRING_GET(x::GetControlTypeName); \
DEFINE_PROP(_T("Visibility"), _T(""), UIGQtLib::PT_CHECK); \
DEFINE_BOOL_GETSET(x::GetVisibility, x::SetVisibility); \
DEFINE_PROP(_T("Enable"), _T(""), UIGQtLib::PT_CHECK); \
DEFINE_BOOL_GETSET(x::GetEnable, x::SetEnable) \
DEFINE_PROP(_T("Alpha"), _T(""), UIGQtLib::PT_NUM); \
DEFINE_NUM_GETSET(x::GetAlpha, x::SetAlpha) \
DEFINE_PROP(_T("Line"), _T(""), UIGQtLib::PT_LINE);


#define INSERT_STYLE(obj, pos) \
			{if(!obj.name.isEmpty()){ Json::Value item;\
			item.append(obj.name.toUtf8().data());\
			obj.isTextStyle ? item.append(2) : item.append(1);\
            item.append((int)pos); \
			style.append(item); } }

#define INSERT_STYLE_RANGE(obj, start, end) \
{ \
bool allSame = true;\
for (size_t i = start; i < end - 1; i++)\
{\
	if (obj[i - start] != obj[i + 1 - start] && obj[i + 1 - start].name != "" && obj[i - start].name != "")\
	{\
		allSame = false;\
		break;\
	}\
}\
if (allSame)\
{\
	INSERT_STYLE(obj[start - start], start);\
}\
else\
{\
	for (size_t i = start; i < end; i++)\
	{\
		INSERT_STYLE(obj[i - start], i);\
	}\
}\
}

#define CLR_TO_STR(color) \
QString().sprintf("%02X%02X%02X%02X", \
	color.alpha(),\
	color.red(),\
	color.green(),\
	color.blue()).toUtf8().constData()


#define SERIALIZE_BOOL(value, name, defValue) \
			if((int)(value) != defValue)attr[name] = (int)(value);

#define SERIALIZE_STRING(value, name, defValue) \
			if(value != defValue)attr[name] = value.toUtf8().data();

#define SERIALIZE_CLR_STRING(value, name, defValue) \
			{QString clr = CLR_TO_STR(value); \
			if (clr != defValue)attr[name] = clr.toUtf8().data();}

#define SERIALIZE_INT(value, name, defValue) \
			if(value != defValue)attr[name] = value;

#endif
