//默认库源代码

/* 
Author: crane he, lujjjh  
This Component uses HTMLayout Component
Copyright http://terrainformatica.com
*/ 

import fsys
import win.ui;
import fsys.codepage; 
import util.metaProperty;

namespace web;
var raw_convert = ..raw.convert;
 
layout = class {
	ctor (winform) { 
		if( winform.className == "static" ){
			winform.modifyStyle(,0x100/*_SS_NOTIFY*/ | 0x2000000/*_WS_CLIPCHILDREN*/); 
		} 
		else{
			winform.modifyStyle(,0x2000000/*_WS_CLIPCHILDREN*/)
		};
		
		winform.layout = this;
		this.hwnd = winform[["hwnd"]];
		this._form = winform;
		   
		ProcND(this.hwnd, 0x1/*_WM_CREATE*/, 0, 0);
		SetOption( this.hwnd, 5/*_HTMLAYOUT_ANIMATION_THREAD*/,1) ;  
		winform.tailWndproc = function (hwnd, message, wParam, lParam) {  
			if( message == 0x2/*_WM_DESTROY*/ ){
				ProcND(this.hwnd, 0x2/*_WM_DESTROY*/, 0, 0); 
				WindowDetachEventHandler(this.hwnd,this._domEventsHandler_c);
				SetCallback(this.hwnd,null);
				winform.wndproc = null;
				return;
			}
			
			var re, handled = ProcND(hwnd, message, wParam, lParam);  
			if( handled && ( message != 0x5/*_WM_SIZE*/ ) ) 
				return re; 
		};
		
		winform.onEraseBkgnd = null; 
		if( winform.isDialogMessage ){
			if( winform.isDialogMessage!= ..win.isDialogMessage ){
				error("在创建web.layout窗体以前,禁止重写默认 isDialogMessage() 函数 ",2)
			}
			else{
				winform.isDialogMessage = function(hwnd,msg) {
					return false; 
				}
			}
		};
		
		this._callback_c = ..raw.tostdcall( _callback, "int(INT uMsg,INT wParam,int lParam,pointer vPara)",this);
		SetCallback(this.hwnd, this._callback_c);

		this._domEventsHandler_c = ..raw.tostdcall( event._handler, "int(pointer tag,pointer he,INT evtg,pointer prms)",this); 
		WindowAttachEventHandler(this.hwnd, this._domEventsHandler_c, , 0xFFFF/*_HANDLE_ALL*/);
		
		//自定义窗口控件
		this._contrls = {};
		this._form.adjust = function(){
			for(k,ctrl in this._contrls){
				if(ctrl.adjust){
					var x,y,cx,cy = ctrl.getPos();
					ctrl.adjust(cx,cy);
				};
			}
		}; 
	}
	
	go = function (filename,charset) { 
		this.charset =  charset;
		if ( ..io.localpath(filename) ) {
			this.localBaseDir = ..io.splitpath(filename).dir; 
			return this.write( ( ..fsys.codepage.load(filename,charset) ) ) ,..io.fullpath( this.localBaseDir ) );
		}
		else {
			return LoadFile(this.hwnd, ..string.toUnicode( filename ) );
		}
	}
	
	write = function (data, baseUrl) {
		data = ..string.toUnicode(data);
		if ( ! baseUrl)
			return LoadHtml( this.hwnd, data, #data - 2 );
		else
			return LoadHtmlEx( this.hwnd, data, #data - 2, baseUrl );
	};
	
	createEle = function (tag, text) {
		if(text)text=..string.toUnicode(text);
		var re, he = CreateElement(tag, text);
		if( re == 0/*_HLDOM_OK*/) {
			return element(he,false);
		}
	};
	
	@_meta;
}

namespace layout {
	dll = ..raw.loadDll($"/.res/HTMLayout.dll","HTMLayout.dll");
	import web.layout.value;
	import web.layout.element;
	import web.layout.event; 
 
 	var conflictCustomControls ={ button=1; checkbox=1; calendar=1 }; 
 	var txtExtensionName = { htm=1;html=1;css=1}
	_defaultNotifyHandler ={
		[ 0xB01/*_HLN_LOAD_DATA*/ ]  = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){
			
			var nmld = NMHL_LOAD_DATA();  
			raw_convert(pNmhdr, nmld);
			var uri = ..string.fromUnicode(nmld.uri,0,true); 
			var protocol = ..string.match( uri,"^\a+\://" );
			if( protocol ){
				return 0/*_LOAD_OK*/;
			}
			 
			if ( #this.localBaseDir )
				uri = ..fsys.joinpath(this.localBaseDir,uri) 
			
			var ext = ..fsys.getExtensionName(uri);
			var data;
			if( ext && txtExtensionName[ext] ){
				data = ..fsys.codepage.load(uri);   
			}
			else {
				data = ..string.load(uri);  
			}
			
			if (data) {
				DataReady(this.hwnd, uri, data, #data);
			}
			return 0/*_LOAD_OK*/;
		 
		}
		[0xB04/*_HLN_DOCUMENT_COMPLETE*/]  = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){  
		
			if(this.onDocumentComplete){
				this.onDocumentComplete();
			}
 			return 0;
		}
		[ 0xB00/*_HLN_CREATE_CONTROL*/ ]  = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){
			var nmld = NMHL_CREATE_CONTROL();
			raw_convert(pNmhdr, nmld);
			var ele = element(nmld.helement);  
			if(! (ele.name && ele.type ) )return 0;  
			if( conflictCustomControls[ele.type] ) return 0;
			var value = ele.value; 
			this._form.addCtrl( [ele.name] = { bottom=1;right=1;left=0;top=0;text=type(value)==type.string?value:"";cls=ele.type;autoResize=false} );   
			if(this._form[ele.name]){
				nmld.outControlHwnd = this._form[ele.name].hwnd; 
 				CopyMemoryByStruct(pNmhdr, nmld, ..raw.sizeof(nmld));
 				this._contrls[ele.name]=this._form[ele.name]; 
 			} 
 			return 0;
		}
		[0xB02/*_HLN_CONTROL_CREATED*/] = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){
			var nmld = NMHL_CREATE_CONTROL();
			raw_convert(pNmhdr, nmld);
			var ele = element(nmld.helement); 
			if(! (ele.name && ele.type ) )return 0; 
			if( this.onControlCreate ){
				this.onControlCreate(ele,ele.name,nmld.outControlHwnd)
 			}
 			return 0;
		}
		[0xB06/*_HLN_DESTROY_CONTROL*/] = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){
			var nmld = NMHL_CREATE_CONTROL();
			raw_convert(pNmhdr, nmld);
			var ele = element(nmld.helement); 
			if(! (ele.name && ele.type ) )return 0;
			
			if(this._form[ele.name]){
				this._form[ele.name].close();
				this._contrls[ele.name]=null;
			}
 			return 0;
		} 
		[0xB07/*_HLN_ATTACH_BEHAVIOR*/] = function(this,message, wParam, lParam, vParam,notifyCode, pNmhdr){
			//var nmld = NMHL_ATTACH_BEHAVIOR();
			//raw_convert(pNmhdr, nmld);
			//if( find nmld.behaviorName ok ){
			//	var ele = element(nmld.helement);  
			//	nmld.elementProc = raw.tostdcall(func,"bool(pointer tag,pointer he,INT evtg,pointer prms)");
			//	raw.mixin(pNmhdr,nmld);
			//}
 			return 0;
		}
	};
	
	var NMHDR  = ..win.ui.NMHDR; 
	_callback = function (message, wParam, lParam, vParam) {
		var pNmhdr = topointer( lParam );
		var nmhdr = raw_convert( pNmhdr, NMHDR() );
		var notifyCode = nmhdr.code;  
		if ( owner.callback ) {
			var re = owner.callback(message, wParam, lParam, vParam,notifyCode, pNmhdr);
			if (re !== null) return re;
		} 
		
		var handler = _defaultNotifyHandler[notifyCode]
		if( handler ){
			var result = handler(owner,message, wParam, lParam, vParam,notifyCode, pNmhdr)
			if( result !== null )
				return result;
		}	 
		return 0;
	};
	 
	_meta = ..util.metaProperty(
		documentElement = {
			_get = function () {
				var re, he = GetRootElement( owner.hwnd );
				return element(he);
			}
		}
		getEle = function (id) {
			return owner.documentElement.getElementById(id) ;
		}
		
		getEles = function (name) {
			return owner.documentElement.getElementsByName(name);
		} 
		 
		getElesByTag = function (tag) {
			return owner.documentElement.getElementsByTagName(tag);
		}
		
		queryEles = function (...) {
			return owner.documentElement.queryElements(...);
		};
		
		appendMasterCss = function(css){
			css  = string.fromto(css,0,65001);
			AppendMasterCSS(css,#css);
		};
		
		updateWindow = function(){
			HTMLayoutUpdateWindow(owner.hwnd);
		} 
	); 
	 
	var nmhdr = ..win.ui.NMHDR;
	
	/*intellisense(htmlayout)*/
	NMHL_CREATE_CONTROL = class {
		struct hdr = nmhdr();
		pointer helement;
		int inHwndParent;
		int outControlHwnd;
	}
	
	NMHL_DESTROY_CONTROL = class {
		struct hdr = nmhdr();
		pointer helement;
		int inoutControlHwnd;
	}
	
	NMHL_LOAD_DATA = class {
		struct hdr = nmhdr();
		pointer uri;
		pointer outData;
		INT outDataSize;
		INT dataType;
		int principal;
		int initiator;
	}
	
	NMHL_DATA_LOADED = class {
		struct hdr = nmhdr();
		string uri;
		pointer outData;
		INT outDataSize;
		INT dataType;
		INT status;
	}
	
	NMHL_ATTACH_BEHAVIOR = class {
		struct hdr = nmhdr();
		pointer element;
		string behaviorName;
		pointer elementProc;
		pointer elementTag;
		INT elementEvents;
	}
	
	NMHL_DIALOG_CLOSE_RQ = class {
		struct hdr = nmhdr();
		bool outCancel;
	} 
	
	GESTURE_PARAMS = class {
		INT cmd;
		int target;
		struct pos = ::POINT();
		struct pos_view = ::POINT();
		INT flags;
		INT delta_time;
		struct delta_xy = ::SIZE();
		double delta_v;
	}
	
	DRAW_PARAMS = class {
		INT cmd;
		pointer hdc;
		struct area = ::RECT();
		INT reserved;
	}
	
	EXCHANGE_PARAMS = class {
		INT cmd;
		int target;
		struct pos = ::POINT();
		struct pos_view = ::POINT();
		INT data_types;
		INT drag_cmd;
		pointer fetch_data;
	} 
	
	TIMER_PARAMS = class {
		INT timerId;
	}
	
	_METHOD_PARAMS = class {
		INT methodID;
	}
	
	XCALL_PARAMS = class {
		string method_name;
		INT argc;
		pointer argv;
		pointer retval;
	}
	
	VALUE_PARAMS = class {
		pointer val;
	}
	
	IS_EMPTY_PARAMS = class {
		INT is_empty;
	}
	
	TEXT_VALUE_PARAMS = class {
		string text;
		INT length;
	}
	
	TEXT_EDIT_SELECTION_PARAMS = class {
		INT selection_start;
		INT selection_end;
	}
	 
	ResourceType = {
		HLRT_DATA_HTML = 0;
		HLRT_DATA_IMAGE = 1;
		HLRT_DATA_STYLE = 2;
		HLRT_DATA_CURSOR = 3;
		HLRT_DATA_SCRIPT = 4;
	}
	
	Modes  = {
		HLM_LAYOUT_ONLY = 0;
		HLM_SHOW_SELECTION = 1;
	}
	
	ELEMENT_MODEL = {
		DATA_ELEMENT = 0;
		INLINE_TEXT_ELEMENT = 1;
		INLINE_BLOCK_ELEMENT = 2;
		BLOCK_TEXT_ELEMENT = 3;
		BLOCK_BLOCK_ELEMENT = 4;
	}
	
	OPTIONS = {
		HTMLAYOUT_SMOOTH_SCROLL = 1;
		HTMLAYOUT_CONNECTION_TIMEOUT = 2;
		HTMLAYOUT_HTTPS_ERROR = 3;
		HTMLAYOUT_FONT_SMOOTHING = 4;
		HTMLAYOUT_ANIMATION_THREAD = 5;
		HTMLAYOUT_TRANSPARENT_WINDOW = 6;
	}
	
	PHASE_MASK = {
		BUBBLING = 0;
		SINKING = 0x08000;
		HANDLED = 0x10000;
	}
	
	MOUSE_BUTTONS = {
		MAIN_MOUSE_BUTTON = 0x01;
		PROP_MOUSE_BUTTON = 0x02;
		MIDDLE_MOUSE_BUTTON = 0x04;
		X1_MOUSE_BUTTON = 0x08;
		X2_MOUSE_BUTTON = 0x10;
	}

	KEYBOARD_STATES = {
		CONTROL_KEY_PRESSED = 0x1;
		SHIFT_KEY_PRESSED = 0x2;
		ALT_KEY_PRESSED = 0x4;
	}
	
	DRAGGING_TYPE = {
		NO_DRAGGING = 0;
		DRAGGING_MOVE = 1;
		DRAGGING_COPY = 2;
	}
	
	CURSOR_TYPE = {
		CURSOR_ARROW = 0;
		CURSOR_IBEAM = 1;
		CURSOR_WAIT = 2;
		CURSOR_CROSS = 3;
		CURSOR_UPARROW = 4;
		CURSOR_SIZENWSE = 5;
		CURSOR_SIZENESW = 6;
		CURSOR_SIZEWE = 7;
		CURSOR_SIZENS = 8;
		CURSOR_SIZEALL = 9; 
		CURSOR_NO = 10;
		CURSOR_APPSTARTING = 11;
		CURSOR_HELP = 12;
		CURSOR_HAND = 13;
		CURSOR_DRAG_MOVE = 14;
		CURSOR_DRAG_COPY = 15;
	}
	
	FOCUS_CAUSE = {
		BY_CODE = 0;
		BY_MOUSE = 1;
		BY_KEY_NEXT = 2;
		BY_KEY_PREV = 3;
	}
	
	GESTURE_CMD = {
		GESTURE_REQUEST = 0;
		GESTURE_ZOOM = 1;
		GESTURE_PAN = 2;
		GESTURE_ROTATE = 3;
		GESTURE_TAP1 = 4;
		GESTURE_TAP2 = 5;
	}
	
	GESTURE_STATE = {
		GESTURE_STATE_BEGIN   = 1;
		GESTURE_STATE_INERTIA = 2;
		GESTURE_STATE_END     = 4;
	}
	
	GESTURE_TYPE_FLAGS = {
		GESTURE_FLAG_ZOOM               = 0x0001;
		GESTURE_FLAG_ROTATE             = 0x0002;
		GESTURE_FLAG_PAN_VERTICAL       = 0x0004;
		GESTURE_FLAG_PAN_HORIZONTAL     = 0x0008;
		GESTURE_FLAG_TAP1               = 0x0010;
		GESTURE_FLAG_TAP2               = 0x0020;
		GESTURE_FLAG_PAN_WITH_GUTTER    = 0x4000;
		GESTURE_FLAG_PAN_WITH_INERTIA   = 0x8000;
		GESTURE_FLAGS_ALL               = 0xFFFF;
	}
	
	DRAW_EVENTS = {
		DRAW_BACKGROUND = 0;
		DRAW_CONTENT = 1;
		DRAW_FOREGROUND = 2;
	}
	
	EXCHANGE_EVENTS = {
		X_DRAG_ENTER = 0;
		X_DRAG_LEAVE = 1;
		X_DRAG = 2;
		X_DROP = 3;
	}
	
	EXCHANGE_DATA_TYPE = {
		EXF_UNDEFINED   = 0;
		EXF_TEXT        = 0x01;
		EXF_HTML        = 0x02;
		EXF_HYPERLINK   = 0x04;
		EXF_JSON        = 0x08;
		EXF_FILE        = 0x10;
	}
	
	EXCHANGE_COMMANDS = {
		EXC_NONE = 0;
		EXC_COPY = 1;
		EXC_MOVE = 2;
		EXC_LINK = 4;
	}
 
	EVENT_REASON = {
		BY_MOUSE_CLICK = 0;
		BY_KEY_CLICK = 1;
		SYNTHESIZED = 2;
	}

	EDIT_CHANGED_REASON = {
		BY_INS_CHAR = 3;
		BY_INS_CHARS = 4;
		BY_DEL_CHAR = 5;
		BY_DEL_CHARS = 6;
	};
	
	BEHAVIOR_METHOD_IDENTIFIERS = {
		DO_CLICK = 0;
		GET_TEXT_VALUE = 1;
		SET_TEXT_VALUE = 2;
		TEXT_EDIT_GET_SELECTION = 3;
		TEXT_EDIT_SET_SELECTION = 4;
		TEXT_EDIT_REPLACE_SELECTION = 5;
		SCROLL_BAR_GET_VALUE = 6;
		SCROLL_BAR_SET_VALUE = 7;
		TEXT_EDIT_GET_CARET_POSITION = 8;
		TEXT_EDIT_GET_SELECTION_TEXT = 9;
		TEXT_EDIT_GET_SELECTION_HTML = 10;
		TEXT_EDIT_CHAR_POS_AT_XY = 11;
		IS_EMPTY = 0xFC;
		GET_VALUE = 0xFD;
		SET_VALUE = 0xFE;
		XCALL = 0xFF;
		FIRST_APPLICATION_METHOD_ID = 0x100;
	}
	
	ELEMENT_AREAS = {
		ROOT_RELATIVE = 0x01;
		SELF_RELATIVE = 0x02;
		CONTAINER_RELATIVE = 0x03;
		VIEW_RELATIVE = 0x04;
		CONTENT_BOX = 0x00;
		PADDING_BOX = 0x10;
		BORDER_BOX  = 0x20;
		MARGIN_BOX  = 0x30;
		BACK_IMAGE_AREA = 0x40;
		FORE_IMAGE_AREA = 0x50;
		SCROLLABLE_AREA = 0x60;
	}
	
	HTMLAYOUT_SCROLL_FLAGS = {
		SCROLL_TO_TOP = 0x01;
		SCROLL_SMOOTH = 0x10;
	}
	
	UPDATE_ELEMENT_FLAGS = {
		RESET_STYLE_THIS = 0x20;
		RESET_STYLE_DEEP = 0x10;
		MEASURE_INPLACE = 0x0001;
		MEASURE_DEEP    = 0x0002;
		REDRAW_NOW = 0x8000;
	} 
	
	REQUEST_TYPE = {
		GET_ASYNC = 0;
		POST_ASYNC = 1;
	}
	
	CTL_TYPE = {
		CTL_NO = 0;
		CTL_UNKNOWN = 1;
		CTL_EDIT = 2;
		CTL_NUMERIC = 3;
		CTL_BUTTON = 4;
		CTL_CHECKBOX = 5;
		CTL_RADIO = 6;
		CTL_SELECT_SINGLE = 7;
		CTL_SELECT_MULTIPLE = 8;
		CTL_DD_SELECT = 9;
		CTL_TEXTAREA = 10;
		CTL_HTMLAREA = 11;
		CTL_PASSWORD = 12;
		CTL_PROGRESS = 13;
		CTL_SLIDER = 14;
		CTL_DECIMAL = 15;
		CTL_CURRENCY = 16;
		CTL_SCROLLBAR = 17;
		CTL_HYPERLINK = 18;
		CTL_MENUBAR = 19;
		CTL_MENU = 20;
		CTL_MENUBUTTON = 21;
		CTL_CALENDAR = 22;
		CTL_DATE = 23;
		CTL_TIME = 24;
		CTL_FRAME = 25;
		CTL_FRAMESET = 26;
		CTL_GRAPHICS = 27;
		CTL_SPRITE = 28;
		CTL_LIST = 29;
		CTL_RICHTEXT = 30;
		CTL_TOOLTIP = 31;
		CTL_HIDDEN = 32;
		CTL_URL = 33;
		CTL_TOOLBAR = 34;
		CTL_FORM = 35;
	}
	
	ADVANCE_TO = {
		GO_FIRST = 0;
		GO_LAST  = 1;
		GO_NEXT  = 2;
		GO_PREV  = 3;
		GO_NEXT_CHAR  = 4;
		GO_PREV_CHAR  = 5;
	} 
	SetOption = dll.api("HTMLayoutSetOption", "bool(int hWndHTMLayout, INT option, INT value)"); 
	ClipboardCopy = dll.api("HTMLayoutClipboardCopy", "int(int hWndHTMLayout)");
	DataReady = dll.api("HTMLayoutDataReady", "int(int hwnd, pointer uri, pointer data, INT dataLength)");
	DataReadyAsync = dll.api("HTMLayoutDataReadyAsync", "int(int hwnd, pointer uri, pointer data, INT dataLength, INT dataType)");
	Dialog = dll.api("HTMLayoutDialog", "int(int hWndParent, struct position, INT alignment, INT style, INT styleEx, pointer notificationCallback, pointer eventsCallback, pointer callbackParam, pointer html, INT htmlLength)");
	EnumResources = dll.api("HTMLayoutEnumResources", "INT(int hWndHTMLayout, pointer cb)");
	GetMinHeight = dll.api("HTMLayoutGetMinHeight", "INT(int hWndHTMLayout, INT width)");
	GetMinWidth = dll.api("HTMLayoutGetMinWidth", "INT(int hWndHTMLayout)");
	GetSelectedHTML = dll.api("HTMLayoutGetSelectedHTML", "string(int hWndHTMLayout, INT& pSize)");
	LoadFile = dll.api("HTMLayoutLoadFile", "int(int hWndHTMLayout, pointer filename)");
	LoadHtml = dll.api("HTMLayoutLoadHtml", "int(int hWndHTMLayout, pointer html, INT htmlSize)");
	LoadHtmlEx = dll.api("HTMLayoutLoadHtmlEx", "int(int hWndHTMLayout, pointer html, INT htmlSize, pointer baseUrl)");
	Proc = dll.api("HTMLayoutProc", "INT(int hwnd, INT msg,INT wParam, int lParam)");
	ProcND = dll.api("HTMLayoutProcND", "INT(int hwnd, INT msg,INT wParam, int lParam, bool& pbHandled)");
	HTMLayoutUpdateWindow = dll.api("HTMLayoutUpdateWindow", "INT(int hwnd)"); 
	Render = dll.api("HTMLayoutRender", "int(int hWndHTMLayout, pointer hBmp, struct area)");
	SelectionExist = dll.api("HTMLayoutSelectionExist", "int(int hWndHTMLayout)");
	SetCallback = dll.api("HTMLayoutSetCallback", "void(int hWndHTMLayout, pointer cb, pointer cbParam)");
	SetCSS = dll.api("HTMLayoutSetCSS", "int(int hWndHTMLayout, pointer utf8, INT numBytes, pointer baseUrl, pointer mediaType)");
	SetHttpHeaders = dll.api("HTMLayoutSetHttpHeaders", "int(int hWndHTMLayout, pointer htmlHeaders, INT httpHeadersLength)");
	SetMasterCSS = dll.api("HTMLayoutSetMasterCSS", "int(pointer utf8, INT numBytes)");
	SetMediaType = dll.api("HTMLayoutSetMediaType", "int(int hWndHTMLayout, pointer mediaType)");
	SetMode = dll.api("HTMLayoutSetMode", "void(int hWndHTMLayout, int mode)");  
	GetRootElement = dll.api("HTMLayoutGetRootElement", "int(int hwnd, pointer& phe)");
	GetFocusElement = dll.api("HTMLayoutGetFocusElement", "int(int hwnd, pointer& phe)");
	FindElement = dll.api("HTMLayoutFindElement", "int(int hwnd, struct pt, pointer& phe)");
	GetChildrenCount = dll.api("HTMLayoutGetChildrenCount", "int(pointer he, INT& count)");
	GetNthChild = dll.api("HTMLayoutGetNthChild", "int(pointer he, INT n, int& he)"); 
	GetElementByUID = dll.api("HTMLayoutGetElementByUID", "int(int hwnd, INT uid, pointer& phe)");
	ShowPopup = dll.api("HTMLayoutShowPopup", "int(pointer hePopup, pointer heAnchor, INT placement)");
	ShowPopupAt = dll.api("HTMLayoutShowPopupAt", "int(pointer hePopup, struct pos, INT mode)");
	TrackPopupAt = dll.api("HTMLayoutTrackPopupAt", "int(pointer hePopup, struct posRoot, INT mode, pointer& pheItem)");
	HidePopup = dll.api("HTMLayoutHidePopup", "int(pointer he)");
	AppendMasterCSS = dll.api("HTMLayoutAppendMasterCSS", "bool(str utf8 ,INT numBytes)") 
	CreateElement = dll.api("HTMLayoutCreateElement", "int(pointer tagname, pointer textOrNull, pointer& phe)");  
	WindowAttachEventHandler = dll.api("HTMLayoutWindowAttachEventHandler", "int(int hwndLayout, pointer pep, pointer tag, INT subscription)");
	WindowDetachEventHandler = dll.api("HTMLayoutWindowDetachEventHandler", "int(int hwndLayout, pointer pep, pointer tag)");
	/*end intellisense*/
}



/**intellisense()
web.layout(__/*窗口对象*/) = 从窗口对象创建HTMLayout窗口\n如是参数不是控件窗口,而是窗体对象,\n则必须重写 isDialogMessage() 函数以禁用对话框快捷键
?web.layout = !weblayout.
!weblayout._contrls = 自定义窗口控件集合,\n使用INPUT,WIDGET,OBJECT标签,可创建自定义控件,type属性指定控件类名
!weblayout.queryEles = @.queryEles("标签名[属性名='属性值']__/*支持CSS选择器语法*/")
!weblayout.callback = @.callback = function ( message, wParam, lParam, vParam, notifyCode, pNmhdr ) {\n	__\n}
!weblayout.eventsHandler = @.eventsHandler = function (tag, he, evtg, prms) {\n	__\n}
!weblayout.onDocumentComplete = @.onDocumentComplete = function() {
	__/*网页加载完成*/;
}
!weblayout.onControlCreate = @.onControlCreate = function( layoutEle, name, hwnd ){
	if( owner._contrls[name].hwnd = hwnd ){
		__
	}
}
!weblayout._contrls[] = !static.
!weblayout.appendMasterCss(公用CSS) =  添加公用CSS
!weblayout.go("__/*路径*/") = 跳转到指定网址（支持资源文件）
!weblayout.write(__/*HTML 代码*/) = 写出指定 HTML 代码
!weblayout.documentElement = !layoutEle.
!weblayout.getEle() = !layoutEle.
!weblayout.getEle("__") = 根据ID查找节点\n如果未找到，尝试使用name查找	
!weblayout.getEles("__") = 根据name属性查找节点
!weblayout.createEle(.(标签名) = 创建节点
!weblayout.createEle(.(标签名,节点内容) = 创建节点
!weblayout.createEle() = !layoutEle. 
!weblayout.updateWindow() = 刷新窗口
end intellisense**/

 /**intellisense()
_HLN_CREATE_CONTROL=@0xB00/*_HLN_CREATE_CONTROL*/
_HLN_DESTROY_CONTROL=@0xB06/*_HLN_DESTROY_CONTROL*/
_HLN_LOAD_DATA=@0xB01/*_HLN_LOAD_DATA*/
_HLN_CONTROL_CREATED=@0xB02/*_HLN_CONTROL_CREATED*/
_HLN_DATA_LOADED=@0xB03/*_HLN_DATA_LOADED*/
_HLN_DOCUMENT_COMPLETE=@0xB04/*_HLN_DOCUMENT_COMPLETE*/
_HLN_UPDATE_UI=@0xB05/*_HLN_UPDATE_UI*/
_HLN_ATTACH_BEHAVIOR=@0xB07/*_HLN_ATTACH_BEHAVIOR*/
_HLN_DIALOG_CREATED=@0xB0F/*_HLN_DIALOG_CREATED*/
_HLN_DIALOG_CLOSE_RQ=@0xB10/*_HLN_DIALOG_CLOSE_RQ*/
_HWND_TRY_DEFAULT=@0/*_HWND_TRY_DEFAULT*/
_HWND_DISCARD_CREATION=@1/*_HWND_DISCARD_CREATION*/
_LOAD_OK=@0/*_LOAD_OK*/
_LOAD_DISCARD=@1/*_LOAD_DISCARD*/

_HLRT_DATA_HTML=@0/*_HLRT_DATA_HTML*/
_HLRT_DATA_IMAGE=@1/*_.HLRT_DATA_IMAGE*/
_HLRT_DATA_STYLE=@2/*_HLRT_DATA_STYLE*/
_HLRT_DATA_CURSOR=@3/*_HLRT_DATA_CURSOR*/
_HLRT_DATA_SCRIPT=@4/*_HLRT_DATA_SCRIPT*/

_HLM_LAYOUT_ONLY=@0/*_HLM_LAYOUT_ONLY*/
_HLM_SHOW_SELECTION=@1/*_HLM_SHOW_SELECTION*/

_DATA_ELEMENT=@0/*_DATA_ELEMENT*/
_INLINE_TEXT_ELEMENT=@1/*_INLINE_TEXT_ELEMENT*/
_INLINE_BLOCK_ELEMENT=@2/*_INLINE_BLOCK_ELEMENT*/
_BLOCK_TEXT_ELEMENT=@3/*_BLOCK_TEXT_ELEMENT*/
_BLOCK_BLOCK_ELEMENT=@4/*_BLOCK_BLOCK_ELEMENT*/

_HTMLAYOUT_SMOOTH_SCROLL=@1/*_HTMLAYOUT_SMOOTH_SCROLL*/
_HTMLAYOUT_CONNECTION_TIMEOUT=@2/*_HTMLAYOUT_CONNECTION_TIMEOUT*/
_HTMLAYOUT_HTTPS_ERROR=@3/*_HTMLAYOUT_HTTPS_ERROR*/
_HTMLAYOUT_FONT_SMOOTHING=@4/*_HTMLAYOUT_FONT_SMOOTHING*/
_HTMLAYOUT_ANIMATION_THREAD=@5/*_HTMLAYOUT_ANIMATION_THREAD*/
_HTMLAYOUT_TRANSPARENT_WINDOW=@6/*_HTMLAYOUT_TRANSPARENT_WINDOW*/

_HANDLE_INITIALIZATION=@0/*_HANDLE_INITIALIZATION*/
_HANDLE_MOUSE=@1/*_HANDLE_MOUSE*/
_HANDLE_KEY=@2/*_HANDLE_KEY*/
_HANDLE_FOCUS=@4/*_HANDLE_FOCUS*/
_HANDLE_SCROLL=@8/*_HANDLE_SCROLL*/
_HANDLE_TIMER=@0x10/*_HANDLE_TIMER*/
_HANDLE_SIZE=@0x20/*_HANDLE_SIZE*/
_HANDLE_DRAW=@0x40/*_HANDLE_DRAW*/
_HANDLE_DATA_ARRIVED=@0x80/*_HANDLE_DATA_ARRIVED*/
_HANDLE_BEHAVIOR_EVENT=@0x100/*_HANDLE_BEHAVIOR_EVENT*/
_HANDLE_METHOD_CALL=@0x200/*_HANDLE_METHOD_CALL*/
_HANDLE_EXCHANGE=@0x1000/*_HANDLE_EXCHANGE*/
_HANDLE_GESTURE=@0x2000/*_HANDLE_GESTURE*/
_HANDLE_ALL=@0xFFFF/*_HANDLE_ALL*/
_DISABLE_INITIALIZATION=@0x80000000/*_DISABLE_INITIALIZATION*/

_SIH_REPLACE_CONTENT=@0/*_SIH_REPLACE_CONTENT*/
_SIH_INSERT_AT_START=@1/*_SIH_INSERT_AT_START*/
_SIH_APPEND_AFTER_LAST=@2/*_SIH_APPEND_AFTER_LAST*/
_SOH_REPLACE=@3/*_SOH_REPLACE*/
_SOH_INSERT_BEFORE=@4/*_SOH_INSERT_BEFORE*/
_SOH_INSERT_AFTER=@5/*_SOH_INSERT_AFTER*/
end intellisense**/
