diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-11 04:51:21 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-11 04:51:21 +0000 |
commit | 7554d0b06f53969d56402f3343c35063a7b4b56a (patch) | |
tree | 81258b81d9111c762cb80ca56141cd1f8ce9d0f9 | |
parent | d3caa0ae0ba3a85108ff11919b227a2ddcf290eb (diff) | |
download | ruby-7554d0b06f53969d56402f3343c35063a7b4b56a.tar.gz ruby-7554d0b06f53969d56402f3343c35063a7b4b56a.tar.xz ruby-7554d0b06f53969d56402f3343c35063a7b4b56a.zip |
* ext/tk/lib/tk/*: untabify
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
296 files changed, 13911 insertions, 13878 deletions
@@ -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' diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index f17354fca..8ec34f021 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -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 - - 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 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 + 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_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 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 diff --git a/ext/tcltklib/lib/tcltk.rb b/ext/tcltklib/lib/tcltk.rb index a6bc773b9..1a6694dbf 100644 --- a/ext/tcltklib/lib/tcltk.rb +++ b/ext/tcltklib/lib/tcltk.rb @@ -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 diff --git a/ext/tcltklib/sample/sample1.rb b/ext/tcltklib/sample/sample1.rb index 21ee0f29d..77b79e6db 100644 --- a/ext/tcltklib/sample/sample1.rb +++ b/ext/tcltklib/sample/sample1.rb @@ -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 diff --git a/ext/tcltklib/sample/sample2.rb b/ext/tcltklib/sample/sample2.rb index 969d8de09..5d43470de 100644 --- a/ext/tcltklib/sample/sample2.rb +++ b/ext/tcltklib/sample/sample2.rb @@ -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 diff --git a/ext/tcltklib/stubs.c b/ext/tcltklib/stubs.c index 8faa4ca24..3913abb57 100644 --- a/ext/tcltklib/stubs.c +++ b/ext/tcltklib/stubs.c @@ -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); diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 8b180bf49..765417d92 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -1,12 +1,12 @@ /* - * tcltklib.c - * Aug. 27, 1997 Y. Shigehiro - * Oct. 24, 1997 Y. Matsumoto + * tcltklib.c + * Aug. 27, 1997 Y. Shigehiro + * Oct. 24, 1997 Y. Matsumoto */ #include "ruby.h" #include "rubysig.h" -#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */ +#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */ #include <stdio.h> #ifdef HAVE_STDARG_PROTOTYPES #include <stdarg.h> @@ -196,12 +196,12 @@ static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, char **)); /*---- class TclTkIp ----*/ struct tcltkip { - Tcl_Interp *ip; /* the interpreter */ - int has_orig_exit; /* has original 'exit' command ? */ - Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */ - int ref_count; /* reference count of rbtk_preserve_ip call */ - int allow_ruby_exit; /* allow exiting ruby by 'exit' function */ - int return_value; /* return value */ + Tcl_Interp *ip; /* the interpreter */ + int has_orig_exit; /* has original 'exit' command ? */ + Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */ + int ref_count; /* reference count of rbtk_preserve_ip call */ + int allow_ruby_exit; /* allow exiting ruby by 'exit' function */ + int return_value; /* return value */ }; static struct tcltkip * @@ -212,7 +212,7 @@ get_ip(self) Data_Get_Struct(self, struct tcltkip, ptr); if (ptr == 0) { - rb_raise(rb_eTypeError, "uninitialized TclTkIp"); + rb_raise(rb_eTypeError, "uninitialized TclTkIp"); } return ptr; } @@ -233,9 +233,9 @@ rbtk_release_ip(ptr) { ptr->ref_count--; if (ptr->ref_count < 0) { - ptr->ref_count = 0; + ptr->ref_count = 0; } else { - Tcl_Release((ClientData)ptr->ip); + Tcl_Release((ClientData)ptr->ip); } return(ptr->ref_count); } @@ -267,46 +267,46 @@ call_original_exit(ptr, state) Tcl_IncrRefCount(state_obj); if (info->isNativeObjectProc) { - Tcl_Obj **argv; - argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3); - argv[0] = Tcl_NewStringObj("exit", 4); - argv[1] = state_obj; - argv[2] = (Tcl_Obj *)NULL; + Tcl_Obj **argv; + argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3); + argv[0] = Tcl_NewStringObj("exit", 4); + argv[1] = state_obj; + argv[2] = (Tcl_Obj *)NULL; - ptr->return_value - = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv); + ptr->return_value + = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv); - free(argv); + free(argv); } else { - /* string interface */ - char **argv; - argv = (char **)ALLOC_N(char *, 3); - argv[0] = "exit"; - argv[1] = Tcl_GetString(state_obj); - argv[2] = (char *)NULL; + /* string interface */ + char **argv; + argv = (char **)ALLOC_N(char *, 3); + argv[0] = "exit"; + argv[1] = Tcl_GetString(state_obj); + argv[2] = (char *)NULL; - ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, - 2, (CONST84 char **)argv); + ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, + 2, (CONST84 char **)argv); - free(argv); + free(argv); } Tcl_DecrRefCount(state_obj); #else /* TCL_MAJOR_VERSION < 8 */ { - /* string interface */ - char **argv; - argv = (char **)ALLOC_N(char *, 3); - argv[0] = "exit"; - argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr; - argv[2] = (char *)NULL; + /* string interface */ + char **argv; + argv = (char **)ALLOC_N(char *, 3); + argv[0] = "exit"; + argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr; + argv[2] = (char *)NULL; - ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, - 2, argv); + ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, + 2, argv); - free(argv); + free(argv); } #endif @@ -337,10 +337,10 @@ _timer_for_tcl(clientData) run_timer_flag = 1; if (timer_tick > 0) { - timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, - (ClientData)0); + timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, + (ClientData)0); } else { - timer_token = (Tcl_TimerToken)NULL; + timer_token = (Tcl_TimerToken)NULL; } rb_thread_critical = thr_crit_bup; @@ -360,8 +360,8 @@ set_eventloop_tick(self, tick) rb_secure(4); if (ttick < 0) { - rb_raise(rb_eArgError, - "timer-tick parameter must be 0 or positive number"); + rb_raise(rb_eArgError, + "timer-tick parameter must be 0 or positive number"); } thr_crit_bup = rb_thread_critical; @@ -372,11 +372,11 @@ set_eventloop_tick(self, tick) timer_tick = req_timer_tick = ttick; if (timer_tick > 0) { - /* start timer callback */ - timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, - (ClientData)0); + /* start timer callback */ + timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, + (ClientData)0); } else { - timer_token = (Tcl_TimerToken)NULL; + timer_token = (Tcl_TimerToken)NULL; } rb_thread_critical = thr_crit_bup; @@ -400,13 +400,13 @@ ip_set_eventloop_tick(self, tick) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return get_eventloop_tick(self); + DUMP1("ip is deleted"); + return get_eventloop_tick(self); } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return get_eventloop_tick(self); + /* slave IP */ + return get_eventloop_tick(self); } return set_eventloop_tick(self, tick); } @@ -428,8 +428,8 @@ set_no_event_wait(self, wait) rb_secure(4); if (t_wait <= 0) { - rb_raise(rb_eArgError, - "no_event_wait parameter must be positive number"); + rb_raise(rb_eArgError, + "no_event_wait parameter must be positive number"); } no_event_wait = t_wait; @@ -453,13 +453,13 @@ ip_set_no_event_wait(self, wait) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return get_no_event_wait(self); + DUMP1("ip is deleted"); + return get_no_event_wait(self); } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return get_no_event_wait(self); + /* slave IP */ + return get_no_event_wait(self); } return set_no_event_wait(self, wait); } @@ -483,7 +483,7 @@ set_eventloop_weight(self, loop_max, no_event) rb_secure(4); if (lpmax <= 0 || no_ev <= 0) { - rb_raise(rb_eArgError, "weight parameters must be positive numbers"); + rb_raise(rb_eArgError, "weight parameters must be positive numbers"); } event_loop_max = lpmax; @@ -509,13 +509,13 @@ ip_set_eventloop_weight(self, loop_max, no_event) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return get_eventloop_weight(self); + DUMP1("ip is deleted"); + return get_eventloop_weight(self); } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return get_eventloop_weight(self); + /* slave IP */ + return get_eventloop_weight(self); } return set_eventloop_weight(self, loop_max, no_event); } @@ -538,21 +538,21 @@ set_max_block_time(self, time) switch(TYPE(time)) { case T_FIXNUM: case T_BIGNUM: - /* time is micro-second value */ - divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000)); - tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); - tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]); - break; + /* time is micro-second value */ + divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000)); + tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); + tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]); + break; case T_FLOAT: - /* time is second value */ - divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1)); - tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); - tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000); + /* time is second value */ + divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1)); + tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); + tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000); default: - rb_raise(rb_eArgError, "invalid value for time: '%s'", - RSTRING(rb_funcall(time, ID_inspect, 0, 0))->ptr); + rb_raise(rb_eArgError, "invalid value for time: '%s'", + RSTRING(rb_funcall(time, ID_inspect, 0, 0))->ptr); } Tcl_SetMaxBlockTime(&tcl_time); @@ -565,11 +565,11 @@ lib_evloop_abort_on_exc(self) VALUE self; { if (event_loop_abort_on_exc > 0) { - return Qtrue; + return Qtrue; } else if (event_loop_abort_on_exc == 0) { - return Qfalse; + return Qfalse; } else { - return Qnil; + return Qnil; } } @@ -586,11 +586,11 @@ lib_evloop_abort_on_exc_set(self, val) { rb_secure(4); if (RTEST(val)) { - event_loop_abort_on_exc = 1; + event_loop_abort_on_exc = 1; } else if (NIL_P(val)) { - event_loop_abort_on_exc = -1; + event_loop_abort_on_exc = -1; } else { - event_loop_abort_on_exc = 0; + event_loop_abort_on_exc = 0; } return lib_evloop_abort_on_exc(self); } @@ -605,13 +605,13 @@ ip_evloop_abort_on_exc_set(self, val) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return lib_evloop_abort_on_exc(self); + DUMP1("ip is deleted"); + return lib_evloop_abort_on_exc(self); } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return lib_evloop_abort_on_exc(self); + /* slave IP */ + return lib_evloop_abort_on_exc(self); } return lib_evloop_abort_on_exc_set(self, val); } @@ -644,134 +644,134 @@ lib_eventloop_core(check_root, update_flag, check_var) Tk_DeleteTimerHandler(timer_token); run_timer_flag = 0; if (timer_tick > 0) { - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, - (ClientData)0); - rb_thread_critical = thr_crit_bup; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl, + (ClientData)0); + rb_thread_critical = thr_crit_bup; } else { - timer_token = (Tcl_TimerToken)NULL; + timer_token = (Tcl_TimerToken)NULL; } for(;;) { - if (rb_thread_alone()) { - DUMP1("no other thread"); - event_loop_wait_event = 0; - - if (update_flag) { - event_flag = update_flag | TCL_DONT_WAIT; /* for safety */ - } else { - event_flag = TCL_ALL_EVENTS; - } - - if (timer_tick == 0 && update_flag == 0) { - timer_tick = NO_THREAD_INTERRUPT_TIME; - timer_token = Tk_CreateTimerHandler(timer_tick, - _timer_for_tcl, - (ClientData)0); - } - - if (check_var != (int *)NULL) { - if (*check_var || !found_event) { - return found_event; - } - } - - found_event = Tcl_DoOneEvent(event_flag); - - if (update_flag != 0) { - if (found_event) { - DUMP1("next update loop"); - continue; - } else { - DUMP1("update complete"); - return 0; - } - } - - DUMP1("check Root Widget"); - if (check_root && Tk_GetNumMainWindows() == 0) { - run_timer_flag = 0; - if (!rb_prohibit_interrupt) { - if (rb_trap_pending) rb_trap_exec(); - } - return 1; - } - - if (loop_counter++ > 30000) { - /* fprintf(stderr, "loop_counter > 30000\n"); */ - loop_counter = 0; - } - - } else { - int tick_counter; - - DUMP1("there are other threads"); - event_loop_wait_event = 1; - - found_event = 1; - - if (update_flag) { - event_flag = update_flag | TCL_DONT_WAIT; /* for safety */ - } else { - event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT; - } - - timer_tick = req_timer_tick; - tick_counter = 0; - while(tick_counter < event_loop_max) { - if (check_var != (int *)NULL) { - if (*check_var || !found_event) { - return found_event; - } - } - - if (Tcl_DoOneEvent(event_flag)) { - tick_counter++; - } else { - if (update_flag != 0) { - DUMP1("update complete"); - return 0; - } - tick_counter += no_event_tick; - rb_thread_wait_for(t); - } - - if (watchdog_thread != 0 && eventloop_thread != current) { - return 1; - } - - DUMP1("check Root Widget"); - if (check_root && Tk_GetNumMainWindows() == 0) { - run_timer_flag = 0; - if (!rb_prohibit_interrupt) { - if (rb_trap_pending) rb_trap_exec(); - } - return 1; - } - - DUMP1("trap check"); - if (!rb_prohibit_interrupt) { - if (rb_trap_pending) rb_trap_exec(); - } - - if (loop_counter++ > 30000) { - /* fprintf(stderr, "loop_counter > 30000\n"); */ - loop_counter = 0; - } - - if (run_timer_flag) { - /* - DUMP1("timer interrupt"); - run_timer_flag = 0; - */ - break; /* switch to other thread */ - } - } - } - - DUMP1("trap check & thread scheduling"); - if (update_flag == 0) CHECK_INTS; + if (rb_thread_alone()) { + DUMP1("no other thread"); + event_loop_wait_event = 0; + + if (update_flag) { + event_flag = update_flag | TCL_DONT_WAIT; /* for safety */ + } else { + event_flag = TCL_ALL_EVENTS; + } + + if (timer_tick == 0 && update_flag == 0) { + timer_tick = NO_THREAD_INTERRUPT_TIME; + timer_token = Tk_CreateTimerHandler(timer_tick, + _timer_for_tcl, + (ClientData)0); + } + + if (check_var != (int *)NULL) { + if (*check_var || !found_event) { + return found_event; + } + } + + found_event = Tcl_DoOneEvent(event_flag); + + if (update_flag != 0) { + if (found_event) { + DUMP1("next update loop"); + continue; + } else { + DUMP1("update complete"); + return 0; + } + } + + DUMP1("check Root Widget"); + if (check_root && Tk_GetNumMainWindows() == 0) { + run_timer_flag = 0; + if (!rb_prohibit_interrupt) { + if (rb_trap_pending) rb_trap_exec(); + } + return 1; + } + + if (loop_counter++ > 30000) { + /* fprintf(stderr, "loop_counter > 30000\n"); */ + loop_counter = 0; + } + + } else { + int tick_counter; + + DUMP1("there are other threads"); + event_loop_wait_event = 1; + + found_event = 1; + + if (update_flag) { + event_flag = update_flag | TCL_DONT_WAIT; /* for safety */ + } else { + event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT; + } + + timer_tick = req_timer_tick; + tick_counter = 0; + while(tick_counter < event_loop_max) { + if (check_var != (int *)NULL) { + if (*check_var || !found_event) { + return found_event; + } + } + + if (Tcl_DoOneEvent(event_flag)) { + tick_counter++; + } else { + if (update_flag != 0) { + DUMP1("update complete"); + return 0; + } + tick_counter += no_event_tick; + rb_thread_wait_for(t); + } + + if (watchdog_thread != 0 && eventloop_thread != current) { + return 1; + } + + DUMP1("check Root Widget"); + if (check_root && Tk_GetNumMainWindows() == 0) { + run_timer_flag = 0; + if (!rb_prohibit_interrupt) { + if (rb_trap_pending) rb_trap_exec(); + } + return 1; + } + + DUMP1("trap check"); + if (!rb_prohibit_interrupt) { + if (rb_trap_pending) rb_trap_exec(); + } + + if (loop_counter++ > 30000) { + /* fprintf(stderr, "loop_counter > 30000\n"); */ + loop_counter = 0; + } + + if (run_timer_flag) { + /* + DUMP1("timer interrupt"); + run_timer_flag = 0; + */ + break; /* switch to other thread */ + } + } + } + + DUMP1("trap check & thread scheduling"); + if (update_flag == 0) CHECK_INTS; } return 1; @@ -784,9 +784,9 @@ lib_eventloop_main(check_rootwidget) check_rootwidget_flag = RTEST(check_rootwidget); if (lib_eventloop_core(check_rootwidget_flag, 0, (int *)NULL)) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -799,8 +799,8 @@ lib_eventloop_ensure(parent_evloop) DUMP2("eventloop-ensure: current-thread : %lx\n", rb_thread_current()); DUMP2("eventloop-ensure: eventloop-thread : %lx\n", eventloop_thread); if (eventloop_thread == rb_thread_current()) { - DUMP2("eventloop-thread -> %lx\n", parent_evloop); - eventloop_thread = parent_evloop; + DUMP2("eventloop-thread -> %lx\n", parent_evloop); + eventloop_thread = parent_evloop; } return Qnil; } @@ -814,12 +814,12 @@ lib_eventloop_launcher(check_rootwidget) eventloop_thread = rb_thread_current(); if (ruby_debug) { - fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n", - parent_evloop, eventloop_thread); + fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n", + parent_evloop, eventloop_thread); } return rb_ensure(lib_eventloop_main, check_rootwidget, - lib_eventloop_ensure, parent_evloop); + lib_eventloop_ensure, parent_evloop); } /* execute Tk_MainLoop */ @@ -832,11 +832,11 @@ lib_mainloop(argc, argv, self) VALUE check_rootwidget; if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) { - check_rootwidget = Qtrue; + check_rootwidget = Qtrue; } else if (RTEST(check_rootwidget)) { - check_rootwidget = Qtrue; + check_rootwidget = Qtrue; } else { - check_rootwidget = Qfalse; + check_rootwidget = Qfalse; } return lib_eventloop_launcher(check_rootwidget); @@ -852,13 +852,13 @@ ip_mainloop(argc, argv, self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return Qnil; + DUMP1("ip is deleted"); + return Qnil; } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return Qnil; + /* slave IP */ + return Qnil; } return lib_mainloop(argc, argv, self); } @@ -880,40 +880,40 @@ lib_watchdog_core(check_rootwidget) /* check other watchdog thread */ if (watchdog_thread != 0) { - if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) { - rb_funcall(watchdog_thread, ID_kill, 0); - } else { - return Qnil; - } + if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) { + rb_funcall(watchdog_thread, ID_kill, 0); + } else { + return Qnil; + } } watchdog_thread = rb_thread_current(); /* watchdog start */ do { - if (eventloop_thread == 0 - || (loop_counter == prev_val - && RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0)) - && ++chance >= 3 ) - ) { - /* start new eventloop thread */ - DUMP2("eventloop thread %lx is sleeping or dead", - eventloop_thread); - evloop = rb_thread_create(lib_eventloop_launcher, - (void*)&check_rootwidget); - DUMP2("create new eventloop thread %lx", evloop); - loop_counter = -1; - chance = 0; - rb_thread_run(evloop); - } else { - loop_counter = prev_val; - chance = 0; - if (event_loop_wait_event) { - rb_thread_wait_for(t0); - } else { - rb_thread_wait_for(t1); - } - /* rb_thread_schedule(); */ - } + if (eventloop_thread == 0 + || (loop_counter == prev_val + && RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0)) + && ++chance >= 3 ) + ) { + /* start new eventloop thread */ + DUMP2("eventloop thread %lx is sleeping or dead", + eventloop_thread); + evloop = rb_thread_create(lib_eventloop_launcher, + (void*)&check_rootwidget); + DUMP2("create new eventloop thread %lx", evloop); + loop_counter = -1; + chance = 0; + rb_thread_run(evloop); + } else { + loop_counter = prev_val; + chance = 0; + if (event_loop_wait_event) { + rb_thread_wait_for(t0); + } else { + rb_thread_wait_for(t1); + } + /* rb_thread_schedule(); */ + } } while(!check || Tk_GetNumMainWindows() != 0); return Qnil; @@ -936,15 +936,15 @@ lib_mainloop_watchdog(argc, argv, self) VALUE check_rootwidget; if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) { - check_rootwidget = Qtrue; + check_rootwidget = Qtrue; } else if (RTEST(check_rootwidget)) { - check_rootwidget = Qtrue; + check_rootwidget = Qtrue; } else { - check_rootwidget = Qfalse; + check_rootwidget = Qfalse; } return rb_ensure(lib_watchdog_core, check_rootwidget, - lib_watchdog_ensure, Qnil); + lib_watchdog_ensure, Qnil); } static VALUE @@ -957,13 +957,13 @@ ip_mainloop_watchdog(argc, argv, self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return Qnil; + DUMP1("ip is deleted"); + return Qnil; } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return Qnil; + /* slave IP */ + return Qnil; } return lib_mainloop_watchdog(argc, argv, self); } @@ -980,10 +980,10 @@ lib_do_one_event_core(argc, argv, self, is_ip) int found_event; if (rb_scan_args(argc, argv, "01", &vflags) == 0) { - flags = TCL_ALL_EVENTS | TCL_DONT_WAIT; + flags = TCL_ALL_EVENTS | TCL_DONT_WAIT; } else { - Check_Type(vflags, T_FIXNUM); - flags = FIX2INT(vflags); + Check_Type(vflags, T_FIXNUM); + flags = FIX2INT(vflags); } if (rb_safe_level() >= 4 || (rb_safe_level() >=1 && OBJ_TAINTED(vflags))) { @@ -991,28 +991,28 @@ lib_do_one_event_core(argc, argv, self, is_ip) } if (is_ip) { - /* check IP */ - struct tcltkip *ptr = get_ip(self); + /* check IP */ + struct tcltkip *ptr = get_ip(self); - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return Qfalse; - } + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + return Qfalse; + } - if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - flags |= TCL_DONT_WAIT; - } + if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { + /* slave IP */ + flags |= TCL_DONT_WAIT; + } } /* found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); */ found_event = Tcl_DoOneEvent(flags); if (found_event) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -1058,18 +1058,18 @@ ip_set_exc_message(interp, exc) #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) enc = Qnil; if (RTEST(rb_ivar_defined(exc, ID_at_enc))) { - enc = rb_ivar_get(exc, ID_at_enc); + enc = rb_ivar_get(exc, ID_at_enc); } if (NIL_P(enc) && RTEST(rb_ivar_defined(msg, ID_at_enc))) { - enc = rb_ivar_get(msg, ID_at_enc); + enc = rb_ivar_get(msg, ID_at_enc); } if (NIL_P(enc)) { - encoding = (Tcl_Encoding)NULL; + encoding = (Tcl_Encoding)NULL; } else if (TYPE(enc) == T_STRING) { - encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); + encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); } else { - enc = rb_funcall(enc, ID_to_s, 0, 0); - encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); + enc = rb_funcall(enc, ID_to_s, 0, 0); + encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); } /* to avoid a garbled error message dialog */ @@ -1098,24 +1098,24 @@ TkStringValue(obj) { switch(TYPE(obj)) { case T_STRING: - return obj; + return obj; case T_NIL: - return rb_str_new2(""); + return rb_str_new2(""); case T_TRUE: - return rb_str_new2("1"); + return rb_str_new2("1"); case T_FALSE: - return rb_str_new2("0"); + return rb_str_new2("0"); case T_ARRAY: - return rb_funcall(obj, ID_join, 1, rb_str_new2(" ")); + return rb_funcall(obj, ID_join, 1, rb_str_new2(" ")); default: - if (rb_respond_to(obj, ID_to_s)) { - return rb_funcall(obj, ID_to_s, 0, 0); - } + if (rb_respond_to(obj, ID_to_s)) { + return rb_funcall(obj, ID_to_s, 0, 0); + } } return rb_funcall(obj, ID_inspect, 0, 0); @@ -1153,105 +1153,105 @@ ip_ruby_eval_body(arg) #if 0 ret = rb_rescue2(rb_eval_string, (VALUE)arg->string, - ip_ruby_eval_rescue, arg->failed, - rb_eStandardError, rb_eScriptError, rb_eSystemExit, - (VALUE)0); + ip_ruby_eval_rescue, arg->failed, + rb_eStandardError, rb_eScriptError, rb_eSystemExit, + (VALUE)0); #else rb_thread_critical = Qfalse; ret = rb_eval_string_protect(arg->string, &status); rb_thread_critical = Qtrue; if (status) { - char *errtype, *buf; - int errtype_len, len; - VALUE old_gc; - - old_gc = rb_gc_disable(); - - switch(status) { - case TAG_RETURN: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf); - free(buf); - break; - - case TAG_BREAK: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf); - free(buf); - break; - - case TAG_NEXT: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf); - free(buf); - break; - - case TAG_RETRY: - case TAG_REDO: - if (NIL_P(ruby_errinfo)) { - rb_jump_tag(status); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - case TAG_RAISE: - case TAG_FATAL: - if (NIL_P(ruby_errinfo)) { - RARRAY(arg->failed)->ptr[0] - = rb_exc_new2(rb_eException, "unknown exception"); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - case TAG_THROW: - if (NIL_P(ruby_errinfo)) { - rb_jump_tag(TAG_THROW); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - default: - buf = ALLOC_N(char, 256); - sprintf(buf, "unknown loncaljmp status %d", status); - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf); - free(buf); - break; - } - - if (old_gc == Qfalse) rb_gc_enable(); - - ret = Qnil; + char *errtype, *buf; + int errtype_len, len; + VALUE old_gc; + + old_gc = rb_gc_disable(); + + switch(status) { + case TAG_RETURN: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf); + free(buf); + break; + + case TAG_BREAK: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf); + free(buf); + break; + + case TAG_NEXT: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf); + free(buf); + break; + + case TAG_RETRY: + case TAG_REDO: + if (NIL_P(ruby_errinfo)) { + rb_jump_tag(status); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + case TAG_RAISE: + case TAG_FATAL: + if (NIL_P(ruby_errinfo)) { + RARRAY(arg->failed)->ptr[0] + = rb_exc_new2(rb_eException, "unknown exception"); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + case TAG_THROW: + if (NIL_P(ruby_errinfo)) { + rb_jump_tag(TAG_THROW); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + default: + buf = ALLOC_N(char, 256); + sprintf(buf, "unknown loncaljmp status %d", status); + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf); + free(buf); + break; + } + + if (old_gc == Qfalse) rb_gc_enable(); + + ret = Qnil; } #endif @@ -1292,8 +1292,8 @@ ip_ruby_eval(clientData, interp, argc, argv) /* ruby command has 1 arg. */ if (argc != 2) { - rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", - argc - 1); + rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", + argc - 1); } /* allocate */ @@ -1329,11 +1329,11 @@ ip_ruby_eval(clientData, interp, argc, argv) old_trapflag = rb_trap_immediate; #ifdef HAVE_NATIVETHREAD if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on ip_ruby_eval()"); + rb_bug("cross-thread violation on ip_ruby_eval()"); } #endif res = rb_ensure(ip_ruby_eval_body, (VALUE)arg, - ip_ruby_eval_ensure, INT2FIX(old_trapflag)); + ip_ruby_eval_ensure, INT2FIX(old_trapflag)); #if TCL_MAJOR_VERSION >= 8 free(arg->string); @@ -1348,93 +1348,93 @@ ip_ruby_eval(clientData, interp, argc, argv) volatile VALUE bt_ary; volatile VALUE backtrace; - DUMP1("(rb_eval_string result) failed"); + DUMP1("(rb_eval_string result) failed"); - Tcl_ResetResult(interp); + Tcl_ResetResult(interp); - res = RARRAY(exception)->ptr[0]; - eclass = rb_obj_class(res); + res = RARRAY(exception)->ptr[0]; + eclass = rb_obj_class(res); - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - DUMP1("set backtrace"); - if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) { - backtrace = rb_ary_join(bt_ary, rb_str_new2("\n")); - StringValue(backtrace); - Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr); - } + DUMP1("set backtrace"); + if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) { + backtrace = rb_ary_join(bt_ary, rb_str_new2("\n")); + StringValue(backtrace); + Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr); + } - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - if (eclass == eTkCallbackReturn) { - ip_set_exc_message(interp, res); - return TCL_RETURN; + if (eclass == eTkCallbackReturn) { + ip_set_exc_message(interp, res); + return TCL_RETURN; - } else if (eclass == eTkCallbackBreak) { - ip_set_exc_message(interp, res); - return TCL_BREAK; + } else if (eclass == eTkCallbackBreak) { + ip_set_exc_message(interp, res); + return TCL_BREAK; - } else if (eclass == eTkCallbackContinue) { - ip_set_exc_message(interp, res); - return TCL_CONTINUE; + } else if (eclass == eTkCallbackContinue) { + ip_set_exc_message(interp, res); + return TCL_CONTINUE; - } else if (eclass == rb_eSystemExit) { - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + } else if (eclass == rb_eSystemExit) { + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - /* Tcl_Eval(interp, "destroy ."); */ - if (Tk_GetNumMainWindows() > 0) { - Tk_Window main_win = Tk_MainWindow(interp); - if (main_win != (Tk_Window)NULL) { - Tk_DestroyWindow(main_win); - } - } + /* Tcl_Eval(interp, "destroy ."); */ + if (Tk_GetNumMainWindows() > 0) { + Tk_Window main_win = Tk_MainWindow(interp); + if (main_win != (Tk_Window)NULL) { + Tk_DestroyWindow(main_win); + } + } - /* StringValue(res); */ - res = rb_funcall(res, ID_message, 0, 0); + /* StringValue(res); */ + res = rb_funcall(res, ID_message, 0, 0); - Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL); + Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - rb_raise(rb_eSystemExit, RSTRING(res)->ptr); + rb_raise(rb_eSystemExit, RSTRING(res)->ptr); - } else if (rb_obj_is_kind_of(res, eLocalJumpError)) { - VALUE reason = rb_ivar_get(res, ID_at_reason); + } else if (rb_obj_is_kind_of(res, eLocalJumpError)) { + VALUE reason = rb_ivar_get(res, ID_at_reason); - if (TYPE(reason) != T_SYMBOL) { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } + if (TYPE(reason) != T_SYMBOL) { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } - if (SYM2ID(reason) == ID_return) { - ip_set_exc_message(interp, res); - return TCL_RETURN; + if (SYM2ID(reason) == ID_return) { + ip_set_exc_message(interp, res); + return TCL_RETURN; - } else if (SYM2ID(reason) == ID_break) { - ip_set_exc_message(interp, res); - return TCL_BREAK; + } else if (SYM2ID(reason) == ID_break) { + ip_set_exc_message(interp, res); + return TCL_BREAK; - } else if (SYM2ID(reason) == ID_next) { - ip_set_exc_message(interp, res); - return TCL_CONTINUE; + } else if (SYM2ID(reason) == ID_next) { + ip_set_exc_message(interp, res); + return TCL_CONTINUE; - } else { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } - } else { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } + } else { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } + } else { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } } /* result must be string or nil */ if (NIL_P(res)) { - DUMP1("(rb_eval_string result) nil"); - Tcl_ResetResult(interp); - return TCL_OK; + DUMP1("(rb_eval_string result) nil"); + Tcl_ResetResult(interp); + return TCL_OK; } /* copy result to the tcl interpreter */ @@ -1509,102 +1509,102 @@ ip_ruby_cmd_body(arg) #if 0 ret = rb_rescue2(ip_ruby_cmd_core, (VALUE)arg, - ip_ruby_cmd_rescue, arg->failed, - rb_eStandardError, rb_eScriptError, rb_eSystemExit, - (VALUE)0); + ip_ruby_cmd_rescue, arg->failed, + rb_eStandardError, rb_eScriptError, rb_eSystemExit, + (VALUE)0); #else ret = rb_protect(ip_ruby_cmd_core, (VALUE)arg, &status); if (status) { - char *errtype, *buf; - int errtype_len, len; - - old_gc = rb_gc_disable(); - - switch(status) { - case TAG_RETURN: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf); - free(buf); - break; - - case TAG_BREAK: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf); - free(buf); - break; - - case TAG_NEXT: - errtype = "LocalJumpError: "; - errtype_len = strlen(errtype); - len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; - buf = ALLOC_N(char, len + 1); - strncpy(buf, errtype, errtype_len); - strncpy(buf + errtype_len, - RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, - RSTRING(rb_obj_as_string(ruby_errinfo))->len); - *(buf + len) = 0; - - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf); - free(buf); - break; - - case TAG_RETRY: - case TAG_REDO: - if (NIL_P(ruby_errinfo)) { - rb_jump_tag(status); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - case TAG_RAISE: - case TAG_FATAL: - if (NIL_P(ruby_errinfo)) { - RARRAY(arg->failed)->ptr[0] - = rb_exc_new2(rb_eException, "unknown exception"); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - case TAG_THROW: - if (NIL_P(ruby_errinfo)) { - rb_jump_tag(TAG_THROW); - } else { - RARRAY(arg->failed)->ptr[0] = ruby_errinfo; - } - break; - - default: - buf = ALLOC_N(char, 256); - rb_warn(buf, "unknown loncaljmp status %d", status); - RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf); - free(buf); - break; - } - - if (old_gc == Qfalse) rb_gc_enable(); - - ret = Qnil; + char *errtype, *buf; + int errtype_len, len; + + old_gc = rb_gc_disable(); + + switch(status) { + case TAG_RETURN: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf); + free(buf); + break; + + case TAG_BREAK: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf); + free(buf); + break; + + case TAG_NEXT: + errtype = "LocalJumpError: "; + errtype_len = strlen(errtype); + len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; + buf = ALLOC_N(char, len + 1); + strncpy(buf, errtype, errtype_len); + strncpy(buf + errtype_len, + RSTRING(rb_obj_as_string(ruby_errinfo))->ptr, + RSTRING(rb_obj_as_string(ruby_errinfo))->len); + *(buf + len) = 0; + + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf); + free(buf); + break; + + case TAG_RETRY: + case TAG_REDO: + if (NIL_P(ruby_errinfo)) { + rb_jump_tag(status); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + case TAG_RAISE: + case TAG_FATAL: + if (NIL_P(ruby_errinfo)) { + RARRAY(arg->failed)->ptr[0] + = rb_exc_new2(rb_eException, "unknown exception"); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + case TAG_THROW: + if (NIL_P(ruby_errinfo)) { + rb_jump_tag(TAG_THROW); + } else { + RARRAY(arg->failed)->ptr[0] = ruby_errinfo; + } + break; + + default: + buf = ALLOC_N(char, 256); + rb_warn(buf, "unknown loncaljmp status %d", status); + RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf); + free(buf); + break; + } + + if (old_gc == Qfalse) rb_gc_enable(); + + ret = Qnil; } #endif @@ -1652,7 +1652,7 @@ ip_ruby_cmd(clientData, interp, argc, argv) VALUE old_gc; if (argc < 3) { - rb_raise(rb_eArgError, "too few arguments"); + rb_raise(rb_eArgError, "too few arguments"); } /* allocate */ @@ -1671,26 +1671,26 @@ ip_ruby_cmd(clientData, interp, argc, argv) #endif DUMP2("receiver:%s",str); if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) { - /* class | module | constant */ - receiver = rb_const_get(rb_cObject, rb_intern(str)); + /* class | module | constant */ + receiver = rb_const_get(rb_cObject, rb_intern(str)); } else if (str[0] == '$') { - /* global variable */ - receiver = rb_gv_get(str); + /* global variable */ + receiver = rb_gv_get(str); } else { - /* global variable omitted '$' */ - char *buf; + /* global variable omitted '$' */ + char *buf; - len = strlen(str); - buf = ALLOC_N(char, len + 2); - buf[0] = '$'; - strncpy(buf + 1, str, len); - buf[len + 1] = 0; - receiver = rb_gv_get(buf); - free(buf); + len = strlen(str); + buf = ALLOC_N(char, len + 2); + buf[0] = '$'; + strncpy(buf + 1, str, len); + buf[len + 1] = 0; + receiver = rb_gv_get(buf); + free(buf); } if (NIL_P(receiver)) { - rb_raise(rb_eArgError, "unknown class/module/global-variable '%s'", - str); + rb_raise(rb_eArgError, "unknown class/module/global-variable '%s'", + str); } /* get metrhod */ @@ -1705,12 +1705,12 @@ ip_ruby_cmd(clientData, interp, argc, argv) RARRAY(args)->len = 0; for(i = 3; i < argc; i++) { #if TCL_MAJOR_VERSION >= 8 - str = Tcl_GetStringFromObj(argv[i], &len); - DUMP2("arg:%s",str); - RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len); + str = Tcl_GetStringFromObj(argv[i], &len); + DUMP2("arg:%s",str); + RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len); #else /* TCL_MAJOR_VERSION < 8 */ - DUMP2("arg:%s",argv[i]); - RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]); + DUMP2("arg:%s",argv[i]); + RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]); #endif } @@ -1729,12 +1729,12 @@ ip_ruby_cmd(clientData, interp, argc, argv) old_trapflag = rb_trap_immediate; #ifdef HAVE_NATIVETHREAD if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on ip_ruby_cmd()"); + rb_bug("cross-thread violation on ip_ruby_cmd()"); } #endif res = rb_ensure(ip_ruby_cmd_body, (VALUE)arg, - ip_ruby_cmd_ensure, INT2FIX(old_trapflag)); + ip_ruby_cmd_ensure, INT2FIX(old_trapflag)); free(arg); @@ -1745,93 +1745,93 @@ ip_ruby_cmd(clientData, interp, argc, argv) volatile VALUE bt_ary; volatile VALUE backtrace; - DUMP1("(rb_eval_cmd result) failed"); + DUMP1("(rb_eval_cmd result) failed"); - Tcl_ResetResult(interp); + Tcl_ResetResult(interp); - res = RARRAY(exception)->ptr[0]; - eclass = rb_obj_class(res); + res = RARRAY(exception)->ptr[0]; + eclass = rb_obj_class(res); - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - DUMP1("set backtrace"); - if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) { - backtrace = rb_ary_join(bt_ary, rb_str_new2("\n")); - StringValue(backtrace); - Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr); - } + DUMP1("set backtrace"); + if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) { + backtrace = rb_ary_join(bt_ary, rb_str_new2("\n")); + StringValue(backtrace); + Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr); + } - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - if (eclass == eTkCallbackReturn) { - ip_set_exc_message(interp, res); - return TCL_RETURN; + if (eclass == eTkCallbackReturn) { + ip_set_exc_message(interp, res); + return TCL_RETURN; - } else if (eclass == eTkCallbackBreak) { - ip_set_exc_message(interp, res); - return TCL_BREAK; + } else if (eclass == eTkCallbackBreak) { + ip_set_exc_message(interp, res); + return TCL_BREAK; - } else if (eclass == eTkCallbackContinue) { - ip_set_exc_message(interp, res); - return TCL_CONTINUE; + } else if (eclass == eTkCallbackContinue) { + ip_set_exc_message(interp, res); + return TCL_CONTINUE; - } else if (eclass == rb_eSystemExit) { - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + } else if (eclass == rb_eSystemExit) { + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - /* Tcl_Eval(interp, "destroy ."); */ - if (Tk_GetNumMainWindows() > 0) { - Tk_Window main_win = Tk_MainWindow(interp); - if (main_win != (Tk_Window)NULL) { - Tk_DestroyWindow(main_win); - } - } + /* Tcl_Eval(interp, "destroy ."); */ + if (Tk_GetNumMainWindows() > 0) { + Tk_Window main_win = Tk_MainWindow(interp); + if (main_win != (Tk_Window)NULL) { + Tk_DestroyWindow(main_win); + } + } - /* StringValue(res); */ - res = rb_funcall(res, ID_message, 0, 0); + /* StringValue(res); */ + res = rb_funcall(res, ID_message, 0, 0); - Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL); + Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - rb_raise(rb_eSystemExit, RSTRING(res)->ptr); + rb_raise(rb_eSystemExit, RSTRING(res)->ptr); - } else if (rb_obj_is_kind_of(res, eLocalJumpError)) { - VALUE reason = rb_ivar_get(res, ID_at_reason); + } else if (rb_obj_is_kind_of(res, eLocalJumpError)) { + VALUE reason = rb_ivar_get(res, ID_at_reason); - if (TYPE(reason) != T_SYMBOL) { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } + if (TYPE(reason) != T_SYMBOL) { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } - if (SYM2ID(reason) == ID_return) { - ip_set_exc_message(interp, res); - return TCL_RETURN; + if (SYM2ID(reason) == ID_return) { + ip_set_exc_message(interp, res); + return TCL_RETURN; - } else if (SYM2ID(reason) == ID_break) { - ip_set_exc_message(interp, res); - return TCL_BREAK; + } else if (SYM2ID(reason) == ID_break) { + ip_set_exc_message(interp, res); + return TCL_BREAK; - } else if (SYM2ID(reason) == ID_next) { - ip_set_exc_message(interp, res); - return TCL_CONTINUE; + } else if (SYM2ID(reason) == ID_next) { + ip_set_exc_message(interp, res); + return TCL_CONTINUE; - } else { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } - } else { - ip_set_exc_message(interp, res); - return TCL_ERROR; - } + } else { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } + } else { + ip_set_exc_message(interp, res); + return TCL_ERROR; + } } /* result must be string or nil */ if (NIL_P(res)) { - DUMP1("(rb_eval_cmd result) nil"); - Tcl_ResetResult(interp); - return TCL_OK; + DUMP1("(rb_eval_cmd result) nil"); + Tcl_ResetResult(interp); + return TCL_OK; } @@ -1839,7 +1839,6 @@ ip_ruby_cmd(clientData, interp, argc, argv) thr_crit_bup = rb_thread_critical; rb_thread_critical = Qtrue; - old_gc = rb_gc_disable(); res = TkStringValue(res); @@ -1873,9 +1872,9 @@ ip_InterpExitCommand(clientData, interp, argc, argv) #endif { if (!Tcl_InterpDeleted(interp)) { - Tcl_Preserve(interp); - Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}"); - Tcl_Release(interp); + Tcl_Preserve(interp); + Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}"); + Tcl_Release(interp); } return TCL_OK; } @@ -1907,19 +1906,19 @@ ip_RubyExitCommand(clientData, interp, argc, argv) #endif if (rb_safe_level() >= 4) { - rb_raise(rb_eSecurityError, - "Insecure operation `exit' at level %d", - rb_safe_level()); + rb_raise(rb_eSecurityError, + "Insecure operation `exit' at level %d", + rb_safe_level()); } else if (Tcl_IsSafe(interp)) { - rb_raise(rb_eSecurityError, - "Insecure operation `exit' on a safe interpreter"); + rb_raise(rb_eSecurityError, + "Insecure operation `exit' on a safe interpreter"); #if 0 } else if (Tcl_GetMaster(interp) != (Tcl_Interp *)NULL) { - Tcl_Preserve(interp); - Tcl_Eval(interp, "interp eval {} {destroy .}"); - Tcl_Eval(interp, "interp delete {}"); - Tcl_Release(interp); - return TCL_OK; + Tcl_Preserve(interp); + Tcl_Eval(interp, "interp eval {} {destroy .}"); + Tcl_Eval(interp, "interp delete {}"); + Tcl_Release(interp); + return TCL_OK; #endif } @@ -1927,38 +1926,38 @@ ip_RubyExitCommand(clientData, interp, argc, argv) switch(argc) { case 1: - rb_exit(0); /* not return if succeed */ + rb_exit(0); /* not return if succeed */ - Tcl_AppendResult(interp, - "fail to call \"", cmd, "\"", (char *)NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, + "fail to call \"", cmd, "\"", (char *)NULL); + return TCL_ERROR; case 2: #if TCL_MAJOR_VERSION >= 8 - if (!Tcl_GetIntFromObj(interp, argv[1], &state)) { - return TCL_ERROR; - } - param = Tcl_GetString(argv[1]); + if (!Tcl_GetIntFromObj(interp, argv[1], &state)) { + return TCL_ERROR; + } + param = Tcl_GetString(argv[1]); #else /* TCL_MAJOR_VERSION < 8 */ - state = (int)strtol(argv[1], &endptr, 0); - if (endptr) { - Tcl_AppendResult(interp, - "expected integer but got \"", - argv[1], "\"", (char *)NULL); - } - param = argv[1]; -#endif - rb_exit(state); /* not return if succeed */ - - Tcl_AppendResult(interp, "fail to call \"", cmd, " ", - param, "\"", (char *)NULL); - return TCL_ERROR; + state = (int)strtol(argv[1], &endptr, 0); + if (endptr) { + Tcl_AppendResult(interp, + "expected integer but got \"", + argv[1], "\"", (char *)NULL); + } + param = argv[1]; +#endif + rb_exit(state); /* not return if succeed */ + + Tcl_AppendResult(interp, "fail to call \"", cmd, " ", + param, "\"", (char *)NULL); + return TCL_ERROR; default: - /* arguemnt error */ - Tcl_AppendResult(interp, - "wrong number of arguments: should be \"", - cmd, " ?returnCode?\"", (char *)NULL); - return TCL_ERROR; + /* arguemnt error */ + Tcl_AppendResult(interp, + "wrong number of arguments: should be \"", + cmd, " ?returnCode?\"", (char *)NULL); + return TCL_ERROR; } } @@ -1968,10 +1967,10 @@ ip_RubyExitCommand(clientData, interp, argc, argv) /**************************/ #if 0 /* - Disable the following "update" and "thread_update". Bcause, - they don't work in a callback-proc. After calling update in - a callback-proc, the callback proc never be worked. - If the problem will be fixed in the future, may enable the + Disable the following "update" and "thread_update". Bcause, + they don't work in a callback-proc. After calling update in + a callback-proc, the callback proc never be worked. + If the problem will be fixed in the future, may enable the functions. */ /*********************/ @@ -1979,7 +1978,7 @@ ip_RubyExitCommand(clientData, interp, argc, argv) /*********************/ #if TCL_MAJOR_VERSION >= 8 static int ip_rbUpdateObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rbUpdateObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2006,37 +2005,37 @@ ip_rbUpdateCommand(clientData, interp, objc, objv) DUMP1("Ruby's 'update' is called"); if (objc == 1) { - flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; + flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; } else if (objc == 2) { - if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, - "option", 0, &optionIndex) != TCL_OK) { - return TCL_ERROR; - } - switch ((enum updateOptions) optionIndex) { - case REGEXP_IDLETASKS: { - flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; - break; - } - default: { + if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, + "option", 0, &optionIndex) != TCL_OK) { + return TCL_ERROR; + } + switch ((enum updateOptions) optionIndex) { + case REGEXP_IDLETASKS: { + flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; + break; + } + default: { Tcl_Panic("ip_rbUpdateObjCmd: bad option index to UpdateOptions"); - } - } + } + } } else { #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]"); #else # if TCL_MAJOR_VERSION >= 8 Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - Tcl_GetStringFromObj(objv[0], &dummy), - " [ idletasks ]\"", - (char *) NULL); + Tcl_GetStringFromObj(objv[0], &dummy), + " [ idletasks ]\"", + (char *) NULL); # else /* TCL_MAJOR_VERSION < 8 */ Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - objv[0], " [ idletasks ]\"", (char *) NULL); + objv[0], " [ idletasks ]\"", (char *) NULL); # endif #endif - return TCL_ERROR; + return TCL_ERROR; } /* call eventloop */ @@ -2082,7 +2081,7 @@ rb_threadUpdateProc(clientData) #if TCL_MAJOR_VERSION >= 8 static int ip_rb_threadUpdateObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2091,7 +2090,7 @@ ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; #else /* TCL_MAJOR_VERSION < 8 */ static int ip_rb_threadUpdateCommand _((ClientData, Tcl_Interp *, int, - char *[])); + char *[])); static int ip_rb_threadUpdateCommand(clientData, interp, objc, objv) ClientData clientData; @@ -2115,19 +2114,19 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv) #define USE_TCL_UPDATE 0 #if TCL_MAJOR_VERSION >= 8 # if USE_TCL_UPDATE - DUMP1("call Tcl_UpdateObjCmd"); - return Tcl_UpdateObjCmd(clientData, interp, objc, objv); + DUMP1("call Tcl_UpdateObjCmd"); + return Tcl_UpdateObjCmd(clientData, interp, objc, objv); # else - DUMP1("call ip_rbUpdateObjCmd"); - return ip_rbUpdateObjCmd(clientData, interp, objc, objv); + DUMP1("call ip_rbUpdateObjCmd"); + return ip_rbUpdateObjCmd(clientData, interp, objc, objv); # endif #else /* TCL_MAJOR_VERSION < 8 */ # if USE_TCL_UPDATE - DUMP1("call ip_rbUpdateCommand"); - return Tcl_UpdateCommand(clientData, interp, objc, objv); + DUMP1("call ip_rbUpdateCommand"); + return Tcl_UpdateCommand(clientData, interp, objc, objv); # else - DUMP1("call ip_rbUpdateCommand"); - return ip_rbUpdateCommand(clientData, interp, objc, objv); + DUMP1("call ip_rbUpdateCommand"); + return ip_rbUpdateCommand(clientData, interp, objc, objv); # endif #endif } @@ -2135,37 +2134,37 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv) DUMP1("start Ruby's 'thread_update' body"); if (objc == 1) { - flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; + flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; } else if (objc == 2) { - if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, - "option", 0, &optionIndex) != TCL_OK) { - return TCL_ERROR; - } - switch ((enum updateOptions) optionIndex) { - case REGEXP_IDLETASKS: { - flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; - break; - } - default: { + if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, + "option", 0, &optionIndex) != TCL_OK) { + return TCL_ERROR; + } + switch ((enum updateOptions) optionIndex) { + case REGEXP_IDLETASKS: { + flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; + break; + } + default: { Tcl_Panic("ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions"); - } - } + } + } } else { #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]"); #else # if TCL_MAJOR_VERSION >= 8 Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - Tcl_GetStringFromObj(objv[0], &dummy), - " [ idletasks ]\"", - (char *) NULL); + Tcl_GetStringFromObj(objv[0], &dummy), + " [ idletasks ]\"", + (char *) NULL); # else /* TCL_MAJOR_VERSION < 8 */ Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - objv[0], " [ idletasks ]\"", (char *) NULL); + objv[0], " [ idletasks ]\"", (char *) NULL); # endif #endif - return TCL_ERROR; + return TCL_ERROR; } DUMP1("pass argument check"); @@ -2179,8 +2178,8 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv) Tcl_DoWhenIdle(rb_threadUpdateProc, (ClientData) param); while(!param->done) { - DUMP1("wait for complete idle proc"); - rb_thread_stop(); + DUMP1("wait for complete idle proc"); + rb_thread_stop(); } Tcl_Release(param); @@ -2197,7 +2196,7 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv) /***************************/ #if TCL_MAJOR_VERSION >= 8 static char *VwaitVarProc _((ClientData, Tcl_Interp *, - CONST84 char *,CONST84 char *, int)); + CONST84 char *,CONST84 char *, int)); static char * VwaitVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ @@ -2224,7 +2223,7 @@ VwaitVarProc(clientData, interp, name1, name2, flags) #if TCL_MAJOR_VERSION >= 8 static int ip_rbVwaitObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rbVwaitObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2253,22 +2252,22 @@ ip_rbVwaitCommand(clientData, interp, objc, objv) #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "name"); #else - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; #if TCL_MAJOR_VERSION >= 8 - /* nameString = Tcl_GetString(objv[0]); */ - nameString = Tcl_GetStringFromObj(objv[0], &dummy); + /* nameString = Tcl_GetString(objv[0]); */ + nameString = Tcl_GetStringFromObj(objv[0], &dummy); #else /* TCL_MAJOR_VERSION < 8 */ - nameString = objv[0]; + nameString = objv[0]; #endif Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - nameString, " name\"", (char *) NULL); + nameString, " name\"", (char *) NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } @@ -2285,22 +2284,22 @@ ip_rbVwaitCommand(clientData, interp, objc, objv) /* if (Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VwaitVarProc, (ClientData) &done) != TCL_OK) { + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + VwaitVarProc, (ClientData) &done) != TCL_OK) { return TCL_ERROR; } */ ret = Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VwaitVarProc, (ClientData) &done); + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + VwaitVarProc, (ClientData) &done); rb_thread_critical = thr_crit_bup; if (ret != TCL_OK) { #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[1]); + Tcl_DecrRefCount(objv[1]); #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } done = 0; @@ -2310,8 +2309,8 @@ ip_rbVwaitCommand(clientData, interp, objc, objv) rb_thread_critical = Qtrue; Tcl_UntraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VwaitVarProc, (ClientData) &done); + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + VwaitVarProc, (ClientData) &done); rb_thread_critical = thr_crit_bup; @@ -2322,18 +2321,18 @@ ip_rbVwaitCommand(clientData, interp, objc, objv) Tcl_ResetResult(interp); if (!foundEvent) { - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; Tcl_AppendResult(interp, "can't wait for variable \"", nameString, - "\": would wait forever", (char *) NULL); + "\": would wait forever", (char *) NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[1]); + Tcl_DecrRefCount(objv[1]); #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } @@ -2350,7 +2349,7 @@ ip_rbVwaitCommand(clientData, interp, objc, objv) /**************************/ #if TCL_MAJOR_VERSION >= 8 static char *WaitVariableProc _((ClientData, Tcl_Interp *, - CONST84 char *,CONST84 char *, int)); + CONST84 char *,CONST84 char *, int)); static char * WaitVariableProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ @@ -2360,7 +2359,7 @@ WaitVariableProc(clientData, interp, name1, name2, flags) int flags; /* Information about what happened. */ #else /* TCL_MAJOR_VERSION < 8 */ static char *WaitVariableProc _((ClientData, Tcl_Interp *, - char *, char *, int)); + char *, char *, int)); static char * WaitVariableProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ @@ -2407,7 +2406,7 @@ WaitWindowProc(clientData, eventPtr) #if TCL_MAJOR_VERSION >= 8 static int ip_rbTkWaitObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rbTkWaitObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2428,7 +2427,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv) Tk_Window window; int done, index; static CONST char *optionStrings[] = { "variable", "visibility", "window", - (char *) NULL }; + (char *) NULL }; enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW }; char *nameString; int ret, dummy; @@ -2442,24 +2441,24 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv) #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name"); #else - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; #if TCL_MAJOR_VERSION >= 8 Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - Tcl_GetStringFromObj(objv[0], &dummy), - " variable|visibility|window name\"", - (char *) NULL); + Tcl_GetStringFromObj(objv[0], &dummy), + " variable|visibility|window name\"", + (char *) NULL); #else /* TCL_MAJOR_VERSION < 8 */ Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - objv[0], " variable|visibility|window name\"", - (char *) NULL); + objv[0], " variable|visibility|window name\"", + (char *) NULL); #endif - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } @@ -2470,40 +2469,40 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv) /* if (Tcl_GetIndexFromObj(interp, objv[1], (CONST84 char **)optionStrings, - "option", 0, &index) != TCL_OK) { + "option", 0, &index) != TCL_OK) { return TCL_ERROR; } */ ret = Tcl_GetIndexFromObj(interp, objv[1], - (CONST84 char **)optionStrings, - "option", 0, &index); + (CONST84 char **)optionStrings, + "option", 0, &index); rb_thread_critical = thr_crit_bup; if (ret != TCL_OK) { - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } #else /* TCL_MAJOR_VERSION < 8 */ { - int c = objv[1][0]; - size_t length = strlen(objv[1]); - - if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0) - && (length >= 2)) { - index = TKWAIT_VARIABLE; - } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0) - && (length >= 2)) { - index = TKWAIT_VISIBILITY; - } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) { - index = TKWAIT_WINDOW; - } else { - Tcl_AppendResult(interp, "bad option \"", objv[1], - "\": must be variable, visibility, or window", - (char *) NULL); - Tcl_Release(interp); - return TCL_ERROR; - } + int c = objv[1][0]; + size_t length = strlen(objv[1]); + + if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0) + && (length >= 2)) { + index = TKWAIT_VARIABLE; + } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0) + && (length >= 2)) { + index = TKWAIT_VISIBILITY; + } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) { + index = TKWAIT_WINDOW; + } else { + Tcl_AppendResult(interp, "bad option \"", objv[1], + "\": must be variable, visibility, or window", + (char *) NULL); + Tcl_Release(interp); + return TCL_ERROR; + } } #endif @@ -2522,142 +2521,142 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv) switch ((enum options) index) { case TKWAIT_VARIABLE: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - /* - if (Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - WaitVariableProc, (ClientData) &done) != TCL_OK) { - return TCL_ERROR; - } - */ - ret = Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - WaitVariableProc, (ClientData) &done); - - rb_thread_critical = thr_crit_bup; - - if (ret != TCL_OK) { + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + /* + if (Tcl_TraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + WaitVariableProc, (ClientData) &done) != TCL_OK) { + return TCL_ERROR; + } + */ + ret = Tcl_TraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + WaitVariableProc, (ClientData) &done); + + rb_thread_critical = thr_crit_bup; + + if (ret != TCL_OK) { #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tcl_Release(interp); - return TCL_ERROR; - } - done = 0; - lib_eventloop_core(check_rootwidget_flag, 0, &done); + Tcl_Release(interp); + return TCL_ERROR; + } + done = 0; + lib_eventloop_core(check_rootwidget_flag, 0, &done); - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - Tcl_UntraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - WaitVariableProc, (ClientData) &done); + Tcl_UntraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + WaitVariableProc, (ClientData) &done); #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - break; + break; case TKWAIT_VISIBILITY: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - if (Tk_MainWindow(interp) == (Tk_Window)NULL) { - window = NULL; - } else { - window = Tk_NameToWindow(interp, nameString, tkwin); - } + if (Tk_MainWindow(interp) == (Tk_Window)NULL) { + window = NULL; + } else { + window = Tk_NameToWindow(interp, nameString, tkwin); + } - if (window == NULL) { - rb_thread_critical = thr_crit_bup; + if (window == NULL) { + rb_thread_critical = thr_crit_bup; #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tcl_Release(interp); - return TCL_ERROR; - } + Tcl_Release(interp); + return TCL_ERROR; + } - Tk_CreateEventHandler(window, - VisibilityChangeMask|StructureNotifyMask, - WaitVisibilityProc, (ClientData) &done); + Tk_CreateEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + WaitVisibilityProc, (ClientData) &done); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - done = 0; - lib_eventloop_core(check_rootwidget_flag, 0, &done); - if (done != 1) { - /* - * Note that we do not delete the event handler because it - * was deleted automatically when the window was destroyed. - */ - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + done = 0; + lib_eventloop_core(check_rootwidget_flag, 0, &done); + if (done != 1) { + /* + * Note that we do not delete the event handler because it + * was deleted automatically when the window was destroyed. + */ + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "window \"", nameString, - "\" was deleted before its visibility changed", - (char *) NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "window \"", nameString, + "\" was deleted before its visibility changed", + (char *) NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tcl_Release(interp); - return TCL_ERROR; - } + Tcl_Release(interp); + return TCL_ERROR; + } - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tk_DeleteEventHandler(window, - VisibilityChangeMask|StructureNotifyMask, - WaitVisibilityProc, (ClientData) &done); + Tk_DeleteEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + WaitVisibilityProc, (ClientData) &done); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - break; + break; case TKWAIT_WINDOW: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - if (Tk_MainWindow(interp) == (Tk_Window)NULL) { - window = NULL; - } else { - window = Tk_NameToWindow(interp, nameString, tkwin); - } + if (Tk_MainWindow(interp) == (Tk_Window)NULL) { + window = NULL; + } else { + window = Tk_NameToWindow(interp, nameString, tkwin); + } #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - if (window == NULL) { - rb_thread_critical = thr_crit_bup; - Tcl_Release(interp); - return TCL_ERROR; - } + if (window == NULL) { + rb_thread_critical = thr_crit_bup; + Tcl_Release(interp); + return TCL_ERROR; + } - Tk_CreateEventHandler(window, StructureNotifyMask, - WaitWindowProc, (ClientData) &done); + Tk_CreateEventHandler(window, StructureNotifyMask, + WaitWindowProc, (ClientData) &done); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - done = 0; - lib_eventloop_core(check_rootwidget_flag, 0, &done); - /* - * Note: there's no need to delete the event handler. It was - * deleted automatically when the window was destroyed. - */ - break; + done = 0; + lib_eventloop_core(check_rootwidget_flag, 0, &done); + /* + * Note: there's no need to delete the event handler. It was + * deleted automatically when the window was destroyed. + */ + break; } /* @@ -2680,7 +2679,7 @@ struct th_vwait_param { #if TCL_MAJOR_VERSION >= 8 static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *, - CONST84 char *,CONST84 char *, int)); + CONST84 char *,CONST84 char *, int)); static char * rb_threadVwaitProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ @@ -2690,7 +2689,7 @@ rb_threadVwaitProc(clientData, interp, name1, name2, flags) int flags; /* Information about what happened. */ #else /* TCL_MAJOR_VERSION < 8 */ static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *, - char *, char *, int)); + char *, char *, int)); static char * rb_threadVwaitProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ @@ -2703,9 +2702,9 @@ rb_threadVwaitProc(clientData, interp, name1, name2, flags) struct th_vwait_param *param = (struct th_vwait_param *) clientData; if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) { - param->done = -1; + param->done = -1; } else { - param->done = 1; + param->done = 1; } rb_thread_wakeup(param->thread); @@ -2748,7 +2747,7 @@ rb_threadWaitWindowProc(clientData, eventPtr) #if TCL_MAJOR_VERSION >= 8 static int ip_rb_threadVwaitObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2757,7 +2756,7 @@ ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; #else /* TCL_MAJOR_VERSION < 8 */ static int ip_rb_threadVwaitCommand _((ClientData, Tcl_Interp *, int, - char *[])); + char *[])); static int ip_rb_threadVwaitCommand(clientData, interp, objc, objv) ClientData clientData; @@ -2776,11 +2775,11 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv) if (rb_thread_alone() || eventloop_thread == current_thread) { #if TCL_MAJOR_VERSION >= 8 - DUMP1("call ip_rbVwaitObjCmd"); - return ip_rbVwaitObjCmd(clientData, interp, objc, objv); + DUMP1("call ip_rbVwaitObjCmd"); + return ip_rbVwaitObjCmd(clientData, interp, objc, objv); #else /* TCL_MAJOR_VERSION < 8 */ - DUMP1("call ip_rbVwaitCommand"); - return ip_rbVwaitCommand(clientData, interp, objc, objv); + DUMP1("call ip_rbVwaitCommand"); + return ip_rbVwaitCommand(clientData, interp, objc, objv); #endif } @@ -2790,22 +2789,22 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv) #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "name"); #else - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; #if TCL_MAJOR_VERSION >= 8 - /* nameString = Tcl_GetString(objv[0]); */ - nameString = Tcl_GetStringFromObj(objv[0], &dummy); + /* nameString = Tcl_GetString(objv[0]); */ + nameString = Tcl_GetStringFromObj(objv[0], &dummy); #else /* TCL_MAJOR_VERSION < 8 */ - nameString = objv[0]; + nameString = objv[0]; #endif Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - nameString, " name\"", (char *) NULL); + nameString, " name\"", (char *) NULL); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } @@ -2826,37 +2825,37 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv) /* if (Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param) != TCL_OK) { + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param) != TCL_OK) { return TCL_ERROR; } */ ret = Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param); + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param); rb_thread_critical = thr_crit_bup; if (ret != TCL_OK) { #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[1]); + Tcl_DecrRefCount(objv[1]); #endif - Tcl_Release(interp); + Tcl_Release(interp); return TCL_ERROR; } /* if (!param->done) { */ while(!param->done) { - rb_thread_stop(); + rb_thread_stop(); } thr_crit_bup = rb_thread_critical; rb_thread_critical = Qtrue; if (param->done > 0) { - Tcl_UntraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param); + Tcl_UntraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param); } Tcl_Release(param); @@ -2873,7 +2872,7 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv) #if TCL_MAJOR_VERSION >= 8 static int ip_rb_threadTkWaitObjCmd _((ClientData, Tcl_Interp *, int, - Tcl_Obj *CONST [])); + Tcl_Obj *CONST [])); static int ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv) ClientData clientData; @@ -2882,7 +2881,7 @@ ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; #else /* TCL_MAJOR_VERSION < 8 */ static int ip_rb_threadTkWaitCommand _((ClientData, Tcl_Interp *, int, - char *[])); + char *[])); static int ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) ClientData clientData; @@ -2896,7 +2895,7 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) Tk_Window window; int index; static CONST char *optionStrings[] = { "variable", "visibility", "window", - (char *) NULL }; + (char *) NULL }; enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW }; char *nameString; int ret, dummy; @@ -2907,11 +2906,11 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) if (rb_thread_alone() || eventloop_thread == current_thread) { #if TCL_MAJOR_VERSION >= 8 - DUMP1("call ip_rbTkWaitObjCmd"); - return ip_rbTkWaitObjCmd(clientData, interp, objc, objv); + DUMP1("call ip_rbTkWaitObjCmd"); + return ip_rbTkWaitObjCmd(clientData, interp, objc, objv); #else /* TCL_MAJOR_VERSION < 8 */ - DUMP1("call rb_VwaitCommand"); - return ip_rbTkWaitCommand(clientData, interp, objc, objv); + DUMP1("call rb_VwaitCommand"); + return ip_rbTkWaitCommand(clientData, interp, objc, objv); #endif } @@ -2922,25 +2921,25 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) #ifdef Tcl_WrongNumArgs Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name"); #else - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; #if TCL_MAJOR_VERSION >= 8 Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - Tcl_GetStringFromObj(objv[0], &dummy), - " variable|visibility|window name\"", - (char *) NULL); + Tcl_GetStringFromObj(objv[0], &dummy), + " variable|visibility|window name\"", + (char *) NULL); #else /* TCL_MAJOR_VERSION < 8 */ Tcl_AppendResult(interp, "wrong number of arguments: should be \"", - objv[0], " variable|visibility|window name\"", - (char *) NULL); + objv[0], " variable|visibility|window name\"", + (char *) NULL); #endif - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; #endif - Tcl_Release(tkwin); - Tcl_Release(interp); + Tcl_Release(tkwin); + Tcl_Release(interp); return TCL_ERROR; } @@ -2950,42 +2949,42 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) /* if (Tcl_GetIndexFromObj(interp, objv[1], (CONST84 char **)optionStrings, - "option", 0, &index) != TCL_OK) { + "option", 0, &index) != TCL_OK) { return TCL_ERROR; } */ ret = Tcl_GetIndexFromObj(interp, objv[1], - (CONST84 char **)optionStrings, - "option", 0, &index); + (CONST84 char **)optionStrings, + "option", 0, &index); rb_thread_critical = thr_crit_bup; if (ret != TCL_OK) { - Tcl_Release(tkwin); - Tcl_Release(interp); + Tcl_Release(tkwin); + Tcl_Release(interp); return TCL_ERROR; } #else /* TCL_MAJOR_VERSION < 8 */ { - int c = objv[1][0]; - size_t length = strlen(objv[1]); - - if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0) - && (length >= 2)) { - index = TKWAIT_VARIABLE; - } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0) - && (length >= 2)) { - index = TKWAIT_VISIBILITY; - } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) { - index = TKWAIT_WINDOW; - } else { - Tcl_AppendResult(interp, "bad option \"", objv[1], - "\": must be variable, visibility, or window", - (char *) NULL); - Tcl_Release(tkwin); - Tcl_Release(interp); - return TCL_ERROR; - } + int c = objv[1][0]; + size_t length = strlen(objv[1]); + + if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0) + && (length >= 2)) { + index = TKWAIT_VARIABLE; + } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0) + && (length >= 2)) { + index = TKWAIT_VISIBILITY; + } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) { + index = TKWAIT_WINDOW; + } else { + Tcl_AppendResult(interp, "bad option \"", objv[1], + "\": must be variable, visibility, or window", + (char *) NULL); + Tcl_Release(tkwin); + Tcl_Release(interp); + return TCL_ERROR; + } } #endif @@ -3009,196 +3008,196 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv) switch ((enum options) index) { case TKWAIT_VARIABLE: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - /* - if (Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param) != TCL_OK) { - return TCL_ERROR; - } - */ - ret = Tcl_TraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param); - - rb_thread_critical = thr_crit_bup; - - if (ret != TCL_OK) { - Tcl_Release(param); - Tcl_Free((char *)param); + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + /* + if (Tcl_TraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param) != TCL_OK) { + return TCL_ERROR; + } + */ + ret = Tcl_TraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param); + + rb_thread_critical = thr_crit_bup; + + if (ret != TCL_OK) { + Tcl_Release(param); + Tcl_Free((char *)param); #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tcl_Release(tkwin); - Tcl_Release(interp); - return TCL_ERROR; - } + Tcl_Release(tkwin); + Tcl_Release(interp); + return TCL_ERROR; + } - /* if (!param->done) { */ - while(!param->done) { - rb_thread_stop(); - } + /* if (!param->done) { */ + while(!param->done) { + rb_thread_stop(); + } - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - if (param->done > 0) { - Tcl_UntraceVar(interp, nameString, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - rb_threadVwaitProc, (ClientData) param); - } + if (param->done > 0) { + Tcl_UntraceVar(interp, nameString, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + rb_threadVwaitProc, (ClientData) param); + } #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - break; + break; case TKWAIT_VISIBILITY: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - if (Tk_MainWindow(interp) == (Tk_Window)NULL) { - window = NULL; - } else { - window = Tk_NameToWindow(interp, nameString, tkwin); - } + if (Tk_MainWindow(interp) == (Tk_Window)NULL) { + window = NULL; + } else { + window = Tk_NameToWindow(interp, nameString, tkwin); + } - if (window == NULL) { - rb_thread_critical = thr_crit_bup; + if (window == NULL) { + rb_thread_critical = thr_crit_bup; - Tcl_Release(param); - Tcl_Free((char *)param); + Tcl_Release(param); + Tcl_Free((char *)param); #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); -#endif - Tcl_Release(tkwin); - Tcl_Release(interp); - return TCL_ERROR; - } - Tcl_Preserve(window); - - Tk_CreateEventHandler(window, - VisibilityChangeMask|StructureNotifyMask, - rb_threadWaitVisibilityProc, (ClientData) param); - - rb_thread_critical = thr_crit_bup; - - /* if (!param->done) { */ - /* - while(!param->done) { - rb_thread_stop(); - } - */ - while(param->done != TKWAIT_MODE_VISIBILITY) { - if (param->done == TKWAIT_MODE_DESTROY) break; - rb_thread_stop(); - } - - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - - /* when a window is destroyed, no need to call Tk_DeleteEventHandler */ - if (param->done != TKWAIT_MODE_DESTROY) { - Tk_DeleteEventHandler(window, - VisibilityChangeMask|StructureNotifyMask, - rb_threadWaitVisibilityProc, - (ClientData) param); - } - - if (param->done != 1) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "window \"", nameString, - "\" was deleted before its visibility changed", - (char *) NULL); - - rb_thread_critical = thr_crit_bup; - - Tcl_Release(window); - - Tcl_Release(param); - Tcl_Free((char *)param); + Tcl_DecrRefCount(objv[2]); +#endif + Tcl_Release(tkwin); + Tcl_Release(interp); + return TCL_ERROR; + } + Tcl_Preserve(window); + + Tk_CreateEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + rb_threadWaitVisibilityProc, (ClientData) param); + + rb_thread_critical = thr_crit_bup; + + /* if (!param->done) { */ + /* + while(!param->done) { + rb_thread_stop(); + } + */ + while(param->done != TKWAIT_MODE_VISIBILITY) { + if (param->done == TKWAIT_MODE_DESTROY) break; + rb_thread_stop(); + } + + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + + /* when a window is destroyed, no need to call Tk_DeleteEventHandler */ + if (param->done != TKWAIT_MODE_DESTROY) { + Tk_DeleteEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + rb_threadWaitVisibilityProc, + (ClientData) param); + } + + if (param->done != 1) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "window \"", nameString, + "\" was deleted before its visibility changed", + (char *) NULL); + + rb_thread_critical = thr_crit_bup; + + Tcl_Release(window); + + Tcl_Release(param); + Tcl_Free((char *)param); #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - Tcl_Release(tkwin); - Tcl_Release(interp); - return TCL_ERROR; - } + Tcl_Release(tkwin); + Tcl_Release(interp); + return TCL_ERROR; + } - Tcl_Release(window); + Tcl_Release(window); #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - break; + break; case TKWAIT_WINDOW: - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - if (Tk_MainWindow(interp) == (Tk_Window)NULL) { - window = NULL; - } else { - window = Tk_NameToWindow(interp, nameString, tkwin); - } + if (Tk_MainWindow(interp) == (Tk_Window)NULL) { + window = NULL; + } else { + window = Tk_NameToWindow(interp, nameString, tkwin); + } #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(objv[2]); + Tcl_DecrRefCount(objv[2]); #endif - if (window == NULL) { - rb_thread_critical = thr_crit_bup; + if (window == NULL) { + rb_thread_critical = thr_crit_bup; - Tcl_Release(param); - Tcl_Free((char *)param); + Tcl_Release(param); + Tcl_Free((char *)param); - Tcl_Release(tkwin); - Tcl_Release(interp); - return TCL_ERROR; - } + Tcl_Release(tkwin); + Tcl_Release(interp); + return TCL_ERROR; + } - Tcl_Preserve(window); + Tcl_Preserve(window); - Tk_CreateEventHandler(window, StructureNotifyMask, - rb_threadWaitWindowProc, (ClientData) param); + Tk_CreateEventHandler(window, StructureNotifyMask, + rb_threadWaitWindowProc, (ClientData) param); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - /* if (!param->done) { */ - /* - while(!param->done) { - rb_thread_stop(); - } - */ - while(param->done != TKWAIT_MODE_DESTROY) { - rb_thread_stop(); - } + /* if (!param->done) { */ + /* + while(!param->done) { + rb_thread_stop(); + } + */ + while(param->done != TKWAIT_MODE_DESTROY) { + rb_thread_stop(); + } - Tcl_Release(window); + Tcl_Release(window); - /* when a window is destroyed, no need to call Tk_DeleteEventHandler - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + /* when a window is destroyed, no need to call Tk_DeleteEventHandler + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - Tk_DeleteEventHandler(window, StructureNotifyMask, - rb_threadWaitWindowProc, (ClientData) param); + Tk_DeleteEventHandler(window, StructureNotifyMask, + rb_threadWaitWindowProc, (ClientData) param); - rb_thread_critical = thr_crit_bup; - */ + rb_thread_critical = thr_crit_bup; + */ - break; + break; } /* end of 'switch' statement */ Tcl_Release(param); @@ -3251,12 +3250,12 @@ VALUE del_root(ip) Tk_Window main_win; if (!Tcl_InterpDeleted(ip)) { - Tcl_Preserve(ip); - while((main_win = Tk_MainWindow(ip)) != (Tk_Window)NULL) { - DUMP1("wait main_win is destroyed"); - Tk_DestroyWindow(main_win); - } - Tcl_Release(ip); + Tcl_Preserve(ip); + while((main_win = Tk_MainWindow(ip)) != (Tk_Window)NULL) { + DUMP1("wait main_win is destroyed"); + Tk_DestroyWindow(main_win); + } + Tcl_Release(ip); } return Qnil; } @@ -3276,52 +3275,52 @@ delete_slaves(ip) Tcl_Preserve(ip); if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) { - DUMP2("ip(%lx) cannot get a list of slave IPs", ip); - return; + DUMP2("ip(%lx) cannot get a list of slave IPs", ip); + return; } slave_list = Tcl_GetObjResult(ip); Tcl_IncrRefCount(slave_list); if (Tcl_ListObjLength((Tcl_Interp*)NULL, slave_list, &len) == TCL_ERROR) { - DUMP1("slave_list is not a list object"); - Tcl_DecrRefCount(slave_list); - return; + DUMP1("slave_list is not a list object"); + Tcl_DecrRefCount(slave_list); + return; } for(i = 0; i < len; i++) { - Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem); - Tcl_IncrRefCount(elem); + Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem); + Tcl_IncrRefCount(elem); - if (elem == (Tcl_Obj*)NULL) continue; + if (elem == (Tcl_Obj*)NULL) continue; - /* get slave */ - slave_name = Tcl_GetString(elem); - slave = Tcl_GetSlave(ip, slave_name); - if (slave == (Tcl_Interp*)NULL) { - DUMP2("slave \"%s\" does not exist", slave_name); - continue; - } + /* get slave */ + slave_name = Tcl_GetString(elem); + slave = Tcl_GetSlave(ip, slave_name); + if (slave == (Tcl_Interp*)NULL) { + DUMP2("slave \"%s\" does not exist", slave_name); + continue; + } - Tcl_DecrRefCount(elem); + Tcl_DecrRefCount(elem); - Tcl_Preserve(slave); + Tcl_Preserve(slave); - if (!Tcl_InterpDeleted(slave)) { - Tcl_Eval(slave, "foreach i [after info] { after cancel $i }"); - } + if (!Tcl_InterpDeleted(slave)) { + Tcl_Eval(slave, "foreach i [after info] { after cancel $i }"); + } - /* delete slaves of slave */ - delete_slaves(slave); + /* delete slaves of slave */ + delete_slaves(slave); - /* delete slave */ - del_root(slave); - while(!Tcl_InterpDeleted(slave)) { - DUMP1("wait ip is deleted"); - Tcl_DeleteInterp(slave); - } + /* delete slave */ + del_root(slave); + while(!Tcl_InterpDeleted(slave)) { + DUMP1("wait ip is deleted"); + Tcl_DeleteInterp(slave); + } - Tcl_Release(slave); + Tcl_Release(slave); } Tcl_DecrRefCount(slave_list); @@ -3338,47 +3337,47 @@ ip_free(ptr) DUMP2("free Tcl Interp %lx", ptr->ip); if (ptr) { - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - DUMP2("IP ref_count = %d", ptr->ref_count); + DUMP2("IP ref_count = %d", ptr->ref_count); - if (!Tcl_InterpDeleted(ptr->ip)) { - DUMP2("IP(%lx) is not deleted", ptr->ip); - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); + if (!Tcl_InterpDeleted(ptr->ip)) { + DUMP2("IP(%lx) is not deleted", ptr->ip); + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); - delete_slaves(ptr->ip); + delete_slaves(ptr->ip); - Tcl_ResetResult(ptr->ip); + Tcl_ResetResult(ptr->ip); - if (Tcl_GetCommandInfo(ptr->ip, finalize_hook_name, &info)) { - DUMP2("call finalize hook proc '%s'", finalize_hook_name); - Tcl_Eval(ptr->ip, finalize_hook_name); - } + if (Tcl_GetCommandInfo(ptr->ip, finalize_hook_name, &info)) { + DUMP2("call finalize hook proc '%s'", finalize_hook_name); + Tcl_Eval(ptr->ip, finalize_hook_name); + } - if (!Tcl_InterpDeleted(ptr->ip)) { - Tcl_Eval(ptr->ip, "foreach i [after info] {after cancel $i}"); - } + if (!Tcl_InterpDeleted(ptr->ip)) { + Tcl_Eval(ptr->ip, "foreach i [after info] {after cancel $i}"); + } - del_root(ptr->ip); + del_root(ptr->ip); - DUMP1("delete interp"); - while(!Tcl_InterpDeleted(ptr->ip)) { - DUMP1("wait ip is deleted"); - Tcl_DeleteInterp(ptr->ip); - } + DUMP1("delete interp"); + while(!Tcl_InterpDeleted(ptr->ip)) { + DUMP1("wait ip is deleted"); + Tcl_DeleteInterp(ptr->ip); + } - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + } - rbtk_release_ip(ptr); - DUMP2("IP ref_count = %d", ptr->ref_count); + rbtk_release_ip(ptr); + DUMP2("IP ref_count = %d", ptr->ref_count); - free(ptr); + free(ptr); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; } DUMP1("complete freeing Tcl Interp"); } @@ -3398,7 +3397,7 @@ ip_init(argc, argv, self) VALUE *argv; VALUE self; { - struct tcltkip *ptr; /* tcltkip data struct */ + struct tcltkip *ptr; /* tcltkip data struct */ VALUE argv0, opts; int cnt; int with_tk = 1; @@ -3406,7 +3405,7 @@ ip_init(argc, argv, self) /* security check */ if (ruby_safe_level >= 4) { - rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", ruby_safe_level); + rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", ruby_safe_level); } /* create object */ @@ -3421,7 +3420,7 @@ ip_init(argc, argv, self) DUMP1("Tcl_CreateInterp"); ptr->ip = Tcl_CreateInterp(); if (ptr->ip == NULL) { - rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter"); + rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter"); } rbtk_preserve_ip(ptr); @@ -3429,15 +3428,15 @@ ip_init(argc, argv, self) current_interp = ptr->ip; ptr->has_orig_exit - = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info)); + = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info)); /* from Tcl_AppInit() */ DUMP1("Tcl_Init"); if (Tcl_Init(ptr->ip) == TCL_ERROR) { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); #endif } @@ -3445,41 +3444,41 @@ ip_init(argc, argv, self) cnt = rb_scan_args(argc, argv, "02", &argv0, &opts); switch(cnt) { case 2: - /* options */ - if (NIL_P(opts) || opts == Qfalse) { - /* without Tk */ - with_tk = 0; - } else { - /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */ - Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY); - } + /* options */ + if (NIL_P(opts) || opts == Qfalse) { + /* without Tk */ + with_tk = 0; + } else { + /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */ + Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY); + } case 1: - /* argv0 */ - if (!NIL_P(argv0)) { - /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */ - Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), TCL_GLOBAL_ONLY); - } + /* argv0 */ + if (!NIL_P(argv0)) { + /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */ + Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), TCL_GLOBAL_ONLY); + } case 0: - /* no args */ - ; + /* no args */ + ; } /* from Tcl_AppInit() */ if (with_tk) { - DUMP1("Tk_Init"); - if (Tk_Init(ptr->ip) == TCL_ERROR) { + DUMP1("Tk_Init"); + if (Tk_Init(ptr->ip) == TCL_ERROR) { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); #endif - } - DUMP1("Tcl_StaticPackage(\"Tk\")"); + } + DUMP1("Tcl_StaticPackage(\"Tk\")"); #if TCL_MAJOR_VERSION >= 8 - Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit); + Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit); #else /* TCL_MAJOR_VERSION < 8 */ - Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, - (Tcl_PackageInitProc *) NULL); + Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, + (Tcl_PackageInitProc *) NULL); #endif } @@ -3491,75 +3490,75 @@ ip_init(argc, argv, self) #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"ruby\")"); Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateObjCommand(\"ruby_eval\")"); Tcl_CreateObjCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateObjCommand(\"ruby_cmd\")"); Tcl_CreateObjCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"ruby\")"); Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateCommand(\"ruby_eval\")"); Tcl_CreateCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateCommand(\"ruby_cmd\")"); Tcl_CreateCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); + (Tcl_CmdDeleteProc *)NULL); #endif /* add 'interp_exit', 'ruby_exit' and replace 'exit' command */ #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"interp_exit\")"); Tcl_CreateObjCommand(ptr->ip, "interp_exit", ip_InterpExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateObjCommand(\"ruby_exit\")"); Tcl_CreateObjCommand(ptr->ip, "ruby_exit", ip_RubyExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\""); Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"interp_exit\")"); Tcl_CreateCommand(ptr->ip, "interp_exit", ip_InterpExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateCommand(\"ruby_exit\")"); Tcl_CreateCommand(ptr->ip, "ruby_exit", ip_RubyExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\""); Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif #if 0 /* - Disable the following "update" and "thread_update". Bcause, - they don't work in a callback-proc. After calling update in - a callback-proc, the callback proc never be worked. - If the problem will be fixed in the future, may enable the + Disable the following "update" and "thread_update". Bcause, + they don't work in a callback-proc. After calling update in + a callback-proc, the callback proc never be worked. + If the problem will be fixed in the future, may enable the functions. */ /* replace 'update' command */ # if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"update\")"); Tcl_CreateObjCommand(ptr->ip, "update", ip_rbUpdateObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); # else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"update\")"); Tcl_CreateCommand(ptr->ip, "update", ip_rbUpdateCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); # endif /* add 'thread_update' command */ # if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"thread_update\")"); Tcl_CreateObjCommand(ptr->ip, "thread_update", ip_rb_threadUpdateObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); # else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"thread_update\")"); Tcl_CreateCommand(ptr->ip, "thread_update", ip_rb_threadUpdateCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); # endif #endif @@ -3567,44 +3566,44 @@ ip_init(argc, argv, self) #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"vwait\")"); Tcl_CreateObjCommand(ptr->ip, "vwait", ip_rbVwaitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"vwait\")"); Tcl_CreateCommand(ptr->ip, "vwait", ip_rbVwaitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif /* replace 'tkwait' command */ #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"tkwait\")"); Tcl_CreateObjCommand(ptr->ip, "tkwait", ip_rbTkWaitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"tkwait\")"); Tcl_CreateCommand(ptr->ip, "tkwait", ip_rbTkWaitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif /* add 'thread_vwait' command */ #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"thread_vwait\")"); Tcl_CreateObjCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"thread_vwait\")"); Tcl_CreateCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif /* add 'thread_tkwait' command */ #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"thread_tkwait\")"); Tcl_CreateObjCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"thread_tkwait\")"); Tcl_CreateCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif Tk_Release((ClientData)mainWin); @@ -3628,15 +3627,15 @@ ip_create_slave(argc, argv, self) /* safe-mode check */ if (rb_scan_args(argc, argv, "11", &name, &safemode) == 1) { - safemode = Qfalse; + safemode = Qfalse; } if (Tcl_IsSafe(master->ip) == 1) { - safe = 1; + safe = 1; } else if (safemode == Qfalse || NIL_P(safemode)) { - safe = 0; - rb_secure(4); + safe = 0; + rb_secure(4); } else { - safe = 1; + safe = 1; } thr_crit_bup = rb_thread_critical; @@ -3644,9 +3643,9 @@ ip_create_slave(argc, argv, self) /* ip is deleted? */ if (Tcl_InterpDeleted(master->ip)) { - DUMP1("master-ip is deleted"); - rb_thread_critical = thr_crit_bup; - rb_raise(rb_eRuntimeError, "deleted master cannot create a new slave interpreter"); + DUMP1("master-ip is deleted"); + rb_thread_critical = thr_crit_bup; + rb_raise(rb_eRuntimeError, "deleted master cannot create a new slave interpreter"); } /* create slave-ip */ @@ -3656,24 +3655,24 @@ ip_create_slave(argc, argv, self) slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe); if (slave->ip == NULL) { - rb_thread_critical = thr_crit_bup; - rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter"); + rb_thread_critical = thr_crit_bup; + rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter"); } rbtk_preserve_ip(slave); slave->has_orig_exit - = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info)); + = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info)); /* replace 'exit' command --> 'interp_exit' command */ mainWin = Tk_MainWindow(slave->ip); #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\""); Tcl_CreateObjCommand(slave->ip, "exit", ip_InterpExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\""); Tcl_CreateCommand(slave->ip, "exit", ip_InterpExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif rb_thread_critical = thr_crit_bup; @@ -3691,15 +3690,15 @@ ip_make_safe(self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); #endif } @@ -3710,11 +3709,11 @@ ip_make_safe(self) #if TCL_MAJOR_VERSION >= 8 DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\""); Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\""); Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif return self; @@ -3729,14 +3728,14 @@ ip_is_safe_p(self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } if (Tcl_IsSafe(ptr->ip)) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -3749,14 +3748,14 @@ ip_allow_ruby_exit_p(self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } if (ptr->allow_ruby_exit) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -3772,42 +3771,42 @@ ip_allow_ruby_exit_set(self, val) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } if (Tcl_IsSafe(ptr->ip)) { - rb_raise(rb_eSecurityError, - "insecure operation on a safe interpreter"); + rb_raise(rb_eSecurityError, + "insecure operation on a safe interpreter"); } mainWin = Tk_MainWindow(ptr->ip); if (RTEST(val)) { - ptr->allow_ruby_exit = 1; + ptr->allow_ruby_exit = 1; #if TCL_MAJOR_VERSION >= 8 - DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\""); - Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\""); + Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd, + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ - DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\""); - Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\""); + Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand, + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif - return Qtrue; + return Qtrue; } else { - ptr->allow_ruby_exit = 0; + ptr->allow_ruby_exit = 0; #if TCL_MAJOR_VERSION >= 8 - DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\""); - Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\""); + Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd, + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #else /* TCL_MAJOR_VERSION < 8 */ - DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\""); - Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand, - (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); + DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\""); + Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand, + (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL); #endif - return Qfalse; + return Qfalse; } } @@ -3822,15 +3821,15 @@ ip_delete(self) rbtk_preserve_ip(ptr); if (!Tcl_InterpDeleted(ptr->ip)) { - Tcl_Eval(ptr->ip, "foreach i [after info] { after cancel $i }"); + Tcl_Eval(ptr->ip, "foreach i [after info] { after cancel $i }"); } del_root(ptr->ip); DUMP1("delete interp"); while(!Tcl_InterpDeleted(ptr->ip)) { - DUMP1("wait ip is deleted"); - Tcl_DeleteInterp(ptr->ip); + DUMP1("wait ip is deleted"); + Tcl_DeleteInterp(ptr->ip); } /* Tcl_Release(ptr->ip); */ @@ -3847,9 +3846,9 @@ ip_is_deleted_p(self) struct tcltkip *ptr = get_ip(self); if (Tcl_InterpDeleted(ptr->ip)) { - return Qtrue; + return Qtrue; } else { - return Qfalse; + return Qfalse; } } @@ -3903,14 +3902,14 @@ ip_get_result_string_obj(interp) rb_thread_critical = Qtrue; if (Tcl_GetCharLength(retobj) != Tcl_UniCharLen(Tcl_GetUnicode(retobj))) { - /* possibly binary string */ - s = Tcl_GetByteArrayFromObj(retobj, &len); - strval = rb_tainted_str_new(s, len); - rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); + /* possibly binary string */ + s = Tcl_GetByteArrayFromObj(retobj, &len); + strval = rb_tainted_str_new(s, len); + rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); } else { - /* possibly text string */ - s = Tcl_GetStringFromObj(retobj, &len); - strval = rb_tainted_str_new(s, len); + /* possibly text string */ + s = Tcl_GetStringFromObj(retobj, &len); + strval = rb_tainted_str_new(s, len); } rb_thread_critical = thr_crit_bup; @@ -3951,17 +3950,17 @@ ip_eval_real(self, cmd_str, cmd_len) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - Tcl_DecrRefCount(cmd); - rb_thread_critical = thr_crit_bup; - ptr->return_value = TCL_OK; - return rb_tainted_str_new2(""); + DUMP1("ip is deleted"); + Tcl_DecrRefCount(cmd); + rb_thread_critical = thr_crit_bup; + ptr->return_value = TCL_OK; + return rb_tainted_str_new2(""); } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - - ptr->return_value = Tcl_EvalObj(ptr->ip, cmd); - /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */ + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + + ptr->return_value = Tcl_EvalObj(ptr->ip, cmd); + /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */ } Tcl_DecrRefCount(cmd); @@ -3969,14 +3968,14 @@ ip_eval_real(self, cmd_str, cmd_len) } if (ptr->return_value == TCL_ERROR) { - volatile VALUE exc; - exc = create_ip_exc(self, rb_eRuntimeError, - "%s", Tcl_GetStringResult(ptr->ip)); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); + volatile VALUE exc; + exc = create_ip_exc(self, rb_eRuntimeError, + "%s", Tcl_GetStringResult(ptr->ip)); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); } DUMP2("(TCL_Eval result) %d", ptr->return_value); @@ -3992,22 +3991,22 @@ ip_eval_real(self, cmd_str, cmd_len) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - ptr->return_value = TCL_OK; - return rb_tainted_str_new2(""); + DUMP1("ip is deleted"); + ptr->return_value = TCL_OK; + return rb_tainted_str_new2(""); } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ptr->return_value = Tcl_Eval(ptr->ip, cmd_str); - /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */ + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ptr->return_value = Tcl_Eval(ptr->ip, cmd_str); + /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */ } if (ptr->return_value == TCL_ERROR) { - volatile VALUE exc; - exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_exc_raise(exc); + volatile VALUE exc; + exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_exc_raise(exc); } DUMP2("(TCL_Eval result) %d", ptr->return_value); @@ -4047,10 +4046,10 @@ eval_queue_handler(evPtr, flags) DUMP2("added by thread : %lx", q->thread); if (*(q->done)) { - DUMP1("processed by another event-loop"); - return 0; + DUMP1("processed by another event-loop"); + return 0; } else { - DUMP1("process it on current event-loop"); + DUMP1("process it on current event-loop"); } /* process it */ @@ -4059,19 +4058,19 @@ eval_queue_handler(evPtr, flags) /* check safe-level */ if (rb_safe_level() != q->safe_level) { #ifdef HAVE_NATIVETHREAD - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on eval_queue_handler()"); - } -#endif - /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */ - q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q); - ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat), - ID_call, 0); - rb_gc_force_recycle(q_dat); + if (!is_ruby_native_thread()) { + rb_bug("cross-thread violation on eval_queue_handler()"); + } +#endif + /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */ + q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q); + ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat), + ID_call, 0); + rb_gc_force_recycle(q_dat); } else { - DUMP2("call eval_real (for caller thread:%lx)", q->thread); - DUMP2("call eval_real (current thread:%lx)", rb_thread_current()); - ret = ip_eval_real(q->interp, q->str, q->len); + DUMP2("call eval_real (for caller thread:%lx)", q->thread); + DUMP2("call eval_real (current thread:%lx)", rb_thread_current()); + ret = ip_eval_real(q->interp, q->str, q->len); } /* set result */ @@ -4111,16 +4110,16 @@ ip_eval(self, str) rb_thread_critical = thr_crit_bup; if (eventloop_thread == 0 || current == eventloop_thread) { - if (eventloop_thread) { - DUMP2("eval from current eventloop %lx", current); - } else { - DUMP2("eval from thread:%lx but no eventloop", current); - } - result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len); - if (rb_obj_is_kind_of(result, rb_eException)) { - rb_exc_raise(result); - } - return result; + if (eventloop_thread) { + DUMP2("eval from current eventloop %lx", current); + } else { + DUMP2("eval from thread:%lx but no eventloop", current); + } + result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len); + if (rb_obj_is_kind_of(result, rb_eException)) { + rb_exc_raise(result); + } + return result; } DUMP2("eval from thread %lx (NOT current eventloop)", current); @@ -4165,7 +4164,7 @@ ip_eval(self, str) /* wait for the handler to be processed */ DUMP2("wait for handler (current thread:%lx)", current); while(*alloc_done >= 0) { - rb_thread_stop(); + rb_thread_stop(); } DUMP2("back from handler (current thread:%lx)", current); @@ -4177,7 +4176,7 @@ ip_eval(self, str) Tcl_Release(evq); if (rb_obj_is_kind_of(ret, rb_eException)) { - rb_exc_raise(ret); + rb_exc_raise(ret); } return ret; @@ -4197,8 +4196,8 @@ lib_restart(self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } thr_crit_bup = rb_thread_critical; @@ -4228,31 +4227,31 @@ lib_restart(self) /* execute Tk_Init of Tk_SafeInit */ #if TCL_MAJOR_VERSION >= 8 if (Tcl_IsSafe(ptr->ip)) { - DUMP1("Tk_SafeInit"); - if (Tk_SafeInit(ptr->ip) == TCL_ERROR) { - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + DUMP1("Tk_SafeInit"); + if (Tk_SafeInit(ptr->ip) == TCL_ERROR) { + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } } else { - DUMP1("Tk_Init"); - if (Tk_Init(ptr->ip) == TCL_ERROR) { - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + DUMP1("Tk_Init"); + if (Tk_Init(ptr->ip) == TCL_ERROR) { + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } } #else /* TCL_MAJOR_VERSION < 8 */ DUMP1("Tk_Init"); if (Tk_Init(ptr->ip) == TCL_ERROR) { - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_exc_raise(exc); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_exc_raise(exc); } #endif @@ -4275,13 +4274,13 @@ ip_restart(self) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - rb_raise(rb_eRuntimeError, "interpreter is deleted"); + DUMP1("ip is deleted"); + rb_raise(rb_eRuntimeError, "interpreter is deleted"); } if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) { - /* slave IP */ - return Qnil; + /* slave IP */ + return Qnil; } return lib_restart(self); } @@ -4304,76 +4303,76 @@ lib_toUTF8_core(ip_obj, src, encodename) int thr_crit_bup; if (NIL_P(ip_obj)) { - interp = (Tcl_Interp *)NULL; + interp = (Tcl_Interp *)NULL; } else { - interp = get_ip(ip_obj)->ip; + interp = get_ip(ip_obj)->ip; - /* ip is deleted? */ - if (Tcl_InterpDeleted(interp)) { - DUMP1("ip is deleted"); - interp = (Tcl_Interp *)NULL; - } + /* ip is deleted? */ + if (Tcl_InterpDeleted(interp)) { + DUMP1("ip is deleted"); + interp = (Tcl_Interp *)NULL; + } } thr_crit_bup = rb_thread_critical; rb_thread_critical = Qtrue; if (NIL_P(encodename)) { - if (TYPE(str) == T_STRING) { - volatile VALUE enc; - - enc = Qnil; - if (RTEST(rb_ivar_defined(str, ID_at_enc))) { - enc = rb_ivar_get(str, ID_at_enc); - } - if (NIL_P(enc)) { - if (NIL_P(ip_obj)) { - encoding = (Tcl_Encoding)NULL; - } else { - if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { - enc = rb_ivar_get(ip_obj, ID_at_enc); - } - if (NIL_P(enc)) { - encoding = (Tcl_Encoding)NULL; - } else { - StringValue(enc); - encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); - if (encoding == (Tcl_Encoding)NULL) { - rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); - } - } - } - } else { - StringValue(enc); - if (strcmp(RSTRING(enc)->ptr, "binary") == 0) { - rb_thread_critical = thr_crit_bup; - return str; - } - encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); - if (encoding == (Tcl_Encoding)NULL) { - rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); - } - } - } else { - encoding = (Tcl_Encoding)NULL; - } + if (TYPE(str) == T_STRING) { + volatile VALUE enc; + + enc = Qnil; + if (RTEST(rb_ivar_defined(str, ID_at_enc))) { + enc = rb_ivar_get(str, ID_at_enc); + } + if (NIL_P(enc)) { + if (NIL_P(ip_obj)) { + encoding = (Tcl_Encoding)NULL; + } else { + if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { + enc = rb_ivar_get(ip_obj, ID_at_enc); + } + if (NIL_P(enc)) { + encoding = (Tcl_Encoding)NULL; + } else { + StringValue(enc); + encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); + if (encoding == (Tcl_Encoding)NULL) { + rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); + } + } + } + } else { + StringValue(enc); + if (strcmp(RSTRING(enc)->ptr, "binary") == 0) { + rb_thread_critical = thr_crit_bup; + return str; + } + encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); + if (encoding == (Tcl_Encoding)NULL) { + rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); + } + } + } else { + encoding = (Tcl_Encoding)NULL; + } } else { - StringValue(encodename); - encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr); - if (encoding == (Tcl_Encoding)NULL) { - /* - rb_warning("unknown encoding name '%s'", - RSTRING(encodename)->ptr); - */ - rb_raise(rb_eArgError, "unknown encoding name '%s'", - RSTRING(encodename)->ptr); - } + StringValue(encodename); + encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr); + if (encoding == (Tcl_Encoding)NULL) { + /* + rb_warning("unknown encoding name '%s'", + RSTRING(encodename)->ptr); + */ + rb_raise(rb_eArgError, "unknown encoding name '%s'", + RSTRING(encodename)->ptr); + } } StringValue(str); if (!RSTRING(str)->len) { - rb_thread_critical = thr_crit_bup; - return str; + rb_thread_critical = thr_crit_bup; + return str; } buf = ALLOC_N(char,(RSTRING(str)->len)+1); @@ -4391,7 +4390,7 @@ lib_toUTF8_core(ip_obj, src, encodename) if (taint_flag) OBJ_TAINT(str); if (encoding != (Tcl_Encoding)NULL) { - Tcl_FreeEncoding(encoding); + Tcl_FreeEncoding(encoding); } Tcl_DStringFree(&dstr); @@ -4412,7 +4411,7 @@ lib_toUTF8(argc, argv, self) VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { - encodename = Qnil; + encodename = Qnil; } return lib_toUTF8_core(Qnil, str, encodename); } @@ -4426,7 +4425,7 @@ ip_toUTF8(argc, argv, self) VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { - encodename = Qnil; + encodename = Qnil; } return lib_toUTF8_core(self, str, encodename); } @@ -4448,82 +4447,82 @@ lib_fromUTF8_core(ip_obj, src, encodename) int thr_crit_bup; if (NIL_P(ip_obj)) { - interp = (Tcl_Interp *)NULL; + interp = (Tcl_Interp *)NULL; } else { - interp = get_ip(ip_obj)->ip; + interp = get_ip(ip_obj)->ip; } thr_crit_bup = rb_thread_critical; rb_thread_critical = Qtrue; if (NIL_P(encodename)) { - volatile VALUE enc; - - if (TYPE(str) == T_STRING) { - enc = Qnil; - if (RTEST(rb_ivar_defined(str, ID_at_enc))) { - enc = rb_ivar_get(str, ID_at_enc); - } - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - rb_thread_critical = thr_crit_bup; - return str; - } - } - - if (NIL_P(ip_obj)) { - encoding = (Tcl_Encoding)NULL; - } else { - enc = Qnil; - if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { - enc = rb_ivar_get(ip_obj, ID_at_enc); - } - if (NIL_P(enc)) { - encoding = (Tcl_Encoding)NULL; - } else { - StringValue(enc); - encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); - if (encoding == (Tcl_Encoding)NULL) { - rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); - } else { - encodename = rb_obj_dup(enc); - } - } - } + volatile VALUE enc; + + if (TYPE(str) == T_STRING) { + enc = Qnil; + if (RTEST(rb_ivar_defined(str, ID_at_enc))) { + enc = rb_ivar_get(str, ID_at_enc); + } + if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { + rb_thread_critical = thr_crit_bup; + return str; + } + } + + if (NIL_P(ip_obj)) { + encoding = (Tcl_Encoding)NULL; + } else { + enc = Qnil; + if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { + enc = rb_ivar_get(ip_obj, ID_at_enc); + } + if (NIL_P(enc)) { + encoding = (Tcl_Encoding)NULL; + } else { + StringValue(enc); + encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr); + if (encoding == (Tcl_Encoding)NULL) { + rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr); + } else { + encodename = rb_obj_dup(enc); + } + } + } } else { - StringValue(encodename); - - if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) { - char *s; - int len; - - s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr, - RSTRING(str)->len), - &len); - str = rb_tainted_str_new(s, len); - rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary")); - - rb_thread_critical = thr_crit_bup; - return str; - } - - encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr); - if (encoding == (Tcl_Encoding)NULL) { - /* - rb_warning("unknown encoding name '%s'", - RSTRING(encodename)->ptr); - encodename = Qnil; - */ - rb_raise(rb_eArgError, "unknown encoding name '%s'", - RSTRING(encodename)->ptr); - } + StringValue(encodename); + + if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) { + char *s; + int len; + + s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr, + RSTRING(str)->len), + &len); + str = rb_tainted_str_new(s, len); + rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary")); + + rb_thread_critical = thr_crit_bup; + return str; + } + + encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr); + if (encoding == (Tcl_Encoding)NULL) { + /* + rb_warning("unknown encoding name '%s'", + RSTRING(encodename)->ptr); + encodename = Qnil; + */ + rb_raise(rb_eArgError, "unknown encoding name '%s'", + RSTRING(encodename)->ptr); + } } StringValue(str); if (RSTRING(str)->len == 0) { - rb_thread_critical = thr_crit_bup; - return rb_tainted_str_new2(""); + rb_thread_critical = thr_crit_bup; + return rb_tainted_str_new2(""); } buf = ALLOC_N(char,strlen(RSTRING(str)->ptr)+1); @@ -4542,7 +4541,7 @@ lib_fromUTF8_core(ip_obj, src, encodename) if (taint_flag) OBJ_TAINT(str); if (encoding != (Tcl_Encoding)NULL) { - Tcl_FreeEncoding(encoding); + Tcl_FreeEncoding(encoding); } Tcl_DStringFree(&dstr); @@ -4563,7 +4562,7 @@ lib_fromUTF8(argc, argv, self) VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { - encodename = Qnil; + encodename = Qnil; } return lib_fromUTF8_core(Qnil, str, encodename); } @@ -4577,7 +4576,7 @@ ip_fromUTF8(argc, argv, self) VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { - encodename = Qnil; + encodename = Qnil; } return lib_fromUTF8_core(self, str, encodename); } @@ -4596,7 +4595,7 @@ lib_UTF_backslash_core(self, str, all_bs) StringValue(str); if (!RSTRING(str)->len) { - return str; + return str; } thr_crit_bup = rb_thread_critical; @@ -4610,12 +4609,12 @@ lib_UTF_backslash_core(self, str, all_bs) ptr = src_buf; while(RSTRING(str)->len > ptr - src_buf) { - if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) { - dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len)); - ptr += read_len; - } else { - *(dst_buf + (dst_len++)) = *(ptr++); - } + if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) { + dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len)); + ptr += read_len; + } else { + *(dst_buf + (dst_len++)) = *(ptr++); + } } str = rb_str_new(dst_buf, dst_len); @@ -4686,28 +4685,28 @@ ip_invoke_core(interp, argc, argv) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); } /* map from the command name to a C procedure */ DUMP2("call Tcl_GetCommandInfo, %s", cmd); if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) { - DUMP1("error Tcl_GetCommandInfo"); - /* if (event_loop_abort_on_exc || cmd[0] != '.') { */ - if (event_loop_abort_on_exc > 0) { - /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/ - return create_ip_exc(interp, rb_eNameError, - "invalid command name `%s'", cmd); - } else { - if (event_loop_abort_on_exc < 0) { - rb_warning("invalid command name `%s' (ignore)", cmd); - } else { - rb_warn("invalid command name `%s' (ignore)", cmd); - } - Tcl_ResetResult(ptr->ip); - return rb_tainted_str_new2(""); - } + DUMP1("error Tcl_GetCommandInfo"); + /* if (event_loop_abort_on_exc || cmd[0] != '.') { */ + if (event_loop_abort_on_exc > 0) { + /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/ + return create_ip_exc(interp, rb_eNameError, + "invalid command name `%s'", cmd); + } else { + if (event_loop_abort_on_exc < 0) { + rb_warning("invalid command name `%s' (ignore)", cmd); + } else { + rb_warn("invalid command name `%s' (ignore)", cmd); + } + Tcl_ResetResult(ptr->ip); + return rb_tainted_str_new2(""); + } } DUMP1("end Tcl_GetCommandInfo"); @@ -4717,12 +4716,12 @@ ip_invoke_core(interp, argc, argv) /* memory allocation for arguments of this command */ #if TCL_MAJOR_VERSION >= 8 if (!info.isNativeObjectProc) { - /* string interface */ - argv = (char **)ALLOC_N(char *, argc+1); - for (i = 0; i < argc; ++i) { - argv[i] = Tcl_GetStringFromObj(objv[i], &len); - } - argv[argc] = (char *)NULL; + /* string interface */ + argv = (char **)ALLOC_N(char *, argc+1); + for (i = 0; i < argc; ++i) { + argv[i] = Tcl_GetStringFromObj(objv[i], &len); + } + argv[argc] = (char *)NULL; } #endif @@ -4731,27 +4730,27 @@ ip_invoke_core(interp, argc, argv) /* Invoke the C procedure */ #if TCL_MAJOR_VERSION >= 8 if (info.isNativeObjectProc) { - ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip, - objc, objv); + ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip, + objc, objv); #if 0 - /* get the string value from the result object */ - resultPtr = Tcl_GetObjResult(ptr->ip); - Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len), - TCL_VOLATILE); + /* get the string value from the result object */ + resultPtr = Tcl_GetObjResult(ptr->ip); + Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len), + TCL_VOLATILE); #endif } else #endif { #if TCL_MAJOR_VERSION >= 8 - ptr->return_value = (*info.proc)(info.clientData, ptr->ip, - argc, (CONST84 char **)argv); + ptr->return_value = (*info.proc)(info.clientData, ptr->ip, + argc, (CONST84 char **)argv); - free(argv); + free(argv); #else /* TCL_MAJOR_VERSION < 8 */ - ptr->return_value = (*info.proc)(info.clientData, ptr->ip, - argc, argv); + ptr->return_value = (*info.proc)(info.clientData, ptr->ip, + argc, argv); #endif } @@ -4759,31 +4758,31 @@ ip_invoke_core(interp, argc, argv) /* exception on mainloop */ if (ptr->return_value == TCL_ERROR) { - if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) { + if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) { #if TCL_MAJOR_VERSION >= 8 - return create_ip_exc(interp, rb_eRuntimeError, - "%s", Tcl_GetStringResult(ptr->ip)); + return create_ip_exc(interp, rb_eRuntimeError, + "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - return create_ip_exc(interp, rb_eRuntimeError, - "%s", ptr->ip->result); + return create_ip_exc(interp, rb_eRuntimeError, + "%s", ptr->ip->result); #endif - } else { - if (event_loop_abort_on_exc < 0) { + } else { + if (event_loop_abort_on_exc < 0) { #if TCL_MAJOR_VERSION >= 8 - rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip)); + rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_warning("%s (ignore)", ptr->ip->result); + rb_warning("%s (ignore)", ptr->ip->result); #endif - } else { + } else { #if TCL_MAJOR_VERSION >= 8 - rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip)); + rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_warn("%s (ignore)", ptr->ip->result); + rb_warn("%s (ignore)", ptr->ip->result); #endif - } - Tcl_ResetResult(ptr->ip); - return rb_tainted_str_new2(""); - } + } + Tcl_ResetResult(ptr->ip); + return rb_tainted_str_new2(""); + } } /* pass back the result (as string) */ @@ -4819,30 +4818,30 @@ alloc_invoke_arguments(argc, argv) #if TCL_MAJOR_VERSION >= 8 av = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, argc+1); for (i = 0; i < argc; ++i) { - VALUE enc; + VALUE enc; - v = argv[i]; - s = StringValuePtr(v); + v = argv[i]; + s = StringValuePtr(v); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - av[i] = Tcl_NewStringObj(s, RSTRING(v)->len); + av[i] = Tcl_NewStringObj(s, RSTRING(v)->len); # else /* TCL_VERSION >= 8.1 */ - enc = Qnil; - if (RTEST(rb_ivar_defined(v, ID_at_enc))) { - enc = rb_ivar_get(v, ID_at_enc); - } - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - /* binary string */ - av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len); - } else if (strlen(s) != RSTRING(v)->len) { - /* probably binary string */ - av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len); - } else { - /* probably text string */ - av[i] = Tcl_NewStringObj(s, RSTRING(v)->len); - } + enc = Qnil; + if (RTEST(rb_ivar_defined(v, ID_at_enc))) { + enc = rb_ivar_get(v, ID_at_enc); + } + if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { + /* binary string */ + av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len); + } else if (strlen(s) != RSTRING(v)->len) { + /* probably binary string */ + av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len); + } else { + /* probably text string */ + av[i] = Tcl_NewStringObj(s, RSTRING(v)->len); + } # endif - Tcl_IncrRefCount(av[i]); + Tcl_IncrRefCount(av[i]); } av[argc] = (Tcl_Obj *)NULL; @@ -4850,10 +4849,10 @@ alloc_invoke_arguments(argc, argv) /* string interface */ av = (char **)ALLOC_N(char *, argc+1); for (i = 0; i < argc; ++i) { - v = argv[i]; - s = StringValuePtr(v); - av[i] = ALLOC_N(char, strlen(s)+1); - strcpy(av[i], s); + v = argv[i]; + s = StringValuePtr(v); + av[i] = ALLOC_N(char, strlen(s)+1); + strcpy(av[i], s); } av[argc] = (char *)NULL; #endif @@ -4876,9 +4875,9 @@ free_invoke_arguments(argc, av) for (i = 0; i < argc; ++i) { #if TCL_MAJOR_VERSION >= 8 - Tcl_DecrRefCount(av[i]); + Tcl_DecrRefCount(av[i]); #else /* TCL_MAJOR_VERSION < 8 */ - free(av[i]); + free(av[i]); #endif } free(av); @@ -4891,7 +4890,7 @@ ip_invoke_real(argc, argv, interp) VALUE interp; { VALUE v; - struct tcltkip *ptr; /* tcltkip data struct */ + struct tcltkip *ptr; /* tcltkip data struct */ int i; Tcl_CmdInfo info; char *s; @@ -4915,8 +4914,8 @@ ip_invoke_real(argc, argv, interp) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); } /* Invoke the C procedure */ @@ -4957,10 +4956,10 @@ invoke_queue_handler(evPtr, flags) DUMP2("added by thread : %lx", q->thread); if (*(q->done)) { - DUMP1("processed by another event-loop"); - return 0; + DUMP1("processed by another event-loop"); + return 0; } else { - DUMP1("process it on current event-loop"); + DUMP1("process it on current event-loop"); } /* process it */ @@ -4968,15 +4967,15 @@ invoke_queue_handler(evPtr, flags) /* check safe-level */ if (rb_safe_level() != q->safe_level) { - /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */ - q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q); - ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat), - ID_call, 0); - rb_gc_force_recycle(q_dat); + /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */ + q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q); + ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat), + ID_call, 0); + rb_gc_force_recycle(q_dat); } else { - DUMP2("call invoke_real (for caller thread:%lx)", q->thread); - DUMP2("call invoke_real (current thread:%lx)", rb_thread_current()); - ret = ip_invoke_core(q->interp, q->argc, q->argv); + DUMP2("call invoke_real (for caller thread:%lx)", q->thread); + DUMP2("call invoke_real (current thread:%lx)", rb_thread_current()); + ret = ip_invoke_core(q->interp, q->argc, q->argv); } /* set result */ @@ -5020,19 +5019,19 @@ ip_invoke_with_position(argc, argv, obj, position) #endif if (argc < 1) { - rb_raise(rb_eArgError, "command name missing"); + rb_raise(rb_eArgError, "command name missing"); } if (eventloop_thread == 0 || current == eventloop_thread) { - if (eventloop_thread) { - DUMP2("invoke from current eventloop %lx", current); - } else { - DUMP2("invoke from thread:%lx but no eventloop", current); - } - result = ip_invoke_real(argc, argv, ip_obj); - if (rb_obj_is_kind_of(result, rb_eException)) { - rb_exc_raise(result); - } - return result; + if (eventloop_thread) { + DUMP2("invoke from current eventloop %lx", current); + } else { + DUMP2("invoke from thread:%lx but no eventloop", current); + } + result = ip_invoke_real(argc, argv, ip_obj); + if (rb_obj_is_kind_of(result, rb_eException)) { + rb_exc_raise(result); + } + return result; } DUMP2("invoke from thread %lx (NOT current eventloop)", current); @@ -5075,7 +5074,7 @@ ip_invoke_with_position(argc, argv, obj, position) /* wait for the handler to be processed */ DUMP2("wait for handler (current thread:%lx)", current); while(*alloc_done >= 0) { - rb_thread_stop(); + rb_thread_stop(); } DUMP2("back from handler (current thread:%lx)", current); @@ -5090,8 +5089,8 @@ ip_invoke_with_position(argc, argv, obj, position) /* exception? */ if (rb_obj_is_kind_of(ret, rb_eException)) { - DUMP1("raise exception"); - rb_exc_raise(ret); + DUMP1("raise exception"); + rb_exc_raise(ret); } DUMP1("exit ip_invoke"); @@ -5104,15 +5103,15 @@ static VALUE ip_retval(self) VALUE self; { - struct tcltkip *ptr; /* tcltkip data struct */ + struct tcltkip *ptr; /* tcltkip data struct */ /* get the data strcut */ ptr = get_ip(self); /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); } return (INT2FIX(ptr->return_value)); @@ -5154,112 +5153,112 @@ ip_get_variable(self, varname_arg, flag_arg) #if TCL_MAJOR_VERSION >= 8 { - Tcl_Obj *nameobj, *ret; - char *s; - int len; - volatile VALUE strval; - - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - - nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, - RSTRING(varname)->len); - Tcl_IncrRefCount(nameobj); - - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - Tcl_DecrRefCount(nameobj); - rb_thread_critical = thr_crit_bup; - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_ObjGetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, - FIX2INT(flag)); - } - - Tcl_DecrRefCount(nameobj); - - if (ret == (Tcl_Obj*)NULL) { - volatile VALUE exc; + Tcl_Obj *nameobj, *ret; + char *s; + int len; + volatile VALUE strval; + + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + + nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, + RSTRING(varname)->len); + Tcl_IncrRefCount(nameobj); + + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + Tcl_DecrRefCount(nameobj); + rb_thread_critical = thr_crit_bup; + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_ObjGetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, + FIX2INT(flag)); + } + + Tcl_DecrRefCount(nameobj); + + if (ret == (Tcl_Obj*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - Tcl_IncrRefCount(ret); + Tcl_IncrRefCount(ret); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - return(strval); + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + return(strval); # else /* TCL_VERSION >= 8.1 */ - if (Tcl_GetCharLength(ret) - != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { - /* possibly binary string */ - s = Tcl_GetByteArrayFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary")); - } else { - /* possibly text string */ - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - } - - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - - return(strval); + if (Tcl_GetCharLength(ret) + != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { + /* possibly binary string */ + s = Tcl_GetByteArrayFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary")); + } else { + /* possibly text string */ + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + } + + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + + return(strval); # endif } #else /* TCL_MAJOR_VERSION < 8 */ { - char *ret; - - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr, - (char*)NULL, FIX2INT(flag)); - } - - if (ret == (char*)NULL) { - volatile VALUE exc; + char *ret; + + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr, + (char*)NULL, FIX2INT(flag)); + } + + if (ret == (char*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - strval = rb_tainted_str_new2(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + strval = rb_tainted_str_new2(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #endif } @@ -5288,115 +5287,115 @@ ip_get_variable2(self, varname_arg, index_arg, flag_arg) #if TCL_MAJOR_VERSION >= 8 { - Tcl_Obj *nameobj, *idxobj, *ret; - char *s; - int len; - volatile VALUE strval; - - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - - nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, - RSTRING(varname)->len); - Tcl_IncrRefCount(nameobj); - idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, RSTRING(index)->len); - Tcl_IncrRefCount(idxobj); - - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(idxobj); - rb_thread_critical = thr_crit_bup; - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag)); - } - - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(idxobj); - - if (ret == (Tcl_Obj*)NULL) { - volatile VALUE exc; + Tcl_Obj *nameobj, *idxobj, *ret; + char *s; + int len; + volatile VALUE strval; + + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + + nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, + RSTRING(varname)->len); + Tcl_IncrRefCount(nameobj); + idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, RSTRING(index)->len); + Tcl_IncrRefCount(idxobj); + + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(idxobj); + rb_thread_critical = thr_crit_bup; + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag)); + } + + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(idxobj); + + if (ret == (Tcl_Obj*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - Tcl_IncrRefCount(ret); + Tcl_IncrRefCount(ret); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - return(strval); + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + return(strval); # else /* TCL_VERSION >= 8.1 */ - if (Tcl_GetCharLength(ret) - != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { - /* possibly binary string */ - s = Tcl_GetByteArrayFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary")); - } else { - /* possibly text string */ - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - } - - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - - return(strval); + if (Tcl_GetCharLength(ret) + != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { + /* possibly binary string */ + s = Tcl_GetByteArrayFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary")); + } else { + /* possibly text string */ + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + } + + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + + return(strval); # endif } #else /* TCL_MAJOR_VERSION < 8 */ { - char *ret; - - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr, - RSTRING(index)->ptr, FIX2INT(flag)); - } - - if (ret == (char*)NULL) { - volatile VALUE exc; + char *ret; + + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr, + RSTRING(index)->ptr, FIX2INT(flag)); + } + + if (ret == (char*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - strval = rb_tainted_str_new2(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + strval = rb_tainted_str_new2(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #endif } @@ -5421,137 +5420,137 @@ ip_set_variable(self, varname_arg, value_arg, flag_arg) #if TCL_MAJOR_VERSION >= 8 { - Tcl_Obj *nameobj, *valobj, *ret; - char *s; - int len; - volatile VALUE strval; + Tcl_Obj *nameobj, *valobj, *ret; + char *s; + int len; + volatile VALUE strval; - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, - RSTRING(varname)->len); + nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, + RSTRING(varname)->len); - Tcl_IncrRefCount(nameobj); + Tcl_IncrRefCount(nameobj); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - valobj = Tcl_NewStringObj(RSTRING(value)->ptr, - RSTRING(value)->len); - Tcl_IncrRefCount(valobj); + valobj = Tcl_NewStringObj(RSTRING(value)->ptr, + RSTRING(value)->len); + Tcl_IncrRefCount(valobj); # else /* TCL_VERSION >= 8.1 */ - { - volatile VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(value, ID_at_enc))) { - enc = rb_ivar_get(value, ID_at_enc); - } - - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - /* binary string */ - valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) { - /* probably binary string */ - valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } else { - /* probably text string */ - valobj = Tcl_NewStringObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } - - Tcl_IncrRefCount(valobj); - } + { + volatile VALUE enc = Qnil; + + if (RTEST(rb_ivar_defined(value, ID_at_enc))) { + enc = rb_ivar_get(value, ID_at_enc); + } + + if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { + /* binary string */ + valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) { + /* probably binary string */ + valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } else { + /* probably text string */ + valobj = Tcl_NewStringObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } + + Tcl_IncrRefCount(valobj); + } # endif - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(valobj); - rb_thread_critical = thr_crit_bup; - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_ObjSetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, valobj, - FIX2INT(flag)); - } - - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(valobj); - - if (ret == (Tcl_Obj*)NULL) { - volatile VALUE exc; + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(valobj); + rb_thread_critical = thr_crit_bup; + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_ObjSetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, valobj, + FIX2INT(flag)); + } + + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(valobj); + + if (ret == (Tcl_Obj*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - Tcl_IncrRefCount(ret); + Tcl_IncrRefCount(ret); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); # else /* TCL_VERSION >= 8.1 */ - { - VALUE old_gc; - - old_gc = rb_gc_disable(); - - if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { - /* possibly binary string */ - s = Tcl_GetByteArrayFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); - } else { - /* possibly text string */ - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - } - if (old_gc == Qfalse) rb_gc_enable(); - } + { + VALUE old_gc; + + old_gc = rb_gc_disable(); + + if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { + /* possibly binary string */ + s = Tcl_GetByteArrayFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); + } else { + /* possibly text string */ + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + } + if (old_gc == Qfalse) rb_gc_enable(); + } # endif - Tcl_DecrRefCount(ret); + Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #else /* TCL_MAJOR_VERSION < 8 */ { - CONST char *ret; + CONST char *ret; - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, (char*)NULL, - RSTRING(value)->ptr, (int)FIX2INT(flag)); - } + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, (char*)NULL, + RSTRING(value)->ptr, (int)FIX2INT(flag)); + } - if (ret == NULL) { - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); - } + if (ret == NULL) { + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + } - strval = rb_tainted_str_new2(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + strval = rb_tainted_str_new2(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #endif } @@ -5583,138 +5582,138 @@ ip_set_variable2(self, varname_arg, index_arg, value_arg, flag_arg) #if TCL_MAJOR_VERSION >= 8 { - Tcl_Obj *nameobj, *idxobj, *valobj, *ret; - char *s; - int len; - volatile VALUE strval; + Tcl_Obj *nameobj, *idxobj, *valobj, *ret; + char *s; + int len; + volatile VALUE strval; - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, - RSTRING(varname)->len); - Tcl_IncrRefCount(nameobj); + nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr, + RSTRING(varname)->len); + Tcl_IncrRefCount(nameobj); - idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, - RSTRING(index)->len); - Tcl_IncrRefCount(idxobj); + idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, + RSTRING(index)->len); + Tcl_IncrRefCount(idxobj); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - valobj = Tcl_NewStringObj(RSTRING(value)->ptr, - RSTRING(value)->len); + valobj = Tcl_NewStringObj(RSTRING(value)->ptr, + RSTRING(value)->len); # else /* TCL_VERSION >= 8.1 */ - { - VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(value, ID_at_enc))) { - enc = rb_ivar_get(value, ID_at_enc); - } - - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - /* binary string */ - valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) { - /* probably binary string */ - valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } else { - /* probably text string */ - valobj = Tcl_NewStringObj(RSTRING(value)->ptr, - RSTRING(value)->len); - } - } + { + VALUE enc = Qnil; + + if (RTEST(rb_ivar_defined(value, ID_at_enc))) { + enc = rb_ivar_get(value, ID_at_enc); + } + + if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { + /* binary string */ + valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) { + /* probably binary string */ + valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } else { + /* probably text string */ + valobj = Tcl_NewStringObj(RSTRING(value)->ptr, + RSTRING(value)->len); + } + } # endif - Tcl_IncrRefCount(valobj); - - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(idxobj); - Tcl_DecrRefCount(valobj); - rb_thread_critical = thr_crit_bup; - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_ObjSetVar2(ptr->ip, nameobj, idxobj, valobj, - FIX2INT(flag)); - } - - Tcl_DecrRefCount(nameobj); - Tcl_DecrRefCount(idxobj); - Tcl_DecrRefCount(valobj); - - if (ret == (Tcl_Obj*)NULL) { - volatile VALUE exc; + Tcl_IncrRefCount(valobj); + + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(idxobj); + Tcl_DecrRefCount(valobj); + rb_thread_critical = thr_crit_bup; + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_ObjSetVar2(ptr->ip, nameobj, idxobj, valobj, + FIX2INT(flag)); + } + + Tcl_DecrRefCount(nameobj); + Tcl_DecrRefCount(idxobj); + Tcl_DecrRefCount(valobj); + + if (ret == (Tcl_Obj*)NULL) { + volatile VALUE exc; #if TCL_MAJOR_VERSION >= 8 - exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); + exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); + exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result); #endif - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; - rb_exc_raise(exc); - } + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; + rb_exc_raise(exc); + } - Tcl_IncrRefCount(ret); + Tcl_IncrRefCount(ret); # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); # else /* TCL_VERSION >= 8.1 */ - if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { - /* possibly binary string */ - s = Tcl_GetByteArrayFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); - } else { - /* possibly text string */ - s = Tcl_GetStringFromObj(ret, &len); - strval = rb_tainted_str_new(s, len); - } + if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) { + /* possibly binary string */ + s = Tcl_GetByteArrayFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary")); + } else { + /* possibly text string */ + s = Tcl_GetStringFromObj(ret, &len); + strval = rb_tainted_str_new(s, len); + } # endif - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #else /* TCL_MAJOR_VERSION < 8 */ { - CONST char *ret; + CONST char *ret; - /* ip is deleted? */ - if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return rb_tainted_str_new2(""); - } else { - /* Tcl_Preserve(ptr->ip); */ - rbtk_preserve_ip(ptr); - ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, - RSTRING(index)->ptr, - RSTRING(value)->ptr, FIX2INT(flag)); - } + /* ip is deleted? */ + if (Tcl_InterpDeleted(ptr->ip)) { + DUMP1("ip is deleted"); + return rb_tainted_str_new2(""); + } else { + /* Tcl_Preserve(ptr->ip); */ + rbtk_preserve_ip(ptr); + ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, + RSTRING(index)->ptr, + RSTRING(value)->ptr, FIX2INT(flag)); + } - if (ret == (char*)NULL) { - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); - } + if (ret == (char*)NULL) { + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + } - Tcl_IncrRefCount(ret); + Tcl_IncrRefCount(ret); - strval = rb_tainted_str_new2(ret); + strval = rb_tainted_str_new2(ret); - Tcl_DecrRefCount(ret); - /* Tcl_Release(ptr->ip); */ - rbtk_release_ip(ptr); - rb_thread_critical = thr_crit_bup; + Tcl_DecrRefCount(ret); + /* Tcl_Release(ptr->ip); */ + rbtk_release_ip(ptr); + rb_thread_critical = thr_crit_bup; - return(strval); + return(strval); } #endif } @@ -5735,21 +5734,21 @@ ip_unset_variable(self, varname_arg, flag_arg) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return Qtrue; + DUMP1("ip is deleted"); + return Qtrue; } ptr->return_value = Tcl_UnsetVar(ptr->ip, RSTRING(varname)->ptr, - FIX2INT(flag)); + FIX2INT(flag)); if (ptr->return_value == TCL_ERROR) { - if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) { + if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); #endif - } - return Qfalse; + } + return Qfalse; } return Qtrue; } @@ -5777,21 +5776,21 @@ ip_unset_variable2(self, varname_arg, index_arg, flag_arg) /* ip is deleted? */ if (Tcl_InterpDeleted(ptr->ip)) { - DUMP1("ip is deleted"); - return Qtrue; + DUMP1("ip is deleted"); + return Qtrue; } ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING(varname)->ptr, - RSTRING(index)->ptr, FIX2INT(flag)); + RSTRING(index)->ptr, FIX2INT(flag)); if (ptr->return_value == TCL_ERROR) { - if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) { + if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); #endif - } - return Qfalse; + } + return Qfalse; } return Qtrue; } @@ -5802,7 +5801,7 @@ ip_get_global_var(self, varname) VALUE varname; { return ip_get_variable(self, varname, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } static VALUE @@ -5812,7 +5811,7 @@ ip_get_global_var2(self, varname, index) VALUE index; { return ip_get_variable2(self, varname, index, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } static VALUE @@ -5822,7 +5821,7 @@ ip_set_global_var(self, varname, value) VALUE value; { return ip_set_variable(self, varname, value, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } static VALUE @@ -5833,7 +5832,7 @@ ip_set_global_var2(self, varname, index, value) VALUE value; { return ip_set_variable2(self, varname, index, value, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } static VALUE @@ -5842,7 +5841,7 @@ ip_unset_global_var(self, varname) VALUE varname; { return ip_unset_variable(self, varname, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } static VALUE @@ -5852,7 +5851,7 @@ ip_unset_global_var2(self, varname, index) VALUE index; { return ip_unset_variable2(self, varname, index, - INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); + INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)); } @@ -5870,161 +5869,161 @@ lib_split_tklist_core(ip_obj, list_str) VALUE old_gc; if (NIL_P(ip_obj)) { - interp = (Tcl_Interp *)NULL; + interp = (Tcl_Interp *)NULL; } else { - interp = get_ip(ip_obj)->ip; + interp = get_ip(ip_obj)->ip; } StringValue(list_str); { #if TCL_MAJOR_VERSION >= 8 - /* object style interface */ - Tcl_Obj *listobj; - int objc; - Tcl_Obj **objv; - int thr_crit_bup; + /* object style interface */ + Tcl_Obj *listobj; + int objc; + Tcl_Obj **objv; + int thr_crit_bup; # if 1 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, - RSTRING(list_str)->len); + listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, + RSTRING(list_str)->len); # else /* TCL_VERSION >= 8.1 */ - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - - { - VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) { - enc = rb_ivar_get(list_str, ID_at_enc); - } - - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - /* binary string */ - listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr, - RSTRING(list_str)->len); - } else if (strlen(RSTRING(list_str)->ptr) - != RSTRING(list_str)->len) { - /* probably binary string */ - listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr, - RSTRING(list_str)->len); - } else { - /* probably text string */ - listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, - RSTRING(list_str)->len); - } - } - - rb_thread_critical = thr_crit_bup; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + + { + VALUE enc = Qnil; + + if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) { + enc = rb_ivar_get(list_str, ID_at_enc); + } + + if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { + /* binary string */ + listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr, + RSTRING(list_str)->len); + } else if (strlen(RSTRING(list_str)->ptr) + != RSTRING(list_str)->len) { + /* probably binary string */ + listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr, + RSTRING(list_str)->len); + } else { + /* probably text string */ + listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, + RSTRING(list_str)->len); + } + } + + rb_thread_critical = thr_crit_bup; # endif # else - listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, - RSTRING(list_str)->len); + listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr, + RSTRING(list_str)->len); # endif - Tcl_IncrRefCount(listobj); + Tcl_IncrRefCount(listobj); - result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv); + result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv); - if (result == TCL_ERROR) { - Tcl_DecrRefCount(listobj); - if (interp == (Tcl_Interp*)NULL) { - rb_raise(rb_eRuntimeError, "cannot get elements from list"); - } else { + if (result == TCL_ERROR) { + Tcl_DecrRefCount(listobj); + if (interp == (Tcl_Interp*)NULL) { + rb_raise(rb_eRuntimeError, "cannot get elements from list"); + } else { #if TCL_MAJOR_VERSION >= 8 - rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp)); + rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp)); #else /* TCL_MAJOR_VERSION < 8 */ - rb_raise(rb_eRuntimeError, "%s", interp->result); + rb_raise(rb_eRuntimeError, "%s", interp->result); #endif - } - } + } + } - for(idx = 0; idx < objc; idx++) { - Tcl_IncrRefCount(objv[idx]); - } + for(idx = 0; idx < objc; idx++) { + Tcl_IncrRefCount(objv[idx]); + } - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; - ary = rb_ary_new2(objc); - if (taint_flag) OBJ_TAINT(ary); + ary = rb_ary_new2(objc); + if (taint_flag) OBJ_TAINT(ary); - old_gc = rb_gc_disable(); + old_gc = rb_gc_disable(); - for(idx = 0; idx < objc; idx++) { - char *str; - int len; + for(idx = 0; idx < objc; idx++) { + char *str; + int len; # if 1 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 - str = Tcl_GetStringFromObj(objv[idx], &len); - elem = rb_str_new(str, len); + str = Tcl_GetStringFromObj(objv[idx], &len); + elem = rb_str_new(str, len); # else /* TCL_VERSION >= 8.1 */ - if (Tcl_GetCharLength(objv[idx]) - != Tcl_UniCharLen(Tcl_GetUnicode(objv[idx]))) { - /* possibly binary string */ - str = Tcl_GetByteArrayFromObj(objv[idx], &len); - elem = rb_str_new(str, len); - rb_ivar_set(elem, ID_at_enc, rb_tainted_str_new2("binary")); - } else { - /* possibly text string */ - str = Tcl_GetStringFromObj(objv[idx], &len); - elem = rb_str_new(str, len); - } + if (Tcl_GetCharLength(objv[idx]) + != Tcl_UniCharLen(Tcl_GetUnicode(objv[idx]))) { + /* possibly binary string */ + str = Tcl_GetByteArrayFromObj(objv[idx], &len); + elem = rb_str_new(str, len); + rb_ivar_set(elem, ID_at_enc, rb_tainted_str_new2("binary")); + } else { + /* possibly text string */ + str = Tcl_GetStringFromObj(objv[idx], &len); + elem = rb_str_new(str, len); + } # endif # else - str = Tcl_GetStringFromObj(objv[idx], &len); - elem = rb_str_new(str, len); + str = Tcl_GetStringFromObj(objv[idx], &len); + elem = rb_str_new(str, len); # endif - if (taint_flag) OBJ_TAINT(elem); - RARRAY(ary)->ptr[idx] = elem; - } + if (taint_flag) OBJ_TAINT(elem); + RARRAY(ary)->ptr[idx] = elem; + } - RARRAY(ary)->len = objc; + RARRAY(ary)->len = objc; - if (old_gc == Qfalse) rb_gc_enable(); + if (old_gc == Qfalse) rb_gc_enable(); - rb_thread_critical = thr_crit_bup; + rb_thread_critical = thr_crit_bup; - for(idx = 0; idx < objc; idx++) { - Tcl_DecrRefCount(objv[idx]); - } + for(idx = 0; idx < objc; idx++) { + Tcl_DecrRefCount(objv[idx]); + } - Tcl_DecrRefCount(listobj); + Tcl_DecrRefCount(listobj); #else /* TCL_MAJOR_VERSION < 8 */ - /* string style interface */ - int argc; - char **argv; + /* string style interface */ + int argc; + char **argv; - if (Tcl_SplitList(interp, RSTRING(list_str)->ptr, - &argc, &argv) == TCL_ERROR) { - if (interp == (Tcl_Interp*)NULL) { - rb_raise(rb_eRuntimeError, "cannot get elements from list"); - } else { - rb_raise(rb_eRuntimeError, "%s", interp->result); - } - } + if (Tcl_SplitList(interp, RSTRING(list_str)->ptr, + &argc, &argv) == TCL_ERROR) { + if (interp == (Tcl_Interp*)NULL) { + rb_raise(rb_eRuntimeError, "cannot get elements from list"); + } else { + rb_raise(rb_eRuntimeError, "%s", interp->result); + } + } - ary = rb_ary_new2(argc); - if (taint_flag) OBJ_TAINT(ary); + ary = rb_ary_new2(argc); + if (taint_flag) OBJ_TAINT(ary); - old_gc = rb_gc_disable(); + old_gc = rb_gc_disable(); - for(idx = 0; idx < argc; idx++) { - if (taint_flag) { - elem = rb_tainted_str_new2(argv[idx]); - } else { - elem = rb_str_new2(argv[idx]); - } - /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */ - RARRAY(ary)->ptr[idx] = elem; - } - RARRAY(ary)->len = argc; + for(idx = 0; idx < argc; idx++) { + if (taint_flag) { + elem = rb_tainted_str_new2(argv[idx]); + } else { + elem = rb_str_new2(argv[idx]); + } + /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */ + RARRAY(ary)->ptr[idx] = elem; + } + RARRAY(ary)->len = argc; - if (old_gc == Qfalse) rb_gc_enable(); + if (old_gc == Qfalse) rb_gc_enable(); #endif } @@ -6074,13 +6073,13 @@ lib_merge_tklist(argc, argv, obj) /* pass 1 */ len = 1; for(num = 0; num < argc; num++) { - if (OBJ_TAINTED(argv[num])) taint_flag = 1; - dst = StringValuePtr(argv[num]); + if (OBJ_TAINTED(argv[num])) taint_flag = 1; + dst = StringValuePtr(argv[num]); #if TCL_MAJOR_VERSION >= 8 - len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len, - &flagPtr[num]) + 1; + len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len, + &flagPtr[num]) + 1; #else /* TCL_MAJOR_VERSION < 8 */ - len += Tcl_ScanElement(dst, &flagPtr[num]) + 1; + len += Tcl_ScanElement(dst, &flagPtr[num]) + 1; #endif } @@ -6090,8 +6089,8 @@ lib_merge_tklist(argc, argv, obj) for(num = 0; num < argc; num++) { #if TCL_MAJOR_VERSION >= 8 len = Tcl_ConvertCountedElement(RSTRING(argv[num])->ptr, - RSTRING(argv[num])->len, - dst, flagPtr[num]); + RSTRING(argv[num])->len, + dst, flagPtr[num]); #else /* TCL_MAJOR_VERSION < 8 */ len = Tcl_ConvertElement(RSTRING(argv[num])->ptr, dst, flagPtr[num]); #endif @@ -6135,10 +6134,10 @@ lib_conv_listelement(self, src) #if TCL_MAJOR_VERSION >= 8 len = Tcl_ScanCountedElement(RSTRING(src)->ptr, RSTRING(src)->len, - &scan_flag); + &scan_flag); dst = rb_str_new(0, len + 1); len = Tcl_ConvertCountedElement(RSTRING(src)->ptr, RSTRING(src)->len, - RSTRING(dst)->ptr, scan_flag); + RSTRING(dst)->ptr, scan_flag); #else /* TCL_MAJOR_VERSION < 8 */ len = Tcl_ScanElement(RSTRING(src)->ptr, &scan_flag); dst = rb_str_new(0, len + 1); @@ -6183,7 +6182,7 @@ Init_tcltklib() int ret = ruby_tcltk_stubs(); if (ret) - rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret); + rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret); #endif /* --------------------------------------------------------------- */ @@ -6198,7 +6197,7 @@ Init_tcltklib() /* --------------------------------------------------------------- */ rb_define_const(lib, "FINALIZE_PROC_NAME", - rb_str_new2(finalize_hook_name)); + rb_str_new2(finalize_hook_name)); /* --------------------------------------------------------------- */ @@ -6262,7 +6261,7 @@ Init_tcltklib() rb_define_module_function(lib, "mainloop", lib_mainloop, -1); rb_define_module_function(lib, "mainloop_watchdog", - lib_mainloop_watchdog, -1); + lib_mainloop_watchdog, -1); rb_define_module_function(lib, "do_one_event", lib_do_one_event, -1); rb_define_module_function(lib, "mainloop_abort_on_exception", lib_evloop_abort_on_exc, 0); @@ -6273,25 +6272,25 @@ Init_tcltklib() rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1); rb_define_module_function(lib, "get_no_event_wait", get_no_event_wait, 0); rb_define_module_function(lib, "set_eventloop_weight", - set_eventloop_weight, 2); + set_eventloop_weight, 2); rb_define_module_function(lib, "set_max_block_time", set_max_block_time,1); rb_define_module_function(lib, "get_eventloop_weight", - get_eventloop_weight, 0); + get_eventloop_weight, 0); rb_define_module_function(lib, "num_of_mainwindows", - lib_num_of_mainwindows, 0); + lib_num_of_mainwindows, 0); /* --------------------------------------------------------------- */ rb_define_module_function(lib, "_split_tklist", lib_split_tklist, 1); rb_define_module_function(lib, "_merge_tklist", lib_merge_tklist, -1); rb_define_module_function(lib, "_conv_listelement", - lib_conv_listelement, 1); + lib_conv_listelement, 1); rb_define_module_function(lib, "_toUTF8", lib_toUTF8, -1); rb_define_module_function(lib, "_fromUTF8", lib_fromUTF8, -1); rb_define_module_function(lib, "_subst_UTF_backslash", - lib_UTF_backslash, 1); + lib_UTF_backslash, 1); rb_define_module_function(lib, "_subst_Tcl_backslash", - lib_Tcl_backslash, 1); + lib_Tcl_backslash, 1); /* --------------------------------------------------------------- */ @@ -6339,9 +6338,9 @@ Init_tcltklib() rb_define_method(ip, "mainloop_watchdog", ip_mainloop_watchdog, -1); rb_define_method(ip, "do_one_event", ip_do_one_event, -1); rb_define_method(ip, "mainloop_abort_on_exception", - ip_evloop_abort_on_exc, 0); + ip_evloop_abort_on_exc, 0); rb_define_method(ip, "mainloop_abort_on_exception=", - ip_evloop_abort_on_exc_set, 1); + ip_evloop_abort_on_exc_set, 1); rb_define_method(ip, "set_eventloop_tick", ip_set_eventloop_tick, 1); rb_define_method(ip, "get_eventloop_tick", ip_get_eventloop_tick, 0); rb_define_method(ip, "set_no_event_wait", ip_set_no_event_wait, 1); diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 061123b79..38e4b28de 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -1,6 +1,6 @@ # -# multi-tk.rb - supports multi Tk interpreters -# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> +# multi-tk.rb - supports multi Tk interpreters +# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> require 'tcltklib' require 'tkutil' @@ -78,17 +78,17 @@ class MultiTkIp end def call(*args) begin - unless @ip.deleted? - @ip.cb_eval(@cmd, *args) - end + unless @ip.deleted? + @ip.cb_eval(@cmd, *args) + end rescue TkCallbackBreak, TkCallbackContinue => e - fail e + fail e rescue Exception => e - if @ip.safe? - # ignore - else - fail e - end + if @ip.safe? + # ignore + else + fail e + end end end }.freeze @@ -106,19 +106,19 @@ class MultiTkIp def _check_and_return(thread, exception, wait=0) unless thread unless exception.kind_of?(MultiTkIp_OK) || safe? - msg = "#{exception.class}: #{exception.message}" - begin - if @interp.deleted? - warn('Warning: ' + msg) - elsif @interp._eval_without_enc('info command bgerror').size != 0 - @interp._eval(@interp._merge_tklist('bgerror', msg)) - else - warn('Warning: ' + msg) - end - rescue Exception => e - warn('Warning: ' + msg) - warn('Warning: ' + e.message) - end + msg = "#{exception.class}: #{exception.message}" + begin + if @interp.deleted? + warn('Warning: ' + msg) + elsif @interp._eval_without_enc('info command bgerror').size != 0 + @interp._eval(@interp._merge_tklist('bgerror', msg)) + else + warn('Warning: ' + msg) + end + rescue Exception => e + warn('Warning: ' + msg) + warn('Warning: ' + e.message) + end end return nil end @@ -127,7 +127,7 @@ class MultiTkIp # no wait Thread.pass if thread.stop? - thread.raise exception + thread.raise exception end return thread end @@ -135,9 +135,9 @@ class MultiTkIp # wait to stop the caller thread wait.times{ if thread.stop? - # ready to send exception - thread.raise exception - return thread + # ready to send exception + thread.raise exception + return thread end # wait @@ -188,39 +188,39 @@ class MultiTkIp def _destroy_slaves_of_slaveIP(ip) unless ip.deleted? ip._split_tklist(ip._invoke('interp', 'slaves')).each{|name| - begin - ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}") - rescue Exception - end - begin - # ip._invoke('interp', 'eval', name, 'destroy', '.') - ip._invoke(name, 'eval', 'destroy', '.') - rescue Exception - end - - # safe_base? - if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - ip._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - end - end + begin + ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}") + rescue Exception + end + begin + # ip._invoke('interp', 'eval', name, 'destroy', '.') + ip._invoke(name, 'eval', 'destroy', '.') + rescue Exception + end + + # safe_base? + if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + ip._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + end + end =begin - if ip._invoke('interp', 'exists', name) == '1' - begin - ip._invoke(name, 'eval', 'exit') - rescue Exception - end - end + if ip._invoke('interp', 'exists', name) == '1' + begin + ip._invoke(name, 'eval', 'exit') + rescue Exception + end + end =end - unless ip.deleted? - if ip._invoke('interp', 'exists', name) == '1' - begin - ip._invoke('interp', 'delete', name) - rescue Exception - end - end - end + unless ip.deleted? + if ip._invoke('interp', 'exists', name) == '1' + begin + ip._invoke('interp', 'delete', name) + rescue Exception + end + end + end } end end @@ -233,139 +233,139 @@ class MultiTkIp rescue SystemExit => e # delete IP unless @interp.deleted? - @slave_ip_tbl.each{|name, subip| - _destroy_slaves_of_slaveIP(subip) - begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + @slave_ip_tbl.each{|name, subip| + _destroy_slaves_of_slaveIP(subip) + begin + subip._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - subip._invoke('destroy', '.') unless subip.deleted? - rescue Exception - end + begin + subip._invoke('destroy', '.') unless subip.deleted? + rescue Exception + end =end - # safe_base? - if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end - end - if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end - else - begin - subip.delete unless subip.deleted? - rescue Exception - end - end - } - - begin - @interp._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end - begin - @interp._invoke('destroy', '.') unless @interp.deleted? - rescue Exception - end - if @safe_base && !@interp.deleted? - # do 'exit' to call the delete_hook procedure - @interp._eval_without_enc('exit') - else - @interp.delete unless @interp.deleted? - end + # safe_base? + if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end + end + if subip.respond_to?(:safe_base?) && subip.safe_base? && + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end + else + begin + subip.delete unless subip.deleted? + rescue Exception + end + end + } + + begin + @interp._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end + begin + @interp._invoke('destroy', '.') unless @interp.deleted? + rescue Exception + end + if @safe_base && !@interp.deleted? + # do 'exit' to call the delete_hook procedure + @interp._eval_without_enc('exit') + else + @interp.delete unless @interp.deleted? + end end if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/ - _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit')) + _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit')) else - _check_and_return(thread, MultiTkIp_OK.new(nil)) + _check_and_return(thread, MultiTkIp_OK.new(nil)) end if master? && !safe? && allow_ruby_exit? =begin - ObjectSpace.each_object(TclTkIp){|obj| - obj.delete unless obj.deleted? - } + ObjectSpace.each_object(TclTkIp){|obj| + obj.delete unless obj.deleted? + } =end - #exit(e.status) - fail e + #exit(e.status) + fail e end # break rescue SecurityError => e # in 'exit', 'exit!', and 'abort' : security error --> delete IP if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/ - ret = ($3 == 'exit') - unless @interp.deleted? - @slave_ip_tbl.each{|name, subip| - _destroy_slaves_of_slaveIP(subip) - begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + ret = ($3 == 'exit') + unless @interp.deleted? + @slave_ip_tbl.each{|name, subip| + _destroy_slaves_of_slaveIP(subip) + begin + subip._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - subip._invoke('destroy', '.') unless subip.deleted? - rescue Exception - end + begin + subip._invoke('destroy', '.') unless subip.deleted? + rescue Exception + end =end - # safe_base? - if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end - end - if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end - else - begin - subip.delete unless subip.deleted? - rescue Exception - end - end - } - - begin - @interp._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + # safe_base? + if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end + end + if subip.respond_to?(:safe_base?) && subip.safe_base? && + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end + else + begin + subip.delete unless subip.deleted? + rescue Exception + end + end + } + + begin + @interp._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - @interp._invoke('destroy', '.') unless @interp.deleted? - rescue Exception - end + begin + @interp._invoke('destroy', '.') unless @interp.deleted? + rescue Exception + end =end - if @safe_base && !@interp.deleted? - # do 'exit' to call the delete_hook procedure - @interp._eval_without_enc('exit') - else - @interp.delete unless @interp.deleted? - end - end - _check_and_return(thread, MultiTkIp_OK.new(ret)) - # break + if @safe_base && !@interp.deleted? + # do 'exit' to call the delete_hook procedure + @interp._eval_without_enc('exit') + else + @interp.delete unless @interp.deleted? + end + end + _check_and_return(thread, MultiTkIp_OK.new(ret)) + # break else - # raise security error - _check_and_return(thread, e) + # raise security error + _check_and_return(thread, e) end rescue Exception => e @@ -381,16 +381,16 @@ class MultiTkIp def _receiver_eval_proc(last_thread, safe_level, thread, cmd, *args) if thread Thread.new{ - last_thread.join if last_thread - unless @interp.deleted? - _receiver_eval_proc_core(safe_level, thread, cmd, *args) - end + last_thread.join if last_thread + unless @interp.deleted? + _receiver_eval_proc_core(safe_level, thread, cmd, *args) + end } else Thread.new{ - unless @interp.deleted? - _receiver_eval_proc_core(safe_level, thread, cmd, *args) - end + unless @interp.deleted? + _receiver_eval_proc_core(safe_level, thread, cmd, *args) + end } last_thread end @@ -401,8 +401,8 @@ class MultiTkIp def _receiver_mainloop(check_root) Thread.new{ while !@interp.deleted? - break if @interp._invoke_without_enc('info', 'command', '.').size == 0 - sleep 0.5 + break if @interp._invoke_without_enc('info', 'command', '.').size == 0 + sleep 0.5 end } end @@ -415,54 +415,54 @@ class MultiTkIp last_thread = nil loop do - break if @interp.deleted? - thread, cmd, *args = @cmd_queue.deq - if thread == @system - # control command - case cmd - when 'set_safe_level' - begin - safe_level = args[0] if safe_level < args[0] - rescue Exception - end - when 'call_mainloop' - thread = args.shift - _check_and_return(thread, - MultiTkIp_OK.new(_receiver_mainloop(*args))) - else - # ignore - end - - else - # procedure - last_thread = _receiver_eval_proc(last_thread, safe_level, - thread, cmd, *args) - end + break if @interp.deleted? + thread, cmd, *args = @cmd_queue.deq + if thread == @system + # control command + case cmd + when 'set_safe_level' + begin + safe_level = args[0] if safe_level < args[0] + rescue Exception + end + when 'call_mainloop' + thread = args.shift + _check_and_return(thread, + MultiTkIp_OK.new(_receiver_mainloop(*args))) + else + # ignore + end + + else + # procedure + last_thread = _receiver_eval_proc(last_thread, safe_level, + thread, cmd, *args) + end end } # watchdog of receiver watchdog = Thread.new{ begin - loop do - sleep 1 - break unless receiver.alive? - end + loop do + sleep 1 + break unless receiver.alive? + end rescue Exception - # ignore all kind of Exception + # ignore all kind of Exception end # receiver is dead loop do - thread, cmd, *args = @cmd_queue.deq - next unless thread - if thread.alive? - if @interp.deleted? - thread.raise RuntimeError, 'the interpreter is already deleted' - else - thread.raise RuntimeError, - 'the interpreter no longer receives command procedures' - end - end + thread, cmd, *args = @cmd_queue.deq + next unless thread + if thread.alive? + if @interp.deleted? + thread.raise RuntimeError, 'the interpreter is already deleted' + else + thread.raise RuntimeError, + 'the interpreter no longer receives command procedures' + end + end end } @@ -528,38 +528,38 @@ class MultiTkIp @assign_request = Class.new(Exception){ def self.new(target, ret) - obj = super() - obj.target = target - obj.ret = ret - obj + obj = super() + obj.target = target + obj.ret = ret + obj end attr_accessor :target, :ret } @assign_thread = Thread.new{ loop do - begin - Thread.stop - rescue @assign_request=>req - begin - req.ret[0] = req.target.instance_eval{ - @cmd_receiver, @receiver_watchdog = - _create_receiver_and_watchdog(@safe_level[0]) - @threadgroup.add @cmd_receiver - @threadgroup.add @receiver_watchdog - @threadgroup.enclose - true - } - rescue Exception=>e - begin - req.ret[0] = e - rescue Exception - # ignore - end - end - rescue Exception - # ignore - end + begin + Thread.stop + rescue @assign_request=>req + begin + req.ret[0] = req.target.instance_eval{ + @cmd_receiver, @receiver_watchdog = + _create_receiver_and_watchdog(@safe_level[0]) + @threadgroup.add @cmd_receiver + @threadgroup.add @receiver_watchdog + @threadgroup.enclose + true + } + rescue Exception=>e + begin + req.ret[0] = e + rescue Exception + # ignore + end + end + rescue Exception + # ignore + end end } @@ -567,14 +567,14 @@ class MultiTkIp ret = [nil] @assign_thread.raise(@assign_request.new(target, ret)) while ret[0] == nil - unless @assign_thread.alive? - raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread' - end + unless @assign_thread.alive? + raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread' + end end if ret[0].kind_of?(Exception) - raise ret[0] + raise ret[0] else - ret[0] + ret[0] end end @@ -592,21 +592,21 @@ class MultiTkIp # trust if on ThreadGroup::Default or @@DEFAULT_MASTER's ThreadGroup if @@IP_TABLE[Thread.current.group] == @@DEFAULT_MASTER begin - class << subclass - self.methods.each{|m| - begin - unless m == '__id__' || m == '__send__' || m == 'freeze' - undef_method(m) - end - rescue Exception - # ignore all exceptions - end - } - end + class << subclass + self.methods.each{|m| + begin + unless m == '__id__' || m == '__send__' || m == 'freeze' + undef_method(m) + end + rescue Exception + # ignore all exceptions + end + } + end ensure - subclass.freeze - fail SecurityError, - "cannot create subclass of MultiTkIp on a untrusted ThreadGroup" + subclass.freeze + fail SecurityError, + "cannot create subclass of MultiTkIp on a untrusted ThreadGroup" end end end @@ -629,13 +629,13 @@ class MultiTkIp keys.each{|k,v| k_str = k.to_s if k_str == 'name' - name = v + name = v elsif k_str == 'safe' - safe = v + safe = v elsif SAFE_OPT_LIST.member?(k_str) - safe_opts[k_str] = v + safe_opts[k_str] = v else - tk_opts[k_str] = v + tk_opts[k_str] = v end } @@ -664,15 +664,15 @@ class MultiTkIp # check 'display' if !new_keys.key?('display') begin - #new_keys['display'] = @interp._invoke('winfo screen .') - new_keys['display'] = @interp._invoke('winfo', 'screen', '.') + #new_keys['display'] = @interp._invoke('winfo screen .') + new_keys['display'] = @interp._invoke('winfo', 'screen', '.') rescue - if ENV[DISPLAY] - new_keys['display'] = ENV[DISPLAY] - elsif !new_keys.key?('use') - warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'" - new_keys['display'] = ':0.0' - end + if ENV[DISPLAY] + new_keys['display'] = ENV[DISPLAY] + elsif !new_keys.key?('use') + warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'" + new_keys['display'] = ':0.0' + end end end @@ -681,30 +681,30 @@ class MultiTkIp # given 'use' case new_keys['use'] when TkWindow - new_keys['use'] = TkWinfo.id(new_keys['use']) - #assoc_display = @interp._eval('winfo screen .') - assoc_display = @interp._invoke('winfo', 'screen', '.') + new_keys['use'] = TkWinfo.id(new_keys['use']) + #assoc_display = @interp._eval('winfo screen .') + assoc_display = @interp._invoke('winfo', 'screen', '.') when /^\..*/ - new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use']) - assoc_display = @interp._invoke('winfo', 'screen', new_keys['use']) + new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use']) + assoc_display = @interp._invoke('winfo', 'screen', new_keys['use']) else - begin - pathname = @interp._invoke('winfo', 'pathname', new_keys['use']) - assco_display = @interp._invoke('winfo', 'screen', pathname) - rescue - assoc_display = new_keys['display'] - end + begin + pathname = @interp._invoke('winfo', 'pathname', new_keys['use']) + assco_display = @interp._invoke('winfo', 'screen', pathname) + rescue + assoc_display = new_keys['display'] + end end # match display? if assoc_display != new_keys['display'] - if optkeys.keys?(:display) || optkeys.keys?('display') - fail RuntimeError, - "conflicting 'display'=>#{new_keys['display']} " + - "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}" - else - new_keys['display'] = assoc_display - end + if optkeys.keys?(:display) || optkeys.keys?('display') + fail RuntimeError, + "conflicting 'display'=>#{new_keys['display']} " + + "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}" + else + new_keys['display'] = assoc_display + end end end @@ -746,11 +746,11 @@ class MultiTkIp # procedure to delete slave interpreter slave_delete_proc = proc{ unless slave_ip.deleted? - #if slave_ip._invoke('info', 'command', '.') != "" - # slave_ip._invoke('destroy', '.') - #end - #slave_ip.delete - slave_ip._eval_without_enc('exit') + #if slave_ip._invoke('info', 'command', '.') != "" + # slave_ip._invoke('destroy', '.') + #end + #slave_ip.delete + slave_ip._eval_without_enc('exit') end top.destroy if top.winfo_exist? } @@ -763,15 +763,15 @@ class MultiTkIp fc.bindtags = fc.bindtags.unshift(tag) TkFrame.new(fc, :bd=>0){|f| - TkButton.new(f, - :text=>'Delete', :bd=>1, :padx=>2, :pady=>0, - :highlightthickness=>0, :command=>slave_delete_proc - ).pack(:side=>:right, :fill=>:both) - f.pack(:side=>:right, :fill=>:both, :expand=>true) + TkButton.new(f, + :text=>'Delete', :bd=>1, :padx=>2, :pady=>0, + :highlightthickness=>0, :command=>slave_delete_proc + ).pack(:side=>:right, :fill=>:both) + f.pack(:side=>:right, :fill=>:both, :expand=>true) } TkLabel.new(fc, :text=>msg, :padx=>2, :pady=>0, - :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true) + :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true) fc.pack(:side=>:bottom, :fill=>:x) } @@ -803,11 +803,11 @@ class MultiTkIp if tk_opts tk_opts = __check_safetk_optkeys(tk_opts) if tk_opts.key?('use') - @slave_ip_top[ip_name] = '' + @slave_ip_top[ip_name] = '' else - tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name, - tk_opts) - @slave_ip_top[ip_name] = top_path + tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name, + tk_opts) + @slave_ip_top[ip_name] = top_path end @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}") else @@ -816,13 +816,13 @@ class MultiTkIp if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook) @interp._eval("::safe::interpConfigure #{ip_name} " + - _keys2opts(safe_opts)) + _keys2opts(safe_opts)) else @interp._eval("::safe::interpConfigure #{ip_name} " + - _keys2opts(safe_opts) + '-deleteHook {' + - TkComm._get_eval_string(proc{|slave| - self._default_delete_hook(slave) - }) + '}') + _keys2opts(safe_opts) + '-deleteHook {' + + TkComm._get_eval_string(proc{|slave| + self._default_delete_hook(slave) + }) + '}') end [slave_ip, ip_name] @@ -890,34 +890,34 @@ class MultiTkIp @ip_name = nil if safe - safe = $SAFE if safe < $SAFE - @safe_level = [safe] + safe = $SAFE if safe < $SAFE + @safe_level = [safe] else - @safe_level = [$SAFE] + @safe_level = [$SAFE] end else # create slave-ip if safeip || master.safe? - @safe_base = true - @interp, @ip_name = master.__create_safe_slave_obj(safe_opts, - name, tk_opts) - if safe - safe = master.safe_level if safe < master.safe_level - @safe_level = [safe] - else - @safe_level = [4] - end + @safe_base = true + @interp, @ip_name = master.__create_safe_slave_obj(safe_opts, + name, tk_opts) + if safe + safe = master.safe_level if safe < master.safe_level + @safe_level = [safe] + else + @safe_level = [4] + end else - @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts) - if safe - safe = master.safe_level if safe < master.safe_level - @safe_level = [safe] - else - @safe_level = [master.safe_level] - end + @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts) + if safe + safe = master.safe_level if safe < master.safe_level + @safe_level = [safe] + else + @safe_level = [master.safe_level] + end end @set_alias_proc = proc{|name| - master._invoke('interp', 'alias', @ip_name, name, '', name) + master._invoke('interp', 'alias', @ip_name, name, '', name) }.freeze end @@ -959,22 +959,22 @@ class MultiTkIp if @slave_ip_top[slave].kind_of?(String) # call default hook of safetk.tcl (ignore exceptions) if @slave_ip_top[slave] == '' - begin - @interp._eval("::safe::disallowTk #{slave}") - rescue - warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG - end + begin + @interp._eval("::safe::disallowTk #{slave}") + rescue + warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG + end else # toplevel path - begin - @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}") - rescue - warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG - begin - @interp._eval("destroy #{@slave_ip_top[slave]}") - rescue - warn("Waring: fail to destroy toplevel") if $DEBUG - end - end + begin + @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}") + rescue + warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG + begin + @interp._eval("destroy #{@slave_ip_top[slave]}") + rescue + warn("Waring: fail to destroy toplevel") if $DEBUG + end + end end end @slave_ip_tbl.delete(slave) @@ -998,8 +998,8 @@ class MultiTkIp else ip = @@IP_TABLE[Thread.current.group] unless ip - fail SecurityError, - "cannot call Tk methods on #{Thread.current.inspect}" + fail SecurityError, + "cannot call Tk methods on #{Thread.current.inspect}" end ip end @@ -1019,7 +1019,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end elsif safe == nil # do nothing @@ -1040,7 +1040,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end elsif safe == nil # do nothing @@ -1060,7 +1060,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end else raise ArgumentError, "unexpected argument(s)" @@ -1082,9 +1082,9 @@ class MultiTkIp s << ':master' else if @interp.safe? - s << ':safe-slave' + s << ':safe-slave' else - s << ':trusted-slave' + s << ':trusted-slave' end end s << '>' @@ -1144,11 +1144,11 @@ class MultiTkIp def slaves(all = false) @interp._invoke('interp','slaves').split.map!{|name| if @slave_ip_tbl.key?(name) - @slave_ip_tbl[name] + @slave_ip_tbl[name] elsif all - name + name else - nil + nil end }.compact! end @@ -1197,9 +1197,9 @@ class MultiTkIp init_ip_env.each{|script| script.call(self)} add_tk_procs.each{|name, args, body| if master? - @interp._invoke('proc', name, args, body) if args && body + @interp._invoke('proc', name, args, body) if args && body else - @set_alias_proc.call(name) + @set_alias_proc.call(name) end } end @@ -1226,7 +1226,7 @@ class MultiTkIp @@TK_TABLE_LIST << obj obj.instance_eval <<-EOD def self.method_missing(m, *args) - MultiTkIp.tk_object_table(#{id}).__send__(m, *args) + MultiTkIp.tk_object_table(#{id}).__send__(m, *args) end EOD obj.freeze @@ -1285,23 +1285,23 @@ class MultiTkIp # on IP thread if (@cmd_receiver == Thread.current) begin - ret = cmd.call(*args) + ret = cmd.call(*args) rescue SystemExit - # exit IP - warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG - begin - self._eval_without_enc('exit') - rescue Exception - end - self.delete - ret = nil + # exit IP + warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG + begin + self._eval_without_enc('exit') + rescue Exception + end + self.delete + ret = nil rescue Exception => e - if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - ret = e + if $DEBUG + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + ret = e end return ret end @@ -1309,15 +1309,15 @@ class MultiTkIp # send cmd to the proc-queue unless req_val begin - @cmd_queue.enq([nil, cmd, *args]) + @cmd_queue.enq([nil, cmd, *args]) rescue Exception => e - # ignore - if $DEBUG || true - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - return e + # ignore + if $DEBUG || true + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + return e end return nil end @@ -1333,20 +1333,20 @@ class MultiTkIp # exit IP warn("Warning: " + $! + " on " + self.inspect) if $DEBUG begin - self._eval_without_enc('exit') + self._eval_without_enc('exit') rescue Exception end if !safe? && allow_ruby_exit? - self.delete - fail e + self.delete + fail e else - self.delete + self.delete end rescue Exception => e if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) end return e end @@ -1388,14 +1388,14 @@ class MultiTkIp cmd = Proc.new else unless (cmd = args.shift) - fail ArgumentError, "A Proc or Method object is expected for 1st argument" + fail ArgumentError, "A Proc or Method object is expected for 1st argument" end end eval_proc_core(true, - proc{|safe, *params| - $SAFE=safe; Thread.new(*params, &cmd).value - }, - *args) + proc{|safe, *params| + $SAFE=safe; Thread.new(*params, &cmd).value + }, + *args) end alias call eval_proc @@ -1404,15 +1404,15 @@ class MultiTkIp cmd = Proc.new else unless (cmd = args.shift) - fail ArgumentError, "A Proc or Method object is expected for 1st argument" + fail ArgumentError, "A Proc or Method object is expected for 1st argument" end end Thread.new{ eval_proc_core(false, - proc{|safe, *params| - $SAFE=safe; Thread.new(*params, &cmd).value - }, - *args) + proc{|safe, *params| + $SAFE=safe; Thread.new(*params, &cmd).value + }, + *args) } end alias background_eval_proc bg_eval_proc @@ -1436,7 +1436,7 @@ class MultiTkIp end Thread.new{ eval_proc_core(true, - proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)}) + proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)}) } end alias background_eval_string bg_eval_string @@ -1723,35 +1723,35 @@ class MultiTkIp #return self if self != @@DEFAULT_MASTER if self != @@DEFAULT_MASTER if @wait_on_mainloop[0] - begin - @wait_on_mainloop[1] = true - @cmd_queue.enq([@system, 'call_mainloop', - Thread.current, check_root]) - Thread.stop - rescue MultiTkIp_OK => ret - # return value - @wait_on_mainloop[1] = false - return ret.value.value - rescue SystemExit - # exit IP - warn("Warning: " + $! + " on " + self.inspect) if $DEBUG - @wait_on_mainloop[1] = false - begin - self._eval_without_enc('exit') - rescue Exception - end - self.delete - rescue Exception => e - if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - @wait_on_mainloop[1] = false - return e - ensure - @wait_on_mainloop[1] = false - end + begin + @wait_on_mainloop[1] = true + @cmd_queue.enq([@system, 'call_mainloop', + Thread.current, check_root]) + Thread.stop + rescue MultiTkIp_OK => ret + # return value + @wait_on_mainloop[1] = false + return ret.value.value + rescue SystemExit + # exit IP + warn("Warning: " + $! + " on " + self.inspect) if $DEBUG + @wait_on_mainloop[1] = false + begin + self._eval_without_enc('exit') + rescue Exception + end + self.delete + rescue Exception => e + if $DEBUG + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + @wait_on_mainloop[1] = false + return e + ensure + @wait_on_mainloop[1] = false + end end return end @@ -1762,27 +1762,27 @@ class MultiTkIp @wait_on_mainloop[1] = false else begin - @wait_on_mainloop[1] = true - loop do - break unless self.alive? - if check_root - begin - break if TclTkLib.num_of_mainwindows == 0 - rescue Exception - break - end - end - @interp.mainloop(check_root) - end + @wait_on_mainloop[1] = true + loop do + break unless self.alive? + if check_root + begin + break if TclTkLib.num_of_mainwindows == 0 + rescue Exception + break + end + end + @interp.mainloop(check_root) + end #rescue StandardError rescue Exception - if TclTkLib.mainloop_abort_on_exception != nil - STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect, - " exception (ignore) : ", $!.message, "\n"); - end - retry + if TclTkLib.mainloop_abort_on_exception != nil + STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect, + " exception (ignore) : ", $!.message, "\n"); + end + retry ensure - @wait_on_mainloop[1] = false + @wait_on_mainloop[1] = false end end self @@ -1813,36 +1813,36 @@ class MultiTkIp _destroy_slaves_of_slaveIP(subip) =begin begin - subip._invoke('destroy', '.') unless subip.deleted? + subip._invoke('destroy', '.') unless subip.deleted? rescue Exception end =end begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") + subip._eval_without_enc("foreach i [after info] {after cancel $i}") rescue Exception end # safe_base? if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end end if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end else - begin - subip.delete unless subip.deleted? - rescue Exception - end + begin + subip.delete unless subip.deleted? + rescue Exception + end end } @@ -1872,9 +1872,9 @@ class MultiTkIp def abort(msg = nil) if master? if msg - Kernel.abort(msg) + Kernel.abort(msg) else - Kernel.abort + Kernel.abort end else # ignore msg @@ -2076,7 +2076,7 @@ class MultiTkIp def def_alias(slave, new_cmd, org_cmd, *args) ret = @interp._invoke('interp', 'alias', _slavearg(slave), new_cmd, - '', org_cmd, *args) + '', org_cmd, *args) (ret == new_cmd)? self: nil end def self.def_alias(slave, new_cmd, org_cmd, *args) @@ -2161,7 +2161,7 @@ class MultiTkIp def invoke_hidden_on_global(slave, cmd, *args) @interp._invoke('interp', 'invokehidden', _slavearg(slave), - '-global', cmd, *args) + '-global', cmd, *args) end def self.invoke_hidden_on_global(slave, cmd, *args) __getip.invoke_hidden_on_global(slave, cmd, *args) @@ -2178,7 +2178,7 @@ class MultiTkIp def recursion_limit(slave = '', limit = None) number(@interp._invoke('interp', 'recursionlimit', - _slavearg(slave), limit)) + _slavearg(slave), limit)) end def self.recursion_limit(slave = '', limit = None) __getip.recursion_limit(slave) @@ -2279,7 +2279,7 @@ class MultiTkIp ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + _keys2opts(slot)) else ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + - "-#{slot} #{_get_eval_string(value)}") + "-#{slot} #{_get_eval_string(value)}") end self end @@ -2289,28 +2289,28 @@ class MultiTkIp ret = {} if slot conf = _lst2ary(ip._eval("::safe::interpConfigure " + - @ip_name + " -#{slot}")) + @ip_name + " -#{slot}")) if conf[0] == '-deleteHook' - if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/ - ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1] - else - ret[conf[0][1..-1]] = conf[1] - end + if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/ + ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[conf[0][1..-1]] = conf[1] + end else - ret[conf[0][1..-1]] = conf[1] + ret[conf[0][1..-1]] = conf[1] end else Hash[*_lst2ary(ip._eval("::safe::interpConfigure " + - @ip_name))].each{|k, v| - if k == '-deleteHook' - if v =~ /^rb_out\S* (c(_\d+_)?\d+)/ - ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1] - else - ret[k[1..-1]] = v - end - else - ret[k[1..-1]] = v - end + @ip_name))].each{|k, v| + if k == '-deleteHook' + if v =~ /^rb_out\S* (c(_\d+_)?\d+)/ + ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[k[1..-1]] = v + end + else + ret[k[1..-1]] = v + end } end ret diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb index 77dbacfb1..1ef5310bd 100644 --- a/ext/tk/lib/remote-tk.rb +++ b/ext/tk/lib/remote-tk.rb @@ -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 diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index a5d2645e9..5fa466592 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1,7 +1,7 @@ # -# tk.rb - Tk interface module using tcltklib -# $Date$ -# by Yukihiro Matsumoto <matz@netlab.jp> +# tk.rb - Tk interface module using tcltklib +# $Date$ +# by Yukihiro Matsumoto <matz@netlab.jp> # use Shigehiro's tcltklib require 'tcltklib' @@ -96,32 +96,32 @@ module TkComm else # ruby_class == nil mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)} mods.each{|mod| - begin - mod.const_get(tk_class) # auto_load - break if (ruby_class = WidgetClassNames[tk_class]) - rescue LoadError - # ignore load error - end + begin + mod.const_get(tk_class) # auto_load + break if (ruby_class = WidgetClassNames[tk_class]) + rescue LoadError + # ignore load error + end } unless ruby_class - std_class = 'Tk' << tk_class - if Object.const_defined?(std_class) - Object.const_get(std_class) # auto_load - ruby_class = WidgetClassNames[tk_class] - end + std_class = 'Tk' << tk_class + if Object.const_defined?(std_class) + Object.const_get(std_class) # auto_load + ruby_class = WidgetClassNames[tk_class] + end end if ruby_class - # found - ruby_class_name = ruby_class.name - gen_class_name = ruby_class_name - classname_def = '' + # found + ruby_class_name = ruby_class.name + gen_class_name = ruby_class_name + classname_def = '' else - # unknown - ruby_class_name = 'TkWindow' - gen_class_name = 'TkWidget_' + tk_class - classname_def = "WidgetClassName = '#{tk_class}'.freeze" + # unknown + ruby_class_name = 'TkWindow' + gen_class_name = 'TkWidget_' + tk_class + classname_def = "WidgetClassName = '#{tk_class}'.freeze" end end @@ -135,19 +135,19 @@ module TkComm else mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)} if mod - ruby_class_name = mod.name + '::' + tk_class - gen_class_name = ruby_class_name - classname_def = '' + ruby_class_name = mod.name + '::' + tk_class + gen_class_name = ruby_class_name + classname_def = '' elsif Object.const_defined?('Tk' + tk_class) - ruby_class_name = 'Tk' + tk_class - # gen_class_name = ruby_class_name + 'GeneratedOnTk' - gen_class_name = ruby_class_name - classname_def = '' + ruby_class_name = 'Tk' + tk_class + # gen_class_name = ruby_class_name + 'GeneratedOnTk' + gen_class_name = ruby_class_name + classname_def = '' else - ruby_class_name = 'TkWindow' - # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk' - gen_class_name = 'TkWidget_' + tk_class - classname_def = "WidgetClassName = '#{tk_class}'.freeze" + ruby_class_name = 'TkWindow' + # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk' + gen_class_name = 'TkWidget_' + tk_class + classname_def = "WidgetClassName = '#{tk_class}'.freeze" end end =end @@ -165,9 +165,9 @@ module TkComm gen_class_name.split('::').each{|klass| next if klass == '' if base.const_defined?(klass) - base = base.class_eval klass + base = base.class_eval klass else - base = base.class_eval "class #{klass}<#{ruby_class_name} + base = base.class_eval "class #{klass}<#{ruby_class_name} #{classname_def} end #{klass}" @@ -215,19 +215,19 @@ module TkComm val.gsub(/\\ /, ' ') when /[^\\] / if listobj - tk_split_escstr(val).collect{|elt| - tk_tcl2ruby(elt, enc_mode, listobj) - } + tk_split_escstr(val).collect{|elt| + tk_tcl2ruby(elt, enc_mode, listobj) + } elsif enc_mode - _fromUTF8(val) + _fromUTF8(val) else - val + val end else if enc_mode - _fromUTF8(val) + _fromUTF8(val) else - val + val end end end @@ -288,14 +288,14 @@ if USE_TCLs_LIST_FUNCTIONS dst = ary.collect{|e| if e.kind_of? Array - array2tk_list(e) + array2tk_list(e) elsif e.kind_of? Hash - tmp_ary = [] - #e.each{|k,v| tmp_ary << k << v } - e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } - array2tk_list(tmp_ary) + tmp_ary = [] + #e.each{|k,v| tmp_ary << k << v } + e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } + array2tk_list(tmp_ary) else - _get_eval_string(e) + _get_eval_string(e) end } TkCore::INTERP._merge_tklist(*dst) @@ -402,7 +402,7 @@ else if c == '\\' && !escape escape = true token = (token || "") << c if brace > 0 - next + next end brace += 1 if c == '{' && !escape brace -= 1 if c == '}' && !escape @@ -421,14 +421,14 @@ else def array2tk_list(ary) ary.collect{|e| if e.kind_of? Array - "{#{array2tk_list(e)}}" + "{#{array2tk_list(e)}}" elsif e.kind_of? Hash - # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}" - e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } - array2tk_list(tmp_ary) + # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}" + e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } + array2tk_list(tmp_ary) else - s = _get_eval_string(e) - (s.index(/\s/) || s.size == 0)? "{#{s}}": s + s = _get_eval_string(e) + (s.index(/\s/) || s.size == 0)? "{#{s}}": s end }.join(" ") end @@ -466,13 +466,13 @@ end dst = [] if keys and keys != None keys.each{|k, v| - #dst.push("-#{k}") - dst.push('-' + k.to_s) - if v != None - # v = _get_eval_string(v, enc_mode) if (enc_mode || flat) - v = _get_eval_string(v, enc_mode) if enc_mode - dst.push(v) - end + #dst.push("-#{k}") + dst.push('-' + k.to_s) + if v != None + # v = _get_eval_string(v, enc_mode) if (enc_mode || flat) + v = _get_eval_string(v, enc_mode) if enc_mode + dst.push(v) + end } end if conf @@ -600,7 +600,7 @@ end else str = str.to_s() || '' unless str.kind_of? String - fail RuntimeError, "fail to convert the object to a string" + fail RuntimeError, "fail to convert the object to a string" end str = _toUTF8(str) if enc_mode end @@ -634,14 +634,14 @@ end nil else if (obj.respond_to?(:to_eval)) - (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval + (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval else - begin - obj = obj.to_s || '' - rescue - fail RuntimeError, "fail to convert object '#{obj}' to string" - end - (enc_mode)? _toUTF8(obj): obj + begin + obj = obj.to_s || '' + rescue + fail RuntimeError, "fail to convert object '#{obj}' to string" + end + (enc_mode)? _toUTF8(obj): obj end end end @@ -751,12 +751,12 @@ end def install_win(ppath,name=nil) if name if name == '' - raise ArgumentError, "invalid wiget-name '#{name}'" + raise ArgumentError, "invalid wiget-name '#{name}'" end if name[0] == ?. - @path = '' + name - @path.freeze - return TkCore::INTERP.tk_windows[@path] = self + @path = '' + name + @path.freeze + return TkCore::INTERP.tk_windows[@path] = self end else name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1] @@ -800,11 +800,11 @@ module TkComm end if context.kind_of? Array context = context.collect{|ev| - if ev.kind_of? TkVirtualEvent - ev.path - else - ev - end + if ev.kind_of? TkVirtualEvent + ev.path + else + ev + end }.join("><") end if /,/ =~ context @@ -818,7 +818,7 @@ module TkComm id = install_bind(cmd, args) if cmd begin tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", - mode + id])) + mode + id])) rescue uninstall_cmd(id) if cmd fail @@ -840,26 +840,26 @@ module TkComm def _bindinfo(what, context=nil) if context tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline| - if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/ - #[Tk_CMDTBL[$1], $2] - [TkCore::INTERP.tk_cmd_tbl[$1], $2] - else - cmdline - end + if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/ + #[Tk_CMDTBL[$1], $2] + [TkCore::INTERP.tk_cmd_tbl[$1], $2] + else + cmdline + end } else tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq| - l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| - case (subseq) - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(subseq[1..-2]) - when /^<[^<>]+>$/ - subseq[1..-2] - else - subseq.split('') - end - }.flatten - (l.size == 1) ? l[0] : l + l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| + case (subseq) + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(subseq[1..-2]) + when /^<[^<>]+>$/ + subseq[1..-2] + else + subseq.split('') + end + }.flatten + (l.size == 1) ? l[0] : l } end end @@ -868,7 +868,7 @@ module TkComm id = install_bind_for_event_class(klass, cmd, args) if cmd begin tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", - mode + id])) + mode + id])) rescue uninstall_cmd(id) if cmd fail @@ -950,9 +950,9 @@ module TkCore end if self.const_defined? :IP_OPTS if IP_OPTS.kind_of?(Hash) - opts = hash_kv(IP_OPTS).join(' ') + opts = hash_kv(IP_OPTS).join(' ') else - opts = IP_OPTS.to_s + opts = IP_OPTS.to_s end else opts = '' @@ -974,25 +974,25 @@ module TkCore @add_tk_procs = [].taint # table of [name, args, body] @cb_entry_class = Class.new(TkCallbackEntry){|c| - class << c - def inspect - sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__) - end - alias to_s inspect - end - - def initialize(ip, cmd) - @ip = ip - @cmd = cmd - end - attr_reader :ip, :cmd - def call(*args) - @ip.cb_eval(@cmd, *args) - end - def inspect - sprintf("#<cb_entry:%0x>", self.__id__) - end - alias to_s inspect + class << c + def inspect + sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__) + end + alias to_s inspect + end + + def initialize(ip, cmd) + @ip = ip + @cmd = cmd + end + attr_reader :ip, :cmd + def call(*args) + @ip.cb_eval(@cmd, *args) + end + def inspect + sprintf("#<cb_entry:%0x>", self.__id__) + end + alias to_s inspect }.freeze } @@ -1008,10 +1008,10 @@ module TkCore class Tk_OBJECT_TABLE def initialize(id) - @id = id + @id = id end def method_missing(m, *args, &b) - TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b) + TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b) end end @@ -1025,7 +1025,7 @@ module TkCore # obj = Object.new # obj.instance_eval <<-EOD # def self.method_missing(m, *args) -# TkCore::INTERP.tk_object_table(#{id}).send(m, *args) +# TkCore::INTERP.tk_object_table(#{id}).send(m, *args) # end # EOD # return obj @@ -1056,23 +1056,23 @@ module TkCore WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>' INTERP._invoke_without_enc('event', 'add', - "<#{WIDGET_DESTROY_HOOK}>", 'Destroy') + "<#{WIDGET_DESTROY_HOOK}>", 'Destroy') INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>", - install_bind(proc{|xpath| - path = xpath[1..-1] - unless TkCore::INTERP.deleted? - if (widget = TkCore::INTERP.tk_windows[path]) - if widget.respond_to?(:__destroy_hook__) - begin - widget.__destroy_hook__ - rescue Exception - end - end - end - end - }, 'x%W')) + install_bind(proc{|xpath| + path = xpath[1..-1] + unless TkCore::INTERP.deleted? + if (widget = TkCore::INTERP.tk_windows[path]) + if widget.respond_to?(:__destroy_hook__) + begin + widget.__destroy_hook__ + rescue Exception + end + end + end + end + }, 'x%W')) INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '', - "bind all <#{WIDGET_DESTROY_HOOK}> {}") + "bind all <#{WIDGET_DESTROY_HOOK}> {}") INTERP.add_tk_procs('rb_out', 'args', <<-'EOL') if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} { @@ -1087,7 +1087,7 @@ module TkCore return -code $st $ret } } else { - return $ret + return $ret } EOL =begin @@ -1108,7 +1108,7 @@ module TkCore return -code $st $ret } } else { - return $ret + return $ret } EOL =end @@ -1132,17 +1132,17 @@ module TkCore 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 @@ -1153,7 +1153,7 @@ module TkCore arg = tk_split_simplelist(arg_str) #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], - # *arg)) + # *arg)) # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) begin TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) @@ -1169,17 +1169,17 @@ module TkCore # cb_obj.call(*arg) # else # begin -# raise 'check backtrace' +# raise 'check backtrace' # rescue -# # ignore backtrace before 'callback' -# pos = -($!.backtrace.size) +# # ignore backtrace before 'callback' +# pos = -($!.backtrace.size) # end # begin -# cb_obj.call(*arg) +# cb_obj.call(*arg) # 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 #=end @@ -1203,10 +1203,10 @@ module TkCore # return # if false #defined? Thread # Thread.start do -# ms = Float(ms)/1000 -# ms = 10 if ms == 0 -# sleep ms/1000 -# cmd.call +# ms = Float(ms)/1000 +# ms = 10 if ms == 0 +# sleep ms/1000 +# cmd.call # end # else # cmdid = install_cmd(cmd) @@ -1383,11 +1383,11 @@ module TkCore #window = window.path if window.kind_of?(TkObject) if keys tk_call_without_enc('event', 'generate', window, - "<#{tk_event_sequence(context)}>", - *hash_kv(keys, true)) + "<#{tk_event_sequence(context)}>", + *hash_kv(keys, true)) else tk_call_without_enc('event', 'generate', window, - "<#{tk_event_sequence(context)}>") + "<#{tk_event_sequence(context)}>") end nil end @@ -1488,10 +1488,10 @@ module TkCore #res = INTERP._invoke(*args).taint #res = INTERP._invoke(enc_mode, *args) res = _ip_invoke_core(enc_mode, *args) - # >>>>> _invoke returns a TAINTED string <<<<< + # >>>>> _invoke returns a TAINTED string <<<<< rescue StandardError => err2 - fail err2 unless /^invalid command/ =~ err2.message - fail err + fail err2 unless /^invalid command/ =~ err2.message + fail err end end if INTERP._return_value() != 0 @@ -1535,7 +1535,7 @@ module Tk TK_MINOR_VERSION = minor.to_i JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands", - "kanji") != "").freeze + "kanji") != "").freeze def Tk.const_missing(sym) case(sym) @@ -1560,11 +1560,11 @@ module Tk when :PLATFORM, :TCL_PLATFORM if $SAFE >= 4 - fail SecurityError, "can't get #{sym} when $SAFE >= 4" + fail SecurityError, "can't get #{sym} when $SAFE >= 4" end INTERP._invoke_without_enc('global', 'tcl_platform') Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', - 'tcl_platform'))] + 'tcl_platform'))] when :ENV INTERP._invoke_without_enc('global', 'env') @@ -1583,22 +1583,22 @@ module Tk when :PRIV, :PRIVATE, :TK_PRIV priv = {} if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != "" - var_nam = 'tk::Priv' + var_nam = 'tk::Priv' else - var_nam = 'tkPriv' + var_nam = 'tkPriv' end INTERP._invoke_without_enc('global', var_nam) Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', - var_nam))].each{|k,v| - k.freeze - case v - when /^-?\d+$/ - priv[k] = v.to_i - when /^-?\d+\.?\d*(e[-+]?\d+)?$/ - priv[k] = v.to_f - else - priv[k] = v.freeze - end + var_nam))].each{|k,v| + k.freeze + case v + when /^-?\d+$/ + priv[k] = v.to_i + when /^-?\d+\.?\d*(e[-+]?\d+)?$/ + priv[k] = v.to_f + else + priv[k] = v.freeze + end } priv @@ -1618,8 +1618,8 @@ module Tk case code[0] when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP' begin - pid = Integer(code[1]) - code[1] = pid + pid = Integer(code[1]) + code[1] = pid rescue end end @@ -1840,45 +1840,45 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) def _toUTF8(str, encoding = nil) # decide encoding if encoding - encoding = encoding.to_s + encoding = encoding.to_s elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil - encoding = str.encoding.to_s + encoding = str.encoding.to_s elsif str.instance_variable_get(:@encoding) - encoding = str.instance_variable_get(:@encoding).to_s + encoding = str.instance_variable_get(:@encoding).to_s elsif defined?(@encoding) && @encoding != nil - encoding = @encoding.to_s + encoding = @encoding.to_s else - encoding = __invoke('encoding', 'system') + encoding = __invoke('encoding', 'system') end # convert case encoding when 'utf-8', 'binary' - str + str else - __toUTF8(str, encoding) + __toUTF8(str, encoding) end end def _fromUTF8(str, encoding = nil) unless encoding - if defined?(@encoding) && @encoding != nil - encoding = @encoding.to_s - else - encoding = __invoke('encoding', 'system') - end + if defined?(@encoding) && @encoding != nil + encoding = @encoding.to_s + else + encoding = __invoke('encoding', 'system') + end end if str.kind_of?(Tk::EncodedString) - if str.encoding == 'binary' - str - else - __fromUTF8(str, encoding) - end + if str.encoding == 'binary' + str + else + __fromUTF8(str, encoding) + end elsif str.instance_variable_get(:@encoding).to_s == 'binary' - str + str else - __fromUTF8(str, encoding) + __fromUTF8(str, encoding) end end =end @@ -1897,53 +1897,53 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) =begin def _eval(cmd) if defined?(@encoding) && @encoding != 'utf-8' - ret = if cmd.kind_of?(Tk::EncodedString) - case cmd.encoding - when 'utf-8', 'binary' - __eval(cmd) - else - __eval(_toUTF8(cmd, cmd.encoding)) - end - elsif cmd.instance_variable_get(:@encoding) == 'binary' - __eval(cmd) - else - __eval(_toUTF8(cmd, @encoding)) - end - if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' - ret - else - _fromUTF8(ret, @encoding) - end + ret = if cmd.kind_of?(Tk::EncodedString) + case cmd.encoding + when 'utf-8', 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, cmd.encoding)) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, @encoding)) + end + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret + else + _fromUTF8(ret, @encoding) + end else - __eval(cmd) + __eval(cmd) end end def _invoke(*cmds) if defined?(@encoding) && @encoding != 'utf-8' - cmds = cmds.collect{|cmd| - if cmd.kind_of?(Tk::EncodedString) - case cmd.encoding - when 'utf-8', 'binary' - cmd - else - _toUTF8(cmd, cmd.encoding) - end - elsif cmd.instance_variable_get(:@encoding) == 'binary' - cmd - else - _toUTF8(cmd, @encoding) - end - } - ret = __invoke(*cmds) - if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' - ret - else - _fromUTF8(ret, @encoding) - end + cmds = cmds.collect{|cmd| + if cmd.kind_of?(Tk::EncodedString) + case cmd.encoding + when 'utf-8', 'binary' + cmd + else + _toUTF8(cmd, cmd.encoding) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + cmd + else + _toUTF8(cmd, @encoding) + end + } + ret = __invoke(*cmds) + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret + else + _fromUTF8(ret, @encoding) + end else - __invoke(*cmds) - end + __invoke(*cmds) + end end =end end @@ -1955,39 +1955,39 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) TkCommandNames = ['encoding'.freeze].freeze def encoding=(name) - TkCore::INTERP.encoding = name + TkCore::INTERP.encoding = name end def encoding - TkCore::INTERP.encoding + TkCore::INTERP.encoding end def encoding_names - tk_split_simplelist(tk_call('encoding', 'names')) + tk_split_simplelist(tk_call('encoding', 'names')) end def encoding_system - tk_call('encoding', 'system') + tk_call('encoding', 'system') end def encoding_system=(enc) - tk_call('encoding', 'system', enc) + tk_call('encoding', 'system', enc) end def encoding_convertfrom(str, enc=nil) - # str must be a Tcl's internal string expression in enc. - # the return value is a UTF-8 string. - enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) + # str must be a Tcl's internal string expression in enc. + # the return value is a UTF-8 string. + enc = encoding_system unless enc + TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) end alias encoding_convert_from encoding_convertfrom def encoding_convertto(str, enc=nil) - # str must be a UTF-8 string. - # The return value is a Tcl's internal string expression in enc. + # str must be a UTF-8 string. + # The return value is a Tcl's internal string expression in enc. # To get an usual enc string, use Tk.fromUTF8(ret_val, enc). - enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) + enc = encoding_system unless enc + TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) end alias encoding_convert_to encoding_convertto end @@ -2026,28 +2026,28 @@ else extend Encoding def encoding=(name) - nil + nil end def encoding - nil + nil end def encoding_names - nil + nil end def encoding_system - nil + nil end def encoding_system=(enc) - nil + nil end def encoding_convertfrom(str, enc=None) - str + str end alias encoding_convert_from encoding_convertfrom def encoding_convertto(str, enc=None) - str + str end alias encoding_convert_to encoding_convertto end @@ -2098,19 +2098,19 @@ module TkTreatFont if key pathname = [win, tag, key].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *__config_cmd) + TkFont.init_widget_font(pathname, *__config_cmd) elsif optkeys.size == 1 pathname = [win, tag, optkeys[0]].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *__config_cmd) + TkFont.init_widget_font(pathname, *__config_cmd) 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, *__config_cmd) + key = key.to_s + pathname = [win, tag, key].join(';') + fonts[key] = + TkFont.used_on(pathname) || + TkFont.init_widget_font(pathname, *__config_cmd) } fonts end @@ -2129,38 +2129,38 @@ module TkTreatFont 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.call_font_configure([pathname, optkey], *(__config_cmd << {})) - 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) - - fnt.latin_replace(lfnt) if lfnt - fnt.kanji_replace(kfnt) if kfnt - - fnt.call_font_configure([pathname, optkey], - *(__config_cmd << {})) - next - else - fnt = hash_kv(fnt) if fnt.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << fnt)) - end - end - next - end + 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], *(__config_cmd << {})) + 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) + + fnt.latin_replace(lfnt) if lfnt + fnt.kanji_replace(kfnt) if kfnt + + fnt.call_font_configure([pathname, optkey], + *(__config_cmd << {})) + next + else + fnt = hash_kv(fnt) if fnt.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{optkey}" << fnt)) + end + end + next + end end lfnt = slot.delete(l_optkey) @@ -2168,12 +2168,12 @@ module TkTreatFont kfnt = slot.delete(k_optkey) if lfnt && kfnt - TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], - *(__config_cmd << {})) + TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], + *(__config_cmd << {})) elsif lfnt - latinfont_configure([lfnt, optkey]) + latinfont_configure([lfnt, optkey]) elsif kfnt - kanjifont_configure([kfnt, optkey]) + kanjifont_configure([kfnt, optkey]) end } @@ -2205,27 +2205,27 @@ module TkTreatFont 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 - ltn = hash_kv(ltn) if ltn.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << ltn)) - next + ltn = hash_kv(ltn) if ltn.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{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], *(__config_cmd << {})) @@ -2257,27 +2257,27 @@ module TkTreatFont 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 - knj = hash_kv(knj) if knj.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << knj)) - next + knj = hash_kv(knj) if knj.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{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], *(__config_cmd << {})) @@ -2288,15 +2288,15 @@ module TkTreatFont def font_copy(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 @@ -2311,22 +2311,22 @@ module TkTreatFont def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], - *(__config_cmd << {})) + *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) 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 @@ -2336,22 +2336,22 @@ module TkTreatFont def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], - *(__config_cmd << {})) + *(__config_cmd << {})) else - fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) + fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) 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 @@ -2426,16 +2426,16 @@ module TkConfigMethod keys.each{|k, v| optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s} if optkey - defkey, undefkey = optkey - if v - keys2[defkey.to_s] = None - elsif undefkey - keys2[undefkey.to_s] = None - else - # remove key - end + defkey, undefkey = optkey + if v + keys2[defkey.to_s] = None + elsif undefkey + keys2[undefkey.to_s] = None + else + # remove key + end else - keys2[k.to_s] = v + keys2[k.to_s] = v end } keys2 @@ -2466,9 +2466,9 @@ module TkConfigMethod case slot when /^(#{__numval_optkeys.join('|')})$/ begin - number(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) + number(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue - nil + nil end when /^(#{__numstrval_optkeys.join('|')})$/ @@ -2476,9 +2476,9 @@ module TkConfigMethod when /^(#{__boolval_optkeys.join('|')})$/ begin - bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) + bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue - nil + nil end when /^(#{__listval_optkeys.join('|')})$/ @@ -2487,9 +2487,9 @@ module TkConfigMethod when /^(#{__numlistval_optkeys.join('|')})$/ conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) if conf =~ /^[0-9+-]/ - list(conf) + list(conf) else - conf + conf end when /^(#{__strval_optkeys.join('|')})$/ @@ -2500,13 +2500,13 @@ module TkConfigMethod fontkey = $2 fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true) unless fnt.kind_of?(TkFont) - fnt = fontobj(fontkey) + fnt = fontobj(fontkey) end if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font + # obsolete; just for compatibility + fnt.kanji_font else - fnt + fnt end else @@ -2519,48 +2519,48 @@ module TkConfigMethod slot = _symbolkey2str(slot) __methodcall_optkeys.each{|key, method| - value = slot.delete(key.to_s) - self.__send__(method, value) if value + value = slot.delete(key.to_s) + self.__send__(method, value) if value } __keyonly_optkeys.each{|defkey, undefkey| - conf = slot.find{|kk, vv| kk == defkey.to_s} - if conf - k, v = conf - if v - slot[k] = None - else - slot[undefkey.to_s] = None if undefkey - slot.delete(k) - end - end + conf = slot.find{|kk, vv| kk == defkey.to_s} + if conf + k, v = conf + if v + slot[k] = None + else + slot[undefkey.to_s] = None if undefkey + slot.delete(k) + end + end } if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/}) - font_configure(slot) + font_configure(slot) elsif slot.size > 0 - tk_call(*(__config_cmd.concat(hash_kv(slot)))) + tk_call(*(__config_cmd.concat(hash_kv(slot)))) end else slot = slot.to_s if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} ) - defkey, undefkey = conf - if value - tk_call(*(__config_cmd << "-#{defkey}")) - elsif undefkey - tk_call(*(__config_cmd << "-#{undefkey}")) - end + defkey, undefkey = conf + if value + tk_call(*(__config_cmd << "-#{defkey}")) + elsif undefkey + tk_call(*(__config_cmd << "-#{undefkey}")) + end elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) - self.__send__(method, value) + self.__send__(method, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - if value == None - fontobj($2) - else - font_configure({slot=>value}) - end + if value == None + fontobj($2) + else + font_configure({slot=>value}) + end else - tk_call(*(__config_cmd << "-#{slot}" << value)) + tk_call(*(__config_cmd << "-#{slot}" << value)) end end self @@ -2573,529 +2573,529 @@ module TkConfigMethod def configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - conf[__configinfo_struct[:current_value]] = fontobj(fontkey) - elsif ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 \ - && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - conf + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + conf[__configinfo_struct[:current_value]] = fontobj(fontkey) + elsif ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 \ + && conf[__configinfo_struct[:alias]][0] == ?- ) + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + conf else - if slot - slot = slot.to_s - case slot - when /^(#{__methodcall_optkeys.keys.join('|')})$/ - method = _symbolkey2str(__methodcall_optkeys)[slot] - return [slot, '', '', '', self.__send__(method)] - - when /^(#{__numval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - conf[__configinfo_struct[:default_value]] = - num_or_str(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - conf[__configinfo_struct[:default_value]] = - simplelist(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = - list(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] \ - && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = - list(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__strval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - end - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 \ - && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - - conf - - else - ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - case conf[__configinfo_struct[:key]] - when /^(#{__strval_optkeys.join('|')})$/ - # do nothing - - when /^(#{__numval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - num_or_str(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - simplelist(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = - list(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] \ - && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = - list(conf[__configinfo_struct[:current_value]]) - end - - else - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - if conf[__configinfo_struct[:default_value]].index('{') - conf[__configinfo_struct[:default_value]] = - tk_split_list(conf[__configinfo_struct[:default_value]]) - else - conf[__configinfo_struct[:default_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) - end - end - if conf[__configinfo_struct[:current_value]] - if conf[__configinfo_struct[:current_value]].index('{') - conf[__configinfo_struct[:current_value]] = - tk_split_list(conf[__configinfo_struct[:current_value]]) - else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) - end - end - end - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 \ - && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - - conf - } - - __font_optkeys.each{|optkey| - optkey = optkey.to_s - fontconf = ret.assoc(optkey) - if fontconf && fontconf.size > 2 - ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} - fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) - ret.push(fontconf) - end - } - - __methodcall_optkeys.each{|optkey, method| - ret << [optkey.to_s, '', '', '', self.__send__(method)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__methodcall_optkeys.keys.join('|')})$/ + method = _symbolkey2str(__methodcall_optkeys)[slot] + return [slot, '', '', '', self.__send__(method)] + + when /^(#{__numval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + num_or_str(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + simplelist(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:default_value]] = + list(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] \ + && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:current_value]] = + list(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__strval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + end + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 \ + && conf[__configinfo_struct[:alias]][0] == ?- ) + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + + conf + + else + ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + case conf[__configinfo_struct[:key]] + when /^(#{__strval_optkeys.join('|')})$/ + # do nothing + + when /^(#{__numval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + num_or_str(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + simplelist(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:default_value]] = + list(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] \ + && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:current_value]] = + list(conf[__configinfo_struct[:current_value]]) + end + + else + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + if conf[__configinfo_struct[:default_value]].index('{') + conf[__configinfo_struct[:default_value]] = + tk_split_list(conf[__configinfo_struct[:default_value]]) + else + conf[__configinfo_struct[:default_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) + end + end + if conf[__configinfo_struct[:current_value]] + if conf[__configinfo_struct[:current_value]].index('{') + conf[__configinfo_struct[:current_value]] = + tk_split_list(conf[__configinfo_struct[:current_value]]) + else + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + end + end + end + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 \ + && conf[__configinfo_struct[:alias]][0] == ?- ) + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + + conf + } + + __font_optkeys.each{|optkey| + optkey = optkey.to_s + fontconf = ret.assoc(optkey) + if fontconf && fontconf.size > 2 + ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} + fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) + ret.push(fontconf) + end + } + + __methodcall_optkeys.each{|optkey, method| + ret << [optkey.to_s, '', '', '', self.__send__(method)] + } + + ret + end end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - conf[__configinfo_struct[:current_value]] = fontobj(fontkey) - { conf.shift => conf } - elsif ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 ) - if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + conf[__configinfo_struct[:current_value]] = fontobj(fontkey) + { conf.shift => conf } + elsif ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 ) + if conf[__configinfo_struct[:alias]][0] == ?- + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end else - if slot - slot = slot.to_s - case slot - when /^(#{__methodcall_optkeys.keys.join('|')})$/ - method = _symbolkey2str(__methodcall_optkeys)[slot] - return {slot => ['', '', '', self.__send__(method)]} - - when /^(#{__numval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - num_or_str(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - simplelist(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = - list(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] \ - && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = - list(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__strval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}")))) - end - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 ) - if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end - - else - ret = {} - tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist| - conf = tk_split_simplelist(conflist) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - case conf[__configinfo_struct[:key]] - when /^(#{__strval_optkeys.join('|')})$/ - # do nothing - - when /^(#{__numval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - num_or_str(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = - simplelist(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = - list(conf[__configinfo_struct[:default_value]]) - end - if ( conf[__configinfo_struct[:current_value]] \ - && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = - list(conf[__configinfo_struct[:current_value]]) - end - - else - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - if conf[__configinfo_struct[:default_value]].index('{') - conf[__configinfo_struct[:default_value]] = - tk_split_list(conf[__configinfo_struct[:default_value]]) - else - conf[__configinfo_struct[:default_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) - end - end - if conf[__configinfo_struct[:current_value]] - if conf[__configinfo_struct[:current_value]].index('{') - conf[__configinfo_struct[:current_value]] = - tk_split_list(conf[__configinfo_struct[:current_value]]) - else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) - end - end - end - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 ) - if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - ret[conf[0]] = conf[1] - else - ret[conf.shift] = conf - end - } - - __font_optkeys.each{|optkey| - optkey = optkey.to_s - fontconf = ret[optkey] - if fontconf.kind_of?(Array) - ret.delete(optkey) - ret.delete('latin' << optkey) - ret.delete('ascii' << optkey) - ret.delete('kanji' << optkey) - fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) - ret[optkey] = fontconf - end - } - - __methodcall_optkeys.each{|optkey, method| - ret[optkey.to_s] = ['', '', '', self.__send__(method)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__methodcall_optkeys.keys.join('|')})$/ + method = _symbolkey2str(__methodcall_optkeys)[slot] + return {slot => ['', '', '', self.__send__(method)]} + + when /^(#{__numval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + num_or_str(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + simplelist(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:default_value]] = + list(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] \ + && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:current_value]] = + list(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__strval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}")))) + end + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 ) + if conf[__configinfo_struct[:alias]][0] == ?- + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end + + else + ret = {} + tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist| + conf = tk_split_simplelist(conflist) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + case conf[__configinfo_struct[:key]] + when /^(#{__strval_optkeys.join('|')})$/ + # do nothing + + when /^(#{__numval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + num_or_str(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + conf[__configinfo_struct[:default_value]] = + simplelist(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] ) + conf[__configinfo_struct[:current_value]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:default_value]] = + list(conf[__configinfo_struct[:default_value]]) + end + if ( conf[__configinfo_struct[:current_value]] \ + && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) + conf[__configinfo_struct[:current_value]] = + list(conf[__configinfo_struct[:current_value]]) + end + + else + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + if conf[__configinfo_struct[:default_value]].index('{') + conf[__configinfo_struct[:default_value]] = + tk_split_list(conf[__configinfo_struct[:default_value]]) + else + conf[__configinfo_struct[:default_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) + end + end + if conf[__configinfo_struct[:current_value]] + if conf[__configinfo_struct[:current_value]].index('{') + conf[__configinfo_struct[:current_value]] = + tk_split_list(conf[__configinfo_struct[:current_value]]) + else + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + end + end + end + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 ) + if conf[__configinfo_struct[:alias]][0] == ?- + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + ret[conf[0]] = conf[1] + else + ret[conf.shift] = conf + end + } + + __font_optkeys.each{|optkey| + optkey = optkey.to_s + fontconf = ret[optkey] + if fontconf.kind_of?(Array) + ret.delete(optkey) + ret.delete('latin' << optkey) + ret.delete('ascii' << optkey) + ret.delete('kanji' << optkey) + fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) + ret[optkey] = fontconf + end + } + + __methodcall_optkeys.each{|optkey, method| + ret[optkey.to_s] = ['', '', '', self.__send__(method)] + } + + ret + end end end end @@ -3103,31 +3103,31 @@ module TkConfigMethod def current_configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - org_slot = slot - begin - conf = configinfo(slot) - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - return {conf[0] => conf[-1]} - end - slot = conf[__configinfo_struct[:alias]] - end while(org_slot != slot) - fail RuntimeError, - "there is a configure alias loop about '#{org_slot}'" + org_slot = slot + begin + conf = configinfo(slot) + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + return {conf[0] => conf[-1]} + end + slot = conf[__configinfo_struct[:alias]] + end while(org_slot != slot) + fail RuntimeError, + "there is a configure alias loop about '#{org_slot}'" else - ret = {} - configinfo().each{|conf| - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - ret[conf[0]] = conf[-1] - end - } - ret + ret = {} + configinfo().each{|conf| + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + ret[conf[0]] = conf[-1] + end + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} - configinfo(slot).each{|key, conf| - ret[key] = conf[-1] if conf.kind_of?(Array) + configinfo(slot).each{|key, conf| + ret[key] = conf[-1] if conf.kind_of?(Array) } ret end @@ -3169,17 +3169,17 @@ class TkObject<TkKernel case args.length when 1 if name[-1] == ?= - configure name[0..-2], args[0] + configure name[0..-2], args[0] else - configure name, args[0] + configure name, args[0] end when 0 begin - cget(name) + cget(name) rescue - fail NameError, - "undefined local variable or method `#{name}' for #{self.to_s}", - error_at + fail NameError, + "undefined local variable or method `#{name}' for #{self.to_s}", + error_at end else fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at @@ -3200,14 +3200,14 @@ class TkObject<TkKernel def event_generate(context, keys=nil) if keys #tk_call('event', 'generate', path, - # "<#{tk_event_sequence(context)}>", *hash_kv(keys)) + # "<#{tk_event_sequence(context)}>", *hash_kv(keys)) tk_call_without_enc('event', 'generate', path, - "<#{tk_event_sequence(context)}>", - *hash_kv(keys, true)) + "<#{tk_event_sequence(context)}>", + *hash_kv(keys, true)) else #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>") tk_call_without_enc('event', 'generate', path, - "<#{tk_event_sequence(context)}>") + "<#{tk_event_sequence(context)}>") end end @@ -3277,24 +3277,24 @@ class TkWindow<TkObject #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key| # fontkeys[key] = keys.delete(key) if keys.key?(key) #} - __font_optkeys.each{|key| - fkey = key.to_s - fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey) + __font_optkeys.each{|key| + 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) + } - __methodcall_optkeys.each{|key| - key = key.to_s - methodkeys[key] = keys.delete(key) if keys.key?(key) - } + __methodcall_optkeys.each{|key| + key = key.to_s + methodkeys[key] = keys.delete(key) if keys.key?(key) + } end if without_creating && keys #configure(keys) @@ -3491,7 +3491,7 @@ class TkWindow<TkObject # ilist = list(tk_call('grid', 'columnconfigure', epath, index)) # info = {} # while key = ilist.shift - # info[key[1..-1]] = ilist.shift + # info[key[1..-1]] = ilist.shift # end # info #end @@ -3505,7 +3505,7 @@ class TkWindow<TkObject # ilist = list(tk_call('grid', 'rowconfigure', epath, index)) # info = {} # while key = ilist.shift - # info[key[1..-1]] = ilist.shift + # info[key[1..-1]] = ilist.shift # end # info #end @@ -3596,10 +3596,10 @@ class TkWindow<TkObject # conf #else # tk_split_simplelist(tk_call('place', - # 'configure', epath)).collect{|conflist| - # conf = tk_split_simplelist(conflist) - # conf[0] = conf[0][1..-1] - # conf + # 'configure', epath)).collect{|conflist| + # conf = tk_split_simplelist(conflist) + # conf[0] = conf[0][1..-1] + # conf # } #end TkPlace.configinfo(self, slot) @@ -3718,15 +3718,15 @@ class TkWindow<TkObject } if defined?(@cmdtbl) for id in @cmdtbl - uninstall_cmd id + uninstall_cmd id end end children.each{|path, obj| if defined?(@cmdtbl) - for id in @cmdtbl - uninstall_cmd id - end + for id in @cmdtbl + uninstall_cmd id + end end TkCore::INTERP.tk_windows.delete(path) } @@ -3801,17 +3801,17 @@ class TkWindow<TkObject taglist else list(tk_call('bindtags', path)).collect{|tag| - if tag.kind_of?(String) - if cls = WidgetClassNames[tag] - cls - elsif btag = TkBindTag.id2obj(tag) - btag - else - tag - end - else - tag - end + if tag.kind_of?(String) + if cls = WidgetClassNames[tag] + cls + elsif btag = TkBindTag.id2obj(tag) + btag + else + tag + end + else + tag + end } end end diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index ac297c8ce..1a8a7927d 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.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 - } - - 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 = 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 + + 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 - } - - 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 + 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 + + ret['coords'] = ['', '', '', self.coords(tagOrId)] + + 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 diff --git a/ext/tk/lib/tk/clock.rb b/ext/tk/lib/tk/clock.rb index 88b66129e..823b8a634 100644 --- a/ext/tk/lib/tk/clock.rb +++ b/ext/tk/lib/tk/clock.rb @@ -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 diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb index ac5ed2f17..d85b815dd 100644 --- a/ext/tk/lib/tk/composite.rb +++ b/ext/tk/lib/tk/composite.rb @@ -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 - - 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 - - super + 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 + + 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 else # slot == nil - 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 - - @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 - } - - info_list + 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 + + @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 + } + + 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 - - 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 - - super + 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 + + 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 else # slot == nil - info_list = super - - 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 - } - - @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 = super + + 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 + } + + @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 end end end diff --git a/ext/tk/lib/tk/console.rb b/ext/tk/lib/tk/console.rb index 855ee6a94..f0d2c7aa8 100644 --- a/ext/tk/lib/tk/console.rb +++ b/ext/tk/lib/tk/console.rb @@ -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 diff --git a/ext/tk/lib/tk/dialog.rb b/ext/tk/lib/tk/dialog.rb index d6355f21c..2ced26b19 100644 --- a/ext/tk/lib/tk/dialog.rb +++ b/ext/tk/lib/tk/dialog.rb @@ -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) diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb index 5eb989f42..aed0e7524 100644 --- a/ext/tk/lib/tk/encodedstr.rb +++ b/ext/tk/lib/tk/encodedstr.rb @@ -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 diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb index 0e45538c7..2a8a9d413 100644 --- a/ext/tk/lib/tk/entry.rb +++ b/ext/tk/lib/tk/entry.rb @@ -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' diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb index 9c46cb5d7..16adeedc6 100644 --- a/ext/tk/lib/tk/event.rb +++ b/ext/tk/lib/tk/event.rb @@ -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 diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 527584f1e..02e09c606 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -30,36 +30,36 @@ class TkFont if JAPANIZED_TK begin fontnames = tk_call('font', 'names') - case fontnames - when /defaultgui/ + case fontnames + when /defaultgui/ # Tcl/Tk-JP for Windows ltn = 'defaultgui' knj = 'defaultgui' - when /Mincho:Helvetica-Bold-12/ + when /Mincho:Helvetica-Bold-12/ # Tcl/Tk-JP for UNIX/X ltn, knj = tk_split_simplelist(tk_call('font', 'configure', 'Mincho:Helvetica-Bold-12', '-compound')) else # unknown Tcl/Tk-JP - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - #knj = 'k14' - #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' - knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - knj = 'mincho' - when 'macintosh' - ltn = 'system' - knj = 'mincho' - else # unknown - ltn = 'Helvetica' - knj = 'mincho' - end + platform = tk_call('set', 'tcl_platform(platform)') + case platform + when 'unix' + ltn = {'family'=>'Helvetica'.freeze, + 'size'=>-12, 'weight'=>'bold'.freeze} + #knj = 'k14' + #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' + knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' + when 'windows' + ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} + knj = 'mincho' + when 'macintosh' + ltn = 'system' + knj = 'mincho' + else # unknown + ltn = 'Helvetica' + knj = 'mincho' + end end rescue ltn = 'Helvetica' @@ -68,20 +68,20 @@ class TkFont else # not JAPANIZED_TK begin - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - when 'macintosh' - ltn = 'system' - else # unknown - ltn = 'Helvetica' - end + platform = tk_call('set', 'tcl_platform(platform)') + case platform + when 'unix' + ltn = {'family'=>'Helvetica'.freeze, + 'size'=>-12, 'weight'=>'bold'.freeze} + when 'windows' + ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} + when 'macintosh' + ltn = 'system' + else # unknown + ltn = 'Helvetica' + end rescue - ltn = 'Helvetica' + ltn = 'Helvetica' end knj = ltn.dup @@ -106,14 +106,14 @@ class TkFont class DescendantFont def initialize(compound, type) unless compound.kind_of?(TkFont) - fail ArgumentError, "a TkFont object is expected for the 1st argument" + fail ArgumentError, "a TkFont object is expected for the 1st argument" end @compound = compound case type when 'kanji', 'latin', 'ascii' - @type = type + @type = type else - fail ArgumentError, "unknown type '#{type}'" + fail ArgumentError, "unknown type '#{type}'" end end @@ -155,9 +155,9 @@ class TkFont when /^8\.*/ if window - tk_split_simplelist(tk_call('font', 'families', '-displayof', window)) + tk_split_simplelist(tk_call('font', 'families', '-displayof', window)) else - tk_split_simplelist(tk_call('font', 'families')) + tk_split_simplelist(tk_call('font', 'families')) end end end @@ -205,11 +205,11 @@ class TkFont regexp = /^-(|kanji)#{key} / conf_list = tk_split_simplelist(tk_call(*args)). - find_all{|prop| prop =~ regexp}. - collect{|prop| tk_split_simplelist(prop)} + find_all{|prop| prop =~ regexp}. + collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 - raise RuntimeError, "the widget may not support 'font' option" + raise RuntimeError, "the widget may not support 'font' option" end args << {} @@ -231,11 +231,11 @@ class TkFont regexp = /^-#{key} / conf_list = tk_split_simplelist(tk_call(*args)). - find_all{|prop| prop =~ regexp}. - collect{|prop| tk_split_simplelist(prop)} + find_all{|prop| prop =~ regexp}. + collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 - raise RuntimeError, "the widget may not support 'font' option" + raise RuntimeError, "the widget may not support 'font' option" end args << {} @@ -247,23 +247,23 @@ class TkFont fnt = nil if fnt == [] || fnt == "" unless fnt - TkFont.new(nil, nil).call_font_configure([path, key], *args) + TkFont.new(nil, nil).call_font_configure([path, key], *args) else - begin - compound = tk_split_simplelist( + begin + compound = tk_split_simplelist( Hash[*tk_split_simplelist(tk_call('font', 'configure', - fnt))].collect{|key,value| + fnt))].collect{|key,value| [key[1..-1], value] }.assoc('compound')[1]) - rescue - compound = [] - end - if compound == [] - TkFont.new(fnt).call_font_configure([path, key], *args) - else - TkFont.new(compound[0], - compound[1]).call_font_configure([path, key], *args) - end + rescue + compound = [] + end + if compound == [] + TkFont.new(fnt).call_font_configure([path, key], *args) + else + TkFont.new(compound[0], + compound[1]).call_font_configure([path, key], *args) + end end end end @@ -307,33 +307,33 @@ class TkFont # compound font check if Tk::TK_VERSION == '8.0' && JAPANIZED_TK begin - compound = tk_split_simplelist(tk_call('font', 'configure', - ltn, '-compound')) - if knj == nil - if compound != [] - ltn, knj = compound - end - else - if compound != [] - ltn = compound[0] - end - compound = tk_split_simplelist(tk_call('font', 'configure', - knj, '-compound')) - if compound != [] - knj = compound[1] - end - end + compound = tk_split_simplelist(tk_call('font', 'configure', + ltn, '-compound')) + if knj == nil + if compound != [] + ltn, knj = compound + end + else + if compound != [] + ltn = compound[0] + end + compound = tk_split_simplelist(tk_call('font', 'configure', + knj, '-compound')) + if compound != [] + knj = compound[1] + end + end rescue end end if ltn if JAPANIZED_TK && !knj - if Tk::TK_VERSION =~ /^4.*/ - knj = DEFAULT_KANJI_FONT_NAME - else - knj = ltn - end + if Tk::TK_VERSION =~ /^4.*/ + knj = DEFAULT_KANJI_FONT_NAME + else + knj = ltn + end end else ltn = DEFAULT_LATIN_FONT_NAME @@ -372,28 +372,28 @@ class TkFont finfo = {} finfo['family'] = font[0].to_s if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end + else + finfo['points'] = '13' + end end font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end + case (style) + when 'normal' + finfo['weight'] = style + when 'bold' + finfo['weight'] = style + when 'roman' + finfo['slant'] = 'r' + when 'italic' + finfo['slant'] = 'i' + end } @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' @@ -424,28 +424,28 @@ class TkFont finfo = {} finfo['family'] = font[0].to_s if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end + else + finfo['points'] = '13' + end end font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end + case (style) + when 'normal' + finfo['weight'] = style + when 'bold' + finfo['weight'] = style + when 'roman' + finfo['slant'] = 'r' + when 'italic' + finfo['slant'] = 'i' + end } @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' @@ -478,42 +478,42 @@ class TkFont if JAPANIZED_TK if font.kind_of? Hash - if font[:charset] || font['charset'] - tk_call('font', 'create', @latinfont, *hash_kv(font)) - else - tk_call('font', 'create', @latinfont, + if font[:charset] || font['charset'] + tk_call('font', 'create', @latinfont, *hash_kv(font)) + else + tk_call('font', 'create', @latinfont, '-charset', 'iso8859', *hash_kv(font)) - end + end elsif font.kind_of? Array - tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font)) + tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font)) tk_call('font', 'configure', @latinfont, '-charset', 'iso8859') elsif font.kind_of? TkFont - tk_call('font', 'create', @latinfont, '-copy', font.latin_font) + tk_call('font', 'create', @latinfont, '-copy', font.latin_font) elsif font - tk_call('font', 'create', @latinfont, '-copy', font, + tk_call('font', 'create', @latinfont, '-copy', font, '-charset', 'iso8859') else - tk_call('font', 'create', @latinfont, '-charset', 'iso8859') + tk_call('font', 'create', @latinfont, '-charset', 'iso8859') end else if font.kind_of? Hash - tk_call('font', 'create', @latinfont, *hash_kv(font)) + tk_call('font', 'create', @latinfont, *hash_kv(font)) else - keys = {} - if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} - elsif font.kind_of? TkFont - actual_core(font.latin_font).each{|key,val| keys[key] = val} - elsif font - actual_core(font).each{|key,val| keys[key] = val} - end - tk_call('font', 'create', @latinfont, *hash_kv(keys)) + keys = {} + if font.kind_of? Array + actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} + elsif font.kind_of? TkFont + actual_core(font.latin_font).each{|key,val| keys[key] = val} + elsif font + actual_core(font).each{|key,val| keys[key] = val} + end + tk_call('font', 'create', @latinfont, *hash_kv(keys)) end if font && @compoundfont keys = {} actual_core(@latinfont).each{|key,val| keys[key] = val} - tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) end end end @@ -524,10 +524,10 @@ class TkFont if JAPANIZED_TK if font.kind_of? Hash if font[:charset] || font['charset'] - tk_call('font', 'create', @kanjifont, *hash_kv(font)) + tk_call('font', 'create', @kanjifont, *hash_kv(font)) else - tk_call('font', 'create', @kanjifont, - '-charset', 'jisx0208.1983', *hash_kv(font)) + tk_call('font', 'create', @kanjifont, + '-charset', 'jisx0208.1983', *hash_kv(font)) end elsif font.kind_of? Array tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font)) @@ -536,7 +536,7 @@ class TkFont tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id) elsif font tk_call('font', 'create', @kanjifont, '-copy', font, - '-charset', 'jisx0208.1983') + '-charset', 'jisx0208.1983') else tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983') end @@ -548,11 +548,11 @@ class TkFont else keys = {} if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} + actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} elsif font.kind_of? TkFont - actual_core(font.kanji_font_id).each{|key,val| keys[key] = val} + actual_core(font.kanji_font_id).each{|key,val| keys[key] = val} elsif font - actual_core(font).each{|key,val| keys[key] = val} + actual_core(font).each{|key,val| keys[key] = val} end tk_call('font', 'create', @kanjifont, *hash_kv(keys)) end @@ -572,87 +572,87 @@ class TkFont @compoundfont = @id + 'c' if JAPANIZED_TK unless keys - keys = {} + keys = {} else - keys = keys.dup + keys = keys.dup end if (tk_call('font', 'configure', @latinfont, '-underline') == '1' && - tk_call('font', 'configure', @kanjifont, '-underline') == '1' && - !keys.key?('underline')) - keys['underline'] = true + tk_call('font', 'configure', @kanjifont, '-underline') == '1' && + !keys.key?('underline')) + keys['underline'] = true end if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' && - tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' && - !keys.key?('overstrike')) - keys['overstrike'] = true + tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' && + !keys.key?('overstrike')) + keys['overstrike'] = true end @fontslot = {'font'=>@compoundfont} begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) rescue RuntimeError => e - if ltn == knj - if e.message =~ /kanji font .* specified/ - tk_call('font', 'delete', @latinfont) - create_latinfont(DEFAULT_LATIN_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @kanjifont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @latinfont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - elsif e.message =~ /ascii font .* specified/ - tk_call('font', 'delete', @kanjifont) - create_kanjifont(DEFAULT_KANJI_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @latinfont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @kanjifont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - else - raise e - end - else - raise e - end + if ltn == knj + if e.message =~ /kanji font .* specified/ + tk_call('font', 'delete', @latinfont) + create_latinfont(DEFAULT_LATIN_FONT_NAME) + opts = [] + Hash[*(tk_split_simplelist(tk_call('font', 'configure', + @kanjifont)))].each{|k,v| + case k + when '-size', '-weight', '-slant', '-underline', '-overstrike' + opts << k << v + end + } + tk_call('font', 'configure', @latinfont, *opts) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + + elsif e.message =~ /ascii font .* specified/ + tk_call('font', 'delete', @kanjifont) + create_kanjifont(DEFAULT_KANJI_FONT_NAME) + opts = [] + Hash[*(tk_split_simplelist(tk_call('font', 'configure', + @latinfont)))].each{|k,v| + case k + when '-size', '-weight', '-slant', '-underline', '-overstrike' + opts << k << v + end + } + tk_call('font', 'configure', @kanjifont, *opts) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + + else + raise e + end + else + raise e + end end else tk_call('font', 'create', @compoundfont) latinkeys = {} begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} rescue - latinkeys {} + latinkeys {} end if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) end if knj - kanjikeys = {} - begin - actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val} - rescue - kanjikeys {} - end - if kanjikeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys)) - end + kanjikeys = {} + begin + actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val} + rescue + kanjikeys {} + end + if kanjikeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys)) + end end @fontslot = {'font'=>@compoundfont} @@ -666,8 +666,8 @@ class TkFont "" else [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] + ['underline',[]], ['overstrike',[]], ['charset',[]], + ['pointadjust',[]]] end end @@ -676,24 +676,24 @@ class TkFont "" elsif option if window - tk_call('font', 'actual', font, "-displayof", window, "-#{option}") + tk_call('font', 'actual', font, "-displayof", window, "-#{option}") else - tk_call('font', 'actual', font, "-#{option}") + tk_call('font', 'actual', font, "-#{option}") end else l = tk_split_simplelist(if window - tk_call('font', 'actual', font, - "-displayof", window) - else - tk_call('font', 'actual', font) - end) + tk_call('font', 'actual', font, + "-displayof", window) + else + tk_call('font', 'actual', font) + end) r = [] while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end + if key == '-compound' + l.shift + else + r.push [key[1..-1], l.shift] + end end r end @@ -708,11 +708,11 @@ class TkFont # dummy if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY if option - "" + "" else - [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] + [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], + ['underline',[]], ['overstrike',[]], ['charset',[]], + ['pointadjust',[]]] end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY current_configinfo_core_tk4x(font, option) @@ -724,69 +724,69 @@ class TkFont "" else {'family'=>'', 'size'=>'', 'weight'=>'', 'slant'=>'', - 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''} + 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''} end end def configure_core_tk8x(font, slot, value=None) if JAPANIZED_TK begin - padjust = tk_call('font', 'configure', font, '-pointadjust') + padjust = tk_call('font', 'configure', font, '-pointadjust') rescue - padjust = nil + padjust = nil end else padjust = nil end if slot.kind_of? Hash if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family)) - slot = _symbolkey2str(slot) - configure_core_tk8x(font, 'family', slot.delete('family')) + slot = _symbolkey2str(slot) + configure_core_tk8x(font, 'family', slot.delete('family')) end if ((slot.key?('size') || slot.key?(:size)) && - padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) - tk_call('font', 'configure', font, - '-pointadjust', padjust, *hash_kv(slot)) + padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) + tk_call('font', 'configure', font, + '-pointadjust', padjust, *hash_kv(slot)) else - tk_call('font', 'configure', font, *hash_kv(slot)) + tk_call('font', 'configure', font, *hash_kv(slot)) end elsif (slot == 'size' || slot == :size) && padjust != nil tk_call('font', 'configure', font, - "-#{slot}", value, '-pointadjust', padjust) + "-#{slot}", value, '-pointadjust', padjust) elsif JAPANIZED_TK && (slot == 'family' || slot == :family) # coumpund font? begin - compound = tk_split_simplelist(tk_call('font', 'configure', - font, '-compound')) + compound = tk_split_simplelist(tk_call('font', 'configure', + font, '-compound')) rescue - tk_call('font', 'configure', font, '-family', value) - return self + tk_call('font', 'configure', font, '-family', value) + return self end if compound == [] - tk_call('font', 'configure', font, '-family', value) - return self + tk_call('font', 'configure', font, '-family', value) + return self end ltn, knj = compound lfnt = tk_call('font', 'create', '-copy', ltn) begin - tk_call('font', 'configure', lfnt, '-family', value) - latin_replace_core_tk8x(lfnt) + tk_call('font', 'configure', lfnt, '-family', value) + latin_replace_core_tk8x(lfnt) rescue RuntimeError => e - fail e if $DEBUG + fail e if $DEBUG ensure - tk_call('font', 'delete', lfnt) if lfnt != '' + tk_call('font', 'delete', lfnt) if lfnt != '' end kfnt = tk_call('font', 'create', '-copy', knj) begin - tk_call('font', 'configure', kfnt, '-family', value) - kanji_replace_core_tk8x(lfnt) + tk_call('font', 'configure', kfnt, '-family', value) + kanji_replace_core_tk8x(lfnt) rescue RuntimeError => e - fail e if $DEBUG + fail e if $DEBUG ensure - tk_call('font', 'delete', kfnt) if kfnt != '' + tk_call('font', 'delete', kfnt) if kfnt != '' end else @@ -798,20 +798,20 @@ class TkFont def configinfo_core_tk8x(font, option=nil) if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY if option == 'compound' - "" + "" elsif option - tk_call('font', 'configure', font, "-#{option}") + tk_call('font', 'configure', font, "-#{option}") else - l = tk_split_simplelist(tk_call('font', 'configure', font)) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end - end - r + l = tk_split_simplelist(tk_call('font', 'configure', font)) + r = [] + while key=l.shift + if key == '-compound' + l.shift + else + r.push [key[1..-1], l.shift] + end + end + r end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY current_configinfo_core_tk8x(font, option) @@ -827,11 +827,11 @@ class TkFont l = tk_split_simplelist(tk_call('font', 'configure', font)) r = {} while key=l.shift - if key == '-compound' - l.shift - else - r[key[1..-1]] = l.shift - end + if key == '-compound' + l.shift + else + r[key[1..-1]] = l.shift + end end r end @@ -865,28 +865,28 @@ class TkFont @fontslot['font'] = @latinfont Tk_FontUseTBL.dup.each{|w, fobj| if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'font' if optkey == nil || optkey == '' - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'font'=>@latinfont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('font'=>@latinfont) - tk_call(w, 'configure', '-font', @latinfont) - end - rescue - Tk_FontUseTBL.delete(w) - end + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'font' if optkey == nil || optkey == '' + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'font'=>@latinfont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('font'=>@latinfont) + tk_call(w, 'configure', '-font', @latinfont) + end + rescue + Tk_FontUseTBL.delete(w) + end end } self @@ -900,28 +900,28 @@ class TkFont @fontslot['kanjifont'] = @kanjifont Tk_FontUseTBL.dup.each{|w, fobj| if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'kanjifont' unless optkey - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) - tk_call(w, 'configure', '-kanjifont', @kanjifont) - end - rescue - Tk_FontUseTBL.delete(w) - end + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'kanjifont' unless optkey + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) + tk_call(w, 'configure', '-kanjifont', @kanjifont) + end + rescue + Tk_FontUseTBL.delete(w) + end end } self @@ -930,14 +930,14 @@ class TkFont def latin_replace_core_tk8x(ltn) if JAPANIZED_TK begin - tk_call('font', 'delete', '@font_tmp') + tk_call('font', 'delete', '@font_tmp') rescue end begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) rescue - #fnt_bup = '' - fnt_bup = DEFAULT_LATIN_FONT_NAME + #fnt_bup = '' + fnt_bup = DEFAULT_LATIN_FONT_NAME end end @@ -951,40 +951,40 @@ class TkFont keys = self.configinfo tk_call('font', 'delete', @compoundfont) begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) =begin - latinkeys = {} - begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} - rescue - latinkeys {} - end - if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) - end + latinkeys = {} + begin + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + rescue + latinkeys {} + end + if latinkeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + end =end rescue RuntimeError => e - tk_call('font', 'delete', @latinfont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @latinfont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end + tk_call('font', 'delete', @latinfont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @latinfont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end end else latinkeys = {} begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} rescue - latinkeys {} + latinkeys {} end if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) end end self @@ -993,14 +993,14 @@ class TkFont def kanji_replace_core_tk8x(knj) if JAPANIZED_TK begin - tk_call('font', 'delete', '@font_tmp') + tk_call('font', 'delete', '@font_tmp') rescue end begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) rescue - #fnt_bup = '' - fnt_bup = DEFAULT_KANJI_FONT_NAME + #fnt_bup = '' + fnt_bup = DEFAULT_KANJI_FONT_NAME end end @@ -1014,18 +1014,18 @@ class TkFont keys = self.configinfo tk_call('font', 'delete', @compoundfont) begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) rescue RuntimeError => e - tk_call('font', 'delete', @kanjifont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end + tk_call('font', 'delete', @kanjifont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end end end self @@ -1038,7 +1038,7 @@ class TkFont def measure_core_tk8x(window, text) if window number(tk_call('font', 'measure', @compoundfont, - '-displayof', window, text)) + '-displayof', window, text)) else number(tk_call('font', 'measure', @compoundfont, text)) end @@ -1056,20 +1056,20 @@ class TkFont def metrics_core_tk8x(font, window, option=nil) if option if window - number(tk_call('font', 'metrics', font, - "-displayof", window, "-#{option}")) + number(tk_call('font', 'metrics', font, + "-displayof", window, "-#{option}")) else - number(tk_call('font', 'metrics', font, "-#{option}")) + number(tk_call('font', 'metrics', font, "-#{option}")) end else l = tk_split_list(if window - tk_call('font','metrics',font,"-displayof",window) - else - tk_call('font','metrics',font) - end) + tk_call('font','metrics',font,"-displayof",window) + else + tk_call('font','metrics',font) + end) r = [] while key=l.shift - r.push [key[1..-1], l.shift.to_i] + r.push [key[1..-1], l.shift.to_i] end r end @@ -1133,9 +1133,9 @@ class TkFont configure name, args[0] when 0 begin - configinfo name + configinfo name rescue - fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at + fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at end else fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at @@ -1171,49 +1171,49 @@ class TkFont Tk_FontUseTBL.each{|key,value| next unless self == value if key.include?(';') - win, tag, optkey = key.split(';') - winobj = tk_tcl2ruby(win) - if winobj.kind_of? TkText - if optkey - ret.push([winobj, winobj.tagid2obj(tag), optkey]) - else - ret.push([winobj, winobj.tagid2obj(tag)]) - end - elsif winobj.kind_of? TkCanvas - if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - else - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end - end - elsif winobj.kind_of? TkMenu - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end - else - if optkey - ret.push([win, tag, optkey]) - else - ret.push([win, tag]) - end - end + win, tag, optkey = key.split(';') + winobj = tk_tcl2ruby(win) + if winobj.kind_of? TkText + if optkey + ret.push([winobj, winobj.tagid2obj(tag), optkey]) + else + ret.push([winobj, winobj.tagid2obj(tag)]) + end + elsif winobj.kind_of? TkCanvas + if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + else + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end + end + elsif winobj.kind_of? TkMenu + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end + else + if optkey + ret.push([win, tag, optkey]) + else + ret.push([win, tag]) + end + end else - ret.push(tk_tcl2ruby(key)) + ret.push(tk_tcl2ruby(key)) end } ret diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb index c591eea18..74287d43b 100644 --- a/ext/tk/lib/tk/grid.rb +++ b/ext/tk/lib/tk/grid.rb @@ -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 diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb index 7868ed0c8..7fd61eff5 100644 --- a/ext/tk/lib/tk/image.rb +++ b/ext/tk/lib/tk/image.rb @@ -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 diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb index 271450041..34c64adb2 100644 --- a/ext/tk/lib/tk/itemconfig.rb +++ b/ext/tk/lib/tk/itemconfig.rb @@ -61,14 +61,14 @@ module TkItemConfigOptkeys keys.each{|k, v| optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s} if optkey - defkey, undefkey = optkey - if v - keys2[defkey.to_s] = None - else - keys2[undefkey.to_s] = None - end + defkey, undefkey = optkey + if v + keys2[defkey.to_s] = None + else + keys2[undefkey.to_s] = None + end else - keys2[k.to_s] = v + keys2[k.to_s] = v end } keys2 @@ -122,9 +122,9 @@ module TkItemConfigMethod case option when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ begin - number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))) + number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))) rescue - nil + nil end when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ @@ -132,9 +132,9 @@ module TkItemConfigMethod when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ begin - bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))) + bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))) rescue - nil + nil end when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ @@ -143,9 +143,9 @@ module TkItemConfigMethod when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ conf = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")) if conf =~ /^[0-9]/ - list(conf) + list(conf) else - conf + conf end when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ @@ -156,13 +156,13 @@ module TkItemConfigMethod fontkey = $2 fnt = tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{fontkey}")), true) unless fnt.kind_of?(TkFont) - fnt = tagfontobj(tagid(tagOrId), fontkey) + fnt = tagfontobj(tagid(tagOrId), fontkey) end if fontcode == 'kanji' && 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(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true) @@ -174,48 +174,48 @@ module TkItemConfigMethod slot = _symbolkey2str(slot) __item_methodcall_optkeys(tagid(tagOrId)).each{|key, method| - value = slot.delete(key.to_s) - self.__send__(method, tagOrId, value) if value + value = slot.delete(key.to_s) + self.__send__(method, tagOrId, value) if value } __item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey| - conf = slot.find{|kk, vv| kk == defkey.to_s} - if conf - k, v = conf - if v - slot[k] = None - else - slot[undefkey.to_s] = None if undefkey - slot.delete(k) - end - end + conf = slot.find{|kk, vv| kk == defkey.to_s} + if conf + k, v = conf + if v + slot[k] = None + else + slot[undefkey.to_s] = None if undefkey + slot.delete(k) + end + end } if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/}) - tagfont_configure(tagid(tagOrId), slot) + tagfont_configure(tagid(tagOrId), slot) elsif slot.size > 0 - tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) + tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) end else slot = slot.to_s if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } ) - defkey, undefkey = conf - if value - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}")) - elsif undefkey - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}")) - end + defkey, undefkey = conf + if value + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}")) + elsif undefkey + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}")) + end elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] ) - self.__send__(method, tagOrId, value) + self.__send__(method, tagOrId, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - if value == None - tagfontobj(tagid(tagOrId), $2) - else - tagfont_configure(tagid(tagOrId), {slot=>value}) - end + if value == None + tagfontobj(tagid(tagOrId), $2) + else + tagfont_configure(tagid(tagOrId), {slot=>value}) + end else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value)) + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value)) end end self @@ -224,531 +224,531 @@ module TkItemConfigMethod def itemconfiginfo(tagOrId, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey) - elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - conf + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey) + elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + conf else - if slot - slot = slot.to_s - case slot - when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ - method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] - return [slot, '', '', '', self.__send__(method, tagOrId)] - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - end - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - - conf - - else - ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - # do nothing - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - else - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - end - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - end - end - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - - conf - } - - __item_font_optkeys(tagid(tagOrId)).each{|optkey| - optkey = optkey.to_s - fontconf = ret.assoc(optkey) - if fontconf && fontconf.size > 2 - ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} - fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) - ret.push(fontconf) - end - } - - __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| - ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] + return [slot, '', '', '', self.__send__(method, tagOrId)] + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + end + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + + conf + + else + ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + # do nothing + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + else + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + end + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + end + end + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + + conf + } + + __item_font_optkeys(tagid(tagOrId)).each{|optkey| + optkey = optkey.to_s + fontconf = ret.assoc(optkey) + if fontconf && fontconf.size > 2 + ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} + fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) + ret.push(fontconf) + end + } + + __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| + ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)] + } + + ret + end end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey) - { conf.shift => conf } - elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey) + { conf.shift => conf } + elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end else - if slot - slot = slot.to_s - case slot - when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ - method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] - return {slot => ['', '', '', self.__send__(method, tagOrId)]} - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - end - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end - - else - ret = {} - tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist| - conf = tk_split_simplelist(conflist) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - # do nothing - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - else - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - end - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - end - end - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - ret[conf[0]] = conf[1] - else - ret[conf.shift] = conf - end - } - - __item_font_optkeys(tagid(tagOrId)).each{|optkey| - optkey = optkey.to_s - fontconf = ret[optkey] - if fontconf.kind_of?(Array) - ret.delete(optkey) - ret.delete('latin' << optkey) - ret.delete('ascii' << optkey) - ret.delete('kanji' << optkey) - fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) - ret[optkey] = fontconf - end - } - - __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| - ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] + return {slot => ['', '', '', self.__send__(method, tagOrId)]} + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + end + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end + + else + ret = {} + tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist| + conf = tk_split_simplelist(conflist) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + # do nothing + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + else + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + end + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + end + end + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + ret[conf[0]] = conf[1] + else + ret[conf.shift] = conf + end + } + + __item_font_optkeys(tagid(tagOrId)).each{|optkey| + optkey = optkey.to_s + fontconf = ret[optkey] + if fontconf.kind_of?(Array) + ret.delete(optkey) + ret.delete('latin' << optkey) + ret.delete('ascii' << optkey) + ret.delete('kanji' << optkey) + fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) + ret[optkey] = fontconf + end + } + + __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| + ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)] + } + + ret + end end end end @@ -756,31 +756,31 @@ module TkItemConfigMethod def current_itemconfiginfo(tagOrId, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - org_slot = slot - begin - conf = itemconfiginfo(tagOrId, slot) - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - return {conf[0] => conf[-1]} - end - slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] - end while(org_slot != slot) - fail RuntimeError, - "there is a configure alias loop about '#{org_slot}'" + org_slot = slot + begin + conf = itemconfiginfo(tagOrId, slot) + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + return {conf[0] => conf[-1]} + end + slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] + end while(org_slot != slot) + fail RuntimeError, + "there is a configure alias loop about '#{org_slot}'" else - ret = {} - itemconfiginfo(tagOrId).each{|conf| - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - ret[conf[0]] = conf[-1] - end - } - ret + ret = {} + itemconfiginfo(tagOrId).each{|conf| + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + ret[conf[0]] = conf[-1] + end + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} - itemconfiginfo(slot).each{|key, conf| - ret[key] = conf[-1] if conf.kind_of?(Array) + itemconfiginfo(slot).each{|key, conf| + ret[key] = conf[-1] if conf.kind_of?(Array) } ret end diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb index f194595d5..1f77ad11e 100644 --- a/ext/tk/lib/tk/itemfont.rb +++ b/ext/tk/lib/tk/itemfont.rb @@ -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.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) - - 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 = 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) + + 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.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 diff --git a/ext/tk/lib/tk/kinput.rb b/ext/tk/lib/tk/kinput.rb index 418b3aec4..fc731b656 100644 --- a/ext/tk/lib/tk/kinput.rb +++ b/ext/tk/lib/tk/kinput.rb @@ -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 diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb index d642ba2f0..f00db1923 100644 --- a/ext/tk/lib/tk/listbox.rb +++ b/ext/tk/lib/tk/listbox.rb @@ -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 diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb index f13a7c5a6..5014dea60 100644 --- a/ext/tk/lib/tk/menu.rb +++ b/ext/tk/lib/tk/menu.rb @@ -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) diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb index f29c40ff3..392b6fbd4 100644 --- a/ext/tk/lib/tk/menubar.rb +++ b/ext/tk/lib/tk/menubar.rb @@ -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') diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb index dfc1871ba..c8819f8e4 100644 --- a/ext/tk/lib/tk/menuspec.rb +++ b/ext/tk/lib/tk/menuspec.rb @@ -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['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 - - 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 - # 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 = orig_opts.dup + + 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 + + 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 + # 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) 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 diff --git a/ext/tk/lib/tk/msgcat.rb b/ext/tk/lib/tk/msgcat.rb index e7a549900..4e095c6fc 100644 --- a/ext/tk/lib/tk/msgcat.rb +++ b/ext/tk/lib/tk/msgcat.rb @@ -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) diff --git a/ext/tk/lib/tk/namespace.rb b/ext/tk/lib/tk/namespace.rb index 912ed1b5d..a236fb6a9 100644 --- a/ext/tk/lib/tk/namespace.rb +++ b/ext/tk/lib/tk/namespace.rb @@ -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 diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb index d940f3876..148467192 100644 --- a/ext/tk/lib/tk/optiondb.rb +++ b/ext/tk/lib/tk/optiondb.rb @@ -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 diff --git a/ext/tk/lib/tk/optionobj.rb b/ext/tk/lib/tk/optionobj.rb index 2c8a1efd5..8fe7e0ee5 100644 --- a/ext/tk/lib/tk/optionobj.rb +++ b/ext/tk/lib/tk/optionobj.rb @@ -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 - - 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 - - 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 + 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 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 } 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 diff --git a/ext/tk/lib/tk/package.rb b/ext/tk/lib/tk/package.rb index dbb0ca33e..d1eb27674 100644 --- a/ext/tk/lib/tk/package.rb +++ b/ext/tk/lib/tk/package.rb @@ -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 diff --git a/ext/tk/lib/tk/palette.rb b/ext/tk/lib/tk/palette.rb index abcafcfb3..dfe46940f 100644 --- a/ext/tk/lib/tk/palette.rb +++ b/ext/tk/lib/tk/palette.rb @@ -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 } diff --git a/ext/tk/lib/tk/panedwindow.rb b/ext/tk/lib/tk/panedwindow.rb index 1e0430b60..37be77508 100644 --- a/ext/tk/lib/tk/panedwindow.rb +++ b/ext/tk/lib/tk/panedwindow.rb @@ -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 diff --git a/ext/tk/lib/tk/place.rb b/ext/tk/lib/tk/place.rb index ea70a6bea..f7ebdfcbd 100644 --- a/ext/tk/lib/tk/place.rb +++ b/ext/tk/lib/tk/place.rb @@ -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 diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb index 6e16fb198..24a5cf1ea 100644 --- a/ext/tk/lib/tk/root.rb +++ b/ext/tk/lib/tk/root.rb @@ -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? diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb index 135a0cf62..7214c46f5 100644 --- a/ext/tk/lib/tk/scale.rb +++ b/ext/tk/lib/tk/scale.rb @@ -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 diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb index 6e10ef51a..74816a922 100644 --- a/ext/tk/lib/tk/scrollable.rb +++ b/ext/tk/lib/tk/scrollable.rb @@ -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 diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb index c6591a127..70aadfdd4 100644 --- a/ext/tk/lib/tk/scrollbar.rb +++ b/ext/tk/lib/tk/scrollbar.rb @@ -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 diff --git a/ext/tk/lib/tk/scrollbox.rb b/ext/tk/lib/tk/scrollbox.rb index 5f304d377..fd04057fb 100644 --- a/ext/tk/lib/tk/scrollbox.rb +++ b/ext/tk/lib/tk/scrollbox.rb @@ -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' diff --git a/ext/tk/lib/tk/selection.rb b/ext/tk/lib/tk/selection.rb index 970c3faa8..5caa6ef8e 100644 --- a/ext/tk/lib/tk/selection.rb +++ b/ext/tk/lib/tk/selection.rb @@ -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 diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index 06abb5fb3..f4febb05b 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -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' diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb index 123f49af0..a0af64237 100644 --- a/ext/tk/lib/tk/text.rb +++ b/ext/tk/lib/tk/text.rb @@ -1,7 +1,7 @@ # -# tk/text.rb - Tk text classes -# $Date$ -# by Yukihiro Matsumoto <matz@caelum.co.jp> +# tk/text.rb - Tk text classes +# $Date$ +# by Yukihiro Matsumoto <matz@caelum.co.jp> require 'tk' require 'tk/itemfont' require 'tk/itemconfig' @@ -91,7 +91,7 @@ class TkText<TkTextWin #if keys and keys != None # #tk_call_without_enc('text', @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('text', @path) # tk_call_without_enc(self.class::TkCommandNames[0], @path) @@ -169,7 +169,7 @@ class TkText<TkTextWin 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)) @@ -178,27 +178,27 @@ class TkText<TkTextWin 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 @@ -206,24 +206,24 @@ class TkText<TkTextWin 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 @@ -231,80 +231,80 @@ class TkText<TkTextWin 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 @@ -312,19 +312,19 @@ class TkText<TkTextWin 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 @@ -351,16 +351,16 @@ class TkText<TkTextWin # 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 @@ -383,7 +383,7 @@ class TkText<TkTextWin 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 count(idx1, idx2, *opts) @@ -495,8 +495,8 @@ class TkText<TkTextWin def tag_add(tag, index1, index2=None) tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag), - _get_eval_enc_str(index1), - _get_eval_enc_str(index2)) + _get_eval_enc_str(index1), + _get_eval_enc_str(index2)) self end alias addtag tag_add @@ -504,14 +504,14 @@ class TkText<TkTextWin def tag_delete(*tags) tk_send_without_enc('tag', 'delete', - *(tags.collect{|tag| _get_eval_enc_str(tag)})) + *(tags.collect{|tag| _get_eval_enc_str(tag)})) if TkTextTag::TTagID_TBL[@path] tags.each{|tag| - if tag.kind_of? TkTextTag - TkTextTag::TTagID_TBL[@path].delete(tag.id) - else - TkTextTag::TTagID_TBL[@path].delete(tag) - end + if tag.kind_of? TkTextTag + TkTextTag::TTagID_TBL[@path].delete(tag.id) + else + TkTextTag::TTagID_TBL[@path].delete(tag) + end } end self @@ -543,18 +543,18 @@ class TkText<TkTextWin case key.to_s when 'text', 'label', 'show', 'data', 'file' tk_call_without_enc(@path, 'tag', 'cget', - _get_eval_enc_str(tag), "-#{key}") + _get_eval_enc_str(tag), "-#{key}") when 'font', 'kanjifont' #fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}")) fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('tag','cget',_get_eval_enc_str(tag),'-font'))) unless fnt.kind_of?(TkFont) - fnt = tagfontobj(tag, fnt) + fnt = tagfontobj(tag, 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(@path,'tag','cget',_get_eval_enc_str(tag),"-#{key}"))) @@ -565,26 +565,26 @@ class TkText<TkTextWin if key.kind_of? Hash key = _symbolkey2str(key) if ( key['font'] || key['kanjifont'] \ - || key['latinfont'] || key['asciifont'] ) - tagfont_configure(tag, key) + || key['latinfont'] || key['asciifont'] ) + tagfont_configure(tag, key) else - tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), - *hash_kv(key, true)) + tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), + *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(tag) - else - tagfont_configure(tag, {key=>val}) - end + if val == None + tagfontobj(tag) + else + tagfont_configure(tag, {key=>val}) + end else - tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), - "-#{key}", _get_eval_enc_str(val)) + tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), + "-#{key}", _get_eval_enc_str(val)) end end self @@ -593,101 +593,101 @@ class TkText<TkTextWin def tag_configinfo(tag, key=nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if key - case key.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - when 'font', 'kanjifont' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - conf[4] = tagfont_configinfo(tag, conf[4]) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - end - conf[0] = conf[0][1..-1] - conf + case key.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + conf[4] = tagfont_configinfo(tag, conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + end + conf[0] = conf[0][1..-1] + conf else - ret = tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).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 - } - fontconf = ret.assoc('font') - if fontconf - ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} - fontconf[4] = tagfont_configinfo(tag, fontconf[4]) - ret.push(fontconf) - else - ret - end + ret = tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).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 + } + fontconf = ret.assoc('font') + if fontconf + ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} + fontconf[4] = tagfont_configinfo(tag, 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', 'data', 'file' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - when 'font', 'kanjifont' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - conf[4] = tagfont_configinfo(tag, conf[4]) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) - end - key = conf.shift[1..-1] - { key => conf } + case key.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + conf[4] = tagfont_configinfo(tag, conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).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 - } - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(tag, fontconf[3]) - ret['font'] = fontconf - end - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).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 + } + fontconf = ret['font'] + if fontconf + ret.delete('font') + ret.delete('kanjifont') + fontconf[3] = tagfont_configinfo(tag, fontconf[3]) + ret['font'] = fontconf + end + ret end end end @@ -695,19 +695,19 @@ class TkText<TkTextWin def current_tag_configinfo(tag, key=nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if key - conf = tag_configinfo(tag, key) - {conf[0] => conf[4]} + conf = tag_configinfo(tag, key) + {conf[0] => conf[4]} else - ret = {} - tag_configinfo(tag).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + tag_configinfo(tag).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} tag_configinfo(tag, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -716,25 +716,25 @@ class TkText<TkTextWin def tag_raise(tag, above=None) tk_send_without_enc('tag', 'raise', _get_eval_enc_str(tag), - _get_eval_enc_str(above)) + _get_eval_enc_str(above)) self end def tag_lower(tag, below=None) tk_send_without_enc('tag', 'lower', _get_eval_enc_str(tag), - _get_eval_enc_str(below)) + _get_eval_enc_str(below)) self end def tag_remove(tag, *indices) tk_send_without_enc('tag', 'remove', _get_eval_enc_str(tag), - *(indices.collect{|idx| _get_eval_enc_str(idx)})) + *(indices.collect{|idx| _get_eval_enc_str(idx)})) self end def tag_ranges(tag) l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges', - _get_eval_enc_str(tag))) + _get_eval_enc_str(tag))) r = [] while key=l.shift r.push [key, l.shift] @@ -744,16 +744,16 @@ class TkText<TkTextWin def tag_nextrange(tag, first, last=None) tk_split_list(tk_send_without_enc('tag', 'nextrange', - _get_eval_enc_str(tag), - _get_eval_enc_str(first), - _get_eval_enc_str(last))) + _get_eval_enc_str(tag), + _get_eval_enc_str(first), + _get_eval_enc_str(last))) end def tag_prevrange(tag, first, last=None) tk_split_list(tk_send_without_enc('tag', 'prevrange', - _get_eval_enc_str(tag), - _get_eval_enc_str(first), - _get_eval_enc_str(last))) + _get_eval_enc_str(tag), + _get_eval_enc_str(first), + _get_eval_enc_str(last))) end =begin @@ -761,18 +761,18 @@ class TkText<TkTextWin case slot.to_s when 'text', 'label', 'show', 'data', 'file' _fromUTF8(tk_send_without_enc('window', 'cget', - _get_eval_enc_str(index), "-#{slot}")) + _get_eval_enc_str(index), "-#{slot}")) when 'font', 'kanjifont' #fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}")) fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), '-font'))) unless fnt.kind_of?(TkFont) - fnt = tagfontobj(index, fnt) + fnt = tagfontobj(index, fnt) end if slot.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('window', 'cget', _get_eval_enc_str(index), "-#{slot}"))) @@ -784,54 +784,54 @@ class TkText<TkTextWin index.configure(slot, value) else if slot.kind_of? Hash - slot = _symbolkey2str(slot) - win = slot['window'] - # slot['window'] = win.epath if win.kind_of?(TkWindow) - slot['window'] = _epath(win) if win - if slot['create'] - p_create = slot['create'] - if p_create.kind_of? Proc + slot = _symbolkey2str(slot) + win = slot['window'] + # slot['window'] = win.epath if win.kind_of?(TkWindow) + slot['window'] = _epath(win) if win + if slot['create'] + p_create = slot['create'] + if p_create.kind_of? Proc #=begin - slot['create'] = install_cmd(proc{ - id = p_create.call - if id.kind_of?(TkWindow) - id.epath - else - id - end - }) + slot['create'] = install_cmd(proc{ + id = p_create.call + if id.kind_of?(TkWindow) + id.epath + else + id + end + }) #=end - slot['create'] = install_cmd(proc{_epath(p_create.call)}) - end - end - tk_send_without_enc('window', 'configure', - _get_eval_enc_str(index), - *hash_kv(slot, true)) + slot['create'] = install_cmd(proc{_epath(p_create.call)}) + end + end + tk_send_without_enc('window', 'configure', + _get_eval_enc_str(index), + *hash_kv(slot, true)) else - if slot == 'window' || slot == :window - # id = value - # value = id.epath if id.kind_of?(TkWindow) - value = _epath(value) - end - if slot == 'create' || slot == :create - p_create = value - if p_create.kind_of? Proc + if slot == 'window' || slot == :window + # id = value + # value = id.epath if id.kind_of?(TkWindow) + value = _epath(value) + end + if slot == 'create' || slot == :create + p_create = value + if p_create.kind_of? Proc #=begin - value = install_cmd(proc{ - id = p_create.call - if id.kind_of?(TkWindow) - id.epath - else - id - end - }) + value = install_cmd(proc{ + id = p_create.call + if id.kind_of?(TkWindow) + id.epath + else + id + end + }) #=end - value = install_cmd(proc{_epath(p_create.call)}) - end - end - tk_send_without_enc('window', 'configure', - _get_eval_enc_str(index), - "-#{slot}", _get_eval_enc_str(value)) + value = install_cmd(proc{_epath(p_create.call)}) + end + end + tk_send_without_enc('window', 'configure', + _get_eval_enc_str(index), + "-#{slot}", _get_eval_enc_str(value)) end end self @@ -840,80 +840,80 @@ class TkText<TkTextWin def window_configinfo(win, 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('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) - else - conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{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('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + end + conf[0] = conf[0][1..-1] + conf else - tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file' - else - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - if conf[4] - if conf[4].index('{') - conf[4] = tk_split_list(conf[4]) - else - conf[4] = tk_tcl2ruby(conf[4]) - end - end - end - conf[1] = conf[1][1..-1] if conf.size == 2 # alias info - conf - } + tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[0] = conf[0][1..-1] + case conf[0] + when 'text', 'label', 'show', 'data', 'file' + else + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + if conf[4] + if conf[4].index('{') + conf[4] = tk_split_list(conf[4]) + else + conf[4] = tk_tcl2ruby(conf[4]) + end + end + end + conf[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('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) - else - conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{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('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).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('window', 'configure', _get_eval_enc_str(win)))).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 @@ -921,19 +921,19 @@ class TkText<TkTextWin def current_window_configinfo(win, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - conf = window_configinfo(win, slot) - {conf[0] => conf[4]} + conf = window_configinfo(win, slot) + {conf[0] => conf[4]} else - ret = {} - window_configinfo(win).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + window_configinfo(win).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} window_configinfo(win, slot).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -954,14 +954,14 @@ class TkText<TkTextWin # $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 @@ -974,9 +974,9 @@ class TkText<TkTextWin nocase = false if args[0].kind_of?(Array) opts = args.shift.collect{|opt| - s_opt = opt.to_s - nocase = true if s_opt == 'nocase' - '-' + s_opt + s_opt = opt.to_s + nocase = true if s_opt == 'nocase' + '-' + s_opt } else opts = [] @@ -985,7 +985,7 @@ class TkText<TkTextWin if args[0].kind_of?(Regexp) regexp = args.shift if !nocase && (regexp.options & Regexp::IGNORECASE) != 0 - opts << '-nocase' + opts << '-nocase' end args.unshift(regexp.source) end @@ -1007,9 +1007,9 @@ class TkText<TkTextWin nocase = false if args[0].kind_of?(Array) opts = args.shift.collect{|opt| - s_opt = opt.to_s - nocase = true if s_opt == 'nocase' - '-' + s_opt + s_opt = opt.to_s + nocase = true if s_opt == 'nocase' + '-' + s_opt } else opts = [] @@ -1020,7 +1020,7 @@ class TkText<TkTextWin if args[0].kind_of?(Regexp) regexp = args.shift if !nocase && (regexp.options & Regexp::IGNORECASE) != 0 - opts << '-nocase' + opts << '-nocase' end args.unshift(regexp.source) end @@ -1041,53 +1041,53 @@ class TkText<TkTextWin 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 @@ -1102,48 +1102,48 @@ class TkText<TkTextWin 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 @@ -1168,56 +1168,56 @@ class TkText<TkTextWin # retrieve value case result[-1] when 'text' - if str[i] == ?{ - # text formed as {...} - val, i = _retrieve_braced_text(str, i) - result.push val - else - # text which may contain backslahes - val, i = _retrieve_backslashed_text(str, i) - result.push val - end + if str[i] == ?{ + # text formed as {...} + val, i = _retrieve_braced_text(str, i) + result.push val + else + # text which may contain backslahes + val, i = _retrieve_backslashed_text(str, i) + result.push val + end else - idx = str.index(/ /, i) - val = str[i..(idx-1)] - case result[-1] - when 'mark' - case val - when 'insert' - result.push TkTextMarkInsert.new(self) - when 'current' - result.push TkTextMarkCurrent.new(self) - when 'anchor' - result.push TkTextMarkAnchor.new(self) - else - result.push tk_tcl2ruby(val) - end - when 'tagon' - if val == 'sel' - if sel - result.push sel - else - result.push TkTextTagSel.new(self) - end - else - result.push tk_tcl2ruby(val) - end - when 'tagoff' - result.push tk_tcl2ruby(val) - when 'window' - result.push tk_tcl2ruby(val) - end - i = idx + 1 + idx = str.index(/ /, i) + val = str[i..(idx-1)] + case result[-1] + when 'mark' + case val + when 'insert' + result.push TkTextMarkInsert.new(self) + when 'current' + result.push TkTextMarkCurrent.new(self) + when 'anchor' + result.push TkTextMarkAnchor.new(self) + else + result.push tk_tcl2ruby(val) + end + when 'tagon' + if val == 'sel' + if sel + result.push sel + else + result.push TkTextTagSel.new(self) + end + else + result.push tk_tcl2ruby(val) + end + when 'tagoff' + result.push tk_tcl2ruby(val) + when 'window' + result.push tk_tcl2ruby(val) + end + i = idx + 1 end # retrieve index idx = str.index(/ /, i) if idx - result.push str[i..(idx-1)] - i = idx + 1 + result.push str[i..(idx-1)] + i = idx + 1 else - result.push str[i..-1] - break + result.push str[i..-1] + break end end @@ -1234,12 +1234,12 @@ class TkText<TkTextWin while idx < str.size case str[idx] when ?{ - cnt += 1 + cnt += 1 when ?} - cnt -= 1 - if cnt == 0 - break - end + cnt -= 1 + if cnt == 0 + break + end end idx += 1 end @@ -1253,9 +1253,9 @@ class TkText<TkTextWin loop { idx = str.index(/ /, j) if str[idx-1] == ?\\ - j += 1 + j += 1 else - break + break end } val = str[i..(idx-1)] diff --git a/ext/tk/lib/tk/textimage.rb b/ext/tk/lib/tk/textimage.rb index d36d17098..bd92387e3 100644 --- a/ext/tk/lib/tk/textimage.rb +++ b/ext/tk/lib/tk/textimage.rb @@ -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 diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb index a5e6f99d2..6004b8602 100644 --- a/ext/tk/lib/tk/textmark.rb +++ b/ext/tk/lib/tk/textmark.rb @@ -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 diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb index 3196da9b5..d2611509a 100644 --- a/ext/tk/lib/tk/texttag.rb +++ b/ext/tk/lib/tk/texttag.rb @@ -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 diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb index 778cf0f73..59fafff18 100644 --- a/ext/tk/lib/tk/textwindow.rb +++ b/ext/tk/lib/tk/textwindow.rb @@ -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 diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb index 79d7ef55f..a6d7efa10 100644 --- a/ext/tk/lib/tk/timer.rb +++ b/ext/tk/lib/tk/timer.rb @@ -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 diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb index 198495224..b96e184aa 100644 --- a/ext/tk/lib/tk/toplevel.rb +++ b/ext/tk/lib/tk/toplevel.rb @@ -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 diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb index ac99f32bd..5a50de456 100644 --- a/ext/tk/lib/tk/validation.rb +++ b/ext/tk/lib/tk/validation.rb @@ -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 diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb index 97d18e4a5..d5882fd64 100644 --- a/ext/tk/lib/tk/variable.rb +++ b/ext/tk/lib/tk/variable.rb @@ -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(/[\[\]$"\\]/, '\\\\\&') + '"' #" diff --git a/ext/tk/lib/tk/virtevent.rb b/ext/tk/lib/tk/virtevent.rb index d64c0a319..c82cfe46e 100644 --- a/ext/tk/lib/tk/virtevent.rb +++ b/ext/tk/lib/tk/virtevent.rb @@ -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 } diff --git a/ext/tk/lib/tk/winfo.rb b/ext/tk/lib/tk/winfo.rb index b4cb79a29..948042558 100644 --- a/ext/tk/lib/tk/winfo.rb +++ b/ext/tk/lib/tk/winfo.rb @@ -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 diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb index 1d7d47338..d6f7a0e9d 100644 --- a/ext/tk/lib/tk/winpkg.rb +++ b/ext/tk/lib/tk/winpkg.rb @@ -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 diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb index b5106adad..a1002f7b9 100644 --- a/ext/tk/lib/tk/wm.rb +++ b/ext/tk/lib/tk/wm.rb @@ -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 diff --git a/ext/tk/lib/tk/xim.rb b/ext/tk/lib/tk/xim.rb index b4dacdc33..701cd7531 100644 --- a/ext/tk/lib/tk/xim.rb +++ b/ext/tk/lib/tk/xim.rb @@ -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 {} diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb index 9ea275e56..87f5acc45 100644 --- a/ext/tk/lib/tkclass.rb +++ b/ext/tk/lib/tkclass.rb @@ -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" diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb index 275903f30..20d706df6 100644 --- a/ext/tk/lib/tkextlib/ICONS/icons.rb +++ b/ext/tk/lib/tkextlib/ICONS/icons.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget.rb b/ext/tk/lib/tkextlib/bwidget.rb index 2fe008976..56009f469 100644 --- a/ext/tk/lib/tkextlib/bwidget.rb +++ b/ext/tk/lib/tkextlib/bwidget.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb index 4a60a7ceb..d175a2d8b 100644 --- a/ext/tk/lib/tkextlib/bwidget/dialog.rb +++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb index 102be9a5f..9f505703f 100644 --- a/ext/tk/lib/tkextlib/bwidget/listbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -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) diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb index 55cc4ba0d..d7b2bbc32 100644 --- a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb +++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb index 26c11ac0d..e0cc04d30 100644 --- a/ext/tk/lib/tkextlib/bwidget/notebook.rb +++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb index 399353367..7136ae8d7 100644 --- a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb +++ b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb index f657e7148..9a49a96bb 100644 --- a/ext/tk/lib/tkextlib/bwidget/tree.rb +++ b/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -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) diff --git a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb index 9e53a9be8..c03f3c36c 100644 --- a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb +++ b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb index 84143a3ea..a52c43e51 100644 --- a/ext/tk/lib/tkextlib/itk/incr_tk.rb +++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -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 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 - - super(master, component) + 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 ComponentID_TBL.key?(master) + if ComponentID_TBL[master].key?(component) + return ComponentID_TBL[master][component] + end + else + ComponentID_TBL[master] = {} + end + + 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 - - # 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 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}" + name = id.id2name + + # 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 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}" 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 diff --git a/ext/tk/lib/tkextlib/iwidgets.rb b/ext/tk/lib/tkextlib/iwidgets.rb index b76fb79cc..5ef82f68c 100644 --- a/ext/tk/lib/tkextlib/iwidgets.rb +++ b/ext/tk/lib/tkextlib/iwidgets.rb @@ -25,9 +25,9 @@ module Tk def self.package_version begin - TkPackage.require('Iwidgets') + TkPackage.require('Iwidgets') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb index dab10b118..f382cfd14 100644 --- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -30,7 +30,7 @@ class Tk::Iwidgets::Calendar _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb index 300573bce..ae7d63f3f 100644 --- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb +++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb index a7024356a..077d84c7a 100644 --- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb +++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb index b4c94ff56..b60349be1 100644 --- a/ext/tk/lib/tkextlib/iwidgets/menubar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb index 511ee3dff..d9abf1b02 100644 --- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb +++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index c5ed19c1f..c26eda158 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb index 95d1034f1..39a9ed63c 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb index f4f0eb46c..b5c72b4df 100644 --- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb +++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb index fffd5b388..a2a7f3162 100644 --- a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/pkg_checker.rb b/ext/tk/lib/tkextlib/pkg_checker.rb index 5ebf67518..5002ed7ff 100755 --- a/ext/tk/lib/tkextlib/pkg_checker.rb +++ b/ext/tk/lib/tkextlib/pkg_checker.rb @@ -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 } diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index d0cb2812c..34e34046c 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb index 0a043b173..89bfeff0f 100644 --- a/ext/tk/lib/tkextlib/tcllib/ctext.rb +++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tcllib/cursor.rb b/ext/tk/lib/tkextlib/tcllib/cursor.rb index 8813aa05d..cbe1e2f1b 100644 --- a/ext/tk/lib/tkextlib/tcllib/cursor.rb +++ b/ext/tk/lib/tkextlib/tcllib/cursor.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb index 4d80b0686..1d029e456 100644 --- a/ext/tk/lib/tkextlib/tcllib/datefield.rb +++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb index 977ef4e5c..da9f1eb3a 100644 --- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb +++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index 65451a27a..86327ceff 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -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 - - @xaxis = args.shift - @yaxis = args.shift - - 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 + parent = args.shift + + @xaxis = args.shift + @yaxis = args.shift + + 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 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 - - @xlabels = args.shift - @ylabels = args.shift - - 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 + parent = args.shift + + @xlabels = args.shift + @ylabels = args.shift + + 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 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 diff --git a/ext/tk/lib/tkextlib/tcllib/style.rb b/ext/tk/lib/tkextlib/tcllib/style.rb index 17fc834cc..9fc4e9232 100644 --- a/ext/tk/lib/tkextlib/tcllib/style.rb +++ b/ext/tk/lib/tkextlib/tcllib/style.rb @@ -13,9 +13,9 @@ module Tk::Tcllib module Style def self.package_version begin - TkPackage.require('style') + TkPackage.require('style') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb index 4665edca7..4e6008bb3 100644 --- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb +++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb @@ -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})" diff --git a/ext/tk/lib/tkextlib/tclx/tclx.rb b/ext/tk/lib/tkextlib/tclx/tclx.rb index d10689d20..760ebd92b 100644 --- a/ext/tk/lib/tkextlib/tclx/tclx.rb +++ b/ext/tk/lib/tkextlib/tclx/tclx.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 91c01ca73..80a908369 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkDND/shape.rb b/ext/tk/lib/tkextlib/tkDND/shape.rb index 8f4716cee..7187f0a3b 100644 --- a/ext/tk/lib/tkextlib/tkDND/shape.rb +++ b/ext/tk/lib/tkextlib/tkDND/shape.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb index d0895c2af..78381f8df 100644 --- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb +++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb index 0c900cdb8..b9a203575 100644 --- a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb +++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb @@ -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] diff --git a/ext/tk/lib/tkextlib/tkimg.rb b/ext/tk/lib/tkextlib/tkimg.rb index f70d76c9d..ffeafbb58 100644 --- a/ext/tk/lib/tkextlib/tkimg.rb +++ b/ext/tk/lib/tkextlib/tkimg.rb @@ -19,9 +19,9 @@ module Tk module Img def self.package_version begin - TkPackage.require('Img') + TkPackage.require('Img') rescue - '' + '' end end end diff --git a/ext/tk/lib/tkextlib/tkimg/bmp.rb b/ext/tk/lib/tkextlib/tkimg/bmp.rb index e6031a43e..581483f8f 100644 --- a/ext/tk/lib/tkextlib/tkimg/bmp.rb +++ b/ext/tk/lib/tkextlib/tkimg/bmp.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/gif.rb b/ext/tk/lib/tkextlib/tkimg/gif.rb index b46443449..6ef18f8e9 100644 --- a/ext/tk/lib/tkextlib/tkimg/gif.rb +++ b/ext/tk/lib/tkextlib/tkimg/gif.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/ico.rb b/ext/tk/lib/tkextlib/tkimg/ico.rb index 2872a621a..1e3cb5f49 100644 --- a/ext/tk/lib/tkextlib/tkimg/ico.rb +++ b/ext/tk/lib/tkextlib/tkimg/ico.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/ext/tk/lib/tkextlib/tkimg/jpeg.rb index eac39083b..017c93ee0 100644 --- a/ext/tk/lib/tkextlib/tkimg/jpeg.rb +++ b/ext/tk/lib/tkextlib/tkimg/jpeg.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/pcx.rb b/ext/tk/lib/tkextlib/tkimg/pcx.rb index 26311e598..e924d4886 100644 --- a/ext/tk/lib/tkextlib/tkimg/pcx.rb +++ b/ext/tk/lib/tkextlib/tkimg/pcx.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ext/tk/lib/tkextlib/tkimg/pixmap.rb index ae8d3201c..f9aaa65a9 100644 --- a/ext/tk/lib/tkextlib/tkimg/pixmap.rb +++ b/ext/tk/lib/tkextlib/tkimg/pixmap.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/png.rb b/ext/tk/lib/tkextlib/tkimg/png.rb index acdd8c536..b15583639 100644 --- a/ext/tk/lib/tkextlib/tkimg/png.rb +++ b/ext/tk/lib/tkextlib/tkimg/png.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tkimg/ppm.rb b/ext/tk/lib/tkextlib/tkimg/ppm.rb index f15bdb9f1..df56baee4 100644 --- a/ext/tk/lib/tkextlib/tkimg/ppm.rb +++ b/ext/tk/lib/tkextlib/tkimg/ppm.rb @@ -17,11 +17,11 @@ module Tk module Img module PPM def self.package_version - begin - TkPackage.require('img::ppm') - rescue - '' - end + begin + TkPackage.require('img::ppm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/ps.rb b/ext/tk/lib/tkextlib/tkimg/ps.rb index 7c5cab2a4..3025066eb 100644 --- a/ext/tk/lib/tkextlib/tkimg/ps.rb +++ b/ext/tk/lib/tkextlib/tkimg/ps.rb @@ -17,11 +17,11 @@ module Tk module Img module PS def self.package_version - begin - TkPackage.require('img::ps') - rescue - '' - end + begin + TkPackage.require('img::ps') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/sgi.rb b/ext/tk/lib/tkextlib/tkimg/sgi.rb index 1cdf60e64..e505c87e8 100644 --- a/ext/tk/lib/tkextlib/tkimg/sgi.rb +++ b/ext/tk/lib/tkextlib/tkimg/sgi.rb @@ -17,11 +17,11 @@ module Tk module Img module SGI def self.package_version - begin - TkPackage.require('img::sgi') - rescue - '' - end + begin + TkPackage.require('img::sgi') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/sun.rb b/ext/tk/lib/tkextlib/tkimg/sun.rb index 88f9a4465..25bfea8fb 100644 --- a/ext/tk/lib/tkextlib/tkimg/sun.rb +++ b/ext/tk/lib/tkextlib/tkimg/sun.rb @@ -17,11 +17,11 @@ module Tk module Img module SUN def self.package_version - begin - TkPackage.require('img::sun') - rescue - '' - end + begin + TkPackage.require('img::sun') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/tga.rb b/ext/tk/lib/tkextlib/tkimg/tga.rb index c4068a729..e3f84c371 100644 --- a/ext/tk/lib/tkextlib/tkimg/tga.rb +++ b/ext/tk/lib/tkextlib/tkimg/tga.rb @@ -17,11 +17,11 @@ module Tk module Img module TGA def self.package_version - begin - TkPackage.require('img::tga') - rescue - '' - end + begin + TkPackage.require('img::tga') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/tiff.rb b/ext/tk/lib/tkextlib/tkimg/tiff.rb index 529999ef2..e7e12406a 100644 --- a/ext/tk/lib/tkextlib/tkimg/tiff.rb +++ b/ext/tk/lib/tkextlib/tkimg/tiff.rb @@ -17,11 +17,11 @@ module Tk module Img module TIFF def self.package_version - begin - TkPackage.require('img::tiff') - rescue - '' - end + begin + TkPackage.require('img::tiff') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/window.rb b/ext/tk/lib/tkextlib/tkimg/window.rb index 229445dd4..00ed7d1b8 100644 --- a/ext/tk/lib/tkextlib/tkimg/window.rb +++ b/ext/tk/lib/tkextlib/tkimg/window.rb @@ -17,11 +17,11 @@ module Tk module Img module WINDOW def self.package_version - begin - TkPackage.require('img::window') - rescue - '' - end + begin + TkPackage.require('img::window') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/xbm.rb b/ext/tk/lib/tkextlib/tkimg/xbm.rb index 3b680d9b5..08b1b9876 100644 --- a/ext/tk/lib/tkextlib/tkimg/xbm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xbm.rb @@ -17,11 +17,11 @@ module Tk module Img module XBM def self.package_version - begin - TkPackage.require('img::xbm') - rescue - '' - end + begin + TkPackage.require('img::xbm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/xpm.rb b/ext/tk/lib/tkextlib/tkimg/xpm.rb index eff1e3c2b..e29c1d554 100644 --- a/ext/tk/lib/tkextlib/tkimg/xpm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xpm.rb @@ -17,11 +17,11 @@ module Tk module Img module XPM def self.package_version - begin - TkPackage.require('img::xpm') - rescue - '' - end + begin + TkPackage.require('img::xpm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tktable/tktable.rb b/ext/tk/lib/tkextlib/tktable/tktable.rb index 18751fca6..2f2b14a69 100644 --- a/ext/tk/lib/tkextlib/tktable/tktable.rb +++ b/ext/tk/lib/tkextlib/tktable/tktable.rb @@ -19,9 +19,9 @@ module Tk class TkTable < TkWindow def self.package_version begin - TkPackage.require('Tktable') + TkPackage.require('Tktable') rescue - '' + '' end end @@ -200,28 +200,28 @@ class Tk::TkTable class BrowseCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?x, :cursor ], - [ ?r, ?n, :row ], - [ ?s, ?s, :last_index ], - [ ?S, ?s, :new_index ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?x, :cursor ], + [ ?r, ?n, :row ], + [ ?s, ?s, :last_index ], + [ ?S, ?s, :new_index ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?x, TkComm.method(:num_or_str) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?n, TkComm.method(:number) ], + [ ?x, TkComm.method(:num_or_str) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -233,28 +233,28 @@ class Tk::TkTable class CellCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?m, :rw_mode ], - [ ?r, ?n, :row ], - [ ?s, ?v, :value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?m, :rw_mode ], + [ ?r, ?n, :row ], + [ ?s, ?v, :value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ], - [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ], + [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - TkComm._get_eval_string(val) + TkComm._get_eval_string(val) end end @@ -266,26 +266,26 @@ class Tk::TkTable class SelectionCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :sel_columns ], - [ ?C, ?s, :sel_area ], - [ ?i, ?n, :total ], - [ ?r, ?n, :sel_rows ], - [ ?s, ?s, :value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :sel_columns ], + [ ?C, ?s, :sel_area ], + [ ?i, ?n, :total ], + [ ?r, ?n, :sel_rows ], + [ ?s, ?s, :value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val.to_s + val.to_s end end @@ -297,23 +297,23 @@ class Tk::TkTable class ValidateCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?x, :cursor ], - [ ?r, ?n, :row ], - [ ?s, ?v, :current_value ], - [ ?S, ?v, :new_value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?x, :cursor ], + [ ?r, ?n, :row ], + [ ?s, ?v, :current_value ], + [ ?S, ?v, :new_value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?x, TkComm.method(:num_or_str) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], - nil + [ ?n, TkComm.method(:number) ], + [ ?x, TkComm.method(:num_or_str) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); @@ -447,9 +447,9 @@ class Tk::TkTable def hidden?(idx, *args) if args.empty? if (ret = tk_send('hidden', tagid(idx))) == '' - false + false else - ret + ret end else bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)}))) @@ -582,8 +582,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', *args) end @@ -599,8 +599,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', 'row', *args) end @@ -616,8 +616,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', 'col', *args) end @@ -647,9 +647,9 @@ class Tk::TkTable args << tagid(pairs[i]) val = pairs[i+1] if val.kind_of?(Array) - args << val.join(',') + args << val.join(',') else - args << val + args << val end } tk_send('spans', *args) @@ -661,25 +661,25 @@ class Tk::TkTable # [idx, val], [idx, val], ... args = [] pairs.each{|idx, val| - args << tagid(idx) - if val.kind_of?(Array) - args << val.join(',') - else - args << val - end + args << tagid(idx) + if val.kind_of?(Array) + args << val.join(',') + else + args << val + end } tk_send('spans', *args) else # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - val = pairs[i+1] - if val.kind_of?(Array) - args << val.join(',') - else - args << val - end + args << tagid(pairs[i]) + val = pairs[i+1] + if val.kind_of?(Array) + args << val.join(',') + else + args << val + end } tk_send('spans', *args) end @@ -692,10 +692,10 @@ class Tk::TkTable tag.id elsif tag.kind_of?(Array) if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer) - # [row, col] - tag.join(',') + # [row, col] + tag.join(',') else - tag + tag end else tag @@ -705,9 +705,9 @@ class Tk::TkTable def tagid2obj(tagid) if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path) if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid) - Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid] + Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid] else - tagid + tagid end else tagid @@ -734,9 +734,9 @@ class Tk::TkTable tk_send('tag', 'delete', tagid(tag)) if Tk::TkTable::CellTag::CellTagID_TBL[@path] if tag.kind_of? Tk::TkTable::CellTag - Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id) + Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id) else - Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag) + Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag) end end self diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb index 2acdac721..55ac03e56 100644 --- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb +++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb @@ -16,9 +16,9 @@ module Tk module TkTrans def self.package_version begin - TkPackage.require('tktrans') + TkPackage.require('tktrans') rescue - '' + '' end end end diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index 3ea1a324c..cc23857c5 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -18,9 +18,9 @@ module Tk class TreeCtrl < TkWindow def self.package_version begin - TkPackage.require('treectrl') + TkPackage.require('treectrl') rescue - '' + '' end end @@ -81,14 +81,14 @@ class Tk::TreeCtrl::NotifyEvent [ ?b, proc{|val| list(val)} ], [ ?e, proc{|val| - case val - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(val[1..-2]) - when /^<[^<>]+>$/ - val[1..-2] - else - val - end + case val + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(val[1..-2]) + when /^<[^<>]+>$/ + val[1..-2] + else + val + end } ], @@ -194,12 +194,12 @@ module Tk::TreeCtrl::ConfigMethod if id.kind_of?(Array) key = id[0] if key.kind_of?(Array) - key = key.join(' ') + key = key.join(' ') end tag = id[1] if tag.kind_of?(Array) - tag = tag.join(' ') + tag = tag.join(' ') end id = [key, tag].join(':') @@ -211,10 +211,10 @@ module Tk::TreeCtrl::ConfigMethod def __item_configinfo_struct(id) if id.kind_of?(Array) && id[0].to_s == 'notify' {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil, - :default_value=>nil, :current_value=>1} + :default_value=>nil, :current_value=>1} else {:key=>0, :alias=>1, :db_name=>1, :db_class=>2, - :default_value=>3, :current_value=>4} + :default_value=>3, :current_value=>4} end end private :__item_configinfo_struct @@ -621,13 +621,13 @@ class Tk::TreeCtrl opts = opts.collect{|opt| if opt.kind_of?(Array) - key = "-#{opt[0]}" - flag = true if key == '-notreally' - ["-#{opt[0]}", opt[1]] + key = "-#{opt[0]}" + flag = true if key == '-notreally' + ["-#{opt[0]}", opt[1]] else - key = "-#{opt}" - flag = true if key == '-notreally' - key + key = "-#{opt}" + flag = true if key == '-notreally' + key end }.flatten @@ -664,9 +664,9 @@ class Tk::TreeCtrl def item_style_set(item, column=nil, *args) if args.empty? if column - tk_send('item', 'style', 'set', item, column) + tk_send('item', 'style', 'set', item, column) else - list(tk_send('item', 'style', 'set', item)) + list(tk_send('item', 'style', 'set', item)) end else tk_send('item', 'style', 'set', item, *(args.flatten)) @@ -677,10 +677,10 @@ class Tk::TreeCtrl def item_text(item, column, txt=nil, *args) if args.empty? if txt - tk_send('item', 'text', item, column, txt) - self + tk_send('item', 'text', item, column, txt) + self else - tk_send('item', 'text', item, column) + tk_send('item', 'text', item, column) end else tk_send('item', 'text', item, txt, *args) @@ -897,10 +897,10 @@ class Tk::TreeCtrl def style_layout(style, elem, keys=None) if keys && keys != None if keys.kind_of?(Hash) - tk_send('style', 'layout', style, elem, *hash_kv(keys)) - self + tk_send('style', 'layout', style, elem, *hash_kv(keys)) + self else - tk_send('style', 'layout', style, elem, "-#{keys}") + tk_send('style', 'layout', style, elem, "-#{keys}") end else list(tk_send('style', 'layout', style, elem)) diff --git a/ext/tk/lib/tkextlib/vu.rb b/ext/tk/lib/tkextlib/vu.rb index d3809f05b..c4ea1b86e 100644 --- a/ext/tk/lib/tkextlib/vu.rb +++ b/ext/tk/lib/tkextlib/vu.rb @@ -22,9 +22,9 @@ module Tk def self.package_version begin - TkPackage.require('vu') + TkPackage.require('vu') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/vu/charts.rb b/ext/tk/lib/tkextlib/vu/charts.rb index 594582d69..a578c6979 100644 --- a/ext/tk/lib/tkextlib/vu/charts.rb +++ b/ext/tk/lib/tkextlib/vu/charts.rb @@ -13,12 +13,12 @@ module Tk module ChartsConfig include TkItemConfigOptkeys def __item_boolval_optkeys(id) - super(id) << 'lefttrunc' << 'autocolor' + super(id) << 'lefttrunc' << 'autocolor' end private :__item_boolval_optkeys def __item_listval_optkeys(id) - super(id) << 'values' << 'tags' + super(id) << 'values' << 'tags' end private :__item_listval_optkeys end diff --git a/ext/tk/lib/tkextlib/vu/dial.rb b/ext/tk/lib/tkextlib/vu/dial.rb index e675ceb2d..e27a38ae4 100644 --- a/ext/tk/lib/tkextlib/vu/dial.rb +++ b/ext/tk/lib/tkextlib/vu/dial.rb @@ -58,7 +58,7 @@ class Tk::Vu::Dial < TkWindow ret = [] lst = simplelist(tk_call(@path, 'label')) while lst.size > 0 - ret << ([num_or_str(lst.shift)] << lst.shift) + ret << ([num_or_str(lst.shift)] << lst.shift) end end end @@ -80,7 +80,7 @@ class Tk::Vu::Dial < TkWindow ret = [] lst = simplelist(tk_call(@path, 'tag')) while lst.size > 0 - ret << ([num_or_str(lst.shift)] << lst.shift) + ret << ([num_or_str(lst.shift)] << lst.shift) end end end diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb index 959f05ec7..8a71cbb40 100644 --- a/ext/tk/lib/tkextlib/winico/winico.rb +++ b/ext/tk/lib/tkextlib/winico/winico.rb @@ -18,9 +18,9 @@ module Tk class Winico < TkObject def self.package_version begin - TkPackage.require('winico') + TkPackage.require('winico') rescue - '' + '' end end end @@ -61,9 +61,9 @@ class Tk::Winico if resource_name # from resource if file_name - @id = Tk.tk_call('winico', 'load', resource_name, file_name) + @id = Tk.tk_call('winico', 'load', resource_name, file_name) else - @id = Tk.tk_call('winico', 'load', resource_name) + @id = Tk.tk_call('winico', 'load', resource_name) end elsif file_name # from .ico file @@ -72,7 +72,7 @@ class Tk::Winico @id = winico_id else fail ArgumentError, - "must be given proper information from where loading icons" + "must be given proper information from where loading icons" end @path = @id WinicoID_TBL[@id] = self @@ -104,35 +104,35 @@ class Tk::Winico class Winico_callback < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?m, ?s, :message ], - [ ?i, ?x, :icon ], - [ ?x, ?n, :x ], - [ ?y, ?n, :y ], - [ ?X, ?n, :last_x ], - [ ?Y, ?n, :last_y ], - [ ?t, ?n, :tickcount ], - [ ?w, ?n, :icon_idnum ], - [ ?l, ?n, :msg_idnum ], - nil + [ ?m, ?s, :message ], + [ ?i, ?x, :icon ], + [ ?x, ?n, :x ], + [ ?y, ?n, :y ], + [ ?X, ?n, :last_x ], + [ ?Y, ?n, :last_y ], + [ ?t, ?n, :tickcount ], + [ ?w, ?n, :icon_idnum ], + [ ?l, ?n, :msg_idnum ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?x, proc{|id| - if Tk::Winico::WinicoID_TBL.key?(id) - Tk::Winico::WinicoID_TBL[id] - else - Tk::Winico.new(nil, nil, id) - end - } ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?x, proc{|id| + if Tk::Winico::WinicoID_TBL.key?(id) + Tk::Winico::WinicoID_TBL[id] + else + Tk::Winico.new(nil, nil, id) + end + } ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -147,10 +147,10 @@ class Tk::Winico keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) - cmd, *args = keys[k] - keys[k] = Winico_callback.new(cmd, args.join(' ')) + cmd, *args = keys[k] + keys[k] = Winico_callback.new(cmd, args.join(' ')) elsif keys[k].kind_of?(Proc) - keys[k] = Winico_callback.new(keys[k]) + keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys))) @@ -162,10 +162,10 @@ class Tk::Winico keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) - cmd, *args = keys[k] - keys[k] = Winico_callback.new(cmd, args.join(' ')) + cmd, *args = keys[k] + keys[k] = Winico_callback.new(cmd, args.join(' ')) elsif keys[k].kind_of?(Proc) - keys[k] = Winico_callback.new(keys[k]) + keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys))) diff --git a/ext/tk/sample/binding_sample.rb b/ext/tk/sample/binding_sample.rb index b98cd66a2..693cc7de2 100644 --- a/ext/tk/sample/binding_sample.rb +++ b/ext/tk/sample/binding_sample.rb @@ -24,17 +24,17 @@ class Button_clone < TkLabel self.bind('Enter', proc{self.background(self.activebackground)}) self.bind('Leave', proc{ - @press = false - self.background(self.highlightbackground) - self.relief('raised') - }) + @press = false + self.background(self.highlightbackground) + self.relief('raised') + }) self.bind('ButtonPress-1', proc{@press = true; self.relief('sunken')}) self.bind('ButtonRelease-1', proc{ - self.relief('raised') - @command.call if @press && @command - @press = false - }) + self.relief('raised') + @command.call if @press && @command + @press = false + }) end def command(cmd = Proc.new) @@ -67,20 +67,20 @@ TkFrame.new{|f| }.pack TkButton.new(:text=>'normal Button widget', - :command=>proc{ - puts 'button is clicked!!' - lbl.text 'button is clicked!!' - v.numeric += 1 - }){ + :command=>proc{ + puts 'button is clicked!!' + lbl.text 'button is clicked!!' + v.numeric += 1 + }){ pack(:fill=>:x, :expand=>true) } Button_clone.new(:text=>'Label with Button binding', - :command=>proc{ - puts 'label is clicked!!' - lbl.text 'label is clicked!!' - v.numeric += 1 - }){ + :command=>proc{ + puts 'label is clicked!!' + lbl.text 'label is clicked!!' + v.numeric += 1 + }){ pack(:fill=>:x, :expand=>true) } diff --git a/ext/tk/sample/bindtag_sample.rb b/ext/tk/sample/bindtag_sample.rb index caf7a2d75..8c93b4a26 100644 --- a/ext/tk/sample/bindtag_sample.rb +++ b/ext/tk/sample/bindtag_sample.rb @@ -12,9 +12,9 @@ EOT def set_class_bind TkButton.bind('ButtonPress-1', - proc{puts 'bind "ButtonPress-1" of TkButton class'}) + proc{puts 'bind "ButtonPress-1" of TkButton class'}) TkButton.bind('ButtonRelease-1', - proc{puts 'bind "ButtonRelease-1" of TkButton class'}) + proc{puts 'bind "ButtonRelease-1" of TkButton class'}) end # set root binding @@ -24,21 +24,21 @@ r.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of root widget'}) # set 'all' binding TkBindTag::ALL.bind('ButtonPress-1', - proc{puts 'bind "ButtonPress-1" of the tag "all"'}) + proc{puts 'bind "ButtonPress-1" of the tag "all"'}) TkBindTag::ALL.bind('ButtonRelease-1', - proc{puts 'bind "ButtonRelease-1" of the tag "all"'}) + proc{puts 'bind "ButtonRelease-1" of the tag "all"'}) # create buttons b1 = TkButton.new(:text=>'button-1', - :command=>proc{puts "command of button-1"}).pack + :command=>proc{puts "command of button-1"}).pack b2 = TkButton.new(:text=>'button-2', - :command=>proc{puts "command of button-2"}).pack + :command=>proc{puts "command of button-2"}).pack b3 = TkButton.new(:text=>'button-3', - :command=>proc{puts "command of button-3"}).pack + :command=>proc{puts "command of button-3"}).pack b4 = TkButton.new(:text=>'button-4', - :command=>proc{puts "command of button-4"}).pack + :command=>proc{puts "command of button-4"}).pack b5 = TkButton.new(:text=>'button-5', - :command=>proc{puts "command of button-5"}).pack + :command=>proc{puts "command of button-5"}).pack # set button binding b1.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-1'}) @@ -63,35 +63,35 @@ tag1.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of tag1'}) tag2 = TkBindTag.new tag2.bind('ButtonPress-1', - proc{ - puts 'bind "ButtonPress-1" of tag2' - puts 'call Tk.callback_continue' - Tk.callback_continue - puts 'never see this message' - }) + proc{ + puts 'bind "ButtonPress-1" of tag2' + puts 'call Tk.callback_continue' + Tk.callback_continue + puts 'never see this message' + }) tag2.bind('ButtonRelease-1', - proc{ - puts 'bind "ButtonRelease-1" of tag2' - puts 'call Tk.callback_continue' - Tk.callback_continue - puts 'never see this message' - }) + proc{ + puts 'bind "ButtonRelease-1" of tag2' + puts 'call Tk.callback_continue' + Tk.callback_continue + puts 'never see this message' + }) tag3 = TkBindTag.new tag3.bind('ButtonPress-1', - proc{ - puts 'bind "ButtonPress-1" of tag3' - puts 'call Tk.callback_break' - Tk.callback_break - puts 'never see this message' - }) + proc{ + puts 'bind "ButtonPress-1" of tag3' + puts 'call Tk.callback_break' + Tk.callback_break + puts 'never see this message' + }) tag3.bind('ButtonRelease-1', - proc{ - puts 'bind "ButtonRelease-1" of tag3' - puts 'call Tk.callback_break' - Tk.callback_break - puts 'never see this message' - }) + proc{ + puts 'bind "ButtonRelease-1" of tag3' + puts 'call Tk.callback_break' + Tk.callback_break + puts 'never see this message' + }) # set bindtags p b1.bindtags @@ -118,10 +118,10 @@ b5.bindtags([tag1, TkButton, tag2, b5]) # create button to set button class binding TkButton.new(:text=>'set binding to TkButton class', - :command=>proc{ - puts 'call "set_class_bind"' - set_class_bind - }).pack(:pady=>7) + :command=>proc{ + puts 'call "set_class_bind"' + set_class_bind + }).pack(:pady=>7) # start event-loop Tk.mainloop diff --git a/ext/tk/sample/cmd_res_test.rb b/ext/tk/sample/cmd_res_test.rb index 9bbb2044c..6e954f26e 100644 --- a/ext/tk/sample/cmd_res_test.rb +++ b/ext/tk/sample/cmd_res_test.rb @@ -1,6 +1,6 @@ require 'tk' TkOptionDB.readfile(File.expand_path('cmd_resource', - File.dirname(__FILE__))) + File.dirname(__FILE__))) f = TkFrame.new(:class=>'BtnFrame').pack b = TkButton.new(:parent=>f, :widgetname=>'hello').pack cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3) diff --git a/ext/tk/sample/demos-en/arrow.rb b/ext/tk/sample/demos-en/arrow.rb index 3f07b8e66..b62e1966e 100644 --- a/ext/tk/sample/demos-en/arrow.rb +++ b/ext/tk/sample/demos-en/arrow.rb @@ -13,7 +13,7 @@ # interactively. # # Arguments: -# c - Name of the canvas widget. +# c - Name of the canvas widget. def arrowSetup(c) v = $demo_arrowInfo @@ -29,59 +29,59 @@ def arrowSetup(c) # Create the arrow and outline. c.delete('all') TkcLine.new(c, v.x1, v.y, v.x2, v.y, - { 'width'=>10 * v.width, - 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], - 'arrow'=>'last' - }.update(v.bigLineStyle) ) + { 'width'=>10 * v.width, + 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], + 'arrow'=>'last' + }.update(v.bigLineStyle) ) xtip = v.x2 - 10*v.b deltaY = 10*v.c + 5*v.width TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY, - v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, - 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round') + v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, + 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round') # Create the boxes for reshaping the line and arrowhead. TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5, - {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) ) TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5, - {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) ) TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5, - {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) ) c.itemconfigure cur, v.activeStyle if cur # Create three arrows in actual size with the same parameters TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2) tmp = v.x2+100 TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) # Create a bunch of other arrows and text items showing the # current dimensions. tmp = v.x2+10 TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w') tmp = v.x1-10 TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e') tmp = v.y+5*v.width+10*v.c+10 TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n') tmp = tmp+25 TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n') TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') TkcText.new(c, v.x1, 330, - 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') v.count += 1 end @@ -101,7 +101,7 @@ $arrow_demo = TkToplevel.new {|w| # label TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){ + 'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){ pack('side'=>'top') } @@ -125,14 +125,14 @@ $arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # canvas $arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350, - 'relief'=>'sunken', 'borderwidth'=>2) + 'relief'=>'sunken', 'borderwidth'=>2) $arrow_canvas.pack('expand'=>'yes', 'fill'=>'both') # unless Struct.const_defined?("ArrowInfo") $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc, - :x1, :x2, :y, :smallTips, :count, - :bigLineStyle, :boxStyle, :activeStyle).new + :x1, :x2, :y, :smallTips, :count, + :bigLineStyle, :boxStyle, :activeStyle).new end $demo_arrowInfo.a = 8 $demo_arrowInfo.b = 10 @@ -161,16 +161,16 @@ $arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_ar $arrowTag_box.bind('B1-Enter', proc{}) $arrowTag_box.bind('B1-Leave', proc{}) $arrow_canvas.itembind('box1', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove1 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove1 $arrow_canvas, x, y}}) $arrow_canvas.itembind('box2', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove2 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove2 $arrow_canvas, x, y}}) $arrow_canvas.itembind('box3', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove3 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove3 $arrow_canvas, x, y}}) $arrowTag_box.bind('B1-Motion', - proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y") + proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y") $arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas}) # arrowMove1 -- @@ -179,8 +179,8 @@ $arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas}) # for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove1(c,x,y) v = $demo_arrowInfo @@ -199,8 +199,8 @@ end # parameters for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove2(c,x,y) v = $demo_arrowInfo @@ -223,8 +223,8 @@ end # controlling parameters for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove3(c,x,y) v = $demo_arrowInfo diff --git a/ext/tk/sample/demos-en/bind.rb b/ext/tk/sample/demos-en/bind.rb index ab2a32de8..0bd1f0ca6 100644 --- a/ext/tk/sample/demos-en/bind.rb +++ b/ext/tk/sample/demos-en/bind.rb @@ -76,34 +76,34 @@ TkText.new($bind_demo){|t| insert('end', '2. A simple two-dimensional plot that allows you to adjust the positions of the data points.', (d2 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '3. Anchoring and justification modes for text items.', - (d3 = TkTextTag.new(t)) ) + (d3 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '4. An editor for arrow-head shapes for line items.', - (d4 = TkTextTag.new(t)) ) + (d4 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '5. A ruler with facilities for editing tab stops.', - (d5 = TkTextTag.new(t)) ) + (d5 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', - '6. A grid that demonstrates how canvases can be scrolled.', - (d6 = TkTextTag.new(t)) ) + '6. A grid that demonstrates how canvases can be scrolled.', + (d6 = TkTextTag.new(t)) ) # binding [d1, d2, d3, d4, d5, d6].each{|tag| tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal) } d1.bind('1', - proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`}) d2.bind('1', - proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`}) d3.bind('1', - proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`}) d4.bind('1', - proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`}) d5.bind('1', - proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`}) d6.bind('1', - proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`}) TkTextMarkInsert.new(t, '0.0') configure('state','disabled') diff --git a/ext/tk/sample/demos-en/bitmap.rb b/ext/tk/sample/demos-en/bitmap.rb index c81e4ac59..7fd551c7a 100644 --- a/ext/tk/sample/demos-en/bitmap.rb +++ b/ext/tk/sample/demos-en/bitmap.rb @@ -9,19 +9,19 @@ # Create a row of bitmap items in a window. # # Arguments: -# w - The parent window that is to contain the row. -# args - The names of one or more bitmaps, which will be displayed -# in a new row across the bottom of w along with their -# names. +# w - The parent window that is to contain the row. +# args - The names of one or more bitmaps, which will be displayed +# in a new row across the bottom of w along with their +# names. def bitmapRow(w,*args) TkFrame.new(w){|row| pack('side'=>'top', 'fill'=>'both') for bitmap in args TkFrame.new(row){|base| - pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c') - TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom') - TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom') + pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c') + TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom') + TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom') } end } @@ -42,7 +42,7 @@ $bitmap_demo = TkToplevel.new {|w| # label TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){ + 'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){ pack('side'=>'top') } diff --git a/ext/tk/sample/demos-en/check.rb b/ext/tk/sample/demos-en/check.rb index b5def6a89..971a8fea7 100644 --- a/ext/tk/sample/demos-en/check.rb +++ b/ext/tk/sample/demos-en/check.rb @@ -55,7 +55,7 @@ TkFrame.new($check_demo) {|frame| text 'See Variables' command proc{ showVars($check_demo, - ['wipers', wipers], ['brakes', brakes], ['sober', sober]) + ['wipers', wipers], ['brakes', brakes], ['sober', sober]) } }.pack('side'=>'left', 'expand'=>'yes') diff --git a/ext/tk/sample/demos-en/check2.rb b/ext/tk/sample/demos-en/check2.rb index b01e3ffc9..e2d5982d2 100644 --- a/ext/tk/sample/demos-en/check2.rb +++ b/ext/tk/sample/demos-en/check2.rb @@ -33,35 +33,35 @@ sober = TkVariable.new(0) # frame TkFrame.new($check2_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'See Variables', - :image=>$image['view'], :compound=>:left, - :command=>proc{ - showVars($check2_demo, - ['safety', safety], ['wipers', wipers], - ['brakes', brakes], ['sober', sober]) - }), - TkButton.new(frame, :text=>'See Code', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'check2'}), - TkButton.new(frame, :text=>'Dismiss', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $check2_demo - $check2_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'See Variables', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars($check2_demo, + ['safety', safety], ['wipers', wipers], + ['brakes', brakes], ['sober', sober]) + }), + TkButton.new(frame, :text=>'See Code', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'check2'}), + TkButton.new(frame, :text=>'Dismiss', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $check2_demo + $check2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) }.pack('side'=>'bottom', 'fill'=>'x') # checkbutton TkCheckButton.new($check2_demo, :text=>'Safety Check', :variable=>safety, - :relief=>:flat, :onvalue=>'all', :offvalue=>'none', - :tristatevalue=>'partial'){ + :relief=>:flat, :onvalue=>'all', :offvalue=>'none', + :tristatevalue=>'partial'){ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') } @@ -82,21 +82,21 @@ tristate_check = proc{|n1,n2,op| begin if n1 == safety if safety == 'none' - wipers.value = 0 - brakes.value = 0 - sober.value = 0 + wipers.value = 0 + brakes.value = 0 + sober.value = 0 elsif safety == 'all' - wipers.value = 1 - brakes.value = 1 - sober.value = 1 + wipers.value = 1 + brakes.value = 1 + sober.value = 1 end else if wipers == 1 && brakes == 1 && sober == 1 - safety.value = 'all' + safety.value = 'all' elsif wipers == 1 || brakes == 1 || sober == 1 - safety.value = 'partial' + safety.value = 'partial' else - safety.value = 'none' + safety.value = 'none' end end ensure diff --git a/ext/tk/sample/demos-en/clrpick.rb b/ext/tk/sample/demos-en/clrpick.rb index 72c52a439..9486fde31 100644 --- a/ext/tk/sample/demos-en/clrpick.rb +++ b/ext/tk/sample/demos-en/clrpick.rb @@ -20,7 +20,7 @@ $clrpick_demo = TkToplevel.new {|w| # label TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top') + 'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top') # frame TkFrame.new($clrpick_demo) {|frame| @@ -42,7 +42,7 @@ TkFrame.new($clrpick_demo) {|frame| # button TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b| command(proc{setColor $clrpick_demo, b, 'background', - ['background', 'highlightbackground']}) + ['background', 'highlightbackground']}) pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m') } @@ -55,7 +55,7 @@ def setColor(w,button,name,options) w.grab initialColor = button[name] color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w, - 'initialcolor'=>initialColor) + 'initialcolor'=>initialColor) if color != "" setColor_helper(w,options,color) end diff --git a/ext/tk/sample/demos-en/cscroll.rb b/ext/tk/sample/demos-en/cscroll.rb index 8250c6e5e..0838dfbe0 100644 --- a/ext/tk/sample/demos-en/cscroll.rb +++ b/ext/tk/sample/demos-en/cscroll.rb @@ -21,7 +21,7 @@ $cscroll_demo = TkToplevel.new {|w| # label TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i', - 'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){ + 'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){ pack('side'=>'top') } @@ -54,14 +54,14 @@ end # canvas $cscroll_canvas = TkCanvas.new($cscroll_demo, - 'relief'=>'sunken', 'borderwidth'=>2, - 'scrollregion'=>['-11c', '-11c', '50c', '20c'] - ) {|c| + 'relief'=>'sunken', 'borderwidth'=>2, + 'scrollregion'=>['-11c', '-11c', '50c', '20c'] + ) {|c| if $tk_version =~ /^4\.[01]/ pack('expand'=>'yes', 'fill'=>'both') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs| @@ -70,18 +70,18 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo, pack('side'=>'right', 'fill'=>'y') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end } TkScrollbar.new($cscroll_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}) {|hs| + 'command'=>proc{|*args| c.xview(*args)}) {|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) if $tk_version =~ /^4\.[01]/ pack('side'=>'bottom', 'fill'=>'x') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end } } @@ -92,9 +92,9 @@ bg = $cscroll_canvas.configinfo('bg')[4] y = -10 (0..9).each{|j| TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c", - 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect') + 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect') TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c", - 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text') + 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text') y += 3 } } @@ -105,7 +105,7 @@ $cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas}) $cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas}) $cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y') $cscroll_canvas.bind('B2-Motion', - proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y') + proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y') def scrollEnter(c) id = c.find_withtag('current')[0].id diff --git a/ext/tk/sample/demos-en/ctext.rb b/ext/tk/sample/demos-en/ctext.rb index 13f8de721..dbb5e3263 100644 --- a/ext/tk/sample/demos-en/ctext.rb +++ b/ext/tk/sample/demos-en/ctext.rb @@ -21,7 +21,7 @@ $ctext_demo = TkToplevel.new {|w| # label TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing: + 'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing: 1. You can point, click, and type. 2. You can also select with button 1. 3. You can copy the selection to the mouse position with button 2. @@ -52,7 +52,7 @@ $ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # canvas $ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat', - 'borderwidth'=>0, 'width'=>500, 'height'=>350) + 'borderwidth'=>0, 'width'=>500, 'height'=>350) $ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both') # font @@ -60,37 +60,37 @@ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' # canvas TkcRectangle.new($ctext_canvas, 245, 195, 255, 205, - 'outline'=>'black', 'fill'=>'red') + 'outline'=>'black', 'fill'=>'red') $ctag_text = TkcTag.new($ctext_canvas) $ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, - 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).", - 'width'=>440, 'anchor'=>'n', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*', - 'kanjifont'=>'-*--24-*-jisx0208.1983-0', - 'justify'=>'left') ) + 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).", + 'width'=>440, 'anchor'=>'n', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*', + 'kanjifont'=>'-*--24-*-jisx0208.1983-0', + 'justify'=>'left') ) $ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('Shift-1', - proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"}, - "%x %y") + proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"}, + "%x %y") $ctag_text.bind('Shift-B1-Motion', - proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") + proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A") $ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"}) $ctag_text.bind('Control-h', proc{textBs $ctext_canvas}) $ctag_text.bind('BackSpace', proc{textBs $ctext_canvas}) $ctag_text.bind('Delete', proc{textDel $ctext_canvas}) $ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"}, - "%x %y") + "%x %y") # Next, create some items that allow the text's anchor position # to be edited. def mkTextConfig(w,x,y,option,value,color) item = TkcRectangle.new(w, x, y, x+30, y+30, - 'outline'=>'black', 'fill'=>color, 'width'=>1) + 'outline'=>'black', 'fill'=>color, 'width'=>1) item.bind('1', proc{$ctag_text.configure option, value}) w.addtag_withtag('config', item) end @@ -108,11 +108,11 @@ mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50, - 'outline'=>'black', 'fill'=>'red') + 'outline'=>'black', 'fill'=>'red') item.bind('1', proc{$ctag_text.configure 'anchor', 'center'}) TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'fill'=>'brown') # Lastly, create some items that allow the text's justification to be # changed. @@ -124,14 +124,14 @@ mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'fill'=>'brown') $ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas}) $ctext_canvas.itembind('config', 'Leave', - proc{$ctext_canvas\ - .itemconfigure('current', - 'fill'=>$textConfigFill)}) + proc{$ctext_canvas\ + .itemconfigure('current', + 'fill'=>$textConfigFill)}) $textConfigFill = '' diff --git a/ext/tk/sample/demos-en/dialog2.rb b/ext/tk/sample/demos-en/dialog2.rb index 21bf25c88..efc4b714d 100644 --- a/ext/tk/sample/demos-en/dialog2.rb +++ b/ext/tk/sample/demos-en/dialog2.rb @@ -27,9 +27,9 @@ class TkDialog_Demo2 < TkDialog end ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'}, - 'prev_command'=>proc{|dialog| - Tk.after 100, proc{dialog.grab('global')} - }).value + 'prev_command'=>proc{|dialog| + Tk.after 100, proc{dialog.grab('global')} + }).value case ret when 0 print "\You pressed OK\n" diff --git a/ext/tk/sample/demos-en/entry3.rb b/ext/tk/sample/demos-en/entry3.rb index 3ec162e48..415b45f86 100644 --- a/ext/tk/sample/demos-en/entry3.rb +++ b/ext/tk/sample/demos-en/entry3.rb @@ -18,8 +18,8 @@ $entry3_demo = TkToplevel.new {|w| } TkLabel.new($entry3_demo, - :font=>$font, :wraplength=>'5i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) Four different entries are displayed below. You can add characters \ by pointing, clicking and typing, though each is constrained in what \ it will accept. The first only accepts integers or the empty string \ @@ -38,13 +38,13 @@ TkFrame.new($entry3_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $entry3_demo.destroy - $entry3_demo = nil - }).pack(:side=>:left, :expand=>true) + $entry3_demo.destroy + $entry3_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'entry3' - }).pack(:side=>:left, :expand=>true) + showCode 'entry3' + }).pack(:side=>:left, :expand=>true) } # focusAndFlash -- @@ -54,32 +54,32 @@ TkFrame.new($entry3_demo){|f| # 2.5Hz). # # Arguments: -# widget - entry widget to flash -# fg - Initial foreground colour -# bg - Initial background colour -# count - Counter to control the number of times flashed +# widget - entry widget to flash +# fg - Initial foreground colour +# bg - Initial background colour +# count - Counter to control the number of times flashed def focusAndFlash(widget, fg, bg, count=5) return if count <= 0 TkTimer.new(200, count, - proc{widget.configure(:foreground=>bg, :background=>fg)}, - proc{widget.configure(:foreground=>fg, :background=>bg)} - ).start + proc{widget.configure(:foreground=>bg, :background=>fg)}, + proc{widget.configure(:foreground=>fg, :background=>bg)} + ).start widget.focus(true) end l1 = TkLabelFrame.new($entry3_demo, :text=>"Integer Entry") TkEntry.new(l1, :validate=>:focus, - :vcmd=>[ - proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' - ]) {|e| + :vcmd=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]) {|e| invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W'] pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') } l2 = TkLabelFrame.new($entry3_demo, :text=>"Length-Constrained Entry") TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell}, - :vcmd=>[proc{|s| s.length < 10}, '%P'] - ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + :vcmd=>[proc{|s| s.length < 10}, '%P'] + ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') ### PHONE NUMBER ENTRY ### # Note that the source to this is quite a bit longer as the behaviour @@ -101,7 +101,7 @@ Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n| # Skip over fixed characters in a phone-number string when moving left. # # Arguments: -# widget - The entry widget containing the phone-number. +# widget - The entry widget containing the phone-number. def phoneSkipLeft(widget) idx = widget.index('insert') if idx == 8 @@ -121,7 +121,7 @@ end # Skip over fixed characters in a phone-number string when moving right. # # Arguments: -# widget - The entry widget containing the phone-number. +# widget - The entry widget containing the phone-number. # add - Offset to add to index before calculation (used by validation.) def phoneSkipRight(widget, add = 0) idx = widget.index('insert') @@ -145,14 +145,14 @@ end # # widget - entry widget to validate # vmode - The widget's validation mode -# idx - The index where replacement is to occur +# idx - The index where replacement is to occur # char - The character (or string, though that will always be -# refused) to be overwritten at that point. +# refused) to be overwritten at that point. def validatePhoneChange(widget, vmode, idx, char) return true if idx == nil Tk.after_idle(proc{widget.configure(:validate=>vmode, - :invcmd=>proc{Tk.bell})}) + :invcmd=>proc{Tk.bell})}) if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/ widget.delete(idx) widget.insert(idx, $phoneNumberMap[char] || char) @@ -167,17 +167,17 @@ end l3 = TkLabelFrame.new($entry3_demo, :text=>"US Phone-Number Entry") TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell}, - :textvariable=>entry3content, - :vcmd=>[ - proc{|w,v,i,s| validatePhoneChange(w,v,i,s)}, - "%W %v %i %S" - ]){|e| + :textvariable=>entry3content, + :vcmd=>[ + proc{|w,v,i,s| validatePhoneChange(w,v,i,s)}, + "%W %v %i %S" + ]){|e| # Click to focus goes to the first editable character... bind('FocusIn', proc{|d,w| - if d != "NotifyAncestor" - w.cursor = 3 - Tk.after_idle(proc{w.selection_clear}) - end + if d != "NotifyAncestor" + w.cursor = 3 + Tk.after_idle(proc{w.selection_clear}) + end }, '%d %W') bind('Left', proc{|w| phoneSkipLeft(w)}, '%W') bind('Right', proc{|w| phoneSkipRight(w)}, '%W') @@ -186,10 +186,10 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell}, l4 = TkLabelFrame.new($entry3_demo, :text=>"Password Entry") TkEntry.new(l4, :validate=>:key, :show=>'*', - :vcmd=>[ - proc{|s| s.length <= 8}, - '%P' - ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + :vcmd=>[ + proc{|s| s.length <= 8}, + '%P' + ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') TkFrame.new($entry3_demo){|f| lower diff --git a/ext/tk/sample/demos-en/filebox.rb b/ext/tk/sample/demos-en/filebox.rb index 7caaaf0ed..36b19de55 100644 --- a/ext/tk/sample/demos-en/filebox.rb +++ b/ext/tk/sample/demos-en/filebox.rb @@ -19,7 +19,7 @@ $filebox_demo = TkToplevel.new {|w| # label TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top') + 'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top') # frame TkFrame.new($filebox_demo) {|frame| @@ -48,7 +48,7 @@ TkFrame.new($filebox_demo) {|frame| pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') TkButton.new(f, 'text'=>'Browse ...', - 'command'=>proc{fileDialog $filebox_demo,e,type})\ + 'command'=>proc{fileDialog $filebox_demo,e,type})\ .pack('side'=>'left') } @@ -59,9 +59,9 @@ TkFrame.new($filebox_demo) {|frame| $tk_strictMotif = TkVarAccess.new('tk_strictMotif') if ($tk_platform['platform'] == 'unix') TkCheckButton.new($filebox_demo, - 'text'=>'Use Motif Style Dialog', - 'variable'=>$tk_strictMotif, - 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c') + 'text'=>'Use Motif Style Dialog', + 'variable'=>$tk_strictMotif, + 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c') end def fileDialog(w,ent,operation) @@ -85,8 +85,8 @@ def fileDialog(w,ent,operation) file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w) else file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w, - 'initialfile'=>'Untitled', - 'defaultextension'=>'.txt') + 'initialfile'=>'Untitled', + 'defaultextension'=>'.txt') end if file != "" ent.delete 0, 'end' diff --git a/ext/tk/sample/demos-en/floor.rb b/ext/tk/sample/demos-en/floor.rb index db4d59fe7..15c56a154 100644 --- a/ext/tk/sample/demos-en/floor.rb +++ b/ext/tk/sample/demos-en/floor.rb @@ -12,8 +12,8 @@ # visible. # # Arguments: -# w - Name of the canvas window. -# active - Number of active floor (1, 2, or 3). +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). def floorDisplay(w,active) return if $activeFloor == active @@ -63,7 +63,7 @@ end # highlighted. # # Arguments: -# w - The name of the canvas window. +# w - The name of the canvas window. def newRoom(w) id = w.find_withtag('current')[0] @@ -76,8 +76,8 @@ end # It highlights the current room and unhighlights any previous room. # # Arguments: -# w - The canvas window displaying the floorplan. -# args - Not used. +# w - The canvas window displaying the floorplan. +# args - Not used. def roomChanged(w,*args) w.delete('highlight') @@ -94,24 +94,24 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg1(w,fill,outline) TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104, - 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, - 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, - 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, - 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, - 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, - 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, - 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, - 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, - 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, - 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, - 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, - 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) @@ -218,17 +218,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg2(w,fill,outline) TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129, - 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, - 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, - 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, - 367,802,367,802,129,725,129,725,133,559,133,559,129, - 'tags'=>['floor2','bg'], 'fill'=>fill) + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) @@ -273,17 +273,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg3(w,fill,outline) TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96, - 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129, - 315,129,315,133,176,133,176,129,159,129,159,370,258,370, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) @@ -303,7 +303,7 @@ def floor_bg3(w,fill,outline) TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,107,300,159,300,159,248,107,248,107,300, - 'fill'=>outline, 'tags'=>['floor3','bg']) + 'fill'=>outline, 'tags'=>['floor3','bg']) end # floor_fg1 -- @@ -312,321 +312,321 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg1(w,color) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '101' $floorItems['101'] = i TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Pub Lift1' $floorItems['Pub Lift1'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Priv Lift1' $floorItems['Priv Lift1'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '110' $floorItems['110'] = i TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '109' $floorItems['109'] = i TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '111' $floorItems['111'] = i TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117B' $floorItems['117B'] = i TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '112' $floorItems['112'] = i TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '113' $floorItems['113'] = i TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117A' $floorItems['117A'] = i TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117' $floorItems['117'] = i TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '114' $floorItems['114'] = i TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '115' $floorItems['115'] = i TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '116' $floorItems['116'] = i TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '118' $floorItems['118'] = i TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, - 163,91,163,112,149,112,149,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '120' $floorItems['120'] = i TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, - 156,192,156,169,175,169,175,246,79,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '122' $floorItems['122'] = i TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '121' $floorItems['121'] = i TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106A' $floorItems['106A'] = i TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '105' $floorItems['105'] = i TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106B' $floorItems['106B'] = i TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '104' $floorItems['104'] = i TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '108' $floorItems['108'] = i TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '107' $floorItems['107'] = i TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Smoking' $floorItems['Smoking'] = i TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '123' $floorItems['123'] = i TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '103' $floorItems['103'] = i TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '124' $floorItems['124'] = i TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '125' $floorItems['125'] = i TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '126' $floorItems['126'] = i TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, - 486,253,486,239,474,239,474,209, - 'fill'=>'', 'tags'=>['floor1','room']) + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '127' $floorItems['127'] = i TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, - 490,188,490,204,476,204,476,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'MShower' $floorItems['MShower'] = i TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Closet' $floorItems['Closet'] = i TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'WShower' $floorItems['WShower'] = i TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, - 697,166,697,275,553,275,531,254,515,254, - 515,174,503,174,503,161,486,161, - 'fill'=>'', 'tags'=>['floor1','room']) + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '130' $floorItems['130'] = i TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, - 342,246,397,246,397,276,393,276, - 393,309,300,309,300,248,308,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '102' $floorItems['102'] = i TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '128' $floorItems['128'] = i TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, - 552,277,561,277,561,325,510,325, - 'fill'=>'', 'tags'=>['floor1','room']) + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '129' $floorItems['129'] = i TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, - 642,389,561,389,561,277,696,277, - 'fill'=>'', 'tags'=>['floor1','room']) + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '133' $floorItems['133'] = i TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '132' $floorItems['132'] = i TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '134' $floorItems['134'] = i TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '135' $floorItems['135'] = i TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, - 304,312,396,312,396,288,400,288,404,288, - 409,290,413,292,418,297,421,302,422,309, - 421,318,417,325,411,330,405,332,397,333, - 344,333,340,334,336,336,335,338,332,342, - 331,347,332,351,334,354,336,357,341,359, - 'fill'=>'', 'tags'=>['floor1','room']) + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Ramona Stair' $floorItems['Ramona Stair'] = i TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, - 122,28,123,32,123,68,220,68,220,87,90,87,90,23, - 'fill'=>'', 'tags'=>['floor1','room']) + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'University Stair' $floorItems['University Stair'] = i TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, - 358,48,363,39,365,29,348,25,335,22,321,14, - 300,5,283,1,260,0,246,0,242,2,236,4,231,8, - 227,13,223,17,221,22,220,34,260,34, - 'fill'=>'', 'tags'=>['floor1','room']) + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Plaza Stair' $floorItems['Plaza Stair'] = i TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, - 323,56,337,70,350,83,365,94,377,100, - 386,104,386,128,220,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Plaza Deck' $floorItems['Plaza Deck'] = i TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106' $floorItems['106'] = i TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, - 95,128,114,128,114,151,157,151,157,153,112,153, - 112,130,97,130,97,168,175,168,175,131,146,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '119' $floorItems['119'] = i TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) @@ -793,327 +793,327 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg2(w,color) i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, - 800,222,800,168,748,168, - 'fill'=>'', 'tags'=>['floor2','room']) + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '238' $floorItems['238'] = i TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '237' $floorItems['237'] = i TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, - 643,324,643,291,641,291,641,205,696,205, - 696,291,694,291,694,314,715,314,715,291, - 715,205,755,205,755,190,724,190,724,187, - 'fill'=>'', 'tags'=>['floor2','room']) + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '246' $floorItems['246'] = i TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '247' $floorItems['247'] = i TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, - 397,246,397,255,476,255,476,250,482,250,559,250, - 559,274,482,274,482,278,396,278,396,274,232,274, - 'fill'=>'', 'tags'=>['floor2','room']) + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '202' $floorItems['202'] = i TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, - 306,196,306,180,175,180,175,169,156,169, - 156,196,176,196,176,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '206' $floorItems['206'] = i TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '212' $floorItems['212'] = i TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '245' $floorItems['245'] = i TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '244' $floorItems['244'] = i TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '243' $floorItems['243'] = i TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '242' $floorItems['242'] = i TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Barbecue Deck' $floorItems['Barbecue Deck'] = i TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '240' $floorItems['240'] = i TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '241' $floorItems['241'] = i TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '239' $floorItems['239'] = i TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '248' $floorItems['248'] = i TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '236' $floorItems['236'] = i TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '235' $floorItems['235'] = i TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, - 572,143,579,143,579,185,626,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '234' $floorItems['234'] = i TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, - 578,185,527,185,527,131,557,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '233' $floorItems['233'] = i TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '230' $floorItems['230'] = i TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '232' $floorItems['232'] = i TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '229' $floorItems['229'] = i TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '227' $floorItems['227'] = i TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '228' $floorItems['228'] = i TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '226' $floorItems['226'] = i TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '225' $floorItems['225'] = i TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '224' $floorItems['224'] = i TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '223' $floorItems['223'] = i TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '222' $floorItems['222'] = i TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '221' $floorItems['221'] = i TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '204' $floorItems['204'] = i TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '205' $floorItems['205'] = i TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '207' $floorItems['207'] = i TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '208' $floorItems['208'] = i TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '209' $floorItems['209'] = i TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '217' $floorItems['217'] = i TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '217A' $floorItems['217A'] = i TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '216' $floorItems['216'] = i TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '215' $floorItems['215'] = i TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '214' $floorItems['214'] = i TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '213' $floorItems['213'] = i TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '210' $floorItems['210'] = i TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '211' $floorItems['211'] = i TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '203' $floorItems['203'] = i TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, - 154,198,154,192,109,192,109,169,99,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '220' $floorItems['220'] = i TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Priv Lift2' $floorItems['Priv Lift2'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Pub Lift 2' $floorItems['Pub Lift 2'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '218' $floorItems['218'] = i TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '219' $floorItems['219'] = i TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '201' $floorItems['201'] = i TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) @@ -1275,215 +1275,215 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg3(w,color) i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316' $floorItems['316'] = i TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '309' $floorItems['309'] = i TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '308' $floorItems['308'] = i TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '307' $floorItems['307'] = i TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '305' $floorItems['305'] = i TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324B' $floorItems['324B'] = i TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324A' $floorItems['324A'] = i TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '320' $floorItems['320'] = i TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '310' $floorItems['310'] = i TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '312' $floorItems['312'] = i TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '313' $floorItems['313'] = i TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '314' $floorItems['314'] = i TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '315' $floorItems['315'] = i TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316B' $floorItems['316B'] = i TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316A' $floorItems['316A'] = i TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, - 174,198,174,226,101,226,101,179,97,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '319' $floorItems['319'] = i TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '311' $floorItems['311'] = i TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '318' $floorItems['318'] = i TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '317' $floorItems['317'] = i TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '323' $floorItems['323'] = i TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '325' $floorItems['325'] = i TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '321' $floorItems['321'] = i TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, - 264,181,264,135,314,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '322' $floorItems['322'] = i TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = 'Pub Lift3' $floorItems['Pub Lift3'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = 'Priv Lift3' $floorItems['Priv Lift3'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '303' $floorItems['303'] = i TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, - 244,230,244,221,252,221,252,203, - 'fill'=>'', 'tags'=>['floor3','room']) + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324' $floorItems['324'] = i TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '304' $floorItems['304'] = i TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '301' $floorItems['301'] = i TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '327' $floorItems['327'] = i TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '326' $floorItems['326'] = i TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, - 375,274,397,274,397,248,339,248,339,242,308,242, - 'fill'=>'', 'tags'=>['floor3','room']) + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '302' $floorItems['302'] = i TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, - 272,193,263,180,242,180,175,180,175,169,156,169, - 156,196,177,196,177,228,107,228,70,228,70,275,107,275, - 107,248,160,248,160,301,107,301,107,275,70,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '306' $floorItems['306'] = i TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) @@ -1592,7 +1592,7 @@ $floor_demo = TkToplevel.new {|w| # label TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', - 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){ + 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){ pack('side'=>'top') } @@ -1621,12 +1621,12 @@ $floorItems = {} # canvas if $tk_version =~ /^4\.[01]/ $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken', - 'highlightthickness'=>2) + 'highlightthickness'=>2) $floor_canvas = TkCanvas.new($floor_canvas_frame, - 'width'=>900, 'height'=>500, 'borderwidth'=>0, - 'highlightthickness'=>0) {|c| + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| TkScrollbar.new($floor_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}){|hs| + 'command'=>proc{|*args| c.xview(*args)}){|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) pack('side'=>'bottom', 'fill'=>'x') } @@ -1647,20 +1647,20 @@ else TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, - 'borderwidth'=>0, - 'highlightthickness'=>0) { - xscrollcommand(proc{|first,last| h.set first,last}) - yscrollcommand(proc{|first,last| v.set first,last}) - pack('expand'=>'yes', 'fill'=>'both') + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') } grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') } v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) @@ -1677,7 +1677,7 @@ end $currentRoom = TkVariable.new $floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken', - 'bd'=>2, 'textvariable'=>$currentRoom) + 'bd'=>2, 'textvariable'=>$currentRoom) # Choose colors, then fill in the floorplan. @@ -1714,7 +1714,7 @@ $floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas}) $floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''}) $floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y') $floor_canvas.bind('B2-Motion', - proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y') + proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y') $floor_canvas.bind('Destroy', proc{$currentRoom.unset}) $currentRoom.value = '' $currentRoom.trace('w',proc{roomChanged $floor_canvas}) diff --git a/ext/tk/sample/demos-en/floor2.rb b/ext/tk/sample/demos-en/floor2.rb index 7e418066d..ab8659a62 100644 --- a/ext/tk/sample/demos-en/floor2.rb +++ b/ext/tk/sample/demos-en/floor2.rb @@ -12,8 +12,8 @@ # visible. # # Arguments: -# w - Name of the canvas window. -# active - Number of active floor (1, 2, or 3). +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). def floorDisplay2(w,active) return if $activeFloor2 == active @@ -63,7 +63,7 @@ end # highlighted. # # Arguments: -# w - The name of the canvas window. +# w - The name of the canvas window. def newRoom2(w) id = w.find_withtag('current')[0] @@ -76,8 +76,8 @@ end # It highlights the current room and unhighlights any previous room. # # Arguments: -# w - The canvas window displaying the floorplan. -# args - Not used. +# w - The canvas window displaying the floorplan. +# args - Not used. def roomChanged2(w,*args) w.delete('highlight') @@ -94,24 +94,24 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg1(w,fill,outline) w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104, - 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, - 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, - 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, - 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, - 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, - 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, - 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, - 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, - 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, - 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, - 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, - 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) @@ -218,17 +218,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg2(w,fill,outline) w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129, - 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, - 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, - 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, - 367,802,367,802,129,725,129,725,133,559,133,559,129, - 'tags'=>['floor2','bg'], 'fill'=>fill) + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) @@ -273,17 +273,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg3(w,fill,outline) w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96, - 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129, - 315,129,315,133,176,133,176,129,159,129,159,370,258,370, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) @@ -303,7 +303,7 @@ def floor2_bg3(w,fill,outline) w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,107,300,159,300,159,248,107,248,107,300, - 'fill'=>outline, 'tags'=>['floor3','bg']) + 'fill'=>outline, 'tags'=>['floor3','bg']) end # floor2_fg1 -- @@ -312,321 +312,321 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg1(w,color) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '101' $floorItems2['101'] = i w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Pub Lift1' $floorItems2['Pub Lift1'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Priv Lift1' $floorItems2['Priv Lift1'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '110' $floorItems2['110'] = i w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '109' $floorItems2['109'] = i w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '111' $floorItems2['111'] = i w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117B' $floorItems2['117B'] = i w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '112' $floorItems2['112'] = i w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '113' $floorItems2['113'] = i w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117A' $floorItems2['117A'] = i w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117' $floorItems2['117'] = i w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '114' $floorItems2['114'] = i w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '115' $floorItems2['115'] = i w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '116' $floorItems2['116'] = i w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '118' $floorItems2['118'] = i w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, - 163,91,163,112,149,112,149,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '120' $floorItems2['120'] = i w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, - 156,192,156,169,175,169,175,246,79,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '122' $floorItems2['122'] = i w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '121' $floorItems2['121'] = i w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106A' $floorItems2['106A'] = i w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '105' $floorItems2['105'] = i w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106B' $floorItems2['106B'] = i w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '104' $floorItems2['104'] = i w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '108' $floorItems2['108'] = i w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '107' $floorItems2['107'] = i w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Smoking' $floorItems2['Smoking'] = i w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '123' $floorItems2['123'] = i w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '103' $floorItems2['103'] = i w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '124' $floorItems2['124'] = i w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '125' $floorItems2['125'] = i w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '126' $floorItems2['126'] = i w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, - 486,253,486,239,474,239,474,209, - 'fill'=>'', 'tags'=>['floor1','room']) + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '127' $floorItems2['127'] = i w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, - 490,188,490,204,476,204,476,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'MShower' $floorItems2['MShower'] = i w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Closet' $floorItems2['Closet'] = i w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'WShower' $floorItems2['WShower'] = i w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, - 697,166,697,275,553,275,531,254,515,254, - 515,174,503,174,503,161,486,161, - 'fill'=>'', 'tags'=>['floor1','room']) + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '130' $floorItems2['130'] = i w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, - 342,246,397,246,397,276,393,276, - 393,309,300,309,300,248,308,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '102' $floorItems2['102'] = i w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '128' $floorItems2['128'] = i w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, - 552,277,561,277,561,325,510,325, - 'fill'=>'', 'tags'=>['floor1','room']) + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '129' $floorItems2['129'] = i w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, - 642,389,561,389,561,277,696,277, - 'fill'=>'', 'tags'=>['floor1','room']) + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '133' $floorItems2['133'] = i w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '132' $floorItems2['132'] = i w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '134' $floorItems2['134'] = i w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '135' $floorItems2['135'] = i w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, - 304,312,396,312,396,288,400,288,404,288, - 409,290,413,292,418,297,421,302,422,309, - 421,318,417,325,411,330,405,332,397,333, - 344,333,340,334,336,336,335,338,332,342, - 331,347,332,351,334,354,336,357,341,359, - 'fill'=>'', 'tags'=>['floor1','room']) + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Ramona Stair' $floorItems2['Ramona Stair'] = i w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, - 122,28,123,32,123,68,220,68,220,87,90,87,90,23, - 'fill'=>'', 'tags'=>['floor1','room']) + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'University Stair' $floorItems2['University Stair'] = i w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, - 358,48,363,39,365,29,348,25,335,22,321,14, - 300,5,283,1,260,0,246,0,242,2,236,4,231,8, - 227,13,223,17,221,22,220,34,260,34, - 'fill'=>'', 'tags'=>['floor1','room']) + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Plaza Stair' $floorItems2['Plaza Stair'] = i w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, - 323,56,337,70,350,83,365,94,377,100, - 386,104,386,128,220,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Plaza Deck' $floorItems2['Plaza Deck'] = i w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106' $floorItems2['106'] = i w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, - 95,128,114,128,114,151,157,151,157,153,112,153, - 112,130,97,130,97,168,175,168,175,131,146,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '119' $floorItems2['119'] = i w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) @@ -793,327 +793,327 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg2(w,color) i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, - 800,222,800,168,748,168, - 'fill'=>'', 'tags'=>['floor2','room']) + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '238' $floorItems2['238'] = i w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '237' $floorItems2['237'] = i w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, - 643,324,643,291,641,291,641,205,696,205, - 696,291,694,291,694,314,715,314,715,291, - 715,205,755,205,755,190,724,190,724,187, - 'fill'=>'', 'tags'=>['floor2','room']) + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '246' $floorItems2['246'] = i w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '247' $floorItems2['247'] = i w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, - 397,246,397,255,476,255,476,250,482,250,559,250, - 559,274,482,274,482,278,396,278,396,274,232,274, - 'fill'=>'', 'tags'=>['floor2','room']) + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '202' $floorItems2['202'] = i w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, - 306,196,306,180,175,180,175,169,156,169, - 156,196,176,196,176,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '206' $floorItems2['206'] = i w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '212' $floorItems2['212'] = i w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '245' $floorItems2['245'] = i w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '244' $floorItems2['244'] = i w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '243' $floorItems2['243'] = i w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '242' $floorItems2['242'] = i w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Barbecue Deck' $floorItems2['Barbecue Deck'] = i w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '240' $floorItems2['240'] = i w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '241' $floorItems2['241'] = i w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '239' $floorItems2['239'] = i w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '248' $floorItems2['248'] = i w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '236' $floorItems2['236'] = i w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '235' $floorItems2['235'] = i w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, - 572,143,579,143,579,185,626,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '234' $floorItems2['234'] = i w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, - 578,185,527,185,527,131,557,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '233' $floorItems2['233'] = i w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '230' $floorItems2['230'] = i w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '232' $floorItems2['232'] = i w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '229' $floorItems2['229'] = i w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '227' $floorItems2['227'] = i w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '228' $floorItems2['228'] = i w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '226' $floorItems2['226'] = i w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '225' $floorItems2['225'] = i w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '224' $floorItems2['224'] = i w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '223' $floorItems2['223'] = i w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '222' $floorItems2['222'] = i w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '221' $floorItems2['221'] = i w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '204' $floorItems2['204'] = i w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '205' $floorItems2['205'] = i w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '207' $floorItems2['207'] = i w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '208' $floorItems2['208'] = i w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '209' $floorItems2['209'] = i w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '217' $floorItems2['217'] = i w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '217A' $floorItems2['217A'] = i w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '216' $floorItems2['216'] = i w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '215' $floorItems2['215'] = i w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '214' $floorItems2['214'] = i w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '213' $floorItems2['213'] = i w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '210' $floorItems2['210'] = i w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '211' $floorItems2['211'] = i w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '203' $floorItems2['203'] = i w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, - 154,198,154,192,109,192,109,169,99,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '220' $floorItems2['220'] = i w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Priv Lift2' $floorItems2['Priv Lift2'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Pub Lift 2' $floorItems2['Pub Lift 2'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '218' $floorItems2['218'] = i w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '219' $floorItems2['219'] = i w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '201' $floorItems2['201'] = i w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) @@ -1275,215 +1275,215 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg3(w,color) i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316' $floorItems2['316'] = i w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '309' $floorItems2['309'] = i w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '308' $floorItems2['308'] = i w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '307' $floorItems2['307'] = i w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '305' $floorItems2['305'] = i w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324B' $floorItems2['324B'] = i w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324A' $floorItems2['324A'] = i w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '320' $floorItems2['320'] = i w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '310' $floorItems2['310'] = i w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '312' $floorItems2['312'] = i w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '313' $floorItems2['313'] = i w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '314' $floorItems2['314'] = i w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '315' $floorItems2['315'] = i w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316B' $floorItems2['316B'] = i w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316A' $floorItems2['316A'] = i w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, - 174,198,174,226,101,226,101,179,97,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '319' $floorItems2['319'] = i w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '311' $floorItems2['311'] = i w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '318' $floorItems2['318'] = i w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '317' $floorItems2['317'] = i w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '323' $floorItems2['323'] = i w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '325' $floorItems2['325'] = i w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '321' $floorItems2['321'] = i w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, - 264,181,264,135,314,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '322' $floorItems2['322'] = i w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = 'Pub Lift3' $floorItems2['Pub Lift3'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = 'Priv Lift3' $floorItems2['Priv Lift3'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '303' $floorItems2['303'] = i w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, - 244,230,244,221,252,221,252,203, - 'fill'=>'', 'tags'=>['floor3','room']) + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324' $floorItems2['324'] = i w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '304' $floorItems2['304'] = i w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '301' $floorItems2['301'] = i w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '327' $floorItems2['327'] = i w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '326' $floorItems2['326'] = i w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, - 375,274,397,274,397,248,339,248,339,242,308,242, - 'fill'=>'', 'tags'=>['floor3','room']) + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '302' $floorItems2['302'] = i w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, - 272,193,263,180,242,180,175,180,175,169,156,169, - 156,196,177,196,177,228,107,228,70,228,70,275,107,275, - 107,248,160,248,160,301,107,301,107,275,70,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '306' $floorItems2['306'] = i w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) @@ -1592,7 +1592,7 @@ $floor2_demo = TkToplevel.new {|w| # label TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', - 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){ + 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){ pack('side'=>'top') } @@ -1621,12 +1621,12 @@ $floorItems2 = {} # canvas if $tk_version =~ /^4\.[01]/ $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken', - 'highlightthickness'=>2) + 'highlightthickness'=>2) $floor2_canvas = TkCanvas.new($floor2_canvas_frame, - 'width'=>900, 'height'=>500, 'borderwidth'=>0, - 'highlightthickness'=>0) {|c| + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| TkScrollbar.new($floor2_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}){|hs| + 'command'=>proc{|*args| c.xview(*args)}){|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) pack('side'=>'bottom', 'fill'=>'x') } @@ -1647,20 +1647,20 @@ else TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, - 'borderwidth'=>0, - 'highlightthickness'=>0) { - xscrollcommand(proc{|first,last| h.set first,last}) - yscrollcommand(proc{|first,last| v.set first,last}) - pack('expand'=>'yes', 'fill'=>'both') + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') } grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') } v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) @@ -1677,7 +1677,7 @@ end $currentRoom2 = TkVariable.new $floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken', - 'bd'=>2, 'textvariable'=>$currentRoom2) + 'bd'=>2, 'textvariable'=>$currentRoom2) # Choose colors, then fill in the floorplan. @@ -1714,7 +1714,7 @@ $floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas}) $floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''}) $floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y') $floor2_canvas.bind('B2-Motion', - proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y') + proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y') $floor2_canvas.bind('Destroy', proc{$currentRoom2.unset}) $currentRoom2.value = '' $currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas}) diff --git a/ext/tk/sample/demos-en/icon.rb b/ext/tk/sample/demos-en/icon.rb index 0acf8c041..58aca2df0 100644 --- a/ext/tk/sample/demos-en/icon.rb +++ b/ext/tk/sample/demos-en/icon.rb @@ -50,14 +50,14 @@ TkFrame.new($icon_demo) {|frame| flagup = \ TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagup.xbm'].join(File::Separator), - 'maskfile'=>\ - [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) + 'maskfile'=>\ + [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) flagdown = \ TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagdown.xbm'].join(File::Separator), - 'maskfile'=>\ - [$demo_dir,'..', - 'images','flagdown.xbm'].join(File::Separator)) + 'maskfile'=>\ + [$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator)) # create variable letters = TkVariable.new @@ -67,14 +67,14 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w| TkFrame.new(w) {|f| TkRadioButton.new(f){ bitmap '@' + [$demo_dir,'..', - 'images','letters.xbm'].join(File::Separator) + 'images','letters.xbm'].join(File::Separator) variable letters value 'full' }.pack('side'=>'top', 'expand'=>'yes') TkRadioButton.new(f){ bitmap '@' + [$demo_dir,'..', - 'images','noletter.xbm'].join(File::Separator) + 'images','noletter.xbm'].join(File::Separator) variable letters value 'empty' }.pack('side'=>'top', 'expand'=>'yes') diff --git a/ext/tk/sample/demos-en/image3.rb b/ext/tk/sample/demos-en/image3.rb index d7d823ccf..d77cc0f99 100644 --- a/ext/tk/sample/demos-en/image3.rb +++ b/ext/tk/sample/demos-en/image3.rb @@ -33,7 +33,7 @@ end # listbox from the directory named in the demo's entry. # # Arguments: -# w - Name of the toplevel window of the demo. +# w - Name of the toplevel window of the demo. def selectAndLoadDir(w, lbox) dir = Tk.chooseDirectory(:initialdir=>$dirName, :parent=>w, :mustexist=>true) if dir.length > 0 @@ -90,11 +90,11 @@ image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true) image3_df = TkLabelFrame.new($image3_demo, :text=>'Directory:') image3_ff = TkLabelFrame.new($image3_demo, :text=>'File:', - :padx=>'2m', :pady=>'2m') + :padx=>'2m', :pady=>'2m') image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) { pack(:side=>:left, :fill=>:y, :expand=>true) yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y, - :expand=>true)) + :expand=>true)) insert(0, *(%w(earth.gif earthris.gif teapot.ppm))) bind('Double-1', proc{|x,y| loadImage(self, x, y)}, '%x %y') } @@ -105,7 +105,7 @@ image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){ } TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"Select Dir.", - :command=>proc{selectAndLoadDir(image3_ent, image3_lbx)}) { + :command=>proc{selectAndLoadDir(image3_ent, image3_lbx)}) { pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m') } @@ -114,8 +114,8 @@ image3_if = TkLabelFrame.new($image3_demo, :text=>'Image:') {|f| } Tk.grid(image3_df, '-', - :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f) + :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f) Tk.grid(image3_ff, image3_if, - :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f) + :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f) TkGrid.columnconfigure(image3_f, 1, :weight=>1) diff --git a/ext/tk/sample/demos-en/items.rb b/ext/tk/sample/demos-en/items.rb index 81b447878..8ab7668a0 100644 --- a/ext/tk/sample/demos-en/items.rb +++ b/ext/tk/sample/demos-en/items.rb @@ -74,11 +74,11 @@ TkFrame.new($items_demo) {|cf| else c.grid('in'=>cf, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') vs.grid('row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') hs.grid('row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) @@ -114,126 +114,126 @@ $tag_item = TkcGroup.new(cvs) # Set up demos within each of the areas of the grid. TkcText.new(cvs, '5c', '.2c', 'text'=>'Lines', 'anchor'=>'n') TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c', - 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt', - 'join'=>'miter', 'tags'=>$tag_item ) + 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt', + 'join'=>'miter', 'tags'=>$tag_item ) TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item) TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item) TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c', - '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c', - '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', - 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) + '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c', + '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', + 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c', - 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', - 'tags'=>$tag_item ) + 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', + 'tags'=>$tag_item ) TkcText.new(cvs, '15c', '.2c', - 'text'=>'Curves (smoothed lines)', 'anchor'=>'n') + 'text'=>'Curves (smoothed lines)', 'anchor'=>'n') TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c', - 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item ) + 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item ) TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c', - 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item ) + 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item ) TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c', - '16.5c','4.5c','13.5c','7.5c','12c','6c', - 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', - 'stipple'=>'@'+[$demo_dir, '..', - 'images', 'gray25.xbm'].join(File::Separator), - 'fill'=>red, 'tags'=>$tag_item ) + '16.5c','4.5c','13.5c','7.5c','12c','6c', + 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), + 'fill'=>red, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '.2c', 'text'=>'Polygons', 'anchor'=>'n') TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c', - '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c', - 'fill'=>'green', 'outline'=>'black', 'width'=>4, - 'tags'=>$tag_item ) + '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c', + 'fill'=>'green', 'outline'=>'black', 'width'=>4, + 'tags'=>$tag_item ) TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c', - '28c','1c','29c','1c','29c','4c','29c','4c', - 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item) + '28c','1c','29c','1c','29c','4c','29c','4c', + 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item) TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c', - '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', - '7.5c','22c','7.5c', - 'stipple'=>'@' + [$demo_dir, '..', + '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', + '7.5c','22c','7.5c', + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'gray25.xbm'].join(File::Separator), - 'outline'=>'black', 'tags'=>$tag_item ) + 'outline'=>'black', 'tags'=>$tag_item ) TkcText.new(cvs, '5c', '8.2c', 'text'=>'Rectangles', 'anchor'=>'n') TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c', - 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c', - 'fill'=>green, 'tags'=>$tag_item ) + 'fill'=>green, 'tags'=>$tag_item ) TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'fill'=>blue, 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '15c', '8.2c', 'text'=>'Ovals', 'anchor'=>'n') TkcOval.new(cvs, '11c','9.5c','14c','12.5c', - 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c', - 'fill'=>green, 'tags'=>$tag_item ) + 'fill'=>green, 'tags'=>$tag_item ) TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'fill'=>blue, 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '8.2c', 'text'=>'Text', 'anchor'=>'n') TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c') TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c', - 'text'=>'A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text.', 'tags'=>$tag_item ) + 'text'=>'A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text.', 'tags'=>$tag_item ) TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c') TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue, - 'text'=>"Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge.", 'justify'=>'center', 'tags'=>$tag_item ) + 'text'=>"Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge.", 'justify'=>'center', 'tags'=>$tag_item ) TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c') if $tk_version =~ /^4\.[01]/ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'@' + [$demo_dir, '..', + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'grey.5'].join(File::Separator), - 'text'=>'Stippled characters', 'tags'=>$tag_item ) + 'text'=>'Stippled characters', 'tags'=>$tag_item ) else TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'gray50', 'text'=>'Stippled characters', - 'tags'=>$tag_item ) + 'stipple'=>'gray50', 'text'=>'Stippled characters', + 'tags'=>$tag_item ) end TkcText.new(cvs, '5c', '16.2c', 'text'=>'Arcs', 'anchor'=>'n') TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black', - 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item) + 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item) #TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', -# 'outline'=>blue, 'start'=>135, 'extent'=>270, -# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator), -# 'tags'=>$tag_item) +# 'outline'=>blue, 'start'=>135, 'extent'=>270, +# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator), +# 'tags'=>$tag_item) TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', - 'outline'=>blue, 'start'=>135, 'extent'=>270, - 'outlinestipple'=>'@'+[$demo_dir, '..', + 'outline'=>blue, 'start'=>135, 'extent'=>270, + 'outlinestipple'=>'@'+[$demo_dir, '..', 'images','gray25.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'tags'=>$tag_item) TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice', - 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, - 'tags'=>$tag_item) + 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, + 'tags'=>$tag_item) TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord', - 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270, - 'tags'=>$tag_item) + 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270, + 'tags'=>$tag_item) TkcText.new(cvs, '15c', '16.2c', 'text'=>'Bitmaps', 'anchor'=>'n') #TkcBitmap.new(cvs, '13c','20c', -# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), +# 'tags'=>$tag_item) TkcBitmap.new(cvs, '13c','20c', - 'bitmap'=>'@' + [$demo_dir, '..', + 'bitmap'=>'@' + [$demo_dir, '..', 'images', 'face.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','18.5c', -# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), +# 'tags'=>$tag_item) TkcBitmap.new(cvs, '17c','18.5c', - 'bitmap'=>'@' + [$demo_dir, '..', - 'images', 'noletter.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'noletter.xbm'].join(File::Separator), + 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','21.5c', -# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), +# 'tags'=>$tag_item) # TkcBitmap.new(cvs, '17c','21.5c') { bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator) @@ -249,17 +249,17 @@ TkButton.new(cvs) {|b| text 'Press Me' command proc{butPress cvs, red} TkcWindow.new(cvs, '21c','18c', - 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item) + 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item) } TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e| insert 'end', 'Edit this text' TkcWindow.new(cvs, '21c','21c', - 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item) + 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item) } TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c', - 'width'=>'.5c', 'tickinterval'=>0 ) {|scl| + 'width'=>'.5c', 'tickinterval'=>0 ) {|scl| TkcWindow.new(cvs, '28.5c','17.5c', - 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item) + 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item) } TkcText.new(cvs, '21c', '17.9c', 'text'=>'Button:', 'anchor'=>'sw') TkcText.new(cvs, '21c', '20.9c', 'text'=>'Entry:', 'anchor'=>'sw') @@ -324,7 +324,7 @@ def itemStroke(c,x,y) if $areaX1 != x && $areaY1 != y c.delete 'area' c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y, - '-outline', 'black') + '-outline', 'black') $areaX2 = x $areaY2 = y end @@ -369,6 +369,6 @@ end def butPress(w,color) i = TkcText.new(w, '25c', '18.1c', - 'text'=>'Ouch!!', 'fill'=>color, 'anchor'=>'n') + 'text'=>'Ouch!!', 'fill'=>color, 'anchor'=>'n') Tk.after(500, proc{w.delete i}) end diff --git a/ext/tk/sample/demos-en/label.rb b/ext/tk/sample/demos-en/label.rb index 96f76d35f..55e07a5eb 100644 --- a/ext/tk/sample/demos-en/label.rb +++ b/ext/tk/sample/demos-en/label.rb @@ -50,12 +50,12 @@ TkFrame.new($label_demo) {|frame| f_left = TkFrame.new($label_demo) f_right = TkFrame.new($label_demo) [f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes', - 'padx'=>10, 'pady'=>10, 'fill'=>'both')} + 'padx'=>10, 'pady'=>10, 'fill'=>'both')} # label [ TkLabel.new(f_left, 'text'=>'First label'), TkLabel.new(f_left, 'text'=>'Second label, raised', - 'relief'=>'raised'), + 'relief'=>'raised'), TkLabel.new(f_left, 'text'=>'Third label, sunken', 'relief'=>'sunken') ].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')} diff --git a/ext/tk/sample/demos-en/labelframe.rb b/ext/tk/sample/demos-en/labelframe.rb index 8636a4a9b..842a4f6c0 100644 --- a/ext/tk/sample/demos-en/labelframe.rb +++ b/ext/tk/sample/demos-en/labelframe.rb @@ -19,8 +19,8 @@ $labelframe_demo = TkToplevel.new {|w| # Some information TkLabel.new($labelframe_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) Labelframes are used to group related widgets together. \ The label may be either plain text or another widget. \ If your Tk library linked to Ruby doesn't include a 'labelframe' widget, \ @@ -33,28 +33,28 @@ TkFrame.new($labelframe_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $labelframe_demo.destroy - $labelframe_demo = nil - }).pack(:side=>:left, :expand=>true) + $labelframe_demo.destroy + $labelframe_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'labelframe' - }).pack(:side=>:left, :expand=>true) + showCode 'labelframe' + }).pack(:side=>:left, :expand=>true) } # Demo area w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both, - :expand=>true) + :expand=>true) # A group of radiobuttons in a labelframe TkLabelFrame.new(w, :text=>'Value', - :padx=>2, :pady=>2) {|f| + :padx=>2, :pady=>2) {|f| grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m') v = TkVariable.new (1..4).each{|i| TkRadiobutton.new(f, :text=>"This is value #{i}", - :variable=>v, :value=>i) { + :variable=>v, :value=>i) { pack(:side=>:top, :fill=>:x, :pady=>2) } } @@ -77,7 +77,7 @@ end TkLabelFrame.new(w, :pady=>2, :padx=>2){|f| TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy, - :text=>"Use this option.", :padx=>0) {|cb| + :text=>"Use this option.", :padx=>0) {|cb| command proc{lfEnableButtons(f)} f.labelwidget(cb) } diff --git a/ext/tk/sample/demos-en/menu.rb b/ext/tk/sample/demos-en/menu.rb index c29f6e90d..d835d145e 100644 --- a/ext/tk/sample/demos-en/menu.rb +++ b/ext/tk/sample/demos-en/menu.rb @@ -77,8 +77,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m| add('command', 'label'=>'Long entry that does nothing') ['A','B','C','D','E','F','G'].each{|c| add('command', 'label'=>"Print letter \"#{c}\"", - 'underline'=>14, 'accelerator'=>"Meta+#{c}", - 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) } } @@ -89,17 +89,17 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|cascade_menu| m.configure('menu'=>cascade_menu) add('command', 'label'=>'Print hello', - 'command'=>proc{print "Hello\n"}, - 'accelerator'=>"#{modifier}+H", 'underline'=>6) + 'command'=>proc{print "Hello\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) $menu_demo.bind("#{modifier}-h", proc{print "Hello\n"}) add('command', 'label'=>'Print goodbye', - 'command'=>proc{print "Goodbye\n"}, - 'accelerator'=>"#{modifier}+G", 'underline'=>6) + 'command'=>proc{print "Goodbye\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) $menu_demo.bind("#{modifier}-g", proc{print "Goodbye\n"}) TkMenu.new(m, 'tearoff'=>false) {|cascade_check| cascade_menu.add('cascade', 'label'=>'Check buttons', - 'menu'=>cascade_check, 'underline'=>0) + 'menu'=>cascade_check, 'underline'=>0) oil = TkVariable.new(0) add('check', 'label'=>'Oil checked', 'variable'=>oil) trans = TkVariable.new(0) @@ -110,18 +110,18 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| add('check', 'label'=>'Lights checked', 'variable'=>lights) add('separator') add('command', 'label'=>'Show current values', - 'command'=>proc{showVars($menu_demo, - ['oil', oil], - ['trans', trans], - ['brakes', brakes], - ['lights', lights])} ) + 'command'=>proc{showVars($menu_demo, + ['oil', oil], + ['trans', trans], + ['brakes', brakes], + ['lights', lights])} ) invoke 1 invoke 3 } TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| cascade_menu.add('cascade', 'label'=>'Radio buttons', - 'menu'=>cascade_radio, 'underline'=>0) + 'menu'=>cascade_radio, 'underline'=>0) pointSize = TkVariable.new add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10) add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14) @@ -135,9 +135,9 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic') add('separator') add('command', 'label'=>'Show current values', - 'command'=>proc{showVars($menu_demo, - ['pointSize', pointSize], - ['style', style])} ) + 'command'=>proc{showVars($menu_demo, + ['pointSize', pointSize], + ['style', style])} ) invoke 1 invoke 7 } @@ -149,15 +149,15 @@ TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|icon_menu| m.configure('menu'=>icon_menu) add('command', - 'bitmap'=>'@'+[$demo_dir,'..', - 'images','pattern.xbm'].join(File::Separator), - 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', - 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', - 'bitmap'=>'', 'default'=>0, - 'buttons'=>'Dismiss')} ) + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'Dismiss')} ) ['info', 'questhead', 'error'].each{|icon| add('command', 'bitmap'=>icon, - 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) } } } @@ -169,7 +169,7 @@ TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m| [ 'An entry','Another entry','Does nothing','Does almost nothing', 'Make life meaningful' ].each{|i| add('command', 'label'=>i, - 'command'=>proc{print "You invoked \"#{i}\"\n"}) + 'command'=>proc{print "You invoked \"#{i}\"\n"}) } } } @@ -180,7 +180,7 @@ TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m| m.configure('menu'=>colors_menu) ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| add('command', 'label'=>c, 'background'=>c, - 'command'=>proc{print "You invoked \"#{c}\"\n"}) + 'command'=>proc{print "You invoked \"#{c}\"\n"}) } } } diff --git a/ext/tk/sample/demos-en/menu84.rb b/ext/tk/sample/demos-en/menu84.rb index 8f7be9770..cb616d846 100644 --- a/ext/tk/sample/demos-en/menu84.rb +++ b/ext/tk/sample/demos-en/menu84.rb @@ -35,9 +35,9 @@ TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { menustatus = TkVariable.new(" ") TkFrame.new($menu84_demo) {|frame| TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken', - 'bd'=>1, 'font'=>['Helvetica', '10'], - 'anchor'=>'w').pack('side'=>'left', 'padx'=>2, - 'expand'=>true, 'fill'=>'both') + 'bd'=>1, 'font'=>['Helvetica', '10'], + 'anchor'=>'w').pack('side'=>'left', 'padx'=>2, + 'expand'=>true, 'fill'=>'both') pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) } @@ -91,8 +91,8 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('command', 'label'=>'Long entry that does nothing') ['A','B','C','D','E','F','G'].each{|c| add('command', 'label'=>"Print letter \"#{c}\"", - 'underline'=>14, 'accelerator'=>"Meta+#{c}", - 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) } } @@ -110,7 +110,7 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| TkMenu.new(m, 'tearoff'=>false) {|cascade_check| m.add('cascade', 'label'=>'Check buttons', - 'menu'=>cascade_check, 'underline'=>0) + 'menu'=>cascade_check, 'underline'=>0) oil = TkVariable.new(0) add('check', 'label'=>'Oil checked', 'variable'=>oil) trans = TkVariable.new(0) @@ -121,18 +121,18 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('check', 'label'=>'Lights checked', 'variable'=>lights) add('separator') add('command', 'label'=>'Show current values', - 'command'=>proc{showVars($menu84_demo, - ['oil', oil], - ['trans', trans], - ['brakes', brakes], - ['lights', lights])} ) + 'command'=>proc{showVars($menu84_demo, + ['oil', oil], + ['trans', trans], + ['brakes', brakes], + ['lights', lights])} ) invoke 1 invoke 3 } TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| m.add('cascade', 'label'=>'Radio buttons', - 'menu'=>cascade_radio, 'underline'=>0) + 'menu'=>cascade_radio, 'underline'=>0) pointSize = TkVariable.new add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10) add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14) @@ -146,9 +146,9 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic') add('separator') add('command', 'label'=>'Show current values', - 'command'=>proc{showVars($menu84_demo, - ['pointSize', pointSize], - ['style', style])} ) + 'command'=>proc{showVars($menu84_demo, + ['pointSize', pointSize], + ['style', style])} ) invoke 1 invoke 7 } @@ -158,14 +158,14 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0) add('command', 'hidemargin'=>1, 'bitmap'=>'@'+[$demo_dir,'..', - 'images','pattern.xbm'].join(File::Separator), + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', - 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', - 'bitmap'=>'', 'default'=>0, - 'buttons'=>'Dismiss')} ) + 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'Dismiss')} ) ['info', 'questhead', 'error'].each{|icon| add('command', 'bitmap'=>icon, 'hidemargin'=>1, - 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) } entryconfigure(2, :columnbreak=>true) @@ -176,38 +176,38 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| [ 'An entry','Another entry','Does nothing','Does almost nothing', 'Make life meaningful' ].each{|i| add('command', 'label'=>i, - 'command'=>proc{print "You invoked \"#{i}\"\n"}) + 'command'=>proc{print "You invoked \"#{i}\"\n"}) } m.entryconfigure('Does almost nothing', - 'bitmap'=>'questhead', 'compound'=>'left', - 'command'=>proc{ - TkDialog.new('title'=>'Compound Menu Entry', - 'message'=>'The menu entry you invoked'+ - 'displays both a bitmap and '+ - 'a text string. Other than '+ - 'this, it isjust like any '+ - 'other menu entry.', - 'buttons'=>['OK'], 'bitmap'=>'') - }) + 'bitmap'=>'questhead', 'compound'=>'left', + 'command'=>proc{ + TkDialog.new('title'=>'Compound Menu Entry', + 'message'=>'The menu entry you invoked'+ + 'displays both a bitmap and '+ + 'a text string. Other than '+ + 'this, it isjust like any '+ + 'other menu entry.', + 'buttons'=>['OK'], 'bitmap'=>'') + }) } TkMenu.new($menu84_frame) {|m| $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0) ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| add('command', 'label'=>c, 'background'=>c, - 'command'=>proc{print "You invoked \"#{c}\"\n"}) + 'command'=>proc{print "You invoked \"#{c}\"\n"}) } } $menu84_demo.menu($menu84_frame) TkMenu.bind('<MenuSelect>', proc{|w| - begin - label = w.entrycget('active', 'label') - rescue - label = " " - end - menustatus.value = label - Tk.update(true) - }, '%W') + begin + label = w.entrycget('active', 'label') + rescue + label = " " + end + menustatus.value = label + Tk.update(true) + }, '%W') diff --git a/ext/tk/sample/demos-en/menubu.rb b/ext/tk/sample/demos-en/menubu.rb index cc1ccafa7..e2ddd07bc 100644 --- a/ext/tk/sample/demos-en/menubu.rb +++ b/ext/tk/sample/demos-en/menubu.rb @@ -187,7 +187,7 @@ TkFrame.new(center) {|f| menubuttonoptions = TkVariable.new mbutton = TkMenubutton.new(f) options = optionMenu(mbutton, menubuttonoptions, - 'one', 'two', 'three') + 'one', 'two', 'three') mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25) paletteColor = TkVariable.new colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75', diff --git a/ext/tk/sample/demos-en/msgbox.rb b/ext/tk/sample/demos-en/msgbox.rb index 4152477e6..aab1b619c 100644 --- a/ext/tk/sample/demos-en/msgbox.rb +++ b/ext/tk/sample/demos-en/msgbox.rb @@ -20,7 +20,7 @@ $msgbox_demo = TkToplevel.new {|w| # label TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', - 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box.").pack('side'=>'top') + 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box.").pack('side'=>'top') # frame TkFrame.new($msgbox_demo) {|frame| @@ -48,9 +48,9 @@ TkFrame.new($msgbox_demo) {|frame| $msgbox_leftframe = TkFrame.new($msgbox_demo) $msgbox_rightframe = TkFrame.new($msgbox_demo) $msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', - 'pady'=>'.5c', 'padx'=>'.5c') + 'pady'=>'.5c', 'padx'=>'.5c') $msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', - 'pady'=>'.5c', 'padx'=>'.5c') + 'pady'=>'.5c', 'padx'=>'.5c') TkLabel.new($msgbox_leftframe, 'text'=>'Icon').pack('side'=>'top') TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ @@ -59,9 +59,9 @@ TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ $msgboxIcon = TkVariable.new('info') ['error', 'info', 'question', 'warning'].each {|icon| TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon, - 'relief'=>'flat', 'value'=>icon, 'width'=>16, - 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, - 'anchor'=>'w', 'fill'=>'x') + 'relief'=>'flat', 'value'=>icon, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') } TkLabel.new($msgbox_rightframe, 'text'=>'Type').pack('side'=>'top') @@ -72,17 +72,17 @@ $msgboxType = TkVariable.new('ok') ['abortretryignore', 'ok', 'okcancel', 'retrycancel', 'yesno', 'yesnocancel'].each {|type| TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType, - 'relief'=>'flat', 'value'=>type, 'width'=>16, - 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, - 'anchor'=>'w', 'fill'=>'x') + 'relief'=>'flat', 'value'=>type, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') } def showMessageBox(w) button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value, - 'title'=>'Message', 'parent'=>w, - 'message'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon") + 'title'=>'Message', 'parent'=>w, + 'message'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon") Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w, - 'message'=>"You have selected \"#{button}\"") + 'message'=>"You have selected \"#{button}\"") end diff --git a/ext/tk/sample/demos-en/paned1.rb b/ext/tk/sample/demos-en/paned1.rb index 8c25de0ef..48ba86de0 100644 --- a/ext/tk/sample/demos-en/paned1.rb +++ b/ext/tk/sample/demos-en/paned1.rb @@ -17,8 +17,8 @@ $paned1_demo = TkToplevel.new {|w| } TkLabel.new($paned1_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.) If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'. EOL @@ -28,13 +28,13 @@ TkFrame.new($paned1_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $paned1_demo.destroy - $paned1_demo = nil - }).pack(:side=>:left, :expand=>true) + $paned1_demo.destroy + $paned1_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'paned1' - }).pack(:side=>:left, :expand=>true) + showCode 'paned1' + }).pack(:side=>:left, :expand=>true) } TkPanedwindow.new($paned1_demo){|f| diff --git a/ext/tk/sample/demos-en/paned2.rb b/ext/tk/sample/demos-en/paned2.rb index 53c19c0ff..5911cadab 100644 --- a/ext/tk/sample/demos-en/paned2.rb +++ b/ext/tk/sample/demos-en/paned2.rb @@ -17,8 +17,8 @@ $paned2_demo = TkToplevel.new {|w| } TkLabel.new($paned2_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.) If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'. EOL @@ -28,13 +28,13 @@ TkFrame.new($paned2_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $paned2_demo.destroy - $paned2_demo = nil - }).pack(:side=>:left, :expand=>true) + $paned2_demo.destroy + $paned2_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'paned2' - }).pack(:side=>:left, :expand=>true) + showCode 'paned2' + }).pack(:side=>:left, :expand=>true) } paneList = TkVariable.new # define as normal variable (not array) @@ -65,28 +65,28 @@ TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f| pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m') add(TkFrame.new(f){|paned2_top| - TkListbox.new(paned2_top, :listvariable=>paneList) { - # Invert the first item to highlight it - itemconfigure(0, :background=>self.cget(:foreground), - :foreground=>self.cget(:background) ) - yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, - :fill=>:y)) - pack(:fill=>:both, :expand=>true) - } + TkListbox.new(paned2_top, :listvariable=>paneList) { + # Invert the first item to highlight it + itemconfigure(0, :background=>self.cget(:foreground), + :foreground=>self.cget(:background) ) + yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, + :fill=>:y)) + pack(:fill=>:both, :expand=>true) + } }, TkFrame.new(f, :height=>120) {|paned2_bottom| - # The bottom window is a text widget with scrollbar - paned2_xscr = TkScrollbar.new(paned2_bottom) - paned2_yscr = TkScrollbar.new(paned2_bottom) - paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) { - insert('1.0', "This is just a normal text widget") - xscrollbar(paned2_xscr) - yscrollbar(paned2_yscr) - } - Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew') - Tk.grid(paned2_xscr, :sticky=>'nsew') - TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1) - TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1) + # The bottom window is a text widget with scrollbar + paned2_xscr = TkScrollbar.new(paned2_bottom) + paned2_yscr = TkScrollbar.new(paned2_bottom) + paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) { + insert('1.0', "This is just a normal text widget") + xscrollbar(paned2_xscr) + yscrollbar(paned2_yscr) + } + Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew') + Tk.grid(paned2_xscr, :sticky=>'nsew') + TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1) + TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1) } ) } diff --git a/ext/tk/sample/demos-en/plot.rb b/ext/tk/sample/demos-en/plot.rb index fb887011a..6d01deeef 100644 --- a/ext/tk/sample/demos-en/plot.rb +++ b/ext/tk/sample/demos-en/plot.rb @@ -21,7 +21,7 @@ $plot_demo = TkToplevel.new {|w| # label TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', - 'text'=>"This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."){ + 'text'=>"This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."){ pack('side'=>'top') } @@ -54,39 +54,39 @@ $plot_canvas.pack('side'=>'top', 'fill'=>'x') TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2) TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2) TkcText.new($plot_canvas, 225, 20, - 'text'=>"A Simple Plot", 'font'=>plotFont, 'fill'=>'brown') + 'text'=>"A Simple Plot", 'font'=>plotFont, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2) TkcText.new($plot_canvas, x, 254, - 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n') + 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2) TkcText.new($plot_canvas, 96, y, - 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $plot_canvas.itembind('point', 'Any-Enter', - proc{$plot_canvas.itemconfigure 'current','fill','red'}) + proc{$plot_canvas.itemconfigure 'current','fill','red'}) $plot_canvas.itembind('point', 'Any-Leave', - proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'}) + proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'}) $plot_canvas.itembind('point', '1', - proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y") + proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y") $plot_canvas.itembind('point', 'ButtonRelease-1', - proc{$plot_canvas.dtag 'selected'}) + proc{$plot_canvas.dtag 'selected'}) $plot_canvas.bind('B1-Motion', - proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y") + proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y") $plot = {'lastX'=>0, 'lastY'=>0} @@ -95,8 +95,8 @@ $plot = {'lastX'=>0, 'lastY'=>0} # data points. It sets up state to allow the point to be dragged. # # Arguments: -# w - The canvas window. -# x, y - The coordinates of the mouse press. +# w - The canvas window. +# x, y - The coordinates of the mouse press. def plotDown (w, x, y) w.dtag 'selected' @@ -111,8 +111,8 @@ end # current item. # # Arguments: -# w - The canvas window. -# x, y - The coordinates of the mouse. +# w - The canvas window. +# x, y - The coordinates of the mouse. def plotMove (w, x, y) w.move 'selected', x - $plot['lastX'], y - $plot['lastY'] diff --git a/ext/tk/sample/demos-en/puzzle.rb b/ext/tk/sample/demos-en/puzzle.rb index d206efe34..0885cf297 100644 --- a/ext/tk/sample/demos-en/puzzle.rb +++ b/ext/tk/sample/demos-en/puzzle.rb @@ -88,7 +88,7 @@ order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12] highlightthickness 0 command def_puzzleswitch_proc(w, num) }.place('relx'=>$xpos[num], 'rely'=>$ypos[num], - 'relwidth'=>0.25, 'relheight'=>0.25) + 'relwidth'=>0.25, 'relheight'=>0.25) } $xpos['space'] = 0.75 $ypos['space'] = 0.75 @@ -105,9 +105,9 @@ def puzzleSwitch(w, num) && ($xpos[num] >= ($xpos['space'] - 0.26)) \ && ($xpos[num] <= ($xpos['space'] + 0.26))) \ || (($xpos[num] >= ($xpos['space'] - 0.01)) \ - && ($xpos[num] <= ($xpos['space'] + 0.01)) \ - && ($ypos[num] >= ($ypos['space'] - 0.26)) \ - && ($ypos[num] <= ($ypos['space'] + 0.26))) + && ($xpos[num] <= ($xpos['space'] + 0.01)) \ + && ($ypos[num] >= ($ypos['space'] - 0.26)) \ + && ($ypos[num] <= ($ypos['space'] + 0.26))) tmp = $xpos['space'] $xpos['space'] = $xpos[num] $xpos[num] = tmp diff --git a/ext/tk/sample/demos-en/radio2.rb b/ext/tk/sample/demos-en/radio2.rb index 090e75c2c..2b56ccc9b 100644 --- a/ext/tk/sample/demos-en/radio2.rb +++ b/ext/tk/sample/demos-en/radio2.rb @@ -54,18 +54,18 @@ TkFrame.new($radio2_demo) {|frame| text 'See Variables' command proc{ showVars($radio2_demo, - ['size', size], ['color', color], ['compound', align]) + ['size', size], ['color', color], ['compound', align]) } }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame f_left = TkLabelFrame.new($radio2_demo, 'text'=>'Point Size', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'Color', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_right = TkLabelFrame.new($radio2_demo, 'text'=>'Alignment', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') @@ -91,14 +91,14 @@ f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') } label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead', - 'compound'=>'left') + 'compound'=>'left') label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') label.height(TkWinfo.reqheight(label)) abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| lower = a.downcase TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', - 'value'=>lower, 'indicatoron'=>0, 'width'=>7, - 'command'=>proc{label.compound(align.value)}) + 'value'=>lower, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) } Tk.grid('x', abtn[0]) diff --git a/ext/tk/sample/demos-en/radio3.rb b/ext/tk/sample/demos-en/radio3.rb index ca0453416..70c4abb3b 100644 --- a/ext/tk/sample/demos-en/radio3.rb +++ b/ext/tk/sample/demos-en/radio3.rb @@ -36,43 +36,43 @@ align = TkVariable.new # frame TkFrame.new($radio3_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'See Variables', - :image=>$image['view'], :compound=>:left, - :command=>proc{ - showVars($radio3_demo, ['size', size], - ['color', color], ['compound', align]) - }), - TkButton.new(frame, :text=>'See Code', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'radio3'}), - TkButton.new(frame, :text=>'Dismiss', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $radio3_demo - $radio3_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'See Variables', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars($radio3_demo, ['size', size], + ['color', color], ['compound', align]) + }), + TkButton.new(frame, :text=>'See Code', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'radio3'}), + TkButton.new(frame, :text=>'Dismiss', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $radio3_demo + $radio3_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew') } # frame f_left = TkLabelFrame.new($radio3_demo, 'text'=>'Point Size', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'Color', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_right = TkLabelFrame.new($radio3_demo, 'text'=>'Alignment', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c') TkButton.new($radio3_demo, 'text'=>'Tristate', - 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){ + 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c') } @@ -100,13 +100,13 @@ TkButton.new($radio3_demo, 'text'=>'Tristate', } label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead', - 'compound'=>'left') + 'compound'=>'left') label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') label.height(TkWinfo.reqheight(label)) a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', - 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7, - 'command'=>proc{label.compound(align.value)}) + 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) } Tk.grid('x', a_btn[0]) diff --git a/ext/tk/sample/demos-en/ruler.rb b/ext/tk/sample/demos-en/ruler.rb index 03a00b75b..4299d57b4 100644 --- a/ext/tk/sample/demos-en/ruler.rb +++ b/ext/tk/sample/demos-en/ruler.rb @@ -11,8 +11,8 @@ # represent a tab stop. # # Arguments: -# c - The canvas window. -# x, y - Coordinates at which to create the tab stop. +# c - The canvas window. +# x, y - Coordinates at which to create the tab stop. def rulerMkTab(c,x,y) v = $demo_rulerInfo @@ -34,7 +34,7 @@ $ruler_demo = TkToplevel.new {|w| # label TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){ + 'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){ pack('side'=>'top') } @@ -63,8 +63,8 @@ $ruler_canvas.pack('side'=>'top', 'fill'=>'x') # unless Struct.const_defined?("RulerInfo") $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y, - :top, :bottom, :size, :normalStyle, - :activeStyle, :deleteStyle).new + :top, :bottom, :size, :normalStyle, + :activeStyle, :deleteStyle).new end $demo_rulerInfo.grid = '.25c' $demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c') @@ -86,7 +86,7 @@ else end TkcLine.new($ruler_canvas, - '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1) + '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1) (0..11).each{|i| x = i+1 TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1) @@ -99,22 +99,22 @@ TkcLine.new($ruler_canvas, $rulerTag_well = TkcTag.new($ruler_canvas) $ruler_canvas\ .addtag_withtag($rulerTag_well, - TkcRectangle.new($ruler_canvas, - '13.2c', '1c', '13.8c', '0.5c', - 'outline'=>'black', - 'fill'=>($ruler_canvas\ - .configinfo('background'))[4]) ) + TkcRectangle.new($ruler_canvas, + '13.2c', '1c', '13.8c', '0.5c', + 'outline'=>'black', + 'fill'=>($ruler_canvas\ + .configinfo('background'))[4]) ) $ruler_canvas\ .addtag_withtag($rulerTag_well, - rulerMkTab($ruler_canvas, - TkWinfo.pixels($ruler_canvas, '13.5c'), - TkWinfo.pixels($ruler_canvas, '.65c') ) ) + rulerMkTab($ruler_canvas, + TkWinfo.pixels($ruler_canvas, '13.5c'), + TkWinfo.pixels($ruler_canvas, '.65c') ) ) $rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.itembind('tab', '1', - proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y') + proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.bind('B1-Motion', - proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y') + proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)}) # rulerNewTab -- @@ -122,8 +122,8 @@ $ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)}) # triangle object and adding tags to it to give it tab behavior. # # Arguments: -# c - The canvas window. -# x, y - The coordinates of the tab stop. +# c - The canvas window. +# x, y - The coordinates of the tab stop. def rulerNewTab(c,x,y) v = $demo_rulerInfo @@ -140,9 +140,9 @@ end # be dragged interactively. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse (identifies the point by -# which the tab was picked up for dragging). +# c - The canvas widget. +# x, y - The coordinates of the mouse (identifies the point by +# which the tab was picked up for dragging). def rulerSelectTab(c,x,y) v = $demo_rulerInfo @@ -159,8 +159,8 @@ end # it is about to be dragged out of the ruler. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse. +# c - The canvas widget. +# x, y - The coordinates of the mouse. def rulerMoveTab(c,x,y) v = $demo_rulerInfo @@ -187,8 +187,8 @@ end # it was dragged out of the ruler. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse. +# c - The canvas widget. +# x, y - The coordinates of the mouse. def rulerReleaseTab(c) v = $demo_rulerInfo diff --git a/ext/tk/sample/demos-en/sayings.rb b/ext/tk/sample/demos-en/sayings.rb index 4ba3097be..cef0f4ecf 100644 --- a/ext/tk/sample/demos-en/sayings.rb +++ b/ext/tk/sample/demos-en/sayings.rb @@ -69,11 +69,11 @@ TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w| else sayings_lbox.grid('row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') sv.grid('row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') sh.grid('row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0) end diff --git a/ext/tk/sample/demos-en/search.rb b/ext/tk/sample/demos-en/search.rb index 59a8117bb..3d3b4aecc 100644 --- a/ext/tk/sample/demos-en/search.rb +++ b/ext/tk/sample/demos-en/search.rb @@ -13,9 +13,9 @@ # not affected, however. # # Arguments: -# w - The window into which to load the file. Must be a -# text widget. -# file - The name of the file to load. Must be readable. +# w - The window into which to load the file. Must be a +# text widget. +# file - The name of the file to load. Must be readable. def textLoadFile(w,file) w.delete('1.0', 'end') @@ -31,10 +31,10 @@ end # apply a given tag to each instance found. # # Arguments: -# w - The window in which to search. Must be a text widget. -# string - The string to search for. The search is done using -# exact matching only; no special characters. -# tag - Tag to apply to each instance of a matching string. +# w - The window in which to search. Must be a text widget. +# string - The string to search for. The search is done using +# exact matching only; no special characters. +# tag - Tag to apply to each instance of a matching string. def textSearch(w, string, tag) tag.remove('0.0', 'end') @@ -55,15 +55,15 @@ end # deleted) then it doesn't reschedule itself. # # Arguments: -# cmd1 - Command to execute when method is called. -# sleep1 - Ms to sleep after executing cmd1 before executing cmd2. -# cmd2 - Command to execute in the *next* invocation of this method. -# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again. +# cmd1 - Command to execute when method is called. +# sleep1 - Ms to sleep after executing cmd1 before executing cmd2. +# cmd2 - Command to execute in the *next* invocation of this method. +# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again. def textToggle(cmd1,sleep1,cmd2,sleep2) sleep_list = [sleep2, sleep1] TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep}, - -1, cmd1, cmd2).start(sleep1) + -1, cmd1, cmd2).start(sleep1) end # toplevel widget @@ -100,35 +100,35 @@ $search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame TkFrame.new($search_demo) {|f| TkLabel.new(f, 'text'=>'File name:', - 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') $search_fileName = TkVariable.new TkEntry.new(f, 'width'=>40, - 'textvariable'=>$search_fileName) { + 'textvariable'=>$search_fileName) { pack('side'=>'left') bind('Return', proc{textLoadFile($search_text, $search_fileName.value) - $search_string_entry.focus}) + $search_string_entry.focus}) focus } TkButton.new(f, 'text'=>'Load File', - 'command'=>proc{textLoadFile($search_text, - $search_fileName.value)})\ + 'command'=>proc{textLoadFile($search_text, + $search_fileName.value)})\ .pack('side'=>'left', 'pady'=>5, 'padx'=>10) }.pack('side'=>'top', 'fill'=>'x') TkFrame.new($search_demo) {|f| TkLabel.new(f, 'text'=>'Search string:', - 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') $search_searchString = TkVariable.new $search_string_entry = TkEntry.new(f, 'width'=>40, - 'textvariable'=>$search_searchString) { + 'textvariable'=>$search_searchString) { pack('side'=>'left') bind('Return', proc{textSearch($search_text, $search_searchString.value, - $search_Tag)}) + $search_Tag)}) } TkButton.new(f, 'text'=>'Highlight', - 'command'=>proc{textSearch($search_text, - $search_searchString.value, - $search_Tag)}) { + 'command'=>proc{textSearch($search_text, + $search_searchString.value, + $search_Tag)}) { pack('side'=>'left', 'pady'=>5, 'padx'=>10) } }.pack('side'=>'top', 'fill'=>'x') @@ -146,24 +146,24 @@ $search_text = TkText.new($search_demo, 'setgrid'=>true, 'wrap'=>'word') {|t| if TkWinfo.depth($search_demo) > 1 textToggle(proc{ - $search_Tag.configure('background'=>'#ce5555', - 'foreground'=>'white') - }, - 800, - proc{ - $search_Tag.configure('background'=>'', 'foreground'=>'') - }, - 200 ) + $search_Tag.configure('background'=>'#ce5555', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) else textToggle(proc{ - $search_Tag.configure('background'=>'black', - 'foreground'=>'white') - }, - 800, - proc{ - $search_Tag.configure('background'=>'', 'foreground'=>'') - }, - 200 ) + $search_Tag.configure('background'=>'black', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) end $search_text.insert('1.0', "\ This window demonstrates how to use the tagging facilities in text \ diff --git a/ext/tk/sample/demos-en/spin.rb b/ext/tk/sample/demos-en/spin.rb index 5d3245417..58616b1e0 100644 --- a/ext/tk/sample/demos-en/spin.rb +++ b/ext/tk/sample/demos-en/spin.rb @@ -16,8 +16,8 @@ $spin_demo = TkToplevel.new {|w| } TkLabel.new($spin_demo, - :font=>$font, :wraplength=>'5i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) Three different spin-boxes are displayed below. \ You can add characters by pointing, clicking and typing. \ The normal Motif editing characters are supported, along with \ @@ -38,13 +38,13 @@ TkFrame.new($spin_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $spin_demo.destroy - $spin_demo = nil - }).pack(:side=>:left, :expand=>true) + $spin_demo.destroy + $spin_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'spin' - }).pack(:side=>:left, :expand=>true) + showCode 'spin' + }).pack(:side=>:left, :expand=>true) } australianCities = [ @@ -54,10 +54,10 @@ australianCities = [ [ TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key, - :validatecommand=>[ - proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' - ]), + :validatecommand=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]), TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5, - :format=>'%05.2f', :width=>10), + :format=>'%05.2f', :width=>10), TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10) ].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)} diff --git a/ext/tk/sample/demos-en/style.rb b/ext/tk/sample/demos-en/style.rb index def83d1a2..5ed11aa45 100644 --- a/ext/tk/sample/demos-en/style.rb +++ b/ext/tk/sample/demos-en/style.rb @@ -65,13 +65,13 @@ TkText.new($style_demo){|t| # unless $style_demo_do_first # $style_demo_do_first = true # Tk.tk_call('font', 'create', '@bigascii', -# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*') +# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*') # Tk.tk_call('font', 'create', '@smallascii', -# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*') +# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*') # Tk.tk_call('font', 'create', '@cBigFont', -# '-compound', '@bigascii @msg_knj') +# '-compound', '@bigascii @msg_knj') # Tk.tk_call('font', 'create', '@cSmallFont', -# '-compound', '@smallascii @kanji') +# '-compound', '@smallascii @kanji') # end # style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont') # style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont') @@ -85,24 +85,24 @@ TkText.new($style_demo){|t| style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1) else style_tag_color1 = TkTextTag.new(t, 'background'=>'black', - 'foreground'=>'white') + 'foreground'=>'white') style_tag_color2 = TkTextTag.new(t, 'background'=>'black', - 'foreground'=>'white') + 'foreground'=>'white') style_tag_raised = TkTextTag.new(t, 'background'=>'white', - 'relief'=>'raised', 'borderwidth'=>1) + 'relief'=>'raised', 'borderwidth'=>1) style_tag_sunken = TkTextTag.new(t, 'background'=>'white', - 'relief'=>'sunken', 'borderwidth'=>1) + 'relief'=>'sunken', 'borderwidth'=>1) end # if $tk_version =~ /^4\.[01]/ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', - 'borderwidth'=>0, - 'bgstipple'=>'gray25') + 'borderwidth'=>0, + 'bgstipple'=>'gray25') else style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', - 'borderwidth'=>0, - 'bgstipple'=>'gray12') + 'borderwidth'=>0, + 'bgstipple'=>'gray12') end style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50') style_tag_underline = TkTextTag.new(t, 'underline'=>'on') @@ -112,10 +112,10 @@ TkText.new($style_demo){|t| style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m', - 'rmargin'=>'10m') + 'rmargin'=>'10m') style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p', - 'lmargin1'=>'12m', 'lmargin2'=>'6m', - 'rmargin'=>'10m') + 'lmargin1'=>'12m', 'lmargin2'=>'6m', + 'rmargin'=>'10m') # insert('end', 'Text widgets like this one allow you to display information in a diff --git a/ext/tk/sample/demos-en/text.rb b/ext/tk/sample/demos-en/text.rb index 2ed53e693..4bb4b6bc7 100644 --- a/ext/tk/sample/demos-en/text.rb +++ b/ext/tk/sample/demos-en/text.rb @@ -102,16 +102,16 @@ a new line by inserting a newline character to the right of the insertion cursor. Control-t transposes the two characters on either side of the insertion cursor. #{ if undo_support - undo_text = "Control-z undoes the last editing action performed,\nand " - case $tk_platform['platform'] - when "unix", "macintosh" - undo_text << "Control-Shift-z" - else # 'windows' - undo_text << "Control-y" - end - undo_text << "redoes undone edits." + undo_text = "Control-z undoes the last editing action performed,\nand " + case $tk_platform['platform'] + when "unix", "macintosh" + undo_text << "Control-Shift-z" + else # 'windows' + undo_text << "Control-y" + end + undo_text << "redoes undone edits." else - "" + "" end } diff --git a/ext/tk/sample/demos-en/twind.rb b/ext/tk/sample/demos-en/twind.rb index c841b7c31..24a4bcf70 100644 --- a/ext/tk/sample/demos-en/twind.rb +++ b/ext/tk/sample/demos-en/twind.rb @@ -40,10 +40,10 @@ $twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame $twind_text = nil TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2, - 'relief'=>'sunken') {|f| + 'relief'=>'sunken') {|f| $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font, - 'width'=>'70', 'height'=>35, 'wrap'=>'word', - 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| TkScrollbar.new(f) {|s| command proc{|*args| t.yview(args)} t.yscrollcommand proc{|first,last| s.set first,last} @@ -53,16 +53,16 @@ TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2, # $tag_center = TkTextTag.new($twind_text, - 'justify' =>'center', - 'spacing1'=>'5m', - 'spacing3'=>'5m' ) + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) $tag_buttons = TkTextTag.new($twind_text, - 'lmargin1'=>'1c', - 'lmargin2'=>'1c', - 'rmargin' =>'1c', - 'spacing1'=>'3m', - 'spacing2'=>0, - 'spacing3'=>0 ) + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) $twind_text.insert('end', "A text widget can contain other widgets embedded ") $twind_text.insert('end', "it. These are called \"embedded windows\", ") @@ -70,42 +70,42 @@ $twind_text.insert('end', "and they can consist of arbitrary widgets. ") $twind_text.insert('end', "For example, here are two embedded button ") $twind_text.insert('end', "widgets. You can click on the first button to ") TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - #text 'ON' - text 'Turn On' - command proc{textWindOn $twind_text,$twind_buttons} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + #text 'ON' + text 'Turn On' + command proc{textWindOn $twind_text,$twind_buttons} + cursor 'top_left_arrow' + }) $twind_text.insert('end', " horizontal scrolling, which also turns off ") $twind_text.insert('end', "word wrapping. Or, you can click on the second ") $twind_text.insert('end', "button to\n") TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - #text 'OFF' - text 'Turn Off' - command proc{textWindOff $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + #text 'OFF' + text 'Turn Off' + command proc{textWindOff $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', " horizontal scrolling and turn back on word wrapping.\n\n") $twind_text.insert('end', "Or, here is another example. If you ") TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text 'Click Here' - command proc{textWindPlot $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + text 'Click Here' + command proc{textWindPlot $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', " a canvas displaying an x-y plot will appear right here.") $mark_plot = TkTextMark.new($twind_text, 'insert') $mark_plot.gravity='left' $twind_text.insert('end', " You can drag the data points around with the mouse, ") $twind_text.insert('end', "or you can click here to ") TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text 'Delete' - command proc{textWindDel $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + text 'Delete' + command proc{textWindDel $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', " the plot again.\n\n") $twind_text.insert('end', "You may also find it useful to put embedded windows in ") @@ -123,27 +123,27 @@ $twind_text.insert('end', "to restore the short string.\n") TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) {|b| - text 'Default' - command proc{embDefBg $twind_text} - cursor 'top_left_arrow' - $tag_buttons.add('end') - }, - 'padx'=>3 ) + 'window'=>TkButton.new($twind_text) {|b| + text 'Default' + command proc{embDefBg $twind_text} + cursor 'top_left_arrow' + $tag_buttons.add('end') + }, + 'padx'=>3 ) embToggle = TkVariable.new('Short') TkTextWindow.new($twind_text, 'end', - 'window'=>TkCheckButton.new($twind_text) { - textvariable embToggle - indicatoron 0 - variable embToggle - onvalue 'A much longer string' - offvalue 'Short' - cursor 'top_left_arrow' - pady 5 - padx 2 - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkCheckButton.new($twind_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) [ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', @@ -151,13 +151,13 @@ TkTextWindow.new($twind_text, 'end', 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' ].each{|twind_color| TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text twind_color - cursor 'top_left_arrow' - command proc{$twind_text.bg twind_color} - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkButton.new($twind_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) } # @@ -211,39 +211,39 @@ def textWindPlot (t) TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2) TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2) TkcText.new($twind_plot, 225, 20, - 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2) TkcText.new($twind_plot, x, 254, - 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2) TkcText.new($twind_plot, 96, y, - 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $twind_plot.itembind('point', 'Any-Enter', - proc{$twind_plot.itemconfigure 'current', 'fill', 'red'}) + proc{$twind_plot.itemconfigure 'current', 'fill', 'red'}) $twind_plot.itembind('point', 'Any-Leave', - proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) $twind_plot.itembind('point', '1', - proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y") + proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y") $twind_plot.itembind('point', 'ButtonRelease-1', - proc{$twind_plot.dtag 'selected'}) + proc{$twind_plot.dtag 'selected'}) $twind_plot.bind('B1-Motion', - proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y") + proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y") while ($twind_text.get($mark_plot) =~ /[ \t\n]/) $twind_text.delete $mark_plot end diff --git a/ext/tk/sample/demos-en/twind2.rb b/ext/tk/sample/demos-en/twind2.rb index 95b11a799..c42e0999d 100644 --- a/ext/tk/sample/demos-en/twind2.rb +++ b/ext/tk/sample/demos-en/twind2.rb @@ -18,20 +18,20 @@ $twind2_demo = TkToplevel.new {|w| # frame $twind2_buttons = TkFrame.new($twind2_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'See Code', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'twind2'}), - TkButton.new(frame, :text=>'Dismiss', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $twind2_demo - $twind2_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'See Code', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'twind2'}), + TkButton.new(frame, :text=>'Dismiss', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $twind2_demo + $twind2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) } $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') @@ -39,11 +39,11 @@ $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame $twind2_text = nil TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2, - 'relief'=>'sunken') {|f| + 'relief'=>'sunken') {|f| $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font, - # 'width'=>'70', 'height'=>35, 'wrap'=>'word', - 'width'=>'70', 'height'=>35, 'wrap'=>'char', - 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + # 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'width'=>'70', 'height'=>35, 'wrap'=>'char', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| TkScrollbar.new(f) {|s| command proc{|*args| t.yview(*args)} t.yscrollcommand proc{|first,last| s.set first,last} @@ -53,26 +53,26 @@ TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2, # text tags $tag2_center = TkTextTag.new($twind2_text, - 'justify' =>'center', - 'spacing1'=>'5m', - 'spacing3'=>'5m' ) + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) $tag2_buttons = TkTextTag.new($twind2_text, - 'lmargin1'=>'1c', - 'lmargin2'=>'1c', - 'rmargin' =>'1c', - 'spacing1'=>'3m', - 'spacing2'=>0, - 'spacing3'=>0 ) + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) # insert text $twind2_text.insert('end', - 'A text widget can contain many different kinds of items, ') + 'A text widget can contain many different kinds of items, ') $twind2_text.insert('end', - "both active and passive. It can lay these out in various ") + "both active and passive. It can lay these out in various ") $twind2_text.insert('end', - "ways, with wrapping, tabs, centering, etc. In addition, ") + "ways, with wrapping, tabs, centering, etc. In addition, ") $twind2_text.insert('end', - "when the contents are too big for the window, smooth ") + "when the contents are too big for the window, smooth ") $twind2_text.insert('end', "scrolling in all directions is provided.\n\n") $twind2_text.insert('end', "A text widget can contain other widgets embedded ") @@ -81,59 +81,59 @@ $twind2_text.insert('end', "and they can consist of arbitrary widgets. ") $twind2_text.insert('end', "For example, here are two embedded button ") $twind2_text.insert('end', "widgets. You can click on the first button to ") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text 'ON' - command proc{textWindOn2 $twind2_text,$twind2_buttons} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text 'ON' + command proc{textWindOn2 $twind2_text,$twind2_buttons} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', " horizontal scrolling, which also turns off ") $twind2_text.insert('end', "word wrapping. Or, you can click on the second ") $twind2_text.insert('end', "button to\n") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text 'OFF' - command proc{textWindOff2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text 'OFF' + command proc{textWindOff2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', - " horizontal scrolling and turn back on word wrapping.\n\n") + " horizontal scrolling and turn back on word wrapping.\n\n") $twind2_text.insert('end', "Or, here is another example. If you ") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text 'Click Here' - command proc{textWindPlot2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text 'Click Here' + command proc{textWindPlot2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', - " a canvas displaying an x-y plot will appear right here.") + " a canvas displaying an x-y plot will appear right here.") $mark2_plot = TkTextMark.new($twind2_text, 'insert') $mark2_plot.gravity='left' $twind2_text.insert('end', - " You can drag the data points around with the mouse, ") + " You can drag the data points around with the mouse, ") $twind2_text.insert('end', "or you can click here to ") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text 'Delete' - command proc{textWindDel2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text 'Delete' + command proc{textWindDel2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', " the plot again.\n\n") $twind2_text.insert('end', - "You may also find it useful to put embedded windows in ") + "You may also find it useful to put embedded windows in ") $twind2_text.insert('end', - "a text without any actual text. In this case the ") + "a text without any actual text. In this case the ") $twind2_text.insert('end', "text widget acts like a geometry manager. For ") $twind2_text.insert('end', - "example, here is a collection of buttons laid out ") + "example, here is a collection of buttons laid out ") $twind2_text.insert('end', - "neatly into rows by the text widget. These buttons ") + "neatly into rows by the text widget. These buttons ") $twind2_text.insert('end', - "can be used to change the background color of the ") + "can be used to change the background color of the ") $twind2_text.insert('end', "text widget (\"Default\" restores the color to ") $twind2_text.insert('end', - "its default). If you click on the button labeled ") + "its default). If you click on the button labeled ") $twind2_text.insert('end', "\"Short\", it changes to a longer string so that ") $twind2_text.insert('end', "you can see how the text widget automatically ") $twind2_text.insert('end', "changes the layout. Click on the button again ") @@ -147,18 +147,18 @@ btn_default = TkButton.new($twind2_text) {|b| TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3) embToggle = TkVariable.new('Short') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkCheckButton.new($twind2_text) { - textvariable embToggle - indicatoron 0 - variable embToggle - onvalue 'A much longer string' - offvalue 'Short' - cursor 'top_left_arrow' - pady 5 - padx 2 - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkCheckButton.new($twind2_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) [ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', @@ -166,13 +166,13 @@ TkTextWindow.new($twind2_text, 'end', 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' ].each{|twind_color| TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text twind_color - cursor 'top_left_arrow' - command proc{$twind2_text.bg twind_color} - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkButton.new($twind2_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind2_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) } $tag2_buttons.add(btn_default, 'end') @@ -186,55 +186,55 @@ $twind2_text.insert('end', "\nYou can also change the usual border width and ") $twind2_text.insert('end', "highlightthickness and padding.\n") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big borders", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigB2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigB2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small borders", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallB2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallB2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big highlight", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigH2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigH2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small highlight", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallH2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallH2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big pad", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigP2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigP2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small pad", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallP2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallP2 $twind2_text + })) $twind2_text.insert('end', - "\n\nFinally, images fit comfortably in text widgets too:") + "\n\nFinally, images fit comfortably in text widgets too:") TkTextImage.new($twind2_text, 'end', - 'image'=>TkBitmapImage.new(:file=>[ - $demo_dir, '..', - 'images', 'face.xbm' - ].join(File::Separator))) + 'image'=>TkBitmapImage.new(:file=>[ + $demo_dir, '..', + 'images', 'face.xbm' + ].join(File::Separator))) # methods def textWinBigB2(w) @@ -308,39 +308,39 @@ def textWindPlot2 (t) TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2) TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2) TkcText.new($twind2_plot, 225, 20, - 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2) TkcText.new($twind2_plot, x, 254, - 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2) TkcText.new($twind2_plot, 96, y, - 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $twind2_plot.itembind('point', 'Any-Enter', - proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'}) + proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'}) $twind2_plot.itembind('point', 'Any-Leave', - proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) $twind2_plot.itembind('point', '1', - proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y") + proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y") $twind2_plot.itembind('point', 'ButtonRelease-1', - proc{$twind2_plot.dtag 'selected'}) + proc{$twind2_plot.dtag 'selected'}) $twind2_plot.bind('B1-Motion', - proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y") + proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y") while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/) $twind2_text.delete $mark2_plot end diff --git a/ext/tk/sample/demos-en/unicodeout.rb b/ext/tk/sample/demos-en/unicodeout.rb index 7bb951c93..07e3bf52b 100644 --- a/ext/tk/sample/demos-en/unicodeout.rb +++ b/ext/tk/sample/demos-en/unicodeout.rb @@ -17,8 +17,8 @@ $unicodeout_demo = TkToplevel.new {|w| } TkLabel.new($unicodeout_demo, - :font=>$font, :wraplength=>'5.4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5.4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) This is a sample of Tk's support for languages that use non-Western \ character sets. However, what you will actually see below depends \ largely on what character sets you have installed, and what you see \ @@ -40,18 +40,18 @@ TkFrame.new($unicodeout_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{ - $unicodeout_demo.destroy - $unicodeout_demo = nil - }).pack(:side=>:left, :expand=>true) + $unicodeout_demo.destroy + $unicodeout_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{ - showCode 'unicodeout' - }).pack(:side=>:left, :expand=>true) + showCode 'unicodeout' + }).pack(:side=>:left, :expand=>true) } wait_msg = TkLabel.new($unicodeout_demo, - :text=>"Please wait while loading fonts...", - :font=>"Helvetica 12 italic").pack + :text=>"Please wait while loading fonts...", + :font=>"Helvetica 12 italic").pack class Unicodeout_SampleFrame < TkFrame @@font = $font @@ -71,10 +71,10 @@ class Unicodeout_SampleFrame < TkFrame def add_sample(lang, *args) sample_txt = Tk::UTF8_String(args.join('')) l = TkLabel.new(self, :font=>@@font, :text=>lang+':', - :anchor=>:nw, :pady=>0) + :anchor=>:nw, :pady=>0) #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt, s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt, - :anchor=>:nw, :width=>30, :pady=>0) + :anchor=>:nw, :width=>30, :pady=>0) Tk.grid(l, s, :sticky=>:ew, :pady=>0) l.grid_config(:padx, '1m') end @@ -90,23 +90,23 @@ $unicodeout_demo.cursor('watch') Tk.update f.add_sample('Arabic', - '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94', - '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D') + '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94', + '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D') f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57') f.add_sample('Simpl. Chinese', '\u6C49\u8BED') f.add_sample('Greek', - '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ', - '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1') + '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ', + '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1') f.add_sample('Hebrew', - '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ', - '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9') + '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ', + '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9') f.add_sample('Japanese', - '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ', - '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA') + '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ', + '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA') f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00') f.add_sample('Russian', - '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ', - '\u044F\u0437\u044B\u043A') + '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ', + '\u044F\u0437\u044B\u043A') wait_msg.destroy $unicodeout_demo.cursor(oldCursor) diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index f529792e7..133d151d4 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -103,11 +103,11 @@ end # TkMenubar.new($root, - [[['File', 0], - ['About ... ', proc{aboutBox}, 0, '<F1>'], - '---', - ['Quit', proc{exit}, 0, 'Meta-Q'] - ]]).pack('side'=>'top', 'fill'=>'x') + [[['File', 0], + ['About ... ', proc{aboutBox}, 0, '<F1>'], + '---', + ['Quit', proc{exit}, 0, 'Meta-Q'] + ]]).pack('side'=>'top', 'fill'=>'x') $root.bind('F1', proc{aboutBox}) $root.bind('Meta-q', proc{exit}) @@ -141,7 +141,7 @@ if $tk_version =~ /^4\.[01]/ else textFrame = TkFrame.new($root) scr = TkScrollbar.new($root, 'orient'=>'vertical', - 'highlightthickness'=>0, 'takefocus'=>1) { + 'highlightthickness'=>0, 'takefocus'=>1) { pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1) } txt = TkText.new($root) { @@ -166,11 +166,11 @@ else statusBar = TkFrame.new($root) {|f| $statusBarLabel = \ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ - .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') + 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ + .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ - .pack('side'=>'left', 'padx'=>2) + 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ + .pack('side'=>'left', 'padx'=>2) }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) end @@ -188,53 +188,53 @@ tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c') if TkWinfo.depth($root) == 1 tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'underline'=>1) + 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'underline'=>1) + 'underline'=>1) tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white') else tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'foreground'=>'blue', 'underline'=>1) + 'foreground'=>'blue', 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'foreground'=>'#303080', 'underline'=>1) + 'foreground'=>'#303080', 'underline'=>1) # tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1, -# 'background'=>'SeaGreen3') +# 'background'=>'SeaGreen3') tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red') end #tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')}) tag_demo.bind('ButtonRelease-1', - proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y') + proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y') lastLine = TkVariable.new("") newLine = TkVariable.new("") tag_demo.bind('Enter', proc{|x,y| - lastLine.value = txt.index("@#{x},#{y} linestart") - tag_hot.add(lastLine.value, "#{lastLine.value} lineend") - showStatus txt, txt.index("@#{x},#{y}") - }, - '%x %y') + lastLine.value = txt.index("@#{x},#{y} linestart") + tag_hot.add(lastLine.value, "#{lastLine.value} lineend") + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') tag_demo.bind('Leave', - proc{ - tag_hot.remove('1.0','end') - txt.configure('cursor','xterm') - $statusBarLabel.configure('text'=>"") - }) + proc{ + tag_hot.remove('1.0','end') + txt.configure('cursor','xterm') + $statusBarLabel.configure('text'=>"") + }) tag_demo.bind('Motion', proc{|x, y| - newLine.value = txt.index("@#{x},#{y} linestart") - if newLine.value != lastLine.value - tag_hot.remove('1.0','end') - lastLine.value = newLine.value - if ( txt.tag_names("@#{x},#{y}").find{|t| - t.kind_of?(String) && t =~ /^demo-/ - } ) - tag_hot.add(lastLine.value, - "#{lastLine.value} lineend -1 chars") - end - end - showStatus txt, txt.index("@#{x},#{y}") - }, - '%x %y') + newLine.value = txt.index("@#{x},#{y} linestart") + if newLine.value != lastLine.value + tag_hot.remove('1.0','end') + lastLine.value = newLine.value + if ( txt.tag_names("@#{x},#{y}").find{|t| + t.kind_of?(String) && t =~ /^demo-/ + } ) + tag_hot.add(lastLine.value, + "#{lastLine.value} lineend -1 chars") + end + end + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') # Create the text for the text widget. @@ -308,8 +308,8 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. With scrollbars.\n", tag_demo, "demo-entry2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', - "3. Validated entries and password fields. (if supported)\n", - tag_demo, "demo-entry3") + "3. Validated entries and password fields. (if supported)\n", + tag_demo, "demo-entry3") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. Spin-boxes. (if supported)\n", tag_demo, "demo-spin") txt.insert('end', " \n ", tag_demospace) @@ -406,7 +406,7 @@ scr.focus # new demo window. # # Arguments: -# w - The name of the window to position. +# w - The name of the window to position. def positionWindow(w) w.geometry('+300+300') @@ -417,8 +417,8 @@ end # updates the display whenever any of the variables changes. # # Arguments: -# w - Name of new window to create for display. -# args - Any number of names of variables. +# w - Name of new window to create for display. +# args - Any number of names of variables. $showVarsWin = {} def showVars1(parent, *args) @@ -442,10 +442,10 @@ def showVars1(parent, *args) } args.each{|vnam,vbody| TkFrame.new(w){|f| - #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left') - TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left') - TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\ - .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') + #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left') + TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left') + TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\ + .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x') } TkButton.new(w) { @@ -467,11 +467,11 @@ def showVars2(parent, *args) title "Variable values" TkLabelFrame.new(w, :text=>"Variable values:", - :font=>{:family=>'Helvetica', :size=>14}){|f| + :font=>{:family=>'Helvetica', :size=>14}){|f| args.each{|vnam,vbody| - TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), - TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), - :padx=>2, :pady=>2, :sticky=>'w') + TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), + TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), + :padx=>2, :pady=>2, :sticky=>'w') } f.grid(:sticky=>'news', :padx=>4) @@ -479,7 +479,7 @@ def showVars2(parent, *args) f.grid_rowconfig(100, :weight=>1) } TkButton.new(w, :text=>"OK", :width=>8, :default=>:active, - :command=>proc{w.destroy}){|b| + :command=>proc{w.destroy}){|b| w.bind('Return', proc{b.invoke}) w.bind('Escape', proc{b.invoke}) @@ -503,8 +503,8 @@ end # It is responsible for invoking the demonstration. # # Arguments: -# txt - Name of text widget -# index - The index of the character that the user clicked on. +# txt - Name of text widget +# index - The index of the character that the user clicked on. def invoke (txt, index) tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/} @@ -524,8 +524,8 @@ end # showStatus -- # -# Show the name of the demo program in the status bar. This procedure -# is called when the user moves the cursor over a demo description. +# Show the name of the demo program in the status bar. This procedure +# is called when the user moves the cursor over a demo description. # def showStatus (txt, index) @@ -537,7 +537,7 @@ def showStatus (txt, index) else demoname = tag[5..-1] $statusBarLabel.configure('text', - "Run the \"#{demoname}\" sample program") + "Run the \"#{demoname}\" sample program") newcursor = 'hand2' end txt.configure('cursor'=>newcursor) if cursor != newcursor @@ -548,8 +548,8 @@ end # a demonstration and allows it to be edited and reinvoked. # # Arguments: -# demo - The name of the demonstration's window, which can be -# used to derive the name of the file containing its code. +# demo - The name of the demonstration's window, which can be +# used to derive the name of the file containing its code. def showCode1(demo) file = "#{demo}.rb" @@ -560,8 +560,8 @@ def showCode1(demo) TkButton.new(f) { text "Dismiss" command proc{ - $code_window.destroy - $code_window = nil + $code_window.destroy + $code_window = nil } }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2) TkButton.new(f) { @@ -574,44 +574,44 @@ def showCode1(demo) if $tk_version =~ /^4\.[01]/ s = TkScrollbar.new($code_window, 'orient'=>'vertical') $code_text = TkText.new($code_window) { - height 40 - setgrid 'yes' - yscrollcommand proc{|first,last| s.set first,last} + height 40 + setgrid 'yes' + yscrollcommand proc{|first,last| s.set first,last} } s.command(proc{|*args| $code_text.yview(*args)}) s.pack('side'=>'right', 'fill'=>'y') $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both') else TkFrame.new($code_window) {|f| - pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) - - hs = TkScrollbar.new($code_window, 'highlightthickness'=>0, - 'orient'=>'horizontal') - vs = TkScrollbar.new($code_window, 'highlightthickness'=>0, - 'orient'=>'vertical') - $code_text = TkText.new($code_window) {|t| - height 40 - wrap 'word' - xscrollcommand proc{|first,last| hs.set first,last} - yscrollcommand proc{|first,last| vs.set first,last} - setgrid 'yes' - highlightthickness 0 - pady 2 - padx 3 - hs.command(proc{|*args| $code_text.xview(*args)}) - vs.command(proc{|*args| $code_text.yview(*args)}) - } - - $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') - vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') -# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, -# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + + hs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'horizontal') + vs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'vertical') + $code_text = TkText.new($code_window) {|t| + height 40 + wrap 'word' + xscrollcommand proc{|first,last| hs.set first,last} + yscrollcommand proc{|first,last| vs.set first,last} + setgrid 'yes' + highlightthickness 0 + pady 2 + padx 3 + hs.command(proc{|*args| $code_text.xview(*args)}) + vs.command(proc{|*args| $code_text.yview(*args)}) + } + + $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') +# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, +# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') # JKC 2001-07-26: segfaults under 1.7.1 (2001-06-19) [i686-linux] - TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) - TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) } end else @@ -638,8 +638,8 @@ def showCode2(demo) $code_window = TkToplevel.new(nil) tf = TkFrame.new($code_window) $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30, - :wrap=>'word', :bd=>1, :setgrid=>true, - :highlightthickness=>0, :pady=>2, :padx=>3) + :wrap=>'word', :bd=>1, :setgrid=>true, + :highlightthickness=>0, :pady=>2, :padx=>3) xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} TkGrid($code_text, yscr, :sticky=>'news') @@ -650,17 +650,17 @@ def showCode2(demo) bf = TkFrame.new($code_window) b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active, - :command=>proc{ - $code_window.destroy - $code_window = nil - }, - :image=>$image['delete'], :compound=>:left) + :command=>proc{ + $code_window.destroy + $code_window = nil + }, + :image=>$image['delete'], :compound=>:left) b_prn = TkButton.new(bf, :text=>'Print Code', - :command=>proc{printCode($code_text, file)}, - :image=>$image['print'], :compound=>:left) + :command=>proc{printCode($code_text, file)}, + :image=>$image['print'], :compound=>:left) b_run = TkButton.new(bf, :text=>'Rerun Demo', - :command=>proc{eval($code_text.get('1.0','end'))}, - :image=>$image['refresh'], :compound=>:left) + :command=>proc{eval($code_text.get('1.0','end'))}, + :image=>$image['refresh'], :compound=>:left) TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4]) bf.grid_columnconfigure(0, :weight=>1) @@ -671,8 +671,8 @@ def showCode2(demo) $code_window.grid_rowconfigure(0, :weight=>1) $code_window.bind('Return', proc{|win| - b_dis.invoke unless win.kind_of?(TkText) - }, '%W') + b_dis.invoke unless win.kind_of?(TkText) + }, '%W') $code_window.bindinfo('Return').each{|cmd, arg| $code_window.bind_append('Escape', cmd, arg) } @@ -704,8 +704,8 @@ end # Much thanks to Arjen Markus for this. # # Arguments: -# txt - Name of text widget containing code to print -# file - Name of the original file (implicitly for title) +# txt - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) def printCode(txt, file) code = txt.get('1.0', 'end - 1c') @@ -721,24 +721,24 @@ def printCode(txt, file) when 'unix' msg = `lp -c #{fname}` unless $?.exitstatus == 0 - Tk.messageBox(:title=>'Print spooling failure', - :message=>'Print spooling probably failed: ' + msg) + Tk.messageBox(:title=>'Print spooling failure', + :message=>'Print spooling probably failed: ' + msg) end when 'windows' begin - printTextWin32(fname) + printTextWin32(fname) rescue => e - Tk.messageBox(:title=>'Print spooling failure', - :message=>'Print spooling probably failed: ' + - e.message) + Tk.messageBox(:title=>'Print spooling failure', + :message=>'Print spooling probably failed: ' + + e.message) end when 'macintosh' Tk.messageBox(:title=>'Operation not Implemented', - :message=>'Oops, sorry: not implemented yet!') + :message=>'Oops, sorry: not implemented yet!') else Tk.messageBox(:title=>'Operation not Implemented', - :message=>'Wow! Unknown platform: ' + - Tk::TCL_PLATFORM('platform')) + :message=>'Wow! Unknown platform: ' + + Tk::TCL_PLATFORM('platform')) end ensure File.delete(fname) @@ -749,7 +749,7 @@ end # Print a file under Windows # # Arguments: -# filename - Name of the file +# filename - Name of the file # def printTextWin32(fname) require 'win32/registry' @@ -780,12 +780,12 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk widget demonstration Ver.1.4.3-en\n\n" + + 'message'=>"Ruby/Tk widget demonstration Ver.1.4.3-en\n\n" + "based on demos of Tk8.1 -- 8.5 " + - "( Copyright:: " + - "(c) 1996-1997 Sun Microsystems, Inc. / " + + "( Copyright:: " + + "(c) 1996-1997 Sun Microsystems, Inc. / " + "(c) 1997-2000 Ajuba Solutions, Inc. / " + - "(c) 2001-2003 Donal K. Fellows )\n\n" + + "(c) 2001-2003 Donal K. Fellows )\n\n" + "Your Ruby & Tk Version ::\n" + "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}") end @@ -809,7 +809,7 @@ if no_launcher loop do count = 0 $root.winfo_children.each{|w| - count += 1 if w.kind_of?(TkToplevel) + count += 1 if w.kind_of?(TkToplevel) } $root.destroy if count == 0 end diff --git a/ext/tk/sample/demos-jp/arrow.rb b/ext/tk/sample/demos-jp/arrow.rb index 70fe346b6..477a0abf6 100644 --- a/ext/tk/sample/demos-jp/arrow.rb +++ b/ext/tk/sample/demos-jp/arrow.rb @@ -9,7 +9,7 @@ # interactively. # # Arguments: -# c - Name of the canvas widget. +# c - Name of the canvas widget. def arrowSetup(c) v = $demo_arrowInfo @@ -25,59 +25,59 @@ def arrowSetup(c) # Create the arrow and outline. c.delete('all') TkcLine.new(c, v.x1, v.y, v.x2, v.y, - { 'width'=>10 * v.width, - 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], - 'arrow'=>'last' - }.update(v.bigLineStyle) ) + { 'width'=>10 * v.width, + 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], + 'arrow'=>'last' + }.update(v.bigLineStyle) ) xtip = v.x2 - 10*v.b deltaY = 10*v.c + 5*v.width TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY, - v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, - 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round') + v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, + 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round') # Create the boxes for reshaping the line and arrowhead. TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5, - {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) ) TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5, - {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) ) TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5, - {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) ) + {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) ) c.itemconfigure cur, v.activeStyle if cur # Create three arrows in actual size with the same parameters TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2) tmp = v.x2+100 TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width, - 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) # Create a bunch of other arrows and text items showing the # current dimensions. tmp = v.x2+10 TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w') tmp = v.x1-10 TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e') tmp = v.y+5*v.width+10*v.c+10 TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n') tmp = tmp+25 TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp, - 'arrow'=>'both', 'arrowshape'=>v.smallTips) + 'arrow'=>'both', 'arrowshape'=>v.smallTips) TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n') TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') TkcText.new(c, v.x1, 330, - 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') v.count += 1 end @@ -97,7 +97,7 @@ $arrow_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"¤³¤Î widget ¤Ç¡¢¥¥ã¥ó¥Ð¥¹¤Ç»È¤ï¤ì¤ë¥é¥¤¥ó¤Ë¤Ä¤¤¤ÆÍÍ¡¹¤ÊÉý¤äÌð°õ¤ÎƬ¤Î·Á¤ò»î¤·¤Æ¤ß¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£Àþ¤ÎÉý¤äÌð°õ¤Î·Á¤òÊѤ¨¤ë¤Ë¤Ï¡¢³ÈÂ礵¤ì¤¿Ìð°õ¤Ë¤Ä¤¤¤Æ¤¤¤ë 3¤Ä¤Î»Í³Ñ¤ò¥É¥é¥Ã¥°¤·¤Æ¤¯¤À¤µ¤¤¡£±¦Â¦¤ÎÌð°õ¤ÏÉáÄ̤ÎÂ礤µ¤Ç¤Î¥µ¥ó¥×¥ë¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Æ¥¥¹¥È¤Ï¥é¥¤¥ó¥¢¥¤¥Æ¥à¤ËÂФ¹¤ëÀßÄꥪ¥×¥·¥ç¥ó¤Ç¤¹¡£"){ + 'text'=>"¤³¤Î widget ¤Ç¡¢¥¥ã¥ó¥Ð¥¹¤Ç»È¤ï¤ì¤ë¥é¥¤¥ó¤Ë¤Ä¤¤¤ÆÍÍ¡¹¤ÊÉý¤äÌð°õ¤ÎƬ¤Î·Á¤ò»î¤·¤Æ¤ß¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£Àþ¤ÎÉý¤äÌð°õ¤Î·Á¤òÊѤ¨¤ë¤Ë¤Ï¡¢³ÈÂ礵¤ì¤¿Ìð°õ¤Ë¤Ä¤¤¤Æ¤¤¤ë 3¤Ä¤Î»Í³Ñ¤ò¥É¥é¥Ã¥°¤·¤Æ¤¯¤À¤µ¤¤¡£±¦Â¦¤ÎÌð°õ¤ÏÉáÄ̤ÎÂ礤µ¤Ç¤Î¥µ¥ó¥×¥ë¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Æ¥¥¹¥È¤Ï¥é¥¤¥ó¥¢¥¤¥Æ¥à¤ËÂФ¹¤ëÀßÄꥪ¥×¥·¥ç¥ó¤Ç¤¹¡£"){ pack('side'=>'top') } @@ -122,14 +122,14 @@ $arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # canvas ÀßÄê $arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350, - 'relief'=>'sunken', 'borderwidth'=>2) + 'relief'=>'sunken', 'borderwidth'=>2) $arrow_canvas.pack('expand'=>'yes', 'fill'=>'both') # ÃÍÀßÄê unless Struct.const_defined?("ArrowInfo") $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc, - :x1, :x2, :y, :smallTips, :count, - :bigLineStyle, :boxStyle, :activeStyle).new + :x1, :x2, :y, :smallTips, :count, + :bigLineStyle, :boxStyle, :activeStyle).new end $demo_arrowInfo.a = 8 $demo_arrowInfo.b = 10 @@ -158,16 +158,16 @@ $arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_ar $arrowTag_box.bind('B1-Enter', proc{}) $arrowTag_box.bind('B1-Leave', proc{}) $arrow_canvas.itembind('box1', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove1 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove1 $arrow_canvas, x, y}}) $arrow_canvas.itembind('box2', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove2 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove2 $arrow_canvas, x, y}}) $arrow_canvas.itembind('box3', '1', - proc{$demo_arrowInfo.motionProc \ - = proc{|x,y| arrowMove3 $arrow_canvas, x, y}}) + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove3 $arrow_canvas, x, y}}) $arrowTag_box.bind('B1-Motion', - proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y") + proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y") $arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas}) # arrowMove1 -- @@ -176,8 +176,8 @@ $arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas}) # for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove1(c,x,y) v = $demo_arrowInfo @@ -196,8 +196,8 @@ end # parameters for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove2(c,x,y) v = $demo_arrowInfo @@ -220,8 +220,8 @@ end # controlling parameters for the line and arrowhead. # # Arguments: -# c - The name of the canvas window. -# x, y - The coordinates of the mouse. +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. def arrowMove3(c,x,y) v = $demo_arrowInfo diff --git a/ext/tk/sample/demos-jp/bind.rb b/ext/tk/sample/demos-jp/bind.rb index eebd62fc0..70127424c 100644 --- a/ext/tk/sample/demos-jp/bind.rb +++ b/ext/tk/sample/demos-jp/bind.rb @@ -73,34 +73,34 @@ TkText.new($bind_demo){|t| insert('end', '2. ´Êñ¤Ê 2¼¡¸µ¤Î¥×¥í¥Ã¥È¡£¥Ç¡¼¥¿¤òɽ¤¹ÅÀ¤òÆ°¤«¤¹¤³¤È¤¬¤Ç¤¤ë¡£', (d2 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '3. ¥Æ¥¥¹¥È¥¢¥¤¥Æ¥à¤Î¥¢¥ó¥«¡¼¤È¹Ô·¤¨¡£', - (d3 = TkTextTag.new(t)) ) + (d3 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '4. ¥é¥¤¥ó¥¢¥¤¥Æ¥à¤Î¤¿¤á¤ÎÌð°õ¤ÎƬ¤Î·Á¤Î¥¨¥Ç¥£¥¿¡£', - (d4 = TkTextTag.new(t)) ) + (d4 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', '5. ¥¿¥Ö¥¹¥È¥Ã¥×¤òÊѹ¹¤¹¤ë¤¿¤á¤Îµ¡Ç½¤Ä¤¤Î¥ë¡¼¥é¡¼¡£', - (d5 = TkTextTag.new(t)) ) + (d5 = TkTextTag.new(t)) ) insert('end', "\n\n") insert('end', - '6. ¥¥ã¥ó¥Ð¥¹¤¬¤É¤¦¤ä¤Ã¤Æ¥¹¥¯¥í¡¼¥ë¤¹¤ë¤Î¤«¤ò¼¨¤¹¥°¥ê¥Ã¥É¡£', - (d6 = TkTextTag.new(t)) ) + '6. ¥¥ã¥ó¥Ð¥¹¤¬¤É¤¦¤ä¤Ã¤Æ¥¹¥¯¥í¡¼¥ë¤¹¤ë¤Î¤«¤ò¼¨¤¹¥°¥ê¥Ã¥É¡£', + (d6 = TkTextTag.new(t)) ) # binding [d1, d2, d3, d4, d5, d6].each{|tag| tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal) } d1.bind('1', - proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`}) d2.bind('1', - proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`}) d3.bind('1', - proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`}) d4.bind('1', - proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`}) d5.bind('1', - proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`}) d6.bind('1', - proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`}) + proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`}) TkTextMarkInsert.new(t, '0.0') configure('state','disabled') diff --git a/ext/tk/sample/demos-jp/bitmap.rb b/ext/tk/sample/demos-jp/bitmap.rb index 644b96081..b71c67d3f 100644 --- a/ext/tk/sample/demos-jp/bitmap.rb +++ b/ext/tk/sample/demos-jp/bitmap.rb @@ -6,19 +6,19 @@ # Create a row of bitmap items in a window. # # Arguments: -# w - The parent window that is to contain the row. -# args - The names of one or more bitmaps, which will be displayed -# in a new row across the bottom of w along with their -# names. +# w - The parent window that is to contain the row. +# args - The names of one or more bitmaps, which will be displayed +# in a new row across the bottom of w along with their +# names. def bitmapRow(w,*args) TkFrame.new(w){|row| pack('side'=>'top', 'fill'=>'both') for bitmap in args TkFrame.new(row){|base| - pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c') - TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom') - TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom') + pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c') + TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom') + TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom') } end } @@ -39,7 +39,7 @@ $bitmap_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¡¢Tk ¤ËÁȤ߹þ¤Þ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¤¬¡¢¤½¤ì¤é¤Î̾Á°¤È¶¦¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Tcl ¤Î¥¹¥¯¥ê¥×¥ÈÃæ¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤Î̾Á°¤òÍѤ¤¤Æ»²¾È¤·¤Þ¤¹¡£"){ + 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¡¢Tk ¤ËÁȤ߹þ¤Þ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¤¬¡¢¤½¤ì¤é¤Î̾Á°¤È¶¦¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Tcl ¤Î¥¹¥¯¥ê¥×¥ÈÃæ¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤Î̾Á°¤òÍѤ¤¤Æ»²¾È¤·¤Þ¤¹¡£"){ pack('side'=>'top') } diff --git a/ext/tk/sample/demos-jp/check.rb b/ext/tk/sample/demos-jp/check.rb index 88e90c71d..be675b904 100644 --- a/ext/tk/sample/demos-jp/check.rb +++ b/ext/tk/sample/demos-jp/check.rb @@ -52,7 +52,7 @@ TkFrame.new($check_demo) {|frame| text 'ÊÑ¿ô»²¾È' command proc{ showVars($check_demo, - ['wipers', wipers], ['brakes', brakes], ['sober', sober]) + ['wipers', wipers], ['brakes', brakes], ['sober', sober]) } }.pack('side'=>'left', 'expand'=>'yes') diff --git a/ext/tk/sample/demos-jp/check2.rb b/ext/tk/sample/demos-jp/check2.rb index 63d3bf939..5d0c74a74 100644 --- a/ext/tk/sample/demos-jp/check2.rb +++ b/ext/tk/sample/demos-jp/check2.rb @@ -33,35 +33,35 @@ sober = TkVariable.new(0) # frame À¸À® TkFrame.new($check2_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È', - :image=>$image['view'], :compound=>:left, - :command=>proc{ - showVars($check2_demo, - ['safety', safety], ['wipers', wipers], - ['brakes', brakes], ['sober', sober]) - }), - TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'check2'}), - TkButton.new(frame, :text=>'ÊĤ¸¤ë', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $check2_demo - $check2_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars($check2_demo, + ['safety', safety], ['wipers', wipers], + ['brakes', brakes], ['sober', sober]) + }), + TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'check2'}), + TkButton.new(frame, :text=>'ÊĤ¸¤ë', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $check2_demo + $check2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) }.pack('side'=>'bottom', 'fill'=>'x') # checkbutton À¸À® TkCheckButton.new($check2_demo, :text=>'°ÂÁ´À¸¡ºº', :variable=>safety, - :relief=>:flat, :onvalue=>'all', :offvalue=>'none', - :tristatevalue=>'partial'){ + :relief=>:flat, :onvalue=>'all', :offvalue=>'none', + :tristatevalue=>'partial'){ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') } @@ -82,21 +82,21 @@ tristate_check = proc{|n1,n2,op| begin if n1 == safety if safety == 'none' - wipers.value = 0 - brakes.value = 0 - sober.value = 0 + wipers.value = 0 + brakes.value = 0 + sober.value = 0 elsif safety == 'all' - wipers.value = 1 - brakes.value = 1 - sober.value = 1 + wipers.value = 1 + brakes.value = 1 + sober.value = 1 end else if wipers == 1 && brakes == 1 && sober == 1 - safety.value = 'all' + safety.value = 'all' elsif wipers == 1 || brakes == 1 || sober == 1 - safety.value = 'partial' + safety.value = 'partial' else - safety.value = 'none' + safety.value = 'none' end end ensure diff --git a/ext/tk/sample/demos-jp/clrpick.rb b/ext/tk/sample/demos-jp/clrpick.rb index 284611a77..de8cd80fc 100644 --- a/ext/tk/sample/demos-jp/clrpick.rb +++ b/ext/tk/sample/demos-jp/clrpick.rb @@ -17,7 +17,7 @@ $clrpick_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"°Ê²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¡¢¤³¤Î¥¦¥£¥ó¥É¥¦¾å¤Ë¤¢¤ë¥¦¥£¥¸¥§¥Ã¥È¤ÎÁ°·Ê¿§¤ÈÇØ·Ê¿§¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£").pack('side'=>'top') + 'text'=>"°Ê²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¡¢¤³¤Î¥¦¥£¥ó¥É¥¦¾å¤Ë¤¢¤ë¥¦¥£¥¸¥§¥Ã¥È¤ÎÁ°·Ê¿§¤ÈÇØ·Ê¿§¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£").pack('side'=>'top') # frame À¸À® TkFrame.new($clrpick_demo) {|frame| @@ -40,7 +40,7 @@ TkFrame.new($clrpick_demo) {|frame| # button À¸À® TkButton.new($clrpick_demo, 'text'=>'ÇØ·Ê¿§¤òÀßÄê ...') {|b| command(proc{setColor $clrpick_demo, b, 'background', - ['background', 'highlightbackground']}) + ['background', 'highlightbackground']}) pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m') } @@ -53,7 +53,7 @@ def setColor(w,button,name,options) w.grab initialColor = button[name] color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w, - 'initialcolor'=>initialColor) + 'initialcolor'=>initialColor) if color != "" setColor_helper(w,options,color) end diff --git a/ext/tk/sample/demos-jp/cscroll.rb b/ext/tk/sample/demos-jp/cscroll.rb index d128b63a7..0d6db69af 100644 --- a/ext/tk/sample/demos-jp/cscroll.rb +++ b/ext/tk/sample/demos-jp/cscroll.rb @@ -17,7 +17,7 @@ $cscroll_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i', - 'justify'=>'left', 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ä¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2 ¤Ç¥¹¥¯¥í¡¼¥ë¤Ç¤¤ë¥¥ã¥ó¥Ð¥¹ widget ¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£»Í³Ñ¤Î¾å¤Ç¥Ü¥¿¥ó1 ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬É¸½à½ÐÎϤ˽ÐÎϤµ¤ì¤Þ¤¹¡£"){ + 'justify'=>'left', 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ä¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2 ¤Ç¥¹¥¯¥í¡¼¥ë¤Ç¤¤ë¥¥ã¥ó¥Ð¥¹ widget ¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£»Í³Ñ¤Î¾å¤Ç¥Ü¥¿¥ó1 ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬É¸½à½ÐÎϤ˽ÐÎϤµ¤ì¤Þ¤¹¡£"){ pack('side'=>'top') } @@ -51,14 +51,14 @@ end # canvas ÀßÄê $cscroll_canvas = TkCanvas.new($cscroll_demo, - 'relief'=>'sunken', 'borderwidth'=>2, - 'scrollregion'=>['-11c', '-11c', '50c', '20c'] - ) {|c| + 'relief'=>'sunken', 'borderwidth'=>2, + 'scrollregion'=>['-11c', '-11c', '50c', '20c'] + ) {|c| if $tk_version =~ /^4\.[01]/ pack('expand'=>'yes', 'fill'=>'both') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs| @@ -67,18 +67,18 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo, pack('side'=>'right', 'fill'=>'y') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end } TkScrollbar.new($cscroll_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}) {|hs| + 'command'=>proc{|*args| c.xview(*args)}) {|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) if $tk_version =~ /^4\.[01]/ pack('side'=>'bottom', 'fill'=>'x') else grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') end } } @@ -89,9 +89,9 @@ bg = $cscroll_canvas.configinfo('bg')[4] y = -10 (0..9).each{|j| TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c", - 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect') + 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect') TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c", - 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text') + 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text') y += 3 } } @@ -102,7 +102,7 @@ $cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas}) $cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas}) $cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y') $cscroll_canvas.bind('B2-Motion', - proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y') + proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y') def scrollEnter(c) id = c.find_withtag('current')[0].id diff --git a/ext/tk/sample/demos-jp/ctext.rb b/ext/tk/sample/demos-jp/ctext.rb index 4704b4141..a71b6f2cb 100644 --- a/ext/tk/sample/demos-jp/ctext.rb +++ b/ext/tk/sample/demos-jp/ctext.rb @@ -17,7 +17,7 @@ $ctext_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Î¥Æ¥¥¹¥Èʸ»úÎó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Þ¥¦¥¹¤ò»Í³Ñ¤ÎÃæ¤Ë»ý¤Ã¤Æ¤¤¤¡¢¥¯¥ê¥Ã¥¯¤¹¤ë¤È°ÌÃÖ¤®¤áÍѤÎÅÀ¤«¤é¤ÎÁêÂаÌÃÖ¤òÊѤ¨¤¿¤ê¡¢¹Ô·¤¨¤òÊѤ¨¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿°Ê²¼¤Î¤è¤¦¤ÊÊÔ½¸¤Î¤¿¤á¤Î´Êñ¤Ê¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ + 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Î¥Æ¥¥¹¥Èʸ»úÎó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Þ¥¦¥¹¤ò»Í³Ñ¤ÎÃæ¤Ë»ý¤Ã¤Æ¤¤¤¡¢¥¯¥ê¥Ã¥¯¤¹¤ë¤È°ÌÃÖ¤®¤áÍѤÎÅÀ¤«¤é¤ÎÁêÂаÌÃÖ¤òÊѤ¨¤¿¤ê¡¢¹Ô·¤¨¤òÊѤ¨¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿°Ê²¼¤Î¤è¤¦¤ÊÊÔ½¸¤Î¤¿¤á¤Î´Êñ¤Ê¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ 1. ¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤¡¢¥¯¥ê¥Ã¥¯¤·¡¢ÆþÎϤǤ¤Þ¤¹¡£ 2. ¥Ü¥¿¥ó1¤ÇÁªÂò¤Ç¤¤Þ¤¹¡£ @@ -48,7 +48,7 @@ $ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # canvas À¸À® $ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat', - 'borderwidth'=>0, 'width'=>500, 'height'=>350) + 'borderwidth'=>0, 'width'=>500, 'height'=>350) $ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both') # font ÀßÄê @@ -56,37 +56,37 @@ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' # canvas ÀßÄê TkcRectangle.new($ctext_canvas, 245, 195, 255, 205, - 'outline'=>'black', 'fill'=>'red') + 'outline'=>'black', 'fill'=>'red') $ctag_text = TkcTag.new($ctext_canvas) $ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, - 'text'=>"¤³¤ì¤Ï¥¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ç¤¹¡£¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤¡¢¥¯¥ê¥Ã¥¯¤·¤ÆÆþÎϤǤ¤Þ¤¹¡£ÁªÂò¤·¤Æ¥³¥ó¥È¥í¡¼¥ë-D¤Ç¾Ãµî¤¹¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£", - 'width'=>440, 'anchor'=>'n', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*', - 'kanjifont'=>'-*-r-*--24-*-jisx0208.1983-0', - 'justify'=>'left') ) + 'text'=>"¤³¤ì¤Ï¥¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ç¤¹¡£¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤¡¢¥¯¥ê¥Ã¥¯¤·¤ÆÆþÎϤǤ¤Þ¤¹¡£ÁªÂò¤·¤Æ¥³¥ó¥È¥í¡¼¥ë-D¤Ç¾Ãµî¤¹¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£", + 'width'=>440, 'anchor'=>'n', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*', + 'kanjifont'=>'-*-r-*--24-*-jisx0208.1983-0', + 'justify'=>'left') ) $ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('Shift-1', - proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"}, - "%x %y") + proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"}, + "%x %y") $ctag_text.bind('Shift-B1-Motion', - proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") + proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A") $ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"}) $ctag_text.bind('Control-h', proc{textBs $ctext_canvas}) $ctag_text.bind('BackSpace', proc{textBs $ctext_canvas}) $ctag_text.bind('Delete', proc{textDel $ctext_canvas}) $ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"}, - "%x %y") + "%x %y") # Next, create some items that allow the text's anchor position # to be edited. def mkTextConfig(w,x,y,option,value,color) item = TkcRectangle.new(w, x, y, x+30, y+30, - 'outline'=>'black', 'fill'=>color, 'width'=>1) + 'outline'=>'black', 'fill'=>color, 'width'=>1) item.bind('1', proc{$ctag_text.configure option, value}) w.addtag_withtag('config', item) end @@ -104,11 +104,11 @@ mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50, - 'outline'=>'black', 'fill'=>'red') + 'outline'=>'black', 'fill'=>'red') item.bind('1', proc{$ctag_text.configure 'anchor', 'center'}) TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'fill'=>'brown') # Lastly, create some items that allow the text's justification to be # changed. @@ -120,14 +120,14 @@ mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'fill'=>'brown') $ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas}) $ctext_canvas.itembind('config', 'Leave', - proc{$ctext_canvas\ - .itemconfigure('current', - 'fill'=>$textConfigFill)}) + proc{$ctext_canvas\ + .itemconfigure('current', + 'fill'=>$textConfigFill)}) $textConfigFill = '' diff --git a/ext/tk/sample/demos-jp/dialog2.rb b/ext/tk/sample/demos-jp/dialog2.rb index 36b2356cc..a934378dd 100644 --- a/ext/tk/sample/demos-jp/dialog2.rb +++ b/ext/tk/sample/demos-jp/dialog2.rb @@ -28,9 +28,9 @@ class TkDialog_Demo2 < TkDialog end ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'}, - 'prev_command'=>proc{|dialog| - Tk.after 100, proc{dialog.grab('global')} - }).value + 'prev_command'=>proc{|dialog| + Tk.after 100, proc{dialog.grab('global')} + }).value case ret when 0 print "¤¢¤Ê¤¿¤Ï¡Öλ²ò¡×¤ò²¡¤·¤Þ¤·¤¿¤Í¡£\n" diff --git a/ext/tk/sample/demos-jp/entry3.rb b/ext/tk/sample/demos-jp/entry3.rb index 4dff97a93..f57dc1355 100644 --- a/ext/tk/sample/demos-jp/entry3.rb +++ b/ext/tk/sample/demos-jp/entry3.rb @@ -18,8 +18,8 @@ $entry3_demo = TkToplevel.new {|w| } TkLabel.new($entry3_demo, - :font=>$font, :wraplength=>'5i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) °Ê²¼¤Ë¤Ï£´¼ïÎà¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥³Æ¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ï¡¤\ ¥Þ¥¦¥¹¥¯¥ê¥Ã¥¯¤ÇÁªÂò¤·Ê¸»ú¤òÂǤÁ¹þ¤à¤³¤È¤¬²Äǽ¤Ç¤¹¤¬¡¤¤½¤ì¤¾¤ì¤¬¤É¤Î¤è¤¦¤Ê\ ÆþÎϤò¼õ¤±ÉÕ¤±¤ë¤³¤È¤¬¤Ç¤¤ë¤«¤Ë¤ÏÀ©Ìó¤¬Àߤ±¤é¤ì¤Æ¤¤¤Þ¤¹¡¥\ @@ -42,13 +42,13 @@ TkFrame.new($entry3_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $entry3_demo.destroy - $entry3_demo = nil - }).pack(:side=>:left, :expand=>true) + $entry3_demo.destroy + $entry3_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'entry3' - }).pack(:side=>:left, :expand=>true) + showCode 'entry3' + }).pack(:side=>:left, :expand=>true) } # focusAndFlash -- @@ -58,32 +58,32 @@ TkFrame.new($entry3_demo){|f| # 2.5Hz). # # Arguments: -# widget - entry widget to flash -# fg - Initial foreground colour -# bg - Initial background colour -# count - Counter to control the number of times flashed +# widget - entry widget to flash +# fg - Initial foreground colour +# bg - Initial background colour +# count - Counter to control the number of times flashed def focusAndFlash(widget, fg, bg, count=5) return if count <= 0 TkTimer.new(100, count, - proc{widget.configure(:foreground=>bg, :background=>fg)}, - proc{widget.configure(:foreground=>fg, :background=>bg)} - ).start + proc{widget.configure(:foreground=>bg, :background=>fg)}, + proc{widget.configure(:foreground=>fg, :background=>bg)} + ).start widget.focus(true) end l1 = TkLabelFrame.new($entry3_demo, :text=>"À°¿ô¥¨¥ó¥È¥ê") TkEntry.new(l1, :validate=>:focus, - :vcmd=>[ - proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' - ]) {|e| + :vcmd=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]) {|e| invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W'] pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') } l2 = TkLabelFrame.new($entry3_demo, :text=>"ŤµÀ©ÌóÉÕ¤¥¨¥ó¥È¥ê") TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell}, - :vcmd=>[proc{|s| s.length < 10}, '%P'] - ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + :vcmd=>[proc{|s| s.length < 10}, '%P'] + ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') ### PHONE NUMBER ENTRY ### # Note that the source to this is quite a bit longer as the behaviour @@ -105,7 +105,7 @@ Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n| # Skip over fixed characters in a phone-number string when moving left. # # Arguments: -# widget - The entry widget containing the phone-number. +# widget - The entry widget containing the phone-number. def phoneSkipLeft(widget) idx = widget.index('insert') if idx == 8 @@ -125,7 +125,7 @@ end # Skip over fixed characters in a phone-number string when moving right. # # Arguments: -# widget - The entry widget containing the phone-number. +# widget - The entry widget containing the phone-number. # add - Offset to add to index before calculation (used by validation.) def phoneSkipRight(widget, add = 0) idx = widget.index('insert') @@ -149,14 +149,14 @@ end # # widget - entry widget to validate # vmode - The widget's validation mode -# idx - The index where replacement is to occur +# idx - The index where replacement is to occur # char - The character (or string, though that will always be -# refused) to be overwritten at that point. +# refused) to be overwritten at that point. def validatePhoneChange(widget, vmode, idx, char) return true if idx == nil Tk.after_idle(proc{widget.configure(:validate=>vmode, - :invcmd=>proc{Tk.bell})}) + :invcmd=>proc{Tk.bell})}) if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/ widget.delete(idx) widget.insert(idx, $phoneNumberMap[char] || char) @@ -171,17 +171,17 @@ end l3 = TkLabelFrame.new($entry3_demo, :text=>"ÊƹñÅÅÏÃÈֹ楨¥ó¥È¥ê") TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell}, - :textvariable=>entry3content, - :vcmd=>[ - proc{|w,v,i,s| validatePhoneChange(w,v,i,s)}, - "%W %v %i %S" - ]){|e| + :textvariable=>entry3content, + :vcmd=>[ + proc{|w,v,i,s| validatePhoneChange(w,v,i,s)}, + "%W %v %i %S" + ]){|e| # Click to focus goes to the first editable character... bind('FocusIn', proc{|d,w| - if d != "NotifyAncestor" - w.cursor = 3 - Tk.after_idle(proc{w.selection_clear}) - end + if d != "NotifyAncestor" + w.cursor = 3 + Tk.after_idle(proc{w.selection_clear}) + end }, '%d %W') bind('Left', proc{|w| phoneSkipLeft(w)}, '%W') bind('Right', proc{|w| phoneSkipRight(w)}, '%W') @@ -190,10 +190,10 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell}, l4 = TkLabelFrame.new($entry3_demo, :text=>"¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê") TkEntry.new(l4, :validate=>:key, :show=>'*', - :vcmd=>[ - proc{|s| s.length <= 8}, - '%P' - ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + :vcmd=>[ + proc{|s| s.length <= 8}, + '%P' + ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') TkFrame.new($entry3_demo){|f| lower diff --git a/ext/tk/sample/demos-jp/filebox.rb b/ext/tk/sample/demos-jp/filebox.rb index 78ae50a45..f3608ab70 100644 --- a/ext/tk/sample/demos-jp/filebox.rb +++ b/ext/tk/sample/demos-jp/filebox.rb @@ -17,7 +17,7 @@ $filebox_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', - 'text'=>"¥¨¥ó¥È¥ê¤Ë¥Õ¥¡¥¤¥ë̾¤òľÀÜÆþÎϤ¹¤ë¤«¡¢\"Browse\" ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤«¤é¥Õ¥¡¥¤¥ë̾¤òÁª¤ó¤Ç²¼¤µ¤¤¡£").pack('side'=>'top') + 'text'=>"¥¨¥ó¥È¥ê¤Ë¥Õ¥¡¥¤¥ë̾¤òľÀÜÆþÎϤ¹¤ë¤«¡¢\"Browse\" ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤«¤é¥Õ¥¡¥¤¥ë̾¤òÁª¤ó¤Ç²¼¤µ¤¤¡£").pack('side'=>'top') # frame À¸À® TkFrame.new($filebox_demo) {|frame| @@ -47,7 +47,7 @@ TkFrame.new($filebox_demo) {|frame| pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') TkButton.new(f, 'text'=>'Browse ...', - 'command'=>proc{fileDialog $filebox_demo,e,type})\ + 'command'=>proc{fileDialog $filebox_demo,e,type})\ .pack('side'=>'left') } @@ -58,9 +58,9 @@ TkFrame.new($filebox_demo) {|frame| $tk_strictMotif = TkVarAccess.new('tk_strictMotif') if ($tk_platform['platform'] == 'unix') TkCheckButton.new($filebox_demo, - 'text'=>'Motif¥¹¥¿¥¤¥ë¤Î¥À¥¤¥¢¥í¥°¤òÍѤ¤¤ë', - 'variable'=>$tk_strictMotif, - 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c') + 'text'=>'Motif¥¹¥¿¥¤¥ë¤Î¥À¥¤¥¢¥í¥°¤òÍѤ¤¤ë', + 'variable'=>$tk_strictMotif, + 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c') end def fileDialog(w,ent,operation) @@ -84,8 +84,8 @@ def fileDialog(w,ent,operation) file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w) else file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w, - 'initialfile'=>'Untitled', - 'defaultextension'=>'.txt') + 'initialfile'=>'Untitled', + 'defaultextension'=>'.txt') end if file != "" ent.delete 0, 'end' diff --git a/ext/tk/sample/demos-jp/floor.rb b/ext/tk/sample/demos-jp/floor.rb index d9d17ee94..517600de9 100644 --- a/ext/tk/sample/demos-jp/floor.rb +++ b/ext/tk/sample/demos-jp/floor.rb @@ -8,8 +8,8 @@ # visible. # # Arguments: -# w - Name of the canvas window. -# active - Number of active floor (1, 2, or 3). +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). def floorDisplay(w,active) return if $activeFloor == active @@ -59,7 +59,7 @@ end # highlighted. # # Arguments: -# w - The name of the canvas window. +# w - The name of the canvas window. def newRoom(w) id = w.find_withtag('current')[0] @@ -72,8 +72,8 @@ end # It highlights the current room and unhighlights any previous room. # # Arguments: -# w - The canvas window displaying the floorplan. -# args - Not used. +# w - The canvas window displaying the floorplan. +# args - Not used. def roomChanged(w,*args) w.delete('highlight') @@ -90,24 +90,24 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg1(w,fill,outline) TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104, - 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, - 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, - 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, - 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, - 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, - 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, - 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, - 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, - 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, - 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, - 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, - 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) @@ -214,17 +214,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg2(w,fill,outline) TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129, - 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, - 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, - 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, - 367,802,367,802,129,725,129,725,133,559,133,559,129, - 'tags'=>['floor2','bg'], 'fill'=>fill) + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) @@ -269,17 +269,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor_bg3(w,fill,outline) TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96, - 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129, - 315,129,315,133,176,133,176,129,159,129,159,370,258,370, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) @@ -299,7 +299,7 @@ def floor_bg3(w,fill,outline) TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) TkcLine.new(w,107,300,159,300,159,248,107,248,107,300, - 'fill'=>outline, 'tags'=>['floor3','bg']) + 'fill'=>outline, 'tags'=>['floor3','bg']) end # floor_fg1 -- @@ -308,321 +308,321 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg1(w,color) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '101' $floorItems['101'] = i TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Pub Lift1' $floorItems['Pub Lift1'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Priv Lift1' $floorItems['Priv Lift1'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '110' $floorItems['110'] = i TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '109' $floorItems['109'] = i TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '111' $floorItems['111'] = i TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117B' $floorItems['117B'] = i TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '112' $floorItems['112'] = i TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '113' $floorItems['113'] = i TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117A' $floorItems['117A'] = i TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '117' $floorItems['117'] = i TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '114' $floorItems['114'] = i TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '115' $floorItems['115'] = i TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '116' $floorItems['116'] = i TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '118' $floorItems['118'] = i TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, - 163,91,163,112,149,112,149,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '120' $floorItems['120'] = i TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, - 156,192,156,169,175,169,175,246,79,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '122' $floorItems['122'] = i TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '121' $floorItems['121'] = i TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106A' $floorItems['106A'] = i TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '105' $floorItems['105'] = i TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106B' $floorItems['106B'] = i TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '104' $floorItems['104'] = i TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '108' $floorItems['108'] = i TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '107' $floorItems['107'] = i TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Smoking' $floorItems['Smoking'] = i TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '123' $floorItems['123'] = i TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '103' $floorItems['103'] = i TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '124' $floorItems['124'] = i TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '125' $floorItems['125'] = i TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '126' $floorItems['126'] = i TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, - 486,253,486,239,474,239,474,209, - 'fill'=>'', 'tags'=>['floor1','room']) + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '127' $floorItems['127'] = i TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, - 490,188,490,204,476,204,476,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'MShower' $floorItems['MShower'] = i TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Closet' $floorItems['Closet'] = i TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'WShower' $floorItems['WShower'] = i TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, - 697,166,697,275,553,275,531,254,515,254, - 515,174,503,174,503,161,486,161, - 'fill'=>'', 'tags'=>['floor1','room']) + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '130' $floorItems['130'] = i TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, - 342,246,397,246,397,276,393,276, - 393,309,300,309,300,248,308,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '102' $floorItems['102'] = i TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '128' $floorItems['128'] = i TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, - 552,277,561,277,561,325,510,325, - 'fill'=>'', 'tags'=>['floor1','room']) + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '129' $floorItems['129'] = i TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, - 642,389,561,389,561,277,696,277, - 'fill'=>'', 'tags'=>['floor1','room']) + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '133' $floorItems['133'] = i TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '132' $floorItems['132'] = i TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '134' $floorItems['134'] = i TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '135' $floorItems['135'] = i TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, - 304,312,396,312,396,288,400,288,404,288, - 409,290,413,292,418,297,421,302,422,309, - 421,318,417,325,411,330,405,332,397,333, - 344,333,340,334,336,336,335,338,332,342, - 331,347,332,351,334,354,336,357,341,359, - 'fill'=>'', 'tags'=>['floor1','room']) + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Ramona Stair' $floorItems['Ramona Stair'] = i TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, - 122,28,123,32,123,68,220,68,220,87,90,87,90,23, - 'fill'=>'', 'tags'=>['floor1','room']) + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'University Stair' $floorItems['University Stair'] = i TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, - 358,48,363,39,365,29,348,25,335,22,321,14, - 300,5,283,1,260,0,246,0,242,2,236,4,231,8, - 227,13,223,17,221,22,220,34,260,34, - 'fill'=>'', 'tags'=>['floor1','room']) + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Plaza Stair' $floorItems['Plaza Stair'] = i TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, - 323,56,337,70,350,83,365,94,377,100, - 386,104,386,128,220,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = 'Plaza Deck' $floorItems['Plaza Deck'] = i TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '106' $floorItems['106'] = i TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, - 95,128,114,128,114,151,157,151,157,153,112,153, - 112,130,97,130,97,168,175,168,175,131,146,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels[i.id] = '119' $floorItems['119'] = i TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) @@ -789,327 +789,327 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg2(w,color) i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, - 800,222,800,168,748,168, - 'fill'=>'', 'tags'=>['floor2','room']) + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '238' $floorItems['238'] = i TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '237' $floorItems['237'] = i TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, - 643,324,643,291,641,291,641,205,696,205, - 696,291,694,291,694,314,715,314,715,291, - 715,205,755,205,755,190,724,190,724,187, - 'fill'=>'', 'tags'=>['floor2','room']) + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '246' $floorItems['246'] = i TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '247' $floorItems['247'] = i TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, - 397,246,397,255,476,255,476,250,482,250,559,250, - 559,274,482,274,482,278,396,278,396,274,232,274, - 'fill'=>'', 'tags'=>['floor2','room']) + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '202' $floorItems['202'] = i TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, - 306,196,306,180,175,180,175,169,156,169, - 156,196,176,196,176,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '206' $floorItems['206'] = i TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '212' $floorItems['212'] = i TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '245' $floorItems['245'] = i TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '244' $floorItems['244'] = i TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '243' $floorItems['243'] = i TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '242' $floorItems['242'] = i TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Barbecue Deck' $floorItems['Barbecue Deck'] = i TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '240' $floorItems['240'] = i TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '241' $floorItems['241'] = i TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '239' $floorItems['239'] = i TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '248' $floorItems['248'] = i TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '236' $floorItems['236'] = i TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '235' $floorItems['235'] = i TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, - 572,143,579,143,579,185,626,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '234' $floorItems['234'] = i TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, - 578,185,527,185,527,131,557,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '233' $floorItems['233'] = i TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '230' $floorItems['230'] = i TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '232' $floorItems['232'] = i TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '229' $floorItems['229'] = i TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '227' $floorItems['227'] = i TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '228' $floorItems['228'] = i TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '226' $floorItems['226'] = i TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '225' $floorItems['225'] = i TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '224' $floorItems['224'] = i TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '223' $floorItems['223'] = i TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '222' $floorItems['222'] = i TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '221' $floorItems['221'] = i TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '204' $floorItems['204'] = i TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '205' $floorItems['205'] = i TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '207' $floorItems['207'] = i TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '208' $floorItems['208'] = i TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '209' $floorItems['209'] = i TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '217' $floorItems['217'] = i TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '217A' $floorItems['217A'] = i TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '216' $floorItems['216'] = i TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '215' $floorItems['215'] = i TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '214' $floorItems['214'] = i TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '213' $floorItems['213'] = i TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '210' $floorItems['210'] = i TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '211' $floorItems['211'] = i TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '203' $floorItems['203'] = i TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, - 154,198,154,192,109,192,109,169,99,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '220' $floorItems['220'] = i TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Priv Lift2' $floorItems['Priv Lift2'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = 'Pub Lift 2' $floorItems['Pub Lift 2'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '218' $floorItems['218'] = i TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '219' $floorItems['219'] = i TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels[i.id] = '201' $floorItems['201'] = i TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) @@ -1271,215 +1271,215 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor_fg3(w,color) i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316' $floorItems['316'] = i TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '309' $floorItems['309'] = i TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '308' $floorItems['308'] = i TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '307' $floorItems['307'] = i TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '305' $floorItems['305'] = i TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324B' $floorItems['324B'] = i TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324A' $floorItems['324A'] = i TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '320' $floorItems['320'] = i TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '310' $floorItems['310'] = i TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '312' $floorItems['312'] = i TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '313' $floorItems['313'] = i TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '314' $floorItems['314'] = i TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '315' $floorItems['315'] = i TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316B' $floorItems['316B'] = i TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '316A' $floorItems['316A'] = i TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, - 174,198,174,226,101,226,101,179,97,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '319' $floorItems['319'] = i TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '311' $floorItems['311'] = i TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '318' $floorItems['318'] = i TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '317' $floorItems['317'] = i TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '323' $floorItems['323'] = i TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '325' $floorItems['325'] = i TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '321' $floorItems['321'] = i TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, - 264,181,264,135,314,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '322' $floorItems['322'] = i TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = 'Pub Lift3' $floorItems['Pub Lift3'] = i TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = 'Priv Lift3' $floorItems['Priv Lift3'] = i TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '303' $floorItems['303'] = i TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, - 244,230,244,221,252,221,252,203, - 'fill'=>'', 'tags'=>['floor3','room']) + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '324' $floorItems['324'] = i TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '304' $floorItems['304'] = i TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '301' $floorItems['301'] = i TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '327' $floorItems['327'] = i TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '326' $floorItems['326'] = i TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, - 375,274,397,274,397,248,339,248,339,242,308,242, - 'fill'=>'', 'tags'=>['floor3','room']) + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '302' $floorItems['302'] = i TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, - 272,193,263,180,242,180,175,180,175,169,156,169, - 156,196,177,196,177,228,107,228,70,228,70,275,107,275, - 107,248,160,248,160,301,107,301,107,275,70,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels[i.id] = '306' $floorItems['306'] = i TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) @@ -1588,7 +1588,7 @@ $floor_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', - 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òÆ°¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){ + 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òÆ°¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){ pack('side'=>'top') } @@ -1618,12 +1618,12 @@ $floorItems = {} # canvas ÀßÄê if $tk_version =~ /^4\.[01]/ $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken', - 'highlightthickness'=>2) + 'highlightthickness'=>2) $floor_canvas = TkCanvas.new($floor_canvas_frame, - 'width'=>900, 'height'=>500, 'borderwidth'=>0, - 'highlightthickness'=>0) {|c| + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| TkScrollbar.new($floor_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}){|hs| + 'command'=>proc{|*args| c.xview(*args)}){|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) pack('side'=>'bottom', 'fill'=>'x') } @@ -1644,20 +1644,20 @@ else TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, - 'borderwidth'=>0, - 'highlightthickness'=>0) { - xscrollcommand(proc{|first,last| h.set first,last}) - yscrollcommand(proc{|first,last| v.set first,last}) - pack('expand'=>'yes', 'fill'=>'both') + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') } grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') } v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) @@ -1674,7 +1674,7 @@ end $currentRoom = TkVariable.new $floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken', - 'bd'=>2, 'textvariable'=>$currentRoom) + 'bd'=>2, 'textvariable'=>$currentRoom) # Choose colors, then fill in the floorplan. @@ -1711,7 +1711,7 @@ $floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas}) $floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''}) $floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y') $floor_canvas.bind('B2-Motion', - proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y') + proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y') $floor_canvas.bind('Destroy', proc{$currentRoom.unset}) $currentRoom.value = '' $currentRoom.trace('w',proc{roomChanged $floor_canvas}) diff --git a/ext/tk/sample/demos-jp/floor2.rb b/ext/tk/sample/demos-jp/floor2.rb index e5a8f53f2..fcf208b61 100644 --- a/ext/tk/sample/demos-jp/floor2.rb +++ b/ext/tk/sample/demos-jp/floor2.rb @@ -8,8 +8,8 @@ # visible. # # Arguments: -# w - Name of the canvas window. -# active - Number of active floor (1, 2, or 3). +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). def floorDisplay2(w,active) return if $activeFloor2 == active @@ -59,7 +59,7 @@ end # highlighted. # # Arguments: -# w - The name of the canvas window. +# w - The name of the canvas window. def newRoom2(w) id = w.find_withtag('current')[0] @@ -72,8 +72,8 @@ end # It highlights the current room and unhighlights any previous room. # # Arguments: -# w - The canvas window displaying the floorplan. -# args - Not used. +# w - The canvas window displaying the floorplan. +# args - Not used. def roomChanged2(w,*args) w.delete('highlight') @@ -90,24 +90,24 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg1(w,fill,outline) w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104, - 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, - 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, - 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, - 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, - 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, - 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, - 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, - 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, - 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, - 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, - 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, - 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) @@ -214,17 +214,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg2(w,fill,outline) w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129, - 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, - 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, - 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, - 367,802,367,802,129,725,129,725,133,559,133,559,129, - 'tags'=>['floor2','bg'], 'fill'=>fill) + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) @@ -269,17 +269,17 @@ end # floor. # # Arguments: -# w - The canvas window. -# fill - Fill color to use for the floor's background. -# outline - Color to use for the floor's outline. +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. def floor2_bg3(w,fill,outline) w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96, - 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129, - 315,129,315,133,176,133,176,129,159,129,159,370,258,370, - 'tags'=>['floor3','bg'], 'fill'=>fill) + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) @@ -299,7 +299,7 @@ def floor2_bg3(w,fill,outline) w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) w.create(TkcLine,107,300,159,300,159,248,107,248,107,300, - 'fill'=>outline, 'tags'=>['floor3','bg']) + 'fill'=>outline, 'tags'=>['floor3','bg']) end # floor2_fg1 -- @@ -308,321 +308,321 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg1(w,color) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '101' $floorItems2['101'] = i w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Pub Lift1' $floorItems2['Pub Lift1'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Priv Lift1' $floorItems2['Priv Lift1'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '110' $floorItems2['110'] = i w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '109' $floorItems2['109'] = i w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '111' $floorItems2['111'] = i w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117B' $floorItems2['117B'] = i w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '112' $floorItems2['112'] = i w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '113' $floorItems2['113'] = i w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117A' $floorItems2['117A'] = i w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '117' $floorItems2['117'] = i w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '114' $floorItems2['114'] = i w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '115' $floorItems2['115'] = i w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '116' $floorItems2['116'] = i w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '118' $floorItems2['118'] = i w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, - 163,91,163,112,149,112,149,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '120' $floorItems2['120'] = i w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, - 156,192,156,169,175,169,175,246,79,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '122' $floorItems2['122'] = i w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '121' $floorItems2['121'] = i w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106A' $floorItems2['106A'] = i w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '105' $floorItems2['105'] = i w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106B' $floorItems2['106B'] = i w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '104' $floorItems2['104'] = i w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '108' $floorItems2['108'] = i w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '107' $floorItems2['107'] = i w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Smoking' $floorItems2['Smoking'] = i w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '123' $floorItems2['123'] = i w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '103' $floorItems2['103'] = i w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '124' $floorItems2['124'] = i w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '125' $floorItems2['125'] = i w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '126' $floorItems2['126'] = i w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, - 486,253,486,239,474,239,474,209, - 'fill'=>'', 'tags'=>['floor1','room']) + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '127' $floorItems2['127'] = i w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, - 490,188,490,204,476,204,476,164, - 'fill'=>'', 'tags'=>['floor1','room']) + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'MShower' $floorItems2['MShower'] = i w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Closet' $floorItems2['Closet'] = i w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'WShower' $floorItems2['WShower'] = i w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, - 697,166,697,275,553,275,531,254,515,254, - 515,174,503,174,503,161,486,161, - 'fill'=>'', 'tags'=>['floor1','room']) + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '130' $floorItems2['130'] = i w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, - 342,246,397,246,397,276,393,276, - 393,309,300,309,300,248,308,248, - 'fill'=>'', 'tags'=>['floor1','room']) + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '102' $floorItems2['102'] = i w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '128' $floorItems2['128'] = i w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, - 552,277,561,277,561,325,510,325, - 'fill'=>'', 'tags'=>['floor1','room']) + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '129' $floorItems2['129'] = i w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, - 642,389,561,389,561,277,696,277, - 'fill'=>'', 'tags'=>['floor1','room']) + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '133' $floorItems2['133'] = i w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '132' $floorItems2['132'] = i w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '134' $floorItems2['134'] = i w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '135' $floorItems2['135'] = i w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, - 304,312,396,312,396,288,400,288,404,288, - 409,290,413,292,418,297,421,302,422,309, - 421,318,417,325,411,330,405,332,397,333, - 344,333,340,334,336,336,335,338,332,342, - 331,347,332,351,334,354,336,357,341,359, - 'fill'=>'', 'tags'=>['floor1','room']) + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Ramona Stair' $floorItems2['Ramona Stair'] = i w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, - 122,28,123,32,123,68,220,68,220,87,90,87,90,23, - 'fill'=>'', 'tags'=>['floor1','room']) + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'University Stair' $floorItems2['University Stair'] = i w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, - 358,48,363,39,365,29,348,25,335,22,321,14, - 300,5,283,1,260,0,246,0,242,2,236,4,231,8, - 227,13,223,17,221,22,220,34,260,34, - 'fill'=>'', 'tags'=>['floor1','room']) + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Plaza Stair' $floorItems2['Plaza Stair'] = i w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, - 323,56,337,70,350,83,365,94,377,100, - 386,104,386,128,220,128, - 'fill'=>'', 'tags'=>['floor1','room']) + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = 'Plaza Deck' $floorItems2['Plaza Deck'] = i w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, - 'fill'=>'', 'tags'=>['floor1','room']) + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '106' $floorItems2['106'] = i w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, - 95,128,114,128,114,151,157,151,157,153,112,153, - 112,130,97,130,97,168,175,168,175,131,146,131, - 'fill'=>'', 'tags'=>['floor1','room']) + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) $floorLabels2[i.id] = '119' $floorItems2['119'] = i w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor1','label']) + 'anchor'=>'c', 'tags'=>['floor1','label']) w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) @@ -789,327 +789,327 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg2(w,color) i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, - 800,222,800,168,748,168, - 'fill'=>'', 'tags'=>['floor2','room']) + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '238' $floorItems2['238'] = i w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '237' $floorItems2['237'] = i w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, - 643,324,643,291,641,291,641,205,696,205, - 696,291,694,291,694,314,715,314,715,291, - 715,205,755,205,755,190,724,190,724,187, - 'fill'=>'', 'tags'=>['floor2','room']) + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '246' $floorItems2['246'] = i w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '247' $floorItems2['247'] = i w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, - 397,246,397,255,476,255,476,250,482,250,559,250, - 559,274,482,274,482,278,396,278,396,274,232,274, - 'fill'=>'', 'tags'=>['floor2','room']) + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '202' $floorItems2['202'] = i w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, - 306,196,306,180,175,180,175,169,156,169, - 156,196,176,196,176,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '206' $floorItems2['206'] = i w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '212' $floorItems2['212'] = i w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '245' $floorItems2['245'] = i w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '244' $floorItems2['244'] = i w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '243' $floorItems2['243'] = i w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '242' $floorItems2['242'] = i w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Barbecue Deck' $floorItems2['Barbecue Deck'] = i w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '240' $floorItems2['240'] = i w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '241' $floorItems2['241'] = i w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '239' $floorItems2['239'] = i w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '248' $floorItems2['248'] = i w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '236' $floorItems2['236'] = i w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '235' $floorItems2['235'] = i w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, - 572,143,579,143,579,185,626,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '234' $floorItems2['234'] = i w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, - 578,185,527,185,527,131,557,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '233' $floorItems2['233'] = i w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '230' $floorItems2['230'] = i w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '232' $floorItems2['232'] = i w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '229' $floorItems2['229'] = i w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '227' $floorItems2['227'] = i w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '228' $floorItems2['228'] = i w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '226' $floorItems2['226'] = i w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '225' $floorItems2['225'] = i w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '224' $floorItems2['224'] = i w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '223' $floorItems2['223'] = i w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '222' $floorItems2['222'] = i w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '221' $floorItems2['221'] = i w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '204' $floorItems2['204'] = i w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '205' $floorItems2['205'] = i w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '207' $floorItems2['207'] = i w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '208' $floorItems2['208'] = i w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '209' $floorItems2['209'] = i w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '217' $floorItems2['217'] = i w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '217A' $floorItems2['217A'] = i w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '216' $floorItems2['216'] = i w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '215' $floorItems2['215'] = i w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '214' $floorItems2['214'] = i w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '213' $floorItems2['213'] = i w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '210' $floorItems2['210'] = i w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '211' $floorItems2['211'] = i w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '203' $floorItems2['203'] = i w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, - 154,198,154,192,109,192,109,169,99,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '220' $floorItems2['220'] = i w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Priv Lift2' $floorItems2['Priv Lift2'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = 'Pub Lift 2' $floorItems2['Pub Lift 2'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '218' $floorItems2['218'] = i w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '219' $floorItems2['219'] = i w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor2','room']) + 'fill'=>'', 'tags'=>['floor2','room']) $floorLabels2[i.id] = '201' $floorItems2['201'] = i w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor2','label']) + 'anchor'=>'c', 'tags'=>['floor2','label']) w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) @@ -1271,215 +1271,215 @@ end # floor (office outlines and numbers). # # Arguments: -# w - The canvas window. -# color - Color to use for drawing foreground information. +# w - The canvas window. +# color - Color to use for drawing foreground information. def floor2_fg3(w,color) i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316' $floorItems2['316'] = i w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '309' $floorItems2['309'] = i w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '308' $floorItems2['308'] = i w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '307' $floorItems2['307'] = i w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '305' $floorItems2['305'] = i w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324B' $floorItems2['324B'] = i w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324A' $floorItems2['324A'] = i w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '320' $floorItems2['320'] = i w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '310' $floorItems2['310'] = i w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '312' $floorItems2['312'] = i w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '313' $floorItems2['313'] = i w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '314' $floorItems2['314'] = i w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '315' $floorItems2['315'] = i w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316B' $floorItems2['316B'] = i w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '316A' $floorItems2['316A'] = i w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, - 174,198,174,226,101,226,101,179,97,179, - 'fill'=>'', 'tags'=>['floor3','room']) + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '319' $floorItems2['319'] = i w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '311' $floorItems2['311'] = i w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '318' $floorItems2['318'] = i w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '317' $floorItems2['317'] = i w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '323' $floorItems2['323'] = i w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '325' $floorItems2['325'] = i w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '321' $floorItems2['321'] = i w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, - 264,181,264,135,314,135, - 'fill'=>'', 'tags'=>['floor3','room']) + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '322' $floorItems2['322'] = i w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = 'Pub Lift3' $floorItems2['Pub Lift3'] = i w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = 'Priv Lift3' $floorItems2['Priv Lift3'] = i w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '303' $floorItems2['303'] = i w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, - 244,230,244,221,252,221,252,203, - 'fill'=>'', 'tags'=>['floor3','room']) + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '324' $floorItems2['324'] = i w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '304' $floorItems2['304'] = i w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '301' $floorItems2['301'] = i w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '327' $floorItems2['327'] = i w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, - 'fill'=>'', 'tags'=>['floor3','room']) + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '326' $floorItems2['326'] = i w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, - 375,274,397,274,397,248,339,248,339,242,308,242, - 'fill'=>'', 'tags'=>['floor3','room']) + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '302' $floorItems2['302'] = i w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, - 272,193,263,180,242,180,175,180,175,169,156,169, - 156,196,177,196,177,228,107,228,70,228,70,275,107,275, - 107,248,160,248,160,301,107,301,107,275,70,275, - 'fill'=>'', 'tags'=>['floor3','room']) + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) $floorLabels2[i.id] = '306' $floorItems2['306'] = i w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color, - 'anchor'=>'c', 'tags'=>['floor3','label']) + 'anchor'=>'c', 'tags'=>['floor3','label']) w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) @@ -1588,7 +1588,7 @@ $floor2_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', - 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òÆ°¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){ + 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òÆ°¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){ pack('side'=>'top') } @@ -1618,12 +1618,12 @@ $floorItems2 = {} # canvas ÀßÄê if $tk_version =~ /^4\.[01]/ $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken', - 'highlightthickness'=>2) + 'highlightthickness'=>2) $floor2_canvas = TkCanvas.new($floor2_canvas_frame, - 'width'=>900, 'height'=>500, 'borderwidth'=>0, - 'highlightthickness'=>0) {|c| + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| TkScrollbar.new($floor2_demo, 'orient'=>'horiz', - 'command'=>proc{|*args| c.xview(*args)}){|hs| + 'command'=>proc{|*args| c.xview(*args)}){|hs| c.xscrollcommand(proc{|first,last| hs.set first,last}) pack('side'=>'bottom', 'fill'=>'x') } @@ -1644,20 +1644,20 @@ else TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, - 'borderwidth'=>0, - 'highlightthickness'=>0) { - xscrollcommand(proc{|first,last| h.set first,last}) - yscrollcommand(proc{|first,last| v.set first,last}) - pack('expand'=>'yes', 'fill'=>'both') + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') } grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') } v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) @@ -1673,7 +1673,7 @@ end $currentRoom2 = TkVariable.new $floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken', - 'bd'=>2, 'textvariable'=>$currentRoom2) + 'bd'=>2, 'textvariable'=>$currentRoom2) # Choose colors, then fill in the floorplan. @@ -1710,7 +1710,7 @@ $floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas}) $floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''}) $floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y') $floor2_canvas.bind('B2-Motion', - proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y') + proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y') $floor2_canvas.bind('Destroy', proc{$currentRoom2.unset}) $currentRoom2.value = '' $currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas}) diff --git a/ext/tk/sample/demos-jp/icon.rb b/ext/tk/sample/demos-jp/icon.rb index 3180787da..e4fef5cae 100644 --- a/ext/tk/sample/demos-jp/icon.rb +++ b/ext/tk/sample/demos-jp/icon.rb @@ -47,14 +47,14 @@ TkFrame.new($icon_demo) {|frame| flagup = \ TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagup.xbm'].join(File::Separator), - 'maskfile'=>\ - [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) + 'maskfile'=>\ + [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) flagdown = \ TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagdown.xbm'].join(File::Separator), - 'maskfile'=>\ - [$demo_dir,'..', - 'images','flagdown.xbm'].join(File::Separator)) + 'maskfile'=>\ + [$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator)) # ÊÑ¿ôÀ¸À® letters = TkVariable.new @@ -64,14 +64,14 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w| TkFrame.new(w) {|f| TkRadioButton.new(f){ bitmap '@' + [$demo_dir,'..', - 'images','letters.xbm'].join(File::Separator) + 'images','letters.xbm'].join(File::Separator) variable letters value 'full' }.pack('side'=>'top', 'expand'=>'yes') TkRadioButton.new(f){ bitmap '@' + [$demo_dir,'..', - 'images','noletter.xbm'].join(File::Separator) + 'images','noletter.xbm'].join(File::Separator) variable letters value 'empty' }.pack('side'=>'top', 'expand'=>'yes') diff --git a/ext/tk/sample/demos-jp/image3.rb b/ext/tk/sample/demos-jp/image3.rb index d42650f45..549152514 100644 --- a/ext/tk/sample/demos-jp/image3.rb +++ b/ext/tk/sample/demos-jp/image3.rb @@ -33,7 +33,7 @@ end # listbox from the directory named in the demo's entry. # # Arguments: -# w - Name of the toplevel window of the demo. +# w - Name of the toplevel window of the demo. def selectAndLoadDir3(w, lbox) dir = Tk.chooseDirectory(:initialdir=>$dirName, :parent=>w, :mustexist=>true) if dir.length > 0 @@ -91,11 +91,11 @@ image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true) image3_df = TkLabelFrame.new($image3_demo, :text=>'¥Ç¥£¥ì¥¯¥È¥ê:') image3_ff = TkLabelFrame.new($image3_demo, :text=>'¥Õ¥¡¥¤¥ë:', - :padx=>'2m', :pady=>'2m') + :padx=>'2m', :pady=>'2m') image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) { pack(:side=>:left, :fill=>:y, :expand=>true) yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y, - :expand=>true)) + :expand=>true)) insert(0, *(%w(earth.gif earthris.gif teapot.ppm))) bind('Double-1', proc{|x,y| loadImage3(self, x, y)}, '%x %y') } @@ -106,7 +106,7 @@ image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){ } TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"¥Ç¥£¥ì¥¯¥È¥êÁªÂò", - :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) { + :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) { pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m') } @@ -115,8 +115,8 @@ image3_if = TkLabelFrame.new($image3_demo, :text=>'¥¤¥á¡¼¥¸:') {|f| } Tk.grid(image3_df, '-', - :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f) + :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f) Tk.grid(image3_ff, image3_if, - :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f) + :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f) TkGrid.columnconfigure(image3_f, 1, :weight=>1) diff --git a/ext/tk/sample/demos-jp/items.rb b/ext/tk/sample/demos-jp/items.rb index 0dc604bb6..38774d10d 100644 --- a/ext/tk/sample/demos-jp/items.rb +++ b/ext/tk/sample/demos-jp/items.rb @@ -71,11 +71,11 @@ TkFrame.new($items_demo) {|cf| else c.grid('in'=>cf, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') vs.grid('row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') hs.grid('row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) @@ -111,126 +111,126 @@ $tag_item = TkcGroup.new(cvs) # Set up demos within each of the areas of the grid. TkcText.new(cvs, '5c', '.2c', 'text'=>'¥é¥¤¥ó', 'anchor'=>'n') TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c', - 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt', - 'join'=>'miter', 'tags'=>$tag_item ) + 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt', + 'join'=>'miter', 'tags'=>$tag_item ) TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item) TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item) TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c', - '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c', - '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', - 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) + '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c', + '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', + 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c', - 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', - 'tags'=>$tag_item ) + 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', + 'tags'=>$tag_item ) TkcText.new(cvs, '15c', '.2c', - 'text'=>'¶ÊÀþ (³ê¤é¤«¤Ë¤Ä¤Ê¤¤¤ÀľÀþ)', 'anchor'=>'n') + 'text'=>'¶ÊÀþ (³ê¤é¤«¤Ë¤Ä¤Ê¤¤¤ÀľÀþ)', 'anchor'=>'n') TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c', - 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item ) + 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item ) TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c', - 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item ) + 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item ) TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c', - '16.5c','4.5c','13.5c','7.5c','12c','6c', - 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', - 'stipple'=>'@'+[$demo_dir, '..', - 'images', 'gray25.xbm'].join(File::Separator), - 'fill'=>red, 'tags'=>$tag_item ) + '16.5c','4.5c','13.5c','7.5c','12c','6c', + 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), + 'fill'=>red, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '.2c', 'text'=>'¿³Ñ·Á', 'anchor'=>'n') TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c', - '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c', - 'fill'=>'green', 'outline'=>'black', 'width'=>4, - 'tags'=>$tag_item ) + '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c', + 'fill'=>'green', 'outline'=>'black', 'width'=>4, + 'tags'=>$tag_item ) TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c', - '28c','1c','29c','1c','29c','4c','29c','4c', - 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item) + '28c','1c','29c','1c','29c','4c','29c','4c', + 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item) TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c', - '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', - '7.5c','22c','7.5c', - 'stipple'=>'@' + [$demo_dir, '..', + '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', + '7.5c','22c','7.5c', + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'gray25.xbm'].join(File::Separator), - 'outline'=>'black', 'tags'=>$tag_item ) + 'outline'=>'black', 'tags'=>$tag_item ) TkcText.new(cvs, '5c', '8.2c', 'text'=>'¶ë·Á', 'anchor'=>'n') TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c', - 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c', - 'fill'=>green, 'tags'=>$tag_item ) + 'fill'=>green, 'tags'=>$tag_item ) TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'fill'=>blue, 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '15c', '8.2c', 'text'=>'Âʱß', 'anchor'=>'n') TkcOval.new(cvs, '11c','9.5c','14c','12.5c', - 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c', - 'fill'=>green, 'tags'=>$tag_item ) + 'fill'=>green, 'tags'=>$tag_item ) TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir,'..', - 'images','gray25.xbm'].join(File::Separator), - 'fill'=>blue, 'tags'=>$tag_item ) + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '8.2c', 'text'=>'¥Æ¥¥¹¥È', 'anchor'=>'n') TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c') TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c', - 'text'=>'û¤¤¥Æ¥¥¹¥È¡£¥ï¡¼¥É¥é¥Ã¥×¡¢º¸Â·¤¨¡¢¥¢¥ó¥«¡¼¤ÏËÌ(¾å)¡£¢¢¤Ï³Æ¥Æ¥¥¹¥È¤Î¥¢¥ó¥«¡¼¥Ý¥¤¥ó¥È¤ò¼¨¤¹¡£', 'tags'=>$tag_item ) + 'text'=>'û¤¤¥Æ¥¥¹¥È¡£¥ï¡¼¥É¥é¥Ã¥×¡¢º¸Â·¤¨¡¢¥¢¥ó¥«¡¼¤ÏËÌ(¾å)¡£¢¢¤Ï³Æ¥Æ¥¥¹¥È¤Î¥¢¥ó¥«¡¼¥Ý¥¤¥ó¥È¤ò¼¨¤¹¡£', 'tags'=>$tag_item ) TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c') TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue, - 'text'=>"¤¤¤¯¤Ä¤«¤Î¹Ô¡£\n¤½¤ì¤¾¤ìÆÈΩ¤Ë\n¹Ô·¤¨¡£\nÁ´¤Æº¸Ã¼¤¬¥¢¥ó¥«¡¼¤µ¤ì¤Æ¤¤¤ë¡£", 'justify'=>'center', 'tags'=>$tag_item ) + 'text'=>"¤¤¤¯¤Ä¤«¤Î¹Ô¡£\n¤½¤ì¤¾¤ìÆÈΩ¤Ë\n¹Ô·¤¨¡£\nÁ´¤Æº¸Ã¼¤¬¥¢¥ó¥«¡¼¤µ¤ì¤Æ¤¤¤ë¡£", 'justify'=>'center', 'tags'=>$tag_item ) TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c') if $tk_version =~ /^4\.[01]/ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'@' + [$demo_dir, '..', + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'grey.5'].join(File::Separator), - 'text'=>'Stippled characters', 'tags'=>$tag_item ) + 'text'=>'Stippled characters', 'tags'=>$tag_item ) else TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'gray50', 'text'=>'Stippled characters', - 'tags'=>$tag_item ) + 'stipple'=>'gray50', 'text'=>'Stippled characters', + 'tags'=>$tag_item ) end TkcText.new(cvs, '5c', '16.2c', 'text'=>'¸Ì', 'anchor'=>'n') TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black', - 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item) + 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item) #TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', -# 'outline'=>blue, 'start'=>135, 'extent'=>270, -# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator), -# 'tags'=>$tag_item) +# 'outline'=>blue, 'start'=>135, 'extent'=>270, +# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator), +# 'tags'=>$tag_item) TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', - 'outline'=>blue, 'start'=>135, 'extent'=>270, - 'outlinestipple'=>'@'+[$demo_dir, '..', + 'outline'=>blue, 'start'=>135, 'extent'=>270, + 'outlinestipple'=>'@'+[$demo_dir, '..', 'images','gray25.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'tags'=>$tag_item) TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice', - 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, - 'tags'=>$tag_item) + 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, + 'tags'=>$tag_item) TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord', - 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270, - 'tags'=>$tag_item) + 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270, + 'tags'=>$tag_item) TkcText.new(cvs, '15c', '16.2c', 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×', 'anchor'=>'n') #TkcBitmap.new(cvs, '13c','20c', -# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), +# 'tags'=>$tag_item) TkcBitmap.new(cvs, '13c','20c', - 'bitmap'=>'@' + [$demo_dir, '..', + 'bitmap'=>'@' + [$demo_dir, '..', 'images', 'face.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','18.5c', -# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), +# 'tags'=>$tag_item) TkcBitmap.new(cvs, '17c','18.5c', - 'bitmap'=>'@' + [$demo_dir, '..', - 'images', 'noletter.xbm'].join(File::Separator), - 'tags'=>$tag_item) + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'noletter.xbm'].join(File::Separator), + 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','21.5c', -# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), -# 'tags'=>$tag_item) +# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), +# 'tags'=>$tag_item) # ¢¤Î·Á¼°¤Ç¤â²Äǽ TkcBitmap.new(cvs, '17c','21.5c') { bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator) @@ -246,17 +246,17 @@ TkButton.new(cvs) {|b| text '²¡¤·¤Æ¤Í' command proc{butPress cvs, red} TkcWindow.new(cvs, '21c','18c', - 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item) + 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item) } TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e| insert 'end', 'ÊÔ½¸¤·¤Æ¤Í' TkcWindow.new(cvs, '21c','21c', - 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item) + 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item) } TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c', - 'width'=>'.5c', 'tickinterval'=>0 ) {|scl| + 'width'=>'.5c', 'tickinterval'=>0 ) {|scl| TkcWindow.new(cvs, '28.5c','17.5c', - 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item) + 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item) } TkcText.new(cvs, '21c', '17.9c', 'text'=>'¥Ü¥¿¥ó:', 'anchor'=>'sw') TkcText.new(cvs, '21c', '20.9c', 'text'=>'¥¨¥ó¥È¥ê:', 'anchor'=>'sw') @@ -321,7 +321,7 @@ def itemStroke(c,x,y) if $areaX1 != x && $areaY1 != y c.delete 'area' c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y, - '-outline', 'black') + '-outline', 'black') $areaX2 = x $areaY2 = y end @@ -366,6 +366,6 @@ end def butPress(w,color) i = TkcText.new(w, '25c', '18.1c', - 'text'=>'¤¤¤Æ¤Æ!!', 'fill'=>color, 'anchor'=>'n') + 'text'=>'¤¤¤Æ¤Æ!!', 'fill'=>color, 'anchor'=>'n') Tk.after(500, proc{w.delete i}) end diff --git a/ext/tk/sample/demos-jp/label.rb b/ext/tk/sample/demos-jp/label.rb index 425654216..59626289f 100644 --- a/ext/tk/sample/demos-jp/label.rb +++ b/ext/tk/sample/demos-jp/label.rb @@ -47,12 +47,12 @@ TkFrame.new($label_demo) {|frame| f_left = TkFrame.new($label_demo) f_right = TkFrame.new($label_demo) [f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes', - 'padx'=>10, 'pady'=>10, 'fill'=>'both')} + 'padx'=>10, 'pady'=>10, 'fill'=>'both')} # label À¸À® [ TkLabel.new(f_left, 'text'=>'ºÇ½é¤Î¥é¥Ù¥ë'), TkLabel.new(f_left, 'text'=>'2 ÈÖÌÜ¡£¤Á¤ç¤Ã¤ÈÉ⤾夬¤é¤»¤Æ¤ß¤Þ¤·¤¿', - 'relief'=>'raised'), + 'relief'=>'raised'), TkLabel.new(f_left, 'text'=>'3 ÈÖÌÜ¡£ÄÀ¤ó¤Ç¤¤¤Þ¤¹ ', 'relief'=>'sunken') ].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')} diff --git a/ext/tk/sample/demos-jp/labelframe.rb b/ext/tk/sample/demos-jp/labelframe.rb index 8f76ffacf..23c974dcc 100644 --- a/ext/tk/sample/demos-jp/labelframe.rb +++ b/ext/tk/sample/demos-jp/labelframe.rb @@ -19,8 +19,8 @@ $labelframe_demo = TkToplevel.new {|w| # Some information TkLabel.new($labelframe_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) TkLabelFrame ¥¦¥£¥¸¥§¥Ã¥È¤Ï´ØÏ¢¤¹¤ë widget ·²¤ò¤Þ¤È¤á¤Æ¼è¤ê°·¤¦¤¿¤á¤ËÍѤ¤¤é¤ì¤Þ¤¹¡£¥é ¥Ù¥ë¤ÏÄ̾ï¤Îʸ»úÎó¤Ç¤â²¿¤é¤«¤Î¥¦¥£¥¸¥§¥Ã¥È @@ -38,28 +38,28 @@ TkFrame.new($labelframe_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $labelframe_demo.destroy - $labelframe_demo = nil - }).pack(:side=>:left, :expand=>true) + $labelframe_demo.destroy + $labelframe_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'labelframe' - }).pack(:side=>:left, :expand=>true) + showCode 'labelframe' + }).pack(:side=>:left, :expand=>true) } # Demo area w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both, - :expand=>true) + :expand=>true) # A group of radiobuttons in a labelframe TkLabelFrame.new(w, :text=>'ÁªÂòÃÍ', - :padx=>2, :pady=>2) {|f| + :padx=>2, :pady=>2) {|f| grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m') v = TkVariable.new (1..4).each{|i| TkRadiobutton.new(f, :text=>"This is value #{i}", - :variable=>v, :value=>i) { + :variable=>v, :value=>i) { pack(:side=>:top, :fill=>:x, :pady=>2) } } @@ -82,7 +82,7 @@ end TkLabelFrame.new(w, :pady=>2, :padx=>2){|f| TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy, - :text=>"¥ª¥×¥·¥ç¥ó¤ò»ÈÍÑ", :padx=>0) {|cb| + :text=>"¥ª¥×¥·¥ç¥ó¤ò»ÈÍÑ", :padx=>0) {|cb| command proc{lfEnableButtons(f)} f.labelwidget(cb) } diff --git a/ext/tk/sample/demos-jp/menu.rb b/ext/tk/sample/demos-jp/menu.rb index 79d5b3d4c..50152cead 100644 --- a/ext/tk/sample/demos-jp/menu.rb +++ b/ext/tk/sample/demos-jp/menu.rb @@ -79,8 +79,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m| ['A','B','C','D','E','F','G'].each{|c| # add('command', 'label'=>"ʸ»ú \"#{c}\" ¤ò°õ»ú", 'underline'=>4, add('command', 'label'=>"Print letter \"#{c}\" (ʸ»ú \"#{c}\" ¤ò°õ»ú)", - 'underline'=>14, 'accelerator'=>"Meta+#{c}", - 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) } } @@ -91,17 +91,17 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|cascade_menu| m.configure('menu'=>cascade_menu) add('command', 'label'=>'Print hello(¤³¤ó¤Ë¤Á¤Ï)', - 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}, - 'accelerator'=>"#{modifier}+H", 'underline'=>6) + 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) $menu_demo.bind("#{modifier}-h", proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}) add('command', 'label'=>'Print goodbye(¤µ¤è¤¦¤Ê¤é)', - 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}, - 'accelerator'=>"#{modifier}+G", 'underline'=>6) + 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) $menu_demo.bind("#{modifier}-g", proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}) TkMenu.new(m, 'tearoff'=>false) {|cascade_check| cascade_menu.add('cascade', 'label'=>'Check buttons(¥Á¥§¥Ã¥¯¥Ü¥¿¥ó)', - 'menu'=>cascade_check, 'underline'=>0) + 'menu'=>cascade_check, 'underline'=>0) oil = TkVariable.new(0) add('check', 'label'=>'¥ª¥¤¥ëÅÀ¸¡', 'variable'=>oil) trans = TkVariable.new(0) @@ -112,18 +112,18 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| add('check', 'label'=>'¥é¥¤¥ÈÅÀ¸¡', 'variable'=>lights) add('separator') add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨', - 'command'=>proc{showVars($menu_demo, - ['¥ª¥¤¥ëÅÀ¸¡', oil], - ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans], - ['¥Ö¥ì¡¼¥ÅÀ¸¡', brakes], - ['¥é¥¤¥ÈÅÀ¸¡', lights])} ) + 'command'=>proc{showVars($menu_demo, + ['¥ª¥¤¥ëÅÀ¸¡', oil], + ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans], + ['¥Ö¥ì¡¼¥ÅÀ¸¡', brakes], + ['¥é¥¤¥ÈÅÀ¸¡', lights])} ) invoke 1 invoke 3 } TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| cascade_menu.add('cascade', 'label'=>'Radio buttons(¥é¥¸¥ª¥Ü¥¿¥ó)', - 'menu'=>cascade_radio, 'underline'=>0) + 'menu'=>cascade_radio, 'underline'=>0) pointSize = TkVariable.new add('radio', 'label'=>'10 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>10) add('radio', 'label'=>'14 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>14) @@ -137,9 +137,9 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| add('radio', 'label'=>'¥¤¥¿¥ê¥Ã¥¯', 'variable'=>style, 'value'=>'italic') add('separator') add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨', - 'command'=>proc{showVars($menu_demo, - ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize], - ['¥¹¥¿¥¤¥ë', style])} ) + 'command'=>proc{showVars($menu_demo, + ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize], + ['¥¹¥¿¥¤¥ë', style])} ) invoke 1 invoke 7 } @@ -151,15 +151,15 @@ TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|icon_menu| m.configure('menu'=>icon_menu) add('command', - 'bitmap'=>'@'+[$demo_dir,'..', - 'images','pattern.xbm'].join(File::Separator), - 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', - 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£', - 'bitmap'=>'', 'default'=>0, - 'buttons'=>'λ²ò')} ) + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'λ²ò')} ) ['info', 'questhead', 'error'].each{|icon| add('command', 'bitmap'=>icon, - 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) } } } @@ -171,7 +171,7 @@ TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m| [ '¥¨¥ó¥È¥ê','Ê̤Υ¨¥ó¥È¥ê','²¿¤â¤·¤Ê¤¤','¤Û¤È¤ó¤É²¿¤â¤·¤Ê¤¤', '¿ÍÀ¸¤ò°ÕµÁ¤¢¤ë¤â¤Î¤Ë' ].each{|i| add('command', 'label'=>i, - 'command'=>proc{print "You invoked \"#{i}\"\n"}) + 'command'=>proc{print "You invoked \"#{i}\"\n"}) } } } @@ -182,7 +182,7 @@ TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m| m.configure('menu'=>colors_menu) ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| add('command', 'label'=>c, 'background'=>c, - 'command'=>proc{print "You invoked \"#{c}\"\n"}) + 'command'=>proc{print "You invoked \"#{c}\"\n"}) } } } diff --git a/ext/tk/sample/demos-jp/menu84.rb b/ext/tk/sample/demos-jp/menu84.rb index 78d4e6887..8c2a815d7 100644 --- a/ext/tk/sample/demos-jp/menu84.rb +++ b/ext/tk/sample/demos-jp/menu84.rb @@ -35,9 +35,9 @@ TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { menustatus = TkVariable.new(" ") TkFrame.new($menu84_demo) {|frame| TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken', - 'bd'=>1, 'font'=>['Helvetica', '10'], - 'anchor'=>'w').pack('side'=>'left', 'padx'=>2, - 'expand'=>true, 'fill'=>'both') + 'bd'=>1, 'font'=>['Helvetica', '10'], + 'anchor'=>'w').pack('side'=>'left', 'padx'=>2, + 'expand'=>true, 'fill'=>'both') pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) } @@ -92,8 +92,8 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('command', 'label'=>'Long entry that does nothing') ['A','B','C','D','E','F','G'].each{|c| add('command', 'label'=>"Print letter \"#{c}\"", - 'underline'=>14, 'accelerator'=>"Meta+#{c}", - 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) } } @@ -111,7 +111,7 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| TkMenu.new(m, 'tearoff'=>false) {|cascade_check| m.add('cascade', 'label'=>'Check button', - 'menu'=>cascade_check, 'underline'=>0) + 'menu'=>cascade_check, 'underline'=>0) oil = TkVariable.new(0) add('check', 'label'=>'¥ª¥¤¥ë¸¡ºº', 'variable'=>oil) trans = TkVariable.new(0) @@ -122,18 +122,18 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('check', 'label'=>'¥é¥¤¥È¸¡ºº', 'variable'=>lights) add('separator') add('command', 'label'=>'Show current values', - 'command'=>proc{showVars($menu84_demo, - ['¥ª¥¤¥ë', oil], - ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥ó', trans], - ['¥Ö¥ì¡¼¥', brakes], - ['¥é¥¤¥È', lights])} ) + 'command'=>proc{showVars($menu84_demo, + ['¥ª¥¤¥ë', oil], + ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥ó', trans], + ['¥Ö¥ì¡¼¥', brakes], + ['¥é¥¤¥È', lights])} ) invoke 1 invoke 3 } TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| m.add('cascade', 'label'=>'Radio buttons', - 'menu'=>cascade_radio, 'underline'=>0) + 'menu'=>cascade_radio, 'underline'=>0) pointSize = TkVariable.new add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10) add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14) @@ -147,9 +147,9 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic') add('separator') add('command', 'label'=>'¸½ºßÃͤÎɽ¼¨', - 'command'=>proc{showVars($menu84_demo, - ['pointSize', pointSize], - ['style', style])} ) + 'command'=>proc{showVars($menu84_demo, + ['pointSize', pointSize], + ['style', style])} ) invoke 1 invoke 7 } @@ -159,14 +159,14 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0) add('command', 'hidemargin'=>1, 'bitmap'=>'@'+[$demo_dir,'..', - 'images','pattern.xbm'].join(File::Separator), + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', - 'text'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢Ê¸»úÎó¤ÎÂå¤ï¤ê¤Ë¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Ç¹àÌܤòɽ¼¨¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌܤȤδ֤ÇÆä˰㤤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£', - 'bitmap'=>'', 'default'=>0, - 'buttons'=>'ÊĤ¸¤ë')} ) + 'text'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢Ê¸»úÎó¤ÎÂå¤ï¤ê¤Ë¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Ç¹àÌܤòɽ¼¨¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌܤȤδ֤ÇÆä˰㤤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'ÊĤ¸¤ë')} ) ['info', 'questhead', 'error'].each{|icon| add('command', 'bitmap'=>icon, 'hidemargin'=>1, - 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) } entryconfigure(2, :columnbreak=>true) @@ -177,34 +177,34 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| [ 'An entry','Another entry','Does nothing','Does almost nothing', 'Make life meaningful' ].each{|i| add('command', 'label'=>i, - 'command'=>proc{print "You invoked \"#{i}\"\n"}) + 'command'=>proc{print "You invoked \"#{i}\"\n"}) } m.entryconfigure('Does almost nothing', - 'bitmap'=>'questhead', 'compound'=>'left', - 'command'=>proc{ - TkDialog.new('title'=>'Compound Menu Entry', - 'message'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Èʸ»úÎó¤È¤òƱ»þ¤Ë°ì¤Ä¤Î¹àÌܤËɽ¼¨¤¹¤ë¤è¤¦¤Ë¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌܤȤδ֤ÇÆä˰㤤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£', - 'buttons'=>['λ²ò'], 'bitmap'=>'') - }) + 'bitmap'=>'questhead', 'compound'=>'left', + 'command'=>proc{ + TkDialog.new('title'=>'Compound Menu Entry', + 'message'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Èʸ»úÎó¤È¤òƱ»þ¤Ë°ì¤Ä¤Î¹àÌܤËɽ¼¨¤¹¤ë¤è¤¦¤Ë¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌܤȤδ֤ÇÆä˰㤤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£', + 'buttons'=>['λ²ò'], 'bitmap'=>'') + }) } TkMenu.new($menu84_frame) {|m| $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0) ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| add('command', 'label'=>c, 'background'=>c, - 'command'=>proc{print "You invoked \"#{c}\"\n"}) + 'command'=>proc{print "You invoked \"#{c}\"\n"}) } } $menu84_demo.menu($menu84_frame) TkMenu.bind('<MenuSelect>', proc{|w| - begin - label = w.entrycget('active', 'label') - rescue - label = " " - end - menustatus.value = label - Tk.update(true) - }, '%W') + begin + label = w.entrycget('active', 'label') + rescue + label = " " + end + menustatus.value = label + Tk.update(true) + }, '%W') diff --git a/ext/tk/sample/demos-jp/menu8x.rb b/ext/tk/sample/demos-jp/menu8x.rb index e2f477da8..ab691a42b 100644 --- a/ext/tk/sample/demos-jp/menu8x.rb +++ b/ext/tk/sample/demos-jp/menu8x.rb @@ -56,7 +56,7 @@ TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { $menu8xstatus = TkVariable.new(" ") TkFrame.new($menu8x_demo) {|frame| TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken', - 'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\ + 'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) @@ -107,8 +107,8 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| ['A','B','C','D','E','F','G'].each{|c| # add('command', 'label'=>"ʸ»ú \"#{c}\" ¤ò°õ»ú", 'underline'=>4, add('command', 'label'=>"Print letter \"#{c}\" (ʸ»ú \"#{c}\" ¤ò°õ»ú)", - 'underline'=>14, 'accelerator'=>"Meta+#{c}", - 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") $menu8x_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) } } @@ -116,17 +116,17 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| TkMenu.new(m, 'tearoff'=>false) {|cascade_menu| m.add('cascade', 'label'=>'Cascades', 'menu'=>cascade_menu, 'underline'=>0) add('command', 'label'=>'Print hello(¤³¤ó¤Ë¤Á¤Ï)', - 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}, - 'accelerator'=>"#{modifier}+H", 'underline'=>6) + 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) $menu8x_demo.bind("#{modifier}-h", proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"}) add('command', 'label'=>'Print goodbye(¤µ¤è¤¦¤Ê¤é)', - 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}, - 'accelerator'=>"#{modifier}+G", 'underline'=>6) + 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) $menu8x_demo.bind("#{modifier}-g", proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"}) TkMenu.new(m, 'tearoff'=>false) {|cascade_check| cascade_menu.add('cascade', 'label'=>'Check buttons(¥Á¥§¥Ã¥¯¥Ü¥¿¥ó)', - 'menu'=>cascade_check, 'underline'=>0) + 'menu'=>cascade_check, 'underline'=>0) oil = TkVariable.new(0) add('check', 'label'=>'¥ª¥¤¥ëÅÀ¸¡', 'variable'=>oil) trans = TkVariable.new(0) @@ -137,18 +137,18 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| add('check', 'label'=>'¥é¥¤¥ÈÅÀ¸¡', 'variable'=>lights) add('separator') add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨', - 'command'=>proc{showVars($menu8x_demo, - ['¥ª¥¤¥ëÅÀ¸¡', oil], - ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans], - ['¥Ö¥ì¡¼¥ÅÀ¸¡', brakes], - ['¥é¥¤¥ÈÅÀ¸¡', lights])} ) + 'command'=>proc{showVars($menu8x_demo, + ['¥ª¥¤¥ëÅÀ¸¡', oil], + ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans], + ['¥Ö¥ì¡¼¥ÅÀ¸¡', brakes], + ['¥é¥¤¥ÈÅÀ¸¡', lights])} ) invoke 1 invoke 3 } TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| cascade_menu.add('cascade', 'label'=>'Radio buttons(¥é¥¸¥ª¥Ü¥¿¥ó)', - 'menu'=>cascade_radio, 'underline'=>0) + 'menu'=>cascade_radio, 'underline'=>0) pointSize = TkVariable.new add('radio', 'label'=>'10 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>10) add('radio', 'label'=>'14 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>14) @@ -162,9 +162,9 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| add('radio', 'label'=>'¥¤¥¿¥ê¥Ã¥¯', 'variable'=>style, 'value'=>'italic') add('separator') add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨', - 'command'=>proc{showVars($menu8x_demo, - ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize], - ['¥¹¥¿¥¤¥ë', style])} ) + 'command'=>proc{showVars($menu8x_demo, + ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize], + ['¥¹¥¿¥¤¥ë', style])} ) invoke 1 invoke 7 } @@ -173,16 +173,16 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| TkMenu.new(m, 'tearoff'=>false) {|icon_menu| m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0) add('command', - 'bitmap'=>'@'+[$demo_dir,'..', - 'images','pattern.xbm'].join(File::Separator), - 'hidemargin'=>1, - 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', - 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£', - 'bitmap'=>'', 'default'=>0, - 'buttons'=>'λ²ò')} ) + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'hidemargin'=>1, + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'λ²ò')} ) ['info', 'questhead', 'error'].each{|icon| add('command', 'bitmap'=>icon, 'hidemargin'=>1, - 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) } entryconfigure(2, 'columnbreak'=>1) @@ -193,7 +193,7 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| [ '¥¨¥ó¥È¥ê','Ê̤Υ¨¥ó¥È¥ê','²¿¤â¤·¤Ê¤¤','¤Û¤È¤ó¤É²¿¤â¤·¤Ê¤¤', '¿ÍÀ¸¤ò°ÕµÁ¤¢¤ë¤â¤Î¤Ë' ].each{|i| add('command', 'label'=>i, - 'command'=>proc{print "You invoked \"#{i}\"\n"}) + 'command'=>proc{print "You invoked \"#{i}\"\n"}) } } @@ -201,7 +201,7 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| m.add('cascade', 'label'=>'Colors', 'menu'=>colors_menu, 'underline'=>1) ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| add('command', 'label'=>c, 'background'=>c, - 'command'=>proc{print "You invoked \"#{c}\"\n"}) + 'command'=>proc{print "You invoked \"#{c}\"\n"}) } } @@ -209,14 +209,14 @@ TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| } TkMenu.bind('<MenuSelect>', - proc{|w| - begin - label = w.entrycget('active', 'label') - rescue - label = ' ' - end - $menu8xstatus.value = label - Tk.update('idletasks') - }, '%W') + proc{|w| + begin + label = w.entrycget('active', 'label') + rescue + label = ' ' + end + $menu8xstatus.value = label + Tk.update('idletasks') + }, '%W') end ; # Tk 8.x diff --git a/ext/tk/sample/demos-jp/menubu.rb b/ext/tk/sample/demos-jp/menubu.rb index 130801418..aa90a3087 100644 --- a/ext/tk/sample/demos-jp/menubu.rb +++ b/ext/tk/sample/demos-jp/menubu.rb @@ -187,7 +187,7 @@ TkFrame.new(center) {|f| menubuttonoptions = TkVariable.new mbutton = TkMenubutton.new(f) options = optionMenu(mbutton, menubuttonoptions, - 'one', 'two', 'three') + 'one', 'two', 'three') mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25) paletteColor = TkVariable.new colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75', diff --git a/ext/tk/sample/demos-jp/msgbox.rb b/ext/tk/sample/demos-jp/msgbox.rb index 03ab1f7db..983e6b658 100644 --- a/ext/tk/sample/demos-jp/msgbox.rb +++ b/ext/tk/sample/demos-jp/msgbox.rb @@ -17,7 +17,7 @@ $msgbox_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', - 'text'=>"ɽ¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤·¤Æ \"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\" ¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤷ¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top') + 'text'=>"ɽ¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤·¤Æ \"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\" ¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤷ¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top') # frame À¸À® TkFrame.new($msgbox_demo) {|frame| @@ -46,9 +46,9 @@ TkFrame.new($msgbox_demo) {|frame| $msgbox_leftframe = TkFrame.new($msgbox_demo) $msgbox_rightframe = TkFrame.new($msgbox_demo) $msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', - 'pady'=>'.5c', 'padx'=>'.5c') + 'pady'=>'.5c', 'padx'=>'.5c') $msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', - 'pady'=>'.5c', 'padx'=>'.5c') + 'pady'=>'.5c', 'padx'=>'.5c') TkLabel.new($msgbox_leftframe, 'text'=>'¥¢¥¤¥³¥ó').pack('side'=>'top') TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ @@ -57,9 +57,9 @@ TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ $msgboxIcon = TkVariable.new('info') ['error', 'info', 'question', 'warning'].each {|icon| TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon, - 'relief'=>'flat', 'value'=>icon, 'width'=>16, - 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, - 'anchor'=>'w', 'fill'=>'x') + 'relief'=>'flat', 'value'=>icon, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') } TkLabel.new($msgbox_rightframe, 'text'=>'¼ïÎà').pack('side'=>'top') @@ -70,17 +70,17 @@ $msgboxType = TkVariable.new('ok') ['abortretryignore', 'ok', 'okcancel', 'retrycancel', 'yesno', 'yesnocancel'].each {|type| TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType, - 'relief'=>'flat', 'value'=>type, 'width'=>16, - 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, - 'anchor'=>'w', 'fill'=>'x') + 'relief'=>'flat', 'value'=>type, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') } def showMessageBox(w) button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value, - 'title'=>'Message', 'parent'=>w, - 'message'=>"¤³¤ì¤Ï \"#{$msgboxType.value}\" ¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\" ¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£") + 'title'=>'Message', 'parent'=>w, + 'message'=>"¤³¤ì¤Ï \"#{$msgboxType.value}\" ¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\" ¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£") Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w, - 'message'=>"¤¢¤Ê¤¿¤Ï \"#{button}\" ¤ò²¡¤·¤Þ¤·¤¿¤Í¡£") + 'message'=>"¤¢¤Ê¤¿¤Ï \"#{button}\" ¤ò²¡¤·¤Þ¤·¤¿¤Í¡£") end diff --git a/ext/tk/sample/demos-jp/paned1.rb b/ext/tk/sample/demos-jp/paned1.rb index cd51e34aa..8d16d03c0 100644 --- a/ext/tk/sample/demos-jp/paned1.rb +++ b/ext/tk/sample/demos-jp/paned1.rb @@ -17,8 +17,8 @@ $paned1_demo = TkToplevel.new {|w| } TkLabel.new($paned1_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) ²¼¤Î¿§ÉÕ¤±¤µ¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆɽ¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ ¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤¬ panedwindow ¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤ ¾ì¹ç¡¢¤³¤Î¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï panedwindow ¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê @@ -31,13 +31,13 @@ TkFrame.new($paned1_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $paned1_demo.destroy - $paned1_demo = nil - }).pack(:side=>:left, :expand=>true) + $paned1_demo.destroy + $paned1_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'paned1' - }).pack(:side=>:left, :expand=>true) + showCode 'paned1' + }).pack(:side=>:left, :expand=>true) } TkPanedwindow.new($paned1_demo){|f| diff --git a/ext/tk/sample/demos-jp/paned2.rb b/ext/tk/sample/demos-jp/paned2.rb index c6b0f0691..1e82eddda 100644 --- a/ext/tk/sample/demos-jp/paned2.rb +++ b/ext/tk/sample/demos-jp/paned2.rb @@ -17,8 +17,8 @@ $paned2_demo = TkToplevel.new {|w| } TkLabel.new($paned2_demo, - :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) ²¼¤Î¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉÕ¤¤Î¥¦¥£¥¸¥§¥Ã¥È¤¬ÃÖ¤«¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆɽ¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ ¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤¬ panedwindow ¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤ ¾ì¹ç¡¢¤³¤Î¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï panedwindow ¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê @@ -31,13 +31,13 @@ TkFrame.new($paned2_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $paned2_demo.destroy - $paned2_demo = nil - }).pack(:side=>:left, :expand=>true) + $paned2_demo.destroy + $paned2_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'paned2' - }).pack(:side=>:left, :expand=>true) + showCode 'paned2' + }).pack(:side=>:left, :expand=>true) } paneList = TkVariable.new # define as normal variable (not array) @@ -68,29 +68,29 @@ TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f| pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m') add(TkFrame.new(f){|paned2_top| - TkListbox.new(paned2_top, :listvariable=>paneList) { - # Invert the first item to highlight it - itemconfigure(0, :background=>self.cget(:foreground), - :foreground=>self.cget(:background) ) - yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, - :fill=>:y)) - pack(:fill=>:both, :expand=>true) - } + TkListbox.new(paned2_top, :listvariable=>paneList) { + # Invert the first item to highlight it + itemconfigure(0, :background=>self.cget(:foreground), + :foreground=>self.cget(:background) ) + yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, + :fill=>:y)) + pack(:fill=>:both, :expand=>true) + } }, TkFrame.new(f, :height=>120) {|paned2_bottom| - # The bottom window is a text widget with scrollbar - paned2_xscr = TkScrollbar.new(paned2_bottom) - paned2_yscr = TkScrollbar.new(paned2_bottom) - paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) { - insert('1.0', '¤³¤³¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢' + - '¤´¤¯ÉáÄ̤Υƥ¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ç¤¹¡£') - xscrollbar(paned2_xscr) - yscrollbar(paned2_yscr) - } - Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew') - Tk.grid(paned2_xscr, :sticky=>'nsew') - TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1) - TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1) + # The bottom window is a text widget with scrollbar + paned2_xscr = TkScrollbar.new(paned2_bottom) + paned2_yscr = TkScrollbar.new(paned2_bottom) + paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) { + insert('1.0', '¤³¤³¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢' + + '¤´¤¯ÉáÄ̤Υƥ¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ç¤¹¡£') + xscrollbar(paned2_xscr) + yscrollbar(paned2_yscr) + } + Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew') + Tk.grid(paned2_xscr, :sticky=>'nsew') + TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1) + TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1) } ) } diff --git a/ext/tk/sample/demos-jp/plot.rb b/ext/tk/sample/demos-jp/plot.rb index c8025d8bf..902b144f7 100644 --- a/ext/tk/sample/demos-jp/plot.rb +++ b/ext/tk/sample/demos-jp/plot.rb @@ -17,7 +17,7 @@ $plot_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', - 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï´Êñ¤Ê2¼¡¸µ¤Î¥×¥í¥Ã¥È¤ò´Þ¤ó¤À¥¥ã¥ó¥Ð¥¹ widget¤Ç¤¹¡£É½¼¨¤µ¤ì¤¿ÅÀ¤ò¥Þ¥¦¥¹¥Ü¥¿¥ó1¤Ç¥É¥é¥Ã¥°¤·¤Æ¥Ç¡¼¥¿¤ò¤¤¤¸¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£"){ + 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï´Êñ¤Ê2¼¡¸µ¤Î¥×¥í¥Ã¥È¤ò´Þ¤ó¤À¥¥ã¥ó¥Ð¥¹ widget¤Ç¤¹¡£É½¼¨¤µ¤ì¤¿ÅÀ¤ò¥Þ¥¦¥¹¥Ü¥¿¥ó1¤Ç¥É¥é¥Ã¥°¤·¤Æ¥Ç¡¼¥¿¤ò¤¤¤¸¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£"){ pack('side'=>'top') } @@ -51,39 +51,39 @@ $plot_canvas.pack('side'=>'top', 'fill'=>'x') TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2) TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2) TkcText.new($plot_canvas, 225, 20, - 'text'=>"´Êñ¤Ê¥×¥í¥Ã¥È", 'font'=>plotFont, 'fill'=>'brown') + 'text'=>"´Êñ¤Ê¥×¥í¥Ã¥È", 'font'=>plotFont, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2) TkcText.new($plot_canvas, x, 254, - 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n') + 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2) TkcText.new($plot_canvas, 96, y, - 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $plot_canvas.itembind('point', 'Any-Enter', - proc{$plot_canvas.itemconfigure 'current','fill','red'}) + proc{$plot_canvas.itemconfigure 'current','fill','red'}) $plot_canvas.itembind('point', 'Any-Leave', - proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'}) + proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'}) $plot_canvas.itembind('point', '1', - proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y") + proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y") $plot_canvas.itembind('point', 'ButtonRelease-1', - proc{$plot_canvas.dtag 'selected'}) + proc{$plot_canvas.dtag 'selected'}) $plot_canvas.bind('B1-Motion', - proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y") + proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y") $plot = {'lastX'=>0, 'lastY'=>0} @@ -92,8 +92,8 @@ $plot = {'lastX'=>0, 'lastY'=>0} # data points. It sets up state to allow the point to be dragged. # # Arguments: -# w - The canvas window. -# x, y - The coordinates of the mouse press. +# w - The canvas window. +# x, y - The coordinates of the mouse press. def plotDown (w, x, y) w.dtag 'selected' @@ -108,8 +108,8 @@ end # current item. # # Arguments: -# w - The canvas window. -# x, y - The coordinates of the mouse. +# w - The canvas window. +# x, y - The coordinates of the mouse. def plotMove (w, x, y) w.move 'selected', x - $plot['lastX'], y - $plot['lastY'] diff --git a/ext/tk/sample/demos-jp/puzzle.rb b/ext/tk/sample/demos-jp/puzzle.rb index afef8fcb0..ad69775aa 100644 --- a/ext/tk/sample/demos-jp/puzzle.rb +++ b/ext/tk/sample/demos-jp/puzzle.rb @@ -89,7 +89,7 @@ order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12] highlightthickness 0 command def_puzzleswitch_proc(w, num) }.place('relx'=>$xpos[num], 'rely'=>$ypos[num], - 'relwidth'=>0.25, 'relheight'=>0.25) + 'relwidth'=>0.25, 'relheight'=>0.25) } $xpos['space'] = 0.75 $ypos['space'] = 0.75 @@ -101,9 +101,9 @@ def puzzleSwitch(w, num) && ($xpos[num] >= ($xpos['space'] - 0.26)) \ && ($xpos[num] <= ($xpos['space'] + 0.26))) \ || (($xpos[num] >= ($xpos['space'] - 0.01)) \ - && ($xpos[num] <= ($xpos['space'] + 0.01)) \ - && ($ypos[num] >= ($ypos['space'] - 0.26)) \ - && ($ypos[num] <= ($ypos['space'] + 0.26))) + && ($xpos[num] <= ($xpos['space'] + 0.01)) \ + && ($ypos[num] >= ($ypos['space'] - 0.26)) \ + && ($ypos[num] <= ($ypos['space'] + 0.26))) tmp = $xpos['space'] $xpos['space'] = $xpos[num] $xpos[num] = tmp diff --git a/ext/tk/sample/demos-jp/radio2.rb b/ext/tk/sample/demos-jp/radio2.rb index c7b98e631..5ac877d99 100644 --- a/ext/tk/sample/demos-jp/radio2.rb +++ b/ext/tk/sample/demos-jp/radio2.rb @@ -55,18 +55,18 @@ TkFrame.new($radio2_demo) {|frame| text 'ÊÑ¿ô»²¾È' command proc{ showVars($radio2_demo, - ['size', size], ['color', color], ['compound', align]) + ['size', size], ['color', color], ['compound', align]) } }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame f_left = TkLabelFrame.new($radio2_demo, 'text'=>'ʸ»ú¥µ¥¤¥º', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'¿§', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_right = TkLabelFrame.new($radio2_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') @@ -92,14 +92,14 @@ f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') } label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead', - 'compound'=>'left') + 'compound'=>'left') label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') label.height(TkWinfo.reqheight(label)) abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| lower = a.downcase TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', - 'value'=>lower, 'indicatoron'=>0, 'width'=>7, - 'command'=>proc{label.compound(align.value)}) + 'value'=>lower, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) } Tk.grid('x', abtn[0]) diff --git a/ext/tk/sample/demos-jp/radio3.rb b/ext/tk/sample/demos-jp/radio3.rb index bdc3ee0bf..6e9a0f750 100644 --- a/ext/tk/sample/demos-jp/radio3.rb +++ b/ext/tk/sample/demos-jp/radio3.rb @@ -36,43 +36,43 @@ align = TkVariable.new # frame TkFrame.new($radio3_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È', - :image=>$image['view'], :compound=>:left, - :command=>proc{ - showVars($radio3_demo, ['size', size], - ['color', color], ['compound', align]) - }), - TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'radio3'}), - TkButton.new(frame, :text=>'ÊĤ¸¤ë', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $radio3_demo - $radio3_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars($radio3_demo, ['size', size], + ['color', color], ['compound', align]) + }), + TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'radio3'}), + TkButton.new(frame, :text=>'ÊĤ¸¤ë', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $radio3_demo + $radio3_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew') } # frame f_left = TkLabelFrame.new($radio3_demo, 'text'=>'ʸ»ú¥µ¥¤¥º', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'¿§', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_right = TkLabelFrame.new($radio3_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ', - 'pady'=>2, 'padx'=>2) + 'pady'=>2, 'padx'=>2) f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c') TkButton.new($radio3_demo, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È', - 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){ + 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c') } @@ -100,13 +100,13 @@ TkButton.new($radio3_demo, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È', } label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead', - 'compound'=>'left') + 'compound'=>'left') label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') label.height(TkWinfo.reqheight(label)) a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', - 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7, - 'command'=>proc{label.compound(align.value)}) + 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) } Tk.grid('x', a_btn[0]) diff --git a/ext/tk/sample/demos-jp/ruler.rb b/ext/tk/sample/demos-jp/ruler.rb index 5d8c0443c..94b4c921d 100644 --- a/ext/tk/sample/demos-jp/ruler.rb +++ b/ext/tk/sample/demos-jp/ruler.rb @@ -7,8 +7,8 @@ # represent a tab stop. # # Arguments: -# c - The canvas window. -# x, y - Coordinates at which to create the tab stop. +# c - The canvas window. +# x, y - Coordinates at which to create the tab stop. def rulerMkTab(c,x,y) v = $demo_rulerInfo @@ -30,7 +30,7 @@ $ruler_demo = TkToplevel.new {|w| # label À¸À® TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', - 'text'=>"¤³¤Î¥¥ã¥ó¥Ð¥¹widget¤Ï¥ë¡¼¥é¡¼¤ÎÌÏ·¿¤Ç¤¹¡£¥ë¡¼¥é¡¼¤Î±¦¤Ë¤¢¤ë¤Î¤Ï¥¿¥Ö¥¹¥È¥Ã¥×¤Î°æ¸Í¤Ç¡¢¤³¤³¤«¤é°ú¤ÃÄ¥¤Ã¤Æ¤¯¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥¿¥Ö¥¹¥È¥Ã¥×¤òºî¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿¡¢¤¹¤Ç¤Ë¤¢¤ë¥¿¥Ö¥¹¥È¥Ã¥×¤òÆ°¤«¤¹¤³¤È¤â¤Ç¤¤Þ¤¹¡£¥¿¥Ö¥¹¥È¥Ã¥×¤ò¾åÊý¤Þ¤¿¤Ï²¼Êý¤Ë¤«¤¹¤ì¤Æɽ¼¨¤µ¤ì¤ë¤Þ¤Ç¥É¥é¥Ã¥°¤¹¤ë¤È¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤òÎ¥¤·¤¿»þ¤Ë¤½¤Î¥¿¥Ö¥¹¥È¥Ã¥×¤Ï¾Ã¤¨¤Þ¤¹¡£"){ + 'text'=>"¤³¤Î¥¥ã¥ó¥Ð¥¹widget¤Ï¥ë¡¼¥é¡¼¤ÎÌÏ·¿¤Ç¤¹¡£¥ë¡¼¥é¡¼¤Î±¦¤Ë¤¢¤ë¤Î¤Ï¥¿¥Ö¥¹¥È¥Ã¥×¤Î°æ¸Í¤Ç¡¢¤³¤³¤«¤é°ú¤ÃÄ¥¤Ã¤Æ¤¯¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥¿¥Ö¥¹¥È¥Ã¥×¤òºî¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿¡¢¤¹¤Ç¤Ë¤¢¤ë¥¿¥Ö¥¹¥È¥Ã¥×¤òÆ°¤«¤¹¤³¤È¤â¤Ç¤¤Þ¤¹¡£¥¿¥Ö¥¹¥È¥Ã¥×¤ò¾åÊý¤Þ¤¿¤Ï²¼Êý¤Ë¤«¤¹¤ì¤Æɽ¼¨¤µ¤ì¤ë¤Þ¤Ç¥É¥é¥Ã¥°¤¹¤ë¤È¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤òÎ¥¤·¤¿»þ¤Ë¤½¤Î¥¿¥Ö¥¹¥È¥Ã¥×¤Ï¾Ã¤¨¤Þ¤¹¡£"){ pack('side'=>'top') } @@ -60,8 +60,8 @@ $ruler_canvas.pack('side'=>'top', 'fill'=>'x') # ÃÍÀßÄê unless Struct.const_defined?("RulerInfo") $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y, - :top, :bottom, :size, :normalStyle, - :activeStyle, :deleteStyle).new + :top, :bottom, :size, :normalStyle, + :activeStyle, :deleteStyle).new end $demo_rulerInfo.grid = '.25c' $demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c') @@ -83,7 +83,7 @@ else end TkcLine.new($ruler_canvas, - '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1) + '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1) (0..11).each{|i| x = i+1 TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1) @@ -96,22 +96,22 @@ TkcLine.new($ruler_canvas, $rulerTag_well = TkcTag.new($ruler_canvas) $ruler_canvas\ .addtag_withtag($rulerTag_well, - TkcRectangle.new($ruler_canvas, - '13.2c', '1c', '13.8c', '0.5c', - 'outline'=>'black', - 'fill'=>($ruler_canvas\ - .configinfo('background'))[4]) ) + TkcRectangle.new($ruler_canvas, + '13.2c', '1c', '13.8c', '0.5c', + 'outline'=>'black', + 'fill'=>($ruler_canvas\ + .configinfo('background'))[4]) ) $ruler_canvas\ .addtag_withtag($rulerTag_well, - rulerMkTab($ruler_canvas, - TkWinfo.pixels($ruler_canvas, '13.5c'), - TkWinfo.pixels($ruler_canvas, '.65c') ) ) + rulerMkTab($ruler_canvas, + TkWinfo.pixels($ruler_canvas, '13.5c'), + TkWinfo.pixels($ruler_canvas, '.65c') ) ) $rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.itembind('tab', '1', - proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y') + proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.bind('B1-Motion', - proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y') + proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y') $ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)}) # rulerNewTab -- @@ -119,8 +119,8 @@ $ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)}) # triangle object and adding tags to it to give it tab behavior. # # Arguments: -# c - The canvas window. -# x, y - The coordinates of the tab stop. +# c - The canvas window. +# x, y - The coordinates of the tab stop. def rulerNewTab(c,x,y) v = $demo_rulerInfo @@ -137,9 +137,9 @@ end # be dragged interactively. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse (identifies the point by -# which the tab was picked up for dragging). +# c - The canvas widget. +# x, y - The coordinates of the mouse (identifies the point by +# which the tab was picked up for dragging). def rulerSelectTab(c,x,y) v = $demo_rulerInfo @@ -156,8 +156,8 @@ end # it is about to be dragged out of the ruler. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse. +# c - The canvas widget. +# x, y - The coordinates of the mouse. def rulerMoveTab(c,x,y) v = $demo_rulerInfo @@ -184,8 +184,8 @@ end # it was dragged out of the ruler. # # Arguments: -# c - The canvas widget. -# x, y - The coordinates of the mouse. +# c - The canvas widget. +# x, y - The coordinates of the mouse. def rulerReleaseTab(c) v = $demo_rulerInfo diff --git a/ext/tk/sample/demos-jp/sayings.rb b/ext/tk/sample/demos-jp/sayings.rb index bcbdd7a5e..ce195a0e5 100644 --- a/ext/tk/sample/demos-jp/sayings.rb +++ b/ext/tk/sample/demos-jp/sayings.rb @@ -65,11 +65,11 @@ TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w| else sayings_lbox.grid('row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') sv.grid('row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') sh.grid('row'=>1, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0) end diff --git a/ext/tk/sample/demos-jp/search.rb b/ext/tk/sample/demos-jp/search.rb index 3ae7de769..f5268f987 100644 --- a/ext/tk/sample/demos-jp/search.rb +++ b/ext/tk/sample/demos-jp/search.rb @@ -8,9 +8,9 @@ # not affected, however. # # Arguments: -# w - The window into which to load the file. Must be a -# text widget. -# file - The name of the file to load. Must be readable. +# w - The window into which to load the file. Must be a +# text widget. +# file - The name of the file to load. Must be readable. def textLoadFile(w,file) w.delete('1.0', 'end') @@ -26,10 +26,10 @@ end # apply a given tag to each instance found. # # Arguments: -# w - The window in which to search. Must be a text widget. -# string - The string to search for. The search is done using -# exact matching only; no special characters. -# tag - Tag to apply to each instance of a matching string. +# w - The window in which to search. Must be a text widget. +# string - The string to search for. The search is done using +# exact matching only; no special characters. +# tag - Tag to apply to each instance of a matching string. def textSearch(w, string, tag) tag.remove('0.0', 'end') @@ -50,15 +50,15 @@ end # deleted) then it doesn't reschedule itself. # # Arguments: -# cmd1 - Command to execute when method is called. -# sleep1 - Ms to sleep after executing cmd1 before executing cmd2. -# cmd2 - Command to execute in the *next* invocation of this method. -# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again. +# cmd1 - Command to execute when method is called. +# sleep1 - Ms to sleep after executing cmd1 before executing cmd2. +# cmd2 - Command to execute in the *next* invocation of this method. +# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again. def textToggle(cmd1,sleep1,cmd2,sleep2) sleep_list = [sleep2, sleep1] TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep}, - -1, cmd1, cmd2).start(sleep1) + -1, cmd1, cmd2).start(sleep1) end # toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë @@ -96,35 +96,35 @@ $search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame À¸À® TkFrame.new($search_demo) {|f| TkLabel.new(f, 'text'=>'¥Õ¥¡¥¤¥ë̾:', - 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') $search_fileName = TkVariable.new TkEntry.new(f, 'width'=>40, - 'textvariable'=>$search_fileName) { + 'textvariable'=>$search_fileName) { pack('side'=>'left') bind('Return', proc{textLoadFile($search_text, $search_fileName.value) - $search_string_entry.focus}) + $search_string_entry.focus}) focus } TkButton.new(f, 'text'=>'Æɤ߹þ¤ß', - 'command'=>proc{textLoadFile($search_text, - $search_fileName.value)})\ + 'command'=>proc{textLoadFile($search_text, + $search_fileName.value)})\ .pack('side'=>'left', 'pady'=>5, 'padx'=>10) }.pack('side'=>'top', 'fill'=>'x') TkFrame.new($search_demo) {|f| TkLabel.new(f, 'text'=>'¸¡º÷ʸ»úÎó:', - 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') $search_searchString = TkVariable.new $search_string_entry = TkEntry.new(f, 'width'=>40, - 'textvariable'=>$search_searchString) { + 'textvariable'=>$search_searchString) { pack('side'=>'left') bind('Return', proc{textSearch($search_text, $search_searchString.value, - $search_Tag)}) + $search_Tag)}) } TkButton.new(f, 'text'=>'ȿž', - 'command'=>proc{textSearch($search_text, - $search_searchString.value, - $search_Tag)}) { + 'command'=>proc{textSearch($search_text, + $search_searchString.value, + $search_Tag)}) { pack('side'=>'left', 'pady'=>5, 'padx'=>10) } }.pack('side'=>'top', 'fill'=>'x') @@ -142,24 +142,24 @@ $search_text = TkText.new($search_demo, 'setgrid'=>true) {|t| if TkWinfo.depth($search_demo) > 1 textToggle(proc{ - $search_Tag.configure('background'=>'#ce5555', - 'foreground'=>'white') - }, - 800, - proc{ - $search_Tag.configure('background'=>'', 'foreground'=>'') - }, - 200 ) + $search_Tag.configure('background'=>'#ce5555', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) else textToggle(proc{ - $search_Tag.configure('background'=>'black', - 'foreground'=>'white') - }, - 800, - proc{ - $search_Tag.configure('background'=>'', 'foreground'=>'') - }, - 200 ) + $search_Tag.configure('background'=>'black', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) end $search_text.insert('1.0', "\ ¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¸¡º÷µ¡¹½¤ò¼Â¸½¤¹¤ë¤Î¤Ë¥Æ¥¥¹¥È widget ¤Î¥¿¥°µ¡Ç½¤¬¤É¤Î \ diff --git a/ext/tk/sample/demos-jp/spin.rb b/ext/tk/sample/demos-jp/spin.rb index 69d6d71d8..c7b809672 100644 --- a/ext/tk/sample/demos-jp/spin.rb +++ b/ext/tk/sample/demos-jp/spin.rb @@ -16,8 +16,8 @@ $spin_demo = TkToplevel.new {|w| } TkLabel.new($spin_demo, - :font=>$font, :wraplength=>'5i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) ²¼¤Ë¤Ï£³¼ïÎà¤Î¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\ ¤½¤ì¤¾¤ì¡¢¥Þ¥¦¥¹¤ÇÁªÂò¤·¤Æʸ»ú¤òÆþÎϤ¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ ÊÔ½¸Áàºî¤È¤·¤Æ¤Ï¡¢Emacs ·Á¼°¤Î¿¤¯¤Ë²Ã¤¨¤Æ¡¢°ìÈÌŪ¤Ê @@ -42,13 +42,13 @@ TkFrame.new($spin_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $spin_demo.destroy - $spin_demo = nil - }).pack(:side=>:left, :expand=>true) + $spin_demo.destroy + $spin_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'spin' - }).pack(:side=>:left, :expand=>true) + showCode 'spin' + }).pack(:side=>:left, :expand=>true) } australianCities = [ @@ -58,10 +58,10 @@ australianCities = [ [ TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key, - :validatecommand=>[ - proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' - ]), + :validatecommand=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]), TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5, - :format=>'%05.2f', :width=>10), + :format=>'%05.2f', :width=>10), TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10) ].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)} diff --git a/ext/tk/sample/demos-jp/style.rb b/ext/tk/sample/demos-jp/style.rb index 458479611..59e406bc8 100644 --- a/ext/tk/sample/demos-jp/style.rb +++ b/ext/tk/sample/demos-jp/style.rb @@ -62,13 +62,13 @@ TkText.new($style_demo){|t| # unless $style_demo_do_first # $style_demo_do_first = true # Tk.tk_call('font', 'create', '@bigascii', -# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*') +# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*') # Tk.tk_call('font', 'create', '@smallascii', -# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*') +# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*') # Tk.tk_call('font', 'create', '@cBigFont', -# '-compound', '@bigascii @msg_knj') +# '-compound', '@bigascii @msg_knj') # Tk.tk_call('font', 'create', '@cSmallFont', -# '-compound', '@smallascii @kanji') +# '-compound', '@smallascii @kanji') # end # style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont') # style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont') @@ -82,24 +82,24 @@ TkText.new($style_demo){|t| style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1) else style_tag_color1 = TkTextTag.new(t, 'background'=>'black', - 'foreground'=>'white') + 'foreground'=>'white') style_tag_color2 = TkTextTag.new(t, 'background'=>'black', - 'foreground'=>'white') + 'foreground'=>'white') style_tag_raised = TkTextTag.new(t, 'background'=>'white', - 'relief'=>'raised', 'borderwidth'=>1) + 'relief'=>'raised', 'borderwidth'=>1) style_tag_sunken = TkTextTag.new(t, 'background'=>'white', - 'relief'=>'sunken', 'borderwidth'=>1) + 'relief'=>'sunken', 'borderwidth'=>1) end # ¥Æ¥¥¹¥È¥¿¥°ÀßÄê (¤½¤Î¾) if $tk_version =~ /^4\.[01]/ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', - 'borderwidth'=>0, - 'bgstipple'=>'gray25') + 'borderwidth'=>0, + 'bgstipple'=>'gray25') else style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', - 'borderwidth'=>0, - 'bgstipple'=>'gray12') + 'borderwidth'=>0, + 'bgstipple'=>'gray12') end style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50') style_tag_underline = TkTextTag.new(t, 'underline'=>'on') @@ -109,10 +109,10 @@ TkText.new($style_demo){|t| style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m', - 'rmargin'=>'10m') + 'rmargin'=>'10m') style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p', - 'lmargin1'=>'12m', 'lmargin2'=>'6m', - 'rmargin'=>'10m') + 'lmargin1'=>'12m', 'lmargin2'=>'6m', + 'rmargin'=>'10m') # ¥Æ¥¥¹¥ÈÁÞÆþ insert('end', '¤³¤Î¤è¤¦¤Ë¥Æ¥¥¹¥È widget ¤Ï¾ðÊó¤òÍÍ¡¹¤Ê¥¹¥¿¥¤¥ë¤Çɽ¼¨¤¹¤ë¤³¤È @@ -198,9 +198,9 @@ X') insert('end', '¥Æ¥¥¹¥È¤Îº¸Â¦¤Ë;ʬ¤Ê¶õÇò¤òÃÖ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹: ') insert('end', '¤³¤ÎÃÊÍî¤Ï¥Þ¡¼¥¸¥ó¤Î»ÈÍÑÎã¤Ç¤¹¡£¥¹¥¯¥ê¡¼¥ó', - style_tag_margins) + style_tag_margins) insert('end', '¾å¤ÇÀÞ¤êÊÖ¤µ¤ì¤Æɽ¼¨¤µ¤ì¤Æ¤¤¤ë1¹Ô¤Î¥Æ¥¥¹¥È¤Ç¤¹¡£', - style_tag_margins) + style_tag_margins) insert('end', 'º¸Â¦¤Ë¤Ï2¼ïÎà¤Î¥Þ¡¼¥¸¥ó¤ò»ý¤Á¤Þ¤¹¡£', style_tag_margins) insert('end', '1¹ÔÌܤËÂФ¹¤ë¤â¤Î¤È¡¢', style_tag_margins) insert('end', '2¹ÔÌܰʹߤÎϢ³¤·¤¿¥Þ¡¼¥¸¥ó', style_tag_margins) @@ -222,9 +222,9 @@ spacing3') ¤¯¤«¤ò¼¨¤·¤Þ¤¹¡£ ') insert('end', '¤³¤ì¤é¤Î¥¤¥ó¥Ç¥ó¥È¤µ¤ì¤¿ÃÊÍî¤Ï¤É¤Î¤è¤¦¤Ë', - style_tag_spacing) + style_tag_spacing) insert('end', '¥¹¥Ú¡¼¥·¥ó¥°¤¬¤¬¹Ô¤ï¤ì¤ë¤Î¤«¤ò¼¨¤·¤Þ¤¹¡£', - style_tag_spacing) + style_tag_spacing) insert('end', '³ÆÃÊÍî¤Ï¼ÂºÝ¤Ï¥Æ¥¥¹¥Èwidget', style_tag_spacing) insert('end', '¤Î1¹Ô¤Ç¡¢widget¤Ë¤è¤Ã¤ÆÀÞ¤ê¾ö¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ ', style_tag_spacing) @@ -234,11 +234,11 @@ spacing3') insert('end', '¸ºß¤·¤Æ¤¤¤Þ¤¹¡£', style_tag_spacing) insert('end', 'Spacing2¤Ï2point¤ËÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡£', style_tag_spacing) insert('end', '¤³¤ì¤ÇÃÊÍî¤ÎÃæ¤Ë¤Û¤ó¤Î¾¯¤·´Ö³Ö¤¬Â¸ºß¤·¤Æ¤¤¤Þ¤¹¡£', - style_tag_spacing) + style_tag_spacing) insert('end', 'Spacing3¤Ï¤³¤ÎÎã¤Ç¤Ï»ÈÍѤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ', style_tag_spacing) insert('end', '´Ö³Ö¤¬¤É¤³¤Ë¤¢¤ë¤«¤ò¸«¤¿¤±¤ì¤Ð¡¢¤³¤ì¤é¤ÎÃÊÍî¤Î', - style_tag_spacing) + style_tag_spacing) insert('end', '¤Ê¤«¤Ç¥Æ¥¥¹¥È¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£ÁªÂò¤Î', style_tag_spacing) insert('end', 'ȿž¤·¤¿Éôʬ¤Ë¤Ï;ʬ¤Ë¤È¤é¤ì¤¿´Ö³Ö¤¬', style_tag_spacing) insert('end', '´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ diff --git a/ext/tk/sample/demos-jp/text.rb b/ext/tk/sample/demos-jp/text.rb index bec95ee52..0057d5dbd 100644 --- a/ext/tk/sample/demos-jp/text.rb +++ b/ext/tk/sample/demos-jp/text.rb @@ -92,16 +92,16 @@ TkText.new($text_demo){|t| ¥³¥ó¥È¥í¡¼¥ë-K ¤ÏÁÞÆþ¥«¡¼¥½¥ë¤«¤é¹ÔËö¤Þ¤Ç¤òºï½ü¤·¡¢¤½¤Î°ÌÃ֤˲þ¹Ô ¤·¤«¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢²þ¹Ô¤òºï½ü¤·¤Þ¤¹¡£#{ if undo_support - undo_text = "Control-z ¤ÏºÇ¸å¤Ë¹Ô¤Ã¤¿Êѹ¹¤Î¼è¤ê¾Ã¤·(undo)¤ò¹Ô¤¤¡¢" - case $tk_platform['platform'] - when "unix", "macintosh" - undo_text << "Control-Shift-z" - else # 'windows' - undo_text << "Control-y" - end - undo_text << "¤Ïundo¤·¤¿Êѹ¹¤ÎºÆŬÍÑ(redo)¤ò¹Ô¤¤¤Þ¤¹¡£" + undo_text = "Control-z ¤ÏºÇ¸å¤Ë¹Ô¤Ã¤¿Êѹ¹¤Î¼è¤ê¾Ã¤·(undo)¤ò¹Ô¤¤¡¢" + case $tk_platform['platform'] + when "unix", "macintosh" + undo_text << "Control-Shift-z" + else # 'windows' + undo_text << "Control-y" + end + undo_text << "¤Ïundo¤·¤¿Êѹ¹¤ÎºÆŬÍÑ(redo)¤ò¹Ô¤¤¤Þ¤¹¡£" else - "" + "" end } diff --git a/ext/tk/sample/demos-jp/twind.rb b/ext/tk/sample/demos-jp/twind.rb index 8716ad727..2b228e4ac 100644 --- a/ext/tk/sample/demos-jp/twind.rb +++ b/ext/tk/sample/demos-jp/twind.rb @@ -37,10 +37,10 @@ $twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame À¸À® $twind_text = nil TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2, - 'relief'=>'sunken') {|f| + 'relief'=>'sunken') {|f| $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font, - 'width'=>'70', 'height'=>35, 'wrap'=>'word', - 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| TkScrollbar.new(f) {|s| command proc{|*args| t.yview(*args)} t.yscrollcommand proc{|first,last| s.set first,last} @@ -50,60 +50,60 @@ TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2, # ¥¿¥°À¸À® $tag_center = TkTextTag.new($twind_text, - 'justify' =>'center', - 'spacing1'=>'5m', - 'spacing3'=>'5m' ) + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) $tag_buttons = TkTextTag.new($twind_text, - 'lmargin1'=>'1c', - 'lmargin2'=>'1c', - 'rmargin' =>'1c', - 'spacing1'=>'3m', - 'spacing2'=>0, - 'spacing3'=>0 ) + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) # ¥Æ¥¥¹¥È¤ÎÀ¸À® $twind_text.insert('end', - '¥Æ¥¥¹¥Èwidget¾å¤Ë¾¤Îwidget¤òÁȤ߹þ¤à¤³¤È¤¬¤Ç¤¤Þ¤¹¡£') + '¥Æ¥¥¹¥Èwidget¾å¤Ë¾¤Îwidget¤òÁȤ߹þ¤à¤³¤È¤¬¤Ç¤¤Þ¤¹¡£') $twind_text.insert('end', - 'ÁȤ߹þ¤ß¥¦¥£¥ó¥É¥¦¤È¸Æ¤Ð¤ì¡¢Ç¤°Õ¤Îwidget¤¬²Äǽ¤Ç¤¹¡£') + 'ÁȤ߹þ¤ß¥¦¥£¥ó¥É¥¦¤È¸Æ¤Ð¤ì¡¢Ç¤°Õ¤Îwidget¤¬²Äǽ¤Ç¤¹¡£') $twind_text.insert('end', - 'Î㤨¤Ð¡¢¤³¤³¤Ë2¤Ä¤Î¥Ü¥¿¥ówidget¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£') + 'Î㤨¤Ð¡¢¤³¤³¤Ë2¤Ä¤Î¥Ü¥¿¥ówidget¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£') $twind_text.insert('end', 'ºÇ½é¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤È¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò') TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - #text 'ON' - text '¥ª¥ó' - command proc{textWindOn $twind_text,$twind_buttons} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + #text 'ON' + text '¥ª¥ó' + command proc{textWindOn $twind_text,$twind_buttons} + cursor 'top_left_arrow' + }) $twind_text.insert('end', "¤Ë¤·¤Þ¤¹¡£¤Þ¤¿2¤Ä¤á¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È\n") $twind_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò') TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - #text 'OFF' - text '¥ª¥Õ' - command proc{textWindOff $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + #text 'OFF' + text '¥ª¥Õ' + command proc{textWindOff $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', '¤Ë¤·¤Þ¤¹¡£') $twind_text.insert('end', '¤â¤¦¤Ò¤È¤Ä¤ÎÎã¤Ç¤¹¡£') TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text '¤³¤³¤ò¥¯¥ê¥Ã¥¯' - command proc{textWindPlot $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + text '¤³¤³¤ò¥¯¥ê¥Ã¥¯' + command proc{textWindPlot $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', '¤¹¤ë¤È¡¢x-y¥×¥í¥Ã¥È¤¬¤³¤³¤Ë¸½¤ì¤Þ¤¹¡£') $mark_plot = TkTextMark.new($twind_text, 'insert') $mark_plot.gravity='left' $twind_text.insert('end', '¥Þ¥¦¥¹¤Ç¥Ç¡¼¥¿¤òÉÁ²è¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£') TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text '¾Ãµî' - command proc{textWindDel $twind_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind_text) { + text '¾Ãµî' + command proc{textWindDel $twind_text} + cursor 'top_left_arrow' + }) $twind_text.insert('end', '¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£ ') @@ -123,27 +123,27 @@ $twind_text.insert('end', '¤â¤¦°ìÅÙƱ¤¸¥Ü¥¿¥ó¤ò²¡¤¹¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£ ') TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) {|b| - text '¥Ç¥Õ¥©¥ë¥È' - command proc{embDefBg $twind_text} - cursor 'top_left_arrow' - $tag_buttons.add('end') - }, - 'padx'=>3 ) + 'window'=>TkButton.new($twind_text) {|b| + text '¥Ç¥Õ¥©¥ë¥È' + command proc{embDefBg $twind_text} + cursor 'top_left_arrow' + $tag_buttons.add('end') + }, + 'padx'=>3 ) embToggle = TkVariable.new('Short') TkTextWindow.new($twind_text, 'end', - 'window'=>TkCheckButton.new($twind_text) { - textvariable embToggle - indicatoron 0 - variable embToggle - onvalue 'A much longer string' - offvalue 'Short' - cursor 'top_left_arrow' - pady 5 - padx 2 - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkCheckButton.new($twind_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) [ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', @@ -151,13 +151,13 @@ TkTextWindow.new($twind_text, 'end', 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' ].each{|twind_color| TkTextWindow.new($twind_text, 'end', - 'window'=>TkButton.new($twind_text) { - text twind_color - cursor 'top_left_arrow' - command proc{$twind_text.bg twind_color} - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkButton.new($twind_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) } # ¥á¥½¥Ã¥ÉÄêµÁ @@ -211,39 +211,39 @@ def textWindPlot (t) TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2) TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2) TkcText.new($twind_plot, 225, 20, - 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2) TkcText.new($twind_plot, x, 254, - 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2) TkcText.new($twind_plot, 96, y, - 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $twind_plot.itembind('point', 'Any-Enter', - proc{$twind_plot.itemconfigure 'current', 'fill', 'red'}) + proc{$twind_plot.itemconfigure 'current', 'fill', 'red'}) $twind_plot.itembind('point', 'Any-Leave', - proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) $twind_plot.itembind('point', '1', - proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y") + proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y") $twind_plot.itembind('point', 'ButtonRelease-1', - proc{$twind_plot.dtag 'selected'}) + proc{$twind_plot.dtag 'selected'}) $twind_plot.bind('B1-Motion', - proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y") + proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y") while ($twind_text.get($mark_plot) =~ /[ \t\n]/) $twind_text.delete $mark_plot end diff --git a/ext/tk/sample/demos-jp/twind2.rb b/ext/tk/sample/demos-jp/twind2.rb index 8c871688b..b634f07b4 100644 --- a/ext/tk/sample/demos-jp/twind2.rb +++ b/ext/tk/sample/demos-jp/twind2.rb @@ -18,20 +18,20 @@ $twind2_demo = TkToplevel.new {|w| # frame À¸À® $twind2_buttons = TkFrame.new($twind2_demo) {|frame| TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), - :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) TkGrid('x', - TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'twind2'}), - TkButton.new(frame, :text=>'ÊĤ¸¤ë', - :image=>$image['delete'], :compound=>:left, - :command=>proc{ - tmppath = $twind2_demo - $twind2_demo = nil - $showVarsWin[tmppath.path] = nil - tmppath.destroy - }), - :padx=>4, :pady=>4) + TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'twind2'}), + TkButton.new(frame, :text=>'ÊĤ¸¤ë', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $twind2_demo + $twind2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) frame.grid_columnconfigure(0, :weight=>1) } $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') @@ -39,11 +39,11 @@ $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # frame À¸À® $twind2_text = nil TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2, - 'relief'=>'sunken') {|f| + 'relief'=>'sunken') {|f| $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font, - # 'width'=>'70', 'height'=>35, 'wrap'=>'word', - 'width'=>'70', 'height'=>35, 'wrap'=>'char', - 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + # 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'width'=>'70', 'height'=>35, 'wrap'=>'char', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| TkScrollbar.new(f) {|s| command proc{|*args| t.yview(*args)} t.yscrollcommand proc{|first,last| s.set first,last} @@ -53,16 +53,16 @@ TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2, # ¥¿¥°À¸À® $tag2_center = TkTextTag.new($twind2_text, - 'justify' =>'center', - 'spacing1'=>'5m', - 'spacing3'=>'5m' ) + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) $tag2_buttons = TkTextTag.new($twind2_text, - 'lmargin1'=>'1c', - 'lmargin2'=>'1c', - 'rmargin' =>'1c', - 'spacing1'=>'3m', - 'spacing2'=>0, - 'spacing3'=>0 ) + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) # ¥Æ¥¥¹¥È¤ÎÀ¸À® $twind2_text.insert('end', '¥Æ¥¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë¤Ï¿§¡¹¤Ê¼ïÎà¤Î¥¢¥¤¥Æ¥à') @@ -84,41 +84,41 @@ $twind2_text.insert('end', '¥Ü¥¿¥ó¥¦¥£¥¸¥§¥Ã¥È¤¬Ëä¤á¹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£') $twind2_text.insert('end', 'ºÇ½é¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢') $twind2_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò ') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - #text 'ON' - text '¥ª¥ó' - command proc{textWindOn2 $twind2_text,$twind2_buttons} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + #text 'ON' + text '¥ª¥ó' + command proc{textWindOn2 $twind2_text,$twind2_buttons} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', "¤Ë¤·¤Þ¤¹¡£¤Þ¤¿¡¢£²¤Ä¤á¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È\n") $twind2_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - #text 'OFF' - text '¥ª¥Õ' - command proc{textWindOff2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + #text 'OFF' + text '¥ª¥Õ' + command proc{textWindOff2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', "¤Ë¤·¤Þ¤¹¡£\n\n") $twind2_text.insert('end', '¼¡¤Ï¤â¤¦¤Ò¤È¤Ä¤ÎÎã¤Ç¤¹¡£') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text '¤³¤³¤ò¥¯¥ê¥Ã¥¯' - command proc{textWindPlot2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text '¤³¤³¤ò¥¯¥ê¥Ã¥¯' + command proc{textWindPlot2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', '¤¹¤ë¤È¡¢x-y¥×¥í¥Ã¥È¤¬¤³¤³¤Ë¸½¤ì¤Þ¤¹¡£') $mark2_plot = TkTextMark.new($twind2_text, 'insert') $mark2_plot.gravity='left' $twind2_text.insert('end', '¥Þ¥¦¥¹¤Ç¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¡¢') $twind2_text.insert('end', '¥×¥í¥Ã¥È¾å¤Î¥Ç¡¼¥¿ÅÀ¤ò°ÜÆ°¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text '¾Ãµî' - command proc{textWindDel2 $twind2_text} - cursor 'top_left_arrow' - }) + 'window'=>TkButton.new($twind2_text) { + text '¾Ãµî' + command proc{textWindDel2 $twind2_text} + cursor 'top_left_arrow' + }) $twind2_text.insert('end', '¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£') $twind2_text.insert('end', "\n\n") @@ -146,18 +146,18 @@ btn_default = TkButton.new($twind2_text) {|b| TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3) embToggle = TkVariable.new('Short') TkTextWindow.new($twind2_text, 'end', - 'window'=>TkCheckButton.new($twind2_text) { - textvariable embToggle - indicatoron 0 - variable embToggle - onvalue 'A much longer string' - offvalue 'Short' - cursor 'top_left_arrow' - pady 5 - padx 2 - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkCheckButton.new($twind2_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) [ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', @@ -165,13 +165,13 @@ TkTextWindow.new($twind2_text, 'end', 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' ].each{|twind_color| TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text) { - text twind_color - cursor 'top_left_arrow' - command proc{$twind2_text.bg twind_color} - }, - 'padx'=>3, - 'pady'=>2 ) + 'window'=>TkButton.new($twind2_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind2_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) } $tag2_buttons.add(btn_default, 'end') @@ -185,55 +185,55 @@ $twind2_text.insert('end', "\nborder width ¤ä highlightthickness, ") $twind2_text.insert('end', "padding ¤òÄ̾ï¤ÎÃͤ«¤éÊѹ¹¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡£\n") TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big borders", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigB2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigB2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small borders", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallB2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallB2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big highlight", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigH2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigH2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small highlight", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallH2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallH2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Big pad", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinBigP2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Big pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigP2 $twind2_text + })) TkTextWindow.new($twind2_text, 'end', - 'window'=>TkButton.new($twind2_text, :text=>"Small pad", - :cursor=>'top_left_arrow', - 'command'=>proc{ - textWinSmallP2 $twind2_text - })) + 'window'=>TkButton.new($twind2_text, :text=>"Small pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallP2 $twind2_text + })) $twind2_text.insert('end', "\n\n¹¹¤Ë¥¤¥á¡¼¥¸¤â¥Æ¥¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë") $twind2_text.insert('end', "¤¦¤Þ¤¯ÇÛÃ֤Ǥ¤Þ¤¹¡§") TkTextImage.new($twind2_text, 'end', - 'image'=>TkBitmapImage.new(:file=>[ - $demo_dir, '..', - 'images', 'face.xbm' - ].join(File::Separator))) + 'image'=>TkBitmapImage.new(:file=>[ + $demo_dir, '..', + 'images', 'face.xbm' + ].join(File::Separator))) # ¥á¥½¥Ã¥ÉÄêµÁ def textWinBigB2(w) @@ -307,39 +307,39 @@ def textWindPlot2 (t) TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2) TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2) TkcText.new($twind2_plot, 225, 20, - 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') (0..10).each {|i| x = 100 + (i * 30) TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2) TkcText.new($twind2_plot, x, 254, - 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') } (0..5).each {|i| y = 250 - (i * 40) TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2) TkcText.new($twind2_plot, 96, y, - 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') } for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] x = 100 + (3*xx) y = 250 - (4*yy)/5 item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6, - 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') item.addtag 'point' end $twind2_plot.itembind('point', 'Any-Enter', - proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'}) + proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'}) $twind2_plot.itembind('point', 'Any-Leave', - proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) $twind2_plot.itembind('point', '1', - proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y") + proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y") $twind2_plot.itembind('point', 'ButtonRelease-1', - proc{$twind2_plot.dtag 'selected'}) + proc{$twind2_plot.dtag 'selected'}) $twind2_plot.bind('B1-Motion', - proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y") + proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y") while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/) $twind2_text.delete $mark2_plot end diff --git a/ext/tk/sample/demos-jp/unicodeout.rb b/ext/tk/sample/demos-jp/unicodeout.rb index 37cc1699b..090cdf305 100644 --- a/ext/tk/sample/demos-jp/unicodeout.rb +++ b/ext/tk/sample/demos-jp/unicodeout.rb @@ -17,8 +17,8 @@ $unicodeout_demo = TkToplevel.new {|w| } TkLabel.new($unicodeout_demo, - :font=>$font, :wraplength=>'5.4i', :justify=>:left, - :text=><<EOL).pack(:side=>:top) + :font=>$font, :wraplength=>'5.4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) ¤³¤ì¤Ï¡¤Tk¤Ë¤ª¤±¤ëÈó²¤ÊÆʸ»ú½¸¹ç¤òÍѤ¤¤ë¸À¸ì¤ËÂФ¹¤ë¥µ¥Ý¡¼¥È¤Ë¤Ä¤¤¤Æ¤Î\ ¥µ¥ó¥×¥ë¤Ç¤¹¡¥¤¿¤À¤·¡¤²¼¤Îɽ¼¨¤Ë¤ª¤¤¤Æ¤¢¤Ê¤¿¤¬¼ÂºÝ¤Ë¤É¤Î¤è¤¦¤Êɽ¼¨¤ò\ Ìܤˤ¹¤ë¤«¤Ï¡¤¤¢¤Ê¤¿¤Î´Ä¶¤Ë¤É¤Î¤è¤¦¤Êʸ»ú½¸¹ç¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤«¤Ë\ @@ -42,19 +42,19 @@ TkFrame.new($unicodeout_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{ - $unicodeout_demo.destroy - $unicodeout_demo = nil - }).pack(:side=>:left, :expand=>true) + $unicodeout_demo.destroy + $unicodeout_demo = nil + }).pack(:side=>:left, :expand=>true) TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{ - showCode 'unicodeout' - }).pack(:side=>:left, :expand=>true) + showCode 'unicodeout' + }).pack(:side=>:left, :expand=>true) } wait_msg = TkLabel.new($unicodeout_demo, - :text=>"¥Õ¥©¥ó¥ÈÆɤ߹þ¤ß¤Î´°Î»¤Þ¤Ç" + - "¤·¤Ð¤é¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡¥¡¥¡¥", - :font=>"Helvetica 12 italic").pack + :text=>"¥Õ¥©¥ó¥ÈÆɤ߹þ¤ß¤Î´°Î»¤Þ¤Ç" + + "¤·¤Ð¤é¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡¥¡¥¡¥", + :font=>"Helvetica 12 italic").pack class Unicodeout_SampleFrame < TkFrame @@font = $font @@ -74,10 +74,10 @@ class Unicodeout_SampleFrame < TkFrame def add_sample(lang, *args) sample_txt = Tk::UTF8_String(args.join('')) l = TkLabel.new(self, :font=>@@font, :text=>lang+':', - :anchor=>:nw, :pady=>0) + :anchor=>:nw, :pady=>0) #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt, s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt, - :anchor=>:nw, :width=>30, :pady=>0) + :anchor=>:nw, :width=>30, :pady=>0) Tk.grid(l, s, :sticky=>:ew, :pady=>0) l.grid_config(:padx, '1m') end @@ -93,23 +93,23 @@ $unicodeout_demo.cursor('watch') Tk.update f.add_sample('Arabic', - '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94', - '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D') + '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94', + '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D') f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57') f.add_sample('Simpl. Chinese', '\u6C49\u8BED') f.add_sample('Greek', - '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ', - '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1') + '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ', + '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1') f.add_sample('Hebrew', - '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ', - '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9') + '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ', + '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9') f.add_sample('Japanese', - '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ', - '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA') + '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ', + '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA') f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00') f.add_sample('Russian', - '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ', - '\u044F\u0437\u044B\u043A') + '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ', + '\u044F\u0437\u044B\u043A') wait_msg.destroy $unicodeout_demo.cursor(oldCursor) diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 0544127cb..e8196aec8 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -28,10 +28,10 @@ when /^4.*/ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) knjfont = '-*--16-*-jisx0208.1983-0' $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - knjfont) + knjfont) TkOption.add('*kanjiFont', knjfont, 'startupFile') $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - '-*--24-*-jisx0208.1983-0') + '-*--24-*-jisx0208.1983-0') #when '8.0' # $font = TkFont.new('Helvetica -12') @@ -49,10 +49,10 @@ else $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) knjfont = '-*--16-*-jisx0208.1983-0' $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - knjfont) + knjfont) TkOption.add('*kanjiFont', knjfont, 'startupFile') $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - '-*--24-*-jisx0208.1983-0') + '-*--24-*-jisx0208.1983-0') end ####### @@ -117,11 +117,11 @@ end # ¥á¥Ë¥å¡¼ÀßÄê TkMenubar.new($root, - [[['File', 0], - ['About ... ', proc{aboutBox}, 0, '<F1>'], - '---', - ['Quit', proc{exit}, 0, 'Meta-Q'] - ]]).pack('side'=>'top', 'fill'=>'x') + [[['File', 0], + ['About ... ', proc{aboutBox}, 0, '<F1>'], + '---', + ['Quit', proc{exit}, 0, 'Meta-Q'] + ]]).pack('side'=>'top', 'fill'=>'x') $root.bind('F1', proc{aboutBox}) $root.bind('Meta-q', proc{exit}) @@ -156,7 +156,7 @@ if $tk_version =~ /^4\.[01]/ else textFrame = TkFrame.new($root) scr = TkScrollbar.new($root, 'orient'=>'vertical', - 'highlightthickness'=>0, 'takefocus'=>1) { + 'highlightthickness'=>0, 'takefocus'=>1) { pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1) } txt = TkText.new($root) { @@ -182,10 +182,10 @@ else statusBar = TkFrame.new($root) {|f| $statusBarLabel = \ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ + 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ + 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \ .pack('side'=>'left', 'padx'=>2) }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) end @@ -200,53 +200,53 @@ tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c') if TkWinfo.depth($root) == 1 tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'underline'=>1) + 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'underline'=>1) + 'underline'=>1) tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white') else tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'foreground'=>'blue', 'underline'=>1) + 'foreground'=>'blue', 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', - 'foreground'=>'#303080', 'underline'=>1) + 'foreground'=>'#303080', 'underline'=>1) # tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1, -# 'background'=>'SeaGreen3') +# 'background'=>'SeaGreen3') tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red') end #tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')}) tag_demo.bind('ButtonRelease-1', - proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y') + proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y') lastLine = TkVariable.new("") newLine = TkVariable.new("") tag_demo.bind('Enter', proc{|x,y| - lastLine.value = txt.index("@#{x},#{y} linestart") - tag_hot.add(lastLine.value, "#{lastLine.value} lineend") - showStatus txt, txt.index("@#{x},#{y}") - }, - '%x %y') + lastLine.value = txt.index("@#{x},#{y} linestart") + tag_hot.add(lastLine.value, "#{lastLine.value} lineend") + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') tag_demo.bind('Leave', - proc{ - tag_hot.remove('1.0','end') - txt.configure('cursor','xterm') - $statusBarLabel.configure('text'=>"") - }) + proc{ + tag_hot.remove('1.0','end') + txt.configure('cursor','xterm') + $statusBarLabel.configure('text'=>"") + }) tag_demo.bind('Motion', proc{|x, y| - newLine.value = txt.index("@#{x},#{y} linestart") - if newLine.value != lastLine.value - tag_hot.remove('1.0','end') - lastLine.value = newLine.value - if ( txt.tag_names("@#{x},#{y}").find{|t| - t.kind_of?(String) && t =~ /^demo-/ - } ) - tag_hot.add(lastLine.value, - "#{lastLine.value} lineend -1 chars") - end - end - showStatus txt, txt.index("@#{x},#{y}") - }, - '%x %y') + newLine.value = txt.index("@#{x},#{y} linestart") + if newLine.value != lastLine.value + tag_hot.remove('1.0','end') + lastLine.value = newLine.value + if ( txt.tag_names("@#{x},#{y}").find{|t| + t.kind_of?(String) && t =~ /^demo-/ + } ) + tag_hot.add(lastLine.value, + "#{lastLine.value} lineend -1 chars") + end + end + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') # ¥Æ¥¥¹¥ÈÀ¸À® txt.insert('end', 'Ruby/Tk : Widget', tag_title) @@ -276,47 +276,47 @@ EOT #txt.insert('end',"¥é¥Ù¥ë, ¥Ü¥¿¥ó, ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó, ¥é¥¸¥ª¥Ü¥¿¥ó\n",tag_middle) txt.insert('end', "¥é¥Ù¥ë, ¥Ü¥¿¥ó, ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó, ¥é¥¸¥ª¥Ü¥¿¥ó\n", - tag_kanji_title) + tag_kanji_title) txt.insert('end', " \n ", tag_demospace) txt.insert('end', "1. ¥é¥Ù¥ë (¥Æ¥¥¹¥È, ¥Ó¥Ã¥È¥Þ¥Ã¥×)\n", - tag_demo, "demo-label") + tag_demo, "demo-label") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¥é¥Ù¥ë¤ÈUNICODE¥Æ¥¥¹¥È (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", tag_demo, "demo-unicodeout") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ¥Ü¥¿¥ó \n", tag_demo, "demo-button") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó (Ê£¿ô¤òÁªÂò²Äǽ)\n", - tag_demo, "demo-check") + tag_demo, "demo-check") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "5. £³¾õÂÖ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-check2") + tag_demo, "demo-check2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "6. ¥é¥¸¥ª¥Ü¥¿¥ó (Ǥ°Õ¤Î°ì¤Ä¤òÁªÂò²Äǽ)\n", - tag_demo, "demo-radio") + tag_demo, "demo-radio") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "7. ¥é¥¸¥ª¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-radio2") + tag_demo, "demo-radio2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "8. £³¾õÂ֥饸¥ª¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-radio3") + tag_demo, "demo-radio3") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "9. ¥Ü¥¿¥ó¤Çºî¤é¤ì¤¿15-¥Ñ¥º¥ë¥²¡¼¥à\n", - tag_demo, "demo-puzzle") + tag_demo, "demo-puzzle") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "10. ¥Ó¥Ã¥È¥Þ¥Ã¥×¤ò»ÈÍѤ·¤¿¥¢¥¤¥³¥ó¥Ü¥¿¥ó\n", - tag_demo, "demo-icon") + tag_demo, "demo-icon") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "11. ²èÁü¤òɽ¼¨¤¹¤ëÆó¤Ä¤Î¥é¥Ù¥ë\n", - tag_demo, "demo-image1") + tag_demo, "demo-image1") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "12. ²èÁü¤ò¸«¤ë¤¿¤á¤Î´Êñ¤Ê¥æ¡¼¥¶¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹\n", - tag_demo, "demo-image2") + tag_demo, "demo-image2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "13. ²èÁü¤ò¸«¤ë¤¿¤á¤Î´Êñ¤Ê¥æ¡¼¥¶¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-image3") + tag_demo, "demo-image3") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "14. ¥é¥Ù¥ëÉÕ¤¥Õ¥ì¡¼¥à (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-labelframe") + tag_demo, "demo-labelframe") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -326,7 +326,7 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "1. ÅÔÆ»Éܸ©.\n", tag_demo, "demo-states") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¿§: ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¤¿¤á¤ÎÇÛ¿§¤òÊѤ¨¤ë\n", - "#{tag_demo.id} demo-colors") + "#{tag_demo.id} demo-colors") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ³Ê¸À½¸\n", tag_demo, "demo-sayings") txt.insert('end', " \n ", tag_demospace) @@ -340,10 +340,10 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤¢¤ê\n", tag_demo, "demo-entry2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ǧ¾Ú½èÍýÉÕ¤¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤È¥Ñ¥¹¥ï¡¼¥É¥Õ¥£¡¼¥ë¥É (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-entry3") + tag_demo, "demo-entry3") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. ¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-spin") + tag_demo, "demo-spin") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "5. ´Êñ¤Ê¥Õ¥©¡¼¥à\n", tag_demo, "demo-form") txt.insert('end', " \n ", tag_demospace) @@ -357,13 +357,13 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ɽ¼¨¥¹¥¿¥¤¥ë.\n", tag_demo, "demo-style") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ¥Ï¥¤¥Ñ¡¼¥Æ¥¥¹¥È(¥¿¥°¥Ð¥¤¥ó¥É).\n", - tag_demo, "demo-bind") + tag_demo, "demo-bind") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. ¥¦¥£¥ó¥É¥¦¤òËä¤á¹þ¤ó¤À¥Æ¥¥¹¥È\n", - tag_demo, "demo-twind") + tag_demo, "demo-twind") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "5. ¥¦¥£¥ó¥É¥¦¤òËä¤á¹þ¤ó¤À¥Æ¥¥¹¥È (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-twind2") + tag_demo, "demo-twind2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "6. ¸¡º÷\n", tag_demo, "demo-search") txt.insert('end', " \n ", tag_demospace) @@ -387,7 +387,7 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "7. ¥Õ¥í¥¢¥×¥é¥ó (°Û¤Ê¤ë¥¥ã¥ó¥Ð¥¹¥¢¥¤¥Æ¥àºîÀ®ÊýË¡¤ò»ÈÍÑ)\n", tag_demo, "demo-floor2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "8. ¥¹¥¯¥í¡¼¥ë²Äǽ¤Ê¥¥ã¥ó¥Ð¥¹\n", - tag_demo, "demo-cscroll") + tag_demo, "demo-cscroll") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -403,10 +403,10 @@ txt.insert('end', "\n") txt.insert('end', "¥Ú¥¤¥ó¥É¥¦¥£¥ó¥É¥¦\n", tag_kanji_title) txt.insert('end', " \n ", tag_demospace) txt.insert('end', "1. ¿åÊ¿Êý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo.id, "demo-paned1") + tag_demo.id, "demo-paned1") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¿âľÊý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo.id, "demo-paned2") + tag_demo.id, "demo-paned2") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -414,16 +414,16 @@ txt.insert('end', "\n") txt.insert('end', "¥á¥Ë¥å¡¼\n", tag_kanji_title) txt.insert('end', " \n ", tag_demospace) txt.insert('end', "1. ¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¤ò´Þ¤ó¤À¥¦¥£¥ó¥É¥¦\n", - tag_demo, "demo-menu") + tag_demo, "demo-menu") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¤ò´Þ¤ó¤À¥¦¥£¥ó¥É¥¦ (Tk8.x ÀìÍÑ)\n", - tag_demo, "demo-menu8x") + tag_demo, "demo-menu8x") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ¡· (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", - tag_demo, "demo-menu84") + tag_demo, "demo-menu84") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. ¥á¥Ë¥å¡¼¥Ü¥¿¥ó (Tk8.x ÀìÍÑ)\n", - tag_demo, "demo-menubu") + tag_demo, "demo-menubu") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -444,10 +444,10 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "1. ÁȤ߹þ¤ß¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×\n", tag_demo, "demo-bitmap") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "2. ¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°(¥í¡¼¥«¥ë¥°¥é¥Ö)\n", - tag_demo, "demo-dialog1") + tag_demo, "demo-dialog1") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "3. ¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°(¥°¥í¡¼¥Ð¥ë¥°¥é¥Ö)\n", - tag_demo, "demo-dialog2") + tag_demo, "demo-dialog2") txt.insert('end', " \n ", tag_demospace) txt.state('disabled') @@ -483,10 +483,10 @@ def showVars1(parent, *args) } args.each{|vnam,vbody| TkFrame.new(w){|f| - #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left') - TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left') - TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\ - .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') + #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left') + TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left') + TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\ + .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x') } TkButton.new(w) { @@ -508,11 +508,11 @@ def showVars2(parent, *args) title "Variable values" TkLabelFrame.new(w, :text=>"ÊÑ¿ôÃÍ:", - :font=>{:family=>'Helvetica', :size=>14}){|f| + :font=>{:family=>'Helvetica', :size=>14}){|f| args.each{|vnam,vbody| - TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), - TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), - :padx=>2, :pady=>2, :sticky=>'w') + TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), + TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), + :padx=>2, :pady=>2, :sticky=>'w') } f.grid(:sticky=>'news', :padx=>4) @@ -520,7 +520,7 @@ def showVars2(parent, *args) f.grid_rowconfig(100, :weight=>1) } TkButton.new(w, :text=>"λ²ò", :width=>8, :default=>:active, - :command=>proc{w.destroy}){|b| + :command=>proc{w.destroy}){|b| w.bind('Return', proc{b.invoke}) w.bind('Escape', proc{b.invoke}) @@ -566,7 +566,7 @@ def showStatus (txt, index) else demoname = tag[5..-1] $statusBarLabel.configure('text', - "¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à \"#{demoname}\" ¤Î¼Â¹Ô ") + "¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à \"#{demoname}\" ¤Î¼Â¹Ô ") newcursor = 'hand2' end txt.configure('cursor'=>newcursor) if cursor != newcursor @@ -583,8 +583,8 @@ def showCode1(demo) #text "λ²ò" text "ÊĤ¸¤ë" command proc{ - $code_window.destroy - $code_window = nil + $code_window.destroy + $code_window = nil } }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2) TkButton.new(f) { @@ -597,43 +597,43 @@ def showCode1(demo) if $tk_version =~ /^4\.[01]/ s = TkScrollbar.new($code_window, 'orient'=>'vertical') $code_text = TkText.new($code_window) { - height 40 - setgrid 'yes' - yscrollcommand proc{|first,last| s.set first,last} + height 40 + setgrid 'yes' + yscrollcommand proc{|first,last| s.set first,last} } s.command(proc{|*args| $code_text.yview(*args)}) s.pack('side'=>'right', 'fill'=>'y') $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both') else TkFrame.new($code_window) {|f| - pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) - - hs = TkScrollbar.new($code_window, 'highlightthickness'=>0, - 'orient'=>'horizontal') - vs = TkScrollbar.new($code_window, 'highlightthickness'=>0, - 'orient'=>'vertical') - $code_text = TkText.new($code_window) {|t| - height 40 - #wrap 'word' - wrap 'char' - xscrollcommand proc{|first,last| hs.set first,last} - yscrollcommand proc{|first,last| vs.set first,last} - setgrid 'yes' - highlightthickness 0 - pady 2 - padx 3 - hs.command(proc{|*args| $code_text.xview(*args)}) - vs.command(proc{|*args| $code_text.yview(*args)}) - } - - $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') - vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, - 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') -# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, -# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') - TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) - TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + + hs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'horizontal') + vs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'vertical') + $code_text = TkText.new($code_window) {|t| + height 40 + #wrap 'word' + wrap 'char' + xscrollcommand proc{|first,last| hs.set first,last} + yscrollcommand proc{|first,last| vs.set first,last} + setgrid 'yes' + highlightthickness 0 + pady 2 + padx 3 + hs.command(proc{|*args| $code_text.xview(*args)}) + vs.command(proc{|*args| $code_text.yview(*args)}) + } + + $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') +# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, +# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) } end else @@ -660,8 +660,8 @@ def showCode2(demo) $code_window = TkToplevel.new(nil) tf = TkFrame.new($code_window) $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30, - :wrap=>'word', :bd=>1, :setgrid=>true, - :highlightthickness=>0, :pady=>2, :padx=>3) + :wrap=>'word', :bd=>1, :setgrid=>true, + :highlightthickness=>0, :pady=>2, :padx=>3) xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} TkGrid($code_text, yscr, :sticky=>'news') @@ -673,17 +673,17 @@ def showCode2(demo) #b_dis = TkButton.new(bf, :text=>'λ²ò', :default=>:active, b_dis = TkButton.new(bf, :text=>'ÊĤ¸¤ë', :default=>:active, - :command=>proc{ - $code_window.destroy - $code_window = nil - }, - :image=>$image['delete'], :compound=>:left) + :command=>proc{ + $code_window.destroy + $code_window = nil + }, + :image=>$image['delete'], :compound=>:left) b_prn = TkButton.new(bf, :text=>'°õºþ', - :command=>proc{printCode($code_text, file)}, - :image=>$image['print'], :compound=>:left) + :command=>proc{printCode($code_text, file)}, + :image=>$image['print'], :compound=>:left) b_run = TkButton.new(bf, :text=>'ºÆ¼Â¹Ô', - :command=>proc{eval($code_text.get('1.0','end'))}, - :image=>$image['refresh'], :compound=>:left) + :command=>proc{eval($code_text.get('1.0','end'))}, + :image=>$image['refresh'], :compound=>:left) TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4]) bf.grid_columnconfigure(0, :weight=>1) @@ -694,8 +694,8 @@ def showCode2(demo) $code_window.grid_rowconfigure(0, :weight=>1) $code_window.bind('Return', proc{|win| - b_dis.invoke unless win.kind_of?(TkText) - }, '%W') + b_dis.invoke unless win.kind_of?(TkText) + }, '%W') $code_window.bindinfo('Return').each{|cmd, arg| $code_window.bind_append('Escape', cmd, arg) } @@ -727,8 +727,8 @@ end # Much thanks to Arjen Markus for this. # # Arguments: -# txt - Name of text widget containing code to print -# file - Name of the original file (implicitly for title) +# txt - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) def printCode(txt, file) code = txt.get('1.0', 'end - 1c') @@ -744,27 +744,27 @@ def printCode(txt, file) when 'unix' msg = `lp -c #{fname}` unless $?.exitstatus == 0 - Tk.messageBox(:title=>'Print spooling failure', - :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' + - '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' + msg) + Tk.messageBox(:title=>'Print spooling failure', + :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' + + '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' + msg) end when 'windows' begin - printTextWin32(fname) + printTextWin32(fname) rescue => e - Tk.messageBox(:title=>'Print spooling failure', - :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' + - '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' + - e.message) + Tk.messageBox(:title=>'Print spooling failure', + :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' + + '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' + + e.message) end when 'macintosh' Tk.messageBox(:title=>'Operation not Implemented', - :message=>'°õºþµ¡Ç½¤Ï¤Þ¤À¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó') + :message=>'°õºþµ¡Ç½¤Ï¤Þ¤À¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó') else Tk.messageBox(:title=>'Operation not Implemented', - :message=>'¸¡½Ð¤µ¤ì¤¿´Ä¶ ' + - Tk::TCL_PLATFORM('platform') + - ' ¤Ï̤ÃΤδĶ¤Ç¤¢¤ë¤¿¤á¡¤' + + :message=>'¸¡½Ð¤µ¤ì¤¿´Ä¶ ' + + Tk::TCL_PLATFORM('platform') + + ' ¤Ï̤ÃΤδĶ¤Ç¤¢¤ë¤¿¤á¡¤' + '°õºþµ¡Ç½¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó: ') end ensure @@ -776,7 +776,7 @@ end # Print a file under Windows # # Arguments: -# filename - Name of the file +# filename - Name of the file # def printTextWin32(fname) require 'win32/registry' @@ -807,12 +807,12 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk ¥¦¥£¥¸¥§¥Ã¥È¥Ç¥â Ver.1.4.3-jp\n\n" + + 'message'=>"Ruby/Tk ¥¦¥£¥¸¥§¥Ã¥È¥Ç¥â Ver.1.4.3-jp\n\n" + "based on demos of Tk8.1 -- 8.5 " + - "( Copyright:: " + - "(c) 1996-1997 Sun Microsystems, Inc. / " + + "( Copyright:: " + + "(c) 1996-1997 Sun Microsystems, Inc. / " + "(c) 1997-2000 Ajuba Solutions, Inc. / " + - "(c) 2001-2003 Donal K. Fellows )\n\n" + + "(c) 2001-2003 Donal K. Fellows )\n\n" + "Your Ruby & Tk Version ::\n" + "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}") end @@ -836,7 +836,7 @@ if no_launcher loop do count = 0 $root.winfo_children.each{|w| - count += 1 if w.kind_of?(TkToplevel) + count += 1 if w.kind_of?(TkToplevel) } $root.destroy if count == 0 end diff --git a/ext/tk/sample/encstr_usage.rb b/ext/tk/sample/encstr_usage.rb index 2155544c6..4285ec861 100644 --- a/ext/tk/sample/encstr_usage.rb +++ b/ext/tk/sample/encstr_usage.rb @@ -14,12 +14,12 @@ t3 = TkText.new(:height=>5).pack src_str = IO.readlines('iso2022-kr.txt').join t1.insert('end', - "use neither Tk::EncodedString class nor Tk.encoding= method\n\n") + "use neither Tk::EncodedString class nor Tk.encoding= method\n\n") t1.insert('end', src_str) enc_str = Tk::EncodedString(src_str, 'iso2022-kr') t2.insert('end', - "use Tk::EncodedString class (Tk.encoding => '#{Tk.encoding}')\n\n") + "use Tk::EncodedString class (Tk.encoding => '#{Tk.encoding}')\n\n") t2.insert('end', enc_str) Tk.encoding = 'iso2022-kr' diff --git a/ext/tk/sample/menubar2.rb b/ext/tk/sample/menubar2.rb index 6ca58e45a..4507d8b2f 100644 --- a/ext/tk/sample/menubar2.rb +++ b/ext/tk/sample/menubar2.rb @@ -40,11 +40,11 @@ menu_spec = [ ] mbar = Tk.root.add_menubar(menu_spec, - # followings are default configure options - 'tearoff'=>'false', - 'foreground'=>'grey40', - 'activeforeground'=>'red', - 'font'=>'Helvetia 12 bold') + # followings are default configure options + 'tearoff'=>'false', + 'foreground'=>'grey40', + 'activeforeground'=>'red', + 'font'=>'Helvetia 12 bold') # This (default configure options) is NOT same the following. # # mbar = Tk.root.add_menubar(menu_spec) diff --git a/ext/tk/sample/msgs_rb/ru.msg b/ext/tk/sample/msgs_rb/ru.msg index d6739ceb5..f389dff0b 100644 --- a/ext/tk/sample/msgs_rb/ru.msg +++ b/ext/tk/sample/msgs_rb/ru.msg @@ -20,7 +20,7 @@ TkMsgCatalog.new('::tk') { ru '&Blue', ' &\u0413\u043e\u043b\u0443\u0431\u043e\u0439' ru '&Cancel', '\u041e\u0442&\u043c\u0435\u043d\u0430' ru 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.' \ - '\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 "%1\$s".' "\n" '\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430' + '\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 "%1\$s".' "\n" '\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430' ru 'Choose Directory', '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433' ru 'Clear', '\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c' ru 'Color', '\u0426\u0432\u0435\u0442' @@ -34,7 +34,7 @@ TkMsgCatalog.new('::tk') { ru 'Error: %1\$s', '\u041e\u0448\u0438\u0431\u043a\u0430: %1\$s' ru 'Exit', '\u0412\u044b\u0445\u043e\u0434' ru 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?' \ - '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n" '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?' + '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n" '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?' ru 'File "%1\$s" already exists.' "\n\n", '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n\n" ru 'File "%1\$s" does not exist.', '\u0424\u0430\u0439\u043b "%1\$s" \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.' ru 'File &name:', '&\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430:' diff --git a/ext/tk/sample/multi-ip_sample.rb b/ext/tk/sample/multi-ip_sample.rb index 2bb20db4c..8d6e1bc62 100644 --- a/ext/tk/sample/multi-ip_sample.rb +++ b/ext/tk/sample/multi-ip_sample.rb @@ -86,17 +86,17 @@ TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start TkTimer.new(2000, -1, proc{p ['trusted', trusted_slave.deleted?]}).start TkTimer.new(5000, 1, - proc{ - safe_slave1.eval_proc{Tk.root.destroy} - safe_slave1.delete - print "*** The safe_slave1 is deleted by the timer.\n" - }).start + proc{ + safe_slave1.eval_proc{Tk.root.destroy} + safe_slave1.delete + print "*** The safe_slave1 is deleted by the timer.\n" + }).start TkTimer.new(10000, 1, - proc{ - trusted_slave.eval_proc{Tk.root.destroy} - trusted_slave.delete - print "*** The trusted_slave is deleted by the timer.\n" - }).start + proc{ + trusted_slave.eval_proc{Tk.root.destroy} + trusted_slave.delete + print "*** The trusted_slave is deleted by the timer.\n" + }).start Tk.mainloop diff --git a/ext/tk/sample/multi-ip_sample2.rb b/ext/tk/sample/multi-ip_sample2.rb index e5e3c2920..f4a45d8d9 100644 --- a/ext/tk/sample/multi-ip_sample2.rb +++ b/ext/tk/sample/multi-ip_sample2.rb @@ -15,7 +15,7 @@ cmd = proc{|s| TkButton.new(:text=>'b2: p $SAFE', :command=>proc{p $SAFE}).pack(:fill=>:x) sleep s TkButton.new(:text=>'b3: p MultiTkIp.ip_name', - :command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x) + :command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x) sleep s TkButton.new(:text=>'EXIT', :command=>proc{exit}).pack(:fill=>:x) diff --git a/ext/tk/sample/optobj_sample.rb b/ext/tk/sample/optobj_sample.rb index b7bab0632..cafacbdd1 100644 --- a/ext/tk/sample/optobj_sample.rb +++ b/ext/tk/sample/optobj_sample.rb @@ -13,13 +13,13 @@ b2 = TkButton.new(f, :text=>'BBB').pack(:fill=>:x) b3 = TkButton.new(f, :text=>'CCC').pack(:fill=>:x) optobj.assign( b1, - [ b2, 'configure', - { 'foreground'=>'background', - 'background'=>'foreground' } ], - [ b3, nil, - { 'foreground'=>'background', - 'activeforeground'=>nil, - 'background'=>['foreground', 'activeforeground'] } ] ) + [ b2, 'configure', + { 'foreground'=>'background', + 'background'=>'foreground' } ], + [ b3, nil, + { 'foreground'=>'background', + 'activeforeground'=>nil, + 'background'=>['foreground', 'activeforeground'] } ] ) optobj.update('activeforeground'=>'yellow') @@ -30,9 +30,9 @@ TkButton.new(f){ TkButton.new(f){ configure( optobj.assign([self, nil, - {'foreground'=>'activeforeground', - 'background'=>'foreground', - 'activeforeground'=>'background'}]) \ + {'foreground'=>'activeforeground', + 'background'=>'foreground', + 'activeforeground'=>'background'}]) \ + {:text=>'EEE', :relief=>:groove, :borderwidth=>5} ) pack(:fill=>:x) } diff --git a/ext/tk/sample/propagate.rb b/ext/tk/sample/propagate.rb index a6fbc9725..800cef553 100644 --- a/ext/tk/sample/propagate.rb +++ b/ext/tk/sample/propagate.rb @@ -4,7 +4,7 @@ require 'tk' TkLabel.new(:text=>"Please click the bottom frame").pack f = TkFrame.new(:width=>400, :height=>100, :background=>'yellow', - :relief=>'ridge', :borderwidth=>5).pack + :relief=>'ridge', :borderwidth=>5).pack # TkPack.propagate(f, false) # <== important!! f.pack_propagate(false) # <== important!! @@ -21,10 +21,10 @@ list = (1..3).collect{|n| list.unshift(nil) f.bind('1', proc{ - w = list.shift - w.unpack if w - list.push(w) - list[0].pack(:expand=>true, :anchor=>:center) if list[0] + w = list.shift + w.unpack if w + list.push(w) + list[0].pack(:expand=>true, :anchor=>:center) if list[0] }) Tk.mainloop diff --git a/ext/tk/sample/remote-ip_sample.rb b/ext/tk/sample/remote-ip_sample.rb index 3c153e94f..3696a2085 100644 --- a/ext/tk/sample/remote-ip_sample.rb +++ b/ext/tk/sample/remote-ip_sample.rb @@ -28,6 +28,6 @@ end ip.eval_proc{TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)} TkButton.new(:command=>proc{exit}, :text=>'QUIT', - :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7) + :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7) Tk.mainloop diff --git a/ext/tk/sample/remote-ip_sample2.rb b/ext/tk/sample/remote-ip_sample2.rb index cc7f42448..e12b2a96c 100644 --- a/ext/tk/sample/remote-ip_sample2.rb +++ b/ext/tk/sample/remote-ip_sample2.rb @@ -19,14 +19,14 @@ btns = [] ip.eval_proc{ btns << TkButton.new(:command=>proc{ - puts 'This procesure is on the controller-ip (Ruby-side)' - }, - :text=>'print on controller-ip (Ruby-side)').pack(:fill=>:x) + puts 'This procesure is on the controller-ip (Ruby-side)' + }, + :text=>'print on controller-ip (Ruby-side)').pack(:fill=>:x) btns << TkButton.new(:command=> - 'puts {This procesure is on the remote-ip (Tk-side)}', - :text=>'print on remote-ip (Tk-side)').pack(:fill=>:x) + 'puts {This procesure is on the remote-ip (Tk-side)}', + :text=>'print on remote-ip (Tk-side)').pack(:fill=>:x) btns << TkButton.new(:command=> @@ -34,7 +34,7 @@ ip.eval_proc{ puts "This procedure is on the remote-ip (Ruby-side)" p Array.new(3,"ruby") }', - :text=>'ruby cmd on the remote-ip').pack(:fill=>:x) + :text=>'ruby cmd on the remote-ip').pack(:fill=>:x) TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x) } @@ -45,12 +45,12 @@ btns.each_with_index{|btn, idx| # the enternal. If you want to pass local values to the eval-block, # use arguments of eval_proc method. They are passed to block-arguments. TkButton.new(:command=>proc{ip.eval_proc(btn){|b| b.flash}}, - :text=>"flash button-#{idx}", - :padx=>10).pack(:padx=>10, :pady=>2) + :text=>"flash button-#{idx}", + :padx=>10).pack(:padx=>10, :pady=>2) } TkButton.new(:command=>proc{exit}, :text=>'QUIT', - :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7) + :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7) # start eventloop Tk.mainloop diff --git a/ext/tk/sample/safe-tk.rb b/ext/tk/sample/safe-tk.rb index 48d9a6bfc..e2289697e 100644 --- a/ext/tk/sample/safe-tk.rb +++ b/ext/tk/sample/safe-tk.rb @@ -8,8 +8,8 @@ require "multi-tk" TkLabel.new(:text=>'This is the Default Master Ipnterpreter').pack(:padx=>5, :pady=>3) TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack(:pady=>3) TkFrame.new(:borderwidth=>2, :height=>3, - :relief=>:sunken).pack(:fill=>:x, :expand=>true, - :padx=>10, :pady=>7) + :relief=>:sunken).pack(:fill=>:x, :expand=>true, + :padx=>10, :pady=>7) ############################### @@ -20,17 +20,17 @@ puts "\n---- create procs ----------" puts 'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}' x = proc{p ['proc x', "$SAFE==#{$SAFE}"]; exit} TkLabel.new(:text=>'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}', - :anchor=>:w).pack(:fill=>:x) + :anchor=>:w).pack(:fill=>:x) puts 'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}' y = proc{|label| p ['proc y', "$SAFE==#{$SAFE}", label]; label.text($SAFE)} TkLabel.new(:text=>'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}', - :anchor=>:w).pack(:fill=>:x) + :anchor=>:w).pack(:fill=>:x) puts 'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}' z = proc{p ['proc z', "$SAFE==#{$SAFE}"]; exit} TkLabel.new(:text=>'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}', - :anchor=>:w).pack(:fill=>:x) + :anchor=>:w).pack(:fill=>:x) puts "\n---- call 1st eval_proc ----------" print 'lbl = ' @@ -43,13 +43,13 @@ p lbl = ip.eval_proc{ l = TkLabel.new(f).pack(:side=>:right) TkButton.new(:text=>':command=>proc{l.text($SAFE)}', - :command=>proc{l.text($SAFE)}).pack(:fill=>:x, :padx=>5) + :command=>proc{l.text($SAFE)}).pack(:fill=>:x, :padx=>5) TkButton.new(:text=>':command=>x', :command=>x).pack(:fill=>:x, :padx=>5) TkButton.new(:text=>':command=>proc{exit}', - :command=>proc{exit}).pack(:fill=>:x, :padx=>5) + :command=>proc{exit}).pack(:fill=>:x, :padx=>5) TkFrame.new(:borderwidth=>2, :height=>3, - :relief=>:sunken).pack(:fill=>:x, :expand=>true, - :padx=>10, :pady=>7) + :relief=>:sunken).pack(:fill=>:x, :expand=>true, + :padx=>10, :pady=>7) l # return the label widget } @@ -58,26 +58,26 @@ ip.safe_level = 3 puts "\n---- call 2nd eval_proc ----------" p ip.eval_proc(proc{ - TkLabel.new(:text=>"2nd eval_proc : $SAFE == #{$SAFE}").pack - f = TkFrame.new.pack - TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left) - l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right) - TkButton.new(:text=>':command=>proc{l.text($SAFE)}', - :command=>proc{l.text($SAFE)}).pack(:fill=>:x, - :padx=>5) - TkButton.new(:text=>':command=>proc{y.call(l)}', - :command=>proc{y.call(l)}).pack(:fill=>:x, - :padx=>5) - TkButton.new(:text=>':command=>proc{Thread.new(l, &y).value}', - :command=>proc{ - Thread.new(l, &y).value - }).pack(:fill=>:x, :padx=>5) - TkButton.new(:text=>':command=>proc{z.call}', - :command=>proc{z.call}).pack(:fill=>:x, :padx=>5) - TkFrame.new(:borderwidth=>2, :height=>3, - :relief=>:sunken).pack(:fill=>:x, :expand=>true, - :padx=>10, :pady=>7) - }) + TkLabel.new(:text=>"2nd eval_proc : $SAFE == #{$SAFE}").pack + f = TkFrame.new.pack + TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left) + l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right) + TkButton.new(:text=>':command=>proc{l.text($SAFE)}', + :command=>proc{l.text($SAFE)}).pack(:fill=>:x, + :padx=>5) + TkButton.new(:text=>':command=>proc{y.call(l)}', + :command=>proc{y.call(l)}).pack(:fill=>:x, + :padx=>5) + TkButton.new(:text=>':command=>proc{Thread.new(l, &y).value}', + :command=>proc{ + Thread.new(l, &y).value + }).pack(:fill=>:x, :padx=>5) + TkButton.new(:text=>':command=>proc{z.call}', + :command=>proc{z.call}).pack(:fill=>:x, :padx=>5) + TkFrame.new(:borderwidth=>2, :height=>3, + :relief=>:sunken).pack(:fill=>:x, :expand=>true, + :padx=>10, :pady=>7) + }) puts "\n---- call 1st and 2nd eval_str ----------" p bind = ip.eval_str(' @@ -92,10 +92,10 @@ p bind = ip.eval_str(' p ip.eval_str(" TkButton.new(:text=>':command=>proc{ l.text = $SAFE }', - :command=>proc{ l.text = $SAFE }).pack(:fill=>:x, :padx=>5) + :command=>proc{ l.text = $SAFE }).pack(:fill=>:x, :padx=>5) TkFrame.new(:borderwidth=>2, :height=>3, - :relief=>:sunken).pack(:fill=>:x, :expand=>true, - :padx=>10, :pady=>7) + :relief=>:sunken).pack(:fill=>:x, :expand=>true, + :padx=>10, :pady=>7) ", bind) puts "\n---- change the safe slave IP's safe-level ==> 4 ----------" @@ -107,7 +107,7 @@ p ip.eval_proc{ } p ip.eval_proc{ TkButton.new(:text=>':command=>proc{ lbl.text = $SAFE }', - :command=>proc{ lbl.text = $SAFE }).pack(:fill=>:x, :padx=>5) + :command=>proc{ lbl.text = $SAFE }).pack(:fill=>:x, :padx=>5) } puts "\n---- start event-loop ( current $SAFE == #{$SAFE} ) ----------" diff --git a/ext/tk/sample/tkalignbox.rb b/ext/tk/sample/tkalignbox.rb index b56c9cc11..32915a5e6 100644 --- a/ext/tk/sample/tkalignbox.rb +++ b/ext/tk/sample/tkalignbox.rb @@ -54,7 +54,7 @@ class TkAlignBox < TkFrame def add(*widgets) widgets.each{|w| unless w.kind_of? TkWindow - fail RuntimeError, "#{w.inspect} is not a widget instance." + fail RuntimeError, "#{w.inspect} is not a widget instance." end @widgets.delete(w) @widgets << w @@ -127,10 +127,10 @@ class TkHBox < TkAlignBox def _place_config(widget, idx, cnt) widget.place_in(self, - 'relx'=>idx/cnt, 'x'=>@padx, - 'rely'=>0, 'y'=>@pady, - 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, - 'relheight'=>1.0, 'height'=>-2*@pady) + 'relx'=>idx/cnt, 'x'=>@padx, + 'rely'=>0, 'y'=>@pady, + 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, + 'relheight'=>1.0, 'height'=>-2*@pady) end private :_place_config end @@ -139,10 +139,10 @@ TkHLBox = TkHBox class TkHRBox < TkHBox def _place_config(widget, idx, cnt) widget.place_in(self, - 'relx'=>(cnt - idx - 1)/cnt, 'x'=>@padx, - 'rely'=>0, 'y'=>@pady, - 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, - 'relheight'=>1.0, 'height'=>-2*@pady) + 'relx'=>(cnt - idx - 1)/cnt, 'x'=>@padx, + 'rely'=>0, 'y'=>@pady, + 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, + 'relheight'=>1.0, 'height'=>-2*@pady) end private :_place_config end @@ -157,10 +157,10 @@ class TkVBox < TkAlignBox def _place_config(widget, idx, cnt) widget.place_in(self, - 'relx'=>0, 'x'=>@padx, - 'rely'=>idx/cnt, 'y'=>@pady, - 'relwidth'=>1.0, 'width'=>-2*@padx, - 'relheight'=>1.0/cnt, 'height'=>-2*@pady) + 'relx'=>0, 'x'=>@padx, + 'rely'=>idx/cnt, 'y'=>@pady, + 'relwidth'=>1.0, 'width'=>-2*@padx, + 'relheight'=>1.0/cnt, 'height'=>-2*@pady) end private :_place_config end @@ -169,10 +169,10 @@ TkVTBox = TkVBox class TkVBBox < TkVBox def _place_config(widget, idx, cnt) widget.place_in(self, - 'relx'=>0, 'x'=>@padx, - 'rely'=>(cnt - idx - 1)/cnt, 'y'=>@pady, - 'relwidth'=>1.0, 'width'=>-2*@padx, - 'relheight'=>1.0/cnt, 'height'=>-2*@pady) + 'relx'=>0, 'x'=>@padx, + 'rely'=>(cnt - idx - 1)/cnt, 'y'=>@pady, + 'relwidth'=>1.0, 'width'=>-2*@padx, + 'relheight'=>1.0/cnt, 'height'=>-2*@pady) end private :_place_config end @@ -183,43 +183,43 @@ end if __FILE__ == $0 f = TkHBox.new(:borderwidth=>3, :relief=>'ridge').pack f.add(TkButton.new(f, :text=>'a'), - TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), - TkButton.new(f, :text=>'aaa'), - TkButton.new(f, :text=>'aaaa')) + TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), + TkButton.new(f, :text=>'aaa'), + TkButton.new(f, :text=>'aaaa')) f = TkHBox.new(:borderwidth=>3, :relief=>'ridge', - :padx=>7, :pady=>3, :background=>'yellow').pack + :padx=>7, :pady=>3, :background=>'yellow').pack f.add(TkButton.new(f, :text=>'a'), - TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), - TkButton.new(f, :text=>'aaa'), - TkButton.new(f, :text=>'aaaa')) + TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), + TkButton.new(f, :text=>'aaa'), + TkButton.new(f, :text=>'aaaa')) f = TkVBox.new(:borderwidth=>5, :relief=>'groove').pack f.add(TkButton.new(f, :text=>'a'), - TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'), - TkButton.new(f, :text=>'aaa'), - TkButton.new(f, :text=>'aaaa')) + TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'), + TkButton.new(f, :text=>'aaa'), + TkButton.new(f, :text=>'aaaa')) f = TkHRBox.new(:borderwidth=>3, :relief=>'raised').pack(:fill=>:x) f.add(TkButton.new(f, :text=>'a'), - TkButton.new(f, :text=>'aa'), - TkButton.new(f, :text=>'aaa')) + TkButton.new(f, :text=>'aa'), + TkButton.new(f, :text=>'aaa')) f = TkVBBox.new(:borderwidth=>3, :relief=>'ridge').pack(:fill=>:x) f.propagate = false f.height 100 f.add(TkFrame.new(f){|ff| - TkButton.new(ff, :text=>'a').pack(:pady=>4, :padx=>6, - :fill=>:both, :expand=>true) - }, - TkFrame.new(f){|ff| - TkButton.new(ff, :text=>'aa').pack(:pady=>4, :padx=>6, - :fill=>:both, :expand=>true) - }, - TkFrame.new(f){|ff| - TkButton.new(ff, :text=>'aaaa').pack(:pady=>4, :padx=>6, - :fill=>:both, :expand=>true) - }) + TkButton.new(ff, :text=>'a').pack(:pady=>4, :padx=>6, + :fill=>:both, :expand=>true) + }, + TkFrame.new(f){|ff| + TkButton.new(ff, :text=>'aa').pack(:pady=>4, :padx=>6, + :fill=>:both, :expand=>true) + }, + TkFrame.new(f){|ff| + TkButton.new(ff, :text=>'aaaa').pack(:pady=>4, :padx=>6, + :fill=>:both, :expand=>true) + }) Tk.mainloop end diff --git a/ext/tk/sample/tkballoonhelp.rb b/ext/tk/sample/tkballoonhelp.rb index b71c5746d..d66bc35a8 100644 --- a/ext/tk/sample/tkballoonhelp.rb +++ b/ext/tk/sample/tkballoonhelp.rb @@ -92,8 +92,8 @@ if __FILE__ == $0 TkButton.new('text'=>'This button has another balloon help') {|b| pack('fill'=>'x') TkBalloonHelp.new(b, 'text'=>'configured message', - 'interval'=>200, 'font'=>'courier', - 'background'=>'gray', 'foreground'=>'red') + 'interval'=>200, 'font'=>'courier', + 'background'=>'gray', 'foreground'=>'red') } Tk.mainloop end diff --git a/ext/tk/sample/tkbiff.rb b/ext/tk/sample/tkbiff.rb index e89644bd9..c6699629c 100644 --- a/ext/tk/sample/tkbiff.rb +++ b/ext/tk/sample/tkbiff.rb @@ -40,13 +40,13 @@ class Mail @body = [] while line = f.gets() line.chop! - next if /^From / =~ line # skip From-line - break if /^$/ =~ line # end of header + next if /^From / =~ line # skip From-line + break if /^$/ =~ line # end of header if /^(\S+):\s*(.*)/ =~ line - @header[attr = $1.capitalize] = $2 + @header[attr = $1.capitalize] = $2 elsif attr - sub(/^\s*/, '') - @header[attr] += "\n" + $_ + sub(/^\s*/, '') + @header[attr] += "\n" + $_ end end @@ -112,7 +112,7 @@ if defined? Thread loop do sleep 600 if Time.now - $check_time > 200 - Tk.after 5000, proc{check} + Tk.after 5000, proc{check} end end end diff --git a/ext/tk/sample/tkbrowse.rb b/ext/tk/sample/tkbrowse.rb index 7395688e9..4893f57f9 100644 --- a/ext/tk/sample/tkbrowse.rb +++ b/ext/tk/sample/tkbrowse.rb @@ -41,8 +41,8 @@ def browsedir (dir) list.bind "Double-Button-1", proc{ for i in TkSelection.get.split - print "clicked ", i, "\n" - browse dir, i + print "clicked ", i, "\n" + browse dir, i end } $dirlist[dir] = list @@ -56,9 +56,9 @@ def browse (dir, file) else if File.file? file if ENV['EDITOR'] - system format("%s %s&", ENV['EDITOR'], file) + system format("%s %s&", ENV['EDITOR'], file) else - system "xedit #{file}&" + system "xedit #{file}&" end else STDERR.print "\"#{file}\" isn't a directory or regular file" diff --git a/ext/tk/sample/tkcombobox.rb b/ext/tk/sample/tkcombobox.rb index 61ab25469..184027095 100644 --- a/ext/tk/sample/tkcombobox.rb +++ b/ext/tk/sample/tkcombobox.rb @@ -45,9 +45,9 @@ EOD @scr.command(proc{|*args| @lbox.yview(*args); _config_proc}) @up_arrow = TkLabel.new(@lbox, :image=>@@up_bmp, - :relief=>:raised, :borderwidth=>1) + :relief=>:raised, :borderwidth=>1) @down_arrow = TkLabel.new(@lbox, :image=>@@down_bmp, - :relief=>:raised, :borderwidth=>1) + :relief=>:raised, :borderwidth=>1) _init_binding @@ -198,10 +198,10 @@ EOD @lbox.bind('Configure', proc{_config_proc}) @lbox.bind('Enter', proc{|y| _set_sel(@lbox.nearest(y))}, '%y') @lbox.bind('Motion', proc{|y| - @up_timer.stop if @up_timer.running? - @down_timer.stop if @down_timer.running? - _check_sel(@lbox.nearest(y)) - }, '%y') + @up_timer.stop if @up_timer.running? + @down_timer.stop if @down_timer.running? + _check_sel(@lbox.nearest(y)) + }, '%y') @lbox.bind('Up', proc{_key_UP_proc}) @lbox.bind('Down', proc{_key_DOWN_proc}) @@ -267,7 +267,7 @@ EOD begin @var.tkwait if (idx = @var.to_i) >= 0 - @ent.value = @lst.get(idx) + @ent.value = @lst.get(idx) end @top.withdraw @btn.relief(:raised) @@ -275,8 +275,8 @@ EOD rescue ensure begin - @top.grab(:release) - @ent.focus + @top.grab(:release) + @ent.focus rescue end end @@ -299,8 +299,8 @@ EOD keys = _symbolkey2str(keys) @btn = TkLabel.new(@frame, :relief=>:raised, :borderwidth=>3, - :image=>@@down_btn_bmp).pack(:side=>:right, - :ipadx=>2, :fill=>:y) + :image=>@@down_btn_bmp).pack(:side=>:right, + :ipadx=>2, :fill=>:y) @ent = TkEntry.new(@frame).pack(:side=>:left) @path = @ent.path @@ -313,9 +313,9 @@ EOD startwait = keys.delete('startwait'){300} interval = keys.delete('interval'){150} @lst = TkAutoScrollbox.new(@top, - :startwait=>startwait, - :interval=>interval).pack(:fill=>:both, - :expand=>true) + :startwait=>startwait, + :interval=>interval).pack(:fill=>:both, + :expand=>true) @ent_list = [] @var = TkVariable.new @@ -397,8 +397,8 @@ end if __FILE__ == $0 v = TkVariable.new e = TkCombobox.new(:height=>7, :scrollbar=>true, :textvariable=>v, - :arrowrelief=>:flat, :arrowborderwidth=>0, - :startwait=>400, :interval=>200).pack + :arrowrelief=>:flat, :arrowborderwidth=>0, + :startwait=>400, :interval=>200).pack e.values(%w(aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu)) #e.see(e.list_index('end') - 2) e.value = 'cc' @@ -409,17 +409,17 @@ if __FILE__ == $0 }.pack TkFrame.new(:relief=>:raised, :borderwidth=>2, - :height=>3).pack(:fill=>:x, :expand=>true, :padx=>5, :pady=>3) + :height=>3).pack(:fill=>:x, :expand=>true, :padx=>5, :pady=>3) l = TkAutoScrollbox.new(nil, :relief=>:groove, :borderwidth=>4, - :width=>20).pack(:fill=>:both, :expand=>true) + :width=>20).pack(:fill=>:both, :expand=>true) (0..20).each{|i| l.insert('end', "line #{i}")} TkFrame.new(:relief=>:ridge, :borderwidth=>3){ TkButton.new(self, :text=>'ON', - :command=>proc{l.scrollbar(true)}).pack(:side=>:left) + :command=>proc{l.scrollbar(true)}).pack(:side=>:left) TkButton.new(self, :text=>'OFF', - :command=>proc{l.scrollbar(false)}).pack(:side=>:right) + :command=>proc{l.scrollbar(false)}).pack(:side=>:right) pack(:fill=>:x) } Tk.mainloop diff --git a/ext/tk/sample/tkextlib/ICONS/viewIcons.rb b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb index fa8741f41..fc88eb5c8 100644 --- a/ext/tk/sample/tkextlib/ICONS/viewIcons.rb +++ b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb @@ -28,17 +28,17 @@ class ViewIcons ent_groups = TkEntry.new(base, :width=>50, :textvariable=>@groups) btn_browse = TkButton.new(base, :text=>'Browse', - :command=>method(:select_icons)) + :command=>method(:select_icons)) btn_view = TkButton.new(base, :text=>'View', - :command=>method(:display_icons)) + :command=>method(:display_icons)) btn_exit = TkButton.new(base, :text=>'Exit', :command=>proc{exit}) @column_btns = {} 6.step(20, 2){|i| @column_btns[i] = TkButton.new(columns, - :text=>i.to_s, :width=>2, - :command=>proc{set_columns(i)} - ).pack(:side=>:left) + :text=>i.to_s, :width=>2, + :command=>proc{set_columns(i)} + ).pack(:side=>:left) } @column_btns[@columns][:relief] = :sunken @@ -91,15 +91,15 @@ class ViewIcons def _create_info_window @info_window = TkToplevel.new(:background=>'lightyellow', :borderwidth=>1, - :relief=>:solid){|w| + :relief=>:solid){|w| lbl_name = TkLabel.new(w, :text=>'Name', :background=>'lightyellow', - :font=>@boldfont, :justify=>:left) + :font=>@boldfont, :justify=>:left) lbl_grps = TkLabel.new(w, :text=>'Groups', :background=>'lightyellow', - :font=>@boldfont, :justify=>:left) + :font=>@boldfont, :justify=>:left) lbl_type = TkLabel.new(w, :text=>'Type', :background=>'lightyellow', - :font=>@boldfont, :justify=>:left) + :font=>@boldfont, :justify=>:left) lbl_size = TkLabel.new(w, :text=>'Size', :background=>'lightyellow', - :font=>@boldfont, :justify=>:left) + :font=>@boldfont, :justify=>:left) lbl_name.grid(:row=>0, :column=>0, :sticky=>:w) lbl_grps.grid(:row=>1, :column=>0, :sticky=>:w) @@ -117,16 +117,16 @@ class ViewIcons @size.grid(:row=>3, :column=>1, :sticky=>:w) def name(txt) - @name['text'] = txt + @name['text'] = txt end def groups(txt) - @grps['text'] = txt + @grps['text'] = txt end def type(txt) - @type['text'] = txt + @type['text'] = txt end def size(txt) - @size['text'] = txt + @size['text'] = txt end overrideredirect(true) @@ -243,9 +243,9 @@ class ViewIcons if Tk::PLATFORM['platform'] == 'unix' TkSelection.handle(Tk.root, method(:primary_transfer), - :selection=>'PRIMARY') + :selection=>'PRIMARY') TkSelection.set_owner(Tk.root, :selection=>'PRIMARY', - :command=>method(:lost_selection)) + :command=>method(:lost_selection)) end Tk.bell @@ -257,18 +257,18 @@ class ViewIcons width = @controls.winfo_width - @icons_window.yscrollbar.winfo_width - 8 @icons_window.configure(:width=>width, :scrollregion=>bbox, - :xscrollincrement=>'0.1i', - :yscrollincrement=>'0.1i') + :xscrollincrement=>'0.1i', + :yscrollincrement=>'0.1i') end def select_icons new_lib = Tk.getOpenFile(:initialdir=>@initial_dir, - :initialfile=>'tkIcons', - :title=>'Select Icon Library', - :filetypes=>[ - ['Icon Libraries', ['tkIcons*']], - ['All Files', ['*']] - ]) + :initialfile=>'tkIcons', + :title=>'Select Icon Library', + :filetypes=>[ + ['Icon Libraries', ['tkIcons*']], + ['All Files', ['*']] + ]) @library.value = new_lib if new_lib.length != 0 display_icons @@ -281,7 +281,7 @@ class ViewIcons unless File.exist?(@library.value) Tk.messageBox(:icon=>'warning', :message=>'File does not exist', - :title=>'viewIcons') + :title=>'viewIcons') return end @@ -306,10 +306,10 @@ class ViewIcons init_info(lbl, name) if column == limit - column = 0 - row += 1 + column = 0 + row += 1 else - column += 1 + column += 1 end } diff --git a/ext/tk/sample/tkextlib/bwidget/basic.rb b/ext/tk/sample/tkextlib/bwidget/basic.rb index f622c142e..c1521651f 100644 --- a/ext/tk/sample/tkextlib/bwidget/basic.rb +++ b/ext/tk/sample/tkextlib/bwidget/basic.rb @@ -30,37 +30,37 @@ module DemoBasic def self._label(parent) lab = Tk::BWidget::Label.new(parent, :text=>'This is a Label widget', - :helptext=>'Label widget') + :helptext=>'Label widget') chk = TkCheckbutton.new(parent, :text=>'Disabled', - :variable=>@@var.ref(lab, 'state'), - :onvalue=>'disabled', :offvalue=>'normal', - :command=>proc{lab[:state] = @@var[lab, 'state']}) + :variable=>@@var.ref(lab, 'state'), + :onvalue=>'disabled', :offvalue=>'normal', + :command=>proc{lab[:state] = @@var[lab, 'state']}) lab.pack(:anchor=>:w, :pady=>4) chk.pack(:anchor=>:w) end def self._entry(parent) ent = Tk::BWidget::Entry.new(parent, :text=>'Press enter', - :helptext=>'Entry widtet', - :command=>proc{ - @@var['entcmd'] = 'command called' - Tk.after(500, proc{@@var['entcmd'] = ''}) - }) + :helptext=>'Entry widtet', + :command=>proc{ + @@var['entcmd'] = 'command called' + Tk.after(500, proc{@@var['entcmd'] = ''}) + }) chk1 = TkCheckbutton.new(parent, :text=>'Disabled', - :variable=>@@var.ref(ent, 'state'), - :onvalue=>'disabled', :offvalue=>'normal', - :command=>proc{ent.state = @@var[ent, 'state']}) + :variable=>@@var.ref(ent, 'state'), + :onvalue=>'disabled', :offvalue=>'normal', + :command=>proc{ent.state = @@var[ent, 'state']}) chk2 = TkCheckbutton.new(parent, :text=>'Non editable', - :variable=>@@var.ref(ent, 'editable'), - :onvalue=>false, :offvalue=>true, - :command=>proc{ - ent.editable = @@var[ent, 'editable'] - }) + :variable=>@@var.ref(ent, 'editable'), + :onvalue=>false, :offvalue=>true, + :command=>proc{ + ent.editable = @@var[ent, 'editable'] + }) lab = TkLabel.new(parent, :textvariable=>@@var.ref('entcmd'), - :foreground=>'red') + :foreground=>'red') ent.pack(:pady=>4, :anchor=>:w) Tk.pack(chk1, chk2, :anchor=>:w) @@ -70,22 +70,22 @@ module DemoBasic def self._button(parent) frame = TkFrame.new(parent) but = Tk::BWidget::Button.new(frame, :text=>'Press me!', - :repeatdelay=>300, - :command=>proc{_butcmd('command')}, - :helptext=>'This is a Button widget') + :repeatdelay=>300, + :command=>proc{_butcmd('command')}, + :helptext=>'This is a Button widget') sep1 = Tk::BWidget::Separator.new(frame, :orient=>:vertical) arr1 = Tk::BWidget::ArrowButton.new(frame, :type=>:button, - :width=>25, :height=>25, :repeatdelay=>300, - :command=>proc{_butcmd('command')}, - :helptext=>"This is an ArrowButton widget\nof type button") + :width=>25, :height=>25, :repeatdelay=>300, + :command=>proc{_butcmd('command')}, + :helptext=>"This is an ArrowButton widget\nof type button") sep2 = Tk::BWidget::Separator.new(frame, :orient=>:vertical) arr2 = Tk::BWidget::ArrowButton.new(frame, :type=>:arrow, - :width=>25, :height=>25, :relief=>:sunken, - :ipadx=>0, :ipady=>0, :repeatdelay=>300, - :command=>proc{_butcmd('command')}, - :helptext=>"This is an ArrowButton widget\nof type arrow") + :width=>25, :height=>25, :relief=>:sunken, + :ipadx=>0, :ipady=>0, :repeatdelay=>300, + :command=>proc{_butcmd('command')}, + :helptext=>"This is an ArrowButton widget\nof type arrow") but.pack(:side=>:left, :padx=>4) sep1.pack(:side=>:left, :padx=>4, :fill=>:y) @@ -95,51 +95,51 @@ module DemoBasic frame.pack Tk::BWidget::Separator.new(parent, - :orient=>:horizontal).pack(:fill=>:x, :pady=>10) + :orient=>:horizontal).pack(:fill=>:x, :pady=>10) labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Command', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1) subf = labf1.get_frame chk1 = TkCheckbutton.new(subf, :text=>'Disabled', - :variable=>@@var.ref('bstate'), - :onvalue=>'disabled', :offvalue=>'normal', - :command=>proc{_bstate(@@var['bstate'], - but, arr1, arr2)}) + :variable=>@@var.ref('bstate'), + :onvalue=>'disabled', :offvalue=>'normal', + :command=>proc{_bstate(@@var['bstate'], + but, arr1, arr2)}) chk2 = TkCheckbutton.new(subf, :text=>"Use armcommand/\ndisarmcommand", - :variable=>@@var.ref('barmcmd'), - :command=>proc{_barmcmd(@@var['barmcmd'], - but, arr1, arr2)}) + :variable=>@@var.ref('barmcmd'), + :command=>proc{_barmcmd(@@var['barmcmd'], + but, arr1, arr2)}) Tk.pack(chk1, chk2, :anchor=>:w) label = TkLabel.new(parent, :textvariable=>@@var.ref('butcmd'), - :foreground=>'red').pack(:side=>:bottom, :pady=>4) + :foreground=>'red').pack(:side=>:bottom, :pady=>4) labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Direction', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1) subf = labf2.get_frame @@var['bside'] = :top [:top, :left, :bottom, :right].each{|dir| TkRadiobutton.new(subf, :text=>"#{dir} arrow", - :variable=>@@var.ref('bside'), :value=>dir, - :command=>proc{_bside(@@var['bside'], arr1, arr2)} - ).pack(:anchor=>:w) + :variable=>@@var.ref('bside'), :value=>dir, + :command=>proc{_bside(@@var['bside'], arr1, arr2)} + ).pack(:anchor=>:w) } labf3 = Tk::BWidget::LabelFrame.new(parent, :text=>'Relief', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1) subf = labf3.get_frame @@var['brelief'] = :raised [ %w(raised sunken ridge groove), %w(flat solid link)].each{|lrelief| f = TkFrame.new(subf) lrelief.each{|relief| - TkRadiobutton.new(f, :text=>relief, - :variable=>@@var.ref('brelief'), :value=>relief, - :command=>proc{ - _brelief(@@var['brelief'], but, arr1, arr2) - }).pack(:anchor=>:w) + TkRadiobutton.new(f, :text=>relief, + :variable=>@@var.ref('brelief'), :value=>relief, + :command=>proc{ + _brelief(@@var['brelief'], but, arr1, arr2) + }).pack(:anchor=>:w) } f.pack(:side=>:left, :padx=>2, :anchor=>:n) } @@ -164,19 +164,19 @@ module DemoBasic def self._barmcmd(value, but, arr1, arr2) if TkComm.bool(value) but.configure(:armcommand=>proc{_butcmd('arm')}, - :disarmcommand=>proc{_butcmd('disarm')}, - :command=>'') + :disarmcommand=>proc{_butcmd('disarm')}, + :command=>'') [arr1, arr2].each{|arr| - arr.configure(:armcommand=>proc{_butcmd('arm')}, - :disarmcommand=>proc{_butcmd('disarm')}, - :command=>'') + arr.configure(:armcommand=>proc{_butcmd('arm')}, + :disarmcommand=>proc{_butcmd('disarm')}, + :command=>'') } else but.configure(:armcommand=>'', :disarmcommand=>'', - :command=>proc{_butcmd('command')}) + :command=>proc{_butcmd('command')}) [arr1, arr2].each{|arr| - arr.configure(:armcommand=>'', :disarmcommand=>'', - :command=>proc{_butcmd('command')}) + arr.configure(:armcommand=>'', :disarmcommand=>'', + :command=>proc{_butcmd('command')}) } end end diff --git a/ext/tk/sample/tkextlib/bwidget/demo.rb b/ext/tk/sample/tkextlib/bwidget/demo.rb index e192cd636..785d2681a 100644 --- a/ext/tk/sample/tkextlib/bwidget/demo.rb +++ b/ext/tk/sample/tkextlib/bwidget/demo.rb @@ -54,26 +54,26 @@ class BWidget_Demo descmenu = [ '&File', 'all', 'file', 0, [ - ['command', 'E&xit', [], 'Exit BWidget demo', [], - {:command=>proc{exit}}] + ['command', 'E&xit', [], 'Exit BWidget demo', [], + {:command=>proc{exit}}] ], '&Options', 'all', 'options', 0, [ - ['checkbutton', 'Toolbar &1', ['all', 'option'], - 'Show/hide toolbar 1', [], - { :variable=>DemoVar.toolbar1, - :command=>proc{ - DemoVar.mainframe.show_toolbar(0, DemoVar.toolbar1.value) - } - } - ], - ['checkbutton', 'Toolbar &2', ['all', 'option'], - 'Show/hide toolbar 2', [], - { :variable=>DemoVar.toolbar2, - :command=>proc{ - DemoVar.mainframe.show_toolbar(1, DemoVar.toolbar2.value) - } - } - ] + ['checkbutton', 'Toolbar &1', ['all', 'option'], + 'Show/hide toolbar 1', [], + { :variable=>DemoVar.toolbar1, + :command=>proc{ + DemoVar.mainframe.show_toolbar(0, DemoVar.toolbar1.value) + } + } + ], + ['checkbutton', 'Toolbar &2', ['all', 'option'], + 'Show/hide toolbar 2', [], + { :variable=>DemoVar.toolbar2, + :command=>proc{ + DemoVar.mainframe.show_toolbar(1, DemoVar.toolbar2.value) + } + } + ] ] ] @@ -81,63 +81,63 @@ class BWidget_Demo DemoVar.prgindic.value = 0 DemoVar.mainframe = Tk::BWidget::MainFrame.new( - :menu=>descmenu, - :textvariable=>DemoVar.status, - :progressvar=>DemoVar.prgindic - ) + :menu=>descmenu, + :textvariable=>DemoVar.status, + :progressvar=>DemoVar.prgindic + ) # toobar 1 creation DemoVar.prgindic.numeric += 1 DemoVar.mainframe.add_toolbar{|tb1| Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox| - add(:image=>Tk::BWidget::Bitmap.new('new'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Create a new file" icon'}, - :helptext=>"Create a new file") - - add(:image=>Tk::BWidget::Bitmap.new('open'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Open an existing file" icon'}, - :helptext=>"Open an existing file") - - add(:image=>Tk::BWidget::Bitmap.new('save'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Save file" icon'}, - :helptext=>"Save file") - - pack(:side=>:left, :anchor=>:w) + add(:image=>Tk::BWidget::Bitmap.new('new'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Create a new file" icon'}, + :helptext=>"Create a new file") + + add(:image=>Tk::BWidget::Bitmap.new('open'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Open an existing file" icon'}, + :helptext=>"Open an existing file") + + add(:image=>Tk::BWidget::Bitmap.new('save'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Save file" icon'}, + :helptext=>"Save file") + + pack(:side=>:left, :anchor=>:w) } Tk::BWidget::Separator.new(tb1, :orient=>:vertical){ - pack(:side=>:left, :fill=>:y, :padx=>4, :anchor=>:w) + pack(:side=>:left, :fill=>:y, :padx=>4, :anchor=>:w) } DemoVar.prgindic.numeric += 1 Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox| - add(:image=>Tk::BWidget::Bitmap.new('cut'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Cut selection" icon'}, - :helptext=>"Cut selection") - - add(:image=>Tk::BWidget::Bitmap.new('copy'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Copy selection" icon'}, - :helptext=>"Copy selection") - - add(:image=>Tk::BWidget::Bitmap.new('paste'), - :highlightthickness=>0, :takefocus=>0, :relief=>:link, - :borderwidth=>1, :padx=>1, :pady=>1, - :command=>proc{puts 'select "Paste selection" icon'}, - :helptext=>"Paste selection") - - pack(:side=>:left, :anchor=>:w) + add(:image=>Tk::BWidget::Bitmap.new('cut'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Cut selection" icon'}, + :helptext=>"Cut selection") + + add(:image=>Tk::BWidget::Bitmap.new('copy'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Copy selection" icon'}, + :helptext=>"Copy selection") + + add(:image=>Tk::BWidget::Bitmap.new('paste'), + :highlightthickness=>0, :takefocus=>0, :relief=>:link, + :borderwidth=>1, :padx=>1, :pady=>1, + :command=>proc{puts 'select "Paste selection" icon'}, + :helptext=>"Paste selection") + + pack(:side=>:left, :anchor=>:w) } } @@ -147,7 +147,7 @@ class BWidget_Demo tb2 = DemoVar.mainframe.add_toolbar DemoVar._wfont = Tk::BWidget::SelectFont::Toolbar.new(tb2, :command=>proc{update_font(DemoVar._wfont[:font])} - ) + ) DemoVar.font = DemoVar._wfont[:font] DemoVar._wfont.pack(:side=>:left, :anchor=>:w) @@ -214,18 +214,18 @@ class BWidget_Demo top.overrideredirect(true) ximg = TkLabel.new(top, :bitmap=>"@#{File.join(DEMODIR,'x1.xbm')}", - :foreground=>'grey90', :background=>'white') + :foreground=>'grey90', :background=>'white') bwimg = TkLabel.new(ximg, :bitmap=>"@#{File.join(DEMODIR,'bwidget.xbm')}", - :foreground=>'grey90', :background=>'white') + :foreground=>'grey90', :background=>'white') frame = TkFrame.new(ximg, :background=>'white') TkLabel.new(frame, :text=>'Loading demo', - :background=>'white', :font=>'times 8').pack + :background=>'white', :font=>'times 8').pack TkLabel.new(frame, :textvariable=>DemoVar.prgtext, - :background=>'white', :font=>'times 8', :width=>35).pack + :background=>'white', :font=>'times 8', :width=>35).pack Tk::BWidget::ProgressBar.new(frame, :width=>50, :height=>10, - :background=>'white', - :variable=>DemoVar.prgindic, - :maximum=>10).pack + :background=>'white', + :variable=>DemoVar.prgindic, + :maximum=>10).pack frame.place(:x=>0, :y=>0, :anchor=>:nw) bwimg.place(:relx=>1, :rely=>1, :anchor=>:se) ximg.pack diff --git a/ext/tk/sample/tkextlib/bwidget/dnd.rb b/ext/tk/sample/tkextlib/bwidget/dnd.rb index fd6cc40dd..1c8b03653 100644 --- a/ext/tk/sample/tkextlib/bwidget/dnd.rb +++ b/ext/tk/sample/tkextlib/bwidget/dnd.rb @@ -13,19 +13,19 @@ module DemoDnD subf = titf1.get_frame ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry', - :labelwidth=>14, :dragenabled=>true, - :dragevent=>3) + :labelwidth=>14, :dragenabled=>true, + :dragevent=>3) labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (text)', - :width=>14) + :width=>14) f = labf1.get_frame lab = Tk::BWidget::Label.new(f, :text=>'Drag this text', - :dragenabled=>true, :dragevent=>3).pack + :dragenabled=>true, :dragevent=>3).pack labf2 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (bitmap)', - :width=>14) + :width=>14) f = labf2.get_frame lab = Tk::BWidget::Label.new(f, :bitmap=>'info', - :dragenabled=>true, :dragevent=>3).pack + :dragenabled=>true, :dragevent=>3).pack Tk.pack(ent1, labf1, labf2, :side=>:top, :fill=>:x, :pady=>4) @@ -33,11 +33,11 @@ module DemoDnD subf = titf2.get_frame ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry', - :labelwidth=>14, :dropenabled=>true) + :labelwidth=>14, :dropenabled=>true) labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label', :width=>14) f = labf1.get_frame lab = Tk::BWidget::Label.new(f, :dropenabled=>true, - :highlightthickness=>1).pack(:fill=>:x) + :highlightthickness=>1).pack(:fill=>:x) Tk.pack(ent1, labf1, :side=>:top, :fill=>:x, :pady=>4) Tk.pack(titf1, titf2, :pady=>4) diff --git a/ext/tk/sample/tkextlib/bwidget/manager.rb b/ext/tk/sample/tkextlib/bwidget/manager.rb index 65bbe0f9e..776cb3065 100644 --- a/ext/tk/sample/tkextlib/bwidget/manager.rb +++ b/ext/tk/sample/tkextlib/bwidget/manager.rb @@ -33,34 +33,34 @@ module DemoManager def self._mainframe(parent) labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Toolbar', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>2) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>2) subf = labf1.get_frame chk1 = TkCheckbutton.new(subf, :text=>'View toolbar 1', - :variable=>DemoVar.toolbar1, - :command=>proc{ - DemoVar.mainframe.show_toolbar( - 0, DemoVar.toolbar1.value - ) - }) + :variable=>DemoVar.toolbar1, + :command=>proc{ + DemoVar.mainframe.show_toolbar( + 0, DemoVar.toolbar1.value + ) + }) chk2 = TkCheckbutton.new(subf, :text=>'View toolbar 2', - :variable=>DemoVar.toolbar2, - :command=>proc{ - DemoVar.mainframe.show_toolbar( - 1, DemoVar.toolbar2.value - ) - }) + :variable=>DemoVar.toolbar2, + :command=>proc{ + DemoVar.mainframe.show_toolbar( + 1, DemoVar.toolbar2.value + ) + }) Tk.pack(chk1, chk2, :anchor=>:w, :fill=>:x) labf1.pack(:fill=>:both) labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Status bar', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>2) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>2) subf = labf2.get_frame chk1 = TkCheckbutton.new(subf, :text=>"Show Progress\nindicator", - :justify=>:left, :variable=>@@progress, - :command=>proc{ _show_progress }) + :justify=>:left, :variable=>@@progress, + :command=>proc{ _show_progress }) chk1.pack(:anchor=>:w, :fill=>:x) Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :fill=>:both) @@ -68,10 +68,10 @@ module DemoManager def self._notebook(parent) TkCheckbutton.new(parent, :text=>'Homogeneous label', - :variable=>@@homogeneous, - :command=>proc{ - DemoVar.notebook[:homogeneous] = @@homogeneous.value - }).pack(:side=>:left, :anchor=>:n, :fill=>:x) + :variable=>@@homogeneous, + :command=>proc{ + DemoVar.notebook[:homogeneous] = @@homogeneous.value + }).pack(:side=>:left, :anchor=>:n, :fill=>:x) end def self._paned(parent) @@ -93,15 +93,15 @@ module DemoManager } sw = Tk::BWidget::ScrolledWindow.new(pane3, :relief=>:sunken, - :borderwidth=>2) + :borderwidth=>2) sf = Tk::BWidget::ScrollableFrame.new(sw) sw.set_widget(sf) subf = sf.get_frame lab = TkLabel.new(subf, :text=>'This is a ScrollableFrame') chk = TkCheckbutton.new(subf, :text=>'Constrained with', - :variable=>@@constw, :command=>proc{ - sf['constrainedwidth'] = @@constw.value - }) + :variable=>@@constw, :command=>proc{ + sf['constrainedwidth'] = @@constw.value + }) lab.pack chk.pack(:anchor=>:w) chk.bind('FocusIn', proc{sf.see(chk)}) @@ -133,13 +133,13 @@ module DemoManager def self._update_progress if @@progress.bool if DemoVar.prgindic.numeric < 100 - DemoVar.prgindic.numeric += 5 + DemoVar.prgindic.numeric += 5 else - @@progress.value = false - DemoVar.mainframe.show_statusbar(:status) - DemoVar.status.value = 'Done' - @@afterobj.stop - Tk.after(500, proc{ DemoVar.status.value = '' }) + @@progress.value = false + DemoVar.mainframe.show_statusbar(:status) + DemoVar.status.value = 'Done' + @@afterobj.stop + Tk.after(500, proc{ DemoVar.status.value = '' }) end else @@afterobj.stop diff --git a/ext/tk/sample/tkextlib/bwidget/select.rb b/ext/tk/sample/tkextlib/bwidget/select.rb index a04d8da48..ea24b47e2 100644 --- a/ext/tk/sample/tkextlib/bwidget/select.rb +++ b/ext/tk/sample/tkextlib/bwidget/select.rb @@ -14,30 +14,30 @@ module DemoSelect titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'SpinBox') subf = titf1.get_frame spin = Tk::BWidget::SpinBox.new(subf, :range=>[1, 100, 1], - :textvariable=>@@var.ref('spin', 'var'), - :helptext=>'This is the SpinBox') + :textvariable=>@@var.ref('spin', 'var'), + :helptext=>'This is the SpinBox') ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var', - :labelwidth=>10, :labelanchor=>:w, - :textvariable=>@@var.ref('spin', 'var'), - :editable=>0, - :helptext=>"This is an Entry reflecting\nthe linked var of SpinBox") + :labelwidth=>10, :labelanchor=>:w, + :textvariable=>@@var.ref('spin', 'var'), + :editable=>0, + :helptext=>"This is an Entry reflecting\nthe linked var of SpinBox") labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1, - :helptext=>'Modify some options of SpinBox') + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1, + :helptext=>'Modify some options of SpinBox') subf = labf.get_frame chk1 = TkCheckbutton.new(subf, :text=>'Non editable', - :variable=>@@var.ref('spin', 'editable'), - :onvalue=>false, :offvalue=>true, - :command=>proc{ - spin.editable(@@var['spin', 'editable']) - }) + :variable=>@@var.ref('spin', 'editable'), + :onvalue=>false, :offvalue=>true, + :command=>proc{ + spin.editable(@@var['spin', 'editable']) + }) chk2 = TkCheckbutton.new(subf, :text=>'Disabled', - :variable=>@@var.ref('spin', 'state'), - :onvalue=>'disabled', :offvalue=>'normal', - :command=>proc{ - spin.state(@@var['spin', 'state']) - }) + :variable=>@@var.ref('spin', 'state'), + :onvalue=>'disabled', :offvalue=>'normal', + :command=>proc{ + spin.state(@@var['spin', 'state']) + }) Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w) Tk.pack(spin, ent, labf, :pady=>4, :fill=>:x) titf1.pack @@ -45,33 +45,33 @@ module DemoSelect titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'ComboBox') subf = titf2.get_frame combo = Tk::BWidget::ComboBox.new(subf, - :textvariable=>@@var.ref('combo', 'var'), - :values=>[ - 'first value', 'second value', - 'third value', 'fourth value', - 'fifth value' - ], - :helptext=>'This is the ComboBox') + :textvariable=>@@var.ref('combo', 'var'), + :values=>[ + 'first value', 'second value', + 'third value', 'fourth value', + 'fifth value' + ], + :helptext=>'This is the ComboBox') ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var', - :labelwidth=>10, :labelanchor=>:w, - :textvariable=>@@var.ref('combo', 'var'), - :editable=>0, :helptext=>"This is an Entry reflecting\nthe linked var of ComboBox") + :labelwidth=>10, :labelanchor=>:w, + :textvariable=>@@var.ref('combo', 'var'), + :editable=>0, :helptext=>"This is an Entry reflecting\nthe linked var of ComboBox") labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options', :side=>:top, - :anchor=>:w, :relief=>:sunken, - :borderwidth=>1, :helptext=>'Modify some options of ComboBox') + :anchor=>:w, :relief=>:sunken, + :borderwidth=>1, :helptext=>'Modify some options of ComboBox') subf = labf.get_frame chk1 = TkCheckbutton.new(subf, :text=>'Non editable', - :variable=>@@var.ref('combo', 'editable'), - :onvalue=>false, :offvalue=>true, - :command=>proc{ - combo.editable(@@var['combo', 'editable']) - }) + :variable=>@@var.ref('combo', 'editable'), + :onvalue=>false, :offvalue=>true, + :command=>proc{ + combo.editable(@@var['combo', 'editable']) + }) chk2 = TkCheckbutton.new(subf, :text=>'Disabled', - :variable=>@@var.ref('combo', 'state'), - :onvalue=>'disabled', :offvalue=>'normal', - :command=>proc{ - combo.state(@@var['combo', 'state']) - }) + :variable=>@@var.ref('combo', 'state'), + :onvalue=>'disabled', :offvalue=>'normal', + :command=>proc{ + combo.state(@@var['combo', 'state']) + }) Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w) Tk.pack(combo, ent, labf, :pady=>4, :fill=>:x) diff --git a/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb index 1ed84e21a..3d19c8d09 100644 --- a/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb +++ b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb @@ -24,14 +24,14 @@ module DemoDialog subf = titf1.get_frame cmd = proc{ TkOption.read_file(File.join(Tk::BWidget::LIBRARY, 'lang', - @@resources.value + '.rc')) } + @@resources.value + '.rc')) } Tk.pack(TkRadiobutton.new(subf, :text=>'English', :value=>'en', - :variable=>@@resources, :command=>cmd), - TkRadiobutton.new(subf, :text=>'French', :value=>'fr', - :variable=>@@resources, :command=>cmd), - TkRadiobutton.new(subf, :text=>'German', :value=>'de', - :variable=>@@resources, :command=>cmd), - :side=>:left) + :variable=>@@resources, :command=>cmd), + TkRadiobutton.new(subf, :text=>'French', :value=>'fr', + :variable=>@@resources, :command=>cmd), + TkRadiobutton.new(subf, :text=>'German', :value=>'de', + :variable=>@@resources, :command=>cmd), + :side=>:left) _tmpldlg(titf2.get_frame) _msgdlg(titf3.get_frame) @@ -47,34 +47,34 @@ module DemoDialog @@tmpl['anchor'] = :c labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button side', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1) subf = labf1.get_frame Tk.pack(TkRadiobutton.new(subf, :text=>'Bottom', :value=>:bottom, - :variable=>@@tmpl.ref('side'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Left', :value=>:left, - :variable=>@@tmpl.ref('side'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Right', :value=>:right, - :variable=>@@tmpl.ref('side'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Top', :value=>:top, - :variable=>@@tmpl.ref('side'), :anchor=>:w), - :fill=>:x, :anchor=>:w) + :variable=>@@tmpl.ref('side'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Left', :value=>:left, + :variable=>@@tmpl.ref('side'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Right', :value=>:right, + :variable=>@@tmpl.ref('side'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Top', :value=>:top, + :variable=>@@tmpl.ref('side'), :anchor=>:w), + :fill=>:x, :anchor=>:w) labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button anchor', - :side=>:top, :anchor=>:w, - :relief=>:sunken, :borderwidth=>1) + :side=>:top, :anchor=>:w, + :relief=>:sunken, :borderwidth=>1) subf = labf2.get_frame Tk.pack(TkRadiobutton.new(subf, :text=>'North', :value=>:n, - :variable=>@@tmpl.ref('anchor'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'West', :value=>:w, - :variable=>@@tmpl.ref('anchor'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'East', :value=>:e, - :variable=>@@tmpl.ref('anchor'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'South', :value=>:s, - :variable=>@@tmpl.ref('anchor'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Center', :value=>:c, - :variable=>@@tmpl.ref('anchor'), :anchor=>:w), - :fill=>:x, :anchor=>:w) + :variable=>@@tmpl.ref('anchor'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'West', :value=>:w, + :variable=>@@tmpl.ref('anchor'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'East', :value=>:e, + :variable=>@@tmpl.ref('anchor'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'South', :value=>:s, + :variable=>@@tmpl.ref('anchor'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Center', :value=>:c, + :variable=>@@tmpl.ref('anchor'), :anchor=>:w), + :fill=>:x, :anchor=>:w) sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal) button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_tmpldlg}) @@ -89,44 +89,44 @@ module DemoDialog @@msg['icon'] = 'info' labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Type', :side=>:top, - :anchor=>:w, :relief=>:sunken, - :borderwidth=>1) + :anchor=>:w, :relief=>:sunken, + :borderwidth=>1) subf = labf1.get_frame Tk.pack(TkRadiobutton.new(subf, :text=>'Ok', :value=>'ok', - :variable=>@@msg.ref('type'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Ok, Cancel', :value=>'okcancel', - :variable=>@@msg.ref('type'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Retry, Cancel', - :value=>'retrycancel', - :variable=>@@msg.ref('type'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Yes, No', :value=>'yesno', - :variable=>@@msg.ref('type'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Yes, No, Cancel', - :value=>'yesnocancel', - :variable=>@@msg.ref('type'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Abort, Retry, Ignore', - :value=>'abortretryignore', - :variable=>@@msg.ref('type'), :anchor=>:w), - :fill=>:x, :anchor=>:w) + :variable=>@@msg.ref('type'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Ok, Cancel', :value=>'okcancel', + :variable=>@@msg.ref('type'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Retry, Cancel', + :value=>'retrycancel', + :variable=>@@msg.ref('type'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Yes, No', :value=>'yesno', + :variable=>@@msg.ref('type'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Yes, No, Cancel', + :value=>'yesnocancel', + :variable=>@@msg.ref('type'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Abort, Retry, Ignore', + :value=>'abortretryignore', + :variable=>@@msg.ref('type'), :anchor=>:w), + :fill=>:x, :anchor=>:w) Tk.pack(TkRadiobutton.new(subf, :text=>'User', :value=>'user', - :variable=>@@msg.ref('type'), :anchor=>:w), - Tk::BWidget::Entry.new(subf, :textvariable=>@@msg.ref('buttons')), - :side=>:left) + :variable=>@@msg.ref('type'), :anchor=>:w), + Tk::BWidget::Entry.new(subf, :textvariable=>@@msg.ref('buttons')), + :side=>:left) labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Icon', :side=>:top, - :anchor=>:w, :relief=>:sunken, - :borderwidth=>1) + :anchor=>:w, :relief=>:sunken, + :borderwidth=>1) subf = labf2.get_frame Tk.pack(TkRadiobutton.new(subf, :text=>'Information', :value=>'info', - :variable=>@@msg.ref('icon'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Question', :value=>'question', - :variable=>@@msg.ref('icon'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Warning', :value=>'warning', - :variable=>@@msg.ref('icon'), :anchor=>:w), - TkRadiobutton.new(subf, :text=>'Error', :value=>'error', - :variable=>@@msg.ref('icon'), :anchor=>:w), - :fill=>:x, :anchor=>:w) + :variable=>@@msg.ref('icon'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Question', :value=>'question', + :variable=>@@msg.ref('icon'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Warning', :value=>'warning', + :variable=>@@msg.ref('icon'), :anchor=>:w), + TkRadiobutton.new(subf, :text=>'Error', :value=>'error', + :variable=>@@msg.ref('icon'), :anchor=>:w), + :fill=>:x, :anchor=>:w) sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal) button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_msgdlg}) @@ -138,15 +138,15 @@ module DemoDialog def self._stddlg(parent) Tk.pack(TkButton.new(parent, :text=>'Select a color '){|w| - command(proc{DemoDialog._show_color(w)}) - }, - TkButton.new(parent, :text=>'Font selector dialog', - :command=>proc{_show_fontdlg}), - TkButton.new(parent, :text=>'Progression dialog', - :command=>proc{_show_progdlg}), - TkButton.new(parent, :text=>'Password dialog', - :command=>proc{_show_passdlg}), - :side=>:left, :padx=>5, :anchor=>:w) + command(proc{DemoDialog._show_color(w)}) + }, + TkButton.new(parent, :text=>'Font selector dialog', + :command=>proc{_show_fontdlg}), + TkButton.new(parent, :text=>'Progression dialog', + :command=>proc{_show_progdlg}), + TkButton.new(parent, :text=>'Password dialog', + :command=>proc{_show_passdlg}), + :side=>:left, :padx=>5, :anchor=>:w) end def self._show_color(w) @@ -159,15 +159,15 @@ module DemoDialog def self._show_tmpldlg dlg = Tk::BWidget::Dialog.new(:relative=>Tk.root, :modal=>:local, - :separator=>true, :title=>'Template dialog', - :side=>@@tmpl['side'], - :anchor=>@@tmpl['anchor'], - :default=>0, :cancel=>1) + :separator=>true, :title=>'Template dialog', + :side=>@@tmpl['side'], + :anchor=>@@tmpl['anchor'], + :default=>0, :cancel=>1) dlg.add('name'=>'ok') dlg.add('name'=>'cancel') TkMessage.new(dlg.get_frame, :text=>"Template\nDialog", :justify=>:center, - :anchor=>:c, :width=>80).pack(:fill=>:both, :expand=>true, - :padx=>100, :pady=>100) + :anchor=>:c, :width=>80).pack(:fill=>:both, :expand=>true, + :padx=>100, :pady=>100) dlg.draw dlg.destroy end @@ -175,16 +175,16 @@ module DemoDialog def self._show_msgdlg @@msgdlg.destroy if @@msgdlg @@msgdlg = Tk::BWidget::MessageDlg.new(:relative=>Tk.root, - :message=>'Message for MessageBox', - :type=>@@msg['type'], - :icon=>@@msg['icon'], - :buttons=>@@msg['buttons']) + :message=>'Message for MessageBox', + :type=>@@msg['type'], + :icon=>@@msg['icon'], + :buttons=>@@msg['buttons']) @@msgdlg.create end def self._show_fontdlg font = Tk::BWidget::SelectFont.new(:relative=>Tk.root, - :font=>DemoVar.font).create + :font=>DemoVar.font).create DemoVar::Demo.update_font(font) end @@ -193,11 +193,11 @@ module DemoDialog @@progval.value = 0 @@progdlg = Tk::BWidget::ProgressDlg.new(:relative=>Tk.root, - :title=>'Wait...', - :type=>'infinite', :width=>20, - :textvariable=>@@progmsg, - :variable=>@@progval, - :stop=>'Stop') { + :title=>'Wait...', + :type=>'infinite', :width=>20, + :textvariable=>@@progmsg, + :variable=>@@progval, + :stop=>'Stop') { command(proc{self.destroy}) create } @@ -206,12 +206,12 @@ module DemoDialog def self._update_progdlg TkTimer.new(20, -1, proc{ - if @@progdlg && @@progdlg.winfo_exist? - @@progval.value = 2 - else - stop - end - }).start + if @@progdlg && @@progdlg.winfo_exist? + @@progval.value = 2 + else + stop + end + }).start end def self._show_passdlg diff --git a/ext/tk/sample/tkextlib/bwidget/tree.rb b/ext/tk/sample/tkextlib/bwidget/tree.rb index 9bfa4f3cc..a355b6759 100644 --- a/ext/tk/sample/tkextlib/bwidget/tree.rb +++ b/ext/tk/sample/tkextlib/bwidget/tree.rb @@ -17,29 +17,29 @@ module DemoTree pane = pw.add(:weight=>1) title = Tk::BWidget::TitleFrame.new(pane, :text=>'Directory tree') sw = Tk::BWidget::ScrolledWindow.new(title.get_frame, - :relief=>:sunken, :borderwidth=>2) + :relief=>:sunken, :borderwidth=>2) tree = Tk::BWidget::Tree.new(sw, :relief=>:flat, :borderwidth=>0, - :width=>15, :highlightthickness=>0, - :redraw=>false, :dropenabled=>true, - :dragenabled=>true, :dragevent=>3, - :droptypes=>[ - 'TREE_NODE', [ - :copy, [], - :move, [], - :link, [] - ], - 'LISTBOX_ITEM', [ - :copy, [], - :move, [], - :link, [] - ] - ], - :opencmd=>proc{|node| - moddir(1, tree, node) - }, - :closecmd=>proc{|node| - moddir(0, tree, node) - }) + :width=>15, :highlightthickness=>0, + :redraw=>false, :dropenabled=>true, + :dragenabled=>true, :dragevent=>3, + :droptypes=>[ + 'TREE_NODE', [ + :copy, [], + :move, [], + :link, [] + ], + 'LISTBOX_ITEM', [ + :copy, [], + :move, [], + :link, [] + ] + ], + :opencmd=>proc{|node| + moddir(1, tree, node) + }, + :closecmd=>proc{|node| + moddir(0, tree, node) + }) sw.set_widget(tree) sw.pack(:side=>:top, :expand=>true, :fill=>:both) @@ -48,27 +48,27 @@ module DemoTree pane = pw.add(:weight=>2) lf = Tk::BWidget::TitleFrame.new(pane, :text=>'Content') sw = Tk::BWidget::ScrolledWindow.new(lf.get_frame, - :scrollbar=>:horizontal, - :auto=>:none, :relief=>:sunken, - :borderwidth=>2) + :scrollbar=>:horizontal, + :auto=>:none, :relief=>:sunken, + :borderwidth=>2) list = Tk::BWidget::ListBox.new(sw, :relief=>:flat, :borderwidth=>0, - :highlightthickness=>0, :width=>20, - :multicolumn=>true, :redraw=>false, - :dragevent=>3, :dropenabled=>true, - :dragenabled=>true, - :droptypes=>[ - 'TREE_NODE', [ - :copy, [], - :move, [], - :link, [] - ], - 'LISTBOX_ITEM', [ - :copy, [], - :move, [], - :link, [] - ] - ]) + :highlightthickness=>0, :width=>20, + :multicolumn=>true, :redraw=>false, + :dragevent=>3, :dropenabled=>true, + :dragenabled=>true, + :droptypes=>[ + 'TREE_NODE', [ + :copy, [], + :move, [], + :link, [] + ], + 'LISTBOX_ITEM', [ + :copy, [], + :move, [], + :link, [] + ] + ]) sw.set_widget(list) Tk.pack(sw, lf, :fill=>:both, :expand=>true) @@ -76,51 +76,51 @@ module DemoTree pw.pack(:fill=>:both, :expand=>true) tree.textbind('ButtonPress-1', - proc{|node, ev| select('tree', 1, tree, list, node)}) + proc{|node, ev| select('tree', 1, tree, list, node)}) tree.textbind('Double-ButtonPress-1', - proc{|node, ev| select('tree', 2, tree, list, node)}) + proc{|node, ev| select('tree', 2, tree, list, node)}) list.textbind('ButtonPress-1', - proc{|node, ev| select('list', 1, tree, list, node)}) + proc{|node, ev| select('list', 1, tree, list, node)}) list.textbind('Double-ButtonPress-1', - proc{|node, ev| select('list', 2, tree, list, node)}) + proc{|node, ev| select('list', 2, tree, list, node)}) list.imagebind('Double-ButtonPress-1', - proc{|node, ev| select('list', 2, tree, list, node)}) + proc{|node, ev| select('list', 2, tree, list, node)}) nb.itemconfigure('demoTree', - :createcmd=>proc{|*args| init(tree, list, *args)}, - :raisecmd=>proc{ - Tk.root.geometry =~ - /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/ - global_w = ($1 || 0).to_i - global_h = ($2 || 0).to_i - if @@top - Tk::BWidget.place(@@top, 0, 0, :at, - global_w - Tk.root.winfo_screenwidth, global_h) - @@top.deiconify - Tk.root.bind('Unmap', proc{@@top.withdraw}) - Tk.root.bind('Map', proc{@@top.deiconify}) - Tk.root.bind('Configure', proc{|w| - if w == Tk.root - Tk.root.geometry =~ - /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/ - global_w = ($1 || 0).to_i - global_h = ($2 || 0).to_i - BWidget.place(@@top, 0, 0, :at, - global_w - Tk.root.winfo_screenwidth, - global_h) - end - }, '%W') - end - }, - :leavecmd=>proc{ - @@top.withdraw if @@top - Tk.root.bind_remove('Unmap') - Tk.root.bind_remove('Map') - Tk.root.bind_remove('Configure') - return true - }) + :createcmd=>proc{|*args| init(tree, list, *args)}, + :raisecmd=>proc{ + Tk.root.geometry =~ + /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/ + global_w = ($1 || 0).to_i + global_h = ($2 || 0).to_i + if @@top + Tk::BWidget.place(@@top, 0, 0, :at, + global_w - Tk.root.winfo_screenwidth, global_h) + @@top.deiconify + Tk.root.bind('Unmap', proc{@@top.withdraw}) + Tk.root.bind('Map', proc{@@top.deiconify}) + Tk.root.bind('Configure', proc{|w| + if w == Tk.root + Tk.root.geometry =~ + /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/ + global_w = ($1 || 0).to_i + global_h = ($2 || 0).to_i + BWidget.place(@@top, 0, 0, :at, + global_w - Tk.root.winfo_screenwidth, + global_h) + end + }, '%W') + end + }, + :leavecmd=>proc{ + @@top.withdraw if @@top + Tk.root.bind_remove('Unmap') + Tk.root.bind_remove('Map') + Tk.root.bind_remove('Configure') + return true + }) end def self.init(tree, list, *args) @@ -132,8 +132,8 @@ module DemoTree end tree.insert('end', 'root', 'home', - :text=>rootdir, :data=>rootdir, :open=>true, - :image=>Tk::BWidget::Bitmap.new('openfold')) + :text=>rootdir, :data=>rootdir, :open=>true, + :image=>Tk::BWidget::Bitmap.new('openfold')) getdir(tree, 'home', rootdir) select('tree', 1, tree, list, 'home') tree.redraw(true) @@ -148,8 +148,8 @@ module DemoTree @@top.title('Drag rectangle to scroll directory tree') @@top.transient(Tk.root) Tk::BWidget::ScrollView.new(@@top, :window=>tree, :fill=>'white', - :width=>300, :height=>300, :relief=>:sunken, - :bd=>1).pack(:fill=>:both, :expand=>true) + :width=>300, :height=>300, :relief=>:sunken, + :bd=>1).pack(:fill=>:both, :expand=>true) end def self.getdir(tree, node, path) @@ -158,13 +158,13 @@ module DemoTree lentries.each{|f| basename = File.basename(f) if File.directory?(f) - Tk::BWidget::Tree::Node.new(tree, node, - :index=>'end', :text=>basename, - :image=>Tk::BWidget::Bitmap.new('folder'), - :drawcross=>:allways, :data=>f) - @@count += 1 + Tk::BWidget::Tree::Node.new(tree, node, + :index=>'end', :text=>basename, + :image=>Tk::BWidget::Bitmap.new('folder'), + :drawcross=>:allways, :data=>f) + @@count += 1 else - lfiles << basename + lfiles << basename end } tree.itemconfigure(node, :drawcross=>:auto, :data=>lfiles) @@ -174,9 +174,9 @@ module DemoTree if (idx != 0 && tree.itemcget(node, :drawcross).to_s == 'allways') getdir(tree, node, tree.itemcget(node, :data)) if tree.nodes(node).empty? - tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('folder')) + tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('folder')) else - tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('openfold')) + tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('openfold')) end else img = %w(folder openfold)[idx] || 'openfold' @@ -188,31 +188,31 @@ module DemoTree @@dblclick = true if num == 1 if (where == 'tree' && - tree.selection_get.find{|x| - TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) - }) - @@dblclick = false - Tk.after(500, proc{edit('tree', tree, list, node)}) - return + tree.selection_get.find{|x| + TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) + }) + @@dblclick = false + Tk.after(500, proc{edit('tree', tree, list, node)}) + return end if (where == 'list' && - list.selection_get.find{|x| - TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) - }) - @@dblclick = false - Tk.after(500, proc{edit('list', tree, list, node)}) - return + list.selection_get.find{|x| + TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) + }) + @@dblclick = false + Tk.after(500, proc{edit('list', tree, list, node)}) + return end if where == 'tree' - select_node(tree, list, node) + select_node(tree, list, node) else - list.selection_set(node) + list.selection_set(node) end elsif (where == 'list' && tree.exist?(node)) parent = tree.parent(node) while TkUtil._get_eval_string(parent) != 'root' - tree.itemconfigure(parent, :open=>true) - parent = tree.parent(parent) + tree.itemconfigure(parent, :open=>true) + parent = tree.parent(parent) end select_node(tree, list, node) end @@ -231,13 +231,13 @@ module DemoTree tree.nodes(node).each{|subnode| list.insert('end', subnode, - :text=>tree.itemcget(subnode, :text), - :image=>Tk::BWidget::Bitmap.new('folder')) + :text=>tree.itemcget(subnode, :text), + :image=>Tk::BWidget::Bitmap.new('folder')) } TkComm.simplelist(dir).each{|f| Tk::BWidget::ListBox::Item.new(list, 'end', :text=>f, - :image=>Tk::BWidget::Bitmap.new('file')) + :image=>Tk::BWidget::Bitmap.new('file')) } end @@ -245,16 +245,16 @@ module DemoTree return if @@dblclick if (where == 'tree' && - tree.selection_get.find{|x| - TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) - }) + tree.selection_get.find{|x| + TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node) + }) res = tree.edit(node, tree.itemcget(node, :text)) if res != '' - tree.itemconfigure(node, :text=>res) - if list.exist?(node) - list.itemconfigure(node, :text=>res) - end - tree.selection_set(node) + tree.itemconfigure(node, :text=>res) + if list.exist?(node) + list.itemconfigure(node, :text=>res) + end + tree.selection_set(node) end return end @@ -262,17 +262,17 @@ module DemoTree if (where == 'list') res = list.edit(node, list.igemcget(node, :text)) if res != '' - list.itemconfigure(node, :text=>res) - if tree.exist?(node) - tree.itemconfigure(node, :text=>res) - else - cursel = tree.selection_get[0] - index = list.index(node) - tree.nodes(cursel).size - data = TkComm.simplelist(tree.itemcget(cursel, :data)) - data[index] = res - tree.itemconfigure(cursel, :date=>data) - end - list.selection_set(node) + list.itemconfigure(node, :text=>res) + if tree.exist?(node) + tree.itemconfigure(node, :text=>res) + else + cursel = tree.selection_get[0] + index = list.index(node) - tree.nodes(cursel).size + data = TkComm.simplelist(tree.itemcget(cursel, :data)) + data[index] = res + tree.itemconfigure(cursel, :date=>data) + end + list.selection_set(node) end end end @@ -280,9 +280,9 @@ module DemoTree def self.expand(tree, but) unless (cur = tree.selection_get).empty? if TkComm.bool(but) - tree.opentree(cur) + tree.opentree(cur) else - tree.closetree(cur) + tree.closetree(cur) end end end diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb index 7a7c65ae8..4dd929c03 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb @@ -3,8 +3,8 @@ require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Calendar.new(:command=>proc{|arg| puts(arg.date)}, - :weekendbackground=>'mistyrose', - :weekdaybackground=>'ghostwhite', - :outline=>'black', :startday=>'wednesday', - :days=>%w(We Th Fr Sa Su Mo Tu)).pack + :weekendbackground=>'mistyrose', + :weekdaybackground=>'ghostwhite', + :outline=>'black', :startday=>'wednesday', + :days=>%w(We Th Fr Sa Su Mo Tu)).pack Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb index 5c2e6cbbd..ec9c7a1df 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb @@ -6,11 +6,11 @@ require 'tkextlib/iwidgets' # Non-editable Dropdown Combobox # cb1 = Tk::Iwidgets::Combobox.new(:labeltext=>'Month:', - :selectioncommand=>proc{ - puts(cb1.get_curselection) - }, - :editable=>false, :listheight=>185, - :popupcursor=>'hand1') + :selectioncommand=>proc{ + puts(cb1.get_curselection) + }, + :editable=>false, :listheight=>185, + :popupcursor=>'hand1') cb1.insert_list('end', *%w(Jan Feb Mar Apr May June Jul Aug Sept Oct Nov Dec)) @@ -19,9 +19,9 @@ cb1.insert_list('end', *%w(Jan Feb Mar Apr May June Jul Aug Sept Oct Nov Dec)) # Editable Dropdown Combobox # cb2 = Tk::Iwidgets::Combobox.new(:labeltext=>'Operating System:', - :selectioncommand=>proc{ - puts(cb2.get_curselection) - }) + :selectioncommand=>proc{ + puts(cb2.get_curselection) + }) cb2.insert_list('end', *%w(Linux HP-UX SunOS Solaris Irix)) cb2.insert_entry('end', 'L') diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb b/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb index d4578297e..197521e0a 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb @@ -9,6 +9,6 @@ ds.add('Cancel', :text=>'Cancel', :command=>proc{puts 'Cancel'; ds.deactivate}) ds.default('OK') TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7, - :command=>proc{puts ds.activate}).pack(:padx=>10, :pady=>10) + :command=>proc{puts ds.activate}).pack(:padx=>10, :pady=>10) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb index f7a0e5c48..85c5d03d1 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb @@ -3,7 +3,7 @@ require 'tk' require 'tkextlib/iwidgets' djl = Tk::Iwidgets::Disjointlistbox.new.pack(:fill=>:both, :expand=>true, - :padx=>10, :pady=>10) + :padx=>10, :pady=>10) djl.set_lhs(*[0,2,4,5]) djl.set_rhs(3,6) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb index 24253fcb9..856d883a9 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb @@ -12,21 +12,21 @@ TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"}) fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:', - :fixed=>10, :width=>12) + :fixed=>10, :width=>12) nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:', - :validate=>:numeric, :width=>12) + :validate=>:numeric, :width=>12) aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:', - :validate=>:alphabetic, :width=>12, - :invalid=>proc{ - puts "Alphabetic contents invalid" - }) + :validate=>:alphabetic, :width=>12, + :invalid=>proc{ + puts "Alphabetic contents invalid" + }) pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12, - :show=>Tk::UTF8_String("\267"), - ## <=== utf8 character - :command=>proc{puts "Return Pressed"}) + :show=>Tk::UTF8_String("\267"), + ## <=== utf8 character + :command=>proc{puts "Return Pressed"}) Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb index 9a80e4aaf..4a4c2e7eb 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb @@ -14,20 +14,20 @@ TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"}) fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:', - :fixed=>10, :width=>12) + :fixed=>10, :width=>12) nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:', - :validate=>:numeric, :width=>12) + :validate=>:numeric, :width=>12) aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:', - :validate=>:alphabetic, :width=>12, - :invalid=>proc{ - puts "Alphabetic contents invalid" - }) + :validate=>:alphabetic, :width=>12, + :invalid=>proc{ + puts "Alphabetic contents invalid" + }) pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12, - :show=>"\267", ## <=== utf8 character - :command=>proc{puts "Return Pressed"}) + :show=>"\267", ## <=== utf8 character + :command=>proc{puts "Return Pressed"}) Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb index e83030839..bddd542f6 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb @@ -14,20 +14,20 @@ TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"}) fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:', - :fixed=>10, :width=>12) + :fixed=>10, :width=>12) nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:', - :validate=>:numeric, :width=>12) + :validate=>:numeric, :width=>12) aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:', - :validate=>:alphabetic, :width=>12, - :invalid=>proc{ - puts "Alphabetic contents invalid" - }) + :validate=>:alphabetic, :width=>12, + :invalid=>proc{ + puts "Alphabetic contents invalid" + }) pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12, - :show=>"\267", ## <=== utf8 character - :command=>proc{puts "Return Pressed"}) + :show=>"\267", ## <=== utf8 character + :command=>proc{puts "Return Pressed"}) Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb index 83a6a07b6..6971052b6 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb @@ -3,18 +3,18 @@ require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Extbutton.new(:text=>'Bitmap example', :bitmap=>'info', - :background=>'bisque', :activeforeground=>'red', - :bitmapforeground=>'blue', :defaultring=>true, - :command=>proc{ - puts "Bisque is beautiful" - }).pack(:expand=>true) + :background=>'bisque', :activeforeground=>'red', + :bitmapforeground=>'blue', :defaultring=>true, + :command=>proc{ + puts "Bisque is beautiful" + }).pack(:expand=>true) #img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../../../images/earthris.gif')) img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/clear.gif')) Tk::Iwidgets::Extbutton.new(:text=>'Image example', :relief=>:ridge, - :image=>img, :imagepos=>:e, :font=>'9x15bold', - :activebackground=>'lightyellow', - :background=>'lightgreen').pack(:expand=>true) + :image=>img, :imagepos=>:e, :font=>'9x15bold', + :activebackground=>'lightyellow', + :background=>'lightgreen').pack(:expand=>true) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb index ef3b14ff4..4738084d9 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb @@ -3,6 +3,6 @@ require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Extfileselectionbox.new.pack(:padx=>10, :pady=>10, - :fill=>:both, :expand=>true) + :fill=>:both, :expand=>true) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb index 80a31d06e..c1a9b3def 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb @@ -9,9 +9,9 @@ mainloop = Thread.new{Tk.mainloop} # nmfsd = Tk::Iwidgets::Extfileselectiondialog.new(:title=>'Non-Modal') nmfsd.buttonconfigure('OK', :command=>proc{ - puts "You selected #{nmfsd.get}" - nmfsd.deactivate - }) + puts "You selected #{nmfsd.get}" + nmfsd.deactivate + }) nmfsd.activate # diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb index f0313d948..2ad3adb97 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb @@ -3,6 +3,6 @@ require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Fileselectionbox.new.pack(:padx=>10, :pady=>10, - :fill=>:both, :expand=>true) + :fill=>:both, :expand=>true) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb index 955e5cbd2..ff22b2f64 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb @@ -9,9 +9,9 @@ mainloop = Thread.new{Tk.mainloop} # nmfsd = Tk::Iwidgets::Fileselectiondialog.new(:title=>'Non-Modal') nmfsd.buttonconfigure('OK', :command=>proc{ - puts "You selected #{nmfsd.get}" - nmfsd.deactivate - }) + puts "You selected #{nmfsd.get}" + nmfsd.deactivate + }) nmfsd.activate # diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb b/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb index 594158294..c83ae3724 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb @@ -11,15 +11,15 @@ def get_files(file) end Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{|arg| get_files(arg.node)}, - :visibleitems=>'30x15', - :labeltext=>ENV['HOME']).pack(:side=>:left, - :expand=>true, - :fill=>:both) + :visibleitems=>'30x15', + :labeltext=>ENV['HOME']).pack(:side=>:left, + :expand=>true, + :fill=>:both) # Tk::Iwidgets::Hierarchy.new(:querycommand=>[proc{|n| get_files(n)}, '%n'], -# :visibleitems=>'30x15', -# :labeltext=>ENV['HOME']).pack(:side=>:left, -# :expand=>true, -# :fill=>:both) +# :visibleitems=>'30x15', +# :labeltext=>ENV['HOME']).pack(:side=>:left, +# :expand=>true, +# :fill=>:both) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb b/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb index 1fed7d55e..1d2e0a98a 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb @@ -3,11 +3,11 @@ require 'tk' require 'tkextlib/iwidgets' lw = Tk::Iwidgets::Labeledwidget.new(:labeltext=>'Canvas Widget', - :labelpos=>:s) + :labelpos=>:s) lw.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10) cw = TkCanvas.new(lw.child_site, :relief=>:raised, :width=>200, :height=>200, - :borderwidth=>3, :background=>:white) + :borderwidth=>3, :background=>:white) cw.pack(:padx=>10, :pady=>10) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb index 85b28b45e..b87a6d27f 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb @@ -5,57 +5,57 @@ require 'tkextlib/iwidgets' mw = Tk::Iwidgets::Mainwindow.new mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0, - :padx=>8, :pady=>2, :menu=>[ - [:options, {:tearoff=>false}], + :padx=>8, :pady=>2, :menu=>[ + [:options, {:tearoff=>false}], - [:command, 'new', { - :label=>'New', :underline=>0, - :helpstr=>'Create a new file' - } - ], + [:command, 'new', { + :label=>'New', :underline=>0, + :helpstr=>'Create a new file' + } + ], - [:command, 'open', { - :label=>'Open ...', :underline=>0, - :helpstr=>'Open an existing file' - } - ], + [:command, 'open', { + :label=>'Open ...', :underline=>0, + :helpstr=>'Open an existing file' + } + ], - [:command, 'save', { - :label=>'Save', :underline=>0, - :helpstr=>'Save the current file' - } - ], + [:command, 'save', { + :label=>'Save', :underline=>0, + :helpstr=>'Save the current file' + } + ], - [:command, 'saveas', { - :label=>'Save As', :underline=>5, - :helpstr=>'Save the file as a different name' - } - ], + [:command, 'saveas', { + :label=>'Save As', :underline=>5, + :helpstr=>'Save the file as a different name' + } + ], - [:command, 'print', { - :label=>'Print', :underline=>0, - :helpstr=>'Print the file' - } - ], + [:command, 'print', { + :label=>'Print', :underline=>0, + :helpstr=>'Print the file' + } + ], - [:separator, 'sep1'], + [:separator, 'sep1'], - [:command, 'close', { - :label=>'Close', :underline=>0, - :helpstr=>'Close the file' - } - ], + [:command, 'close', { + :label=>'Close', :underline=>0, + :helpstr=>'Close the file' + } + ], - [:separator, 'sep2'], + [:separator, 'sep2'], - [:command, 'exit', { - :label=>'Exit', :underline=>1, - :helpstr=>'Exit this application' - } - ], + [:command, 'exit', { + :label=>'Exit', :underline=>1, + :helpstr=>'Exit this application' + } + ], - nil - ]) + nil + ]) Tk::Iwidgets::Scrolledtext.new(mw.child_site).pack(:fill=>:both, :expand=>true) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb index c61071470..891761adc 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb @@ -8,109 +8,109 @@ viewmode = TkVariable.new menu_spec = [ [:menubutton, 'file', { :text=>'File', :menu=>[ - [:options, {:tearoff=>false}], - - [:command, 'new', { - :label=>'New', :helpstr=>'Open new document', - :command=>proc{puts 'NEW'} - } - ], - - [:command, 'close', { - :label=>'Close', :helpstr=>'Close current document', - :command=>proc{puts 'CLOSE'} - } - ], - - [:separator, 'sep1'], - - [:command, 'exit', { - :label=>'Exit', :helpstr=>'Exit application', - :command=>proc{exit} - } - ] + [:options, {:tearoff=>false}], + + [:command, 'new', { + :label=>'New', :helpstr=>'Open new document', + :command=>proc{puts 'NEW'} + } + ], + + [:command, 'close', { + :label=>'Close', :helpstr=>'Close current document', + :command=>proc{puts 'CLOSE'} + } + ], + + [:separator, 'sep1'], + + [:command, 'exit', { + :label=>'Exit', :helpstr=>'Exit application', + :command=>proc{exit} + } + ] ] } ], [:menubutton, 'edit', { :text=>'Edit', :menu=>[ - [:options, {:tearoff=>false}], - - [:command, 'undo', { - :label=>'Undo', :underline=>0, - :helpstr=>'Undo last command', - :command=>proc{puts 'UNDO'} - } - ], - - [:separator, 'sep2'], - - [:command, 'cut', { - :label=>'Cut', :underline=>1, - :helpstr=>'Cut selection to clipboard', - :command=>proc{puts 'CUT'} - } - ], - - [:command, 'copy', { - :label=>'Copy', :underline=>1, - :helpstr=>'Copy selection to clipboard', - :command=>proc{puts 'COPY'} - } - ], - - [:command, 'paste', { - :label=>'Paste', :underline=>0, - :helpstr=>'Paste clipboard contents', - :command=>proc{puts 'PASTE'} - } - ] + [:options, {:tearoff=>false}], + + [:command, 'undo', { + :label=>'Undo', :underline=>0, + :helpstr=>'Undo last command', + :command=>proc{puts 'UNDO'} + } + ], + + [:separator, 'sep2'], + + [:command, 'cut', { + :label=>'Cut', :underline=>1, + :helpstr=>'Cut selection to clipboard', + :command=>proc{puts 'CUT'} + } + ], + + [:command, 'copy', { + :label=>'Copy', :underline=>1, + :helpstr=>'Copy selection to clipboard', + :command=>proc{puts 'COPY'} + } + ], + + [:command, 'paste', { + :label=>'Paste', :underline=>0, + :helpstr=>'Paste clipboard contents', + :command=>proc{puts 'PASTE'} + } + ] ] } ], [:menubutton, 'options', { :text=>'Options', :menu=>[ - [:options, {:tearoff=>false, :selectcolor=>'blue'}], - - [:radiobutton, 'byName', { - :variable=>viewmode, :value=>'NAME', - :label=>'by Name', :helpstr=>'View files by name order', - :command=>proc{puts 'NAME'} - } - ], - - [:radiobutton, 'byDate', { - :variable=>viewmode, :value=>'DATE', - :label=>'by Date', :helpstr=>'View files by date order', - :command=>proc{puts 'DATE'} - } - ], - - [:cascade, 'prefs', { - :label=>'Preferences', :menu=>[ - [:command, 'colors', { - :label=>'Colors...', :helpstr=>'Change text colors', - :command=>proc{puts 'COLORS'} - } - ], - - [:command, 'fonts', { - :label=>'Fonts...', :helpstr=>'Change text font', - :command=>proc{puts 'COLORS'} - } - ] - ] - } - ] + [:options, {:tearoff=>false, :selectcolor=>'blue'}], + + [:radiobutton, 'byName', { + :variable=>viewmode, :value=>'NAME', + :label=>'by Name', :helpstr=>'View files by name order', + :command=>proc{puts 'NAME'} + } + ], + + [:radiobutton, 'byDate', { + :variable=>viewmode, :value=>'DATE', + :label=>'by Date', :helpstr=>'View files by date order', + :command=>proc{puts 'DATE'} + } + ], + + [:cascade, 'prefs', { + :label=>'Preferences', :menu=>[ + [:command, 'colors', { + :label=>'Colors...', :helpstr=>'Change text colors', + :command=>proc{puts 'COLORS'} + } + ], + + [:command, 'fonts', { + :label=>'Fonts...', :helpstr=>'Change text font', + :command=>proc{puts 'COLORS'} + } + ] + ] + } + ] ] } ] ] #mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar, -# :menubuttons=>menu_spec) +# :menubuttons=>menu_spec) mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar) mb.configure(:menubuttons=>menu_spec) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb index eec4928af..d6f229265 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb @@ -9,10 +9,10 @@ mb = Tk::Iwidgets::Menubar.new mb.menubuttons = [ [:menubutton, 'file', { :text=>'File', :menu=>[ - [:command, 'new', {:label=>'New'}], - [:command, 'close', {:label=>'Close'}], - [:separator, 'sep1'], - [:command, 'quit', {:label=>'Quit'}] + [:command, 'new', {:label=>'New'}], + [:command, 'close', {:label=>'Close'}], + [:separator, 'sep1'], + [:command, 'quit', {:label=>'Quit'}] ] } ], @@ -26,17 +26,17 @@ mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1) mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0) mb.add(:menubutton, '.options', :text=>'Options', :menu=>[ - [:radiobutton, 'byName', { - :variable=>viewmode, :value=>'NAME', :label=>'by Name'} - ], - [:radiobutton, 'byDate', { - :variable=>viewmode, :value=>'DATE', :label=>'by Date'} - ] + [:radiobutton, 'byName', { + :variable=>viewmode, :value=>'NAME', :label=>'by Name'} + ], + [:radiobutton, 'byDate', { + :variable=>viewmode, :value=>'DATE', :label=>'by Date'} + ] ]) mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[ - [:command, 'colors', {:label=>'Colors...'}], - [:command, 'fonts', {:label=>'Fonts...'}] + [:command, 'colors', {:label=>'Colors...'}], + [:command, 'fonts', {:label=>'Fonts...'}] ]) mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb index 3f7b137b1..3221dbc30 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb @@ -3,9 +3,9 @@ require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, - :labeltext=>'Messages', :labelpos=>:n, - :height=>120, :width=>550, - :savedir=>'/tmp', :textbackground=>'#d9d9d9') + :labeltext=>'Messages', :labelpos=>:n, + :height=>120, :width=>550, + :savedir=>'/tmp', :textbackground=>'#d9d9d9') mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true) mb.type_add('ERROR', :background=>'red', :foreground=>'white', :bell=>true) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb index 1aae7587e..2f0e3648a 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb @@ -3,9 +3,9 @@ require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, - :labeltext=>'Messages', :labelpos=>:n, - :height=>120, :width=>550, - :savedir=>'/tmp', :textbackground=>'#d9d9d9') + :labeltext=>'Messages', :labelpos=>:n, + :height=>120, :width=>550, + :savedir=>'/tmp', :textbackground=>'#d9d9d9') mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true) error = mb.type_add(:background=>'red', :foreground=>'white', :bell=>true) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb index 8cf373f96..6c6bfbca3 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb @@ -8,8 +8,8 @@ mainloop = Thread.new{Tk.mainloop} # Standard question message dialog used for confirmation. # md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog', - :text=>'Are you sure ? ', - :bitmap=>'questhead', :modality=>:global) + :text=>'Are you sure ? ', + :bitmap=>'questhead', :modality=>:global) md.buttonconfigure('OK', :text=>'Yes') md.buttonconfigure('Cancel', :text=>'No') @@ -33,8 +33,8 @@ md.destroy bmp = '@' + File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/text.xbm') cr = Tk::Iwidgets::Messagedialog.new(:title=>'Copyright', - :bitmap=>bmp, :imagepos=>:n, - :text=>"Copyright 200x XXX Corporation\nAll rights reserved") + :bitmap=>bmp, :imagepos=>:n, + :text=>"Copyright 200x XXX Corporation\nAll rights reserved") cr.hide('Cancel') diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb index 77f1c1dc6..e33b81eb6 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb @@ -5,7 +5,7 @@ require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, - :side=>:left, :padx=>10, :pady=>10) + :side=>:left, :padx=>10, :pady=>10) # Add two pages to the tabnotebook, # labelled "Page One" and "Page Two" diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb index e14e1207a..649de4f02 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb @@ -5,7 +5,7 @@ require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, - :side=>:top, :padx=>10, :pady=>0) + :side=>:top, :padx=>10, :pady=>0) # Add two pages to the tabnotebook, # labelled "Page One" and "Page Two" diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb index bdeafb691..1fd7a5bc0 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb @@ -3,7 +3,7 @@ require 'tk' require 'tkextlib/iwidgets' om = Tk::Iwidgets::Optionmenu.new(:labelmargin=>5, :labelpos=>:w, - :labeltext=>"Operating System :") + :labeltext=>"Operating System :") om.insert('end', 'Unix', 'VMS', 'Linux', 'OS/2', 'Windows NT', 'DOS') om.sort_ascending diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb index 902b2c4bc..6e4458e50 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb @@ -12,7 +12,7 @@ pw.pack(:fill=>:both, :expand=>true) pw.child_site_list.each{|pane| TkButton.new(pane, :text=>pane.path, :relief=>:raised, - :borderwidth=>2).pack(:fill=>:both, :expand=>true) + :borderwidth=>2).pack(:fill=>:both, :expand=>true) } pw.fraction(50,30,20) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb index 8928393a8..6779cb57d 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb @@ -12,7 +12,7 @@ pw.pack(:fill=>:both, :expand=>true) pw.child_site_list.each{|pane| TkButton.new(pane, :text=>pane.path, :relief=>:raised, - :borderwidth=>2).pack(:fill=>:both, :expand=>true) + :borderwidth=>2).pack(:fill=>:both, :expand=>true) } pw.fraction(50,30,20) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb index 7dbecc6dc..2c643e56f 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb @@ -7,7 +7,7 @@ mainloop = Thread.new{Tk.mainloop} TkOption.add('*textBackground', 'white') pd = Tk::Iwidgets::Promptdialog.new(:modality=>:global, :title=>'Password', - :labeltext=>'Password:', :show=>'*') + :labeltext=>'Password:', :show=>'*') pd.hide('Apply') if TkComm.bool(pd.activate) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb index b1f4d7d11..6e1c3fffe 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb @@ -3,7 +3,7 @@ require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Pushbutton.new(:text=>'Hello', - :command=>proc{puts 'Hello World'}, - :defaultring=>true).pack(:padx=>10, :pady=>10) + :command=>proc{puts 'Hello World'}, + :defaultring=>true).pack(:padx=>10, :pady=>10) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb index c12b66448..5219847c9 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb @@ -3,7 +3,7 @@ require 'tk' require 'tkextlib/iwidgets' sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180, - :labeltext=>'scrolledframe') + :labeltext=>'scrolledframe') cs = sf.child_site TkButton.new(cs, :text=>'Hello').pack(:pady=>10) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb index 6b0827ec8..04334b8da 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb @@ -5,9 +5,9 @@ require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') sh = Tk::Iwidgets::Scrolledhtml.new(:fontname=>'helvetica', - :linkcommand=>proc{|href| - sh.import_link(href) - }) + :linkcommand=>proc{|href| + sh.import_link(href) + }) sh.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) sh.import(Tk.getOpenFile(:title=>'select HTML document')) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb index 98f932d05..0b6975191 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb @@ -5,16 +5,16 @@ require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') slb = Tk::Iwidgets::Scrolledlistbox.new(:selectmode=>:single, - :vscrollmode=>:static, - :hscrollmode=>:dynamic, - :labeltext=>'List', - :selectioncommand=>proc{ - puts(slb.get_curselection) - }, - :dblclickcommand=>proc{ - puts('Double Click') - puts(slb.get_curselection) - }) + :vscrollmode=>:static, + :hscrollmode=>:dynamic, + :labeltext=>'List', + :selectioncommand=>proc{ + puts(slb.get_curselection) + }, + :dblclickcommand=>proc{ + puts('Double Click') + puts(slb.get_curselection) + }) slb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) slb.insert('end', *['Hello', 'Out There', 'World']) diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb index 59a96fb9f..dd1a99a82 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb @@ -3,7 +3,7 @@ require 'tk' require 'tkextlib/iwidgets' st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none, - :labeltext=>'Password File') + :labeltext=>'Password File') st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) st.import('/etc/passwd') diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb index d19970fac..a5d623ae8 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb @@ -5,12 +5,12 @@ require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') sb = Tk::Iwidgets::Selectionbox.new.pack(:padx=>10, :pady=>10, - :fill=>:both, :expand=>true) + :fill=>:both, :expand=>true) sb.insert_items('end', *['Hello', 'Out There', 'World']) TkLabel.new(sb.child_site, - :text=>'Child Site is Here').pack(:fill=>:x, :padx=>10, :pady=>10) + :text=>'Child Site is Here').pack(:fill=>:x, :padx=>10, :pady=>10) sb.insert_items(2, 'Cruel Cruel') diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb index 4fbb2aa37..f40b41918 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb @@ -5,7 +5,7 @@ require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} TkButton.new(:text=>'QUIT', - :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10) + :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10) Tk::Iwidgets::Selectiondialog.new.activate diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb b/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb index 850ddb29d..c44b5554a 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb @@ -3,15 +3,15 @@ require 'tk' require 'tkextlib/iwidgets' sh = Tk::Iwidgets::Shell.new(:modality=>:application, - :padx=>20, :pady=>20, :title=>'Shell') + :padx=>20, :pady=>20, :title=>'Shell') TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7, - :command=>proc{puts sh.activate}).pack(:padx=>10, :pady=>10) + :command=>proc{puts sh.activate}).pack(:padx=>10, :pady=>10) TkLabel.new(sh.child_site, :text=>'SHELL').pack TkButton.new(sh.child_site, :text=>'YES', - :command=>proc{sh.deactivate 'press YES'}).pack(:fill=>:x) + :command=>proc{sh.deactivate 'press YES'}).pack(:fill=>:x) TkButton.new(sh.child_site, :text=>'NO', - :command=>proc{sh.deactivate 'press NO'}).pack(:fill=>:x) + :command=>proc{sh.deactivate 'press NO'}).pack(:fill=>:x) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb index 406408174..0bcdefb76 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb @@ -5,6 +5,6 @@ require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') Tk::Iwidgets::Spinint.new(:labeltext=>'Temperature', :labelpos=>:w, :width=>5, - :fixed=>true, :range=>[32, 212]).pack(:pady=>10) + :fixed=>true, :range=>[32, 212]).pack(:pady=>10) Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb index 44e8ec303..295d38ee9 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb @@ -19,10 +19,10 @@ class Spinner_demo < TkWindow def initialize(parent=nil) @spinner = Tk::Iwidgets::Spinner.new(parent, :labeltext=>'Month : ', - :width=>10, :fixed=>10, - :validate=>proc{|c| block_input}, - :decrement=>proc{spin_month -1}, - :increment=>proc{spin_month 1}) + :width=>10, :fixed=>10, + :validate=>proc{|c| block_input}, + :decrement=>proc{spin_month -1}, + :increment=>proc{spin_month 1}) @path = @spinner @spinner.insert(0, Months[0]) end diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb index 5a9897845..6f1ecc4fa 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb @@ -5,7 +5,7 @@ require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, - :side=>:left, :padx=>10, :pady=>10) + :side=>:left, :padx=>10, :pady=>10) # Add two pages to the tabnotebook, # labelled "Page One" and "Page Two" diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb index c08603f89..4a5eef5a8 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb @@ -5,7 +5,7 @@ require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, - :side=>:top, :padx=>10, :pady=>0) + :side=>:top, :padx=>10, :pady=>0) # Add two pages to the tabnotebook, # labelled "Page One" and "Page Two" diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb index eba52ba5d..355466eb1 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb @@ -89,7 +89,7 @@ EOD ########################################## bmp_dir = File.join(File.dirname(File.expand_path(__FILE__)), - '../catalog_demo/images') + '../catalog_demo/images') ########################################## diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb b/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb index d2b6246bf..808c798ae 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb @@ -9,7 +9,7 @@ Thread.new{ } Tk::Iwidgets::Watch.new(:state=>:disabled, :showampm=>:no, - :width=>155, :height=>155){|w| + :width=>155, :height=>155){|w| w.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) # TkTimer.new(1000, -1, proc{w.show; Tk.update}).start TkTimer.new(25, -1, proc{w.show; Tk.update}).start diff --git a/ext/tk/sample/tkextlib/tcllib/datefield.rb b/ext/tk/sample/tkextlib/tcllib/datefield.rb index 1b0a29c0b..cfeca0c6d 100644 --- a/ext/tk/sample/tkextlib/tcllib/datefield.rb +++ b/ext/tk/sample/tkextlib/tcllib/datefield.rb @@ -21,8 +21,8 @@ my_date1.trace('w'){ df = Tk::Tcllib::Datefield.new(:textvariable=>my_date1) Tk.grid(TkLabel.new(:text=>'Enter a date:', :anchor=>:e), df, :sticky=>:ew) Tk.grid(TkLabel.new(:text=>'That date ia a:', :anchor=>:e), - TkLabel.new(:textvariable=>my_date2, :relief=>:sunken, :width=>12), - :sticky=>:ew) + TkLabel.new(:textvariable=>my_date2, :relief=>:sunken, :width=>12), + :sticky=>:ew) df.set_focus diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb index 6077d8ab2..053b0de08 100644 --- a/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb +++ b/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb @@ -24,7 +24,7 @@ Tk.pack(vc1,vc2,vc3, :fill=>:both, :side=>:top) ############################### s = Tk::Tcllib::Plotchart::XYPlot.new(c1, [0.0, 100.0, 10.0], - [0.0, 100.0, 20.0]) + [0.0, 100.0, 20.0]) xd = 5.0 @@ -57,7 +57,7 @@ s.save_plot "aha.ps" s = Tk::Tcllib::Plotchart::Piechart.new(c2) s.plot([ ["Long names", 10], ["Short names", 30], - ["Average", 40], ["Ultra-short names", 5] ]) + ["Average", 40], ["Ultra-short names", 5] ]) # # Note: title should be shifted up @@ -79,7 +79,7 @@ s.title "Cardioid" ############################### s = Tk::Tcllib::Plotchart::Barchart.new(hc1, %w(A B C D E), - [0.0, 10.0, 2.0], 2) + [0.0, 10.0, 2.0], 2) s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red') s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green') @@ -88,7 +88,7 @@ s.title "Arbitrary data" ############################### s = Tk::Tcllib::Plotchart::Barchart.new(hc2, %w(A B C D E), - [0.0, 20.0, 5.0], :stacked) + [0.0, 20.0, 5.0], :stacked) s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red') s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green') @@ -97,7 +97,7 @@ s.title "Stacked diagram" ############################### s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc1, [0.0, 10.0, 2.0], - %w(A B C D E), 2) + %w(A B C D E), 2) s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red') s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green') @@ -106,7 +106,7 @@ s.title "Arbitrary data" ############################### s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc2, [0.0, 20.0, 5.0], - %w(A B C D E), :stacked) + %w(A B C D E), :stacked) s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red') s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green') @@ -115,7 +115,7 @@ s.title "Stacked diagram" ############################### s = Tk::Tcllib::Plotchart::Timechart.new(vc3, "1 january 2004", - "31 december 2004", 4) + "31 december 2004", 4) s.period("Spring", "1 march 2004", "1 june 2004", 'green') s.period("Summer", "1 june 2004", "1 september 2004", 'yellow') @@ -135,7 +135,7 @@ zc2 = TkCanvas.new(z, :background=>'white', :width=>400, :height=>250) Tk.pack(zc1,zc2) s = Tk::Tcllib::Plotchart::Plot3D.new(zc1, - [0, 10, 3], [-10, 10, 10], [0, 10, 2.5]) + [0, 10, 3], [-10, 10, 10], [0, 10, 2.5]) s.title "3D Plot" s.plot_function{|x, y| @@ -146,12 +146,12 @@ s.plot_function{|x, y| } s = Tk::Tcllib::Plotchart::Plot3D.new(zc2, - [0, 10, 3], [-10, 10, 10], [0, 10, 2.5]) + [0, 10, 3], [-10, 10, 10], [0, 10, 2.5]) s.title "3D Plot - data " s.colour("green", "black") s.plot_data([ [1.0, 2.0, 1.0, 0.0], - [1.1, 3.0, 1.1, -0.5], - [3.0, 1.0, 4.0, 5.0] ]) + [1.1, 3.0, 1.1, -0.5], + [3.0, 1.0, 4.0, 5.0] ]) ############################### diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb index 3fd57f380..33a6f2994 100644 --- a/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb +++ b/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb @@ -13,21 +13,21 @@ Tk.pack(c1,c2, :fill=>:both, :side=>:top) # Set up a strip chart ############################### slipchart = Tk::Tcllib::Plotchart::Stripchart.new(c1, [0.0, 100.0, 10.0], - [0.0, 100.0, 20.0]) + [0.0, 100.0, 20.0]) TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object - slipchart, xold, xd, yold, yd = obj.return_value - xnew = xold + xd - ynew = yold + (rand() - 0.5) * yd - ynew2 = yold + (rand() - 0.5) * 2.0 * yd - slipchart.plot('series1', xnew, ynew) - slipchart.plot('series2', xnew, ynew2) - obj.stop if xnew >= 200 - [slipchart, xnew, xd, ynew, yd] # return_value - }).start(100, proc{ - # init return_value - [slipchart, 0.0, 15.0, 50.0, 30.0] - }) + slipchart, xold, xd, yold, yd = obj.return_value + xnew = xold + xd + ynew = yold + (rand() - 0.5) * yd + ynew2 = yold + (rand() - 0.5) * 2.0 * yd + slipchart.plot('series1', xnew, ynew) + slipchart.plot('series2', xnew, ynew2) + obj.stop if xnew >= 200 + [slipchart, xnew, xd, ynew, yd] # return_value + }).start(100, proc{ + # init return_value + [slipchart, 0.0, 15.0, 50.0, 30.0] + }) slipchart.title "Aha!" @@ -35,7 +35,7 @@ slipchart.title "Aha!" # Set up an isometric plot ############################### s = Tk::Tcllib::Plotchart::IsometricPlot.new(c2, [0.0, 100.0], [0.0, 200.0], - :noaxes) + :noaxes) s.set_zoom_pan @@ -51,7 +51,7 @@ h = TkToplevel.new(:title=>'h') c = TkCanvas.new(h, :bg=>'white', :width=>400, :height=>200).pack(:fill=>:both) s = Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0], - [0.0, 100.0, 20.0]) + [0.0, 100.0, 20.0]) s.dataconfig('series1', :colour=>'red', :type=>:symbol) s.dataconfig('series2', :colour=>'green', :type=>:both) diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb index 3b74b1f59..2b5c7642b 100644 --- a/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb +++ b/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb @@ -8,9 +8,9 @@ require 'tkextlib/tcllib/plotchart' ############################### Tk::Tcllib::Plotchart::Stripchart.new([0.0, 100.0, 10.0], - [0.0, 100.0, 20.0], - :background=>'white', - :width=>400, :height=>200){|chart| + [0.0, 100.0, 20.0], + :background=>'white', + :width=>400, :height=>200){|chart| title "Aha!" pack(:fill=>:both, :side=>:top) @@ -21,26 +21,26 @@ Tk::Tcllib::Plotchart::Stripchart.new([0.0, 100.0, 10.0], yd = 30.0 TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object - xold, yold = obj.return_value - xnew = xold + xd - ynew = yold + (rand() - 0.5) * yd - ynew2 = yold + (rand() - 0.5) * 2.0 * yd + xold, yold = obj.return_value + xnew = xold + xd + ynew = yold + (rand() - 0.5) * yd + ynew2 = yold + (rand() - 0.5) * 2.0 * yd - series1.plot(xnew, ynew) - series2.plot(xnew, ynew2) + series1.plot(xnew, ynew) + series2.plot(xnew, ynew2) - obj.stop if xnew >= 200 + obj.stop if xnew >= 200 - [xnew, ynew] # return_value - }).start(100, proc{ [0.0, 50.0] }) # init return_value + [xnew, ynew] # return_value + }).start(100, proc{ [0.0, 50.0] }) # init return_value } ############################### # Set up an isometric plot ############################### Tk::Tcllib::Plotchart::IsometricPlot.new([0.0, 100.0], [0.0, 200.0], :noaxes, - :background=>'white', - :width=>400, :height=>200){|chart| + :background=>'white', + :width=>400, :height=>200){|chart| pack(:fill=>:both, :side=>:top) set_zoom_pan @@ -55,17 +55,17 @@ Tk::Tcllib::Plotchart::IsometricPlot.new([0.0, 100.0], [0.0, 200.0], :noaxes, ############################### TkToplevel.new(:title=>'h'){|h| Tk::Tcllib::Plotchart::XYPlot.new(h, [0.0, 100.0, 10.0], - [0.0, 100.0, 20.0], - :bg=>'white', - :width=>400, :height=>200){|chart| + [0.0, 100.0, 20.0], + :bg=>'white', + :width=>400, :height=>200){|chart| pack(:fill=>:both) yconfig(:format=>"%12.2e") series1 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'red', - :type=>:symbol) + :type=>:symbol) series2 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'green', - :type=>:both) + :type=>:both) x = 5.0 %w(plus cross circle up down dot upfilled downfilled).each{|sym| diff --git a/ext/tk/sample/tkextlib/tcllib/xyplot.rb b/ext/tk/sample/tkextlib/tcllib/xyplot.rb index 116609e34..8f8c3eb88 100644 --- a/ext/tk/sample/tkextlib/tcllib/xyplot.rb +++ b/ext/tk/sample/tkextlib/tcllib/xyplot.rb @@ -6,7 +6,7 @@ require 'tkextlib/tcllib/plotchart' TkCanvas.new(:background=>'white', :width=>400, :height=>200){|c| pack(:fill=>:both) Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0], - [0.0, 100.0, 20.0]){ + [0.0, 100.0, 20.0]){ [ [0.0, 32.0], [10.0, 50.0], [25.0, 60.0], [78.0, 11.0] ].each{|x, y| plot('series1', x, y) } diff --git a/ext/tk/sample/tkextlib/tkHTML/hv.rb b/ext/tk/sample/tkextlib/tkHTML/hv.rb index cf93ad3ba..d9f3ea7d7 100644 --- a/ext/tk/sample/tkextlib/tkHTML/hv.rb +++ b/ext/tk/sample/tkextlib/tkHTML/hv.rb @@ -130,12 +130,12 @@ applet_cmd = proc{|w, arglist| # Construct the main HTML viewer # html = Tk::HTML_Widget.new(:padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>image_cmd, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :underlinehyperlinks=>0, - :bg=>'white', :tablerelief=>:raised) + :formcommand=>form_cmd, + :imagecommand=>image_cmd, + :scriptcommand=>script_cmd, + :appletcommand=>applet_cmd, + :underlinehyperlinks=>0, + :bg=>'white', :tablerelief=>:raised) vscr = html.yscrollbar(TkScrollbar.new) hscr = html.xscrollbar(TkScrollbar.new) @@ -162,7 +162,7 @@ read_file = proc{|name| ret = nil fp = nil Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", - :type=>:ok) + :type=>:ok) ensure fp.close if fp end @@ -212,15 +212,15 @@ html.clipping_window.bind('1', href_binding, '%x %y') # marking text with the mouse and copying to the clipboard just with tkhtml2.0 working html.clipping_window.bind('B1-Motion', proc{|w, x, y| - w.selection_set(priv['mark'], "@#{x},#{y}") - TkClipboard.clear - # avoid tkhtml0.0 errors - # anyone can fix this for tkhtml0.0 - begin - TkClipboard.append(TkSelection.get) - rescue - end - }, '%W %x %y') + w.selection_set(priv['mark'], "@#{x},#{y}") + TkClipboard.clear + # avoid tkhtml0.0 errors + # anyone can fix this for tkhtml0.0 + begin + TkClipboard.append(TkSelection.get) + rescue + end + }, '%W %x %y') # This procedure is called when the user selects the File/Open # menu option. @@ -249,14 +249,14 @@ refresh = proc{|*args| # top of a hyperlink. # Tk::HTML_Widget::ClippingWindow.bind('Motion', proc{|w, x, y| - parent = w.winfo_parent - url = parent.href(x, y) - unless url.empty? - parent[:cursor] = 'hand2' - else - parent[:cursor] = '' - end - }, '%W %x %y') + parent = w.winfo_parent + url = parent.href(x, y) + unless url.empty? + parent[:cursor] = 'hand2' + else + parent[:cursor] = '' + end + }, '%W %x %y') # # Setup menu # @@ -279,18 +279,18 @@ mbar = Tk.root.add_menubar(menu_spec) # Setup trace # ul_hyper.trace('w', proc{ - html[:underlinehyperlinks] = ul_hyper.value - refresh.call - }) + html[:underlinehyperlinks] = ul_hyper.value + refresh.call + }) show_tbl.trace('w', proc{ - if show_tbl.bool - html[:tablerelief] = :flat - else - html[:tablerelief] = :raised - end - refresh.call - }) + if show_tbl.bool + html[:tablerelief] = :flat + else + html[:tablerelief] = :raised + end + refresh.call + }) show_img.trace('w', refresh) diff --git a/ext/tk/sample/tkextlib/tkHTML/ss.rb b/ext/tk/sample/tkextlib/tkHTML/ss.rb index e71c26f7d..179bdc13c 100644 --- a/ext/tk/sample/tkextlib/tkHTML/ss.rb +++ b/ext/tk/sample/tkextlib/tkHTML/ss.rb @@ -198,7 +198,7 @@ read_file = proc{|name| ret = nil fp = nil Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", - :type=>:ok) + :type=>:ok) ensure fp.close if fp end @@ -291,20 +291,20 @@ fullscreen = proc{ width = root.winfo_screenwidth height = root.winfo_screenheight fswin = TkToplevel.new(:overrideredirect=>true, - :geometry=>"#{width}x#{height}+0+0") + :geometry=>"#{width}x#{height}+0+0") html_fs = Tk::HTML_Widget.new(fswin, :padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>proc{image_cmd.call(0)}, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :hyperlinkcommand=>hyper_cmd, - :bg=>'white', :tablerelief=>:raised, - :appletcommand=>proc{|*args| - run_applet('big', *args) - }, - :fontcommand=>pick_font_fs, - :cursor=>:tcross) { + :formcommand=>form_cmd, + :imagecommand=>proc{image_cmd.call(0)}, + :scriptcommand=>script_cmd, + :appletcommand=>applet_cmd, + :hyperlinkcommand=>hyper_cmd, + :bg=>'white', :tablerelief=>:raised, + :appletcommand=>proc{|*args| + run_applet('big', *args) + }, + :fontcommand=>pick_font_fs, + :cursor=>:tcross) { pack(:fill=>:both, :expand=>true) token_handler('meta', proc{|*args| meta.call(self, *args)}) } @@ -361,19 +361,19 @@ menu_spec = [ mbar = root.add_menubar(menu_spec) html = Tk::HTML_Widget.new(:width=>512, :height=>384, - :padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>proc{|*args| - image_cmd.call(1, *args) - }, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :hyperlinkcommand=>hyper_cmd, - :fontcommand=>pick_font, - :appletcommand=>proc{|*args| - run_applet.call('small', *args) - }, - :bg=>'white', :tablerelief=>:raised) + :padx=>5, :pady=>9, + :formcommand=>form_cmd, + :imagecommand=>proc{|*args| + image_cmd.call(1, *args) + }, + :scriptcommand=>script_cmd, + :appletcommand=>applet_cmd, + :hyperlinkcommand=>hyper_cmd, + :fontcommand=>pick_font, + :appletcommand=>proc{|*args| + run_applet.call('small', *args) + }, + :bg=>'white', :tablerelief=>:raised) html.token_handler('meta', proc{|*args| meta.call(html, *args)}) diff --git a/ext/tk/sample/tkextlib/tktable/basic.rb b/ext/tk/sample/tkextlib/tktable/basic.rb index a7dfe2a78..ece46b318 100644 --- a/ext/tk/sample/tkextlib/tktable/basic.rb +++ b/ext/tk/sample/tkextlib/tktable/basic.rb @@ -23,19 +23,19 @@ cols = 8 lbl = TkLabel.new(:text=>"TkTable v1 Example") table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, - :width=>6, :height=>6, - :titlerows=>1, :titlecols=>2, - :roworigin=>-1, :colorigin=>-2, - :rowstretchmode=>:last, :colstretchmode=>:last, - :rowtagcommand=>proc{|row| - row = Integer(row) - return 'OddRow' if row>0 && row%2 == 1 - }, - :coltagcommand=>proc{|col| - col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 - }, - :selectmode=>:extended, :sparsearray=>false) + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>2, + :roworigin=>-1, :colorigin=>-2, + :rowstretchmode=>:last, :colstretchmode=>:last, + :rowtagcommand=>proc{|row| + row = Integer(row) + return 'OddRow' if row>0 && row%2 == 1 + }, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :sparsearray=>false) sx = table.xscrollbar(TkScrollbar.new) sy = table.yscrollbar(TkScrollbar.new) diff --git a/ext/tk/sample/tkextlib/tktable/buttons.rb b/ext/tk/sample/tkextlib/tktable/buttons.rb index b6995bb54..b21e8673c 100644 --- a/ext/tk/sample/tkextlib/tktable/buttons.rb +++ b/ext/tk/sample/tkextlib/tktable/buttons.rb @@ -15,11 +15,11 @@ rows = 20 cols = 20 table = Tk::TkTable.new(:rows=>rows + 1, :cols=>cols + 1, - :variable=>tab, :titlerows=>1, :titlecols=>1, - :roworigin=>-1, :colorigin=>-1, - :colwidth=>4, :width=>8, :height=>8, - :cursor=>'top_left_arrow', :borderwidth=>2, - :flashmode=>false, :state=>:disabled) + :variable=>tab, :titlerows=>1, :titlecols=>1, + :roworigin=>-1, :colorigin=>-1, + :colwidth=>4, :width=>8, :height=>8, + :cursor=>'top_left_arrow', :borderwidth=>2, + :flashmode=>false, :state=>:disabled) sx = table.xscrollbar(TkScrollbar.new) sy = table.yscrollbar(TkScrollbar.new) @@ -40,25 +40,25 @@ table.bind('Leave', proc{|w| w.selection_clear_all}, '%W') # highlight the cell under the mouse table.bind('Motion', proc{|w, x, y| - Tk.callback_break if w.selection_include?(TkComm._at(x,y)) - w.selection_clear_all - w.selection_set(TkComm._at(x,y)) - Tk.callback_break - ## "break" prevents the call to tkTableCheckBorder - }, '%W %x %y') + Tk.callback_break if w.selection_include?(TkComm._at(x,y)) + w.selection_clear_all + w.selection_set(TkComm._at(x,y)) + Tk.callback_break + ## "break" prevents the call to tkTableCheckBorder + }, '%W %x %y') # mousebutton 1 toggles the value of the cell # use of "selection includes" would work here table.bind('1', proc{|w, x, y| - #rc = w.curselection[0] - rc = w.index(TkComm._at(x,y)) - if tab[rc] == 'ON' - tab[rc] = 'OFF' - w.tag_cell('OFF', rc) - else - tab[rc] = 'ON' - w.tag_cell('ON', rc) - end}, '%W %x %y') + #rc = w.curselection[0] + rc = w.index(TkComm._at(x,y)) + if tab[rc] == 'ON' + tab[rc] = 'OFF' + w.tag_cell('OFF', rc) + else + tab[rc] = 'ON' + w.tag_cell('ON', rc) + end}, '%W %x %y') # inititialize the array, titles, and celltags diff --git a/ext/tk/sample/tkextlib/tktable/command.rb b/ext/tk/sample/tkextlib/tktable/command.rb index 950bc0ccb..eb9ddffb7 100644 --- a/ext/tk/sample/tkextlib/tktable/command.rb +++ b/ext/tk/sample/tkextlib/tktable/command.rb @@ -28,44 +28,44 @@ ent_var = TkVariable.new entry = TkEntry.new(:textvariable=>ent_var) table = Tk::TkTable.new(:rows=>rows, :cols=>cols, - :command=>[proc{|mode, cell, val| - if (mode == :w) - data[cell] = val - else - begin - data[cell] # exist - rescue - '' # not exist - end - end - }, '%i %C %s'], - :width=>6, :height=>6, - :titlerows=>1, :titlecols=>1, - :roworigin=>-1, :colorigin=>-1, - :rowstretchmode=>:last, :colstretchmode=>:last, - :rowtagcommand=>proc{|row| - row = Integer(row) - return 'OddRow' if row>0 && row%2 == 1 - }, - :coltagcommand=>proc{|col| - col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 - }, - :selectmode=>:extended, :flashmode=>true, - :rowstretch=>:unset, :colstretch=>:unset, - :browsecommand=>[proc{|w, s| - cur_var.value = s - ent_var.value = w.get(s) - }, '%W %S'], - :validate=>true, - :validatecommand=>proc{|e| - ent_var.value = e.new_value; true - }) + :command=>[proc{|mode, cell, val| + if (mode == :w) + data[cell] = val + else + begin + data[cell] # exist + rescue + '' # not exist + end + end + }, '%i %C %s'], + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>1, + :roworigin=>-1, :colorigin=>-1, + :rowstretchmode=>:last, :colstretchmode=>:last, + :rowtagcommand=>proc{|row| + row = Integer(row) + return 'OddRow' if row>0 && row%2 == 1 + }, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :flashmode=>true, + :rowstretch=>:unset, :colstretch=>:unset, + :browsecommand=>[proc{|w, s| + cur_var.value = s + ent_var.value = w.get(s) + }, '%W %S'], + :validate=>true, + :validatecommand=>proc{|e| + ent_var.value = e.new_value; true + }) =begin - :validatecommand=>[ - proc{|s| - ent_var.value = s; true - }, '%S']) + :validatecommand=>[ + proc{|s| + ent_var.value = s; true + }, '%S']) =end sx = table.xscrollbar(TkScrollbar.new) diff --git a/ext/tk/sample/tkextlib/tktable/debug.rb b/ext/tk/sample/tkextlib/tktable/debug.rb index 30508acea..3200c1c77 100644 --- a/ext/tk/sample/tkextlib/tktable/debug.rb +++ b/ext/tk/sample/tkextlib/tktable/debug.rb @@ -24,16 +24,16 @@ cols = 20 lbl = TkLabel.new(:text=>"TkTable v2 Example") table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, - :width=>6, :height=>6, - :titlerows=>1, :titlecols=>2, - :roworigin=>-5, :colorigin=>-2, - :coltagcommand=>proc{|col| - col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 - }, - :selectmode=>:extended, :flashmode=>true, - :rowstretch=>:unset, :colstretch=>:unset, - :selecttitles=>false, :drawmode=>:single) + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>2, + :roworigin=>-5, :colorigin=>-2, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :flashmode=>true, + :rowstretch=>:unset, :colstretch=>:unset, + :selecttitles=>false, :drawmode=>:single) sx = table.xscrollbar(TkScrollbar.new) sy = table.yscrollbar(TkScrollbar.new) @@ -68,8 +68,8 @@ table.tag_cell('dis', [2,1], [1,-1], [3,0]) table.set_width([-2,8], [-1,9], [0, 12], [4, 14]) table.set([1,1], "multi-line\ntext\nmight be\ninteresting", - [3,2], "more\nmulti-line\nplaying\n", - [2,2], "null\0byte") + [3,2], "more\nmulti-line\nplaying\n", + [2,2], "null\0byte") # This is in the row span l = TkLabel.new(table, :text=>'Window s', :bg=>'yellow') diff --git a/ext/tk/sample/tkextlib/tktable/dynarows.rb b/ext/tk/sample/tkextlib/tktable/dynarows.rb index 35359046f..d083e2655 100644 --- a/ext/tk/sample/tkextlib/tktable/dynarows.rb +++ b/ext/tk/sample/tkextlib/tktable/dynarows.rb @@ -25,21 +25,21 @@ def table_validate(w, idx) time = Tk.tk_call('clock', 'scan', val) date = [] Tk.tk_call('clock', 'format', time, - :format=>'%m %d %Y').split(' ').each{|item| + :format=>'%m %d %Y').split(' ').each{|item| date << item.sub(/^\s*0*/,'') } w.set(idx, date.join('/')) if row == nrows - 1 if w.get([row,1]) != '' && w.get([row,2]) != '' - w.tag_row_reset(row) - w.set([row,0], row) - nrows += 1 - row += 1 - w.configure(:rows=>nrows) - w.tag_row('unset', row) - w.set([row,0], '*') - w.see([row,1]) - w.activate([row,1]) + w.tag_row_reset(row) + w.set([row,0], row) + nrows += 1 + row += 1 + w.configure(:rows=>nrows) + w.tag_row('unset', row) + w.set([row,0], '*') + w.see([row,1]) + w.activate([row,1]) end end rescue @@ -55,13 +55,13 @@ end lbl = TkLabel.new(:text=>"Dynamic Date Validated Rows") table = Tk::TkTable.new(:rows=>2, :cols=>3, :cache=>1, :selecttype=>:row, - :titlerows=>1, :titlecols=>1, :height=>5, - :colstretch=>:unset, :rowstretch=>:unset, - :autoclear=>true, - :browsecommand=>[ - proc{|w,s| table_validate(w, s)}, - '%W %s' - ]) + :titlerows=>1, :titlecols=>1, :height=>5, + :colstretch=>:unset, :rowstretch=>:unset, + :autoclear=>true, + :browsecommand=>[ + proc{|w,s| table_validate(w, s)}, + '%W %s' + ]) table.set([0,1], 'Begin', [0,2], 'End', [1,0], '*') table.tag_configure('unset', :fg=>'#008811') table.tag_configure('title', :fg=>'red') diff --git a/ext/tk/sample/tkextlib/tktable/maxsize.rb b/ext/tk/sample/tkextlib/tktable/maxsize.rb index a2c5f606a..c9ca745ee 100644 --- a/ext/tk/sample/tkextlib/tktable/maxsize.rb +++ b/ext/tk/sample/tkextlib/tktable/maxsize.rb @@ -24,15 +24,15 @@ cols = 10 lbl = TkLabel.new(:text=>"TkTable v2 Example") table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, - :width=>6, :height=>8, - :titlerows=>1, :titlecols=>1, - :coltagcommand=>proc{|col| - col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 - }, - :selectmode=>:extended, - :colstretch=>:unset, :rowstretch=>:unset, - :selecttitles=>false, :drawmode=>:slow) + :width=>6, :height=>8, + :titlerows=>1, :titlecols=>1, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, + :colstretch=>:unset, :rowstretch=>:unset, + :selecttitles=>false, :drawmode=>:slow) sx = table.xscrollbar(TkScrollbar.new) sy = table.yscrollbar(TkScrollbar.new) diff --git a/ext/tk/sample/tkextlib/tktable/spreadsheet.rb b/ext/tk/sample/tkextlib/tktable/spreadsheet.rb index 5f3ba63bb..9da896f5a 100644 --- a/ext/tk/sample/tkextlib/tktable/spreadsheet.rb +++ b/ext/tk/sample/tkextlib/tktable/spreadsheet.rb @@ -31,11 +31,11 @@ def fill_table(tbl_list, page, r=10, c=10) (0...r).each{|i| (0...c).each{|j| if i!=0 && j!=0 - ary[i,j] = "#{page} #{i},#{j}" + ary[i,j] = "#{page} #{i},#{j}" elsif i!=0 - ary[i,j] = i.to_s + ary[i,j] = i.to_s else - ary[i,j] = (64+j).chr + ary[i,j] = (64+j).chr end } } @@ -68,16 +68,16 @@ fill_table(table_list, page.value) fill_table(table_list, 'BB', Integer(rows/2), Integer(cols/2)) table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :width=>5, :height=>5, - :variable=>table_list[page.value], - :titlerows=>1, :titlecols=>1, - :coltagcommand=>proc{|n| colorize(n)}, - :flashmode=>true, :selectmode=>:extended, - :colstretch=>:unset, :rowstretch=>:unset, - :browsecommand=>proc{|e| cur_var.value = e.new_index}) + :variable=>table_list[page.value], + :titlerows=>1, :titlecols=>1, + :coltagcommand=>proc{|n| colorize(n)}, + :flashmode=>true, :selectmode=>:extended, + :colstretch=>:unset, :rowstretch=>:unset, + :browsecommand=>proc{|e| cur_var.value = e.new_index}) page.trace(:w, proc{|var, elem, op| - changepage(table_list, table, entry, color, var, elem, op) - }) + changepage(table_list, table, entry, color, var, elem, op) + }) table.tag_configure('colored', :bg=>color[page.value]) table.tag_configure('title', :fg=>'red', :relief=>:groove) @@ -107,29 +107,29 @@ Tk.root.grid_rowconfig(2, :weight=>1) table.grid_configure(:sticky=>:news) entry.bind('Return', proc{ - r = table.row_index(:active) - c = table.col_index(:active) - rmax = table[:rows] - cmax = table[:cols] - - c += 1 - if c == cmax - c = table[:titlecols] - r += 1 - if r == rmax - r = table[:titlerows] - end - end - table.activate([r, c]) - table.see('active') - }) + r = table.row_index(:active) + c = table.col_index(:active) + rmax = table[:rows] + cmax = table[:cols] + + c += 1 + if c == cmax + c = table[:titlecols] + r += 1 + if r == rmax + r = table[:titlerows] + end + end + table.activate([r, c]) + table.see('active') + }) menu = TkMenu.new m_file = TkMenu.new(menu) Tk.root.menu(menu) menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file) m_file.add(:command, :label=>'Fill Array', - :command=>proc{ fill_table(table_list, page.value) }) + :command=>proc{ fill_table(table_list, page.value) }) m_file.add(:command, :label=>'Quit', :command=>proc{exit}) puts "Table is #{table.path} with array #{(table['variable'])}" diff --git a/ext/tk/sample/tkextlib/tktable/valid.rb b/ext/tk/sample/tkextlib/tktable/valid.rb index 457044166..e5d3f11d8 100644 --- a/ext/tk/sample/tkextlib/tktable/valid.rb +++ b/ext/tk/sample/tkextlib/tktable/valid.rb @@ -54,15 +54,15 @@ end lbl = TkLabel.new(:text=>"TkTable v1 Validated Table Example") table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :cache=>1, - :width=>5, :height=>5, :titlerows=>1, :titlecols=>1, - :coltagcommand=>proc{|n| colorize(n)}, - :flashmode=>true, :selectmode=>:extended, - :colstretch=>:unset, :rowstretch=>:unset, - :validate=>true, - :validatecommand=>proc{|e| - unless e.widget.tag_include?('title', e.index) - validate_proc(e.column, e.new_value) - end } ) + :width=>5, :height=>5, :titlerows=>1, :titlecols=>1, + :coltagcommand=>proc{|n| colorize(n)}, + :flashmode=>true, :selectmode=>:extended, + :colstretch=>:unset, :rowstretch=>:unset, + :validate=>true, + :validatecommand=>proc{|e| + unless e.widget.tag_include?('title', e.index) + validate_proc(e.column, e.new_value) + end } ) fill_headers(table) diff --git a/ext/tk/sample/tkextlib/vu/canvItems.rb b/ext/tk/sample/tkextlib/vu/canvItems.rb index c3e563058..33acf4f7e 100644 --- a/ext/tk/sample/tkextlib/vu/canvItems.rb +++ b/ext/tk/sample/tkextlib/vu/canvItems.rb @@ -10,63 +10,63 @@ xbm = File.join(File.dirname(File.expand_path(__FILE__)), 'm128_000.xbm') sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ] l0 = TkLabel.new(:width=>128, :height=>128, - :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) + :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) c0 = TkCanvas.new(:width=>80, :height=>80, - :insertwidth=>0, :highlightthickness=>0, - :selectborderwidth=>0, :borderwidth=>2, - :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5, - :anchor=>:c) + :insertwidth=>0, :highlightthickness=>0, + :selectborderwidth=>0, :borderwidth=>2, + :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5, + :anchor=>:c) st = Tk::Vu::TkcStripchart.new(c0, 3, 3, 80, 80, - :background=>"#b7c0d7", :fill=>'slategray3', - :jumpscroll=>1, :outline=>'black', - :scaleline=>'blue', :stripline=>'red', - :selected=>1, :values=>sval) + :background=>"#b7c0d7", :fill=>'slategray3', + :jumpscroll=>1, :outline=>'black', + :scaleline=>'blue', :stripline=>'red', + :selected=>1, :values=>sval) TkcText.create(c0, 40, 40, - :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text') + :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text') l1 = TkLabel.new(:width=>128, :height=>128, - :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) + :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) c1 = TkCanvas.new(:width=>80, :height=>80, - :insertwidth=>0, :highlightthickness=>0, - :selectborderwidth=>0, :borderwidth=>2, - :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5, - :anchor=>:c) + :insertwidth=>0, :highlightthickness=>0, + :selectborderwidth=>0, :borderwidth=>2, + :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5, + :anchor=>:c) bar1 = Tk::Vu::TkcBarchart.new(c1, 3, 3, 80, 80, - :background=>"#b7c0d7", :scalevalue=>10.0, - :autocolor=>true, :selected=>1, - :outline=>'black', :barline=>'yellow', - :scalelinestyle=>0) + :background=>"#b7c0d7", :scalevalue=>10.0, + :autocolor=>true, :selected=>1, + :outline=>'black', :barline=>'yellow', + :scalelinestyle=>0) bar2 = Tk::Vu::TkcBarchart.new(c1, 53, 3, 80, 80, - :background=>"#b7c0d7", :scalevalue=>10.0, - :autocolor=>true, :selected=>1, - :outline=>'black', :fill=>"#b7c0d7", - :barline=>'red', :scalelinestyle=>22) + :background=>"#b7c0d7", :scalevalue=>10.0, + :autocolor=>true, :selected=>1, + :outline=>'black', :fill=>"#b7c0d7", + :barline=>'red', :scalelinestyle=>22) l2 = TkLabel.new(:width=>128, :height=>128, - :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) + :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left) c2 = TkCanvas.new(:width=>80, :height=>80, - :insertwidth=>0, :highlightthickness=>0, - :selectborderwidth=>0, :borderwidth=>2, - :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5, - :anchor=>:c) + :insertwidth=>0, :highlightthickness=>0, + :selectborderwidth=>0, :borderwidth=>2, + :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5, + :anchor=>:c) begin stick = Tk::Vu::TkcSticker.new(c2, 3, 3, 80, 80, - :text=>"Tcl/Tk", :space=>0, :color=>'red', - :outline=>'red', :font=>'Helvetica 14 bold', - :fill=>'', :stipple=>'', :bar=>'blue', - :orient=>:vertical, :anchor=>:s, - :relheight=>1.0, :relwidth=>0.15, - :relx=>0.1, :rely=>0.0) + :text=>"Tcl/Tk", :space=>0, :color=>'red', + :outline=>'red', :font=>'Helvetica 14 bold', + :fill=>'', :stipple=>'', :bar=>'blue', + :orient=>:vertical, :anchor=>:s, + :relheight=>1.0, :relwidth=>0.15, + :relx=>0.1, :rely=>0.0) rescue stick = nil TkcText.new(c2, 40, 10, :text=>"No Sticker Item") diff --git a/ext/tk/sample/tkextlib/vu/canvSticker.rb b/ext/tk/sample/tkextlib/vu/canvSticker.rb index 431ca56fd..e2cd60497 100644 --- a/ext/tk/sample/tkextlib/vu/canvSticker.rb +++ b/ext/tk/sample/tkextlib/vu/canvSticker.rb @@ -15,7 +15,7 @@ begin st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) rescue Tk.messageBox(:type=>'ok', :title=>"No sticker Item", - :message=>"This build of vu does not include the sticker item") + :message=>"This build of vu does not include the sticker item") exit end #st.delete @@ -57,7 +57,7 @@ steps << proc{ steps << proc{ puts 'A vertical bar appears in the lower right region and text jumps to the left.' st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7, - :relx=>0.6, :rely=>0.3, :bar=>'red') + :relx=>0.6, :rely=>0.3, :bar=>'red') } steps << proc{ diff --git a/ext/tk/sample/tkextlib/vu/canvSticker2.rb b/ext/tk/sample/tkextlib/vu/canvSticker2.rb index 1e6b59a18..f54e74866 100644 --- a/ext/tk/sample/tkextlib/vu/canvSticker2.rb +++ b/ext/tk/sample/tkextlib/vu/canvSticker2.rb @@ -11,7 +11,7 @@ begin st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) rescue Tk.messageBox(:type=>'ok', :title=>"No sticker Item", - :message=>"This build of vu does not include the sticker item") + :message=>"This build of vu does not include the sticker item") exit end @@ -21,7 +21,7 @@ c.destroy #--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center} #sti_conf = [ [10, 10, 180, 180], "Sticker äöüß@²³¼½¾", :center ] -#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ] +#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ] sti_conf = [ [10, 10, 350, 350], Tk::UTF8_String("Sticker äöüß@²³¼½¾"), :center ] txt_conf = [ [250, 250], @@ -65,32 +65,32 @@ txt = TkcText.new(c, txt_conf[0]){ anchor txt_conf[2] disabledfill '' disabledstipple '' - fill 'blue' - font fnt + fill 'blue' + font fnt justify :left offset '0,0' state '' stipple '' - tags ['tex'] + tags ['tex'] text txt_conf[1] width 0 } #---BINDINGS c.bind('2', proc{ - sti[:orient] = :horizontal - txt[:width] = 0 # horizontal + sti[:orient] = :horizontal + txt[:width] = 0 # horizontal }) c.bind('3', proc{ - sti[:orient] = :vertical - txt[:width] = 1 # top down + sti[:orient] = :vertical + txt[:width] = 1 # top down }) Tk.root.bind('p', proc{ - c.postscript(:file=>'DEMO.ps') - puts "DEMO.ps printed" - }) + c.postscript(:file=>'DEMO.ps') + puts "DEMO.ps printed" + }) Tk.root.bind('q', proc{exit}) diff --git a/ext/tk/sample/tkextlib/vu/dial.rb b/ext/tk/sample/tkextlib/vu/dial.rb index d2ae0990c..09bd3e918 100644 --- a/ext/tk/sample/tkextlib/vu/dial.rb +++ b/ext/tk/sample/tkextlib/vu/dial.rb @@ -13,61 +13,61 @@ v_linked = TkVariable.new v_needle = TkVariable.new volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to=>0.1, - :resolution=>0.001, :minortickinterval=>0.01, - :tickinterval=>0.1, :beginangle=>-20, - :endangle=>260, :variable=>v_volume) + :resolution=>0.001, :minortickinterval=>0.01, + :tickinterval=>0.1, :beginangle=>-20, + :endangle=>260, :variable=>v_volume) speed = Tk::Vu::Dial.new(:label=>"Speed", :from=>2000, :to=>100, - :resolution=>10, :tickinterval=>100, - :minortickinterval=>0, :variable=>v_speed, - :showtags=>:label, :showvalue=>false) + :resolution=>10, :tickinterval=>100, + :minortickinterval=>0, :variable=>v_speed, + :showtags=>:label, :showvalue=>false) speed.set_tag_constrain(100, 'Fast', 2000, 'Slow') fwd = Tk::Vu::Dial.new(:from=>-10.0, :to=>-20.0, :resolution=>0.1, - :tickinterval=>5.0, :minortickinterval=>1.0, - :variable=>v_dir) + :tickinterval=>5.0, :minortickinterval=>1.0, + :variable=>v_dir) rev = Tk::Vu::Dial.new(:from=>-20.0, :to=>-10.0, :resolution=>0.1, - :tickinterval=>5.0, :minortickinterval=>1.0, - :variable=>v_dir) + :tickinterval=>5.0, :minortickinterval=>1.0, + :variable=>v_dir) small = Tk::Vu::Dial.new(:font=>"Helvetica -10", :from=>0, :to=>10, - :resolution=>0.05, :tickinterval=>2, - :minortickinterval=>0.5, :radius=>20, - :dialcolor=>'red2', :activebackground=>'red', - :variable=>v_rot) + :resolution=>0.05, :tickinterval=>2, + :minortickinterval=>0.5, :radius=>20, + :dialcolor=>'red2', :activebackground=>'red', + :variable=>v_rot) large = Tk::Vu::Dial.new(:font=>"Helvetica -8", :from=>0, :to=>10, - :resolution=>0.05, :tickinterval=>1, - :minortickinterval=>0.25, :radius=>40, - :dialcolor=>'red2', :activebackground=>'red', - :variable=>v_rot) + :resolution=>0.05, :tickinterval=>1, + :minortickinterval=>0.25, :radius=>40, + :dialcolor=>'red2', :activebackground=>'red', + :variable=>v_rot) turn = Tk::Vu::Dial.new(:needlecolor=>'red', :label=>"Linked", - :variable=>v_linked) + :variable=>v_linked) scale = TkScale.new(:label=>"Linked", :variable=>v_linked) d1 = Tk::Vu::Dial.new(:resolution=>0.0001, :from=>-0.1, :to=>0.1, - :showvalue=>true, :minortickinterval=>0.01, - :tickinterval=>0.1, :radius=>30, :label=>"Dial", - :beginangle=>-20, :endangle=>260, :variable=>v_needle, - :relief=>:raised) + :showvalue=>true, :minortickinterval=>0.01, + :tickinterval=>0.1, :radius=>30, :label=>"Dial", + :beginangle=>-20, :endangle=>260, :variable=>v_needle, + :relief=>:raised) d2 = Tk::Vu::Dial.new(:resolution=>0.01, :from=>-0.1, :to=>0.1, - :showvalue=>true, :minortickinterval=>0.01, - :tickinterval=>0.1, :radius=>30, :label=>"Dial 2", - :beginangle=>-20, :endangle=>260, :variable=>v_needle, - :dialrelief=>:flat, :needlecolor=>'red', - :needletype=>:triangle, :relief=>:sunken) + :showvalue=>true, :minortickinterval=>0.01, + :tickinterval=>0.1, :radius=>30, :label=>"Dial 2", + :beginangle=>-20, :endangle=>260, :variable=>v_needle, + :dialrelief=>:flat, :needlecolor=>'red', + :needletype=>:triangle, :relief=>:sunken) d3 = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1, - :showvalue=>true, :minortickinterval=>0.01, - :tickinterval=>0.1, :radius=>30, :label=>"Dial 3", - :beginangle=>-20, :endangle=>260, :variable=>v_needle, - :dialrelief=>:flat, :needlecolor=>'blue', - :needletype=>:arc, :relief=>:ridge) + :showvalue=>true, :minortickinterval=>0.01, + :tickinterval=>0.1, :radius=>30, :label=>"Dial 3", + :beginangle=>-20, :endangle=>260, :variable=>v_needle, + :dialrelief=>:flat, :needlecolor=>'blue', + :needletype=>:arc, :relief=>:ridge) f_btns = TkFrame.new f_sep = TkFrame.new(:height=>2, :relief=>:sunken, :bd=>1) @@ -77,12 +77,12 @@ v_volume.value = -0.1 v_speed.value = 500 update = TkTimer.new(proc{v_speed.numeric}, -1, proc{ - if v_volume == volume[:to] - v_volume.numeric = volume[:from] - else - v_volume.numeric += volume[:resolution] - end - }) + if v_volume == volume[:to] + v_volume.numeric = volume[:from] + else + v_volume.numeric += volume[:resolution] + end + }) b_start = TkButton.new(:text=>"Start", :command=>proc{update.start}) b_stop = TkButton.new(:text=>"Stop", :command=>proc{update.stop}) diff --git a/ext/tk/sample/tkextlib/vu/oscilloscope.rb b/ext/tk/sample/tkextlib/vu/oscilloscope.rb index 43254c9b2..2015e4664 100644 --- a/ext/tk/sample/tkextlib/vu/oscilloscope.rb +++ b/ext/tk/sample/tkextlib/vu/oscilloscope.rb @@ -23,43 +23,43 @@ c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true) #---background TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3', - :tags=>['osc', 'frbg']) + :tags=>['osc', 'frbg']) #---channel 0 ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0, - :fill=>'', :jumpscroll=>false, - :outline=>'', :scaleline=>'', - :stripline=>'cyan', :tags=>['osc', 'ch0']) + :fill=>'', :jumpscroll=>false, + :outline=>'', :scaleline=>'', + :stripline=>'cyan', :tags=>['osc', 'ch0']) #---channel 1 ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1, - :fill=>'', :jumpscroll=>0, - :outline=>'', :scaleline=>'', - :stripline=>'red', :tags=>['osc', 'ch1']) + :fill=>'', :jumpscroll=>0, + :outline=>'', :scaleline=>'', + :stripline=>'red', :tags=>['osc', 'ch1']) #---frame TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg']) #---position txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y", - :anchor=>:nw, :tags=>['osc', 'txt1']) + :anchor=>:nw, :tags=>['osc', 'txt1']) #---BINDINGS c.bind('B1-Motion', proc{|x, y, xx, yy| - ch0[:values] = x - ch1[:values] = y - txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}" + ch0[:values] = x + ch1[:values] = y + txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}" }, '%x %y %X %Y') Tk.root.bind('v', proc{ - puts ch0[:values].join(' ') - puts ch0[:values].size - }) + puts ch0[:values].join(' ') + puts ch0[:values].size + }) Tk.root.bind('p', proc{ - c.postscript(:file=>'DEMO.ps') - puts "DEMO.ps printed" - }) + c.postscript(:file=>'DEMO.ps') + puts "DEMO.ps printed" + }) Tk.root.bind('q', proc{exit}) diff --git a/ext/tk/sample/tkextlib/vu/pie.rb b/ext/tk/sample/tkextlib/vu/pie.rb index a567f840a..ed598d623 100644 --- a/ext/tk/sample/tkextlib/vu/pie.rb +++ b/ext/tk/sample/tkextlib/vu/pie.rb @@ -27,7 +27,7 @@ Tk.grid(pie, :sticky=>:news) Tk.grid(f, :sticky=>:ew) Tk.pack(fast_btn, slow_btn, quit_btn, - :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4) + :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4) Tk.root.grid_columnconfigure(0, :weight=>1) Tk.root.grid_rowconfigure(0, :weight=>1) @@ -37,20 +37,20 @@ priv = { } pie.bind('ButtonPress-1', proc{|w, x, y| - priv[:x] = x - priv[:y] = y - priv[:pie_in] = (w.winfo_width/1.8 > x) - priv[:angle] = w[:angle] - priv[:origin] = w[:origin] - }, '%W %x %y') + priv[:x] = x + priv[:y] = y + priv[:pie_in] = (w.winfo_width/1.8 > x) + priv[:angle] = w[:angle] + priv[:origin] = w[:origin] + }, '%W %x %y') pie.bind('B1-Motion', proc{|w, x, y| - if priv[:pie_in] - w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3, - :origin=>(priv[:origin] + - ((w.winfo_height/2.2 > y)? -1: 1) * - (priv[:x] - x)/3) % 360) - end - }, '%W %x %y') + if priv[:pie_in] + w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3, + :origin=>(priv[:origin] + + ((w.winfo_height/2.2 > y)? -1: 1) * + (priv[:x] - x)/3) % 360) + end + }, '%W %x %y') Tk.mainloop diff --git a/ext/tk/sample/tkextlib/vu/vu.rb b/ext/tk/sample/tkextlib/vu/vu.rb index df9a7f38a..d078ae16f 100644 --- a/ext/tk/sample/tkextlib/vu/vu.rb +++ b/ext/tk/sample/tkextlib/vu/vu.rb @@ -10,13 +10,13 @@ puts "Show off barchart and dial widgets" speed = TkVariable.new(0) dial = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1, - :showvalue=>true, :minortickinterval=>0.01, - :tickinterval=>0.1, :radius=>50, :label=>"Dial", - :beginangle=>-20, :endangle=>260, :dialcolor=>'red3', - :active=>'red2', :variable=>speed) + :showvalue=>true, :minortickinterval=>0.01, + :tickinterval=>0.1, :radius=>50, :label=>"Dial", + :beginangle=>-20, :endangle=>260, :dialcolor=>'red3', + :active=>'red2', :variable=>speed) bar = Tk::Vu::Bargraph.new(:from=>0, :to=>100, :relief=>:groove, - :border=>2, :label=>"Bar Chart") + :border=>2, :label=>"Bar Chart") ####################################### @@ -30,24 +30,24 @@ def rand_bool end update = TkTimer.new(200, -1, proc{ - if (rand() - 0.5 + speed.numeric * 3) > 0 - current += 1 - else - current -= 1 - end - bar.set(current) - if current < green - current = 100 if current <= 0 - bar[:barcolor] = 'green' - elsif current < blue - bar[:barcolor] = 'blue' - elsif current < purple - bar[:barcolor] = 'purple' - else - bar[:barcolor] = 'red' - current = 0 if current >= 100 - end - }) + if (rand() - 0.5 + speed.numeric * 3) > 0 + current += 1 + else + current -= 1 + end + bar.set(current) + if current < green + current = 100 if current <= 0 + bar[:barcolor] = 'green' + elsif current < blue + bar[:barcolor] = 'blue' + elsif current < purple + bar[:barcolor] = 'purple' + else + bar[:barcolor] = 'red' + current = 0 if current >= 100 + end + }) ####################################### @@ -61,7 +61,7 @@ Tk.grid('x', nobar, :sticky=>:ew, :padx=>4, :pady=>4) Tk.grid(quit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4) Tk.root.grid_columnconfigure(2, :weight=>1) Tk.root.grid_rowconfigure(1, :weight=>1) - + ####################################### Tk.mainloop diff --git a/ext/tk/sample/tkfrom.rb b/ext/tk/sample/tkfrom.rb index 25f1d7c42..2cece7337 100644 --- a/ext/tk/sample/tkfrom.rb +++ b/ext/tk/sample/tkfrom.rb @@ -22,13 +22,13 @@ class Mail @body = [] while line = f.gets() $_.chop! - next if /^From / =~ line # skip From-line - break if /^$/ =~ line # end of header + next if /^From / =~ line # skip From-line + break if /^$/ =~ line # end of header if /^(\S+):\s*(.*)/ =~ line - @header[attr = $1.capitalize] = $2 + @header[attr = $1.capitalize] = $2 elsif attr - sub(/^\s*/, '') - @header[attr] += "\n" + $_ + sub(/^\s*/, '') + @header[attr] += "\n" + $_ end end @@ -65,7 +65,7 @@ list = scroll = nil TkFrame.new{|f| list = TkListbox.new(f) { yscroll proc{|*idx| - scroll.set *idx + scroll.set *idx } relief 'raised' # geometry "80x5" diff --git a/ext/tk/sample/tkhello.rb b/ext/tk/sample/tkhello.rb index ab236963e..3b505f498 100644 --- a/ext/tk/sample/tkhello.rb +++ b/ext/tk/sample/tkhello.rb @@ -1,10 +1,10 @@ require "tk" TkButton.new(nil, - 'text' => 'hello', - 'command' => proc{print "hello\n"}).pack('fill'=>'x') + :text => 'hello', + :command => proc{print "hello\n"}).pack(:fill=>'x') TkButton.new(nil, - 'text' => 'quit', - 'command' => proc{exit}).pack('fill'=>'x') + :text => 'quit', + :command => proc{exit}).pack(:fill=>'x') Tk.mainloop diff --git a/ext/tk/sample/tkline.rb b/ext/tk/sample/tkline.rb index 5bdf3aec7..3124c2fe0 100644 --- a/ext/tk/sample/tkline.rb +++ b/ext/tk/sample/tkline.rb @@ -8,8 +8,8 @@ def start_random if defined? Thread Thread.start do loop do - sleep 2 - Line.new($c, rand(400), rand(200), rand(400), rand(200)) + sleep 2 + Line.new($c, rand(400), rand(200), rand(400), rand(200)) end end end diff --git a/ext/tk/sample/tkmenubutton.rb b/ext/tk/sample/tkmenubutton.rb index 1c7f51000..37f6128fd 100644 --- a/ext/tk/sample/tkmenubutton.rb +++ b/ext/tk/sample/tkmenubutton.rb @@ -11,7 +11,7 @@ TkFrame.new{|f| TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0, - :direction=>:right, :relief=>:raised){|mb| + :direction=>:right, :relief=>:raised){|mb| menu TkMenu.new(:parent=>mb, :tearoff=>0){ add(:command, :label=>'Right menu: first item', :command=>proc{print 'You have selected the first item' + @@ -24,7 +24,7 @@ TkFrame.new{|f| } TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0, - :direction=>:below, :relief=>:raised){|mb| + :direction=>:below, :relief=>:raised){|mb| menu(TkMenu.new(:parent=>mb, :tearoff=>0){ add(:command, :label=>'Below menu: first item', :command=>proc{print 'You have selected the first item' + @@ -37,7 +37,7 @@ TkFrame.new{|f| } TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0, - :direction=>:above, :relief=>:raised){|mb| + :direction=>:above, :relief=>:raised){|mb| menu TkMenu.new(:parent=>mb, :tearoff=>0){ add(:command, :label=>'Above menu: first item', :command=>proc{print 'You have selected the first item' + @@ -50,7 +50,7 @@ TkFrame.new{|f| } TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0, - :direction=>:left, :relief=>:raised){|mb| + :direction=>:left, :relief=>:raised){|mb| menu(TkMenu.new(:parent=>mb, :tearoff=>0){ add(:command, :label=>'Left menu: first item', :command=>proc{print 'You have selected the first item' + @@ -65,7 +65,7 @@ TkFrame.new{|f| ############################ TkFrame.new(:borderwidth=>2, :relief=>:sunken, - :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20) + :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20) ############################ TkLabel.new(:text=>'Sample of TkOptionMenu').pack(:side=>:top) @@ -83,21 +83,21 @@ TkFrame.new{|f| b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB| colors.each{|color| no_sel = TkPhotoImage.new(:height=>16, :width=>16){ - put 'gray50', *[ 0, 0, 16, 1] - put 'gray50', *[ 0, 1, 1, 16] - put 'gray75', *[ 0, 15, 16, 16] - put 'gray75', *[15, 1, 16, 16] - put color, *[ 1, 1, 15, 15] + put 'gray50', *[ 0, 0, 16, 1] + put 'gray50', *[ 0, 1, 1, 16] + put 'gray75', *[ 0, 15, 16, 16] + put 'gray75', *[15, 1, 16, 16] + put color, *[ 1, 1, 15, 15] } sel = TkPhotoImage.new(:height=>16, :width=>16){ - put 'Black', *[ 0, 0, 16, 2] - put 'Black', *[ 0, 2, 2, 16] - put 'Black', *[ 2, 14, 16, 16] - put 'Black', *[14, 2, 16, 14] - put color, *[ 2, 2, 14, 14] + put 'Black', *[ 0, 0, 16, 2] + put 'Black', *[ 0, 2, 2, 16] + put 'Black', *[ 2, 14, 16, 16] + put 'Black', *[14, 2, 16, 14] + put color, *[ 2, 2, 14, 14] } optMB.entryconfigure(color, :hidemargin=>1, - :image=>no_sel, :selectimage=>sel) + :image=>no_sel, :selectimage=>sel) } optMB.menuconfigure(:tearoff, 1) %w(Black gray75 gray50 White).each{|color| @@ -115,7 +115,7 @@ TkFrame.new{|f| ############################ TkFrame.new(:borderwidth=>2, :relief=>:sunken, - :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20) + :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20) ############################ root = TkRoot.new(:title=>'menubutton samples') @@ -127,8 +127,8 @@ TkButton.new(root, :text=>'exit', :command=>proc{exit}){ # VirtualEvent <<MenuSelect>> on Tcl/Tk ==> '<MenuSelect>' on Ruby/Tk # ( remove the most external <, > for Ruby/Tk notation ) TkMenu.bind('<MenuSelect>', proc{|widget| - p widget.entrycget('active', :label) - }, '%W') + p widget.entrycget('active', :label) + }, '%W') ############################ diff --git a/ext/tk/sample/tkmsgcat-load_rb.rb b/ext/tk/sample/tkmsgcat-load_rb.rb index 6a3289e06..5373e0086 100644 --- a/ext/tk/sample/tkmsgcat-load_rb.rb +++ b/ext/tk/sample/tkmsgcat-load_rb.rb @@ -12,19 +12,19 @@ default_locale = msgcat.locale msgcat.load(msgcat_dir) col_proc = TkComm.install_bind(proc{|w, color, frame, label| - TkComm.window(frame).background(color) - Tk.update - TkComm.window(label).text( - msgcat["%1$s:: %2$s", 'Color', - color.capitalize]) - w.flash; w.flash - Tk.callback_break; - }, "%W") + TkComm.window(frame).background(color) + Tk.update + TkComm.window(label).text( + msgcat["%1$s:: %2$s", 'Color', + color.capitalize]) + w.flash; w.flash + Tk.callback_break; + }, "%W") del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil}) err_proc = TkComm.install_cmd(proc{fail(RuntimeError, - msgcat['Application Error'])}) + msgcat['Application Error'])}) show_sample = proc{|loc| top_win = TkToplevel.new(:title=>loc) @@ -39,24 +39,24 @@ show_sample = proc{|loc| } lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s", - 'Color', '']).pack(:anchor=>'w') + 'Color', '']).pack(:anchor=>'w') bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10, - :expand=>true, :fill=>:both) + :expand=>true, :fill=>:both) TkFrame.new(bg){|f| ['blue', 'green', 'red'].each{|col| TkButton.new(f, :text=>msgcat[col]){ - bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") + bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") }.pack(:fill=>:x) } }.pack(:anchor=>'center', :pady=>15) TkFrame.new(top_win){|f| TkButton.new(f, :text=>msgcat['Delete'], - :command=>del_proc).pack(:side=>:right, :padx=>5) + :command=>del_proc).pack(:side=>:right, :padx=>5) TkButton.new(f, :text=>msgcat['Error'], - :command=>err_proc).pack(:side=>:left, :padx=>5) + :command=>err_proc).pack(:side=>:left, :padx=>5) }.pack(:side=>:bottom, :fill=>:x) top_win @@ -68,7 +68,7 @@ TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3) TkFrame.new{|f| TkButton.new(f, :text=>msgcat['Exit'], - :command=>proc{exit}).pack(:side=>:right, :padx=>5) + :command=>proc{exit}).pack(:side=>:right, :padx=>5) }.pack(:side=>:bottom, :fill=>:x) f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true) diff --git a/ext/tk/sample/tkmsgcat-load_rb2.rb b/ext/tk/sample/tkmsgcat-load_rb2.rb index 720ab94e1..55246545c 100644 --- a/ext/tk/sample/tkmsgcat-load_rb2.rb +++ b/ext/tk/sample/tkmsgcat-load_rb2.rb @@ -12,19 +12,19 @@ default_locale = msgcat.locale msgcat.load(msgcat_dir) col_proc = TkComm.install_bind(proc{|w, color, frame, label| - TkComm.window(frame).background(color) - Tk.update - TkComm.window(label).text( - msgcat["%1$s:: %2$s", 'Color', - color.capitalize]) - w.flash; w.flash - Tk.callback_break; - }, "%W") + TkComm.window(frame).background(color) + Tk.update + TkComm.window(label).text( + msgcat["%1$s:: %2$s", 'Color', + color.capitalize]) + w.flash; w.flash + Tk.callback_break; + }, "%W") del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil}) err_proc = TkComm.install_cmd(proc{fail(RuntimeError, - msgcat['Application Error'])}) + msgcat['Application Error'])}) show_sample = proc{|loc| top_win = TkToplevel.new(:title=>loc) @@ -39,24 +39,24 @@ show_sample = proc{|loc| } lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s", - 'Color', '']).pack(:anchor=>'w') + 'Color', '']).pack(:anchor=>'w') bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10, - :expand=>true, :fill=>:both) + :expand=>true, :fill=>:both) TkFrame.new(bg){|f| ['blue', 'green', 'red'].each{|col| TkButton.new(f, :text=>msgcat[col]){ - bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") + bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") }.pack(:fill=>:x) } }.pack(:anchor=>'center', :pady=>15) TkFrame.new(top_win){|f| TkButton.new(f, :text=>msgcat['Delete'], - :command=>del_proc).pack(:side=>:right, :padx=>5) + :command=>del_proc).pack(:side=>:right, :padx=>5) TkButton.new(f, :text=>msgcat['Error'], - :command=>err_proc).pack(:side=>:left, :padx=>5) + :command=>err_proc).pack(:side=>:left, :padx=>5) }.pack(:side=>:bottom, :fill=>:x) top_win @@ -68,7 +68,7 @@ TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3) TkFrame.new{|f| TkButton.new(f, :text=>msgcat['Exit'], - :command=>proc{exit}).pack(:side=>:right, :padx=>5) + :command=>proc{exit}).pack(:side=>:right, :padx=>5) }.pack(:side=>:bottom, :fill=>:x) f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true) diff --git a/ext/tk/sample/tkmsgcat-load_tk.rb b/ext/tk/sample/tkmsgcat-load_tk.rb index 8ad26a5f2..45d68e4e0 100644 --- a/ext/tk/sample/tkmsgcat-load_tk.rb +++ b/ext/tk/sample/tkmsgcat-load_tk.rb @@ -11,19 +11,19 @@ default_locale = msgcat.locale msgcat.load_tk(msgcat_dir) col_proc = TkComm.install_bind(proc{|w, color, frame, label| - TkComm.window(frame).background(color) - Tk.update - TkComm.window(label).text( - msgcat.mc("%1$s:: %2$s", 'Color', - color.capitalize)) - w.flash; w.flash - Tk.callback_break; - }, "%W") + TkComm.window(frame).background(color) + Tk.update + TkComm.window(label).text( + msgcat.mc("%1$s:: %2$s", 'Color', + color.capitalize)) + w.flash; w.flash + Tk.callback_break; + }, "%W") del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil}) err_proc = TkComm.install_cmd(proc{fail(RuntimeError, - msgcat.mc('Application Error'))}) + msgcat.mc('Application Error'))}) show_sample = proc{|loc| top_win = TkToplevel.new(:title=>loc) @@ -37,41 +37,41 @@ show_sample = proc{|loc| } lbl = TkLabel.new(top_win, :text=>msgcat.mc("%1$s:: %2$s", - 'Color', '')).pack(:anchor=>'w') + 'Color', '')).pack(:anchor=>'w') bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10, - :expand=>true, :fill=>:both) + :expand=>true, :fill=>:both) TkFrame.new(bg){|f| ['blue', 'green', 'red'].each{|col| TkButton.new(f, :text=>msgcat.mc(col)){ - bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") + bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}") }.pack(:fill=>:x) =begin TkButton.new(f, :text=>msgcat.mc(col), - :command=>proc{ - bg.background col - lbl.text msgcat.mc("%1$s:: %2$s", 'Color', col.capitalize) - }).pack(:fill=>:x) + :command=>proc{ + bg.background col + lbl.text msgcat.mc("%1$s:: %2$s", 'Color', col.capitalize) + }).pack(:fill=>:x) =end } }.pack(:anchor=>'center', :pady=>15) TkFrame.new(top_win){|f| TkButton.new(f, :text=>msgcat.mc('Delete'), - :command=>del_proc).pack(:side=>:right, :padx=>5) + :command=>del_proc).pack(:side=>:right, :padx=>5) TkButton.new(f, :text=>msgcat.mc('Error'), - :command=>err_proc).pack(:side=>:left, :padx=>5) + :command=>err_proc).pack(:side=>:left, :padx=>5) =begin TkButton.new(f, :text=>msgcat.mc('Delete'), - :command=>proc{ - top_win.destroy - top_win = nil - }).pack(:side=>:right, :padx=>5) + :command=>proc{ + top_win.destroy + top_win = nil + }).pack(:side=>:right, :padx=>5) TkButton.new(f, :text=>msgcat.mc('Error'), - :command=>proc{ - fail RuntimeError, msgcat.mc('Application Error') - }).pack(:side=>:left, :padx=>5) + :command=>proc{ + fail RuntimeError, msgcat.mc('Application Error') + }).pack(:side=>:left, :padx=>5) =end }.pack(:side=>:bottom, :fill=>:x) @@ -84,7 +84,7 @@ TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3) TkFrame.new{|f| TkButton.new(f, :text=>msgcat.mc('Exit'), - :command=>proc{exit}).pack(:side=>:right, :padx=>5) + :command=>proc{exit}).pack(:side=>:right, :padx=>5) }.pack(:side=>:bottom, :fill=>:x) f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true) diff --git a/ext/tk/sample/tkmulticolumnlist.rb b/ext/tk/sample/tkmulticolumnlist.rb index 5d6aa81bc..255eb691e 100644 --- a/ext/tk/sample/tkmulticolumnlist.rb +++ b/ext/tk/sample/tkmulticolumnlist.rb @@ -55,28 +55,28 @@ class TkMultiColumnList < TkText # virtical scrollbar @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'width'=>@scrbar_width) # horizontal scrollbar @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'width'=>@scrbar_width) # create base flames @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_title = TkFrame.new(@c_title, 'width'=>@width_total) @w_title = TkcWindow.new(@c_title, 0, 0, - 'window'=>@f_title, 'anchor'=>'nw') + 'window'=>@f_title, 'anchor'=>'nw') @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total) @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw') @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total) @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw') @@ -86,9 +86,9 @@ class TkMultiColumnList < TkText title_info.each_with_index{|(label, width), idx| # set relation between label and index if @name_index.include?(label) - @name_index[label] << idx + @name_index[label] << idx else - @name_index[label] = [idx] + @name_index[label] = [idx] end # calculate relative positioning @@ -100,69 +100,69 @@ class TkMultiColumnList < TkText base = [f] title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border, - 'relief'=>'raised', 'highlightthickness'=>@h_l_thick) + 'relief'=>'raised', 'highlightthickness'=>@h_l_thick) title_binding(title, idx) title.pack('fill'=>'x') @title_list << title f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relheight'=>1.0, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relheight'=>1.0, + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) # listbox field f = TkFrame.new(@f_lbox, 'width'=>width) base << f @lbox_list << TkText.new(f, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@lbox_border, - 'takefocus'=>false, - 'wrap'=>'none') { - - bindtags(bindtags - [TkText]) - - @seltag = TkTextTag.new(self, 'background'=>'#b3b3b3', - 'borderwidth'=>1, 'relief'=>'raised') - def self.nearest(y) - self.index("@1,#{y}").split('.')[0].to_i - end - - def self.select_clear(first, last=nil) - first = "#{first}.0" if first.kind_of?(Integer) - first = self.index(first.to_s + ' linestart') - last = first unless last - last = "#{last}.0" if first.kind_of?(Integer) - last = self.index(last.to_s + ' + 1 lines linestart') - @seltag.remove(first, last) - end - - def self.select_set(first, last=nil) - first = "#{first}.0" if first.kind_of?(Integer) - first = self.index(first.to_s + ' linestart') - last = first unless last - last = "#{last}.0" if first.kind_of?(Integer) - last = self.index(last.to_s + ' + 1 lines linestart') - @seltag.add(first, last) - end - - def self.select_index - self.index(@seltag.first).split('.')[0].to_i - end - - pack('fill'=>'both', 'expand'=>true) + 'borderwidth'=>@lbox_border, + 'takefocus'=>false, + 'wrap'=>'none') { + + bindtags(bindtags - [TkText]) + + @seltag = TkTextTag.new(self, 'background'=>'#b3b3b3', + 'borderwidth'=>1, 'relief'=>'raised') + def self.nearest(y) + self.index("@1,#{y}").split('.')[0].to_i + end + + def self.select_clear(first, last=nil) + first = "#{first}.0" if first.kind_of?(Integer) + first = self.index(first.to_s + ' linestart') + last = first unless last + last = "#{last}.0" if first.kind_of?(Integer) + last = self.index(last.to_s + ' + 1 lines linestart') + @seltag.remove(first, last) + end + + def self.select_set(first, last=nil) + first = "#{first}.0" if first.kind_of?(Integer) + first = self.index(first.to_s + ' linestart') + last = first unless last + last = "#{last}.0" if first.kind_of?(Integer) + last = self.index(last.to_s + ' + 1 lines linestart') + @seltag.add(first, last) + end + + def self.select_index + self.index(@seltag.first).split('.')[0].to_i + end + + pack('fill'=>'both', 'expand'=>true) } f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) # scrollbar field f = TkFrame.new(@f_hscr, 'width'=>width) base << f @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width, - 'borderwidth'=>@scrbar_border, - 'highlightthickness'=>@h_l_thick - ).pack('fill'=>'x', 'anchor'=>'w') + 'borderwidth'=>@scrbar_border, + 'highlightthickness'=>@h_l_thick + ).pack('fill'=>'x', 'anchor'=>'w') f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) @lbox_list[idx].xscrollbar(@hscr_list[idx]) @@ -172,12 +172,12 @@ class TkMultiColumnList < TkText # pad @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised', - 'borderwidth'=>@title_border, - 'highlightthickness'=>@h_l_thick) + 'borderwidth'=>@title_border, + 'highlightthickness'=>@h_l_thick) @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken', - 'borderwidth'=>1, - 'highlightthickness'=>@h_l_thick) + 'borderwidth'=>1, + 'highlightthickness'=>@h_l_thick) # height check title_height = 0 @@ -205,27 +205,27 @@ class TkMultiColumnList < TkText # binding for listboxes @lbox_list.each_with_index{|l, idx| l.bind('Button-1', proc{|w, y| - @frame.focus - select_line(w, w.nearest(y)) - }, '%W %y') + @frame.focus + select_line(w, w.nearest(y)) + }, '%W %y') l.bind('B1-Motion', proc{|w, y| - select_line(w, w.nearest(y)) - }, '%W %y') + select_line(w, w.nearest(y)) + }, '%W %y') l.bind('Double-Button-1', proc{ - @command.call(get_select) if @command - }) + @command.call(get_select) if @command + }) l.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W') l.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W') l.bind('Button-2', proc{|x, y| - @lbox_mark_x = x - @lbox_list.each{|lbox| lbox.scan_mark(x, y)} - }, '%x %y') + @lbox_mark_x = x + @lbox_list.each{|lbox| lbox.scan_mark(x, y)} + }, '%x %y') l.bind('B2-Motion', proc{|x, y| - @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} - l.scan_dragto(x, y) - }, '%x %y') + @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} + l.scan_dragto(x, y) + }, '%x %y') } bbox = @w_title.bbox @@ -266,8 +266,8 @@ class TkMultiColumnList < TkText # binding for 'Configure' event @c_lbox.bind('Configure', - proc{|height, width| reconstruct(height, width)}, - '%h %w') + proc{|height, width| reconstruct(height, width)}, + '%h %w') # set default receiver of method calls @path = @frame.path @@ -433,9 +433,9 @@ class TkMultiColumnList < TkText def delete(*idx) idx = idx.collect{|i| if i.kind_of?(Integer) - "#{i}.0" + "#{i}.0" else - i.to_s + i.to_s end } @lbox_list.collect{|lbox| lbox.delete(*idx)} @@ -444,30 +444,30 @@ class TkMultiColumnList < TkText def get(idx_s, idx_e=nil) unless idx_e if idx_s.kind_of?(Integer) - idx_s = "#{idx_s}.0" - idx_e = "#{idx_s} lineend" + idx_s = "#{idx_s}.0" + idx_e = "#{idx_s} lineend" else - idx_s = idx_s.to_s - idx_e = "#{idx_s} lineend" + idx_s = idx_s.to_s + idx_e = "#{idx_s} lineend" end @lbox_list.collect{|lbox| - lbox.get(idx_s, idx_e) + lbox.get(idx_s, idx_e) } else if idx_s.kind_of?(Integer) - idx_s = "#{idx_s}.0" + idx_s = "#{idx_s}.0" else - idx_s = idx_s.to_s + idx_s = idx_s.to_s end if idx_e.kind_of?(Integer) - idx_e = "#{idx_e}.end" + idx_e = "#{idx_e}.end" else - idx_e = "#{idx_e} lineend" + idx_e = "#{idx_e} lineend" end list = @lbox_list.collect{|lbox| lbox.get(idx_s, idx_e).split(/\n/)} result = [] list[0].each_with_index{|line, index| - result << list.collect{|lines| lines[index]} + result << list.collect{|lines| lines[index]} } result end @@ -481,9 +481,9 @@ class TkMultiColumnList < TkText result = {} @name_index.each_pair{|label, indices| if indices.size == 1 - result[label] = line[indices[0]] + result[label] = line[indices[0]] else - result[label] = indices.collect{|index| line[index]} + result[label] = indices.collect{|index| line[index]} end } result @@ -517,31 +517,31 @@ class TkMultiColumnList < TkText lines.each{|line| if line.kind_of? Hash - array = [] - @name_index.each_pair{|label, indices| - if indices.size == 1 - array[indices[0]] = line[label] - else - if line[label].kind_of? Array - indices.each_with_index{|index, num| - array[index] = line[label][num] - } - else - array[indices[0]] = line[label] - end - end - } - line = array + array = [] + @name_index.each_pair{|label, indices| + if indices.size == 1 + array[indices[0]] = line[label] + else + if line[label].kind_of? Array + indices.each_with_index{|index, num| + array[index] = line[label][num] + } + else + array[indices[0]] = line[label] + end + end + } + line = array end @name_index.each_pair{|label, indices| - if indices.size == 1 - lbox_ins[indices[0]] << line[indices[0]] - else - indices.each{|index| lbox_ins[index] << line[index]} - end + if indices.size == 1 + lbox_ins[indices[0]] << line[indices[0]] + else + indices.each{|index| lbox_ins[index] << line[index]} + end } - } + } @lbox_list.each_with_index{|lbox, index| lbox.insert(idx, cr + lbox_ins[index].join("\n")) if lbox_ins[index] @@ -582,7 +582,7 @@ class TkMultiColumnList < TkText title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relheight'=>1.0) + 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) } end @@ -609,11 +609,11 @@ class TkMultiColumnList < TkText # adjustment of rightside widget of the sash title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx], 'relheight'=>1.0) + 'relx'=>@rel_list[idx], 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) # update reference position @x = x @@ -637,34 +637,34 @@ class TkMultiColumnList < TkText def title_binding(title, index) title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)}, - "%W %x #{index}") + "%W %x #{index}") title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)}, - "%W %x #{index}") + "%W %x #{index}") title.bind('Leave', proc{|w| w.cursor ""}, "%W") title.bind('Button-1', - proc{|w, x| - if @mode == :sash - @x = x - @frame_width = TkWinfo.width(@f_title).to_f - else - title.relief 'sunken' - end - }, - '%W %X') + proc{|w, x| + if @mode == :sash + @x = x + @frame_width = TkWinfo.width(@f_title).to_f + else + title.relief 'sunken' + end + }, + '%W %X') title.bind('ButtonRelease-1', - proc{|w, x, idx| - i = idx.to_i - if @mode == :title && @title_cmd[i].kind_of?(Proc) - @title_cmd[i].call - end - title.relief 'raised' - motion_cb(w,x,i) - }, - "%W %x #{index}") + proc{|w, x, idx| + i = idx.to_i + if @mode == :title && @title_cmd[i].kind_of?(Proc) + @title_cmd[i].call + end + title.relief 'raised' + motion_cb(w,x,i) + }, + "%W %x #{index}") title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X") end @@ -706,21 +706,21 @@ end ################################################ if __FILE__ == $0 l = TkMultiColumnList.new(nil, 200, - [ ['L1', 200, proc{p 'click L1'}], - ['L2', 100], - ['L3', 200] ], - 'width'=>350, - #'titleforeground'=>'yellow', - 'titleforeground'=>'white', - #'titlebackground'=>'navy', - 'titlebackground'=>'blue', - 'titlefont'=>'courier' - ).pack('fill'=>'both', 'expand'=>true) + [ ['L1', 200, proc{p 'click L1'}], + ['L2', 100], + ['L3', 200] ], + 'width'=>350, + #'titleforeground'=>'yellow', + 'titleforeground'=>'white', + #'titlebackground'=>'navy', + 'titlebackground'=>'blue', + 'titlefont'=>'courier' + ).pack('fill'=>'both', 'expand'=>true) l.insert('end', [1,2,3]) l.insert('end', [4,5,6]) l.insert('end', [4,5,6], [4,5,6]) l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'cccccccccccccccccccccccccccccccccccccccccccccccccccc']) l.insert('end', [1,2,3]) l.insert('end', [4,5,6], [4,5,6]) diff --git a/ext/tk/sample/tkmultilistbox.rb b/ext/tk/sample/tkmultilistbox.rb index c3787a0cf..6f956d0ed 100644 --- a/ext/tk/sample/tkmultilistbox.rb +++ b/ext/tk/sample/tkmultilistbox.rb @@ -36,10 +36,10 @@ class TkMultiListbox < TkListbox # create base flames @f_title = TkFrame.new(@frame, 'width'=>@width_total) @f_lbox = TkFrame.new(@frame, - 'width'=>@width_total, 'height'=>lbox_height) + 'width'=>@width_total, 'height'=>lbox_height) @f_hscr = TkFrame.new(@frame, 'width'=>@width_total, - 'height'=>@v_scroll.cget('width') + - 2 * @v_scroll.cget('borderwidth')) + 'height'=>@v_scroll.cget('width') + + 2 * @v_scroll.cget('borderwidth')) # dummy label to keep the hight of title space TkLabel.new(@f_title, 'text'=>' ').pack @@ -50,9 +50,9 @@ class TkMultiListbox < TkListbox title_info.each_with_index{|(label, width), idx| # set relation between label and index if @name_index.include?(label) - @name_index[label] << idx + @name_index[label] << idx else - @name_index[label] = [idx] + @name_index[label] = [idx] end # calculate relative positioning @@ -64,25 +64,25 @@ class TkMultiListbox < TkListbox base = [f] @title_list << TkLabel.new(f, 'text'=>label).pack('fill'=>'x') f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-6, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) # listbox field f = TkFrame.new(@f_lbox, 'width'=>width) base << f @lbox_list << TkListbox.new(f).pack('fill'=>'both', 'expand'=>true) f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) # scrollbar field f = TkFrame.new(@f_hscr, 'width'=>width) base << f @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal') . - pack('fill'=>'x', 'anchor'=>'w') + pack('fill'=>'x', 'anchor'=>'w') f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) @lbox_list[idx].xscrollcommand proc{|first, last| - @hscr_list[idx].set first, last + @hscr_list[idx].set first, last } @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args} @@ -94,19 +94,19 @@ class TkMultiListbox < TkListbox @tab_list = [nil] (1..(@rel_list.size - 2)).each{|idx| tab = TkFrame.new(@f_title, 'cursor'=>'sb_h_double_arrow', - 'width'=>6, 'borderwidth'=>2, 'relief'=>'raised') + 'width'=>6, 'borderwidth'=>2, 'relief'=>'raised') @tab_list << tab tab.place('relx'=>@rel_list[idx], 'anchor'=>'ne', 'relheight'=>0.95) tab.bind('Button-1', - proc{|x| @x = x; @frame_width = TkWinfo.width(@f_title).to_f}, - '%X') + proc{|x| @x = x; @frame_width = TkWinfo.width(@f_title).to_f}, + '%X') tab.bind('B1-Motion', proc{|x, idx| resize(x, idx.to_i)}, "%X #{idx}") } # set control procedure for virtical scroll @lbox_list.each{|lbox| lbox.yscrollcommand proc{|first, last| - @v_scroll.set first, last + @v_scroll.set first, last } } @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} } @@ -120,18 +120,18 @@ class TkMultiListbox < TkListbox @current_mode = 'browse' @lbox_list.each{|l| l.bind('Shift-Key-Left', - proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W') + proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W') l.bind('Shift-Key-Right', - proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W') + proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W') l.bind('Button-2', proc{|x, y| - @lbox_mark_x = x - @lbox_list.each{|lbox| lbox.scan_mark(x, y)} - }, '%x %y') + @lbox_mark_x = x + @lbox_list.each{|lbox| lbox.scan_mark(x, y)} + }, '%x %y') l.bind('B2-Motion', proc{|x, y| - @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} - l.scan_dragto(x, y) - }, '%x %y') + @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} + l.scan_dragto(x, y) + }, '%x %y') l.bindtags(l.bindtags.unshift(@mode[@current_mode])) } @@ -242,7 +242,7 @@ class TkMultiListbox < TkListbox list = @lbox_list.collect{|lbox| lbox.get(*idx)} result = [] list[0].each_with_index{|line, index| - result << list.collect{|lines| lines[index]} + result << list.collect{|lines| lines[index]} } result end @@ -252,9 +252,9 @@ class TkMultiListbox < TkListbox result = {} @name_index.each_pair{|label, indices| if indices.size == 1 - result[label] = line[indices[0]] + result[label] = line[indices[0]] else - result[label] = indices.collect{|index| line[index]} + result[label] = indices.collect{|index| line[index]} end } result @@ -276,31 +276,31 @@ class TkMultiListbox < TkListbox lines.each{|line| if line.kind_of? Hash - array = [] - @name_index.each_pair{|label, indices| - if indices.size == 1 - array[indices[0]] = line[label] - else - if line[label].kind_of? Array - indices.each_with_index{|index, num| - array[index] = line[label][num] - } - else - array[indices[0]] = line[label] - end - end - } - line = array + array = [] + @name_index.each_pair{|label, indices| + if indices.size == 1 + array[indices[0]] = line[label] + else + if line[label].kind_of? Array + indices.each_with_index{|index, num| + array[index] = line[label][num] + } + else + array[indices[0]] = line[label] + end + end + } + line = array end @name_index.each_pair{|label, indices| - if indices.size == 1 - lbox_ins[indices[0]] << line[indices[0]] - else - indices.each{|index| lbox_ins[index] << line[index]} - end + if indices.size == 1 + lbox_ins[indices[0]] << line[indices[0]] + else + indices.each{|index| lbox_ins[index] << line[index]} + end } - } + } @lbox_list.each_with_index{|lbox, index| lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index] @@ -327,7 +327,7 @@ class TkMultiListbox < TkListbox title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relheight'=>1.0) + 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) tab = @tab_list[idx] @@ -357,11 +357,11 @@ class TkMultiListbox < TkListbox # adjustment of rightside widget of the tab title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx], 'relheight'=>1.0) + 'relx'=>@rel_list[idx], 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) # update reference position @x = x @@ -371,11 +371,11 @@ class TkMultiListbox < TkListbox def browse_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y') t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W') @@ -386,7 +386,7 @@ class TkMultiListbox < TkListbox t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-slash', - proc{|w| select_line(w, w.index('active').to_i)}, '%W') + proc{|w| select_line(w, w.index('active').to_i)}, '%W') t end @@ -395,12 +395,12 @@ class TkMultiListbox < TkListbox def single_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W') @@ -411,9 +411,9 @@ class TkMultiListbox < TkListbox t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-slash', - proc{|w| select_line(w, w.index('active').to_i)}, '%W') + proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-backslash', - proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}}) + proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}}) t end @@ -422,22 +422,22 @@ class TkMultiListbox < TkListbox def extended_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('Shift-B1-Motion', - proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('Control-Button-1', - proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y') t.bind('Control-B1-Motion', - proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W') @@ -463,9 +463,9 @@ class TkMultiListbox < TkListbox def multiple_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W') @@ -509,9 +509,9 @@ class TkMultiListbox < TkListbox @lbox_list.each{|l| l.selection_anchor(idx) if st == 1 - l.selection_clear(idx) + l.selection_clear(idx) else - l.selection_set(idx) + l.selection_set(idx) end } end @@ -520,9 +520,9 @@ class TkMultiListbox < TkListbox st = w.selection_includes('anchor') @lbox_list.each{|l| if st == 1 - l.selection_set('anchor', idx) + l.selection_set('anchor', idx) else - l.selection_clear('anchor', idx) + l.selection_clear('anchor', idx) end } end @@ -625,16 +625,16 @@ end ################################################ if __FILE__ == $0 f = TkFrame.new(nil, 'width'=>300, - 'height'=>200).pack('fill'=>'both', 'expand'=>'true') + 'height'=>200).pack('fill'=>'both', 'expand'=>'true') #f = TkFrame.new.pack('fill'=>'both', 'expand'=>'true') l = TkMultiListbox.new(f, 150, - [ ['L1', 100], - ['L2', 200], - ['L3', 50] ], - 'titlefont'=>'courier', - 'titleforeground'=>'yellow', - 'titlebackground'=>'navy' - ).pack('fill'=>'both', 'expand'=>true) + [ ['L1', 100], + ['L2', 200], + ['L3', 50] ], + 'titlefont'=>'courier', + 'titleforeground'=>'yellow', + 'titlebackground'=>'navy' + ).pack('fill'=>'both', 'expand'=>true) l.insert('end', [1,2,3]) l.insert('end', [4,5,6]) l.insert('end', [4,5,6], [4,5,6]) diff --git a/ext/tk/sample/tkmultilistframe.rb b/ext/tk/sample/tkmultilistframe.rb index dac1df551..ef1a0a824 100644 --- a/ext/tk/sample/tkmultilistframe.rb +++ b/ext/tk/sample/tkmultilistframe.rb @@ -55,37 +55,37 @@ class TkMultiListFrame < TkListbox # virtical scrollbar =begin @v_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'orient'=>'vertical', 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'orient'=>'vertical', 'width'=>@scrbar_width) =end @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'width'=>@scrbar_width) # horizontal scrollbar =begin @h_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'orient'=>'horizontal', 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'orient'=>'horizontal', 'width'=>@scrbar_width) =end @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@scrbar_border, - 'width'=>@scrbar_width) + 'borderwidth'=>@scrbar_border, + 'width'=>@scrbar_width) # create base flames @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_title = TkFrame.new(@c_title, 'width'=>@width_total) @w_title = TkcWindow.new(@c_title, 0, 0, - 'window'=>@f_title, 'anchor'=>'nw') + 'window'=>@f_title, 'anchor'=>'nw') @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total) @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw') @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick, - 'width'=>@window_width) + 'width'=>@window_width) @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total) @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw') @@ -95,9 +95,9 @@ class TkMultiListFrame < TkListbox title_info.each_with_index{|(label, width), idx| # set relation between label and index if @name_index.include?(label) - @name_index[label] << idx + @name_index[label] << idx else - @name_index[label] = [idx] + @name_index[label] = [idx] end # calculate relative positioning @@ -109,45 +109,45 @@ class TkMultiListFrame < TkListbox base = [f] title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border, - 'relief'=>'raised', 'highlightthickness'=>@h_l_thick) + 'relief'=>'raised', 'highlightthickness'=>@h_l_thick) title_binding(title, idx) title.pack('fill'=>'x') @title_list << title f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relheight'=>1.0, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relheight'=>1.0, + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) # listbox field f = TkFrame.new(@f_lbox, 'width'=>width) base << f @lbox_list << TkListbox.new(f, 'highlightthickness'=>@h_l_thick, - 'borderwidth'=>@lbox_border - ).pack('fill'=>'both', 'expand'=>true) + 'borderwidth'=>@lbox_border + ).pack('fill'=>'both', 'expand'=>true) f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0) # scrollbar field f = TkFrame.new(@f_hscr, 'width'=>width) base << f =begin @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal', - 'width'=>@scrbar_width, - 'borderwidth'=>@scrbar_border, - 'highlightthickness'=>@h_l_thick - ).pack('fill'=>'x', 'anchor'=>'w') + 'width'=>@scrbar_width, + 'borderwidth'=>@scrbar_border, + 'highlightthickness'=>@h_l_thick + ).pack('fill'=>'x', 'anchor'=>'w') =end @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width, - 'borderwidth'=>@scrbar_border, - 'highlightthickness'=>@h_l_thick - ).pack('fill'=>'x', 'anchor'=>'w') + 'borderwidth'=>@scrbar_border, + 'highlightthickness'=>@h_l_thick + ).pack('fill'=>'x', 'anchor'=>'w') f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1, - 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) + 'relwidth'=>@rel_list[idx+1] - @rel_list[idx]) =begin @lbox_list[idx].xscrollcommand proc{|first, last| - @hscr_list[idx].set first, last + @hscr_list[idx].set first, last } @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args} =end @@ -160,12 +160,12 @@ class TkMultiListFrame < TkListbox # pad # @f_title_pad = TkFrame.new(@frame) @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised', - 'borderwidth'=>@title_border, - 'highlightthickness'=>@h_l_thick) + 'borderwidth'=>@title_border, + 'highlightthickness'=>@h_l_thick) @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken', - 'borderwidth'=>1, - 'highlightthickness'=>@h_l_thick) + 'borderwidth'=>1, + 'highlightthickness'=>@h_l_thick) # height check title_height = 0 @@ -188,7 +188,7 @@ class TkMultiListFrame < TkListbox =begin @lbox_list.each{|lbox| lbox.yscrollcommand proc{|first, last| - @v_scroll.set first, last + @v_scroll.set first, last } } @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} } @@ -223,18 +223,18 @@ class TkMultiListFrame < TkListbox @current_mode = 'browse' @lbox_list.each_with_index{|l, idx| l.bind('Shift-Key-Left', - proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W') + proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W') l.bind('Shift-Key-Right', - proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W') + proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W') l.bind('Button-2', proc{|x, y| - @lbox_mark_x = x - @lbox_list.each{|lbox| lbox.scan_mark(x, y)} - }, '%x %y') + @lbox_mark_x = x + @lbox_list.each{|lbox| lbox.scan_mark(x, y)} + }, '%x %y') l.bind('B2-Motion', proc{|x, y| - @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} - l.scan_dragto(x, y) - }, '%x %y') + @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)} + l.scan_dragto(x, y) + }, '%x %y') l.bindtags(l.bindtags.unshift(@lbox_mode[@current_mode])) } @@ -271,8 +271,8 @@ class TkMultiListFrame < TkListbox # binding for 'Configure' event @c_lbox.bind('Configure', - proc{|height, width| reconstruct(height, width)}, - '%h %w') + proc{|height, width| reconstruct(height, width)}, + '%h %w') # set default receiver of method calls @path = @lbox_list[0].path @@ -458,7 +458,7 @@ class TkMultiListFrame < TkListbox list = @lbox_list.collect{|lbox| lbox.get(*idx)} result = [] list[0].each_with_index{|line, index| - result << list.collect{|lines| lines[index]} + result << list.collect{|lines| lines[index]} } result end @@ -468,9 +468,9 @@ class TkMultiListFrame < TkListbox result = {} @name_index.each_pair{|label, indices| if indices.size == 1 - result[label] = line[indices[0]] + result[label] = line[indices[0]] else - result[label] = indices.collect{|index| line[index]} + result[label] = indices.collect{|index| line[index]} end } result @@ -492,31 +492,31 @@ class TkMultiListFrame < TkListbox lines.each{|line| if line.kind_of? Hash - array = [] - @name_index.each_pair{|label, indices| - if indices.size == 1 - array[indices[0]] = line[label] - else - if line[label].kind_of? Array - indices.each_with_index{|index, num| - array[index] = line[label][num] - } - else - array[indices[0]] = line[label] - end - end - } - line = array + array = [] + @name_index.each_pair{|label, indices| + if indices.size == 1 + array[indices[0]] = line[label] + else + if line[label].kind_of? Array + indices.each_with_index{|index, num| + array[index] = line[label][num] + } + else + array[indices[0]] = line[label] + end + end + } + line = array end @name_index.each_pair{|label, indices| - if indices.size == 1 - lbox_ins[indices[0]] << line[indices[0]] - else - indices.each{|index| lbox_ins[index] << line[index]} - end + if indices.size == 1 + lbox_ins[indices[0]] << line[indices[0]] + else + indices.each{|index| lbox_ins[index] << line[index]} + end } - } + } @lbox_list.each_with_index{|lbox, index| lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index] @@ -561,7 +561,7 @@ class TkMultiListFrame < TkListbox title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relheight'=>1.0) + 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx]) } end @@ -588,11 +588,11 @@ class TkMultiListFrame < TkListbox # adjustment of rightside widget of the sash title, lbox, hscr = @base_list[idx] title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx], 'relheight'=>1.0) + 'relx'=>@rel_list[idx], 'relheight'=>1.0) hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx], - 'relx'=>@rel_list[idx]) + 'relx'=>@rel_list[idx]) # update reference position @x = x @@ -616,34 +616,34 @@ class TkMultiListFrame < TkListbox def title_binding(title, index) title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)}, - "%W %x #{index}") + "%W %x #{index}") title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)}, - "%W %x #{index}") + "%W %x #{index}") title.bind('Leave', proc{|w| w.cursor ""}, "%W") title.bind('Button-1', - proc{|w, x| - if @mode == :sash - @x = x - @frame_width = TkWinfo.width(@f_title).to_f - else - title.relief 'sunken' - end - }, - '%W %X') + proc{|w, x| + if @mode == :sash + @x = x + @frame_width = TkWinfo.width(@f_title).to_f + else + title.relief 'sunken' + end + }, + '%W %X') title.bind('ButtonRelease-1', - proc{|w, x, idx| - i = idx.to_i - if @mode == :title && @title_cmd[i].kind_of?(Proc) - @title_cmd[i].call - end - title.relief 'raised' - motion_cb(w,x,i) - }, - "%W %x #{index}") + proc{|w, x, idx| + i = idx.to_i + if @mode == :title && @title_cmd[i].kind_of?(Proc) + @title_cmd[i].call + end + title.relief 'raised' + motion_cb(w,x,i) + }, + "%W %x #{index}") title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X") end @@ -652,11 +652,11 @@ class TkMultiListFrame < TkListbox def browse_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y') t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W') @@ -667,7 +667,7 @@ class TkMultiListFrame < TkListbox t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-slash', - proc{|w| select_line(w, w.index('active').to_i)}, '%W') + proc{|w| select_line(w, w.index('active').to_i)}, '%W') t end @@ -676,12 +676,12 @@ class TkMultiListFrame < TkListbox def single_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W') @@ -692,9 +692,9 @@ class TkMultiListFrame < TkListbox t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-slash', - proc{|w| select_line(w, w.index('active').to_i)}, '%W') + proc{|w| select_line(w, w.index('active').to_i)}, '%W') t.bind('Control-backslash', - proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}}) + proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}}) t end @@ -703,22 +703,22 @@ class TkMultiListFrame < TkListbox def extended_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y') t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Shift-Button-1', - proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('Shift-B1-Motion', - proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_range(w, w.nearest(y))}, '%W %y') t.bind('Control-Button-1', - proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y') t.bind('Control-B1-Motion', - proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y') + proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W') @@ -744,9 +744,9 @@ class TkMultiListFrame < TkListbox def multiple_mode_bindtag t = TkBindTag.new t.bind('Button-1', - proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y') + proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y') t.bind('ButtonRelease-1', - proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') + proc{|w, y| active_line(w, w.nearest(y))}, '%W %y') t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W') t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W') @@ -790,9 +790,9 @@ class TkMultiListFrame < TkListbox @lbox_list.each{|l| l.selection_anchor(idx) if st == 1 - l.selection_clear(idx) + l.selection_clear(idx) else - l.selection_set(idx) + l.selection_set(idx) end } end @@ -801,9 +801,9 @@ class TkMultiListFrame < TkListbox st = w.selection_includes('anchor') @lbox_list.each{|l| if st == 1 - l.selection_set('anchor', idx) + l.selection_set('anchor', idx) else - l.selection_clear('anchor', idx) + l.selection_clear('anchor', idx) end } end @@ -906,21 +906,21 @@ end ################################################ if __FILE__ == $0 l = TkMultiListFrame.new(nil, 200, - [ ['L1', 200, proc{p 'click L1'}], - ['L2', 100], - ['L3', 200] ], - 'width'=>350, - #'titleforeground'=>'yellow', - 'titleforeground'=>'white', - #'titlebackground'=>'navy', - 'titlebackground'=>'blue', - 'titlefont'=>'courier' - ).pack('fill'=>'both', 'expand'=>true) + [ ['L1', 200, proc{p 'click L1'}], + ['L2', 100], + ['L3', 200] ], + 'width'=>350, + #'titleforeground'=>'yellow', + 'titleforeground'=>'white', + #'titlebackground'=>'navy', + 'titlebackground'=>'blue', + 'titlefont'=>'courier' + ).pack('fill'=>'both', 'expand'=>true) l.insert('end', [1,2,3]) l.insert('end', [4,5,6]) l.insert('end', [4,5,6], [4,5,6]) l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'cccccccccccccccccccccccccccccccccccccccccccccccccccc']) l.insert('end', [1,2,3]) l.insert('end', [4,5,6], [4,5,6]) diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb index 4b0816d30..a06098323 100644 --- a/ext/tk/sample/tkoptdb-safeTk.rb +++ b/ext/tk/sample/tkoptdb-safeTk.rb @@ -19,12 +19,12 @@ EOM if ENV['LANG'] =~ /^ja/ # read Japanese resource ent = TkOptionDB.read_entries(File.expand_path('resource.ja', - File.dirname(__FILE__)), - 'euc-jp') + File.dirname(__FILE__)), + 'euc-jp') else # read English resource ent = TkOptionDB.read_entries(File.expand_path('resource.en', - File.dirname(__FILE__))) + File.dirname(__FILE__))) end file = File.expand_path('tkoptdb.rb', File.dirname(__FILE__)) diff --git a/ext/tk/sample/tkoptdb.rb b/ext/tk/sample/tkoptdb.rb index 897701c22..47784ea23 100644 --- a/ext/tk/sample/tkoptdb.rb +++ b/ext/tk/sample/tkoptdb.rb @@ -12,12 +12,12 @@ if __FILE__ == $0 || !TkCore::INTERP.safe? if ENV['LANG'] =~ /^ja/ # read Japanese resource TkOptionDB.read_with_encoding(File.expand_path('resource.ja', - File.dirname(__FILE__)), - 'euc-jp') + File.dirname(__FILE__)), + 'euc-jp') else # read English resource TkOptionDB.readfile(File.expand_path('resource.en', - File.dirname(__FILE__))) + File.dirname(__FILE__))) end end @@ -49,12 +49,12 @@ TkFrame.new(:class=>'BtnFrame'){|f| pack(:fill=>:x, :padx=>10, :pady=>10) } TkButton.new(:command=>proc{ - print "($SAFE=#{$SAFE} >>>) : " - cmd.bye_msg - print "(<<< $SAFE=#{$SAFE} ) : " - exit - }, - :parent=>f, :widgetname=>'quit'){ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE} ) : " + exit + }, + :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } } @@ -71,12 +71,12 @@ BtnFrame.new{|f| pack(:fill=>:x, :padx=>10, :pady=>10) } TkButton.new(:command=>proc{ - print "($SAFE=#{$SAFE} >>>) : " - cmd.bye_msg - print "(<<< $SAFE=#{$SAFE})" - exit - }, - :parent=>f, :widgetname=>'quit'){ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE})" + exit + }, + :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } } @@ -93,12 +93,12 @@ TkFrame.new(:class=>'BtnFrame2'){|f| pack(:fill=>:x, :padx=>10, :pady=>10) } TkButton.new(:command=>proc{ - print "($SAFE=#{$SAFE} >>>) : " - cmd.bye_msg - print "(<<< $SAFE=#{$SAFE})" - exit - }, - :parent=>f, :widgetname=>'quit'){ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE})" + exit + }, + :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } } diff --git a/ext/tk/sample/tktextframe.rb b/ext/tk/sample/tktextframe.rb index 72bc7c187..bdab057d3 100644 --- a/ext/tk/sample/tktextframe.rb +++ b/ext/tk/sample/tktextframe.rb @@ -147,16 +147,16 @@ if __FILE__ == $0 f = TkFrame.new.pack('fill'=>'x') #t = TkTextFrame.new.pack t = TkTextFrame.new(:textborderwidth=>3, - :textrelief=>:ridge, - :scrollbarrelief=>:ridge).pack + :textrelief=>:ridge, + :scrollbarrelief=>:ridge).pack p t.configinfo TkButton.new(f, 'text'=>'vscr OFF', - 'command'=>proc{t.vscroll(false)}).pack('side'=>'right') + 'command'=>proc{t.vscroll(false)}).pack('side'=>'right') TkButton.new(f, 'text'=>'vscr ON', - 'command'=>proc{t.vscroll(true)}).pack('side'=>'right') + 'command'=>proc{t.vscroll(true)}).pack('side'=>'right') TkButton.new(f, 'text'=>'hscr ON', - 'command'=>proc{t.hscroll(true)}).pack('side'=>'left') + 'command'=>proc{t.hscroll(true)}).pack('side'=>'left') TkButton.new(f, 'text'=>'hscr OFF', - 'command'=>proc{t.hscroll(false)}).pack('side'=>'left') + 'command'=>proc{t.hscroll(false)}).pack('side'=>'left') Tk.mainloop end diff --git a/ext/tk/sample/tktree.rb b/ext/tk/sample/tktree.rb index bcb94d360..d16d3344b 100644 --- a/ext/tk/sample/tktree.rb +++ b/ext/tk/sample/tktree.rb @@ -80,14 +80,14 @@ EOL items.each{|item| tr1.newitem(item, - :command=>proc{Tk.messageBox(:message=>"#{item} executed")}) + :command=>proc{Tk.messageBox(:message=>"#{item} executed")}) } f = TkFrame.new.pack(:expand=>true, :fill=>:both) tr2 = TkTree.new(f, :bg=>'black', #:itemfont=>{:family=>'Times', :size=>14}, - :textcolor=>'red', :bd=>4, :relief=>:ridge, - :selectbackground=>'darkBlue', :selectforeground=>'yellow', - :selectborderwidth=>3, :linecolor=>'yellow') { + :textcolor=>'red', :bd=>4, :relief=>:ridge, + :selectbackground=>'darkBlue', :selectforeground=>'yellow', + :selectborderwidth=>3, :linecolor=>'yellow') { yscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:right, :fill=>:y)) xscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:bottom, :fill=>:x)) pack(:expand=>true, :fill=>:both) @@ -95,8 +95,8 @@ EOL items.each{|item| tr2.newitem(item, :textcolor=>'green', :image=>'', - :itemfont=>{:family=>'Times', :size=>10}, - :command=>proc{Tk.messageBox(:message=>"#{item} executed")}) + :itemfont=>{:family=>'Times', :size=>10}, + :command=>proc{Tk.messageBox(:message=>"#{item} executed")}) } Tk.mainloop diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c index 152860c56..7e626409b 100644 --- a/ext/tk/tkutil.c +++ b/ext/tk/tkutil.c @@ -95,7 +95,7 @@ tk_do_callback(argc, argv, self) return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest); #endif return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]), - ID_call, argc - 1, argv + 1); + ID_call, argc - 1, argv + 1); } static char *cmd_id_head = "ruby_cmd TkUtil callback "; @@ -124,14 +124,14 @@ tk_install_cmd(argc, argv, self) #if 0 if (rb_scan_args(argc, argv, "01", &cmd) == 0) { - cmd = rb_block_proc(); + cmd = rb_block_proc(); } return tk_install_cmd_core(cmd); #endif if (argc == 0) { - cmd = rb_block_proc(); + cmd = rb_block_proc(); } else { - cmd = argv[0]; + cmd = argv[0]; } return tk_install_cmd_core(cmd); } @@ -146,15 +146,15 @@ tk_uninstall_cmd(self, cmd_id) StringValue(cmd_id); if (strncmp(cmd_id_head, RSTRING(cmd_id)->ptr, head_len) != 0) { - return Qnil; + return Qnil; } if (strncmp(cmd_id_prefix, - RSTRING(cmd_id)->ptr + head_len, prefix_len) != 0) { - return Qnil; + RSTRING(cmd_id)->ptr + head_len, prefix_len) != 0) { + return Qnil; } return rb_hash_delete(CALLBACK_TABLE, - rb_str_new2(RSTRING(cmd_id)->ptr + head_len)); + rb_str_new2(RSTRING(cmd_id)->ptr + head_len)); } static VALUE @@ -218,7 +218,7 @@ tk_symbolkey2str(self, keys) if NIL_P(keys) return new_keys; if (TYPE(keys) != T_HASH) { - rb_raise(rb_eArgError, "Hash is expected"); + rb_raise(rb_eArgError, "Hash is expected"); } st_foreach(RHASH(keys)->tbl, to_strkey, new_keys); return new_keys; @@ -242,53 +242,53 @@ ary2list(ary, self) /* size = RARRAY(ary)->len; */ size = 0; for(idx = 0; idx < RARRAY(ary)->len; idx++) { - if (TYPE(RARRAY(ary)->ptr[idx]) == T_HASH) { - size += 2 * RHASH(RARRAY(ary)->ptr[idx])->tbl->num_entries; - } else { - size++; - } + if (TYPE(RARRAY(ary)->ptr[idx]) == T_HASH) { + size += 2 * RHASH(RARRAY(ary)->ptr[idx])->tbl->num_entries; + } else { + size++; + } } dst = rb_ary_new2(size); RARRAY(dst)->len = 0; for(idx = 0; idx < RARRAY(ary)->len; idx++) { - val = RARRAY(ary)->ptr[idx]; - switch(TYPE(val)) { - case T_ARRAY: - RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self); - break; - - case T_HASH: - /* RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); */ - val = hash2kv(val, Qnil, self); - size2 = RARRAY(val)->len; - for(idx2 = 0; idx2 < size2; idx2++) { - val2 = RARRAY(val)->ptr[idx2]; - switch(TYPE(val2)) { - case T_ARRAY: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = ary2list(val2, self); - break; - - case T_HASH: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = hash2list(val2, self); - - default: - if (val2 != TK_None) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(val2, Qnil, self); - } - } - } - break; - - default: - if (val != TK_None) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(val, Qnil, self); - } - } + val = RARRAY(ary)->ptr[idx]; + switch(TYPE(val)) { + case T_ARRAY: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self); + break; + + case T_HASH: + /* RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); */ + val = hash2kv(val, Qnil, self); + size2 = RARRAY(val)->len; + for(idx2 = 0; idx2 < size2; idx2++) { + val2 = RARRAY(val)->ptr[idx2]; + switch(TYPE(val2)) { + case T_ARRAY: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = ary2list(val2, self); + break; + + case T_HASH: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = hash2list(val2, self); + + default: + if (val2 != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val2, Qnil, self); + } + } + } + break; + + default: + if (val != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val, Qnil, self); + } + } } return rb_apply(cTclTkLib, ID_merge_tklist, dst); } @@ -306,22 +306,22 @@ ary2list2(ary, self) dst = rb_ary_new2(size); RARRAY(dst)->len = 0; for(idx = 0; idx < RARRAY(ary)->len; idx++) { - val = RARRAY(ary)->ptr[idx]; - switch(TYPE(val)) { - case T_ARRAY: - RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self); - break; - - case T_HASH: - RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); - break; - - default: - if (val != TK_None) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(val, Qnil, self); - } - } + val = RARRAY(ary)->ptr[idx]; + switch(TYPE(val)) { + case T_ARRAY: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self); + break; + + case T_HASH: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); + break; + + default: + if (val != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val, Qnil, self); + } + } } return rb_apply(cTclTkLib, ID_merge_tklist, dst); } @@ -347,40 +347,40 @@ assoc2kv(assoc, ary, self) len = RARRAY(assoc)->len; for(i = 0; i < len; i++) { - pair = RARRAY(assoc)->ptr[i]; - if (TYPE(pair) != T_ARRAY) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); - continue; - } - switch(RARRAY(assoc)->len) { - case 2: - RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(pair)->ptr[2]; - - case 1: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = key2keyname(RARRAY(pair)->ptr[0]); - - case 0: - continue; - - default: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = key2keyname(RARRAY(pair)->ptr[0]); - - val = rb_ary_new2(RARRAY(pair)->len - 1); - RARRAY(val)->len = 0; - for(j = 1; j < RARRAY(pair)->len; j++) { - RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; - } - - RARRAY(dst)->ptr[RARRAY(dst)->len++] = val; - } + pair = RARRAY(assoc)->ptr[i]; + if (TYPE(pair) != T_ARRAY) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); + continue; + } + switch(RARRAY(assoc)->len) { + case 2: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(pair)->ptr[2]; + + case 1: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + case 0: + continue; + + default: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + val = rb_ary_new2(RARRAY(pair)->len - 1); + RARRAY(val)->len = 0; + for(j = 1; j < RARRAY(pair)->len; j++) { + RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; + } + + RARRAY(dst)->ptr[RARRAY(dst)->len++] = val; + } } if (NIL_P(ary)) { - return dst; + return dst; } else { - return rb_ary_plus(ary, dst); + return rb_ary_plus(ary, dst); } } @@ -398,42 +398,42 @@ assoc2kv_enc(assoc, ary, self) len = RARRAY(assoc)->len; for(i = 0; i < len; i++) { - pair = RARRAY(assoc)->ptr[i]; - if (TYPE(pair) != T_ARRAY) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); - continue; - } - switch(RARRAY(assoc)->len) { - case 2: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(RARRAY(pair)->ptr[2], Qtrue, self); - - case 1: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = key2keyname(RARRAY(pair)->ptr[0]); - - case 0: - continue; - - default: - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = key2keyname(RARRAY(pair)->ptr[0]); - - val = rb_ary_new2(RARRAY(pair)->len - 1); - RARRAY(val)->len = 0; - for(j = 1; j < RARRAY(pair)->len; j++) { - RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; - } - - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(val, Qtrue, self); - } + pair = RARRAY(assoc)->ptr[i]; + if (TYPE(pair) != T_ARRAY) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); + continue; + } + switch(RARRAY(assoc)->len) { + case 2: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(RARRAY(pair)->ptr[2], Qtrue, self); + + case 1: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + case 0: + continue; + + default: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + val = rb_ary_new2(RARRAY(pair)->len - 1); + RARRAY(val)->len = 0; + for(j = 1; j < RARRAY(pair)->len; j++) { + RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; + } + + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val, Qtrue, self); + } } if (NIL_P(ary)) { - return dst; + return dst; } else { - return rb_ary_plus(ary, dst); + return rb_ary_plus(ary, dst); } } @@ -455,7 +455,7 @@ push_kv(key, val, args) if (val == TK_None) return ST_CONTINUE; RARRAY(ary)->ptr[RARRAY(ary)->len++] - = get_eval_string_core(val, Qnil, RARRAY(args)->ptr[1]); + = get_eval_string_core(val, Qnil, RARRAY(args)->ptr[1]); return ST_CONTINUE; } @@ -477,9 +477,9 @@ hash2kv(hash, ary, self) st_foreach(RHASH(hash)->tbl, push_kv, args); if (NIL_P(ary)) { - return dst; + return dst; } else { - return rb_ary_concat(ary, dst); + return rb_ary_concat(ary, dst); } } @@ -495,8 +495,8 @@ push_kv_enc(key, val, args) #if 0 rb_ary_push(ary, key2keyname(key)); if (val != TK_None) { - rb_ary_push(ary, get_eval_string_core(val, Qtrue, - RARRAY(args)->ptr[1])); + rb_ary_push(ary, get_eval_string_core(val, Qtrue, + RARRAY(args)->ptr[1])); } #endif RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key); @@ -504,7 +504,7 @@ push_kv_enc(key, val, args) if (val == TK_None) return ST_CONTINUE; RARRAY(ary)->ptr[RARRAY(ary)->len++] - = get_eval_string_core(val, Qtrue, RARRAY(args)->ptr[1]); + = get_eval_string_core(val, Qtrue, RARRAY(args)->ptr[1]); return ST_CONTINUE; } @@ -526,9 +526,9 @@ hash2kv_enc(hash, ary, self) st_foreach(RHASH(hash)->tbl, push_kv_enc, args); if (NIL_P(ary)) { - return dst; + return dst; } else { - return rb_ary_concat(ary, dst); + return rb_ary_concat(ary, dst); } } @@ -561,49 +561,49 @@ tk_hash_kv(argc, argv, self) enc_flag = Qnil; switch(argc) { case 3: - ary = argv[2]; + ary = argv[2]; case 2: - enc_flag = argv[1]; + enc_flag = argv[1]; case 1: - hash = argv[0]; - break; + hash = argv[0]; + break; case 0: - rb_raise(rb_eArgError, "too few arguments"); + rb_raise(rb_eArgError, "too few arguments"); default: /* >= 3 */ - rb_raise(rb_eArgError, "too many arguments"); + rb_raise(rb_eArgError, "too many arguments"); } switch(TYPE(hash)) { case T_ARRAY: - if (RTEST(enc_flag)) { - return assoc2kv_enc(hash, ary, self); - } else { - return assoc2kv(hash, ary, self); - } + if (RTEST(enc_flag)) { + return assoc2kv_enc(hash, ary, self); + } else { + return assoc2kv(hash, ary, self); + } case T_HASH: - if (RTEST(enc_flag)) { - return hash2kv_enc(hash, ary, self); - } else { - return hash2kv(hash, ary, self); - } + if (RTEST(enc_flag)) { + return hash2kv_enc(hash, ary, self); + } else { + return hash2kv(hash, ary, self); + } case T_NIL: - if (NIL_P(ary)) { - return rb_ary_new(); - } else { - return ary; - } + if (NIL_P(ary)) { + return rb_ary_new(); + } else { + return ary; + } default: - if (hash == TK_None) { - if (NIL_P(ary)) { - return rb_ary_new(); - } else { - return ary; - } - } - rb_raise(rb_eArgError, "Hash is expected for 1st argument"); + if (hash == TK_None) { + if (NIL_P(ary)) { + return rb_ary_new(); + } else { + return ary; + } + } + rb_raise(rb_eArgError, "Hash is expected for 1st argument"); } } @@ -617,91 +617,91 @@ get_eval_string_core(obj, enc_flag, self) case T_FLOAT: case T_FIXNUM: case T_BIGNUM: - return rb_funcall(obj, ID_to_s, 0, 0); + return rb_funcall(obj, ID_to_s, 0, 0); case T_STRING: - if (RTEST(enc_flag)) { - if (rb_respond_to(self, ID_toUTF8)) { - return rb_funcall(self, ID_toUTF8, 1, obj); - } else { - return fromDefaultEnc_toUTF8(obj, self); - } - } else { - return obj; - } + if (RTEST(enc_flag)) { + if (rb_respond_to(self, ID_toUTF8)) { + return rb_funcall(self, ID_toUTF8, 1, obj); + } else { + return fromDefaultEnc_toUTF8(obj, self); + } + } else { + return obj; + } case T_SYMBOL: - if (RTEST(enc_flag)) { - if (rb_respond_to(self, ID_toUTF8)) { - return rb_funcall(self, ID_toUTF8, 1, - rb_str_new2(rb_id2name(SYM2ID(obj)))); - } else { - return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self); - } - } else { - return rb_str_new2(rb_id2name(SYM2ID(obj))); - } + if (RTEST(enc_flag)) { + if (rb_respond_to(self, ID_toUTF8)) { + return rb_funcall(self, ID_toUTF8, 1, + rb_str_new2(rb_id2name(SYM2ID(obj)))); + } else { + return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self); + } + } else { + return rb_str_new2(rb_id2name(SYM2ID(obj))); + } case T_HASH: - if (RTEST(enc_flag)) { - return hash2list_enc(obj, self); - } else { - return hash2list(obj, self); - } + if (RTEST(enc_flag)) { + return hash2list_enc(obj, self); + } else { + return hash2list(obj, self); + } case T_ARRAY: - if (RTEST(enc_flag)) { - return fromDefaultEnc_toUTF8(ary2list(obj, self), self); - } else { - return ary2list(obj, self); - } + if (RTEST(enc_flag)) { + return fromDefaultEnc_toUTF8(ary2list(obj, self), self); + } else { + return ary2list(obj, self); + } case T_FALSE: - return rb_str_new2("0"); + return rb_str_new2("0"); case T_TRUE: - return rb_str_new2("1"); + return rb_str_new2("1"); case T_NIL: - return rb_str_new2(""); + return rb_str_new2(""); case T_REGEXP: - return rb_funcall(obj, ID_source, 0, 0); + return rb_funcall(obj, ID_source, 0, 0); default: - if (rb_obj_is_kind_of(obj, cTkObject)) { - /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */ - return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), - enc_flag, self); - } - - if (rb_obj_is_kind_of(obj, rb_cProc) - || rb_obj_is_kind_of(obj, cMethod) - || rb_obj_is_kind_of(obj, cTkCallbackEntry)) { - if (rb_respond_to(self, ID_install_cmd)) { - return rb_funcall(self, ID_install_cmd, 1, obj); - } else { - return tk_install_cmd_core(obj); - } - } - - if (obj == TK_None) return Qnil; - - if (rb_respond_to(obj, ID_to_eval)) { - /* return rb_funcall(obj, ID_to_eval, 0, 0); */ - return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0), - enc_flag, self); - } else if (rb_respond_to(obj, ID_path)) { - /* return rb_funcall(obj, ID_path, 0, 0); */ - return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), - enc_flag, self); - } else if (rb_respond_to(obj, ID_to_s)) { - return rb_funcall(obj, ID_to_s, 0, 0); - } + if (rb_obj_is_kind_of(obj, cTkObject)) { + /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */ + return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), + enc_flag, self); + } + + if (rb_obj_is_kind_of(obj, rb_cProc) + || rb_obj_is_kind_of(obj, cMethod) + || rb_obj_is_kind_of(obj, cTkCallbackEntry)) { + if (rb_respond_to(self, ID_install_cmd)) { + return rb_funcall(self, ID_install_cmd, 1, obj); + } else { + return tk_install_cmd_core(obj); + } + } + + if (obj == TK_None) return Qnil; + + if (rb_respond_to(obj, ID_to_eval)) { + /* return rb_funcall(obj, ID_to_eval, 0, 0); */ + return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0), + enc_flag, self); + } else if (rb_respond_to(obj, ID_path)) { + /* return rb_funcall(obj, ID_path, 0, 0); */ + return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), + enc_flag, self); + } else if (rb_respond_to(obj, ID_to_s)) { + return rb_funcall(obj, ID_to_s, 0, 0); + } } rb_warning("fail to convert '%s' to string for Tk", - RSTRING(rb_funcall(obj, rb_intern("inspect"), 0, 0))->ptr); + RSTRING(rb_funcall(obj, rb_intern("inspect"), 0, 0))->ptr); return obj; } @@ -715,7 +715,7 @@ tk_get_eval_string(argc, argv, self) volatile VALUE obj, enc_flag; if (rb_scan_args(argc, argv, "11", &obj, &enc_flag) == 1) { - enc_flag = Qnil; + enc_flag = Qnil; } return get_eval_string_core(obj, enc_flag, self); @@ -727,9 +727,9 @@ tk_get_eval_enc_str(self, obj) VALUE obj; { if (obj == TK_None) { - return obj; + return obj; } else { - return get_eval_string_core(obj, Qtrue, self); + return get_eval_string_core(obj, Qtrue, self); } } @@ -753,26 +753,26 @@ tk_conv_args(argc, argv, self) rb_raise(rb_eArgError, "too few arguments"); } for(size = 0, idx = 2; idx < argc; idx++) { - if (TYPE(argv[idx]) == T_HASH) { - size += 2 * RHASH(argv[idx])->tbl->num_entries; - } else { - size++; - } + if (TYPE(argv[idx]) == T_HASH) { + size += 2 * RHASH(argv[idx])->tbl->num_entries; + } else { + size++; + } } /* dst = rb_ary_new2(argc - 2); */ dst = rb_ary_new2(size); RARRAY(dst)->len = 0; for(idx = 2; idx < argc; idx++) { - if (TYPE(argv[idx]) == T_HASH) { - if (RTEST(argv[1])) { - hash2kv_enc(argv[idx], dst, self); - } else { - hash2kv(argv[idx], dst, self); - } - } else if (argv[idx] != TK_None) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = get_eval_string_core(argv[idx], argv[1], self); - } + if (TYPE(argv[idx]) == T_HASH) { + if (RTEST(argv[1])) { + hash2kv_enc(argv[idx], dst, self); + } else { + hash2kv(argv[idx], dst, self); + } + } else if (argv[idx] != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(argv[idx], argv[1], self); + } } if (old_gc == Qfalse) rb_gc_enable(); @@ -790,15 +790,15 @@ tcl2rb_bool(self, value) VALUE value; { if (TYPE(value) == T_FIXNUM) { - if (NUM2INT(value) == 0) { - return Qfalse; - } else { - return Qtrue; - } + if (NUM2INT(value) == 0) { + return Qfalse; + } else { + return Qtrue; + } } if (TYPE(value) == T_TRUE || TYPE(value) == T_FALSE) { - return value; + return value; } rb_check_type(value, T_STRING); @@ -806,13 +806,13 @@ tcl2rb_bool(self, value) value = rb_funcall(value, ID_downcase, 0); if (RSTRING(value)->ptr[0] == '\0' - || strcmp(RSTRING(value)->ptr, "0") == 0 - || strcmp(RSTRING(value)->ptr, "no") == 0 - || strcmp(RSTRING(value)->ptr, "off") == 0 - || strcmp(RSTRING(value)->ptr, "false") == 0) { - return Qfalse; + || strcmp(RSTRING(value)->ptr, "0") == 0 + || strcmp(RSTRING(value)->ptr, "no") == 0 + || strcmp(RSTRING(value)->ptr, "off") == 0 + || strcmp(RSTRING(value)->ptr, "false") == 0) { + return Qfalse; } else { - return Qtrue; + return Qtrue; } } @@ -842,7 +842,7 @@ tkstr_invalid_numstr(value) VALUE value; { rb_raise(rb_eArgError, - "invalid value for Number: '%s'", RSTRING(value)->ptr); + "invalid value for Number: '%s'", RSTRING(value)->ptr); return Qnil; /*dummy*/ } @@ -851,8 +851,8 @@ tkstr_rescue_float(value) VALUE value; { return rb_rescue2(tkstr_to_float, value, - tkstr_invalid_numstr, value, - rb_eArgError, 0); + tkstr_invalid_numstr, value, + rb_eArgError, 0); } static VALUE @@ -862,8 +862,8 @@ tkstr_to_number(value) rb_check_type(value, T_STRING); return rb_rescue2(tkstr_to_int, value, - tkstr_rescue_float, value, - rb_eArgError, 0); + tkstr_rescue_float, value, + rb_eArgError, 0); } static VALUE @@ -885,7 +885,7 @@ tkstr_to_str(value) len = RSTRING(value)->len; if (len > 1 && *ptr == '{' && *(ptr + len - 1) == '}') { - return rb_str_new(ptr + 1, len - 2); + return rb_str_new(ptr + 1, len - 2); } return value; } @@ -908,8 +908,8 @@ tcl2rb_num_or_str(self, value) rb_check_type(value, T_STRING); return rb_rescue2(tkstr_to_number, value, - tkstr_to_str, value, - rb_eArgError, 0); + tkstr_to_str, value, + rb_eArgError, 0); } @@ -935,10 +935,10 @@ subst_free(ptr) struct cbsubst_info *ptr; { if (ptr) { - if (ptr->key != (char*)NULL) free(ptr->key); - if (ptr->type != (char*)NULL) free(ptr->type); - if (ptr->ivar != (ID*)NULL) free(ptr->ivar); - free(ptr); + if (ptr->key != (char*)NULL) free(ptr->key); + if (ptr->type != (char*)NULL) free(ptr->type); + if (ptr->ivar != (ID*)NULL) free(ptr->ivar); + free(ptr); } } @@ -966,7 +966,7 @@ cbsubst_init() inf->proc = proc; rb_const_set(cCB_SUBST, ID_SUBST_INFO, - Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free, inf)); + Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free, inf)); } static VALUE @@ -980,10 +980,10 @@ cbsubst_initialize(argc, argv, self) int idx; Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO), - struct cbsubst_info, inf); + struct cbsubst_info, inf); for(idx = 0; idx < argc; idx++) { - rb_ivar_set(self, inf->ivar[idx], argv[idx]); + rb_ivar_set(self, inf->ivar[idx], argv[idx]); } return self; @@ -1015,12 +1015,12 @@ cbsubst_get_subst_key(self, str) buf = ALLOC_N(char, len + 1); for(i = 0; i < len; i++) { - ptr = RSTRING(RARRAY(list)->ptr[i])->ptr; - if (*ptr == '%' && *(ptr + 2) == '\0') { - *(buf + i) = *(ptr + 1); - } else { - *(buf + i) = ' '; - } + ptr = RSTRING(RARRAY(list)->ptr[i])->ptr; + if (*ptr == '%' && *(ptr + 2) == '\0') { + *(buf + i) = *(ptr + 1); + } else { + *(buf + i) = ' '; + } } *(buf + len) = '\0'; @@ -1039,15 +1039,15 @@ cbsubst_get_all_subst_keys(self) volatile VALUE ret; Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), - struct cbsubst_info, inf); + struct cbsubst_info, inf); len = strlen(inf->key); buf = ALLOC_N(char, 3*len + 1); ptr = buf; for(i = 0; i < len; i++) { - *(ptr++) = '%'; - *(ptr++) = *(inf->key + i); - *(ptr++) = ' '; + *(ptr++) = '%'; + *(ptr++) = *(inf->key + i); + *(ptr++) = ' '; } *(buf + 3*len) = '\0'; @@ -1089,21 +1089,21 @@ cbsubst_table_setup(self, key_inf, proc_inf) * ivar ==> symbol */ for(idx = 0; idx < len; idx++) { - inf = RARRAY(key_inf)->ptr[idx]; - if (TYPE(inf) != T_ARRAY) continue; - *(key + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[0]); - *(type + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[1]); - - *(ivar + real_len) - = rb_intern( - RSTRING( - rb_str_cat2(rb_str_new2("@"), - rb_id2name(SYM2ID(RARRAY(inf)->ptr[2]))) - )->ptr - ); - - rb_attr(self, SYM2ID(RARRAY(inf)->ptr[2]), 1, 0, Qtrue); - real_len++; + inf = RARRAY(key_inf)->ptr[idx]; + if (TYPE(inf) != T_ARRAY) continue; + *(key + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[0]); + *(type + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[1]); + + *(ivar + real_len) + = rb_intern( + RSTRING( + rb_str_cat2(rb_str_new2("@"), + rb_id2name(SYM2ID(RARRAY(inf)->ptr[2]))) + )->ptr + ); + + rb_attr(self, SYM2ID(RARRAY(inf)->ptr[2]), 1, 0, Qtrue); + real_len++; } *(key + real_len) = '\0'; *(type + real_len) = '\0'; @@ -1116,14 +1116,14 @@ cbsubst_table_setup(self, key_inf, proc_inf) */ len = RARRAY(proc_inf)->len; for(idx = 0; idx < len; idx++) { - inf = RARRAY(proc_inf)->ptr[idx]; - if (TYPE(inf) != T_ARRAY) continue; - rb_hash_aset(proc, RARRAY(inf)->ptr[0], RARRAY(inf)->ptr[1]); + inf = RARRAY(proc_inf)->ptr[idx]; + if (TYPE(inf) != T_ARRAY) continue; + rb_hash_aset(proc, RARRAY(inf)->ptr[0], RARRAY(inf)->ptr[1]); } rb_const_set(self, ID_SUBST_INFO, - Data_Wrap_Struct(cSUBST_INFO, subst_mark, - subst_free, subst_inf)); + Data_Wrap_Struct(cSUBST_INFO, subst_mark, + subst_free, subst_inf)); return self; } @@ -1157,30 +1157,30 @@ cbsubst_scan_args(self, arg_key, val_ary) old_gc = rb_gc_disable(); Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), - struct cbsubst_info, inf); + struct cbsubst_info, inf); RARRAY(dst)->len = 0; for(idx = 0; idx < len; idx++) { - if (idx >= RSTRING(arg_key)->len) { - proc = Qnil; - } else if (*(RSTRING(arg_key)->ptr + idx) == ' ') { - proc = Qnil; - } else { - ptr = strchr(inf->key, *(RSTRING(arg_key)->ptr + idx)); - if (ptr == (char*)NULL) { - proc = Qnil; - } else { - c = *(inf->type + (ptr - inf->key)); - proc = rb_hash_aref(inf->proc, INT2FIX(c)); - } - } - - if (NIL_P(proc)) { - RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(val_ary)->ptr[idx]; - } else { - RARRAY(dst)->ptr[RARRAY(dst)->len++] - = rb_funcall(proc, ID_call, 1, RARRAY(val_ary)->ptr[idx]); - } + if (idx >= RSTRING(arg_key)->len) { + proc = Qnil; + } else if (*(RSTRING(arg_key)->ptr + idx) == ' ') { + proc = Qnil; + } else { + ptr = strchr(inf->key, *(RSTRING(arg_key)->ptr + idx)); + if (ptr == (char*)NULL) { + proc = Qnil; + } else { + c = *(inf->type + (ptr - inf->key)); + proc = rb_hash_aref(inf->proc, INT2FIX(c)); + } + } + + if (NIL_P(proc)) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(val_ary)->ptr[idx]; + } else { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = rb_funcall(proc, ID_call, 1, RARRAY(val_ary)->ptr[idx]); + } } if (old_gc == Qfalse) rb_gc_enable(); @@ -1256,13 +1256,13 @@ Init_tkutil() rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1); rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2); rb_define_singleton_method(cCB_SUBST, "_get_subst_key", - cbsubst_get_subst_key, 1); + cbsubst_get_subst_key, 1); rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys", - cbsubst_get_all_subst_keys, 0); + cbsubst_get_all_subst_keys, 0); rb_define_singleton_method(cCB_SUBST, "_setup_subst_table", - cbsubst_table_setup, 2); + cbsubst_table_setup, 2); rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl", - cbsubst_get_extra_args_tbl, 0); + cbsubst_get_extra_args_tbl, 0); rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1); @@ -1309,9 +1309,9 @@ Init_tkutil() rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1); rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1); rb_define_singleton_method(mTK, "_get_eval_string", - tk_get_eval_string, -1); + tk_get_eval_string, -1); rb_define_singleton_method(mTK, "_get_eval_enc_str", - tk_get_eval_enc_str, 1); + tk_get_eval_enc_str, 1); rb_define_singleton_method(mTK, "bool", tcl2rb_bool, 1); rb_define_singleton_method(mTK, "number", tcl2rb_number, 1); |