* ext/tk/lib : improve framework of developping Tcl/Tk extension wrappers

* BWidget extension support on Ruby/Tk


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2004-07-06 09:42:12 +00:00
parent 3d8fa55561
commit d8465ff9ab
138 changed files with 8457 additions and 426 deletions

View file

@ -1,3 +1,8 @@
Tue Jul 6 18:38:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib : improve framework of developping Tcl/Tk extension
wrappers
Mon Jul 5 23:56:42 2004 Kouhei Sutou <kou@cozmixng.org> Mon Jul 5 23:56:42 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/{trackback,syndication,dublincore,content}.rb: worked * lib/rss/{trackback,syndication,dublincore,content}.rb: worked

View file

@ -24,16 +24,23 @@ For example, when you install ActiveTcl-8.4.x to '/usr/local/ActiveTcl',
--enable-tcltk-stubs --enable-tcltk-stubs
It depends on your environment that you have to add the directory of It depends on your environment that you have to add the directory of
ActiveTcl's dynamic link libraries to your library path when execute ActiveTcl's libraries to your library path when execute Ruby/Tk.
Ruby/Tk. One of the way is to add entries to TCLLIBPATH environment variable,
and one of the others add to LD_LIBRARY_PATH environment variable
# For example, on Linux, one of the ways is to use LD_LIBRARY_PATH Probably, using TCLLIBPATH is better. The value is appended at the
# environment variable. head of Tcl's 'auto_path' variable. You can see the value of the
# variable by using 'Tk::AUTO_PATH.value' or 'Tk::AUTO_PATH.list'.
# [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \
# ruby your-Ruby/Tk-script For example, on Linux, one of the ways is to use LD_LIBRARY_PATH
# environment variable.
# [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb -------------------------------------------------------------------------
[bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \
ruby your-Ruby/Tk-script
[bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb
-------------------------------------------------------------------------
Based on it, the Tcl interpreter changes auto_path variable's value.
Then, you'll be able to use Tcl/Tk extension libraries included in the Then, you'll be able to use Tcl/Tk extension libraries included in the
ActiveTcl package (e.g. call TkPackage.require('BWidget'), and then, ActiveTcl package (e.g. call TkPackage.require('BWidget'), and then,

View file

@ -1,3 +1,13 @@
2004-07-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* support BWidget extension
* add BWidget extension demo
* add ICONS extension demo
* many bug fix
2004-07-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> 2004-07-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* 1st release of tkextlib ( to support Tcl/Tk extensions ) * 1st release of tkextlib ( to support Tcl/Tk extensions )

View file

@ -96,6 +96,40 @@ lib/tkextlib/setup.rb
lib/tkextlib/ICONS.rb lib/tkextlib/ICONS.rb
lib/tkextlib/ICONS/icons.rb lib/tkextlib/ICONS/icons.rb
lib/tkextlib/ICONS/setup.rb lib/tkextlib/ICONS/setup.rb
lib/tkextlib/bwidget.rb
lib/tkextlib/bwidget/arrowbutton.rb
lib/tkextlib/bwidget/bitmap.rb
lib/tkextlib/bwidget/button.rb
lib/tkextlib/bwidget/buttonbox.rb
lib/tkextlib/bwidget/combobox.rb
lib/tkextlib/bwidget/dialog.rb
lib/tkextlib/bwidget/dragsite.rb
lib/tkextlib/bwidget/dropsite.rb
lib/tkextlib/bwidget/dynamichelp.rb
lib/tkextlib/bwidget/entry.rb
lib/tkextlib/bwidget/label.rb
lib/tkextlib/bwidget/labelentry.rb
lib/tkextlib/bwidget/labelframe.rb
lib/tkextlib/bwidget/listbox.rb
lib/tkextlib/bwidget/mainframe.rb
lib/tkextlib/bwidget/messagedlg.rb
lib/tkextlib/bwidget/notebook.rb
lib/tkextlib/bwidget/pagesmanager.rb
lib/tkextlib/bwidget/panedwindow.rb
lib/tkextlib/bwidget/passwddlg.rb
lib/tkextlib/bwidget/progressbar.rb
lib/tkextlib/bwidget/progressdlg.rb
lib/tkextlib/bwidget/scrollableframe.rb
lib/tkextlib/bwidget/scrolledwindow.rb
lib/tkextlib/bwidget/scrollview.rb
lib/tkextlib/bwidget/selectcolor.rb
lib/tkextlib/bwidget/selectfont.rb
lib/tkextlib/bwidget/separator.rb
lib/tkextlib/bwidget/setup.rb
lib/tkextlib/bwidget/spinbox.rb
lib/tkextlib/bwidget/titleframe.rb
lib/tkextlib/bwidget/tree.rb
lib/tkextlib/bwidget/widget.rb
lib/tkextlib/tcllib.rb lib/tkextlib/tcllib.rb
lib/tkextlib/tcllib/README lib/tkextlib/tcllib/README
lib/tkextlib/tcllib/autoscroll.rb lib/tkextlib/tcllib/autoscroll.rb
@ -382,6 +416,22 @@ sample/msgs_tk/ja.msg
sample/msgs_tk/nl.msg sample/msgs_tk/nl.msg
sample/msgs_tk/pl.msg sample/msgs_tk/pl.msg
sample/msgs_tk/ru.msg sample/msgs_tk/ru.msg
sample/tkextlib/ICONS/LICENSE.orig
sample/tkextlib/ICONS/viewIcons.rb
sample/tkextlib/ICONS/tkIcons
sample/tkextlib/ICONS/tkIcons-sample.kde
sample/tkextlib/ICONS/tkIcons.kde
sample/tkextlib/bwidget/LICENSE.orig
sample/tkextlib/bwidget/basic.rb
sample/tkextlib/bwidget/bwidget.xbm
sample/tkextlib/bwidget/demo.rb
sample/tkextlib/bwidget/dnd.rb
sample/tkextlib/bwidget/manager.rb
sample/tkextlib/bwidget/select.rb
sample/tkextlib/bwidget/tmpldlg.rb
sample/tkextlib/bwidget/tree.rb
sample/tkextlib/bwidget/x1.xbm
sample/tkextlib/tcllib/LICENSE.orig
sample/tkextlib/tcllib/datefield.rb sample/tkextlib/tcllib/datefield.rb
sample/tkextlib/tcllib/plotdemos1.rb sample/tkextlib/tcllib/plotdemos1.rb
sample/tkextlib/tcllib/plotdemos2.rb sample/tkextlib/tcllib/plotdemos2.rb
@ -470,6 +520,7 @@ sample/tkextlib/tkHTML/page4/image7
sample/tkextlib/tkHTML/page4/image8 sample/tkextlib/tkHTML/page4/image8
sample/tkextlib/tkHTML/page4/image9 sample/tkextlib/tkHTML/page4/image9
sample/tkextlib/tkHTML/page4/index.html sample/tkextlib/tkHTML/page4/index.html
sample/tkextlib/vu/LICENSE.orig
sample/tkextlib/vu/README.txt sample/tkextlib/vu/README.txt
sample/tkextlib/vu/canvItems.rb sample/tkextlib/vu/canvItems.rb
sample/tkextlib/vu/canvSticker.rb sample/tkextlib/vu/canvSticker.rb

View file

@ -807,8 +807,39 @@ module TkComm
} }
end end
end end
def _bind_core_for_event_class(klass, mode, what, context, cmd, args=nil)
id = install_bind_for_event_class(klass, cmd, args) if cmd
begin
tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
mode + id]))
rescue
uninstall_cmd(id) if cmd
fail
end
end
def _bind_for_event_class(klass, what, context, cmd, args=nil)
_bind_core_for_event_class(klass, '', what, context, cmd, args)
end
def _bind_append_for_event_class(klass, what, context, cmd, args=nil)
_bind_core_for_event_class(klass, '+', what, context, cmd, args)
end
def _bind_remove_for_event_class(klass, what, context)
_bind_remove(what, context)
end
def _bindinfo_for_event_class(klass, what, context=nil)
_bindinfo(what, context)
end
private :tk_event_sequence private :tk_event_sequence
private :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo private :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
private :_bind_core_for_event_class, :_bind_for_event_class,
:_bind_append_for_event_class, :_bind_remove_for_event_class,
:_bindinfo_for_event_class
def bind(tagOrClass, context, cmd=Proc.new, args=nil) def bind(tagOrClass, context, cmd=Proc.new, args=nil)
_bind(["bind", tagOrClass], context, cmd, args) _bind(["bind", tagOrClass], context, cmd, args)
@ -1437,28 +1468,34 @@ module Tk
def Tk.const_missing(sym) def Tk.const_missing(sym)
case(sym) case(sym)
when :TCL_LIBRARY when :TCL_LIBRARY
INTERP._invoke_without_enc('global', 'tcl_library')
INTERP._invoke("set", "tcl_library").freeze INTERP._invoke("set", "tcl_library").freeze
when :TK_LIBRARY when :TK_LIBRARY
INTERP._invoke_without_enc('global', 'tk_library')
INTERP._invoke("set", "tk_library").freeze INTERP._invoke("set", "tk_library").freeze
when :LIBRARY when :LIBRARY
INTERP._invoke("info", "library").freeze INTERP._invoke("info", "library").freeze
#when :PKG_PATH, :PACKAGE_PATH, :TCL_PACKAGE_PATH #when :PKG_PATH, :PACKAGE_PATH, :TCL_PACKAGE_PATH
# INTERP._invoke_without_enc('global', 'tcl_pkgPath')
# tk_split_simplelist(INTERP._invoke('set', 'tcl_pkgPath')) # tk_split_simplelist(INTERP._invoke('set', 'tcl_pkgPath'))
#when :LIB_PATH, :LIBRARY_PATH, :TCL_LIBRARY_PATH #when :LIB_PATH, :LIBRARY_PATH, :TCL_LIBRARY_PATH
# INTERP._invoke_without_enc('global', 'tcl_libPath')
# tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath')) # tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath'))
when :PLATFORM, :TCL_PLATFORM when :PLATFORM, :TCL_PLATFORM
if $SAFE >= 4 if $SAFE >= 4
fail SecurityError, "can't get #{sym} when $SAFE >= 4" fail SecurityError, "can't get #{sym} when $SAFE >= 4"
end end
INTERP._invoke_without_enc('global', 'tcl_platform')
Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get',
'tcl_platform'))] 'tcl_platform'))]
when :ENV when :ENV
INTERP._invoke_without_enc('global', 'env')
Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))] Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))]
#when :AUTO_PATH #<=== #when :AUTO_PATH #<===
@ -1468,6 +1505,7 @@ module Tk
# tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath')) # tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))
when :AUTO_INDEX when :AUTO_INDEX
INTERP._invoke_without_enc('global', 'auto_index')
Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'auto_index'))] Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'auto_index'))]
when :PRIV, :PRIVATE, :TK_PRIV when :PRIV, :PRIVATE, :TK_PRIV
@ -1477,6 +1515,7 @@ module Tk
else else
var_nam = 'tkPriv' var_nam = 'tkPriv'
end end
INTERP._invoke_without_enc('global', var_nam)
Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', Hash[*tk_split_simplelist(INTERP._invoke('array', 'get',
var_nam))].each{|k,v| var_nam))].each{|k,v|
k.freeze k.freeze
@ -2302,6 +2341,15 @@ module TkConfigMethod
################################ ################################
def [](id)
cget(id)
end
def []=(id, val)
configure(id, val)
val
end
def cget(slot) def cget(slot)
slot = slot.to_s slot = slot.to_s
@ -3031,6 +3079,7 @@ class TkObject<TkKernel
end end
end end
=begin
def [](id) def [](id)
cget(id) cget(id)
end end
@ -3039,6 +3088,7 @@ class TkObject<TkKernel
configure(id, val) configure(id, val)
val val
end end
=end
def event_generate(context, keys=nil) def event_generate(context, keys=nil)
if keys if keys

View file

@ -8,14 +8,14 @@ class TkButton<TkLabel
TkCommandNames = ['button'.freeze].freeze TkCommandNames = ['button'.freeze].freeze
WidgetClassName = 'Button'.freeze WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('button', @path, *hash_kv(keys, true)) # tk_call_without_enc('button', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('button', @path) # tk_call_without_enc('button', @path)
end # end
end #end
private :create_self #private :create_self
def invoke def invoke
_fromUTF8(tk_send_without_enc('invoke')) _fromUTF8(tk_send_without_enc('invoke'))

View file

@ -40,20 +40,21 @@ class TkCanvas<TkWindow
TkcItem::CItemID_TBL.delete(@path) TkcItem::CItemID_TBL.delete(@path)
end end
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('canvas', @path, *hash_kv(keys, true)) # tk_call_without_enc('canvas', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('canvas', @path) # tk_call_without_enc('canvas', @path)
end # end
end #end
private :create_self #private :create_self
def tagid(tag) def tagid(tag)
if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag) if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
tag.id tag.id
else else
tag # tag
_get_eval_string(tag)
end end
end end
private :tagid private :tagid

View file

@ -316,7 +316,8 @@ end
class TkcGroup<TkcTag class TkcGroup<TkcTag
Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze
def create_self(parent, *args) #def create_self(parent, *args)
def initialize(parent, *args)
unless parent.kind_of?(TkCanvas) unless parent.kind_of?(TkCanvas)
fail ArguemntError, "expect TkCanvas for 1st argument" fail ArguemntError, "expect TkCanvas for 1st argument"
end end
@ -329,7 +330,7 @@ class TkcGroup<TkcTag
Tk_cGroup_ID[1].succ! Tk_cGroup_ID[1].succ!
add(*args) if args != [] add(*args) if args != []
end end
private :create_self #private :create_self
def include(*tags) def include(*tags)
for i in tags for i in tags

View file

@ -8,14 +8,14 @@ class TkCheckButton<TkRadioButton
TkCommandNames = ['checkbutton'.freeze].freeze TkCommandNames = ['checkbutton'.freeze].freeze
WidgetClassName = 'Checkbutton'.freeze WidgetClassName = 'Checkbutton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true)) # tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('checkbutton', @path) # tk_call_without_enc('checkbutton', @path)
end # end
end #end
private :create_self #private :create_self
def toggle def toggle
tk_send_without_enc('toggle') tk_send_without_enc('toggle')

View file

@ -162,8 +162,11 @@ class TkDialog2 < TkWindow
# @path+" "+@title+" {#{@message}} "+@bitmap+" "+ # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
# String(default_button)+" "+@buttons.join(' ')+']}') # String(default_button)+" "+@buttons.join(' ')+']}')
Tk.ip_eval(@config) Tk.ip_eval(@config)
@val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title + # @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
' {' + @message + '} ' + @bitmap + ' ' + # ' {' + @message + '} ' + @bitmap + ' ' +
# String(default_button) + ' ' + @buttons.join(' ')).to_i
@val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
@title + ' {' + @message + '} ' + @bitmap + ' ' +
String(default_button) + ' ' + @buttons.join(' ')).to_i String(default_button) + ' ' + @buttons.join(' ')).to_i
end end

View file

@ -16,14 +16,13 @@ class TkEntry<TkLabel
WidgetClassName = 'Entry'.freeze WidgetClassName = 'Entry'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
#def create_self(keys)
def create_self(keys) # tk_call_without_enc('entry', @path)
tk_call_without_enc('entry', @path) # if keys and keys != None
if keys and keys != None # configure(keys)
configure(keys) # end
end #end
end #private :create_self
private :create_self
def bbox(index) def bbox(index)
list(tk_send_without_enc('bbox', index)) list(tk_send_without_enc('bbox', index))

View file

@ -117,9 +117,21 @@ module TkEvent
# that is generated by _get_subst_key() or _get_all_subst_keys(). # that is generated by _get_subst_key() or _get_all_subst_keys().
# #
_setup_subst_table(KEY_TBL, PROC_TBL); _setup_subst_table(KEY_TBL, PROC_TBL);
# If you need support extra arguments given by Tcl/Tk,
# please override _get_extra_args_tbl
#
#def self._get_extra_args_tbl
# # return an array of convert procs
# []
#end
end end
def install_bind_for_event_class(klass, cmd, *args) def install_bind_for_event_class(klass, cmd, *args)
extra_args_tbl = klass._get_extra_args_tbl
if args.compact.size > 0 if args.compact.size > 0
args = args.join(' ') args = args.join(' ')
keys = klass._get_subst_key(args) keys = klass._get_subst_key(args)
@ -130,7 +142,9 @@ module TkEvent
id = install_cmd(cmd) id = install_cmd(cmd)
else else
id = install_cmd(proc{|*arg| id = install_cmd(proc{|*arg|
TkUtil.eval_cmd(cmd, *klass.scan_args(keys, arg)) ex_args = []
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
}) })
end end
id + ' ' + args id + ' ' + args
@ -143,7 +157,10 @@ module TkEvent
id = install_cmd(cmd) id = install_cmd(cmd)
else else
id = install_cmd(proc{|*arg| id = install_cmd(proc{|*arg|
TkUtil.eval_cmd(cmd, klass.new(*klass.scan_args(keys, arg))) ex_args = []
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
TkUtil.eval_cmd(cmd,
*(ex_args << klass.new(*klass.scan_args(keys, arg))))
}) })
end end
id + ' ' + args id + ' ' + args
@ -151,7 +168,7 @@ module TkEvent
end end
def install_bind(cmd, *args) def install_bind(cmd, *args)
install_bind_for_event_class(Event, cmd, *args) install_bind_for_event_class(TkEvent::Event, cmd, *args)
end end
end end

View file

@ -197,7 +197,7 @@ class TkFont
def TkFont.init_widget_font(pathname, *args) def TkFont.init_widget_font(pathname, *args)
win, tag, key = pathname.split(';') win, tag, key = pathname.split(';')
key = 'font' unless key key = 'font' if key == nil || key == ''
path = [win, tag, key].join(';') path = [win, tag, key].join(';')
case (Tk::TK_VERSION) case (Tk::TK_VERSION)
@ -868,7 +868,7 @@ class TkFont
begin begin
if w.include?(';') if w.include?(';')
win, tag, optkey = w.split(';') win, tag, optkey = w.split(';')
optkey = 'font' unless optkey optkey = 'font' if optkey == nil || optkey == ''
winobj = tk_tcl2ruby(win) winobj = tk_tcl2ruby(win)
# winobj.tagfont_configure(tag, {'font'=>@latinfont}) # winobj.tagfont_configure(tag, {'font'=>@latinfont})
if winobj.kind_of? TkText if winobj.kind_of? TkText

View file

@ -32,7 +32,7 @@ class TkFrame<TkWindow
def initialize(parent=nil, keys=nil) def initialize(parent=nil, keys=nil)
my_class_name = nil my_class_name = nil
if self.class < WidgetClassNames[WidgetClassName] if self.class < WidgetClassNames[self.class::WidgetClassName]
my_class_name = self.class.name my_class_name = self.class.name
my_class_name = nil if my_class_name == '' my_class_name = nil if my_class_name == ''
end end
@ -68,14 +68,14 @@ class TkFrame<TkWindow
super(keys) super(keys)
end end
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('frame', @path, *hash_kv(keys)) # tk_call_without_enc('frame', @path, *hash_kv(keys))
else # else
tk_call_without_enc( 'frame', @path) # tk_call_without_enc( 'frame', @path)
end # end
end #end
private :create_self #private :create_self
def database_classname def database_classname
@classname @classname

View file

@ -105,6 +105,13 @@ module TkItemConfigMethod
################################################ ################################################
def tagid(tagOrId)
# maybe need to override
tagOrId
end
################################################
def itemcget(tagOrId, option) def itemcget(tagOrId, option)
option = option.to_s option = option.to_s

View file

@ -28,7 +28,7 @@ module TkTreatItemFont
fail ArgumentError, "unknown font option name `#{key}'" fail ArgumentError, "unknown font option name `#{key}'"
end end
win, tag = __item_pathname(tagid(tagOrId)).split(':') win, tag = __item_pathname(tagid(tagOrId)).split(';')
if key if key
pathname = [win, tag, key].join(';') pathname = [win, tag, key].join(';')
@ -130,7 +130,7 @@ module TkTreatItemFont
fail ArgumentError, "unknown font option name `#{key}'" fail ArgumentError, "unknown font option name `#{key}'"
end end
win, tag = __item_pathname(tagid(tagOrId)).split(':') win, tag = __item_pathname(tagid(tagOrId)).split(';')
optkeys = [key] if key optkeys = [key] if key
@ -181,7 +181,7 @@ module TkTreatItemFont
fail ArgumentError, "unknown font option name `#{key}'" fail ArgumentError, "unknown font option name `#{key}'"
end end
win, tag = __item_pathname(tagid(tagOrId)).split(':') win, tag = __item_pathname(tagid(tagOrId)).split(';')
optkeys = [key] if key optkeys = [key] if key

View file

@ -7,14 +7,14 @@ class TkLabel<TkWindow
TkCommandNames = ['label'.freeze].freeze TkCommandNames = ['label'.freeze].freeze
WidgetClassName = 'Label'.freeze WidgetClassName = 'Label'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('label', @path, *hash_kv(keys, true)) # tk_call_without_enc('label', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('label', @path) # tk_call_without_enc('label', @path)
end # end
end #end
private :create_self #private :create_self
def textvariable(v) def textvariable(v)
configure 'textvariable', tk_trace_variable(v) configure 'textvariable', tk_trace_variable(v)

View file

@ -8,13 +8,13 @@ class TkLabelFrame<TkFrame
TkCommandNames = ['labelframe'.freeze].freeze TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('labelframe', @path, *hash_kv(keys, true)) # tk_call_without_enc('labelframe', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('labelframe', @path) # tk_call_without_enc('labelframe', @path)
end # end
end #end
private :create_self #private :create_self
end end
TkLabelframe = TkLabelFrame TkLabelframe = TkLabelFrame

View file

@ -23,17 +23,18 @@ class TkListbox<TkTextWin
WidgetClassName = 'Listbox'.freeze WidgetClassName = 'Listbox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('listbox', @path, *hash_kv(keys, true)) # tk_call_without_enc('listbox', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('listbox', @path) # tk_call_without_enc('listbox', @path)
end # end
end #end
private :create_self #private :create_self
def tagid(id) def tagid(id)
id.to_s #id.to_s
_get_eval_string(id)
end end
def activate(y) def activate(y)

View file

@ -38,17 +38,18 @@ class TkMenu<TkWindow
WidgetClassName = 'Menu'.freeze WidgetClassName = 'Menu'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('menu', @path, *hash_kv(keys, true)) # tk_call_without_enc('menu', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('menu', @path) # tk_call_without_enc('menu', @path)
end # end
end #end
private :create_self #private :create_self
def tagid(id) def tagid(id)
id.to_s #id.to_s
_get_eval_string(id)
end end
def activate(index) def activate(index)

View file

@ -8,12 +8,12 @@ class TkMessage<TkLabel
TkCommandNames = ['message'.freeze].freeze TkCommandNames = ['message'.freeze].freeze
WidgetClassName = 'Message'.freeze WidgetClassName = 'Message'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('message', @path, *hash_kv(keys, true)) # tk_call_without_enc('message', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('message', @path) # tk_call_without_enc('message', @path)
end # end
end #end
private :create_self private :create_self
end end

View file

@ -34,7 +34,8 @@ module TkOptionDB
def readfile(file, pri=None) def readfile(file, pri=None)
tk_call('option', 'readfile', file, pri) tk_call('option', 'readfile', file, pri)
end end
module_function :add, :clear, :get, :readfile alias read_file readfile
module_function :add, :clear, :get, :readfile, :read_file
def read_entries(file, f_enc=nil) def read_entries(file, f_enc=nil)
if TkCore::INTERP.safe? if TkCore::INTERP.safe?

View file

@ -7,14 +7,14 @@ class TkPanedWindow<TkWindow
TkCommandNames = ['panedwindow'.freeze].freeze TkCommandNames = ['panedwindow'.freeze].freeze
WidgetClassName = 'Panedwindow'.freeze WidgetClassName = 'Panedwindow'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true)) # tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('panedwindow', @path) # tk_call_without_enc('panedwindow', @path)
end # end
end #end
private :create_self #private :create_self
def add(*args) def add(*args)
keys = args.pop keys = args.pop

View file

@ -8,14 +8,14 @@ class TkRadioButton<TkButton
TkCommandNames = ['radiobutton'.freeze].freeze TkCommandNames = ['radiobutton'.freeze].freeze
WidgetClassName = 'Radiobutton'.freeze WidgetClassName = 'Radiobutton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true)) # tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('radiobutton', @path) # tk_call_without_enc('radiobutton', @path)
end # end
end #end
private :create_self #private :create_self
def deselect def deselect
tk_send_without_enc('deselect') tk_send_without_enc('deselect')

View file

@ -10,13 +10,16 @@ class TkScale<TkWindow
def create_self(keys) def create_self(keys)
if keys and keys != None if keys and keys != None
if keys.key?('command') if keys.key?('command') && ! keys['command'].kind_of?(String)
cmd = keys.delete('command') cmd = keys.delete('command')
keys['command'] = proc{|val| cmd.call(val.to_f)} keys['command'] = proc{|val| cmd.call(val.to_f)}
end end
tk_call_without_enc('scale', @path, *hash_kv(keys, true)) #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true))
else else
tk_call_without_enc('scale', @path) #tk_call_without_enc('scale', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
end end
end end
private :create_self private :create_self

View file

@ -52,8 +52,8 @@ module Tk
@xscrollbar.orient 'horizontal' @xscrollbar.orient 'horizontal'
self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} self.xscrollcommand {|*arg| @xscrollbar.set(*arg)}
@xscrollbar.command {|*arg| self.xview(*arg)} @xscrollbar.command {|*arg| self.xview(*arg)}
Tk.update # avoid scrollbar trouble
end end
Tk.update # avoid scrollbar trouble
@xscrollbar @xscrollbar
end end
def yscrollbar(bar=nil) def yscrollbar(bar=nil)
@ -62,8 +62,8 @@ module Tk
@yscrollbar.orient 'vertical' @yscrollbar.orient 'vertical'
self.yscrollcommand {|*arg| @yscrollbar.set(*arg)} self.yscrollcommand {|*arg| @yscrollbar.set(*arg)}
@yscrollbar.command {|*arg| self.yview(*arg)} @yscrollbar.command {|*arg| self.yview(*arg)}
Tk.update # avoid scrollbar trouble
end end
Tk.update # avoid scrollbar trouble
@yscrollbar @yscrollbar
end end
end end

View file

@ -19,9 +19,12 @@ class TkScrollbar<TkWindow
} }
if keys and keys != None if keys and keys != None
tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true)) #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true))
else else
tk_call_without_enc('scrollbar', @path) #tk_call_without_enc('scrollbar', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
end end
end end
private :create_self private :create_self

View file

@ -11,13 +11,13 @@ class TkSpinbox<TkEntry
WidgetClassName = 'Spinbox'.freeze WidgetClassName = 'Spinbox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def create_self(keys) #def create_self(keys)
tk_call_without_enc('spinbox', @path) # tk_call_without_enc('spinbox', @path)
if keys and keys != None # if keys and keys != None
configure(keys) # configure(keys)
end # end
end #end
private :create_self #private :create_self
def identify(x, y) def identify(x, y)
tk_send_without_enc('identify', x, y) tk_send_without_enc('identify', x, y)

View file

@ -88,11 +88,15 @@ class TkText<TkTextWin
end end
def create_self(keys) def create_self(keys)
if keys and keys != None #if keys and keys != None
tk_call_without_enc('text', @path, *hash_kv(keys, true)) # #tk_call_without_enc('text', @path, *hash_kv(keys, true))
else # tk_call_without_enc(self.class::TkCommandNames[0], @path,
tk_call_without_enc('text', @path) # *hash_kv(keys, true))
end #else
# #tk_call_without_enc('text', @path)
# tk_call_without_enc(self.class::TkCommandNames[0], @path)
#end
super(keys)
init_instance_variable init_instance_variable
end end
private :create_self private :create_self
@ -131,7 +135,8 @@ class TkText<TkTextWin
|| tag.kind_of?(TkTextWindow) || tag.kind_of?(TkTextWindow)
tag.id tag.id
else else
tag # tag
_get_eval_string(tag)
end end
end end
private :tagid private :tagid

View file

@ -158,14 +158,14 @@ class TkToplevel<TkWindow
} }
end end
def create_self(keys) #def create_self(keys)
if keys and keys != None # if keys and keys != None
tk_call_without_enc('toplevel', @path, *hash_kv(keys, true)) # tk_call_without_enc('toplevel', @path, *hash_kv(keys, true))
else # else
tk_call_without_enc('toplevel', @path) # tk_call_without_enc('toplevel', @path)
end # end
end #end
private :create_self #private :create_self
def specific_class def specific_class
@classname @classname

View file

@ -4,10 +4,11 @@
require 'tk' require 'tk'
class TkTextWin<TkWindow class TkTextWin<TkWindow
def create_self TkCommnadNames = [].freeze
fail RuntimeError, "TkTextWin is an abstract class" #def create_self
end # fail RuntimeError, "TkTextWin is an abstract class"
private :create_self #end
#private :create_self
def bbox(index) def bbox(index)
list(tk_send_without_enc('bbox', index)) list(tk_send_without_enc('bbox', index))

View file

@ -158,6 +158,15 @@ module TkValidation
] ]
_setup_subst_table(KEY_TBL, PROC_TBL); _setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
(val)? '1': '0'
end
#def self._get_extra_args_tbl
# # return an array of convert procs
# []
#end
end end
############################## ##############################
@ -168,6 +177,8 @@ module TkValidation
end end
def _initialize_for_cb_class(klass, cmd = Proc.new, *args) def _initialize_for_cb_class(klass, cmd = Proc.new, *args)
extra_args_tbl = klass._get_extra_args_tbl
if args.compact.size > 0 if args.compact.size > 0
args = args.join(' ') args = args.join(' ')
keys = klass._get_subst_key(args) keys = klass._get_subst_key(args)
@ -177,7 +188,11 @@ module TkValidation
@id = install_cmd(cmd) @id = install_cmd(cmd)
else else
@id = install_cmd(proc{|*arg| @id = install_cmd(proc{|*arg|
(cmd.call(*klass.scan_args(keys, arg)))? '1':'0' ex_args = []
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(args.pop)}
klass.ret_val(cmd.call(
*(ex_args.concat(klass.scan_args(keys, arg)))
))
}) + ' ' + args }) + ' ' + args
end end
else else
@ -188,9 +203,11 @@ module TkValidation
@id = install_cmd(cmd) @id = install_cmd(cmd)
else else
@id = install_cmd(proc{|*arg| @id = install_cmd(proc{|*arg|
(cmd.call( ex_args = []
klass.new(*klass.scan_args(keys,arg))) extra_args_tbl.reverse_each{|conv| ex_args << conv.call(args.pop)}
)? '1': '0' klass.ret_val(cmd.call(
*(ex_args << klass.new(*klass.scan_args(keys,arg)))
))
}) + ' ' + args }) + ' ' + args
end end
end end

View file

@ -197,8 +197,13 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
@id @id
end end
def ref(*idxs)
"#{@id}(#{idxs.collect{|idx| _get_eval_string(idx)}.join(',')})"
end
def is_hash? def is_hash?
#ITNERP._eval("global #{@id}; array exist #{@id}") == '1' #ITNERP._eval("global #{@id}; array exist #{@id}") == '1'
INTERP._invoke_without_enc('global', @id)
INTERP._invoke_without_enc('array', 'exist', @id) == '1' INTERP._invoke_without_enc('array', 'exist', @id) == '1'
end end
@ -211,6 +216,7 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
fail RuntimeError, 'cannot get keys from a scalar variable' fail RuntimeError, 'cannot get keys from a scalar variable'
end end
#tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}")) #tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))
INTERP._invoke_without_enc('global', @id)
tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id))) tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id)))
end end
@ -242,6 +248,7 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
def value def value
#if INTERP._eval("global #{@id}; array exist #{@id}") == '1' #if INTERP._eval("global #{@id}; array exist #{@id}") == '1'
INTERP._invoke_without_enc('global', @id)
if INTERP._invoke('array', 'exist', @id) == '1' if INTERP._invoke('array', 'exist', @id) == '1'
#Hash[*tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))] #Hash[*tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))]
Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', @id))] Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', @id))]
@ -277,16 +284,21 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
end end
end end
def [](index) def [](*idxs)
index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
_fromUTF8(INTERP._get_global_var2(@id, index))
#_fromUTF8(INTERP._get_global_var2(@id, _toUTF8(_get_eval_string(index)))) #_fromUTF8(INTERP._get_global_var2(@id, _toUTF8(_get_eval_string(index))))
_fromUTF8(INTERP._get_global_var2(@id, _get_eval_string(index, true))) #_fromUTF8(INTERP._get_global_var2(@id, _get_eval_string(index, true)))
end end
def []=(index,val) def []=(*args)
val = args.pop
index = args.collect{|idx| _get_eval_string(idx, true)}.join(',')
_fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true)))
#_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)), #_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)),
# _toUTF8(_get_eval_string(val)))) # _toUTF8(_get_eval_string(val))))
_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true), #_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true),
_get_eval_string(val, true))) # _get_eval_string(val, true)))
end end
def unset(elem=nil) def unset(elem=nil)
@ -371,16 +383,22 @@ else
end end
end end
def [](index) def [](*idxs)
INTERP._eval(Kernel.format('global %s; set %s(%s)', index = idxs.collect{|idx| _get_eval_string(idx)}.join(',')
@id, @id, _get_eval_string(index))) INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
#INTERP._eval(Kernel.format('global %s; set %s(%s)',
# @id, @id, _get_eval_string(index)))
#INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index))) #INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index)))
#INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')') #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')')
end end
def []=(index,val) def []=(*args)
val = args.pop
index = args.collect{|idx| _get_eval_string(idx)}.join(',')
INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id, INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
_get_eval_string(index), _get_eval_string(val))) index, _get_eval_string(val)))
#INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
# _get_eval_string(index), _get_eval_string(val)))
#INTERP._eval(Kernel.format('set %s(%s) %s', @id, #INTERP._eval(Kernel.format('set %s(%s) %s', @id,
# _get_eval_string(index), _get_eval_string(val))) # _get_eval_string(index), _get_eval_string(val)))
#INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' + #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' +
@ -869,6 +887,7 @@ class TkVarAccess<TkVariable
def self.new_hash(name, *args) def self.new_hash(name, *args)
return TkVar_ID_TBL[name] if TkVar_ID_TBL[name] return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
INTERP._invoke_without_enc('global', name)
if args.empty? && INTERP._invoke_without_enc('array', 'exist', name) == '0' if args.empty? && INTERP._invoke_without_enc('array', 'exist', name) == '0'
self.new(name, {}) # force creating self.new(name, {}) # force creating
else else

View file

@ -178,10 +178,13 @@ module Tk
self self
end end
end end
def protocol(name=nil, cmd=nil) def protocol(name=nil, cmd=nil, &b)
if cmd if cmd
tk_call_without_enc('wm', 'protocol', path, name, cmd) tk_call_without_enc('wm', 'protocol', path, name, cmd)
self self
elsif b
tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
self
elsif name elsif name
result = tk_call_without_enc('wm', 'protocol', path, name) result = tk_call_without_enc('wm', 'protocol', path, name)
(result == "")? nil : tk_tcl2ruby(result) (result == "")? nil : tk_tcl2ruby(result)

View file

@ -6,11 +6,8 @@
# call setup script for general 'tkextlib' libraries # call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# call setup script # call setup script
require File.join(dir, 'setup.rb') require 'tkextlib/ICONS/setup.rb'
# load library # load library
require File.join(dir, 'icons') require 'tkextlib/ICONS/icons'

View file

@ -9,39 +9,63 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/ICONS/setup.rb'
# TkPackage.require('icons', '1.0') # TkPackage.require('icons', '1.0')
TkPackage.require('icons') TkPackage.require('icons')
module Tk module Tk
class ICONS < TkImage class ICONS < TkImage
def self.create(*args) # icon, icon, ..., keys extend Tk
def self.package_version
begin
TkPackage.require('icons')
rescue
''
end
end
def self.create(*args) # icon, icon, ..., ?option=>value, ...?
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
icons = simplelist(tk_call('::icons::icons', 'create', icons = simplelist(tk_call('::icons::icons', 'create',
*(hash_kv(keys).concat(args.flatten)))) *(hash_kv(keys) << (args.flatten))))
else else
icons = simplelist(tk_call('::icons::icons', 'create', icons = simplelist(tk_call('::icons::icons', 'create',
*(args.flatten))) args.flatten))
end end
icons.collect{|icon| self.new(icon, :without_creating=>true)} icons.collect{|icon| self.new(icon, :without_creating=>true)}
end end
def self.delete(*icons) def self.delete(*icons) # icon, icon, ...
icons = icons.flatten
return if icons.empty? return if icons.empty?
icons.map!{|icon|
if icon.kind_of?(Tk::ICONS)
Tk_IMGTBL.delete(icon.path)
icon.name
elsif icon.to_s =~ /^::icon::(.*)/
name = $1
Tk_IMGTBL.delete(icon)
name
else
Tk_IMGTBL.delete("::icon::#{icon}")
icon
end
}
tk_call('::icons::icons', 'delete', icons) tk_call('::icons::icons', 'delete', icons)
end end
def self.query(*args) def self.query(*args) # icon, icon, ..., ?option=>value, ...?
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
list(tk_call('::icons::icons', 'query', simplelist(tk_call('::icons::icons', 'query',
*(hash_kv(keys).concat(args.flatten)))) *(hash_kv(keys) << (args.flatten))))
else else
list(tk_call('::icons::icons', 'query', *(args.flatten))) simplelist(tk_call('::icons::icons', 'query', args.flatten))
end end . map{|inf| list(inf) }
end end
########################################## ##########################################
@ -75,7 +99,7 @@ module Tk
self self
end end
def query(keys) def query(keys={})
list(simplelist(tk_call('::icons::icons', 'query', list(simplelist(tk_call('::icons::icons', 'query',
*(hash_kv(keys) << @name)) *(hash_kv(keys) << @name))
)[0]) )[0])

View file

@ -47,33 +47,35 @@ script may give you some hints about that.
===< support with some examples (may be beta quality) >======================= ===< support with some examples (may be beta quality) >=======================
Tcllib http://sf.net/projects/tcllib Tcllib http://sf.net/projects/tcllib
==> tcllib (partial support; Tklib part only) ==> tcllib (partial support; Tklib part only)
BWidgets http://sf.net/projects/tcllib ==> bwidget
vu http://tktable.sourceforge.net ==> vu vu http://tktable.sourceforge.net ==> vu
TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML
ICONS http://www.satisoft.com/tcltk/icons/ ==> ICONS
===< support (may be alpha or beta quality) >================================= ===< support (may be alpha or beta quality) >=================================
TkImg http://sf.net/projects/tkimg ==> tkimg TkImg http://sf.net/projects/tkimg ==> tkimg
TkTreeCtrl http://tktreectrl.sourceforge.net/ ==> treectrl TkTreeCtrl http://tktreectrl.sourceforge.net/ ==> treectrl
Tile http://tktable.sourceforge.net/tile/ ==> tile Tile http://tktable.sourceforge.net/tile/ ==> tile
===< possibly support (not tested; alpha quality) >=========================== ===< possibly available (not tested; alpha quality) >=========================
TkTrans http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html TkTrans http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html
==> tktrans (win32 only) ==> tktrans (win32 only)
TkDND http://sourceforge.net/projects/tkdnd ==> tkDND TkDND http://sourceforge.net/projects/tkdnd ==> tkDND
ICONS http://www.satisoft.com/tcltk/icons/ ==> ICONS
===< plan to support (alpha quality libraries may be included) >============== ===< plan to support (alpha quality libraries may be included) >==============
@ -87,8 +89,6 @@ IWidgets http://sf.net/projects/incrTcl
TkTable http://sf.net/projects/tktable TkTable http://sf.net/projects/tktable
* see http://www.korus.hu/~fery/ruby/tktable.rb * see http://www.korus.hu/~fery/ruby/tktable.rb
BWidgets http://sf.net/projects/tcllib
winico http://tktable.sourceforge.net winico http://tktable.sourceforge.net

View file

@ -0,0 +1,144 @@
#
# BWidget extension support
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require 'tkextlib/bwidget/setup.rb'
# load all image format handlers
#TkPackage.require('BWidget', '1.7')
TkPackage.require('BWidget')
module Tk
module BWidget
extend TkCore
LIBRARY = tk_call('set', '::BWIDGET::LIBRARY')
def self.package_version
begin
TkPackage.require('BWidget')
rescue
''
end
end
def self.XLFDfont(cmd, *args)
if args[-1].kind_of?(Hash)
keys = args.pop
args.concat(hash_kv(keys))
end
tk_call('BWidget::XLFDfont', cmd, *args)
end
def self.assert(exp, msg=None)
tk_call('BWidget::assert', exp, msg)
end
def self.badOptionString(type, value, list)
tk_call('BWidget::badOptionString', type, value, list)
end
def self.bindMouseWheel(widget)
tk_call('BWidget::bindMouseWheel', widget)
end
def self.classes(klass)
list(tk_call('BWidget::classes', klass))
end
def self.clonename(menu)
tk_call('BWidget::clonename', menu)
end
def self.focus(opt, path)
tk_call('BWidget::focus', opt, path)
end
def self.get3dcolor(path, bgcolor)
tk_call('BWidget::get3dcolor', path, bgcolor)
end
def self.getname(name)
tk_call('BWidget::getname', name)
end
def self.grab(opt, path)
tk_call('BWidget::', opt, path)
end
def self.inuse(klass)
bool(tk_call('BWidget::inuse', klass))
end
def self.library(klass, *klasses)
tk_call('BWidget::library', klass, *klasses)
end
def self.lreorder(list, neworder)
tk_call('BWidget::lreorder', list, neworder)
end
def self.parsetext(text)
tk_call('BWidget::parsetext', text)
end
def self.place(path, w, h, *args)
if args[-1].kind_of?(Hash)
keys = args.pop
args.concat(hash_kv(keys))
end
tk_call('BWidget::place', path, w, h, *(args.flatten))
end
def self.write(file, mode=None)
tk_call('BWidget::write', file, mode)
end
def self.wrongNumArgsString(str)
tk_call('BWidget::wrongNumArgsString', str)
end
####################################################
autoload :ArrowButton, 'tkextlib/bwidget/arrowbutton'
autoload :Bitmap, 'tkextlib/bwidget/bitmap'
autoload :Button, 'tkextlib/bwidget/button'
autoload :ButtonBox, 'tkextlib/bwidget/buttonbox'
autoload :ComboBox, 'tkextlib/bwidget/combobox'
autoload :Dialog, 'tkextlib/bwidget/dialog'
autoload :DragSite, 'tkextlib/bwidget/dragsite'
autoload :DropSite, 'tkextlib/bwidget/dropsite'
autoload :DynamicHelp, 'tkextlib/bwidget/dynamichelp'
autoload :Entry, 'tkextlib/bwidget/entry'
autoload :Label, 'tkextlib/bwidget/label'
autoload :LabelEntry, 'tkextlib/bwidget/labelentry'
autoload :LabelFrame, 'tkextlib/bwidget/labelframe'
autoload :ListBox, 'tkextlib/bwidget/listbox'
autoload :MainFrame, 'tkextlib/bwidget/mainframe'
autoload :MessageDlg, 'tkextlib/bwidget/messagedlg'
autoload :NoteBook, 'tkextlib/bwidget/notebook'
autoload :PagesManager, 'tkextlib/bwidget/pagesmanager'
autoload :PanedWindow, 'tkextlib/bwidget/panedwindow'
autoload :PasswdDlg, 'tkextlib/bwidget/passwddlg'
autoload :ProgressBar, 'tkextlib/bwidget/progressbar'
autoload :ProgressDlg, 'tkextlib/bwidget/progressdlg'
autoload :ScrollableFrame, 'tkextlib/bwidget/scrollableframe'
autoload :ScrolledWindow, 'tkextlib/bwidget/scrolledwindow'
autoload :ScrollView, 'tkextlib/bwidget/scrollview'
autoload :SelectColor, 'tkextlib/bwidget/selectcolor'
autoload :SelectFont, 'tkextlib/bwidget/selectfont'
autoload :Separator, 'tkextlib/bwidget/separator'
autoload :SpinBox, 'tkextlib/bwidget/spinbox'
autoload :TitleFrame, 'tkextlib/bwidget/titleframe'
autoload :Tree, 'tkextlib/bwidget/tree'
autoload :Widget, 'tkextlib/bwidget/widget'
end
end

View file

@ -0,0 +1,21 @@
#
# tkextlib/bwidget/arrowbutton.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/button'
module Tk
module BWidget
class ArrowButton < Tk::BWidget::Button
end
end
end
class Tk::BWidget::ArrowButton
TkCommandNames = ['ArrowButton'.freeze].freeze
WidgetClassName = 'ArrowButton'.freeze
WidgetClassNames[WidgetClassName] = self
end

View file

@ -0,0 +1,21 @@
#
# tkextlib/bwidget/bitmap.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/image'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Bitmap < TkPhotoImage
end
end
end
class Tk::BWidget::Bitmap
def initialize(name)
@path = tk_call_without_enc('Bitmap::get', name)
Tk_IMGTBL[@path] = self
end
end

View file

@ -0,0 +1,21 @@
#
# tkextlib/bwidget/button.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/button'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Button < TkButton
end
end
end
class Tk::BWidget::Button
TkCommandNames = ['Button'.freeze].freeze
WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self
end

View file

@ -0,0 +1,73 @@
#
# tkextlib/bwidget/buttonbox.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/button'
module Tk
module BWidget
class ButtonBox < TkWindow
end
end
end
class Tk::BWidget::ButtonBox
TkCommandNames = ['ButtonBox'.freeze].freeze
WidgetClassName = 'ButtonBox'.freeze
WidgetClassNames[WidgetClassName] = self
include TkItemConfigMethod
def tagid(tagOrId)
if tagOrId.kind_of?(Tk::BWidget::Button)
name = tagOrId[:name]
return index(name) unless name.empty?
end
if tagOrId.kind_of?(TkButton)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
index(_get_eval_string(tagOrId))
end
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
win.instance_eval(&b) if b
win
end
def delete(idx)
tk_send('delete', tagid(idx))
self
end
def index(idx)
if idx.kind_of?(Tk::BWidget::Button)
name = idx[:name]
idx = name unless name.empty?
end
if idx.kind_of?(TkButton)
idx = idx[:text]
end
number(tk_send('index', idx.to_s))
end
def insert(idx, keys={}, &b)
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
win.instance_eval(&b) if b
win
end
def invoke(idx)
tk_send('invoke', tagid(idx))
self
end
def set_focus(idx)
tk_send('setfocus', tagid(idx))
self
end
end

View file

@ -0,0 +1,45 @@
#
# tkextlib/bwidget/combobox.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/entry'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/listbox'
require 'tkextlib/bwidget/spinbox'
module Tk
module BWidget
class ComboBox < Tk::BWidget::SpinBox
end
end
end
class Tk::BWidget::ComboBox
include Scrollable
TkCommandNames = ['ComboBox'.freeze].freeze
WidgetClassName = 'ComboBox'.freeze
WidgetClassNames[WidgetClassName] = self
def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox'))
win.instance_eval(&b) if b
win
end
def icursor(idx)
tk_send_without_enc('icursor', idx)
end
def post
tk_send_without_enc('post')
self
end
def unpost
tk_send_without_enc('unpost')
self
end
end

View file

@ -0,0 +1,147 @@
#
# tkextlib/bwidget/dialog.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/buttonbox'
module Tk
module BWidget
class Dialog < TkWindow
end
end
end
class Tk::BWidget::Dialog
TkCommandNames = ['Dialog'.freeze].freeze
WidgetClassName = 'Dialog'.freeze
WidgetClassNames[WidgetClassName] = self
include TkItemConfigMethod
def initialize(parent=nil, keys=nil)
@relative = ''
if parent.kind_of?(Hash)
keys = _symbolkey2str(parent)
@relative = keys['parent'] if keys.key?('parent')
@relative = keys.delete('relative') if keys.key?('relative')
super(keys)
elsif keys
keys = _symbolkey2str(keys)
@relative = keys.delete('parent') if keys.key?('parent')
@relative = keys.delete('relative') if keys.key?('relative')
super(parent, keys)
else
super(parent)
end
end
def create_self(keys)
cmd = self.class::TkCommandNames[0]
if keys and keys != None
tk_call_without_enc(cmd, @path, '-parent', @relative,
*hash_kv(keys, true))
else
tk_call_without_enc(cmd, @path, '-parent', @relative)
end
end
def cget(slot)
if slot.to_s == 'relative'
super('parent')
else
super(slot)
end
end
def configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
slot['parent'] = slot.delete('relative') if slot.key?('relative')
super(slot)
else
if slot.to_s == 'relative'
super('parent', value)
else
super(slot, value)
end
end
end
def configinfo(slot=nil)
if slot
if slot.to_s == 'relative'
super('parent')
else
super(slot)
end
else
ret = super()
if TkComm::GET_CONFIGINFO_AS_ARRAY
ret << ['relative', 'parent']
else
ret['relative'] = 'parent'
end
end
end
def tagid(tagOrId)
if tagOrId.kind_of?(Tk::BWidget::Button)
name = tagOrId[:name]
return index(name) unless name.empty?
end
if tagOrId.kind_of?(TkButton)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
index(_get_eval_string(tagOrId))
end
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
win.instance_eval(&b) if b
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
win.instance_eval(&b) if b
win
end
def get_buttonbox(&b)
win = window(@path + '.bbox')
win.instance_eval(&b) if b
win
end
def draw(focus_win=None)
tk_send('draw', focus_win)
end
def enddialog(ret)
tk_send('enddialog', ret)
end
def index(idx)
get_buttonbox.index(idx)
end
def invoke(idx)
tk_send('invoke', tagid(idx))
self
end
def set_focus(idx)
tk_send('setfocus', tagid(idx))
self
end
def withdraw
tk_send('withdraw')
self
end
end

View file

@ -0,0 +1,31 @@
#
# tkextlib/bwidget/dragsite.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
module DragSite
end
end
end
module Tk::BWidget::DragSite
include Tk
extend Tk
def self.include(klass, type, event)
tk_call('DragSite::include', klass, type, event)
end
def self.register(path, keys={})
tk_call('DragSite::register', path, *hash_kv(keys))
end
def self.set_drag(path, subpath, initcmd, endcmd, force=None)
tk_call('DragSite::setdrag', path, subpath, initcmd, endcmd, force)
end
end

View file

@ -0,0 +1,39 @@
#
# tkextlib/bwidget/dropsite.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
module DropSite
end
end
end
module Tk::BWidget::DropSite
include Tk
extend Tk
def self.include(klass, type)
tk_call('DropSite::include', klass, type)
end
def self.register(path, keys={})
tk_call('DropSite::register', path, *hash_kv(keys))
end
def self.set_cursor(cursor)
tk_call('DropSite::setcursor', cursor)
end
def self.set_drop(path, subpath, dropover, drop, force=None)
tk_call('DropSite::setdrop', path, subpath, dropover, drop, force)
end
def self.set_operation(op)
tk_call('DropSite::setoperation', op)
end
end

View file

@ -0,0 +1,51 @@
#
# tkextlib/bwidget/dynamichelp.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
module DynamicHelp
end
end
end
module Tk::BWidget::DynamicHelp
include Tk
extend Tk
def self.__pathname
'DynamicHelp::configure'
end
def self.__cget_cmd
['DynamicHelp::configure']
end
def self.__config_cmd
['DynamicHelp::configure']
end
def self.cget(slot)
self.current_configinfo(slot).values[0]
end
def self.add(widget, keys={})
tk_call('DynamicHelp::add', widget, *hash_kv(keys))
end
def self.delete(widget)
tk_call('DynamicHelp::delete', widget)
end
def self.include(klass, type)
tk_call('DynamicHelp::include', klass, type)
end
def self.sethelp(path, subpath, force=None)
tk_call('DynamicHelp::sethelp', path, subpath, force)
end
end

View file

@ -0,0 +1,28 @@
#
# tkextlib/bwidget/entry.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/entry'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Entry < TkEntry
end
end
end
class Tk::BWidget::Entry
include Scrollable
TkCommandNames = ['Entry'.freeze].freeze
WidgetClassName = 'Entry'.freeze
WidgetClassNames[WidgetClassName] = self
def invoke
tk_send_without_enc('invoke')
self
end
end

View file

@ -0,0 +1,26 @@
#
# tkextlib/bwidget/label.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/label'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Label < TkLabel
end
end
end
class Tk::BWidget::Label
TkCommandNames = ['Label'.freeze].freeze
WidgetClassName = 'Label'.freeze
WidgetClassNames[WidgetClassName] = self
def set_focus
tk_send_without_enc('setfocus')
self
end
end

View file

@ -0,0 +1,45 @@
#
# tkextlib/bwidget/labelentry.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/entry'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/labelframe'
require 'tkextlib/bwidget/entry'
module Tk
module BWidget
class LabelEntry < TkEntry
end
end
end
class Tk::BWidget::LabelEntry
include Scrollable
TkCommandNames = ['LabelEntry'.freeze].freeze
WidgetClassName = 'LabelEntry'.freeze
WidgetClassNames[WidgetClassName] = self
def entrybind(*args)
_bind([path, 'bind'], *args)
self
end
def entrybind_append(*args)
_bind_append([path, 'bind'], *args)
self
end
def entrybind_remove(*args)
_bind_remove([path, 'bind'], *args)
self
end
def entrybindinfo(*args)
_bindinfo([path, 'bind'], *args)
self
end
end

View file

@ -0,0 +1,30 @@
#
# tkextlib/bwidget/labelframe.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class LabelFrame < TkWindow
end
end
end
class Tk::BWidget::LabelFrame
TkCommandNames = ['LabelFrame'.freeze].freeze
WidgetClassName = 'LabelFrame'.freeze
WidgetClassNames[WidgetClassName] = self
def self.align(*args)
tk_call('LabelFrame::align', *args)
end
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
win
end
end

View file

@ -0,0 +1,290 @@
#
# tkextlib/bwidget/listbox.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/canvas'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ListBox < TkWindow
# is NOT a subclass of a listbox widget class.
# because it constructed on a canvas widget.
class Item < TkObject
end
end
end
end
class Tk::BWidget::ListBox
include TkItemConfigMethod
include Scrollable
TkCommandNames = ['ListBox'.freeze].freeze
WidgetClassName = 'ListBox'.freeze
WidgetClassNames[WidgetClassName] = self
class Event_for_Items < TkEvent::Event
def self._get_extra_args_tbl
[
TkComm.method(:string) # item idenfier
]
end
end
def tagid(tag)
if tag.kind_of?(Tk::BWidget::ListBox::Item)
tag.id
else
# tag
_get_eval_string(tag)
end
end
def imagebind(*args)
_bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebind_append(*args)
_bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebind_remove(*args)
_bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebindinfo(*args)
_bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
end
def textbind(*args)
_bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbind_append(*args)
_bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbind_remove(*args)
_bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbindinfo(*args)
_bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
end
def delete(*args)
tk_send('delete', *args)
self
end
def edit(item, text, *args)
tk_send('edit', tagid(item), text, *args)
self
end
def exist?(item)
bool(tk_send('exists', tagid(item)))
end
def index(item)
num_or_str(tk_send('index', tagid(item)))
end
def insert(idx, item, keys={})
tk_send('insert', idx, tagid(item), *hash_kv(keys))
self
end
def get_item(idx)
tk_send('items', idx)
end
def items(first=None, last=None)
list(tk_send('items', first, last))
end
def move(item, idx)
tk_send('move', tagid(item), idx)
self
end
def reorder(neworder)
tk_send('reorder', neworder)
self
end
def see(item)
tk_send('see', tagid(item))
self
end
def selection_clear
tk_send_without_enc('selection', 'clear')
self
end
def selection_set(*args)
tk_send_without_enc('selection', 'set',
*(args.collect{|item| tagid(item)}))
self
end
def selection_add(*args)
tk_send_without_enc('selection', 'add',
*(args.collect{|item| tagid(item)}))
self
end
def selection_remove(*args)
tk_send_without_enc('selection', 'remove',
*(args.collect{|item| tagid(item)}))
self
end
def selection_get(*args)
simplelist(tk_send_without_enc('selection', 'get')).collect{|item|
Tk::BWidget::ListBox::Item.id2obj(self, item)
}
end
end
class Tk::BWidget::ListBox::Item
include TkTreatTagFont
ListItem_TBL = TkCore::INTERP.create_table
ListItem_ID = ['item:'.freeze, '00000'.taint].freeze
TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
def self.id2obj(lbox, id)
lpath = lbox.path
return id unless ListItem_TBL[lpath]
ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
end
def initialize(lbox, *args)
if lbox.kind_of?(Tk::BWidget::ListBox)
@listbox = lbox
else
fail RuntimeError,
"expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
end
if args[-1].kind_of?(Hash)
keys = _symbolkey2str(args.pop)
else
keys = {}
end
index = keys.delete('index')
unless args.empty?
index = args.shift
end
index = 'end' unless index
unless args.empty?
fail RuntimeError, 'too much arguments'
end
@lpath = @listbox.path
if keys.key?('itemname')
@path = @id = keys.delete('itemname')
else
@path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
ListItem_ID[1].succ!
end
ListItem_TBL[@id] = self
ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
ListItem_TBL[@lpath][@id] = self
@listbox.insert(index, @id, keys)
end
def listbox
@listbox
end
def id
@id
end
def [](key)
cget(key)
end
def []=(key, val)
configure(key, val)
val
end
def cget(key)
@listbox.itemcget(@id, key)
end
def configure(key, val=None)
@listbox.itemconfigure(@id, key, val)
end
def configinfo(key=nil)
@listbox.itemconfiginfo(@id, key)
end
def current_configinfo(key=nil)
@listbox.current_itemconfiginfo(@id, key)
end
def delete
@listbox.delete(@id)
self
end
def edit(*args)
@listbox.edit(@id, *args)
self
end
def exist?
@listbox.exist?(@id)
end
def index
@listbox.index(@id)
end
def move(index)
@listbox.move(@id, index)
end
def see
@listbox.see(@id)
end
def selection_add
@listbox.selection_add(@id)
end
def selection_remove
@listbox.selection_remove(@id)
end
def selection_set
@listbox.selection_set(@id)
end
def selection_toggle
@listbox.selection_toggle(@id)
end
end

View file

@ -0,0 +1,73 @@
#
# tkextlib/bwidget/mainframe.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/progressbar'
module Tk
module BWidget
class MainFrame < TkWindow
end
end
end
class Tk::BWidget::MainFrame
TkCommandNames = ['MainFrame'.freeze].freeze
WidgetClassName = 'MainFrame'.freeze
WidgetClassNames[WidgetClassName] = self
def add_indicator(keys={}, &b)
win = window(tk_send('addindicator', *hash_kv(keys)))
win.instance_eval(&b) if b
win
end
def add_toolbar(&b)
win = window(tk_send('addtoolbar'))
win.instance_eval(&b) if b
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
win.instance_eval(&b) if b
win
end
def get_indicator(idx, &b)
win = window(tk_send('getindicator', idx))
win.instance_eval(&b) if b
win
end
def get_menu(menu_id, &b)
win = window(tk_send('getmenu', menu_id))
win.instance_eval(&b) if b
win
end
def get_toolbar(idx, &b)
win = window(tk_send('gettoolbar', idx))
win.instance_eval(&b) if b
win
end
def set_menustate(tag, state)
tk_send('setmenustate', tag, state)
self
end
def show_statusbar(name)
tk_send('showstatusbar', name)
self
end
def show_toolbar(idx, mode)
tk_send('showtoolbar', idx, mode)
self
end
end

View file

@ -0,0 +1,167 @@
#
# tkextlib/bwidget/messagedlg.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class MessageDlg < TkWindow
end
end
end
class Tk::BWidget::MessageDlg
TkCommandNames = ['MessageDlg'.freeze].freeze
WidgetClassName = 'MessageDlg'.freeze
WidgetClassNames[WidgetClassName] = self
def initialize(parent=nil, keys=nil)
@relative = ''
if parent.kind_of?(Hash)
keys = _symbolkey2str(parent)
@relative = keys['parent'] if keys.key?('parent')
@relative = keys.delete('relative') if keys.key?('relative')
super(keys)
elsif keys
keys = _symbolkey2str(keys)
@relative = keys.delete('parent') if keys.key?('parent')
@relative = keys.delete('relative') if keys.key?('relative')
super(parent, keys)
else
super(parent)
end
end
def create_self(keys)
# NOT create widget.
# Because the widget no longer exist when returning from creation.
@keys = _symbolkey2str(keys).update('parent'=>@relative)
@info = nil
end
private :create_self
def cget(slot)
slot = slot.to_s
if slot == 'relative'
slot = 'parent'
end
if winfo_exist?
val = super(slot)
@keys[slot] = val
end
@keys[slot]
end
def configure(slot, value=None)
if winfo_exist?
super(slot, value)
end
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
slot['parent'] = slot.delete('relative') if slot.key?('relative')
@keys.update(slot)
if @info
# update @info
slot.each{|k, v|
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (inf = @info.assoc(k))
inf[-1] = v
else
@info << [k, '', '', '', v]
end
else
if (inf = @info[k])
inf[-1] = v
else
@info[k] = ['', '', '', v]
end
end
}
end
else # ! Hash
slot = slot.to_s
slot = 'parent' if slot == 'relative'
@keys[slot] = value
if @info
# update @info
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (inf = @info.assoc(slot))
inf[-1] = value
else
@info << [slot, '', '', '', value]
end
else
if (inf = @info[slot])
inf[-1] = value
else
@info[slot] = ['', '', '', value]
end
end
end
end
self
end
def configinfo(slot=nil)
if winfo_exist?
@info = super()
if TkComm::GET_CONFIGINFO_AS_ARRAY
@info << ['relative', 'parent']
else
@info['relative'] = 'parent'
end
end
if TkComm::GET_CONFIGINFO_AS_ARRAY
if @info
if winfo_exist?
# update @keys
@info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
end
else
@info = []
@keys.each{|k, v|
@info << [k, '', '', '', v]
}
@info << ['relative', 'parent']
end
if slot
@info.asoc(slot.to_s).dup
else
@info.dup
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if @info
if winfo_exist?
# update @keys
@info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
end
else
@info = {}
@keys.each{|k, v|
@info[k] = ['', '', '', v]
}
@info['relative'] = 'parent'
end
if slot
@info[slot.to_s].dup
else
@info.dup
end
end
end
def create
num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
end
end

View file

@ -0,0 +1,116 @@
#
# tkextlib/bwidget/notebook.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class NoteBook < TkWindow
end
end
end
class Tk::BWidget::NoteBook
include TkItemConfigMethod
TkCommandNames = ['NoteBook'.freeze].freeze
WidgetClassName = 'NoteBook'.freeze
WidgetClassNames[WidgetClassName] = self
class Event_for_Tabs < TkEvent::Event
def self._get_extra_args_tbl
[
TkComm.method(:string) # page idenfier
]
end
end
def tagid(id)
if id.kind_of?(TkWindow)
id.path
elsif id.kind_of?(TkObject)
id.to_eval
else
# id.to_s
_get_eval_string(id)
end
end
def tabbind(*args)
_bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
self
end
def tabbind_append(*args)
_bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
self
end
def tabbind_remove(*args)
_bind_remove_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
self
end
def tabbindinfo(*args)
_bindinfo_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
end
def add(page, &b)
win = window(tk_send('add', tagid(page)))
win.instance_eval(&b) if b
win
end
def compute_size
tk_send('compute_size')
self
end
def delete(page, destroyframe=None)
tk_send('delete', tagid(page), destroyframe)
self
end
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
win.instance_eval(&b) if b
win
end
def index(page)
num_or_str(tk_send('index', tagid(page)))
end
def insert(index, page, keys={}, &b)
win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
win.instance_eval(&b) if b
win
end
def move(page, index)
tk_send('move', tagid(page), index)
self
end
def get_page(page)
tk_send('pages', page)
end
def pages(first=None, last=None)
list(tk_send('pages', first, last))
end
def raise(page=None)
tk_send('raise', page)
self
end
def see(page)
tk_send('see', page)
self
end
end

View file

@ -0,0 +1,61 @@
#
# tkextlib/bwidget/pagesmanager.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class PagesManager < TkWindow
end
end
end
class Tk::BWidget::PagesManager
TkCommandNames = ['PagesManager'.freeze].freeze
WidgetClassName = 'PagesManager'.freeze
WidgetClassNames[WidgetClassName] = self
def tagid(id)
# id.to_s
_get_eval_string(id)
end
def add(page, &b)
win = window(tk_send('add', tagid(page)))
win.instance_eval(&b) if b
win
end
def compute_size
tk_send('compute_size')
self
end
def delete(page)
tk_send('delete', tagid(page))
self
end
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
win.instance_eval(&b) if b
win
end
def get_page(page)
tk_send('pages', page)
end
def pages(first=None, last=None)
list(tk_send('pages', first, last))
end
def raise(page=None)
tk_send('raise', page)
self
end
end

View file

@ -0,0 +1,31 @@
#
# tkextlib/bwidget/panedwindow.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class PanedWindow < TkWindow
end
end
end
class Tk::BWidget::PanedWindow
TkCommandNames = ['PanedWindow'.freeze].freeze
WidgetClassName = 'PanedWindow'.freeze
WidgetClassNames[WidgetClassName] = self
def add(keys={})
window(tk_send('add', *hash_kv(keys)))
end
def get_frame(idx, &b)
win = window(tk_send_without_enc('getframe', idx))
win.instance_eval(&b) if b
win
end
end

View file

@ -0,0 +1,27 @@
#
# tkextlib/bwidget/passwddlg.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class PasswdDlg < Tk::BWidget::MessageDlg
end
end
end
class Tk::BWidget::PasswdDlg
TkCommandNames = ['PasswdDlg'.freeze].freeze
WidgetClassName = 'PasswdDlg'.freeze
WidgetClassNames[WidgetClassName] = self
def create
login, passwd = simplelist(tk_call(self.class::TkCommandNames[0],
@path, *hash_kv(@keys)))
[login, passwd]
end
end

View file

@ -0,0 +1,20 @@
#
# tkextlib/bwidget/progressbar.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ProgressBar < TkWindow
end
end
end
class Tk::BWidget::ProgressBar
TkCommandNames = ['ProgressBar'.freeze].freeze
WidgetClassName = 'ProgressBar'.freeze
WidgetClassNames[WidgetClassName] = self
end

View file

@ -0,0 +1,54 @@
#
# tkextlib/bwidget/progressdlg.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/variable'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/progressbar'
require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class ProgressDlg < Tk::BWidget::MessageDlg
end
end
end
class Tk::BWidget::ProgressDlg
TkCommandNames = ['ProgressDlg'.freeze].freeze
WidgetClassName = 'ProgressDlg'.freeze
WidgetClassNames[WidgetClassName] = self
def create_self(keys)
# NOT create widget for reusing the object
super(keys)
@keys['textvariable'] = TkVariable.new unless @keys.key?('textvariable')
@keys['variable'] = TkVariable.new unless @keys.key?('variable')
end
def textvariable
@keys['textvariable']
end
def text
@keys['textvariable'].value
end
def text= (txt)
@keys['textvariable'].value = txt
end
def variable
@keys['variable']
end
def value
@keys['variable'].value
end
def value= (val)
@keys['variable'].value = val
end
end

View file

@ -0,0 +1,34 @@
#
# tkextlib/bwidget/scrollableframe.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ScrollableFrame < TkWindow
end
end
end
class Tk::BWidget::ScrollableFrame
include Scrollable
TkCommandNames = ['ScrollableFrame'.freeze].freeze
WidgetClassName = 'ScrollableFrame'.freeze
WidgetClassNames[WidgetClassName] = self
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
win
end
def see(win, vert=None, horiz=None)
tk_send_without_enc('see', win, vert, horiz)
self
end
end

View file

@ -0,0 +1,32 @@
#
# tkextlib/bwidget/scrolledwindow.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ScrolledWindow < TkWindow
end
end
end
class Tk::BWidget::ScrolledWindow
TkCommandNames = ['ScrolledWindow'.freeze].freeze
WidgetClassName = 'ScrolledWindow'.freeze
WidgetClassNames[WidgetClassName] = self
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
win
end
def set_widget(win)
tk_send_without_enc('setwidget', win)
self
end
end

View file

@ -0,0 +1,20 @@
#
# tkextlib/bwidget/scrollview.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ScrollView < TkWindow
end
end
end
class Tk::BWidget::ScrollView
TkCommandNames = ['ScrollView'.freeze].freeze
WidgetClassName = 'ScrollView'.freeze
WidgetClassNames[WidgetClassName] = self
end

View file

@ -0,0 +1,45 @@
#
# tkextlib/bwidget/selectcolor.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class SelectColor < Tk::BWidget::MessageDlg
end
end
end
class Tk::BWidget::SelectColor
extend Tk
TkCommandNames = ['SelectColor'.freeze].freeze
WidgetClassName = 'SelectColor'.freeze
WidgetClassNames[WidgetClassName] = self
def dialog(keys={})
newkeys = @keys.dup
newkeys.update(_symbolkey2str(keys))
tk_call('SelectColor::dialog', @path, *hash_kv(newkeys))
end
def menu(*args)
if args[-1].kind_of?(Hash)
keys = args.pop
else
keys = {}
end
place = args.flatten
newkeys = @keys.dup
newkeys.update(_symbolkey2str(keys))
tk_call('SelectColor::menu', @path, place, *hash_kv(newkeys))
end
def self.set_color(idx, color)
tk_call('SelectColor::setcolor', idx, color)
end
end

View file

@ -0,0 +1,79 @@
#
# tkextlib/bwidget/selectfont.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class SelectFont < Tk::BWidget::MessageDlg
class Dialog < Tk::BWidget::SelectFont
end
class Toolbar < TkWindow
end
end
end
end
class Tk::BWidget::SelectFont
extend Tk
TkCommandNames = ['SelectFont'.freeze].freeze
WidgetClassName = 'SelectFont'.freeze
WidgetClassNames[WidgetClassName] = self
def __font_optkeys
[] # without fontobj operation
end
def create
tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
end
def self.load_font
tk_call('SelectFont::loadfont')
end
end
class Tk::BWidget::SelectFont::Dialog
def __font_optkeys
[] # without fontobj operation
end
def create_self(keys)
super(keys)
@keys['type'] = 'dialog'
end
def configure(slot, value=None)
if slot.kind_of?(Hash)
slot.delete['type']
slot.delete[:type]
return self if slot.empty?
else
return self if slot == 'type' || slot == :type
end
super(slot, value)
end
def create
@keys['type'] = 'dialog'
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
end
end
class Tk::BWidget::SelectFont::Toolbar
def __font_optkeys
[] # without fontobj operation
end
def create_self(keys)
keys = {} unless keys
keys = _symbolkey2str(keys)
keys['type'] = 'toolbar'
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys))
end
end

View file

@ -0,0 +1,20 @@
#
# tkextlib/bwidget/separator.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Separator < TkWindow
end
end
end
class Tk::BWidget::Separator
TkCommandNames = ['Separator'.freeze].freeze
WidgetClassName = 'Separator'.freeze
WidgetClassNames[WidgetClassName] = self
end

View file

@ -0,0 +1,8 @@
#
# setup.rb -- setup script before calling TkPackage.require()
#
# If you need some setup operations (for example, add a library path
# to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup
# operations in this file.
#

View file

@ -0,0 +1,58 @@
#
# tkextlib/bwidget/entry.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
require 'tkextlib/bwidget/arrowbutton'
require 'tkextlib/bwidget/entry'
module Tk
module BWidget
class SpinBox < TkEntry
end
end
end
class Tk::BWidget::SpinBox
include Scrollable
TkCommandNames = ['SpinBox'.freeze].freeze
WidgetClassName = 'SpinBox'.freeze
WidgetClassNames[WidgetClassName] = self
def entrybind(*args)
_bind([path, 'bind'], *args)
self
end
def entrybind_append(*args)
_bind_append([path, 'bind'], *args)
self
end
def entrybind_remove(*args)
_bind_remove([path, 'bind'], *args)
self
end
def entrybindinfo(*args)
_bindinfo([path, 'bind'], *args)
self
end
def get_index_of_value
number(tk_send_without_enc('getvalue'))
end
alias get_value get_index_of_value
alias get_value_index get_index_of_value
def set_value_by_index(idx)
idx = "@#{idx}" if idx.kind_of?(Integer)
tk_send_without_enc('setvalue', idx)
self
end
alias set_value set_value_by_index
alias set_index_value set_value_by_index
end

View file

@ -0,0 +1,27 @@
#
# tkextlib/bwidget/titleframe.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class TitleFrame < TkWindow
end
end
end
class Tk::BWidget::TitleFrame
TkCommandNames = ['TitleFrame'.freeze].freeze
WidgetClassName = 'TitleFrame'.freeze
WidgetClassNames[WidgetClassName] = self
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
win
end
end

View file

@ -0,0 +1,374 @@
#
# tkextlib/bwidget/tree.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/canvas'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class Tree < TkWindow
class Node < TkObject
end
end
end
end
class Tk::BWidget::Tree
include TkItemConfigMethod
include Scrollable
TkCommandNames = ['Tree'.freeze].freeze
WidgetClassName = 'Tree'.freeze
WidgetClassNames[WidgetClassName] = self
class Event_for_Items < TkEvent::Event
def self._get_extra_args_tbl
[
TkComm.method(:string) # item idenfier
]
end
end
def tagid(tag)
if tag.kind_of?(Tk::BWidget::Tree::Node)
tag.id
else
# tag
_get_eval_string(tag)
end
end
def imagebind(*args)
_bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebind_append(*args)
_bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebind_remove(*args)
_bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
self
end
def imagebindinfo(*args)
_bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
end
def textbind(*args)
_bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbind_append(*args)
_bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbind_remove(*args)
_bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
self
end
def textbindinfo(*args)
_bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
end
def close_tree(node, recurse=None)
tk_send('closetree', tagid(node), recurse)
self
end
def delete(*args)
tk_send('delete', *(args.collect{|node| tagid(node)}))
self
end
def edit(node, text, *args)
tk_send('edit', tagid(node), text, *args)
self
end
def exist?(node)
bool(tk_send('exists', tagid(node)))
end
def index(node)
num_or_str(tk_send('index', tagid(node)))
end
def insert(idx, parent, node, keys={})
tk_send('insert', idx, tagid(parent), tagid(node), *hash_kv(keys))
self
end
def move(parent, node, idx)
tk_send('move', tagid(parent), tagid(node), idx)
self
end
def get_node(node, idx)
Tk::BWidget::Tree::Node.id2obj(self, tk_send('nodes', tagid(node), idx))
end
def nodes(node, first=None, last=None)
simplelist(tk_send('nodes', tagid(node), first, last)).collect{|node|
Tk::BWidget::Tree::Node.id2obj(self, node)
}
end
def open?(node)
bool(@tree.itemcget(tagid(node), 'open'))
end
def open_tree(node, recurse=None)
tk_send('opentree', tagid(node), recurse)
self
end
def parent(node)
Tk::BWidget::Tree::Node.id2obj(self, tk_send('parent', tagid(node)))
end
def reorder(node, neworder)
tk_send('reorder', tagid(node), neworder)
self
end
def see(node)
tk_send('see', tagid(node))
self
end
def selection_add(*args)
tk_send_without_enc('selection', 'add',
*(args.collect{|node| tagid(node)}))
self
end
def selection_clear
tk_send_without_enc('selection', 'clear')
self
end
def selection_get
list(tk_send_without_enc('selection', 'get'))
end
def selection_include?(*args)
bool(tk_send_without_enc('selection', 'get',
*(args.collect{|node| tagid(node)})))
end
def selection_range(*args)
tk_send_without_enc('selection', 'range',
*(args.collect{|node| tagid(node)}))
self
end
def selection_remove(*args)
tk_send_without_enc('selection', 'remove',
*(args.collect{|node| tagid(node)}))
self
end
def selection_set(*args)
tk_send_without_enc('selection', 'set',
*(args.collect{|node| tagid(node)}))
self
end
def selection_toggle(*args)
tk_send_without_enc('selection', 'toggle',
*(args.collect{|node| tagid(node)}))
self
end
def toggle(node)
tk_send_without_enc('toggle', tagid(node))
self
end
def visible(node)
bool(tk_send_without_enc('visible', tagid(node)))
end
end
class Tk::BWidget::Tree::Node
include TkTreatTagFont
TreeNode_TBL = TkCore::INTERP.create_table
TreeNode_ID = ['node:'.freeze, '00000'.taint].freeze
TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
def self.id2obj(tree, id)
tpath = tree.path
return id unless TreeNode_TBL[tpath]
TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
end
def initialize(tree, *args)
if tree.kind_of?(Tk::BWidget::Tree)
@tree = tree
parent = args.shift
if parent.kind_of?(Tk::BWidget::Tree::Node)
if parent.tree.path != @tree.path
fail RuntimeError, 'tree of parent node is not match'
end
end
elsif tree.kind_of?(Tk::BWidget::Tree::Node)
@tree = tree.tree
parent = tree.parent
else
fail RuntimeError,
"expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
end
if args[-1].kind_of?(Hash)
keys = _symbolkey2str(args.pop)
else
keys = {}
end
index = keys.delete('index')
unless args.empty?
index = args.shift
end
index = 'end' unless index
unless args.empty?
fail RuntimeError, 'too much arguments'
end
@tpath = @tree.path
if keys.key?('nodename')
@path = @id = keys.delete('nodename')
else
@path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
TreeNode_ID[1].succ!
end
TreeNode_TBL[@id] = self
TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
TreeNode_TBL[@tpath][@id] = self
@tree.insert(index, parent, @id, keys)
end
def tree
@tree
end
def id
@id
end
def [](key)
cget(key)
end
def []=(key, val)
configure(key, val)
val
end
def cget(key)
@tree.itemcget(@id, key)
end
def configure(key, val=None)
@tree.itemconfigure(@id, key, val)
end
def configinfo(key=nil)
@tree.itemconfiginfo(@id, key)
end
def current_configinfo(key=nil)
@tree.current_itemconfiginfo(@id, key)
end
def close_tree(recurse=None)
@tree.close_tree(@id, recurse)
self
end
def delete
@tree.delete(@id)
self
end
def edit(*args)
@tree.edit(@id, *args)
self
end
def exist?
@tree.exist?(@id)
end
def index
@tree.index(@id)
end
def move(index, parent=nil)
if parent
@tree.move(parent, @id, index)
else
@tree.move(self.parent, @id, index)
end
end
def open_tree(recurse=None)
@tree.open_tree(@id, recurse)
self
end
def open?
bool(@tree.itemcget(@id, 'open'))
end
def parent
@tree.parent(@id)
end
def reorder(neworder)
@tree.reorder(@id, neworder)
end
def see
@tree.see(@id)
end
def selection_add
@tree.selection_add(@id)
end
def selection_remove
@tree.selection_remove(@id)
end
def selection_set
@tree.selection_set(@id)
end
def selection_toggle
@tree.selection_toggle(@id)
end
def toggle
@tree.toggle(@id)
end
def visible
@tree.visible(@id)
end
end

View file

@ -0,0 +1,113 @@
#
# tkextlib/bwidget/widget.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
module Widget
end
end
end
module Tk::BWidget::Widget
include Tk
extend Tk
def self.__pathname
'Widget::configure'
end
def self.__cget_cmd
['Widget::cget']
end
def self.__config_cmd
['Widget::configure']
end
def self.cget(slot)
self.current_configinfo(slot).values[0]
end
def self.add_map(klass, subclass, subpath, opts)
tk_call('Widget::addmap', klass, subclass, subpath, opts)
end
def self.bwinclude(klass, subclass, subpath, *args)
tk_call('Widget::bwinclude', klass, subclass, subpath, *args)
end
def self.create(klass, path, rename=None, &b)
win = window(tk_call('Widget::create', klass, path, rename))
win.instance_eval(&b) if b
win
end
def self.declare(klass, optlist)
tk_call('Widget::declare', klass, optlist)
end
def self.define(klass, filename, *args)
tk_call('Widget::define', klass, filename, *args)
end
def self.destroy(win)
tk_call('Widget::destroy', win)
end
def self.focus_next(win)
tk_call('Widget::focusNext', win)
end
def self.focus_ok(win)
tk_call('Widget::focusOk', win)
end
def self.focus_prev(win)
tk_call('Widget::focusPrev', win)
end
def self.generate_doc(dir, widgetlist)
tk_call('Widget::generate-doc', dir, widgetlist)
end
def self.generate_widget_doc(klass, iscmd, file)
tk_call('Widget::generate-widget-doc', klass, iscmd, file)
end
def self.get_option(win, option)
tk_call('Widget::getoption', win, option)
end
def self.get_variable(win, varname, my_varname=None)
tk_call('Widget::getVariable', win, varname, my_varname)
end
def self.has_changed(win, option, pvalue)
tk_call('Widget::hasChanged', win, option, pvalue)
end
def self.init(klass, win, options)
tk_call('Widget::init', klass, win, options)
end
def self.set_option(win, option, value)
tk_call('Widget::setoption', win, option, value)
end
def self.sub_cget(win, subwidget)
tk_call('Widget::subcget', win, subwidget)
end
def self.sync_options(klass, subclass, subpath, options)
tk_call('Widget::syncoptions', klass, subclass, subpath, options)
end
def self.tkinclude(klass, tkwidget, subpath, *args)
tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args)
end
end

View file

@ -8,50 +8,36 @@ require 'tk'
# call setup script for general 'tkextlib' libraries # call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# call setup script # call setup script
require File.join(dir, 'setup.rb') require 'tkextlib/tcllib/setup.rb'
# package:: autoscroll # package:: autoscroll
#require 'tkextlib/tcllib/autoscroll' require 'tkextlib/tcllib/autoscroll'
require File.join(dir, 'autoscroll')
# package:: cursor # package:: cursor
#require 'tkextlib/tcllib/cursor' require 'tkextlib/tcllib/cursor'
require File.join(dir, 'cursor')
# package:: style # package:: style
#require 'tkextlib/tcllib/style' require 'tkextlib/tcllib/style'
require File.join(dir, 'style')
# autoload # autoload
module Tk module Tk
module Tcllib module Tcllib
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# package:: ctext # package:: ctext
#autoload :CText, 'tkextlib/tcllib/ctext' autoload :CText, 'tkextlib/tcllib/ctext'
autoload :CText, File.join(dir, 'ctext')
# package:: datefield # package:: datefield
#autoload :Datefield, 'tkextlib/tcllib/datefield' autoload :Datefield, 'tkextlib/tcllib/datefield'
#autoload :DateField, 'tkextlib/tcllib/datefield' autoload :DateField, 'tkextlib/tcllib/datefield'
autoload :Datefield, File.join(dir, 'datefield')
autoload :DateField, File.join(dir, 'datefield')
# package:: ipentry # package:: ipentry
#autoload :IP_Entry, 'tkextlib/tcllib/ip_entry' autoload :IP_Entry, 'tkextlib/tcllib/ip_entry'
autoload :IP_Entry, File.join(dir, 'ip_entry')
# package:: Plotchart # package:: Plotchart
#autoload :Plotchart, 'tkextlib/tcllib/plotchart' autoload :Plotchart, 'tkextlib/tcllib/plotchart'
autoload :Plotchart, File.join(dir, 'plotchart')
# package:: tkpiechart # package:: tkpiechart
#autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart' autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart'
autoload :Tkpiechart, File.join(dir, 'tkpiechart')
end end
end end

View file

@ -26,17 +26,24 @@
require 'tk' require 'tk'
require 'tk/scrollbar' require 'tk/scrollbar'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('autoscroll', '1.0') # TkPackage.require('autoscroll', '1.0')
TkPackage.require('autoscroll') TkPackage.require('autoscroll')
module Tk module Tk
module Tcllib
module Autoscroll
def self.package_version
begin
TkPackage.require('autoscroll')
rescue
''
end
end
end
end
module Scrollable module Scrollable
def autoscroll(mode = nil) def autoscroll(mode = nil)
case mode case mode

View file

@ -8,12 +8,7 @@
require 'tk' require 'tk'
require 'tk/text' require 'tk/text'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('ctext', '3.1') # TkPackage.require('ctext', '3.1')
TkPackage.require('ctext') TkPackage.require('ctext')
@ -21,6 +16,13 @@ TkPackage.require('ctext')
module Tk module Tk
module Tcllib module Tcllib
class CText < TkText class CText < TkText
def self.package_version
begin
TkPackage.require('ctext')
rescue
''
end
end
end end
end end
end end

View file

@ -7,17 +7,24 @@
# #
require 'tk' require 'tk'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('cursor', '0.1') # TkPackage.require('cursor', '0.1')
TkPackage.require('cursor') TkPackage.require('cursor')
module Tk module Tk
module Tcllib
module Cursor
def self.package_version
begin
TkPackage.require('ipentry')
rescue
''
end
end
end
end
def self.cursor_display(parent=None) def self.cursor_display(parent=None)
# Pops up a dialog with a listbox containing all the cursor names. # Pops up a dialog with a listbox containing all the cursor names.
# Selecting a cursor name will display it in that dialog. # Selecting a cursor name will display it in that dialog.

View file

@ -17,12 +17,7 @@
require 'tk' require 'tk'
require 'tk/entry' require 'tk/entry'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('datefield', '0.1') # TkPackage.require('datefield', '0.1')
TkPackage.require('datefield') TkPackage.require('datefield')
@ -30,6 +25,13 @@ TkPackage.require('datefield')
module Tk module Tk
module Tcllib module Tcllib
class Datefield < TkEntry class Datefield < TkEntry
def self.package_version
begin
TkPackage.require('datefield')
rescue
''
end
end
end end
DateField = Datefield DateField = Datefield
end end

View file

@ -11,13 +11,7 @@
# It guarantees a valid address at all times. # It guarantees a valid address at all times.
require 'tk' require 'tk'
require 'tk/entry' require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('ipentry', '0.1') # TkPackage.require('ipentry', '0.1')
TkPackage.require('ipentry') TkPackage.require('ipentry')
@ -25,6 +19,13 @@ TkPackage.require('ipentry')
module Tk module Tk
module Tcllib module Tcllib
class IP_Entry < TkEntry class IP_Entry < TkEntry
def self.package_version
begin
TkPackage.require('ipentry')
rescue
''
end
end
end end
end end
end end

View file

@ -58,12 +58,7 @@
# #
require 'tk' require 'tk'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('Plotchart', '0.9') # TkPackage.require('Plotchart', '0.9')
TkPackage.require('Plotchart') TkPackage.require('Plotchart')
@ -71,6 +66,13 @@ TkPackage.require('Plotchart')
module Tk module Tk
module Tcllib module Tcllib
module Plotchart module Plotchart
def self.package_version
begin
TkPackage.require('Plotchart')
rescue
''
end
end
end end
end end
end end
@ -122,7 +124,7 @@ module Tk::Tcllib::Plotchart
############################ ############################
module ChartMethod module ChartMethod
include TkUtil include TkCore
def title(str) def title(str)
tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str)) tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str))

View file

@ -7,18 +7,21 @@
# #
require 'tk' require 'tk'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('style', '0.1') # TkPackage.require('style', '0.1')
TkPackage.require('style') TkPackage.require('style')
module Tk module Tk
module Style module Style
def self.package_version
begin
TkPackage.require('style')
rescue
''
end
end
def self.names def self.names
tk_split_simplelist(tk_call('style::names')) tk_split_simplelist(tk_call('style::names'))
end end

View file

@ -8,12 +8,7 @@
require 'tk' require 'tk'
require 'tk/canvas' require 'tk/canvas'
require 'tkextlib/tcllib.rb'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
# call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb')
# TkPackage.require('tkpiechart', '6.6') # TkPackage.require('tkpiechart', '6.6')
TkPackage.require('tkpiechart') TkPackage.require('tkpiechart')
@ -26,6 +21,14 @@ module Tk
end end
module Tk::Tcllib::Tkpiechart module Tk::Tcllib::Tkpiechart
def self.package_version
begin
TkPackage.require('tkpiechart')
rescue
''
end
end
module ConfigMethod module ConfigMethod
include TkConfigMethod include TkConfigMethod

View file

@ -9,10 +9,7 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory # library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') require 'tkextlib/tile/setup.rb'
# call setup script
require File.join(dir, 'setup.rb')
# load package # load package
# TkPackage.require('tile', '0.4') # TkPackage.require('tile', '0.4')
@ -21,6 +18,14 @@ TkPackage.require('tile')
# autoload # autoload
module Tk module Tk
module Tile module Tile
def self.package_version
begin
TkPackage.require('tile')
rescue
''
end
end
module TileWidget module TileWidget
def instate(state, script=nil, &b) def instate(state, script=nil, &b)
if script if script
@ -41,33 +46,22 @@ module Tk
end end
end end
######################################
# library directory autoload :TButton, 'tkextlib/tile/tbutton'
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
#autoload :TButton, 'tkextlib/tile/tbutton' autoload :TCheckButton, 'tkextlib/tile/tcheckbutton'
autoload :TButton, File.join(dir, 'tbutton') autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton'
#autoload :TCheckButton, 'tkextlib/tile/tcheckbutton' autoload :TLabel, 'tkextlib/tile/tlabel'
#autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton'
autoload :TCheckButton, File.join(dir, 'tcheckbutton')
autoload :TCheckbutton, File.join(dir, 'tcheckbutton')
#autoload :TLabel, 'tkextlib/tile/tlabel' autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
autoload :TLabel, File.join(dir, 'tlabel')
#autoload :TMenubutton, 'tkextlib/tile/tmenubutton' autoload :TNotebook, 'tkextlib/tile/tnotebook'
autoload :TMenubutton, File.join(dir, 'tmenubutton')
#autoload :TNotebook, 'tkextlib/tile/tnotebook' autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
autoload :TNotebook, File.join(dir, 'tnotebook') autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
#autoload :TRadioButton, 'tkextlib/tile/tradiobutton' autoload :Style, 'tkextlib/tile/style'
#autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
autoload :TRadioButton, File.join(dir, 'tradiobutton')
autoload :TRadiobutton, File.join(dir, 'tradiobutton')
#autoload :Style, 'tkextlib/tile/style'
autoload :Style, File.join(dir, 'style')
end end
end end

View file

@ -3,12 +3,14 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
module Style
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') end
end
module Tk::Tile::Style module Tk::Tile::Style
end end

View file

@ -3,12 +3,14 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TButton < TkButton
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') end
end
class Tk::Tile::TButton < TkButton class Tk::Tile::TButton < TkButton
include Tk::Tile::TileWidget include Tk::Tile::TileWidget

View file

@ -3,12 +3,15 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TCheckButton < TkCheckButton
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') TCheckbutton = TCheckButton
end
end
class Tk::Tile::TCheckButton < TkCheckButton class Tk::Tile::TCheckButton < TkCheckButton
include Tk::Tile::TileWidget include Tk::Tile::TileWidget
@ -26,8 +29,3 @@ class Tk::Tile::TCheckButton < TkCheckButton
end end
private :create_self private :create_self
end end
module Tk
module Tile
TCheckbutton = TCheckButton
end
end

View file

@ -3,12 +3,14 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TLabel < TkLabel
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') end
end
class Tk::Tile::TLabel < TkLabel class Tk::Tile::TLabel < TkLabel
include Tk::Tile::TileWidget include Tk::Tile::TileWidget

View file

@ -3,12 +3,14 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TMenubutton < TkMenubutton
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') end
end
class Tk::Tile::TMenubutton < TkMenubutton class Tk::Tile::TMenubutton < TkMenubutton
include Tk::Tile::TileWidget include Tk::Tile::TileWidget

View file

@ -3,12 +3,14 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TNotebook < TkWindow
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') end
end
class Tk::Tile::TNotebook < TkWindow class Tk::Tile::TNotebook < TkWindow
################################ ################################

View file

@ -3,12 +3,15 @@
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
require 'tk' require 'tk'
require 'tkextlib/tile.rb'
# call setup script for general 'tkextlib' libraries module Tk
require 'tkextlib/setup.rb' module Tile
class TRadioButton < TkRadioButton
# call setup script -- <libdir>/tkextlib/tile.rb end
require(File.dirname(File.expand_path(__FILE__)) + '.rb') TRadiobutton = TRadioButton
end
end
class Tk::Tile::TRadioButton < TkRadioButton class Tk::Tile::TRadioButton < TkRadioButton
include Tk::Tile::TileWidget include Tk::Tile::TileWidget
@ -26,8 +29,3 @@ class Tk::Tile::TRadioButton < TkRadioButton
end end
private :create_self private :create_self
end end
module Tk
module Tile
TRadiobutton = TRadioButton
end
end

View file

@ -7,19 +7,12 @@ require 'tk'
# call setup script for general 'tkextlib' libraries # call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# call setup script # call setup script
require File.join(dir, 'setup.rb') require 'tkextlib/tkDND/setup.rb'
module Tk module Tk
module TkDND module TkDND
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') autoload :DND, 'tkextlib/tkDND/tkdnd'
autoload :Shape, 'tkextlib/tkDND/shape'
#autoload :DND, 'tkextlib/tkDND/tkdnd'
#autoload :Shape, 'tkextlib/tkDND/shape'
autoload :DND, File.join(dir, 'tkdnd')
autoload :Shape, File.join(dir, 'shape')
end end
end end

View file

@ -9,7 +9,7 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkDND/setup.rb'
# TkPackage.require('shape', '0.3') # TkPackage.require('shape', '0.3')
TkPackage.require('shape') TkPackage.require('shape')
@ -17,9 +17,29 @@ TkPackage.require('shape')
module Tk module Tk
module TkDND module TkDND
module Shape module Shape
=begin
def self.package_version
begin
TkPackage.require('shape')
rescue
''
end
end
=end
def self.package_version
Tk.tk_call('set', 'shape_version')
end
alias shape_version package_version
def self.package_patchlevel
Tk.tk_call('set', 'shape_patchlevel')
end
alias shape_patchlevel package_patchlevel
def self.version def self.version
tk_call('shape', 'version') tk_call('shape', 'version')
end end
alias xshape_version version
############################ ############################

View file

@ -9,12 +9,20 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkDND/setup.rb'
TkPackage.require('tkdnd') TkPackage.require('tkdnd')
module Tk module Tk
module TkDND module TkDND
def self.package_version
begin
TkPackage.require('tkdnd')
rescue
''
end
end
class DND_Subst < TkUtil::CallbackSubst class DND_Subst < TkUtil::CallbackSubst
KEY_TBL = [ KEY_TBL = [
[ ?a, ?l, :actions ], [ ?a, ?l, :actions ],
@ -49,6 +57,14 @@ module Tk
end end
module DND module DND
def self.version
begin
TkPackage.require('tkdnd')
rescue
''
end
end
def dnd_bindtarget_info(type=nil, event=nil) def dnd_bindtarget_info(type=nil, event=nil)
if event if event
procedure(tk_call('dnd', 'bindtarget', @path, type, event)) procedure(tk_call('dnd', 'bindtarget', @path, type, event))

View file

@ -6,11 +6,8 @@
# call setup script for general 'tkextlib' libraries # call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# call setup script # call setup script
require File.join(dir, 'setup.rb') require 'tkextlib/tkHTML/setup.rb'
# load library # load library
require File.join(dir, 'htmlwidget') require 'tkextlib/tkHTML/htmlwidget'

View file

@ -9,21 +9,27 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkHTML/setup.rb'
# TkPackage.require('Tkhtml', '2.0') # TkPackage.require('Tkhtml', '2.0')
TkPackage.require('Tkhtml') TkPackage.require('Tkhtml')
module Tk module Tk
class HTML_Widget < TkWindow class HTML_Widget < TkWindow
def self.package_version
begin
TkPackage.require('Tkhtml')
rescue
''
end
end
class ClippingWindow < TkWindow class ClippingWindow < TkWindow
end end
end end
end end
class Tk::HTML_Widget::ClippingWindow class Tk::HTML_Widget::ClippingWindow
extend TkUtil
WidgetClassName = 'HtmlClip'.freeze WidgetClassName = 'HtmlClip'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
@ -32,7 +38,7 @@ class Tk::HTML_Widget::ClippingWindow
def self.new(parent, keys={}) def self.new(parent, keys={})
if parent.kind_of?(Hash) if parent.kind_of?(Hash)
keys = _symbolkey2str(parent) keys = TkComm._symbolkey2str(parent)
parent = keys.delete('parent') parent = keys.delete('parent')
end end

View file

@ -8,16 +8,24 @@ require 'tk'
# call setup script for general 'tkextlib' libraries # call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# library directory
dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '')
# call setup script # call setup script
require File.join(dir, 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# load all image format handlers # load all image format handlers
#TkPackage.require('Img', '1.3') #TkPackage.require('Img', '1.3')
TkPackage.require('Img') TkPackage.require('Img')
module Tk
module Img
def self.package_version
begin
TkPackage.require('Img')
rescue
''
end
end
end
end
# autoload # autoload
#autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap' autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap'
autoload :TkPixmapImage, File.join(dir, 'pixmap')

View file

@ -8,7 +8,21 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
#TkPackage.require('img::bmp', '1.3') #TkPackage.require('img::bmp', '1.3')
TkPackage.require('img::bmp') TkPackage.require('img::bmp')
module Tk
module Img
module BMP
def self.package_version
begin
TkPackage.require('img::bmp')
rescue
''
end
end
end
end
end

View file

@ -8,7 +8,21 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# TkPackage.require('img::gif', '1.3') # TkPackage.require('img::gif', '1.3')
TkPackage.require('img::gif') TkPackage.require('img::gif')
module Tk
module Img
module GIF
def self.package_version
begin
TkPackage.require('img::gif')
rescue
''
end
end
end
end
end

View file

@ -8,7 +8,21 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# TkPackage.require('img::ico', '1.3') # TkPackage.require('img::ico', '1.3')
TkPackage.require('img::ico') TkPackage.require('img::ico')
module Tk
module Img
module ICO
def self.package_version
begin
TkPackage.require('img::ico')
rescue
''
end
end
end
end
end

View file

@ -8,7 +8,21 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# TkPackage.require('img::jpeg', '1.3') # TkPackage.require('img::jpeg', '1.3')
TkPackage.require('img::jpeg') TkPackage.require('img::jpeg')
module Tk
module Img
module JPEG
def self.package_version
begin
TkPackage.require('img::jpeg')
rescue
''
end
end
end
end
end

View file

@ -8,7 +8,21 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# TkPackage.require('img::pcx', '1.3') # TkPackage.require('img::pcx', '1.3')
TkPackage.require('img::pcx') TkPackage.require('img::pcx')
module Tk
module Img
module PCX
def self.package_version
begin
TkPackage.require('img::pcx')
rescue
''
end
end
end
end
end

View file

@ -8,12 +8,30 @@ require 'tk'
require 'tkextlib/setup.rb' require 'tkextlib/setup.rb'
# call setup script # call setup script
require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') require 'tkextlib/tkimg/setup.rb'
# TkPackage.require('img::pixmap', '1.3') # TkPackage.require('img::pixmap', '1.3')
TkPackage.require('img::pixmap') TkPackage.require('img::pixmap')
module Tk
module Img
module PIXMAP
def self.package_version
begin
TkPackage.require('img::pixmap')
rescue
''
end
end
end
end
end
class TkPixmapImage<TkImage class TkPixmapImage<TkImage
def self.version
Tk::Img::PIXMAP.version
end
def initialize(*args) def initialize(*args)
@type = 'pixmap' @type = 'pixmap'
super super

Some files were not shown because too many files have changed in this diff Show more