aUCBLogo Demos and Tests / listcontroltest
be listcontroltest
lctest
; thread [lctest]
end
to lctest
; local [f icid id row tcfname tcname tclogo lc i
; bappend bdelete bs bsh bsh2 finish]
f=Frame [][MyFrame]
wxDefault_Frame_Style+wxStay_on_Top
[0 0][400 400]
FrameSetBackgroundColor f RGB .89 .87 .83
FrameOnClose f [lctest::finish=true]
icid=(IntControl f [ID] 1 1 400
[ id=IntControlValue
repeat ListControlItemCount lc
[ row=repcount-1
if (ListControlGetItem lc row 0)==id [break]
]
updateForm row lc
] wxSP_Arrow_Keys [10 20][50 -1])
row=0
tcfname=(TextControl f [First name] "
[ ;OnChange
]
[ ;OnEnter
txt=TextControlValue
ListControlSetItem lc row 1 txt
])
tcname=(TextControl f [Name] "
[ ;OnChange
]
[ ;OnEnter
txt=TextControlValue
ListControlSetItem lc row 2 txt
])
tclogo=(TextControl f [Logo] "
[ ;OnChange
]
[ ;OnEnter
txt=TextControlValue
ListControlSetItem lc row 3 txt
])
lc=(ListControl f [MyListControl]
[ row=ListControlRow
(pr word [row=] row
word [column=] ListControlColumn
ListControlText
[Selected])
id=Int (ListControlGetItem lc row 0)
IntControlSetValue icid id
updateForm row lc
]
[ (pr word [row=] ListControlRow
word [column=] ListControlColumn
ListControlText
[Activated])
]
[ c=ListControlColumn
(pr word [column=] c
[Columnclick])
ListControlSort lc c
] wxLC_REPORT [-1 -1][-1 -1])
foreach [[[ID] 40][[First Name] 80][[Name] 120][[Logo] 120]]
[ (ListControlInsertColumn lc # (?).1 (?).2)
]
data=
[ [1 Brian Harvey UCBLogo]
[2 George Mills MSWLogo]
[3 Pavel Boytchev Elica]
[4 Lionel Laske Liogo]
[5 Andreas Micheler aUCBLogo]
]
ListControlSet lc data
; foreach data
; [ row=repcount-1
; ListControlInsertItem lc row
; ListControlSetRow lc row ?
; ]
; ListControlSetColumn lc 2 [H. M. B. L. M.]
bappend=Button f [&Insert item]
[ i=ListControlItemCount lc
ListControlInsertItem lc i
repeat ListControlColumnCount lc
[ ListControlSetItem lc i repcount-1 se [Item] gensym
]
]
bdelete=Button f [&Delete last item]
[ if (ListControlItemCount lc) > 0
[ ListControlDeleteItem lc (ListControlItemCount lc)-1
]
]
bs=BoxSizer wxVertical
bsh=BoxSizer wxHorizontal
BoxSizerAdd bs bsh 0 wxAll+wxExpand 10
BoxSizerAdd bsh icid 0 wxExpand 0
BoxSizerAdd bsh tcfname 1 wxExpand 0
BoxSizerAdd bsh tcname 1 wxExpand 0
BoxSizerAdd bsh tclogo 1 wxExpand 0
BoxSizerAdd bs lc 1 wxExpand 0
bsh2=BoxSizer wxHorizontal
BoxSizerAdd bsh2 bappend 1 wxExpand 0
BoxSizerAdd bsh2 bdelete 1 wxExpand 0
BoxSizerAdd bs bsh2 0 wxExpand 0
FrameSetSizer f bs
updateForm 0 lc
stop
finish=false
until [finish]
[ dispatchMessages
waituS 100000
]
end
to updateForm row lc
TextControlSetValue tcfname (ListControlGetItem lc row 1)
TextControlSetValue tcname (ListControlGetItem lc row 2)
TextControlSetValue tclogo (ListControlGetItem lc row 3)
end