Class: TkScrollWidget
- Inherits:
-
Object
- Object
- TkScrollWidget
- Defined in:
- lib/a-tkcommons.rb
Instance Method Summary collapse
- #add_xscrollcommand(cmd = Proc.new) ⇒ Object
- #add_yscrollcommand(cmd = Proc.new) ⇒ Object
- #do_xscrollcommand(first, last) ⇒ Object
- #do_yscrollcommand(first, last) ⇒ Object
- #hide ⇒ Object
- #hide_h_scroll ⇒ Object
- #hide_v_scroll ⇒ Object
-
#initialize(widget) ⇒ TkScrollWidget
constructor
A new instance of TkScrollWidget.
- #show(_x = 0, _y = 0, _border_mode = 'outside') ⇒ Object
- #show_h_scroll ⇒ Object
- #show_v_scroll ⇒ Object
Constructor Details
#initialize(widget) ⇒ TkScrollWidget
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 |
# File 'lib/a-tkcommons.rb', line 1309 def initialize() @widget = @parent = TkWinfo.parent(@widget) @scroll_width = 15 @v_scroll_on = false @h_scroll_on = false @v_scroll = TkScrollbar.new(@parent,{ 'orient'=>'vertical'}.update(Arcadia.style('scrollbar')) ) @v_scroll.command(proc{|*args| @widget.yview *args }) @widget.yscrollcommand(proc{|first,last| do_yscrollcommand(first,last) }) @h_scroll = TkScrollbar.new(@parent,{ 'orient'=>'horizontal'}.update(Arcadia.style('scrollbar')) ) @h_scroll.command(proc{|*args| @widget.xview *args }) @widget.xscrollcommand(proc{|first,last| do_xscrollcommand(first,last) }) end |
Instance Method Details
#add_xscrollcommand(cmd = Proc.new) ⇒ Object
1345 1346 1347 |
# File 'lib/a-tkcommons.rb', line 1345 def add_xscrollcommand(cmd=Proc.new) @h_scroll_command = cmd end |
#add_yscrollcommand(cmd = Proc.new) ⇒ Object
1336 1337 1338 |
# File 'lib/a-tkcommons.rb', line 1336 def add_yscrollcommand(cmd=Proc.new) @v_scroll_command = cmd end |
#do_xscrollcommand(first, last) ⇒ Object
1349 1350 1351 1352 |
# File 'lib/a-tkcommons.rb', line 1349 def do_xscrollcommand(first,last) @h_scroll.set(first,last) @h_scroll_command.call(first,last) if !@h_scroll_command.nil? end |
#do_yscrollcommand(first, last) ⇒ Object
1340 1341 1342 1343 |
# File 'lib/a-tkcommons.rb', line 1340 def do_yscrollcommand(first,last) @v_scroll.set(first,last) @v_scroll_command.call(first,last) if !@v_scroll_command.nil? end |
#hide ⇒ Object
1374 1375 1376 1377 1378 |
# File 'lib/a-tkcommons.rb', line 1374 def hide @widget.unplace @v_scroll.unpack @h_scroll.unpack end |
#hide_h_scroll ⇒ Object
1398 1399 1400 1401 1402 |
# File 'lib/a-tkcommons.rb', line 1398 def hide_h_scroll @widget.place('height' => 0) @h_scroll.unpack @h_scroll_on = false end |
#hide_v_scroll ⇒ Object
1392 1393 1394 1395 1396 |
# File 'lib/a-tkcommons.rb', line 1392 def hide_v_scroll @widget.place('width' => 0) @v_scroll.unpack @v_scroll_on = false end |
#show(_x = 0, _y = 0, _border_mode = 'outside') ⇒ Object
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
# File 'lib/a-tkcommons.rb', line 1354 def show(_x=0,_y=0,_border_mode='outside') @x=_x @y=_y @widget.place( 'x'=>@x, 'y'=>@y, 'width' => -@x, 'height' => -@y, 'relheight'=>1, 'relwidth'=>1, 'bordermode'=>_border_mode ) if @v_scroll_on show_v_scroll end if @h_scroll_on show_h_scroll end end |
#show_h_scroll ⇒ Object
1386 1387 1388 1389 1390 |
# File 'lib/a-tkcommons.rb', line 1386 def show_h_scroll @widget.place('height' => -@scroll_width-@y) @h_scroll.pack('side' => 'bottom', 'fill' => 'x') @h_scroll_on = true end |
#show_v_scroll ⇒ Object
1380 1381 1382 1383 1384 |
# File 'lib/a-tkcommons.rb', line 1380 def show_v_scroll @widget.place('width' => -@scroll_width-@x) @v_scroll.pack('side' => 'right', 'fill' => 'y') @v_scroll_on = true end |