Methods
Class Public methods
new(dir)
Link
# File ext/tk/sample/tkextlib/treectrl/demo.rb, line 24 def initialize(dir) @ScriptDir = dir || '.' @thisPlatform = Tk::PLATFORM['platform'] if @thisPlatform == 'unix' && Tk.windowingsystem == 'aqua' @thisPlatform = 'macosx' end @RandomN = [500] @images = Hash.new @sel_images = Hash.new @popup = Hash.new @mTree = Hash.new @mHeader = Hash.new @non_clear_list = [] @demoCmd = Hash.new @demoFile = Hash.new # Get default colors w = TkListbox.new @SystemButtonFace = w[:highlightbackground] @SystemHighlight = w[:selectbackground] @SystemHighlightText = w[:selectforeground] w.destroy #################### make_source_window() make_menubar() make_main_window() if $Version_1_1_OrLater begin @tree2[:backgroundimage] @has_bgimg = true rescue @has_bgimg = false end else @has_bgimg = false end #################### make_list_popup() make_header_popup() init_pics('sky') #################### @tree2.bind('ButtonPress-3', proc{|w, x, y, rootx, rooty| show_list_popup(w, x, y, rootx, rooty) }, '%W %x %y %X %Y') # Allow "scan" bindings if @thisPlatform == 'windows' @tree2.bind_remove('Control-ButtonPress-3') end #################### init_demo_scripts_module() load_demo_scripts() init_demo_list() #################### @tree1.notify_bind(@tree1, 'Selection', proc{|c, t| if c == 1 item = t.selection_get[0] demo_set(@demoCmd[item], @demoFile[item]) end }, '%c %T') # When one item is selected in the demo list, display the styles in # that item. # See DemoClear for why the tag "DontDelete" is used @tree2.notify_bind('DontDelete', 'Selection', proc{|c, t| display_styles_in_item(t.selection_get[0]) if c == 1 }, '%c %T') end
Instance Public methods
init_pics(*args)
Link
# File ext/tk/sample/tkextlib/treectrl/demo.rb, line 116 def init_pics(*args) args.each{|pat| unless TkImage.names.find{|img| (name = @images.key(img)) && File.fnmatch(pat, name)} Dir.glob(File.join(@ScriptDir, 'pics', "#{pat}.gif")).each{|file| name = File.basename(file, '.gif') img = TkPhotoImage.new(:file=>file) @images[name] = img @sel_images[name] = TkPhotoImage.new @sel_images[name].copy(img) Tk::TreeCtrl.image_tint(@sel_images[name], @SystemHighlight, 128) } end } end