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
985
|
# 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_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})
@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_right_label(_frame) ⇒ Object
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
1007
1008
1009
1010
1011
1012
1013
1014
1015
|
# File 'lib/a-tkcommons.rb', line 1007
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 ⇒ Object
def create_left_label
__create_left_label(@top)
end
991
992
993
|
# File 'lib/a-tkcommons.rb', line 991
def create_right_label
__create_right_label(@top)
end
|
def top_text(_text)
@right_label.text(_text)
end
1103
1104
1105
1106
|
# File 'lib/a-tkcommons.rb', line 1103
def head_buttons
@bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
end
|
#last_caption(_name) ⇒ Object
1083
1084
1085
|
# File 'lib/a-tkcommons.rb', line 1083
def last_caption(_name)
@right_labels_text[_name]
end
|
#last_caption_image(_name) ⇒ Object
1087
1088
1089
|
# File 'lib/a-tkcommons.rb', line 1087
def last_caption_image(_name)
@right_labels_image[_name]
end
|
#maximize ⇒ Object
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
1158
|
# File 'lib/a-tkcommons.rb', line 1130
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
1126
1127
1128
|
# File 'lib/a-tkcommons.rb', line 1126
def maximized?
@state == 'maximize'
end
|
#resize ⇒ Object
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
# File 'lib/a-tkcommons.rb', line 1108
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
1091
1092
1093
1094
1095
1096
1097
|
# File 'lib/a-tkcommons.rb', line 1091
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
1078
1079
1080
1081
|
# File 'lib/a-tkcommons.rb', line 1078
def save_caption(_name, _caption, _image=nil)
@right_labels_text[_name] = _caption
@right_labels_image[_name] = _image
end
|
#top_text(_text = nil, _image = nil) ⇒ Object
1046
1047
1048
1049
1050
1051
1052
1053
1054
|
# File 'lib/a-tkcommons.rb', line 1046
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
1056
1057
1058
|
# File 'lib/a-tkcommons.rb', line 1056
def top_text_bind_append(_tkevent, _proc=nil)
@right_label.bind_append(_tkevent, _proc)
end
|
#top_text_bind_remove(_tkevent) ⇒ Object
1060
1061
1062
|
# File 'lib/a-tkcommons.rb', line 1060
def top_text_bind_remove(_tkevent)
@right_label.bind_remove(_tkevent)
end
|
#top_text_clear ⇒ Object
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
1038
1039
1040
|
# File 'lib/a-tkcommons.rb', line 1038
def top_text_clear
@right_label.configure('text'=>'', 'image'=>nil)
end
|
#top_text_hide ⇒ Object
1042
1043
1044
|
# File 'lib/a-tkcommons.rb', line 1042
def top_text_hide
@right_label.unpack
end
|
#top_text_hint(_text = nil) ⇒ Object
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
|
# File 'lib/a-tkcommons.rb', line 1064
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
|