Sha256: 3fe0c1d1da83094fce6b0c3359df5e94e1cd61c6b10dcf48021fb215eae15cc2

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.
# 
# Some parts are
# Copyright 2004-2007, wxRuby development team
# released under the MIT-like wxRuby2 license

# Bottom-up implementation of a Directory lister

class Wx::GenericDirCtrl
  module DirCtrlTree 
    # The TreeCtrl contained in a GenericDirCtrl already has C++ data
    # associated with the items. If these are returned to Ruby crashes
    # will result. So this module sets the TreeCtrl to return the path
    # string.
    def get_item_data(tree_id)
      root_id = get_root_item
      return "" if tree_id == root_id

      path = item_text(tree_id)
      while tree_id = item_parent(tree_id) and tree_id != root_id
        path = item_text(tree_id) + "/#{path}" 
      end
      unless Wx::PLATFORM == 'WXMSW'
        path = "/" + path
      end
      path
    end

    alias :get_item_path :get_item_data

    # Not allowed
    def set_item_data(tree_id, data)
      Kernel.raise "Item data cannot be set for a GenericDirCtrl's Tree"
    end
  end
  
  wx_get_tree_ctrl = instance_method(:get_tree_ctrl)
  define_method(:get_tree_ctrl) do 
    tree = wx_get_tree_ctrl.bind(self).call
    tree.extend(DirCtrlTree)
    tree
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
wxruby3-1.3.1 lib/wx/core/genericdirctrl.rb
wxruby3-1.3.0 lib/wx/core/genericdirctrl.rb
wxruby3-1.2.1 lib/wx/core/genericdirctrl.rb
wxruby3-1.2.0 lib/wx/core/genericdirctrl.rb
wxruby3-1.1.2 lib/wx/core/genericdirctrl.rb
wxruby3-1.1.1 lib/wx/core/genericdirctrl.rb
wxruby3-1.1.0 lib/wx/core/genericdirctrl.rb
wxruby3-1.0.1 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.8 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.7 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.5 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.4 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.3 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.2 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.1 lib/wx/core/genericdirctrl.rb
wxruby3-0.9.0 lib/wx/core/genericdirctrl.rb