Class: TkFrameAdapter

Inherits:
TkFrame
  • Object
show all
Includes:
TkMovable
Defined in:
lib/a-tkcommons.rb

Direct Known Subclasses

AGTkSplittedFrames

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TkMovable

#moving_do_move_obj, #moving_do_press, #start_moving, #stop_moving

Constructor Details

#initialize(scope_parent = nil, *args) ⇒ TkFrameAdapter

Returns a new instance of TkFrameAdapter.



242
243
244
245
246
247
# File 'lib/a-tkcommons.rb', line 242

def initialize(scope_parent=nil, *args)
  super(scope_parent, *args)
  @scope_parent = scope_parent
  @movable = true
  #ObjectSpace.define_finalizer(self, self.method(:detach_frame).to_proc)
end

Instance Attribute Details

#frameObject (readonly)

Returns the value of attribute frame.



241
242
243
# File 'lib/a-tkcommons.rb', line 241

def frame
  @frame
end

Instance Method Details

#add_moved_by(_obj) ⇒ Object



249
250
251
252
# File 'lib/a-tkcommons.rb', line 249

def add_moved_by(_obj)
  @movable = true
  start_moving(_obj, self)
end

#attach_frame(_frame) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
# File 'lib/a-tkcommons.rb', line 274

def attach_frame(_frame)
  @frame = _frame
  @frame_manager = TkWinfo.manager(@frame)
  refresh
  if @movable
    @frame.bind_append("Configure",proc{refresh})
    @frame.bind_append("Map",proc{refresh})
    @frame.bind_append("Unmap",proc{unmap  if TkWinfo.mapped?(@frame)})
  end
  self
end

#detach_frameObject



254
255
256
257
258
259
260
261
262
263
264
# File 'lib/a-tkcommons.rb', line 254

def detach_frame
  if @frame
    if @movable
      @frame.bind_remove("Configure")
      @frame.bind_remove("Map")
      @frame.bind_remove("Unmap")
    end
    @frame = nil
    self.unmap
  end
end

#is_pack?Boolean

Returns:

  • (Boolean)


290
291
292
# File 'lib/a-tkcommons.rb', line 290

def is_pack?
  @frame_manager == 'pack'
end

#is_place?Boolean

Returns:

  • (Boolean)


286
287
288
# File 'lib/a-tkcommons.rb', line 286

def is_place?
  @frame_manager == 'place' || @frame_manager.nil? || @frame_manager == ''
end

#refresh(_x = 0, _y = 0) ⇒ Object



294
295
296
297
298
299
300
# File 'lib/a-tkcommons.rb', line 294

def refresh(_x=0, _y=0)
  if is_place?
    place('in'=>@frame, 'x'=>_x, 'y'=>_y, 'relheight'=> 1, 'relwidth'=>1, 'bordermode'=>'outside')
  elsif is_pack?
    pack('in'=>@frame, 'fill'=>'both', 'expand'=>true)
  end
end

#unmapObject



266
267
268
269
270
271
272
# File 'lib/a-tkcommons.rb', line 266

def unmap
  if is_place?
    self.unplace
  elsif is_pack?
    self.unpack
  end
end