--[[

Common Dialog Module

* about

This is simple wrapper of Win32 Common Dialog Addon to adapt K-Meleon.
See w32cd.txt and MSDN.


* example

** file selection dialog

c, t = GetOpenFileName({
	Filter = "HTML Files(*.html;*.htm)\0*.html;*.htm\0All Files(*.*)\0*.*\0\0",
	FilterIndex = 0,
	InitialDir = "C:\\HOME",
	Title = "Select HTML",
	Flags = OFN_HIDEREADONLY,
	DefExt = "htm",
});


** folder selection dialog

c = SelectDirectory({
	Root = "C:\\HOME",
	Folder = "K-MELEON",
	Title = "K-Meleon",
})


** color selection dialog

t = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000,};
c, t = ChooseColor({
	CustColors = t,
});


** font selection dialog

c, t = ChooseFont({
	LogFont = {
		FaceName = "System",
	},
	Flags = CF_BOTH + CF_INITTOLOGFONTSTRUCT,
});

]]

require "kmplus"

local k, v
for k, v in pairs(w32cd) do
	km[k] = v
end

function km.ChooseColor(cc)
	return w32cd.ChooseColor(km.hwnd, cc)
end
function km.ChooseFont(cf)
	return w32cd.ChooseFont(km.hwnd, cf)
end
function km.GetOpenFileName(ofn)
	return w32cd.GetOpenFileName(km.hwnd, ofn)
end
function km.GetSaveFileName(cc)
	return w32cd.GetSaveFileName(km.hwnd, ofn)
end
function km.SelectDirectory(tbl)
	return w32cd.SelectDirectory(km.hwnd, tbl)
end
