Class: AGTkLManager

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_agobj, _activate) ⇒ AGTkLManager

Returns a new instance of AGTkLManager.


628
629
630
631
632
633
634
635
636
637
638
639
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 628

def initialize(_agobj, _activate)
  unless defined? _agobj.ag_parent
    return
  end
  @@place_managers = Array.new if !defined? @@place_managers
  @@pack_managers = Array.new if !defined? @@pack_managers
  @@grid_managers = Array.new if !defined? @@grid_managers
  @agobj = _agobj
  @agobj.obj.bind_append("ButtonPress-1", proc{switch_manager(_activate)})
  set_manager(_agobj.props['layout_man']['manager']['get'].call, _activate)
  @active = _activate
end

Instance Attribute Details

#place_managerObject (readonly)

Returns the value of attribute place_manager


625
626
627
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 625

def place_manager
  @place_manager
end

#simple_managerObject (readonly)

Returns the value of attribute simple_manager


626
627
628
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 626

def simple_manager
  @simple_manager
end

Class Method Details

.deactivate_allObject


716
717
718
719
720
721
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 716

def AGTkLManager.deactivate_all
  @@place_managers.each{|value| value.deactivate}
  @@pack_managers.each{|value| value.deactivate}
  @@grid_managers.each{|value| value.deactivate}
  @active = false
end

Instance Method Details

#activate(free = true) ⇒ Object


685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 685

def activate(free=true)
  #Tk.messageBox('message'=>'activate')
  if !defined?(@manager)
    set_manager(@agobj.props['layout_man']['manager']['get'].call, true)
  end
  case @manager
  when 'place'
    @place_manager.activate(free) if defined? @place_manager
    @@last = @place_manager if defined? @place_manager
  when 'pack'
    @pack_manager.activate if defined? @pack_manager
    @@last = @place_manager if defined? @pack_manager
  else
    AGTkLManager.deactivate_all
    @@last = nil
  end
  @active = true
  #@agobj.obj.callback_break
end

#active?Boolean

Returns:

  • (Boolean)

641
642
643
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 641

def active?
  return @active||@place_manager.active?
end

#deactivateObject


723
724
725
726
727
728
729
730
731
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 723

def deactivate
  case @manager
  when 'place'
    @place_manager.deactivate if defined? @place_manager
  when 'pack'
    @pack_manager.deactivate if defined? @pack_manager
  end
  @active = false
end

#deactivate_lastObject


712
713
714
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 712

def deactivate_last
  @@last.deactivate if @@last
end

#refreshObject


705
706
707
708
709
710
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 705

def refresh
  case @manager
    when 'place'
      @place_manager.refresh
  end
end

#set_manager(_name, _activate) ⇒ Object


652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 652

def set_manager(_name, _activate)
  case _name
  when 'place'
    if !defined? @place_manager
      @place_manager = AGTkPlaceManager.new(@agobj,_activate)
      @@last = @place_manager
      @@place_managers << @place_manager
    end
    if defined? @pack_manager
      @pack_manager.free_rect
    end
  when 'pack'
    if !defined? @pack_manager
      @pack_manager = AGTkPackManager.new(@agobj,_activate) if !defined? @pack_manager
      @@last = @pack_manager
      @@pack_managers << @pack_manager
    end
    if defined? @place_manager
      @place_manager.free_rect
    end
  when 'grid'
    if !defined? @grid_manager
      @grid_manager = AGTkGridManager.new(@agobj,_activate) if !defined? @grid_manager
      @@last = @grid_manager
      @@grid_managers << @grid_manager
    end
  else
    @simple_manager = AGTkSimpleManager.new(@agobj,_activate)
  end
  @manager = _name
  @active = _activate
end

#switch_manager(_activate = true) ⇒ Object


645
646
647
648
649
650
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 645

def switch_manager(_activate=true)
  _req_manager = @agobj.props['layout_man']['manager']['get'].call
  if @manager != _req_manager
    set_manager(_req_manager, _activate)
  end
end

#util_bindObject


733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 733

def util_bind
  @agobj.obj.bind_append("Control-KeyPress"){|e|
    _deltax = 0
    _deltay = 0
    case e.keysym
    when 'Left'
      _deltax = -1
      _deltay = 0
    when 'Right'
      _deltax = 1
      _deltay = 0
    when 'Up'
      _deltax = 0
      _deltay = -1
    when 'Down'
      _deltax = 0
      _deltay = 1
    end
    if (_deltax != 0) || (_deltay != 0)
      active_object = AG.active
      active_object.l_manager.place_manager.do_mov_obj_delta(_deltax,_deltay)
      active_object.l_manager.place_manager.move_other_obj(_deltax, _deltay)
      active_object.l_manager.place_manager.refresh_active
    end
  }
  @agobj.obj.bind_append("Shift-KeyPress"){|e|
    active_object = AG.active
    case e.keysym
    when 'Left'
      active_object.l_manager.place_manager.do_mov_obj_delta_dim(-1,0)
      active_object.l_manager.activate
    when 'Right'
      active_object.l_manager.place_manager.do_mov_obj_delta_dim(1,0)
      active_object.l_manager.activate
    when 'Up'
      active_object.l_manager.place_manager.do_mov_obj_delta_dim(0,-1)
      active_object.l_manager.activate
    when 'Down'
      active_object.l_manager.place_manager.do_mov_obj_delta_dim(0,1)
      active_object.l_manager.activate
    end
  }
end