| | |
| | | #include "XDevEditPage.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class export XDevEditXRuler : public XDevEditPage |
| | | class export dw_xwkdlg : public XDevEditPage |
| | | { |
| | | public: |
| | | XDevEditXRuler(void* implPtr, HWND hWnd) :XDevEditPage(implPtr, hWnd) {} |
| | | dw_xwkdlg(void* implPtr, HWND hWnd) :XDevEditPage(implPtr, hWnd) {} |
| | | public: |
| | | static XDevEditXRuler* CreateInstance(void* implPtr, void* hWnd) |
| | | static dw_xwkdlg* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | XDevEditXRuler* pWin = new XDevEditXRuler(implPtr, (HWND)hWnd); |
| | | dw_xwkdlg* pWin = new dw_xwkdlg(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | private: // |
| | | //xdwgrid dw_list; |
| | | |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring m_agentCond; //Agent Node |
| | | int SetAgent() |
| | | { |
| | | /*xstring xfNodeAgentArea = L"agentarea"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | var xframeElement = GetElement(); |
| | | var agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); |
| | | if(agent) |
| | | { |
| | | xstring s = agent.xml; |
| | | m_agentNode = SetAgentNodeContent (anode,s); |
| | | }*/ |
| | | return 1; |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt,LPARAM param) |
| | | { |
| | | SetAgent(); |
| | | |
| | | //重置工具条 |
| | | return 1; |
| | | } |
| | | |
| | | int LoadData() |
| | | { |
| | | if (!GetWinParam()) return 1; |
| | | xstring content = GetData(); |
| | | if (content != L"") |
| | | { |
| | | xsedit xs = GetControl(L"xcontent"); |
| | | xs.LoadContent(content,L".xml"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | xstring OnGetType() |
| | | { |
| | | xwin w = GetFrameWindow(); |
| | | xtreeview tv_folder = w.GetControl(L"DevExplorer"); |
| | | HTREEITEM hItem = (HTREEITEM)GetWinParam(); |
| | | KXMLDOMElement e = tv_folder.GetItemData(hItem); |
| | | xstring str = e.getAttribute(L"type"); |
| | | return str; |
| | | } |
| | | xtreeview tv_folder; |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | xstring content; |
| | | xsedit xs = GetControl(L"xcontent"); |
| | | xs.GetContent(content); |
| | | |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | if (comdid == L"xmFileSave") |
| | | if (GetWinParam()) |
| | | { |
| | | //save xml content |
| | | SaveContent(content); |
| | | SetArg(); |
| | | xaserverarg arg = GetArg(); |
| | | if (comdid == L"xmDevOk") |
| | | { |
| | | HTREEITEM hItem = tv_folder.GetSelectedItem(); |
| | | if (hItem <= 0) |
| | | { |
| | | MessageBox(0,L"请选择功能模块!",L"",0); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmValid") |
| | | KXMLDOMElement e = tv_folder.GetItemData(hItem); |
| | | //xstring node = e.tagName(); |
| | | xstring node = e.getAttribute(L"name"); |
| | | if (node== L"file") |
| | | { |
| | | xml x ; |
| | | if (!x.loadXML(content)) |
| | | { |
| | | KXMLDOMParseError pError = x.parseError(); |
| | | if (pError) |
| | | { |
| | | xstring str = pError.srcText(); |
| | | xstring sError = L"\r\nXML错误: " + str.trim() + L"\r\n"; |
| | | int s = pError.errorCode(); |
| | | sError += L" 代码: " + xstring(s) + L"\r\n"; |
| | | s = pError.line(); |
| | | sError += L" 位置: 第" + xstring(s) + L"行,L"; |
| | | s = pError.linepos(); |
| | | sError += L"第" + xstring(s) + L"列" + L"\r\n"; |
| | | str = pError.reason(); |
| | | sError += L" 原因: " + str; |
| | | trace(sError); |
| | | xstring caption = e.getAttribute(L"caption"); |
| | | xstring guid = e.getAttribute(L"guid"); |
| | | arg.AddArg(L"guid",L"" + guid); |
| | | arg.AddArg(L"caption",L"" + caption); |
| | | } |
| | | else |
| | | { |
| | | trace(L"XML 错误"); |
| | | MessageBox(0,L"请选择功能模块!",L"",0); |
| | | return 1; |
| | | } |
| | | return -1; |
| | | } |
| | | /*xstring sType = OnGetType(); |
| | | if (sType == L"xml.xsd") |
| | | else |
| | | { |
| | | xstring sError; |
| | | x.ValidSchema(content, &sError); |
| | | trace(sError); |
| | | }*/ |
| | | arg.AddArg(L"guid",L""); |
| | | arg.AddArg(L"caption",L""); |
| | | } |
| | | else if (comdid == L"xmEditFind") |
| | | { |
| | | OpenWindow(L"dev:xpage[xcode.finddlg]"); |
| | | } |
| | | else if (comdid == L"xmEditReplace") |
| | | { |
| | | OpenWindow(L"dev:xpage[xcode.replacedlg]"); |
| | | } |
| | | xutil::RestoreCursor(hCursor); |
| | | CloseWindow(); |
| | | return 0; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt,LPARAM param) |
| | | int OnXCommand(TEvent* evt, LPARAM p) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&XDevEditXRuler::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&XDevEditXRuler::OnSetFocus); |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&dw_xwkdlg::OnXCommand); |
| | | } |
| | | |
| | | int OnInitial() |
| | | { |
| | | SetAgent(); |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | tv_folder = GetControl(L"DevExplorer"); |
| | | OnInitial(); |
| | | LoadData(); |
| | | |
| | | if (GetWinParam()) alert(L"xxx"); |
| | | return 1; |
| | | } |
| | | }; |