From 918cf2c844f524641396e72c6ecebcc620c57813 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期五, 18 十月 2024 10:23:34 +0800 Subject: [PATCH] update --- jrj/xframe/xcontrol/xsedit.hpp | 356 +++++++++++ jrj/project/business/QuoteFile.cpp | 4 jrj/xframe/xcontrol/xtreeview.hpp | 9 jrj/xframe/devloper/sqlwatch.cpp | 1226 ++++++++++++++++++++++++++++++++++++++++ jrj/xframe/kobject/kxsedit.hpp | 148 ++++ jrj/xframe/win32/win.hpp | 3 jrj/ext-jrj/ext-jrj.vcxproj | 6 jrj/ext-jrj/ext-jrj.vcxproj.filters | 18 8 files changed, 1,761 insertions(+), 9 deletions(-) diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj index 30ebd76..7d78754 100644 --- a/jrj/ext-jrj/ext-jrj.vcxproj +++ b/jrj/ext-jrj/ext-jrj.vcxproj @@ -216,6 +216,7 @@ <ClInclude Include="..\xframe\kobject\kwin.hpp" /> <ClInclude Include="..\xframe\kobject\kxaserver.hpp" /> <ClInclude Include="..\xframe\kobject\kxml.hpp" /> + <ClInclude Include="..\xframe\kobject\kxsedit.hpp" /> <ClInclude Include="..\xframe\platform\nmemory.hpp" /> <ClInclude Include="..\xframe\platform\nstring.hpp" /> <ClInclude Include="..\xframe\system\base.hpp" /> @@ -263,6 +264,7 @@ <ClInclude Include="..\xframe\xcontrol\xlistview.hpp" /> <ClInclude Include="..\xframe\xcontrol\xoffice.hpp" /> <ClInclude Include="..\xframe\xcontrol\xreport.hpp" /> + <ClInclude Include="..\xframe\xcontrol\xsedit.hpp" /> <ClInclude Include="..\xframe\xcontrol\xshtml.hpp" /> <ClInclude Include="..\xframe\xcontrol\xtreeview.hpp" /> <ClInclude Include="framework.h" /> @@ -1135,6 +1137,10 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\xframe\devloper\devloper.cpp" /> + <ClCompile Include="..\xframe\devloper\sqlwatch.cpp"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + </ClCompile> <ClCompile Include="..\xframe\devloper\XDevItemDlg.cpp" /> <ClCompile Include="..\xframe\src\nmemory.cpp" /> <ClCompile Include="..\xframe\src\nstring.cpp" /> diff --git a/jrj/ext-jrj/ext-jrj.vcxproj.filters b/jrj/ext-jrj/ext-jrj.vcxproj.filters index 7e0b9ef..0f6abff 100644 --- a/jrj/ext-jrj/ext-jrj.vcxproj.filters +++ b/jrj/ext-jrj/ext-jrj.vcxproj.filters @@ -465,6 +465,12 @@ <ClInclude Include="JGui.hpp"> <Filter>jarch</Filter> </ClInclude> + <ClInclude Include="..\xframe\kobject\kxsedit.hpp"> + <Filter>xframe\kobject</Filter> + </ClInclude> + <ClInclude Include="..\xframe\xcontrol\xsedit.hpp"> + <Filter>xframe\xcontrol</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> @@ -1421,12 +1427,18 @@ <ClCompile Include="..\project\business\SO\select.gdnitem.so.cpp"> <Filter>project\business\SO</Filter> </ClCompile> - <ClCompile Include="..\project\business\PO\paymentmethod.cpp"> - <Filter>婧愭枃浠�</Filter> - </ClCompile> <ClCompile Include="..\project\business\Expense\maint.Document.Test.v3.cpp"> <Filter>project\business\Expense</Filter> </ClCompile> + <ClCompile Include="..\xframe\devloper\sqlwatch.cpp"> + <Filter>devloper</Filter> + </ClCompile> + <ClCompile Include="..\project\business\Quote\QuoteFilePurch2Select.cpp"> + <Filter>project\business\Quote</Filter> + </ClCompile> + <ClCompile Include="..\project\business\PO\paymentmethod.cpp"> + <Filter>project\business\PO</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <None Include="ext-jrj.def"> diff --git a/jrj/project/business/QuoteFile.cpp b/jrj/project/business/QuoteFile.cpp index a048890..8f3644f 100644 --- a/jrj/project/business/QuoteFile.cpp +++ b/jrj/project/business/QuoteFile.cpp @@ -4235,6 +4235,8 @@ else if (col == colTyp1 || col == colTyp || col == colTyp2 || col == colTyp3) { xstring pitems1 = L""; + pitems1 += (xstring)L"<row><显示列></显示列><数据列>" + + L"</数据列></row>"; pitems1 += (xstring)L"<row><显示列>成品</显示列><数据列>" + L"成品</数据列></row>"; pitems1 += (xstring)L"<row><显示列>散货</显示列><数据列>" @@ -4489,6 +4491,8 @@ else if (col == colTyp1 || col == colTyp) { xstring pitems1 = L""; + pitems1 += (xstring)L"<row><显示列></显示列><数据列>" + + L"</数据列></row>"; pitems1 += (xstring)L"<row><显示列>成品</显示列><数据列>" + L"成品</数据列></row>"; pitems1 += (xstring)L"<row><显示列>散货</显示列><数据列>" diff --git a/jrj/xframe/devloper/sqlwatch.cpp b/jrj/xframe/devloper/sqlwatch.cpp new file mode 100644 index 0000000..b7b61e1 --- /dev/null +++ b/jrj/xframe/devloper/sqlwatch.cpp @@ -0,0 +1,1226 @@ +#include <wobject/xstring.hpp> +#include <wobject/xwin.hpp> +#include <wobject/xaserver.hpp> +#include <wobject/xaserverarg.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xlayersheet.hpp> +#include <xcontrol/xsedit.hpp> +#include <xcontrol/xdwgrid.hpp> +using xml = KXMLDOMDocument; +class __declspec(dllexport) SqlWatchWin : public xwin +{ +public: //xdwgrid dw_list; + + xnode m_agentNode; //Agent Condition + xtreeview m_exploer; + KXMLDOMElement toEle; + xml toXml; + +public: + SqlWatchWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} +public: + static SqlWatchWin* CreateInstance(void* implPtr, void* hWnd) + { + SqlWatchWin* pWin = new SqlWatchWin(implPtr, (HWND)hWnd); + return pWin; + } + + int trace(xstring info) + { +#define EM_SETSEL 0x00B1 +#define EM_REPLACESEL 0x00C2 +#define EM_SCROLL 0x00B5 +#define SB_LINEDOWN 1 + xcontrol xc = GetControl(L"output"); + SendMessage(xc.GetHWND(), EM_SETSEL, -1, 0); + SendMessage(xc.GetHWND(), EM_REPLACESEL, false, (LPARAM)info.c_str()); + SendMessage(xc.GetHWND(), EM_SCROLL, SB_LINEDOWN, 0); + return 1; + } + + int SetAgent() + { + xstring xfNodeAgentArea = L"agentarea"; + xnode anode = GetAgentNode(xfNodeAgentArea); + if (m_agentNode) + { + SetAgentNode(anode, m_agentNode); + } + else + { + KXMLDOMElement xframeElement = GetElement(); + KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*"); + if (agent) + { + xstring s = agent.xml(); + m_agentNode = SetAgentNode(anode, s); + } + } + return 1; + } + + //焦点激活处理函数 + int OnSetFocus(TEvent* evt, LPARAM param) + { + //重置工具条 + SetAgent(); + return 1; + } + + xstring getLink(HTREEITEM hItem) + { + return L"hxerp"; + } + + xstring makeSheet(xstring labels, xstring datas) + { + xstring ls_sheet = L"<sheet ver='10315' editer='xcell' version='3.0' report='true'>"; + + //style + ls_sheet += L"\r\n<stylesheet>"; + ls_sheet += L"\r\n\t<item name='f0'>font-facename:宋体;font-style:normal;font-weight:400;font-size:-21.000000px</item>"; + ls_sheet += L"\r\n\t<item name='f1'>font-facename:宋体;font-style:normal;font-weight:bold;font-size:-21.000000px</item>"; + ls_sheet += L"\r\n</stylesheet>"; + + //axis + ls_sheet += L"\r\n<axis>"; + ls_sheet += L"\r\n\t<col>"; + ls_sheet += L"\r\n\t\t<item width='28' colend='0'/>"; + ls_sheet += L"\r\n\t\t<item width='90' colend='64'/>"; + ls_sheet += L"\r\n\t</col>"; + ls_sheet += L"\r\n\t<row>"; + ls_sheet += L"\r\n\t\t<item height='1' rowend='0'/>"; + ls_sheet += L"\r\n\t\t<item height='24' rowend='64'/>"; + ls_sheet += L"\r\n\t</row>"; + ls_sheet += L"\r\n</axis>"; + + //cell + ls_sheet += L"\r\n<cells>"; + ls_sheet += L"\r\n\t<row><cell colindex='0'><prestr>data/Item</prestr></cell></row>"; + ls_sheet += L"\r\n\t<row rowindex='3'>" + labels + L"\r\n\t</row>"; + ls_sheet += L"\r\n\t<row rowindex='5'>" + datas + L"\r\n\t</row>"; + ls_sheet += L"\r\n</cells>"; + + //report + ls_sheet += L"\r\n<report right='0' left='0'>"; + ls_sheet += L"\r\n\t<PageHeader endRow='1' startRow='1'/>"; + ls_sheet += L"\r\n\t<Header endRow='2' startRow='2'/>"; + ls_sheet += L"\r\n\t<Title endRow='4' startRow='3'/>"; + ls_sheet += L"\r\n\t<Detail endRow='6' startRow='5'/>"; + ls_sheet += L"\r\n\t<Summury endRow='7' startRow='7'/>"; + ls_sheet += L"\r\n\t<Footer endRow='8' startRow='8'/>"; + ls_sheet += L"\r\n\t<PageFooter endRow='9' startRow='9'/>"; + ls_sheet += L"\r\n</report>"; + + ls_sheet += L"\r\n</sheet>"; + + return ls_sheet; + } + + int OnProcessUrl(xstring kind, xstring url) + { + xml x; + xaserverarg xarg; + xarg.AddArg(L"url", url); + xarg.AddArg(L"kind", kind); + xaserver::ExecXQuery(GetServerUrl(), L"[service.url.info.xq]", xarg.GetString(), x); + alert(x.xml()); + return 1; + } + + int FetchVSql() + { + xsedit xs; + xstring content = L""; + xs = GetControl(L"sqlcontent"); + int start = xs.GetSelectionStart(); + int end = xs.GetSelectionEnd(); + xs.GetContent(content); + if (start != end) + { + content = content.mid(start, end - start); + } + + xml x; + xaserverarg xarg ; + xarg.AddArg(L"func", L"fetch-vsql"); + xarg.AddArg(L"sql", content.c_str()); + xarg.AddArg(L"xquery", L""); + xaserver::ExecXQuery(GetServerUrl(), L"[sqlExec.xq]", xarg.GetString(), x); + if (x) + { + trace(x.text()); + } + else + trace(L"have a error"); + return 1; + } + + int FetchSql() + { + xsedit xs; + xstring content = L""; + xs = GetControl(L"sqlcontent"); + int start = xs.GetSelectionStart(); + int end = xs.GetSelectionEnd(); + xs.GetContent(content); + if (start != end) + { + content = content.mid(start, end - start); + } + + xml x ; + xaserverarg xarg; + xarg.AddArg(L"func", L"fetch-sql"); + xarg.AddArg(L"sql", content); + xarg.AddArg(L"xquery", L""); + xaserver::ExecXQuery(GetServerUrl(), L"[sqlExec.xq]", xarg.GetString(), x); + if (x) + { + trace(x.text()); + } + else + trace(L"have a error"); + return 1; + } + + xstring GetFolder(xstring file) + { + int pos = 0; + int pos1 = 0; + pos = file.find(L"/", pos); + while (pos) + { + pos1 = file.find(L"/", pos + 1); + if (pos1 < 0) break; + pos = pos1; + } + if (pos > 0) + return file.left(pos); + else + return L""; + } + + int surePath(xstring base, xstring file) + { + CreateDirectory(base, nullptr); + if (file == L"") return 1; + + xstring src = file; + int pos = src.find(L"/"); + while (pos >= 0) + { + xstring folder = src.left(pos); + pos = src.find(L"/", pos + 1); + if(src.left(1)==L"/") + CreateDirectory(base + folder, __nullptr); + else + CreateDirectory(base + L"/" + folder, nullptr); + } + return 1; + } + + int processhxw(xstring base, xstring sfile) + { + surePath(base, sfile); + int ret = DownLoadFile2(sfile, base + sfile); + if (ret < 0) + { + trace(L"\r\n error load:" + sfile + L" " + base + L"/" + sfile); + return -1; + } + + xml x ; + x.load(base + L"/" + sfile); + KXMLDOMNodeList items = x.selectNodes(L"/category/domain/folder[count(@deleted)=0]"); + int len = items.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMNode node = items.item(i); + xstring src = node.selectSingleNode(L"@src").text(); + if (src.find(L"mh.com") < 0) + { + src = src.replace(L"\\", L"/"); + processhxd(base + L"/developer", src); + } + } + } + + int reconnect() + { + SendMessage(GetFrameWindow().GetHWND(), 0x401, (LPARAM)L"xmAuth", 0); + return 1; + } + + int DownLoadFile2(xstring src, xstring dest) + { + int ret = xaserver::DownLoadFile(GetServerUrl(), src, L"", dest); + if (ret < 0) + { + reconnect(); + ret = xaserver::DownLoadFile(GetServerUrl(), src, L"", dest); + } + if (ret < 0)reconnect(); + return ret; + } + + int processprj1(xstring base, xstring path, xstring src, bool processItem) + { + //xcontrol xc = GetControl(L"frame:output"); + //xc.SetText(L"\r\n process: "+path+L"/"+src); + + trace(L"\r\n base:" + base); + surePath(base + L"/" + path, src); + int ret = DownLoadFile2(L"/developer/" + path + L"/" + src, base + L"/" + path + L"/" + src); + if (ret < 0) + { + trace(L"\r\nerror load /developer/" + path + L"/" + src + L" " + base + L"/" + path + L"/" + src); + reconnect(); + return 1; + } + trace(L"\r\n prj /developer/" + path + L"/" + src + L" " + base + L"/" + path + L"/" + src); + + xml x; + if (!x.load(base + L"/" + path + L"/" + src)) + { + trace(L"\r\nerror load:" + base + L"/" + path + L"/" + src); + return 1; + } + + KXMLDOMNodeList items = x.selectNodes(L"//file[count(@deleted)=0]"); + xstring caption = x.documentElement().getAttribute(L"caption");; + xstring srcpath = GetFolder(src); + if (caption == L"") + { + trace(L"\r\nerror caption:" + base + L"/" + path + L"/" + src); + return 1; + } + + xstring spath = L"/developer/" + path + L"/" + srcpath + L"/" + caption; + xstring dpath = base + L"/" + path + L"/" + srcpath + L"/" + caption; + + surePath(dpath, L""); + int len = items.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMNode node = items.item(i); + + xstring srcItem = L""; + xstring id = L""; + if (node.selectSingleNode(L"@guid")) id = node.selectSingleNode(L"@guid").text(); + if (node.selectSingleNode(L"@src")) srcItem = node.selectSingleNode(L"@src").text(); + xstring typ = L""; + if (node.selectSingleNode(L"@type")) typ = node.selectSingleNode(L"@type").text(); + xstring values = L""; + if (srcItem != L"" && typ != L"") + { + ret = DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", dpath + L"/" + srcItem); + if (ret < 0) + { + trace(L"\r\nerror load dev:" + typ + L"[" + srcItem + L"]" + L" " + dpath + L"/" + srcItem); + continue; + //return 1; + } + CreateDirectory(base + L"/working", nullptr); + CreateDirectory(base + L"/working/code", nullptr); + CreateDirectory(base + L"/working/sheets", nullptr); + if (id != L"") + { + if (typ == L"xruler") + { + CreateDirectory(base + L"/working/" + typ + L"s", nullptr); + DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", base + L"/working" + L"/" + typ + L"s/" + id + L".xrl"); + } + else if (typ == L"serialize") + { + CreateDirectory(base + L"/working/" + typ, nullptr); + DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", base + L"/working" + L"/" + typ + L"/" + id + L".xml"); + } + else if (typ == L"workflow" || typ == L"worknode" || typ == L"xaction" || typ == L"template" || typ == L"xfile" + || typ == L"xquery" || typ == L"entity" || typ == L"xpage") + { + CreateDirectory(base + L"/working/" + typ + L"s", nullptr); + DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", base + L"/working" + L"/" + typ + L"s/" + id + L".xml"); + } + else + { + CreateDirectory(base + L"/working/" + typ, nullptr); + DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", base + L"/working" + L"/" + typ + L"/" + id); + } + + values = L""; + if (xutil::HasCacheData(L"object-types"))values = xutil::GetUrlData(L"object-types"); + if (values.find(L",L" + typ + L",L") < 0) values += L",L" + typ + L",L"; + xutil::CacheUrlData(L"object-types", values); + + values = L""; + if (xutil::HasCacheData(typ))values = xutil::GetUrlData(typ); + if (values != L"") values += L"\r\n"; + values += L"T(\"" + srcItem + L"\",\"" + id + L"\",\"" + spath + L"/" + srcItem + L"\")"; + xutil::CacheUrlData(typ, values); + } + if (typ == L"template") + { + xml xtempl; + if (xtempl.load(base + L"/working" + L"/" + typ + L"s/" + id + L".xml")) + { + KXMLDOMNodeList nodes = xtempl.selectNodes(L"/xdoc/sheet"); + int count = nodes.length(); + for (int k = 0; k < count; k++) + { + KXMLDOMNode tnode = nodes.item(k); + xstring content = tnode.xml(); + xstring sheetid = L""; + xstring sheetcaption = L""; + if (node.selectSingleNode(L"@guid")) sheetid = tnode.selectSingleNode(L"@guid").text(); + if (node.selectSingleNode(L"@caption")) sheetcaption = tnode.selectSingleNode(L"@caption").text(); + xutil::SaveToFile(base + L"/working/sheets/" + sheetid + L".xml", content, L"", L"", (LPTSTR)L""); + tnode.Release(); + + values = L""; + if (xutil::HasCacheData(L"object-types"))values = xutil::GetUrlData(L"object-types"); + if (values.find(L",sheet,L") < 0) values += L",sheet,L"; + xutil::CacheUrlData(L"object-types", values); + + values = L""; + xstring str = L""; + if (xutil::HasCacheData(L"sheet"))values = xutil::GetUrlData(L"sheet"); + str = L"\r\n"; + if (id != L"")str += L"T(\"" + srcItem + L"/" + id + L"\",\"" + id + L"\")"; + str += L"\r\n"; + if (sheetcaption != L"")str += L"T(\"" + srcItem + L"/" + sheetcaption + L"\",\"" + id + L"\")"; + values += str; + xutil::CacheUrlData(L"sheet", values); + } + } + } + if (typ == L"xpage") + { + xstring srccode = srcItem.replace(L".xpage", L".xss"); + srccode = srccode.replace(L".vx", L".xss"); + ret = DownLoadFile2(L"dev:code[" + srcItem + L"]", dpath + L"/" + srccode); + if (ret < 0) + { + trace(L"\r\nerror load dev:code[" + srcItem + L"]" + L" " + dpath + L"/" + srccode); + continue; + //return 1; + } + if (id != L"") DownLoadFile2(L"dev:code[" + srcItem + L"]", base + L"/working" + L"/code/" + id + L".xss"); + + values = L""; + if (xutil::HasCacheData(L"object-types"))values = xutil::GetUrlData(L"object-types"); + if (values.find(L",code,L") < 0) values += L",code,L"; + xutil::CacheUrlData(L"object-types", values); + + values = L""; + if (xutil::HasCacheData(typ))values = xutil::GetUrlData(typ); + if (values != L"") values += L"\r\n"; + values += L"T(\"" + srcItem + L"\",\"" + id + L"\",\"" + spath + L"\"" + srcItem + L"\")"; + xutil::CacheUrlData(L"code", values); + } + } + } + trace(L" -- finished"); + return 1; + } + + int processprj_xml(xstring base, xstring path, xstring src, bool processItem) + { + //xcontrol xc = GetControl(L"frame:output"); + //xc.SetText(L"\r\n process: "+path+L"/"+src); + + trace(L"\r\n base:" + base); + surePath(base + L"/" + path, src); + int ret = DownLoadFile2(L"/developer/" + path + L"/" + src, base + L"/" + path + L"/" + src); + if (ret < 0) + { + trace(L"\r\nerror load /developer/" + path + L"/" + src + L" " + base + L"/" + path + L"/" + src); + return 1; + } + trace(L"\r\n prj /developer/" + path + L"/" + src + L" " + base + L"/" + path + L"/" + src); + + xml x; + + if (!x.load(base + L"/" + path + L"/" + src)) + { + trace(L"\r\nerror load:" + base + L"/" + path + L"/" + src); + return 1; + } + + KXMLDOMNodeList items = x.selectNodes(L"//file[count(@deleted)=0]"); + xstring caption = x.documentElement().getAttribute(L"caption");; + xstring srcpath = GetFolder(src); + if (caption == L"") + { + trace(L"\r\nerror caption:" + base + L"/" + path + L"/" + src); + return 1; + } + + xstring spath = L"/developer/" + path + L"/" + srcpath + L"/" + caption; + xstring dpath = base + L"/" + path + L"/" + srcpath + L"/" + caption; + + surePath(dpath, L""); + int len = items.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMNode node = items.item(i); + trace(L"."); + + xstring srcItem = L""; + xstring id = L""; + if (node.selectSingleNode(L"@guid")) id = node.selectSingleNode(L"@guid").text(); + if (node.selectSingleNode(L"@src")) srcItem = node.selectSingleNode(L"@src").text(); + xstring typ = L""; + if (node.selectSingleNode(L"@type")) typ = node.selectSingleNode(L"@type").text(); + xstring values = L""; + if (srcItem != L"" && typ != L"") + { + ret = DownLoadFile2(L"dev:" + typ + L"[" + srcItem + L"]", dpath + L"/" + srcItem); + if (ret < 0) + { + trace(L"\r\nerror load dev:" + typ + L"[" + srcItem + L"]" + L" " + dpath + L"/" + srcItem); + continue; + //return 1; + } + CreateDirectory(base + L"/working", nullptr); + CreateDirectory(base + L"/working/code", nullptr); + CreateDirectory(base + L"/working/sheets", nullptr); + if (id != L"") + { + if (typ == L"xruler") + { + CreateDirectory(base + L"/working/" + typ + L"s", nullptr); + //DownLoadFile2(L"dev:"+typ+L"["+srcItem+L"]",base+L"/working"+L"/"+typ+L"s/"+id+L".xrl"); + DownLoadFile2(L"dev:" + typ + id, base + L"/working" + L"/" + typ + L"s/" + id + L".xrl"); + } + else if (typ == L"serialize") + { + CreateDirectory(base + L"/working/" + typ, nullptr); + //DownLoadFile2(L"dev:"+typ+L"["+srcItem+L"]",base+L"/working"+L"/"+typ+L"/"+id+L".xml"); + DownLoadFile2(L"dev:" + typ + id, base + L"/working" + L"/" + typ + L"/" + id + L".xml"); + } + else if (typ == L"workflow" || typ == L"worknode" || typ == L"xaction" || typ == L"template" || typ == L"xfile" + || typ == L"xquery" || typ == L"entity" || typ == L"xpage") + { + CreateDirectory(base + L"/working/" + typ + L"s", nullptr); + //DownLoadFile2(L"dev:"+typ+L"["+srcItem+L"]",base+L"/working"+L"/"+typ+L"s/"+id+L".xml"); + DownLoadFile2(L"dev:" + typ + id, base + L"/working" + L"/" + typ + L"s/" + id + L".xml"); + } + else + { + CreateDirectory(base + L"/working/" + typ, nullptr); + //DownLoadFile2(L"dev:"+typ+L"["+srcItem+L"]",base+L"/working"+L"/"+typ+L"/"+id); + DownLoadFile2(L"dev:" + typ + id, base + L"/working" + L"/" + typ + L"/" + id); + } + appendto(typ, L"T(\"" + srcItem + L"\",\"" + id + L"\",\"" + spath + L"/" + srcItem + L"\")[ln]"); + } + + if (typ == L"template") + { + xml xtempl; + if (xtempl.load(base + L"/working" + L"/" + typ + L"s/" + id + L".xml")) + { + KXMLDOMNodeList nodes = xtempl.selectNodes(L"/xdoc/sheet"); + int count = nodes.length(); + for (int k = 0; k < count; k++) + { + KXMLDOMNode tnode = nodes.item(k); + xstring content = tnode.xml(); + xstring sheetid = L""; + xstring sheetcaption = L""; + if (node.selectSingleNode(L"@guid")) sheetid = tnode.selectSingleNode(L"@guid").text(); + if (node.selectSingleNode(L"@caption")) sheetcaption = tnode.selectSingleNode(L"@caption").text(); + xutil::SaveToFile(base + L"/working/sheets/" + sheetid + L".xml", content, L"", L"", (LPTSTR)L""); + + appendto(L"sheet", L"T(\"" + srcItem + L"/" + sheetid + L"\",\"" + sheetid + L"\")[ln]"); + appendto(L"sheet", L"T(\"" + srcItem + L"/" + sheetcaption + L"\",\"" + sheetid + L"\")[ln]"); + } + } + } + if (typ == L"xpage") + { + xstring srccode = srcItem.replace(L".xpage", L".xss"); + srccode = srccode.replace(L".vx", L".xss"); + ret = DownLoadFile2(L"dev:code[" + srcItem + L"]", dpath + L"/" + srccode); + if (ret < 0) + { + trace(L"\r\nerror load dev:code[" + srcItem + L"]" + L" " + dpath + L"/" + srccode); + continue; + //return 1; + } + if (id != L"") + { + DownLoadFile2(L"dev:code[" + srcItem + L"]", base + L"/working" + L"/code/" + id + L".xss"); + //DownLoadFile2(L"dev:code"+id,base+L"/working"+L"/code/"+id+L".xss"); + appendto(L"code", L"T(\"" + srcItem + L"\",\"" + id + L"\",\"" + spath + L"\"" + srcItem + L"\")[ln]"); + } + } + } + } + trace(L" -- finished"); + return 1; + } + + int processhxd(xstring base, xstring sfile) + { + surePath(base, sfile); + trace(L"\r\n" + base + L"/" + sfile); + int ret = DownLoadFile2(L"/developer/" + sfile, base + L"/" + sfile); + if (ret < 0) + { + trace((xstring)L"\r\n error load:" + L"/developer/" + sfile + L" " + base + L"/" + sfile); + return -1; + } + + xml xhd ; + xhd.load(base + L"/" + sfile); + + KXMLDOMNodeList items = xhd.selectNodes(L"//project[count(@deleted)=0]"); + int len = items.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMNode node = items.item(i); + xstring src = L""; + if (node.selectSingleNode(L"@src")) src = node.selectSingleNode(L"@src").text(); + if (src != L"") + { + xstring path = GetFolder(sfile); + src = src.replace(L"\\", L"/"); + processprj_xml(base, path, src, true); + } + } + return 1; + } + + int Initenv() + { + xstring values = L""; + if (xutil::HasCacheData(L"object-types"))values = xutil::GetUrlData(L"object-types"); + values = values.replace(L",,L", L",L"); + if (values != L"") + { + int pos = values.find(L",L", 0); + xstring typ = L""; + while (pos >= 0) + { + int pos1 = values.find(L",L", pos + 1); + if (pos1 < 0) break; + typ = values.mid(pos + 1, pos1 - pos - 1); + xutil::CacheUrlData(typ, L""); + if (pos1 == values.length())break; + pos = pos1; + } + } + return 1; + } + int Initenv_xml() + { + if (!toXml) + { + toXml = xml(); + } + else + { + if (toEle)toEle.Release(); + } + toXml.loadXML(L"<root/>"); + toEle = toXml.documentElement(); + return 1; + } + + int appendto(xstring typ, xstring val) + { + KXMLDOMElement ele; + KXMLDOMDocument doc = toEle.ownerDocument(); + KXMLDOMNode node = toEle.selectSingleNode(L"to[@name='" + typ + L"']"); + if (!node) + { + ele = doc.createElement(L"to"); + ele.setAttribute(L"name", typ); + toEle.appendChild(ele); + } + else + { + ele = node; + //node.Release(); + } + KXMLDOMElement t = doc.createElement(L"item"); + t.settext(val); + ele.appendChild(t); + return 1; + } + + int maketo_xml(xstring base) + { + toXml.save(base + L"/developer/working/index.xml"); + //return 1; + KXMLDOMNodeList items = toEle.selectNodes(L"to"); + int lens = items.length(); + xstring typ; + xstring val; + KXMLDOMNode node; + for (int i = 0; i < lens; i++) + { + node = items.item(i).selectSingleNode(L"@name"); + if (node) + { + typ = node.text(); + } + val = items.item(i).text(); + val = val.replace(L"[ln]", L"\r\n"); + xutil::SaveToFile(base + L"/developer/working/" + typ + L".tu", val, L"", L"", (LPTSTR)L""); + } + return 1; + } + + int maketo(xstring base) + { + xstring values = L""; + xstring tvalue = L""; + if (xutil::HasCacheData(L"object-types"))values = xutil::GetUrlData(L"object-types"); + values = values.replace(L",,L", L",L"); + trace(values); + if (values != L"") + { + int len = values.length(); + int pos = values.find(L",L", 0); + xstring typ = L""; + while (pos >= 0) + { + int pos1 = values.find(L",L", pos + 1); + if (pos1 < 0) break; + typ = values.mid(pos + 1, pos1 - pos - 1); + tvalue = L""; + if (xutil::HasCacheData(typ))tvalue = xutil::GetUrlData(typ); + xutil::SaveToFile(base + L"/developer/working/" + typ + L".tu", xutil::GetUrlData(typ), L"", L"", (LPTSTR)L""); + if (pos1 == len)break; + pos = pos1; + } + } + return 1; + } + + int OnExport() + { + Initenv_xml(); + + int EM_EXLIMITTEXT = 0x400 + 53; + xcontrol xc = GetControl(L"output"); + //xcontrol xc = GetControl(L"frame:output"); + trace(L"\r\nstart export:"); + SendMessage(xc.GetHWND(), EM_EXLIMITTEXT, 0x00100000, 0); + int ret = processhxw(L"D:/jrjhome", L"/developer/projects/Projects.xhw"); + + trace(L"\r\nstart make to"); + maketo_xml(L"D:/jrjhome"); + trace(L"\r\nfinish export"); + return ret; + } + + //命令发布函数 + int OnCmdDispatch(xstring comdid) + { + xsedit xs; + HCURSOR hCursor = xutil::SetCursorWait(); + xstring content = L""; + int result = 1; + if (comdid == L"xmCheckUrl") + { + xstring url1 = xcontrol(GetControl(L"frame:url")).GetText(); + return OnProcessUrl(L"info", url1); + } + else if (comdid == L"xmExport") + { + return OnExport(); + } + else if (comdid == L"xmClearBuffer") + { + xstring url2 = xcontrol(GetControl(L"frame:url")).GetText(); + return OnProcessUrl(L"clearbuffer", url2); + } + else if (comdid == L"xmFetchSql") + { + return FetchSql(); + } + else if (comdid == L"xmFetchVSql") + { + return FetchVSql(); + } + else if (comdid == L"xmSqlExec" || comdid == L"xmXQueryExec") + { + xs = GetControl(L"sqlcontent"); + int start = xs.GetSelectionStart(); + int end = xs.GetSelectionEnd(); + xs.GetContent(content); + if (start != end) + { + content = content.mid(start, end - start); + } + //alert(content); + + xml x; + xaserverarg xarg ; + xarg.AddArg(L"func", L"exec"); + if (comdid == L"xmXQueryExec") + { + xarg.AddArg(L"sql", L""); + xarg.AddArg(L"xquery", content); + } + else + { + xarg.AddArg(L"sql", content); + xarg.AddArg(L"xquery", L""); + } + + xaserver::ExecXQuery(GetServerUrl(), L"[sqlExec.xq]", xarg.GetString(), x); + + trace(x.xml()); + + KXMLDOMNodeList n = x.selectNodes(L"data/Item[1]/*"); + int len = n.length(); + xstring ls_labels = L""; + xstring ls_datas = L""; + for (int i = 0; i < len; i++) + { + KXMLDOMElement t = n.item(i); + xstring name = t.tagName(); + ls_labels += L"\r\n<cell><text>" + name + L"</text></cell>"; + ls_datas += L"\r\n<cell group='.' column='" + name + L"'></cell>"; + } + xstring ls_sheet = makeSheet(ls_labels, ls_datas); + xml x1; + x1.loadXML(ls_sheet); + //trace(ls_sheet); + + xdwgrid dw_list = GetControl(L"dw_list"); + dw_list.SetDataObject(x1); + dw_list.Retrieve(x); + dw_list.Redraw(); + } + else if (comdid == L"xmSaveAs") + { + xdwgrid dw_list1 = GetControl(L"dw_list"); + + + dw_list1.SaveAs(L""); + + return 1; + } + else if (comdid == L"xmEntitySel") + { + xaserverarg arg; + OpenWindow(L"dev:xpage[sqlSelect.vx]", arg); + xstring str = arg.GetArgString(L"select"); + { + xs = GetControl(L"sqlcontent"); + xs.GetContent(content); + int pos = xs.GetSelectionStart(); + + xstring txt = content.left(pos); + txt += str + L"\r\n"; + txt += content.right(content.length() - pos + 1); + xs.SetContent(txt, L".sql"); + } + } + else if (comdid == L"xmEditFind") + { + xutil::RestoreCursor(hCursor); + xs = GetControl(L"sqlcontent"); + xs.OnFindDlg(); + } + else if (comdid == L"xmEditReplace") + { + xutil::RestoreCursor(hCursor); + xs = GetControl(L"sqlcontent"); + xs.OnReplaceDlg(); + } + else + result = 0; + + xutil::RestoreCursor(hCursor); + return result; + } + + int CreateSubTree(HTREEITEM hitem, KXMLDOMNode e) + { + KXMLDOMNodeList listn = e.selectNodes(L"entity"); + int nlen = listn.length(); + int i = 0; + for (i = 0; i < nlen; i++) + { + KXMLDOMElement n = listn.item(i); + xstring cp = n.getAttribute(L"name"); + if (cp) + { + HTREEITEM pitem = m_exploer.InsertChildItem(hitem, cp, (LPARAM)n, 16); + } + } + return 1; + } + + int setGrid(KXMLDOMElement e, xstring caption) + { + xml x; + + xdwgrid grid = GetControl(caption); + if (!e.selectSingleNode(L"grid/sheet")) return 0; + x.loadXML(e.selectSingleNode(L"grid/sheet").xml()); + grid.SetDataObject(x); + if (!e.selectSingleNode(L"datas")) + { + grid.Redraw(); + return 0; + } + x.loadXML(e.selectSingleNode(L"datas").xml()); + grid.Retrieve(x); + grid.Redraw(); + return 1; + } + + xstring getCaption(xstring str) + { + while (str.find(L"@", 0) > 0) + { + xstring tmp = str.mid(str.find(L"@", 0) + 1, str.length()); + str = tmp; + } + return str; + } + + int OnDel(HTREEITEM item) + { + return 1; + } + + int OnRefresh(HTREEITEM item) + { + while (m_exploer.GetChildItem(item)) + m_exploer.DeleteItem(m_exploer.GetChildItem(item)); + OnTreeExpand(item); + return 1; + } + + KXMLDOMElement OnXQuery(xstring data) + { + HTREEITEM hItem = m_exploer.GetSelectedItem(); + xstring link = getLink(hItem); + xml x; + + xaserverarg arg ; + arg.AddArg(L"type", data); + arg.AddArg(L"link", link); + + if (xaserver::ExecXQuery(GetServerUrl(), L"[sqlWatch.xq]", arg.GetString(), x) != 1) { + trace(x.xml()); + return KXMLDOMElement(); + } + return x.documentElement(); + } + + int OnOpen(xstring caption, xstring kind) + { + return 1; + } + + int OnQuery(xstring caption) + { + if (OnOpen(caption, L"query") == 0) return 0; + //KXMLDOMElement e = OnXQuery(L"column@"+caption); + KXMLDOMElement e = OnXQuery(L"Entity/Table/Query@" + caption); + if (!e) return 0; + KXMLDOMNodeList nodes = e.selectNodes(L"columns/column"); + int i; + int s = nodes.length(); + xstring str; + str = L"SELECT TOP 500 \r\n"; + for (i = 0; i < s; i++) + { + KXMLDOMElement ele = nodes.item(i); + xstring tmp = ele.getAttribute(L"name"); + if (i < s - 1) tmp = tmp + L",L"; + str += L"\t" + tmp + L"\r\n"; + } + //str += L"FROM " + caption; + str += L"FROM {qt:Entity('" + caption + L"')} "; + + xstring content; + xsedit xs = GetControl(L"sqlcontent"); + xs.GetContent(content); + content += L"\r\n" + str; + xs.SetContent(content, L".sql"); + + /*xsedit xs = GetControl(L"sql_"+caption); + xs.LoadContent(str,L".sql"); + + setGrid(e,L"grid_"+caption); + */ + + //trace(e.xml); + setGrid(e, L"dw_list"); + + return 1; + } + + int OnEdit(xstring caption) + { + /* + if(OnOpen(caption,L"edit")==0) return 0; + KXMLDOMElement e = OnXQuery(L"edit@"+caption); + if(!e) return 0; + setGrid(e,L"editgrid_"+caption); + */ + return 1; + } + + int OnDesign(xstring caption) + { + if (OnOpen(caption, L"design") == 0) return 0; + OpenWindow(L"dev:xpage[SqlTypeFieldMaint.vx]", caption); + /* + if(OnOpen(caption,L"design")==0) return 0; + KXMLDOMElement e = OnXQuery(L"design@"+caption); + if(!e) return 0; + setGrid(e,L"designgrid_"+caption);*/ + return 1; + } + + int OnTreeRClick(TEvent* evt,LPARAM param) + { + TVNNMHDR& nmtv = *(TVNNMHDR*)evt->notify.pnmh; + HTREEITEM item = nmtv.FromItem; + xstring data = m_exploer.GetItemData(item); + xstring popup; + xstring menu = L"<root>"; + xstring str = L""; + if (data == L"table") + { + menu += L"<Item>新建表</Item>"; + menu += L"<Item>新建分组</Item>"; + menu += L"<Item>-</Item>"; + menu += L"<Item>刷新</Item>"; + menu += L"</root>"; + str = m_exploer.PopupMenu(menu); + popup = str; + } + else if (data.left(13) == L"Entity/Table@" && data.find(L"@", 14) < 0) + { + menu += L"<Item>新建实体</Item>"; + menu += L"<Item>设计</Item>"; + menu += L"<Item>-</Item>"; + menu += L"<Item>打开前500行</Item>"; + menu += L"<Item>编辑前200行</Item>"; + menu += L"<Item>-</Item>"; + menu += L"<Item>重命名</Item>"; + menu += L"<Item>刷新</Item>"; + menu += L"<Item>删除</Item>"; + menu += L"</root>"; + + str = m_exploer.PopupMenu(menu); + popup = str; + } + else if (data.left(6) == L"table@" && data.find(L"@", 7) < 0) + { + menu += L"<Item>新建表</Item>"; + menu += L"<Item>设计</Item>"; + menu += L"<Item>-</Item>"; + menu += L"<Item>打开前500行</Item>"; + menu += L"<Item>编辑前200行</Item>"; + menu += L"<Item>-</Item>"; + menu += L"<Item>重命名</Item>"; + menu += L"<Item>刷新</Item>"; + menu += L"<Item>删除</Item>"; + menu += L"</root>"; + str = m_exploer.PopupMenu(menu); + popup = str; + } + else if (data.left(6) == L"group@") + { + menu += L"<Item>重命名</Item>"; + menu += L"<Item>刷新</Item>"; + menu += L"<Item>删除</Item>"; + menu += L"</root>"; + str = m_exploer.PopupMenu(menu); + popup = str; + } + else if (data.left(5) == L"view@" || data.left(10) == L"procedure@" || data.left(9) == L"function@") + { + menu += L"<Item>重命名</Item>"; + menu += L"<Item>修改</Item>"; + menu += L"<Item>删除</Item>"; + menu += L"</root>"; + str = m_exploer.PopupMenu(menu); + popup = str; + } + + xstring caption = getCaption(data); + /*if(popup == L"新建分组") + OnNewGroup(item); + else*/ if (popup == L"删除") + OnDel(item); + else if (popup == L"刷新") + OnRefresh(item); + else if (popup == L"打开前500行") + OnQuery(caption); + else if (popup == L"编辑前200行") + OnEdit(caption); + else if (popup == L"设计") + OnDesign(caption); + /*else if(popup == L"新建表") + { + xstring guid = GetGuid(); + xstring text = L"Table_" + guid.mid(1,8); + OnDesign(text); + } + else if(popup == L"修改") + OnOpen(caption,L"query");*/ + return 1; + } + + int OnTreeAdd(HTREEITEM hItem, xstring typ, KXMLDOMElement e) + { + KXMLDOMNodeList nodes = e.selectNodes(L"*"); + int i; + int s = nodes.length(); + for (i = 0; i < s; i++) + { + KXMLDOMElement ele = nodes.item(i); + xstring name = ele.getAttribute(L"name"); + xstring image = ele.getAttribute(L"image"); + xstring d = ele.getAttribute(L"data"); + xstring c = ele.getAttribute(L"child"); + image = L"" + image; + if (d == L"") + d = typ + L"@" + name; + HTREEITEM j = m_exploer.InsertChildItem(hItem, L"" + name, (LPARAM)d.c_str(true), image.toInt()); + if (c != L"") + { + if (c.toInt() > 0)m_exploer.SetItemChild1(j, 1); + } + else + { + if (image.toInt() > 9)m_exploer.SetItemChild1(j, 1); + } + OnTreeAdd(j, d, ele); + } + return 1; + } + + int OnTreeExpand(HTREEITEM hItem) + { + xstring typ = m_exploer.GetItemData(hItem); + xstring link = getLink(hItem); + xml x; + + xaserverarg arg; + arg.AddArg(L"type", typ); + arg.AddArg(L"link", link); + + if (xaserver::ExecXQuery(GetServerUrl(), L"[sqlWatch.xq]", arg.GetString(), x) != 1) + { + trace(x.xml()); + return 0; + } + KXMLDOMElement e = x.documentElement(); + OnTreeAdd(hItem, typ, e); + return 1; + } + + int OnTreeExpanding(TEvent* evt, int p) + { + NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; + HTREEITEM hItem = nmtv.itemNew.hItem; + if (m_exploer.GetChildItem(hItem)) return 0; + OnTreeExpand(hItem); + return 1; + } + + int CreateRootTree(xml x) + { + KXMLDOMNodeList listx = x.selectNodes(L"//group"); + int nlen = listx.length(); + int i = 0; + for (i = 0; i < nlen; i++) + { + KXMLDOMElement n = listx.item(i); + xstring cp = n.getAttribute(L"caption"); + if (cp) + { + HTREEITEM hitem = m_exploer.InsertChildItem( 0, cp, n, 15); + trace(xstring((_int64)hitem).c_str()); + CreateSubTree(hitem, n); + m_exploer.ExpandItemAll(hitem); + } + } + return 1; + } + + int ExpandChildFolder(HTREEITEM hItem, KXMLDOMElement pElement) + { + KXMLDOMNodeList nlist = pElement.selectNodes(L"Item"); + int len = nlist.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMElement e = nlist.item(i); + xstring name = e.getAttribute(L"name"); + xstring sImage = e.getAttribute(L"image"); + xstring data = e.getAttribute(L"data"); + int image = 15; + if (sImage) image = sImage.toInt(); + HTREEITEM h = m_exploer.InsertChildItem(hItem, name, (LPARAM)data.c_str(true), image); + m_exploer.SetItemChild(h, 1); + ExpandChildFolder(h, e); + } + return 1; + } + + int InitialFolder() + { + KXMLDOMElement xframeElement = GetElement(); + KXMLDOMElement e = xframeElement.selectSingleNode(L"//xtree[@name='tv_exploer']/initial"); + ExpandChildFolder(0, e); + return 1; + } + + //命令处理事件 + int OnXCommand(TEvent* evt, LPARAM param) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + //绑定工具条点击事件 + AttachEvent(L"WM_XCOMMAND", (FEvent) & SqlWatchWin::OnXCommand); + //获取焦点事件,用于重置工具条 + AttachEvent(L"WM_SETFOCUS", (FEvent)&SqlWatchWin::OnSetFocus); + AttachEvent(L"tv_exploer", L"TVN_ITEMEXPANDING", (FEvent)&SqlWatchWin::OnTreeExpanding); + AttachEvent(L"tv_exploer", L"TVN_RCLICK", (FEvent)&SqlWatchWin::OnTreeRClick); + return 1; + } + + int onload() + { + OnAttachEvent(); + m_exploer = GetControl(L"tv_exploer"); + + xml x; + + + InitialFolder(); + //if(xaserver::FetchXml(L"",L"dev:xml[sale.entity.xml]",L"",x)==1)CreateRootTree(x); + + xsedit xs = GetControl(L"sqlcontent"); + xs.SetContent(L"--import 'qx.object.xq'", L".sql"); + + + return 1; + } + + int onloaded() + { + SetAgent(); + + + return 1; + } +}; \ No newline at end of file diff --git a/jrj/xframe/kobject/kxsedit.hpp b/jrj/xframe/kobject/kxsedit.hpp new file mode 100644 index 0000000..1f900d7 --- /dev/null +++ b/jrj/xframe/kobject/kxsedit.hpp @@ -0,0 +1,148 @@ +#pragma once + +#include "kcontrol.hpp" +namespace Hxsoft { namespace XFrame { + +class IXSEdit : public IXFControl +{ +public: + + // @access public macro members + // @cmember return linenumber display flag + BOOL GetDisplayLinenumbers(); + // @cmember return selection display flag + BOOL GetDisplaySelection(); + // @cmember return folding margin display flag + BOOL GetDisplayFolding(); + // @cmember set search flags + void SetSearchflags(int nSearchflags); + int GetSearchflags(); + +public: + // @access public function members + // @cmember register a window class to use scintilla in a dialog + //static BOOL Register(CWinApp *app, UINT id); + // @cmember try to load Lexer DLL + static HMODULE LoadScintillaDll(LPCTSTR szLexerDll = NULL); + // @cmember create window + // BOOL Create (LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); + // @cmember Set Text to the Scintilla control + void SetText(LPCTSTR szText); + // @cmember Get Text from the Scintilla control + void GetText(LPTSTR& strText); + // @cmember Get Text from the Scintilla control + LPTSTR GetText(); + // @cmember Load a file + BOOL LoadFile(LPCTSTR szFile); + // @cmember Save a file + BOOL SaveFile(LPCTSTR szFile); + // @cmember try to find lexer format from extension + int GetFormatFromExtension(LPCTSTR szExtension); + // @cmember calcluate number of chars needed for linenumberdisplay + int GetLinenumberChars(); + // @cmember calcluate number of pixels for linenumber display + int GetLinenumberWidth(); + // @cmember set display of linenumbers on/off + void SetDisplayLinenumbers(BOOL bFlag =true); + // @cmember set display of selection/bookmark margin on/off + void SetDisplaySelection(BOOL bFlag = true); + // @cmember set display of source folding margin on/off + void SetDisplayFolding(BOOL bFlag = true); + // @cmember cut selection to clipboard + void Cut(); + // @cmember copy selection to clipboard + void Copy(); + // @cmember paste from clipboard + void Paste(); + // @cmember clear selection + void Clear(); + // @cmember undo last change + void Undo(); + // @cmember redo last change + void Redo(); + // @cmember check if we can undo + BOOL CanUndo(); + // @cmember check if we can redo + BOOL CanRedo(); + // @cmember check if we have something to paste from clipboard + BOOL CanPaste(); + // @cmember select complete text + void SelectAll(); + // @cmember return the current line number + long GetCurrentLine(); + // @cmember return the current column number + long GetCurrentColumn(); + // @cmember return the current character position within the file + long GetCurrentPosition(); + // @cmember return the current style number at the current character position + int GetCurrentStyle(); + // @cmember return the current folding level at the current character position + int GetCurrentFoldinglevel(); + // @cmember set the fontname for a style number + void SetFontname(int nStyle, LPCTSTR szFontname); + // @cmember set the fontname height in points for a style number + void SetFontheight(int nStyle, int nHeight); + // @cmember set the foregroundcolor for a style number + void SetForeground(int nStyle, COLORREF crForeground); + // @cmember set the backgroundcolor for a style number + void SetBackground(int nStyle, COLORREF crBackground); + // @cmember set given style to bold + void SetBold(int nStyle, BOOL bFlag); + // @cmember set given style to bold + void SetItalic(int nStyle, BOOL bFlag); + // @cmember set given style to bold + void SetUnderline(int nStyle, BOOL bFlag); + // @cmember get flag if we are in overstrike mode + BOOL GetOverstrike(); + // @cmember set flag for overstrike mode + void SetOverstrike(BOOL bOverstrike); + // @cmember init the view with reasonable defaults + void Init(); + // @cmember called whenever the text is changed - we can update any indicators and do brace matching + void UpdateUI(); + // @cmember do default folding + void DoDefaultFolding(int nMargin, long lPosition); + // @cmember refresh lexer and display after new settings + void Refresh(); + // @cmember add a bookmark = marker type 0 + void AddBookmark(long lLine); + // @cmember delete a bookmark = marker type 0 + void DeleteBookmark(long lLine); + // @cmember check for bookmark = marker type 0 + BOOL HasBookmark(long lLine); + // @cmember Find next bookmark + void FindNextBookmark(); + // @cmember Find previous bookmark + void FindPreviousBookmark(); + // @cmember goto line + void GotoLine(long lLine); + // @cmember goto position + void GotoPosition(long lPos); + // @cmember search forward for a given text + BOOL SearchForward(LPTSTR szText); + // @cmember search backward for a given text + BOOL SearchBackward(LPTSTR szText); + // @cmember replace a text found by SearchForward or SearchBackward + void ReplaceSearchedText(LPCTSTR szText); + // @cmember Set your own lexer + void SetLexer(int nLexer); + // @cmember return start position of selection + long GetSelectionStart(); + // @cmember return end position of selection + long GetSelectionEnd(); + // @cmember get selected text + LPTSTR GetSelectedText(); + // @cmember replace all in buffer or selection + int ReplaceAll(LPTSTR szFind, LPTSTR szReplace, BOOL bSelection = true); +public: + // @cmember load text + int LoadContent(BSTR bstr, LPCTSTR ext = L".xml"); + // @cmember set text + int SetContent(BSTR bstr, LPCTSTR ext = L".xml"); + // @cmember get text + int GetContent(BSTR* bstr); +public: + int OnFindDlg(); + int OnReplaceDlg(); +}; +}} diff --git a/jrj/xframe/win32/win.hpp b/jrj/xframe/win32/win.hpp index 1fbfcee..8f8ebfc 100644 --- a/jrj/xframe/win32/win.hpp +++ b/jrj/xframe/win32/win.hpp @@ -99,7 +99,7 @@ int WINAPI ShellExecuteW(HWND hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd) ;//native from "shell32.dll" alias "ShellExecuteW"; int WINAPI DeleteFile(string lpFileName) ;//native from "Shlwapi.dll" alias "DeleteFileW"; bool WINAPI PathFileExists(string lpFileName) ;//native from "shlwapi.dll" alias "PathFileExistsW"; - int WINAPI CreateDirectory(string lpFileName, string lpFileAttributes) ;//native from "kernel32.dll" alias "CreateDirectoryW"; + int WINAPI CreateDirectoryW(string lpFileName, void* lpFileAttributes) ;//native from "kernel32.dll" alias "CreateDirectoryW"; //bool WINAPI SystemParametersinfo(int uiAction,int uiParam,param pvParam,int fWinlni) ;//native from "user32.dll" alias "SystemParametersinfo"; int WINAPI GetSystemMetrics(int nIndex) ;//native from "user32.dll" alias "GetSystemMetrics"; HWND WINAPI FindWindowW(string lpClassName, string lpWindowName);//native from "user32.dll" alias "FindWindowW"; @@ -122,6 +122,7 @@ #define GetWindowText GetWindowTextW #define AppendMenu AppendMenuW #define FindWindowEx FindWindowExW +#define CreateDirectory CreateDirectoryW #endif #if 0 diff --git a/jrj/xframe/xcontrol/xsedit.hpp b/jrj/xframe/xcontrol/xsedit.hpp new file mode 100644 index 0000000..941c0c1 --- /dev/null +++ b/jrj/xframe/xcontrol/xsedit.hpp @@ -0,0 +1,356 @@ +#pragma once + +#include "wobject/xcontrol.hpp" +#include "kobject/kxsedit.hpp" + +using kxsedit = Hxsoft::XFrame::IXSEdit; +class xsedit : public xcontrol +{ + public: + xsedit():xcontrol(nullptr){} + xsedit(void * implptr):xcontrol(implptr){} + kxsedit* getKXSEdit(){return (kxsedit*)this->GetNativePtr();} + public: + + // @access public macro members + // @cmember return linenumber display flag + BOOL GetDisplayLinenumbers() + { + return getKXSEdit()->GetDisplayLinenumbers(); + } + // @cmember return selection display flag + BOOL GetDisplaySelection() + { + return getKXSEdit()->GetDisplaySelection(); + } + // @cmember return folding margin display flag + BOOL GetDisplayFolding() + { + return getKXSEdit()->GetDisplayFolding(); + } + // @cmember set search flags + void SetSearchflags(int nSearchflags) + { + return getKXSEdit()->SetSearchflags(nSearchflags); + } + int GetSearchflags() + { + return getKXSEdit()->GetSearchflags(); + } + +public: + // @access public function members + // @cmember register a window class to use scintilla in a dialog + //static BOOL Register(CWinApp *app, UINT id); + // @cmember try to load Lexer DLL + static HMODULE LoadScintillaDll(LPCTSTR szLexerDll = NULL) + { + return kxsedit::LoadScintillaDll(szLexerDll); + } + // @cmember create window + // BOOL Create (LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); + // @cmember Set Text to the Scintilla control + void SetText(LPCTSTR szText) + { + return getKXSEdit()->SetText(szText); + } + // @cmember Get Text from the Scintilla control + void GetText(LPTSTR& strText) + { + return getKXSEdit()->GetText(strText); + } + // @cmember Get Text from the Scintilla control + LPTSTR GetText() + { + return getKXSEdit()->GetText(); + } + // @cmember Load a file + BOOL LoadFile(LPCTSTR szFile) + { + return getKXSEdit()->LoadFile(szFile); + } + // @cmember Save a file + BOOL SaveFile(LPCTSTR szFile) + { + return getKXSEdit()->SaveFile(szFile); + } + // @cmember try to find lexer format from extension + int GetFormatFromExtension(LPCTSTR szExtension) + { + return getKXSEdit()->GetFormatFromExtension(szExtension); + } + // @cmember calcluate number of chars needed for linenumberdisplay + int GetLinenumberChars() + { + return getKXSEdit()->GetLinenumberChars(); + } + // @cmember calcluate number of pixels for linenumber display + int GetLinenumberWidth() + { + return getKXSEdit()->GetLinenumberWidth(); + } + // @cmember set display of linenumbers on/off + void SetDisplayLinenumbers(BOOL bFlag = true) + { + return getKXSEdit()->SetDisplayLinenumbers(bFlag); + } + // @cmember set display of selection/bookmark margin on/off + void SetDisplaySelection(BOOL bFlag = true) + { + return getKXSEdit()->SetDisplaySelection(bFlag); + } + // @cmember set display of source folding margin on/off + void SetDisplayFolding(BOOL bFlag = true) + { + return getKXSEdit()->SetDisplayFolding(bFlag); + } + // @cmember cut selection to clipboard + void Cut() + { + return getKXSEdit()->Cut(); + } + // @cmember copy selection to clipboard + void Copy() + { + return getKXSEdit()->Copy(); + } + // @cmember paste from clipboard + void Paste() + { + return getKXSEdit()->Paste(); + } + // @cmember clear selection + void Clear() + { + return getKXSEdit()->Clear(); + } + // @cmember undo last change + void Undo() + { + return getKXSEdit()->Undo(); + } + // @cmember redo last change + void Redo() + { + return getKXSEdit()->Redo(); + } + // @cmember check if we can undo + BOOL CanUndo() + { + return getKXSEdit()->CanUndo(); + } + // @cmember check if we can redo + BOOL CanRedo() + { + return getKXSEdit()->CanRedo(); + } + // @cmember check if we have something to paste from clipboard + BOOL CanPaste() + { + return getKXSEdit()->CanPaste(); + } + // @cmember select complete text + void SelectAll() + { + return getKXSEdit()->SelectAll(); + } + // @cmember return the current line number + long GetCurrentLine() + { + return getKXSEdit()->GetCurrentLine(); + } + // @cmember return the current column number + long GetCurrentColumn() + { + return getKXSEdit()->GetCurrentColumn(); + } + // @cmember return the current character position within the file + long GetCurrentPosition() + { + return getKXSEdit()->GetCurrentPosition(); + } + // @cmember return the current style number at the current character position + int GetCurrentStyle() + { + return getKXSEdit()->GetCurrentStyle(); + } + // @cmember return the current folding level at the current character position + int GetCurrentFoldinglevel() + { + return getKXSEdit()->GetCurrentFoldinglevel(); + } + // @cmember set the fontname for a style number + void SetFontname(int nStyle, LPCTSTR szFontname) + { + return getKXSEdit()->SetFontname(nStyle, szFontname); + } + // @cmember set the fontname height in points for a style number + void SetFontheight(int nStyle, int nHeight) + { + return getKXSEdit()->SetFontheight(nStyle, nHeight); + } + // @cmember set the foregroundcolor for a style number + void SetForeground(int nStyle, COLORREF crForeground) + { + return getKXSEdit()->SetForeground(nStyle, crForeground); + } + // @cmember set the backgroundcolor for a style number + void SetBackground(int nStyle, COLORREF crBackground) + { + return getKXSEdit()->SetBackground(nStyle,crBackground); + } + // @cmember set given style to bold + void SetBold(int nStyle, BOOL bFlag) + { + return getKXSEdit()->SetBold(nStyle,bFlag); + } + // @cmember set given style to bold + void SetItalic(int nStyle, BOOL bFlag) + { + return getKXSEdit()->SetItalic(nStyle,bFlag); + } + // @cmember set given style to bold + void SetUnderline(int nStyle, BOOL bFlag) + { + return getKXSEdit()->SetUnderline(nStyle,bFlag); + } + // @cmember get flag if we are in overstrike mode + BOOL GetOverstrike() + { + return getKXSEdit()->GetOverstrike(); + } + // @cmember set flag for overstrike mode + void SetOverstrike(BOOL bOverstrike) + { + return getKXSEdit()->SetOverstrike(bOverstrike); + } + // @cmember init the view with reasonable defaults + void Init() + { + return getKXSEdit()->Init(); + } + // @cmember called whenever the text is changed - we can update any indicators and do brace matching + void UpdateUI() + { + return getKXSEdit()->UpdateUI(); + } + // @cmember do default folding + void DoDefaultFolding(int nMargin, long lPosition) + { + return getKXSEdit()->DoDefaultFolding(nMargin,lPosition); + } + // @cmember refresh lexer and display after new settings + void Refresh() + { + return getKXSEdit()-> Refresh(); + } + // @cmember add a bookmark = marker type 0 + void AddBookmark(long lLine) + { + return getKXSEdit()->AddBookmark(lLine);; + } + // @cmember delete a bookmark = marker type 0 + void DeleteBookmark(long lLine) + { + return getKXSEdit()->DeleteBookmark(lLine); + } + // @cmember check for bookmark = marker type 0 + BOOL HasBookmark(long lLine) + { + return getKXSEdit()->HasBookmark(lLine); + } + // @cmember Find next bookmark + void FindNextBookmark() + { + return getKXSEdit()->FindNextBookmark(); + } + // @cmember Find previous bookmark + void FindPreviousBookmark() + { + return getKXSEdit()->FindPreviousBookmark(); + } + // @cmember goto line + void GotoLine(long lLine) + { + return getKXSEdit()->GotoLine(lLine); + } + // @cmember goto position + void GotoPosition(long lPos) + { + return getKXSEdit()->GotoPosition(lPos); + } + // @cmember search forward for a given text + BOOL SearchForward(LPTSTR szText) + { + return getKXSEdit()->SearchForward(szText); + } + // @cmember search backward for a given text + BOOL SearchBackward(LPTSTR szText) + { + return getKXSEdit()->SearchBackward(szText); + } + // @cmember replace a text found by SearchForward or SearchBackward + void ReplaceSearchedText(LPCTSTR szText) + { + return getKXSEdit()->ReplaceSearchedText(szText); + } + // @cmember Set your own lexer + void SetLexer(int nLexer) + { + return getKXSEdit()->SetLexer(nLexer); + } + // @cmember return start position of selection + long GetSelectionStart() + { + //return getKXSEdit()->GetSelectionStart(); + return -1; + } + // @cmember return end position of selection + long GetSelectionEnd() + { + //return getKXSEdit()->GetSelectionEnd(); + return -1; + } + // @cmember get selected text + LPTSTR GetSelectedText() + { + return getKXSEdit()->GetSelectedText(); + } + // @cmember replace all in buffer or selection + int ReplaceAll(LPTSTR szFind, LPTSTR szReplace, BOOL bSelection = true) + { + return getKXSEdit()->ReplaceAll(szFind,szReplace,bSelection); + } +public: + // @cmember load text + int LoadContent(xstring bstr, LPCTSTR ext = L".xml") + { + return getKXSEdit()->LoadContent((BSTR)bstr.c_str(), ext); + } + // @cmember set text + int SetContent(xstring bstr, LPCTSTR ext = L".xml") + { + return getKXSEdit()->SetContent((BSTR)bstr.c_str(), ext); + } + // @cmember get text + int GetContent(xstring& xs) + { + BSTR bstr = nullptr; + int ret = getKXSEdit()->GetContent(&bstr); + xs= xstring(bstr, true); + return 1; + } +public: + int OnFindDlg() + { + return getKXSEdit()->OnFindDlg(); + } + int OnReplaceDlg() + { + return getKXSEdit()->OnReplaceDlg(); + } +}; + + + + diff --git a/jrj/xframe/xcontrol/xtreeview.hpp b/jrj/xframe/xcontrol/xtreeview.hpp index 85ca898..715eda7 100644 --- a/jrj/xframe/xcontrol/xtreeview.hpp +++ b/jrj/xframe/xcontrol/xtreeview.hpp @@ -513,17 +513,16 @@ SendMessage(GetHWND(), TVM_GETITEMW, 0,(LPARAM)&xitem); return xitem.cChildren; } -#if 0 - string PopupMenu(string str) + + xstring PopupMenu(string str) { - return (str)SendMessage(GetHWND(), 0x402, (WPARAM)str, 0); + return (string)SendMessage(GetHWND(), 0x402, (WPARAM)str, 0); } string PopupMenu(KXMLDOMElement e) { - return PopupMenu(e.xml); + return PopupMenu(e.xml()); } -#endif void SetLineAtRoot(bool value) { -- Gitblit v1.9.3