diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-09 14:38:15 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-09 14:38:15 +0000 |
commit | 3e30d5452c75f4d18526870276eb82115c1df286 (patch) | |
tree | ae22ede91660a9e74cd8282f2cf28aa0d1408118 /ext/tk/sample | |
parent | bdaef7b528533e52e777b4b3ce757dad579238b9 (diff) | |
download | ruby-3e30d5452c75f4d18526870276eb82115c1df286.tar.gz ruby-3e30d5452c75f4d18526870276eb82115c1df286.tar.xz ruby-3e30d5452c75f4d18526870276eb82115c1df286.zip |
* overrided instance methods, which are private methods on the super
class, are changed to 'private'
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
-rw-r--r-- | ext/tk/sample/demos-en/dialog1.rb | 3 | ||||
-rw-r--r-- | ext/tk/sample/demos-en/dialog2.rb | 3 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/dialog1.rb | 3 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/dialog2.rb | 3 | ||||
-rw-r--r-- | ext/tk/sample/tkalignbox.rb | 83 | ||||
-rw-r--r-- | ext/tk/sample/tkcombobox.rb | 7 | ||||
-rw-r--r-- | ext/tk/sample/tkmultilistbox.rb | 1 | ||||
-rw-r--r-- | ext/tk/sample/tkoptdb.rb | 1 | ||||
-rw-r--r-- | ext/tk/sample/tktextframe.rb | 1 |
9 files changed, 88 insertions, 17 deletions
diff --git a/ext/tk/sample/demos-en/dialog1.rb b/ext/tk/sample/demos-en/dialog1.rb index d2b34e6b4..374fedc98 100644 --- a/ext/tk/sample/demos-en/dialog1.rb +++ b/ext/tk/sample/demos-en/dialog1.rb @@ -2,6 +2,9 @@ # a dialog box with a local grab (called by 'widget') # class TkDialog_Demo1 < TkDialog + ############### + private + ############### def title "Dialog with local grab" end diff --git a/ext/tk/sample/demos-en/dialog2.rb b/ext/tk/sample/demos-en/dialog2.rb index c441dda62..21bf25c88 100644 --- a/ext/tk/sample/demos-en/dialog2.rb +++ b/ext/tk/sample/demos-en/dialog2.rb @@ -2,6 +2,9 @@ # a dialog box with a global grab (called by 'widget') # class TkDialog_Demo2 < TkDialog + ############### + private + ############### def title "Dialog with global grab" end diff --git a/ext/tk/sample/demos-jp/dialog1.rb b/ext/tk/sample/demos-jp/dialog1.rb index 317b6d9eb..5b578a981 100644 --- a/ext/tk/sample/demos-jp/dialog1.rb +++ b/ext/tk/sample/demos-jp/dialog1.rb @@ -2,6 +2,9 @@ # a dialog box with a local grab (called by 'widget') # class TkDialog_Demo1 < TkDialog + ############### + private + ############### def title "Dialog with local grab" end diff --git a/ext/tk/sample/demos-jp/dialog2.rb b/ext/tk/sample/demos-jp/dialog2.rb index 295522e56..4819f18a0 100644 --- a/ext/tk/sample/demos-jp/dialog2.rb +++ b/ext/tk/sample/demos-jp/dialog2.rb @@ -2,6 +2,9 @@ # a dialog box with a global grab (called by 'widget') # class TkDialog_Demo2 < TkDialog + ############### + private + ############### def title "Dialog with global grab" end diff --git a/ext/tk/sample/tkalignbox.rb b/ext/tk/sample/tkalignbox.rb index cca91c9b0..b56c9cc11 100644 --- a/ext/tk/sample/tkalignbox.rb +++ b/ext/tk/sample/tkalignbox.rb @@ -12,6 +12,17 @@ require 'tk' class TkAlignBox < TkFrame def initialize(*args) + if self.class == TkAlignBox + fail RuntimeError, "TkAlignBox is an abstract class" + end + @padx = 0 + @pady = 0 + if args[-1].kind_of? Hash + keys = _symbolkey2str(args.pop) + @padx = keys.delete('padx') || 0 + @pady = keys.delete('pady') || 0 + args.push(keys) + end super(*args) @max_width = 0 @max_height = 0 @@ -53,7 +64,6 @@ class TkAlignBox < TkFrame @max_height = sz if @max_height < sz } align - self end def <<(widget) @@ -71,7 +81,6 @@ class TkAlignBox < TkFrame sz = widget.winfo_reqheight @max_height = sz if @max_height < sz align - self end def delete(idx) @@ -87,46 +96,85 @@ class TkAlignBox < TkFrame ret end + def padx(size = nil) + if size + @padx = size + align + else + @padx + end + end + + def pady(size = nil) + if size + @pady = size + align + else + @pady + end + end + attr_accessor :propagate end class TkHBox < TkAlignBox def _set_framesize bd = self.borderwidth - self.width(@max_width * @widgets.size + 2 * bd) - self.height(@max_height + 2 * bd) + self.width((@max_width + 2*@padx) * @widgets.size + 2*bd) + self.height(@max_height + 2*@pady + 2*bd) end + private :_set_framesize + def _place_config(widget, idx, cnt) - widget.place_in(self, 'relx'=>idx/cnt, 'relwidth'=>1.0/cnt, - 'relheight'=>1.0) + 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) end + private :_place_config end TkHLBox = TkHBox class TkHRBox < TkHBox def _place_config(widget, idx, cnt) - widget.place_in(self, 'relx'=>(cnt - idx - 1)/cnt, 'relwidth'=>1.0/cnt, - 'relheight'=>1.0) + 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) end + private :_place_config end class TkVBox < TkAlignBox def _set_framesize - self.width(@max_width + 2 * bd) - self.height(@max_height * @widgets.size + 2 * bd) + bd = self.borderwidth + self.width(@max_width + 2*@padx + 2*bd) + self.height((@max_height + 2*@pady) * @widgets.size + 2*bd) end + private :_set_framesize + def _place_config(widget, idx, cnt) - widget.place_in(self, 'rely'=>idx/cnt, 'relheight'=>1.0/cnt, - 'relwidth'=>1.0) + 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) end + private :_place_config end TkVTBox = TkVBox class TkVBBox < TkVBox def _place_config(widget, idx, cnt) - widget.place_in(self, 'rely'=>(cnt - idx - 1)/cnt, 'relheight'=>1.0/cnt, - 'relwidth'=>1.0) + 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) end + private :_place_config end ################################################ @@ -139,6 +187,13 @@ if __FILE__ == $0 TkButton.new(f, :text=>'aaa'), TkButton.new(f, :text=>'aaaa')) + f = TkHBox.new(:borderwidth=>3, :relief=>'ridge', + :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')) + f = TkVBox.new(:borderwidth=>5, :relief=>'groove').pack f.add(TkButton.new(f, :text=>'a'), TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'), diff --git a/ext/tk/sample/tkcombobox.rb b/ext/tk/sample/tkcombobox.rb index 08a2dd73a..f0cbdac3b 100644 --- a/ext/tk/sample/tkcombobox.rb +++ b/ext/tk/sample/tkcombobox.rb @@ -24,6 +24,9 @@ static unsigned char down_arrow_bits[] = { 0x10, 0x00, 0x10, 0x00, 0x00, 0x00}; EOD + ############################ + private + ############################ def initialize_composite(keys={}) keys = _symbolkey2str(keys) @@ -64,9 +67,6 @@ EOD configure keys unless keys.empty? end - ############################ - private - ############################ def _show_up_arrow unless @up_arrow.winfo_mapped? @up_arrow.pack(:side=>:top, :fill=>:x) @@ -330,6 +330,7 @@ EOD configure keys unless keys.empty? end + private :initialize_composite def scrollbar(mode) @lst.scrollbar(mode) diff --git a/ext/tk/sample/tkmultilistbox.rb b/ext/tk/sample/tkmultilistbox.rb index 9b66d401b..1896c66da 100644 --- a/ext/tk/sample/tkmultilistbox.rb +++ b/ext/tk/sample/tkmultilistbox.rb @@ -182,6 +182,7 @@ class TkMultiListbox < TkListbox delegate('borderwidth', @frame) delegate('relief', @frame) end + private :initialize_composite # set 'mode' option of listboxes def mode(sel_mode) diff --git a/ext/tk/sample/tkoptdb.rb b/ext/tk/sample/tkoptdb.rb index ab8515ac1..897701c22 100644 --- a/ext/tk/sample/tkoptdb.rb +++ b/ext/tk/sample/tkoptdb.rb @@ -33,6 +33,7 @@ cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) { print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): " str end + private :__check_proc_string__ end } diff --git a/ext/tk/sample/tktextframe.rb b/ext/tk/sample/tktextframe.rb index d1076c5b7..78efdf097 100644 --- a/ext/tk/sample/tktextframe.rb +++ b/ext/tk/sample/tktextframe.rb @@ -51,6 +51,7 @@ class TkTextFrame < TkText # do configure configure keys unless keys.empty? end + private :initialize_composite # set background color of text widget def textbackground(color = nil) |