Class: TkTitledFrame
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_fixed_button, #add_fixed_menu_button, #add_fixed_panel, #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.
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
# File 'lib/a-tkcommons.rb', line 967
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
@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
|
Instance Attribute Details
#frame ⇒ Object
Returns the value of attribute frame.
964
965
966
|
# File 'lib/a-tkcommons.rb', line 964
def frame
@frame
end
|
#parent ⇒ Object
Returns the value of attribute parent.
966
967
968
|
# File 'lib/a-tkcommons.rb', line 966
def parent
@parent
end
|
#top ⇒ Object
Returns the value of attribute top.
965
966
967
|
# File 'lib/a-tkcommons.rb', line 965
def top
@top
end
|
Instance Method Details
#__create_left_label(_frame) ⇒ Object
994
995
996
997
998
999
1000
1001
1002
1003
1004
|
# File 'lib/a-tkcommons.rb', line 994
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
1006
1007
1008
1009
1010
1011
1012
1013
1014
|
# File 'lib/a-tkcommons.rb', line 1006
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_label ⇒ Object
986
987
988
|
# File 'lib/a-tkcommons.rb', line 986
def create_left_label
__create_left_label(@top)
end
|
#create_right_label ⇒ Object
990
991
992
|
# File 'lib/a-tkcommons.rb', line 990
def create_right_label
__create_right_label(@top)
end
|
def top_text(_text)
@right_label.text(_text)
end
1102
1103
1104
1105
|
# File 'lib/a-tkcommons.rb', line 1102
def head_buttons
@bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
end
|
#last_caption(_name) ⇒ Object
1082
1083
1084
|
# File 'lib/a-tkcommons.rb', line 1082
def last_caption(_name)
@right_labels_text[_name]
end
|
#last_caption_image(_name) ⇒ Object
1086
1087
1088
|
# File 'lib/a-tkcommons.rb', line 1086
def last_caption_image(_name)
@right_labels_image[_name]
end
|
#maximize ⇒ Object
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
|
# File 'lib/a-tkcommons.rb', line 1129
def maximize
if @state == 'normal'
p = TkWinfo.parent(self)
while (p != nil) && (TkWinfo.manager(p)=='place')
Arcadia.dialog(self, 'msg'=>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
1125
1126
1127
|
# File 'lib/a-tkcommons.rb', line 1125
def maximized?
@state == 'maximize'
end
|
#resize ⇒ Object
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
|
# File 'lib/a-tkcommons.rb', line 1107
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) ⇒ Object
1090
1091
1092
1093
1094
1095
1096
|
# File 'lib/a-tkcommons.rb', line 1090
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) ⇒ Object
1077
1078
1079
1080
|
# File 'lib/a-tkcommons.rb', line 1077
def save_caption(_name, _caption, _image=nil)
@right_labels_text[_name] = _caption
@right_labels_image[_name] = _image
end
|
#shift_off ⇒ Object
1020
1021
1022
|
# File 'lib/a-tkcommons.rb', line 1020
def shift_off
@left_label.foreground(Arcadia.conf('titlelabel.disabledforeground'))
end
|
#shift_on ⇒ Object
1016
1017
1018
|
# File 'lib/a-tkcommons.rb', line 1016
def shift_on
@left_label.foreground(Arcadia.conf('titlelabel.foreground'))
end
|
#title(_text = nil) ⇒ Object
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
|
# File 'lib/a-tkcommons.rb', line 1024
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, _image = nil) ⇒ Object
1045
1046
1047
1048
1049
1050
1051
1052
1053
|
# File 'lib/a-tkcommons.rb', line 1045
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) ⇒ Object
1055
1056
1057
|
# File 'lib/a-tkcommons.rb', line 1055
def top_text_bind_append(_tkevent, _proc=nil)
@right_label.bind_append(_tkevent, _proc)
end
|
#top_text_bind_remove(_tkevent) ⇒ Object
1059
1060
1061
|
# File 'lib/a-tkcommons.rb', line 1059
def top_text_bind_remove(_tkevent)
@right_label.bind_remove(_tkevent)
end
|
#top_text_clear ⇒ Object
1037
1038
1039
|
# File 'lib/a-tkcommons.rb', line 1037
def top_text_clear
@right_label.configure('text'=>'', 'image'=>nil)
end
|
#top_text_hide ⇒ Object
1041
1042
1043
|
# File 'lib/a-tkcommons.rb', line 1041
def top_text_hide
@right_label.unpack
end
|
#top_text_hint(_text = nil) ⇒ Object
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
|
# File 'lib/a-tkcommons.rb', line 1063
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
|