зеркало из https://github.com/github/ruby.git
* ext/tk/lib/tk/*: untabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
05f5928c9d
Коммит
3514110b89
|
@ -1,3 +1,7 @@
|
|||
Mon Oct 11 13:48:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk/*: untabify
|
||||
|
||||
Sun Oct 10 12:32:08 2004 Dave Thomas <dave@pragprog.com>
|
||||
|
||||
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Allow 'require'
|
||||
|
|
|
@ -42,7 +42,7 @@ def find_tcl(tcllib, stubs)
|
|||
else
|
||||
%w[8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
|
||||
find_library("tcl#{ver}", func, *paths) or
|
||||
find_library("tcl#{ver.delete('.')}", func, *paths)
|
||||
find_library("tcl#{ver.delete('.')}", func, *paths)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -63,7 +63,7 @@ def find_tk(tklib, stubs)
|
|||
else
|
||||
%w[8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
|
||||
find_library("tk#{ver}", func, *paths) or
|
||||
find_library("tk#{ver.delete('.')}", func, *paths)
|
||||
find_library("tk#{ver.delete('.')}", func, *paths)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -90,47 +90,47 @@ def pthread_check()
|
|||
else
|
||||
# tcl-thread is unknown and tclConfig.sh is given
|
||||
begin
|
||||
open(tclConfig, "r") do |cfg|
|
||||
while line = cfg.gets()
|
||||
if line =~ /^\s*TCL_THREADS=(0|1)/
|
||||
tcl_enable_thread = ($1 == "1")
|
||||
break
|
||||
end
|
||||
open(tclConfig, "r") do |cfg|
|
||||
while line = cfg.gets()
|
||||
if line =~ /^\s*TCL_THREADS=(0|1)/
|
||||
tcl_enable_thread = ($1 == "1")
|
||||
break
|
||||
end
|
||||
|
||||
if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
|
||||
tcl_major_ver = $2
|
||||
if tcl_major_ver =~ /^[1-7]$/
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
if tcl_major_ver == "8" && tcl_minor_ver == "0"
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
|
||||
tcl_major_ver = $2
|
||||
if tcl_major_ver =~ /^[1-7]$/
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
if tcl_major_ver == "8" && tcl_minor_ver == "0"
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
|
||||
tcl_minor_ver = $2
|
||||
if tcl_major_ver == "8" && tcl_minor_ver == "0"
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
|
||||
tcl_minor_ver = $2
|
||||
if tcl_major_ver == "8" && tcl_minor_ver == "0"
|
||||
tcl_enable_thread = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if tcl_enable_thread == nil
|
||||
# not find definition
|
||||
if tcl_major_ver
|
||||
puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
|
||||
else
|
||||
puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
|
||||
end
|
||||
tclConfig = false
|
||||
end
|
||||
if tcl_enable_thread == nil
|
||||
# not find definition
|
||||
if tcl_major_ver
|
||||
puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
|
||||
else
|
||||
puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
|
||||
end
|
||||
tclConfig = false
|
||||
end
|
||||
rescue Exception
|
||||
puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
|
||||
tclConfig = false
|
||||
puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
|
||||
tclConfig = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# tof
|
||||
|
||||
#### tcltk library, more direct manipulation of tcl/tk
|
||||
#### Sep. 5, 1997 Y. Shigehiro
|
||||
#### Sep. 5, 1997 Y. Shigehiro
|
||||
|
||||
require "tcltklib"
|
||||
|
||||
|
@ -103,14 +103,14 @@ class TclTkInterpreter
|
|||
def @ip._get_eval_string(*args)
|
||||
argstr = ""
|
||||
args.each{|arg|
|
||||
argstr += " " if argstr != ""
|
||||
# call to_eval if it is defined
|
||||
if (arg.respond_to?(:to_eval))
|
||||
argstr += arg.to_eval()
|
||||
else
|
||||
# call to_s unless defined
|
||||
argstr += arg.to_s()
|
||||
end
|
||||
argstr += " " if argstr != ""
|
||||
# call to_eval if it is defined
|
||||
if (arg.respond_to?(:to_eval))
|
||||
argstr += arg.to_eval()
|
||||
else
|
||||
# call to_s unless defined
|
||||
argstr += arg.to_s()
|
||||
end
|
||||
}
|
||||
return argstr
|
||||
end
|
||||
|
@ -126,9 +126,9 @@ class TclTkInterpreter
|
|||
print("_eval: \"", argstr, "\"") if $DEBUG
|
||||
res = _eval(argstr)
|
||||
if $DEBUG
|
||||
print(" -> \"", res, "\"\n")
|
||||
print(" -> \"", res, "\"\n")
|
||||
elsif _return_value() != 0
|
||||
print(res, "\n")
|
||||
print(res, "\n")
|
||||
end
|
||||
fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #'
|
||||
return res
|
||||
|
@ -139,12 +139,12 @@ class TclTkInterpreter
|
|||
# for all commands registered in tcl/tk interpreter:
|
||||
@ip._eval("info command").split(/ /).each{|comname|
|
||||
if comname =~ /^[.]/
|
||||
# if command is a widget (path), generate TclTkWidget,
|
||||
# and register it in the hash
|
||||
@commands[comname] = TclTkWidget.new(@ip, comname)
|
||||
# if command is a widget (path), generate TclTkWidget,
|
||||
# and register it in the hash
|
||||
@commands[comname] = TclTkWidget.new(@ip, comname)
|
||||
else
|
||||
# otherwise, generate TclTkCommand
|
||||
@commands[comname] = TclTkCommand.new(@ip, comname)
|
||||
# otherwise, generate TclTkCommand
|
||||
@commands[comname] = TclTkCommand.new(@ip, comname)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -189,8 +189,8 @@ class Test1
|
|||
grid.e(w, "-row", ro, "-column", co, "-sticky news")
|
||||
ro += 1
|
||||
if ro == 7
|
||||
ro = 0
|
||||
co += 1
|
||||
ro = 0
|
||||
co += 1
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
# maeda shugo (shuto@po.aianet.ne.jp)
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
|
||||
# maeda shugo (shugo@po.aianet.ne.jp) 氏による
|
||||
# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
|
||||
# maeda shugo (shugo@po.aianet.ne.jp) 氏による
|
||||
# (ruby/tk で書かれていた) ruby のサンプルプログラム
|
||||
# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
|
||||
# を tcltk ライブラリを使うように, 機械的に変更してみました.
|
||||
# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
|
||||
# を tcltk ライブラリを使うように, 機械的に変更してみました.
|
||||
#
|
||||
# なるべくオリジナルと同じになるようにしてあります.
|
||||
# なるべくオリジナルと同じになるようにしてあります.
|
||||
|
||||
require "observer"
|
||||
require "tcltk"
|
||||
|
@ -36,141 +36,141 @@ class Othello
|
|||
include Observable
|
||||
|
||||
DIRECTIONS = [
|
||||
[-1, -1], [-1, 0], [-1, 1],
|
||||
[ 0, -1], [ 0, 1],
|
||||
[ 1, -1], [ 1, 0], [ 1, 1]
|
||||
[-1, -1], [-1, 0], [-1, 1],
|
||||
[ 0, -1], [ 0, 1],
|
||||
[ 1, -1], [ 1, 0], [ 1, 1]
|
||||
]
|
||||
|
||||
attr :com_disk, TRUE
|
||||
|
||||
def initialize(othello)
|
||||
@othello = othello
|
||||
reset
|
||||
@othello = othello
|
||||
reset
|
||||
end
|
||||
|
||||
def notify_observers(*arg)
|
||||
if @observer_peers != nil
|
||||
super(*arg)
|
||||
end
|
||||
if @observer_peers != nil
|
||||
super(*arg)
|
||||
end
|
||||
end
|
||||
|
||||
def reset
|
||||
@data = [
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
|
||||
]
|
||||
changed
|
||||
notify_observers
|
||||
@data = [
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
|
||||
[EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
|
||||
]
|
||||
changed
|
||||
notify_observers
|
||||
end
|
||||
|
||||
def man_disk
|
||||
return - @com_disk
|
||||
return - @com_disk
|
||||
end
|
||||
|
||||
def other_disk(disk)
|
||||
return - disk
|
||||
return - disk
|
||||
end
|
||||
|
||||
def get_disk(row, col)
|
||||
return @data[row][col]
|
||||
return @data[row][col]
|
||||
end
|
||||
|
||||
def reverse_to(row, col, my_disk, dir_y, dir_x)
|
||||
y = row
|
||||
x = col
|
||||
begin
|
||||
y += dir_y
|
||||
x += dir_x
|
||||
if y < 0 || x < 0 || y > 7 || x > 7 ||
|
||||
@data[y][x] == EMPTY
|
||||
return
|
||||
end
|
||||
end until @data[y][x] == my_disk
|
||||
begin
|
||||
@data[y][x] = my_disk
|
||||
changed
|
||||
notify_observers(y, x)
|
||||
y -= dir_y
|
||||
x -= dir_x
|
||||
end until y == row && x == col
|
||||
y = row
|
||||
x = col
|
||||
begin
|
||||
y += dir_y
|
||||
x += dir_x
|
||||
if y < 0 || x < 0 || y > 7 || x > 7 ||
|
||||
@data[y][x] == EMPTY
|
||||
return
|
||||
end
|
||||
end until @data[y][x] == my_disk
|
||||
begin
|
||||
@data[y][x] = my_disk
|
||||
changed
|
||||
notify_observers(y, x)
|
||||
y -= dir_y
|
||||
x -= dir_x
|
||||
end until y == row && x == col
|
||||
end
|
||||
|
||||
def put_disk(row, col, disk)
|
||||
@data[row][col] = disk
|
||||
changed
|
||||
notify_observers(row, col)
|
||||
DIRECTIONS.each do |dir|
|
||||
reverse_to(row, col, disk, *dir)
|
||||
end
|
||||
@data[row][col] = disk
|
||||
changed
|
||||
notify_observers(row, col)
|
||||
DIRECTIONS.each do |dir|
|
||||
reverse_to(row, col, disk, *dir)
|
||||
end
|
||||
end
|
||||
|
||||
def count_disk(disk)
|
||||
num = 0
|
||||
@data.each do |rows|
|
||||
rows.each do |d|
|
||||
if d == disk
|
||||
num += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return num
|
||||
num = 0
|
||||
@data.each do |rows|
|
||||
rows.each do |d|
|
||||
if d == disk
|
||||
num += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
def count_point_to(row, col, my_disk, dir_y, dir_x)
|
||||
return 0 if @data[row][col] != EMPTY
|
||||
count = 0
|
||||
loop do
|
||||
row += dir_y
|
||||
col += dir_x
|
||||
break if row < 0 || col < 0 || row > 7 || col > 7
|
||||
case @data[row][col]
|
||||
when my_disk
|
||||
return count
|
||||
when other_disk(my_disk)
|
||||
count += 1
|
||||
when EMPTY
|
||||
break
|
||||
end
|
||||
end
|
||||
return 0
|
||||
return 0 if @data[row][col] != EMPTY
|
||||
count = 0
|
||||
loop do
|
||||
row += dir_y
|
||||
col += dir_x
|
||||
break if row < 0 || col < 0 || row > 7 || col > 7
|
||||
case @data[row][col]
|
||||
when my_disk
|
||||
return count
|
||||
when other_disk(my_disk)
|
||||
count += 1
|
||||
when EMPTY
|
||||
break
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def count_point(row, col, my_disk)
|
||||
count = 0
|
||||
DIRECTIONS.each do |dir|
|
||||
count += count_point_to(row, col, my_disk, *dir)
|
||||
end
|
||||
return count
|
||||
count = 0
|
||||
DIRECTIONS.each do |dir|
|
||||
count += count_point_to(row, col, my_disk, *dir)
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
def corner?(row, col)
|
||||
return (row == 0 && col == 0) ||
|
||||
(row == 0 && col == 7) ||
|
||||
(row == 7 && col == 0) ||
|
||||
(row == 7 && col == 7)
|
||||
return (row == 0 && col == 0) ||
|
||||
(row == 0 && col == 7) ||
|
||||
(row == 7 && col == 0) ||
|
||||
(row == 7 && col == 7)
|
||||
end
|
||||
|
||||
def search(my_disk)
|
||||
max = 0
|
||||
max_row = nil
|
||||
max_col = nil
|
||||
for row in 0 .. 7
|
||||
for col in 0 .. 7
|
||||
buf = count_point(row, col, my_disk)
|
||||
if (corner?(row, col) && buf > 0) || max < buf
|
||||
max = buf
|
||||
max_row = row
|
||||
max_col = col
|
||||
end
|
||||
end
|
||||
end
|
||||
return max_row, max_col
|
||||
max = 0
|
||||
max_row = nil
|
||||
max_col = nil
|
||||
for row in 0 .. 7
|
||||
for col in 0 .. 7
|
||||
buf = count_point(row, col, my_disk)
|
||||
if (corner?(row, col) && buf > 0) || max < buf
|
||||
max = buf
|
||||
max_row = row
|
||||
max_col = col
|
||||
end
|
||||
end
|
||||
end
|
||||
return max_row, max_col
|
||||
end
|
||||
end #--------------------------> class Board ends here
|
||||
|
||||
|
@ -189,145 +189,145 @@ class Othello
|
|||
attr :bottom
|
||||
|
||||
class Square
|
||||
|
||||
attr :oval, TRUE
|
||||
attr :row
|
||||
attr :col
|
||||
|
||||
def initialize(view, row, col)
|
||||
@view = view
|
||||
@id = @view.e("create rectangle", *view.tk_rect(view.left + col,
|
||||
view.top + row,
|
||||
view.left + col + 1,
|
||||
view.top + row + 1))
|
||||
@row = row
|
||||
@col = col
|
||||
@view.e("itemconfigure", @id,
|
||||
"-width 0.5m -outline #{BORDER_COLOR}")
|
||||
@view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
|
||||
if @oval == nil
|
||||
view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
|
||||
end
|
||||
}))
|
||||
@view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
|
||||
view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
|
||||
}))
|
||||
@view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
|
||||
proc{
|
||||
view.click_square(self)
|
||||
}))
|
||||
end
|
||||
|
||||
def blink(color)
|
||||
@view.e("itemconfigure", @id, "-fill #{color}")
|
||||
$update.e()
|
||||
sleep(0.1)
|
||||
@view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
|
||||
end
|
||||
|
||||
attr :oval, TRUE
|
||||
attr :row
|
||||
attr :col
|
||||
|
||||
def initialize(view, row, col)
|
||||
@view = view
|
||||
@id = @view.e("create rectangle", *view.tk_rect(view.left + col,
|
||||
view.top + row,
|
||||
view.left + col + 1,
|
||||
view.top + row + 1))
|
||||
@row = row
|
||||
@col = col
|
||||
@view.e("itemconfigure", @id,
|
||||
"-width 0.5m -outline #{BORDER_COLOR}")
|
||||
@view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
|
||||
if @oval == nil
|
||||
view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
|
||||
end
|
||||
}))
|
||||
@view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
|
||||
view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
|
||||
}))
|
||||
@view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
|
||||
proc{
|
||||
view.click_square(self)
|
||||
}))
|
||||
end
|
||||
|
||||
def blink(color)
|
||||
@view.e("itemconfigure", @id, "-fill #{color}")
|
||||
$update.e()
|
||||
sleep(0.1)
|
||||
@view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
|
||||
end
|
||||
end #-----------------------> class Square ends here
|
||||
|
||||
def initialize(othello, board)
|
||||
super($ip, $root, $canvas)
|
||||
@othello = othello
|
||||
@board = board
|
||||
@board.add_observer(self)
|
||||
|
||||
@squares = Array.new(8)
|
||||
for i in 0 .. 7
|
||||
@squares[i] = Array.new(8)
|
||||
end
|
||||
@left = 1
|
||||
@top = 0.5
|
||||
@right = @left + 8
|
||||
@bottom = @top + 8
|
||||
|
||||
i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
|
||||
self.e("itemconfigure", i,
|
||||
"-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
|
||||
super($ip, $root, $canvas)
|
||||
@othello = othello
|
||||
@board = board
|
||||
@board.add_observer(self)
|
||||
|
||||
@squares = Array.new(8)
|
||||
for i in 0 .. 7
|
||||
@squares[i] = Array.new(8)
|
||||
end
|
||||
@left = 1
|
||||
@top = 0.5
|
||||
@right = @left + 8
|
||||
@bottom = @top + 8
|
||||
|
||||
i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
|
||||
self.e("itemconfigure", i,
|
||||
"-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
|
||||
|
||||
for row in 0 .. 7
|
||||
for col in 0 .. 7
|
||||
@squares[row][col] = Square.new(self, row, col)
|
||||
end
|
||||
end
|
||||
|
||||
update
|
||||
for row in 0 .. 7
|
||||
for col in 0 .. 7
|
||||
@squares[row][col] = Square.new(self, row, col)
|
||||
end
|
||||
end
|
||||
|
||||
update
|
||||
end
|
||||
|
||||
def tk_rect(left, top, right, bottom)
|
||||
return left.to_s + "c", top.to_s + "c",
|
||||
right.to_s + "c", bottom.to_s + "c"
|
||||
return left.to_s + "c", top.to_s + "c",
|
||||
right.to_s + "c", bottom.to_s + "c"
|
||||
end
|
||||
|
||||
def clear
|
||||
each_square do |square|
|
||||
if square.oval != nil
|
||||
self.e("delete", square.oval)
|
||||
square.oval = nil
|
||||
end
|
||||
end
|
||||
each_square do |square|
|
||||
if square.oval != nil
|
||||
self.e("delete", square.oval)
|
||||
square.oval = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def draw_disk(row, col, disk)
|
||||
if disk == EMPTY
|
||||
if @squares[row][col].oval != nil
|
||||
self.e("delete", @squares[row][col].oval)
|
||||
@squares[row][col].oval = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
$update.e()
|
||||
sleep(0.05)
|
||||
oval = @squares[row][col].oval
|
||||
if oval == nil
|
||||
oval = self.e("create oval", *tk_rect(@left + col + 0.2,
|
||||
@top + row + 0.2,
|
||||
@left + col + 0.8,
|
||||
@top + row + 0.8))
|
||||
@squares[row][col].oval = oval
|
||||
end
|
||||
case disk
|
||||
when BLACK
|
||||
color = BLACK_COLOR
|
||||
when WHITE
|
||||
color = WHITE_COLOR
|
||||
else
|
||||
fail format("Unknown disk type: %d", disk)
|
||||
end
|
||||
self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
|
||||
if disk == EMPTY
|
||||
if @squares[row][col].oval != nil
|
||||
self.e("delete", @squares[row][col].oval)
|
||||
@squares[row][col].oval = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
$update.e()
|
||||
sleep(0.05)
|
||||
oval = @squares[row][col].oval
|
||||
if oval == nil
|
||||
oval = self.e("create oval", *tk_rect(@left + col + 0.2,
|
||||
@top + row + 0.2,
|
||||
@left + col + 0.8,
|
||||
@top + row + 0.8))
|
||||
@squares[row][col].oval = oval
|
||||
end
|
||||
case disk
|
||||
when BLACK
|
||||
color = BLACK_COLOR
|
||||
when WHITE
|
||||
color = WHITE_COLOR
|
||||
else
|
||||
fail format("Unknown disk type: %d", disk)
|
||||
end
|
||||
self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
|
||||
end
|
||||
|
||||
def update(row = nil, col = nil)
|
||||
if row && col
|
||||
draw_disk(row, col, @board.get_disk(row, col))
|
||||
else
|
||||
each_square do |square|
|
||||
draw_disk(square.row, square.col,
|
||||
@board.get_disk(square.row, square.col))
|
||||
end
|
||||
end
|
||||
@othello.show_point
|
||||
if row && col
|
||||
draw_disk(row, col, @board.get_disk(row, col))
|
||||
else
|
||||
each_square do |square|
|
||||
draw_disk(square.row, square.col,
|
||||
@board.get_disk(square.row, square.col))
|
||||
end
|
||||
end
|
||||
@othello.show_point
|
||||
end
|
||||
|
||||
def each_square
|
||||
@squares.each do |rows|
|
||||
rows.each do |square|
|
||||
yield(square)
|
||||
end
|
||||
end
|
||||
@squares.each do |rows|
|
||||
rows.each do |square|
|
||||
yield(square)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def click_square(square)
|
||||
if @othello.in_com_turn || @othello.game_over ||
|
||||
@board.count_point(square.row,
|
||||
square.col,
|
||||
@board.man_disk) == 0
|
||||
square.blink(STOP_COLOR)
|
||||
return
|
||||
end
|
||||
@board.put_disk(square.row, square.col, @board.man_disk)
|
||||
@othello.com_turn
|
||||
if @othello.in_com_turn || @othello.game_over ||
|
||||
@board.count_point(square.row,
|
||||
square.col,
|
||||
@board.man_disk) == 0
|
||||
square.blink(STOP_COLOR)
|
||||
return
|
||||
end
|
||||
@board.put_disk(square.row, square.col, @board.man_disk)
|
||||
@othello.com_turn
|
||||
end
|
||||
|
||||
private :draw_disk
|
||||
|
@ -347,7 +347,7 @@ class Othello
|
|||
@board_view.e("configure -height", y2 - y1)
|
||||
## scrollregion を設定する.
|
||||
@board_view.e("configure -scrollregion {", @board_view.e("bbox all"),
|
||||
"}")
|
||||
"}")
|
||||
#### ここまで
|
||||
$pack.e(@board_view, "-fill both -expand true")
|
||||
|
||||
|
@ -355,19 +355,19 @@ class Othello
|
|||
|
||||
@play_black = TclTkWidget.new($ip, panel, $checkbutton,
|
||||
"-text {com is black} -command", TclTkCallback.new($ip, proc{
|
||||
switch_side
|
||||
switch_side
|
||||
}))
|
||||
$pack.e(@play_black, "-side left")
|
||||
|
||||
quit = TclTkWidget.new($ip, panel, $button, "-text Quit -command",
|
||||
TclTkCallback.new($ip, proc{
|
||||
exit
|
||||
TclTkCallback.new($ip, proc{
|
||||
exit
|
||||
}))
|
||||
$pack.e(quit, "-side right -fill x")
|
||||
|
||||
reset = TclTkWidget.new($ip, panel, $button, "-text Reset -command",
|
||||
TclTkCallback.new($ip, proc{
|
||||
reset_game
|
||||
TclTkCallback.new($ip, proc{
|
||||
reset_game
|
||||
}))
|
||||
$pack.e(reset, "-side right -fill x")
|
||||
|
||||
|
@ -385,17 +385,17 @@ class Othello
|
|||
|
||||
def switch_side
|
||||
if @in_com_turn
|
||||
@play_black.e("toggle")
|
||||
@play_black.e("toggle")
|
||||
else
|
||||
@board.com_disk = @board.man_disk
|
||||
com_turn unless @game_over
|
||||
@board.com_disk = @board.man_disk
|
||||
com_turn unless @game_over
|
||||
end
|
||||
end
|
||||
|
||||
def reset_game
|
||||
if @board.com_disk == BLACK
|
||||
@board.com_disk = WHITE
|
||||
@play_black.e("toggle")
|
||||
@board.com_disk = WHITE
|
||||
@play_black.e("toggle")
|
||||
end
|
||||
@board_view.clear
|
||||
@board.reset
|
||||
|
@ -408,30 +408,30 @@ class Othello
|
|||
$update.e()
|
||||
sleep(0.5)
|
||||
begin
|
||||
com_disk = @board.count_disk(@board.com_disk)
|
||||
man_disk = @board.count_disk(@board.man_disk)
|
||||
if @board.count_disk(EMPTY) == 0
|
||||
if man_disk == com_disk
|
||||
$wm.e("title", $root, "{Othello - Draw!}")
|
||||
elsif man_disk > com_disk
|
||||
$wm.e("title", $root, "{Othello - You Win!}")
|
||||
else
|
||||
$wm.e("title", $root, "{Othello - You Loose!}")
|
||||
end
|
||||
@game_over = TRUE
|
||||
break
|
||||
elsif com_disk == 0
|
||||
$wm.e("title", $root, "{Othello - You Win!}")
|
||||
@game_over = TRUE
|
||||
break
|
||||
elsif man_disk == 0
|
||||
$wm.e("title", $root, "{Othello - You Loose!}")
|
||||
@game_over = TRUE
|
||||
break
|
||||
end
|
||||
row, col = @board.search(@board.com_disk)
|
||||
break if row == nil || col == nil
|
||||
@board.put_disk(row, col, @board.com_disk)
|
||||
com_disk = @board.count_disk(@board.com_disk)
|
||||
man_disk = @board.count_disk(@board.man_disk)
|
||||
if @board.count_disk(EMPTY) == 0
|
||||
if man_disk == com_disk
|
||||
$wm.e("title", $root, "{Othello - Draw!}")
|
||||
elsif man_disk > com_disk
|
||||
$wm.e("title", $root, "{Othello - You Win!}")
|
||||
else
|
||||
$wm.e("title", $root, "{Othello - You Loose!}")
|
||||
end
|
||||
@game_over = TRUE
|
||||
break
|
||||
elsif com_disk == 0
|
||||
$wm.e("title", $root, "{Othello - You Win!}")
|
||||
@game_over = TRUE
|
||||
break
|
||||
elsif man_disk == 0
|
||||
$wm.e("title", $root, "{Othello - You Loose!}")
|
||||
@game_over = TRUE
|
||||
break
|
||||
end
|
||||
row, col = @board.search(@board.com_disk)
|
||||
break if row == nil || col == nil
|
||||
@board.put_disk(row, col, @board.com_disk)
|
||||
end while @board.search(@board.man_disk) == [nil, nil]
|
||||
@in_com_turn = FALSE
|
||||
end
|
||||
|
@ -440,7 +440,7 @@ class Othello
|
|||
black = @board.count_disk(BLACK)
|
||||
white = @board.count_disk(WHITE)
|
||||
@msg_label.e("configure -text",
|
||||
%Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
|
||||
%Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
|
||||
end
|
||||
end #----------------------> class Othello ends here
|
||||
|
||||
|
|
|
@ -50,20 +50,20 @@ ruby_tcltk_stubs()
|
|||
#endif
|
||||
ruby_tk_dll = getenv("RUBY_TK_DLL");
|
||||
if (ruby_tcl_dll && ruby_tk_dll) {
|
||||
tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
|
||||
tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
|
||||
tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
|
||||
tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
|
||||
} else {
|
||||
snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
|
||||
snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
|
||||
/* examine from 8.9 to 8.1 */
|
||||
for (n = '9'; n > '0'; n--) {
|
||||
tcl_name[TCL_INDEX] = n;
|
||||
tk_name[TK_INDEX] = n;
|
||||
tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
|
||||
tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
|
||||
if (tcl_dll && tk_dll)
|
||||
break;
|
||||
}
|
||||
snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
|
||||
snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
|
||||
/* examine from 8.9 to 8.1 */
|
||||
for (n = '9'; n > '0'; n--) {
|
||||
tcl_name[TCL_INDEX] = n;
|
||||
tk_name[TK_INDEX] = n;
|
||||
tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
|
||||
tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
|
||||
if (tcl_dll && tk_dll)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined _WIN32
|
||||
|
@ -71,31 +71,31 @@ ruby_tcltk_stubs()
|
|||
#endif
|
||||
|
||||
if (!tcl_dll || !tk_dll)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
p_Tcl_FindExecutable = (void (*)(const char *))DL_SYM(tcl_dll, "Tcl_FindExecutable");
|
||||
if (!p_Tcl_FindExecutable)
|
||||
return -7;
|
||||
return -7;
|
||||
|
||||
p_Tcl_FindExecutable("ruby");
|
||||
|
||||
p_Tcl_CreateInterp = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp");
|
||||
if (!p_Tcl_CreateInterp)
|
||||
return -2;
|
||||
return -2;
|
||||
|
||||
tcl_ip = (*p_Tcl_CreateInterp)();
|
||||
if (!tcl_ip)
|
||||
return -3;
|
||||
return -3;
|
||||
|
||||
p_Tk_Init = (int (*)(Tcl_Interp *))DL_SYM(tk_dll, "Tk_Init");
|
||||
if (!p_Tk_Init)
|
||||
return -4;
|
||||
return -4;
|
||||
(*p_Tk_Init)(tcl_ip);
|
||||
|
||||
if (!Tcl_InitStubs(tcl_ip, "8.1", 0))
|
||||
return -5;
|
||||
return -5;
|
||||
if (!Tk_InitStubs(tcl_ip, "8.1", 0))
|
||||
return -6;
|
||||
return -6;
|
||||
|
||||
Tcl_DeleteInterp(tcl_ip);
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# remote-tk.rb - supports to control remote Tk interpreters
|
||||
# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
# remote-tk.rb - supports to control remote Tk interpreters
|
||||
# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
if defined? MultiTkIp
|
||||
fail RuntimeError, "'remote-tk' library must be required before requiring 'multi-tk'"
|
||||
|
@ -137,14 +137,14 @@ class RemoteTkIp
|
|||
return nil if timeout < 1
|
||||
@ret_val.value = ''
|
||||
@interp._invoke('send', '-async', @remote,
|
||||
'send', '-async', Tk.appname,
|
||||
"set #{@ret_val.id} ready")
|
||||
'send', '-async', Tk.appname,
|
||||
"set #{@ret_val.id} ready")
|
||||
Tk.update
|
||||
if @ret_val != 'ready'
|
||||
(1..(timeout*5)).each{
|
||||
sleep 0.2
|
||||
Tk.update
|
||||
break if @ret_val == 'ready'
|
||||
sleep 0.2
|
||||
Tk.update
|
||||
break if @ret_val == 'ready'
|
||||
}
|
||||
end
|
||||
@ret_val.value == 'ready'
|
||||
|
@ -154,16 +154,16 @@ class RemoteTkIp
|
|||
def _create_connection
|
||||
ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
|
||||
if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
|
||||
set _rubytk_control_ip_id_ 0
|
||||
set _rubytk_control_ip_id_ 0
|
||||
} else {
|
||||
set _rubytk_control_ip_id_ [expr $ret + 1]
|
||||
set _rubytk_control_ip_id_ [expr $ret + 1]
|
||||
}
|
||||
return $_rubytk_control_ip_id_
|
||||
EOS
|
||||
|
||||
@interp._invoke('send', @remote, <<-EOS)
|
||||
proc rb_out#{ip_id} args {
|
||||
send #{@appname} rb_out \$args
|
||||
send #{@appname} rb_out \$args
|
||||
}
|
||||
EOS
|
||||
|
||||
|
@ -182,17 +182,17 @@ class RemoteTkIp
|
|||
cmds = @interp._merge_tklist(*_conv_args([], enc_mode, *cmds))
|
||||
if @displayof
|
||||
if async
|
||||
@interp.__invoke('send', '-async', '-displayof', @displayof,
|
||||
'--', @remote, *cmds)
|
||||
@interp.__invoke('send', '-async', '-displayof', @displayof,
|
||||
'--', @remote, *cmds)
|
||||
else
|
||||
@interp.__invoke('send', '-displayof', @displayof,
|
||||
'--', @remote, *cmds)
|
||||
@interp.__invoke('send', '-displayof', @displayof,
|
||||
'--', @remote, *cmds)
|
||||
end
|
||||
else
|
||||
if async
|
||||
@interp.__invoke('send', '-async', '--', @remote, *cmds)
|
||||
@interp.__invoke('send', '-async', '--', @remote, *cmds)
|
||||
else
|
||||
@interp.__invoke('send', '--', @remote, *cmds)
|
||||
@interp.__invoke('send', '--', @remote, *cmds)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -271,7 +271,7 @@ class RemoteTkIp
|
|||
def deleted?
|
||||
if @displayof
|
||||
lst = @interp._invoke_without_enc('winfo', 'interps',
|
||||
'-displayof', @displayof)
|
||||
'-displayof', @displayof)
|
||||
else
|
||||
lst = @interp._invoke_without_enc('winfo', 'interps')
|
||||
end
|
||||
|
|
1852
ext/tk/lib/tk.rb
1852
ext/tk/lib/tk.rb
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,9 +1,7 @@
|
|||
#
|
||||
# tk/canvas.rb - Tk canvas classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
# $Date$
|
||||
# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
|
||||
# tk/canvas.rb - Tk canvas classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
#
|
||||
require 'tk'
|
||||
require 'tk/canvastag'
|
||||
|
@ -93,7 +91,7 @@ class TkCanvas<TkWindow
|
|||
|
||||
def bbox(tagOrId, *tags)
|
||||
list(tk_send_without_enc('bbox', tagid(tagOrId),
|
||||
*tags.collect{|t| tagid(t)}))
|
||||
*tags.collect{|t| tagid(t)}))
|
||||
end
|
||||
|
||||
def itembind(tag, context, cmd=Proc.new, args=nil)
|
||||
|
@ -135,14 +133,14 @@ class TkCanvas<TkWindow
|
|||
|
||||
def dchars(tag, first, last=None)
|
||||
tk_send_without_enc('dchars', tagid(tag),
|
||||
_get_eval_enc_str(first), _get_eval_enc_str(last))
|
||||
_get_eval_enc_str(first), _get_eval_enc_str(last))
|
||||
self
|
||||
end
|
||||
|
||||
def delete(*args)
|
||||
if TkcItem::CItemID_TBL[self.path]
|
||||
find('withtag', *args).each{|item|
|
||||
TkcItem::CItemID_TBL[self.path].delete(item.id)
|
||||
TkcItem::CItemID_TBL[self.path].delete(item.id)
|
||||
}
|
||||
end
|
||||
tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
|
||||
|
@ -189,9 +187,9 @@ class TkCanvas<TkWindow
|
|||
else
|
||||
ret = tk_send_without_enc('focus')
|
||||
if ret == ""
|
||||
nil
|
||||
nil
|
||||
else
|
||||
TkcItem.id2obj(self, ret)
|
||||
TkcItem.id2obj(self, ret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -213,7 +211,7 @@ class TkCanvas<TkWindow
|
|||
|
||||
def insert(tagOrId, index, string)
|
||||
tk_send_without_enc('insert', tagid(tagOrId), index,
|
||||
_get_eval_enc_str(string))
|
||||
_get_eval_enc_str(string))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -223,9 +221,9 @@ class TkCanvas<TkWindow
|
|||
when 'dash', 'activedash', 'disableddash'
|
||||
conf = tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}")
|
||||
if conf =~ /^[0-9]/
|
||||
list(conf)
|
||||
list(conf)
|
||||
else
|
||||
conf
|
||||
conf
|
||||
end
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}"))
|
||||
|
@ -233,17 +231,17 @@ class TkCanvas<TkWindow
|
|||
#fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}"))
|
||||
fnt = tk_tcl2ruby(_fromUTF8(tk_send_with_enc('itemcget', tagid(tagOrId), '-font')))
|
||||
unless fnt.kind_of?(TkFont)
|
||||
fnt = tagfontobj(tagid(tagOrId), fnt)
|
||||
fnt = tagfontobj(tagid(tagOrId), fnt)
|
||||
end
|
||||
if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
else
|
||||
fnt
|
||||
fnt
|
||||
end
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
|
||||
"-#{option}")))
|
||||
"-#{option}")))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -254,28 +252,28 @@ class TkCanvas<TkWindow
|
|||
self.coords(tagOrId, coords) if coords
|
||||
|
||||
if ( key['font'] || key['kanjifont'] \
|
||||
|| key['latinfont'] || key['asciifont'] )
|
||||
tagfont_configure(tagid(tagOrId), key.dup)
|
||||
|| key['latinfont'] || key['asciifont'] )
|
||||
tagfont_configure(tagid(tagOrId), key.dup)
|
||||
else
|
||||
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
|
||||
*hash_kv(key, true)))
|
||||
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
|
||||
*hash_kv(key, true)))
|
||||
end
|
||||
|
||||
else
|
||||
if ( key == 'coords' || key == :coords )
|
||||
self.coords(tagOrId, value)
|
||||
self.coords(tagOrId, value)
|
||||
elsif ( key == 'font' || key == :font ||
|
||||
key == 'kanjifont' || key == :kanjifont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'asciifont' || key == :asciifont )
|
||||
if value == None
|
||||
tagfontobj(tagid(tagOrId))
|
||||
else
|
||||
tagfont_configure(tagid(tagOrId), {key=>value})
|
||||
end
|
||||
key == 'kanjifont' || key == :kanjifont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'asciifont' || key == :asciifont )
|
||||
if value == None
|
||||
tagfontobj(tagid(tagOrId))
|
||||
else
|
||||
tagfont_configure(tagid(tagOrId), {key=>value})
|
||||
end
|
||||
else
|
||||
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
|
||||
"-#{key}", _get_eval_enc_str(value)))
|
||||
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
|
||||
"-#{key}", _get_eval_enc_str(value)))
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -294,142 +292,142 @@ class TkCanvas<TkWindow
|
|||
def itemconfiginfo(tagOrId, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'coords'
|
||||
return ['coords', '', '', '', self.coords(tagOrId)]
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
case key.to_s
|
||||
when 'coords'
|
||||
return ['coords', '', '', '', self.coords(tagOrId)]
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
|
||||
fontconf = ret.assoc('font')
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
|
||||
ret.push(fontconf)
|
||||
end
|
||||
fontconf = ret.assoc('font')
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
|
||||
ret.push(fontconf)
|
||||
end
|
||||
|
||||
ret << ['coords', '', '', '', self.coords(tagOrId)]
|
||||
ret << ['coords', '', '', '', self.coords(tagOrId)]
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'coords'
|
||||
{'coords' => ['', '', '', self.coords(tagOrId)]}
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
|
||||
tagid(tagOrId),
|
||||
"-#{key}"))
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
case key.to_s
|
||||
when 'coords'
|
||||
{'coords' => ['', '', '', self.coords(tagOrId)]}
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
|
||||
tagid(tagOrId),
|
||||
"-#{key}"))
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
if conf[4] && conf[4] =~ /^[0-9]/
|
||||
conf[4] = list(conf[4])
|
||||
end
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
if conf[2] && conf[2] =~ /^[0-9]/
|
||||
conf[2] = list(conf[2])
|
||||
end
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||
when 'dash', 'activedash', 'disableddash'
|
||||
if conf[2] && conf[2] =~ /^[0-9]/
|
||||
conf[2] = list(conf[2])
|
||||
end
|
||||
if conf[3] && conf[3] =~ /^[0-9]/
|
||||
conf[3] = list(conf[3])
|
||||
end
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
|
||||
ret['coords'] = ['', '', '', self.coords(tagOrId)]
|
||||
ret['coords'] = ['', '', '', self.coords(tagOrId)]
|
||||
|
||||
ret
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -437,19 +435,19 @@ class TkCanvas<TkWindow
|
|||
def current_itemconfiginfo(tagOrId, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
conf = itemconfiginfo(tagOrId, key)
|
||||
{conf[0] => conf[4]}
|
||||
conf = itemconfiginfo(tagOrId, key)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
itemconfiginfo(tagOrId).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
itemconfiginfo(tagOrId).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
itemconfiginfo(tagOrId, key).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
@ -551,32 +549,32 @@ class TkcItem<TkObject
|
|||
if args[-1].kind_of? Hash
|
||||
keys = _symbolkey2str(args.pop)
|
||||
if args.size == 0
|
||||
args = keys.delete('coords')
|
||||
unless args.kind_of?(Array)
|
||||
fail "coords parameter must be given by an Array"
|
||||
end
|
||||
args = keys.delete('coords')
|
||||
unless args.kind_of?(Array)
|
||||
fail "coords parameter must be given by an Array"
|
||||
end
|
||||
end
|
||||
|
||||
#['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
|
||||
# fontkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
#}
|
||||
__item_font_optkeys(nil).each{|key|
|
||||
fkey = key.to_s
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
fkey = key.to_s
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
|
||||
fkey = "kanji#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
fkey = "kanji#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
|
||||
fkey = "latin#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
fkey = "latin#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
|
||||
fkey = "ascii#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
fkey = "ascii#{key}"
|
||||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
}
|
||||
|
||||
__item_methodcall_optkeys(nil).each{|key|
|
||||
key = key.to_s
|
||||
methodkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
key = key.to_s
|
||||
methodkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
}
|
||||
|
||||
#args = args.flatten.concat(hash_kv(keys))
|
||||
|
@ -595,7 +593,7 @@ class TkcItem<TkObject
|
|||
end
|
||||
args, fontkeys = _parse_create_args(args)
|
||||
idnum = tk_call_without_enc(canvas.path, 'create',
|
||||
self::CItemTypeName, *args)
|
||||
self::CItemTypeName, *args)
|
||||
canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
|
||||
idnum.to_i # 'canvas item id' is an integer number
|
||||
end
|
||||
|
|
|
@ -8,45 +8,45 @@ module Tk
|
|||
def self.clicks(ms=nil)
|
||||
case ms
|
||||
when nil
|
||||
tk_call_without_enc('clock','clicks').to_i
|
||||
tk_call_without_enc('clock','clicks').to_i
|
||||
when /^mic/
|
||||
tk_call_without_enc('clock','clicks','-microseconds').to_i
|
||||
tk_call_without_enc('clock','clicks','-microseconds').to_i
|
||||
when /^mil/
|
||||
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
||||
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
||||
else
|
||||
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
||||
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
||||
end
|
||||
end
|
||||
|
||||
def self.format(clk, form=nil)
|
||||
if form
|
||||
tk_call('clock','format',clk,'-format',form)
|
||||
tk_call('clock','format',clk,'-format',form)
|
||||
else
|
||||
tk_call('clock','format',clk)
|
||||
tk_call('clock','format',clk)
|
||||
end
|
||||
end
|
||||
|
||||
def self.formatGMT(clk, form=nil)
|
||||
if form
|
||||
tk_call('clock','format',clk,'-format',form,'-gmt','1')
|
||||
tk_call('clock','format',clk,'-format',form,'-gmt','1')
|
||||
else
|
||||
tk_call('clock','format',clk,'-gmt','1')
|
||||
tk_call('clock','format',clk,'-gmt','1')
|
||||
end
|
||||
end
|
||||
|
||||
def self.scan(str, base=nil)
|
||||
if base
|
||||
tk_call('clock','scan',str,'-base',base).to_i
|
||||
tk_call('clock','scan',str,'-base',base).to_i
|
||||
else
|
||||
tk_call('clock','scan',str).to_i
|
||||
tk_call('clock','scan',str).to_i
|
||||
end
|
||||
end
|
||||
|
||||
def self.scanGMT(str, base=nil)
|
||||
if base
|
||||
tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
|
||||
tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
|
||||
else
|
||||
tk_call('clock','scan',str,'-gmt','1').to_i
|
||||
tk_call('clock','scan',str,'-gmt','1').to_i
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ module TkComposite
|
|||
m_cget = m_cget.to_s if m_cget
|
||||
m_info = m_info.to_s if m_info
|
||||
@option_methods[m_set] = {
|
||||
:set => m_set, :cget => m_cget, :info => m_info
|
||||
:set => m_set, :cget => m_cget, :info => m_info
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -55,9 +55,9 @@ module TkComposite
|
|||
option = option.to_s
|
||||
if @delegates[alias_opt].kind_of?(Array)
|
||||
if (elem = @delegates[alias_opt].assoc(option))
|
||||
wins.each{|w| elem[1].push(w)}
|
||||
wins.each{|w| elem[1].push(w)}
|
||||
else
|
||||
@delegates[alias_opt] << [option, wins]
|
||||
@delegates[alias_opt] << [option, wins]
|
||||
end
|
||||
else
|
||||
@delegates[alias_opt] = [ [option, wins] ]
|
||||
|
@ -73,13 +73,13 @@ module TkComposite
|
|||
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:cget]
|
||||
return self.__send__(@option_methods[slot][:cget])
|
||||
return self.__send__(@option_methods[slot][:cget])
|
||||
else
|
||||
if @option_setting[slot]
|
||||
return @option_setting[slot]
|
||||
else
|
||||
return ''
|
||||
end
|
||||
if @option_setting[slot]
|
||||
return @option_setting[slot]
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,11 +88,11 @@ module TkComposite
|
|||
|
||||
begin
|
||||
if tbl
|
||||
opt, wins = tbl[-1]
|
||||
opt = slot if opt == 'DEFAULT'
|
||||
if wins && wins[-1]
|
||||
return wins[-1].cget(opt)
|
||||
end
|
||||
opt, wins = tbl[-1]
|
||||
opt = slot if opt == 'DEFAULT'
|
||||
if wins && wins[-1]
|
||||
return wins[-1].cget(opt)
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
@ -110,11 +110,11 @@ module TkComposite
|
|||
|
||||
if @option_methods.include?(slot)
|
||||
unless @option_methods[slot][:cget]
|
||||
if value.kind_of?(Symbol)
|
||||
@option_setting[slot] = value.to_s
|
||||
else
|
||||
@option_setting[slot] = value
|
||||
end
|
||||
if value.kind_of?(Symbol)
|
||||
@option_setting[slot] = value.to_s
|
||||
else
|
||||
@option_setting[slot] = value
|
||||
end
|
||||
end
|
||||
return self.__send__(@option_methods[slot][:set], value)
|
||||
end
|
||||
|
@ -124,12 +124,12 @@ module TkComposite
|
|||
|
||||
begin
|
||||
if tbl
|
||||
last = nil
|
||||
tbl.each{|opt, wins|
|
||||
opt = slot if opt == 'DEFAULT'
|
||||
wins.each{|w| last = w.configure(opt, value)}
|
||||
}
|
||||
return last
|
||||
last = nil
|
||||
tbl.each{|opt, wins|
|
||||
opt = slot if opt == 'DEFAULT'
|
||||
wins.each{|w| last = w.configure(opt, value)}
|
||||
}
|
||||
return last
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
@ -140,153 +140,153 @@ module TkComposite
|
|||
def configinfo(slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:info]
|
||||
return self.__send__(@option_methods[slot][:info])
|
||||
else
|
||||
return [slot, '', '', '', self.cget(slot)]
|
||||
end
|
||||
end
|
||||
slot = slot.to_s
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:info]
|
||||
return self.__send__(@option_methods[slot][:info])
|
||||
else
|
||||
return [slot, '', '', '', self.cget(slot)]
|
||||
end
|
||||
end
|
||||
|
||||
tbl = @delegates[slot]
|
||||
tbl = @delegates['DEFAULT'] unless tbl
|
||||
tbl = @delegates[slot]
|
||||
tbl = @delegates['DEFAULT'] unless tbl
|
||||
|
||||
begin
|
||||
if tbl
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
if slot == opt || opt == 'DEFAULT'
|
||||
return wins[-1].configinfo(slot)
|
||||
else
|
||||
info = wins[-1].configinfo(opt)
|
||||
info[0] = slot
|
||||
return info
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
return [slot, '', '', '', wins[-1].cget(opt)]
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
begin
|
||||
if tbl
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
if slot == opt || opt == 'DEFAULT'
|
||||
return wins[-1].configinfo(slot)
|
||||
else
|
||||
info = wins[-1].configinfo(opt)
|
||||
info[0] = slot
|
||||
return info
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
return [slot, '', '', '', wins[-1].cget(opt)]
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
super
|
||||
super
|
||||
|
||||
else # slot == nil
|
||||
info_list = super
|
||||
info_list = super
|
||||
|
||||
tbl = @delegates['DEFAULT']
|
||||
if tbl
|
||||
wins = tbl[0][1]
|
||||
if wins && wins[-1]
|
||||
wins[-1].configinfo.each{|info|
|
||||
slot = info[0]
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
}
|
||||
end
|
||||
end
|
||||
tbl = @delegates['DEFAULT']
|
||||
if tbl
|
||||
wins = tbl[0][1]
|
||||
if wins && wins[-1]
|
||||
wins[-1].configinfo.each{|info|
|
||||
slot = info[0]
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@delegates.each{|slot, tbl|
|
||||
next if slot == 'DEFAULT'
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
next unless wins && wins[-1]
|
||||
if slot == opt
|
||||
info_list.delete_if{|i| i[0] == slot} <<
|
||||
wins[-1].configinfo(slot)
|
||||
else
|
||||
info = wins[-1].configinfo(opt)
|
||||
info[0] = slot
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
info_list.delete_if{|i| i[0] == slot} <<
|
||||
[slot, '', '', '', wins[-1].cget(opt)]
|
||||
end
|
||||
}
|
||||
@delegates.each{|slot, tbl|
|
||||
next if slot == 'DEFAULT'
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
next unless wins && wins[-1]
|
||||
if slot == opt
|
||||
info_list.delete_if{|i| i[0] == slot} <<
|
||||
wins[-1].configinfo(slot)
|
||||
else
|
||||
info = wins[-1].configinfo(opt)
|
||||
info[0] = slot
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
info_list.delete_if{|i| i[0] == slot} <<
|
||||
[slot, '', '', '', wins[-1].cget(opt)]
|
||||
end
|
||||
}
|
||||
|
||||
@option_methods.each{|slot, m|
|
||||
if m[:info]
|
||||
info = self.__send__(m[:info])
|
||||
else
|
||||
info = [slot, '', '', '', self.cget(slot)]
|
||||
end
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
}
|
||||
@option_methods.each{|slot, m|
|
||||
if m[:info]
|
||||
info = self.__send__(m[:info])
|
||||
else
|
||||
info = [slot, '', '', '', self.cget(slot)]
|
||||
end
|
||||
info_list.delete_if{|i| i[0] == slot} << info
|
||||
}
|
||||
|
||||
info_list
|
||||
info_list
|
||||
end
|
||||
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:info]
|
||||
return self.__send__(@option_methods[slot][:info])
|
||||
else
|
||||
return {slot => ['', '', '', self.cget(slot)]}
|
||||
end
|
||||
end
|
||||
slot = slot.to_s
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:info]
|
||||
return self.__send__(@option_methods[slot][:info])
|
||||
else
|
||||
return {slot => ['', '', '', self.cget(slot)]}
|
||||
end
|
||||
end
|
||||
|
||||
tbl = @delegates[slot]
|
||||
tbl = @delegates['DEFAULT'] unless tbl
|
||||
tbl = @delegates[slot]
|
||||
tbl = @delegates['DEFAULT'] unless tbl
|
||||
|
||||
begin
|
||||
if tbl
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
if slot == opt || opt == 'DEFAULT'
|
||||
return wins[-1].configinfo(slot)
|
||||
else
|
||||
return {slot => wins[-1].configinfo(opt)[opt]}
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
return {slot => ['', '', '', wins[-1].cget(opt)]}
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
begin
|
||||
if tbl
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
if slot == opt || opt == 'DEFAULT'
|
||||
return wins[-1].configinfo(slot)
|
||||
else
|
||||
return {slot => wins[-1].configinfo(opt)[opt]}
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
return {slot => ['', '', '', wins[-1].cget(opt)]}
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
super
|
||||
super
|
||||
|
||||
else # slot == nil
|
||||
info_list = super
|
||||
info_list = super
|
||||
|
||||
tbl = @delegates['DEFAULT']
|
||||
if tbl
|
||||
wins = tbl[0][1]
|
||||
info_list.update(wins[-1].configinfo) if wins && wins[-1]
|
||||
end
|
||||
tbl = @delegates['DEFAULT']
|
||||
if tbl
|
||||
wins = tbl[0][1]
|
||||
info_list.update(wins[-1].configinfo) if wins && wins[-1]
|
||||
end
|
||||
|
||||
@delegates.each{|slot, tbl|
|
||||
next if slot == 'DEFAULT'
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
next unless wins && wins[-1]
|
||||
if slot == opt
|
||||
info_list.update(wins[-1].configinfo(slot))
|
||||
else
|
||||
info_list.update({slot => wins[-1].configinfo(opt)[opt]})
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
|
||||
end
|
||||
}
|
||||
@delegates.each{|slot, tbl|
|
||||
next if slot == 'DEFAULT'
|
||||
if tbl.length == 1
|
||||
opt, wins = tbl[0]
|
||||
next unless wins && wins[-1]
|
||||
if slot == opt
|
||||
info_list.update(wins[-1].configinfo(slot))
|
||||
else
|
||||
info_list.update({slot => wins[-1].configinfo(opt)[opt]})
|
||||
end
|
||||
else
|
||||
opt, wins = tbl[-1]
|
||||
info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
|
||||
end
|
||||
}
|
||||
|
||||
@option_methods.each{|slot, m|
|
||||
if m[:info]
|
||||
info = self.__send__(m[:info])
|
||||
else
|
||||
info = {slot => ['', '', '', self.cget(slot)]}
|
||||
end
|
||||
info_list.update(info)
|
||||
}
|
||||
@option_methods.each{|slot, m|
|
||||
if m[:info]
|
||||
info = self.__send__(m[:info])
|
||||
else
|
||||
info = {slot => ['', '', '', self.cget(slot)]}
|
||||
end
|
||||
info_list.update(info)
|
||||
}
|
||||
|
||||
info_list
|
||||
info_list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,6 @@ module TkConsole
|
|||
# I have no idea to support a Ruby script seamlessly.
|
||||
#
|
||||
_fromUTF8(tk_call_without_enc('console', 'eval',
|
||||
_get_eval_enc_str(tcl_script)))
|
||||
_get_eval_enc_str(tcl_script)))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,34 +17,34 @@ class TkDialog2 < TkWindow
|
|||
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")
|
||||
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 << Kernel.format("%s.button%s configure %s; ",
|
||||
# @path, i, hash_kv(c).join(' '))
|
||||
# @path, i, hash_kv(c).join(' '))
|
||||
@config << @path+'.button'+i.to_s+'configure '+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
|
||||
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
|
||||
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
|
||||
if (c = configs[s]).kind_of? Hash
|
||||
set_config.call(c,i)
|
||||
end
|
||||
}
|
||||
end
|
||||
@config = 'after idle {' + @config + '};' if @config != ""
|
||||
|
@ -99,7 +99,7 @@ class TkDialog2 < TkWindow
|
|||
|
||||
if @buttons.kind_of? Array
|
||||
_set_button_config(@buttons.collect{|cfg|
|
||||
(cfg.kind_of? Array)? cfg[1]: nil})
|
||||
(cfg.kind_of? Array)? cfg[1]: nil})
|
||||
@buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
|
||||
end
|
||||
if @buttons.kind_of? Hash
|
||||
|
@ -109,36 +109,36 @@ class TkDialog2 < TkWindow
|
|||
@buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String
|
||||
@buttons = @buttons.collect{|s|
|
||||
if s.kind_of? Array
|
||||
s = s.join(' ')
|
||||
s = s.join(' ')
|
||||
end
|
||||
if s.include? ?\s
|
||||
'{' + s + '}'
|
||||
'{' + s + '}'
|
||||
else
|
||||
s
|
||||
s
|
||||
end
|
||||
}
|
||||
|
||||
if @message_config.kind_of? Hash
|
||||
# @config << Kernel.format("%s.msg configure %s;",
|
||||
# @path, hash_kv(@message_config).join(' '))
|
||||
# @path, hash_kv(@message_config).join(' '))
|
||||
@config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
|
||||
end
|
||||
|
||||
if @msgframe_config.kind_of? Hash
|
||||
# @config << Kernel.format("%s.top configure %s;",
|
||||
# @path, hash_kv(@msgframe_config).join(' '))
|
||||
# @path, hash_kv(@msgframe_config).join(' '))
|
||||
@config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
|
||||
end
|
||||
|
||||
if @btnframe_config.kind_of? Hash
|
||||
# @config << Kernel.format("%s.bot configure %s;",
|
||||
# @path, hash_kv(@btnframe_config).join(' '))
|
||||
# @path, hash_kv(@btnframe_config).join(' '))
|
||||
@config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
|
||||
end
|
||||
|
||||
if @bitmap_config.kind_of? Hash
|
||||
# @config << Kernel.format("%s.bitmap configure %s;",
|
||||
# @path, hash_kv(@bitmap_config).join(' '))
|
||||
# @path, hash_kv(@bitmap_config).join(' '))
|
||||
@config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
|
||||
end
|
||||
|
||||
|
@ -158,16 +158,16 @@ class TkDialog2 < TkWindow
|
|||
end
|
||||
default_button = '{}' if default_button == nil
|
||||
#Tk.ip_eval('eval {global '+@var.id+';'+@config+
|
||||
# 'set '+@var.id+' [tk_dialog '+
|
||||
# @path+" "+@title+" {#{@message}} "+@bitmap+" "+
|
||||
# String(default_button)+" "+@buttons.join(' ')+']}')
|
||||
# 'set '+@var.id+' [tk_dialog '+
|
||||
# @path+" "+@title+" {#{@message}} "+@bitmap+" "+
|
||||
# String(default_button)+" "+@buttons.join(' ')+']}')
|
||||
Tk.ip_eval(@config)
|
||||
# @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
|
||||
# ' {' + @message + '} ' + @bitmap + ' ' +
|
||||
# String(default_button) + ' ' + @buttons.join(' ')).to_i
|
||||
# ' {' + @message + '} ' + @bitmap + ' ' +
|
||||
# String(default_button) + ' ' + @buttons.join(' ')).to_i
|
||||
@val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
|
||||
@title + ' {' + @message + '} ' + @bitmap + ' ' +
|
||||
String(default_button) + ' ' + @buttons.join(' ')).to_i
|
||||
@title + ' {' + @message + '} ' + @bitmap + ' ' +
|
||||
String(default_button) + ' ' + @buttons.join(' ')).to_i
|
||||
end
|
||||
|
||||
def value
|
||||
|
@ -248,10 +248,10 @@ class TkWarning2 < TkDialog2
|
|||
def initialize(parent = nil, mes = nil)
|
||||
if !mes
|
||||
if parent.kind_of? TkWindow
|
||||
mes = ""
|
||||
mes = ""
|
||||
else
|
||||
mes = parent.to_s
|
||||
parent = nil
|
||||
mes = parent.to_s
|
||||
parent = nil
|
||||
end
|
||||
end
|
||||
super(parent, :message=>mes)
|
||||
|
|
|
@ -24,11 +24,11 @@ module Tk
|
|||
|
||||
def self.utf_to_backslash_sequence(str)
|
||||
str.unpack('U*').collect{|c|
|
||||
if c <= 0xFF # ascii character
|
||||
c.chr
|
||||
else
|
||||
format('\u%X', c)
|
||||
end
|
||||
if c <= 0xFF # ascii character
|
||||
c.chr
|
||||
else
|
||||
format('\u%X', c)
|
||||
end
|
||||
}.join('')
|
||||
end
|
||||
def self.utf_to_backslash(str)
|
||||
|
@ -37,23 +37,23 @@ module Tk
|
|||
|
||||
def self.to_backslash_sequence(str)
|
||||
str.unpack('U*').collect{|c|
|
||||
if c <= 0x1F # control character
|
||||
case c
|
||||
when 0x07; '\a'
|
||||
when 0x08; '\b'
|
||||
when 0x09; '\t'
|
||||
when 0x0a; '\n'
|
||||
when 0x0b; '\v'
|
||||
when 0x0c; '\f'
|
||||
when 0x0d; '\r'
|
||||
else
|
||||
format('\x%02X', c)
|
||||
end
|
||||
elsif c <= 0xFF # ascii character
|
||||
c.chr
|
||||
else
|
||||
format('\u%X', c)
|
||||
end
|
||||
if c <= 0x1F # control character
|
||||
case c
|
||||
when 0x07; '\a'
|
||||
when 0x08; '\b'
|
||||
when 0x09; '\t'
|
||||
when 0x0a; '\n'
|
||||
when 0x0b; '\v'
|
||||
when 0x0c; '\f'
|
||||
when 0x0d; '\r'
|
||||
else
|
||||
format('\x%02X', c)
|
||||
end
|
||||
elsif c <= 0xFF # ascii character
|
||||
c.chr
|
||||
else
|
||||
format('\u%X', c)
|
||||
end
|
||||
}.join('')
|
||||
end
|
||||
|
||||
|
@ -68,8 +68,8 @@ module Tk
|
|||
def initialize(str, enc = nil)
|
||||
super(str)
|
||||
@encoding = ( enc ||
|
||||
((self.class::Encoding)?
|
||||
self.class::Encoding : Tk.encoding_system) )
|
||||
((self.class::Encoding)?
|
||||
self.class::Encoding : Tk.encoding_system) )
|
||||
end
|
||||
|
||||
attr_reader :encoding
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# tk/entry.rb - Tk entry classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
# tk/entry.rb - Tk entry classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
|
||||
require 'tk'
|
||||
require 'tk/label'
|
||||
|
|
|
@ -33,7 +33,7 @@ module TkEvent
|
|||
CreateNotify = 16
|
||||
DestroyNotify = 17
|
||||
UnmapNotify = 18
|
||||
MapNotify = 19
|
||||
MapNotify = 19
|
||||
MapRequest = 20
|
||||
ReparentNotify = 21
|
||||
ConfigureNotify = 22
|
||||
|
@ -93,12 +93,12 @@ module TkEvent
|
|||
[ ?w, TkComm.method(:window) ],
|
||||
|
||||
[ ?x, proc{|val|
|
||||
begin
|
||||
TkComm::number(val)
|
||||
rescue ArgumentError
|
||||
val
|
||||
end
|
||||
}
|
||||
begin
|
||||
TkComm::number(val)
|
||||
rescue ArgumentError
|
||||
val
|
||||
end
|
||||
}
|
||||
],
|
||||
|
||||
nil
|
||||
|
@ -141,14 +141,14 @@ module TkEvent
|
|||
keys = klass._get_subst_key(args)
|
||||
|
||||
if cmd.kind_of?(String)
|
||||
id = cmd
|
||||
id = cmd
|
||||
elsif cmd.kind_of?(TkCallbackEntry)
|
||||
id = install_cmd(cmd)
|
||||
id = install_cmd(cmd)
|
||||
else
|
||||
id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
|
||||
id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
|
||||
})
|
||||
end
|
||||
id + ' ' + args
|
||||
|
@ -156,15 +156,15 @@ module TkEvent
|
|||
keys, args = klass._get_all_subst_keys
|
||||
|
||||
if cmd.kind_of?(String)
|
||||
id = cmd
|
||||
id = cmd
|
||||
elsif cmd.kind_of?(TkCallbackEntry)
|
||||
id = install_cmd(cmd)
|
||||
id = install_cmd(cmd)
|
||||
else
|
||||
id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
TkUtil.eval_cmd(cmd,
|
||||
*(ex_args << klass.new(*klass.scan_args(keys, arg))))
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
TkUtil.eval_cmd(cmd,
|
||||
*(ex_args << klass.new(*klass.scan_args(keys, arg))))
|
||||
})
|
||||
end
|
||||
id + ' ' + args
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -33,9 +33,9 @@ module TkGrid
|
|||
args.each{|win|
|
||||
case win
|
||||
when '-', 'x', '^' # RELATIVE PLACEMENT
|
||||
params.push(win)
|
||||
params.push(win)
|
||||
else
|
||||
params.push(_epath(win))
|
||||
params.push(_epath(win))
|
||||
end
|
||||
}
|
||||
opts.each{|k, v|
|
||||
|
@ -50,7 +50,7 @@ module TkGrid
|
|||
# master = master.epath if master.kind_of?(TkObject)
|
||||
master = _epath(master)
|
||||
tk_call_without_enc("grid", 'columnconfigure',
|
||||
master, index, *hash_kv(args))
|
||||
master, index, *hash_kv(args))
|
||||
end
|
||||
|
||||
def rowconfigure(master, index, args)
|
||||
|
@ -65,24 +65,24 @@ module TkGrid
|
|||
if slot
|
||||
case slot
|
||||
when 'uniform', :uniform
|
||||
tk_call_without_enc('grid', 'columnconfigure',
|
||||
master, index, "-#{slot}")
|
||||
tk_call_without_enc('grid', 'columnconfigure',
|
||||
master, index, "-#{slot}")
|
||||
else
|
||||
num_or_str(tk_call_without_enc('grid', 'columnconfigure',
|
||||
master, index, "-#{slot}"))
|
||||
num_or_str(tk_call_without_enc('grid', 'columnconfigure',
|
||||
master, index, "-#{slot}"))
|
||||
end
|
||||
else
|
||||
#ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
|
||||
ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
|
||||
master, index))
|
||||
master, index))
|
||||
info = {}
|
||||
while key = ilist.shift
|
||||
case key
|
||||
when 'uniform'
|
||||
info[key[1..-1]] = ilist.shift
|
||||
else
|
||||
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
|
||||
end
|
||||
case key
|
||||
when 'uniform'
|
||||
info[key[1..-1]] = ilist.shift
|
||||
else
|
||||
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
|
||||
end
|
||||
end
|
||||
info
|
||||
end
|
||||
|
@ -94,24 +94,24 @@ module TkGrid
|
|||
if slot
|
||||
case slot
|
||||
when 'uniform', :uniform
|
||||
tk_call_without_enc('grid', 'rowconfigure',
|
||||
master, index, "-#{slot}")
|
||||
tk_call_without_enc('grid', 'rowconfigure',
|
||||
master, index, "-#{slot}")
|
||||
else
|
||||
num_or_str(tk_call_without_enc('grid', 'rowconfigure',
|
||||
master, index, "-#{slot}"))
|
||||
num_or_str(tk_call_without_enc('grid', 'rowconfigure',
|
||||
master, index, "-#{slot}"))
|
||||
end
|
||||
else
|
||||
#ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
|
||||
ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
|
||||
master, index))
|
||||
master, index))
|
||||
info = {}
|
||||
while key = ilist.shift
|
||||
case key
|
||||
when 'uniform'
|
||||
info[key[1..-1]] = ilist.shift
|
||||
else
|
||||
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
|
||||
end
|
||||
case key
|
||||
when 'uniform'
|
||||
info[key[1..-1]] = ilist.shift
|
||||
else
|
||||
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
|
||||
end
|
||||
end
|
||||
info
|
||||
end
|
||||
|
|
|
@ -65,9 +65,9 @@ class TkPhotoImage<TkImage
|
|||
keys = _symbolkey2str(keys)
|
||||
NullArgOptionKeys.collect{|opt|
|
||||
if keys[opt]
|
||||
keys[opt] = None
|
||||
keys[opt] = None
|
||||
else
|
||||
keys.delete(opt)
|
||||
keys.delete(opt)
|
||||
end
|
||||
}
|
||||
hash_kv(keys).flatten
|
||||
|
@ -101,11 +101,11 @@ class TkPhotoImage<TkImage
|
|||
else
|
||||
# for backward compatibility
|
||||
args = opts.collect{|term|
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
}.flatten
|
||||
tk_send('copy', src, *args)
|
||||
end
|
||||
|
@ -141,11 +141,11 @@ class TkPhotoImage<TkImage
|
|||
else
|
||||
# for backward compatibility
|
||||
args = opts.collect{|term|
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
}.flatten
|
||||
tk_send('read', file, *args)
|
||||
end
|
||||
|
@ -173,11 +173,11 @@ class TkPhotoImage<TkImage
|
|||
else
|
||||
# for backward compatibility
|
||||
args = opts.collect{|term|
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
if term.kind_of?(String) && term.include?(?\s)
|
||||
term.split
|
||||
else
|
||||
term
|
||||
end
|
||||
}.flatten
|
||||
tk_send('write', file, *args)
|
||||
end
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -33,19 +33,19 @@ module TkTreatItemFont
|
|||
if key
|
||||
pathname = [win, tag, key].join(';')
|
||||
TkFont.used_on(pathname) ||
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
elsif optkeys.size == 1
|
||||
pathname = [win, tag, optkeys[0]].join(';')
|
||||
TkFont.used_on(pathname) ||
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
else
|
||||
fonts = {}
|
||||
optkeys.each{|key|
|
||||
key = key.to_s
|
||||
pathname = [win, tag, key].join(';')
|
||||
fonts[key] =
|
||||
TkFont.used_on(pathname) ||
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
key = key.to_s
|
||||
pathname = [win, tag, key].join(';')
|
||||
fonts[key] =
|
||||
TkFont.used_on(pathname) ||
|
||||
TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
|
||||
}
|
||||
fonts
|
||||
end
|
||||
|
@ -64,38 +64,38 @@ module TkTreatItemFont
|
|||
k_optkey = 'kanji' << optkey
|
||||
|
||||
if slot.key?(optkey)
|
||||
fnt = slot.delete(optkey)
|
||||
if fnt.kind_of?(TkFont)
|
||||
slot.delete(l_optkey)
|
||||
slot.delete(a_optkey)
|
||||
slot.delete(k_optkey)
|
||||
fnt = slot.delete(optkey)
|
||||
if fnt.kind_of?(TkFont)
|
||||
slot.delete(l_optkey)
|
||||
slot.delete(a_optkey)
|
||||
slot.delete(k_optkey)
|
||||
|
||||
fnt.call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
if fnt
|
||||
if (slot.key?(l_optkey) ||
|
||||
slot.key?(a_optkey) ||
|
||||
slot.key?(k_optkey))
|
||||
fnt = TkFont.new(fnt)
|
||||
fnt.call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
if fnt
|
||||
if (slot.key?(l_optkey) ||
|
||||
slot.key?(a_optkey) ||
|
||||
slot.key?(k_optkey))
|
||||
fnt = TkFont.new(fnt)
|
||||
|
||||
lfnt = slot.delete(l_optkey)
|
||||
lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
|
||||
kfnt = slot.delete(k_optkey)
|
||||
lfnt = slot.delete(l_optkey)
|
||||
lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
|
||||
kfnt = slot.delete(k_optkey)
|
||||
|
||||
fnt.latin_replace(lfnt) if lfnt
|
||||
fnt.kanji_replace(kfnt) if kfnt
|
||||
fnt.latin_replace(lfnt) if lfnt
|
||||
fnt.kanji_replace(kfnt) if kfnt
|
||||
|
||||
fnt.call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
fnt.call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
lfnt = slot.delete(l_optkey)
|
||||
|
@ -103,12 +103,12 @@ module TkTreatItemFont
|
|||
kfnt = slot.delete(k_optkey)
|
||||
|
||||
if lfnt && kfnt
|
||||
TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
elsif lfnt
|
||||
latintagfont_configure([lfnt, optkey])
|
||||
latintagfont_configure([lfnt, optkey])
|
||||
elsif kfnt
|
||||
kanjitagfont_configure([kfnt, optkey])
|
||||
kanjitagfont_configure([kfnt, optkey])
|
||||
end
|
||||
}
|
||||
|
||||
|
@ -140,26 +140,26 @@ module TkTreatItemFont
|
|||
pathname = [win, tag, optkey].join(';')
|
||||
|
||||
if (fobj = TkFont.used_on(pathname))
|
||||
fobj = TkFont.new(fobj) # create a new TkFont object
|
||||
fobj = TkFont.new(fobj) # create a new TkFont object
|
||||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
next
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
next
|
||||
end
|
||||
|
||||
if fobj.kind_of?(TkFont)
|
||||
if ltn.kind_of?(TkFont)
|
||||
conf = {}
|
||||
ltn.latin_configinfo.each{|key,val| conf[key] = val}
|
||||
if keys
|
||||
fobj.latin_configure(conf.update(keys))
|
||||
else
|
||||
fobj.latin_configure(conf)
|
||||
end
|
||||
else
|
||||
fobj.latin_replace(ltn)
|
||||
end
|
||||
if ltn.kind_of?(TkFont)
|
||||
conf = {}
|
||||
ltn.latin_configinfo.each{|key,val| conf[key] = val}
|
||||
if keys
|
||||
fobj.latin_configure(conf.update(keys))
|
||||
else
|
||||
fobj.latin_configure(conf)
|
||||
end
|
||||
else
|
||||
fobj.latin_replace(ltn)
|
||||
end
|
||||
end
|
||||
|
||||
fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
|
@ -191,26 +191,26 @@ module TkTreatItemFont
|
|||
pathname = [win, tag, optkey].join(';')
|
||||
|
||||
if (fobj = TkFont.used_on(pathname))
|
||||
fobj = TkFont.new(fobj) # create a new TkFont object
|
||||
fobj = TkFont.new(fobj) # create a new TkFont object
|
||||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
next
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
next
|
||||
end
|
||||
|
||||
if fobj.kind_of?(TkFont)
|
||||
if knj.kind_of?(TkFont)
|
||||
conf = {}
|
||||
knj.kanji_configinfo.each{|key,val| conf[key] = val}
|
||||
if keys
|
||||
fobj.kanji_configure(conf.update(keys))
|
||||
else
|
||||
fobj.kanji_configure(conf)
|
||||
end
|
||||
else
|
||||
fobj.kanji_replace(knj)
|
||||
end
|
||||
if knj.kind_of?(TkFont)
|
||||
conf = {}
|
||||
knj.kanji_configinfo.each{|key,val| conf[key] = val}
|
||||
if keys
|
||||
fobj.kanji_configure(conf.update(keys))
|
||||
else
|
||||
fobj.kanji_configure(conf)
|
||||
end
|
||||
else
|
||||
fobj.kanji_replace(knj)
|
||||
end
|
||||
end
|
||||
|
||||
fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
|
@ -221,24 +221,24 @@ module TkTreatItemFont
|
|||
def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
|
||||
if wintag
|
||||
if winkey
|
||||
fnt = window.tagfontobj(wintag, winkey).dup
|
||||
fnt = window.tagfontobj(wintag, winkey).dup
|
||||
else
|
||||
fnt = window.tagfontobj(wintag).dup
|
||||
fnt = window.tagfontobj(wintag).dup
|
||||
end
|
||||
else
|
||||
if winkey
|
||||
fnt = window.fontobj(winkey).dup
|
||||
fnt = window.fontobj(winkey).dup
|
||||
else
|
||||
fnt = window.fontobj.dup
|
||||
fnt = window.fontobj.dup
|
||||
end
|
||||
end
|
||||
|
||||
if targetkey
|
||||
fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
else
|
||||
fnt.call_font_configure(__item_pathname(tagid(tagOrId)),
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -247,23 +247,23 @@ module TkTreatItemFont
|
|||
def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
|
||||
if targetkey
|
||||
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
else
|
||||
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
end
|
||||
|
||||
if wintag
|
||||
if winkey
|
||||
fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
|
||||
fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
|
||||
else
|
||||
fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
|
||||
fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
|
||||
end
|
||||
else
|
||||
if winkey
|
||||
fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
|
||||
fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
|
||||
else
|
||||
fontobj.latin_replace(window.fontobj.latin_font_id)
|
||||
fontobj.latin_replace(window.fontobj.latin_font_id)
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -273,23 +273,23 @@ module TkTreatItemFont
|
|||
def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
|
||||
if targetkey
|
||||
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
else
|
||||
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
|
||||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
end
|
||||
|
||||
if wintag
|
||||
if winkey
|
||||
fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
|
||||
fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
|
||||
else
|
||||
fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
|
||||
fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
|
||||
end
|
||||
else
|
||||
if winkey
|
||||
fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
|
||||
fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
|
||||
else
|
||||
fontobj.kanji_replace(window.fontobj.kanji_font_id)
|
||||
fontobj.kanji_replace(window.fontobj.kanji_font_id)
|
||||
end
|
||||
end
|
||||
self
|
||||
|
|
|
@ -48,13 +48,13 @@ module TkKinput
|
|||
def TkKinput.attribute_info(window, slot=nil)
|
||||
if slot
|
||||
conf = tk_split_list(tk_call('kanjiInput', 'attribute',
|
||||
window, "-#{slot}"))
|
||||
window, "-#{slot}"))
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf|
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,15 +105,15 @@ class TkListbox<TkTextWin
|
|||
when 'font', 'kanjifont'
|
||||
#fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
|
||||
fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
|
||||
'-font')))
|
||||
'-font')))
|
||||
unless fnt.kind_of?(TkFont)
|
||||
fnt = tagfontobj(index, fnt)
|
||||
fnt = tagfontobj(index, fnt)
|
||||
end
|
||||
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
else
|
||||
fnt
|
||||
fnt
|
||||
end
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
|
||||
|
@ -123,25 +123,25 @@ class TkListbox<TkTextWin
|
|||
if key.kind_of? Hash
|
||||
if (key['font'] || key[:font] ||
|
||||
key['kanjifont'] || key[:kanjifont] ||
|
||||
key['latinfont'] || key[:latinfont] ||
|
||||
key['latinfont'] || key[:latinfont] ||
|
||||
key['asciifont'] || key[:asciifont] )
|
||||
tagfont_configure(index, _symbolkey2str(key))
|
||||
tagfont_configure(index, _symbolkey2str(key))
|
||||
else
|
||||
tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
|
||||
tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
|
||||
end
|
||||
|
||||
else
|
||||
if (key == 'font' || key == :font ||
|
||||
key == 'kanjifont' || key == :kanjifont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'asciifont' || key == :asciifont )
|
||||
if val == None
|
||||
tagfontobj(index)
|
||||
else
|
||||
tagfont_configure(index, {key=>val})
|
||||
end
|
||||
if val == None
|
||||
tagfontobj(index)
|
||||
else
|
||||
tagfont_configure(index, {key=>val})
|
||||
end
|
||||
else
|
||||
tk_call('itemconfigure', index, "-#{key}", val)
|
||||
tk_call('itemconfigure', index, "-#{key}", val)
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -150,101 +150,101 @@ class TkListbox<TkTextWin
|
|||
def itemconfiginfo(index, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
fontconf = ret.assoc('font')
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(index, fontconf[4])
|
||||
ret.push(fontconf)
|
||||
else
|
||||
ret
|
||||
end
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
fontconf = ret.assoc('font')
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(index, fontconf[4])
|
||||
ret.push(fontconf)
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(index, fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
ret
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(index, fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -252,19 +252,19 @@ class TkListbox<TkTextWin
|
|||
def current_itemconfiginfo(index, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
conf = itemconfiginfo(index, key)
|
||||
{conf[0] => conf[4]}
|
||||
conf = itemconfiginfo(index, key)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
itemconfiginfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
itemconfiginfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
itemconfiginfo(index, key).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
|
|
@ -84,13 +84,13 @@ class TkMenu<TkWindow
|
|||
end
|
||||
def insert(index, type, keys=nil)
|
||||
tk_send_without_enc('insert', _get_eval_enc_str(index),
|
||||
type, *hash_kv(keys, true))
|
||||
type, *hash_kv(keys, true))
|
||||
self
|
||||
end
|
||||
def delete(first, last=nil)
|
||||
if last
|
||||
tk_send_without_enc('delete', _get_eval_enc_str(first),
|
||||
_get_eval_enc_str(last))
|
||||
_get_eval_enc_str(last))
|
||||
else
|
||||
tk_send_without_enc('delete', _get_eval_enc_str(first))
|
||||
end
|
||||
|
@ -99,7 +99,7 @@ class TkMenu<TkWindow
|
|||
def popup(x, y, index=nil)
|
||||
if index
|
||||
tk_call_without_enc('tk_popup', path, x, y,
|
||||
_get_eval_enc_str(index))
|
||||
_get_eval_enc_str(index))
|
||||
else
|
||||
tk_call_without_enc('tk_popup', path, x, y)
|
||||
end
|
||||
|
@ -140,18 +140,18 @@ class TkMenu<TkWindow
|
|||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
_fromUTF8(tk_send_without_enc('entrycget',
|
||||
_get_eval_enc_str(index), "-#{key}"))
|
||||
_get_eval_enc_str(index), "-#{key}"))
|
||||
when 'font', 'kanjifont'
|
||||
#fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
|
||||
fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), '-font')))
|
||||
unless fnt.kind_of?(TkFont)
|
||||
fnt = tagfontobj(index, fnt)
|
||||
fnt = tagfontobj(index, fnt)
|
||||
end
|
||||
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
else
|
||||
fnt
|
||||
fnt
|
||||
end
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
|
||||
|
@ -161,26 +161,26 @@ class TkMenu<TkWindow
|
|||
if key.kind_of? Hash
|
||||
if (key['font'] || key[:font] ||
|
||||
key['kanjifont'] || key[:kanjifont] ||
|
||||
key['latinfont'] || key[:latinfont] ||
|
||||
key['latinfont'] || key[:latinfont] ||
|
||||
key['asciifont'] || key[:asciifont])
|
||||
tagfont_configure(index, _symbolkey2str(key))
|
||||
tagfont_configure(index, _symbolkey2str(key))
|
||||
else
|
||||
tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
|
||||
*hash_kv(key, true))
|
||||
tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
|
||||
*hash_kv(key, true))
|
||||
end
|
||||
|
||||
else
|
||||
if (key == 'font' || key == :font ||
|
||||
key == 'kanjifont' || key == :kanjifont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'latinfont' || key == :latinfont ||
|
||||
key == 'asciifont' || key == :asciifont )
|
||||
if val == None
|
||||
tagfontobj(index)
|
||||
else
|
||||
tagfont_configure(index, {key=>val})
|
||||
end
|
||||
if val == None
|
||||
tagfontobj(index)
|
||||
else
|
||||
tagfont_configure(index, {key=>val})
|
||||
end
|
||||
else
|
||||
tk_call('entryconfigure', index, "-#{key}", val)
|
||||
tk_call('entryconfigure', index, "-#{key}", val)
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -189,100 +189,100 @@ class TkMenu<TkWindow
|
|||
def entryconfiginfo(index, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(index, fontconf[4])
|
||||
ret.push(fontconf)
|
||||
else
|
||||
ret
|
||||
end
|
||||
ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
if fontconf
|
||||
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
|
||||
fontconf[4] = tagfont_configinfo(index, fontconf[4])
|
||||
ret.push(fontconf)
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
case key.to_s
|
||||
when 'text', 'label', 'show'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
when 'font', 'kanjifont'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
conf[4] = tagfont_configinfo(index, conf[4])
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(index, fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
ret
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
fontconf = ret['font']
|
||||
if fontconf
|
||||
ret.delete('font')
|
||||
ret.delete('kanjifont')
|
||||
fontconf[3] = tagfont_configinfo(index, fontconf[3])
|
||||
ret['font'] = fontconf
|
||||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -290,19 +290,19 @@ class TkMenu<TkWindow
|
|||
def current_entryconfiginfo(index, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
conf = entryconfiginfo(index, key)
|
||||
{conf[0] => conf[4]}
|
||||
conf = entryconfiginfo(index, key)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
entryconfiginfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
entryconfiginfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
entryconfiginfo(index, key).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
@ -422,7 +422,7 @@ class TkOptionMenubutton<TkMenubutton
|
|||
@variable.value = firstval
|
||||
install_win(if parent then parent.path end)
|
||||
@menu = OptionMenu.new(tk_call('tk_optionMenu', @path, @variable.id,
|
||||
firstval, *vals))
|
||||
firstval, *vals))
|
||||
end
|
||||
|
||||
def value
|
||||
|
@ -435,7 +435,7 @@ class TkOptionMenubutton<TkMenubutton
|
|||
end
|
||||
def add(value)
|
||||
@menu.add('radiobutton', 'variable'=>@variable,
|
||||
'label'=>value, 'value'=>value)
|
||||
'label'=>value, 'value'=>value)
|
||||
self
|
||||
end
|
||||
def index(index)
|
||||
|
@ -446,7 +446,7 @@ class TkOptionMenubutton<TkMenubutton
|
|||
end
|
||||
def insert(index, value)
|
||||
@menu.insert(index, 'radiobutton', 'variable'=>@variable,
|
||||
'label'=>value, 'value'=>value)
|
||||
'label'=>value, 'value'=>value)
|
||||
self
|
||||
end
|
||||
def delete(index, last=None)
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
# ['Paste', proc{puts('Paste clicked')}, 0]]
|
||||
# ]
|
||||
# menubar = TkMenubar.new(nil, menu_spec,
|
||||
# 'tearoff'=>false,
|
||||
# 'foreground'=>'grey40',
|
||||
# 'activeforeground'=>'red',
|
||||
# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
|
||||
# 'tearoff'=>false,
|
||||
# 'foreground'=>'grey40',
|
||||
# 'activeforeground'=>'red',
|
||||
# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
|
||||
# menubar.pack('side'=>'top', 'fill'=>'x')
|
||||
#
|
||||
#
|
||||
|
@ -30,13 +30,13 @@
|
|||
#
|
||||
# menubar = TkMenubar.new
|
||||
# menubar.add_menu([['File', 0],
|
||||
# ['Open', proc{puts('Open clicked')}, 0],
|
||||
# '---',
|
||||
# ['Quit', proc{exit}, 0]])
|
||||
# ['Open', proc{puts('Open clicked')}, 0],
|
||||
# '---',
|
||||
# ['Quit', proc{exit}, 0]])
|
||||
# menubar.add_menu([['Edit', 0],
|
||||
# ['Cut', proc{puts('Cut clicked')}, 2],
|
||||
# ['Copy', proc{puts('Copy clicked')}, 0],
|
||||
# ['Paste', proc{puts('Paste clicked')}, 0]])
|
||||
# ['Cut', proc{puts('Cut clicked')}, 2],
|
||||
# ['Copy', proc{puts('Copy clicked')}, 0],
|
||||
# ['Paste', proc{puts('Paste clicked')}, 0]])
|
||||
# menubar.configure('tearoff', false)
|
||||
# menubar.configure('foreground', 'grey40')
|
||||
# menubar.configure('activeforeground', 'red')
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
module TkMenuSpec
|
||||
def _create_menu(parent, menu_info, menu_name = nil,
|
||||
tearoff = false, default_opts = nil)
|
||||
tearoff = false, default_opts = nil)
|
||||
if tearoff.kind_of?(Hash)
|
||||
default_opts = tearoff
|
||||
tearoff = false
|
||||
|
@ -64,79 +64,79 @@ module TkMenuSpec
|
|||
|
||||
for item_info in menu_info
|
||||
if item_info.kind_of?(Hash)
|
||||
options = orig_opts.dup
|
||||
options.update(_symbolkey2str(item_info))
|
||||
item_type = (options.delete('type') || 'command').to_s
|
||||
menu_name = options.delete('menu_name')
|
||||
menu_opts = orig_opts.dup
|
||||
menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
|
||||
if item_type == 'cascade' && options['menu'].kind_of?(Array)
|
||||
# create cascade menu
|
||||
submenu = _create_menu(menu, options['menu'], menu_name,
|
||||
tearoff, menu_opts)
|
||||
options['menu'] = submenu
|
||||
end
|
||||
menu.add(item_type, options)
|
||||
options = orig_opts.dup
|
||||
options.update(_symbolkey2str(item_info))
|
||||
item_type = (options.delete('type') || 'command').to_s
|
||||
menu_name = options.delete('menu_name')
|
||||
menu_opts = orig_opts.dup
|
||||
menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
|
||||
if item_type == 'cascade' && options['menu'].kind_of?(Array)
|
||||
# create cascade menu
|
||||
submenu = _create_menu(menu, options['menu'], menu_name,
|
||||
tearoff, menu_opts)
|
||||
options['menu'] = submenu
|
||||
end
|
||||
menu.add(item_type, options)
|
||||
|
||||
elsif item_info.kind_of?(Array)
|
||||
options = orig_opts.dup
|
||||
options = orig_opts.dup
|
||||
|
||||
options['label'] = item_info[0] if item_info[0]
|
||||
options['label'] = item_info[0] if item_info[0]
|
||||
|
||||
case item_info[1]
|
||||
when TkVariable
|
||||
# checkbutton
|
||||
item_type = 'checkbutton'
|
||||
options['variable'] = item_info[1]
|
||||
options['onvalue'] = true
|
||||
options['offvalue'] = false
|
||||
case item_info[1]
|
||||
when TkVariable
|
||||
# checkbutton
|
||||
item_type = 'checkbutton'
|
||||
options['variable'] = item_info[1]
|
||||
options['onvalue'] = true
|
||||
options['offvalue'] = false
|
||||
|
||||
when Array
|
||||
# radiobutton or cascade
|
||||
if item_info[1][0].kind_of?(TkVariable)
|
||||
# radiobutton
|
||||
item_type = 'radiobutton'
|
||||
options['variable'] = item_info[1][0]
|
||||
options['value'] = item_info[1][1] if item_info[1][1]
|
||||
when Array
|
||||
# radiobutton or cascade
|
||||
if item_info[1][0].kind_of?(TkVariable)
|
||||
# radiobutton
|
||||
item_type = 'radiobutton'
|
||||
options['variable'] = item_info[1][0]
|
||||
options['value'] = item_info[1][1] if item_info[1][1]
|
||||
|
||||
else
|
||||
# cascade
|
||||
item_type = 'cascade'
|
||||
menu_opts = orig_opts.dup
|
||||
if item_info[4] && item_info[4].kind_of?(Hash)
|
||||
opts = _symbolkey2str(item_info[4])
|
||||
menu_name = opts.delete('menu_name')
|
||||
menu_config = opts.delete('menu_config') || {}
|
||||
menu_opts.update(_symbolkey2str(menu_config))
|
||||
end
|
||||
submenu = _create_menu(menu, item_info[1], menu_name,
|
||||
tearoff, menu_opts)
|
||||
options['menu'] = submenu
|
||||
end
|
||||
else
|
||||
# cascade
|
||||
item_type = 'cascade'
|
||||
menu_opts = orig_opts.dup
|
||||
if item_info[4] && item_info[4].kind_of?(Hash)
|
||||
opts = _symbolkey2str(item_info[4])
|
||||
menu_name = opts.delete('menu_name')
|
||||
menu_config = opts.delete('menu_config') || {}
|
||||
menu_opts.update(_symbolkey2str(menu_config))
|
||||
end
|
||||
submenu = _create_menu(menu, item_info[1], menu_name,
|
||||
tearoff, menu_opts)
|
||||
options['menu'] = submenu
|
||||
end
|
||||
|
||||
else
|
||||
# command
|
||||
item_type = 'command'
|
||||
options['command'] = item_info[1] if item_info[1]
|
||||
end
|
||||
else
|
||||
# command
|
||||
item_type = 'command'
|
||||
options['command'] = item_info[1] if item_info[1]
|
||||
end
|
||||
|
||||
options['underline'] = item_info[2] if item_info[2]
|
||||
options['accelerator'] = item_info[3] if item_info[3]
|
||||
if item_info[4] && item_info[4].kind_of?(Hash)
|
||||
opts = _symbolkey2str(item_info[4])
|
||||
if item_type == 'cascade'
|
||||
opts.delete('menu_name')
|
||||
opts.delete('menu_config')
|
||||
end
|
||||
options.update(opts)
|
||||
end
|
||||
menu.add(item_type, options)
|
||||
options['underline'] = item_info[2] if item_info[2]
|
||||
options['accelerator'] = item_info[3] if item_info[3]
|
||||
if item_info[4] && item_info[4].kind_of?(Hash)
|
||||
opts = _symbolkey2str(item_info[4])
|
||||
if item_type == 'cascade'
|
||||
opts.delete('menu_name')
|
||||
opts.delete('menu_config')
|
||||
end
|
||||
options.update(opts)
|
||||
end
|
||||
menu.add(item_type, options)
|
||||
|
||||
elsif /^-+$/ =~ item_info
|
||||
menu.add('separator')
|
||||
menu.add('separator')
|
||||
|
||||
else
|
||||
menu.add('command', 'label' => item_info)
|
||||
menu.add('command', 'label' => item_info)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -150,8 +150,8 @@ module TkMenuSpec
|
|||
return true
|
||||
else
|
||||
begin
|
||||
parent.cget('menu')
|
||||
return true
|
||||
parent.cget('menu')
|
||||
return true
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
@ -192,22 +192,22 @@ module TkMenuSpec
|
|||
menu_name = nil
|
||||
|
||||
if btn_info.kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info))
|
||||
menu_name = keys.delete('menu_name')
|
||||
keys['label'] = keys.delete('text') if keys.key?('text')
|
||||
keys.update(_symbolkey2str(btn_info))
|
||||
menu_name = keys.delete('menu_name')
|
||||
keys['label'] = keys.delete('text') if keys.key?('text')
|
||||
elsif btn_info.kind_of?(Array)
|
||||
keys['label'] = btn_info[0] if btn_info[0]
|
||||
keys['underline'] = btn_info[1] if btn_info[1]
|
||||
if btn_info[2]&&btn_info[2].kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info[2]))
|
||||
menu_name = keys.delete('menu_name')
|
||||
end
|
||||
keys['label'] = btn_info[0] if btn_info[0]
|
||||
keys['underline'] = btn_info[1] if btn_info[1]
|
||||
if btn_info[2]&&btn_info[2].kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info[2]))
|
||||
menu_name = keys.delete('menu_name')
|
||||
end
|
||||
else
|
||||
keys = {:label=>btn_info}
|
||||
keys = {:label=>btn_info}
|
||||
end
|
||||
|
||||
menu = _create_menu(mbar, menu_info[1..-1], menu_name,
|
||||
tearoff, default_opts)
|
||||
tearoff, default_opts)
|
||||
menu.tearoff(tearoff)
|
||||
|
||||
keys['menu'] = menu
|
||||
|
@ -222,27 +222,27 @@ module TkMenuSpec
|
|||
menu_name = nil
|
||||
|
||||
if btn_info.kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info))
|
||||
menu_name = keys.delete('menu_name')
|
||||
keys['text'] = keys.delete('label') if keys.key?('label')
|
||||
mbtn.configure(keys)
|
||||
keys.update(_symbolkey2str(btn_info))
|
||||
menu_name = keys.delete('menu_name')
|
||||
keys['text'] = keys.delete('label') if keys.key?('label')
|
||||
mbtn.configure(keys)
|
||||
elsif btn_info.kind_of?(Array)
|
||||
mbtn.configure('text', btn_info[0]) if btn_info[0]
|
||||
mbtn.configure('underline', btn_info[1]) if btn_info[1]
|
||||
# mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
|
||||
if btn_info[2]&&btn_info[2].kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info[2]))
|
||||
menu_name = keys.delete('menu_name')
|
||||
mbtn.configure(keys)
|
||||
end
|
||||
mbtn.configure('text', btn_info[0]) if btn_info[0]
|
||||
mbtn.configure('underline', btn_info[1]) if btn_info[1]
|
||||
# mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
|
||||
if btn_info[2]&&btn_info[2].kind_of?(Hash)
|
||||
keys.update(_symbolkey2str(btn_info[2]))
|
||||
menu_name = keys.delete('menu_name')
|
||||
mbtn.configure(keys)
|
||||
end
|
||||
else
|
||||
mbtn.configure('text', btn_info)
|
||||
mbtn.configure('text', btn_info)
|
||||
end
|
||||
|
||||
mbtn.pack('side' => 'left')
|
||||
|
||||
menu = _create_menu(mbtn, menu_info[1..-1], menu_name,
|
||||
tearoff, default_opts)
|
||||
tearoff, default_opts)
|
||||
|
||||
mbtn.menu(menu)
|
||||
|
||||
|
@ -255,8 +255,8 @@ module TkMenuSpec
|
|||
menus = []
|
||||
(0..(menu.index('last'))).each{|idx|
|
||||
if menu.menutype(idx) == 'cascade'
|
||||
submenu = menu.entrycget(idx, 'menu')
|
||||
menus << [submenu, _get_cascade_menus(submenu)]
|
||||
submenu = menu.entrycget(idx, 'menu')
|
||||
menus << [submenu, _get_cascade_menus(submenu)]
|
||||
end
|
||||
}
|
||||
menus
|
||||
|
|
|
@ -46,7 +46,7 @@ class TkMsgCatalog < TkObject
|
|||
return -code $st $ret
|
||||
}
|
||||
} else {
|
||||
return $ret
|
||||
return $ret
|
||||
}
|
||||
EOL
|
||||
|
||||
|
@ -64,17 +64,17 @@ class TkMsgCatalog < TkObject
|
|||
exit!(1)
|
||||
rescue Exception => e
|
||||
begin
|
||||
msg = _toUTF8(e.class.inspect) + ': ' +
|
||||
_toUTF8(e.message) + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
_toUTF8(e.backtrace.join("\n")) +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
msg.instance_variable_set(:@encoding, 'utf-8')
|
||||
msg = _toUTF8(e.class.inspect) + ': ' +
|
||||
_toUTF8(e.message) + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
_toUTF8(e.backtrace.join("\n")) +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
msg.instance_variable_set(:@encoding, 'utf-8')
|
||||
rescue Exception
|
||||
msg = e.class.inspect + ': ' + e.message + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
e.backtrace.join("\n") +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
msg = e.class.inspect + ': ' + e.message + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
e.backtrace.join("\n") +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
end
|
||||
fail(e, msg)
|
||||
end
|
||||
|
@ -103,22 +103,22 @@ class TkMsgCatalog < TkObject
|
|||
|
||||
when 1 # src only, or trans_list
|
||||
if args[0].kind_of?(Array)
|
||||
# trans_list
|
||||
#list = args[0].collect{|src, trans|
|
||||
# [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ]
|
||||
#}
|
||||
self.set_translation_list(loc, args[0])
|
||||
# trans_list
|
||||
#list = args[0].collect{|src, trans|
|
||||
# [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ]
|
||||
#}
|
||||
self.set_translation_list(loc, args[0])
|
||||
else
|
||||
# src
|
||||
#self.set_translation(loc, Tk::UTF8_String.new(args[0]))
|
||||
self.set_translation(loc, args[0])
|
||||
# src
|
||||
#self.set_translation(loc, Tk::UTF8_String.new(args[0]))
|
||||
self.set_translation(loc, args[0])
|
||||
end
|
||||
|
||||
when 2 # src and trans, or, trans_list and enc
|
||||
if args[0].kind_of?(Array)
|
||||
else
|
||||
#self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1]))
|
||||
self.set_translation(loc, *args)
|
||||
#self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1]))
|
||||
self.set_translation(loc, *args)
|
||||
end
|
||||
|
||||
when 3 # src and trans and enc
|
||||
|
@ -144,7 +144,7 @@ class TkMsgCatalog < TkObject
|
|||
def translate(*args)
|
||||
dst = args.collect{|src|
|
||||
@namespace.eval{tk_call_without_enc('::msgcat::mc',
|
||||
_get_eval_string(src, true))}
|
||||
_get_eval_string(src, true))}
|
||||
}
|
||||
Tk.UTF8_String(sprintf(*dst))
|
||||
end
|
||||
|
@ -188,8 +188,8 @@ class TkMsgCatalog < TkObject
|
|||
preferences().each{|loc|
|
||||
file = File.join(dir, loc + self::MSGCAT_EXT)
|
||||
if File.readable?(file)
|
||||
count += 1
|
||||
eval(open(file){|f| f.read})
|
||||
count += 1
|
||||
eval(open(file){|f| f.read})
|
||||
end
|
||||
}
|
||||
count
|
||||
|
@ -204,8 +204,8 @@ class TkMsgCatalog < TkObject
|
|||
preferences().each{|loc|
|
||||
file = File.join(dir, loc + @msgcat_ext)
|
||||
if File.readable?(file)
|
||||
count += 1
|
||||
@namespace.eval(open(file){|f| f.read})
|
||||
count += 1
|
||||
@namespace.eval(open(file){|f| f.read})
|
||||
end
|
||||
}
|
||||
count
|
||||
|
@ -220,29 +220,29 @@ class TkMsgCatalog < TkObject
|
|||
if trans_str && trans_str != None
|
||||
trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
|
||||
Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true),
|
||||
trans_str))
|
||||
locale,
|
||||
_get_eval_string(src_str, true),
|
||||
trans_str))
|
||||
else
|
||||
Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true)))
|
||||
locale,
|
||||
_get_eval_string(src_str, true)))
|
||||
end
|
||||
end
|
||||
def set_translation(locale, src_str, trans_str=None, enc='utf-8')
|
||||
if trans_str && trans_str != None
|
||||
trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
|
||||
Tk.UTF8_String(@namespace.eval{
|
||||
tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true),
|
||||
trans_str)
|
||||
})
|
||||
tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true),
|
||||
trans_str)
|
||||
})
|
||||
else
|
||||
Tk.UTF8_String(@namespace.eval{
|
||||
tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true))})
|
||||
tk_call_without_enc('::msgcat::mcset',
|
||||
locale,
|
||||
_get_eval_string(src_str, true))})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -251,10 +251,10 @@ class TkMsgCatalog < TkObject
|
|||
list = []
|
||||
trans_list.each{|src, trans|
|
||||
if trans && trans != None
|
||||
list << _get_eval_string(src, true)
|
||||
list << Tk.UTF8_Stirng(_toUTF8(trans, enc))
|
||||
list << _get_eval_string(src, true)
|
||||
list << Tk.UTF8_Stirng(_toUTF8(trans, enc))
|
||||
else
|
||||
list << _get_eval_string(src, true) << ''
|
||||
list << _get_eval_string(src, true) << ''
|
||||
end
|
||||
}
|
||||
number(tk_call_without_enc('::msgcat::mcmset', locale, list))
|
||||
|
@ -264,15 +264,15 @@ class TkMsgCatalog < TkObject
|
|||
list = []
|
||||
trans_list.each{|src, trans|
|
||||
if trans && trans != None
|
||||
list << _get_eval_string(src, true)
|
||||
list << Tk.UTF8_String(_toUTF8(trans, enc))
|
||||
list << _get_eval_string(src, true)
|
||||
list << Tk.UTF8_String(_toUTF8(trans, enc))
|
||||
else
|
||||
list << _get_eval_string(src, true) << ''
|
||||
list << _get_eval_string(src, true) << ''
|
||||
end
|
||||
}
|
||||
number(@namespace.eval{
|
||||
tk_call_without_enc('::msgcat::mcmset', locale, list)
|
||||
})
|
||||
tk_call_without_enc('::msgcat::mcmset', locale, list)
|
||||
})
|
||||
end
|
||||
|
||||
def self.def_unknown_proc(cmd=Proc.new)
|
||||
|
|
|
@ -24,19 +24,19 @@ class TkNamespace < TkObject
|
|||
#super('namespace', 'eval', @namespace, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @namespace,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
def tk_call_without_enc(*args)
|
||||
#super('namespace', 'eval', @namespace, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @namespace,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
def tk_call_with_enc(*args)
|
||||
#super('namespace', 'eval', @namespace, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @namespace,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
|
||||
def initialize(namespace, *args)
|
||||
|
@ -68,19 +68,19 @@ class TkNamespace < TkObject
|
|||
#super('namespace', 'eval', @fullname, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @fullname,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
def tk_call_without_enc(*args)
|
||||
#super('namespace', 'eval', @fullname, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @fullname,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
def tk_call_with_enc(*args)
|
||||
#super('namespace', 'eval', @fullname, *args)
|
||||
args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
|
||||
super('namespace', 'eval', @fullname,
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
TkCore::INTERP._merge_tklist(*args))
|
||||
end
|
||||
alias ns_tk_call tk_call
|
||||
alias ns_tk_call_without_enc tk_call_without_enc
|
||||
|
@ -95,27 +95,27 @@ class TkNamespace < TkObject
|
|||
name = __tk_call('namespace', 'current') if name == ''
|
||||
if parent
|
||||
if parent =~ /^::/
|
||||
if name =~ /^::/
|
||||
@fullname = parent + name
|
||||
else
|
||||
@fullname = parent +'::'+ name
|
||||
end
|
||||
if name =~ /^::/
|
||||
@fullname = parent + name
|
||||
else
|
||||
@fullname = parent +'::'+ name
|
||||
end
|
||||
else
|
||||
ancestor = __tk_call('namespace', 'current')
|
||||
ancestor = '' if ancestor == '::'
|
||||
if name =~ /^::/
|
||||
@fullname = ancestor + '::' + parent + name
|
||||
else
|
||||
@fullname = ancestor + '::'+ parent +'::'+ name
|
||||
end
|
||||
ancestor = __tk_call('namespace', 'current')
|
||||
ancestor = '' if ancestor == '::'
|
||||
if name =~ /^::/
|
||||
@fullname = ancestor + '::' + parent + name
|
||||
else
|
||||
@fullname = ancestor + '::'+ parent +'::'+ name
|
||||
end
|
||||
end
|
||||
else # parent == nil
|
||||
ancestor = __tk_call('namespace', 'current')
|
||||
ancestor = '' if ancestor == '::'
|
||||
if name =~ /^::/
|
||||
@fullname = name
|
||||
@fullname = name
|
||||
else
|
||||
@fullname = ancestor + '::' + name
|
||||
@fullname = ancestor + '::' + name
|
||||
end
|
||||
end
|
||||
@path = @fullname
|
||||
|
@ -134,9 +134,9 @@ class TkNamespace < TkObject
|
|||
tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
|
||||
# ns is fullname
|
||||
if Tk_Namespace_ID_TBL.key?(ns)
|
||||
Tk_Namespace_ID_TBL[ns]
|
||||
Tk_Namespace_ID_TBL[ns]
|
||||
else
|
||||
ns
|
||||
ns
|
||||
end
|
||||
}
|
||||
end
|
||||
|
@ -156,7 +156,7 @@ class TkNamespace < TkObject
|
|||
fail ArgumentError, "String or Proc is expected"
|
||||
end
|
||||
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
|
||||
_get_eval_string(cmd, false)))
|
||||
_get_eval_string(cmd, false)))
|
||||
end
|
||||
|
||||
def self.current
|
||||
|
|
|
@ -41,7 +41,7 @@ module TkOptionDB
|
|||
def read_entries(file, f_enc=nil)
|
||||
if TkCore::INTERP.safe?
|
||||
fail SecurityError,
|
||||
"can't call 'TkOptionDB.read_entries' on a safe interpreter"
|
||||
"can't call 'TkOptionDB.read_entries' on a safe interpreter"
|
||||
end
|
||||
|
||||
i_enc = Tk.encoding()
|
||||
|
@ -54,29 +54,29 @@ module TkOptionDB
|
|||
cline = ''
|
||||
open(file, 'r') {|f|
|
||||
while line = f.gets
|
||||
#cline += line.chomp!
|
||||
cline.concat(line.chomp!)
|
||||
case cline
|
||||
when /\\$/ # continue
|
||||
cline.chop!
|
||||
next
|
||||
when /^\s*(!|#)/ # coment
|
||||
cline = ''
|
||||
next
|
||||
when /^([^:]+):(.*)$/
|
||||
pat = $1.strip
|
||||
val = $2.lstrip
|
||||
p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
|
||||
pat = TkCore::INTERP._toUTF8(pat, f_enc)
|
||||
pat = TkCore::INTERP._fromUTF8(pat, i_enc)
|
||||
val = TkCore::INTERP._toUTF8(val, f_enc)
|
||||
val = TkCore::INTERP._fromUTF8(val, i_enc)
|
||||
ent << [pat, val]
|
||||
cline = ''
|
||||
else # unknown --> ignore
|
||||
cline = ''
|
||||
next
|
||||
end
|
||||
#cline += line.chomp!
|
||||
cline.concat(line.chomp!)
|
||||
case cline
|
||||
when /\\$/ # continue
|
||||
cline.chop!
|
||||
next
|
||||
when /^\s*(!|#)/ # coment
|
||||
cline = ''
|
||||
next
|
||||
when /^([^:]+):(.*)$/
|
||||
pat = $1.strip
|
||||
val = $2.lstrip
|
||||
p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
|
||||
pat = TkCore::INTERP._toUTF8(pat, f_enc)
|
||||
pat = TkCore::INTERP._fromUTF8(pat, i_enc)
|
||||
val = TkCore::INTERP._toUTF8(val, f_enc)
|
||||
val = TkCore::INTERP._fromUTF8(val, i_enc)
|
||||
ent << [pat, val]
|
||||
cline = ''
|
||||
else # unknown --> ignore
|
||||
cline = ''
|
||||
next
|
||||
end
|
||||
end
|
||||
}
|
||||
ent
|
||||
|
@ -99,28 +99,28 @@ module TkOptionDB
|
|||
cline = ''
|
||||
open(file, 'r') {|f|
|
||||
while line = f.gets
|
||||
cline += line.chomp!
|
||||
case cline
|
||||
when /\\$/ # continue
|
||||
cline.chop!
|
||||
next
|
||||
when /^\s*!/ # coment
|
||||
cline = ''
|
||||
next
|
||||
when /^([^:]+):\s(.*)$/
|
||||
pat = $1
|
||||
val = $2
|
||||
p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
|
||||
pat = TkCore::INTERP._toUTF8(pat, f_enc)
|
||||
pat = TkCore::INTERP._fromUTF8(pat, i_enc)
|
||||
val = TkCore::INTERP._toUTF8(val, f_enc)
|
||||
val = TkCore::INTERP._fromUTF8(val, i_enc)
|
||||
add(pat, val, pri)
|
||||
cline = ''
|
||||
else # unknown --> ignore
|
||||
cline = ''
|
||||
next
|
||||
end
|
||||
cline += line.chomp!
|
||||
case cline
|
||||
when /\\$/ # continue
|
||||
cline.chop!
|
||||
next
|
||||
when /^\s*!/ # coment
|
||||
cline = ''
|
||||
next
|
||||
when /^([^:]+):\s(.*)$/
|
||||
pat = $1
|
||||
val = $2
|
||||
p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
|
||||
pat = TkCore::INTERP._toUTF8(pat, f_enc)
|
||||
pat = TkCore::INTERP._fromUTF8(pat, i_enc)
|
||||
val = TkCore::INTERP._toUTF8(val, f_enc)
|
||||
val = TkCore::INTERP._fromUTF8(val, i_enc)
|
||||
add(pat, val, pri)
|
||||
cline = ''
|
||||
else # unknown --> ignore
|
||||
cline = ''
|
||||
next
|
||||
end
|
||||
end
|
||||
}
|
||||
=end
|
||||
|
@ -133,7 +133,7 @@ module TkOptionDB
|
|||
@@resource_proc_class.const_set(:CARRIER, '.'.freeze)
|
||||
|
||||
@@resource_proc_class.instance_variable_set('@method_tbl',
|
||||
TkCore::INTERP.create_table)
|
||||
TkCore::INTERP.create_table)
|
||||
@@resource_proc_class.instance_variable_set('@add_method', false)
|
||||
@@resource_proc_class.instance_variable_set('@safe_mode', 4)
|
||||
|
||||
|
@ -151,14 +151,14 @@ module TkOptionDB
|
|||
def __closed_block_check__(str)
|
||||
depth = 0
|
||||
str.scan(/[{}]/){|x|
|
||||
if x == "{"
|
||||
depth += 1
|
||||
elsif x == "}"
|
||||
depth -= 1
|
||||
end
|
||||
if depth <= 0 && !($' =~ /\A\s*\Z/)
|
||||
fail RuntimeError, "bad string for procedure : #{str.inspect}"
|
||||
end
|
||||
if x == "{"
|
||||
depth += 1
|
||||
elsif x == "}"
|
||||
depth -= 1
|
||||
end
|
||||
if depth <= 0 && !($' =~ /\A\s*\Z/)
|
||||
fail RuntimeError, "bad string for procedure : #{str.inspect}"
|
||||
end
|
||||
}
|
||||
str
|
||||
end
|
||||
|
@ -184,20 +184,20 @@ module TkOptionDB
|
|||
raise NoMethodError,
|
||||
"not support resource-proc '#{id.id2name}' for #{self.name}"
|
||||
end
|
||||
proc_str = proc_source
|
||||
proc_str = proc_source
|
||||
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
|
||||
#proc_str = __closed_block_check__(proc_str)
|
||||
#proc_str = __closed_block_check__(proc_str)
|
||||
proc_str = __check_proc_string__(proc_str)
|
||||
res_proc = proc{
|
||||
begin
|
||||
#eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str)
|
||||
eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str)
|
||||
rescue SyntaxError=>err
|
||||
raise SyntaxError,
|
||||
TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/,
|
||||
"(#{id.id2name}):"))
|
||||
end
|
||||
}.call
|
||||
begin
|
||||
#eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str)
|
||||
eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str)
|
||||
rescue SyntaxError=>err
|
||||
raise SyntaxError,
|
||||
TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/,
|
||||
"(#{id.id2name}):"))
|
||||
end
|
||||
}.call
|
||||
#self::METHOD_TBL[id] = [res_proc, proc_source]
|
||||
@method_tbl[id] = [res_proc, proc_source]
|
||||
end
|
||||
|
@ -255,16 +255,16 @@ module TkOptionDB
|
|||
else
|
||||
klass = klass.to_s if klass.kind_of? Symbol
|
||||
unless (?A..?Z) === klass[0]
|
||||
fail ArgumentError, "bad string '#{klass}' for class name"
|
||||
fail ArgumentError, "bad string '#{klass}' for class name"
|
||||
end
|
||||
if parent == nil
|
||||
install_win(nil)
|
||||
install_win(nil)
|
||||
elsif parent.kind_of?(TkWindow)
|
||||
install_win(parent.path)
|
||||
install_win(parent.path)
|
||||
elsif parent <= @@resource_proc_class
|
||||
install_win(parent::CARRIER)
|
||||
install_win(parent::CARRIER)
|
||||
else
|
||||
fail ArgumentError, "parent must be Resource-Proc class"
|
||||
fail ArgumentError, "parent must be Resource-Proc class"
|
||||
end
|
||||
carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass)
|
||||
end
|
||||
|
@ -304,16 +304,16 @@ module TkOptionDB
|
|||
class << klass
|
||||
def __null_method(*args); nil; end
|
||||
[ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?,
|
||||
:ancestors, :const_defined?, :const_get, :const_set, :const_missing,
|
||||
:class_variables, :constants, :included_modules, :instance_methods,
|
||||
:method_defined?, :module_eval, :private_instance_methods,
|
||||
:protected_instance_methods, :public_instance_methods,
|
||||
:singleton_methods, :remove_const, :remove_method, :undef_method,
|
||||
:to_s, :inspect, :display, :method, :methods, :respond_to?,
|
||||
:ancestors, :const_defined?, :const_get, :const_set, :const_missing,
|
||||
:class_variables, :constants, :included_modules, :instance_methods,
|
||||
:method_defined?, :module_eval, :private_instance_methods,
|
||||
:protected_instance_methods, :public_instance_methods,
|
||||
:singleton_methods, :remove_const, :remove_method, :undef_method,
|
||||
:to_s, :inspect, :display, :method, :methods, :respond_to?,
|
||||
:instance_variable_get, :instance_variable_set, :instance_method,
|
||||
:instance_eval, :instance_variables, :kind_of?, :is_a?,
|
||||
:private_methods, :protected_methods, :public_methods ].each{|m|
|
||||
alias_method(m, :__null_method)
|
||||
:instance_eval, :instance_variables, :kind_of?, :is_a?,
|
||||
:private_methods, :protected_methods, :public_methods ].each{|m|
|
||||
alias_method(m, :__null_method)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -351,7 +351,7 @@ module TkOptionDB
|
|||
|
||||
def eval_under_random_base(parent = nil, &b)
|
||||
new_klass = __create_new_class(__get_random_basename(),
|
||||
[], 4, false, parent)
|
||||
[], 4, false, parent)
|
||||
ret = new_klass.class_eval(&b) if block_given?
|
||||
__remove_methods_of_proc_class(new_klass)
|
||||
new_klass.freeze
|
||||
|
|
|
@ -25,32 +25,32 @@ module Tk
|
|||
|
||||
def observs
|
||||
@observ.collect{|win|
|
||||
if win.kind_of?(Array)
|
||||
win[0]
|
||||
else
|
||||
win
|
||||
end
|
||||
if win.kind_of?(Array)
|
||||
win[0]
|
||||
else
|
||||
win
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def _remove_win(win)
|
||||
if win.kind_of?(Array)
|
||||
widget, method = win
|
||||
@observ.delete_if{|x|
|
||||
if x.kind_of?(Array)
|
||||
x[0] == widget
|
||||
else
|
||||
x == widget
|
||||
end
|
||||
}
|
||||
widget, method = win
|
||||
@observ.delete_if{|x|
|
||||
if x.kind_of?(Array)
|
||||
x[0] == widget
|
||||
else
|
||||
x == widget
|
||||
end
|
||||
}
|
||||
else
|
||||
@observ.delete_if{|x|
|
||||
if x.kind_of?(Array)
|
||||
x[0] == win
|
||||
else
|
||||
x == win
|
||||
end
|
||||
}
|
||||
@observ.delete_if{|x|
|
||||
if x.kind_of?(Array)
|
||||
x[0] == win
|
||||
else
|
||||
x == win
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
private :_remove_win
|
||||
|
@ -81,27 +81,27 @@ module Tk
|
|||
# #==> set all of them
|
||||
#
|
||||
wins.each{|win|
|
||||
_remove_win(win)
|
||||
@observ << win
|
||||
notify(win)
|
||||
_remove_win(win)
|
||||
@observ << win
|
||||
notify(win)
|
||||
}
|
||||
self
|
||||
end
|
||||
|
||||
def unassign(*wins)
|
||||
wins.each{|win|
|
||||
_remove_win(win)
|
||||
_remove_win(win)
|
||||
}
|
||||
self
|
||||
end
|
||||
|
||||
def notify(target = nil)
|
||||
if target
|
||||
targets = [target]
|
||||
targets = [target]
|
||||
elsif @observ.empty?
|
||||
return self
|
||||
return self
|
||||
else
|
||||
targets = @observ.dup
|
||||
targets = @observ.dup
|
||||
end
|
||||
|
||||
return self if empty?
|
||||
|
@ -109,50 +109,50 @@ module Tk
|
|||
org_hash = _symbolkey2str(self)
|
||||
|
||||
targets.each{|win|
|
||||
widget = receiver = win
|
||||
hash = org_hash
|
||||
begin
|
||||
if win.kind_of?(Array)
|
||||
widget, method, conv_tbl = win
|
||||
receiver = widget
|
||||
widget = receiver = win
|
||||
hash = org_hash
|
||||
begin
|
||||
if win.kind_of?(Array)
|
||||
widget, method, conv_tbl = win
|
||||
receiver = widget
|
||||
|
||||
if conv_tbl
|
||||
hash = {}
|
||||
org_hash.each{|key, val|
|
||||
key = conv_tbl[key] if conv_tbl.key?(key)
|
||||
next unless key
|
||||
if key.kind_of?(Array)
|
||||
key.each{|k| hash[k] = val}
|
||||
else
|
||||
hash[key] = val
|
||||
end
|
||||
}
|
||||
end
|
||||
if conv_tbl
|
||||
hash = {}
|
||||
org_hash.each{|key, val|
|
||||
key = conv_tbl[key] if conv_tbl.key?(key)
|
||||
next unless key
|
||||
if key.kind_of?(Array)
|
||||
key.each{|k| hash[k] = val}
|
||||
else
|
||||
hash[key] = val
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
if method.kind_of?(Array)
|
||||
receiver, method, *args = method
|
||||
receiver.__send__(method, *(args << hash))
|
||||
elsif method
|
||||
widget.__send__(method, hash)
|
||||
else
|
||||
widget.configure(hash)
|
||||
end
|
||||
if method.kind_of?(Array)
|
||||
receiver, method, *args = method
|
||||
receiver.__send__(method, *(args << hash))
|
||||
elsif method
|
||||
widget.__send__(method, hash)
|
||||
else
|
||||
widget.configure(hash)
|
||||
end
|
||||
|
||||
else
|
||||
widget.configure(self)
|
||||
end
|
||||
rescue => e
|
||||
if ( ( widget.kind_of?(TkObject) \
|
||||
&& widget.respond_to?('exist?') \
|
||||
&& ! receiver.exist? ) \
|
||||
|| ( receiver.kind_of?(TkObject) \
|
||||
&& receiver.respond_to?('exist?') \
|
||||
&& ! receiver.exist? ) )
|
||||
@observ.delete(win)
|
||||
else
|
||||
fail e
|
||||
end
|
||||
end
|
||||
else
|
||||
widget.configure(self)
|
||||
end
|
||||
rescue => e
|
||||
if ( ( widget.kind_of?(TkObject) \
|
||||
&& widget.respond_to?('exist?') \
|
||||
&& ! receiver.exist? ) \
|
||||
|| ( receiver.kind_of?(TkObject) \
|
||||
&& receiver.respond_to?('exist?') \
|
||||
&& ! receiver.exist? ) )
|
||||
@observ.delete(win)
|
||||
else
|
||||
fail e
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
self
|
||||
|
@ -161,7 +161,7 @@ module Tk
|
|||
|
||||
def +(hash)
|
||||
unless hash.kind_of?(Hash)
|
||||
fail ArgumentError, "expect a Hash"
|
||||
fail ArgumentError, "expect a Hash"
|
||||
end
|
||||
new_obj = self.dup
|
||||
new_obj.update_without_notify(_symbolkey2str(hash))
|
||||
|
@ -177,9 +177,9 @@ module Tk
|
|||
|
||||
def configure(key, value=nil)
|
||||
if key.kind_of?(Hash)
|
||||
update(key)
|
||||
update(key)
|
||||
else
|
||||
store(key,value)
|
||||
store(key,value)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -35,12 +35,12 @@ module TkPackage
|
|||
# set proc
|
||||
cmd = arg[0]
|
||||
if cmd
|
||||
tk_call('package', 'ifneeded', pkg, ver, cmd)
|
||||
cmd
|
||||
tk_call('package', 'ifneeded', pkg, ver, cmd)
|
||||
cmd
|
||||
else
|
||||
# remove proc
|
||||
tk_call('package', 'ifneeded', pkg, ver, '')
|
||||
nil
|
||||
# remove proc
|
||||
tk_call('package', 'ifneeded', pkg, ver, '')
|
||||
nil
|
||||
end
|
||||
|
||||
else
|
||||
|
@ -112,12 +112,12 @@ module TkPackage
|
|||
# set proc
|
||||
cmd = arg[0]
|
||||
if cmd
|
||||
tk_call('package', 'unknown', cmd)
|
||||
cmd
|
||||
tk_call('package', 'unknown', cmd)
|
||||
cmd
|
||||
else
|
||||
# remove proc
|
||||
tk_call('package', 'unknown', '')
|
||||
nil
|
||||
# remove proc
|
||||
tk_call('package', 'unknown', '')
|
||||
nil
|
||||
end
|
||||
|
||||
else
|
||||
|
|
|
@ -37,11 +37,11 @@ module TkPalette
|
|||
|
||||
colors.each{|key, value|
|
||||
begin
|
||||
if window.cget(key) == tk_call('set', "tkPalette(#{key})")
|
||||
window[key] = colors[key]
|
||||
end
|
||||
if window.cget(key) == tk_call('set', "tkPalette(#{key})")
|
||||
window[key] = colors[key]
|
||||
end
|
||||
rescue
|
||||
# ignore
|
||||
# ignore
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ class TkPanedWindow<TkWindow
|
|||
if key.kind_of? Hash
|
||||
params = []
|
||||
key.each{|k, v|
|
||||
params.push("-#{k}")
|
||||
# params.push((v.kind_of?(TkObject))? v.epath: v)
|
||||
params.push(_epath(v))
|
||||
params.push("-#{k}")
|
||||
# params.push((v.kind_of?(TkObject))? v.epath: v)
|
||||
params.push(_epath(v))
|
||||
}
|
||||
tk_send_without_enc('paneconfigure', win, *params)
|
||||
else
|
||||
|
@ -107,68 +107,68 @@ class TkPanedWindow<TkWindow
|
|||
# win = win.epath if win.kind_of?(TkObject)
|
||||
win = _epath(win)
|
||||
if key
|
||||
conf = tk_split_list(tk_send_without_enc('paneconfigure',
|
||||
win, "-#{key}"))
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
conf = tk_split_list(tk_send_without_enc('paneconfigure',
|
||||
win, "-#{key}"))
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_simplelist(tk_send_without_enc('paneconfigure',
|
||||
win)).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
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
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
tk_split_simplelist(tk_send_without_enc('paneconfigure',
|
||||
win)).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
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
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
# win = win.epath if win.kind_of?(TkObject)
|
||||
win = _epath(win)
|
||||
if key
|
||||
conf = tk_split_list(tk_send_without_enc('paneconfigure',
|
||||
win, "-#{key}"))
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
conf = tk_split_list(tk_send_without_enc('paneconfigure',
|
||||
win, "-#{key}"))
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(tk_send_without_enc('paneconfigure',
|
||||
win)).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
if key
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
tk_split_simplelist(tk_send_without_enc('paneconfigure',
|
||||
win)).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
if key
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -177,19 +177,19 @@ class TkPanedWindow<TkWindow
|
|||
def current_paneconfiginfo(win, key=nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if key
|
||||
conf = paneconfiginfo(win, key)
|
||||
{conf[0] => conf[4]}
|
||||
conf = paneconfiginfo(win, key)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
paneconfiginfo(win).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
paneconfiginfo(win).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
paneconfiginfo(win, key).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@ module TkPlace
|
|||
if slot.kind_of? Hash
|
||||
params = []
|
||||
slot.each{|k, v|
|
||||
params.push("-#{k}")
|
||||
# params.push((v.kind_of?(TkObject))? v.epath: v)
|
||||
params.push(_epath(v))
|
||||
params.push("-#{k}")
|
||||
# params.push((v.kind_of?(TkObject))? v.epath: v)
|
||||
params.push(_epath(v))
|
||||
}
|
||||
tk_call_without_enc('place', 'configure', win, *params)
|
||||
else
|
||||
|
@ -35,24 +35,24 @@ module TkPlace
|
|||
# win = win.epath if win.kind_of?(TkObject)
|
||||
win = _epath(win)
|
||||
if slot
|
||||
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
|
||||
# win, "-#{slot}") )
|
||||
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win, "-#{slot}") )
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf[1] = tk_tcl2ruby(conf[1])
|
||||
conf[2] = tk_tcl2ruby(conf[1])
|
||||
conf[3] = tk_tcl2ruby(conf[1])
|
||||
conf[4] = tk_tcl2ruby(conf[1])
|
||||
conf
|
||||
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
|
||||
# win, "-#{slot}") )
|
||||
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win, "-#{slot}") )
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf[1] = tk_tcl2ruby(conf[1])
|
||||
conf[2] = tk_tcl2ruby(conf[1])
|
||||
conf[3] = tk_tcl2ruby(conf[1])
|
||||
conf[4] = tk_tcl2ruby(conf[1])
|
||||
conf
|
||||
else
|
||||
tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win)).collect{|conflist|
|
||||
#conf = list(conflist)
|
||||
conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
}
|
||||
tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win)).collect{|conflist|
|
||||
#conf = list(conflist)
|
||||
conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
}
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
|
||||
current_configinfo(win, slot)
|
||||
|
@ -66,17 +66,17 @@ module TkPlace
|
|||
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
|
||||
# win, "-#{slot}") )
|
||||
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win, "-#{slot}") )
|
||||
win, "-#{slot}") )
|
||||
# { conf[0][1..-1] => conf[1] }
|
||||
{ conf[0][1..-1] => tk_tcl2ruby(conf[4]) }
|
||||
else
|
||||
ret = {}
|
||||
#tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf|
|
||||
tk_split_simplelist(tk_call_without_enc('place', 'configure',
|
||||
win)).each{|conf_list|
|
||||
#ret[conf[0][1..-1]] = conf[1]
|
||||
conf = simplelist(conf_list)
|
||||
ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4])
|
||||
win)).each{|conf_list|
|
||||
#ret[conf[0][1..-1]] = conf[1]
|
||||
conf = simplelist(conf_list)
|
||||
ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4])
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
|
|
@ -19,11 +19,11 @@ class TkRoot<TkWindow
|
|||
new = super(:without_creating=>true, :widgetname=>'.')
|
||||
if keys # wm commands
|
||||
keys.each{|k,v|
|
||||
if v.kind_of? Array
|
||||
new.send(k,*v)
|
||||
else
|
||||
new.send(k,v)
|
||||
end
|
||||
if v.kind_of? Array
|
||||
new.send(k,*v)
|
||||
else
|
||||
new.send(k,v)
|
||||
end
|
||||
}
|
||||
end
|
||||
ROOT[0] = new
|
||||
|
@ -33,16 +33,16 @@ class TkRoot<TkWindow
|
|||
def TkRoot.new(keys=nil, &b)
|
||||
unless TkCore::INTERP.tk_windows['.']
|
||||
TkCore::INTERP.tk_windows['.'] =
|
||||
super(:without_creating=>true, :widgetname=>'.'){}
|
||||
super(:without_creating=>true, :widgetname=>'.'){}
|
||||
end
|
||||
root = TkCore::INTERP.tk_windows['.']
|
||||
if keys # wm commands
|
||||
keys.each{|k,v|
|
||||
if v.kind_of? Array
|
||||
root.__send__(k,*v)
|
||||
else
|
||||
root.__send__(k,v)
|
||||
end
|
||||
if v.kind_of? Array
|
||||
root.__send__(k,*v)
|
||||
else
|
||||
root.__send__(k,v)
|
||||
end
|
||||
}
|
||||
end
|
||||
root.instance_eval(&b) if block_given?
|
||||
|
|
|
@ -11,12 +11,12 @@ class TkScale<TkWindow
|
|||
def create_self(keys)
|
||||
if keys and keys != None
|
||||
if keys.key?('command') && ! keys['command'].kind_of?(String)
|
||||
cmd = keys.delete('command')
|
||||
keys['command'] = proc{|val| cmd.call(val.to_f)}
|
||||
cmd = keys.delete('command')
|
||||
keys['command'] = proc{|val| cmd.call(val.to_f)}
|
||||
end
|
||||
#tk_call_without_enc('scale', @path, *hash_kv(keys, true))
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
#tk_call_without_enc('scale', @path)
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
|
@ -27,9 +27,9 @@ class TkScale<TkWindow
|
|||
def _wrap_command_arg(cmd)
|
||||
proc{|val|
|
||||
if val.kind_of?(String)
|
||||
cmd.call(number(val))
|
||||
cmd.call(number(val))
|
||||
else
|
||||
cmd.call(val)
|
||||
cmd.call(val)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ class TkScale<TkWindow
|
|||
if (slot == 'command' || slot == :command)
|
||||
configure('command'=>value)
|
||||
elsif slot.kind_of?(Hash) &&
|
||||
(slot.key?('command') || slot.key?(:command))
|
||||
(slot.key?('command') || slot.key?(:command))
|
||||
slot = _symbolkey2str(slot)
|
||||
slot['command'] = _wrap_command_arg(slot.delete('command'))
|
||||
end
|
||||
|
|
|
@ -18,10 +18,10 @@ module Tk
|
|||
|
||||
def xview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('xview'))
|
||||
list(tk_send_without_enc('xview'))
|
||||
else
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
tk_send_without_enc('xview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def xview_moveto(*index)
|
||||
|
@ -33,10 +33,10 @@ module Tk
|
|||
|
||||
def yview(*index)
|
||||
if index.size == 0
|
||||
list(tk_send_without_enc('yview'))
|
||||
list(tk_send_without_enc('yview'))
|
||||
else
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
tk_send_without_enc('yview', *index)
|
||||
self
|
||||
end
|
||||
end
|
||||
def yview_moveto(*index)
|
||||
|
@ -48,21 +48,21 @@ module Tk
|
|||
|
||||
def xscrollbar(bar=nil)
|
||||
if bar
|
||||
@xscrollbar = bar
|
||||
@xscrollbar.orient 'horizontal'
|
||||
self.xscrollcommand {|*arg| @xscrollbar.set(*arg)}
|
||||
@xscrollbar.command {|*arg| self.xview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
@xscrollbar = bar
|
||||
@xscrollbar.orient 'horizontal'
|
||||
self.xscrollcommand {|*arg| @xscrollbar.set(*arg)}
|
||||
@xscrollbar.command {|*arg| self.xview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@xscrollbar
|
||||
end
|
||||
def yscrollbar(bar=nil)
|
||||
if bar
|
||||
@yscrollbar = bar
|
||||
@yscrollbar.orient 'vertical'
|
||||
self.yscrollcommand {|*arg| @yscrollbar.set(*arg)}
|
||||
@yscrollbar.command {|*arg| self.yview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
@yscrollbar = bar
|
||||
@yscrollbar.orient 'vertical'
|
||||
self.yscrollcommand {|*arg| @yscrollbar.set(*arg)}
|
||||
@yscrollbar.command {|*arg| self.yview(*arg)}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
end
|
||||
@yscrollbar
|
||||
end
|
||||
|
|
|
@ -12,16 +12,16 @@ class TkScrollbar<TkWindow
|
|||
@assigned = []
|
||||
@scroll_proc = proc{|*args|
|
||||
if self.orient == 'horizontal'
|
||||
@assigned.each{|w| w.xview(*args)}
|
||||
@assigned.each{|w| w.xview(*args)}
|
||||
else # 'vertical'
|
||||
@assigned.each{|w| w.yview(*args)}
|
||||
@assigned.each{|w| w.yview(*args)}
|
||||
end
|
||||
}
|
||||
|
||||
if keys and keys != None
|
||||
#tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
#tk_call_without_enc('scrollbar', @path)
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
|
@ -48,9 +48,9 @@ class TkScrollbar<TkWindow
|
|||
wins.each{|w|
|
||||
@assigned << w unless @assigned.index(w)
|
||||
if orient == 'horizontal'
|
||||
w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
|
||||
w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
|
||||
else # 'vertical'
|
||||
w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
|
||||
w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
|
||||
end
|
||||
}
|
||||
Tk.update # avoid scrollbar trouble
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#
|
||||
# tk/scrollbox.rb - Tk Listbox with Scrollbar
|
||||
# tk/scrollbox.rb - Tk Listbox with Scrollbar
|
||||
# as an example of Composite Widget
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
#
|
||||
require 'tk'
|
||||
require 'tk/listbox'
|
||||
|
|
|
@ -19,7 +19,7 @@ module TkSelection
|
|||
def self.clear_on_display(win, sel=nil)
|
||||
if sel
|
||||
tk_call_without_enc('selection', 'clear',
|
||||
'-displayof', win, '-selection', sel)
|
||||
'-displayof', win, '-selection', sel)
|
||||
else
|
||||
tk_call_without_enc('selection', 'clear', '-displayof', win)
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ module TkSelection
|
|||
def self.get_on_display(win, keys=nil)
|
||||
#tk_call('selection', 'get', '-displayof', win, *hash_kv(keys))
|
||||
_fromUTF8(tk_call_without_enc('selection', 'get', '-displayof',
|
||||
win, *hash_kv(keys)))
|
||||
win, *hash_kv(keys)))
|
||||
end
|
||||
def get(keys=nil)
|
||||
TkSelection.get_on_display(self, sel)
|
||||
|
@ -66,7 +66,7 @@ module TkSelection
|
|||
def self.get_owner_on_display(win, sel=nil)
|
||||
if sel
|
||||
window(tk_call_without_enc('selection', 'own',
|
||||
'-displayof', win, '-selection', sel))
|
||||
'-displayof', win, '-selection', sel))
|
||||
else
|
||||
window(tk_call_without_enc('selection', 'own', '-displayof', win))
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# tk/spinbox.rb - Tk spinbox classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
# tk/spinbox.rb - Tk spinbox classes
|
||||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
#
|
||||
require 'tk'
|
||||
require 'tk/entry'
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -14,20 +14,20 @@ class TkTextImage<TkObject
|
|||
@path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
|
||||
elsif index.kind_of? TkTextMark
|
||||
if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
'end - 1 chars'))
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
'end - 1 chars'))
|
||||
else
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
index.path))
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
index.path))
|
||||
end
|
||||
else
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
_get_eval_enc_str(index)))
|
||||
_get_eval_enc_str(index)))
|
||||
end
|
||||
@path.gravity = 'left'
|
||||
@index = @path.path
|
||||
@id = tk_call_without_enc(@t.path, 'image', 'create', @index,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
end
|
||||
|
||||
def [](slot)
|
||||
|
@ -65,7 +65,7 @@ class TkTextImage<TkObject
|
|||
|
||||
def image=(value)
|
||||
tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image',
|
||||
_get_eval_enc_str(value))
|
||||
_get_eval_enc_str(value))
|
||||
#self
|
||||
value
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ class TkTextMark<TkObject
|
|||
TMarkID_TBL[@tpath][@id] = self
|
||||
Tk_TextMark_ID[1].succ!
|
||||
tk_call_without_enc(@t.path, 'mark', 'set', @id,
|
||||
_get_eval_enc_str(index))
|
||||
_get_eval_enc_str(index))
|
||||
@t._addtag id, self
|
||||
end
|
||||
|
||||
|
@ -54,7 +54,7 @@ class TkTextMark<TkObject
|
|||
|
||||
def set(where)
|
||||
tk_call_without_enc(@t.path, 'mark', 'set', @id,
|
||||
_get_eval_enc_str(where))
|
||||
_get_eval_enc_str(where))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -111,7 +111,7 @@ class TkTextNamedMark<TkTextMark
|
|||
TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
|
||||
TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id]
|
||||
tk_call_without_enc(@t.path, 'mark', 'set', @id,
|
||||
_get_eval_enc_str(index)) if index
|
||||
_get_eval_enc_str(index)) if index
|
||||
@t._addtag id, self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,11 +35,11 @@ class TkTextTag<TkObject
|
|||
if args != [] then
|
||||
keys = args.pop
|
||||
if keys.kind_of? Hash then
|
||||
add(*args) if args != []
|
||||
configure(keys)
|
||||
add(*args) if args != []
|
||||
configure(keys)
|
||||
else
|
||||
args.push keys
|
||||
add(*args)
|
||||
args.push keys
|
||||
add(*args)
|
||||
end
|
||||
end
|
||||
@t._addtag id, self
|
||||
|
@ -67,13 +67,13 @@ class TkTextTag<TkObject
|
|||
|
||||
def add(*indices)
|
||||
tk_call_without_enc(@t.path, 'tag', 'add', @id,
|
||||
*(indices.collect{|idx| _get_eval_enc_str(idx)}))
|
||||
*(indices.collect{|idx| _get_eval_enc_str(idx)}))
|
||||
self
|
||||
end
|
||||
|
||||
def remove(*indices)
|
||||
tk_call_without_enc(@t.path, 'tag', 'remove', @id,
|
||||
*(indices.collect{|idx| _get_eval_enc_str(idx)}))
|
||||
*(indices.collect{|idx| _get_eval_enc_str(idx)}))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -88,14 +88,14 @@ class TkTextTag<TkObject
|
|||
|
||||
def nextrange(first, last=None)
|
||||
tk_split_list(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
|
||||
_get_eval_enc_str(first),
|
||||
_get_eval_enc_str(last)))
|
||||
_get_eval_enc_str(first),
|
||||
_get_eval_enc_str(last)))
|
||||
end
|
||||
|
||||
def prevrange(first, last=None)
|
||||
tk_split_list(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
|
||||
_get_eval_enc_str(first),
|
||||
_get_eval_enc_str(last)))
|
||||
_get_eval_enc_str(first),
|
||||
_get_eval_enc_str(last)))
|
||||
end
|
||||
|
||||
def [](key)
|
||||
|
@ -118,19 +118,19 @@ class TkTextTag<TkObject
|
|||
when 'font', 'kanjifont'
|
||||
#fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}"))
|
||||
fnt = tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
|
||||
@id, '-font')))
|
||||
@id, '-font')))
|
||||
unless fnt.kind_of?(TkFont)
|
||||
fnt = tagfontobj(@id, fnt)
|
||||
fnt = tagfontobj(@id, fnt)
|
||||
end
|
||||
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
# obsolete; just for compatibility
|
||||
fnt.kanji_font
|
||||
else
|
||||
fnt
|
||||
fnt
|
||||
end
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
|
||||
@id, "-#{key}")))
|
||||
@id, "-#{key}")))
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
@ -183,13 +183,13 @@ class TkTextTag<TkObject
|
|||
|
||||
def raise(above=None)
|
||||
tk_call_without_enc(@t.path, 'tag', 'raise', @id,
|
||||
_get_eval_enc_str(above))
|
||||
_get_eval_enc_str(above))
|
||||
self
|
||||
end
|
||||
|
||||
def lower(below=None)
|
||||
tk_call_without_enc(@t.path, 'tag', 'lower', @id,
|
||||
_get_eval_enc_str(below))
|
||||
_get_eval_enc_str(below))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -205,14 +205,14 @@ class TkTextNamedTag<TkTextTag
|
|||
if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
|
||||
tagobj = TTagID_TBL[parent.path][name]
|
||||
if args != [] then
|
||||
keys = args.pop
|
||||
if keys.kind_of? Hash then
|
||||
tagobj.add(*args) if args != []
|
||||
tagobj.configure(keys)
|
||||
else
|
||||
args.push keys
|
||||
tagobj.add(*args)
|
||||
end
|
||||
keys = args.pop
|
||||
if keys.kind_of? Hash then
|
||||
tagobj.add(*args) if args != []
|
||||
tagobj.configure(keys)
|
||||
else
|
||||
args.push keys
|
||||
tagobj.add(*args)
|
||||
end
|
||||
end
|
||||
return tagobj
|
||||
else
|
||||
|
@ -235,11 +235,11 @@ class TkTextNamedTag<TkTextTag
|
|||
if args != [] then
|
||||
keys = args.pop
|
||||
if keys.kind_of? Hash then
|
||||
add(*args) if args != []
|
||||
configure(keys)
|
||||
add(*args) if args != []
|
||||
configure(keys)
|
||||
else
|
||||
args.push keys
|
||||
add(*args)
|
||||
args.push keys
|
||||
add(*args)
|
||||
end
|
||||
end
|
||||
@t._addtag id, self
|
||||
|
|
|
@ -12,14 +12,14 @@ class TkTextWindow<TkObject
|
|||
@t = parent
|
||||
if index == 'end'
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
'end - 1 chars'))
|
||||
'end - 1 chars'))
|
||||
elsif index.kind_of? TkTextMark
|
||||
if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
'end - 1 chars'))
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
'end - 1 chars'))
|
||||
else
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
index.path))
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
|
||||
index.path))
|
||||
end
|
||||
else
|
||||
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', _get_eval_enc_str(index)))
|
||||
|
@ -34,20 +34,20 @@ class TkTextWindow<TkObject
|
|||
@p_create = keys['create']
|
||||
if @p_create.kind_of? Proc
|
||||
=begin
|
||||
keys['create'] = install_cmd(proc{
|
||||
@id = @p_create.call
|
||||
if @id.kind_of?(TkWindow)
|
||||
@id.epath
|
||||
else
|
||||
@id
|
||||
end
|
||||
})
|
||||
keys['create'] = install_cmd(proc{
|
||||
@id = @p_create.call
|
||||
if @id.kind_of?(TkWindow)
|
||||
@id.epath
|
||||
else
|
||||
@id
|
||||
end
|
||||
})
|
||||
=end
|
||||
keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
|
||||
keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
|
||||
end
|
||||
end
|
||||
tk_call_without_enc(@t.path, 'window', 'create', @index,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
end
|
||||
|
||||
def [](slot)
|
||||
|
@ -66,28 +66,28 @@ class TkTextWindow<TkObject
|
|||
if slot.kind_of? Hash
|
||||
slot = _symbolkey2str(slot)
|
||||
if slot['window']
|
||||
@id = slot['window']
|
||||
# slot['window'] = @id.epath if @id.kind_of?(TkWindow)
|
||||
slot['window'] = _epath(@id) if @id
|
||||
@id = slot['window']
|
||||
# slot['window'] = @id.epath if @id.kind_of?(TkWindow)
|
||||
slot['window'] = _epath(@id) if @id
|
||||
end
|
||||
if slot['create']
|
||||
self.create=slot.delete('create')
|
||||
self.create=slot.delete('create')
|
||||
end
|
||||
if slot.size > 0
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
*hash_kv(slot, true))
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
*hash_kv(slot, true))
|
||||
end
|
||||
else
|
||||
if slot == 'window' || slot == :window
|
||||
@id = value
|
||||
# value = @id.epath if @id.kind_of?(TkWindow)
|
||||
value = _epath(@id) if @id
|
||||
@id = value
|
||||
# value = @id.epath if @id.kind_of?(TkWindow)
|
||||
value = _epath(@id) if @id
|
||||
end
|
||||
if slot == 'create' || slot == :create
|
||||
self.create=value
|
||||
self.create=value
|
||||
else
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
"-#{slot}", _get_eval_enc_str(value))
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
"-#{slot}", _get_eval_enc_str(value))
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -110,7 +110,7 @@ class TkTextWindow<TkObject
|
|||
# value = @id.epath if @id.kind_of?(TkWindow)
|
||||
value = _epath(@id) if @id
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
'-window', _get_eval_enc_str(value))
|
||||
'-window', _get_eval_enc_str(value))
|
||||
value
|
||||
end
|
||||
|
||||
|
@ -122,16 +122,16 @@ class TkTextWindow<TkObject
|
|||
@p_create = value
|
||||
if @p_create.kind_of? Proc
|
||||
value = install_cmd(proc{
|
||||
@id = @p_create.call
|
||||
if @id.kind_of?(TkWindow)
|
||||
@id.epath
|
||||
else
|
||||
@id
|
||||
end
|
||||
})
|
||||
@id = @p_create.call
|
||||
if @id.kind_of?(TkWindow)
|
||||
@id.epath
|
||||
else
|
||||
@id
|
||||
end
|
||||
})
|
||||
end
|
||||
tk_call_without_enc(@t.path, 'window', 'configure', @index,
|
||||
'-create', _get_eval_enc_str(value))
|
||||
'-create', _get_eval_enc_str(value))
|
||||
value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@ class TkTimer
|
|||
|
||||
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
|
||||
if {[set st [catch {eval {ruby_cmd TkTimer callback} $id} ret]] != 0} {
|
||||
return -code $st $ret
|
||||
return -code $st $ret
|
||||
} {
|
||||
return $ret
|
||||
return $ret
|
||||
}
|
||||
EOL
|
||||
|
||||
|
@ -36,19 +36,19 @@ class TkTimer
|
|||
def self.info(obj = nil)
|
||||
if obj
|
||||
if obj.kind_of?(TkTimer)
|
||||
if obj.after_id
|
||||
inf = tk_split_list(tk_call_without_enc('after','info',obj.after_id))
|
||||
[Tk_CBTBL[inf[0][1]], inf[1]]
|
||||
else
|
||||
nil
|
||||
end
|
||||
if obj.after_id
|
||||
inf = tk_split_list(tk_call_without_enc('after','info',obj.after_id))
|
||||
[Tk_CBTBL[inf[0][1]], inf[1]]
|
||||
else
|
||||
nil
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "TkTimer object is expected"
|
||||
fail ArgumentError, "TkTimer object is expected"
|
||||
end
|
||||
else
|
||||
tk_call_without_enc('after', 'info').split(' ').collect!{|id|
|
||||
ret = Tk_CBTBL.find{|key,val| val.after_id == id}
|
||||
(ret == nil)? id: ret[1]
|
||||
ret = Tk_CBTBL.find{|key,val| val.after_id == id}
|
||||
(ret == nil)? id: ret[1]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -67,13 +67,13 @@ class TkTimer
|
|||
exit!(1)
|
||||
rescue Exception => e
|
||||
if @cancel_on_exception &&
|
||||
@cancel_on_exception.find{|exc| e.kind_of?(exc)}
|
||||
cancel
|
||||
@return_value = e
|
||||
@in_callback = false
|
||||
return e
|
||||
@cancel_on_exception.find{|exc| e.kind_of?(exc)}
|
||||
cancel
|
||||
@return_value = e
|
||||
@in_callback = false
|
||||
return e
|
||||
else
|
||||
fail e
|
||||
fail e
|
||||
end
|
||||
end
|
||||
if @set_next
|
||||
|
@ -106,12 +106,12 @@ class TkTimer
|
|||
end
|
||||
if @current_pos >= @proc_max
|
||||
if @do_loop < 0 || (@do_loop -= 1) > 0
|
||||
@current_pos = 0
|
||||
@current_pos = 0
|
||||
else
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
return
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,9 +237,9 @@ class TkTimer
|
|||
@loop_proc = []
|
||||
procs.each{|e|
|
||||
if e.kind_of? Proc
|
||||
@loop_proc.push([e])
|
||||
@loop_proc.push([e])
|
||||
else
|
||||
@loop_proc.push(e)
|
||||
@loop_proc.push(e)
|
||||
end
|
||||
}
|
||||
@proc_max = @loop_proc.size
|
||||
|
@ -248,14 +248,14 @@ class TkTimer
|
|||
@do_loop = 0
|
||||
if loop_exec
|
||||
if loop_exec.kind_of?(Integer) && loop_exec < 0
|
||||
@loop_exec = -1
|
||||
@loop_exec = -1
|
||||
elsif loop_exec == nil || loop_exec == false || loop_exec == 0
|
||||
@loop_exec = 1
|
||||
@loop_exec = 1
|
||||
else
|
||||
if not loop_exec.kind_of?(Integer)
|
||||
fail ArguemntError, "expect Integer for 2nd argument"
|
||||
end
|
||||
@loop_exec = loop_exec
|
||||
if not loop_exec.kind_of?(Integer)
|
||||
fail ArguemntError, "expect Integer for 2nd argument"
|
||||
end
|
||||
@loop_exec = loop_exec
|
||||
end
|
||||
@do_loop = @loop_exec
|
||||
end
|
||||
|
@ -266,9 +266,9 @@ class TkTimer
|
|||
def add_procs(*procs)
|
||||
procs.each{|e|
|
||||
if e.kind_of? Proc
|
||||
@loop_proc.push([e])
|
||||
@loop_proc.push([e])
|
||||
else
|
||||
@loop_proc.push(e)
|
||||
@loop_proc.push(e)
|
||||
end
|
||||
}
|
||||
@proc_max = @loop_proc.size
|
||||
|
@ -279,9 +279,9 @@ class TkTimer
|
|||
def delete_procs(*procs)
|
||||
procs.each{|e|
|
||||
if e.kind_of? Proc
|
||||
@loop_proc.delete([e])
|
||||
@loop_proc.delete([e])
|
||||
else
|
||||
@loop_proc.delete(e)
|
||||
@loop_proc.delete(e)
|
||||
end
|
||||
}
|
||||
@proc_max = @loop_proc.size
|
||||
|
@ -327,7 +327,7 @@ class TkTimer
|
|||
if argc > 0
|
||||
sleep = init_args.shift
|
||||
if !sleep == 'idle' && !sleep.kind_of?(Integer)
|
||||
fail ArguemntError, "expect Integer or 'idle' for 1st argument"
|
||||
fail ArguemntError, "expect Integer or 'idle' for 1st argument"
|
||||
end
|
||||
@init_sleep = sleep
|
||||
end
|
||||
|
@ -340,7 +340,7 @@ class TkTimer
|
|||
@running = true
|
||||
if @init_proc
|
||||
if not @init_proc.kind_of? Proc
|
||||
fail ArgumentError, "Argument '#{@init_proc}' need to be Proc"
|
||||
fail ArgumentError, "Argument '#{@init_proc}' need to be Proc"
|
||||
end
|
||||
@current_proc = @init_proc
|
||||
set_callback(@init_sleep, @init_args)
|
||||
|
@ -393,7 +393,7 @@ class TkTimer
|
|||
fail RuntimeError, "no procedure to continue" unless cmd
|
||||
if wait
|
||||
unless wait.kind_of? Integer
|
||||
fail ArguemntError, "expect Integer for 1st argument"
|
||||
fail ArguemntError, "expect Integer for 1st argument"
|
||||
end
|
||||
sleep = wait
|
||||
end
|
||||
|
@ -428,9 +428,9 @@ class TkTimer
|
|||
|
||||
unless @running
|
||||
if @return_value.kind_of?(Exception)
|
||||
fail @return_value
|
||||
fail @return_value
|
||||
else
|
||||
return @return_value
|
||||
return @return_value
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -51,19 +51,19 @@ class TkToplevel<TkWindow
|
|||
wm_cmds = {}
|
||||
keys.each{|k,v|
|
||||
if Wm.method_defined?(k)
|
||||
case k
|
||||
when 'screen','class','colormap','container','use','visual'
|
||||
new_keys[k] = v
|
||||
else
|
||||
case self.method(k).arity
|
||||
when -1,1
|
||||
wm_cmds[k] = v
|
||||
else
|
||||
new_keys[k] = v
|
||||
end
|
||||
end
|
||||
case k
|
||||
when 'screen','class','colormap','container','use','visual'
|
||||
new_keys[k] = v
|
||||
else
|
||||
case self.method(k).arity
|
||||
when -1,1
|
||||
wm_cmds[k] = v
|
||||
else
|
||||
new_keys[k] = v
|
||||
end
|
||||
end
|
||||
else
|
||||
new_keys[k] = v
|
||||
new_keys[k] = v
|
||||
end
|
||||
}
|
||||
[new_keys, wm_cmds]
|
||||
|
@ -79,7 +79,7 @@ class TkToplevel<TkWindow
|
|||
if parent.kind_of? Hash
|
||||
keys = _symbolkey2str(parent)
|
||||
if keys.key?('classname')
|
||||
keys['class'] = keys.delete('classname')
|
||||
keys['class'] = keys.delete('classname')
|
||||
end
|
||||
@classname = keys['class']
|
||||
@colormap = keys['colormap']
|
||||
|
@ -88,25 +88,25 @@ class TkToplevel<TkWindow
|
|||
@use = keys['use']
|
||||
@visual = keys['visual']
|
||||
if !@classname && my_class_name
|
||||
keys['class'] = @classname = my_class_name
|
||||
keys['class'] = @classname = my_class_name
|
||||
end
|
||||
if @classname.kind_of? TkBindTag
|
||||
@db_class = @classname
|
||||
@classname = @classname.id
|
||||
@db_class = @classname
|
||||
@classname = @classname.id
|
||||
elsif @classname
|
||||
@db_class = TkDatabaseClass.new(@classname)
|
||||
@db_class = TkDatabaseClass.new(@classname)
|
||||
else
|
||||
@db_class = self.class
|
||||
@classname = @db_class::WidgetClassName
|
||||
@db_class = self.class
|
||||
@classname = @db_class::WidgetClassName
|
||||
end
|
||||
keys, cmds = _wm_command_option_chk(keys)
|
||||
super(keys)
|
||||
cmds.each{|k,v|
|
||||
if v.kind_of? Array
|
||||
self.__send__(k,*v)
|
||||
else
|
||||
self.__send__(k,v)
|
||||
end
|
||||
if v.kind_of? Array
|
||||
self.__send__(k,*v)
|
||||
else
|
||||
self.__send__(k,v)
|
||||
end
|
||||
}
|
||||
return
|
||||
end
|
||||
|
@ -116,15 +116,15 @@ class TkToplevel<TkWindow
|
|||
else
|
||||
@screen = screen
|
||||
if classname.kind_of? Hash
|
||||
keys = classname
|
||||
keys = classname
|
||||
else
|
||||
@classname = classname
|
||||
@classname = classname
|
||||
end
|
||||
end
|
||||
if keys.kind_of? Hash
|
||||
keys = _symbolkey2str(keys)
|
||||
if keys.key?('classname')
|
||||
keys['class'] = keys.delete('classname')
|
||||
keys['class'] = keys.delete('classname')
|
||||
end
|
||||
@classname = keys['class'] unless @classname
|
||||
@colormap = keys['colormap']
|
||||
|
@ -151,9 +151,9 @@ class TkToplevel<TkWindow
|
|||
super(parent, keys)
|
||||
cmds.each{|k,v|
|
||||
if v.kind_of? Array
|
||||
self.send(k,*v)
|
||||
self.send(k,*v)
|
||||
else
|
||||
self.send(k,v)
|
||||
self.send(k,v)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Tk
|
|||
def self.__def_validcmd(scope, klass, keys=nil)
|
||||
keys = klass._config_keys unless keys
|
||||
keys.each{|key|
|
||||
eval("def #{key}(*args, &b)
|
||||
eval("def #{key}(*args, &b)
|
||||
__validcmd_call(#{klass.name}, '#{key}', *args, &b)
|
||||
end", scope)
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ module Tk
|
|||
cmd = (b)? proc(&b) : args.shift
|
||||
|
||||
if cmd.kind_of?(klass)
|
||||
configure(key, cmd)
|
||||
configure(key, cmd)
|
||||
elsif !args.empty?
|
||||
configure(key, [cmd, args])
|
||||
configure(key, [cmd, args])
|
||||
else
|
||||
configure(key, cmd)
|
||||
configure(key, cmd)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,9 +36,9 @@ module Tk
|
|||
def __get_validate_key2class
|
||||
k2c = {}
|
||||
__validation_class_list.each{|klass|
|
||||
klass._config_keys.each{|key|
|
||||
k2c[key.to_s] = klass
|
||||
}
|
||||
klass._config_keys.each{|key|
|
||||
k2c[key.to_s] = klass
|
||||
}
|
||||
}
|
||||
k2c
|
||||
end
|
||||
|
@ -48,12 +48,12 @@ module Tk
|
|||
|
||||
keys = _symbolkey2str(keys)
|
||||
key2class.each{|key, klass|
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
keys[key] = klass.new(keys[key])
|
||||
end
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
keys[key] = klass.new(keys[key])
|
||||
end
|
||||
}
|
||||
keys
|
||||
end
|
||||
|
@ -65,9 +65,9 @@ module Tk
|
|||
|
||||
def configure(slot, value=TkComm::None)
|
||||
if slot.kind_of?(Hash)
|
||||
super(__conv_vcmd_on_hash_kv(slot))
|
||||
super(__conv_vcmd_on_hash_kv(slot))
|
||||
else
|
||||
super(__conv_vcmd_on_hash_kv(slot=>value))
|
||||
super(__conv_vcmd_on_hash_kv(slot=>value))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -76,28 +76,28 @@ module Tk
|
|||
key2class = __get_validate_key2class
|
||||
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
key2class.each{|key, klass|
|
||||
if slot[key].kind_of?(Array)
|
||||
cmd, *args = slot[key]
|
||||
slot[key] = klass.new(cmd, args.join(' '))
|
||||
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
||||
slot[key] = klass.new(slot[key])
|
||||
end
|
||||
}
|
||||
super(slot)
|
||||
slot = _symbolkey2str(slot)
|
||||
key2class.each{|key, klass|
|
||||
if slot[key].kind_of?(Array)
|
||||
cmd, *args = slot[key]
|
||||
slot[key] = klass.new(cmd, args.join(' '))
|
||||
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
||||
slot[key] = klass.new(slot[key])
|
||||
end
|
||||
}
|
||||
super(slot)
|
||||
|
||||
else
|
||||
slot = slot.to_s
|
||||
if (klass = key2class[slot])
|
||||
if value.kind_of?(Array)
|
||||
cmd, *args = value
|
||||
value = klass.new(cmd, args.join(' '))
|
||||
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
||||
value = klass.new(value)
|
||||
end
|
||||
end
|
||||
super(slot, value)
|
||||
slot = slot.to_s
|
||||
if (klass = key2class[slot])
|
||||
if value.kind_of?(Array)
|
||||
cmd, *args = value
|
||||
value = klass.new(cmd, args.join(' '))
|
||||
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
||||
value = klass.new(value)
|
||||
end
|
||||
end
|
||||
super(slot, value)
|
||||
end
|
||||
|
||||
self
|
||||
|
@ -109,7 +109,7 @@ module Tk
|
|||
def self.__def_validcmd(scope, klass, keys=nil)
|
||||
keys = klass._config_keys unless keys
|
||||
keys.each{|key|
|
||||
eval("def item_#{key}(id, *args, &b)
|
||||
eval("def item_#{key}(id, *args, &b)
|
||||
__item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b)
|
||||
end", scope)
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ module Tk
|
|||
cmd = (b)? proc(&b) : args.shift
|
||||
|
||||
if cmd.kind_of?(klass)
|
||||
itemconfigure(tagid(tagOrId), key, cmd)
|
||||
itemconfigure(tagid(tagOrId), key, cmd)
|
||||
elsif !args.empty?
|
||||
itemconfigure(tagid(tagOrId), key, [cmd, args])
|
||||
itemconfigure(tagid(tagOrId), key, [cmd, args])
|
||||
else
|
||||
itemconfigure(tagid(tagOrId), key, cmd)
|
||||
itemconfigure(tagid(tagOrId), key, cmd)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,9 +137,9 @@ module Tk
|
|||
def __get_item_validate_key2class(id)
|
||||
k2c = {}
|
||||
__item_validation_class_list(id).each{|klass|
|
||||
klass._config_keys.each{|key|
|
||||
k2c[key.to_s] = klass
|
||||
}
|
||||
klass._config_keys.each{|key|
|
||||
k2c[key.to_s] = klass
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -148,21 +148,21 @@ module Tk
|
|||
|
||||
keys = _symbolkey2str(keys)
|
||||
key2class.each{|key, klass|
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
keys[key] = klass.new(keys[key])
|
||||
end
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
keys[key] = klass.new(keys[key])
|
||||
end
|
||||
}
|
||||
keys
|
||||
end
|
||||
|
||||
def itemconfigure(tagOrId, slot, value=TkComm::None)
|
||||
if slot.kind_of?(Hash)
|
||||
super(__conv_item_vcmd_on_hash_kv(slot))
|
||||
super(__conv_item_vcmd_on_hash_kv(slot))
|
||||
else
|
||||
super(__conv_item_vcmd_on_hash_kv(slot=>value))
|
||||
super(__conv_item_vcmd_on_hash_kv(slot=>value))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -171,28 +171,28 @@ module Tk
|
|||
key2class = __get_item_validate_key2class(tagid(tagOrId))
|
||||
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
key2class.each{|key, klass|
|
||||
if slot[key].kind_of?(Array)
|
||||
cmd, *args = slot[key]
|
||||
slot[key] = klass.new(cmd, args.join(' '))
|
||||
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
||||
slot[key] = klass.new(slot[key])
|
||||
end
|
||||
}
|
||||
super(slot)
|
||||
slot = _symbolkey2str(slot)
|
||||
key2class.each{|key, klass|
|
||||
if slot[key].kind_of?(Array)
|
||||
cmd, *args = slot[key]
|
||||
slot[key] = klass.new(cmd, args.join(' '))
|
||||
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
||||
slot[key] = klass.new(slot[key])
|
||||
end
|
||||
}
|
||||
super(slot)
|
||||
|
||||
else
|
||||
slot = slot.to_s
|
||||
if (klass = key2class[slot])
|
||||
if value.kind_of?(Array)
|
||||
cmd, *args = value
|
||||
value = klass.new(cmd, args.join(' '))
|
||||
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
||||
value = klass.new(value)
|
||||
end
|
||||
end
|
||||
super(slot, value)
|
||||
slot = slot.to_s
|
||||
if (klass = key2class[slot])
|
||||
if value.kind_of?(Array)
|
||||
cmd, *args = value
|
||||
value = klass.new(cmd, args.join(' '))
|
||||
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
||||
value = klass.new(value)
|
||||
end
|
||||
end
|
||||
super(slot, value)
|
||||
end
|
||||
|
||||
self
|
||||
|
@ -224,23 +224,23 @@ class TkValidateCommand
|
|||
[ ?w, TkComm.method(:window) ],
|
||||
|
||||
[ ?e, proc{|val|
|
||||
enc = Tk.encoding
|
||||
if enc
|
||||
Tk.fromUTF8(TkComm::string(val), enc)
|
||||
else
|
||||
TkComm::string(val)
|
||||
end
|
||||
}
|
||||
enc = Tk.encoding
|
||||
if enc
|
||||
Tk.fromUTF8(TkComm::string(val), enc)
|
||||
else
|
||||
TkComm::string(val)
|
||||
end
|
||||
}
|
||||
],
|
||||
|
||||
[ ?x, proc{|val|
|
||||
idx = TkComm::number(val)
|
||||
if idx < 0
|
||||
nil
|
||||
else
|
||||
idx
|
||||
end
|
||||
}
|
||||
idx = TkComm::number(val)
|
||||
if idx < 0
|
||||
nil
|
||||
else
|
||||
idx
|
||||
end
|
||||
}
|
||||
],
|
||||
|
||||
nil
|
||||
|
@ -277,32 +277,32 @@ class TkValidateCommand
|
|||
args = args.join(' ')
|
||||
keys = klass._get_subst_key(args)
|
||||
if cmd.kind_of?(String)
|
||||
id = cmd
|
||||
id = cmd
|
||||
elsif cmd.kind_of?(TkCallbackEntry)
|
||||
@id = install_cmd(cmd)
|
||||
@id = install_cmd(cmd)
|
||||
else
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
*(ex_args.concat(klass.scan_args(keys, arg)))
|
||||
))
|
||||
}) + ' ' + args
|
||||
}) + ' ' + args
|
||||
end
|
||||
else
|
||||
keys, args = klass._get_all_subst_keys
|
||||
if cmd.kind_of?(String)
|
||||
id = cmd
|
||||
id = cmd
|
||||
elsif cmd.kind_of?(TkCallbackEntry)
|
||||
@id = install_cmd(cmd)
|
||||
@id = install_cmd(cmd)
|
||||
else
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
@id = install_cmd(proc{|*arg|
|
||||
ex_args = []
|
||||
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
||||
klass.ret_val(cmd.call(
|
||||
*(ex_args << klass.new(*klass.scan_args(keys, arg)))
|
||||
))
|
||||
}) + ' ' + args
|
||||
))
|
||||
}) + ' ' + args
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,24 +19,24 @@ class TkVariable
|
|||
Tk_VARIABLE_ID = ["v".freeze, "00000".taint].freeze
|
||||
|
||||
#TkCore::INTERP.add_tk_procs('rb_var', 'args',
|
||||
# "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
||||
# "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
||||
TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
|
||||
if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} {
|
||||
set idx [string first "\n\n" $ret]
|
||||
if {$idx > 0} {
|
||||
global errorInfo
|
||||
set tcl_backtrace $errorInfo
|
||||
set errorInfo [string range $ret [expr $idx + 2] \
|
||||
global errorInfo
|
||||
set tcl_backtrace $errorInfo
|
||||
set errorInfo [string range $ret [expr $idx + 2] \
|
||||
[string length $ret]]
|
||||
append errorInfo "\n" $tcl_backtrace
|
||||
bgerror [string range $ret 0 [expr $idx - 1]]
|
||||
bgerror [string range $ret 0 [expr $idx - 1]]
|
||||
} else {
|
||||
bgerror $ret
|
||||
}
|
||||
return ""
|
||||
#return -code $st $ret
|
||||
} else {
|
||||
return $ret
|
||||
return $ret
|
||||
}
|
||||
EOL
|
||||
|
||||
|
@ -47,40 +47,40 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
|
|||
if TkVar_CB_TBL[name1]
|
||||
#_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
|
||||
begin
|
||||
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op))
|
||||
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op))
|
||||
rescue SystemExit
|
||||
exit(0)
|
||||
exit(0)
|
||||
rescue Interrupt
|
||||
exit!(1)
|
||||
exit!(1)
|
||||
rescue Exception => e
|
||||
begin
|
||||
msg = _toUTF8(e.class.inspect) + ': ' +
|
||||
_toUTF8(e.message) + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
_toUTF8(e.backtrace.join("\n")) +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
msg.instance_variable_set(:@encoding, 'utf-8')
|
||||
rescue Exception
|
||||
msg = e.class.inspect + ': ' + e.message + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
e.backtrace.join("\n") +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
end
|
||||
fail(e, msg)
|
||||
begin
|
||||
msg = _toUTF8(e.class.inspect) + ': ' +
|
||||
_toUTF8(e.message) + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
_toUTF8(e.backtrace.join("\n")) +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
msg.instance_variable_set(:@encoding, 'utf-8')
|
||||
rescue Exception
|
||||
msg = e.class.inspect + ': ' + e.message + "\n" +
|
||||
"\n---< backtrace of Ruby side >-----\n" +
|
||||
e.backtrace.join("\n") +
|
||||
"\n---< backtrace of Tk side >-------"
|
||||
end
|
||||
fail(e, msg)
|
||||
end
|
||||
=begin
|
||||
begin
|
||||
raise 'check backtrace'
|
||||
raise 'check backtrace'
|
||||
rescue
|
||||
# ignore backtrace before 'callback'
|
||||
pos = -($!.backtrace.size)
|
||||
# ignore backtrace before 'callback'
|
||||
pos = -($!.backtrace.size)
|
||||
end
|
||||
begin
|
||||
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
|
||||
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
|
||||
rescue
|
||||
trace = $!.backtrace
|
||||
raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
|
||||
"\tfrom #{trace[1..pos].join("\n\tfrom ")}"
|
||||
trace = $!.backtrace
|
||||
raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
|
||||
"\tfrom #{trace[1..pos].join("\n\tfrom ")}"
|
||||
end
|
||||
=end
|
||||
else
|
||||
|
@ -159,7 +159,7 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
|
|||
=begin
|
||||
if val == []
|
||||
# INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
|
||||
# @id, @id, @id))
|
||||
# @id, @id, @id))
|
||||
elsif val.kind_of?(Array)
|
||||
a = []
|
||||
# val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
|
||||
|
@ -202,15 +202,15 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
|
|||
on_thread &= (Thread.list.size != 1)
|
||||
if on_thread
|
||||
if check_root
|
||||
INTERP._thread_tkwait('variable', @id)
|
||||
INTERP._thread_tkwait('variable', @id)
|
||||
else
|
||||
INTERP._thread_vwait(@id)
|
||||
INTERP._thread_vwait(@id)
|
||||
end
|
||||
else
|
||||
if check_root
|
||||
INTERP._invoke_without_enc('tkwait', 'variable', @id)
|
||||
INTERP._invoke_without_enc('tkwait', 'variable', @id)
|
||||
else
|
||||
INTERP._invoke_without_enc('vwait', @id)
|
||||
INTERP._invoke_without_enc('vwait', @id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -299,21 +299,21 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||
if val.kind_of?(Hash)
|
||||
self.clear
|
||||
val.each{|k, v|
|
||||
#INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)),
|
||||
# _toUTF8(_get_eval_string(v)))
|
||||
INTERP._set_global_var2(@id, _get_eval_string(k, true),
|
||||
_get_eval_string(v, true))
|
||||
#INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)),
|
||||
# _toUTF8(_get_eval_string(v)))
|
||||
INTERP._set_global_var2(@id, _get_eval_string(k, true),
|
||||
_get_eval_string(v, true))
|
||||
}
|
||||
self.value
|
||||
elsif val.kind_of?(Array)
|
||||
INTERP._set_global_var(@id, '')
|
||||
val.each{|v|
|
||||
#INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)),
|
||||
INTERP._set_variable(@id, _get_eval_string(v, true),
|
||||
TclTkLib::VarAccessFlag::GLOBAL_ONLY |
|
||||
TclTkLib::VarAccessFlag::LEAVE_ERR_MSG |
|
||||
TclTkLib::VarAccessFlag::APPEND_VALUE |
|
||||
TclTkLib::VarAccessFlag::LIST_ELEMENT)
|
||||
#INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)),
|
||||
INTERP._set_variable(@id, _get_eval_string(v, true),
|
||||
TclTkLib::VarAccessFlag::GLOBAL_ONLY |
|
||||
TclTkLib::VarAccessFlag::LEAVE_ERR_MSG |
|
||||
TclTkLib::VarAccessFlag::APPEND_VALUE |
|
||||
TclTkLib::VarAccessFlag::LIST_ELEMENT)
|
||||
}
|
||||
self.value
|
||||
else
|
||||
|
@ -329,11 +329,11 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||
rescue => e
|
||||
case @def_default
|
||||
when :proc
|
||||
@default_val.call(self, *idxs)
|
||||
@default_val.call(self, *idxs)
|
||||
when :val
|
||||
@default_val
|
||||
@default_val
|
||||
else
|
||||
fail e
|
||||
fail e
|
||||
end
|
||||
end
|
||||
#_fromUTF8(INTERP._get_global_var2(@id, index))
|
||||
|
@ -346,9 +346,9 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||
index = args.collect{|idx| _get_eval_string(idx, true)}.join(',')
|
||||
_fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true)))
|
||||
#_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)),
|
||||
# _toUTF8(_get_eval_string(val))))
|
||||
# _toUTF8(_get_eval_string(val))))
|
||||
#_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true),
|
||||
# _get_eval_string(val, true)))
|
||||
# _get_eval_string(val, true)))
|
||||
end
|
||||
|
||||
def unset(elem=nil)
|
||||
|
@ -372,13 +372,13 @@ else
|
|||
#INTERP._invoke_without_enc('set', @id)
|
||||
rescue
|
||||
if INTERP._eval(Kernel.format('global %s; array exists %s',
|
||||
@id, @id)) != "1"
|
||||
@id, @id)) != "1"
|
||||
#if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
|
||||
#if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
|
||||
fail
|
||||
fail
|
||||
else
|
||||
Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))]
|
||||
#Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))]
|
||||
Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))]
|
||||
#Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -392,43 +392,43 @@ else
|
|||
#_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s)))
|
||||
rescue
|
||||
if INTERP._eval(Kernel.format('global %s; array exists %s',
|
||||
@id, @id)) != "1"
|
||||
@id, @id)) != "1"
|
||||
#if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
|
||||
#if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
|
||||
fail
|
||||
fail
|
||||
else
|
||||
if val == []
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id))
|
||||
#INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)',
|
||||
# @id, @id, @id))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#INTERP._invoke_without_enc('set', @id+'(0)', 0)
|
||||
#INTERP._invoke_without_enc('unset', @id+'(0)')
|
||||
elsif val.kind_of?(Array)
|
||||
a = []
|
||||
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
|
||||
#s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||
s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||
@id, @id, @id, s))
|
||||
#INTERP._eval(Kernel.format('unset %s; array set %s %s',
|
||||
# @id, @id, s))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
|
||||
elsif val.kind_of?(Hash)
|
||||
#s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
||||
# .gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||
s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
||||
.gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||
@id, @id, @id, s))
|
||||
#INTERP._eval(Kernel.format('unset %s; array set %s %s',
|
||||
# @id, @id, s))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
|
||||
else
|
||||
fail
|
||||
end
|
||||
if val == []
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id))
|
||||
#INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)',
|
||||
# @id, @id, @id))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#INTERP._invoke_without_enc('set', @id+'(0)', 0)
|
||||
#INTERP._invoke_without_enc('unset', @id+'(0)')
|
||||
elsif val.kind_of?(Array)
|
||||
a = []
|
||||
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
|
||||
#s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||
s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||
@id, @id, @id, s))
|
||||
#INTERP._eval(Kernel.format('unset %s; array set %s %s',
|
||||
# @id, @id, s))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
|
||||
elsif val.kind_of?(Hash)
|
||||
#s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
||||
# .gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||
s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
||||
.gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
|
||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||
@id, @id, @id, s))
|
||||
#INTERP._eval(Kernel.format('unset %s; array set %s %s',
|
||||
# @id, @id, s))
|
||||
#INTERP._invoke_without_enc('unset', @id)
|
||||
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
|
||||
else
|
||||
fail
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -440,11 +440,11 @@ else
|
|||
rescue => e
|
||||
case @def_default
|
||||
when :proc
|
||||
@default_val.call(self, *idxs)
|
||||
@default_val.call(self, *idxs)
|
||||
when :val
|
||||
@default_val
|
||||
@default_val
|
||||
else
|
||||
fail e
|
||||
fail e
|
||||
end
|
||||
end
|
||||
#INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
|
||||
|
@ -462,9 +462,9 @@ else
|
|||
#INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
|
||||
# _get_eval_string(index), _get_eval_string(val)))
|
||||
#INTERP._eval(Kernel.format('set %s(%s) %s', @id,
|
||||
# _get_eval_string(index), _get_eval_string(val)))
|
||||
# _get_eval_string(index), _get_eval_string(val)))
|
||||
#INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' +
|
||||
# _get_eval_string(val))
|
||||
# _get_eval_string(val))
|
||||
end
|
||||
|
||||
def unset(elem=nil)
|
||||
|
@ -514,9 +514,9 @@ end
|
|||
else
|
||||
case val.to_s.downcase
|
||||
when 'false', '0', 'no', 'off'
|
||||
self.value = '0'
|
||||
self.value = '0'
|
||||
else
|
||||
self.value = '1'
|
||||
self.value = '1'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -602,9 +602,9 @@ end
|
|||
self.value + other
|
||||
else
|
||||
begin
|
||||
number(self.value) + other
|
||||
number(self.value) + other
|
||||
rescue
|
||||
self.value + other.to_s
|
||||
self.value + other.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -670,17 +670,17 @@ end
|
|||
def <=>(other)
|
||||
if other.kind_of?(TkVariable)
|
||||
begin
|
||||
val = other.numeric
|
||||
other = val
|
||||
val = other.numeric
|
||||
other = val
|
||||
rescue
|
||||
other = other.value
|
||||
other = other.value
|
||||
end
|
||||
end
|
||||
if other.kind_of?(Numeric)
|
||||
begin
|
||||
return self.numeric <=> other
|
||||
return self.numeric <=> other
|
||||
rescue
|
||||
return self.value <=> other.to_s
|
||||
return self.value <=> other.to_s
|
||||
end
|
||||
else
|
||||
return self.value <=> other
|
||||
|
@ -697,7 +697,7 @@ end
|
|||
end
|
||||
if elem.kind_of?(String) && elem != ''
|
||||
if @trace_elem.kind_of?(Hash) && @trace_elem[elem].kind_of?(Array)
|
||||
@trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)}
|
||||
@trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -713,12 +713,12 @@ end
|
|||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
else
|
||||
|
@ -726,25 +726,25 @@ end
|
|||
#opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
if newopts != @trace_opts
|
||||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
@ -763,13 +763,13 @@ end
|
|||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
else
|
||||
|
@ -777,25 +777,25 @@ end
|
|||
# opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
if newopts != @trace_opts
|
||||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
@ -820,8 +820,8 @@ end
|
|||
newopts = ''
|
||||
@trace_var.each_with_index{|e,i|
|
||||
if idx < 0 && e[0] == opts && e[1] == cmd
|
||||
idx = i
|
||||
next
|
||||
idx = i
|
||||
next
|
||||
end
|
||||
# e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
|
@ -834,8 +834,8 @@ end
|
|||
|
||||
@trace_elem.each{|elem|
|
||||
@trace_elem[elem].each{|e|
|
||||
# e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
# e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -845,28 +845,28 @@ end
|
|||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
@trace_opts.replace(newopts)
|
||||
if @trace_opts != ''
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
@ -882,8 +882,8 @@ end
|
|||
idx = -1
|
||||
@trace_elem[elem].each_with_index{|e,i|
|
||||
if idx < 0 && e[0] == opts && e[1] == cmd
|
||||
idx = i
|
||||
next
|
||||
idx = i
|
||||
next
|
||||
end
|
||||
}
|
||||
if idx >= 0
|
||||
|
@ -899,8 +899,8 @@ end
|
|||
}
|
||||
@trace_elem.each{|elem|
|
||||
@trace_elem[elem].each{|e|
|
||||
# e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
# e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -910,28 +910,28 @@ end
|
|||
Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'remove', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'vdelete',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
@trace_opts.replace(newopts)
|
||||
if @trace_opts != ''
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
=begin
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id,
|
||||
@trace_opts, 'rb_var')
|
||||
end
|
||||
if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
|
||||
# TCL_VERSION >= 8.4
|
||||
Tk.tk_call_without_enc('trace', 'add', 'variable',
|
||||
@id, @trace_opts, 'rb_var')
|
||||
else
|
||||
# TCL_VERSION <= 8.3
|
||||
Tk.tk_call_without_enc('trace', 'variable', @id,
|
||||
@trace_opts, 'rb_var')
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
@ -966,9 +966,9 @@ class TkVarAccess<TkVariable
|
|||
|
||||
if val
|
||||
if val.kind_of?(Hash)
|
||||
# assoc-array variable
|
||||
self[''] = 0
|
||||
self.clear
|
||||
# assoc-array variable
|
||||
self[''] = 0
|
||||
self.clear
|
||||
end
|
||||
#s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' #"
|
||||
#s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"' #"
|
||||
|
|
|
@ -27,9 +27,9 @@ class TkVirtualEvent<TkObject
|
|||
obj
|
||||
else
|
||||
if tk_call_without_enc('event', 'info').index("<#{event}>")
|
||||
PreDefVirtEvent.new(event)
|
||||
PreDefVirtEvent.new(event)
|
||||
else
|
||||
fail ArgumentError, "undefined virtual event '<#{event}>'"
|
||||
fail ArgumentError, "undefined virtual event '<#{event}>'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -50,9 +50,9 @@ class TkVirtualEvent<TkObject
|
|||
def add(*sequences)
|
||||
if sequences != []
|
||||
tk_call_without_enc('event', 'add', "<#{@id}>",
|
||||
*(sequences.collect{|seq|
|
||||
"<#{tk_event_sequence(seq)}>"
|
||||
}) )
|
||||
*(sequences.collect{|seq|
|
||||
"<#{tk_event_sequence(seq)}>"
|
||||
}) )
|
||||
TkVirtualEventTBL[@id] = self
|
||||
end
|
||||
self
|
||||
|
@ -64,9 +64,9 @@ class TkVirtualEvent<TkObject
|
|||
TkVirtualEventTBL.delete(@id)
|
||||
else
|
||||
tk_call_without_enc('event', 'delete', "<#{@id}>",
|
||||
*(sequences.collect{|seq|
|
||||
"<#{tk_event_sequence(seq)}>"
|
||||
}) )
|
||||
*(sequences.collect{|seq|
|
||||
"<#{tk_event_sequence(seq)}>"
|
||||
}) )
|
||||
TkVirtualEventTBL.delete(@id) if info == []
|
||||
end
|
||||
self
|
||||
|
@ -75,14 +75,14 @@ class TkVirtualEvent<TkObject
|
|||
def info
|
||||
tk_call_without_enc('event','info',"<#{@id}>").split(/\s+/).collect!{|seq|
|
||||
l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
|
||||
case (subseq)
|
||||
when /^<<[^<>]+>>$/
|
||||
TkVirtualEvent.getobj(subseq[1..-2])
|
||||
when /^<[^<>]+>$/
|
||||
subseq[1..-2]
|
||||
else
|
||||
subseq.split('')
|
||||
end
|
||||
case (subseq)
|
||||
when /^<<[^<>]+>>$/
|
||||
TkVirtualEvent.getobj(subseq[1..-2])
|
||||
when /^<[^<>]+>$/
|
||||
subseq[1..-2]
|
||||
else
|
||||
subseq.split('')
|
||||
end
|
||||
}.flatten
|
||||
(l.size == 1) ? l[0] : l
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ module TkWinfo
|
|||
def TkWinfo.atom(name, win=nil)
|
||||
if win
|
||||
number(tk_call_without_enc('winfo', 'atom', '-displayof', win,
|
||||
_get_eval_enc_str(name)))
|
||||
_get_eval_enc_str(name)))
|
||||
else
|
||||
number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name)))
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ module TkWinfo
|
|||
def TkWinfo.atomname(id, win=nil)
|
||||
if win
|
||||
_fromUTF8(tk_call_without_enc('winfo', 'atomname',
|
||||
'-displayof', win, id))
|
||||
'-displayof', win, id))
|
||||
else
|
||||
_fromUTF8(tk_call_without_enc('winfo', 'atomname', id))
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ module TkWinfo
|
|||
def TkWinfo.containing(rootX, rootY, win=nil)
|
||||
if win
|
||||
window(tk_call_without_enc('winfo', 'containing',
|
||||
'-displayof', win, rootX, rootY))
|
||||
'-displayof', win, rootX, rootY))
|
||||
else
|
||||
window(tk_call_without_enc('winfo', 'containing', rootX, rootY))
|
||||
end
|
||||
|
@ -122,7 +122,7 @@ module TkWinfo
|
|||
def TkWinfo.interps(window=nil)
|
||||
if window
|
||||
tk_split_simplelist(tk_call_without_enc('winfo', 'interps',
|
||||
'-displayof', window))
|
||||
'-displayof', window))
|
||||
else
|
||||
tk_split_simplelist(tk_call_without_enc('winfo', 'interps'))
|
||||
end
|
||||
|
@ -299,7 +299,7 @@ module TkWinfo
|
|||
def TkWinfo.visualsavailable(window, includeids=false)
|
||||
if includeids
|
||||
list(tk_call_without_enc('winfo', 'visualsavailable',
|
||||
window, "includeids"))
|
||||
window, "includeids"))
|
||||
else
|
||||
list(tk_call_without_enc('winfo', 'visualsavailable', window))
|
||||
end
|
||||
|
|
|
@ -19,25 +19,27 @@ module TkWinDDE
|
|||
tk_call_without_enc('package', 'require', 'dde')
|
||||
end
|
||||
|
||||
def servername(topic=None)
|
||||
tk_call('dde', 'servername', topic)
|
||||
end
|
||||
#def servername(topic=None)
|
||||
# tk_call('dde', 'servername', topic)
|
||||
#end
|
||||
def servername(*args)
|
||||
if args.size == 0
|
||||
tk_call('dde', 'servername')
|
||||
else
|
||||
if args[-1].kind_of?(Hash)
|
||||
keys = _symbolkey2str(args.pop)
|
||||
force = (keys.delete('force'))? '-force': None
|
||||
exact = (keys.delete('exact'))? '-exact': None
|
||||
if keys.size == 0
|
||||
tk_call('dde', 'servername', force, exact)
|
||||
elsif args.size == 0
|
||||
tk_call('dde', 'servername', force, exact, *hash_kv(keys))
|
||||
else
|
||||
tk_call('dde', 'servername', force, exact,
|
||||
*((hash_kv(keys) << '--') + args))
|
||||
end
|
||||
if args[-1].kind_of?(Hash) # dde 1.2 +
|
||||
keys = _symbolkey2str(args.pop)
|
||||
force = (keys.delete('force'))? '-force': None
|
||||
exact = (keys.delete('exact'))? '-exact': None
|
||||
if keys.size == 0
|
||||
tk_call('dde', 'servername', force, exact)
|
||||
elsif args.size == 0
|
||||
tk_call('dde', 'servername', force, exact, *hash_kv(keys))
|
||||
else
|
||||
tk_call('dde', 'servername', force, exact,
|
||||
*((hash_kv(keys) << '--') + args))
|
||||
end
|
||||
else
|
||||
tk_call('dde', 'servername', *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,237 +11,267 @@ module Tk
|
|||
|
||||
def aspect(*args)
|
||||
if args.length == 0
|
||||
list(tk_call_without_enc('wm', 'aspect', path))
|
||||
list(tk_call_without_enc('wm', 'aspect', path))
|
||||
else
|
||||
tk_call('wm', 'aspect', path, *args)
|
||||
self
|
||||
tk_call('wm', 'aspect', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def attributes(slot=nil,value=None)
|
||||
if slot == nil
|
||||
lst = tk_split_list(tk_call('wm', 'attributes', path))
|
||||
info = {}
|
||||
while key = lst.shift
|
||||
info[key[1..-1]] = lst.shift
|
||||
end
|
||||
info
|
||||
lst = tk_split_list(tk_call('wm', 'attributes', path))
|
||||
info = {}
|
||||
while key = lst.shift
|
||||
info[key[1..-1]] = lst.shift
|
||||
end
|
||||
info
|
||||
elsif slot.kind_of? Hash
|
||||
tk_call('wm', 'attributes', path, *hash_kv(slot))
|
||||
self
|
||||
tk_call('wm', 'attributes', path, *hash_kv(slot))
|
||||
self
|
||||
elsif value == None
|
||||
tk_call('wm', 'attributes', path, "-#{slot}")
|
||||
tk_call('wm', 'attributes', path, "-#{slot}")
|
||||
else
|
||||
tk_call('wm', 'attributes', path, "-#{slot}", value)
|
||||
self
|
||||
tk_call('wm', 'attributes', path, "-#{slot}", value)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def client(name=None)
|
||||
if name == None
|
||||
tk_call('wm', 'client', path)
|
||||
tk_call('wm', 'client', path)
|
||||
else
|
||||
name = '' if name == nil
|
||||
tk_call('wm', 'client', path, name)
|
||||
self
|
||||
tk_call('wm', 'client', path, name)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def colormapwindows(*args)
|
||||
if args.size == 0
|
||||
list(tk_call_without_enc('wm', 'colormapwindows', path))
|
||||
list(tk_call_without_enc('wm', 'colormapwindows', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'colormapwindows', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'colormapwindows', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def wm_command(value=nil)
|
||||
if value
|
||||
tk_call('wm', 'command', path, value)
|
||||
self
|
||||
tk_call('wm', 'command', path, value)
|
||||
self
|
||||
else
|
||||
#procedure(tk_call('wm', 'command', path))
|
||||
tk_call('wm', 'command', path)
|
||||
#procedure(tk_call('wm', 'command', path))
|
||||
tk_call('wm', 'command', path)
|
||||
end
|
||||
end
|
||||
|
||||
def deiconify(ex = true)
|
||||
tk_call_without_enc('wm', 'deiconify', path) if ex
|
||||
self
|
||||
end
|
||||
|
||||
def focusmodel(mode = nil)
|
||||
if mode
|
||||
tk_call_without_enc('wm', 'focusmodel', path, mode)
|
||||
self
|
||||
tk_call_without_enc('wm', 'focusmodel', path, mode)
|
||||
self
|
||||
else
|
||||
tk_call_without_enc('wm', 'focusmodel', path)
|
||||
tk_call_without_enc('wm', 'focusmodel', path)
|
||||
end
|
||||
end
|
||||
|
||||
def frame
|
||||
tk_call_without_enc('wm', 'frame', path)
|
||||
end
|
||||
|
||||
def geometry(geom=nil)
|
||||
if geom
|
||||
tk_call_without_enc('wm', 'geometry', path, geom)
|
||||
self
|
||||
tk_call_without_enc('wm', 'geometry', path, geom)
|
||||
self
|
||||
else
|
||||
tk_call_without_enc('wm', 'geometry', path)
|
||||
tk_call_without_enc('wm', 'geometry', path)
|
||||
end
|
||||
end
|
||||
|
||||
def wm_grid(*args)
|
||||
if args.size == 0
|
||||
list(tk_call_without_enc('wm', 'grid', path))
|
||||
list(tk_call_without_enc('wm', 'grid', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'grid', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'grid', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def group(leader = nil)
|
||||
if leader
|
||||
tk_call('wm', 'group', path, leader)
|
||||
self
|
||||
tk_call('wm', 'group', path, leader)
|
||||
self
|
||||
else
|
||||
window(tk_call('wm', 'group', path))
|
||||
window(tk_call('wm', 'group', path))
|
||||
end
|
||||
end
|
||||
|
||||
def iconbitmap(bmp=nil)
|
||||
if bmp
|
||||
tk_call_without_enc('wm', 'iconbitmap', path, bmp)
|
||||
self
|
||||
tk_call_without_enc('wm', 'iconbitmap', path, bmp)
|
||||
self
|
||||
else
|
||||
image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
|
||||
image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
|
||||
end
|
||||
end
|
||||
|
||||
def iconify(ex = true)
|
||||
tk_call_without_enc('wm', 'iconify', path) if ex
|
||||
self
|
||||
end
|
||||
|
||||
def iconmask(bmp=nil)
|
||||
if bmp
|
||||
tk_call_without_enc('wm', 'iconmask', path, bmp)
|
||||
self
|
||||
tk_call_without_enc('wm', 'iconmask', path, bmp)
|
||||
self
|
||||
else
|
||||
image_obj(tk_call_without_enc('wm', 'iconmask', path))
|
||||
image_obj(tk_call_without_enc('wm', 'iconmask', path))
|
||||
end
|
||||
end
|
||||
|
||||
def iconname(name=nil)
|
||||
if name
|
||||
tk_call('wm', 'iconname', path, name)
|
||||
self
|
||||
tk_call('wm', 'iconname', path, name)
|
||||
self
|
||||
else
|
||||
tk_call('wm', 'iconname', path)
|
||||
tk_call('wm', 'iconname', path)
|
||||
end
|
||||
end
|
||||
|
||||
def iconposition(*args)
|
||||
if args.size == 0
|
||||
list(tk_call_without_enc('wm', 'iconposition', path))
|
||||
list(tk_call_without_enc('wm', 'iconposition', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'iconposition', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'iconposition', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def iconwindow(win = nil)
|
||||
if win
|
||||
tk_call_without_enc('wm', 'iconwindow', path, win)
|
||||
self
|
||||
tk_call_without_enc('wm', 'iconwindow', path, win)
|
||||
self
|
||||
else
|
||||
w = tk_call_without_enc('wm', 'iconwindow', path)
|
||||
(w == '')? nil: window(w)
|
||||
w = tk_call_without_enc('wm', 'iconwindow', path)
|
||||
(w == '')? nil: window(w)
|
||||
end
|
||||
end
|
||||
|
||||
def maxsize(*args)
|
||||
if args.size == 0
|
||||
list(tk_call_without_enc('wm', 'maxsize', path))
|
||||
list(tk_call_without_enc('wm', 'maxsize', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'maxsize', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'maxsize', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def minsize(*args)
|
||||
if args.size == 0
|
||||
list(tk_call_without_enc('wm', 'minsize', path))
|
||||
list(tk_call_without_enc('wm', 'minsize', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'minsize', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'minsize', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def overrideredirect(bool=None)
|
||||
if bool == None
|
||||
bool(tk_call_without_enc('wm', 'overrideredirect', path))
|
||||
bool(tk_call_without_enc('wm', 'overrideredirect', path))
|
||||
else
|
||||
tk_call_without_enc('wm', 'overrideredirect', path, bool)
|
||||
self
|
||||
tk_call_without_enc('wm', 'overrideredirect', path, bool)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def positionfrom(who=None)
|
||||
if who == None
|
||||
r = tk_call_without_enc('wm', 'positionfrom', path)
|
||||
(r == "")? nil: r
|
||||
r = tk_call_without_enc('wm', 'positionfrom', path)
|
||||
(r == "")? nil: r
|
||||
else
|
||||
tk_call_without_enc('wm', 'positionfrom', path, who)
|
||||
self
|
||||
tk_call_without_enc('wm', 'positionfrom', path, who)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def protocol(name=nil, cmd=nil, &b)
|
||||
if cmd
|
||||
tk_call_without_enc('wm', 'protocol', path, name, cmd)
|
||||
self
|
||||
tk_call_without_enc('wm', 'protocol', path, name, cmd)
|
||||
self
|
||||
elsif b
|
||||
tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
|
||||
self
|
||||
tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
|
||||
self
|
||||
elsif name
|
||||
result = tk_call_without_enc('wm', 'protocol', path, name)
|
||||
(result == "")? nil : tk_tcl2ruby(result)
|
||||
result = tk_call_without_enc('wm', 'protocol', path, name)
|
||||
(result == "")? nil : tk_tcl2ruby(result)
|
||||
else
|
||||
tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path))
|
||||
tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path))
|
||||
end
|
||||
end
|
||||
|
||||
def resizable(*args)
|
||||
if args.length == 0
|
||||
list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
|
||||
list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
|
||||
else
|
||||
tk_call_without_enc('wm', 'resizable', path, *args)
|
||||
self
|
||||
tk_call_without_enc('wm', 'resizable', path, *args)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def sizefrom(who=None)
|
||||
if who == None
|
||||
r = tk_call_without_enc('wm', 'sizefrom', path)
|
||||
(r == "")? nil: r
|
||||
r = tk_call_without_enc('wm', 'sizefrom', path)
|
||||
(r == "")? nil: r
|
||||
else
|
||||
tk_call_without_enc('wm', 'sizefrom', path, who)
|
||||
self
|
||||
tk_call_without_enc('wm', 'sizefrom', path, who)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def stackorder
|
||||
list(tk_call('wm', 'stackorder', path))
|
||||
end
|
||||
|
||||
def stackorder_isabove(win)
|
||||
bool(tk_call('wm', 'stackorder', path, 'isabove', win))
|
||||
end
|
||||
|
||||
def stackorder_isbelow(win)
|
||||
bool(tk_call('wm', 'stackorder', path, 'isbelow', win))
|
||||
end
|
||||
|
||||
def state(state=nil)
|
||||
if state
|
||||
tk_call_without_enc('wm', 'state', path, state)
|
||||
self
|
||||
tk_call_without_enc('wm', 'state', path, state)
|
||||
self
|
||||
else
|
||||
tk_call_without_enc('wm', 'state', path)
|
||||
tk_call_without_enc('wm', 'state', path)
|
||||
end
|
||||
end
|
||||
|
||||
def title(str=nil)
|
||||
if str
|
||||
tk_call('wm', 'title', path, str)
|
||||
self
|
||||
tk_call('wm', 'title', path, str)
|
||||
self
|
||||
else
|
||||
tk_call('wm', 'title', path)
|
||||
tk_call('wm', 'title', path)
|
||||
end
|
||||
end
|
||||
|
||||
def transient(master=nil)
|
||||
if master
|
||||
tk_call_without_enc('wm', 'transient', path, master)
|
||||
self
|
||||
tk_call_without_enc('wm', 'transient', path, master)
|
||||
self
|
||||
else
|
||||
window(tk_call_without_enc('wm', 'transient', path))
|
||||
window(tk_call_without_enc('wm', 'transient', path))
|
||||
end
|
||||
end
|
||||
|
||||
def withdraw(ex = true)
|
||||
tk_call_without_enc('wm', 'withdraw', path) if ex
|
||||
self
|
||||
|
|
|
@ -13,14 +13,14 @@ module TkXIM
|
|||
if value == None
|
||||
if window
|
||||
bool(tk_call_without_enc('tk', 'useinputmethods',
|
||||
'-displayof', window))
|
||||
'-displayof', window))
|
||||
else
|
||||
bool(tk_call_without_enc('tk', 'useinputmethods'))
|
||||
end
|
||||
else
|
||||
if window
|
||||
bool(tk_call_without_enc('tk', 'useinputmethods',
|
||||
'-displayof', window, value))
|
||||
bool(tk_call_without_enc('tk', 'useinputmethods',
|
||||
'-displayof', window, value))
|
||||
else
|
||||
bool(tk_call_without_enc('tk', 'useinputmethods', value))
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ module TkXIM
|
|||
lst = tk_split_list(tk_call_without_enc('tk', 'caret', window))
|
||||
info = {}
|
||||
while key = lst.shift
|
||||
info[key[1..-1]] = lst.shift
|
||||
info[key[1..-1]] = lst.shift
|
||||
end
|
||||
info
|
||||
end
|
||||
|
@ -61,22 +61,22 @@ module TkXIM
|
|||
def TkXIM.configinfo(window, slot=nil)
|
||||
if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
|
||||
begin
|
||||
if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
|
||||
if slot
|
||||
conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_list(tk_call('imconfigure', window)).collect{|conf|
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
}
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
|
||||
if slot
|
||||
conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_list(tk_call('imconfigure', window)).collect{|conf|
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
}
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
rescue
|
||||
[]
|
||||
[]
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
|
||||
TkXIM.current_configinfo(window, slot)
|
||||
|
@ -86,18 +86,18 @@ module TkXIM
|
|||
def TkXIM.current_configinfo(window, slot=nil)
|
||||
begin
|
||||
if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
|
||||
if slot
|
||||
conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
|
||||
{ conf[0][1..-1] => conf[1] }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_list(tk_call('imconfigure', window)).each{|conf|
|
||||
ret[conf[0][1..-1]] = conf[1]
|
||||
}
|
||||
ret
|
||||
end
|
||||
if slot
|
||||
conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
|
||||
{ conf[0][1..-1] => conf[1] }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_list(tk_call('imconfigure', window)).each{|conf|
|
||||
ret[conf[0][1..-1]] = conf[1]
|
||||
}
|
||||
ret
|
||||
end
|
||||
else
|
||||
{}
|
||||
{}
|
||||
end
|
||||
rescue
|
||||
{}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# tkclass.rb - Tk classes
|
||||
# Date: 2000/11/27 09:23:36
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
# tkclass.rb - Tk classes
|
||||
# Date: 2000/11/27 09:23:36
|
||||
# by Yukihiro Matsumoto <matz@caelum.co.jp>
|
||||
#
|
||||
# $Id$
|
||||
# $Id$
|
||||
|
||||
require "tk"
|
||||
|
||||
|
|
|
@ -20,20 +20,20 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('icons')
|
||||
TkPackage.require('icons')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def self.create(*args) # icon, icon, ..., ?option=>value, ...?
|
||||
if args[-1].kind_of?(Hash)
|
||||
keys = args.pop
|
||||
icons = simplelist(tk_call('::icons::icons', 'create',
|
||||
*(hash_kv(keys) << (args.flatten))))
|
||||
keys = args.pop
|
||||
icons = simplelist(tk_call('::icons::icons', 'create',
|
||||
*(hash_kv(keys) << (args.flatten))))
|
||||
else
|
||||
icons = simplelist(tk_call('::icons::icons', 'create',
|
||||
args.flatten))
|
||||
icons = simplelist(tk_call('::icons::icons', 'create',
|
||||
args.flatten))
|
||||
end
|
||||
|
||||
icons.collect{|icon| self.new(icon, :without_creating=>true)}
|
||||
|
@ -43,28 +43,28 @@ module Tk
|
|||
icons = icons.flatten
|
||||
return if icons.empty?
|
||||
icons.map!{|icon|
|
||||
if icon.kind_of?(Tk::ICONS)
|
||||
Tk_IMGTBL.delete(icon.path)
|
||||
icon.name
|
||||
elsif icon.to_s =~ /^::icon::(.*)/
|
||||
name = $1
|
||||
Tk_IMGTBL.delete(icon)
|
||||
name
|
||||
else
|
||||
Tk_IMGTBL.delete("::icon::#{icon}")
|
||||
icon
|
||||
end
|
||||
if icon.kind_of?(Tk::ICONS)
|
||||
Tk_IMGTBL.delete(icon.path)
|
||||
icon.name
|
||||
elsif icon.to_s =~ /^::icon::(.*)/
|
||||
name = $1
|
||||
Tk_IMGTBL.delete(icon)
|
||||
name
|
||||
else
|
||||
Tk_IMGTBL.delete("::icon::#{icon}")
|
||||
icon
|
||||
end
|
||||
}
|
||||
tk_call('::icons::icons', 'delete', icons)
|
||||
end
|
||||
|
||||
def self.query(*args) # icon, icon, ..., ?option=>value, ...?
|
||||
if args[-1].kind_of?(Hash)
|
||||
keys = args.pop
|
||||
simplelist(tk_call('::icons::icons', 'query',
|
||||
*(hash_kv(keys) << (args.flatten))))
|
||||
keys = args.pop
|
||||
simplelist(tk_call('::icons::icons', 'query',
|
||||
*(hash_kv(keys) << (args.flatten))))
|
||||
else
|
||||
simplelist(tk_call('::icons::icons', 'query', args.flatten))
|
||||
simplelist(tk_call('::icons::icons', 'query', args.flatten))
|
||||
end . map{|inf| list(inf) }
|
||||
end
|
||||
|
||||
|
@ -76,15 +76,15 @@ module Tk
|
|||
|
||||
def initialize(name, keys=nil)
|
||||
if name.kind_of?(String) && name =~ /^::icon::(.+)$/
|
||||
@name = $1
|
||||
@path = name
|
||||
@name = $1
|
||||
@path = name
|
||||
else
|
||||
@name = name.to_s
|
||||
@path = "::icon::#{@name}"
|
||||
@name = name.to_s
|
||||
@path = "::icon::#{@name}"
|
||||
end
|
||||
keys = _symbolkey2str(keys)
|
||||
unless keys.delete('without_creating')
|
||||
tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name))
|
||||
tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name))
|
||||
end
|
||||
Tk_IMGTBL[@path] = self
|
||||
end
|
||||
|
@ -101,8 +101,8 @@ module Tk
|
|||
|
||||
def query(keys={})
|
||||
list(simplelist(tk_call('::icons::icons', 'query',
|
||||
*(hash_kv(keys) << @name))
|
||||
)[0])
|
||||
*(hash_kv(keys) << @name))
|
||||
)[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,16 +25,16 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('BWidget')
|
||||
TkPackage.require('BWidget')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def self.XLFDfont(cmd, *args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
keys = args.pop
|
||||
args.concat(hash_kv(keys))
|
||||
keys = args.pop
|
||||
args.concat(hash_kv(keys))
|
||||
end
|
||||
tk_call('BWidget::XLFDfont', cmd, *args)
|
||||
end
|
||||
|
@ -93,8 +93,8 @@ module Tk
|
|||
|
||||
def self.place(path, w, h, *args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
keys = args.pop
|
||||
args.concat(hash_kv(keys))
|
||||
keys = args.pop
|
||||
args.concat(hash_kv(keys))
|
||||
end
|
||||
tk_call('BWidget::place', path, w, h, *(args.flatten))
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ class Tk::BWidget::Dialog
|
|||
cmd = self.class::TkCommandNames[0]
|
||||
if keys and keys != None
|
||||
tk_call_without_enc(cmd, @path, '-parent', @relative,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
tk_call_without_enc(cmd, @path, '-parent', @relative)
|
||||
end
|
||||
|
@ -64,9 +64,9 @@ class Tk::BWidget::Dialog
|
|||
super(slot)
|
||||
else
|
||||
if slot.to_s == 'relative'
|
||||
super('parent', value)
|
||||
super('parent', value)
|
||||
else
|
||||
super(slot, value)
|
||||
super(slot, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -74,16 +74,16 @@ class Tk::BWidget::Dialog
|
|||
def configinfo(slot=nil)
|
||||
if slot
|
||||
if slot.to_s == 'relative'
|
||||
super('parent')
|
||||
super('parent')
|
||||
else
|
||||
super(slot)
|
||||
super(slot)
|
||||
end
|
||||
else
|
||||
ret = super()
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret << ['relative', 'parent']
|
||||
ret << ['relative', 'parent']
|
||||
else
|
||||
ret['relative'] = 'parent'
|
||||
ret['relative'] = 'parent'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class Tk::BWidget::ListBox
|
|||
class Event_for_Items < TkEvent::Event
|
||||
def self._get_extra_args_tbl
|
||||
[
|
||||
TkComm.method(:string) # item idenfier
|
||||
TkComm.method(:string) # item idenfier
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -135,19 +135,19 @@ class Tk::BWidget::ListBox
|
|||
|
||||
def selection_set(*args)
|
||||
tk_send_without_enc('selection', 'set',
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_add(*args)
|
||||
tk_send_without_enc('selection', 'add',
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_remove(*args)
|
||||
tk_send_without_enc('selection', 'remove',
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
*(args.collect{|item| tagid(item)}))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -177,7 +177,7 @@ class Tk::BWidget::ListBox::Item
|
|||
@listbox = lbox
|
||||
else
|
||||
fail RuntimeError,
|
||||
"expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
|
||||
"expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
|
||||
end
|
||||
|
||||
if args[-1].kind_of?(Hash)
|
||||
|
|
|
@ -65,22 +65,22 @@ class Tk::BWidget::MessageDlg
|
|||
@keys.update(slot)
|
||||
|
||||
if @info
|
||||
# update @info
|
||||
slot.each{|k, v|
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if (inf = @info.assoc(k))
|
||||
inf[-1] = v
|
||||
else
|
||||
@info << [k, '', '', '', v]
|
||||
end
|
||||
else
|
||||
if (inf = @info[k])
|
||||
inf[-1] = v
|
||||
else
|
||||
@info[k] = ['', '', '', v]
|
||||
end
|
||||
end
|
||||
}
|
||||
# update @info
|
||||
slot.each{|k, v|
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if (inf = @info.assoc(k))
|
||||
inf[-1] = v
|
||||
else
|
||||
@info << [k, '', '', '', v]
|
||||
end
|
||||
else
|
||||
if (inf = @info[k])
|
||||
inf[-1] = v
|
||||
else
|
||||
@info[k] = ['', '', '', v]
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
else # ! Hash
|
||||
|
@ -89,20 +89,20 @@ class Tk::BWidget::MessageDlg
|
|||
@keys[slot] = value
|
||||
|
||||
if @info
|
||||
# update @info
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if (inf = @info.assoc(slot))
|
||||
inf[-1] = value
|
||||
else
|
||||
@info << [slot, '', '', '', value]
|
||||
end
|
||||
else
|
||||
if (inf = @info[slot])
|
||||
inf[-1] = value
|
||||
else
|
||||
@info[slot] = ['', '', '', value]
|
||||
end
|
||||
end
|
||||
# update @info
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if (inf = @info.assoc(slot))
|
||||
inf[-1] = value
|
||||
else
|
||||
@info << [slot, '', '', '', value]
|
||||
end
|
||||
else
|
||||
if (inf = @info[slot])
|
||||
inf[-1] = value
|
||||
else
|
||||
@info[slot] = ['', '', '', value]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -113,50 +113,50 @@ class Tk::BWidget::MessageDlg
|
|||
if winfo_exist?
|
||||
@info = super()
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
@info << ['relative', 'parent']
|
||||
@info << ['relative', 'parent']
|
||||
else
|
||||
@info['relative'] = 'parent'
|
||||
@info['relative'] = 'parent'
|
||||
end
|
||||
end
|
||||
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if @info
|
||||
if winfo_exist?
|
||||
# update @keys
|
||||
@info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
|
||||
end
|
||||
if winfo_exist?
|
||||
# update @keys
|
||||
@info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
|
||||
end
|
||||
else
|
||||
@info = []
|
||||
@keys.each{|k, v|
|
||||
@info << [k, '', '', '', v]
|
||||
}
|
||||
@info << ['relative', 'parent']
|
||||
@info = []
|
||||
@keys.each{|k, v|
|
||||
@info << [k, '', '', '', v]
|
||||
}
|
||||
@info << ['relative', 'parent']
|
||||
end
|
||||
|
||||
if slot
|
||||
@info.asoc(slot.to_s).dup
|
||||
@info.asoc(slot.to_s).dup
|
||||
else
|
||||
@info.dup
|
||||
@info.dup
|
||||
end
|
||||
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if @info
|
||||
if winfo_exist?
|
||||
# update @keys
|
||||
@info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
|
||||
end
|
||||
if winfo_exist?
|
||||
# update @keys
|
||||
@info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
|
||||
end
|
||||
else
|
||||
@info = {}
|
||||
@keys.each{|k, v|
|
||||
@info[k] = ['', '', '', v]
|
||||
}
|
||||
@info['relative'] = 'parent'
|
||||
@info = {}
|
||||
@keys.each{|k, v|
|
||||
@info[k] = ['', '', '', v]
|
||||
}
|
||||
@info['relative'] = 'parent'
|
||||
end
|
||||
|
||||
if slot
|
||||
@info[slot.to_s].dup
|
||||
@info[slot.to_s].dup
|
||||
else
|
||||
@info.dup
|
||||
@info.dup
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ class Tk::BWidget::NoteBook
|
|||
class Event_for_Tabs < TkEvent::Event
|
||||
def self._get_extra_args_tbl
|
||||
[
|
||||
TkComm.method(:string) # page idenfier
|
||||
TkComm.method(:string) # page idenfier
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class Tk::BWidget::PasswdDlg
|
|||
|
||||
def create
|
||||
login, passwd = simplelist(tk_call(self.class::TkCommandNames[0],
|
||||
@path, *hash_kv(@keys)))
|
||||
@path, *hash_kv(@keys)))
|
||||
[login, passwd]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class Tk::BWidget::Tree
|
|||
class Event_for_Items < TkEvent::Event
|
||||
def self._get_extra_args_tbl
|
||||
[
|
||||
TkComm.method(:string) # item idenfier
|
||||
TkComm.method(:string) # item idenfier
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -147,7 +147,7 @@ class Tk::BWidget::Tree
|
|||
|
||||
def selection_add(*args)
|
||||
tk_send_without_enc('selection', 'add',
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -162,30 +162,30 @@ class Tk::BWidget::Tree
|
|||
|
||||
def selection_include?(*args)
|
||||
bool(tk_send_without_enc('selection', 'get',
|
||||
*(args.collect{|node| tagid(node)})))
|
||||
*(args.collect{|node| tagid(node)})))
|
||||
end
|
||||
|
||||
def selection_range(*args)
|
||||
tk_send_without_enc('selection', 'range',
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_remove(*args)
|
||||
tk_send_without_enc('selection', 'remove',
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_set(*args)
|
||||
tk_send_without_enc('selection', 'set',
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
self
|
||||
end
|
||||
|
||||
def selection_toggle(*args)
|
||||
tk_send_without_enc('selection', 'toggle',
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
*(args.collect{|node| tagid(node)}))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -218,16 +218,16 @@ class Tk::BWidget::Tree::Node
|
|||
@tree = tree
|
||||
parent = args.shift
|
||||
if parent.kind_of?(Tk::BWidget::Tree::Node)
|
||||
if parent.tree.path != @tree.path
|
||||
fail RuntimeError, 'tree of parent node is not match'
|
||||
end
|
||||
if parent.tree.path != @tree.path
|
||||
fail RuntimeError, 'tree of parent node is not match'
|
||||
end
|
||||
end
|
||||
elsif tree.kind_of?(Tk::BWidget::Tree::Node)
|
||||
@tree = tree.tree
|
||||
parent = tree.parent
|
||||
else
|
||||
fail RuntimeError,
|
||||
"expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
|
||||
"expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
|
||||
end
|
||||
|
||||
if args[-1].kind_of?(Hash)
|
||||
|
|
|
@ -24,9 +24,9 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Itcl')
|
||||
TkPackage.require('Itcl')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,59 +39,59 @@ module Tk
|
|||
ITCL_OBJ_TBL = {}.taint
|
||||
|
||||
def initialize(*args)
|
||||
if (@klass = self.class::ITCL_CLASSNAME).empty?
|
||||
fail RuntimeError, 'unknown itcl class (abstract class?)'
|
||||
end
|
||||
@id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
|
||||
@path = @id
|
||||
Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
|
||||
if (@klass = self.class::ITCL_CLASSNAME).empty?
|
||||
fail RuntimeError, 'unknown itcl class (abstract class?)'
|
||||
end
|
||||
@id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
|
||||
@path = @id
|
||||
Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
|
||||
end
|
||||
|
||||
def self.call_proc(name, *args)
|
||||
tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args)
|
||||
tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args)
|
||||
end
|
||||
|
||||
def call_method(name, *args)
|
||||
tk_call(@path, name, *args)
|
||||
tk_call(@path, name, *args)
|
||||
end
|
||||
|
||||
def isa(klass)
|
||||
bool(tk_call(@path, 'isa', klass))
|
||||
bool(tk_call(@path, 'isa', klass))
|
||||
end
|
||||
alias itcl_kind_of? isa
|
||||
|
||||
def info_class
|
||||
tk_call(@path, 'info', 'class')
|
||||
tk_call(@path, 'info', 'class')
|
||||
end
|
||||
|
||||
def info_inherit
|
||||
simplelist(tk_call(@path, 'info', 'inherit'))
|
||||
simplelist(tk_call(@path, 'info', 'inherit'))
|
||||
end
|
||||
|
||||
def info_heritage
|
||||
list(tk_call(@path, 'info', 'heritage'))
|
||||
list(tk_call(@path, 'info', 'heritage'))
|
||||
end
|
||||
|
||||
def info_function(*args)
|
||||
if args[-1].kind_of?(Array)
|
||||
params = args.pop
|
||||
params.each{|param|
|
||||
param = param.to_s
|
||||
args << ( (param[0] == ?-)? param: "-#{param}" )
|
||||
}
|
||||
end
|
||||
list(tk_call(@path, 'info', 'function', *args))
|
||||
if args[-1].kind_of?(Array)
|
||||
params = args.pop
|
||||
params.each{|param|
|
||||
param = param.to_s
|
||||
args << ( (param[0] == ?-)? param: "-#{param}" )
|
||||
}
|
||||
end
|
||||
list(tk_call(@path, 'info', 'function', *args))
|
||||
end
|
||||
|
||||
def info_variable(*args)
|
||||
if args[-1].kind_of?(Array)
|
||||
params = args.pop
|
||||
params.each{|param|
|
||||
param = param.to_s
|
||||
args << ( (param[0] == ?-)? param: "-#{param}" )
|
||||
}
|
||||
end
|
||||
list(tk_call(@path, 'info', 'variable', *args))
|
||||
if args[-1].kind_of?(Array)
|
||||
params = args.pop
|
||||
params.each{|param|
|
||||
param = param.to_s
|
||||
args << ( (param[0] == ?-)? param: "-#{param}" )
|
||||
}
|
||||
end
|
||||
list(tk_call(@path, 'info', 'variable', *args))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Itk')
|
||||
TkPackage.require('Itk')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,59 +44,59 @@ module Tk
|
|||
# WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def self.to_eval
|
||||
'::itk::' << self::WidgetClassName
|
||||
'::itk::' << self::WidgetClassName
|
||||
end
|
||||
|
||||
def __destroy_hook__
|
||||
Tk::Itk::Component::ComponentID_TBL.delete(self.path)
|
||||
Tk::Itk::Component::ComponentID_TBL.delete(self.path)
|
||||
end
|
||||
|
||||
#### [incr Tk] public methods
|
||||
def component
|
||||
simplelist(tk_send('component'))
|
||||
simplelist(tk_send('component'))
|
||||
end
|
||||
|
||||
def component_path(name)
|
||||
window(tk_send('component', name))
|
||||
window(tk_send('component', name))
|
||||
end
|
||||
alias component_widget component_path
|
||||
|
||||
def component_invoke(name, cmd, *args)
|
||||
window(tk_send('component', name, cmd, *args))
|
||||
window(tk_send('component', name, cmd, *args))
|
||||
end
|
||||
|
||||
def component_obj(*names)
|
||||
names = component if names.empty?
|
||||
names.collect{|name| Tk::Itk::Component.new(self.path, name) }
|
||||
names = component if names.empty?
|
||||
names.collect{|name| Tk::Itk::Component.new(self.path, name) }
|
||||
end
|
||||
|
||||
#### [incr Tk] protected methods
|
||||
=begin
|
||||
def itk_component_add(visibility, name, create_cmds, option_cmds=None)
|
||||
args = []
|
||||
visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )}
|
||||
args << '--' << name << create_cmd << option_cmds
|
||||
tk_call('itk_component', 'add', *args)
|
||||
args = []
|
||||
visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )}
|
||||
args << '--' << name << create_cmd << option_cmds
|
||||
tk_call('itk_component', 'add', *args)
|
||||
end
|
||||
|
||||
def itk_component_delete(*names)
|
||||
tk_call('itk_component', 'delete', *names)
|
||||
tk_call('itk_component', 'delete', *names)
|
||||
end
|
||||
|
||||
def itk_initialize(keys={})
|
||||
tk_call('itk_initialize', keys)
|
||||
tk_call('itk_initialize', keys)
|
||||
end
|
||||
|
||||
def itk_option_add(*args)
|
||||
tk_call('itk_option', 'add', *args)
|
||||
tk_call('itk_option', 'add', *args)
|
||||
end
|
||||
|
||||
def itk_option_define(name, resource, klass, init, config=None)
|
||||
tk_call('itk_option', 'define', name, resource, klass, init, config)
|
||||
tk_call('itk_option', 'define', name, resource, klass, init, config)
|
||||
end
|
||||
|
||||
def itk_option_remove(*args)
|
||||
tk_call('itk_option', 'remove', *args)
|
||||
tk_call('itk_option', 'remove', *args)
|
||||
end
|
||||
=end
|
||||
end
|
||||
|
@ -125,11 +125,11 @@ module Tk
|
|||
|
||||
class Component < TkObject
|
||||
def __cget_cmd
|
||||
[self.master, 'component', self.name, 'cget']
|
||||
[self.master, 'component', self.name, 'cget']
|
||||
end
|
||||
|
||||
def __config_cmd
|
||||
[self.master, 'component', self.name, 'configure']
|
||||
[self.master, 'component', self.name, 'configure']
|
||||
end
|
||||
|
||||
ComponentID_TBL = TkCore::INTERP.create_table
|
||||
|
@ -138,242 +138,242 @@ module Tk
|
|||
TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear }
|
||||
|
||||
def self.id2obj(master, id)
|
||||
if master.kind_of?(TkObject)
|
||||
master = master.path
|
||||
else
|
||||
master = master.to_s
|
||||
end
|
||||
return id unless ComponentID_TBL.key?(master)
|
||||
(ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
|
||||
if master.kind_of?(TkObject)
|
||||
master = master.path
|
||||
else
|
||||
master = master.to_s
|
||||
end
|
||||
return id unless ComponentID_TBL.key?(master)
|
||||
(ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
|
||||
end
|
||||
|
||||
def self.new(master, component=nil)
|
||||
if master.kind_of?(TkObject)
|
||||
master = master.path
|
||||
else
|
||||
master = master.to_s
|
||||
end
|
||||
if master.kind_of?(TkObject)
|
||||
master = master.path
|
||||
else
|
||||
master = master.to_s
|
||||
end
|
||||
|
||||
if component.kind_of?(Tk::Itk::Component)
|
||||
component = component.name
|
||||
elsif component
|
||||
component = component.to_s
|
||||
else
|
||||
component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
|
||||
Itk_Component_ID[1].succ!
|
||||
end
|
||||
if component.kind_of?(Tk::Itk::Component)
|
||||
component = component.name
|
||||
elsif component
|
||||
component = component.to_s
|
||||
else
|
||||
component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
|
||||
Itk_Component_ID[1].succ!
|
||||
end
|
||||
|
||||
if ComponentID_TBL.key?(master)
|
||||
if ComponentID_TBL[master].key?(component)
|
||||
return ComponentID_TBL[master][component]
|
||||
end
|
||||
else
|
||||
ComponentID_TBL[master] = {}
|
||||
end
|
||||
if ComponentID_TBL.key?(master)
|
||||
if ComponentID_TBL[master].key?(component)
|
||||
return ComponentID_TBL[master][component]
|
||||
end
|
||||
else
|
||||
ComponentID_TBL[master] = {}
|
||||
end
|
||||
|
||||
super(master, component)
|
||||
super(master, component)
|
||||
end
|
||||
|
||||
def initialize(master, component)
|
||||
@master = master
|
||||
@component = component
|
||||
@master = master
|
||||
@component = component
|
||||
|
||||
ComponentID_TBL[@master][@component] = self
|
||||
ComponentID_TBL[@master][@component] = self
|
||||
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
@widget = nil
|
||||
@path = nil
|
||||
end
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
@widget = nil
|
||||
@path = nil
|
||||
end
|
||||
end
|
||||
|
||||
def path
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@path
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@path
|
||||
end
|
||||
|
||||
def epath
|
||||
path()
|
||||
path()
|
||||
end
|
||||
|
||||
def to_eval
|
||||
path()
|
||||
path()
|
||||
end
|
||||
|
||||
def master
|
||||
@master
|
||||
@master
|
||||
end
|
||||
|
||||
def name
|
||||
@component
|
||||
@component
|
||||
end
|
||||
|
||||
def widget
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget
|
||||
end
|
||||
|
||||
def widget_class
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
@widget.classname
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
@widget.classname
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
name = id.id2name
|
||||
name = id.id2name
|
||||
|
||||
# try 1 : component command
|
||||
begin
|
||||
return tk_call(@master, 'component', @component, name, *args)
|
||||
rescue
|
||||
end
|
||||
# try 1 : component command
|
||||
begin
|
||||
return tk_call(@master, 'component', @component, name, *args)
|
||||
rescue
|
||||
end
|
||||
|
||||
# try 2 : component configure
|
||||
len = args.length
|
||||
begin
|
||||
case len
|
||||
when 1
|
||||
if name[-1] == ?=
|
||||
return configure(name[0..-2], args[0])
|
||||
else
|
||||
return configure(name, args[0])
|
||||
end
|
||||
when 0
|
||||
return cget(name)
|
||||
end
|
||||
rescue
|
||||
end
|
||||
# try 2 : component configure
|
||||
len = args.length
|
||||
begin
|
||||
case len
|
||||
when 1
|
||||
if name[-1] == ?=
|
||||
return configure(name[0..-2], args[0])
|
||||
else
|
||||
return configure(name, args[0])
|
||||
end
|
||||
when 0
|
||||
return cget(name)
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
# try 3 : widget method or widget configure
|
||||
begin
|
||||
unless @widget
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
end
|
||||
@widget.__send__(id, *args)
|
||||
rescue
|
||||
end
|
||||
# try 3 : widget method or widget configure
|
||||
begin
|
||||
unless @widget
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
end
|
||||
@widget.__send__(id, *args)
|
||||
rescue
|
||||
end
|
||||
|
||||
# unknown method
|
||||
fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
|
||||
# unknown method
|
||||
fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
|
||||
end
|
||||
|
||||
def tk_send(cmd, *rest)
|
||||
begin
|
||||
tk_call(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call(@path, cmd, *rest)
|
||||
end
|
||||
begin
|
||||
tk_call(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call(@path, cmd, *rest)
|
||||
end
|
||||
end
|
||||
|
||||
def tk_send_without_enc(cmd, *rest)
|
||||
begin
|
||||
tk_call_without_enc(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call_without_enc(@path, cmd, *rest)
|
||||
end
|
||||
begin
|
||||
tk_call_without_enc(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call_without_enc(@path, cmd, *rest)
|
||||
end
|
||||
end
|
||||
|
||||
def tk_send_with_enc(cmd, *rest)
|
||||
begin
|
||||
tk_call_with_enc(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call_with_enc(@path, cmd, *rest)
|
||||
end
|
||||
begin
|
||||
tk_call_with_enc(@master, 'component', @component, cmd, *rest)
|
||||
rescue
|
||||
unless @path
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
tk_call_with_enc(@path, cmd, *rest)
|
||||
end
|
||||
end
|
||||
|
||||
def bind(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind(*args)
|
||||
end
|
||||
|
||||
def bind_append(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind_append(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind_append(*args)
|
||||
end
|
||||
|
||||
def bind_remove(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind_remove(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bind_remove(*args)
|
||||
end
|
||||
|
||||
def bindinfo(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bindinfo(*args)
|
||||
unless @widget
|
||||
begin
|
||||
@widget = window(tk_call(@master, 'component', @component))
|
||||
@path = @widget.path
|
||||
rescue
|
||||
fail RuntimeError, 'component is not assigned to a widget'
|
||||
end
|
||||
end
|
||||
@widget.bindinfo(*args)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -25,9 +25,9 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Iwidgets')
|
||||
TkPackage.require('Iwidgets')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class Tk::Iwidgets::Calendar
|
|||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -26,16 +26,16 @@ class Tk::Iwidgets::Entryfield
|
|||
#class CalCmdArgs < TkUtil::CallbackSubst
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?s, :char ],
|
||||
[ ?P, ?s, :post ],
|
||||
[ ?S, ?s, :current ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
[ ?c, ?s, :char ],
|
||||
[ ?P, ?s, :post ],
|
||||
[ ?S, ?s, :current ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
PROC_TBL = [
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,21 +46,21 @@ class Tk::Iwidgets::Hierarchy
|
|||
class IndicatorCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?n, ?s, :node ],
|
||||
[ ?s, ?b, :status ],
|
||||
nil
|
||||
[ ?n, ?s, :node ],
|
||||
[ ?s, ?b, :status ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?b, TkComm.method(:bool) ],
|
||||
nil
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?b, TkComm.method(:bool) ],
|
||||
nil
|
||||
]
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,15 +73,15 @@ class Tk::Iwidgets::Hierarchy
|
|||
class IconCommand < TkValidateCommand
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?n, ?s, :node ],
|
||||
[ ?i, ?s, :icon ],
|
||||
nil
|
||||
[ ?n, ?s, :node ],
|
||||
[ ?i, ?s, :icon ],
|
||||
nil
|
||||
]
|
||||
PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
def self.ret_val(val)
|
||||
val
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -200,7 +200,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
|
||||
def compare(idx1, op, idx2)
|
||||
bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
|
||||
op, _get_eval_enc_str(idx2)))
|
||||
op, _get_eval_enc_str(idx2)))
|
||||
end
|
||||
|
||||
def debug
|
||||
|
@ -234,16 +234,16 @@ class Tk::Iwidgets::Hierarchy
|
|||
# multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
|
||||
args = [chars]
|
||||
while tags.size > 0
|
||||
args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
|
||||
args << tags.shift if tags.size > 0 # chars
|
||||
args << 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 :: str, tag, tag, ...
|
||||
if tags.size == 0
|
||||
super index, chars
|
||||
super index, chars
|
||||
else
|
||||
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
|
||||
|
|
|
@ -70,41 +70,41 @@ class Tk::Iwidgets::Menubar
|
|||
next unless spec
|
||||
|
||||
if spec.kind_of?(Hash)
|
||||
args = [spec]
|
||||
type = 'options'
|
||||
args = [spec]
|
||||
type = 'options'
|
||||
else
|
||||
type, *args = spec
|
||||
type, *args = spec
|
||||
end
|
||||
|
||||
type = type.to_s
|
||||
case type
|
||||
when 'options'
|
||||
keys = args[0]
|
||||
ary = [type]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
keys = args[0]
|
||||
ary = [type]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
|
||||
when 'menubutton', 'cascade'
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
keys = _symbolkey2str(keys)
|
||||
keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
keys = _symbolkey2str(keys)
|
||||
keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
|
||||
else
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
name, keys = args
|
||||
if keys
|
||||
ary = [type, name]
|
||||
ary.concat(hash_kv(keys))
|
||||
ret << array2tk_list(ary) << "\n"
|
||||
else
|
||||
ret << array2tk_list([type, name]) << "\n"
|
||||
end
|
||||
end
|
||||
}
|
||||
ret
|
||||
|
|
|
@ -72,7 +72,7 @@ class Tk::Iwidgets::Notebook
|
|||
end
|
||||
if idx2
|
||||
if (new_idx2 = self.index(idx2)) < 0
|
||||
new_idx2 = tagid(idx2)
|
||||
new_idx2 = tagid(idx2)
|
||||
end
|
||||
tk_call(@path, 'delete', new_idx1, new_idx2)
|
||||
else
|
||||
|
|
|
@ -94,7 +94,7 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
|
||||
def bbox(tagOrId, *tags)
|
||||
list(tk_send_without_enc('bbox', tagid(tagOrId),
|
||||
*tags.collect{|t| tagid(t)}))
|
||||
*tags.collect{|t| tagid(t)}))
|
||||
end
|
||||
|
||||
def itembind(tag, context, cmd=Proc.new, args=nil)
|
||||
|
@ -136,14 +136,14 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
|
||||
def dchars(tag, first, last=None)
|
||||
tk_send_without_enc('dchars', tagid(tag),
|
||||
_get_eval_enc_str(first), _get_eval_enc_str(last))
|
||||
_get_eval_enc_str(first), _get_eval_enc_str(last))
|
||||
self
|
||||
end
|
||||
|
||||
def delete(*args)
|
||||
if TkcItem::CItemID_TBL[self.path]
|
||||
find('withtag', *args).each{|item|
|
||||
TkcItem::CItemID_TBL[self.path].delete(item.id)
|
||||
TkcItem::CItemID_TBL[self.path].delete(item.id)
|
||||
}
|
||||
end
|
||||
tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
|
||||
|
@ -190,9 +190,9 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
else
|
||||
ret = tk_send_without_enc('focus')
|
||||
if ret == ""
|
||||
nil
|
||||
nil
|
||||
else
|
||||
TkcItem.id2obj(self, ret)
|
||||
TkcItem.id2obj(self, ret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -214,7 +214,7 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
|
||||
def insert(tagOrId, index, string)
|
||||
tk_send_without_enc('insert', tagid(tagOrId), index,
|
||||
_get_eval_enc_str(string))
|
||||
_get_eval_enc_str(string))
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ class Tk::Iwidgets::Scrolledtext
|
|||
end
|
||||
def compare(idx1, op, idx2)
|
||||
bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
|
||||
op, _get_eval_enc_str(idx2)))
|
||||
op, _get_eval_enc_str(idx2)))
|
||||
end
|
||||
|
||||
def debug
|
||||
|
@ -110,24 +110,24 @@ class Tk::Iwidgets::Scrolledtext
|
|||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
_get_eval_enc_str(index), "-#{slot}"))
|
||||
_get_eval_enc_str(index), "-#{slot}"))
|
||||
else
|
||||
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}")))
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}")))
|
||||
end
|
||||
end
|
||||
|
||||
def image_configure(index, slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
_fromUTF8(tk_send_without_enc('image', 'configure',
|
||||
_get_eval_enc_str(index),
|
||||
*hash_kv(slot, true)))
|
||||
_get_eval_enc_str(index),
|
||||
*hash_kv(slot, true)))
|
||||
else
|
||||
_fromUTF8(tk_send_without_enc('image', 'configure',
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}",
|
||||
_get_eval_enc_str(value)))
|
||||
_get_eval_enc_str(index),
|
||||
"-#{slot}",
|
||||
_get_eval_enc_str(value)))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -135,80 +135,80 @@ class Tk::Iwidgets::Scrolledtext
|
|||
def image_configinfo(index, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
conf[0] = conf[0][1..-1]
|
||||
conf
|
||||
else
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
conf[0] = conf[0][1..-1]
|
||||
case conf[0]
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
if conf[4]
|
||||
if conf[4].index('{')
|
||||
conf[4] = tk_split_list(conf[4])
|
||||
else
|
||||
conf[4] = tk_tcl2ruby(conf[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||
conf
|
||||
}
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
else
|
||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
|
||||
end
|
||||
key = conf.shift[1..-1]
|
||||
{ key => conf }
|
||||
else
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
|
||||
conf = tk_split_simplelist(conflist)
|
||||
key = conf.shift[1..-1]
|
||||
case key
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
else
|
||||
if conf[2]
|
||||
if conf[2].index('{')
|
||||
conf[2] = tk_split_list(conf[2])
|
||||
else
|
||||
conf[2] = tk_tcl2ruby(conf[2])
|
||||
end
|
||||
end
|
||||
if conf[3]
|
||||
if conf[3].index('{')
|
||||
conf[3] = tk_split_list(conf[3])
|
||||
else
|
||||
conf[3] = tk_tcl2ruby(conf[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
if conf.size == 1
|
||||
ret[key] = conf[0][1..-1] # alias info
|
||||
else
|
||||
ret[key] = conf
|
||||
end
|
||||
}
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -216,19 +216,19 @@ class Tk::Iwidgets::Scrolledtext
|
|||
def current_image_configinfo(index, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
conf = image_configinfo(index, slot)
|
||||
{conf[0] => conf[4]}
|
||||
conf = image_configinfo(index, slot)
|
||||
{conf[0] => conf[4]}
|
||||
else
|
||||
ret = {}
|
||||
image_configinfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
ret = {}
|
||||
image_configinfo(index).each{|conf|
|
||||
ret[conf[0]] = conf[4] if conf.size > 2
|
||||
}
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
ret = {}
|
||||
image_configinfo(index, slot).each{|k, conf|
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||
}
|
||||
ret
|
||||
end
|
||||
|
@ -258,7 +258,7 @@ class Tk::Iwidgets::Scrolledtext
|
|||
def mark_gravity(mark, direction=nil)
|
||||
if direction
|
||||
tk_send_without_enc('mark', 'gravity',
|
||||
_get_eval_enc_str(mark), direction)
|
||||
_get_eval_enc_str(mark), direction)
|
||||
self
|
||||
else
|
||||
tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
|
||||
|
@ -267,27 +267,27 @@ class Tk::Iwidgets::Scrolledtext
|
|||
|
||||
def mark_set(mark, index)
|
||||
tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
|
||||
_get_eval_enc_str(index))
|
||||
_get_eval_enc_str(index))
|
||||
self
|
||||
end
|
||||
alias set_mark mark_set
|
||||
|
||||
def mark_unset(*marks)
|
||||
tk_send_without_enc('mark', 'unset',
|
||||
*(marks.collect{|mark| _get_eval_enc_str(mark)}))
|
||||
*(marks.collect{|mark| _get_eval_enc_str(mark)}))
|
||||
self
|
||||
end
|
||||
alias unset_mark mark_unset
|
||||
|
||||
def mark_next(index)
|
||||
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
|
||||
_get_eval_enc_str(index))))
|
||||
_get_eval_enc_str(index))))
|
||||
end
|
||||
alias next_mark mark_next
|
||||
|
||||
def mark_previous(index)
|
||||
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
|
||||
_get_eval_enc_str(index))))
|
||||
_get_eval_enc_str(index))))
|
||||
end
|
||||
alias previous_mark mark_previous
|
||||
|
||||
|
@ -309,14 +309,14 @@ class Tk::Iwidgets::Scrolledtext
|
|||
# $KCODE == 'NONE'
|
||||
if JAPANIZED_TK
|
||||
tk_call_without_enc('kstring', 'length',
|
||||
_get_eval_enc_str(txt)).to_i
|
||||
_get_eval_enc_str(txt)).to_i
|
||||
else
|
||||
begin
|
||||
tk_call_without_enc('encoding', 'convertto', 'ascii',
|
||||
_get_eval_enc_str(txt)).length
|
||||
tk_call_without_enc('encoding', 'convertto', 'ascii',
|
||||
_get_eval_enc_str(txt)).length
|
||||
rescue StandardError, NameError
|
||||
# sorry, I have no plan
|
||||
txt.length
|
||||
# sorry, I have no plan
|
||||
txt.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -368,53 +368,53 @@ class Tk::Iwidgets::Scrolledtext
|
|||
return ["", 0] if compare(start,'>=',stop)
|
||||
txt = get(start,stop)
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
return ["", 0]
|
||||
end
|
||||
else
|
||||
txt = get(start,'end - 1 char')
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(start + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(start + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(start + " + #{pos} chars"),
|
||||
_ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.index(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"),
|
||||
_ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -429,48 +429,48 @@ class Tk::Iwidgets::Scrolledtext
|
|||
return ["", 0] if compare(start,'<=',stop)
|
||||
txt = get(stop,start)
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(stop + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(stop + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index(stop + " + #{pos} chars"), pat.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index(stop + " + #{pos} chars"), $&.split('').length]
|
||||
return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
return ["", 0]
|
||||
end
|
||||
else
|
||||
txt = get('1.0',start)
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
txt = get('1.0','end - 1 char')
|
||||
if (pos = txt.rindex(pat))
|
||||
match = $&
|
||||
#pos = txt[0..(pos-1)].split('').length if pos > 0
|
||||
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
|
||||
if pat.kind_of? String
|
||||
#return [index("1.0 + #{pos} chars"), pat.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
|
||||
else
|
||||
#return [index("1.0 + #{pos} chars"), $&.split('').length]
|
||||
return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
|
||||
end
|
||||
else
|
||||
return ["", 0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,16 +26,16 @@ class Tk::Iwidgets::Spinner
|
|||
#class CalCmdArgs < TkUtil::CallbackSubst
|
||||
class ValidateArgs < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?c, ?s, :char ],
|
||||
[ ?P, ?s, :post ],
|
||||
[ ?S, ?s, :current ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
[ ?c, ?s, :char ],
|
||||
[ ?P, ?s, :post ],
|
||||
[ ?S, ?s, :current ],
|
||||
[ ?W, ?w, :widget ],
|
||||
nil
|
||||
]
|
||||
PROC_TBL = [
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
|
|
@ -81,7 +81,7 @@ class Tk::Iwidgets::Toolbar
|
|||
tag = Tk::Itk::Component.new(self)
|
||||
end
|
||||
window(tk_call(@path, 'insert', index(idx), type,
|
||||
tagid(tag), *hash_kv(keys)))
|
||||
tagid(tag), *hash_kv(keys)))
|
||||
tag
|
||||
end
|
||||
end
|
||||
|
|
|
@ -100,29 +100,29 @@ def check_pkg(file, verbose=false)
|
|||
begin
|
||||
case type
|
||||
when :package
|
||||
ver = TkPackage.require(name)
|
||||
success_list[name] = ver
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
ver = TkPackage.require(name)
|
||||
success_list[name] = ver
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
|
||||
when :library
|
||||
Tk.load_tcllibrary(name)
|
||||
success_list[name] = :library
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
Tk.load_tcllibrary(name)
|
||||
success_list[name] = :library
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
|
||||
when :script
|
||||
Tk.load_tclscript(name)
|
||||
success_list[name] = :script
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
Tk.load_tclscript(name)
|
||||
success_list[name] = :script
|
||||
error_list.delete_if{|n, t| n == name}
|
||||
|
||||
when :require_ruby_lib
|
||||
require name
|
||||
require name
|
||||
|
||||
end
|
||||
rescue => e
|
||||
if verbose
|
||||
error_list << [name, type, e.message]
|
||||
error_list << [name, type, e.message]
|
||||
else
|
||||
error_list << [name, type]
|
||||
error_list << [name, type]
|
||||
end
|
||||
end
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ def check_pkg(file, verbose=false)
|
|||
success_list.dup.each{|name, ver|
|
||||
unless ver.kind_of?(String)
|
||||
begin
|
||||
ver = TkPackage.require(name)
|
||||
sccess_list[name] = ver
|
||||
ver = TkPackage.require(name)
|
||||
sccess_list[name] = ver
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
@ -149,10 +149,10 @@ def subdir_check(dir, verbose=false)
|
|||
path = File.join(dir, f)
|
||||
suc, err = check_pkg(path, verbose)
|
||||
if err.empty?
|
||||
print 'Ready : ', path, ' : require->', suc.inspect, "\n"
|
||||
print 'Ready : ', path, ' : require->', suc.inspect, "\n"
|
||||
else
|
||||
print '*LACK : ', path, ' : require->', suc.inspect,
|
||||
' FAIL->', err.inspect, "\n"
|
||||
print '*LACK : ', path, ' : require->', suc.inspect,
|
||||
' FAIL->', err.inspect, "\n"
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
@ -32,23 +32,23 @@ module Tk
|
|||
module Tcllib
|
||||
module Autoscroll
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('autoscroll')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('autoscroll')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def self.not_available
|
||||
fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
|
||||
fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
|
||||
end
|
||||
|
||||
def self.autoscroll(win)
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
end
|
||||
|
||||
def self.unautoscroll(win)
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
Tk::Tcllib::Autoscroll.not_available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,44 +59,44 @@ module Tk
|
|||
def autoscroll(mode = nil)
|
||||
case mode
|
||||
when :x, 'x'
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
when :y, 'y'
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
when nil, :both, 'both'
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
end
|
||||
self
|
||||
end
|
||||
def unautoscroll(mode = nil)
|
||||
case mode
|
||||
when :x, 'x'
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
when :y, 'y'
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
when nil, :both, 'both'
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
if @xscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
|
||||
end
|
||||
if @yscrollbar
|
||||
Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -130,11 +130,11 @@ module Tk
|
|||
|
||||
module Autoscroll
|
||||
def self.autoscroll(win)
|
||||
tk_call_without_enc('::autoscroll::autoscroll', win.path)
|
||||
tk_call_without_enc('::autoscroll::autoscroll', win.path)
|
||||
end
|
||||
|
||||
def self.unautoscroll(win)
|
||||
tk_call_without_enc('::autoscroll::unautoscroll', win.path)
|
||||
tk_call_without_enc('::autoscroll::unautoscroll', win.path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Tcllib
|
||||
class CText < TkText
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('ctext')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('ctext')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -80,19 +80,19 @@ class Tk::Tcllib::CText
|
|||
|
||||
def add_highlight_class_for_special_chars(klass, col, *chrs)
|
||||
tk_call('ctext::addHighlightClassForSpecialChars',
|
||||
@path, klass, col, chrs.join(''))
|
||||
@path, klass, col, chrs.join(''))
|
||||
self
|
||||
end
|
||||
|
||||
def add_highlight_class_for_regexp(klass, col, tcl_regexp)
|
||||
tk_call('ctext::addHighlightClassForRegexp',
|
||||
@path, klass, col, tcl_regexp)
|
||||
@path, klass, col, tcl_regexp)
|
||||
self
|
||||
end
|
||||
|
||||
def add_highlight_class_with_only_char_start(klass, col, chr)
|
||||
tk_call('ctext::addHighlightClassWithOnlyCharStart',
|
||||
@path, klass, col, chr)
|
||||
@path, klass, col, chr)
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -13,27 +13,27 @@ module Tk
|
|||
module Tcllib
|
||||
module Cursor
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('cursor')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('cursor')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def self.not_available
|
||||
fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
|
||||
fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
|
||||
end
|
||||
|
||||
def self.cursor_display(win=None)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
|
||||
def self.cursor_propagate(win, cursor)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
|
||||
def self.cursor_restore(win, cursor = None)
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
Tk::Tcllib::Cursor.not_available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -74,15 +74,15 @@ module Tk
|
|||
|
||||
module Cursor
|
||||
def self.cursor_display(win=None)
|
||||
tk_call_without_enc('::cursor::display', win)
|
||||
tk_call_without_enc('::cursor::display', win)
|
||||
end
|
||||
|
||||
def self.cursor_propagate(win, cursor)
|
||||
tk_call_without_enc('::cursor::propagate', win.path, cursor)
|
||||
tk_call_without_enc('::cursor::propagate', win.path, cursor)
|
||||
end
|
||||
|
||||
def self.cursor_restore(win, cursor = None)
|
||||
tk_call_without_enc('::cursor::restore', win.path, cursor)
|
||||
tk_call_without_enc('::cursor::restore', win.path, cursor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,11 +26,11 @@ module Tk
|
|||
module Tcllib
|
||||
class Datefield < TkEntry
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('datefield')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('datefield')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
DateField = Datefield
|
||||
|
@ -43,7 +43,7 @@ class Tk::Tcllib::Datefield
|
|||
def create_self(keys)
|
||||
if keys and keys != None
|
||||
tk_call_without_enc('::datefield::datefield', @path,
|
||||
*hash_kv(keys, true))
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
tk_call_without_enc('::datefield::datefield', @path)
|
||||
end
|
||||
|
|
|
@ -20,11 +20,11 @@ module Tk
|
|||
module Tcllib
|
||||
class IP_Entry < TkEntry
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('ipentry')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('ipentry')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
IPEntry = IP_Entry
|
||||
|
|
|
@ -67,11 +67,11 @@ module Tk
|
|||
module Tcllib
|
||||
module Plotchart
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Plotchart')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('Plotchart')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -85,13 +85,13 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax
|
||||
tk_call_without_enc('::Plotchart::worldCoordinates',
|
||||
w.path, *(args.flatten))
|
||||
w.path, *(args.flatten))
|
||||
end
|
||||
|
||||
def self.world_3D_coordinates(w, *args)
|
||||
# args := xmin, ymin, zmin, xmax, ymax, zmax
|
||||
tk_call_without_enc('::Plotchart::world3DCoordinates',
|
||||
w.path, *(args.flatten))
|
||||
w.path, *(args.flatten))
|
||||
end
|
||||
|
||||
def self.coords_to_pixel(w, x, y)
|
||||
|
@ -148,20 +148,20 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def xconfig(key, value=None)
|
||||
if key.kind_of?(Hash)
|
||||
tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
|
||||
tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
|
||||
else
|
||||
tk_call_without_enc(@chart, 'xconfig',
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
tk_call_without_enc(@chart, 'xconfig',
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def yconfig(key, value=None)
|
||||
if key.kind_of?(Hash)
|
||||
tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
|
||||
tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
|
||||
else
|
||||
tk_call_without_enc(@chart, 'yconfig',
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
tk_call_without_enc(@chart, 'yconfig',
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
@ -174,14 +174,14 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def world_coordinates(*args) # args := xmin, ymin, xmax, ymax
|
||||
tk_call_without_enc('::Plotchart::worldCoordinates',
|
||||
@path, *(args.flatten))
|
||||
@path, *(args.flatten))
|
||||
self
|
||||
end
|
||||
|
||||
def world_3D_coordinates(*args)
|
||||
# args := xmin, ymin, zmin, xmax, ymax, zmax
|
||||
tk_call_without_enc('::Plotchart::world3DCoordinates',
|
||||
@path, *(args.flatten))
|
||||
@path, *(args.flatten))
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -230,21 +230,21 @@ module Tk::Tcllib::Plotchart
|
|||
# xaxis := Array of [minimum, maximum, stepsize]
|
||||
# yaxis := Array of [minimum, maximum, stepsize]
|
||||
if args[0].kind_of?(Array)
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -253,7 +253,7 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis))
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis))
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -268,10 +268,10 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def dataconfig(series, key, value=None)
|
||||
if key.kind_of?(Hash)
|
||||
tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
|
||||
tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
|
||||
else
|
||||
tk_call_without_enc(@chart, 'dataconfig', series,
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
tk_call_without_enc(@chart, 'dataconfig', series,
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -296,19 +296,19 @@ module Tk::Tcllib::Plotchart
|
|||
def initialize(*args) # args := ([parent,] radius_data [, keys])
|
||||
# radius_data := Array of [maximum_radius, stepsize]
|
||||
if args[0].kind_of?(Array)
|
||||
@radius_data = args.shift
|
||||
@radius_data = args.shift
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@radius_data = args.shift
|
||||
@radius_data = args.shift
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -317,7 +317,7 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@radius_data))
|
||||
array2tk_list(@radius_data))
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -327,16 +327,16 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def plot(series, radius, angle)
|
||||
tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
|
||||
radius, angle)
|
||||
radius, angle)
|
||||
self
|
||||
end
|
||||
|
||||
def dataconfig(series, key, value=None)
|
||||
if key.kind_of?(Hash)
|
||||
tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
|
||||
tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
|
||||
else
|
||||
tk_call_without_enc(@chart, 'dataconfig', series,
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
tk_call_without_enc(@chart, 'dataconfig', series,
|
||||
"-#{key}", _get_eval_enc_str(value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -356,33 +356,33 @@ module Tk::Tcllib::Plotchart
|
|||
# yaxis := Array of [minimum, maximum]
|
||||
# step := Float of stepsize | "noaxes" | :noaxes
|
||||
if args[0].kind_of?(Array)
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
|
||||
if args[0].kind_of?(Hash)
|
||||
@stepsize = :noaxes
|
||||
else
|
||||
@stepsize = args.shift
|
||||
end
|
||||
if args[0].kind_of?(Hash)
|
||||
@stepsize = :noaxes
|
||||
else
|
||||
@stepsize = args.shift
|
||||
end
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
|
||||
if args[0].kind_of?(Hash)
|
||||
@stepsize = :noaxes
|
||||
else
|
||||
@stepsize = args.shift
|
||||
end
|
||||
if args[0].kind_of?(Hash)
|
||||
@stepsize = :noaxes
|
||||
else
|
||||
@stepsize = args.shift
|
||||
end
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -391,8 +391,8 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis),
|
||||
@stepsize)
|
||||
array2tk_list(@xaxis), array2tk_list(@yaxis),
|
||||
@stepsize)
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -436,23 +436,23 @@ module Tk::Tcllib::Plotchart
|
|||
# yaxis := Array of [minimum, maximum, stepsize]
|
||||
# zaxis := Array of [minimum, maximum, stepsize]
|
||||
if args[0].kind_of?(Array)
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@zaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@zaxis = args.shift
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@zaxis = args.shift
|
||||
@xaxis = args.shift
|
||||
@yaxis = args.shift
|
||||
@zaxis = args.shift
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -461,9 +461,9 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xaxis),
|
||||
array2tk_list(@yaxis),
|
||||
array2tk_list(@zaxis))
|
||||
array2tk_list(@xaxis),
|
||||
array2tk_list(@yaxis),
|
||||
array2tk_list(@zaxis))
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -508,10 +508,10 @@ module Tk::Tcllib::Plotchart
|
|||
|
||||
def initialize(*args) # args := ([parent] [, keys])
|
||||
if args[0].kind_of?(TkCanvas)
|
||||
parent = args.shift
|
||||
@path = parent.path
|
||||
parent = args.shift
|
||||
@path = parent.path
|
||||
else
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
end
|
||||
@chart = _create_chart
|
||||
end
|
||||
|
@ -545,33 +545,33 @@ module Tk::Tcllib::Plotchart
|
|||
# axis := Array of [minimum, maximum, stepsize]
|
||||
# series := Integer number of data series | 'stacked' | :stacked
|
||||
if args[0].kind_of?(Array)
|
||||
@xlabels = args.shift
|
||||
@ylabels = args.shift
|
||||
@xlabels = args.shift
|
||||
@ylabels = args.shift
|
||||
|
||||
if args[0].kind_of?(Hash)
|
||||
@series_size = :stacked
|
||||
else
|
||||
@series_size = args.shift
|
||||
end
|
||||
if args[0].kind_of?(Hash)
|
||||
@series_size = :stacked
|
||||
else
|
||||
@series_size = args.shift
|
||||
end
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@xlabels = args.shift
|
||||
@ylabels = args.shift
|
||||
@xlabels = args.shift
|
||||
@ylabels = args.shift
|
||||
|
||||
if args[0].kind_of?(Hash)
|
||||
@series_size = :stacked
|
||||
else
|
||||
@series_size = args.shift
|
||||
end
|
||||
if args[0].kind_of?(Hash)
|
||||
@series_size = :stacked
|
||||
else
|
||||
@series_size = args.shift
|
||||
end
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -580,8 +580,8 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
array2tk_list(@xlabels), array2tk_list(@ylabels),
|
||||
@series_size)
|
||||
array2tk_list(@xlabels), array2tk_list(@ylabels),
|
||||
@series_size)
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
@ -628,23 +628,23 @@ module Tk::Tcllib::Plotchart
|
|||
# items := Expected/maximum number of items
|
||||
# ( This determines the vertical spacing. )
|
||||
if args[0].kind_of?(Array)
|
||||
@time_begin = args.shift
|
||||
@time_end = args.shift
|
||||
@items = args.shift
|
||||
@time_begin = args.shift
|
||||
@time_end = args.shift
|
||||
@items = args.shift
|
||||
|
||||
super(*args) # create canvas widget
|
||||
super(*args) # create canvas widget
|
||||
else
|
||||
parent = args.shift
|
||||
parent = args.shift
|
||||
|
||||
@time_begin = args.shift
|
||||
@time_end = args.shift
|
||||
@items = args.shift
|
||||
@time_begin = args.shift
|
||||
@time_end = args.shift
|
||||
@items = args.shift
|
||||
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
if parent.kind_of?(TkCanvas)
|
||||
@path = parent.path
|
||||
else
|
||||
super(parent, *args) # create canvas widget
|
||||
end
|
||||
end
|
||||
|
||||
@chart = _create_chart
|
||||
|
@ -653,7 +653,7 @@ module Tk::Tcllib::Plotchart
|
|||
def _create_chart
|
||||
p self.class::TkCommandNames[1] if $DEBUG
|
||||
tk_call_without_enc(self.class::TkCommandNames[1], @path,
|
||||
@time_begin, @time_end, @items)
|
||||
@time_begin, @time_end, @items)
|
||||
end
|
||||
private :_create_chart
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ module Tk::Tcllib
|
|||
module Style
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('style')
|
||||
TkPackage.require('style')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def __configinfo_struct
|
||||
{:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
|
||||
:default_value=>1, :current_value=>2}
|
||||
:default_value=>1, :current_value=>2}
|
||||
end
|
||||
private :__configinfo_struct
|
||||
end
|
||||
|
@ -69,10 +69,10 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def create_self(x, y, width, height, keys=None)
|
||||
if keys and keys != None
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pie',
|
||||
@c, x, y, *hash_kv(keys, true))
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pie',
|
||||
@c, x, y, *hash_kv(keys, true))
|
||||
else
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
|
||||
end
|
||||
|
||||
@slice_tbl = {}
|
||||
|
@ -114,20 +114,20 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def delete_slice(slice)
|
||||
unless slice.kind_of?(Slice)
|
||||
unless (slice = @slice_tbl[slice])
|
||||
return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
|
||||
end
|
||||
unless (slice = @slice_tbl[slice])
|
||||
return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
|
||||
end
|
||||
end
|
||||
unless slice.kind_of?(Slice) && slice.pie == self
|
||||
fail ArgumentError, "argument is not a slice of self"
|
||||
fail ArgumentError, "argument is not a slice of self"
|
||||
end
|
||||
slice.delete
|
||||
end
|
||||
|
||||
def selected_slices
|
||||
tk_split_simplelist(tk_call_without_enc('pie::selectedSlices',
|
||||
@tag_key)).collect{|slice|
|
||||
@slice_tbl[slice] || Slice.new(:no_create, self, slice)
|
||||
@tag_key)).collect{|slice|
|
||||
@slice_tbl[slice] || Slice.new(:no_create, self, slice)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -145,15 +145,15 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def initialize(pie, *args)
|
||||
unless pie.kind_of?(Pie) && pie != :no_create
|
||||
fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
|
||||
fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
|
||||
end
|
||||
|
||||
if pie == :no_create
|
||||
@pie, @tag_key = args
|
||||
@pie, @tag_key = args
|
||||
else
|
||||
text = args[0] || None
|
||||
@pie = pie
|
||||
@tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
|
||||
text = args[0] || None
|
||||
@pie = pie
|
||||
@tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
|
||||
end
|
||||
@parent = @c = @pie.canvas
|
||||
@path = @parent.path
|
||||
|
@ -186,7 +186,7 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def size(share, disp=None)
|
||||
tk_call_without_enc('pie::sizeSlice',
|
||||
@pie.tag_key, @tag_key, share, disp)
|
||||
@pie.tag_key, @tag_key, share, disp)
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -209,10 +209,10 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def create_self(keys=None)
|
||||
if keys and keys != None
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
|
||||
*hash_kv(keys, true))
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
|
||||
end
|
||||
|
||||
id = "pieBoxLabeler(#{@tag_key})"
|
||||
|
@ -241,11 +241,11 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def create_self(keys=None)
|
||||
if keys and keys != None
|
||||
@tag_key = tk_call_without_enc('::stooop::new',
|
||||
'piePeripheralLabeler',
|
||||
*hash_kv(keys, true))
|
||||
@tag_key = tk_call_without_enc('::stooop::new',
|
||||
'piePeripheralLabeler',
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
|
||||
end
|
||||
|
||||
id = "piePeripheralLabeler(#{@tag_key})"
|
||||
|
@ -269,12 +269,12 @@ module Tk::Tcllib::Tkpiechart
|
|||
|
||||
def create_self(x, y, keys=None)
|
||||
if keys and keys != None
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
|
||||
@c, x, y, width, height,
|
||||
*hash_kv(keys, true))
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
|
||||
@c, x, y, width, height,
|
||||
*hash_kv(keys, true))
|
||||
else
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
|
||||
@c, x, y, width, height)
|
||||
@tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
|
||||
@c, x, y, width, height)
|
||||
end
|
||||
|
||||
id = "canvasLabel(#{@tag_key})"
|
||||
|
|
|
@ -17,9 +17,9 @@ module Tk
|
|||
module TclX
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Tclx')
|
||||
TkPackage.require('Tclx')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -31,28 +31,28 @@ module Tk
|
|||
|
||||
class XPG3_MsgCat
|
||||
class << self
|
||||
alias open new
|
||||
alias open new
|
||||
end
|
||||
|
||||
def initialize(catname, fail_mode=false)
|
||||
if fail_mode
|
||||
@msgcat_id = Tk.tk_call('catopen', '-fail', catname)
|
||||
else
|
||||
@msgcat_id = Tk.tk_call('catopen', '-nofail', catname)
|
||||
end
|
||||
if fail_mode
|
||||
@msgcat_id = Tk.tk_call('catopen', '-fail', catname)
|
||||
else
|
||||
@msgcat_id = Tk.tk_call('catopen', '-nofail', catname)
|
||||
end
|
||||
end
|
||||
|
||||
def close(fail_mode=false)
|
||||
if fail_mode
|
||||
Tk.tk_call('catclose', '-fail', @msgcat_id)
|
||||
else
|
||||
Tk.tk_call('catclose', '-nofail', @msgcat_id)
|
||||
end
|
||||
self
|
||||
if fail_mode
|
||||
Tk.tk_call('catclose', '-fail', @msgcat_id)
|
||||
else
|
||||
Tk.tk_call('catclose', '-nofail', @msgcat_id)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def get(setnum, msgnum, defaultstr)
|
||||
Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr)
|
||||
Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,29 +22,29 @@ module Tk
|
|||
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('tile')
|
||||
TkPackage.require('tile')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
module TileWidget
|
||||
def instate(state, script=nil, &b)
|
||||
if script
|
||||
tk_send('instate', state, script)
|
||||
elsif b
|
||||
tk_send('instate', state, Proc.new(&b))
|
||||
else
|
||||
bool(tk_send('instate', state))
|
||||
end
|
||||
if script
|
||||
tk_send('instate', state, script)
|
||||
elsif b
|
||||
tk_send('instate', state, Proc.new(&b))
|
||||
else
|
||||
bool(tk_send('instate', state))
|
||||
end
|
||||
end
|
||||
|
||||
def state(state=nil)
|
||||
if state
|
||||
tk_send('state', state)
|
||||
else
|
||||
list(tk_send('state'))
|
||||
end
|
||||
if state
|
||||
tk_send('state', state)
|
||||
else
|
||||
list(tk_send('state'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,93 +19,93 @@ module Tk
|
|||
module Shape
|
||||
=begin
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('shape')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('shape')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
=end
|
||||
def self.package_version
|
||||
Tk.tk_call('set', 'shape_version')
|
||||
Tk.tk_call('set', 'shape_version')
|
||||
end
|
||||
alias shape_version package_version
|
||||
|
||||
def self.package_patchlevel
|
||||
Tk.tk_call('set', 'shape_patchlevel')
|
||||
Tk.tk_call('set', 'shape_patchlevel')
|
||||
end
|
||||
alias shape_patchlevel package_patchlevel
|
||||
|
||||
def self.version
|
||||
tk_call('shape', 'version')
|
||||
tk_call('shape', 'version')
|
||||
end
|
||||
alias xshape_version version
|
||||
|
||||
############################
|
||||
|
||||
def shape_bounds(kind=nil)
|
||||
if kind
|
||||
ret = tk_call('shape', 'bounds', @path, "-#{kind}")
|
||||
else
|
||||
ret = tk_call('shape', 'bounds', @path)
|
||||
end
|
||||
if ret == ""
|
||||
nil
|
||||
else
|
||||
list(ret)
|
||||
end
|
||||
if kind
|
||||
ret = tk_call('shape', 'bounds', @path, "-#{kind}")
|
||||
else
|
||||
ret = tk_call('shape', 'bounds', @path)
|
||||
end
|
||||
if ret == ""
|
||||
nil
|
||||
else
|
||||
list(ret)
|
||||
end
|
||||
end
|
||||
|
||||
def shape_get(kind=nil)
|
||||
if kind
|
||||
list(tk_call('shape', 'get', @path, "-#{kind}"))
|
||||
else
|
||||
list(tk_call('shape', 'get', @path))
|
||||
end
|
||||
if kind
|
||||
list(tk_call('shape', 'get', @path, "-#{kind}"))
|
||||
else
|
||||
list(tk_call('shape', 'get', @path))
|
||||
end
|
||||
end
|
||||
|
||||
def shape_offset(x, y, kind=nil)
|
||||
if kind
|
||||
tk_call('shape', 'get', @path, "-#{kind}", x, y)
|
||||
else
|
||||
tk_call('shape', 'get', @path, x, y)
|
||||
end
|
||||
self
|
||||
if kind
|
||||
tk_call('shape', 'get', @path, "-#{kind}", x, y)
|
||||
else
|
||||
tk_call('shape', 'get', @path, x, y)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def _parse_shapespec_param(args)
|
||||
cmd = []
|
||||
cmd = []
|
||||
|
||||
kind_keys = ['bounding', 'clip', 'both']
|
||||
offset_keys = ['offset']
|
||||
srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window']
|
||||
kind_keys = ['bounding', 'clip', 'both']
|
||||
offset_keys = ['offset']
|
||||
srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window']
|
||||
|
||||
cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s)
|
||||
cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s)
|
||||
|
||||
if offset_keys.member?(args[0].to_s)
|
||||
cmd << "-#{args.shift}"
|
||||
cmd << args.shift # xOffset
|
||||
cmd << args.shift # yOffset
|
||||
end
|
||||
if offset_keys.member?(args[0].to_s)
|
||||
cmd << "-#{args.shift}"
|
||||
cmd << args.shift # xOffset
|
||||
cmd << args.shift # yOffset
|
||||
end
|
||||
|
||||
if srckind_keys.member?(args[0].to_s)
|
||||
cmd << "-#{args.shift}"
|
||||
end
|
||||
if srckind_keys.member?(args[0].to_s)
|
||||
cmd << "-#{args.shift}"
|
||||
end
|
||||
|
||||
cmd.concat(args)
|
||||
cmd.concat(args)
|
||||
|
||||
cmd
|
||||
cmd
|
||||
end
|
||||
private :_parse_shapespec_param
|
||||
|
||||
def shape_set(*args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
|
||||
tk_call('shape', 'set', @path, *(_parse_shapespec_param(args)))
|
||||
self
|
||||
tk_call('shape', 'set', @path, *(_parse_shapespec_param(args)))
|
||||
self
|
||||
end
|
||||
|
||||
def shape_update(op, *args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
|
||||
tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args)))
|
||||
self
|
||||
tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args)))
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,39 +17,39 @@ module Tk
|
|||
module TkDND
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('tkdnd')
|
||||
TkPackage.require('tkdnd')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
class DND_Subst < TkUtil::CallbackSubst
|
||||
KEY_TBL = [
|
||||
[ ?a, ?l, :actions ],
|
||||
[ ?A, ?s, :action ],
|
||||
[ ?b, ?L, :codes ],
|
||||
[ ?c, ?s, :code ],
|
||||
[ ?d, ?l, :descriptions ],
|
||||
[ ?D, ?l, :data ],
|
||||
[ ?L, ?l, :source_types ],
|
||||
[ ?m, ?l, :modifiers ],
|
||||
[ ?t, ?l, :types ],
|
||||
[ ?T, ?s, :type ],
|
||||
[ ?W, ?w, :widget ],
|
||||
[ ?x, ?n, :x ],
|
||||
[ ?X, ?n, :x_root ],
|
||||
[ ?y, ?n, :y ],
|
||||
[ ?Y, ?n, :y_root ],
|
||||
nil
|
||||
[ ?a, ?l, :actions ],
|
||||
[ ?A, ?s, :action ],
|
||||
[ ?b, ?L, :codes ],
|
||||
[ ?c, ?s, :code ],
|
||||
[ ?d, ?l, :descriptions ],
|
||||
[ ?D, ?l, :data ],
|
||||
[ ?L, ?l, :source_types ],
|
||||
[ ?m, ?l, :modifiers ],
|
||||
[ ?t, ?l, :types ],
|
||||
[ ?T, ?s, :type ],
|
||||
[ ?W, ?w, :widget ],
|
||||
[ ?x, ?n, :x ],
|
||||
[ ?X, ?n, :x_root ],
|
||||
[ ?y, ?n, :y ],
|
||||
[ ?Y, ?n, :y_root ],
|
||||
nil
|
||||
]
|
||||
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:num_or_str) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?l, TkComm.method(:list) ],
|
||||
[ ?L, TkComm.method(:simplelist) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
[ ?n, TkComm.method(:num_or_str) ],
|
||||
[ ?s, TkComm.method(:string) ],
|
||||
[ ?l, TkComm.method(:list) ],
|
||||
[ ?L, TkComm.method(:simplelist) ],
|
||||
[ ?w, TkComm.method(:window) ],
|
||||
nil
|
||||
]
|
||||
|
||||
# setup tables
|
||||
|
@ -58,62 +58,62 @@ module Tk
|
|||
|
||||
module DND
|
||||
def self.version
|
||||
begin
|
||||
TkPackage.require('tkdnd')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('tkdnd')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def dnd_bindtarget_info(type=nil, event=nil)
|
||||
if event
|
||||
procedure(tk_call('dnd', 'bindtarget', @path, type, event))
|
||||
elsif type
|
||||
procedure(tk_call('dnd', 'bindtarget', @path, type))
|
||||
else
|
||||
simplelist(tk_call('dnd', 'bindtarget', @path))
|
||||
end
|
||||
if event
|
||||
procedure(tk_call('dnd', 'bindtarget', @path, type, event))
|
||||
elsif type
|
||||
procedure(tk_call('dnd', 'bindtarget', @path, type))
|
||||
else
|
||||
simplelist(tk_call('dnd', 'bindtarget', @path))
|
||||
end
|
||||
end
|
||||
|
||||
def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
|
||||
event = tk_event_sequence(event)
|
||||
if prior.kind_of?(Numeric)
|
||||
tk_call('dnd', 'bindtarget', @path, type, event,
|
||||
install_bind_for_event_class(DND_Subst, cmd, *args),
|
||||
prior)
|
||||
else
|
||||
tk_call('dnd', 'bindtarget', @path, type, event,
|
||||
install_bind_for_event_class(DND_Subst, cmd, prior, *args))
|
||||
end
|
||||
self
|
||||
event = tk_event_sequence(event)
|
||||
if prior.kind_of?(Numeric)
|
||||
tk_call('dnd', 'bindtarget', @path, type, event,
|
||||
install_bind_for_event_class(DND_Subst, cmd, *args),
|
||||
prior)
|
||||
else
|
||||
tk_call('dnd', 'bindtarget', @path, type, event,
|
||||
install_bind_for_event_class(DND_Subst, cmd, prior, *args))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def dnd_cleartarget
|
||||
tk_call('dnd', 'cleartarget', @path)
|
||||
self
|
||||
tk_call('dnd', 'cleartarget', @path)
|
||||
self
|
||||
end
|
||||
|
||||
def dnd_bindsource_info(type=nil)
|
||||
if type
|
||||
procedure(tk_call('dnd', 'bindsource', @path, type))
|
||||
else
|
||||
simplelist(tk_call('dnd', 'bindsource', @path))
|
||||
end
|
||||
if type
|
||||
procedure(tk_call('dnd', 'bindsource', @path, type))
|
||||
else
|
||||
simplelist(tk_call('dnd', 'bindsource', @path))
|
||||
end
|
||||
end
|
||||
|
||||
def dnd_bindsource(type, cmd=Proc.new, prior=None)
|
||||
tk_call('dnd', 'bindsource', @path, type, cmd, prior)
|
||||
self
|
||||
tk_call('dnd', 'bindsource', @path, type, cmd, prior)
|
||||
self
|
||||
end
|
||||
|
||||
def dnd_clearsource()
|
||||
tk_call('dnd', 'clearsource', @path)
|
||||
self
|
||||
tk_call('dnd', 'clearsource', @path)
|
||||
self
|
||||
end
|
||||
|
||||
def dnd_drag(keys=nil)
|
||||
tk_call('dnd', 'drag', @path, *hash_kv(keys))
|
||||
self
|
||||
tk_call('dnd', 'drag', @path, *hash_kv(keys))
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,9 +18,9 @@ module Tk
|
|||
class HTML_Widget < TkWindow
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Tkhtml')
|
||||
TkPackage.require('Tkhtml')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Tk::HTML_Widget::ClippingWindow
|
|||
if widgetname =~ /^(.*)\.[^.]+$/
|
||||
ppath2 = $1
|
||||
if ppath2[0] != ?.
|
||||
ppath2 = ppath + '.' + ppath2
|
||||
ppath2 = ppath + '.' + ppath2
|
||||
end
|
||||
return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ module Tk
|
|||
module Img
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('Img')
|
||||
TkPackage.require('Img')
|
||||
rescue
|
||||
''
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module BMP
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::bmp')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::bmp')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module GIF
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::gif')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::gif')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module ICO
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::ico')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::ico')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module JPEG
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::jpeg')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::jpeg')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module PCX
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::pcx')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::pcx')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module PIXMAP
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::pixmap')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::pixmap')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ module Tk
|
|||
module Img
|
||||
module PNG
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('img::png')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
begin
|
||||
TkPackage.require('img::png')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче