aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/sample/tkextlib/bwidget
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/bwidget
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/bwidget')
-rw-r--r--ext/tk/sample/tkextlib/bwidget/basic.rb118
-rw-r--r--ext/tk/sample/tkextlib/bwidget/demo.rb138
-rw-r--r--ext/tk/sample/tkextlib/bwidget/dnd.rb16
-rw-r--r--ext/tk/sample/tkextlib/bwidget/manager.rb64
-rw-r--r--ext/tk/sample/tkextlib/bwidget/select.rb82
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tmpldlg.rb180
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tree.rb260
7 files changed, 429 insertions, 429 deletions
diff --git a/ext/tk/sample/tkextlib/bwidget/basic.rb b/ext/tk/sample/tkextlib/bwidget/basic.rb
index f622c142e4..c1521651fd 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 e192cd6364..785d2681a8 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 fd6cc40dda..1c8b036530 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 65bbe0f9e6..776cb3065b 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 a04d8da482..ea24b47e2e 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 1ed84e21aa..3d19c8d092 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 9bfa4f3ccf..a355b6759c 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