aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/sample/tkextlib/tktable
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-11 04:51:21 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-11 04:51:21 +0000
commit3514110b89bee5c37e308b4ca887e66dfe841456 (patch)
treed280d8542cc44d1cd1a75e8ec87b1f9d231561b7 /ext/tk/sample/tkextlib/tktable
parent05f5928c9d0f094d1e7e21a9bd9d8a8fc2f1a805 (diff)
downloadruby-3514110b89bee5c37e308b4ca887e66dfe841456.tar.gz
* ext/tk/lib/tk/*: untabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample/tkextlib/tktable')
-rw-r--r--ext/tk/sample/tkextlib/tktable/basic.rb26
-rw-r--r--ext/tk/sample/tkextlib/tktable/buttons.rb40
-rw-r--r--ext/tk/sample/tkextlib/tktable/command.rb74
-rw-r--r--ext/tk/sample/tkextlib/tktable/debug.rb24
-rw-r--r--ext/tk/sample/tkextlib/tktable/dynarows.rb34
-rw-r--r--ext/tk/sample/tkextlib/tktable/maxsize.rb18
-rw-r--r--ext/tk/sample/tkextlib/tktable/spreadsheet.rb56
-rw-r--r--ext/tk/sample/tkextlib/tktable/valid.rb18
8 files changed, 145 insertions, 145 deletions
diff --git a/ext/tk/sample/tkextlib/tktable/basic.rb b/ext/tk/sample/tkextlib/tktable/basic.rb
index a7dfe2a789..ece46b318e 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 b6995bb54b..b21e8673c2 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 950bc0ccb1..eb9ddffb78 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 30508acea6..3200c1c77a 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 35359046f7..d083e26559 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 a2c5f606a8..c9ca745ee5 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 5f3ba63bb3..9da896f5a7 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 4570441667..e5d3f11d84 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)