* ext/tk/, ext/tcltklib/: bug fix
* ext/tk/lib/tk.rb: better operation for SIGINT when processing callbacks. * ext/tk/lib/tk/msgcat.rb: ditto. * ext/tk/lib/tk/variable.rb: ditto. * ext/tk/lib/tk/timer.rb: ditto. * ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd() to define validatecommand methods easier * ext/tk/lib/tk.rb (_genobj_for_tkwidget): support autoload Tk ext classes * ext/tk/lib/tk/canvas.rb and so on: remove the parent widget type check for items (e.g. canvas items; depends on the class) to avoid some troubles on Tk extension widget class definition. * ext/tk/lib/tkextlib/: add Iwidget and TkTable extension support * ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
Thu Jul 15 10:15:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/, ext/tcltklib/: bug fix
|
||||
|
||||
* ext/tk/lib/tk.rb: better operation for SIGINT when processing
|
||||
callbacks.
|
||||
* ext/tk/lib/tk/msgcat.rb: ditto.
|
||||
* ext/tk/lib/tk/variable.rb: ditto.
|
||||
* ext/tk/lib/tk/timer.rb: ditto.
|
||||
|
||||
* ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd
|
||||
to define validatecommand methods easier
|
||||
|
||||
* ext/tk/lib/tk.rb (_genobj_for_tkwidget): support autoload Tk ext
|
||||
classes
|
||||
|
||||
* ext/tk/lib/tk/canvas.rb and so on: remove the parent widget type
|
||||
check for items (e.g. canvas items; depends on the class) to
|
||||
avoid some troubles on Tk extension widget class definition.
|
||||
|
||||
* ext/tk/lib/tkextlib/: add Iwidget and TkTable extension support
|
||||
|
||||
* ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable
|
||||
|
||||
|
||||
Wed Jul 14 23:49:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enum.c (enum_min_by): new method Enum#min_by. added Enum#max_by
|
||||
|
|
|
@ -4401,20 +4401,21 @@ ip_get_variable2(self, varname_arg, index_arg, flag_arg)
|
|||
|
||||
ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag));
|
||||
|
||||
Tcl_IncrRefCount(ret);
|
||||
Tcl_DecrRefCount(nameobj);
|
||||
Tcl_DecrRefCount(idxobj);
|
||||
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
|
||||
if (ret == (Tcl_Obj*)NULL) {
|
||||
Tcl_DecrRefCount(ret);
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
|
||||
#else /* TCL_MAJOR_VERSION < 8 */
|
||||
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
||||
#endif
|
||||
}
|
||||
|
||||
Tcl_IncrRefCount(ret);
|
||||
|
||||
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
|
||||
s = Tcl_GetStringFromObj(ret, &len);
|
||||
strval = rb_tainted_str_new(s, len);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
2004-07-15 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* bug fix
|
||||
|
||||
* support TkTable extension
|
||||
|
||||
2004-07-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* bug fix
|
||||
|
||||
* support Iwidgets extension
|
||||
|
||||
2004-07-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* bug fix
|
||||
|
|
103
ext/tk/MANIFEST
|
@ -139,7 +139,6 @@ lib/tkextlib/itk/setup.rb
|
|||
lib/tkextlib/iwidgets.rb
|
||||
lib/tkextlib/iwidgets/buttonbox.rb
|
||||
lib/tkextlib/iwidgets/calendar.rb
|
||||
lib/tkextlib/iwidgets/setup.rb
|
||||
lib/tkextlib/iwidgets/canvasprintbox.rb
|
||||
lib/tkextlib/iwidgets/canvasprintdialog.rb
|
||||
lib/tkextlib/iwidgets/checkbox.rb
|
||||
|
@ -157,9 +156,41 @@ lib/tkextlib/iwidgets/feedback.rb
|
|||
lib/tkextlib/iwidgets/fileselectionbox.rb
|
||||
lib/tkextlib/iwidgets/fileselectiondialog.rb
|
||||
lib/tkextlib/iwidgets/finddialog.rb
|
||||
lib/tkextlib/iwidgets/hierarchy.rb
|
||||
lib/tkextlib/iwidgets/hyperhelp.rb
|
||||
lib/tkextlib/iwidgets/labeledframe.rb
|
||||
lib/tkextlib/iwidgets/labeledwidget.rb
|
||||
lib/tkextlib/iwidgets/mainwindow.rb
|
||||
lib/tkextlib/iwidgets/menubar.rb
|
||||
lib/tkextlib/iwidgets/messagebox.rb
|
||||
lib/tkextlib/iwidgets/messagedialog.rb
|
||||
lib/tkextlib/iwidgets/notebook.rb
|
||||
lib/tkextlib/iwidgets/optionmenu.rb
|
||||
lib/tkextlib/iwidgets/panedwindow.rb
|
||||
lib/tkextlib/iwidgets/promptdialog.rb
|
||||
lib/tkextlib/iwidgets/pushbutton.rb
|
||||
lib/tkextlib/iwidgets/radiobox.rb
|
||||
lib/tkextlib/iwidgets/scopedobject.rb
|
||||
lib/tkextlib/iwidgets/scrolledcanvas.rb
|
||||
lib/tkextlib/iwidgets/scrolledframe.rb
|
||||
lib/tkextlib/iwidgets/scrolledhtml.rb
|
||||
lib/tkextlib/iwidgets/scrolledlistbox.rb
|
||||
lib/tkextlib/iwidgets/scrolledtext.rb
|
||||
lib/tkextlib/iwidgets/scrolledwidget.rb
|
||||
lib/tkextlib/iwidgets/selectionbox.rb
|
||||
lib/tkextlib/iwidgets/selectiondialog.rb
|
||||
lib/tkextlib/iwidgets/setup.rb
|
||||
lib/tkextlib/iwidgets/shell.rb
|
||||
lib/tkextlib/iwidgets/spindate.rb
|
||||
lib/tkextlib/iwidgets/spinint.rb
|
||||
lib/tkextlib/iwidgets/spinner.rb
|
||||
lib/tkextlib/iwidgets/spintime.rb
|
||||
lib/tkextlib/iwidgets/tabnotebook.rb
|
||||
lib/tkextlib/iwidgets/tabset.rb
|
||||
lib/tkextlib/iwidgets/timeentry.rb
|
||||
lib/tkextlib/iwidgets/timefield.rb
|
||||
lib/tkextlib/iwidgets/toolbar.rb
|
||||
lib/tkextlib/iwidgets/watch.rb
|
||||
lib/tkextlib/tcllib.rb
|
||||
lib/tkextlib/tcllib/README
|
||||
lib/tkextlib/tcllib/autoscroll.rb
|
||||
|
@ -206,7 +237,9 @@ lib/tkextlib/tkimg/tiff.rb
|
|||
lib/tkextlib/tkimg/window.rb
|
||||
lib/tkextlib/tkimg/xbm.rb
|
||||
lib/tkextlib/tkimg/xpm.rb
|
||||
lib/tkextlib/tktrans.rb
|
||||
lib/tkextlib/tktable.rb
|
||||
lib/tkextlib/tktable/setup.rb
|
||||
lib/tkextlib/tktable/tktable.rb
|
||||
lib/tkextlib/tktrans/setup.rb
|
||||
lib/tkextlib/tktrans/tktrans.rb
|
||||
lib/tkextlib/treectrl.rb
|
||||
|
@ -461,7 +494,28 @@ sample/tkextlib/bwidget/select.rb
|
|||
sample/tkextlib/bwidget/tmpldlg.rb
|
||||
sample/tkextlib/bwidget/tree.rb
|
||||
sample/tkextlib/bwidget/x1.xbm
|
||||
sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/clear.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/close.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/find.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/help.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/new.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/open.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/points.xbm
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/print.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/save.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/select.gif
|
||||
sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
|
||||
sample/tkextlib/iwidgets/sample/buttonbox.rb
|
||||
sample/tkextlib/iwidgets/sample/calendar.rb
|
||||
sample/tkextlib/iwidgets/sample/canvasprintbox.rb
|
||||
|
@ -482,14 +536,51 @@ sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb
|
|||
sample/tkextlib/iwidgets/sample/feedback.rb
|
||||
sample/tkextlib/iwidgets/sample/fileselectionbox.rb
|
||||
sample/tkextlib/iwidgets/sample/fileselectiondialog.rb
|
||||
sample/tkextlib/iwidgets/sample/finddialog.rb
|
||||
sample/tkextlib/iwidgets/sample/hierarchy.rb
|
||||
sample/tkextlib/iwidgets/sample/hyperhelp.rb
|
||||
sample/tkextlib/iwidgets/sample/labeledframe.rb
|
||||
sample/tkextlib/iwidgets/sample/labeledwidget.rb
|
||||
sample/tkextlib/iwidgets/sample/mainwindow.rb
|
||||
sample/tkextlib/iwidgets/sample/menubar.rb
|
||||
sample/tkextlib/iwidgets/sample/menubar2.rb
|
||||
sample/tkextlib/iwidgets/sample/messagebox1.rb
|
||||
sample/tkextlib/iwidgets/sample/messagebox2.rb
|
||||
sample/tkextlib/iwidgets/sample/messagedialog.rb
|
||||
sample/tkextlib/iwidgets/sample/notebook.rb
|
||||
sample/tkextlib/iwidgets/sample/notebook2.rb
|
||||
sample/tkextlib/iwidgets/sample/optionmenu.rb
|
||||
sample/tkextlib/iwidgets/sample/panedwindow.rb
|
||||
sample/tkextlib/iwidgets/sample/panedwindow2.rb
|
||||
sample/tkextlib/iwidgets/sample/promptdialog.rb
|
||||
sample/tkextlib/iwidgets/sample/pushbutton.rb
|
||||
sample/tkextlib/iwidgets/sample/radiobox.rb
|
||||
sample/tkextlib/iwidgets/sample/scrolledcanvas.rb
|
||||
sample/tkextlib/iwidgets/sample/scrolledframe.rb
|
||||
sample/tkextlib/iwidgets/sample/scrolledhtml.rb
|
||||
sample/tkextlib/iwidgets/sample/scrolledlistbox.rb
|
||||
sample/tkextlib/iwidgets/sample/scrolledtext.rb
|
||||
sample/tkextlib/iwidgets/sample/selectionbox.rb
|
||||
sample/tkextlib/iwidgets/sample/selectiondialog.rb
|
||||
sample/tkextlib/iwidgets/sample/shell.rb
|
||||
sample/tkextlib/iwidgets/sample/spindate.rb
|
||||
sample/tkextlib/iwidgets/sample/spinint.rb
|
||||
sample/tkextlib/iwidgets/sample/spinner.rb
|
||||
sample/tkextlib/iwidgets/sample/spintime.rb
|
||||
sample/tkextlib/iwidgets/sample/tabnotebook.rb
|
||||
sample/tkextlib/iwidgets/sample/tabnotebook2.rb
|
||||
sample/tkextlib/iwidgets/sample/tabset.rb
|
||||
sample/tkextlib/iwidgets/sample/timeentry.rb
|
||||
sample/tkextlib/iwidgets/sample/timefield.rb
|
||||
sample/tkextlib/iwidgets/sample/toolbar.rb
|
||||
sample/tkextlib/iwidgets/sample/watch.rb
|
||||
sample/tkextlib/tcllib/LICENSE.orig
|
||||
sample/tkextlib/tcllib/datefield.rb
|
||||
sample/tkextlib/tcllib/plotdemos1.rb
|
||||
sample/tkextlib/tcllib/plotdemos2.rb
|
||||
sample/tkextlib/tcllib/plotdemos3.rb
|
||||
sample/tkextlib/tcllib/xyplot.rb
|
||||
sample/tkextlib/tkHTML/COPYRIGHT.orig
|
||||
sample/tkextlib/tkHTML/README
|
||||
sample/tkextlib/tkHTML/hv.rb
|
||||
sample/tkextlib/tkHTML/ss.rb
|
||||
|
@ -573,6 +664,14 @@ sample/tkextlib/tkHTML/page4/image7
|
|||
sample/tkextlib/tkHTML/page4/image8
|
||||
sample/tkextlib/tkHTML/page4/image9
|
||||
sample/tkextlib/tkHTML/page4/index.html
|
||||
sample/tkextlib/tktable/LICENSE.orig
|
||||
sample/tkextlib/tktable/basic.rb
|
||||
sample/tkextlib/tktable/buttons.rb
|
||||
sample/tkextlib/tktable/command.rb
|
||||
sample/tkextlib/tktable/debug.rb
|
||||
sample/tkextlib/tktable/dynarows.rb
|
||||
sample/tkextlib/tktable/maxsize.rb
|
||||
sample/tkextlib/tktable/valid.rb
|
||||
sample/tkextlib/vu/LICENSE.orig
|
||||
sample/tkextlib/vu/README.txt
|
||||
sample/tkextlib/vu/canvItems.rb
|
||||
|
|
|
@ -26,6 +26,7 @@ module TkComm
|
|||
extend TkUtil
|
||||
|
||||
WidgetClassNames = {}.taint
|
||||
TkExtlibAutoloadModule = [].taint
|
||||
|
||||
# None = Object.new ### --> definition is moved to TkUtil module
|
||||
# def None.to_s
|
||||
|
@ -92,6 +93,51 @@ module TkComm
|
|||
# gen_class_name = ruby_class_name + 'GeneratedOnTk'
|
||||
gen_class_name = ruby_class_name
|
||||
classname_def = ''
|
||||
else # ruby_class == nil
|
||||
mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)}
|
||||
mods.each{|mod|
|
||||
begin
|
||||
mod.const_get(tk_class) # auto_load
|
||||
break if (ruby_class = WidgetClassNames[tk_class])
|
||||
rescue LoadError
|
||||
# ignore load error
|
||||
end
|
||||
}
|
||||
|
||||
unless ruby_class
|
||||
std_class = 'Tk' << tk_class
|
||||
if Object.const_defined?(std_class)
|
||||
Object.const_get(std_class) # auto_load
|
||||
ruby_class = WidgetClassNames[tk_class]
|
||||
end
|
||||
end
|
||||
|
||||
if ruby_class
|
||||
# found
|
||||
ruby_class_name = ruby_class.name
|
||||
gen_class_name = ruby_class_name
|
||||
classname_def = ''
|
||||
else
|
||||
# unknown
|
||||
ruby_class_name = 'TkWindow'
|
||||
gen_class_name = 'TkWidget_' + tk_class
|
||||
classname_def = "WidgetClassName = '#{tk_class}'.freeze"
|
||||
end
|
||||
end
|
||||
|
||||
###################################
|
||||
=begin
|
||||
if ruby_class = WidgetClassNames[tk_class]
|
||||
ruby_class_name = ruby_class.name
|
||||
# gen_class_name = ruby_class_name + 'GeneratedOnTk'
|
||||
gen_class_name = ruby_class_name
|
||||
classname_def = ''
|
||||
else
|
||||
mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)}
|
||||
if mod
|
||||
ruby_class_name = mod.name + '::' + tk_class
|
||||
gen_class_name = ruby_class_name
|
||||
classname_def = ''
|
||||
elsif Object.const_defined?('Tk' + tk_class)
|
||||
ruby_class_name = 'Tk' + tk_class
|
||||
# gen_class_name = ruby_class_name + 'GeneratedOnTk'
|
||||
|
@ -103,6 +149,8 @@ module TkComm
|
|||
gen_class_name = 'TkWidget_' + tk_class
|
||||
classname_def = "WidgetClassName = '#{tk_class}'.freeze"
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
||||
=begin
|
||||
unless Object.const_defined? gen_class_name
|
||||
|
@ -131,7 +179,12 @@ module TkComm
|
|||
private :_genobj_for_tkwidget
|
||||
module_function :_genobj_for_tkwidget
|
||||
|
||||
def tk_tcl2ruby(val, enc_mode = nil, listobj = true)
|
||||
def _at(x,y)
|
||||
"@#{Integer(x)},#{Integer(y)}"
|
||||
end
|
||||
module_function :_at
|
||||
|
||||
def tk_tcl2ruby(val, enc_mode = false, listobj = true)
|
||||
if val =~ /^rb_out\S* (c(_\d+_)?\d+)/
|
||||
#return Tk_CMDTBL[$1]
|
||||
return TkCore::INTERP.tk_cmd_tbl[$1]
|
||||
|
@ -181,7 +234,7 @@ module TkComm
|
|||
|
||||
private :tk_tcl2ruby
|
||||
module_function :tk_tcl2ruby
|
||||
private_class_method :tk_tcl2ruby
|
||||
#private_class_method :tk_tcl2ruby
|
||||
|
||||
unless const_defined?(:USE_TCLs_LIST_FUNCTIONS)
|
||||
USE_TCLs_LIST_FUNCTIONS = true
|
||||
|
@ -238,7 +291,8 @@ if USE_TCLs_LIST_FUNCTIONS
|
|||
array2tk_list(e)
|
||||
elsif e.kind_of? Hash
|
||||
tmp_ary = []
|
||||
e.each{|k,v| tmp_ary << k << v }
|
||||
#e.each{|k,v| tmp_ary << k << v }
|
||||
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
||||
array2tk_list(tmp_ary)
|
||||
else
|
||||
_get_eval_string(e)
|
||||
|
@ -369,7 +423,9 @@ else
|
|||
if e.kind_of? Array
|
||||
"{#{array2tk_list(e)}}"
|
||||
elsif e.kind_of? Hash
|
||||
"{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
|
||||
# "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
|
||||
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
||||
array2tk_list(tmp_ary)
|
||||
else
|
||||
s = _get_eval_string(e)
|
||||
(s.index(/\s/) || s.size == 0)? "{#{s}}": s
|
||||
|
@ -3108,7 +3164,6 @@ class TkObject<TkKernel
|
|||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
def tk_trace_variable(v)
|
||||
unless v.kind_of?(TkVariable)
|
||||
fail(ArgumentError, "type error (#{v.class}); must be TkVariable object")
|
||||
|
@ -3116,7 +3171,6 @@ class TkObject<TkKernel
|
|||
v
|
||||
end
|
||||
private :tk_trace_variable
|
||||
=end
|
||||
|
||||
def destroy
|
||||
#tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
|
||||
|
|
|
@ -602,9 +602,9 @@ class TkcItem<TkObject
|
|||
########################################
|
||||
|
||||
def initialize(parent, *args)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@parent = @c = parent
|
||||
@path = parent.path
|
||||
|
||||
|
|
|
@ -189,9 +189,9 @@ class TkcTag<TkObject
|
|||
end
|
||||
|
||||
def initialize(parent, mode=nil, *args)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@c = parent
|
||||
@cpath = parent.path
|
||||
# @path = @id = Tk_CanvasTag_ID.join('')
|
||||
|
@ -276,9 +276,9 @@ class TkcTagString<TkcTag
|
|||
end
|
||||
|
||||
def initialize(parent, name, mode=nil, *args)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@c = parent
|
||||
@cpath = parent.path
|
||||
@path = @id = name
|
||||
|
@ -293,9 +293,9 @@ TkcNamedTag = TkcTagString
|
|||
|
||||
class TkcTagAll<TkcTag
|
||||
def initialize(parent)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@c = parent
|
||||
@cpath = parent.path
|
||||
@path = @id = 'all'
|
||||
|
@ -306,9 +306,9 @@ end
|
|||
|
||||
class TkcTagCurrent<TkcTag
|
||||
def initialize(parent)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@c = parent
|
||||
@cpath = parent.path
|
||||
@path = @id = 'current'
|
||||
|
@ -321,9 +321,9 @@ class TkcGroup<TkcTag
|
|||
Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze
|
||||
#def create_self(parent, *args)
|
||||
def initialize(parent, *args)
|
||||
unless parent.kind_of?(TkCanvas)
|
||||
fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkCanvas)
|
||||
# fail ArguemntError, "expect TkCanvas for 1st argument"
|
||||
#end
|
||||
@c = parent
|
||||
@cpath = parent.path
|
||||
# @path = @id = Tk_cGroup_ID.join('')
|
||||
|
|
|
@ -118,6 +118,10 @@ module TkEvent
|
|||
#
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
#
|
||||
# NOTE: The order of parameters which passed to callback procedure is
|
||||
# <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
|
||||
#
|
||||
|
||||
# If you need support extra arguments given by Tcl/Tk,
|
||||
# please override _get_extra_args_tbl
|
||||
|
|
|
@ -320,9 +320,9 @@ class TkMenuClone<TkMenu
|
|||
widgetname = keys.delete('widgetname')
|
||||
type = keys.delete('type'); type = None unless type
|
||||
end
|
||||
unless parent.kind_of?(TkMenu)
|
||||
fail ArgumentError, "parent must be TkMenu"
|
||||
end
|
||||
#unless parent.kind_of?(TkMenu)
|
||||
# fail ArgumentError, "parent must be TkMenu"
|
||||
#end
|
||||
@parent = parent
|
||||
install_win(@parent.path, widgetname)
|
||||
tk_call_without_enc(@parent.path, 'clone', @path, type)
|
||||
|
@ -336,9 +336,9 @@ module TkSystemMenu
|
|||
keys = _symbolkey2str(parent)
|
||||
parent = keys.delete('parent')
|
||||
end
|
||||
unless parent.kind_of? TkMenu
|
||||
fail ArgumentError, "parent must be a TkMenu object"
|
||||
end
|
||||
#unless parent.kind_of? TkMenu
|
||||
# fail ArgumentError, "parent must be a TkMenu object"
|
||||
#end
|
||||
# @path = Kernel.format("%s.%s", parent.path, self.class::SYSMENU_NAME)
|
||||
@path = parent_path + '.' + self.class::SYSMENU_NAME
|
||||
#TkComm::Tk_WINDOWS[@path] = self
|
||||
|
|
|
@ -144,6 +144,30 @@ module TkMenuSpec
|
|||
end
|
||||
private :_create_menu
|
||||
|
||||
def _use_menubar?(parent)
|
||||
use_menubar = false
|
||||
if parent.kind_of?(TkRoot) || parent.kind_of?(TkToplevel)
|
||||
return true
|
||||
else
|
||||
begin
|
||||
parent.cget('menu')
|
||||
return true
|
||||
rescue
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
private :_use_menubar?
|
||||
|
||||
def _create_menu_for_menubar(parent)
|
||||
unless (mbar = parent.menu).kind_of?(TkMenu)
|
||||
mbar = TkMenu.new(parent, :tearoff=>false)
|
||||
parent.menu(mbar)
|
||||
end
|
||||
mbar
|
||||
end
|
||||
private :_create_menu_for_menubar
|
||||
|
||||
def _create_menubutton(parent, menu_info, tearoff=false, default_opts = nil)
|
||||
btn_info = menu_info[0]
|
||||
|
||||
|
@ -160,12 +184,10 @@ module TkMenuSpec
|
|||
|
||||
tearoff = keys.delete('tearoff') if keys.key?('tearoff')
|
||||
|
||||
if parent.kind_of?(TkRoot) || parent.kind_of?(TkToplevel)
|
||||
if _use_menubar?(parent)
|
||||
# menubar by menu entries
|
||||
unless (mbar = parent.menu).kind_of?(TkMenu)
|
||||
mbar = TkMenu.new(parent, :tearoff=>false)
|
||||
parent.menu(mbar)
|
||||
end
|
||||
|
||||
mbar = _create_menu_for_menubar(parent)
|
||||
|
||||
menu_name = nil
|
||||
|
||||
|
|
|
@ -502,9 +502,9 @@ class TkText<TkTextWin
|
|||
if TkTextTag::TTagID_TBL[@path]
|
||||
tags.each{|tag|
|
||||
if tag.kind_of? TkTextTag
|
||||
TTagID_TBL[@path].delete(tag.id)
|
||||
TkTextTag::TTagID_TBL[@path].delete(tag.id)
|
||||
else
|
||||
TTagID_TBL[@path].delete(tag)
|
||||
TkTextTag::TTagID_TBL[@path].delete(tag)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -6,9 +6,9 @@ require 'tk/text'
|
|||
|
||||
class TkTextImage<TkObject
|
||||
def initialize(parent, index, keys)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@t = parent
|
||||
if index == 'end'
|
||||
@path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
|
||||
|
|
|
@ -17,9 +17,9 @@ class TkTextMark<TkObject
|
|||
end
|
||||
|
||||
def initialize(parent, index)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@parent = @t = parent
|
||||
@tpath = parent.path
|
||||
# @path = @id = Tk_TextMark_ID.join('')
|
||||
|
@ -101,9 +101,9 @@ class TkTextNamedMark<TkTextMark
|
|||
end
|
||||
|
||||
def initialize(parent, name, index=nil)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@parent = @t = parent
|
||||
@tpath = parent.path
|
||||
@path = @id = name
|
||||
|
|
|
@ -20,14 +20,14 @@ class TkTextTag<TkObject
|
|||
end
|
||||
|
||||
def initialize(parent, *args)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@parent = @t = parent
|
||||
@tpath = parent.path
|
||||
# @path = @id = Tk_TextTag_ID.join('')
|
||||
@path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_)
|
||||
TTagID_TBL[@id] = self
|
||||
# TTagID_TBL[@id] = self
|
||||
TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
|
||||
TTagID_TBL[@tpath][@id] = self
|
||||
Tk_TextTag_ID[1].succ!
|
||||
|
@ -221,9 +221,9 @@ class TkTextNamedTag<TkTextTag
|
|||
end
|
||||
|
||||
def initialize(parent, name, *args)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@parent = @t = parent
|
||||
@tpath = parent.path
|
||||
@path = @id = name
|
||||
|
|
|
@ -6,9 +6,9 @@ require 'tk/text'
|
|||
|
||||
class TkTextWindow<TkObject
|
||||
def initialize(parent, index, keys)
|
||||
unless parent.kind_of?(TkText)
|
||||
fail ArguemntError, "expect TkText for 1st argument"
|
||||
end
|
||||
#unless parent.kind_of?(TkText)
|
||||
# fail ArguemntError, "expect TkText for 1st argument"
|
||||
#end
|
||||
@t = parent
|
||||
if index == 'end'
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
|
|
|
@ -183,6 +183,7 @@ end
|
|||
|
||||
class TkValidateCommand
|
||||
include TkComm
|
||||
extend TkComm
|
||||
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
|
@ -227,14 +228,19 @@ class TkValidateCommand
|
|||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
(val)? '1': '0'
|
||||
end
|
||||
#
|
||||
# NOTE: The order of parameters which passed to callback procedure is
|
||||
# <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
|
||||
#
|
||||
|
||||
#def self._get_extra_args_tbl
|
||||
# # return an array of convert procs
|
||||
# []
|
||||
#end
|
||||
|
||||
def self.ret_val(val)
|
||||
(val)? '1': '0'
|
||||
end
|
||||
end
|
||||
|
||||
###############################################
|
||||
|
@ -257,7 +263,7 @@ class TkValidateCommand
|
|||
else
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(args.pop)}
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
*(ex_args.concat(klass.scan_args(keys, arg)))
|
||||
))
|
||||
|
@ -272,7 +278,7 @@ class TkValidateCommand
|
|||
else
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(args.pop)}
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
*(ex_args << klass.new(*klass.scan_args(keys, arg)))
|
||||
))
|
||||
|
|
|
@ -96,12 +96,45 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# default_value is available only when the variable is an assoc array.
|
||||
#
|
||||
def default_value(val=nil, &b)
|
||||
if b
|
||||
@def_default = :proc
|
||||
@default_val = proc(&b)
|
||||
else
|
||||
@def_default = :val
|
||||
@default_val = val
|
||||
end
|
||||
self
|
||||
end
|
||||
def default_value=(val)
|
||||
@def_default = :val
|
||||
@default_val = val
|
||||
self
|
||||
end
|
||||
def default_proc(cmd = Proc.new)
|
||||
@def_default = :proc
|
||||
@default_val = cmd
|
||||
self
|
||||
end
|
||||
|
||||
def undef_default
|
||||
@default_val = nil
|
||||
@def_default = false
|
||||
self
|
||||
end
|
||||
|
||||
def initialize(val="")
|
||||
# @id = Tk_VARIABLE_ID.join('')
|
||||
@id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
|
||||
Tk_VARIABLE_ID[1].succ!
|
||||
TkVar_ID_TBL[@id] = self
|
||||
|
||||
@def_default = false
|
||||
@default_val = nil
|
||||
|
||||
@trace_var = nil
|
||||
@trace_elem = nil
|
||||
@trace_opts = nil
|
||||
|
@ -290,7 +323,19 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||
|
||||
def [](*idxs)
|
||||
index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
|
||||
begin
|
||||
_fromUTF8(INTERP._get_global_var2(@id, index))
|
||||
rescue => e
|
||||
case @def_default
|
||||
when :proc
|
||||
@default_val.call(self, *idxs)
|
||||
when :val
|
||||
@default_val
|
||||
else
|
||||
fail e
|
||||
end
|
||||
end
|
||||
#_fromUTF8(INTERP._get_global_var2(@id, index))
|
||||
#_fromUTF8(INTERP._get_global_var2(@id, _toUTF8(_get_eval_string(index))))
|
||||
#_fromUTF8(INTERP._get_global_var2(@id, _get_eval_string(index, true)))
|
||||
end
|
||||
|
@ -389,7 +434,19 @@ else
|
|||
|
||||
def [](*idxs)
|
||||
index = idxs.collect{|idx| _get_eval_string(idx)}.join(',')
|
||||
begin
|
||||
INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
|
||||
rescue => e
|
||||
case @def_default
|
||||
when :proc
|
||||
@default_val.call(self, *idxs)
|
||||
when :val
|
||||
@default_val
|
||||
else
|
||||
fail e
|
||||
end
|
||||
end
|
||||
#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)))
|
||||
|
|
|
@ -49,8 +49,14 @@ script may give you some hints about that.
|
|||
Tcllib http://sf.net/projects/tcllib
|
||||
==> tcllib (partial support; Tklib part only)
|
||||
|
||||
IWidgets http://sf.net/projects/incrTcl ==> iwidgets
|
||||
|
||||
BWidgets http://sf.net/projects/tcllib ==> bwidget
|
||||
|
||||
TkTable http://sf.net/projects/tktable ==> tktable
|
||||
[ * see also <http://www.korus.hu/~fery/ruby/tktable.rb>
|
||||
written by Ferenc Engard (ferenc@engard.hu) ]
|
||||
|
||||
vu http://tktable.sourceforge.net ==> vu
|
||||
|
||||
TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML
|
||||
|
@ -84,11 +90,6 @@ TkDND http://sourceforge.net/projects/tkdnd ==> tkDND
|
|||
|
||||
TclX http://sf.net/projects/tclx * may support Tk part only
|
||||
|
||||
IWidgets http://sf.net/projects/incrTcl
|
||||
|
||||
TkTable http://sf.net/projects/tktable
|
||||
* see http://www.korus.hu/~fery/ruby/tktable.rb
|
||||
|
||||
winico http://tktable.sourceforge.net
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ TkPackage.require('BWidget')
|
|||
|
||||
module Tk
|
||||
module BWidget
|
||||
TkComm::TkExtlibAutoloadModule.unshift(self)
|
||||
|
||||
extend TkCore
|
||||
|
||||
LIBRARY = tk_call('set', '::BWIDGET::LIBRARY')
|
||||
|
|
|
@ -162,7 +162,7 @@ class Tk::BWidget::ListBox::Item
|
|||
include TkTreatTagFont
|
||||
|
||||
ListItem_TBL = TkCore::INTERP.create_table
|
||||
ListItem_ID = ['item:'.freeze, '00000'.taint].freeze
|
||||
ListItem_ID = ['bw:item'.freeze, '00000'.taint].freeze
|
||||
|
||||
TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ class Tk::BWidget::Tree::Node
|
|||
include TkTreatTagFont
|
||||
|
||||
TreeNode_TBL = TkCore::INTERP.create_table
|
||||
TreeNode_ID = ['node:'.freeze, '00000'.taint].freeze
|
||||
TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze
|
||||
|
||||
TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ module Tk
|
|||
'::itk::' << self::WidgetClassName
|
||||
end
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Itk::Component::ComponentID_TBL.delete(self.path)
|
||||
end
|
||||
|
||||
#### [incr Tk] public methods
|
||||
def component
|
||||
simplelist(tk_send('component'))
|
||||
|
@ -129,7 +133,7 @@ module Tk
|
|||
end
|
||||
|
||||
ComponentID_TBL = TkCore::INTERP.create_table
|
||||
Itk_Component_ID = ['itk_component'.freeze, '00000'.taint].freeze
|
||||
Itk_Component_ID = ['itk:component'.freeze, '00000'.taint].freeze
|
||||
|
||||
TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear }
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ TkPackage.require('Iwidgets')
|
|||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
TkComm::TkExtlibAutoloadModule.unshift(self)
|
||||
|
||||
extend TkCore
|
||||
|
||||
def self.package_version
|
||||
|
@ -55,11 +57,30 @@ module Tk
|
|||
autoload :Labeledframe, 'tkextlib/iwidgets/labeledframe'
|
||||
autoload :Labeledwidget, 'tkextlib/iwidgets/labeledwidget'
|
||||
autoload :Mainwindow, 'tkextlib/iwidgets/mainwindow'
|
||||
autoload :Menubar, 'tkextlib/iwidgets/menubar'
|
||||
autoload :Messagebox, 'tkextlib/iwidgets/messagebox'
|
||||
autoload :Messagedialog, 'tkextlib/iwidgets/messagedialog'
|
||||
autoload :Notebook, 'tkextlib/iwidgets/notebook'
|
||||
autoload :Optionmenu, 'tkextlib/iwidgets/optionmenu'
|
||||
autoload :Panedwindow, 'tkextlib/iwidgets/panedwindow'
|
||||
autoload :Pushbutton, 'tkextlib/iwidgets/pushbutton'
|
||||
autoload :Promptdialog, 'tkextlib/iwidgets/promptdialog'
|
||||
autoload :Radiobox, 'tkextlib/iwidgets/radiobox'
|
||||
autoload :Scrolledcanvas, 'tkextlib/iwidgets/scrolledcanvas'
|
||||
autoload :Scrolledframe, 'tkextlib/iwidgets/scrolledframe'
|
||||
autoload :Scrolledhtml, 'tkextlib/iwidgets/scrolledhtml'
|
||||
autoload :Scrolledlistbox, 'tkextlib/iwidgets/scrolledlistbox'
|
||||
autoload :Scrolledtext, 'tkextlib/iwidgets/scrolledtext'
|
||||
autoload :Scrolledwidget, 'tkextlib/iwidgets/scrolledwidget'
|
||||
autoload :Selectionbox, 'tkextlib/iwidgets/selectionbox'
|
||||
autoload :Selectiondialog, 'tkextlib/iwidgets/selectiondialog'
|
||||
autoload :Shell, 'tkextlib/iwidgets/shell'
|
||||
autoload :Spindate, 'tkextlib/iwidgets/spindate'
|
||||
autoload :Spinint, 'tkextlib/iwidgets/spinint'
|
||||
autoload :Spinner, 'tkextlib/iwidgets/spinner'
|
||||
autoload :Spintime, 'tkextlib/iwidgets/spintime'
|
||||
autoload :Tabnotebook, 'tkextlib/iwidgets/tabnotebook'
|
||||
autoload :Tabset, 'tkextlib/iwidgets/tabset'
|
||||
autoload :Timeentry, 'tkextlib/iwidgets/timeentry'
|
||||
autoload :Timefield, 'tkextlib/iwidgets/timefield'
|
||||
autoload :Toolbar, 'tkextlib/iwidgets/toolbar'
|
||||
|
|
|
@ -56,7 +56,9 @@ class Tk::Iwidgets::Buttonbox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
|
@ -87,7 +89,9 @@ class Tk::Iwidgets::Buttonbox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
|
||||
|
|
|
@ -56,7 +56,9 @@ class Tk::Iwidgets::Checkbox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
|
@ -93,7 +95,9 @@ class Tk::Iwidgets::Checkbox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
|
||||
|
|
|
@ -56,7 +56,9 @@ class Tk::Iwidgets::Dialogshell
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
|
@ -87,7 +89,9 @@ class Tk::Iwidgets::Dialogshell
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
|
||||
|
|
|
@ -87,7 +87,13 @@ class Tk::Iwidgets::Entryfield
|
|||
def value
|
||||
_fromUTF8(tk_send_without_enc('get'))
|
||||
end
|
||||
def value= (val)
|
||||
tk_send_without_enc('delete', 0, 'end')
|
||||
tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
|
||||
val
|
||||
end
|
||||
alias get value
|
||||
alias set value=
|
||||
|
||||
def cursor=(index)
|
||||
tk_send_without_enc('icursor', index)
|
||||
|
|
190
ext/tk/lib/tkextlib/iwidgets/menubar.rb
Normal file
|
@ -0,0 +1,190 @@
|
|||
#
|
||||
# tkextlib/iwidgets/menubar.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Menubar < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Menubar
|
||||
TkCommandNames = ['::iwidgets::menubar'.freeze].freeze
|
||||
WidgetClassName = 'Menubar'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'menucget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'menuconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
#_get_eval_string(tagOrId)
|
||||
tagOrId
|
||||
end
|
||||
end
|
||||
|
||||
alias menucget itemcget
|
||||
alias menuconfigure itemconfigure
|
||||
alias menuconfiginfo itemconfiginfo
|
||||
alias current_menuconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def __methodcall_optkeys
|
||||
{'menubuttons'=>'menubuttons'}
|
||||
end
|
||||
|
||||
def menubuttons(val = nil)
|
||||
unless val
|
||||
return tk_call(@path, 'cget', '-menubuttons')
|
||||
end
|
||||
|
||||
tk_call(@path, 'configure', '-menubuttons', _parse_menu_spec(val))
|
||||
self
|
||||
end
|
||||
|
||||
def _parse_menu_spec(menu_spec)
|
||||
ret = ''
|
||||
menu_spec.each{|spec|
|
||||
next unless spec
|
||||
|
||||
if spec.kind_of?(Hash)
|
||||
args = [spec]
|
||||
type = 'options'
|
||||
else
|
||||
type, *args = spec
|
||||
end
|
||||
|
||||
type = type.to_s
|
||||
case type
|
||||
when 'options'
|
||||
keys = args[0]
|
||||
ary = [type]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
|
||||
when 'menubutton', 'cascade'
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
keys = _symbolkey2str(keys)
|
||||
keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
|
||||
else
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
end
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
||||
####################################
|
||||
|
||||
def add(type, tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
keys = _symbolkey2str(keys)
|
||||
keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
|
||||
tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def delete(path1, path2=nil)
|
||||
if path2
|
||||
else
|
||||
tk_call(@path, 'delete', index(idx))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
number(tk_call(@path, 'index', tagid(idx)))
|
||||
end
|
||||
|
||||
def insert(idx, type, tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
keys = _symbolkey2str(keys)
|
||||
keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
|
||||
tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def invoke(idx)
|
||||
tk_call(@path, 'invoke', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def menupath(pat)
|
||||
if (win = tk_call(@path, 'path', pat)) == '-1'
|
||||
return nil
|
||||
end
|
||||
window(win)
|
||||
end
|
||||
def menupath_glob(pat)
|
||||
if (win = tk_call(@path, 'path', '-glob', pat)) == '-1'
|
||||
return nil
|
||||
end
|
||||
window(win)
|
||||
end
|
||||
def menupath_tclregexp(pat)
|
||||
if (win = tk_call(@path, 'path', '-regexp', pat)) == '-1'
|
||||
return nil
|
||||
end
|
||||
window(win)
|
||||
end
|
||||
|
||||
def type(path)
|
||||
tk_call(@path, 'type', path)
|
||||
end
|
||||
|
||||
def yposition(path)
|
||||
number(tk_call(@path, 'yposition', path))
|
||||
end
|
||||
end
|
|
@ -41,10 +41,10 @@ class Tk::Iwidgets::Messagebox
|
|||
end
|
||||
end
|
||||
|
||||
alias type_cget itemcget
|
||||
alias type_configure itemconfigure
|
||||
alias type_configinfo itemconfiginfo
|
||||
alias current_type_configinfo current_itemconfiginfo
|
||||
alias typecget itemcget
|
||||
alias typeconfigure itemconfigure
|
||||
alias typeconfiginfo itemconfiginfo
|
||||
alias current_typeconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
|
163
ext/tk/lib/tkextlib/iwidgets/notebook.rb
Normal file
|
@ -0,0 +1,163 @@
|
|||
#
|
||||
# tkextlib/iwidgets/notebook.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Notebook < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Notebook
|
||||
TkCommandNames = ['::iwidgets::notebook'.freeze].freeze
|
||||
WidgetClassName = 'Notebook'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'tabcget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'tabconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
#_get_eval_string(tagOrId)
|
||||
tagOrId
|
||||
end
|
||||
end
|
||||
|
||||
alias pagecget itemcget
|
||||
alias pageconfigure itemconfigure
|
||||
alias pageconfiginfo itemconfiginfo
|
||||
alias current_pageconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(keys={})
|
||||
window(tk_call(@path, 'add', *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def child_site_list
|
||||
list(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def child_site(idx)
|
||||
if (new_idx = self.index(idx)) < 0
|
||||
new_idx = tagid(idx)
|
||||
end
|
||||
window(tk_call(@path, 'childsite', new_idx))
|
||||
end
|
||||
|
||||
def delete(idx1, idx2=nil)
|
||||
if (new_idx1 = self.index(idx1)) < 0
|
||||
new_idx1 = tagid(idx1)
|
||||
end
|
||||
if idx2
|
||||
if (new_idx2 = self.index(idx2)) < 0
|
||||
new_idx2 = tagid(idx2)
|
||||
end
|
||||
tk_call(@path, 'delete', new_idx1, new_idx2)
|
||||
else
|
||||
tk_call(@path, 'delete', new_idx1)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
number(tk_call(@path, 'index', tagid(idx)))
|
||||
end
|
||||
|
||||
def insert(idx, keys={})
|
||||
if (new_idx = self.index(idx)) < 0
|
||||
new_idx = tagid(idx)
|
||||
end
|
||||
window(tk_call(@path, 'insert', new_idx, *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def next
|
||||
tk_call(@path, 'next')
|
||||
self
|
||||
end
|
||||
|
||||
def prev
|
||||
tk_call(@path, 'prev')
|
||||
self
|
||||
end
|
||||
|
||||
def select(idx)
|
||||
if (new_idx = self.index(idx)) < 0
|
||||
new_idx = tagid(idx)
|
||||
end
|
||||
tk_call(@path, 'select', new_idx)
|
||||
self
|
||||
end
|
||||
|
||||
def scrollcommand(cmd=Proc.new)
|
||||
configure_cmd 'scrollcommand', cmd
|
||||
self
|
||||
end
|
||||
alias xscrollcommand scrollcommand
|
||||
alias yscrollcommand scrollcommand
|
||||
|
||||
def xscrollbar(bar=nil)
|
||||
if bar
|
||||
@scrollbar = bar
|
||||
@scrollbar.orient 'horizontal'
|
||||
self.scrollcommand {|*arg| @scrollbar.set(*arg)}
|
||||
@scrollbar.command {|*arg| self.xview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@scrollbar
|
||||
end
|
||||
def yscrollbar(bar=nil)
|
||||
if bar
|
||||
@scrollbar = bar
|
||||
@scrollbar.orient 'vertical'
|
||||
self.scrollcommand {|*arg| @scrollbar.set(*arg)}
|
||||
@scrollbar.command {|*arg| self.yview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@scrollbar
|
||||
end
|
||||
alias scrollbar yscrollbar
|
||||
|
||||
def view(*index)
|
||||
if index.size == 0
|
||||
window(tk_send_without_enc('view'))
|
||||
else
|
||||
tk_send_without_enc('view', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
alias xview view
|
||||
alias yview view
|
||||
|
||||
def view_moveto(*index)
|
||||
view('moveto', *index)
|
||||
end
|
||||
alias xview_moveto view_moveto
|
||||
alias yview_moveto view_moveto
|
||||
def view_scroll(*index)
|
||||
view('scroll', *index)
|
||||
end
|
||||
alias xview_scroll view_scroll
|
||||
alias yview_scroll view_scroll
|
||||
end
|
87
ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
Normal file
|
@ -0,0 +1,87 @@
|
|||
#
|
||||
# tkextlib/iwidgets/optionmenu.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Optionmenu < Tk::Iwidgets::Labeledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Optionmenu
|
||||
TkCommandNames = ['::iwidgets::optionmenu'.freeze].freeze
|
||||
WidgetClassName = 'Optionmenu'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def delete(first, last=nil)
|
||||
if last
|
||||
tk_call(@path, 'delete', first, last)
|
||||
else
|
||||
tk_call(@path, 'delete', first)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def disable(idx)
|
||||
tk_call(@path, 'disable', idx)
|
||||
self
|
||||
end
|
||||
|
||||
def enable(idx)
|
||||
tk_call(@path, 'enable', idx)
|
||||
self
|
||||
end
|
||||
|
||||
def get(first=nil, last=nil)
|
||||
if last
|
||||
simplelist(tk_call(@path, 'get', first, last))
|
||||
elsif first
|
||||
tk_call(@path, 'get', first)
|
||||
else
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
end
|
||||
def get_range(first, last)
|
||||
get(first, last)
|
||||
end
|
||||
def get_selected
|
||||
get()
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
number(tk_call(@path, 'index', idx))
|
||||
end
|
||||
|
||||
def insert(idx, *args)
|
||||
tk_call(@path, 'insert', idx, *args)
|
||||
self
|
||||
end
|
||||
|
||||
def select(idx)
|
||||
tk_call(@path, 'select', idx)
|
||||
self
|
||||
end
|
||||
|
||||
def sort(*params, &b)
|
||||
# see 'lsort' man page about params
|
||||
if b
|
||||
tk_call(@path, 'sort', '-command', proc(&b), *params)
|
||||
else
|
||||
tk_call(@path, 'sort', *params)
|
||||
end
|
||||
self
|
||||
end
|
||||
def sort_ascending
|
||||
tk_call(@path, 'sort', 'ascending')
|
||||
self
|
||||
end
|
||||
def sort_descending
|
||||
tk_call(@path, 'sort', 'descending')
|
||||
self
|
||||
end
|
||||
end
|
127
ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
Normal file
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# tkextlib/iwidgets/panedwindow.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Panedwindow < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Panedwindow
|
||||
TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze
|
||||
WidgetClassName = 'Panedwindow'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'panecget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'paneconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
#_get_eval_string(tagOrId)
|
||||
tagOrId
|
||||
end
|
||||
end
|
||||
|
||||
alias panecget itemcget
|
||||
alias paneconfigure itemconfigure
|
||||
alias paneconfiginfo itemconfiginfo
|
||||
alias current_paneconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys)))
|
||||
tag
|
||||
end
|
||||
|
||||
def child_site_list
|
||||
list(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def child_site(idx)
|
||||
window(tk_call(@path, 'childsite', index(idx)))
|
||||
end
|
||||
|
||||
def delete(idx)
|
||||
tk_call(@path, 'delete', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def fraction(*percentages)
|
||||
tk_call(@path, 'fraction', *percentages)
|
||||
self
|
||||
end
|
||||
|
||||
def hide(idx)
|
||||
tk_call(@path, 'hide', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
number(tk_call(@path, 'index', tagid(idx)))
|
||||
end
|
||||
|
||||
def insert(idx, tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)))
|
||||
tag
|
||||
end
|
||||
|
||||
def invoke(idx=nil)
|
||||
if idx
|
||||
tk_call(@path, 'invoke', index(idx))
|
||||
else
|
||||
tk_call(@path, 'invoke')
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def reset
|
||||
tk_call(@path, 'reset')
|
||||
self
|
||||
end
|
||||
|
||||
def show(idx)
|
||||
tk_call(@path, 'show', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
131
ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
Normal file
|
@ -0,0 +1,131 @@
|
|||
#
|
||||
# tkextlib/iwidgets/promptdialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Promptdialog < Tk::Iwidgets::Dialog
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Promptdialog
|
||||
TkCommandNames = ['::iwidgets::promptdialog'.freeze].freeze
|
||||
WidgetClassName = 'Promptdialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
# index method is not available, because it shows index of the entry field
|
||||
def default(name)
|
||||
tk_call(@path, 'default', tagid(name))
|
||||
self
|
||||
end
|
||||
|
||||
def hide(name)
|
||||
tk_call(@path, 'hide', tagid(name))
|
||||
self
|
||||
end
|
||||
|
||||
def invoke(name=nil)
|
||||
if name
|
||||
tk_call(@path, 'invoke', tagid(name))
|
||||
else
|
||||
tk_call(@path, 'invoke')
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def show(name)
|
||||
tk_call(@path, 'show', tagid(name))
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
# based on Tk::Iwidgets::Entryfield
|
||||
def clear
|
||||
tk_call(@path, 'clear')
|
||||
self
|
||||
end
|
||||
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def value
|
||||
_fromUTF8(tk_send_without_enc('get'))
|
||||
end
|
||||
def value= (val)
|
||||
tk_send_without_enc('delete', 0, 'end')
|
||||
tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
|
||||
val
|
||||
end
|
||||
alias get value
|
||||
alias set value=
|
||||
|
||||
def cursor=(index)
|
||||
tk_send_without_enc('icursor', index)
|
||||
#self
|
||||
index
|
||||
end
|
||||
alias icursor cursor=
|
||||
|
||||
def index(index)
|
||||
number(tk_send_without_enc('index', index))
|
||||
end
|
||||
|
||||
def insert(pos,text)
|
||||
tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
|
||||
self
|
||||
end
|
||||
|
||||
def mark(pos)
|
||||
tk_send_without_enc('scan', 'mark', pos)
|
||||
self
|
||||
end
|
||||
def dragto(pos)
|
||||
tk_send_without_enc('scan', 'dragto', pos)
|
||||
self
|
||||
end
|
||||
def selection_adjust(index)
|
||||
tk_send_without_enc('selection', 'adjust', index)
|
||||
self
|
||||
end
|
||||
def selection_clear
|
||||
tk_send_without_enc('selection', 'clear')
|
||||
self
|
||||
end
|
||||
def selection_from(index)
|
||||
tk_send_without_enc('selection', 'from', index)
|
||||
self
|
||||
end
|
||||
def selection_present()
|
||||
bool(tk_send_without_enc('selection', 'present'))
|
||||
end
|
||||
def selection_range(s, e)
|
||||
tk_send_without_enc('selection', 'range', s, e)
|
||||
self
|
||||
end
|
||||
def selection_to(index)
|
||||
tk_send_without_enc('selection', 'to', index)
|
||||
self
|
||||
end
|
||||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
end
|
30
ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# tkextlib/iwidgets/pushbutton.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Pushbutton < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Pushbutton
|
||||
TkCommandNames = ['::iwidgets::pushbutton'.freeze].freeze
|
||||
WidgetClassName = 'Pushbutton'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def invoke
|
||||
tk_call_without_enc(@path, 'invoke')
|
||||
self
|
||||
end
|
||||
|
||||
def flash
|
||||
tk_call_without_enc(@path, 'flash')
|
||||
self
|
||||
end
|
||||
end
|
|
@ -56,7 +56,9 @@ class Tk::Iwidgets::Radiobox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
|
@ -93,7 +95,9 @@ class Tk::Iwidgets::Radiobox
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
|
||||
|
|
24
ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# tkextlib/iwidgets/buttonbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scopedobject < TkObject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scopedobject
|
||||
TkCommandNames = ['::iwidgets::scopedobject'.freeze].freeze
|
||||
WidgetClassName = 'Scopedobject'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def initialize(obj_name, keys={})
|
||||
@path = tk_call(self.class::TkCommandNames[0], obj_name, *hash_kv(keys))
|
||||
end
|
||||
end
|
315
ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
Normal file
|
@ -0,0 +1,315 @@
|
|||
#
|
||||
# tkextlib/iwidgets/scrolledcanvas.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tk/canvas'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scrolledcanvas < Tk::Iwidgets::Scrolledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scrolledcanvas
|
||||
TkCommandNames = ['::iwidgets::scrolledcanvas'.freeze].freeze
|
||||
WidgetClassName = 'Scrolledcanvas'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
################################
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@canvas = component_widget('canvas')
|
||||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @canvas.methods.include?(id.id2name)
|
||||
@canvas.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
end
|
||||
end
|
||||
|
||||
################################
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def justify(dir)
|
||||
tk_call(@path, 'justify', dir)
|
||||
self
|
||||
end
|
||||
|
||||
##########################
|
||||
include TkCanvasItemConfig
|
||||
|
||||
def tagid(tag)
|
||||
if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
|
||||
tag.id
|
||||
elsif tag.kind_of?(Tk::Itk::Component)
|
||||
tag.name
|
||||
else
|
||||
tag # maybe an Array of configure paramters
|
||||
end
|
||||
end
|
||||
private :tagid
|
||||
|
||||
# create a canvas item without creating a TkcItem object
|
||||
def create(type, *args)
|
||||
type.create(self, *args)
|
||||
end
|
||||
|
||||
#######################
|
||||
|
||||
def addtag(tag, mode, *args)
|
||||
tk_send_without_enc('addtag', tagid(tag), mode, *args)
|
||||
self
|
||||
end
|
||||
def addtag_above(tagOrId, target)
|
||||
addtag(tagOrId, 'above', tagid(target))
|
||||
end
|
||||
def addtag_all(tagOrId)
|
||||
addtag(tagOrId, 'all')
|
||||
end
|
||||
def addtag_below(tagOrId, target)
|
||||
addtag(tagOrId, 'below', tagid(target))
|
||||
end
|
||||
def addtag_closest(tagOrId, x, y, halo=None, start=None)
|
||||
addtag(tagOrId, 'closest', x, y, halo, start)
|
||||
end
|
||||
def addtag_enclosed(tagOrId, x1, y1, x2, y2)
|
||||
addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
|
||||
end
|
||||
def addtag_overlapping(tagOrId, x1, y1, x2, y2)
|
||||
addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
|
||||
end
|
||||
def addtag_withtag(tagOrId, tag)
|
||||
addtag(tagOrId, 'withtag', tagid(tag))
|
||||
end
|
||||
|
||||
def bbox(tagOrId, *tags)
|
||||
list(tk_send_without_enc('bbox', tagid(tagOrId),
|
||||
*tags.collect{|t| tagid(t)}))
|
||||
end
|
||||
|
||||
def itembind(tag, context, cmd=Proc.new, args=nil)
|
||||
_bind([path, "bind", tagid(tag)], context, cmd, args)
|
||||
self
|
||||
end
|
||||
|
||||
def itembind_append(tag, context, cmd=Proc.new, args=nil)
|
||||
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
|
||||
self
|
||||
end
|
||||
|
||||
def itembind_remove(tag, context)
|
||||
_bind_remove([path, "bind", tagid(tag)], context)
|
||||
self
|
||||
end
|
||||
|
||||
def itembindinfo(tag, context=nil)
|
||||
_bindinfo([path, "bind", tagid(tag)], context)
|
||||
end
|
||||
|
||||
def canvasx(screen_x, *args)
|
||||
#tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
|
||||
number(tk_send_without_enc('canvasx', screen_x, *args))
|
||||
end
|
||||
def canvasy(screen_y, *args)
|
||||
#tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
|
||||
number(tk_send_without_enc('canvasy', screen_y, *args))
|
||||
end
|
||||
|
||||
def coords(tag, *args)
|
||||
if args == []
|
||||
tk_split_list(tk_send_without_enc('coords', tagid(tag)))
|
||||
else
|
||||
tk_send_without_enc('coords', tagid(tag), *(args.flatten))
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def dchars(tag, first, last=None)
|
||||
tk_send_without_enc('dchars', tagid(tag),
|
||||
_get_eval_enc_str(first), _get_eval_enc_str(last))
|
||||
self
|
||||
end
|
||||
|
||||
def delete(*args)
|
||||
if TkcItem::CItemID_TBL[self.path]
|
||||
find('withtag', *args).each{|item|
|
||||
TkcItem::CItemID_TBL[self.path].delete(item.id)
|
||||
}
|
||||
end
|
||||
tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
|
||||
self
|
||||
end
|
||||
alias remove delete
|
||||
|
||||
def dtag(tag, tag_to_del=None)
|
||||
tk_send_without_enc('dtag', tagid(tag), tag_to_del)
|
||||
self
|
||||
end
|
||||
|
||||
def find(mode, *args)
|
||||
list(tk_send_without_enc('find', mode, *args)).collect!{|id|
|
||||
TkcItem.id2obj(self, id)
|
||||
}
|
||||
end
|
||||
def find_above(target)
|
||||
find('above', tagid(target))
|
||||
end
|
||||
def find_all
|
||||
find('all')
|
||||
end
|
||||
def find_below(target)
|
||||
find('below', tagid(target))
|
||||
end
|
||||
def find_closest(x, y, halo=None, start=None)
|
||||
find('closest', x, y, halo, start)
|
||||
end
|
||||
def find_enclosed(x1, y1, x2, y2)
|
||||
find('enclosed', x1, y1, x2, y2)
|
||||
end
|
||||
def find_overlapping(x1, y1, x2, y2)
|
||||
find('overlapping', x1, y1, x2, y2)
|
||||
end
|
||||
def find_withtag(tag)
|
||||
find('withtag', tag)
|
||||
end
|
||||
|
||||
def itemfocus(tagOrId=nil)
|
||||
if tagOrId
|
||||
tk_send_without_enc('focus', tagid(tagOrId))
|
||||
self
|
||||
else
|
||||
ret = tk_send_without_enc('focus')
|
||||
if ret == ""
|
||||
nil
|
||||
else
|
||||
TkcItem.id2obj(self, ret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def gettags(tagOrId)
|
||||
list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
|
||||
TkcTag.id2obj(self, tag)
|
||||
}
|
||||
end
|
||||
|
||||
def icursor(tagOrId, index)
|
||||
tk_send_without_enc('icursor', tagid(tagOrId), index)
|
||||
self
|
||||
end
|
||||
|
||||
def index(tagOrId, index)
|
||||
number(tk_send_without_enc('index', tagid(tagOrId), index))
|
||||
end
|
||||
|
||||
def insert(tagOrId, index, string)
|
||||
tk_send_without_enc('insert', tagid(tagOrId), index,
|
||||
_get_eval_enc_str(string))
|
||||
self
|
||||
end
|
||||
|
||||
def lower(tag, below=nil)
|
||||
if below
|
||||
tk_send_without_enc('lower', tagid(tag), tagid(below))
|
||||
else
|
||||
tk_send_without_enc('lower', tagid(tag))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def move(tag, x, y)
|
||||
tk_send_without_enc('move', tagid(tag), x, y)
|
||||
self
|
||||
end
|
||||
|
||||
def postscript(keys)
|
||||
tk_send("postscript", *hash_kv(keys))
|
||||
end
|
||||
|
||||
def raise(tag, above=nil)
|
||||
if above
|
||||
tk_send_without_enc('raise', tagid(tag), tagid(above))
|
||||
else
|
||||
tk_send_without_enc('raise', tagid(tag))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def scale(tag, x, y, xs, ys)
|
||||
tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
|
||||
self
|
||||
end
|
||||
|
||||
def scan_mark(x, y)
|
||||
tk_send_without_enc('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send_without_enc('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
|
||||
def select(mode, *args)
|
||||
r = tk_send_without_enc('select', mode, *args)
|
||||
(mode == 'item')? TkcItem.id2obj(self, r): self
|
||||
end
|
||||
def select_adjust(tagOrId, index)
|
||||
select('adjust', tagid(tagOrId), index)
|
||||
end
|
||||
def select_clear
|
||||
select('clear')
|
||||
end
|
||||
def select_from(tagOrId, index)
|
||||
select('from', tagid(tagOrId), index)
|
||||
end
|
||||
def select_item
|
||||
select('item')
|
||||
end
|
||||
def select_to(tagOrId, index)
|
||||
select('to', tagid(tagOrId), index)
|
||||
end
|
||||
|
||||
def itemtype(tag)
|
||||
TkcItem.type2class(tk_send('type', tagid(tag)))
|
||||
end
|
||||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
|
||||
def yview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('yview'))
|
||||
else
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def yview_moveto(*index)
|
||||
yview('moveto', *index)
|
||||
end
|
||||
def yview_scroll(*index)
|
||||
yview('scroll', *index)
|
||||
end
|
||||
end
|
59
ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
#
|
||||
# tkextlib/iwidgets/scrolledframe.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scrolledframe < Tk::Iwidgets::Scrolledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scrolledframe
|
||||
TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze
|
||||
WidgetClassName = 'Scrolledframe'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def justify(dir)
|
||||
tk_call(@path, 'justify', dir)
|
||||
self
|
||||
end
|
||||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
|
||||
def yview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('yview'))
|
||||
else
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def yview_moveto(*index)
|
||||
yview('moveto', *index)
|
||||
end
|
||||
def yview_scroll(*index)
|
||||
yview('scroll', *index)
|
||||
end
|
||||
end
|
43
ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# tkextlib/iwidgets/scrolledhtml.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scrolledhtml < Tk::Iwidgets::Scrolledtext
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scrolledhtml
|
||||
TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze
|
||||
WidgetClassName = 'Scrolledhtml'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def import(href)
|
||||
tk_call(@path, 'import', href)
|
||||
self
|
||||
end
|
||||
|
||||
def import_link(href)
|
||||
tk_call(@path, 'import', '-link', href)
|
||||
self
|
||||
end
|
||||
|
||||
def pwd
|
||||
tk_call(@path, 'pwd')
|
||||
end
|
||||
|
||||
def render(htmltext, workdir=None)
|
||||
tk_call(@path, 'render', htmltext, workdir)
|
||||
self
|
||||
end
|
||||
|
||||
def title
|
||||
tk_call(@path, 'title')
|
||||
end
|
||||
end
|
190
ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
Normal file
|
@ -0,0 +1,190 @@
|
|||
#
|
||||
# tkextlib/iwidgets/scrolledlistbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tk/listbox'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scrolledlistbox
|
||||
TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze
|
||||
WidgetClassName = 'Scrolledlistbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
################################
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@listbox = component_widget('listbox')
|
||||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @listbox.methods.include?(id.id2name)
|
||||
@listbox.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
end
|
||||
end
|
||||
|
||||
################################
|
||||
|
||||
def clear
|
||||
tk_call(@path, 'clear')
|
||||
self
|
||||
end
|
||||
|
||||
def get_curselection
|
||||
tk_call(@path, 'getcurselection')
|
||||
end
|
||||
|
||||
def justify(dir)
|
||||
tk_call(@path, 'justify', dir)
|
||||
self
|
||||
end
|
||||
|
||||
def selected_item_count
|
||||
number(tk_call(@path, 'selecteditemcount'))
|
||||
end
|
||||
|
||||
def sort(*params, &b)
|
||||
# see 'lsort' man page about params
|
||||
if b
|
||||
tk_call(@path, 'sort', '-command', proc(&b), *params)
|
||||
else
|
||||
tk_call(@path, 'sort', *params)
|
||||
end
|
||||
self
|
||||
end
|
||||
def sort_ascending
|
||||
tk_call(@path, 'sort', 'ascending')
|
||||
self
|
||||
end
|
||||
def sort_descending
|
||||
tk_call(@path, 'sort', 'descending')
|
||||
self
|
||||
end
|
||||
|
||||
#####################################
|
||||
|
||||
def bbox(index)
|
||||
list(tk_send_without_enc('bbox', index))
|
||||
end
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
def get(*index)
|
||||
_fromUTF8(tk_send_without_enc('get', *index))
|
||||
end
|
||||
def insert(index, *args)
|
||||
tk_send('insert', index, *args)
|
||||
self
|
||||
end
|
||||
def scan_mark(x, y)
|
||||
tk_send_without_enc('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send_without_enc('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
def see(index)
|
||||
tk_send_without_enc('see', index)
|
||||
self
|
||||
end
|
||||
|
||||
#####################################
|
||||
|
||||
include TkListItemConfig
|
||||
|
||||
def tagid(tag)
|
||||
if tag.kind_of?(Tk::Itk::Component)
|
||||
tag.name
|
||||
else
|
||||
super(tag)
|
||||
end
|
||||
end
|
||||
private :tagid
|
||||
|
||||
#####################################
|
||||
|
||||
def activate(y)
|
||||
tk_send_without_enc('activate', y)
|
||||
self
|
||||
end
|
||||
def curselection
|
||||
list(tk_send_without_enc('curselection'))
|
||||
end
|
||||
def get(first, last=nil)
|
||||
if last
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
|
||||
else
|
||||
_fromUTF8(tk_send_without_enc('get', first))
|
||||
end
|
||||
end
|
||||
def nearest(y)
|
||||
tk_send_without_enc('nearest', y).to_i
|
||||
end
|
||||
def size
|
||||
tk_send_without_enc('size').to_i
|
||||
end
|
||||
def selection_anchor(index)
|
||||
tk_send_without_enc('selection', 'anchor', index)
|
||||
self
|
||||
end
|
||||
def selection_clear(first, last=None)
|
||||
tk_send_without_enc('selection', 'clear', first, last)
|
||||
self
|
||||
end
|
||||
def selection_includes(index)
|
||||
bool(tk_send_without_enc('selection', 'includes', index))
|
||||
end
|
||||
def selection_set(first, last=None)
|
||||
tk_send_without_enc('selection', 'set', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def index(index)
|
||||
tk_send_without_enc('index', index).to_i
|
||||
end
|
||||
|
||||
#####################################
|
||||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
|
||||
def yview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('yview'))
|
||||
else
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def yview_moveto(*index)
|
||||
yview('moveto', *index)
|
||||
end
|
||||
def yview_scroll(*index)
|
||||
yview('scroll', *index)
|
||||
end
|
||||
end
|
518
ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
Normal file
|
@ -0,0 +1,518 @@
|
|||
#
|
||||
# tkextlib/iwidgets/scrolledtext.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tk/text'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Scrolledtext < Tk::Iwidgets::Scrolledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Scrolledtext
|
||||
TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
|
||||
WidgetClassName = 'Scrolledtext'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
################################
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@text = component_widget('text')
|
||||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @text.methods.include?(id.id2name)
|
||||
@text.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
end
|
||||
end
|
||||
|
||||
################################
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def clear
|
||||
tk_call(@path, 'clear')
|
||||
self
|
||||
end
|
||||
|
||||
def import(file, idx=nil)
|
||||
if idx
|
||||
tk_call(@path, 'import', file, index(idx))
|
||||
else
|
||||
tk_call(@path, 'import', file)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def export(file)
|
||||
tk_call(@path, 'export', file)
|
||||
self
|
||||
end
|
||||
|
||||
#####################################
|
||||
|
||||
include TkTextTagConfig
|
||||
|
||||
def tagid(tag)
|
||||
if tag.kind_of?(Tk::Itk::Component)
|
||||
tag.name
|
||||
else
|
||||
super(tag)
|
||||
end
|
||||
end
|
||||
private :tagid
|
||||
|
||||
def bbox(index)
|
||||
list(tk_send('bbox', index))
|
||||
end
|
||||
def compare(idx1, op, idx2)
|
||||
bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
|
||||
op, _get_eval_enc_str(idx2)))
|
||||
end
|
||||
|
||||
def debug
|
||||
bool(tk_send_without_enc('debug'))
|
||||
end
|
||||
def debug=(boolean)
|
||||
tk_send_without_enc('debug', boolean)
|
||||
#self
|
||||
boolean
|
||||
end
|
||||
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def dlineinfo(index)
|
||||
list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
|
||||
end
|
||||
|
||||
def get(*index)
|
||||
_fromUTF8(tk_send_without_enc('get', *index))
|
||||
end
|
||||
def get_displaychars(*index)
|
||||
# Tk8.5 feature
|
||||
get('-displaychars', *index)
|
||||
end
|
||||
|
||||
def image_cget(index, slot)
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
_get_eval_enc_str(index), "-#{slot}"))
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}")))
|
||||
end
|
||||
end
|
||||
|
||||
def image_configure(index, slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
_fromUTF8(tk_send_without_enc('image', 'configure',
|
||||
_get_eval_enc_str(index),
|
||||
*hash_kv(slot, true)))
|
||||
else
|
||||
_fromUTF8(tk_send_without_enc('image', 'configure',
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}",
|
||||
_get_eval_enc_str(value)))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def image_configinfo(index, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def current_image_configinfo(index, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
conf = image_configinfo(index, slot)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
image_configinfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
image_configinfo(index, slot).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def image_names
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
|
||||
tagid2obj(elt)
|
||||
}
|
||||
end
|
||||
|
||||
def index(index)
|
||||
tk_send_without_enc('index', _get_eval_enc_str(index))
|
||||
end
|
||||
|
||||
def insert(index, *args)
|
||||
tk_send('insert', index, *args)
|
||||
self
|
||||
end
|
||||
|
||||
def mark_names
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
|
||||
tagid2obj(elt)
|
||||
}
|
||||
end
|
||||
|
||||
def mark_gravity(mark, direction=nil)
|
||||
if direction
|
||||
tk_send_without_enc('mark', 'gravity',
|
||||
_get_eval_enc_str(mark), direction)
|
||||
self
|
||||
else
|
||||
tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
|
||||
end
|
||||
end
|
||||
|
||||
def mark_set(mark, index)
|
||||
tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
|
||||
_get_eval_enc_str(index))
|
||||
self
|
||||
end
|
||||
alias set_mark mark_set
|
||||
|
||||
def mark_unset(*marks)
|
||||
tk_send_without_enc('mark', 'unset',
|
||||
*(marks.collect{|mark| _get_eval_enc_str(mark)}))
|
||||
self
|
||||
end
|
||||
alias unset_mark mark_unset
|
||||
|
||||
def mark_next(index)
|
||||
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
|
||||
_get_eval_enc_str(index))))
|
||||
end
|
||||
alias next_mark mark_next
|
||||
|
||||
def mark_previous(index)
|
||||
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
|
||||
_get_eval_enc_str(index))))
|
||||
end
|
||||
alias previous_mark mark_previous
|
||||
|
||||
def scan_mark(x, y)
|
||||
tk_send_without_enc('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send_without_enc('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def _ktext_length(txt)
|
||||
if $KCODE !~ /n/i
|
||||
return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
|
||||
end
|
||||
|
||||
# $KCODE == 'NONE'
|
||||
if JAPANIZED_TK
|
||||
tk_call_without_enc('kstring', 'length',
|
||||
_get_eval_enc_str(txt)).to_i
|
||||
else
|
||||
begin
|
||||
tk_call_without_enc('encoding', 'convertto', 'ascii',
|
||||
_get_eval_enc_str(txt)).length
|
||||
rescue StandardError, NameError
|
||||
# sorry, I have no plan
|
||||
txt.length
|
||||
end
|
||||
end
|
||||
end
|
||||
private :_ktext_length
|
||||
|
||||
def tksearch(*args)
|
||||
# call 'search' subcommand of text widget
|
||||
# args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
|
||||
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
||||
if args[0].kind_of?(Array)
|
||||
opts = args.shift.collect{|opt| '-' + opt.to_s }
|
||||
else
|
||||
opts = []
|
||||
end
|
||||
|
||||
opts << '--'
|
||||
|
||||
ret = tk_send('search', *(opts + args))
|
||||
if ret == ""
|
||||
nil
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def tksearch_with_count(*args)
|
||||
# call 'search' subcommand of text widget
|
||||
# args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
|
||||
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
||||
if args[0].kind_of?(Array)
|
||||
opts = args.shift.collect{|opt| '-' + opt.to_s }
|
||||
else
|
||||
opts = []
|
||||
end
|
||||
|
||||
opts << '-count' << args.shift << '--'
|
||||
|
||||
ret = tk_send('search', *(opts + args))
|
||||
if ret == ""
|
||||
nil
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def search_with_length(pat,start,stop=None)
|
||||
pat = pat.chr if pat.kind_of? Integer
|
||||
if stop != None
|
||||
return ["", 0] if compare(start,'>=',stop)
|
||||
txt = get(start,stop)
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
else
|
||||
txt = get(start,'end - 1 char')
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def search(pat,start,stop=None)
|
||||
search_with_length(pat,start,stop)[0]
|
||||
end
|
||||
|
||||
def rsearch_with_length(pat,start,stop=None)
|
||||
pat = pat.chr if pat.kind_of? Integer
|
||||
if stop != None
|
||||
return ["", 0] if compare(start,'<=',stop)
|
||||
txt = get(stop,start)
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(stop + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(stop + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
else
|
||||
txt = get('1.0',start)
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def rsearch(pat,start,stop=None)
|
||||
rsearch_with_length(pat,start,stop)[0]
|
||||
end
|
||||
|
||||
def see(index)
|
||||
tk_send_without_enc('see', index)
|
||||
self
|
||||
end
|
||||
|
||||
###############################
|
||||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
|
||||
def yview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('yview'))
|
||||
else
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def yview_moveto(*index)
|
||||
yview('moveto', *index)
|
||||
end
|
||||
def yview_scroll(*index)
|
||||
yview('scroll', *index)
|
||||
end
|
||||
end
|
92
ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
Normal file
|
@ -0,0 +1,92 @@
|
|||
#
|
||||
# tkextlib/iwidgets/selectionbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Selectionbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Selectionbox
|
||||
TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze
|
||||
WidgetClassName = 'Selectionbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def clear_items
|
||||
tk_call(@path, 'clear', 'items')
|
||||
self
|
||||
end
|
||||
|
||||
def clear_selection
|
||||
tk_call(@path, 'clear', 'selection')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
|
||||
def insert_items(idx, *args)
|
||||
tk_call(@path, 'insert', 'items', idx, *args)
|
||||
end
|
||||
|
||||
def insert_selection(pos, text)
|
||||
tk_call(@path, 'insert', 'selection', pos, text)
|
||||
end
|
||||
|
||||
def select_item
|
||||
tk_call(@path, 'selectitem')
|
||||
self
|
||||
end
|
||||
|
||||
# based on TkListbox ( and TkTextWin )
|
||||
def curselection
|
||||
list(tk_send_without_enc('curselection'))
|
||||
end
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
def index(index)
|
||||
tk_send_without_enc('index', index).to_i
|
||||
end
|
||||
def nearest(y)
|
||||
tk_send_without_enc('nearest', y).to_i
|
||||
end
|
||||
def scan_mark(x, y)
|
||||
tk_send_without_enc('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send_without_enc('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
def selection_anchor(index)
|
||||
tk_send_without_enc('selection', 'anchor', index)
|
||||
self
|
||||
end
|
||||
def selection_clear(first, last=None)
|
||||
tk_send_without_enc('selection', 'clear', first, last)
|
||||
self
|
||||
end
|
||||
def selection_includes(index)
|
||||
bool(tk_send_without_enc('selection', 'includes', index))
|
||||
end
|
||||
def selection_set(first, last=None)
|
||||
tk_send_without_enc('selection', 'set', first, last)
|
||||
self
|
||||
end
|
||||
def size
|
||||
tk_send_without_enc('size').to_i
|
||||
end
|
||||
end
|
92
ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
Normal file
|
@ -0,0 +1,92 @@
|
|||
#
|
||||
# tkextlib/iwidgets/selectiondialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Selectiondialog < Tk::Iwidgets::Dialog
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Selectiondialog
|
||||
TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze
|
||||
WidgetClassName = 'Selectiondialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def clear_items
|
||||
tk_call(@path, 'clear', 'items')
|
||||
self
|
||||
end
|
||||
|
||||
def clear_selection
|
||||
tk_call(@path, 'clear', 'selection')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
|
||||
def insert_items(idx, *args)
|
||||
tk_call(@path, 'insert', 'items', idx, *args)
|
||||
end
|
||||
|
||||
def insert_selection(pos, text)
|
||||
tk_call(@path, 'insert', 'selection', pos, text)
|
||||
end
|
||||
|
||||
def select_item
|
||||
tk_call(@path, 'selectitem')
|
||||
self
|
||||
end
|
||||
|
||||
# based on TkListbox ( and TkTextWin )
|
||||
def curselection
|
||||
list(tk_send_without_enc('curselection'))
|
||||
end
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
def index(index)
|
||||
tk_send_without_enc('index', index).to_i
|
||||
end
|
||||
def nearest(y)
|
||||
tk_send_without_enc('nearest', y).to_i
|
||||
end
|
||||
def scan_mark(x, y)
|
||||
tk_send_without_enc('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send_without_enc('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
def selection_anchor(index)
|
||||
tk_send_without_enc('selection', 'anchor', index)
|
||||
self
|
||||
end
|
||||
def selection_clear(first, last=None)
|
||||
tk_send_without_enc('selection', 'clear', first, last)
|
||||
self
|
||||
end
|
||||
def selection_includes(index)
|
||||
bool(tk_send_without_enc('selection', 'includes', index))
|
||||
end
|
||||
def selection_set(first, last=None)
|
||||
tk_send_without_enc('selection', 'set', first, last)
|
||||
self
|
||||
end
|
||||
def size
|
||||
tk_send_without_enc('size').to_i
|
||||
end
|
||||
end
|
38
ext/tk/lib/tkextlib/iwidgets/spindate.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# tkextlib/iwidgets/spindate.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Spindate < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Spindate
|
||||
TkCommandNames = ['::iwidgets::spindate'.freeze].freeze
|
||||
WidgetClassName = 'Spindate'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def get_string
|
||||
tk_call(@path, 'get', '-string')
|
||||
end
|
||||
alias get get_string
|
||||
|
||||
def get_clicks
|
||||
number(tk_call(@path, 'get', '-clicks'))
|
||||
end
|
||||
|
||||
def show(date=None)
|
||||
tk_call(@path, 'show', date)
|
||||
self
|
||||
end
|
||||
def show_now
|
||||
tk_call(@path, 'show', 'now')
|
||||
self
|
||||
end
|
||||
end
|
20
ext/tk/lib/tkextlib/iwidgets/spinint.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# tkextlib/iwidgets/spinint.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Spinint < Tk::Iwidgets::Spinner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Spinint
|
||||
TkCommandNames = ['::iwidgets::spinint'.freeze].freeze
|
||||
WidgetClassName = 'Spinint'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
end
|
150
ext/tk/lib/tkextlib/iwidgets/spinner.rb
Normal file
|
@ -0,0 +1,150 @@
|
|||
#
|
||||
# tkextlib/iwidgets/spinner.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Spinner < Tk::Iwidgets::Labeledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Spinner
|
||||
TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
|
||||
WidgetClassName = 'Spinner'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include Tk::ValidateConfigure
|
||||
|
||||
class EntryfieldValidate < TkValidateCommand
|
||||
#class CalCmdArgs < TkUtil::CallbackSubst
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?s, :char ],
|
||||
[ ?P, ?s, :post ],
|
||||
[ ?S, ?s, :current ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
PROC_TBL = [
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
['validate', 'invalid']
|
||||
end
|
||||
end
|
||||
|
||||
def __validation_class_list
|
||||
super << EntryfieldValidate
|
||||
end
|
||||
|
||||
Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
|
||||
|
||||
####################################
|
||||
|
||||
def up
|
||||
tk_call_without_enc(@path, 'up')
|
||||
self
|
||||
end
|
||||
|
||||
def down
|
||||
tk_call_without_enc(@path, 'down')
|
||||
self
|
||||
end
|
||||
|
||||
def clear
|
||||
tk_call_without_enc(@path, 'clear')
|
||||
self
|
||||
end
|
||||
|
||||
def delete(first, last=None)
|
||||
tk_send_without_enc('delete', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def value
|
||||
_fromUTF8(tk_send_without_enc('get'))
|
||||
end
|
||||
def value= (val)
|
||||
tk_send_without_enc('delete', 0, 'end')
|
||||
tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
|
||||
val
|
||||
end
|
||||
alias get value
|
||||
alias set value=
|
||||
|
||||
def cursor=(index)
|
||||
tk_send_without_enc('icursor', index)
|
||||
#self
|
||||
index
|
||||
end
|
||||
alias icursor cursor=
|
||||
|
||||
def index(index)
|
||||
number(tk_send_without_enc('index', index))
|
||||
end
|
||||
|
||||
def insert(pos,text)
|
||||
tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
|
||||
self
|
||||
end
|
||||
|
||||
def mark(pos)
|
||||
tk_send_without_enc('scan', 'mark', pos)
|
||||
self
|
||||
end
|
||||
def dragto(pos)
|
||||
tk_send_without_enc('scan', 'dragto', pos)
|
||||
self
|
||||
end
|
||||
def selection_adjust(index)
|
||||
tk_send_without_enc('selection', 'adjust', index)
|
||||
self
|
||||
end
|
||||
def selection_clear
|
||||
tk_send_without_enc('selection', 'clear')
|
||||
self
|
||||
end
|
||||
def selection_from(index)
|
||||
tk_send_without_enc('selection', 'from', index)
|
||||
self
|
||||
end
|
||||
def selection_present()
|
||||
bool(tk_send_without_enc('selection', 'present'))
|
||||
end
|
||||
def selection_range(s, e)
|
||||
tk_send_without_enc('selection', 'range', s, e)
|
||||
self
|
||||
end
|
||||
def selection_to(index)
|
||||
tk_send_without_enc('selection', 'to', index)
|
||||
self
|
||||
end
|
||||
|
||||
# based on tk/scrollable.rb
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
xview('moveto', *index)
|
||||
end
|
||||
def xview_scroll(*index)
|
||||
xview('scroll', *index)
|
||||
end
|
||||
end
|
38
ext/tk/lib/tkextlib/iwidgets/spintime.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# tkextlib/iwidgets/spintime.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Spintime < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Spintime
|
||||
TkCommandNames = ['::iwidgets::spintime'.freeze].freeze
|
||||
WidgetClassName = 'Spintime'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def get_string
|
||||
tk_call(@path, 'get', '-string')
|
||||
end
|
||||
alias get get_string
|
||||
|
||||
def get_clicks
|
||||
number(tk_call(@path, 'get', '-clicks'))
|
||||
end
|
||||
|
||||
def show(date=None)
|
||||
tk_call(@path, 'show', date)
|
||||
self
|
||||
end
|
||||
def show_now
|
||||
tk_call(@path, 'show', 'now')
|
||||
self
|
||||
end
|
||||
end
|
154
ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
Normal file
|
@ -0,0 +1,154 @@
|
|||
#
|
||||
# tkextlib/iwidgets/tabnotebook.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Tabnotebook < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Tabnotebook
|
||||
TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
|
||||
WidgetClassName = 'Tabnotebook'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'tabcget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'tabconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
#_get_eval_string(tagOrId)
|
||||
tagOrId
|
||||
end
|
||||
end
|
||||
|
||||
alias pagecget itemcget
|
||||
alias pageconfigure itemconfigure
|
||||
alias pageconfiginfo itemconfiginfo
|
||||
alias current_pageconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@tabset = self.component_widget('tabset')
|
||||
end
|
||||
|
||||
def add(keys={})
|
||||
window(tk_call(@path, 'add', *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def child_site_list
|
||||
list(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def child_site(idx)
|
||||
window(tk_call(@path, 'childsite', index(idx)))
|
||||
end
|
||||
|
||||
def delete(idx1, idx2=nil)
|
||||
if idx2
|
||||
tk_call(@path, 'delete', index(idx1), index(idx2))
|
||||
else
|
||||
tk_call(@path, 'delete', index(idx1))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
#number(tk_call(@path, 'index', tagid(idx)))
|
||||
@tabset.index(tagid(idx))
|
||||
end
|
||||
|
||||
def insert(idx, keys={})
|
||||
window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def next
|
||||
tk_call(@path, 'next')
|
||||
self
|
||||
end
|
||||
|
||||
def prev
|
||||
tk_call(@path, 'prev')
|
||||
self
|
||||
end
|
||||
|
||||
def select(idx)
|
||||
tk_call(@path, 'select', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def scrollcommand(cmd=Proc.new)
|
||||
configure_cmd 'scrollcommand', cmd
|
||||
self
|
||||
end
|
||||
alias xscrollcommand scrollcommand
|
||||
alias yscrollcommand scrollcommand
|
||||
|
||||
def xscrollbar(bar=nil)
|
||||
if bar
|
||||
@scrollbar = bar
|
||||
@scrollbar.orient 'horizontal'
|
||||
self.scrollcommand {|*arg| @scrollbar.set(*arg)}
|
||||
@scrollbar.command {|*arg| self.xview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@scrollbar
|
||||
end
|
||||
def yscrollbar(bar=nil)
|
||||
if bar
|
||||
@scrollbar = bar
|
||||
@scrollbar.orient 'vertical'
|
||||
self.scrollcommand {|*arg| @scrollbar.set(*arg)}
|
||||
@scrollbar.command {|*arg| self.yview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@scrollbar
|
||||
end
|
||||
alias scrollbar yscrollbar
|
||||
|
||||
def view(*index)
|
||||
if index.size == 0
|
||||
window(tk_send_without_enc('view'))
|
||||
else
|
||||
tk_send_without_enc('view', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
alias xview view
|
||||
alias yview view
|
||||
|
||||
def view_moveto(*index)
|
||||
view('moveto', *index)
|
||||
end
|
||||
alias xview_moveto view_moveto
|
||||
alias yview_moveto view_moveto
|
||||
def view_scroll(*index)
|
||||
view('scroll', *index)
|
||||
end
|
||||
alias xview_scroll view_scroll
|
||||
alias yview_scroll view_scroll
|
||||
end
|
89
ext/tk/lib/tkextlib/iwidgets/tabset.rb
Normal file
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# tkextlib/iwidgets/tabset.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Tabset < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Tabset
|
||||
TkCommandNames = ['::iwidgets::tabset'.freeze].freeze
|
||||
WidgetClassName = 'Tabset'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'tabcget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'tabconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
#_get_eval_string(tagOrId)
|
||||
tagOrId
|
||||
end
|
||||
end
|
||||
|
||||
alias tabcget itemcget
|
||||
alias tabconfigure itemconfigure
|
||||
alias tabconfiginfo itemconfiginfo
|
||||
alias current_tabconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(keys={})
|
||||
window(tk_call(@path, 'add', *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def delete(idx1, idx2=nil)
|
||||
if idx2
|
||||
tk_call(@path, 'delete', index(idx1), index(idx2))
|
||||
else
|
||||
tk_call(@path, 'delete', index(idx1))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
number(tk_call(@path, 'index', tagid(idx)))
|
||||
end
|
||||
|
||||
def insert(idx, keys={})
|
||||
window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
|
||||
end
|
||||
|
||||
def next
|
||||
tk_call(@path, 'next')
|
||||
self
|
||||
end
|
||||
|
||||
def prev
|
||||
tk_call(@path, 'prev')
|
||||
self
|
||||
end
|
||||
|
||||
def select(idx)
|
||||
tk_call(@path, 'select', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
|
@ -22,6 +22,16 @@ class Tk::Iwidgets::Toolbar
|
|||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'itemcget', self.index(id)]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'itemconfigure', self.index(id)]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
|
@ -38,10 +48,12 @@ class Tk::Iwidgets::Toolbar
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))
|
||||
window(tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)))
|
||||
tag
|
||||
end
|
||||
|
||||
|
@ -63,24 +75,13 @@ class Tk::Iwidgets::Toolbar
|
|||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
if tag
|
||||
tag = Tk::Itk::Component.new(self, tagid(tag))
|
||||
else
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys))
|
||||
window(tk_call(@path, 'insert', index(idx), type,
|
||||
tagid(tag), *hash_kv(keys)))
|
||||
tag
|
||||
end
|
||||
|
||||
def invoke(idx=nil)
|
||||
if idx
|
||||
tk_call(@path, 'invoke', index(idx))
|
||||
else
|
||||
tk_call(@path, 'invoke')
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def show(idx)
|
||||
tk_call(@path, 'show', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ rescue => e
|
|||
err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
|
||||
end
|
||||
|
||||
# package:: style
|
||||
# package:: cursor
|
||||
target = 'tkextlib/tcllib/style'
|
||||
begin
|
||||
require target
|
||||
|
@ -40,6 +40,8 @@ end
|
|||
# autoload
|
||||
module Tk
|
||||
module Tcllib
|
||||
TkComm::TkExtlibAutoloadModule.unshift(self)
|
||||
|
||||
# package:: ctext
|
||||
autoload :CText, 'tkextlib/tcllib/ctext'
|
||||
|
||||
|
@ -49,6 +51,7 @@ module Tk
|
|||
|
||||
# package:: ipentry
|
||||
autoload :IP_Entry, 'tkextlib/tcllib/ip_entry'
|
||||
autoload :IPEntry, 'tkextlib/tcllib/ip_entry'
|
||||
|
||||
# package:: Plotchart
|
||||
autoload :Plotchart, 'tkextlib/tcllib/plotchart'
|
||||
|
@ -58,7 +61,6 @@ module Tk
|
|||
end
|
||||
end
|
||||
|
||||
unless err.empty?
|
||||
if $VERBOSE && !err.empty?
|
||||
warn("Warning: some sub-packages are failed to require : " + err)
|
||||
end
|
||||
|
||||
|
|
|
@ -38,12 +38,21 @@ module Tk
|
|||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.not_available
|
||||
fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
|
||||
end
|
||||
|
||||
# TkPackage.require('autoscroll', '1.0')
|
||||
TkPackage.require('autoscroll')
|
||||
def self.autoscroll(win)
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
end
|
||||
|
||||
def self.unautoscroll(win)
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Tk
|
||||
module Scrollable
|
||||
|
@ -51,18 +60,18 @@ module Tk
|
|||
case mode
|
||||
when :x, 'x'
|
||||
if @xscrollbar
|
||||
tk_send_without_enc('::autoscroll::autoscroll', @xscrollbar)
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
when :y, 'y'
|
||||
if @yscrollbar
|
||||
tk_send_without_enc('::autoscroll::autoscroll', @yscrollbar)
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
when nil, :both, 'both'
|
||||
if @xscrollbar
|
||||
tk_send_without_enc('::autoscroll::autoscroll', @xscrollbar)
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
tk_send_without_enc('::autoscroll::autoscroll', @yscrollbar)
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
|
@ -73,18 +82,18 @@ module Tk
|
|||
case mode
|
||||
when :x, 'x'
|
||||
if @xscrollbar
|
||||
tk_send_without_enc('::autoscroll::unautoscroll', @xscrollbar)
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
when :y, 'y'
|
||||
if @yscrollbar
|
||||
tk_send_without_enc('::autoscroll::unautoscroll', @yscrollbar)
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
when nil, :both, 'both'
|
||||
if @xscrollbar
|
||||
tk_send_without_enc('::autoscroll::unautoscroll', @xscrollbar)
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
tk_send_without_enc('::autoscroll::unautoscroll', @yscrollbar)
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
|
@ -98,12 +107,36 @@ class TkScrollbar
|
|||
def autoscroll
|
||||
# Arranges for the already existing scrollbar to be mapped
|
||||
# and unmapped as needed.
|
||||
tk_send_without_enc('::autoscroll::autoscroll', @path)
|
||||
#tk_call_without_enc('::autoscroll::autoscroll', @path)
|
||||
Tk::Tcllib::Autoscroll.autoscroll(self)
|
||||
self
|
||||
end
|
||||
def unautoscroll
|
||||
# Returns the scrollbar to its original static state.
|
||||
tk_send_without_enc('::autoscroll::unautoscroll', @path)
|
||||
#tk_call_without_enc('::autoscroll::unautoscroll', @path)
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(self)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
# TkPackage.require('autoscroll', '1.0')
|
||||
TkPackage.require('autoscroll')
|
||||
|
||||
module Tk
|
||||
module Tcllib
|
||||
class << Autoscroll
|
||||
undef not_available
|
||||
end
|
||||
|
||||
module Autoscroll
|
||||
def self.autoscroll(win)
|
||||
tk_call_without_enc('::autoscroll::autoscroll', win.path)
|
||||
end
|
||||
|
||||
def self.unautoscroll(win)
|
||||
tk_call_without_enc('::autoscroll::unautoscroll', win.path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,19 +9,32 @@
|
|||
require 'tk'
|
||||
require 'tkextlib/tcllib.rb'
|
||||
|
||||
# TkPackage.require('cursor', '0.1')
|
||||
TkPackage.require('cursor')
|
||||
|
||||
module Tk
|
||||
module Tcllib
|
||||
module Cursor
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('ipentry')
|
||||
TkPackage.require('cursor')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def self.not_available
|
||||
fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
|
||||
end
|
||||
|
||||
def self.cursor_display(win=None)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
|
||||
def self.cursor_propagate(win, cursor)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
|
||||
def self.cursor_restore(win, cursor = None)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,20 +42,48 @@ module Tk
|
|||
# Pops up a dialog with a listbox containing all the cursor names.
|
||||
# Selecting a cursor name will display it in that dialog.
|
||||
# This is simply for viewing any available cursors on the platform .
|
||||
tk_call_without_enc('::cursor::display', parent)
|
||||
#tk_call_without_enc('::cursor::display', parent)
|
||||
Tk::Tcllib::Cursor.cursor_display(parent)
|
||||
end
|
||||
end
|
||||
|
||||
class TkWindow
|
||||
def cursor_propagate(cursor)
|
||||
# Sets the cursor for self and all its descendants to cursor.
|
||||
tk_send_without_enc('::cursor::propagate', @path, cursor)
|
||||
#tk_call_without_enc('::cursor::propagate', @path, cursor)
|
||||
Tk::Tcllib::Cursor.cursor_propagate(cursor)
|
||||
end
|
||||
def cursor_restore(cursor = None)
|
||||
# Restore the original or previously set cursor for self and all its
|
||||
# descendants. If cursor is specified, that will be used if on any
|
||||
# widget that did not have a preset cursor (set by a previous call
|
||||
# to TkWindow#cursor_propagate).
|
||||
tk_send_without_enc('::cursor::restore', @path, cursor)
|
||||
#tk_call_without_enc('::cursor::restore', @path, cursor)
|
||||
Tk::Tcllib::Cursor.cursor_restore(cursor)
|
||||
end
|
||||
end
|
||||
|
||||
# TkPackage.require('cursor', '0.1')
|
||||
TkPackage.require('cursor')
|
||||
|
||||
module Tk
|
||||
module Tcllib
|
||||
class << Cursor
|
||||
undef not_available
|
||||
end
|
||||
|
||||
module Cursor
|
||||
def self.cursor_display(win=None)
|
||||
tk_call_without_enc('::cursor::display', win)
|
||||
end
|
||||
|
||||
def self.cursor_propagate(win, cursor)
|
||||
tk_call_without_enc('::cursor::propagate', win.path, cursor)
|
||||
end
|
||||
|
||||
def self.cursor_restore(win, cursor = None)
|
||||
tk_call_without_enc('::cursor::restore', win.path, cursor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,7 @@ module Tk
|
|||
end
|
||||
end
|
||||
end
|
||||
IPEntry = IP_Entry
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -221,7 +221,10 @@ module Tk::Tcllib::Plotchart
|
|||
class XYPlot < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createXYPlot'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createXYPlot'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args) # args := ([parent,] xaxis, yaxis [, keys])
|
||||
# xaxis := Array of [minimum, maximum, stepsize]
|
||||
|
@ -248,12 +251,16 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis))
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
|
||||
end
|
||||
|
||||
def plot(series, x, y)
|
||||
tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), x, y)
|
||||
self
|
||||
|
@ -271,14 +278,20 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
############################
|
||||
class Stripchart < XYPlot
|
||||
TkCommandNames = ['::Plotchart::createStripchart'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createStripchart'.freeze
|
||||
].freeze
|
||||
end
|
||||
|
||||
############################
|
||||
class PolarPlot < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createPolarplot'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createPolarplot'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args) # args := ([parent,] radius_data [, keys])
|
||||
# radius_data := Array of [maximum_radius, stepsize]
|
||||
|
@ -302,12 +315,16 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@radius_data))
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
|
||||
end
|
||||
|
||||
def plot(series, radius, angle)
|
||||
tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
|
||||
radius, angle)
|
||||
|
@ -329,7 +346,10 @@ module Tk::Tcllib::Plotchart
|
|||
class IsometricPlot < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createIsometricPlot'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createIsometricPlot'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args) # args := ([parent,] xaxis, yaxis, [, step] [, keys])
|
||||
# xaxis := Array of [minimum, maximum]
|
||||
|
@ -369,8 +389,8 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis),
|
||||
@stepsize)
|
||||
end
|
||||
|
@ -406,7 +426,10 @@ module Tk::Tcllib::Plotchart
|
|||
class Plot3D < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::create3DPlot'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::create3DPlot'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args) # args := ([parent,] xaxis, yaxis, zaxis [, keys])
|
||||
# xaxis := Array of [minimum, maximum, stepsize]
|
||||
|
@ -436,8 +459,8 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis),
|
||||
array2tk_list(@yaxis),
|
||||
array2tk_list(@zaxis))
|
||||
|
@ -478,7 +501,10 @@ module Tk::Tcllib::Plotchart
|
|||
class Piechart < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createPiechart'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createPiechart'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args) # args := ([parent] [, keys])
|
||||
if args[0].kind_of?(TkCanvas)
|
||||
|
@ -491,8 +517,8 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path)
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -506,7 +532,10 @@ module Tk::Tcllib::Plotchart
|
|||
class Barchart < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createBarchart'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createBarchart'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args)
|
||||
# args := ([parent,] xlabels, ylabels [, series] [, keys])
|
||||
|
@ -549,13 +578,17 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xlabels), array2tk_list(@ylabels),
|
||||
@series_size)
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
|
||||
end
|
||||
|
||||
def plot(series, dat, col=None)
|
||||
tk_call_without_enc(@chart, 'plot', series, dat, col)
|
||||
self
|
||||
|
@ -573,14 +606,20 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
############################
|
||||
class HorizontalBarchart < Barchart
|
||||
TkCommandNames = ['::Plotchart::createHorizontalBarchart'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createHorizontalBarchart'.freeze
|
||||
].freeze
|
||||
end
|
||||
|
||||
############################
|
||||
class Timechart < TkCanvas
|
||||
include ChartMethod
|
||||
|
||||
TkCommandNames = ['::Plotchart::createTimechart'.freeze].freeze
|
||||
TkCommandNames = [
|
||||
'canvas'.freeze,
|
||||
'::Plotchart::createTimechart'.freeze
|
||||
].freeze
|
||||
|
||||
def initialize(*args)
|
||||
# args := ([parent,] time_begin, time_end, items [, keys])
|
||||
|
@ -612,8 +651,8 @@ module Tk::Tcllib::Plotchart
|
|||
end
|
||||
|
||||
def _create_chart
|
||||
p self.class::TkCommandNames[0] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
@time_begin, @time_end, @items)
|
||||
end
|
||||
private :_create_chart
|
||||
|
@ -650,7 +689,7 @@ module Tk::Tcllib::Plotchart
|
|||
@parent = @chart_obj = chart
|
||||
@ppath = @chart_obj.path
|
||||
@path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
|
||||
SeriesID_TBL[@id] = self
|
||||
# SeriesID_TBL[@id] = self
|
||||
SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath]
|
||||
SeriesID_TBL[@ppath][@id] = self
|
||||
Series_ID[1].succ!
|
||||
|
|
|
@ -9,10 +9,7 @@
|
|||
require 'tk'
|
||||
require 'tkextlib/tcllib.rb'
|
||||
|
||||
# TkPackage.require('style', '0.1')
|
||||
TkPackage.require('style')
|
||||
|
||||
module Tk
|
||||
module Tk::Tcllib
|
||||
module Style
|
||||
def self.package_version
|
||||
begin
|
||||
|
@ -22,6 +19,29 @@ module Tk
|
|||
end
|
||||
end
|
||||
|
||||
def self.not_available
|
||||
fail RuntimeError, "'tkextlib/tcllib/style' extension is not available on your current environment."
|
||||
end
|
||||
|
||||
def self.names
|
||||
Tk::Tcllib::Style.not_available
|
||||
end
|
||||
|
||||
def self.use(style)
|
||||
Tk::Tcllib::Style.not_available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TkPackage.require('style', '0.1')
|
||||
TkPackage.require('style')
|
||||
|
||||
module Tk::Tcllib
|
||||
class << Style
|
||||
undef not_available
|
||||
end
|
||||
|
||||
module Style
|
||||
def self.names
|
||||
tk_split_simplelist(tk_call('style::names'))
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ TkPackage.require('tile')
|
|||
# autoload
|
||||
module Tk
|
||||
module Tile
|
||||
TkComm::TkExtlibAutoloadModule.unshift(self)
|
||||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('tile')
|
||||
|
|
14
ext/tk/lib/tkextlib/tktable.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# TkTable 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/tktable/setup.rb'
|
||||
|
||||
# load library
|
||||
require 'tkextlib/tktable/tktable'
|
8
ext/tk/lib/tkextlib/tktable/setup.rb
Normal 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.
|
||||
#
|
796
ext/tk/lib/tkextlib/tktable/tktable.rb
Normal file
|
@ -0,0 +1,796 @@
|
|||
#
|
||||
# tkextlib/tktable/tktable.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tk/validation'
|
||||
|
||||
# call setup script for general 'tkextlib' libraries
|
||||
require 'tkextlib/setup.rb'
|
||||
|
||||
# call setup script
|
||||
require 'tkextlib/tktable/setup.rb'
|
||||
|
||||
# TkPackage.require('Tktable', '2.8')
|
||||
TkPackage.require('Tktable')
|
||||
|
||||
module Tk
|
||||
class TkTable < TkWindow
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Tktable')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
class CellTag < TkObject
|
||||
end
|
||||
|
||||
module ConfigMethod
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Tk::TkTable::ConfigMethod
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id) # id := [ type, tagOrId ]
|
||||
[self.path, id[0], 'cget', id[1]]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id) # id := [ type, tagOrId ]
|
||||
[self.path, id[0], 'configure', id[1]]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def __item_pathname(id)
|
||||
if id.kind_of?(Array)
|
||||
id = tagid(id[1])
|
||||
end
|
||||
[self.path, id].join(';')
|
||||
end
|
||||
private :__item_pathname
|
||||
|
||||
def tag_cget(tagOrId, option)
|
||||
itemcget(['tag', tagid(tagOrId)], option)
|
||||
end
|
||||
def tag_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['tag', tagid(tagOrId)], slot, value)
|
||||
end
|
||||
def tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagid(tagOrId)], slot)
|
||||
end
|
||||
def current_tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagid(tagOrId)], slot)
|
||||
end
|
||||
|
||||
def window_cget(tagOrId, option)
|
||||
itemcget(['window', tagid(tagOrId)], option)
|
||||
end
|
||||
def window_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['window', tagid(tagOrId)], slot, value)
|
||||
end
|
||||
def window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagid(tagOrId)], slot)
|
||||
end
|
||||
def current_window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagid(tagOrId)], slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
#####################################################
|
||||
|
||||
class Tk::TkTable::CellTag
|
||||
include TkTreatTagFont
|
||||
|
||||
CellTagID_TBL = TkCore::INTERP.create_table
|
||||
CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint].freeze
|
||||
|
||||
TkCore::INTERP.init_ip_env{ CellTagID_TBL.clear }
|
||||
|
||||
def self.id2obj(table, id)
|
||||
tpath = table.path
|
||||
return id unless CellTagID_TBL[tpath]
|
||||
CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
|
||||
end
|
||||
|
||||
def initialize(parent, keys=nil)
|
||||
@parent = @t = parent
|
||||
@tpath - parent.path
|
||||
@path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
|
||||
CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
|
||||
CellTagID_TBL[@tpath][@id] = self
|
||||
CellTag_ID[1].succ!
|
||||
configure(keys) if keys
|
||||
end
|
||||
|
||||
def id
|
||||
@id
|
||||
end
|
||||
|
||||
def destroy
|
||||
tk_call(@tpath, 'tag', 'delete', @id)
|
||||
CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
|
||||
self
|
||||
end
|
||||
alias delete destroy
|
||||
|
||||
def exist?
|
||||
@t.tag_exist?(@id)
|
||||
end
|
||||
def include?(idx)
|
||||
@t.tag_include?(@id, idx)
|
||||
end
|
||||
|
||||
def add_cell(*args)
|
||||
@t.tag_cell(@id, *args)
|
||||
end
|
||||
def add_col(*args)
|
||||
@t.tag_col(@id, *args)
|
||||
end
|
||||
def add_row(*args)
|
||||
@t.tag_row(@id, *args)
|
||||
end
|
||||
|
||||
def raise(target=None)
|
||||
@t.tag_raise(@id, target)
|
||||
end
|
||||
def lower(target=None)
|
||||
@t.tag_lower(@id, target)
|
||||
end
|
||||
|
||||
def cget(key)
|
||||
@t.tag_cget(@id, key)
|
||||
end
|
||||
def configure(key, val=None)
|
||||
@t.tag_configure(@id, key, val)
|
||||
end
|
||||
def configinfo(key=nil)
|
||||
@t.tag_configinfo(@id, key)
|
||||
end
|
||||
def current_configinfo(key=nil)
|
||||
@t.current_tag_configinfo(@id, key)
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
|
||||
def self.new(parent, name, keys=nil)
|
||||
if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
|
||||
cell = CellTagID_TBL[parent.path][name]
|
||||
cell.configure(keys) if keys
|
||||
return cell
|
||||
else
|
||||
super(parent, name, keys)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(parent, name, keys=nil)
|
||||
@parent = @t = parent
|
||||
@tpath - parent.path
|
||||
@path = @id = name
|
||||
CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
|
||||
CellTagID_TBL[@tpath][@id] = self
|
||||
configure(keys) if keys
|
||||
end
|
||||
end
|
||||
|
||||
#####################################################
|
||||
|
||||
class Tk::TkTable
|
||||
TkCommandNames = ['table'.freeze].freeze
|
||||
WidgetClassName = 'Table'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
include Scrollable
|
||||
include Tk::TkTable::ConfigMethod
|
||||
include Tk::ValidateConfigure
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
|
||||
end
|
||||
|
||||
#################################
|
||||
|
||||
class BrowseCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?n, :column ],
|
||||
[ ?C, ?s, :index ],
|
||||
[ ?i, ?x, :cursor ],
|
||||
[ ?r, ?n, :row ],
|
||||
[ ?s, ?s, :last_index ],
|
||||
[ ?S, ?s, :new_index ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:number) ],
|
||||
[ ?x, TkComm.method(:num_or_str) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
['browsecommand', 'browsecmd']
|
||||
end
|
||||
end
|
||||
#--------------------------------
|
||||
class CellCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?n, :column ],
|
||||
[ ?C, ?s, :index ],
|
||||
[ ?i, ?m, :rw_mode ],
|
||||
[ ?r, ?n, :row ],
|
||||
[ ?s, ?v, :value ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:number) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
[ ?m, proc{|val| (val == '0')? (:r) : (:w)} ],
|
||||
[ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
|
||||
nil
|
||||
]
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
TkComm._get_eval_string(val)
|
||||
end
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
['command']
|
||||
end
|
||||
end
|
||||
#--------------------------------
|
||||
class SelectionCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?n, :sel_columns ],
|
||||
[ ?C, ?s, :sel_area ],
|
||||
[ ?i, ?n, :total ],
|
||||
[ ?r, ?n, :sel_rows ],
|
||||
[ ?s, ?s, :value ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:number) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
['selectioncommand', 'selcmd']
|
||||
end
|
||||
end
|
||||
#--------------------------------
|
||||
class ValidateCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?n, :column ],
|
||||
[ ?C, ?s, :index ],
|
||||
[ ?i, ?x, :cursor ],
|
||||
[ ?r, ?n, :row ],
|
||||
[ ?s, ?v, :current_value ],
|
||||
[ ?S, ?v, :new_value ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:number) ],
|
||||
[ ?x, TkComm.method(:num_or_str) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
[ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
|
||||
nil
|
||||
]
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
['vcmd', 'validatecommand']
|
||||
end
|
||||
end
|
||||
|
||||
#################################
|
||||
|
||||
def __validation_class_list
|
||||
super <<
|
||||
BrowseCommand << CellCommand << SelectionCommand << ValidateCommand
|
||||
end
|
||||
|
||||
Tk::ValidateConfigure.__def_validcmd(binding, BrowseCommand)
|
||||
Tk::ValidateConfigure.__def_validcmd(binding, CellCommand)
|
||||
Tk::ValidateConfigure.__def_validcmd(binding, SelectionCommand)
|
||||
Tk::ValidateConfigure.__def_validcmd(binding, ValidateCommand)
|
||||
|
||||
#################################
|
||||
|
||||
def activate(idx)
|
||||
tk_send('activate', tagid(idx))
|
||||
end
|
||||
|
||||
def bbox(idx)
|
||||
list(tk_send('bbox', tagid(idx)))
|
||||
end
|
||||
|
||||
def border_mark(x, y)
|
||||
simplelist(tk_send('scan', 'mark', x, y))
|
||||
end
|
||||
def border_mark_row(x, y)
|
||||
tk_send('scan', 'mark', x, y, 'row')
|
||||
end
|
||||
def border_mark_col(x, y)
|
||||
tk_send('scan', 'mark', x, y, 'col')
|
||||
end
|
||||
def border_dragto(x, y)
|
||||
tk_send('scan', 'dragto', x, y)
|
||||
end
|
||||
|
||||
def clear_cache(first=None, last=None)
|
||||
tk_send('clear', 'cache', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
def clear_sizes(first=None, last=None)
|
||||
tk_send('clear', 'sizes', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
def clear_tags(first=None, last=None)
|
||||
tk_send('clear', 'tags', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
def clear_all(first=None, last=None)
|
||||
tk_send('clear', 'all', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
|
||||
def curselection
|
||||
simplelist(tk_send('curselection'))
|
||||
end
|
||||
def curselection=(val)
|
||||
tk_send('curselection', val)
|
||||
val
|
||||
end
|
||||
|
||||
def curvalue
|
||||
tk_tcl2ruby(tk_send('curvalue'), true, false)
|
||||
end
|
||||
def curvalue=(val)
|
||||
tk_send('curvalue', val)
|
||||
val
|
||||
end
|
||||
|
||||
def delete_active(idx1, idx2=None)
|
||||
tk_send('delete', 'active', tagid(idx1), tagid(idx2))
|
||||
self
|
||||
end
|
||||
def delete_cols(*args) # ?switches_array?, index, ?count?
|
||||
params = []
|
||||
if args[0].kind_of?(Array)
|
||||
switches = args.shift
|
||||
switches.each{|k| params << "-#{k}"}
|
||||
end
|
||||
params << '--'
|
||||
params << tagid(args.shift)
|
||||
params.concat(args)
|
||||
tk_send('delete', 'cols', *params)
|
||||
self
|
||||
end
|
||||
def delete_rows(*args) # ?switches_array?, index, ?count?
|
||||
params = []
|
||||
if args[0].kind_of?(Array)
|
||||
switches = args.shift
|
||||
switches.each{|k| params << "-#{k}"}
|
||||
end
|
||||
params << '--'
|
||||
params << tagid(args.shift)
|
||||
params.concat(args)
|
||||
tk_send('delete', 'rows', *params)
|
||||
self
|
||||
end
|
||||
|
||||
def get(idx)
|
||||
tk_tcl2ruby(tk_send('get', tagid(idx)), true, false)
|
||||
end
|
||||
def get_area(idx1, idx2)
|
||||
simplelist(tk_send('get', tagid(idx1), tagid(idx2))).collect{|v|
|
||||
tk_tcl2ruby(v, true, false)
|
||||
}
|
||||
end
|
||||
|
||||
def height_list
|
||||
list(tk_send('height'))
|
||||
end
|
||||
def height(row)
|
||||
number(tk_send('height', row))
|
||||
end
|
||||
def set_height(*pairs)
|
||||
tk_send('height', *(pairs.flatten))
|
||||
self
|
||||
end
|
||||
|
||||
def hidden_list
|
||||
simplelist(tk_send('hidden'))
|
||||
end
|
||||
def hidden?(idx, *args)
|
||||
if args.empty?
|
||||
if (ret = tk_send('hidden', tagid(idx))) == ''
|
||||
false
|
||||
else
|
||||
ret
|
||||
end
|
||||
else
|
||||
bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)})))
|
||||
end
|
||||
end
|
||||
|
||||
def icursor
|
||||
number(tk_send('icursor'))
|
||||
end
|
||||
def icursor_set(idx)
|
||||
number(tk_send('icursor', tagid(idx)))
|
||||
end
|
||||
|
||||
def index(idx)
|
||||
tk_send('index', tagid(idx))
|
||||
end
|
||||
def row_index(idx)
|
||||
number(tk_send('index', tagid(idx), 'row'))
|
||||
end
|
||||
def col_index(idx)
|
||||
number(tk_send('index', tagid(idx), 'col'))
|
||||
end
|
||||
|
||||
def insert_active(idx, val)
|
||||
tk_send('insert', 'active', tagid(idx), val)
|
||||
self
|
||||
end
|
||||
def insert_cols(*args) # ?switches_array?, index, ?count?
|
||||
params = []
|
||||
if args[0].kind_of?(Array)
|
||||
switches = args.shift
|
||||
switches.each{|k| params << "-#{k}"}
|
||||
end
|
||||
params << '--'
|
||||
params.concat(args)
|
||||
params << tagid(args.shift)
|
||||
tk_send('insert', 'cols', *params)
|
||||
self
|
||||
end
|
||||
def insert_rows(*args) # ?switches_array?, index, ?count?
|
||||
params = []
|
||||
if args[0].kind_of?(Array)
|
||||
switches = args.shift
|
||||
switches.each{|k| params << "-#{k}"}
|
||||
end
|
||||
params << '--'
|
||||
params << tagid(args.shift)
|
||||
params.concat(args)
|
||||
tk_send('insert', 'rows', *params)
|
||||
self
|
||||
end
|
||||
|
||||
# def postscript(*args)
|
||||
# tk_send('postscript', *args)
|
||||
# end
|
||||
|
||||
def reread
|
||||
tk_send('reread')
|
||||
self
|
||||
end
|
||||
|
||||
def scan_mark(x, y)
|
||||
tk_send('scan', 'mark', x, y)
|
||||
self
|
||||
end
|
||||
def scan_dragto(x, y)
|
||||
tk_send('scan', 'dragto', x, y)
|
||||
self
|
||||
end
|
||||
|
||||
def see(idx)
|
||||
tk_send('see', tagid(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_anchor(idx)
|
||||
tk_send('selection', 'anchor', tagid(idx))
|
||||
self
|
||||
end
|
||||
def selection_clear(first, last=None)
|
||||
tk_send('selection', 'clear', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
def selection_clear_all
|
||||
selection_clear('all')
|
||||
end
|
||||
def selection_include?(idx)
|
||||
bool(tk_send('selection', 'includes', tagid(idx)))
|
||||
end
|
||||
def selection_set(first, last=None)
|
||||
tk_send('selection', 'set', tagid(first), tagid(last))
|
||||
self
|
||||
end
|
||||
|
||||
def set(*pairs) # idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', *args)
|
||||
self
|
||||
end
|
||||
def set_row(*pairs) # idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', 'row', *args)
|
||||
self
|
||||
end
|
||||
def set_col(*pairs) # idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', 'col', *args)
|
||||
self
|
||||
end
|
||||
=begin
|
||||
def set(*pairs) # idx, val, idx, val, ... OR [idx, val], [idx, val], ...
|
||||
if pairs[0].kind_of?(Array)
|
||||
# [idx, val], [idx, val], ...
|
||||
args = []
|
||||
pairs.each{|idx, val| args << tagid(idx) << val }
|
||||
tk_send('set', *args)
|
||||
else
|
||||
# idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
def set_row(*pairs)
|
||||
if pairs[0].kind_of?(Array)
|
||||
# [idx, val], [idx, val], ...
|
||||
args = []
|
||||
pairs.each{|idx, val| args << tagid(idx) << val }
|
||||
tk_send('set', 'row', *args)
|
||||
else
|
||||
# idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', 'row', *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
def set_col(*pairs)
|
||||
if pairs[0].kind_of?(Array)
|
||||
# [idx, val], [idx, val], ...
|
||||
args = []
|
||||
pairs.each{|idx, val| args << idx << val }
|
||||
tk_send('set', 'col', *args)
|
||||
else
|
||||
# idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
args << pairs[i+1]
|
||||
}
|
||||
tk_send('set', 'col', *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
=end
|
||||
|
||||
def spans
|
||||
simplelist(tk_send('spans')).collect{|inf|
|
||||
lst = simplelist(inf)
|
||||
idx = lst[0]
|
||||
rows, cols = lst[1].split(',').map!{|n| Integer(n)}
|
||||
[idx [rows, cols]]
|
||||
}
|
||||
end
|
||||
alias span_list spans
|
||||
def span(idx)
|
||||
lst = simplelist(tk_send('spans', tagid(idx)))
|
||||
idx = lst[0]
|
||||
rows, cols = lst[1].split(',').map!{|n| Integer(n)}
|
||||
[idx [rows, cols]]
|
||||
end
|
||||
def set_spans(*pairs)
|
||||
# idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
val = pairs[i+1]
|
||||
if val.kind_of?(Array)
|
||||
args << val.join(',')
|
||||
else
|
||||
args << val
|
||||
end
|
||||
}
|
||||
tk_send('spans', *args)
|
||||
self
|
||||
end
|
||||
=begin
|
||||
def set_spans(*pairs)
|
||||
if pairs[0].kind_of?(Array)
|
||||
# [idx, val], [idx, val], ...
|
||||
args = []
|
||||
pairs.each{|idx, val|
|
||||
args << tagid(idx)
|
||||
if val.kind_of?(Array)
|
||||
args << val.join(',')
|
||||
else
|
||||
args << val
|
||||
end
|
||||
}
|
||||
tk_send('spans', *args)
|
||||
else
|
||||
# idx, val, idx, val, ...
|
||||
args = []
|
||||
0.step(pairs.size-1, 2){|i|
|
||||
args << tagid(pairs[i])
|
||||
val = pairs[i+1]
|
||||
if val.kind_of?(Array)
|
||||
args << val.join(',')
|
||||
else
|
||||
args << val
|
||||
end
|
||||
}
|
||||
tk_send('spans', *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
=end
|
||||
|
||||
def tagid(tag)
|
||||
if tag.kind_of?(Tk::TkTable::CellTag)
|
||||
tag.id
|
||||
elsif tag.kind_of?(Array)
|
||||
if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer)
|
||||
# [row, col]
|
||||
tag.join(',')
|
||||
else
|
||||
tag
|
||||
end
|
||||
else
|
||||
tag
|
||||
end
|
||||
end
|
||||
|
||||
def tagid2obj(tagid)
|
||||
if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
|
||||
if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
|
||||
Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
|
||||
else
|
||||
tagid
|
||||
end
|
||||
else
|
||||
tagid
|
||||
end
|
||||
end
|
||||
|
||||
def tag_cell(tag, *cells)
|
||||
tk_send('tag', 'cell', tagid(tag), *(cells.collect{|idx| tagid(idx)}))
|
||||
self
|
||||
end
|
||||
def tag_reset(*cells)
|
||||
tk_send('tag', 'cell', '', *(cells.collect{|idx| tagid(idx)}))
|
||||
self
|
||||
end
|
||||
def tag_col(tag, *cols)
|
||||
tk_send('tag', 'col', tagid(tag), *cols)
|
||||
self
|
||||
end
|
||||
def tag_col_reset(*cols)
|
||||
tk_send('tag', 'col', '', *cols)
|
||||
self
|
||||
end
|
||||
def tag_delete(tag)
|
||||
tk_send('tag', 'delete', tagid(tag))
|
||||
if Tk::TkTable::CellTag::CellTagID_TBL[@path]
|
||||
if tag.kind_of? Tk::TkTable::CellTag
|
||||
Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
|
||||
else
|
||||
Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
|
||||
end
|
||||
end
|
||||
self
|
||||
end
|
||||
def tag_exist?(tag)
|
||||
bool(tk_send('tag', 'exists', tagid(tag)))
|
||||
end
|
||||
def tag_include?(tag, idx)
|
||||
bool(tk_send('tag', 'includes', tagid(tag), tagid(idx)))
|
||||
end
|
||||
def tag_lower(tag, target=None)
|
||||
tk_send('tag', 'lower', tagid(tag), tagid(target))
|
||||
self
|
||||
end
|
||||
def tag_names(pat=None)
|
||||
simplelist(tk_send('tag', 'names', pat)).collect{|tag| tagid2obj(tag)}
|
||||
end
|
||||
def tag_raise(tag, target=None)
|
||||
tk_send('tag', 'raise', tagid(tag), tagid(target))
|
||||
self
|
||||
end
|
||||
def tag_row(tag, *rows)
|
||||
tk_send('tag', 'row', tagid(tag), *rows)
|
||||
self
|
||||
end
|
||||
def tag_row_reset(*rows)
|
||||
tk_send('tag', 'row', '', *rows)
|
||||
self
|
||||
end
|
||||
|
||||
def validate(idx)
|
||||
bool(tk_send('validate', tagid(idx)))
|
||||
end
|
||||
|
||||
def width_list
|
||||
list(tk_send('width'))
|
||||
end
|
||||
def width(row)
|
||||
number(tk_send('width', row))
|
||||
end
|
||||
def set_width(*pairs)
|
||||
tk_send('width', *(pairs.flatten))
|
||||
self
|
||||
end
|
||||
|
||||
def window_delete(*args)
|
||||
tk_send('window', 'delete', *(args.collect{|idx| tagid(idx)}))
|
||||
self
|
||||
end
|
||||
def window_move(from_idx, to_idx)
|
||||
tk_send('window', 'move', tagid(from_idx), tagid(to_idx))
|
||||
self
|
||||
end
|
||||
def window_names(pat=None)
|
||||
simplelist(tk_send('window', 'names', pat))
|
||||
end
|
||||
end
|
|
@ -18,6 +18,8 @@ TkPackage.require('vu')
|
|||
# autoload
|
||||
module Tk
|
||||
module Vu
|
||||
TkComm::TkExtlibAutoloadModule.unshift(self)
|
||||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('vu')
|
||||
|
|
|
@ -39,6 +39,10 @@ class Tk::Vu::Pie < TkWindow
|
|||
WidgetClassName = 'Pie'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Vu::PieSlice::SliceID_TBL.delete(@path)
|
||||
end
|
||||
|
||||
###############################
|
||||
|
||||
include Tk::Vu::PieSliceConfigMethod
|
||||
|
@ -112,7 +116,7 @@ end
|
|||
|
||||
class Tk::Vu::PieSlice
|
||||
SliceID_TBL = TkCore::INTERP.create_table
|
||||
Pie_Slice_ID = ['vu_pie'.freeze, '00000'.taint].freeze
|
||||
Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint].freeze
|
||||
TkCore::INTERP.init_ip_env{ SliceID_TBL.clear }
|
||||
|
||||
def self.id2obj(pie, id)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#########################################################################
|
||||
### The following text is the original file of the Tcl/Tk extension. ###
|
||||
### Icon data files ( those are 'tkIcons', 'tkIcons-sample.kde', and ###
|
||||
### 'tkIcons.kde' ) are refered from the source archive of ICONS ###
|
||||
### 'tkIcons.kde' ) are quoted from the source archive of ICONS ###
|
||||
### extension. As the following document describes, those icon images ###
|
||||
### are not applied the license. ###
|
||||
#########################################################################
|
||||
|
|
|
@ -228,7 +228,7 @@ class ViewIcons
|
|||
name = @icon_name[item]
|
||||
data_width = 60
|
||||
|
||||
cmd = "#{name} = TkPhotoImage.new(:date=><<'EOD')\n"
|
||||
cmd = "#{name} = TkPhotoImage.new(:data=><<'EOD')\n"
|
||||
|
||||
icon_data = Tk::ICONS.query(name, :file=>@library.value, :items=>'d')[0][0]
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
### Original Tcl source files are not include in this directry, ###
|
||||
### because of all of them are rewrited to Ruby files. ###
|
||||
### However, the bitmap data files ('bwidgtet.xbm' and 'x1.xbm') ###
|
||||
### included in this directory are referd from BWidget source ###
|
||||
### included in this directory are quoted from BWidget source ###
|
||||
### archive. So, those bitmaps are under the following license. ###
|
||||
######################################################################
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# basic demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoBasic
|
||||
@@var = TkVariable.new_hash
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# dnd demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoDnD
|
||||
def self.create(nb)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# manager demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoManager
|
||||
@@progress = TkVariable.new(false)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# select demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoSelect
|
||||
@@var = TkVariable.new_hash
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# templdlg demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoDialog
|
||||
@@tmpl = TkVariable.new_hash
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#
|
||||
# templdlg demo --- called from demo.rb
|
||||
#
|
||||
unless Object.const_defined?('DemoVar')
|
||||
fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
|
||||
end
|
||||
|
||||
module DemoTree
|
||||
@@count = 0
|
||||
|
|
42
ext/tk/sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
#######################################################################
|
||||
### The following text is the original 'license.terms' of iwidges ###
|
||||
### extension. ###
|
||||
### Original Tcl source files are not include in this directry, ###
|
||||
### because of all of them are rewrited to Ruby files. ###
|
||||
### However, the image data files in the 'images' directory are ###
|
||||
### quoted from iwidgets source archive. ###
|
||||
#######################################################################
|
||||
|
||||
|
||||
This software is copyrighted by DSC Technologies and private individual
|
||||
contributors. The copyright holder is specifically listed in the header
|
||||
of each file. The following terms apply to all files associated with the
|
||||
software unless explicitly disclaimed in individual files by private
|
||||
contributors.
|
||||
|
||||
Copyright 1997 DSC Technologies Corporation
|
||||
|
||||
Permission to use, copy, modify, distribute and license this software and
|
||||
its documentation for any purpose, and without fee or written agreement
|
||||
with DSC, is hereby granted, provided that the above copyright notice
|
||||
appears in all copies and that both the copyright notice and warranty
|
||||
disclaimer below appear in supporting documentation, and that the names of
|
||||
DSC Technologies Corporation or DSC Communications Corporation not be used
|
||||
in advertising or publicity pertaining to the software without specific,
|
||||
written prior permission.
|
||||
|
||||
DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-INFRINGEMENT.
|
||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND
|
||||
DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
|
||||
ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL DSC BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
RESTRICTED RIGHTS: Use, duplication or disclosure by the government
|
||||
is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
|
||||
of the Rights in Technical Data and Computer Software Clause as DFARS
|
||||
252.227-7013 and FAR 52.227-19.
|
14
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
Normal file
|
@ -0,0 +1,14 @@
|
|||
#define Tool_32_box_width 32
|
||||
#define Tool_32_box_height 32
|
||||
static unsigned char Tool_32_box_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x20, 0x00, 0x00, 0x08,
|
||||
0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
|
||||
0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
|
||||
0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
|
||||
0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
|
||||
0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
|
||||
0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif
Normal file
After Width: | Height: | Size: 249 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
Normal file
After Width: | Height: | Size: 269 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
Normal file
After Width: | Height: | Size: 179 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
Normal file
After Width: | Height: | Size: 396 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif
Normal file
After Width: | Height: | Size: 386 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif
Normal file
After Width: | Height: | Size: 591 B |
14
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
Normal file
|
@ -0,0 +1,14 @@
|
|||
#define lineOp_width 32
|
||||
#define lineOp_height 32
|
||||
static unsigned char lineOp_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
|
||||
0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00,
|
||||
0x80, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
|
||||
0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00,
|
||||
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3c, 0x00,
|
||||
0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01,
|
||||
0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f,
|
||||
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
Normal file
After Width: | Height: | Size: 183 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif
Normal file
After Width: | Height: | Size: 212 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif
Normal file
After Width: | Height: | Size: 258 B |
14
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
Normal file
|
@ -0,0 +1,14 @@
|
|||
#define ovalOp_width 32
|
||||
#define ovalOp_height 32
|
||||
static unsigned char ovalOp_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
|
||||
0x00, 0x1c, 0x70, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02,
|
||||
0x40, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x10,
|
||||
0x10, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20,
|
||||
0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x10,
|
||||
0x10, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04,
|
||||
0x80, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x01, 0x00, 0x1c, 0x70, 0x00,
|
||||
0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
Normal file
After Width: | Height: | Size: 376 B |
|
@ -0,0 +1,14 @@
|
|||
#define dotPencilOp_width 32
|
||||
#define dotPencilOp_height 32
|
||||
static unsigned char dotPencilOp_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x12, 0x00,
|
||||
0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x80, 0x04, 0x00,
|
||||
0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x20, 0x01, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00,
|
||||
0x00, 0x90, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
|
||||
0x00, 0x24, 0x00, 0x18, 0x00, 0x24, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00,
|
||||
0x00, 0x12, 0x00, 0x30, 0x00, 0x0e, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00,
|
||||
0x00, 0x06, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x30, 0xa0, 0x01,
|
||||
0x00, 0x60, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
Normal file
After Width: | Height: | Size: 141 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif
Normal file
After Width: | Height: | Size: 263 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
Normal file
After Width: | Height: | Size: 174 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif
Normal file
After Width: | Height: | Size: 270 B |
BIN
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif
Normal file
After Width: | Height: | Size: 124 B |
14
ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
Normal file
|
@ -0,0 +1,14 @@
|
|||
#define font_edit_width 32
|
||||
#define font_edit_height 32
|
||||
static unsigned char font_edit_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c,
|
||||
0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x80, 0x7b,
|
||||
0x00, 0x00, 0x80, 0x7e, 0x00, 0x00, 0xc0, 0xfd, 0x00, 0x00, 0x60, 0xfb,
|
||||
0x00, 0x00, 0xb0, 0xf7, 0x00, 0x00, 0xd0, 0xef, 0x00, 0x00, 0xf8, 0xdf,
|
||||
0x00, 0x00, 0xd4, 0x7f, 0x00, 0x00, 0xaa, 0x1f, 0x00, 0x00, 0x15, 0x0f,
|
||||
0x00, 0x80, 0x82, 0x06, 0x03, 0x40, 0x01, 0x01, 0x07, 0xa0, 0x80, 0x00,
|
||||
0x0f, 0x10, 0x40, 0x00, 0x1f, 0x08, 0x20, 0x00, 0x3b, 0xe4, 0x1f, 0x00,
|
||||
0x73, 0x1a, 0x00, 0x00, 0xe3, 0x07, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00,
|
||||
0xe3, 0x03, 0x00, 0x00, 0x7b, 0x07, 0x00, 0x00, 0x1f, 0x06, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
|
@ -4,7 +4,7 @@ require 'tkextlib/iwidgets'
|
|||
|
||||
Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb|
|
||||
pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
|
||||
TkTimer.new(500, 20, proc{fb.step}).start(5000)
|
||||
TkTimer.new(500, 20, proc{fb.step}).start(2500)
|
||||
}
|
||||
|
||||
Tk.mainloop
|
||||
|
|
15
ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
mainloop = Thread.new{Tk.mainloop}
|
||||
|
||||
st = Tk::Iwidgets::Scrolledtext.new.pack
|
||||
st.insert('end', "Now is the time for all good men\n")
|
||||
st.insert('end', "to come to the aid of their country")
|
||||
|
||||
fd = Tk::Iwidgets::Finddialog.new(:textwidget=>st)
|
||||
fd.center(st)
|
||||
fd.activate
|
||||
|
||||
mainloop.join
|
14
ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
lf = Tk::Iwidgets::Labeledframe.new(:labeltext=>'Entry Frame', :labelpos=>:n)
|
||||
lf.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10)
|
||||
|
||||
cs = lf.child_site
|
||||
|
||||
Tk::Iwidgets::Entryfield.new(cs, :labeltext=>'Name:').pack(:side=>:top, :fill=>:x)
|
||||
Tk::Iwidgets::Spinint.new(cs, :labeltext=>'Number:').pack(:side=>:top, :fill=>:x)
|
||||
Tk::Iwidgets::Pushbutton.new(cs, :text=>'Details:').pack(:side=>:top, :fill=>:x)
|
||||
|
||||
Tk.mainloop
|
64
ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
mw = Tk::Iwidgets::Mainwindow.new
|
||||
|
||||
mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0,
|
||||
:padx=>8, :pady=>2, :menu=>[
|
||||
[:options, {:tearoff=>false}],
|
||||
|
||||
[:command, 'new', {
|
||||
:label=>'New', :underline=>0,
|
||||
:helpstr=>'Create a new file'
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'open', {
|
||||
:label=>'Open ...', :underline=>0,
|
||||
:helpstr=>'Open an existing file'
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'save', {
|
||||
:label=>'Save', :underline=>0,
|
||||
:helpstr=>'Save the current file'
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'saveas', {
|
||||
:label=>'Save As', :underline=>5,
|
||||
:helpstr=>'Save the file as a different name'
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'print', {
|
||||
:label=>'Print', :underline=>0,
|
||||
:helpstr=>'Print the file'
|
||||
}
|
||||
],
|
||||
|
||||
[:separator, 'sep1'],
|
||||
|
||||
[:command, 'close', {
|
||||
:label=>'Close', :underline=>0,
|
||||
:helpstr=>'Close the file'
|
||||
}
|
||||
],
|
||||
|
||||
[:separator, 'sep2'],
|
||||
|
||||
[:command, 'exit', {
|
||||
:label=>'Exit', :underline=>1,
|
||||
:helpstr=>'Exit this application'
|
||||
}
|
||||
],
|
||||
|
||||
nil
|
||||
])
|
||||
|
||||
Tk::Iwidgets::Scrolledtext.new(mw.child_site).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
mw.activate
|
||||
|
||||
Tk.mainloop
|
124
ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb
Normal file
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
helpvar = TkVariable.new
|
||||
viewmode = TkVariable.new
|
||||
|
||||
menu_spec = [
|
||||
[:menubutton, 'file', {
|
||||
:text=>'File', :menu=>[
|
||||
[:options, {:tearoff=>false}],
|
||||
|
||||
[:command, 'new', {
|
||||
:label=>'New', :helpstr=>'Open new document',
|
||||
:command=>proc{puts 'NEW'}
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'close', {
|
||||
:label=>'Close', :helpstr=>'Close current document',
|
||||
:command=>proc{puts 'CLOSE'}
|
||||
}
|
||||
],
|
||||
|
||||
[:separator, 'sep1'],
|
||||
|
||||
[:command, 'exit', {
|
||||
:label=>'Exit', :helpstr=>'Exit application',
|
||||
:command=>proc{exit}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[:menubutton, 'edit', {
|
||||
:text=>'Edit', :menu=>[
|
||||
[:options, {:tearoff=>false}],
|
||||
|
||||
[:command, 'undo', {
|
||||
:label=>'Undo', :underline=>0,
|
||||
:helpstr=>'Undo last command',
|
||||
:command=>proc{puts 'UNDO'}
|
||||
}
|
||||
],
|
||||
|
||||
[:separator, 'sep2'],
|
||||
|
||||
[:command, 'cut', {
|
||||
:label=>'Cut', :underline=>1,
|
||||
:helpstr=>'Cut selection to clipboard',
|
||||
:command=>proc{puts 'CUT'}
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'copy', {
|
||||
:label=>'Copy', :underline=>1,
|
||||
:helpstr=>'Copy selection to clipboard',
|
||||
:command=>proc{puts 'COPY'}
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'paste', {
|
||||
:label=>'Paste', :underline=>0,
|
||||
:helpstr=>'Paste clipboard contents',
|
||||
:command=>proc{puts 'PASTE'}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[:menubutton, 'options', {
|
||||
:text=>'Options', :menu=>[
|
||||
[:options, {:tearoff=>false, :selectcolor=>'blue'}],
|
||||
|
||||
[:radiobutton, 'byName', {
|
||||
:variable=>viewmode, :value=>'NAME',
|
||||
:label=>'by Name', :helpstr=>'View files by name order',
|
||||
:command=>proc{puts 'NAME'}
|
||||
}
|
||||
],
|
||||
|
||||
[:radiobutton, 'byDate', {
|
||||
:variable=>viewmode, :value=>'DATE',
|
||||
:label=>'by Date', :helpstr=>'View files by date order',
|
||||
:command=>proc{puts 'DATE'}
|
||||
}
|
||||
],
|
||||
|
||||
[:cascade, 'prefs', {
|
||||
:label=>'Preferences', :menu=>[
|
||||
[:command, 'colors', {
|
||||
:label=>'Colors...', :helpstr=>'Change text colors',
|
||||
:command=>proc{puts 'COLORS'}
|
||||
}
|
||||
],
|
||||
|
||||
[:command, 'fonts', {
|
||||
:label=>'Fonts...', :helpstr=>'Change text font',
|
||||
:command=>proc{puts 'COLORS'}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
#mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar,
|
||||
# :menubuttons=>menu_spec)
|
||||
mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar)
|
||||
mb.configure(:menubuttons=>menu_spec)
|
||||
|
||||
fr = TkFrame.new(:width=>300, :height=>300)
|
||||
ef = TkEntry.new(:textvariable=>helpvar)
|
||||
|
||||
mb.pack(:anchor=>:nw, :fill=>:x, :expand=>true)
|
||||
fr.pack(:fill=>:both, :expand=>true)
|
||||
ef.pack(:anchor=>:sw, :fill=>:x, :expand=>true)
|
||||
|
||||
Tk.mainloop
|
44
ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
helpvar = TkVariable.new
|
||||
viewmode = TkVariable.new
|
||||
|
||||
mb = Tk::Iwidgets::Menubar.new
|
||||
mb.menubuttons = [
|
||||
[:menubutton, 'file', {
|
||||
:text=>'File', :menu=>[
|
||||
[:command, 'new', {:label=>'New'}],
|
||||
[:command, 'close', {:label=>'Close'}],
|
||||
[:separator, 'sep1'],
|
||||
[:command, 'quit', {:label=>'Quit'}]
|
||||
]
|
||||
}
|
||||
],
|
||||
[:menubutton, 'edit', {:text=>'Edit'}]
|
||||
]
|
||||
|
||||
mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0)
|
||||
mb.add(:separator, '.edit.sep2')
|
||||
mb.add(:command, '.edit.cut', :label=>'Cut', :underline=>1)
|
||||
mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1)
|
||||
mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0)
|
||||
|
||||
mb.add(:menubutton, '.options', :text=>'Options', :menu=>[
|
||||
[:radiobutton, 'byName', {
|
||||
:variable=>viewmode, :value=>'NAME', :label=>'by Name'}
|
||||
],
|
||||
[:radiobutton, 'byDate', {
|
||||
:variable=>viewmode, :value=>'DATE', :label=>'by Date'}
|
||||
]
|
||||
])
|
||||
|
||||
mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[
|
||||
[:command, 'colors', {:label=>'Colors...'}],
|
||||
[:command, 'fonts', {:label=>'Fonts...'}]
|
||||
])
|
||||
|
||||
mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true)
|
||||
|
||||
Tk.mainloop
|
30
ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
# Create the tabnotebook widget and pack it.
|
||||
nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
|
||||
nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
|
||||
:side=>:left, :padx=>10, :pady=>10)
|
||||
|
||||
# Add two pages to the tabnotebook,
|
||||
# labelled "Page One" and "Page Two"
|
||||
nb.add(:label=>'Page One')
|
||||
nb.add(:label=>'Page Two')
|
||||
|
||||
# Get the child site frames of these two pages.
|
||||
page1CS = nb.child_site(0)
|
||||
page2CS = nb.child_site('Page Two')
|
||||
|
||||
# Create buttons on each page of the tabnotebook.
|
||||
TkButton.new(page1CS, :text=>'Button One').pack
|
||||
TkButton.new(page2CS, :text=>'Button Two').pack
|
||||
|
||||
# Select the first page of the tabnotebook.
|
||||
nb.select(0)
|
||||
|
||||
# Create the scrollbar and associate teh scrollbar
|
||||
# and the notebook together, then pack the scrollbar
|
||||
nb.scrollbar(TkScrollbar.new).pack(:fill=>:y, :expand=>true, :pady=>10)
|
||||
|
||||
Tk.mainloop
|
30
ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets'
|
||||
|
||||
# Create the tabnotebook widget and pack it.
|
||||
nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
|
||||
nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
|
||||
:side=>:top, :padx=>10, :pady=>0)
|
||||
|
||||
# Add two pages to the tabnotebook,
|
||||
# labelled "Page One" and "Page Two"
|
||||
nb.add(:label=>'Page One')
|
||||
nb.add(:label=>'Page Two')
|
||||
|
||||
# Get the child site frames of these two pages.
|
||||
page1CS = nb.child_site(0)
|
||||
page2CS = nb.child_site('Page Two')
|
||||
|
||||
# Create buttons on each page of the tabnotebook.
|
||||
TkButton.new(page1CS, :text=>'Button One').pack
|
||||
TkButton.new(page2CS, :text=>'Button Two').pack
|
||||
|
||||
# Select the first page of the tabnotebook.
|
||||
nb.select(0)
|
||||
|
||||
# Create the scrollbar and associate teh scrollbar
|
||||
# and the notebook together, then pack the scrollbar
|
||||
nb.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10)
|
||||
|
||||
Tk.mainloop
|