Class: TkTitledFrame

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

Direct Known Subclasses

TkTitledScrollFrame

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TkBaseTitledFrame

#add_button, #add_menu_button, #create_frame, #menu_button

Constructor Details

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

Returns a new instance of TkTitledFrame.



783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
# File 'lib/a-tkcommons.rb', line 783

def initialize(parent=nil, title=nil, img=nil , keys=nil)
  super(parent, keys)
  @state = 'normal'
  title.nil??_text_title ='':_text_title = title+' :: ' 
  @title_label =TkLabel.new(@top, Arcadia.style('titlelabel')){
    text _text_title
    anchor  'w'
    compound 'left'
    image  TkAllPhotoImage.new('file' => img) if img
    pack('side'=> 'left','anchor'=> 'e')
  }
  @top_label =TkLabel.new(@top, Arcadia.style('titlelabel')){
    anchor  'w'
    font "#{Arcadia.conf('titlelabel.font')} italic"
    foreground  Arcadia.conf('titlecontext.foreground')
    compound 'left'
    pack('side'=> 'left','anchor'=> 'e')
  }
  
  @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.



779
780
781
# File 'lib/a-tkcommons.rb', line 779

def frame
  @frame
end

#parentObject (readonly)

Returns the value of attribute parent.



781
782
783
# File 'lib/a-tkcommons.rb', line 781

def parent
  @parent
end

#topObject (readonly)

Returns the value of attribute top.



780
781
782
# File 'lib/a-tkcommons.rb', line 780

def top
  @top
end

Instance Method Details

#add_sep(_width = 0, _background = @top.background) ⇒ Object

def top_text(_text)

  @top_label.text(_text)
end


834
835
836
837
838
839
840
# File 'lib/a-tkcommons.rb', line 834

def add_sep(_width=0,_background =@top.background)
  TkLabel.new(@top){||
    text  ''
    background  _background
    pack('side'=> 'right','anchor'=> 'e', 'ipadx'=>_width)
  }
end

#head_buttonsObject



843
844
845
846
# File 'lib/a-tkcommons.rb', line 843

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

#maximizeObject



866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
# File 'lib/a-tkcommons.rb', line 866

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

#resizeObject



848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# File 'lib/a-tkcommons.rb', line 848

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

#title(_text = nil) ⇒ Object



809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/a-tkcommons.rb', line 809

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

#top_text(_text = nil) ⇒ Object



822
823
824
825
826
827
828
# File 'lib/a-tkcommons.rb', line 822

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