Sha256: 2be43ebb7fa243874b8f6a589a10b1ed6f935bce120d5d885fe3c86684982d68

Contents?: true

Size: 1.29 KB

Versions: 53

Compression:

Stored size: 1.29 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 = [ get_first_child(parent) ]
    return [] if kids[0].zero?

    while kid = get_next_sibling(kids.last) and not kid.zero?
      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

53 entries across 53 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 lib/wx/classes/treectrl.rb
wxruby-ruby19-2.0.1-x86-mingw32 lib/wx/classes/treectrl.rb
wxruby-ruby19-2.0.1-x86-linux lib/wx/classes/treectrl.rb
wxruby-ruby19-2.0.1-x86-darwin-9 lib/wx/classes/treectrl.rb
wxruby-2.0.1-x86-mswin32-60 lib/wx/classes/treectrl.rb
wxruby-2.0.1-x86-mingw32 lib/wx/classes/treectrl.rb
wxruby-2.0.1-x86-linux lib/wx/classes/treectrl.rb
wxruby-2.0.1-universal-darwin-9 lib/wx/classes/treectrl.rb
wxruby-1.9.7-i386-mswin32 lib/wx/classes/treectrl.rb
wxruby-1.9.5-i386-mswin32 lib/wx/classes/treectrl.rb
wxruby-1.9.4-i386-mswin32 lib/wx/classes/treectrl.rb
wxruby-1.9.3-i386-mswin32 lib/wx/classes/treectrl.rb
wxruby-1.9.10-universal-darwin-9 lib/wx/classes/treectrl.rb
wxruby-1.9.10-x86-linux lib/wx/classes/treectrl.rb
wxruby-1.9.10-x86-mswin32-60 lib/wx/classes/treectrl.rb
wxruby-1.9.10-x86-mingw32 lib/wx/classes/treectrl.rb
wxruby-1.9.10-x86_64-linux lib/wx/classes/treectrl.rb
wxruby-1.9.3-universal-darwin lib/wx/classes/treectrl.rb
wxruby-1.9.3-x86-linux lib/wx/classes/treectrl.rb
wxruby-1.9.4-x86-linux lib/wx/classes/treectrl.rb