tk.rb :
* small bug fix * rename 'no_create' option to 'without_creating' * add TkWindow#pack_in, TkWindow#grid_in, TkWindow#place_in * add TkWindow#bind_class and TkWindow#database_class If defined specific_class (@db_class), bind_class returns @db_class. In other case, bind_class returns TkWinow#class(). It is useful for binding. TkWindow#database_class is defined for querying the option database. It's same to TkWinfo.classname(self). * add TkBindTag.new_by_name and TkDatabaseClass for binding to database class * check varname whether already exsist or not. (TkVarAccess.new) * TkTextWin#bbox returns an array of four numbers * autoload TkDialog2, TkWarning2 * scan event callback arguments and convert to proper type * TkBindTag.new accepts a block ( TkBindTag.new(context){callback} ) * If given taglist, TkWindow#bindtags(taglist) returns taglist * add TkWindow#bindtags=(taglist) * Tk.focue and Tk.focus_lastfor return nil if there is no target widget. * Tk::Wm.client returns the argument string when setting name * TkGrid.columnconfiginfo and rowconfiginfo given a slot return a number. * TkWindow.grid_columnconfiginfo and grid_rowconfiginfo :: ditto * rename and define alias :: TkOption ==> TkOptionDB * define alias :: TkTimer ==> TkAfter * some instance methods change from public to private * some TkComm methods change to module functions (help to treat return values from Tk) * add support for -displayof option to some TkWinfo methods * bind, bind_append and bind_remove :: returns the target of event-binding * add Tk8.4 features * add TkPaneWindow tkdialog.rb: * classes without showing at initialize : TkDialog2, TkWarning2 * add show method to reuse TkDialog object * some instance methods change from public to private * add new features for configuration tktext.rb : * small bug fix * some methods return self * add TkTextMark#+(mod) and TkTextMark#-(mod) (e.g. mark + '3 chars') * add some methods tkcanvas.rb : * small bug fix * some methods return self tkentry.rb : * some methods return self * TkEntry#bbox returns an array of four numbers * scan validatecommand arguments and convert to proper type tkbgerror.rb : * support to define a error handler by user tcltklib.rb : * reported by Ferenc Engard <engard@all.hu> on [ruby-talk:60759] ... and so on git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
151f1241c6
commit
d8b02b5096
@ -93,9 +93,11 @@ class TclTkInterpreter
|
|||||||
# ruby_fmt command format arguments by `format' and call `ruby' command
|
# ruby_fmt command format arguments by `format' and call `ruby' command
|
||||||
# (notice ruby command receives only one argument)
|
# (notice ruby command receives only one argument)
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
@ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; ruby [format $fmt $args] }")
|
@ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt
|
||||||
|
$args\" ; set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }")
|
||||||
else
|
else
|
||||||
@ip._eval("proc ruby_fmt {fmt args} { ruby [format $fmt $args] }")
|
@ip._eval("proc ruby_fmt {fmt args} { set cmd [list ruby [format
|
||||||
|
$fmt $args]] ; uplevel $cmd }")
|
||||||
end
|
end
|
||||||
|
|
||||||
# @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter
|
# @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter
|
||||||
|
@ -8,6 +8,7 @@ lib/tkafter.rb
|
|||||||
lib/tkbgerror.rb
|
lib/tkbgerror.rb
|
||||||
lib/tkcanvas.rb
|
lib/tkcanvas.rb
|
||||||
lib/tkclass.rb
|
lib/tkclass.rb
|
||||||
|
lib/tkconsole.rb
|
||||||
lib/tkdialog.rb
|
lib/tkdialog.rb
|
||||||
lib/tkentry.rb
|
lib/tkentry.rb
|
||||||
lib/tkfont.rb
|
lib/tkfont.rb
|
||||||
|
@ -4,6 +4,7 @@ tkafter.rb handles Tcl after
|
|||||||
tkbgerror.rb Tk error module
|
tkbgerror.rb Tk error module
|
||||||
tkcanvas.rb Tk canvas interface
|
tkcanvas.rb Tk canvas interface
|
||||||
tkclass.rb provides generic names for Tk classes
|
tkclass.rb provides generic names for Tk classes
|
||||||
|
tkconsole.rb console command support
|
||||||
tkdialog.rb Tk dialog class
|
tkdialog.rb Tk dialog class
|
||||||
tkentry.rb Tk entry class
|
tkentry.rb Tk entry class
|
||||||
tkfont.rb Tk font support
|
tkfont.rb Tk font support
|
||||||
|
1214
ext/tk/lib/tk.rb
1214
ext/tk/lib/tk.rb
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,15 @@ class TkAfter
|
|||||||
Tk_CBID = [0]
|
Tk_CBID = [0]
|
||||||
Tk_CBTBL = {}
|
Tk_CBTBL = {}
|
||||||
|
|
||||||
INTERP._invoke("proc", "rb_after", "id", "ruby [format \"TkAfter.callback %%Q!%s!\" $id]")
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
# cannot clear
|
||||||
|
# Tcl interpreter may keep callbacks
|
||||||
|
end
|
||||||
|
|
||||||
|
INTERP._invoke("proc", "rb_after", "id",
|
||||||
|
"ruby [format \"TkAfter.callback %%Q!%s!\" $id]")
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# class methods
|
# class methods
|
||||||
@ -310,3 +318,5 @@ class TkAfter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
TkTimer = TkAfter
|
||||||
|
@ -12,6 +12,16 @@ module TkBgError
|
|||||||
end
|
end
|
||||||
alias tkerror bgerror
|
alias tkerror bgerror
|
||||||
alias show bgerror
|
alias show bgerror
|
||||||
|
|
||||||
module_function :bgerror, :tkerror, :show
|
module_function :bgerror, :tkerror, :show
|
||||||
|
|
||||||
|
def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... }
|
||||||
|
tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg')
|
||||||
|
end
|
||||||
|
def set_default
|
||||||
|
begin
|
||||||
|
tk_call('rename', 'bgerror', '')
|
||||||
|
rescue RuntimeError
|
||||||
|
end
|
||||||
|
end
|
||||||
|
module_function :set_handler, :set_default
|
||||||
end
|
end
|
||||||
|
@ -31,9 +31,6 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
WidgetClassName = 'Canvas'.freeze
|
WidgetClassName = 'Canvas'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
def self.to_eval
|
|
||||||
WidgetClassName
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
@ -54,6 +51,7 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
def addtag(tag, mode, *args)
|
def addtag(tag, mode, *args)
|
||||||
tk_send 'addtag', tagid(tag), mode, *args
|
tk_send 'addtag', tagid(tag), mode, *args
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def addtag_above(tagOrId, target)
|
def addtag_above(tagOrId, target)
|
||||||
addtag(tagOrId, 'above', tagid(target))
|
addtag(tagOrId, 'above', tagid(target))
|
||||||
@ -83,10 +81,17 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
def itembind(tag, context, cmd=Proc.new, args=nil)
|
def itembind(tag, context, cmd=Proc.new, args=nil)
|
||||||
_bind([path, "bind", tagid(tag)], context, cmd, args)
|
_bind([path, "bind", tagid(tag)], context, cmd, args)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def itembind_append(tag, context, cmd=Proc.new, args=nil)
|
def itembind_append(tag, context, cmd=Proc.new, args=nil)
|
||||||
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
|
_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
|
end
|
||||||
|
|
||||||
def itembindinfo(tag, context=nil)
|
def itembindinfo(tag, context=nil)
|
||||||
@ -104,21 +109,24 @@ class TkCanvas<TkWindow
|
|||||||
if args == []
|
if args == []
|
||||||
tk_split_list(tk_send('coords', tagid(tag)))
|
tk_split_list(tk_send('coords', tagid(tag)))
|
||||||
else
|
else
|
||||||
tk_send('coords', tagid(tag), *args)
|
tk_send('coords', tagid(tag), *(args.flatten))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dchars(tag, first, last=None)
|
def dchars(tag, first, last=None)
|
||||||
tk_send 'dchars', tagid(tag), first, last
|
tk_send 'dchars', tagid(tag), first, last
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(*args)
|
def delete(*args)
|
||||||
tk_send 'delete', *args.collect{|t| tagid(t)}
|
tk_send 'delete', *args.collect{|t| tagid(t)}
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias remove delete
|
alias remove delete
|
||||||
|
|
||||||
def dtag(tag, tag_to_del=None)
|
def dtag(tag, tag_to_del=None)
|
||||||
tk_send 'dtag', tagid(tag), tag_to_del
|
tk_send 'dtag', tagid(tag), tag_to_del
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(mode, *args)
|
def find(mode, *args)
|
||||||
@ -151,6 +159,7 @@ class TkCanvas<TkWindow
|
|||||||
def itemfocus(tagOrId=nil)
|
def itemfocus(tagOrId=nil)
|
||||||
if tagOrId
|
if tagOrId
|
||||||
tk_send 'focus', tagid(tagOrId)
|
tk_send 'focus', tagid(tagOrId)
|
||||||
|
self
|
||||||
else
|
else
|
||||||
ret = tk_send('focus')
|
ret = tk_send('focus')
|
||||||
if ret == ""
|
if ret == ""
|
||||||
@ -169,14 +178,16 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
def icursor(tagOrId, index)
|
def icursor(tagOrId, index)
|
||||||
tk_send 'icursor', tagid(tagOrId), index
|
tk_send 'icursor', tagid(tagOrId), index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def index(tagOrId, index)
|
def index(tagOrId, index)
|
||||||
tk_send 'index', tagid(tagOrId), index
|
number(tk_send('index', tagid(tagOrId), index))
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert(tagOrId, index, string)
|
def insert(tagOrId, index, string)
|
||||||
tk_send 'insert', tagid(tagOrId), index, string
|
tk_send 'insert', tagid(tagOrId), index, string
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def itemcget(tagOrId, option)
|
def itemcget(tagOrId, option)
|
||||||
@ -215,6 +226,7 @@ class TkCanvas<TkWindow
|
|||||||
tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
|
tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
# def itemconfigure(tagOrId, key, value=None)
|
# def itemconfigure(tagOrId, key, value=None)
|
||||||
# if key.kind_of? Hash
|
# if key.kind_of? Hash
|
||||||
@ -285,10 +297,12 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
def lower(tag, below=None)
|
def lower(tag, below=None)
|
||||||
tk_send 'lower', tagid(tag), tagid(below)
|
tk_send 'lower', tagid(tag), tagid(below)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def move(tag, x, y)
|
def move(tag, x, y)
|
||||||
tk_send 'move', tagid(tag), x, y
|
tk_send 'move', tagid(tag), x, y
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def postscript(keys)
|
def postscript(keys)
|
||||||
@ -297,21 +311,26 @@ class TkCanvas<TkWindow
|
|||||||
|
|
||||||
def raise(tag, above=None)
|
def raise(tag, above=None)
|
||||||
tk_send 'raise', tagid(tag), tagid(above)
|
tk_send 'raise', tagid(tag), tagid(above)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def scale(tag, x, y, xs, ys)
|
def scale(tag, x, y, xs, ys)
|
||||||
tk_send 'scale', tagid(tag), x, y, xs, ys
|
tk_send 'scale', tagid(tag), x, y, xs, ys
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def scan_mark(x, y)
|
def scan_mark(x, y)
|
||||||
tk_send 'scan', 'mark', x, y
|
tk_send 'scan', 'mark', x, y
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def scan_dragto(x, y)
|
def scan_dragto(x, y)
|
||||||
tk_send 'scan', 'dragto', x, y
|
tk_send 'scan', 'dragto', x, y
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def select(mode, *args)
|
def select(mode, *args)
|
||||||
tk_send 'select', mode, *args
|
r = tk_send('select', mode, *args)
|
||||||
|
(mode == 'item')? TkcItem.id2obj(self, r): self
|
||||||
end
|
end
|
||||||
def select_adjust(tagOrId, index)
|
def select_adjust(tagOrId, index)
|
||||||
select('adjust', tagid(tagOrId), index)
|
select('adjust', tagid(tagOrId), index)
|
||||||
@ -340,6 +359,7 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def addtag(tag)
|
def addtag(tag)
|
||||||
@c.addtag(tag, 'with', @id)
|
@c.addtag(tag, 'with', @id)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def bbox
|
def bbox
|
||||||
@ -348,6 +368,17 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def bind(seq, cmd=Proc.new, args=nil)
|
def bind(seq, cmd=Proc.new, args=nil)
|
||||||
@c.itembind @id, seq, cmd, args
|
@c.itembind @id, seq, cmd, args
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def bind_append(seq, cmd=Proc.new, args=nil)
|
||||||
|
@c.itembind_append @id, seq, cmd, args
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def bind_remove(seq)
|
||||||
|
@c.itembind_remove @id, seq
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def bindinfo(seq=nil)
|
def bindinfo(seq=nil)
|
||||||
@ -360,6 +391,7 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def configure(key, value=None)
|
def configure(key, value=None)
|
||||||
@c.itemconfigure @id, key, value
|
@c.itemconfigure @id, key, value
|
||||||
|
self
|
||||||
end
|
end
|
||||||
# def configure(keys)
|
# def configure(keys)
|
||||||
# @c.itemconfigure @id, keys
|
# @c.itemconfigure @id, keys
|
||||||
@ -375,10 +407,12 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def dchars(first, last=None)
|
def dchars(first, last=None)
|
||||||
@c.dchars @id, first, last
|
@c.dchars @id, first, last
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def dtag(tag_to_del=None)
|
def dtag(tag_to_del=None)
|
||||||
@c.dtag @id, tag_to_del
|
@c.dtag @id, tag_to_del
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def find
|
def find
|
||||||
@ -396,6 +430,7 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def icursor(index)
|
def icursor(index)
|
||||||
@c.icursor @id, index
|
@c.icursor @id, index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def index(index)
|
def index(index)
|
||||||
@ -404,32 +439,40 @@ module TkcTagAccess
|
|||||||
|
|
||||||
def insert(beforethis, string)
|
def insert(beforethis, string)
|
||||||
@c.insert @id, beforethis, string
|
@c.insert @id, beforethis, string
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def lower(belowthis=None)
|
def lower(belowthis=None)
|
||||||
@c.lower @id, belowthis
|
@c.lower @id, belowthis
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def move(xamount, yamount)
|
def move(xamount, yamount)
|
||||||
@c.move @id, xamount, yamount
|
@c.move @id, xamount, yamount
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def raise(abovethis=None)
|
def raise(abovethis=None)
|
||||||
@c.raise @id, abovethis
|
@c.raise @id, abovethis
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def scale(xorigin, yorigin, xscale, yscale)
|
def scale(xorigin, yorigin, xscale, yscale)
|
||||||
@c.scale @id, xorigin, yorigin, xscale, yscale
|
@c.scale @id, xorigin, yorigin, xscale, yscale
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_adjust(index)
|
def select_adjust(index)
|
||||||
@c.select('adjust', @id, index)
|
@c.select('adjust', @id, index)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def select_from(index)
|
def select_from(index)
|
||||||
@c.select('from', @id, index)
|
@c.select('from', @id, index)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def select_to(index)
|
def select_to(index)
|
||||||
@c.select('to', @id, index)
|
@c.select('to', @id, index)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def itemtype
|
def itemtype
|
||||||
@ -478,6 +521,13 @@ class TkcTag<TkObject
|
|||||||
CTagID_TBL = {}
|
CTagID_TBL = {}
|
||||||
Tk_CanvasTag_ID = ['ctag0000']
|
Tk_CanvasTag_ID = ['ctag0000']
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
CTagID_TBL.clear
|
||||||
|
Tk_CanvasTag_ID[0] = 'ctag0000'
|
||||||
|
end
|
||||||
|
|
||||||
def TkcTag.id2obj(canvas, id)
|
def TkcTag.id2obj(canvas, id)
|
||||||
cpath = canvas.path
|
cpath = canvas.path
|
||||||
return id unless CTagID_TBL[cpath]
|
return id unless CTagID_TBL[cpath]
|
||||||
@ -499,48 +549,56 @@ class TkcTag<TkObject
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def id
|
def id
|
||||||
return @id
|
@id
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
@c.delete @id
|
@c.delete @id
|
||||||
CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
|
CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias remove delete
|
alias remove delete
|
||||||
alias destroy delete
|
alias destroy delete
|
||||||
|
|
||||||
def set_to_above(target)
|
def set_to_above(target)
|
||||||
@c.addtag_above(@id, target)
|
@c.addtag_above(@id, target)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias above set_to_above
|
alias above set_to_above
|
||||||
|
|
||||||
def set_to_all
|
def set_to_all
|
||||||
@c.addtag_all(@id)
|
@c.addtag_all(@id)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias all set_to_all
|
alias all set_to_all
|
||||||
|
|
||||||
def set_to_below(target)
|
def set_to_below(target)
|
||||||
@c.addtag_below(@id, target)
|
@c.addtag_below(@id, target)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias below set_to_below
|
alias below set_to_below
|
||||||
|
|
||||||
def set_to_closest(x, y, halo=None, start=None)
|
def set_to_closest(x, y, halo=None, start=None)
|
||||||
@c.addtag_closest(@id, x, y, halo, start)
|
@c.addtag_closest(@id, x, y, halo, start)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias closest set_to_closest
|
alias closest set_to_closest
|
||||||
|
|
||||||
def set_to_enclosed(x1, y1, x2, y2)
|
def set_to_enclosed(x1, y1, x2, y2)
|
||||||
@c.addtag_enclosed(@id, x1, y1, x2, y2)
|
@c.addtag_enclosed(@id, x1, y1, x2, y2)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias enclosed set_to_enclosed
|
alias enclosed set_to_enclosed
|
||||||
|
|
||||||
def set_to_overlapping(x1, y1, x2, y2)
|
def set_to_overlapping(x1, y1, x2, y2)
|
||||||
@c.addtag_overlapping(@id, x1, y1, x2, y2)
|
@c.addtag_overlapping(@id, x1, y1, x2, y2)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias overlapping set_to_overlapping
|
alias overlapping set_to_overlapping
|
||||||
|
|
||||||
def set_to_withtag(target)
|
def set_to_withtag(target)
|
||||||
@c.addtag_withtag(@id, target)
|
@c.addtag_withtag(@id, target)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias withtag set_to_withtag
|
alias withtag set_to_withtag
|
||||||
end
|
end
|
||||||
@ -615,12 +673,14 @@ class TkcGroup<TkcTag
|
|||||||
for i in tags
|
for i in tags
|
||||||
i.addtag @id
|
i.addtag @id
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def exclude(*tags)
|
def exclude(*tags)
|
||||||
for i in tags
|
for i in tags
|
||||||
i.delete @id
|
i.delete @id
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -630,6 +690,12 @@ class TkcItem<TkObject
|
|||||||
CItemTypeToClass = {}
|
CItemTypeToClass = {}
|
||||||
CItemID_TBL = {}
|
CItemID_TBL = {}
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
CItemID_TBL.clear
|
||||||
|
end
|
||||||
|
|
||||||
def TkcItem.type2class(type)
|
def TkcItem.type2class(type)
|
||||||
CItemTypeToClass[type]
|
CItemTypeToClass[type]
|
||||||
end
|
end
|
||||||
@ -683,12 +749,13 @@ class TkcItem<TkObject
|
|||||||
def create_self(*args); end
|
def create_self(*args); end
|
||||||
private :create_self
|
private :create_self
|
||||||
def id
|
def id
|
||||||
return @id
|
@id
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
@c.delete @id
|
@c.delete @id
|
||||||
CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
|
CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias remove delete
|
alias remove delete
|
||||||
alias destroy delete
|
alias destroy delete
|
||||||
@ -753,8 +820,15 @@ class TkImage<TkObject
|
|||||||
include Tk
|
include Tk
|
||||||
|
|
||||||
Tk_IMGTBL = {}
|
Tk_IMGTBL = {}
|
||||||
|
|
||||||
Tk_Image_ID = ['i00000']
|
Tk_Image_ID = ['i00000']
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
Tk_IMGTBL.clear
|
||||||
|
Tk_Image_ID[0] = 'i00000'
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(keys=nil)
|
def initialize(keys=nil)
|
||||||
@path = Tk_Image_ID[0]
|
@path = Tk_Image_ID[0]
|
||||||
Tk_Image_ID[0] = Tk_Image_ID[0].succ
|
Tk_Image_ID[0] = Tk_Image_ID[0].succ
|
||||||
@ -765,6 +839,7 @@ class TkImage<TkObject
|
|||||||
def delete
|
def delete
|
||||||
Tk_IMGTBL.delete(@id) if @id
|
Tk_IMGTBL.delete(@id) if @id
|
||||||
tk_call('image', 'delete', @path)
|
tk_call('image', 'delete', @path)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def height
|
def height
|
||||||
number(tk_call('image', 'height', @path))
|
number(tk_call('image', 'height', @path))
|
||||||
@ -805,6 +880,7 @@ class TkPhotoImage<TkImage
|
|||||||
|
|
||||||
def blank
|
def blank
|
||||||
tk_send 'blank'
|
tk_send 'blank'
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def cget(option)
|
def cget(option)
|
||||||
@ -826,14 +902,16 @@ class TkPhotoImage<TkImage
|
|||||||
}.flatten
|
}.flatten
|
||||||
|
|
||||||
tk_send 'copy', source, *args
|
tk_send 'copy', source, *args
|
||||||
|
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def data(keys=nil)
|
def data(keys=nil)
|
||||||
tk_send 'data', *hash_kv(keys)
|
tk_send('data', *hash_kv(keys))
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(x, y)
|
def get(x, y)
|
||||||
tk_send 'get', x, y
|
tk_send('get', x, y).split.collect{|n| n.to_i}
|
||||||
end
|
end
|
||||||
|
|
||||||
def put(data, *to)
|
def put(data, *to)
|
||||||
@ -842,6 +920,7 @@ class TkPhotoImage<TkImage
|
|||||||
else
|
else
|
||||||
tk_send 'put', data, '-to', *to
|
tk_send 'put', data, '-to', *to
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(file, *opts)
|
def read(file, *opts)
|
||||||
@ -854,10 +933,21 @@ class TkPhotoImage<TkImage
|
|||||||
}.flatten
|
}.flatten
|
||||||
|
|
||||||
tk_send 'read', file, *args
|
tk_send 'read', file, *args
|
||||||
|
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def redither
|
def redither
|
||||||
tk_send 'redither'
|
tk_send 'redither'
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_transparency(x, y)
|
||||||
|
bool(tk_send('transparency', 'get', x, y))
|
||||||
|
end
|
||||||
|
def set_transparency(x, y, st)
|
||||||
|
tk_send('transparency', 'set', x, y, st)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(file, *opts)
|
def write(file, *opts)
|
||||||
@ -870,5 +960,7 @@ class TkPhotoImage<TkImage
|
|||||||
}.flatten
|
}.flatten
|
||||||
|
|
||||||
tk_send 'write', file, *args
|
tk_send 'write', file, *args
|
||||||
|
|
||||||
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
26
ext/tk/lib/tkconsole.rb
Normal file
26
ext/tk/lib/tkconsole.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# tkconsole.rb : control the console on system without a real console
|
||||||
|
#
|
||||||
|
require 'tk'
|
||||||
|
|
||||||
|
module TkConsole
|
||||||
|
include Tk
|
||||||
|
extend Tk
|
||||||
|
|
||||||
|
def self.title(str=None)
|
||||||
|
tk_call 'console', str
|
||||||
|
end
|
||||||
|
def self.hide
|
||||||
|
tk_call 'console', 'hide'
|
||||||
|
end
|
||||||
|
def self.show
|
||||||
|
tk_call 'console', 'show'
|
||||||
|
end
|
||||||
|
def self.eval(tcl_script)
|
||||||
|
#
|
||||||
|
# supports a Tcl script only
|
||||||
|
# I have no idea to support a Ruby script seamlessly.
|
||||||
|
#
|
||||||
|
tk_call 'console', 'eval', tcl_script
|
||||||
|
end
|
||||||
|
end
|
@ -1,13 +1,55 @@
|
|||||||
require "tk"
|
require "tk"
|
||||||
|
|
||||||
class TkDialog < TkWindow
|
class TkDialog2 < TkWindow
|
||||||
extend Tk
|
extend Tk
|
||||||
|
|
||||||
|
def self.show(*args)
|
||||||
|
dlog = self.new(*args)
|
||||||
|
dlog.show
|
||||||
|
dlog
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set_button_config(configs)
|
||||||
|
set_config = proc{|c,i|
|
||||||
|
if $VERBOSE && (c.has_key?('command') || c.has_key?(:command))
|
||||||
|
STDERR.print("Warning: cannot give a command option " +
|
||||||
|
"to the dialog button#{i}. It was removed.\n")
|
||||||
|
end
|
||||||
|
c.delete('command'); c.delete(:command)
|
||||||
|
@config << format("%s.button%s configure %s; ",
|
||||||
|
@path, i, hash_kv(c).join(' '))
|
||||||
|
}
|
||||||
|
case configs
|
||||||
|
when Proc
|
||||||
|
@buttons.each_index{|i|
|
||||||
|
if (c = configs.call(i)).kind_of? Hash
|
||||||
|
set_config.call(c,i)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
when Array
|
||||||
|
@buttons.each_index{|i|
|
||||||
|
if (c = configs[i]).kind_of? Hash
|
||||||
|
set_config.call(c,i)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
when Hash
|
||||||
|
@buttons.each_with_index{|s,i|
|
||||||
|
if (c = configs[s]).kind_of? Hash
|
||||||
|
set_config.call(c,i)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
@config = 'after idle {' + @config + '};' if @config != ""
|
||||||
|
end
|
||||||
|
private :_set_button_config
|
||||||
|
|
||||||
# initialize tk_dialog
|
# initialize tk_dialog
|
||||||
def initialize(keys = nil)
|
def initialize(keys = nil)
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@var = TkVariable.new
|
@var = TkVariable.new
|
||||||
id = @var.id
|
|
||||||
|
|
||||||
@title = title
|
@title = title
|
||||||
|
|
||||||
@ -20,28 +62,42 @@ class TkDialog < TkWindow
|
|||||||
@default_button = default_button
|
@default_button = default_button
|
||||||
|
|
||||||
@buttons = buttons
|
@buttons = buttons
|
||||||
@button_configs = proc{|num| button_configs num}
|
@button_configs = proc{|num| button_configs(num)}
|
||||||
|
|
||||||
|
#@config = "puts [winfo children .w0000];"
|
||||||
|
@config = ""
|
||||||
|
|
||||||
if keys.kind_of? Hash
|
if keys.kind_of? Hash
|
||||||
keys = _symbolkey2str(keys)
|
keys = _symbolkey2str(keys)
|
||||||
@title = keys['title'] if keys['title']
|
@title = keys['title'] if keys.key? 'title'
|
||||||
@message = keys['message'] if keys['message']
|
@message = keys['message'] if keys.key? 'message'
|
||||||
@bitmap = keys['bitmap'] if keys['bitmap']
|
@bitmap = keys['bitmap'] if keys.key? 'bitmap'
|
||||||
@default_button = keys['default'] if keys['default']
|
@default_button = keys['default'] if keys.key? 'default'
|
||||||
@buttons = keys['buttons'] if keys['buttons']
|
@buttons = keys['buttons'] if keys.key? 'buttons'
|
||||||
|
|
||||||
@command = keys['prev_command']
|
@command = keys['prev_command']
|
||||||
|
|
||||||
@message_config = keys['message_config'] if keys['message_config']
|
@message_config = keys['message_config'] if keys.key? 'message_config'
|
||||||
@bitmap_config = keys['bitmap_config'] if keys['bitmap_config']
|
@msgframe_config = keys['msgframe_config'] if keys.key? 'msgframe_config'
|
||||||
@button_configs = keys['button_configs'] if keys['button_configs']
|
@bitmap_config = keys['bitmap_config'] if keys.key? 'bitmap_config'
|
||||||
|
@button_configs = keys['button_configs'] if keys.key? 'button_configs'
|
||||||
|
@btnframe_config = keys['btnframe_config'] if keys.key? 'btnframe_config'
|
||||||
end
|
end
|
||||||
|
|
||||||
if @title.include? ?\s
|
if @title.include? ?\s
|
||||||
@title = '{' + @title + '}'
|
@title = '{' + @title + '}'
|
||||||
end
|
end
|
||||||
|
|
||||||
@buttons = tk_split_list(@buttons) if @buttons.kind_of? String
|
if @buttons.kind_of? Array
|
||||||
|
_set_button_config(@buttons.collect{|cfg|
|
||||||
|
(cfg.kind_of? Array)? cfg[1]: nil})
|
||||||
|
@buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
|
||||||
|
end
|
||||||
|
if @buttons.kind_of? Hash
|
||||||
|
_set_button_config(@buttons)
|
||||||
|
@buttons = @buttons.keys
|
||||||
|
end
|
||||||
|
@buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String
|
||||||
@buttons = @buttons.collect{|s|
|
@buttons = @buttons.collect{|s|
|
||||||
if s.kind_of? Array
|
if s.kind_of? Array
|
||||||
s = s.join(' ')
|
s = s.join(' ')
|
||||||
@ -53,34 +109,46 @@ class TkDialog < TkWindow
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
config = ""
|
|
||||||
if @message_config.kind_of? Hash
|
if @message_config.kind_of? Hash
|
||||||
config << format("%s.msg configure %s\n",
|
@config << format("%s.msg configure %s;",
|
||||||
@path, hash_kv(@message_config).join(' '))
|
@path, hash_kv(@message_config).join(' '))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @msgframe_config.kind_of? Hash
|
||||||
|
@config << format("%s.top configure %s;",
|
||||||
|
@path, hash_kv(@msgframe_config).join(' '))
|
||||||
|
end
|
||||||
|
|
||||||
|
if @btnframe_config.kind_of? Hash
|
||||||
|
@config << format("%s.bot configure %s;",
|
||||||
|
@path, hash_kv(@btnframe_config).join(' '))
|
||||||
|
end
|
||||||
|
|
||||||
if @bitmap_config.kind_of? Hash
|
if @bitmap_config.kind_of? Hash
|
||||||
config << format("%s.msg configure %s\n",
|
@config << format("%s.bitmap configure %s;",
|
||||||
@path, hash_kv(@bitmap_config).join(' '))
|
@path, hash_kv(@bitmap_config).join(' '))
|
||||||
end
|
end
|
||||||
if @button_configs.kind_of? Proc
|
|
||||||
@buttons.each_index{|i|
|
_set_button_config(@button_configs) if @button_configs
|
||||||
if (c = @button_configs.call(i)).kind_of? Hash
|
|
||||||
config << format("%s.button%s configure %s\n",
|
|
||||||
@path, i, hash_kv(c).join(' '))
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
config = 'after idle {' + config + '};' if config != ""
|
|
||||||
|
|
||||||
if @command.kind_of? Proc
|
if @command.kind_of? Proc
|
||||||
@command.call(self)
|
@command.call(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
INTERP._eval('eval {global '+id+';'+config+
|
|
||||||
'set '+id+' [tk_dialog '+
|
|
||||||
@path+" "+@title+" {#{@message}} "+@bitmap+" "+
|
|
||||||
String(@default_button)+" "+@buttons.join(' ')+']}')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
if @default_button.kind_of? String
|
||||||
|
default_button = @buttons.index(@default_button)
|
||||||
|
else
|
||||||
|
default_button = @default_button
|
||||||
|
end
|
||||||
|
default_button = '{}' if default_button == nil
|
||||||
|
INTERP._eval('eval {global '+@var.id+';'+@config+
|
||||||
|
'set '+@var.id+' [tk_dialog '+
|
||||||
|
@path+" "+@title+" {#{@message}} "+@bitmap+" "+
|
||||||
|
String(default_button)+" "+@buttons.join(' ')+']}')
|
||||||
|
end
|
||||||
|
|
||||||
def value
|
def value
|
||||||
return @var.value.to_i
|
return @var.value.to_i
|
||||||
end
|
end
|
||||||
@ -89,22 +157,36 @@ class TkDialog < TkWindow
|
|||||||
# these methods must be overridden for each dialog #
|
# these methods must be overridden for each dialog #
|
||||||
# #
|
# #
|
||||||
######################################################
|
######################################################
|
||||||
|
private
|
||||||
|
|
||||||
def title
|
def title
|
||||||
|
# returns a title string of the dialog window
|
||||||
return "DIALOG"
|
return "DIALOG"
|
||||||
end
|
end
|
||||||
def message
|
def message
|
||||||
|
# returns a message text to display on the dialog
|
||||||
return "MESSAGE"
|
return "MESSAGE"
|
||||||
end
|
end
|
||||||
def message_config
|
def message_config
|
||||||
|
# returns a Hash {option=>value, ...} for the message text
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
def msgframe_config
|
||||||
|
# returns a Hash {option=>value, ...} for the message text frame
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
def bitmap
|
def bitmap
|
||||||
|
# returns a bitmap name or a bitmap file path
|
||||||
|
# (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm')
|
||||||
return "info"
|
return "info"
|
||||||
end
|
end
|
||||||
def bitmap_config
|
def bitmap_config
|
||||||
|
# returns nil or a Hash {option=>value, ...} for the bitmap
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
def default_button
|
def default_button
|
||||||
|
# returns a default button's number or name
|
||||||
|
# if nil or null string, set no-default
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
def buttons
|
def buttons
|
||||||
@ -112,21 +194,50 @@ class TkDialog < TkWindow
|
|||||||
return ["BUTTON1", "BUTTON2"]
|
return ["BUTTON1", "BUTTON2"]
|
||||||
end
|
end
|
||||||
def button_configs(num)
|
def button_configs(num)
|
||||||
|
# returns nil / Proc / Array or Hash (see _set_button_config)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
def btnframe_config
|
||||||
|
# returns nil or a Hash {option=>value, ...} for the button frame
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# TkDialog : with showing at initialize
|
||||||
|
#
|
||||||
|
class TkDialog < TkDialog2
|
||||||
|
def self.show(*args)
|
||||||
|
self.new(*args)
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(*args)
|
||||||
|
super(*args)
|
||||||
|
show
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# dialog for warning
|
# dialog for warning
|
||||||
#
|
#
|
||||||
class TkWarning < TkDialog
|
class TkWarning2 < TkDialog2
|
||||||
def initialize(mes)
|
def initialize(mes)
|
||||||
@mes = mes
|
super(:message=>mes)
|
||||||
super()
|
|
||||||
end
|
end
|
||||||
def message
|
|
||||||
return @mes
|
def show(mes = nil)
|
||||||
|
mes_bup = @message
|
||||||
|
@message = mes if mes
|
||||||
|
ret = super()
|
||||||
|
@message = mes_bup
|
||||||
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#######
|
||||||
|
private
|
||||||
|
|
||||||
def title
|
def title
|
||||||
return "WARNING";
|
return "WARNING";
|
||||||
end
|
end
|
||||||
@ -140,3 +251,13 @@ class TkWarning < TkDialog
|
|||||||
return "OK";
|
return "OK";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TkWarning < TkWarning2
|
||||||
|
def self.show(*args)
|
||||||
|
self.new(*args)
|
||||||
|
end
|
||||||
|
def initialize(mes)
|
||||||
|
super(mes)
|
||||||
|
show
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -10,14 +10,39 @@ class TkEntry<TkLabel
|
|||||||
|
|
||||||
WidgetClassName = 'Entry'.freeze
|
WidgetClassName = 'Entry'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
def self.to_eval
|
|
||||||
WidgetClassName
|
|
||||||
end
|
|
||||||
|
|
||||||
class ValidateCmd
|
class ValidateCmd
|
||||||
include TkComm
|
include TkComm
|
||||||
|
|
||||||
class ValidateArgs
|
class ValidateArgs
|
||||||
|
VARG_KEY = 'disvPSVW'
|
||||||
|
VARG_TYPE = 'nnsssssw'
|
||||||
|
|
||||||
|
def self.scan_args(arg_str, arg_val)
|
||||||
|
arg_cnv = []
|
||||||
|
arg_str.strip.split(/\s+/).each_with_index{|kwd,idx|
|
||||||
|
if kwd =~ /^%(.)$/
|
||||||
|
if num = VARG_KEY.index($1)
|
||||||
|
case VARG_TYPE[num]
|
||||||
|
when ?n
|
||||||
|
arg_cnv << TkComm::number(arg_val[idx])
|
||||||
|
when ?s
|
||||||
|
arg_cnv << TkComm::string(arg_val[idx])
|
||||||
|
when ?w
|
||||||
|
arg_cnv << TkComm::window(arg_val[idx])
|
||||||
|
else
|
||||||
|
arg_cnv << arg_val[idx]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
arg_cnv << arg_val[idx]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
arg_cnv << arg_val[idx]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
arg_cnv
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(d,i,s,v,pp,ss,vv,ww)
|
def initialize(d,i,s,v,pp,ss,vv,ww)
|
||||||
@action = d
|
@action = d
|
||||||
@index = i
|
@index = i
|
||||||
@ -40,13 +65,19 @@ class TkEntry<TkLabel
|
|||||||
|
|
||||||
def initialize(cmd = Proc.new, args=nil)
|
def initialize(cmd = Proc.new, args=nil)
|
||||||
if args
|
if args
|
||||||
@id = install_cmd(proc{|*arg|
|
@id =
|
||||||
TkUtil.eval_cmd cmd, *arg
|
install_cmd(proc{|*arg|
|
||||||
|
TkUtil.eval_cmd(cmd, ValidateArgs.scan_args(args, arg))
|
||||||
}) + " " + args
|
}) + " " + args
|
||||||
else
|
else
|
||||||
@id = install_cmd(proc{|arg|
|
args = ' %d %i %s %v %P %S %V %W'
|
||||||
TkUtil.eval_cmd cmd, ValidateArgs.new(*arg)
|
@id =
|
||||||
}) + ' %d %i %s %v %P %S %V %W'
|
install_cmd(proc{|*arg|
|
||||||
|
TkUtil.eval_cmd(
|
||||||
|
cmd,
|
||||||
|
ValidateArgs.new(ValidateArgs.scan_args(args, arg))
|
||||||
|
)
|
||||||
|
}) + args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,14 +94,6 @@ class TkEntry<TkLabel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bbox(index)
|
|
||||||
tk_send 'bbox', index
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete(s, e=None)
|
|
||||||
tk_send 'delete', s, e
|
|
||||||
end
|
|
||||||
|
|
||||||
def configure(slot, value=None)
|
def configure(slot, value=None)
|
||||||
if slot.kind_of? Hash
|
if slot.kind_of? Hash
|
||||||
slot = _symbolkey2str(slot)
|
slot = _symbolkey2str(slot)
|
||||||
@ -113,54 +136,60 @@ class TkEntry<TkLabel
|
|||||||
end
|
end
|
||||||
super(slot, value)
|
super(slot, value)
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def cursor
|
def cursor
|
||||||
tk_send 'index', 'insert'
|
number(tk_send('index', 'insert'))
|
||||||
end
|
end
|
||||||
def cursor=(index)
|
def cursor=(index)
|
||||||
tk_send 'icursor', index
|
tk_send 'icursor', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def index(index)
|
def index(index)
|
||||||
number(tk_send('index', index))
|
number(tk_send('index', index))
|
||||||
end
|
end
|
||||||
def insert(pos,text)
|
def insert(pos,text)
|
||||||
tk_send 'insert', pos, text
|
tk_send 'insert', pos, text
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def mark(pos)
|
def mark(pos)
|
||||||
tk_send 'scan', 'mark', pos
|
tk_send 'scan', 'mark', pos
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def dragto(pos)
|
def dragto(pos)
|
||||||
tk_send 'scan', 'dragto', pos
|
tk_send 'scan', 'dragto', pos
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def selection_adjust(index)
|
def selection_adjust(index)
|
||||||
tk_send 'selection', 'adjust', index
|
tk_send 'selection', 'adjust', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def selection_clear
|
def selection_clear
|
||||||
tk_send 'selection', 'clear'
|
tk_send 'selection', 'clear'
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def selection_from(index)
|
def selection_from(index)
|
||||||
tk_send 'selection', 'from', index
|
tk_send 'selection', 'from', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def selection_present()
|
def selection_present()
|
||||||
bool(tk_send('selection', 'present'))
|
bool(tk_send('selection', 'present'))
|
||||||
end
|
end
|
||||||
def selection_range(s, e)
|
def selection_range(s, e)
|
||||||
tk_send 'selection', 'range', s, e
|
tk_send 'selection', 'range', s, e
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def selection_to(index)
|
def selection_to(index)
|
||||||
tk_send 'selection', 'to', index
|
tk_send 'selection', 'to', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(mode = nil)
|
def validate(mode = nil)
|
||||||
if mode
|
if mode
|
||||||
configure 'validate', mode
|
configure 'validate', mode
|
||||||
else
|
else
|
||||||
if tk_send('validate') == '0'
|
bool(tk_send('validate'))
|
||||||
false
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -194,9 +223,6 @@ end
|
|||||||
class TkSpinbox<TkEntry
|
class TkSpinbox<TkEntry
|
||||||
WidgetClassName = 'Spinbox'.freeze
|
WidgetClassName = 'Spinbox'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
def self.to_eval
|
|
||||||
WidgetClassName
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
@ -212,10 +238,12 @@ class TkSpinbox<TkEntry
|
|||||||
|
|
||||||
def spinup
|
def spinup
|
||||||
tk_send 'invoke', 'spinup'
|
tk_send 'invoke', 'spinup'
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def spindown
|
def spindown
|
||||||
tk_send 'invoke', 'spindown'
|
tk_send 'invoke', 'spindown'
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(str)
|
def set(str)
|
||||||
|
@ -13,6 +13,14 @@ class TkFont
|
|||||||
Tk_FontNameTBL = {}
|
Tk_FontNameTBL = {}
|
||||||
Tk_FontUseTBL = {}
|
Tk_FontUseTBL = {}
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
Tk_FontNameTBL.clear
|
||||||
|
Tk_FontUseTBL.clear
|
||||||
|
Tk_FontID[0] = 0
|
||||||
|
end
|
||||||
|
|
||||||
# set default font
|
# set default font
|
||||||
case Tk::TK_VERSION
|
case Tk::TK_VERSION
|
||||||
when /^4\.*/
|
when /^4\.*/
|
||||||
@ -879,6 +887,7 @@ class TkFont
|
|||||||
|
|
||||||
def configure(slot, value=None)
|
def configure(slot, value=None)
|
||||||
configure_core(@compoundfont, slot, value)
|
configure_core(@compoundfont, slot, value)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def configinfo(slot=nil)
|
def configinfo(slot=nil)
|
||||||
@ -895,6 +904,7 @@ class TkFont
|
|||||||
else
|
else
|
||||||
configure(slot, value)
|
configure(slot, value)
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def latin_configinfo(slot=nil)
|
def latin_configinfo(slot=nil)
|
||||||
@ -914,6 +924,7 @@ class TkFont
|
|||||||
#""
|
#""
|
||||||
configure(slot, value)
|
configure(slot, value)
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def kanji_configinfo(slot=nil)
|
def kanji_configinfo(slot=nil)
|
||||||
@ -935,11 +946,13 @@ class TkFont
|
|||||||
def latin_replace(ltn)
|
def latin_replace(ltn)
|
||||||
latin_replace_core(ltn)
|
latin_replace_core(ltn)
|
||||||
reset_pointadjust
|
reset_pointadjust
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def kanji_replace(knj)
|
def kanji_replace(knj)
|
||||||
kanji_replace_core(knj)
|
kanji_replace_core(knj)
|
||||||
reset_pointadjust
|
reset_pointadjust
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def measure(text)
|
def measure(text)
|
||||||
@ -1019,27 +1032,33 @@ module TkTreatTagFont
|
|||||||
|
|
||||||
def font_configure(slot)
|
def font_configure(slot)
|
||||||
@parent.tagfont_configure(@id, slot)
|
@parent.tagfont_configure(@id, slot)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def latinfont_configure(ltn, keys=nil)
|
def latinfont_configure(ltn, keys=nil)
|
||||||
@parent.latintagfont_configure(@id, ltn, keys)
|
@parent.latintagfont_configure(@id, ltn, keys)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias asciifont_configure latinfont_configure
|
alias asciifont_configure latinfont_configure
|
||||||
|
|
||||||
def kanjifont_configure(knj, keys=nil)
|
def kanjifont_configure(knj, keys=nil)
|
||||||
@parent.kanjitagfont_configure(@id, ltn, keys)
|
@parent.kanjitagfont_configure(@id, ltn, keys)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def font_copy(window, wintag=nil)
|
def font_copy(window, wintag=nil)
|
||||||
@parent.tagfont_copy(@id, window, wintag)
|
@parent.tagfont_copy(@id, window, wintag)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def latinfont_copy(window, wintag=nil)
|
def latinfont_copy(window, wintag=nil)
|
||||||
@parent.latintagfont_copy(@id, window, wintag)
|
@parent.latintagfont_copy(@id, window, wintag)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias asciifont_copy latinfont_copy
|
alias asciifont_copy latinfont_copy
|
||||||
|
|
||||||
def kanjifont_copy(window, wintag=nil)
|
def kanjifont_copy(window, wintag=nil)
|
||||||
@parent.kanjitagfont_copy(@id, window, wintag)
|
@parent.kanjitagfont_copy(@id, window, wintag)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# tkmngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl'
|
# tkmngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl'
|
||||||
# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
|
# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
|
||||||
#
|
#
|
||||||
require 'tk'
|
require 'tk'
|
||||||
|
|
||||||
@ -12,14 +12,14 @@ module TkManageFocus
|
|||||||
end
|
end
|
||||||
|
|
||||||
def TkManageFocus.next(window)
|
def TkManageFocus.next(window)
|
||||||
tk_call 'tk_focusNext', window
|
tk_tcl2ruby(tk_call('tk_focusNext', window))
|
||||||
end
|
end
|
||||||
def focusNext
|
def focusNext
|
||||||
TkManageFocus.next(self)
|
TkManageFocus.next(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def TkManageFocus.prev(window)
|
def TkManageFocus.prev(window)
|
||||||
tk_call 'tk_focusPrev', window
|
tk_tcl2ruby(tk_call('tk_focusPrev', window))
|
||||||
end
|
end
|
||||||
def focusPrev
|
def focusPrev
|
||||||
TkManageFocus.prev(self)
|
TkManageFocus.prev(self)
|
||||||
|
@ -31,10 +31,6 @@ class TkText<TkTextWin
|
|||||||
WidgetClassName = 'Text'.freeze
|
WidgetClassName = 'Text'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
def self.to_eval
|
|
||||||
WidgetClassName
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.new(*args, &block)
|
def self.new(*args, &block)
|
||||||
obj = super(*args){}
|
obj = super(*args){}
|
||||||
obj.init_instance_variable
|
obj.init_instance_variable
|
||||||
@ -85,13 +81,13 @@ class TkText<TkTextWin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_names(index=None)
|
def tag_names(index=None)
|
||||||
tk_split_list(tk_send('tag', 'names', index)).collect{|elt|
|
tk_split_simplelist(tk_send('tag', 'names', index)).collect{|elt|
|
||||||
tagid2obj(elt)
|
tagid2obj(elt)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_names
|
def mark_names
|
||||||
tk_split_list(tk_send('mark', 'names')).collect{|elt|
|
tk_split_simplelist(tk_send('mark', 'names')).collect{|elt|
|
||||||
tagid2obj(elt)
|
tagid2obj(elt)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -104,29 +100,94 @@ class TkText<TkTextWin
|
|||||||
tagid2obj(tk_send('mark', 'previous', index))
|
tagid2obj(tk_send('mark', 'previous', index))
|
||||||
end
|
end
|
||||||
|
|
||||||
def window_names
|
def image_cget(index, slot)
|
||||||
tk_send('window', 'names').collect{|elt|
|
case slot.to_s
|
||||||
tagid2obj(elt)
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
|
tk_send('image', 'cget', index, "-#{slot}")
|
||||||
|
else
|
||||||
|
tk_tcl2ruby(tk_send('image', 'cget', index, "-#{slot}"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_configure(index, slot, value=None)
|
||||||
|
if slot.kind_of? Hash
|
||||||
|
tk_send('image', 'configure', index, *hash_kv(slot))
|
||||||
|
else
|
||||||
|
tk_send('image', 'configure', index, "-#{slot}", value)
|
||||||
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_configinfo(index, slot = nil)
|
||||||
|
if slot
|
||||||
|
case slot.to_s
|
||||||
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
|
conf = tk_split_simplelist(tk_send('image', 'configure',
|
||||||
|
index, "-#{slot}"))
|
||||||
|
else
|
||||||
|
conf = tk_split_list(tk_send('image', 'configure',
|
||||||
|
index, "-#{slot}"))
|
||||||
|
end
|
||||||
|
conf[0] = conf[0][1..-1]
|
||||||
|
conf
|
||||||
|
else
|
||||||
|
tk_split_simplelist(tk_send('image', 'configure',
|
||||||
|
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
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def image_names
|
def image_names
|
||||||
tk_send('image', 'names').collect{|elt|
|
tk_split_simplelist(tk_send('image', 'names')).collect{|elt|
|
||||||
tagid2obj(elt)
|
tagid2obj(elt)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_insert(index)
|
def set_insert(index)
|
||||||
tk_send 'mark', 'set', 'insert', index
|
tk_send 'mark', 'set', 'insert', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_current(index)
|
def set_current(index)
|
||||||
tk_send 'mark', 'set', 'current', index
|
tk_send 'mark', 'set', 'current', index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert(index, chars, *tags)
|
def insert(index, chars, *tags)
|
||||||
|
if tags[0].kind_of? Array
|
||||||
|
# multiple chars-taglist argument
|
||||||
|
args = [chars]
|
||||||
|
while tags.size > 0
|
||||||
|
tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
|
||||||
|
args << tags.shift if tags.size > 0 # chars
|
||||||
|
end
|
||||||
|
super index, *args
|
||||||
|
else
|
||||||
|
# single chars-taglist argument
|
||||||
super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')
|
super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@tags = {} unless @tags
|
@tags = {} unless @tags
|
||||||
@ -149,47 +210,87 @@ class TkText<TkTextWin
|
|||||||
end
|
end
|
||||||
def debug=(boolean)
|
def debug=(boolean)
|
||||||
tk_send 'debug', boolean
|
tk_send 'debug', boolean
|
||||||
|
self
|
||||||
|
end
|
||||||
|
def bbox(index)
|
||||||
|
list(tk_send('bbox', index))
|
||||||
end
|
end
|
||||||
|
|
||||||
def bbox(index)
|
|
||||||
inf = tk_send('bbox', index)
|
|
||||||
(inf == "")? [0,0,0,0]: inf
|
|
||||||
end
|
|
||||||
def dlineinfo(index)
|
def dlineinfo(index)
|
||||||
inf = tk_send('dlineinfo', index)
|
list(tk_send('dlineinfo', index))
|
||||||
(inf == "")? [0,0,0,0,0]: inf
|
end
|
||||||
|
|
||||||
|
def modified?
|
||||||
|
bool(tk_send('edit', 'modified'))
|
||||||
|
end
|
||||||
|
def modified(mode)
|
||||||
|
tk_send('edit', 'modified', mode)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
def edit_redo
|
||||||
|
tk_send('edit', 'redo')
|
||||||
|
self
|
||||||
|
end
|
||||||
|
def edit_reset
|
||||||
|
tk_send('edit', 'reset')
|
||||||
|
self
|
||||||
|
end
|
||||||
|
def edit_separator
|
||||||
|
tk_send('edit', 'separator')
|
||||||
|
self
|
||||||
|
end
|
||||||
|
def edit_undo
|
||||||
|
tk_send('edit', 'undo')
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def yview_pickplace(*what)
|
def yview_pickplace(*what)
|
||||||
tk_send 'yview', '-pickplace', *what
|
tk_send 'yview', '-pickplace', *what
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def xview_pickplace(*what)
|
def xview_pickplace(*what)
|
||||||
tk_send 'xview', '-pickplace', *what
|
tk_send 'xview', '-pickplace', *what
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_add(tag, index1, index2=None)
|
def tag_add(tag, index1, index2=None)
|
||||||
tk_send 'tag', 'add', tag, index1, index2
|
tk_send 'tag', 'add', tag, index1, index2
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
alias addtag tag_add
|
||||||
|
|
||||||
|
def tag_delete(*tags)
|
||||||
|
tk_send 'tag', 'delete', *tags
|
||||||
|
self
|
||||||
|
end
|
||||||
|
alias deltag tag_delete
|
||||||
|
|
||||||
def tag_bind(tag, seq, cmd=Proc.new, args=nil)
|
def tag_bind(tag, seq, cmd=Proc.new, args=nil)
|
||||||
_bind(['tag', 'bind', tag], seq, cmd, args)
|
_bind([@path, 'tag', 'bind', tag], seq, cmd, args)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
|
def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
|
||||||
_bind_append(['tag', 'bind', tag], seq, cmd, args)
|
_bind_append([@path, 'tag', 'bind', tag], seq, cmd, args)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def tag_bind_remove(tag, seq)
|
||||||
|
_bind_remove([@path, 'tag', 'bind', tag], seq)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_bindinfo(tag, context=nil)
|
def tag_bindinfo(tag, context=nil)
|
||||||
_bindinfo(['tag', 'bind', tag], context)
|
_bindinfo([@path, 'tag', 'bind', tag], context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_cget(tag, key)
|
def tag_cget(tag, key)
|
||||||
case key.to_s
|
case key.to_s
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call @path, 'tag', 'cget', tag, "-#{key}"
|
tk_call(@path, 'tag', 'cget', tag, "-#{key}")
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call(@path, 'tag', 'cget', tag, "-#{key}")
|
tk_tcl2ruby(tk_call(@path, 'tag', 'cget', tag, "-#{key}"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -213,6 +314,7 @@ class TkText<TkTextWin
|
|||||||
tk_send 'tag', 'configure', tag, "-#{key}", val
|
tk_send 'tag', 'configure', tag, "-#{key}", val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_configinfo(tag, key=nil)
|
def tag_configinfo(tag, key=nil)
|
||||||
@ -254,14 +356,17 @@ class TkText<TkTextWin
|
|||||||
|
|
||||||
def tag_raise(tag, above=None)
|
def tag_raise(tag, above=None)
|
||||||
tk_send 'tag', 'raise', tag, above
|
tk_send 'tag', 'raise', tag, above
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_lower(tag, below=None)
|
def tag_lower(tag, below=None)
|
||||||
tk_send 'tag', 'lower', tag, below
|
tk_send 'tag', 'lower', tag, below
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_remove(tag, *index)
|
def tag_remove(tag, *index)
|
||||||
tk_send 'tag', 'remove', tag, *index
|
tk_send 'tag', 'remove', tag, *index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_ranges(tag)
|
def tag_ranges(tag)
|
||||||
@ -274,11 +379,79 @@ class TkText<TkTextWin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_nextrange(tag, first, last=None)
|
def tag_nextrange(tag, first, last=None)
|
||||||
tk_split_simplelist(tk_send('tag', 'nextrange', tag, first, last))
|
tk_split_list(tk_send('tag', 'nextrange', tag, first, last))
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_prevrange(tag, first, last=None)
|
def tag_prevrange(tag, first, last=None)
|
||||||
tk_split_simplelist(tk_send('tag', 'prevrange', tag, first, last))
|
tk_split_list(tk_send('tag', 'prevrange', tag, first, last))
|
||||||
|
end
|
||||||
|
|
||||||
|
def window_cget(index, slot)
|
||||||
|
case slot.to_s
|
||||||
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
|
tk_send('window', 'cget', index, "-#{slot}")
|
||||||
|
else
|
||||||
|
tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def window_configure(index, slot, value=None)
|
||||||
|
if index.kind_of? TkTextWindow
|
||||||
|
index.configure(slot, value)
|
||||||
|
else
|
||||||
|
if slot.kind_of? Hash
|
||||||
|
tk_send('window', 'configure', index, *hash_kv(slot))
|
||||||
|
else
|
||||||
|
tk_send('window', 'configure', index, "-#{slot}", value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def window_configinfo(win, slot = nil)
|
||||||
|
if slot
|
||||||
|
case slot.to_s
|
||||||
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
|
conf = tk_split_simplelist(tk_send('window', 'configure',
|
||||||
|
win, "-#{slot}"))
|
||||||
|
else
|
||||||
|
conf = tk_split_list(tk_send('window', 'configure',
|
||||||
|
win, "-#{slot}"))
|
||||||
|
end
|
||||||
|
conf[0] = conf[0][1..-1]
|
||||||
|
conf
|
||||||
|
else
|
||||||
|
tk_split_simplelist(tk_send('window', 'configure',
|
||||||
|
win)).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
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def window_names
|
||||||
|
tk_split_simplelist(tk_send('window', 'names')).collect{|elt|
|
||||||
|
tagid2obj(elt)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def _ktext_length(txt)
|
def _ktext_length(txt)
|
||||||
@ -468,7 +641,7 @@ class TkText<TkTextWin
|
|||||||
result.push tk_tcl2ruby(val)
|
result.push tk_tcl2ruby(val)
|
||||||
end
|
end
|
||||||
when 'tagoff'
|
when 'tagoff'
|
||||||
result.push tk_tcl2ruby(sel)
|
result.push tk_tcl2ruby(val)
|
||||||
when 'window'
|
when 'window'
|
||||||
result.push tk_tcl2ruby(val)
|
result.push tk_tcl2ruby(val)
|
||||||
end
|
end
|
||||||
@ -555,6 +728,13 @@ class TkTextTag<TkObject
|
|||||||
TTagID_TBL = {}
|
TTagID_TBL = {}
|
||||||
Tk_TextTag_ID = ['tag0000']
|
Tk_TextTag_ID = ['tag0000']
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
TTagID_TBL.clear
|
||||||
|
Tk_TextTag_ID[0] = 'tag0000'
|
||||||
|
end
|
||||||
|
|
||||||
def TkTextTag.id2obj(text, id)
|
def TkTextTag.id2obj(text, id)
|
||||||
tpath = text.path
|
tpath = text.path
|
||||||
return id unless TTagID_TBL[tpath]
|
return id unless TTagID_TBL[tpath]
|
||||||
@ -587,7 +767,7 @@ class TkTextTag<TkObject
|
|||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
return @id
|
@id
|
||||||
end
|
end
|
||||||
|
|
||||||
def first
|
def first
|
||||||
@ -600,10 +780,12 @@ class TkTextTag<TkObject
|
|||||||
|
|
||||||
def add(*index)
|
def add(*index)
|
||||||
tk_call @t.path, 'tag', 'add', @id, *index
|
tk_call @t.path, 'tag', 'add', @id, *index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove(*index)
|
def remove(*index)
|
||||||
tk_call @t.path, 'tag', 'remove', @id, *index
|
tk_call @t.path, 'tag', 'remove', @id, *index
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def ranges
|
def ranges
|
||||||
@ -616,11 +798,11 @@ class TkTextTag<TkObject
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nextrange(first, last=None)
|
def nextrange(first, last=None)
|
||||||
tk_split_simplelist(tk_call(@t.path, 'tag', 'nextrange', @id, first, last))
|
tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last))
|
||||||
end
|
end
|
||||||
|
|
||||||
def prevrange(first, last=None)
|
def prevrange(first, last=None)
|
||||||
tk_split_simplelist(tk_call(@t.path, 'tag', 'prevrange', @id, first, last))
|
tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last))
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
@ -665,10 +847,17 @@ class TkTextTag<TkObject
|
|||||||
|
|
||||||
def bind(seq, cmd=Proc.new, args=nil)
|
def bind(seq, cmd=Proc.new, args=nil)
|
||||||
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_append(seq, cmd=Proc.new, args=nil)
|
def bind_append(seq, cmd=Proc.new, args=nil)
|
||||||
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def bind_remove(seq)
|
||||||
|
_bind_remove([@t.path, 'tag', 'bind', @id], seq)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def bindinfo(context=nil)
|
def bindinfo(context=nil)
|
||||||
@ -677,15 +866,18 @@ class TkTextTag<TkObject
|
|||||||
|
|
||||||
def raise(above=None)
|
def raise(above=None)
|
||||||
tk_call @t.path, 'tag', 'raise', @id, above
|
tk_call @t.path, 'tag', 'raise', @id, above
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def lower(below=None)
|
def lower(below=None)
|
||||||
tk_call @t.path, 'tag', 'lower', @id, below
|
tk_call @t.path, 'tag', 'lower', @id, below
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
tk_call @t.path, 'tag', 'delete', @id
|
tk_call @t.path, 'tag', 'delete', @id
|
||||||
TTagID_TBL[@tpath].delete(@id) if CTagID_TBL[@tpath]
|
TTagID_TBL[@tpath].delete(@id) if CTagID_TBL[@tpath]
|
||||||
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -707,10 +899,21 @@ class TkTextNamedTag<TkTextTag
|
|||||||
@path = @id = name
|
@path = @id = name
|
||||||
TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
|
TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
|
||||||
TTagID_TBL[@tpath][@id] = self
|
TTagID_TBL[@tpath][@id] = self
|
||||||
if mode
|
#if mode
|
||||||
tk_call @t.path, "addtag", @id, *args
|
# tk_call @t.path, "addtag", @id, *args
|
||||||
|
#end
|
||||||
|
if args != [] then
|
||||||
|
keys = args.pop
|
||||||
|
if keys.kind_of? Hash then
|
||||||
|
add(*args) if args != []
|
||||||
|
configure(keys)
|
||||||
|
else
|
||||||
|
args.push keys
|
||||||
|
add(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@t._addtag id, self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TkTextTagSel<TkTextTag
|
class TkTextTagSel<TkTextTag
|
||||||
@ -738,16 +941,26 @@ class TkTextMark<TkObject
|
|||||||
tk_call @t.path, 'mark', 'set', @id, index
|
tk_call @t.path, 'mark', 'set', @id, index
|
||||||
@t._addtag id, self
|
@t._addtag id, self
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
return @id
|
@id
|
||||||
|
end
|
||||||
|
|
||||||
|
def +(mod)
|
||||||
|
@id + ' + ' + mod
|
||||||
|
end
|
||||||
|
def -(mod)
|
||||||
|
@id + ' - ' + mod
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(where)
|
def set(where)
|
||||||
tk_call @t.path, 'mark', 'set', @id, where
|
tk_call @t.path, 'mark', 'set', @id, where
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def unset
|
def unset
|
||||||
tk_call @t.path, 'mark', 'unset', @id
|
tk_call @t.path, 'mark', 'unset', @id
|
||||||
|
self
|
||||||
end
|
end
|
||||||
alias destroy unset
|
alias destroy unset
|
||||||
|
|
||||||
@ -757,6 +970,7 @@ class TkTextMark<TkObject
|
|||||||
|
|
||||||
def gravity=(direction)
|
def gravity=(direction)
|
||||||
tk_call @t.path, 'mark', 'gravity', @id, direction
|
tk_call @t.path, 'mark', 'gravity', @id, direction
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def next(index = nil)
|
def next(index = nil)
|
||||||
@ -850,12 +1064,7 @@ class TkTextWindow<TkObject
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cget(slot)
|
def cget(slot)
|
||||||
case slot.to_s
|
@t.window_cget(@index, slot)
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
|
||||||
tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
|
|
||||||
else
|
|
||||||
tk_tcl2ruby tk_call(@t.path, 'window', 'cget', @index, "-#{slot}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure(slot, value=None)
|
def configure(slot, value=None)
|
||||||
@ -867,16 +1076,21 @@ class TkTextWindow<TkObject
|
|||||||
slot['create']=nil
|
slot['create']=nil
|
||||||
end
|
end
|
||||||
if slot.size > 0
|
if slot.size > 0
|
||||||
tk_call @t.path, 'window', 'configure', @index, *hash_kv(slot)
|
tk_call(@t.path, 'window', 'configure', @index, *hash_kv(slot))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@id = value if slot == 'window' || slot == :window
|
@id = value if slot == 'window' || slot == :window
|
||||||
if slot == 'create' || slot == :create
|
if slot == 'create' || slot == :create
|
||||||
self.create=value
|
self.create=value
|
||||||
else
|
else
|
||||||
tk_call @t.path, 'window', 'configure', @index, "-#{slot}", value
|
tk_call(@t.path, 'window', 'configure', @index, "-#{slot}", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def configinfo(slot = nil)
|
||||||
|
@t.window_configinfo(@index, slot)
|
||||||
end
|
end
|
||||||
|
|
||||||
def window
|
def window
|
||||||
@ -899,47 +1113,6 @@ class TkTextWindow<TkObject
|
|||||||
end
|
end
|
||||||
tk_call @t.path, 'window', 'configure', @index, '-create', value
|
tk_call @t.path, 'window', 'configure', @index, '-create', value
|
||||||
end
|
end
|
||||||
|
|
||||||
def configinfo(slot = nil)
|
|
||||||
if slot
|
|
||||||
case slot.to_s
|
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
|
||||||
conf = tk_split_simplelist(tk_call(@t.path, 'window', 'configure',
|
|
||||||
@index, "-#{slot}"))
|
|
||||||
else
|
|
||||||
conf = tk_split_list(tk_call(@t.path, 'window', 'configure',
|
|
||||||
@index, "-#{slot}"))
|
|
||||||
end
|
|
||||||
conf[0] = conf[0][1..-1]
|
|
||||||
conf
|
|
||||||
else
|
|
||||||
tk_split_simplelist(tk_call(@t.path, 'window', 'configure',
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TkTextImage<TkObject
|
class TkTextImage<TkObject
|
||||||
@ -972,70 +1145,28 @@ class TkTextImage<TkObject
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cget(slot)
|
def cget(slot)
|
||||||
case slot.to_s
|
@t.image_cget(@index, slot)
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
|
||||||
tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
|
|
||||||
else
|
|
||||||
tk_tcl2ruby tk_call(@t.path, 'image', 'cget', @index, "-#{slot}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure(slot, value=None)
|
def configure(slot, value=None)
|
||||||
if slot.kind_of? Hash
|
@t.image_configure(@index, slot, value)
|
||||||
tk_call @t.path, 'image', 'configure', @index, *hash_kv(slot)
|
self
|
||||||
else
|
|
||||||
tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# def configure(slot, value)
|
# def configure(slot, value)
|
||||||
# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
|
# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
def configinfo(slot = nil)
|
||||||
|
@t.image_configinfo(@index, slot)
|
||||||
|
end
|
||||||
|
|
||||||
def image
|
def image
|
||||||
tk_call @t.path, 'image', 'configure', @index, '-image'
|
img = tk_call(@t.path, 'image', 'configure', @index, '-image')
|
||||||
|
TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
|
||||||
end
|
end
|
||||||
|
|
||||||
def image=(value)
|
def image=(value)
|
||||||
tk_call @t.path, 'image', 'configure', @index, '-image', value
|
tk_call @t.path, 'image', 'configure', @index, '-image', value
|
||||||
end
|
self
|
||||||
|
|
||||||
def configinfo(slot = nil)
|
|
||||||
if slot
|
|
||||||
case slot.to_s
|
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
|
||||||
conf = tk_split_simplelist(tk_call(@t.path, 'image', 'configure',
|
|
||||||
@index, "-#{slot}"))
|
|
||||||
else
|
|
||||||
conf = tk_split_list(tk_call(@t.path, 'image', 'configure',
|
|
||||||
@index, "-#{slot}"))
|
|
||||||
end
|
|
||||||
conf[0] = conf[0][1..-1]
|
|
||||||
conf
|
|
||||||
else
|
|
||||||
tk_split_simplelist(tk_call(@t.path, 'image', 'configure',
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,6 +10,13 @@ class TkVirtualEvent<TkObject
|
|||||||
TkVirtualEventID = [0]
|
TkVirtualEventID = [0]
|
||||||
TkVirtualEventTBL = {}
|
TkVirtualEventTBL = {}
|
||||||
|
|
||||||
|
TkComm::INITIALIZE_TARGETS << self
|
||||||
|
|
||||||
|
def self.__init_tables__
|
||||||
|
TkVirtualEventTBL.clear
|
||||||
|
TkVirtualEventID[0] = 0
|
||||||
|
end
|
||||||
|
|
||||||
class PreDefVirtEvent<self
|
class PreDefVirtEvent<self
|
||||||
def initialize(event)
|
def initialize(event)
|
||||||
@path = @id = event
|
@path = @id = event
|
||||||
|
Loading…
x
Reference in New Issue
Block a user