$PBExportHeader$uo_tv_menu_fx.sru
$PBExportComments$协同系统的treeview menu
forward
global type uo_tv_menu_fx from treeview
end type
end forward

global type uo_tv_menu_fx from treeview
integer width = 549
integer height = 476
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
string picturename[] = {"graphics\application_fx.gif","graphics\Shell32 005.bmp","graphics\application_fx.gif","graphics\application_fx.gif","graphics\application_fx.gif","graphics\application_fx.gif","graphics\application_fx.gif","graphics\application_fx.gif","graphics\application_fx.gif","graphics\task.bmp"}
integer picturewidth = 16
integer pictureheight = 16
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type
global uo_tv_menu_fx uo_tv_menu_fx

type variables
datastore ins_ds
end variables

forward prototypes
public subroutine init (readonly datastore arg_ds)
public subroutine uof_treegrowth (long arg_handl, long arg_parentid)
end prototypes

public subroutine init (readonly datastore arg_ds);//
IF IsValid(ins_ds) THEN
	Destroy ins_ds
END IF

ins_ds = Create datastore

if arg_ds.DataObject <> 'ds_menu_fx' then
	MessageBox('提示', '使用的arg_ds参数有误')
	return
end if

ins_ds = arg_ds
ins_ds.SetSort('parentid,sortflag')
ins_ds.Sort()

this.SetRedraw(false)
DO UNTIL This.FindItem(RootTreeItem!, 0) = -1
	This.DeleteItem(0)
LOOP

long ll_hand_root
ll_hand_root = This.InsertItemLast(0, '协同系统',1)
uof_treegrowth(ll_hand_root, 0)
This.ExpandItem(ll_hand_root)

long ll_hand
ll_hand = This.FindItem(ChildTreeItem!, ll_hand_root)
DO UNTIL ll_hand = - 1
	This.ExpandItem(ll_hand)
	ll_hand = This.FindItem(NextTreeItem!, ll_hand)
LOOP

this.SetRedraw(true)

//Destroy ins_ds ChildTreeItem!	NextTreeItem! 	
end subroutine

public subroutine uof_treegrowth (long arg_handl, long arg_parentid);//
Long li_handl
TreeViewItem l_tvi

Long ll_row, ll_rowChild
ll_row = ins_ds.Find("parentid = " + String(arg_parentid) + ' and functype <> 9', 1, ins_ds.RowCount())
//ll_row = ins_ds.Find("parentid = " + String(arg_parentid), 1, ins_ds.RowCount())

string treename, objname
long funcid, functype
DO WHILE ll_row > 0
	treename = ins_ds.Object.treename[ll_row]
//	objname = ins_ds.Object.objname[ll_row]
	funcid = ins_ds.Object.funcid[ll_row]
	functype = ins_ds.Object.functype[ll_row]
	
	li_handl = This.InsertItemLast(arg_handl, treename, functype + 2)
	
	ll_rowChild = ins_ds.Find("parentid = " + String(funcid) + ' and functype <> 9', 1, ins_ds.RowCount())
//	ll_rowChild = ins_ds.Find("parentid = " + String(funcid), 1, ins_ds.RowCount())
	
	IF This.GetItem(li_handl, l_tvi) = 1 THEN
		l_tvi.Label = treename
		l_tvi.Data  = funcid
		IF ll_rowChild > 0 THEN
			l_tvi.Children = True
		END IF
		This.SetItem(li_handl, l_tvi)
		
		uof_treegrowth(li_handl, funcid)
	END IF
	
	IF ll_row >= ins_ds.RowCount() THEN EXIT
	ll_row = ins_ds.Find("parentid = " + String(arg_parentid) + ' and functype <> 9', ll_row + 1, ins_ds.RowCount())
//	ll_row = ins_ds.Find("parentid = " + String(arg_parentid), ll_row + 1, ins_ds.RowCount())
LOOP



end subroutine

on uo_tv_menu_fx.create
end on

on uo_tv_menu_fx.destroy
end on

event doubleclicked;//
long ll_hand, funcid
treeviewitem tvi

ll_hand = THIS.FindItem(currenttreeitem!, 0)
THIS.GetItem(ll_hand, tvi)
funcid = long(tvi.Data)

if IsNull(funcid) then return
if (funcid <= 0) then return

long row
string objname
if IsValid(w_main_fx) and IsValid(sys_func_pwr) then
	sys_func_pwr.SetFilter('')
	sys_func_pwr.Filter()
	
	row = sys_func_pwr.Find('funcid = ' + string(funcid), 1, sys_func_pwr.RowCount())
	if (row <= 0) then return
	objname = sys_func_pwr.Object.objname[row]
	if IsNull(objname) then return
	if (objname = '') then return
	
	w_main_fx.PostEvent('ue_main_menu_commnd', 0, funcid)
//	Message.LongParm = funcid
//	w_main_fx.Post Event ue_main_menu_commnd()
end if
end event

