#
# tkmultilistbox.rb : multiple listbox widget
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
class TkMultiListbox < TkListbox
include TkComposite
# lbox_height : height of listboxes (pixel)
# title_info : array [ [<title_string>,<init_width>], ... ]
# keys : hash {<option>=><value>, ... }
def initialize_composite(lbox_height, title_info, keys={})
# argument check
if (! title_info.kind_of? Array) or (title_info.size < 2)
raise
end
# decide total width
@width_total = 0
title_info.each{|title, width| @width_total += width.to_f}
# virtical scrollbar
@v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
# init arrays
@base_list = []
@rel_list = []
@title_list = []
@lbox_list = []
@hscr_list = []
# rel-table of label=>index
@name_index = {}
# create base flames
@f_title = TkFrame.new(@frame, 'width'=>@width_total)
@f_lbox = TkFrame.new(@frame,
'width'=>@width_total, 'height'=>lbox_height)
@f_hscr = TkFrame.new(@frame, 'width'=>@width_total,
'height'=>@v_scroll.cget('width') +
|