summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib/iwidgets
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-15 01:18:57 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-15 01:18:57 +0000
commit1ac70e2f77eefc3662e6561d6d8864bb9ec00f32 (patch)
tree537e86474ae310bdbc357b331a580cd42583a745 /ext/tk/lib/tkextlib/iwidgets
parent6e918be6b182ac121412bdd53c78ec1b54b14593 (diff)
* 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/branches/ruby_1_8@6630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib/iwidgets')
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/buttonbox.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/checkbox.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/dialogshell.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/entryfield.rb6
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/menubar.rb190
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/messagebox.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/notebook.rb163
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/optionmenu.rb87
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/panedwindow.rb127
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/promptdialog.rb131
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/pushbutton.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/radiobox.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scopedobject.rb24
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb315
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb59
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb43
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb190
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb518
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectionbox.rb92
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb92
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spindate.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinint.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinner.rb150
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spintime.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb154
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabset.rb89
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/toolbar.rb37
27 files changed, 2603 insertions, 30 deletions
diff --git a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
index 5ca48ed229..1ff190b9ff 100644
--- a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
@@ -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))
diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
index 5e0fb5e7b6..05d0e1d813 100644
--- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -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))
diff --git a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
index 4736ebab77..88b9a97094 100644
--- a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
@@ -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))
diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
index 6299259b9b..300573bcec 100644
--- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -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)
diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
new file mode 100644
index 0000000000..b4c94ff564
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
index a9d9775c75..608f6f7adb 100644
--- a/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
new file mode 100644
index 0000000000..511ee3dff3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
new file mode 100644
index 0000000000..226163a150
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
new file mode 100644
index 0000000000..a205036239
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
new file mode 100644
index 0000000000..ec18647511
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
new file mode 100644
index 0000000000..25d3633507
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
index dd96089ffa..84c15082d6 100644
--- a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -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))
diff --git a/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
new file mode 100644
index 0000000000..bddef50841
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
new file mode 100644
index 0000000000..c5ed19c1f1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
new file mode 100644
index 0000000000..8b47460357
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
new file mode 100644
index 0000000000..7023d889d1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
new file mode 100644
index 0000000000..9fe23b4edc
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
new file mode 100644
index 0000000000..95d1034f16
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
new file mode 100644
index 0000000000..91ba9248e1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
new file mode 100644
index 0000000000..794da5d61c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/ext/tk/lib/tkextlib/iwidgets/spindate.rb
new file mode 100644
index 0000000000..6099ba77b9
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spindate.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/ext/tk/lib/tkextlib/iwidgets/spinint.rb
new file mode 100644
index 0000000000..071b6ab8f7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spinint.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
new file mode 100644
index 0000000000..f4f0eb46c8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/ext/tk/lib/tkextlib/iwidgets/spintime.rb
new file mode 100644
index 0000000000..c1e1f5e5f1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spintime.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
new file mode 100644
index 0000000000..5321331551
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
new file mode 100644
index 0000000000..1b76916ab7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -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
diff --git a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
index 81239f9b97..fffd5b388c 100644
--- a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
@@ -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