3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
|
# File 'lib/a-tkcommons.rb', line 3197
def make_scrollable_frame(_frame)
TkGrid.rowconfigure(_frame, 0, 'weight'=>1, 'minsize'=>0)
TkGrid.columnconfigure(_frame, 0, 'weight'=>1, 'minsize'=>0)
canvas = TkCanvas.new(_frame)
canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
v_scroll = Arcadia.wf.scrollbar(_frame,{'orient'=>'vertical'})
h_scroll = Arcadia.wf.scrollbar(_frame,{'orient'=>'horizontal'})
p_vscroll = proc{|mode|
st = TkGrid.info(v_scroll)
if mode && st.size == 0 then
v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
elsif mode == false
v_scroll.ungrid
end
}
p_hscroll = proc{|mode|
st = TkGrid.info(h_scroll)
if mode && st.size == 0 then
h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
elsif mode == false
h_scroll.ungrid
end
}
p_do_yscrollcommand = proc{|first,last|
if first != nil && last != nil
delta = last.to_f - first.to_f
if delta != @last_y_delta
if delta < 1 && delta > 0 && last != @last_y_last
p_vscroll.call(true)
begin
v_scroll.set(first,last)
rescue Exception => e
Arcadia.runtime_error(e)
end
elsif delta == 1 || delta == 0
p_vscroll.call(false)
end
end
@last_y_last = last if last.to_f < 1
@last_y_delta = delta
end
}
p_do_xscrollcommand = proc{|first,last|
if first != nil && last != nil
delta = last.to_f - first.to_f
if delta != @last_x_delta
if delta < 1 && delta > 0 && last != @last_x_last
p_hscroll.call(true)
begin
h_scroll.set(first,last)
rescue Exception => e
Arcadia.runtime_error(e)
end
elsif delta == 1 || delta == 0
p_hscroll.call(false)
end
end
@last_x_last = last if last.to_f < 1
@last_x_delta = delta
end
}
canvas.yscrollbar(v_scroll)
canvas.xscrollbar(h_scroll)
canvas.yscrollcommand(proc{|first,last|
p_do_yscrollcommand.call(first,last)
})
canvas.xscrollcommand(proc{|first,last|
p_do_xscrollcommand.call(first,last)
})
frame = TkFrame.new(canvas)
frame.bind("Configure", proc{canvas.configure(:scrollregion=>canvas.bbox("all"))})
cwin = TkcWindow.new(canvas, 0, 0, :window=>frame)
canvas.scrollregion(cwin.bbox)
return frame
end
|