//font 字体对话框
/************************************
Author		: lujjjh
Date		: 2010.9
************************************/

namespace win.dlg;
 
font = class {
	ctor(hParent,option){
		var cc = CHOOSEFONT(); 
		cc.structSize = ..raw.sizeof(cc);
		cc.hwndOwner = hParent[["hwnd"]] : hParent;  
		..table.mixin(cc,option );
		cc.logFont = ..raw.malloc( cc.logFont[["_struct"]]?cc.logFont : 60 );  
	} 
	chooseFont = function(){
		var re = ChooseFont(cc);
		var logfont = ..raw.convert(cc.logFont ,LOGFONT())
		logfont.color = cc.rgbColors
		return logfont;
	} 
}

var dll = ..raw.loadDll("comdlg32.dll");
namespace font{
	ChooseFont = dll.api("ChooseFont", "INT(struct &lpcc)");
	class CHOOSEFONT {
   		INT structSize = 60;
   		int hwndOwner;  
   		pointer hDC;  
   		pointer logFont;  
   		int pointSize;
   		INT flags = 0x12143/*_CF_BOTH | _CF_EFFECTS|_CF_FORCEFONTEXIST|_CF_INITTOLOGFONTSTRUCT|_CF_LIMITSIZE*/ ;
   		int rgbColors;  
   		int custData; 
   		pointer lpfnHook; 
   		string templateName;  
   		pointer hInstance; 
   		string style; 
   		WORD fontType = 0x400/*_REGULAR_FONTTYPE*/;
   		WORD ___MISSING_ALIGNMENT__;
   		int sizeMin = 8 ;
   		int sizeMax = 72
	} 
} 

/**intellisense()
win.dlg.font = 通用字体对话框
win.dlg.font(winform__/*父窗体*/) = 创建通用字体对话框
win.dlg.font().chooseFont() = 弹出选择字体对话框\n!logfont.
?.chooseFont = !logfont.
end intellisense**/
