Class: Tk::RbWidget::AlignBox
- Defined in:
- sample/tkalignbox.rb,
sample/tkalignbox.rb
Instance Attribute Summary collapse
-
#propagate ⇒ Object
Returns the value of attribute propagate.
Instance Method Summary collapse
- #<<(widget) ⇒ Object
- #add(*widgets) ⇒ Object
- #align ⇒ Object
- #delete(idx) ⇒ Object
-
#initialize(*args) ⇒ AlignBox
constructor
A new instance of AlignBox.
- #insert(idx, widget) ⇒ Object
- #padx(size = nil) ⇒ Object
- #pady(size = nil) ⇒ Object
Constructor Details
#initialize(*args) ⇒ AlignBox
Returns a new instance of AlignBox.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'sample/tkalignbox.rb', line 21 def initialize(*args) if self.class == Tk::RbWidget::AlignBox fail RuntimeError, "Tk::AlignBox 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 @propagate = true @widgets = [] end |
Instance Attribute Details
#propagate ⇒ Object
Returns the value of attribute propagate
124 125 126 |
# File 'sample/tkalignbox.rb', line 124 def propagate @propagate end |
Instance Method Details
#<<(widget) ⇒ Object
76 77 78 |
# File 'sample/tkalignbox.rb', line 76 def <<() add() end |
#add(*widgets) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'sample/tkalignbox.rb', line 61 def add(*) .each{|w| unless w.kind_of? TkWindow fail RuntimeError, "#{w.inspect} is not a widget instance." end @widgets.delete(w) @widgets << w sz = w.winfo_reqwidth @max_width = sz if @max_width < sz sz = w.winfo_reqheight @max_height = sz if @max_height < sz } align end |
#align ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'sample/tkalignbox.rb', line 50 def align = [] @widgets.each{|w| << w if w.winfo_exist?} @widgets = cnt = @widgets.size.to_f @widgets.each_with_index{|w, idx| _place_config(w, idx, cnt)} @widgets = _set_framesize if @propagate self end |
#delete(idx) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'sample/tkalignbox.rb', line 93 def delete(idx) ret = @widgets.delete_at(idx) @req_size = 0 @widget.each{|w| sz = w.winfo_reqwidth @max_width = sz if @max_width < sz sz = w.winfo_reqheight @max_height = sz if @max_height < sz } align ret end |
#insert(idx, widget) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'sample/tkalignbox.rb', line 80 def insert(idx, ) unless .kind_of? TkWindow fail RuntimeError, "#{.inspect} is not a widget instance." end @widgets.delete() @widgets[idx,0] = sz = .winfo_reqwidth @max_width = sz if @max_width < sz sz = .winfo_reqheight @max_height = sz if @max_height < sz align end |
#padx(size = nil) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'sample/tkalignbox.rb', line 106 def padx(size = nil) if size @padx = size align else @padx end end |
#pady(size = nil) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'sample/tkalignbox.rb', line 115 def pady(size = nil) if size @pady = size align else @pady end end |