Class: TkFrameAdapter

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

Direct Known Subclasses

AGTkSplittedFrames

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of TkFrameAdapter.



268
269
270
271
272
273
274
275
276
# File 'lib/a-tkcommons.rb', line 268

def initialize(scope_parent=nil, args=nil)
  newargs =  Arcadia.style('panel')
  if !args.nil?
    newargs.update(args) 
  end
  super(scope_parent, newargs)
  @scope_parent = scope_parent
  #@movable = false
end

Instance Attribute Details

#frameObject (readonly)

include TkMovable



267
268
269
# File 'lib/a-tkcommons.rb', line 267

def frame
  @frame
end

Instance Method Details

#attach_frame(_frame, _extension = nil, _frame_index = 0) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/a-tkcommons.rb', line 291

def attach_frame(_frame, _extension = nil, _frame_index=0)
  @frame = _frame
  refresh_layout_manager
  self.map
  if _extension
    @frame.bind("Map", proc{
      if _extension.frame_raised?(_frame_index)
        @frame.raise
      else
        @frame.lower
      end
    })

    
#      ffw = Arcadia.instance.layout.frame(_extension.frame_domain(_frame_index),_extension.name)
#      if ffw
#        ffw.bind("Map", proc{
#          if _extension.frame_raised?(_frame_index)
#            p "pack"
#            @frame.pack
#            @frame.raise
#          else
#            p "unpack"
#            @frame.lower
#            @frame.unpack
#          end
#        })
#      end
  else
    self.bind("Map", proc{@frame.raise})
  end
  self
end

#detach_frameObject

def add_moved_by(_obj)

  @movable = true
  start_moving(_obj, self)
end


283
284
285
286
287
288
289
# File 'lib/a-tkcommons.rb', line 283

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

#is_pack?Boolean

Returns:

  • (Boolean)


341
342
343
# File 'lib/a-tkcommons.rb', line 341

def is_pack?
  @frame_manager == 'pack'
end

#is_place?Boolean

Returns:

  • (Boolean)


337
338
339
# File 'lib/a-tkcommons.rb', line 337

def is_place?
  @frame_manager == 'place' || is_undefined?
end

#is_undefined?Boolean

Returns:

  • (Boolean)


333
334
335
# File 'lib/a-tkcommons.rb', line 333

def is_undefined?
  @frame_manager.nil? || @frame_manager == ''
end

#layout_managerObject



325
326
327
# File 'lib/a-tkcommons.rb', line 325

def layout_manager
  @frame_manager
end

#map(_layout_manager = nil) ⇒ Object



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/a-tkcommons.rb', line 345

def map(_layout_manager=nil)
  if _layout_manager == "place" || (_layout_manager.nil? && is_place?) 
    if is_undefined? && _layout_manager
      @frame.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=>1, 'bordermode'=>'outside')
      @manager_forced_to_frame = "place" 
    end
    place('in'=>@frame, 'x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=>1, 'bordermode'=>'outside')
  elsif _layout_manager == "pack" || (_layout_manager.nil? && is_pack?)
    if is_undefined? && _layout_manager
      @frame.pack('fill'=>'both', :padx=>0, :pady=>0,  'expand'=>'yes')
      @manager_forced_to_frame = "pack" 
    end
    pack('in'=>@frame, 'fill'=>'both', :padx=>0, :pady=>0,  'expand'=>'yes')
  end
end

#refresh_layout_managerObject



329
330
331
# File 'lib/a-tkcommons.rb', line 329

def refresh_layout_manager
  @frame_manager = TkWinfo.manager(@frame)
end

#unmap(_layout_manager = nil) ⇒ Object



361
362
363
364
365
366
367
368
369
# File 'lib/a-tkcommons.rb', line 361

def unmap(_layout_manager=nil)
  if _layout_manager == "place" || (_layout_manager.nil? && is_place?)
    self.unplace
    @frame.unplace if @frame && @manager_forced_to_frame == "place"
  elsif _layout_manager == "pack" || (_layout_manager.nil? && is_pack?)
    self.unpack
    @frame.unpack if @frame  && @manager_forced_to_frame == "pack"
  end
end