Class: TkTitledFrameAdapter

Inherits:
TkMenuTitledFrame show all
Defined in:
lib/a-tkcommons.rb

Overview

class TkTitledMovableFrame < TkTitledFrame

attr_reader :wrapper
def initialize(root_parent=nil, parent=nil, title=nil, img=nil , keys=nil)
  @root_parent = root_parent
  #@wrapper = TkFrameAdapter.new(@root_parent, 'background'=>'red')
  @wrapper = TkFrameAdapter.new(@root_parent, Arcadia.style('frame'))
  super(parent, title, img, keys)
  #@wrapper.add_moved_by(@top)
  @wrapper.attach_frame(@frame)
  @frame=@wrapper
end

def change_wrapper(_new_wrapper)
  @wrapper = _new_wrapper
  @frame = _new_wrapper
end

#  def initialize(root_parent=nil, parent=nil, title=nil, img=nil , keys=nil)
#    @root_parent = root_parent
#    @wrapper = TkFrameAdapter.new(@root_parent, Arcadia.style('frame'))
#    super(@wrapper, title, img, keys)
#    @wrapped_frame=parent
#    #@wrapper.add_moved_by(@top)
#    @wrapper.attach_frame(parent)
#  end

end

Instance Attribute Summary collapse

Attributes inherited from TkTitledFrame

#frame, #parent, #top

Attributes inherited from TkBaseTitledFrame

#frame, #top

Instance Method Summary collapse

Methods inherited from TkMenuTitledFrame

#__create_left_menu_button, #create_left_title, #shift_off, #shift_on, #title, #title_menu

Methods inherited from TkTitledFrame

#__create_right_label, #create_right_label, #head_buttons, #last_caption, #last_caption_image, #maximize, #maximized?, #resize, #restore_caption, #save_caption, #top_text, #top_text_bind_append, #top_text_bind_remove, #top_text_clear, #top_text_hide, #top_text_hint

Methods inherited from TkBaseTitledFrame

#add_fixed_button, #add_fixed_menu_button, #add_fixed_panel, #add_fixed_progress, #add_fixed_sep, #create_frame, #head_buttons, #menu_button, #visible?

Constructor Details

#initialize(parent = nil, title = nil, img = nil, keys = nil) ⇒ TkTitledFrameAdapter

Returns a new instance of TkTitledFrameAdapter.



1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
# File 'lib/a-tkcommons.rb', line 1788

def initialize(parent=nil, title=nil, img=nil , keys=nil)
  super(parent, title, img, keys)
  @transient_action_frame = TkFrame.new(@button_frame){
    background  Arcadia.conf('titlelabel.background')
    padx 0
    pady 0
    pack('side'=> "right",'anchor'=> 'e','fill'=>'both', 'expand'=>true)
  }
  @transient_state_frame = TkFrame.new(@state_frame){
    background  Arcadia.conf('titlelabel.background')
    padx 0
    pady 0
    pack('side'=> "left",'anchor'=> 'w','fill'=>'both', 'expand'=>true)
  }
  @transient_frame_adapter = Hash.new
  @@instances = [] if !defined?(@@instances)
  @@instances << self 
end

Instance Attribute Details

#transient_frame_adapterObject (readonly)

Returns the value of attribute transient_frame_adapter.



1786
1787
1788
# File 'lib/a-tkcommons.rb', line 1786

def transient_frame_adapter
  @transient_frame_adapter
end

Instance Method Details

#__attach_action_adapter(_adapter) ⇒ Object

def __attach_adapter(_adapter)

  @last_attached_adapter.detach_frame if @last_attached_adapter
  _adapter.attach_frame(@transient_action_frame)
  @last_attached_adapter = _adapter
end


1826
1827
1828
1829
1830
# File 'lib/a-tkcommons.rb', line 1826

def __attach_action_adapter(_adapter)
  @last_attached_action_adapter.detach_frame if @last_attached_action_adapter
  _adapter.attach_frame(@transient_action_frame)
  @last_attached_action_adapter = _adapter
end

#__attach_state_adapter(_adapter) ⇒ Object



1832
1833
1834
1835
1836
# File 'lib/a-tkcommons.rb', line 1832

def __attach_state_adapter(_adapter)
  @last_attached_state_adapter.detach_frame if @last_attached_state_adapter
  _adapter.attach_frame(@transient_state_frame)
  @last_attached_state_adapter = _adapter
end

#add_button(_sender_name, _label, _proc = nil, _image = nil, _side = 'right') ⇒ Object



1883
1884
1885
1886
# File 'lib/a-tkcommons.rb', line 1883

def add_button(_sender_name, _label,_proc=nil,_image=nil, _side= 'right')
  forge_transient_adapter(_sender_name)
  __add_button(_label,_proc,_image, _side, @transient_frame_adapter[_sender_name][:action])
end

#add_check_button(_sender_name, _label, _proc = nil, _image = nil, _side = 'right') ⇒ Object



1893
1894
1895
1896
# File 'lib/a-tkcommons.rb', line 1893

def add_check_button(_sender_name, _label,_proc=nil,_image=nil, _side= 'right')
  forge_transient_adapter(_sender_name)
  __add_check_button(_label,_proc,_image, _side, @transient_frame_adapter[_sender_name][:action])
end

#add_menu_button(_sender_name, _name = 'default', _image = nil, _side = 'right', _args = nil) ⇒ Object



1888
1889
1890
1891
# File 'lib/a-tkcommons.rb', line 1888

def add_menu_button(_sender_name, _name='default',_image=nil, _side= 'right', _args=nil)
  forge_transient_adapter(_sender_name)
  __add_menu_button(_name, _image, _side, _args, @transient_frame_adapter[_sender_name][:action])
end

#add_panel(_sender_name, _name = 'default', _side = 'right', _args = nil) ⇒ Object



1898
1899
1900
1901
# File 'lib/a-tkcommons.rb', line 1898

def add_panel(_sender_name, _name='default',_side= 'right', _args=nil)
  forge_transient_adapter(_sender_name)
  __add_panel(_name, _side, _args, @transient_frame_adapter[_sender_name][:action])
end

#add_progress(_sender_name, _max = 100, _canc_proc = nil, _hint = nil) ⇒ Object



1913
1914
1915
1916
# File 'lib/a-tkcommons.rb', line 1913

def add_progress(_sender_name, _max=100, _canc_proc=nil, _hint=nil)
  forge_transient_adapter(_sender_name)
  __add_progress(_max, _canc_proc, @transient_frame_adapter[_sender_name][:action], _hint)
end

#add_sep(_sender_name, _width = 0) ⇒ Object



1903
1904
1905
1906
# File 'lib/a-tkcommons.rb', line 1903

def add_sep(_sender_name, _width=0)
  forge_transient_adapter(_sender_name)
  __add_sep(_width, @transient_frame_adapter[_sender_name][:action])
end

#add_state_button(_sender_name, _label, _proc = nil, _image = nil, _side = 'left') ⇒ Object



1908
1909
1910
1911
# File 'lib/a-tkcommons.rb', line 1908

def add_state_button(_sender_name, _label,_proc=nil,_image=nil, _side= 'left')
  forge_transient_adapter(_sender_name)
  __add_state_button(_label,_proc,_image, _side, @transient_frame_adapter[_sender_name][:state])
end

#change_adapters(_name, _adapters) ⇒ Object

def change_adapter(_name, _adapter)

  @transient_frame_adapter[_name] = _adapter
  @transient_frame_adapter[_name].detach_frame
  __attach_adapter(@transient_frame_adapter[_name])
  @transient_frame_adapter[_name].raise
end

def change_adapter_name(_name)
  __attach_adapter(forge_transient_adapter(_name))
  @transient_frame_adapter[_name].raise
end


1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/a-tkcommons.rb', line 1850

def change_adapters(_name, _adapters)
  forge_transient_adapter(_name)
  @transient_frame_adapter[_name][:action] = _adapters[:action]
  @transient_frame_adapter[_name][:state] = _adapters[:state]
  @transient_frame_adapter[_name][:action].detach_frame
  @transient_frame_adapter[_name][:state].detach_frame
  __attach_action_adapter(@transient_frame_adapter[_name][:action])
  __attach_state_adapter(@transient_frame_adapter[_name][:state])
  @transient_frame_adapter[_name][:action].raise
  @transient_frame_adapter[_name][:state].raise
end

#change_adapters_name(_name) ⇒ Object



1862
1863
1864
1865
1866
1867
# File 'lib/a-tkcommons.rb', line 1862

def change_adapters_name(_name)
  __attach_action_adapter(forge_transient_adapter(_name)[:action])
  __attach_state_adapter(forge_transient_adapter(_name)[:state])
  @transient_frame_adapter[_name][:action].raise
  @transient_frame_adapter[_name][:state].raise
end

#clear_transient_adapters(_name) ⇒ Object



1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
# File 'lib/a-tkcommons.rb', line 1869

def clear_transient_adapters(_name)
  @@instances.each{|i| 
    if i.transient_frame_adapter[_name] 
      if i.transient_frame_adapter[_name][:action]
        i.transient_frame_adapter[_name][:action].detach_frame
      end
      if i.transient_frame_adapter[_name][:state]
        i.transient_frame_adapter[_name][:state].detach_frame
      end
      i.transient_frame_adapter.delete(_name).clear
    end 
  }
end

#destroy_progress(_sender_name, _progress) ⇒ Object



1918
1919
1920
# File 'lib/a-tkcommons.rb', line 1918

def destroy_progress(_sender_name, _progress)
  __destroy_progress(_progress, @transient_frame_adapter[_sender_name][:action])
end

#forge_transient_adapter(_name) ⇒ Object



1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
# File 'lib/a-tkcommons.rb', line 1807

def forge_transient_adapter(_name)
  if @transient_frame_adapter[_name].nil?
    @transient_frame_adapter[_name] = Hash.new
    @transient_frame_adapter[_name][:action] = TkFrameAdapter.new(Arcadia.layout.root, {'background'=>  Arcadia.conf('titlelabel.background')})
    @transient_frame_adapter[_name][:state] = TkFrameAdapter.new(Arcadia.layout.root, {'background'=>  Arcadia.conf('titlelabel.background')})
    __attach_action_adapter(@transient_frame_adapter[_name][:action])
    __attach_action_adapter(@transient_frame_adapter[_name][:state])
    @transient_frame_adapter[_name][:action].raise
    @transient_frame_adapter[_name][:state].raise
  end
  @transient_frame_adapter[_name]
end