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

Instance Method Details

#resizing_do_move_obj(_x, _y) ⇒ Object



116
117
118
119
120
121
122
123
124
# File 'lib/a-tkcommons.rb', line 116

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



111
112
113
114
# File 'lib/a-tkcommons.rb', line 111

def resizing_do_press(_x, _y)
		@x0 = _x
		@y0 = _y
end

#start_resizing(_moving_obj = self, _moved_obj = self) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/a-tkcommons.rb', line 97

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_resizingObject



106
107
108
109
# File 'lib/a-tkcommons.rb', line 106

def stop_resizing
  @moving_obj.bind_remove("B1-Motion")
  @moving_obj.bind_remove("ButtonPress-1")
end