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


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_r)['width']
  _height0 = TkPlace.info(@moved_obj_r)['height']
  _width = _width0 + _x - @x0_r
  _height = _height0 + _y -@y0_r
  _width = MIN_WIDTH if _width < MIN_WIDTH
  _height = MIN_HEIGHT if _height < MIN_HEIGHT
  @moved_obj_r.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_r = _x
  @y0_r = _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_r = 0
  @y0_r = 0
  @moving_obj_r = _moving_obj
  @moved_obj_r = _moved_obj
  @moving_obj_r.bind_append("B1-Motion", proc{|x, y| resizing_do_move_obj(x,y)},"%x %y")
  @moving_obj_r.bind_append("ButtonPress-1", proc{|x, y| resizing_do_press(x, y)},"%x %y")
end

#stop_resizingObject


134
135
136
137
# File 'lib/a-tkcommons.rb', line 134

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