¶Ô±ÈÐÂÎļþ |
| | |
| | | #include "xcontrol/xdwgrid.hpp" |
| | | #include "xcontrol/xdwtable.hpp" |
| | | #include "wobject/xwin.hpp" |
| | | #include "wobject/xstring.hpp" |
| | | #include "wobject/xaserverarg.hpp" |
| | | #include "wobject/xaserver.hpp" |
| | | #include "xcontrol/xtreeview.hpp" |
| | | #include "xcontrol/xcombobox.hpp" |
| | | #include "xcontrol/xlayersheet.hpp" |
| | | #include "wobject/xutil.hpp" |
| | | #include "wobject/xnode.hpp" |
| | | #include "platform/nstring.hpp" |
| | | |
| | | class __declspec(dllexport)IndexMenuWin: public xwin |
| | | { |
| | | public: |
| | | xtreeview tv_menu; |
| | | xtreeview tv_menu1; |
| | | xtreeview tv_menu2; |
| | | xlayersheet mainfolder; |
| | | |
| | | xcombobox cbx_menu; |
| | | xcombobox cbx_panelName; |
| | | xcombobox cbx_panelNo; |
| | | xcombobox cbx_tab; |
| | | int m_bCanDestroy; |
| | | |
| | | HWND m_nHwnd; |
| | | int tabNo; |
| | | |
| | | //int m_panelNo; // å½åèåç» |
| | | xstring m_Assignment; |
| | | public: |
| | | IndexMenuWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} |
| | | public: |
| | | static IndexMenuWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | return new IndexMenuWin(implPtr, (HWND)hWnd); |
| | | } |
| | | |
| | | int OnHideWin() |
| | | { |
| | | int nIndex = cbx_menu.GetCurSel(); |
| | | if(nIndex == 0) return 0; |
| | | HWND HWND_NOTOPMOST= ((HWND)-2); |
| | | int SWP_NOSIZE = 0x0001; |
| | | int SWP_NOMOVE = 0x0002; |
| | | int SWP_HIDEWINDOW = 0x0080; |
| | | SetWindowPos(GetHandle(), HWND_NOTOPMOST, -1000,-1000,0,0,SWP_NOSIZE | SWP_HIDEWINDOW); |
| | | return 1; |
| | | } |
| | | |
| | | int OnActive(TEvent* evt, LPARAM p) |
| | | { |
| | | int WA_INACTIVE = 0; |
| | | int WA_ACTIVE = 1; |
| | | int WA_CLICKACTIVE = 2; |
| | | int SW_HIDE=0x1; |
| | | WPARAM lw = evt->wParam; |
| | | int x = m_bCanDestroy; |
| | | if( lw ==WA_INACTIVE && x==1 ) |
| | | { |
| | | //CloseWindow(); |
| | | //xwin::ShowWindow(this.GetHWND(), SW_HIDE); |
| | | OnHideWin(); |
| | | return 1; |
| | | } |
| | | if(lw !=WA_INACTIVE) m_bCanDestroy = 1; |
| | | return 1; |
| | | } |
| | | |
| | | int createPanel() |
| | | { |
| | | KXMLDOMDocument x ; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"pid",L"null"); |
| | | arg.AddArg(L"Assignment", m_Assignment); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[Menu.index.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | alert(x.xml()); |
| | | return -1; |
| | | } |
| | | Hxsoft::XFrame::KXMLDOMNodeList li=x.selectNodes(L"items/item"); |
| | | int i=0; |
| | | long s=li.length(); |
| | | for (i=0;i<s;i++) |
| | | { |
| | | KXMLDOMElement xitem= li.item(i); |
| | | int k = cbx_panelName.AddItem(xstring(i).c_str()); |
| | | cbx_panelName.SetItemData(k, xitem); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int GetCurPanel() |
| | | { |
| | | return cbx_panelName.GetCurSel(); |
| | | } |
| | | |
| | | int createTree(xstring id, HTREEITEM parentItem) |
| | | { |
| | | if(tv_menu.GetChildItem(parentItem)) return 0; |
| | | KXMLDOMDocument x; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"pid",id); |
| | | arg.AddArg(L"Assignment", m_Assignment); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[Menu.index.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | return -1; |
| | | } |
| | | |
| | | KXMLDOMNodeList li=x.selectNodes(L"items/item"); |
| | | int i=0; |
| | | int s=li.length(); |
| | | KXMLDOMElement xitem; |
| | | for (i=0;i<s;i++) |
| | | { |
| | | xitem= li.item(s - i - 1); |
| | | string xid = xitem.selectSingleNode(L"id").text(); |
| | | string Name=xitem.selectSingleNode(L"name").text(); |
| | | xstring image = L"15"; |
| | | if(xitem.selectSingleNode(L"image")) image=xitem.selectSingleNode(L"image").text(); |
| | | HTREEITEM hBeforItem = 0; |
| | | HTREEITEM curItem=tv_menu.InsertItem(parentItem,hBeforItem,Name,(LPARAM)xid, xstring(image).toInt()); |
| | | xstring child=xitem.selectSingleNode(L"@child").text();//item.getAttribute("HasChild"); |
| | | if ((xstring)child != L"0") |
| | | tv_menu.SetItemChild1(curItem,1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int createTreeBase(xtreeview& tv_item, KXMLDOMDocument x) |
| | | { |
| | | KXMLDOMNodeList li=x.selectNodes(L"items/item"); |
| | | int i=0; |
| | | int s=li.length(); |
| | | KXMLDOMElement xitem; |
| | | for (i=0;i<s;i++) |
| | | { |
| | | xitem= li.item(s - i - 1); |
| | | string id =xitem.selectSingleNode(L"id").text(); |
| | | string Name=xitem.selectSingleNode(L"name").text(); |
| | | xstring image(L"15"); |
| | | if(xitem.selectSingleNode(L"image")) image=xitem.selectSingleNode(L"image").text(); |
| | | HTREEITEM curItem=tv_item.InsertItem(0,0,Name, (LPARAM)id, image.toInt()); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int createTree1() |
| | | { |
| | | HTREEITEM rItem = tv_menu1.GetRootItem(); |
| | | while(rItem) |
| | | { |
| | | tv_menu1.DeleteItem(rItem); |
| | | rItem = tv_menu1.GetRootItem(); |
| | | } |
| | | KXMLDOMDocument x ; |
| | | xaserverarg arg; |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[menu.user.list.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | return -1; |
| | | } |
| | | createTreeBase(tv_menu1, x); |
| | | return 1; |
| | | } |
| | | |
| | | int OnTreeExpanding(TEvent* evt,int p) |
| | | { |
| | | |
| | | NMTREEVIEW* nmtv = (NMTREEVIEW*)evt->notify.pnmh; |
| | | HTREEITEM sitem = nmtv->itemNew.hItem; |
| | | string id = (string)tv_menu.GetItemData(sitem); |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | createTree(id, sitem); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | bool rClick(xstring str) |
| | | { |
| | | HMENU m = CreatePopupMenu(); |
| | | int MF_STRING = 0x00000000; |
| | | int TPM_RIGHTBUTTON = 0x0002; |
| | | int TPM_RETURNCMD = 0x0100; |
| | | AppendMenuW(m,MF_STRING, 1, str); |
| | | RECT xr = { 0,0,0,0 }; |
| | | xpoint pt; |
| | | GetCursorPos(pt); |
| | | return TrackPopupMenu (m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, this->GetHandle(), &xr); |
| | | } |
| | | |
| | | int OnRClicked(TEvent* evt,int p) |
| | | { |
| | | TVNNMHDR* nmtv = (TVNNMHDR*)evt->notify.pnmh; |
| | | HTREEITEM hItem = nmtv->FromItem; |
| | | if(hItem == 0) return 1; |
| | | int hasChild = tv_menu.GetItemChild1(hItem); |
| | | if(hasChild > 0) return 1; |
| | | int ret = rClick(L"æ¶èèå"); |
| | | if(ret == 1) |
| | | { |
| | | xstring id = (xstring)tv_menu.GetItemData(hItem); |
| | | KXMLDOMDocument x; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"id",id); |
| | | arg.AddArg(L"flag",L"insert"); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[menu.user.edit.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | //alert("æ¶è失败!"); |
| | | return -1; |
| | | } |
| | | createTree1(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int dbClick(xtreeview& tid, HTREEITEM hItem) |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | xstring id = (string)tid.GetItemData(hItem); |
| | | xstring label = tid.GetItemLabel(hItem); |
| | | KXMLDOMDocument x; |
| | | xaserverarg* arg = new xaserverarg(); |
| | | arg->AddArg(L"id",id); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[Maint.menu.index.xq]",arg->GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | return -1; |
| | | } |
| | | if((xstring)x.xml()==L"") return -1; |
| | | KXMLDOMElement e = x.documentElement(); |
| | | //alert(x.xml); |
| | | |
| | | int nIndex =cbx_menu.FindString(label); |
| | | /*if (e.selectSingleNode(L"ModuelMore") && nIndex > -1) |
| | | { |
| | | xstring mo = e.selectSingleNode(L"ModuelMore").text(); |
| | | if((xstring)mo != L"Y") |
| | | { |
| | | xstring comd = L"changesheet:"+xstring(nIndex); |
| | | SendMessage(m_nHwnd, 0x401, (LPARAM)comd.c_str(), 0); |
| | | OnHideWin(); |
| | | return 0; |
| | | } |
| | | }*/ |
| | | |
| | | if(e.selectSingleNode(L"ModuelPage")) {} else return -1; |
| | | |
| | | cbx_menu.AddItem(label); |
| | | int sheets = cbx_menu.GetCount(); |
| | | cbx_tab.AddItem(xstring(sheets - 1).c_str()); |
| | | |
| | | xstring vx = e.selectSingleNode(L"ModuelPage").text(); |
| | | if((xstring)vx == L"") return -1; |
| | | bool hasArg = false; |
| | | if(e.selectSingleNode(L"ModuelParam/args")) |
| | | { |
| | | KXMLDOMNodeList li=e.selectNodes(L"ModuelParam/args/arg"); |
| | | int i=0; |
| | | long s=li.length(); |
| | | KXMLDOMElement xitem; |
| | | if(s>0) hasArg = true; |
| | | for (i=0;i<s;i++) |
| | | { |
| | | xitem= li.item(i); |
| | | xstring name = xitem.selectSingleNode(L"@name").text(); |
| | | xstring value=xitem.selectSingleNode(L"@value").text(); |
| | | arg->AddArg(name, value); |
| | | } |
| | | } |
| | | //if(xaserver::GetUserNo() == "admin") |
| | | // alert("000"); |
| | | SetFocus(m_nHwnd); |
| | | if(vx.find(L".vx",0)>0 || vx.find(L".xpage",0)>0) |
| | | OpenWindow((L"dev:xpage["+vx+L"]").c_str(), (LPARAM)arg); |
| | | else |
| | | openUrl(vx, arg); |
| | | OnHideWin(); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDbClick(TNotifyEvent& evt,int p) |
| | | { |
| | | HTREEITEM hItem = tv_menu.GetSelectedItem(); |
| | | dbClick(tv_menu, hItem); |
| | | return 1; |
| | | } |
| | | |
| | | int SetInitAgent() |
| | | { |
| | | int no = GetCurPanel(); |
| | | xnode anode(GetAgentNode(L"mainmemu")); |
| | | int p =0; |
| | | xstring id; |
| | | int h = cbx_panelNo.FindString(xstring(no).c_str()); |
| | | if(h < 0) |
| | | { |
| | | int i = 0; |
| | | int s = cbx_panelName.GetCount(); |
| | | xstring toolStr = L"<vbox>"; |
| | | for (i=0;i<s;i++) |
| | | { |
| | | LPARAM pa = cbx_panelName.GetItemData(i); |
| | | if (!pa)return 1; |
| | | KXMLDOMElement hData = pa; |
| | | xstring Name= hData.selectSingleNode(L"name").text(); |
| | | xstring Image = L"15"; |
| | | if(hData.selectSingleNode(L"image")) Image=hData.selectSingleNode(L"image").text(); |
| | | xstring str = (xstring)L"<xtoolbutton image='"+Image+L"' caption='"+Name+L"' height='24' name='xmPanel:"+xstring(i).c_str() + L"' style='background-color:none #ceecce none #ffffff;text-align:left'/>"; |
| | | if(i == no) |
| | | { |
| | | id = hData.selectSingleNode(L"id").text(); |
| | | str += (xstring)L"<vbox><xtree imagelist='0' name='panelTree"+xstring(no)+ L"'/></vbox>"; |
| | | //AttachEvent("panelTree"+no.toString(),"TVN_SELCHANGED",OnTreeSelChanged); |
| | | xstring panelTree = L"panelTree"+xstring(no); |
| | | AttachEvent(panelTree.c_str(true),L"TVN_ITEMEXPANDING", (FEvent)&IndexMenuWin::OnTreeExpanding); |
| | | AttachEvent(panelTree.c_str(true),L"TVN_RCLICK", (FEvent)&IndexMenuWin::OnRClicked); |
| | | AttachEvent(panelTree.c_str(true),L"NM_DBLCLK", (FEvent)&IndexMenuWin::OnDbClick); |
| | | } |
| | | toolStr += str; |
| | | } |
| | | toolStr += L"</vbox>"; |
| | | //alert(toolStr); |
| | | xnode bnode = this->SetAgentNode(anode,toolStr); |
| | | int k = cbx_panelNo.AddItem(xstring(no).c_str()); |
| | | cbx_panelNo.SetItemData(k, (LPARAM)bnode.GetNativePtr()); |
| | | } |
| | | else |
| | | { |
| | | xnode dnode((void*)cbx_panelNo.GetItemData(h)); |
| | | SetAgentNode(anode,dnode); |
| | | } |
| | | tv_menu = xtreeview(GetControl(L"panelTree"+(xstring)no)); |
| | | if(h < 0 && (xstring)id != L"") createTree(id, 0); |
| | | return 1; |
| | | } |
| | | |
| | | int OnQuery() |
| | | { |
| | | xcontrol xc = GetControl(L"editQuery"); |
| | | xstring str = xc.GetText(); |
| | | if(str.isEmpty()) |
| | | { |
| | | alert(L"请è¾å
¥æ¥è¯¢æ¡ä»¶!"); |
| | | return -1; |
| | | } |
| | | HTREEITEM rItem = tv_menu2.GetRootItem(); |
| | | while(rItem) |
| | | { |
| | | tv_menu2.DeleteItem(rItem); |
| | | rItem = tv_menu2.GetRootItem(); |
| | | } |
| | | KXMLDOMDocument x; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"query",str.c_str()); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[menu.user.query.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | return -1; |
| | | } |
| | | createTreeBase(tv_menu2,x); |
| | | return 1; |
| | | } |
| | | |
| | | int OnMenuAgent() |
| | | { |
| | | xstring s = L"menuAgent:Y"; |
| | | SendMessage(m_nHwnd, 0x401, (LPARAM)s.c_str(), 0); |
| | | OnHideWin(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnChangePanel(xstring&& xno) |
| | | { |
| | | int pno = GetCurPanel(); |
| | | if(pno == xno.toInt()) |
| | | cbx_panelName.SetCurSel(-1); |
| | | else |
| | | cbx_panelName.SetCurSel(xno.toInt()); |
| | | SetInitAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnCmdDispatch(xstring&& comdid) |
| | | { |
| | | if (comdid == L"xmAll") mainfolder.SelectSheet(0); |
| | | else if (comdid == L"xmFav") mainfolder.SelectSheet(1); |
| | | else if (comdid == L"xmQue") mainfolder.SelectSheet(2); |
| | | else if (comdid == L"xmQuery") OnQuery(); |
| | | else if (comdid == L"xmMenuAgent") OnMenuAgent(); |
| | | else if(comdid.left(8) == L"xmPanel:") OnChangePanel(comdid.mid(8, 99)); |
| | | return 0; |
| | | } |
| | | |
| | | int OnXCommand(TEvent *evt,int p) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnDbClick1(TNotifyEvent* evt,int p) |
| | | { |
| | | //ref TVNNMHDR nmtv = evt.pnmh; |
| | | //int hItem = nmtv.FromItem; |
| | | HTREEITEM hItem = tv_menu1.GetSelectedItem(); |
| | | dbClick(tv_menu1, hItem); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDbClick2(TNotifyEvent* evt,int p) |
| | | { |
| | | //ref TVNNMHDR nmtv = evt.pnmh; |
| | | //int hItem = nmtv.FromItem; |
| | | HTREEITEM hItem = tv_menu2.GetSelectedItem(); |
| | | dbClick(tv_menu2, hItem); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRClicked1(TNotifyEvent* evt,int p) |
| | | { |
| | | TVNNMHDR& nmtv = *(TVNNMHDR*)evt->notify.pnmh; |
| | | HTREEITEM hItem = nmtv.FromItem; |
| | | if(!hItem) return 1; |
| | | int ret = rClick(L"åæ¶æ¶è"); |
| | | if(ret == 1) |
| | | { |
| | | xstring id = (xstring)tv_menu1.GetItemData(hItem); |
| | | KXMLDOMDocument x; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"id",id); |
| | | arg.AddArg(L"flag",L"del"); |
| | | if(xaserver::ExecXQuery(GetServerUrl(),L"[menu.user.edit.xq]",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.xml()); |
| | | alert("åæ¶å¤±è´¥!"); |
| | | return -1; |
| | | } |
| | | tv_menu1.DeleteItem(hItem); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | AttachEvent(L"WM_XCOMMAND",(FEvent)&IndexMenuWin::OnXCommand); |
| | | AttachEvent(L"WM_ACTIVATE",(FEvent)&IndexMenuWin::OnActive); |
| | | AttachEvent(L"menu1", L"TVN_RCLICK",(FEvent)&IndexMenuWin::OnRClicked1); |
| | | AttachEvent(L"menu1", L"NM_DBLCLK",(FEvent)&IndexMenuWin::OnDbClick1); |
| | | AttachEvent(L"menu2", L"NM_DBLCLK",(FEvent)&IndexMenuWin::OnDbClick2); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInitial() |
| | | { |
| | | if(GetWinParam()) |
| | | { |
| | | xaserverarg arg = GetArg(); |
| | | m_nHwnd = (HWND)arg.GetParam(L"hwnd"); |
| | | cbx_menu = (void*)arg.GetParam(L"cbx_menu"); |
| | | cbx_tab = (void*)arg.GetParam(L"cbx_tab"); |
| | | cbx_panelNo = (void*)arg.GetParam(L"cbx_panelNo"); |
| | | cbx_panelName = (void*)arg.GetParam(L"cbx_panelName"); |
| | | xstring s = L"menuid:"+xstring((LPARAM)GetHWND()); |
| | | SendMessage(m_nHwnd, 0x401, (LPARAM)s.c_str(), 0); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | |
| | | m_bCanDestroy = 1; |
| | | |
| | | tv_menu1 = GetControl(L"menu1"); |
| | | tv_menu2 = GetControl(L"menu2"); |
| | | mainfolder = GetControl(L"mainFolder"); |
| | | |
| | | int GWL_STYLE = -16; |
| | | int WS_CAPTION = 0x00C00000; |
| | | |
| | | int style = GetWindowLong(GetHWND(), GWL_STYLE); |
| | | style = style - WS_CAPTION; |
| | | SetWindowLong(GetHWND(), GWL_STYLE, style); |
| | | |
| | | OnInitial(); |
| | | OnAttachEvent(); |
| | | |
| | | long n = cbx_panelNo.GetCount(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | m_Assignment = xaserver::GetUID(); |
| | | createPanel(); |
| | | cbx_panelName.SetCurSel(-1); |
| | | SetInitAgent(); |
| | | createTree1(); |
| | | |
| | | xutil::RestoreCursor(hCursor); |
| | | //this->Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |
| | | |
| | | |
| | | |