mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/tk/lib : bug fix
* ext/tk/lib/tkextlib/itcl : add [incr Tcl] support * ext/tk/lib/tkextlib/itk : add [incr Tk] support * ext/tk/lib/tkextlib/iwidgets : midway point of [incr Widgets] support * ext/tk/sample/tkextlib/iwidgets : very simple examples of [incr Widgets] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa4878589c
commit
afcfca607e
64 changed files with 2441 additions and 122 deletions
109
ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
Normal file
109
ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
Normal file
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# tkextlib/iwidgets/buttonbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Buttonbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Buttonbox
|
||||
TkCommandNames = ['::iwidgets::buttonbox'.freeze].freeze
|
||||
WidgetClassName = 'Buttonbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'buttoncget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'buttonconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
_get_eval_string(tagOrId)
|
||||
end
|
||||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def default(idx)
|
||||
tk_call(@path, 'default', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def delete(idx)
|
||||
tk_call(@path, 'delete', index(idx))
|
||||
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
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
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 show(idx)
|
||||
tk_call(@path, 'show', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
85
ext/tk/lib/tkextlib/iwidgets/calendar.rb
Normal file
85
ext/tk/lib/tkextlib/iwidgets/calendar.rb
Normal file
|
@ -0,0 +1,85 @@
|
|||
#
|
||||
# tkextlib/iwidgets/calendar.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Calendar < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Calendar
|
||||
TkCommandNames = ['::iwidgets::calendar'.freeze].freeze
|
||||
WidgetClassName = 'Calendar'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include Tk::ValidateConfigure
|
||||
|
||||
class CalendarCommand < TkValidateCommand
|
||||
#class CalCmdArgs < TkUtil::CallbackSubst
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [ [?d, ?s, :date], nil ]
|
||||
PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
def self._config_keys
|
||||
# array of config-option key (string or symbol)
|
||||
['command']
|
||||
end
|
||||
|
||||
#def initialize(cmd = Proc.new, *args)
|
||||
# _initialize_for_cb_class(CalCmdArgs, cmd, *args)
|
||||
#end
|
||||
end
|
||||
|
||||
def __validation_class_list
|
||||
super << CalendarCommand
|
||||
end
|
||||
|
||||
def command(cmd = Proc.new, args = nil)
|
||||
if cmd.kind_of?(CalendarCommand)
|
||||
configure('command', cmd)
|
||||
elsif args
|
||||
configure('command', [cmd, args])
|
||||
else
|
||||
configure('command', cmd)
|
||||
end
|
||||
end
|
||||
|
||||
####################################
|
||||
|
||||
def get_string
|
||||
tk_call(@path, 'get', '-string')
|
||||
end
|
||||
alias get get_string
|
||||
|
||||
def get_clicks
|
||||
number(tk_call(@path, 'get', '-clicks'))
|
||||
end
|
||||
|
||||
def select(date)
|
||||
tk_call(@path, 'select', date)
|
||||
self
|
||||
end
|
||||
|
||||
def show(date)
|
||||
tk_call(@path, 'show', date)
|
||||
self
|
||||
end
|
||||
def show_now
|
||||
tk_call(@path, 'show', 'now')
|
||||
self
|
||||
end
|
||||
end
|
43
ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
Normal file
43
ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# tkextlib/iwidgets/canvasprintbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Canvasprintbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Canvasprintbox
|
||||
TkCommandNames = ['::iwidgets::canvasprintbox'.freeze].freeze
|
||||
WidgetClassName = 'Canvasprintbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def get_output
|
||||
tk_call(@path, 'getoutput')
|
||||
end
|
||||
|
||||
def print
|
||||
bool(tk_call(@path, 'print'))
|
||||
end
|
||||
|
||||
def refresh
|
||||
tk_call(@path, 'refresh')
|
||||
self
|
||||
end
|
||||
|
||||
def set_canvas(win)
|
||||
tk_call(@path, 'setcanvas', win)
|
||||
self
|
||||
end
|
||||
|
||||
def stop
|
||||
tk_call(@path, 'stop')
|
||||
self
|
||||
end
|
||||
end
|
38
ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
Normal file
38
ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# tkextlib/iwidgets/canvasprintdialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Canvasprintdialog < Tk::Iwidgets::Dialog
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Canvasprintdialog
|
||||
TkCommandNames = ['::iwidgets::canvasprintdialog'.freeze].freeze
|
||||
WidgetClassName = 'Canvasprintdialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def get_output
|
||||
tk_call(@path, 'getoutput')
|
||||
end
|
||||
|
||||
def print
|
||||
bool(tk_call(@path, 'print'))
|
||||
end
|
||||
|
||||
def refresh
|
||||
tk_call(@path, 'refresh')
|
||||
self
|
||||
end
|
||||
|
||||
def set_canvas(win)
|
||||
tk_call(@path, 'setcanvas', win)
|
||||
self
|
||||
end
|
||||
end
|
106
ext/tk/lib/tkextlib/iwidgets/checkbox.rb
Normal file
106
ext/tk/lib/tkextlib/iwidgets/checkbox.rb
Normal file
|
@ -0,0 +1,106 @@
|
|||
#
|
||||
# tkextlib/iwidgets/checkbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Checkbox < Tk::Iwidgets::Labeledframe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Checkbox
|
||||
TkCommandNames = ['::iwidgets::checkbox'.freeze].freeze
|
||||
WidgetClassName = 'Checkbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'buttoncget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'buttonconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
_get_eval_string(tagOrId)
|
||||
end
|
||||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def delete(idx)
|
||||
tk_call(@path, 'delete', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def deselect(idx)
|
||||
tk_call(@path, 'deselect', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def flash(idx)
|
||||
tk_call(@path, 'flash', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def get(idx)
|
||||
simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
|
||||
Tk::Itk::Component.id2obj(id)
|
||||
}
|
||||
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
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def select(idx)
|
||||
tk_call(@path, 'select', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
98
ext/tk/lib/tkextlib/iwidgets/combobox.rb
Normal file
98
ext/tk/lib/tkextlib/iwidgets/combobox.rb
Normal file
|
@ -0,0 +1,98 @@
|
|||
#
|
||||
# tkextlib/iwidgets/combobox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Combobox < Tk::Iwidgets::Entryfield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Combobox
|
||||
TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
|
||||
WidgetClassName = 'Combobox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def clear(component=None)
|
||||
tk_call(@path, 'clear', component)
|
||||
self
|
||||
end
|
||||
|
||||
def delete_list(first, last=None)
|
||||
tk_call(@path, 'delete', 'list', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def delete_entry(first, last=None)
|
||||
tk_call(@path, 'delete', 'entry', first, last)
|
||||
self
|
||||
end
|
||||
|
||||
def get_list_contents(index)
|
||||
tk_call(@path, 'get', index)
|
||||
end
|
||||
|
||||
def insert_list(idx, *elems)
|
||||
tk_call(@path, 'insert', 'list', idx, *elems)
|
||||
self
|
||||
end
|
||||
|
||||
def insert_entry(idx, *elems)
|
||||
tk_call(@path, 'insert', 'entry', idx, *elems)
|
||||
self
|
||||
end
|
||||
|
||||
# listbox methods
|
||||
def size
|
||||
tk_send_without_enc('size').to_i
|
||||
end
|
||||
def see(index)
|
||||
tk_send_without_enc('see', index)
|
||||
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
|
||||
|
||||
# scrolledlistbox methods
|
||||
def get_curselection
|
||||
tk_call(@path, 'getcurselection')
|
||||
end
|
||||
def justify(dir)
|
||||
tk_call(@path, 'justify', dir)
|
||||
self
|
||||
end
|
||||
def sort(*params, &b)
|
||||
# see 'lsort' man page about params
|
||||
if b
|
||||
tk_call(@path, 'sort', *params, -'command', proc(&b))
|
||||
else
|
||||
tk_call(@path, 'sort', *params)
|
||||
end
|
||||
self
|
||||
end
|
||||
def sort_ascending
|
||||
tk_call(@path, 'sort', 'ascending')
|
||||
self
|
||||
def sort_descending
|
||||
tk_call(@path, 'sort', 'descending')
|
||||
self
|
||||
end
|
||||
end
|
20
ext/tk/lib/tkextlib/iwidgets/dateentry.rb
Normal file
20
ext/tk/lib/tkextlib/iwidgets/dateentry.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# tkextlib/iwidgets/dateentry.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Dateentry < Tk::Iwidgets::Datefield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Dateentry
|
||||
TkCommandNames = ['::iwidgets::dateentry'.freeze].freeze
|
||||
WidgetClassName = 'Dateentry'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
end
|
42
ext/tk/lib/tkextlib/iwidgets/datefield.rb
Normal file
42
ext/tk/lib/tkextlib/iwidgets/datefield.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# tkextlib/iwidgets/datefield.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Datefield < Tk::Iwidgets::Labeledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Datefield
|
||||
TkCommandNames = ['::iwidgets::datefield'.freeze].freeze
|
||||
WidgetClassName = 'Datefield'.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 valid?
|
||||
bool(tk_call(@path, 'isvalid'))
|
||||
end
|
||||
|
||||
def show(date)
|
||||
tk_call(@path, 'show', date)
|
||||
self
|
||||
end
|
||||
def show_now
|
||||
tk_call(@path, 'show', 'now')
|
||||
self
|
||||
end
|
||||
end
|
20
ext/tk/lib/tkextlib/iwidgets/dialog.rb
Normal file
20
ext/tk/lib/tkextlib/iwidgets/dialog.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# tkextlib/iwidgets/dialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Dialog < Tk::Iwidgets::Dialogshell
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Dialog
|
||||
TkCommandNames = ['::iwidgets::dialog'.freeze].freeze
|
||||
WidgetClassName = 'Dialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
end
|
109
ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
Normal file
109
ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
Normal file
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# tkextlib/iwidgets/dialogshell.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Dialogshell < Tk::Iwidgets::Shell
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Dialogshell
|
||||
TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze
|
||||
WidgetClassName = 'Dialogshell'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
####################################
|
||||
|
||||
include TkItemConfigMethod
|
||||
|
||||
def __item_cget_cmd(id)
|
||||
[self.path, 'buttoncget', id]
|
||||
end
|
||||
private :__item_cget_cmd
|
||||
|
||||
def __item_config_cmd(id)
|
||||
[self.path, 'buttonconfigure', id]
|
||||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
def tagid(tagOrId)
|
||||
if tagOrId.kind_of?(Tk::Itk::Component)
|
||||
tagOrId.name
|
||||
else
|
||||
_get_eval_string(tagOrId)
|
||||
end
|
||||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
def add(tag=nil, keys={})
|
||||
if tag.kind_of?(Hash)
|
||||
keys = tag
|
||||
tag = nil
|
||||
end
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
|
||||
tag
|
||||
end
|
||||
|
||||
def default(idx)
|
||||
tk_call(@path, 'default', index(idx))
|
||||
self
|
||||
end
|
||||
|
||||
def delete(idx)
|
||||
tk_call(@path, 'delete', index(idx))
|
||||
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
|
||||
unless tag
|
||||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
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 show(idx)
|
||||
tk_call(@path, 'show', index(idx))
|
||||
self
|
||||
end
|
||||
end
|
45
ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
Normal file
45
ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# tkextlib/iwidgets/disjointlistbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Disjointlistbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Disjointlistbox
|
||||
TkCommandNames = ['::iwidgets::disjointlistbox'.freeze].freeze
|
||||
WidgetClassName = 'Disjointlistbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def set_lhs(*items)
|
||||
tk_call(@path, 'setlhs', items)
|
||||
self
|
||||
end
|
||||
def set_rhs(*items)
|
||||
tk_call(@path, 'setrhs', items)
|
||||
self
|
||||
end
|
||||
|
||||
def get_lhs
|
||||
simplelist(tk_call(@path, 'getlhs'))
|
||||
end
|
||||
def get_rhs
|
||||
simplelist(tk_call(@path, 'getrhs'))
|
||||
end
|
||||
|
||||
def insert_lhs(*items)
|
||||
tk_call(@path, 'insertlhs', items)
|
||||
self
|
||||
end
|
||||
def insert_rhs(*items)
|
||||
tk_call(@path, 'insertrhs', items)
|
||||
self
|
||||
end
|
||||
end
|
152
ext/tk/lib/tkextlib/iwidgets/entryfield.rb
Normal file
152
ext/tk/lib/tkextlib/iwidgets/entryfield.rb
Normal file
|
@ -0,0 +1,152 @@
|
|||
#
|
||||
# tkextlib/iwidgets/entryfield.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Entryfield < Tk::Iwidgets::Labeledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Entryfield
|
||||
TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze
|
||||
WidgetClassName = 'Entryfield'.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
|
||||
|
||||
def validate(cmd = Proc.new, args = nil)
|
||||
if cmd.kind_of?(ValidateCmd)
|
||||
configure('validate', cmd)
|
||||
elsif args
|
||||
configure('validate', [cmd, args])
|
||||
else
|
||||
configure('validate', cmd)
|
||||
end
|
||||
end
|
||||
|
||||
def invalid(cmd = Proc.new, args = nil)
|
||||
if cmd.kind_of?(ValidateCmd)
|
||||
configure('invalid', cmd)
|
||||
elsif args
|
||||
configure('invalid', [cmd, args])
|
||||
else
|
||||
configure('invalid', cmd)
|
||||
end
|
||||
end
|
||||
|
||||
####################################
|
||||
|
||||
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
|
||||
alias get 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
|
30
ext/tk/lib/tkextlib/iwidgets/extbutton.rb
Normal file
30
ext/tk/lib/tkextlib/iwidgets/extbutton.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# tkextlib/iwidgets/extbutton.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Extbutton < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Extbutton
|
||||
TkCommandNames = ['::iwidgets::extbutton'.freeze].freeze
|
||||
WidgetClassName = 'Extbutton'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def invoke
|
||||
tk_call(@path, 'invoke')
|
||||
self
|
||||
end
|
||||
|
||||
def flash
|
||||
tk_call(@path, 'flash')
|
||||
self
|
||||
end
|
||||
end
|
33
ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
Normal file
33
ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# tkextlib/iwidgets/extfileselectionbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Extfileselectionbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Extfileselectionbox
|
||||
TkCommandNames = ['::iwidgets::extfileselectionbox'.freeze].freeze
|
||||
WidgetClassName = 'Extfileselectionbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def filter
|
||||
tk_call(@path, 'filter')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
end
|
33
ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
Normal file
33
ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# tkextlib/iwidgets/extfileselectiondialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Extfileselectiondialog < Tk::Iwidgets::Dialog
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Extfileselectiondialog
|
||||
TkCommandNames = ['::iwidgets::extfileselectiondialog'.freeze].freeze
|
||||
WidgetClassName = 'Extfileselectiondialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def filter
|
||||
tk_call(@path, 'filter')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
end
|
30
ext/tk/lib/tkextlib/iwidgets/feedback.rb
Normal file
30
ext/tk/lib/tkextlib/iwidgets/feedback.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# tkextlib/iwidgets/feedback.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Feedback < Tk::Iwidgets::Labeledwidget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Feedback
|
||||
TkCommandNames = ['::iwidgets::feedback'.freeze].freeze
|
||||
WidgetClassName = 'Feedback'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def reset
|
||||
tk_call(@path, 'reset')
|
||||
self
|
||||
end
|
||||
|
||||
def step(inc=1)
|
||||
tk_call(@path, 'step', inc)
|
||||
self
|
||||
end
|
||||
end
|
33
ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
Normal file
33
ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# tkextlib/iwidgets/fileselectionbox.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Fileselectionbox < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Fileselectionbox
|
||||
TkCommandNames = ['::iwidgets::fileselectionbox'.freeze].freeze
|
||||
WidgetClassName = 'Fileselectionbox'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def filter
|
||||
tk_call(@path, 'filter')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
end
|
33
ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
Normal file
33
ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# tkextlib/iwidgets/fileselectiondialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Fileselectiondialog < Tk::Iwidgets::Dialog
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Fileselectiondialog
|
||||
TkCommandNames = ['::iwidgets::fileselectiondialog'.freeze].freeze
|
||||
WidgetClassName = 'Fileselectiondialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def filter
|
||||
tk_call(@path, 'filter')
|
||||
self
|
||||
end
|
||||
|
||||
def get
|
||||
tk_call(@path, 'get')
|
||||
end
|
||||
end
|
29
ext/tk/lib/tkextlib/iwidgets/finddialog.rb
Normal file
29
ext/tk/lib/tkextlib/iwidgets/finddialog.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# tkextlib/iwidgets/finddialog.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Finddialog < Tk::Iwidgets::Dialogshell
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Finddialog
|
||||
TkCommandNames = ['::iwidgets::finddialog'.freeze].freeze
|
||||
WidgetClassName = 'Finddialog'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def clear
|
||||
tk_call(@path, 'clear')
|
||||
self
|
||||
end
|
||||
|
||||
def find
|
||||
tk_call(@path, 'find')
|
||||
end
|
||||
end
|
24
ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
Normal file
24
ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# tkextlib/iwidgets/labeledframe.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Labeledframe < Tk::Itk::Archetype
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Labeledframe
|
||||
TkCommandNames = ['::iwidgets::labeledframe'.freeze].freeze
|
||||
WidgetClassName = 'Labeledframe'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
end
|
30
ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
Normal file
30
ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# tkextlib/iwidgets/labeledwidget.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Labeledwidget < Tk::Itk::Widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Labeledwidget
|
||||
extend TkCore
|
||||
|
||||
TkCommandNames = ['::iwidgets::labeledwidget'.freeze].freeze
|
||||
WidgetClassName = 'Labeledwidget'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def self.alignlabels(*wins)
|
||||
tk_call('::iwidgets::Labeledwidget::alignlabels', *wins)
|
||||
end
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
end
|
8
ext/tk/lib/tkextlib/iwidgets/setup.rb
Normal file
8
ext/tk/lib/tkextlib/iwidgets/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.
|
||||
#
|
38
ext/tk/lib/tkextlib/iwidgets/shell.rb
Normal file
38
ext/tk/lib/tkextlib/iwidgets/shell.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# tkextlib/iwidgets/shell.rb
|
||||
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||
#
|
||||
|
||||
require 'tk'
|
||||
require 'tkextlib/iwidgets.rb'
|
||||
|
||||
module Tk
|
||||
module Iwidgets
|
||||
class Shell < Tk::Itk::Toplevel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tk::Iwidgets::Shell
|
||||
TkCommandNames = ['::iwidgets::shell'.freeze].freeze
|
||||
WidgetClassName = 'Shell'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def activate
|
||||
tk_call(@path, 'activate') # may return val of deactibate method
|
||||
end
|
||||
|
||||
def center(win=None)
|
||||
tk_call(@path, 'center', win)
|
||||
self
|
||||
end
|
||||
|
||||
def child_site
|
||||
window(tk_call(@path, 'childsite'))
|
||||
end
|
||||
|
||||
def deactivate(val=None)
|
||||
tk_call(@path, 'deactivate', val)
|
||||
self
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue