Class: Teek::Winfo

Inherits:
Object
  • Object
show all
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).

See Also:

Instance Method Summary collapse

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").

Parameters:

Returns:

  • (String)

    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.

Parameters:

Returns:

  • (Boolean)

    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.

Parameters:

Returns:

  • (Integer)

    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).

Parameters:

Returns:

  • (Boolean)

    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.

Parameters:

  • path (String, Widget) (defaults to: '.')

    any window on the same screen (default: the root window)

Returns:

  • (Integer)

    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.

Parameters:

  • path (String, Widget) (defaults to: '.')

    any window on the same screen (default: the root window)

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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.

Parameters:

Returns:

  • (Integer)

    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