us_fncpwrtree.sru 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. $PBExportHeader$us_fncpwrtree.sru
  2. forward
  3. global type us_fncpwrtree from treeview
  4. end type
  5. end forward
  6. global type us_fncpwrtree from treeview
  7. integer width = 919
  8. integer height = 940
  9. integer textsize = -12
  10. integer weight = 400
  11. fontcharset fontcharset = ansi!
  12. fontpitch fontpitch = variable!
  13. fontfamily fontfamily = swiss!
  14. string facename = "Arial"
  15. long textcolor = 33554432
  16. borderstyle borderstyle = stylelowered!
  17. boolean fullrowselect = true
  18. long picturemaskcolor = 536870912
  19. long statepicturemaskcolor = 536870912
  20. event ue_tree_add_bro ( )
  21. event ue_tree_add_son ( )
  22. event ue_tree_del ( )
  23. event ue_tree_edit ( )
  24. event ue_build_tree_fnc ( )
  25. end type
  26. global us_fncpwrtree us_fncpwrtree
  27. type variables
  28. long il_handle,ol_deep
  29. end variables
  30. forward prototypes
  31. public function integer pf_treegrowth (long arg_handl, long arg_funcid, integer arg_lp, integer arg_showtype)
  32. end prototypes
  33. event ue_tree_add_bro();if not il_handle>0 then return
  34. s_sys_func_parm s_sfp
  35. treeviewitem tvi
  36. this.getitem(il_handle,tvi)
  37. s_sfp.sfunc=tvi.data
  38. s_sfp.opflag=1 // add brother
  39. openwithparm(w_mftree_add,s_sfp)
  40. s_sfp=message.powerobjectparm
  41. if s_sfp.opflag=0 then return // 取消
  42. LONG ll_getitem,ll_newhandle,ll_pahandle
  43. TreeViewItem ltvi_Item,ltvi_PaItem
  44. IF il_handle>0 THEN
  45. ll_getitem=this.GetItem(il_handle, ltvi_Item)
  46. IF ll_getitem>0 THEN
  47. //得到父项,
  48. ll_pahandle=FindItem(ParentTreeItem!, il_handle)
  49. IF ll_pahandle<0 THEN ll_pahandle=0
  50. ltvi_Item.label=s_sfp.sfunc.treename
  51. ltvi_Item.Data = s_sfp.sfunc
  52. ltvi_Item.PictureIndex = 6
  53. // ltvi_Item.SelectedPictureIndex = 5
  54. ll_newhandle=this.InsertItemlast(ll_pahandle,ltvi_Item)
  55. this.GetItem(ll_newhandle, ltvi_Item)
  56. this.ExpandItem(ll_pahandle)
  57. //this.editlabel(ll_newhandle)
  58. il_handle=0
  59. END IF
  60. END IF
  61. end event
  62. event ue_tree_add_son();if not il_handle>0 then return
  63. s_sys_func_parm s_sfp
  64. treeviewitem tvi
  65. this.getitem(il_handle,tvi)
  66. s_sfp.sfunc=tvi.data
  67. s_sfp.opflag=2 // add son
  68. openwithparm(w_mftree_add,s_sfp)
  69. s_sfp=message.powerobjectparm
  70. if s_sfp.opflag=0 then return // 取消
  71. LONG ll_getitem,ll_newhandle
  72. TreeViewItem ltvi_Item
  73. IF il_handle>0 THEN
  74. ll_getitem=this.GetItem(il_handle, ltvi_Item)
  75. IF ll_getitem>0 THEN
  76. //ltvi_Item.children=true
  77. ltvi_Item.label=s_sfp.sfunc.treename
  78. ltvi_Item.Data = s_sfp.sfunc
  79. ltvi_Item.PictureIndex = 6
  80. ltvi_Item.SelectedPictureIndex = 5
  81. ll_newhandle=this.InsertItemlast(il_handle,ltvi_Item)
  82. this.ExpandItem(il_handle)
  83. //this.editlabel(ll_newhandle)
  84. il_handle=0
  85. END IF
  86. END IF
  87. end event
  88. event ue_tree_del();
  89. LONG ll_getitem
  90. TreeViewItem ltvi_Item
  91. uo_sys_funcpwr uo_sfp
  92. s_sys_func s_sf_ls
  93. //SetRedraw(FALSE)
  94. IF il_handle>0 THEN
  95. ll_getitem=this.GetItem(il_handle, ltvi_Item)
  96. IF ll_getitem>0 THEN
  97. IF MessageBox ("警告","是否确定要删除当前结点?("+trim(ltvi_Item.label )+")",Question!,YesNo! ) = 2 THEN RETURN
  98. s_sf_ls=ltvi_Item.data
  99. uo_sfp.del(s_sf_ls.funcid )
  100. This.deleteitem(il_handle)
  101. il_handle=0
  102. END IF
  103. END IF
  104. //SetRedraw(TRUE)
  105. end event
  106. event ue_tree_edit();if not il_handle>0 then return
  107. s_sys_func_parm s_sfp
  108. treeviewitem tvi
  109. this.getitem(il_handle,tvi)
  110. s_sfp.sfunc=tvi.data
  111. s_sfp.opflag=3 // add son
  112. openwithparm(w_mftree_add,s_sfp)
  113. s_sfp=message.powerobjectparm
  114. if s_sfp.opflag=0 then return // 取消
  115. LONG ll_getitem
  116. TreeViewItem ltvi_Item
  117. IF il_handle>0 THEN
  118. ll_getitem=this.GetItem(il_handle, ltvi_Item)
  119. IF ll_getitem>0 THEN
  120. ltvi_Item.label=s_sfp.sfunc.treename
  121. ltvi_Item.data=s_sfp.sfunc
  122. ll_getitem=this.setItem(il_handle, ltvi_Item)
  123. il_handle=0
  124. END IF
  125. END IF
  126. end event
  127. event ue_build_tree_fnc();//====================================================================
  128. // Function: wf_build_functree()
  129. //--------------------------------------------------------------------
  130. // Description:
  131. //--------------------------------------------------------------------
  132. // Arguments:(None)
  133. //--------------------------------------------------------------------
  134. // Returns: integer
  135. //--------------------------------------------------------------------
  136. // Author: yyx Date: 2004.11.16
  137. //--------------------------------------------------------------------
  138. // Modify History:
  139. //
  140. //====================================================================
  141. long hand,ll_getitem
  142. ol_deep=1
  143. s_sys_func s_sf_ls
  144. treeviewitem ltvi_Item
  145. long tvi_hdl = 0
  146. do until this.finditem(roottreeitem!, 0) = -1
  147. this.deleteitem(tvi_hdl)
  148. loop
  149. hand=this.insertitemlast(0,sys_message_title,1)
  150. ll_getitem=this.GetItem(hand, ltvi_Item)
  151. IF ll_getitem>0 THEN
  152. ltvi_Item.data=s_sf_ls
  153. this.setitem( hand, ltvi_Item)
  154. END IF
  155. pf_treegrowth(hand,0,2,1)
  156. this.expanditem(hand)
  157. //return 1
  158. end event
  159. public function integer pf_treegrowth (long arg_handl, long arg_funcid, integer arg_lp, integer arg_showtype);int rslt = 1
  160. s_sys_func ls_s_func[]
  161. long count=0,ls_i
  162. long handl
  163. string ls_power_str
  164. long ll_hand
  165. treeviewitem tvi
  166. ol_deep++
  167. if ol_deep>5000 then //防止死递归
  168. return 0
  169. end if
  170. for ls_i = 1 to sys_ds_funcinfo.rowcount( )
  171. if sys_ds_funcinfo.object.if_use[ls_i] = 0 then continue
  172. if sys_ds_funcinfo.object.functype[ls_i] <= 9 then
  173. if sys_ds_funcinfo.object.parentid[ls_i] = arg_funcid then
  174. count++
  175. ls_s_func[count].funcid = sys_ds_funcinfo.object.funcid[ls_i]
  176. ls_s_func[count].treename = sys_ds_funcinfo.object.treename[ls_i]
  177. ls_s_func[count].menuname = sys_ds_funcinfo.object.menuname[ls_i]
  178. ls_s_func[count].parentid = sys_ds_funcinfo.object.parentid[ls_i]
  179. ls_s_func[count].sortflag = sys_ds_funcinfo.object.sortflag[ls_i]
  180. ls_s_func[count].functype = sys_ds_funcinfo.object.functype[ls_i]
  181. ls_s_func[count].mainid = sys_ds_funcinfo.object.mainid[ls_i]
  182. ls_s_func[count].if_use = sys_ds_funcinfo.object.if_use[ls_i]
  183. ls_s_func[count].worktype= sys_ds_funcinfo.object.worktype[ls_i]
  184. end if
  185. end if
  186. next
  187. for ls_i=1 to count
  188. handl=this.insertitemlast(arg_handl,ls_s_func[ls_i].treename,ls_s_func[ls_i].functype) //生成树
  189. //'['+string(ls_s_func[ls_i].mainid)+']'
  190. this.getitem(handl,tvi)
  191. tvi.data=ls_s_func[ls_i]
  192. this.setitem( handl, tvi)
  193. //this.expanditem(arg_handl)
  194. pf_treegrowth(handl,ls_s_func[ls_i].funcid,arg_lp+1,arg_showtype) //下级生成树
  195. next
  196. return rslt
  197. end function
  198. on us_fncpwrtree.create
  199. end on
  200. on us_fncpwrtree.destroy
  201. end on
  202. event rightclicked; IF Handle<=0 THEN RETURN
  203. il_handle=handle
  204. m_popup om_1
  205. om_1=CREATE m_popup
  206. //把菜单的anyobject指向被右击的对象(dw_1)
  207. om_1.anyobject=this
  208. //om_1.setmenuitem("添加子项|添加兄弟|编辑|-|删除")
  209. //可在此调用om_1.setitemdisable(itemorder)函数disable某菜单项。
  210. om_1.popupmenu(this.x+this.pointerx(),this.y+this.pointery())
  211. destroy om_1
  212. end event
  213. event doubleclicked;long ll_hand,mainid
  214. treeviewitem tvi
  215. string ls_tv_label
  216. s_sys_func s_lss
  217. ll_hand=this.finditem(CurrentTreeItem!,0)
  218. this.getitem(ll_hand,tvi)
  219. s_lss=tvi.data
  220. mainid=s_lss.mainid
  221. if mainid>0 then
  222. f_sys_main(mainid)
  223. return 1
  224. end if
  225. end event