$PBExportHeader$u_function_panel.sru $PBExportComments$By PBKiller v2.5.18(http://kivens.nease.net) forward global type u_function_panel from userobject end type type tv_function from treeview within u_function_panel end type type st_funcarea from statictext within u_function_panel end type type ddplb_module from dropdownpicturelistbox within u_function_panel end type end forward global type u_function_panel from userobject integer width = 997 integer height = 1584 long backcolor = 67108864 string text = "none" long tabtextcolor = 33554432 long picturemaskcolor = 536870912 event ue_clickbutton ( ) event ue_doubleclickfunc ( ) event ue_clickfunc ( ) event ue_getfindtext ( ) event ue_find ( string arg_str ) tv_function tv_function st_funcarea st_funcarea ddplb_module ddplb_module end type global u_function_panel u_function_panel type variables public window iw_parent public integer ii_group_height = 66 public u_function_button iuo_button[] public u_function_list iuo_list[] public integer ii_usrgroup_count = 12 public integer ii_curgroup = 1 public LONG iL_curROWNO = 0 public string is_groupclicked public string is_funcdoubleclicked public string is_funcselected public string is_selectedid public string is_displayid = "N" public string is_smallicon = "N" public string is_ddplb public string is_msg public boolean ib_sort = false public datastore ids_function public datastore ids_module public string is_groupid[] public boolean ib_panel = true public integer ii_selindex public string is_regkey public string rootid = "00" public string all_panel = '全部模块(面板)' public string all_tree = '全部模块(树)' string col_module_ogmid = 'ogmid' string col_module_ogmname = 'ogmname' string col_module_ogmpid = 'ogmpid' string col_function_ogfid = 'ogfid' string col_function_efid = 'efid' string col_function_efname = 'efname' string col_function_efuppict = 'efuppict' string col_function_efdnpict = 'efdnpict' string col_function_ogfmid = 'ogfmid' string system_path = '' private string findstr = '' end variables forward prototypes public subroutine of_buildtreeview (string v_pcode, integer v_handle, boolean v_flag) public subroutine of_changedisplay (boolean val) public function integer of_init () public subroutine of_insertfunction (integer v_handle) public function integer of_movegroup_all () public subroutine of_refreshlist (integer idx) public subroutine of_resettreeview () public function integer of_resize (integer ai_width,integer ai_height) public function integer of_set_eventname (string as_groupclicked,string as_funcselected,string as_funcdoubleclicked) public subroutine of_setbkcolor () public subroutine of_setpanelvisible (boolean val) public subroutine of_settextcolor () public subroutine of_showhelp (integer ai_row) end prototypes event ue_clickbutton();of_movegroup_all() iw_parent.triggerevent(is_groupclicked) end event event ue_doubleclickfunc(); if f_str_isnull(is_selectedid) then return end if ids_function.setfilter("") ids_function.filter() ids_function.sort() iL_curROWNO = ids_function.find(col_function_efid+"='" + is_selectedid + "'",1,ids_function.rowcount()) if iL_curROWNO > 0 then iw_parent.triggerevent(is_funcdoubleclicked) end if end event event ue_clickfunc();integer li_row if f_str_isnull(is_selectedid) then return end if ids_function.setfilter("") ids_function.filter() ids_function.sort() li_row = ids_function.find(col_function_efid+"='" + is_selectedid + "'",1,ids_function.rowcount()) if li_row > 0 then iw_parent.triggerevent(is_funcselected) end if end event event ue_getfindtext();OpenWithParm(w_xls_gettext,findstr) string str str = message.stringparm this.event ue_find(str) end event event ue_find(string arg_str);findstr = arg_str IF ib_panel THEN IF ii_curgroup >= 1 And ii_curgroup <= UpperBound(iuo_list) THEN IF IsValid(iuo_list[ii_curgroup]) THEN iuo_list[ii_curgroup].event ue_find(arg_str) END IF END IF ELSE tv_function.event ue_find(arg_str) END IF end event public subroutine of_buildtreeview (string v_pcode, integer v_handle, boolean v_flag);integer li_row integer l_handle integer li_cnt integer l_parent treeviewitem l_tvi string ls_code li_cnt = ids_module.rowcount() if v_handle = 0 then of_resettreeview() if v_pcode <> rootid then li_row = ids_module.find(col_module_ogmid+"='" + v_pcode + "'",1,li_cnt) if li_row > 0 then l_tvi.label = trim(ids_module.GetItemString(li_row,col_module_ogmname) ) else l_tvi.label = "功能" end if l_tvi.data = v_pcode l_tvi.pictureindex = 1 l_tvi.selectedpictureindex = 1 if ids_function.find(col_function_ogfid+"='" + v_pcode + "'",1,ids_function.rowcount()) > 0 then l_tvi.children = true end if l_parent = tv_function.insertitemlast(v_handle,l_tvi) else l_parent = v_handle end if else l_parent = v_handle end if li_row = ids_module.find(col_module_ogmpid +"='" + v_pcode + "'",1,li_cnt) do while li_row > 0 and li_row <= li_cnt ls_code = ids_module.GetItemString(li_row,col_module_ogmid) if is_displayid = "Y" then l_tvi.label = ids_module.GetItemString(li_row,col_module_ogmid) + " " + trim(ids_module.GetItemString(li_row,col_module_ogmname)) else l_tvi.label = trim(ids_module.GetItemString(li_row,col_module_ogmname)) end if l_tvi.data = ls_code if l_parent = 0 then l_tvi.pictureindex = 1 l_tvi.selectedpictureindex = 1 else l_tvi.pictureindex = 2 l_tvi.selectedpictureindex = 3 end if if ids_function.find(col_function_ogfid+"='" + ls_code + "'",1,ids_function.rowcount()) > 0 then l_tvi.children = true else l_tvi.children = false end if l_tvi.selected = false l_tvi.expanded = false l_tvi.expandedonce = false l_handle = tv_function.insertitemlast(l_parent,l_tvi) if li_row = li_cnt then exit end if if l_handle > 0 then of_buildtreeview(ls_code,l_handle,v_flag) end if li_row = ids_module.find(col_module_ogmpid +"='" + v_pcode + "'",li_row + 1,li_cnt) if v_flag then tv_function.expanditem(l_handle) end if loop return end subroutine public subroutine of_changedisplay (boolean val);return end subroutine public function integer of_init ();Integer i Integer j Integer li_handle Integer li_hdl1 Integer li_hdl2 ddplb_module.Reset() li_handle = ddplb_module.AddItem(all_panel,1) IF li_handle > 0 THEN is_groupid[li_handle] = "ALL" END IF li_hdl1 = li_handle li_handle = ddplb_module.AddItem(all_tree,1) IF li_handle > 0 THEN is_groupid[li_handle] = rootid END IF li_hdl2 = li_handle ids_module.SetFilter(col_module_ogmpid +"='" + rootid + "'") ids_module.Filter() ids_module.Sort() IF ids_module.RowCount() < 1 THEN MessageBox("错误信息","功能模块定义错误!",stopsign!) RETURN -1 END IF ii_usrgroup_count = ids_module.RowCount() FOR i = 1 To ii_usrgroup_count IF iw_parent.OpenUserObject(iuo_button[i],0,0) = -1 THEN MessageBox("错误信息","构造操作面板时出现异常错误!",stopsign!) RETURN -1 END IF IF iw_parent.OpenUserObject(iuo_list[i],0,0) = -1 THEN MessageBox("错误信息","构造操作面板时出现异常错误!",stopsign!) RETURN -1 END IF IF is_smallicon = "Y" THEN iuo_list[i].View = listviewsmallicon! ELSE iuo_list[i].View = listviewlargeicon! END IF iuo_button[i].SetPosition(tobottom!) iuo_button[i].iuo_parent = This iuo_button[i].is_data = ids_module.GetItemString(i,col_module_ogmid) iuo_button[i].of_settext(Trim(ids_module.GetItemString(i,col_module_ogmname))) iuo_button[i].ii_index = i iuo_list[i].iuo_parent = This li_handle = ddplb_module.AddItem(Trim(ids_module.GetItemString(i,col_module_ogmname)),1) IF li_handle > 0 THEN is_groupid[li_handle] = ids_module.GetItemString(i,col_module_ogmid) END IF of_refreshlist(i) NEXT ids_module.SetFilter("") ids_module.Filter() ids_module.Sort() ids_function.SetFilter("") ids_function.Filter() ids_function.Sort() IF ib_panel THEN ddplb_module.SelectItem(li_hdl1) ELSE ddplb_module.SelectItem(li_hdl2) ddplb_module.Event SelectionChanged(li_hdl2) END IF of_setbkcolor() of_settextcolor() ii_curgroup = 1 of_resize(Width,Height) RETURN 1 end function public subroutine of_insertfunction (integer v_handle);string ls_modid string ls_uppic string ls_dnpic string ls_id string ls_name integer i integer li_cnt integer li_picidx1 integer li_picidx2 treeviewitem l_tvi tv_function.getitem(v_handle,l_tvi) ls_modid = string(l_tvi.data) if not f_str_isnull(ls_modid) then if ids_module.find(col_module_ogmid+"='" + ls_modid + "'",1,ids_module.rowcount()) < 1 then return end if else return end if ids_function.setfilter(col_function_ogfid+"='" + ls_modid + "'") ids_function.filter() ids_function.sort() li_cnt = ids_function.rowcount() for i = 1 to li_cnt ls_id = ids_function.getitemstring( i, col_function_efid) if is_displayid = "Y" then ls_name = ids_function.getitemstring( i, col_function_efid) + " " + trim(ids_function.getitemstring( i, col_function_efname) ) else ls_name = trim(ids_function.getitemstring( i, col_function_efname) ) end if ls_uppic = ids_function.getitemstring( i, col_function_efuppict) ls_dnpic = ids_function.getitemstring( i, col_function_efdnpict) li_picidx1 = tv_function.addpicture(ls_uppic) li_picidx2 = tv_function.addpicture(ls_dnpic) l_tvi.label = ls_name l_tvi.data = ls_id l_tvi.pictureindex = li_picidx1 l_tvi.selectedpictureindex = li_picidx2 l_tvi.selected = false l_tvi.children = false tv_function.insertitemlast(v_handle,l_tvi) next ids_function.setfilter("") ids_function.filter() ids_function.sort() return end subroutine public function integer of_movegroup_all ();integer i integer li_x integer li_y integer li_height integer li_width integer li_listy li_x = unitstopixels(x + st_funcarea.x,xunitstopixels!) + 1 li_y = unitstopixels(y + st_funcarea.y,yunitstopixels!) + 1 li_width = unitstopixels(st_funcarea.width,xunitstopixels!) - 2 li_height = unitstopixels(66,yunitstopixels!) for i = 1 to ii_curgroup if i>UpperBound(iuo_button) then exit iuo_button[i].x = pixelstounits(li_x,xpixelstounits!) iuo_button[i].y = pixelstounits(li_y,ypixelstounits!) if iuo_button[i].y + 66 <= y + st_funcarea.y + st_funcarea.height then iuo_button[i].of_resize(pixelstounits(li_width,xpixelstounits!),66) if ib_panel then iuo_button[i].show() else iuo_button[i].hide() end if else iuo_button[i].hide() end if li_y = li_y + li_height next li_listy = li_y li_y = unitstopixels(y + st_funcarea.y + st_funcarea.height,yunitstopixels!) - 1 for i = ii_usrgroup_count to ii_curgroup + 1 step -1 if i>UpperBound(iuo_button) then exit li_y = li_y - li_height iuo_button[i].x = pixelstounits(li_x,xpixelstounits!) iuo_button[i].y = pixelstounits(li_y,ypixelstounits!) if iuo_button[i].y >= y then iuo_button[i].of_resize(pixelstounits(li_width,xpixelstounits!),66) if ib_panel then iuo_button[i].show() else iuo_button[i].hide() end if else iuo_button[i].hide() end if next for i = 1 to ii_usrgroup_count if i>UpperBound(iuo_list) then exit if ii_curgroup <> i then iuo_list[i].hide() end if next iuo_list[ii_curgroup].move(pixelstounits(li_x + 20,xpixelstounits!),pixelstounits(li_listy,ypixelstounits!)) iuo_list[ii_curgroup].resize(pixelstounits(li_width - 20,xpixelstounits!),pixelstounits(li_y - li_listy,ypixelstounits!)) if ib_panel then tv_function.hide() iuo_list[ii_curgroup].show() else iuo_list[ii_curgroup].hide() end if return 1 end function public subroutine of_refreshlist (integer idx);String ls_modid String ls_uppic String ls_dnpic String ls_id String ls_name Integer i Integer li_cnt Integer li_handle Integer li_picidx1 Integer li_picidx2 listviewitem lvi_item If ((idx < 1) Or (idx > ii_usrgroup_count)) THEN RETURN END IF If (( Not IsValid(iuo_list[idx])) Or ( Not IsValid(iuo_button[idx]))) THEN RETURN END IF // if this.is_smallicon = "Y" then // iuo_list[idx].view = listviewsmallicon! // else // iuo_list[idx].view = listviewlargeicon! // end if ls_modid = iuo_button[idx].is_data IF col_function_ogfmid = '' THEN ids_function.SetFilter(col_function_ogfid+"='" + ls_modid + "'") ELSE ids_function.SetFilter(col_function_ogfmid+"='" + ls_modid + "'") END IF ids_function.Filter() ids_function.Sort() li_cnt = ids_function.RowCount() iuo_list[idx].of_reset() FOR i = 1 To li_cnt ls_id = ids_function.GetItemString( i, col_function_efid) ls_name = Trim(ids_function.GetItemString( i, col_function_efname) ) ls_uppic = ids_function.GetItemString( i, col_function_efuppict) ls_dnpic = ids_function.GetItemString( i, col_function_efdnpict) IF This.is_smallicon = "Y" THEN li_picidx1 = iuo_list[idx].AddSmallPicture(ls_uppic) ELSE li_picidx1 = iuo_list[idx].AddLargePicture(ls_uppic) END IF lvi_item.Label = ls_name lvi_item.Data = ls_id lvi_item.PictureIndex = li_picidx1 iuo_list[idx].AddItem(lvi_item) NEXT RETURN end subroutine public subroutine of_resettreeview ();integer li_handle tv_function.setredraw(false) li_handle = tv_function.finditem(roottreeitem!,0) do while li_handle > 0 tv_function.deleteitem(li_handle) li_handle = tv_function.finditem(roottreeitem!,0) loop tv_function.deletepictures() tv_function.deletestatepictures() tv_function.addpicture(system_path + "graphics\package.bmp") tv_function.addpicture(system_path + "graphics\fileclose.bmp") tv_function.addpicture(system_path + "graphics\fileopen.bmp") tv_function.addpicture(system_path + "graphics\program.bmp") tv_function.setredraw(true) end subroutine public function integer of_resize (integer ai_width,integer ai_height);integer i width = ai_width height = ai_height ddplb_module.move(0,0) ddplb_module.width = width st_funcarea.move(0,100) st_funcarea.width = width st_funcarea.height = height - 100 tv_function.move(st_funcarea.x,st_funcarea.y) tv_function.resize(st_funcarea.width,st_funcarea.height) of_movegroup_all() return 1 end function public function integer of_set_eventname (string as_groupclicked,string as_funcselected,string as_funcdoubleclicked);is_groupclicked = as_groupclicked is_funcselected = as_funcselected is_funcdoubleclicked = as_funcdoubleclicked return 0 end function public subroutine of_setbkcolor ();string ls_value integer li_rtn integer i li_rtn = registryget(is_regkey,"PanelBackColor",regstring!,ls_value) if ((li_rtn <> 1) or (long(ls_value) < 0)) then ls_value = "15793151" end if for i = 1 to ii_usrgroup_count if isvalid(iuo_list[i]) then iuo_list[i].backcolor = long(ls_value) end if next tv_function.backcolor = long(ls_value) st_funcarea.backcolor = long(ls_value) end subroutine public subroutine of_setpanelvisible (boolean val);integer i for i = 1 to ii_usrgroup_count if isvalid(iuo_button[i]) then iuo_button[i].visible = val end if next if ii_curgroup >= 1 and ii_curgroup <= upperbound(iuo_list) then if isvalid(iuo_list[ii_curgroup]) then iuo_list[ii_curgroup].visible = val end if end if end subroutine public subroutine of_settextcolor ();string ls_value integer li_rtn integer i li_rtn = registryget(is_regkey,"PanelTextColor",regstring!,ls_value) if ((li_rtn <> 1) or (long(ls_value) < 0)) then ls_value = "0" end if for i = 1 to ii_usrgroup_count if isvalid(iuo_list[i]) then iuo_list[i].textcolor = long(ls_value) end if next tv_function.textcolor = long(ls_value) end subroutine public subroutine of_showhelp (integer ai_row);iw_parent.triggerevent("ue_showmicrohelp") end subroutine event constructor;iw_parent = GetParent() st_funcarea.BringToTop = False end event on u_function_panel.create this.tv_function=create tv_function this.st_funcarea=create st_funcarea this.ddplb_module=create ddplb_module this.Control[]={this.tv_function,& this.st_funcarea,& this.ddplb_module} end on on u_function_panel.destroy destroy(this.tv_function) destroy(this.st_funcarea) destroy(this.ddplb_module) end on event destructor;integer i if ii_usrgroup_count > 0 then for i = ii_usrgroup_count to 1 step -1 if i > UpperBound(iuo_button) then return if i > UpperBound(iuo_list) then return if isvalid(iuo_button[i]) then iw_parent.closeuserobject(iuo_button[i]) end if if isvalid(iuo_list[i]) then iw_parent.closeuserobject(iuo_list[i]) end if next end if end event type tv_function from treeview within u_function_panel event ue_find ( string arg_str ) integer x = 82 integer y = 124 integer width = 599 integer height = 1252 integer taborder = 30 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! boolean linesatroot = true boolean hideselection = false boolean trackselect = true string picturename[] = {"graphics\info.bmp","graphics\fileclose.bmp","graphics\fileopen.bmp","graphics\program.bmp"} integer picturewidth = 16 integer pictureheight = 16 long picturemaskcolor = 12632256 long statepicturemaskcolor = 536870912 end type event ue_find(string arg_str);long handel,handel_child long cnt = 0 treeviewitem tvi this.setredraw( false) handel = this.finditem( RootTreeItem! ,0) do while handel > 0 this.ExpandItem ( handel ) handel_child = this.finditem(ChildTreeItem! ,handel) do while handel_child > 0 if this.GetItem(handel_child, tvi) = 1 then if pos(tvi.label,arg_str )> 0 then this.SelectItem ( handel_child ) this.setredraw( true) // this.setitem(handel_child,tvi) return end if end if handel_child = this.finditem(NextTreeItem! ,handel_child) loop this.CollapseItem ( handel ) handel = this.finditem(NextTreeItem! ,handel) loop this.setredraw( true) return end event event doubleclicked;treeviewitem l_tvi getitem(handle,l_tvi) parent.is_selectedid = string(l_tvi.data) parent.is_msg = l_tvi.label PARENT.triggerevent("ue_doubleclickfunc") //iw_parent.triggerevent(is_funcdoubleclicked) return end event event itempopulate;parent.of_insertfunction(handle) return end event event rightclicked;m_xls_pop m_xls treeviewitem ltvi selectitem(handle) getitem(handle,ltvi) m_xls = create m_xls_pop m_xls.iuo_parent = this.getparent( ) if f_str_isnull(string(ltvi.data)) = false then if parent.is_displayid = "N" then m_xls.m_panel.m_displayid.checked = false else m_xls.m_panel.m_displayid.checked = true end if m_xls.m_panel.m_smallicon.enabled = false u_function_panel u_panel u_panel = this.getparent( ) m_xls.m_panel.popmenu(u_panel.x+ this.x+pointerx(),u_panel.y+this.y+pointery() ) end if return end event type st_funcarea from statictext within u_function_panel integer y = 100 integer width = 891 integer height = 1400 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 15780518 boolean border = true borderstyle borderstyle = stylelowered! boolean focusrectangle = false boolean disabledlook = true end type type ddplb_module from dropdownpicturelistbox within u_function_panel integer x = 5 integer y = 20 integer width = 681 integer height = 1260 integer taborder = 10 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 string text = "none" boolean autohscroll = true boolean sorted = false boolean hscrollbar = true boolean vscrollbar = true borderstyle borderstyle = stylelowered! string picturename[] = {"xls_controlpanel.bmp"} integer picturewidth = 16 integer pictureheight = 16 long picturemaskcolor = 16777215 end type event selectionchanged;integer li_handle if ((index < 1) or (index > upperbound(parent.is_groupid))) then return end if if parent.is_groupid[index] = "ALL" then parent.tv_function.hide() parent.of_setpanelvisible(true) parent.ib_panel = true else parent.of_buildtreeview(parent.is_groupid[index],0,false) parent.is_ddplb = parent.is_groupid[index] li_handle = parent.tv_function.finditem(roottreeitem!,0) if parent.tv_function.finditem(nexttreeitem!,li_handle) < 1 then parent.tv_function.expanditem(li_handle) end if parent.of_setpanelvisible(false) parent.tv_function.show() parent.ib_panel = false parent.ii_selindex = index end if return end event