Class: AGTkFramePlaceManager

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-rad/lib/tk/al-tk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_main_frame = nil) {|_self| ... } ⇒ AGTkFramePlaceManager

Returns a new instance of AGTkFramePlaceManager.

Yields:

  • (_self)

Yield Parameters:


1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1444

def initialize(_main_frame = nil)
  @main_frame = _main_frame
  @frames = Hash.new
  @frames_seq = Array.new

  @frames_left = Hash.new
  @frames_right = Hash.new
  @frames_top = Hash.new
  @frames_bottom = Hash.new

  @Info = Struct.new("Info", :obj, :splitter, :side, :objp, :visible)
  @motion = false
  @nx= 0
  yield(self) if block_given?
end

Instance Attribute Details

#main_frameObject (readonly)

Returns the value of attribute main_frame


1442
1443
1444
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1442

def main_frame
  @main_frame
end

Instance Method Details

#[](_name) ⇒ Object


1580
1581
1582
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1580

def [](_name)
  @frames[_name].obj
end

#add(_name, _frame = TkFrame.new(@main_frame), _ndim = -1,, _splitter = false, _side = 'x') ⇒ Object


1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1460

def add(_name, _frame=TkFrame.new(@main_frame), _ndim=-1, _splitter=false, _side='x' )
  if _frame == nil
    _frame=TkFrame.new(@main_frame)
  end
  case _side
  when 'x'
    @frames_right.each_value{|value|
      value << _name
    }
    if @frames_right[_name]==nil
      @frames_right[_name] = Array.new
    end
  when 'y'
    @frames_bottom.each_value{|value|
      value << _name
    }
  end
  case _side
  when 'x'
    @frames_left[_name]= Array.new
    @frames_seq.each{|item|
      @frames_left[_name] << item
    }
    (_ndim>0)?(_rw=0):_rw=1
    _frame.place(
    'relwidth' => _rw,
    'relx' => 0,
    'x' => @nx,
    'y' => '0',
    'relheight' => '1',
    'rely' => 0,
    'height' => 1,
    'bordermode' => 'inside',
    'width' => _ndim
    )
    if _splitter
      _xbutton = TkButton.new(@main_frame){
        text  '<'
        overrelief  'ridge'
        relief  'groove'
      }
      _xbutton.place(
      'x' => @nx - 20,
      'y' => 0,
      'height' => 20,
      'bordermode' => 'outside',
      'width' => 20
      )
      _xbutton.bind_append(
      "ButtonPress-1",
      proc{
        @frames[@frames_left[_name][0]].objp.obj.unplace
        @frames[_name].objp.amove(1,0)
        do_resize(_name)
        _xbutton.place('x'=>0)
        _xbutton.raise
        if _xbutton.cget('text') == '<'
          _xbutton.configure('text'=>'>')
        else
          _xbutton.configure('text'=>'<')
        end
      }
      )
      if @motion
        _frame.bind_append(
        "B1-Motion",
        proc{do_resize(_name)}
        )
      else
        _frame.bind_append(
        "B1-Motion",
        proc{_frame.raise}
        )
      end
      _frame.bind_append(
      "ButtonRelease-1",
      proc{do_resize(_name)}
      )
    end

    @nx = @nx + _ndim if _ndim > 0

  when 'y'
    @frames_top[_name]= Array.new
    @frames_bottom[_name]= Array.new
    @frames_seq.each{|item|
      @frames_top[_name] << item
    }
  end
  @frames[_name] = @Info.new(
    _frame,
    _splitter,
    _side,
    AGTkObjPlace.new(_frame, _side),
    true
  )
  @frames_seq << _name
  return _frame
end

#do_resize(_name_splitter) ⇒ Object


1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1560

def do_resize (_name_splitter)
  case @frames[_name_splitter].side
  when 'x'
    _x = @frames[_name_splitter].objp.x0
    if (_x > 0)&&(@frames_left.length > 0)
      _w = @frames[_name_splitter].objp.w
      _index = @frames_left[_name_splitter].length - 1
      if (@frames_left.length == 1)||(_x > @frames[@frames_left[_name_splitter][_index]].objp.x0)
        @frames[@frames_left[_name_splitter][_index]].objp.go(_x,0)
      end
      _gap = _w
      @frames_right[_name_splitter].each{|i|
        @frames[i].objp.amove(_x + _gap,0)
        _gap = _gap + @frames[i].objp.w
      }
    end
  when 'y'
  end
end

#frame(_name) ⇒ Object


1584
1585
1586
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1584

def frame(_name)
  @frames[_name].obj
end

#hide(_name) ⇒ Object


1588
1589
1590
1591
1592
1593
1594
1595
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1588

def hide(_name)
  _w = @frames[_name].objp.w
  @frames[_name].obj.unplace
  @frames[_name].visible = false
  @frames_right[_name].each{|i|
    @frames[i].objp.move(-_w,0) if @frames[i].visible
  }
end

#show(_name) ⇒ Object


1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1596

def show(_name)
  _x = @frames[_name].objp.x0
  _w = @frames[_name].objp.w0
  @frames[_name].obj.place(
  'x' => _x,
  'relheight' => '1',
  'width' => _w
  )
  @frames[_name].visible = true
  _x = _x + _w
  @frames_right[_name].each{|i|
    if @frames[i].visible
      @frames[i].obj.place('x' =>_x)
      _x = _x + @frames[i].objp.w
    end
  }
end