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.



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/a-tkcommons.rb', line 822

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.



818
819
820
# File 'lib/a-tkcommons.rb', line 818

def frame
  @frame
end

#parentObject (readonly)

Returns the value of attribute parent.



820
821
822
# File 'lib/a-tkcommons.rb', line 820

def parent
  @parent
end

#topObject (readonly)

Returns the value of attribute top.



819
820
821
# File 'lib/a-tkcommons.rb', line 819

def top
  @top
end

Instance Method Details

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

def top_text(_text)

  @top_label.text(_text)
end


873
874
875
876
877
878
879
# File 'lib/a-tkcommons.rb', line 873

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

#head_buttonsObject



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

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

#maximizeObject



909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
# File 'lib/a-tkcommons.rb', line 909

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)


905
906
907
# File 'lib/a-tkcommons.rb', line 905

def maximized?
  @state == 'maximize'
end

#resizeObject



887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
# File 'lib/a-tkcommons.rb', line 887

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



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

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



861
862
863
864
865
866
867
# File 'lib/a-tkcommons.rb', line 861

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