mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ed6ce8b43b
* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes. ( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. ) * ext/tk/*: Unify sources between Ruby 1.8 & 1.9. Improve default_widget_set handling. * ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9. ( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk callbacks may freeze. On Ruby 1.9, cannot create a second master interpreter (creating slaves are OK); supported master interpreter is the default master interpreter only. ) * ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions. Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5 BWidgets 1.7 ==> BWidgets 1.8 TkTable 2.9 ==> TkTable 2.10 TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9 Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1 IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15 TclX 2005-02-07 ==> TclX 2008-12-15 Trofs 0.4.3 ==> Trofs 0.4.4 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
150 lines
3.2 KiB
Ruby
150 lines
3.2 KiB
Ruby
#
|
|
# tkextlib/tcllib/swaplist.rb
|
|
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
|
#
|
|
# * Part of tcllib extension
|
|
# * A dialog which allows a user to move options between two lists
|
|
#
|
|
|
|
require 'tk'
|
|
require 'tkextlib/tcllib.rb'
|
|
|
|
# TkPackage.require('swaplist', '0.1')
|
|
TkPackage.require('swaplist')
|
|
|
|
module Tk::Tcllib
|
|
class Swaplist_Dialog < TkWindow
|
|
PACKAGE_NAME = 'swaplist'.freeze
|
|
def self.package_name
|
|
PACKAGE_NAME
|
|
end
|
|
|
|
def self.package_version
|
|
begin
|
|
TkPackage.require('swaplist')
|
|
rescue
|
|
''
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
class Tk::Tcllib::Swaplist_Dialog
|
|
TkCommandNames = ['::swaplist::swaplist'.freeze].freeze
|
|
WidgetClassName = 'Swaplist'.freeze
|
|
WidgetClassNames[WidgetClassName] ||= self
|
|
|
|
def self.show(*args)
|
|
dialog = self.new(*args)
|
|
dialog.show
|
|
[dialog.status, dialog.value]
|
|
end
|
|
def self.display(*args)
|
|
self.show(*args)
|
|
end
|
|
|
|
def initialize(*args)
|
|
# args = (parent=nil, complete_list=[], selected_list=[], keys=nil)
|
|
keys = args.pop
|
|
if keys.kind_of?(Hash)
|
|
@selected_list = args.pop
|
|
@complete_list = args.pop
|
|
@keys = _symbolkey2str(keys)
|
|
args.push(keys)
|
|
else
|
|
@selected_list = keys
|
|
@complete_list = args.pop
|
|
@keys = {}
|
|
end
|
|
|
|
@selected_list = [] unless @selected_list
|
|
@complete_list = [] unless @complete_list
|
|
|
|
@variable = TkVariable.new
|
|
@status = nil
|
|
|
|
super(*args)
|
|
end
|
|
|
|
def create_self(keys)
|
|
# dummy
|
|
end
|
|
private :create_self
|
|
|
|
def show
|
|
@variable.value = ''
|
|
@status = bool(tk_call(self.class::TkCommandNames[0],
|
|
@path, @variable,
|
|
@complete_list, @selected_list,
|
|
*hash_kv(@keys)))
|
|
end
|
|
alias display show
|
|
|
|
def status
|
|
@status
|
|
end
|
|
|
|
def value
|
|
@variable.list
|
|
end
|
|
alias selected value
|
|
|
|
def cget_strict(slot)
|
|
slot = slot.to_s
|
|
if slot == 'complete_list'
|
|
@complete_list
|
|
elsif slot == 'selected_list'
|
|
@selected_list
|
|
else
|
|
@keys[slot]
|
|
end
|
|
end
|
|
def cget(slot)
|
|
cget_strict(slot)
|
|
end
|
|
|
|
def configure(slot, value=None)
|
|
if slot.kind_of?(Hash)
|
|
slot.each{|k, v| configure(k, v)}
|
|
else
|
|
slot = slot.to_s
|
|
value = _symbolkey2str(value) if value.kind_of?(Hash)
|
|
if value && value != None
|
|
if slot == 'complete_list'
|
|
@complete_list = value
|
|
elsif slot == 'selected_list'
|
|
@selected_list = value
|
|
else
|
|
@keys[slot] = value
|
|
end
|
|
else
|
|
if slot == 'complete_list'
|
|
@complete_list = []
|
|
elsif slot == 'selected_list'
|
|
@selected_list = []
|
|
else
|
|
@keys.delete(slot)
|
|
end
|
|
end
|
|
end
|
|
self
|
|
end
|
|
|
|
def configinfo(slot = nil)
|
|
if slot
|
|
slot = slot.to_s
|
|
if slot == 'complete_list'
|
|
[ slot, nil, nil, nil, @complete_list ]
|
|
elsif slot == 'selected_list'
|
|
[ slot, nil, nil, nil, @selected_list ]
|
|
else
|
|
[ slot, nil, nil, nil, @keys[slot] ]
|
|
end
|
|
else
|
|
@keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
|
|
<< [ 'complete_list', nil, nil, nil, @complete_list ] \
|
|
<< [ 'selected_list', nil, nil, nil, @selected_list ]
|
|
end
|
|
end
|
|
end
|