teek 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +62 -7
- data/Rakefile +97 -91
- data/ext/teek/extconf.rb +15 -0
- data/ext/teek/tcltkbridge.c +69 -4
- data/ext/teek/tkdrop_x11.c +2 -2
- data/lib/teek/callback_registry.rb +80 -0
- data/lib/teek/canvas_bind_interceptor.rb +68 -0
- data/lib/teek/command_interceptors.rb +47 -0
- data/lib/teek/debugger.rb +7 -10
- data/lib/teek/demo_support.rb +2 -2
- data/lib/teek/dialogs.rb +137 -0
- data/lib/teek/menu_interceptor.rb +61 -0
- data/lib/teek/photo.rb +55 -0
- data/lib/teek/tag_bind_interceptor.rb +66 -0
- data/lib/teek/version.rb +1 -1
- data/lib/teek/widget.rb +25 -2
- data/lib/teek/winfo.rb +104 -0
- data/lib/teek/wm.rb +82 -0
- data/lib/teek.rb +317 -57
- data/teek.gemspec +2 -2
- metadata +11 -3
data/lib/teek/wm.rb
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Teek
|
|
4
|
+
# Thin, typed wrapper around Tk's `wm` (window manager) command family -
|
|
5
|
+
# one method per subcommand, coerced to the right Ruby type, reached via
|
|
6
|
+
# {App#wm}.
|
|
7
|
+
#
|
|
8
|
+
# Grouped behind a single accessor instead of more flat App methods, for
|
|
9
|
+
# the same reason {Winfo} is: `wm` is itself one big, well-known Tcl
|
|
10
|
+
# command namespace, so knowing Tcl's `wm title` gets you to {#title}
|
|
11
|
+
# directly. App's own +set_window_title+/+window_geometry+/etc. are kept
|
|
12
|
+
# as thin delegates to this - use whichever reads better to you, they're
|
|
13
|
+
# the same underlying call.
|
|
14
|
+
#
|
|
15
|
+
# Composite behaviors that orchestrate more than a single +wm+ subcommand
|
|
16
|
+
# (App#on_close's callback tracking, for instance) stay top-level App/
|
|
17
|
+
# Widget methods rather than living here - this class is only 1:1 Tcl
|
|
18
|
+
# command wrappers, nothing with Ruby-side state of its own.
|
|
19
|
+
#
|
|
20
|
+
# @see https://www.tcl-lang.org/man/tcl9.0/TkCmd/wm.htm wm
|
|
21
|
+
class Wm
|
|
22
|
+
# @api private
|
|
23
|
+
def initialize(app)
|
|
24
|
+
@app = app
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param window [String, Widget] (default: the root window)
|
|
28
|
+
# @return [String] the window's current title
|
|
29
|
+
def title(window: '.')
|
|
30
|
+
@app.tcl_invoke('wm', 'title', window.to_s)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @param value [String] new title
|
|
34
|
+
# @param window [String, Widget] (default: the root window)
|
|
35
|
+
# @return [String] the title
|
|
36
|
+
def set_title(value, window: '.')
|
|
37
|
+
@app.tcl_invoke('wm', 'title', window.to_s, value.to_s)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param window [String, Widget] (default: the root window)
|
|
41
|
+
# @return [String] geometry string (e.g. +"400x300+0+0"+)
|
|
42
|
+
def geometry(window: '.')
|
|
43
|
+
@app.tcl_invoke('wm', 'geometry', window.to_s)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @param value [String] new geometry (e.g. +"400x300"+, +"400x300+100+50"+)
|
|
47
|
+
# @param window [String, Widget] (default: the root window)
|
|
48
|
+
# @return [String] the geometry
|
|
49
|
+
def set_geometry(value, window: '.')
|
|
50
|
+
@app.tcl_invoke('wm', 'geometry', window.to_s, value.to_s)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @param window [String, Widget] (default: the root window)
|
|
54
|
+
# @return [Array(Boolean, Boolean)] [width_resizable, height_resizable]
|
|
55
|
+
def resizable(window: '.')
|
|
56
|
+
parts = @app.tcl_invoke('wm', 'resizable', window.to_s).split
|
|
57
|
+
[@app.tcl_to_bool(parts[0]), @app.tcl_to_bool(parts[1])]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @param width [Boolean] allow horizontal resize
|
|
61
|
+
# @param height [Boolean] allow vertical resize
|
|
62
|
+
# @param window [String, Widget] (default: the root window)
|
|
63
|
+
# @return [void]
|
|
64
|
+
def set_resizable(width, height, window: '.')
|
|
65
|
+
@app.tcl_invoke('wm', 'resizable', window.to_s, @app.bool_to_tcl(width), @app.bool_to_tcl(height))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Show a window (map it if withdrawn/iconified).
|
|
69
|
+
# @param window [String, Widget] (default: the root window)
|
|
70
|
+
# @return [void]
|
|
71
|
+
def deiconify(window: '.')
|
|
72
|
+
@app.tcl_invoke('wm', 'deiconify', window.to_s)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Hide a window without destroying it.
|
|
76
|
+
# @param window [String, Widget] (default: the root window)
|
|
77
|
+
# @return [void]
|
|
78
|
+
def withdraw(window: '.')
|
|
79
|
+
@app.tcl_invoke('wm', 'withdraw', window.to_s)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|