Sha256: 4534acdf0affe5e982790c5b8e1669a2331320201d7733beaf90ead1dc18bf81

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# Hierarchical control with items
class Wx::TreeCtrl
  # Make these ruby enumerables so find, find_all, map etc are available
  include Enumerable
  # Iterate over all items
  alias :each :traverse

  # Return the children of +parent+ as an array of TreeItemIDs.
  def get_children(parent)
    kids = []
    kid, _ = get_first_child(parent)
    return [] unless kid.ok?
    kids << kid

    while kid = get_next_sibling(kids.last) and kid.ok?
      kids << kid
    end
    kids
  end

  # Returns a Wx::Rect corresponding to the edges of an individual tree
  # item, including the button, identified by id. The standard wxWidgets
  # API for getting the pixel location of an item is unrubyish, using an
  # input/output parameter. But since the underlying get_bounding_rect
  # method works, it's easier to fix the API in Ruby than adding more to
  # the already-toxic swig interface TreeCtrl.i file.
  def get_item_rect(tree_item_id)
    rect = Wx::Rect.new
    if get_bounding_rect(tree_item_id, rect, false)
      return rect
    else
      return nil
    end
  end

  # Returns a Wx::Rect corresponding to the edges of an individual tree
  # item's text label. See above.
  def get_label_rect(tree_item_id)
    rect = Wx::Rect.new
    if get_bounding_rect(tree_item_id, rect, true)
      return rect
    else
      nil
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.rc.2 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.rc.1 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.14 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.13 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.11 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.10 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.9 lib/wx/core/treectrl.rb
wxruby3-0.9.0.pre.beta.8 lib/wx/core/treectrl.rb