Class: Teek::Winfo
- Inherits:
-
Object
- Object
- Teek::Winfo
- Defined in:
- lib/teek/winfo.rb
Overview
Thin, typed wrapper around Tk's winfo command family - one method
per subquery, coerced to the right Ruby type, reached via App#winfo.
Grouped behind a single accessor instead of a dozen-plus flat App
methods, since winfo is itself one big, well-known Tcl command
namespace - knowing Tcl's winfo width gets you to #width directly.
Every method accepts a path String or anything that responds to
to_s with one (a Widget, for instance).
Instance Method Summary collapse
-
#class_name(path) ⇒ String
The Tk widget class (e.g.
"TButton","Frame"). -
#exists?(path) ⇒ Boolean
Whether a window currently exists at
path. -
#height(path) ⇒ Integer
Current height in pixels.
-
#initialize(app) ⇒ Winfo
constructor
private
A new instance of Winfo.
-
#ismapped?(path) ⇒ Boolean
Whether the window is currently mapped (actually displayed).
-
#pointerx(path = '.') ⇒ Integer
The mouse pointer's current x coordinate, in screen pixels.
-
#pointery(path = '.') ⇒ Integer
The mouse pointer's current y coordinate, in screen pixels.
-
#reqheight(path) ⇒ Integer
Requested (natural) height in pixels.
-
#reqwidth(path) ⇒ Integer
Requested (natural) width in pixels.
-
#rootx(path) ⇒ Integer
X coordinate of the window's top-left corner, in screen pixels.
-
#rooty(path) ⇒ Integer
Y coordinate of the window's top-left corner, in screen pixels.
-
#width(path) ⇒ Integer
Current width in pixels.
-
#x(path) ⇒ Integer
X coordinate relative to the parent widget.
-
#y(path) ⇒ Integer
Y coordinate relative to the parent widget.
Constructor Details
#initialize(app) ⇒ Winfo
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Winfo.
16 17 18 |
# File 'lib/teek/winfo.rb', line 16 def initialize(app) @app = app end |
Instance Method Details
#class_name(path) ⇒ String
Returns the Tk widget class (e.g. "TButton", "Frame").
88 89 90 |
# File 'lib/teek/winfo.rb', line 88 def class_name(path) query('class', path) end |
#exists?(path) ⇒ Boolean
Returns whether a window currently exists at path.
82 83 84 |
# File 'lib/teek/winfo.rb', line 82 def exists?(path) query('exists', path) == '1' end |
#height(path) ⇒ Integer
Returns current height in pixels.
28 29 30 |
# File 'lib/teek/winfo.rb', line 28 def height(path) query('height', path).to_i end |
#ismapped?(path) ⇒ Boolean
Returns whether the window is currently mapped (actually displayed).
94 95 96 |
# File 'lib/teek/winfo.rb', line 94 def ismapped?(path) query('ismapped', path) == '1' end |
#pointerx(path = '.') ⇒ Integer
Returns the mouse pointer's current x coordinate, in screen pixels.
70 71 72 |
# File 'lib/teek/winfo.rb', line 70 def pointerx(path = '.') query('pointerx', path).to_i end |
#pointery(path = '.') ⇒ Integer
Returns the mouse pointer's current y coordinate, in screen pixels.
76 77 78 |
# File 'lib/teek/winfo.rb', line 76 def pointery(path = '.') query('pointery', path).to_i end |
#reqheight(path) ⇒ Integer
Returns requested (natural) height in pixels.
40 41 42 |
# File 'lib/teek/winfo.rb', line 40 def reqheight(path) query('reqheight', path).to_i end |
#reqwidth(path) ⇒ Integer
Returns requested (natural) width in pixels.
34 35 36 |
# File 'lib/teek/winfo.rb', line 34 def reqwidth(path) query('reqwidth', path).to_i end |
#rootx(path) ⇒ Integer
Returns x coordinate of the window's top-left corner, in screen pixels.
46 47 48 |
# File 'lib/teek/winfo.rb', line 46 def rootx(path) query('rootx', path).to_i end |
#rooty(path) ⇒ Integer
Returns y coordinate of the window's top-left corner, in screen pixels.
52 53 54 |
# File 'lib/teek/winfo.rb', line 52 def rooty(path) query('rooty', path).to_i end |
#width(path) ⇒ Integer
Returns current width in pixels.
22 23 24 |
# File 'lib/teek/winfo.rb', line 22 def width(path) query('width', path).to_i end |
#x(path) ⇒ Integer
Returns x coordinate relative to the parent widget.
58 59 60 |
# File 'lib/teek/winfo.rb', line 58 def x(path) query('x', path).to_i end |
#y(path) ⇒ Integer
Returns y coordinate relative to the parent widget.
64 65 66 |
# File 'lib/teek/winfo.rb', line 64 def y(path) query('y', path).to_i end |