Module: TkResizable
- Included in:
- TkFloatTitledFrame, TkResizingTitledFrame
- Defined in:
- lib/a-tkcommons.rb
Constant Summary collapse
- MIN_WIDTH =
50
- MIN_HEIGHT =
50
Instance Method Summary collapse
- #resizing_do_move_obj(_x, _y) ⇒ Object
- #resizing_do_press(_x, _y) ⇒ Object
- #start_resizing(_moving_obj = self, _moved_obj = self) ⇒ Object
- #stop_resizing ⇒ Object
Instance Method Details
#resizing_do_move_obj(_x, _y) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/a-tkcommons.rb', line 144 def resizing_do_move_obj(_x, _y) _width0 = TkPlace.info(@moved_obj)['width'] _height0 = TkPlace.info(@moved_obj)['height'] _width = _width0 + _x - @x0 _height = _height0 + _y -@y0 _width = MIN_WIDTH if _width < MIN_WIDTH _height = MIN_HEIGHT if _height < MIN_HEIGHT @moved_obj.place('width'=>_width, 'height'=>_height) end |
#resizing_do_press(_x, _y) ⇒ Object
139 140 141 142 |
# File 'lib/a-tkcommons.rb', line 139 def resizing_do_press(_x, _y) @x0 = _x @y0 = _y end |
#start_resizing(_moving_obj = self, _moved_obj = self) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/a-tkcommons.rb', line 125 def start_resizing(_moving_obj=self, _moved_obj=self) @x0 = 0 @y0 = 0 @moving_obj = _moving_obj @moved_obj = _moved_obj @moving_obj.bind_append("B1-Motion", proc{|x, y| resizing_do_move_obj(x,y)},"%x %y") @moving_obj.bind_append("ButtonPress-1", proc{|e| resizing_do_press(e.x, e.y)}) end |
#stop_resizing ⇒ Object
134 135 136 137 |
# File 'lib/a-tkcommons.rb', line 134 def stop_resizing @moving_obj.bind_remove("B1-Motion") @moving_obj.bind_remove("ButtonPress-1") end |