class TkBaseTitledFrame

Attributes

frame[R]
top[R]

Public Class Methods

new(parent=nil, *args) click to toggle source
Calls superclass method
# File lib/a-tkcommons.rb, line 1105
def initialize(parent=nil, *args)
  super(parent, Arcadia.style('panel'))
  @parent = parent
  @title_height = 18
  @top = TkFrame.new(self){
    background  Arcadia.conf('titlelabel.background')
  }.place('x'=>0, 'y'=>0,'height'=>@title_height, 'relwidth'=>1)
  #.pack('fill'=> 'x','ipady'=> @title_height, 'side'=>'top')
  @frame = create_frame

  @state_frame=TkFrame.new(@top){
    #background  '#303b50'
    background  Arcadia.conf('titlelabel.background')
  }.pack('side'=> 'left','anchor'=> 'e')

  @button_frame=TkFrame.new(@top){
    #background  '#303b50'
    background  Arcadia.conf('titlelabel.background')
  }.pack('side'=> 'right','anchor'=> 'w', 'fill'=>'both', 'expand'=>'true')

  @buttons = Hash.new
  @menu_buttons = Hash.new
  @panels = Hash.new
  @last_for_frame = Hash.new
  @last_for_state_frame = Hash.new
  self.head_buttons
end

Public Instance Methods

add_fixed_button(_label,_proc=nil,_image=nil, _side= 'right') click to toggle source
# File lib/a-tkcommons.rb, line 1138
def add_fixed_button(_label,_proc=nil,_image=nil, _side= 'right')
  __add_button(_label,_proc,_image, _side,@button_frame)
end
add_fixed_menu_button(_name='default',_image=nil, _side= 'right', _args=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1142
def add_fixed_menu_button(_name='default',_image=nil, _side= 'right', _args=nil)
  __add_menu_button(_name, _image, _side, _args, @button_frame)
end
add_fixed_panel(_name='default',_side= 'right', _args=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1146
def add_fixed_panel(_name='default',_side= 'right', _args=nil)
  __add_panel(_name, _side, _args, @button_frame)
end
add_fixed_progress(_max=100, _canc_proc=nil, _hint=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1154
def add_fixed_progress(_max=100, _canc_proc=nil, _hint=nil)
  __add_progress(_max, _canc_proc, @button_frame, _hint)
end
add_fixed_sep(_width=0) click to toggle source
# File lib/a-tkcommons.rb, line 1150
def add_fixed_sep(_width=0)
  __add_sep(_width, @button_frame)
end
create_frame() click to toggle source
# File lib/a-tkcommons.rb, line 1133
  def create_frame
#    return Tk::ScrollFrame.new(self).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
    return TkFrame.new(self,Arcadia.style('panel')).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
  end
head_buttons() click to toggle source
# File lib/a-tkcommons.rb, line 1358
def head_buttons
  @bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
end
menu_button(_name='default') click to toggle source
visible?() click to toggle source
# File lib/a-tkcommons.rb, line 1362
def visible?
  ret = false
  begin
    ret = TkWinfo.mapped?(self)
  rescue Exception => e
  end
end

Private Instance Methods

__add_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1158
  def __add_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil)
    return if _frame.nil?
    begin
      last = @last_for_frame[_frame]
#      @last_for_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
      @last_for_frame[_frame] = Arcadia.wf.titletoolbutton(_frame){
        text  _label if _label
        image  Arcadia.image_res(_image) if _image
#        padx 0
#        pady 0
        if last
          pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
        else
          pack('side'=> _side,'anchor'=> 'e')
        end
        bind('1',_proc) if _proc
      }
      Tk::BWidget::DynamicHelp::add(@last_for_frame[_frame], 'text'=>_label) if _label
      @last_for_frame[_frame]
    rescue RuntimeError => e
      Arcadia.runtime_error(e)
    end
  end
__add_check_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1224
  def __add_check_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil)
    return if _frame.nil?
    begin
      last = @last_for_frame[_frame]
#      @last_for_frame[_frame] = TkCheckButton.new(_frame, Arcadia.style('checkbox').update('background'=>_frame.background)){
#        text  _label if _label
#        image  Arcadia.image_res(_image) if _image
#        padx 0
#        pady 0
#        if last
#          pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
#        else
#          pack('side'=> _side,'anchor'=> 'e')
#        end
#        command(_proc) if _proc
#      }
#      Tk::BWidget::DynamicHelp::add(@last_for_frame[_frame], 'text'=>_label) if _label

      @last_for_frame[_frame] = Arcadia.wf.titlecontextcheckbutton(@panel){
        text  _label if _label
        variable TkVariable.new
        image Arcadia.image_res(_image) if _image
        if last
          pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
        else
          pack('side'=> _side,'anchor'=> 'e')
        end
        command(_proc) if _proc
      }
      @last_for_frame[_frame].hint=_label if _label 
      @last_for_frame[_frame]
    rescue RuntimeError => e
      Arcadia.runtime_error(e)
    end
  end
__add_menu_button(_name='default',_image=nil, _side= 'right', _args=nil, _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1183
  def __add_menu_button(_name='default',_image=nil, _side= 'right', _args=nil, _frame=nil)
    return if _frame.nil?
    args = Arcadia.style('titlelabel')
    args.update(_args) if _args
    last = @last_for_frame[_frame]
    @last_for_frame[_frame] =  @menu_buttons[_name] = Arcadia.wf.titlecontextmenubutton(_frame, _args){|mb|
      menu Arcadia.wf.titlemenu(mb)
#      menu TkMenu.new(mb, Arcadia.style('titlemenu'))
      if _image
#        indicatoron false
        image Arcadia.image_res(_image)
      else
#        indicatoron true
      end
#      padx 0
      if last
        pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
      else
        pack('side'=> _side,'anchor'=> 'e')
      end
    }
    
#    @last_for_frame[_frame] =  @menu_buttons[_name] = TkMenuButton.new(_frame, args){|mb|
#      menu TkMenu.new(mb, Arcadia.style('titlemenu'))
#      if _image
#        indicatoron false
#        image Arcadia.image_res(_image)
#      else
#        indicatoron true
#      end
#      padx 0
#      if last
#        pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
#      else
#        pack('side'=> _side,'anchor'=> 'e')
#      end
#    }
    @menu_buttons[_name]
  end
__add_panel(_name='default', _side= 'right', _args=nil, _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1261
def __add_panel(_name='default', _side= 'right', _args=nil, _frame=nil)
  return if _frame.nil?
  args = Arcadia.style('panel').update('background'=>_frame.background, 'highlightbackground'=>_frame.background)
  args.update(_args) if _args
  begin
    last = @last_for_frame[_frame]
    @last_for_frame[_frame] = @panels[_name]= TkFrame.new(_frame, args){
      padx 0
      pady 0
      if last
        pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
      else
        pack('side'=> _side,'anchor'=> 'e')
      end
    }
    @panels[_name]
  rescue RuntimeError => e
    Arcadia.runtime_error(e)
  end
end
__add_progress(_max, _canc_proc=nil, _frame=nil, _hint=nil, _side= 'left') click to toggle source
# File lib/a-tkcommons.rb, line 1326
def __add_progress(_max, _canc_proc=nil, _frame=nil, _hint=nil, _side= 'left')
  
  return if _frame.nil?
  begin
    last = @last_for_frame[_frame]
    @last_for_frame[_frame] = TkFrameProgress.new(_frame, _max)
    if last
      @last_for_frame[_frame].pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
    else
      @last_for_frame[_frame].pack('side'=> _side,'anchor'=> 'e')
    end
    
    @last_for_frame[_frame].on_cancel=_canc_proc if _canc_proc

    Tk::BWidget::DynamicHelp::add(@last_for_frame[_frame], 'text'=>_hint) if _hint
    @last_for_frame[_frame]
  rescue RuntimeError => e
    Arcadia.runtime_error(e)
  end
end
__add_sep(_width=0, _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1283
def __add_sep(_width=0, _frame=nil)
  return if _width <= 0 || _frame.nil?
  _background=_frame.background
  last = @last_for_frame[_frame]
  @last_for_frame[_frame] =  TkLabel.new(_frame){||
    text  ''
    background  _background
    if last
      pack('side'=> 'right','anchor'=> 'e', 'ipadx'=>_width, 'after'=>last)
    else
      pack('side'=> 'right','anchor'=> 'e', 'ipadx'=>_width)
    end
  }
end
__add_state_button(_label,_proc=nil,_image=nil, _side= 'left', _frame=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1299
def __add_state_button(_label,_proc=nil,_image=nil, _side= 'left', _frame=nil)
  return if _frame.nil?
  begin
    last = @last_for_state_frame[_frame]
    #@last_for_state_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
    @last_for_state_frame[_frame] = Arcadia.wf.titletoolbutton(_frame){
      text  _label if _label
      image  Arcadia.image_res(_image) if _image
     # font 'helvetica 8 bold'
     # padx 0
     # pady 0
      if last
        pack('side'=> _side,'anchor'=> 'w', 'after'=>last)
      else
        pack('side'=> _side,'anchor'=> 'w')
      end
      bind('1',_proc) if _proc
    }
    @last_for_state_frame[_frame].hint=_label
    #Tk::BWidget::DynamicHelp::add(@last_for_state_frame[_frame], 'text'=>_label) if _label
    @last_for_state_frame[_frame]
  rescue RuntimeError => e
    Arcadia.runtime_error(e)
  end
end
__destroy_progress(_progress, _frame) click to toggle source
# File lib/a-tkcommons.rb, line 1348
def __destroy_progress(_progress, _frame)
  @last_for_frame[_frame] = nil if @last_for_frame[_frame] == _progress
  _progress.destroy
end