Class: VRCombobox

Inherits:
VRStdControl show all
Defined in:
lib/vr/vrcontrol.rb,
lib/vr/compat/vrcontrol.rb

Direct Known Subclasses

VREditCombobox

Constant Summary collapse

WINCLASSINFO =

VRCombobox

Combobox is like Listbox, but Only one string is selected.

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 combobox 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 combobox.
((|opt|)) specifies the attributes of the files to be added.

— findString(findstr,start=0)

Finds ((|findstr|)) in the combobox 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.
["COMBOBOX",WStyle::CBS_STANDARD]

Instance Attribute Summary

Attributes inherited from VRControl

#handlers, #name, #parent

Attributes inherited from VRWinComponent

#parent, #screen

Instance Method Summary collapse

Methods inherited from VRStdControl

#_vr_cmdhandlers, #addCommandHandler, #deleteCommandHandler

Methods inherited from VRControl

Controltype, #add_parentcall, #call_parenthandler, #create, #setFont

Methods inherited from VRWinComponent

#_init, #create, #exwinstyle, #hide, #maximizebox, #maximizebox=, #minimizebox, #minimizebox=, #setscreen, #sizebox, #sizebox=, #tabstop, #tabstop=, #winstyle

Instance Method Details

#addString(*arg) ⇒ Object



719
720
721
722
723
724
725
# File 'lib/vr/vrcontrol.rb', line 719

def addString(*arg)
  if arg[0].is_a?(Integer) then
    sendMessage WMsg::CB_INSERTSTRING,arg[0],arg[1].to_s
  else
    sendMessage WMsg::CB_ADDSTRING,0,arg[0].to_s
  end
end

#clearStringsObject



735
736
737
738
739
740
# File 'lib/vr/vrcontrol.rb', line 735

def clearStrings
  c=getCount
  (1..c).each do |i|
    deleteString 0           #delete #0 c-times
  end
end

#countStringsObject Also known as: getCount



731
732
733
# File 'lib/vr/vrcontrol.rb', line 731

def countStrings
    sendMessage WMsg::CB_GETCOUNT,0,0
end

#deleteString(idx) ⇒ Object



728
729
730
# File 'lib/vr/vrcontrol.rb', line 728

def deleteString(idx)
    sendMessage WMsg::CB_DELETESTRING,idx,0
end

#eachStringObject



742
743
744
745
746
747
# File 'lib/vr/vrcontrol.rb', line 742

def eachString
  c=getCount
  0.upto(c-1) do |i|
    yield getString(i)
  end
end

#findString(findstr, start = 0) ⇒ Object



774
775
776
# File 'lib/vr/vrcontrol.rb', line 774

def findString(findstr,start=0)
  sendMessage(WMsg::CB_FINDSTRING,start.to_i,findstr.to_s)
end

#getDataOf(idx) ⇒ Object Also known as: getItemData



778
779
780
# File 'lib/vr/vrcontrol.rb', line 778

def getDataOf(idx)
  sendMessage(WMsg::CB_GETITEMDATA,idx.to_i,0)
end

#getTextOf(idx) ⇒ Object Also known as: getString, itemString



758
759
760
761
762
763
764
# File 'lib/vr/vrcontrol.rb', line 758

def getTextOf(idx)
  len = sendMessage(WMsg::CB_GETLBTEXTLEN,idx,0)   #CB_gettextlen
  raise "No such index(#{idx}) in the Combobox"if len<0
  str=" " * len
  sendMessage(WMsg::CB_GETLBTEXT,idx,str)          #CB_getText
  str
end

#select(idx) ⇒ Object



766
767
768
# File 'lib/vr/vrcontrol.rb', line 766

def select(idx)
  sendMessage(WMsg::CB_SETCURSEL,idx,0)
end

#selectedStringObject Also known as: selectedIndex



754
755
756
# File 'lib/vr/vrcontrol.rb', line 754

def selectedString
  sendMessage(WMsg::CB_GETCURSEL,0,0)
end

#setDataOf(idx, data) ⇒ Object Also known as: setItemData



781
782
783
# File 'lib/vr/vrcontrol.rb', line 781

def setDataOf(idx,data)
  sendMessage(WMsg::CB_SETITEMDATA,idx.to_i,data.to_i)
end

#setDir(fname, opt = 0) ⇒ Object



770
771
772
# File 'lib/vr/vrcontrol.rb', line 770

def setDir(fname,opt=0)
  sendMessage(WMsg::CB_DIR,opt.to_i,fname.to_s)
end

#setListStrings(sarray) ⇒ Object



749
750
751
752
# File 'lib/vr/vrcontrol.rb', line 749

def setListStrings(sarray)
  @_vr_init_items=sarray
  if hWnd>0 then set_liststrings end
end

#vrinitObject



703
704
705
706
707
# File 'lib/vr/vrcontrol.rb', line 703

def vrinit
  super
  set_liststrings
  addCommandHandler(WMsg::CBN_SELCHANGE, "selchange",MSGTYPE::ARGNONE,nil)
end

#vrinitnewObject



34
35
36
37
38
# File 'lib/vr/compat/vrcontrol.rb', line 34

def vrinit
  super
  set_liststrings
  addCommandHandler(WMsg::CBN_SELCHANGE, "selchange",MSGTYPE::ARGNONE,nil)
end