Class: AGTkObjPlace
- Inherits:
-
Object
- Object
- AGTkObjPlace
- Defined in:
- lib/tk/al-tk.rb
Instance Attribute Summary collapse
-
#h0 ⇒ Object
readonly
Returns the value of attribute h0.
-
#height ⇒ Object
Returns the value of attribute height.
-
#motion ⇒ Object
Returns the value of attribute motion.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#r ⇒ Object
Returns the value of attribute r.
-
#relheight ⇒ Object
Returns the value of attribute relheight.
-
#relwidth ⇒ Object
Returns the value of attribute relwidth.
-
#start_x ⇒ Object
Returns the value of attribute start_x.
-
#start_y ⇒ Object
Returns the value of attribute start_y.
-
#w0 ⇒ Object
readonly
Returns the value of attribute w0.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x0 ⇒ Object
readonly
Returns the value of attribute x0.
-
#y0 ⇒ Object
readonly
Returns the value of attribute y0.
Instance Method Summary collapse
- #amove(_x, _y) ⇒ Object
- #do_enter(x, y) ⇒ Object
- #do_leave ⇒ Object
- #do_motion(_x, _y) ⇒ Object
- #do_press(x, y) ⇒ Object
- #go(_w, _h) ⇒ Object
- #h ⇒ Object
-
#initialize(_obj = nil, _side = 'both', _cursor = nil, _bind = true) ⇒ AGTkObjPlace
constructor
A new instance of AGTkObjPlace.
- #move(_x, _y) ⇒ Object
- #w ⇒ Object
Constructor Details
#initialize(_obj = nil, _side = 'both', _cursor = nil, _bind = true) ⇒ AGTkObjPlace
Returns a new instance of AGTkObjPlace.
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
# File 'lib/tk/al-tk.rb', line 1436 def initialize(_obj=nil , _side='both' , _cursor=nil, _bind = true ) if !_obj break end @obj = _obj if !_cursor case _side when 'x' _cursor = 'sb_h_double_arrow' when 'y' _cursor = 'sb_v_double_arrow' when 'both' _cursor = 'draft_small' end end @motion = false @side = _side @x0 = TkPlace.info(@obj)['x'] @y0 = TkPlace.info(@obj)['y'] if TkWinfo.mapped?(@obj) @w0=TkWinfo.width(@obj) @h0=TkWinfo.height(@obj) else @w0=TkWinfo.reqwidth(@obj) @h0=TkWinfo.reqheight(@obj) end @start_x = @x0 @start_y = @y0 @cursor = _cursor if _bind @obj.bind_append("Enter", proc{|x, y| do_enter(x, y)}, "%x %y") @obj.bind_append("ButtonPress-1", proc{|e| do_press(e.x, e.y)}) @obj.bind_append("B1-Motion", proc{|x, y| do_motion(x,y)},"%x %y") end end |
Instance Attribute Details
#h0 ⇒ Object (readonly)
Returns the value of attribute h0.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def h0 @h0 end |
#height ⇒ Object
Returns the value of attribute height.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def height @height end |
#motion ⇒ Object
Returns the value of attribute motion.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def motion @motion end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def obj @obj end |
#r ⇒ Object
Returns the value of attribute r.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def r @r end |
#relheight ⇒ Object
Returns the value of attribute relheight.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def relheight @relheight end |
#relwidth ⇒ Object
Returns the value of attribute relwidth.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def relwidth @relwidth end |
#start_x ⇒ Object
Returns the value of attribute start_x.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def start_x @start_x end |
#start_y ⇒ Object
Returns the value of attribute start_y.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def start_y @start_y end |
#w0 ⇒ Object (readonly)
Returns the value of attribute w0.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def w0 @w0 end |
#width ⇒ Object
Returns the value of attribute width.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def width @width end |
#x0 ⇒ Object (readonly)
Returns the value of attribute x0.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def x0 @x0 end |
#y0 ⇒ Object (readonly)
Returns the value of attribute y0.
1433 1434 1435 |
# File 'lib/tk/al-tk.rb', line 1433 def y0 @y0 end |
Instance Method Details
#amove(_x, _y) ⇒ Object
1522 1523 1524 |
# File 'lib/tk/al-tk.rb', line 1522 def amove(_x,_y) move(_x - @x0 , _y - @y0) end |
#do_enter(x, y) ⇒ Object
1488 1489 1490 1491 |
# File 'lib/tk/al-tk.rb', line 1488 def do_enter(x, y) @oldcursor = @obj.cget('cursor') @obj.configure('cursor'=> @cursor) end |
#do_leave ⇒ Object
1493 1494 1495 |
# File 'lib/tk/al-tk.rb', line 1493 def do_leave @obj.configure('cursor'=>@oldcursor) end |
#do_motion(_x, _y) ⇒ Object
1502 1503 1504 1505 |
# File 'lib/tk/al-tk.rb', line 1502 def do_motion( _x, _y) @motion = true move(_x - @start_x, _y - @start_y) end |
#do_press(x, y) ⇒ Object
1497 1498 1499 1500 |
# File 'lib/tk/al-tk.rb', line 1497 def do_press(x, y) @start_x = x @start_y = y end |
#go(_w, _h) ⇒ Object
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
# File 'lib/tk/al-tk.rb', line 1526 def go(_w, _h) case @side when 'x' @w0 = _w @obj.place('width' => @w0, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight) when 'y' @h0 = _h @obj.place('height' => @h0, 'width' => @width, 'relwidth'=>@relwidth, 'relheight'=>@relheight) end end |
#h ⇒ Object
1480 1481 1482 1483 1484 1485 1486 |
# File 'lib/tk/al-tk.rb', line 1480 def h if TkWinfo.mapped?(@obj) @h0= TkWinfo.height(@obj) else @h0= TkWinfo.reqheight(@obj) end end |
#move(_x, _y) ⇒ Object
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 |
# File 'lib/tk/al-tk.rb', line 1507 def move(_x,_y) case @side when 'both' @x0 = @x0 + _x if (@x0 + _x) >= 0 @y0 = @y0 + _y @obj.place('x' => @x0, 'y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight) when 'x' @x0 = @x0 + _x if (@x0 + _x) >= 0 @obj.place('x' => @x0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight) when 'y' @y0 = @y0 + _y @obj.place('y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight) end end |
#w ⇒ Object
1472 1473 1474 1475 1476 1477 1478 |
# File 'lib/tk/al-tk.rb', line 1472 def w if TkWinfo.mapped?(@obj) @w0= TkWinfo.width(@obj) else @w0= TkWinfo.reqwidth(@obj) end end |