class TkTitledFrame

Attributes

frame[RW]
parent[R]
top[R]

Public Class Methods

new(parent=nil, title=nil, img=nil , keys=nil) click to toggle source
Calls superclass method TkBaseTitledFrame::new
# File lib/a-tkcommons.rb, line 1375
  def initialize(parent=nil, title=nil, img=nil , keys=nil)
    super(parent, keys)
    @state = 'normal'
    @title = title
    @img = img
#    @left_label = create_left_label
    @left_label = create_left_title
    @right_label = create_right_label
    @right_labels_text = Hash.new
    @right_labels_image = Hash.new
    @ap = Array.new
    @apx = Array.new
    @apy = Array.new
    @apw = Array.new
    @aph = Array.new
    @top.bind_append("Double-Button-1", proc{resize})
    #@left_label.bind_append("Double-Button-1", proc{resize})
    @right_label.bind_append("Double-Button-1", proc{resize})
  end

Public Instance Methods

__create_right_label(_frame) click to toggle source

def __create_left_label(_frame)

@title.nil??_text_title ='':_text_title = @title+' :: '
_img=@img
TkLabel.new(_frame, Arcadia.style('titlelabel')){
  text _text_title
  anchor  'w'
  compound 'left'
  image  TkAllPhotoImage.new('file' => _img) if _img
  pack('side'=> 'left','anchor'=> 'e')
}

end

# File lib/a-tkcommons.rb, line 1415
def __create_right_label(_frame)
  TkLabel.new(_frame, Arcadia.style('titlelabel')){
    anchor  'w'
    font "#{Arcadia.conf('titlelabel.font')} italic"
    foreground  Arcadia.conf('titlecontext.foreground')
    compound 'left'
    pack('side'=> 'left','anchor'=> 'e')
  }
end
create_right_label() click to toggle source

def create_left_label

__create_left_label(@top)

end

# File lib/a-tkcommons.rb, line 1399
def create_right_label
  __create_right_label(@top)
end
head_buttons() click to toggle source

def top_text(_text)

@right_label.text(_text)

end

# File lib/a-tkcommons.rb, line 1511
def head_buttons
  @bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
  #@bmaxmin = add_button('[ ]',proc{resize}, EXPAND_GIF)
end
last_caption(_name) click to toggle source
# File lib/a-tkcommons.rb, line 1491
def last_caption(_name)
  @right_labels_text[_name]
end
last_caption_image(_name) click to toggle source
# File lib/a-tkcommons.rb, line 1495
def last_caption_image(_name)
  @right_labels_image[_name]
end
maximize() click to toggle source
# File lib/a-tkcommons.rb, line 1538
def maximize
  if @state == 'normal'
    p = TkWinfo.parent(self)
    while (p != nil) && (TkWinfo.manager(p)=='place')
      Arcadia.dialog(self, 'msg'=>p.to_s)
      #Tk.messageBox('message'=>p.to_s)
      @ap << p
      @apx << TkPlace.info(p)['x']
      @apy << TkPlace.info(p)['y']
      @apw << TkPlace.info(p)['width']
      @aph << TkPlace.info(p)['height']
      p.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1)
      p.raise
      p = TkWinfo.parent(p)
    end
    @state = 'maximize'
    self.raise
  else
    @ap.each_index{|i|
      @ap[i].place('x'=>@apx[i], 'y'=>@apy[i],'width'=>@apw[i], 'height'=>@aph[i],'relheight'=>1, 'relwidth'=>1)
      @ap[i].raise
    }
    self.raise
    @ap.clear
    @apx.clear
    @apy.clear
    @state = 'normal'
  end
end
maximized?() click to toggle source
# File lib/a-tkcommons.rb, line 1534
def maximized?
  @state == 'maximize'
end
resize() click to toggle source
# File lib/a-tkcommons.rb, line 1516
def resize
  p = TkWinfo.parent(@parent)
  if @state == 'normal'
    if p.kind_of?(AGTkSplittedFrames)
      p.maximize(@parent)
      @bmaxmin.image(Arcadia.image_res(W_NORM_GIF))
    end
    @state = 'maximize'
  else
    if p.kind_of?(AGTkSplittedFrames)
      p.minimize(@parent)
      @bmaxmin.image(Arcadia.image_res(W_MAX_GIF))
    end
    @state = 'normal'
  end
  self.raise
end
restore_caption(_name) click to toggle source
# File lib/a-tkcommons.rb, line 1499
def restore_caption(_name)
  if @right_labels_text[_name]
    top_text(@right_labels_text[_name], @right_labels_image[_name])
  else
    top_text_clear
  end
end
save_caption(_name, _caption, _image=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1486
def save_caption(_name, _caption, _image=nil)
  @right_labels_text[_name] = _caption
  @right_labels_image[_name] = _image
end
top_text(_text=nil, _image=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1454
def top_text(_text=nil, _image=nil)
  if _text.nil? && _image.nil?
    return @right_label.text
  elsif !_text.nil? && _image.nil?
    @right_label.text(_text)
  else
    @right_label.configure('text'=>_text, 'image'=>_image)
  end
end
top_text_bind_append(_tkevent, _proc=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1464
def top_text_bind_append(_tkevent, _proc=nil)
  @right_label.bind_append(_tkevent, _proc)
end
top_text_bind_remove(_tkevent) click to toggle source
# File lib/a-tkcommons.rb, line 1468
def top_text_bind_remove(_tkevent)
  @right_label.bind_remove(_tkevent)
end
top_text_clear() click to toggle source

def title(_text=nil)

if _text.nil?
  return @title
else
  @title=_text
  if _text.strip.length == 0
    @left_label.text('')
  else
    @left_label.text(_text+'::')
  end
end

end

# File lib/a-tkcommons.rb, line 1446
def top_text_clear
  @right_label.configure('text'=>'', 'image'=>nil)
end
top_text_hide() click to toggle source
# File lib/a-tkcommons.rb, line 1450
def top_text_hide
  @right_label.unpack
end
top_text_hint(_text=nil) click to toggle source
# File lib/a-tkcommons.rb, line 1472
def top_text_hint(_text=nil)
  if _text.nil?
    res = ''
    res = @right_label_hint_variable.value if defined?(@right_label_hint_variable)
    res
  else
    if !defined?(@right_label_hint_variable)
      @right_label_hint_variable = TkVariable.new
      Tk::BWidget::DynamicHelp::add(@right_label, 'variable'=>@right_label_hint_variable)
    end      
    @right_label_hint_variable.value=_text
  end
end