Class: TkTitledFrameAdapter

Inherits:
TkTitledFrame 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 TkTitledFrame

#__create_left_label, #__create_right_label, #create_left_label, #create_right_label, #head_buttons, #last_caption, #maximize, #maximized?, #resize, #restore_caption, #save_caption, #title, #top_text

Methods inherited from TkBaseTitledFrame

#add_fixed_button, #add_fixed_menu_button, #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.



1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'lib/a-tkcommons.rb', line 1146

def initialize(parent=nil, title=nil, img=nil , keys=nil)
  super(parent, title, img, keys)
  @transient_frame = TkFrame.new(@button_frame){
    background  Arcadia.conf('titlelabel.background')
    padx 0
    pady 0
    pack('side'=> "right",'anchor'=> 'e','fill'=>'both', 'expand'=>true)
  }
  @transient_frame_adapter = Hash.new
end

Instance Attribute Details

#transient_frame_adapterObject (readonly)

Returns the value of attribute transient_frame_adapter.



1144
1145
1146
# File 'lib/a-tkcommons.rb', line 1144

def transient_frame_adapter
  @transient_frame_adapter
end

Instance Method Details

#__attach_adapter(_adapter) ⇒ Object



1167
1168
1169
1170
1171
# File 'lib/a-tkcommons.rb', line 1167

def __attach_adapter(_adapter)
  @last_attached_adapter.detach_frame if @last_attached_adapter
  _adapter.attach_frame(@transient_frame)
  @last_attached_adapter = _adapter
end

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



1185
1186
1187
1188
# File 'lib/a-tkcommons.rb', line 1185

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])
end

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



1190
1191
1192
1193
# File 'lib/a-tkcommons.rb', line 1190

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])
end

#add_sep(_sender_name, _width = 0) ⇒ Object



1195
1196
1197
1198
# File 'lib/a-tkcommons.rb', line 1195

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

#change_adapter(_name, _adapter) ⇒ Object



1173
1174
1175
1176
1177
1178
# File 'lib/a-tkcommons.rb', line 1173

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

#change_adapter_name(_name) ⇒ Object



1180
1181
1182
1183
# File 'lib/a-tkcommons.rb', line 1180

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

#forge_transient_adapter(_name) ⇒ Object



1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/a-tkcommons.rb', line 1157

def forge_transient_adapter(_name)
  if @transient_frame_adapter[_name].nil?
    @transient_frame_adapter[_name] = TkFrameAdapter.new(Arcadia.layout.root,
    Arcadia.style('frame').update({'background'=>  Arcadia.conf('titlelabel.background')}))
    __attach_adapter(@transient_frame_adapter[_name])
    @transient_frame_adapter[_name].raise
  end
  @transient_frame_adapter[_name]
end