I have been playing with Royale a bit, and wanted to implement a ListTree gadget. I have read the documentation but am stumped as how to add items(leaves) to my list.
Here is the simple test program I have sofar. ( I have used the Drive directory as an example so that I dont have to supply lots of data )
Code: Select all
@VERSION 6,0
@REQUIRE "MUIRoyale"
@APPTITLE ""
@APPVERSION "$VER: 1.0 (01.01.15)"
@APPCOPYRIGHT "©2015, George Leo den Hollander"
@APPAUTHOR "Leo den Hollander"
@APPDESCRIPTION "Program"
@DISPLAY {Hidden = True}
devices = {}
harddisks = {}
optical = {}
usb = {}
ram = {}
Devs = {}
; ###########################################################################################################
MUI.CreateGui([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application base="DidL">
<window title=" Program Name Here" id="window" width="800" height="400" notify="closerequest" >
<vgroup background="pre_ShadowFill">
<vgroup>
<listtree id="Files" >
</listtree>
</vgroup>
</vgroup>
</window>
</application>
]])
; ####################################################################################
Function p_ListDrives() ; * Find all devices *********************************************************************************
Execute("info devices sort volume >TEXTCLIP:")
type, data = GetClipboard()
h = 0
o = 0
u = 0
r = 0
devices, noofdevices = SplitStr(data,"\n")
For Local x = 1 to noofdevices-1
line = devices[x-1]
If FindStr(line,"DH",False) = 0
harddisks[h] = MidStr(line,0, FindStr(line,":"))
h = h +1
ElseIf FindStr(line,"CD",False) = 0
optical[o] = MidStr(line,0, FindStr(line,":"))
o = o +1
ElseIf FindStr(Line,"USB",False) = 0
usb[u] = MidStr(line,0, FindStr(line,":"))
u = u +1
ElseIf FindStr(line,"RAM",False) = 0
ram[r] = MidStr(line,0, FindStr(line,":"))
r = r +1
EndIf
Next
L=1
For Local d = 0 to h-1
Devs[l] = Harddisks[d]
L = L +1
Next
; comment out for demo
; For Local d = 0 to r-1
; Devs[l] = ram[d]
; L = L +1
; Next
; For Local d = 0 to u-1
; Devs[l] = Usb[d]
; L = L +1
; Next
; For Local d = 0 to o-1
; Devs[l] = Optical[d]
; L = L +1
; Next
EndFunction
Function p_ListDirectories(SDir$)
dd = OpenDirectory(NIL,SDir$..":")
E = NextDirectoryEntry(dd)
While E <> Nil
If E.type = #DOSTYPE_FILE
EndIf
If E.type = #DOSTYPE_DIRECTORY
mui.DoMethod("Files","Insert",E.name,E.name,"Root","Tail","NextNode")
EndIf
E = NextDirectoryEntry(dd)
Wend
CloseDirectory(dd)
EndFunction
Function p_MUIEvent(id) ; * Joint event handler for MUI buttons and menus ***********************************
Switch id
Case "Quit":
End
EndSwitch
EndFunction
Function p_EventFunc(msg)
Switch msg.action
Case "MUIRoyale":
Switch msg.attribute
Case "CloseRequest":
End
Case "Pressed":
p_MUIEvent(msg.id)
Endswitch
Case "HideWindow":
MUI.Set("app", "iconified", True)
Case "ShowWindow":
MUI.Set("app", "iconified", False)
EndSwitch
EndFunction
; listen to these events!
InstallEventHandler({MUIRoyale = p_EventFunc, HideWindow = p_EventFunc, ShowWindow = p_EventFunc})
p_ListDrives()
For Local d = 1 to L-1
mui.DoMethod("Files","Insert",Devs[d],Devs[d],"Root","Tail","active")
mui.set("Files","Active",Devs[d])
p_ListDirectories(Devs[d])
Next
; main loop!
Repeat
WaitEvent
Forever
Any help would be great.
Cheers
Leo