Class: TkTitledFrame

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

Direct Known Subclasses

TkTitledFrameAdapter, TkTitledScrollFrame

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TkBaseTitledFrame

#add_fixed_button, #add_fixed_menu_button, #add_fixed_sep, #create_frame, #menu_button, #visible?

Constructor Details

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

Returns a new instance of TkTitledFrame.



863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/a-tkcommons.rb', line 863

def initialize(parent=nil, title=nil, img=nil , keys=nil)
  super(parent, keys)
  @state = 'normal'
  @title = title
  @img = img
  @left_label = create_left_label
  @right_label = create_right_label
  @right_labels_text = Hash.new
  @ap = Array.new
  @apx = Array.new
  @apy = Array.new
  @apw = Array.new
  @aph = Array.new
end

Instance Attribute Details

#frameObject

Returns the value of attribute frame.



860
861
862
# File 'lib/a-tkcommons.rb', line 860

def frame
  @frame
end

#parentObject (readonly)

Returns the value of attribute parent.



862
863
864
# File 'lib/a-tkcommons.rb', line 862

def parent
  @parent
end

#topObject (readonly)

Returns the value of attribute top.



861
862
863
# File 'lib/a-tkcommons.rb', line 861

def top
  @top
end

Instance Method Details

#__create_left_label(_frame) ⇒ Object



886
887
888
889
890
891
892
893
894
895
896
# File 'lib/a-tkcommons.rb', line 886

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

#__create_right_label(_frame) ⇒ Object



898
899
900
901
902
903
904
905
906
# File 'lib/a-tkcommons.rb', line 898

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_left_labelObject



878
879
880
# File 'lib/a-tkcommons.rb', line 878

def create_left_label
  __create_left_label(@top)
end

#create_right_labelObject



882
883
884
# File 'lib/a-tkcommons.rb', line 882

def create_right_label
  __create_right_label(@top)
end

#head_buttonsObject

def top_text(_text)

  @right_label.text(_text)
end


949
950
951
952
# File 'lib/a-tkcommons.rb', line 949

def head_buttons
  @bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
  #@bmaxmin = add_button('[ ]',proc{resize}, EXPAND_GIF)
end

#last_caption(_name) ⇒ Object



933
934
935
# File 'lib/a-tkcommons.rb', line 933

def last_caption(_name)
  @right_labels_text[_name]
end

#maximizeObject



976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
# File 'lib/a-tkcommons.rb', line 976

def maximize
  if @state == 'normal'
    p = TkWinfo.parent(self)
    while (p != nil) && (TkWinfo.manager(p)=='place')
      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?Boolean

Returns:

  • (Boolean)


972
973
974
# File 'lib/a-tkcommons.rb', line 972

def maximized?
  @state == 'maximize'
end

#resizeObject



954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/a-tkcommons.rb', line 954

def resize
  p = TkWinfo.parent(@parent)
  if @state == 'normal'
    if p.kind_of?(AGTkSplittedFrames)
      p.maximize(@parent)
      @bmaxmin.image(TkPhotoImage.new('dat' => W_NORM_GIF))
    end
    @state = 'maximize'
  else
    if p.kind_of?(AGTkSplittedFrames)
      p.minimize(@parent)
      @bmaxmin.image(TkPhotoImage.new('dat' =>W_MAX_GIF))
    end
    @state = 'normal'
  end
  self.raise
end

#restore_caption(_name) ⇒ Object



937
938
939
940
941
942
943
# File 'lib/a-tkcommons.rb', line 937

def restore_caption(_name)
  if @right_labels_text[_name]
    top_text(@right_labels_text[_name])
  else
    top_text('')
  end
end

#save_caption(_name, _caption) ⇒ Object



929
930
931
# File 'lib/a-tkcommons.rb', line 929

def save_caption(_name, _caption)
  @right_labels_text[_name] = _caption
end

#title(_text = nil) ⇒ Object



908
909
910
911
912
913
914
915
916
917
918
919
# File 'lib/a-tkcommons.rb', line 908

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

#top_text(_text = nil) ⇒ Object



921
922
923
924
925
926
927
# File 'lib/a-tkcommons.rb', line 921

def top_text(_text=nil)
  if _text.nil?
    return @right_label.text
  else
    @right_label.text(_text)
  end
end