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
324
325
326
# File 'lib/a-tkcommons.rb', line 291

def attach_frame(_frame, _extension = nil, _frame_index=0)
  if _frame.kind_of?(Tk::ScrollFrame)
    _frame = _frame.baseframe
  end
  @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)

344
345
346
# File 'lib/a-tkcommons.rb', line 344

def is_pack?
  @frame_manager == 'pack'
end

#is_place?Boolean

Returns:

  • (Boolean)

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

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

#is_undefined?Boolean

Returns:

  • (Boolean)

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

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

#layout_managerObject


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

def layout_manager
  @frame_manager
end

#map(_layout_manager = nil) ⇒ Object


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

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


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

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

#unmap(_layout_manager = nil) ⇒ Object


364
365
366
367
368
369
370
371
372
# File 'lib/a-tkcommons.rb', line 364

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