Class: Teek::Wm
- Inherits:
-
Object
- Object
- Teek::Wm
- Defined in:
- lib/teek/wm.rb
Overview
Thin, typed wrapper around Tk's wm (window manager) command family -
one method per subcommand, coerced to the right Ruby type, reached via
App#wm.
Grouped behind a single accessor instead of more flat App methods, for
the same reason Winfo is: wm is itself one big, well-known Tcl
command namespace, so knowing Tcl's wm title gets you to #title
directly. App's own +set_window_title+/+window_geometry+/etc. are kept
as thin delegates to this - use whichever reads better to you, they're
the same underlying call.
Composite behaviors that orchestrate more than a single wm subcommand
(App#on_close's callback tracking, for instance) stay top-level App/
Widget methods rather than living here - this class is only 1:1 Tcl
command wrappers, nothing with Ruby-side state of its own.
Instance Method Summary collapse
-
#deiconify(window: '.') ⇒ void
Show a window (map it if withdrawn/iconified).
-
#geometry(window: '.') ⇒ String
Geometry string (e.g. +"400x300+0+0"+).
-
#initialize(app) ⇒ Wm
constructor
private
A new instance of Wm.
-
#resizable(window: '.') ⇒ Array(Boolean, Boolean)
[width_resizable, height_resizable].
-
#set_geometry(value, window: '.') ⇒ String
The geometry.
- #set_resizable(width, height, window: '.') ⇒ void
-
#set_title(value, window: '.') ⇒ String
The title.
-
#title(window: '.') ⇒ String
The window's current title.
-
#withdraw(window: '.') ⇒ void
Hide a window without destroying it.
Constructor Details
#initialize(app) ⇒ Wm
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 Wm.
23 24 25 |
# File 'lib/teek/wm.rb', line 23 def initialize(app) @app = app end |
Instance Method Details
#deiconify(window: '.') ⇒ void
This method returns an undefined value.
Show a window (map it if withdrawn/iconified).
71 72 73 |
# File 'lib/teek/wm.rb', line 71 def deiconify(window: '.') @app.tcl_invoke('wm', 'deiconify', window.to_s) end |
#geometry(window: '.') ⇒ String
Returns geometry string (e.g. +"400x300+0+0"+).
42 43 44 |
# File 'lib/teek/wm.rb', line 42 def geometry(window: '.') @app.tcl_invoke('wm', 'geometry', window.to_s) end |
#resizable(window: '.') ⇒ Array(Boolean, Boolean)
Returns [width_resizable, height_resizable].
55 56 57 58 |
# File 'lib/teek/wm.rb', line 55 def resizable(window: '.') parts = @app.tcl_invoke('wm', 'resizable', window.to_s).split [@app.tcl_to_bool(parts[0]), @app.tcl_to_bool(parts[1])] end |
#set_geometry(value, window: '.') ⇒ String
Returns the geometry.
49 50 51 |
# File 'lib/teek/wm.rb', line 49 def set_geometry(value, window: '.') @app.tcl_invoke('wm', 'geometry', window.to_s, value.to_s) end |
#set_resizable(width, height, window: '.') ⇒ void
This method returns an undefined value.
64 65 66 |
# File 'lib/teek/wm.rb', line 64 def set_resizable(width, height, window: '.') @app.tcl_invoke('wm', 'resizable', window.to_s, @app.bool_to_tcl(width), @app.bool_to_tcl(height)) end |
#set_title(value, window: '.') ⇒ String
Returns the title.
36 37 38 |
# File 'lib/teek/wm.rb', line 36 def set_title(value, window: '.') @app.tcl_invoke('wm', 'title', window.to_s, value.to_s) end |
#title(window: '.') ⇒ String
Returns the window's current title.
29 30 31 |
# File 'lib/teek/wm.rb', line 29 def title(window: '.') @app.tcl_invoke('wm', 'title', window.to_s) end |
#withdraw(window: '.') ⇒ void
This method returns an undefined value.
Hide a window without destroying it.
78 79 80 |
# File 'lib/teek/wm.rb', line 78 def withdraw(window: '.') @app.tcl_invoke('wm', 'withdraw', window.to_s) end |