Class: VRListbox
Constant Summary
collapse
- WINCLASSINFO =
VRListbox
Listbox.
Listbox has multi strings to select.
Methods
--- addString(idx,str)
Adds ((|str|)) String at the ((|idx|)).
When ((|idx|)) is omitted, ((|str|)) is added at the bottom.
--- deleteString(idx)
Deletes string at ((|idx|))
--- countStrings
Returns the count of its strings.
--- clearStrings
Deletes all strings.
--- eachString
Yields each string.
--- setListStrings(strarray)
Sets array of string ( ((|strarray|)) ) as the listbox strings.
--- selectedString
Returns the selected index.
--- select(idx)
Selects ((|idx|))-th string.
--- getTextOf(idx)
Retrieves the text of ((|idx|))-th string.
--- setDir(fname,opt=0)
Sets the filenames specified by ((|fname|)) to the listbox.
((|opt|)) specifies the attributes of the files to be added.
--- findString(findstr,start=0)
Finds ((|findstr|)) in the listbox strings and returns the its index.
((|start|)) specifies the index to start finding.
--- getDataOf(idx)
Retrieves the 32bit value associated with the ((|idx|))-th string.
--- setDataOf(idx,data)
Associates the 32bit value with the ((|idx|))-th string.
Event handlers
--- ????_selchanged
Fired when the selected string is changed.
["LISTBOX",WStyle::LBS_STANDARD,WExStyle::WS_EX_CLIENTEDGE]
Instance Attribute Summary
Attributes inherited from VRControl
#handlers, #name, #parent
#parent, #screen
Instance Method Summary
collapse
#_vr_cmdhandlers, #addCommandHandler, #deleteCommandHandler
Methods inherited from VRControl
Controltype, #add_parentcall, #call_parenthandler, #create, #setFont
#_init, #create, #exwinstyle, #hide, #maximizebox, #maximizebox=, #minimizebox, #minimizebox=, #setscreen, #sizebox, #sizebox=, #tabstop, #tabstop=, #winstyle
Instance Method Details
#addString(*arg) ⇒ Object
578
579
580
581
582
583
584
|
# File 'lib/vr/vrcontrol.rb', line 578
def addString(*arg)
if arg[0].is_a?(Integer) then
sendMessage WMsg::LB_INSERTSTRING,arg[0],arg[1].to_s
else
sendMessage WMsg::LB_ADDSTRING,0,arg[0].to_s
end
end
|
#clearStrings ⇒ Object
593
594
595
596
597
598
|
# File 'lib/vr/vrcontrol.rb', line 593
def clearStrings
c=getCount
(1..c).each do |i|
deleteString 0 end
end
|
#countStrings ⇒ Object
Also known as:
getCount
589
590
591
|
# File 'lib/vr/vrcontrol.rb', line 589
def countStrings
sendMessage WMsg::LB_GETCOUNT,0,0
end
|
#deleteString(idx) ⇒ Object
586
587
588
|
# File 'lib/vr/vrcontrol.rb', line 586
def deleteString(idx)
sendMessage WMsg::LB_DELETESTRING,idx.to_i,0
end
|
#eachSelected ⇒ Object
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
|
# File 'lib/vr/vrcontrol.rb', line 643
def eachSelected
count = sendMessage(WMsg::LB_GETSELCOUNT,0,0)
if count<1 then
yield selectedString
return
end
buffer = '\0\0\0\0' * count
sendMessage(WMsg::LB_GETSELITEMS,count,buffer)
buffer.unpack("I*")[0,count].each do |i|
yield i
end
end
|
#eachString ⇒ Object
600
601
602
603
604
605
|
# File 'lib/vr/vrcontrol.rb', line 600
def eachString
c=getCount
0.upto(c-1) do |i|
yield getString(i)
end
end
|
#findString(findstr, start = 0) ⇒ Object
632
633
634
|
# File 'lib/vr/vrcontrol.rb', line 632
def findString(findstr,start=0)
sendMessage(WMsg::LB_FINDSTRING,start.to_i,findstr.to_s)
end
|
#getDataOf(idx) ⇒ Object
Also known as:
getItemData
636
637
638
|
# File 'lib/vr/vrcontrol.rb', line 636
def getDataOf(idx)
sendMessage(WMsg::LB_GETITEMDATA,idx.to_i,0)
end
|
#getTextOf(idx) ⇒ Object
Also known as:
getString, itemString
616
617
618
619
620
621
622
|
# File 'lib/vr/vrcontrol.rb', line 616
def getTextOf(idx)
len = sendMessage(WMsg::LB_GETTEXTLEN,idx.to_i,0) raise "No such index(#{idx}) in the Listbox"if len<0
str=" " * len
sendMessage(WMsg::LB_GETTEXT,idx.to_i,str) str
end
|
#select(idx) ⇒ Object
624
625
626
|
# File 'lib/vr/vrcontrol.rb', line 624
def select(idx)
sendMessage(WMsg::LB_SETCURSEL,idx.to_i,0)
end
|
#selectedString ⇒ Object
Also known as:
selectedIndex
612
613
614
|
# File 'lib/vr/vrcontrol.rb', line 612
def selectedString
sendMessage(WMsg::LB_GETCURSEL,0,0)
end
|
#setDataOf(idx, data) ⇒ Object
Also known as:
setItemData
639
640
641
|
# File 'lib/vr/vrcontrol.rb', line 639
def setDataOf(idx,data)
sendMessage(WMsg::LB_SETITEMDATA,idx.to_i,data.to_i)
end
|
#setDir(fname, opt = 0) ⇒ Object
628
629
630
|
# File 'lib/vr/vrcontrol.rb', line 628
def setDir(fname,opt=0)
sendMessage(WMsg::LB_DIR,opt.to_i,fname.to_s)
end
|
#setListStrings(sarray) ⇒ Object
607
608
609
610
|
# File 'lib/vr/vrcontrol.rb', line 607
def setListStrings(sarray)
@_vr_init_items=sarray
if hWnd>0 then set_liststrings end
end
|
561
562
563
564
565
|
# File 'lib/vr/vrcontrol.rb', line 561
def vrinit
super
addCommandHandler(WMsg::LBN_SELCHANGE, "selchange",MSGTYPE::ARGNONE,nil)
set_liststrings
end
|
#vrinitnew ⇒ Object
16
17
18
19
20
|
# File 'lib/vr/compat/vrcontrol.rb', line 16
def vrinit
super
addCommandHandler(WMsg::LBN_SELCHANGE, "selchange",MSGTYPE::ARGNONE,nil)
set_liststrings
end
|