Sha256: fc7089a008997ad45ad215b7130876043b7753354f3798412a20bdef2aef5eee

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

# A ListBox, where each item has a checkbox next to it
class Wx::CheckListBox
  # wxRuby redefinitions of core methods to add item data support (not
  # available in wxWidgets). Use a private method to initialize and
  # access the data, rather than in initialize(), b/c can't guarantee
  # that initialize will be called (eg when loaded from XRC)
  def __wx_item_data
    @__wx_item_data ||= []
  end
  private :__wx_item_data

  # Call method in ControlWithItems, then sync item data
  def append(item, data = nil)
    i = super(item)
    __wx_item_data[count - 1] = data
    return i
  end

  # Call method in ControlWithItems, then sync item data
  def clear
    super
    __wx_item_data.clear
  end

  # delete is defined in Wx::CheckListBox, so must be called in this class
  wx_delete = self.instance_method(:delete)
  define_method(:delete) do | n |
    wx_delete.bind(self).call(n)
    __wx_item_data.delete_at(n)
  end

  # Returns an array of indices of items that are currently checked.
  def get_checked_items
    find_all { | i | checked?(i) }    
  end
  
  # Wholly redefined here
  def get_item_data(n)
    __wx_item_data[n]
  end

  # Wholly redefined here
  def set_item_data(n, data)
    __wx_item_data[n] = data
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 lib/wx/classes/checklistbox.rb
wxruby-ruby19-2.0.1-x86-mingw32 lib/wx/classes/checklistbox.rb
wxruby-ruby19-2.0.1-x86-linux lib/wx/classes/checklistbox.rb
wxruby-ruby19-2.0.1-x86-darwin-9 lib/wx/classes/checklistbox.rb
wxruby-2.0.1-x86-mswin32-60 lib/wx/classes/checklistbox.rb
wxruby-2.0.1-x86-mingw32 lib/wx/classes/checklistbox.rb
wxruby-2.0.1-x86-linux lib/wx/classes/checklistbox.rb
wxruby-2.0.1-universal-darwin-9 lib/wx/classes/checklistbox.rb