summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-11 14:59:49 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-11 14:59:49 +0000
commitd21469f63eb60b5c17fe3d96ce3e0da0fd2deab2 (patch)
tree777f3f1417bc0f28962b5b6d741cf17caa648078 /ext
parent82425ddcf5570a032cecd664f0f2a524d89814da (diff)
downloadruby-d21469f63eb60b5c17fe3d96ce3e0da0fd2deab2.tar.gz
ruby-d21469f63eb60b5c17fe3d96ce3e0da0fd2deab2.tar.xz
ruby-d21469f63eb60b5c17fe3d96ce3e0da0fd2deab2.zip
* ext/tk/lib/tkextlib/SUPPORT_STATUS: update to support libraries in
ActiveTcl8.4.12.0. * ext/tk/lib/tkextlib/tile/tnotebook.rb: add Tk::Tile::TNotebook#insert. * ext/tk/sample/tkextlib/tile/demo.rb: improve the look of a part of the demo. * ext/tk/sample/scrollframe.rb: add a new sample. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/ChangeLog.tkextlib9
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS11
-rw-r--r--ext/tk/lib/tkextlib/tile/tnotebook.rb9
-rw-r--r--ext/tk/sample/scrollframe.rb237
-rw-r--r--ext/tk/sample/tkextlib/tile/demo.rb6
5 files changed, 266 insertions, 6 deletions
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib
index 0100420a7..fa5524da0 100644
--- a/ext/tk/ChangeLog.tkextlib
+++ b/ext/tk/ChangeLog.tkextlib
@@ -1,3 +1,12 @@
+2005-12-11 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: update to support libraries in
+ ActiveTcl8.4.12.0.
+
+ * lib/tkextlib/tile/tnotebook.rb: add Tk::Tile::TNotebook#insert.
+
+ * sample/tkextlib/tile/demo.rb: improve the look of a part of the demo.
+
2005-11-25 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* sample/tkextlib/tile/demo.rb: bug fix
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index d7d9b31a5..8d7b6fc44 100644
--- a/ext/tk/lib/tkextlib/SUPPORT_STATUS
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -1,7 +1,7 @@
[ current support status of Tcl/Tk extensions ]
- *******<<< RELEASE_DATE of the libraries : 2005/11/22 >>>*******
+ *******<<< RELEASE_DATE of the libraries : 2005/12/11 >>>*******
The following list shows *CURRENT* status when this file was modifyed
at last. If you want to add other Tcl/Tk extensions to the planed list
@@ -55,8 +55,8 @@ script may give you some hints about that.
===< support with some examples (may be beta quality) >=======================
-Tcllib 1.8 http://sf.net/projects/tcllib
- ==> tcllib (partial support; Tklib part only)
+Tcllib 1.8
+Tklib 0.4.1 http://sf.net/projects/tcllib ==> tcllib
IWidgets 4.0.2 http://sf.net/projects/incrTcl ==> iwidgets
@@ -80,10 +80,11 @@ BLT 2.4z http://sourceforge.net/projects/blt
(http://raa.ruby-lang.org/)
==> blt
-TkTreeCtrl CVS/Hd(2005-03-25)
+TkTreeCtrl CVS/Hd(2005-12-02)
http://tktreectrl.sourceforge.net/ ==> treectrl
-Tile 0.7.2 http://tktable.sourceforge.net/tile/ ==> tile
+Tile CVS/Hd(2005-12-07)
+ http://tktable.sourceforge.net/tile/ ==> tile
diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb
index da4fa203c..abaed8ee9 100644
--- a/ext/tk/lib/tkextlib/tile/tnotebook.rb
+++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -90,6 +90,15 @@ class Tk::Tile::TNotebook < TkWindow
number(tk_send('index', idx))
end
+ def insert(idx, subwin, keys=nil)
+ if keys && keys != None
+ tk_send('insert', idx, subwin, *hash_kv(keys))
+ else
+ tk_send('insert', idx, subwin)
+ end
+ self
+ end
+
def select(idx)
tk_send('select', idx)
self
diff --git a/ext/tk/sample/scrollframe.rb b/ext/tk/sample/scrollframe.rb
new file mode 100644
index 000000000..b0ac6d387
--- /dev/null
+++ b/ext/tk/sample/scrollframe.rb
@@ -0,0 +1,237 @@
+#
+# Tk::ScrollFrame class
+#
+# This widget class is a frame widget with scrollbars.
+# The ScrollFrame doesn't propagate the size of embedded widgets.
+# When it is configured, scrollregion of the container is changed.
+#
+# Scrollbars can be toggled by Tk::ScrollFrame#vscroll & hscroll.
+# If horizontal or virtical scrollbar is turned off, the horizontal
+# or virtical size of embedded widgets is propagated.
+#
+# Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class Tk::ScrollFrame < TkFrame
+ include TkComposite
+
+ DEFAULT_WIDTH = 200
+ DEFAULT_HEIGHT = 200
+
+ def initialize_composite(keys={})
+ @frame.configure(:width=>DEFAULT_WIDTH, :height=>DEFAULT_HEIGHT)
+
+ # create scrollbars
+ @h_scroll = TkScrollbar.new(@frame, 'orient'=>'horizontal')
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+
+ # create a canvas widget
+ @canvas = TkCanvas.new(@frame,
+ :borderwidth=>0, :selectborderwidth=>0,
+ :highlightthickness=>0)
+
+ # allignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ @canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @frame.grid_propagate(false)
+
+ # assign scrollbars
+ @canvas.xscrollbar(@h_scroll)
+ @canvas.yscrollbar(@v_scroll)
+
+ # convert hash keys
+ keys = _symbolkey2str(keys)
+
+ # check options for the frame
+ framekeys = {}
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ if @classname = keys.delete('class')
+ framekeys['class'] = @classname
+ end
+ if @colormap = keys.delete('colormap')
+ framekeys['colormap'] = @colormap
+ end
+ if @container = keys.delete('container')
+ framekeys['container'] = @container
+ end
+ if @visual = keys.delete('visual')
+ framekeys['visual'] = @visual
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+
+ # create base frame
+ @base = TkFrame.new(@canvas, framekeys)
+
+ # embed base frame
+ @cwin = TkcWindow.new(@canvas, [0, 0], :window=>@base, :anchor=>'nw')
+ @canvas.scrollregion(@cwin.bbox)
+
+ # binding to reset scrollregion
+ @base.bind('Configure'){ _reset_scrollregion(nil, nil) }
+
+ # set default receiver of method calls
+ @path = @base.path
+
+ # scrollbars ON
+ vscroll(keys.delete('vscroll'){true})
+ hscroll(keys.delete('hscroll'){true})
+
+ # please check the differences of the following definitions
+ option_methods(
+ :scrollbarwidth
+ )
+
+ # set receiver widgets for configure methods (with alias)
+ delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)
+
+ # set receiver widgets for configure methods
+ delegate('DEFAULT', @base)
+ delegate('background', @frame, @base, @canvas, @h_scroll, @v_scroll)
+ delegate('width', @frame)
+ delegate('height', @frame)
+ delegate('activebackground', @h_scroll, @v_scroll)
+ delegate('troughcolor', @h_scroll, @v_scroll)
+ delegate('repeatdelay', @h_scroll, @v_scroll)
+ delegate('repeatinterval', @h_scroll, @v_scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ # do configure
+ configure keys unless keys.empty?
+ end
+
+ # callback for Configure event
+ def _reset_scrollregion(h_mod=nil, v_mod=nil)
+ cx1, cy1, cx2, cy2 = @canvas.scrollregion
+ x1, y1, x2, y2 = @cwin.bbox
+ @canvas.scrollregion([x1, y1, x2, y2])
+
+ if h_mod.nil? && v_mod.nil?
+ if x2 != cx2 && TkGrid.info(@h_scroll).size == 0
+ @frame.grid_propagate(true)
+ @canvas.width = x2
+ Tk.update_idletasks
+ @frame.grid_propagate(false)
+ end
+ if y2 != cy2 && TkGrid.info(@v_scroll).size == 0
+ @frame.grid_propagate(true)
+ @canvas.height = y2
+ Tk.update_idletasks
+ @frame.grid_propagate(false)
+ end
+ else
+ @h_scroll.ungrid if h_mod == false
+ @v_scroll.ungrid if v_mod == false
+
+ h_flag = (TkGrid.info(@h_scroll).size == 0)
+ v_flag = (TkGrid.info(@v_scroll).size == 0)
+
+ @frame.grid_propagate(true)
+
+ @canvas.width = (h_flag)? x2: @canvas.winfo_width
+ @canvas.height = (v_flag)? y2: @canvas.winfo_height
+
+ @h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew') if h_mod
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns') if v_mod
+
+ Tk.update_idletasks
+
+ @frame.grid_propagate(false)
+ end
+ end
+ private :_reset_scrollregion
+
+ # forbid to change binding of @base frame
+ def bind(*args)
+ @frame.bind(*args)
+ end
+ def bind_append(*args)
+ @frame.bind_append(*args)
+ end
+ def bind_remove(*args)
+ @frame.bind_remove(*args)
+ end
+ def bindinfo(*args)
+ @frame.bindinfo(*args)
+ end
+
+ # set width of scrollbar
+ def scrollbarwidth(width = nil)
+ if width
+ @h_scroll.width(width)
+ @v_scroll.width(width)
+ else
+ @h_scroll.width
+ end
+ end
+
+ # vertical scrollbar : ON/OFF
+ def vscroll(mode)
+ Tk.update_idletasks
+ st = TkGrid.info(@v_scroll)
+ if mode && st.size == 0 then
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
+ _reset_scrollregion(nil, true)
+ elsif !mode && st.size != 0 then
+ _reset_scrollregion(nil, false)
+ else
+ _reset_scrollregion(nil, nil)
+ end
+ self
+ end
+
+ # horizontal scrollbar : ON/OFF
+ def hscroll(mode)
+ Tk.update_idletasks
+ st = TkGrid.info(@h_scroll)
+ if mode && st.size == 0 then
+ _reset_scrollregion(true, nil)
+ elsif !mode && st.size != 0 then
+ _reset_scrollregion(false, nil)
+ else
+ _reset_scrollregion(nil, nil)
+ end
+ self
+ end
+end
+
+# test
+if __FILE__ == $0
+ f = Tk::ScrollFrame.new(:scrollbarwidth=>10, :width=>300, :height=>200)
+ f.pack(:expand=>true, :fill=>:both)
+
+ TkButton.new(f, :text=>'foo button', :command=>proc{puts 'foo'}).pack
+ TkButton.new(f, :text=>'baaar button', :command=>proc{puts 'baaar'}).pack
+ TkButton.new(f, :text=>'baz button', :command=>proc{puts 'baz'}).pack
+ TkButton.new(f, :text=>'hoge hoge button',
+ :command=>proc{puts 'hoge hoge'}).pack(:side=>:bottom)
+
+ # f.hscroll(false)
+
+ Tk.after(3000){
+ t = TkText.new(f).pack(:expand=>true, :fill=>:both)
+ t.insert(:end, 'Here is a text widget')
+ }
+
+ Tk.after(6000){ f.vscroll(false) }
+
+ Tk.after(9000){ f.vscroll(true) }
+
+ Tk.after(12000){ f.hscroll(false) }
+
+ Tk.after(15000){ f.hscroll(true) }
+
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkextlib/tile/demo.rb b/ext/tk/sample/tkextlib/tile/demo.rb
index 13ec3249d..b604410da 100644
--- a/ext/tk/sample/tkextlib/tile/demo.rb
+++ b/ext/tk/sample/tkextlib/tile/demo.rb
@@ -734,7 +734,11 @@ end
#
$Timers = {:StateMonitor=>nil, :FocusMonitor=>nil}
-msg = TkMessage.new(others, :aspect=>200)
+begin
+ msg = Tk::Tile::Label.new(others, :justify=>:left, :wraplength=>300)
+rescue
+ msg = TkMessage.new(others, :aspect=>200)
+end
$Desc = {}